diff --git a/toonz/sources/include/toonzqt/stageschematicnode.h b/toonz/sources/include/toonzqt/stageschematicnode.h index d9d5f53..313db6f 100644 --- a/toonz/sources/include/toonzqt/stageschematicnode.h +++ b/toonz/sources/include/toonzqt/stageschematicnode.h @@ -283,6 +283,7 @@ class StageSchematicNodeDock : public QObject, public QGraphicsItem StageSchematicNode *m_parent; StageSchematicNodePort *m_port; + SchematicHandleSpinBox* m_handleSpinBox; bool m_isParentPort; QTimer *m_timer; @@ -314,6 +315,7 @@ protected slots: void onPortClicked(); void onPortReleased(const QPointF &); void onTimeOut(); + void onModifyHandle(int); }; //======================================================== @@ -366,7 +368,7 @@ protected: bool m_isGroup; QString m_name; SchematicName *m_nameItem; - + public: StageSchematicNode(StageSchematicScene *scene, TStageObject *obj, int width, int height, bool isGroup = false); ~StageSchematicNode(); @@ -414,7 +416,6 @@ public: QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - void updateChildDockPositions(); protected: void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me); @@ -439,7 +440,7 @@ public: QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - void updateChildDockPositions(); + }; //======================================================== @@ -471,7 +472,6 @@ public: private: void updatePortsPosition(); - void updateChildDockPositions(); protected: void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me); @@ -501,7 +501,6 @@ public: QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - void updateChildDockPositions(); protected: void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me); diff --git a/toonz/sources/include/toonzqt/stageschematicscene.h b/toonz/sources/include/toonzqt/stageschematicscene.h index 9a063dc..5137cbe 100644 --- a/toonz/sources/include/toonzqt/stageschematicscene.h +++ b/toonz/sources/include/toonzqt/stageschematicscene.h @@ -101,6 +101,8 @@ class StageSchematicScene : public SchematicScene QMap> m_nodesToPlace; + bool m_showLetterOnPortFlag; + public: StageSchematicScene(QWidget *parent); ~StageSchematicScene(); @@ -128,6 +130,8 @@ public: void updateNestedGroupEditors(StageSchematicNode *node, const QPointF &newPos); void resizeNodes(bool maximizedNode); + bool isShowLetterOnPortFlagEnabled(){ return m_showLetterOnPortFlag; } + private: StageSchematicNode *addStageSchematicNode(TStageObject *pegbar); StageSchematicGroupNode *addStageGroupNode(QList objs); @@ -200,6 +204,8 @@ protected slots: void onCollapse(QList); void onOpenSubxsheet(); void onEditGroup(); + + void onSwitchPortModeToggled(bool withLetter); }; #endif //STAGESCHEMATIC_H diff --git a/toonz/sources/toonzqt/Resources/switchport_off.png b/toonz/sources/toonzqt/Resources/switchport_off.png new file mode 100644 index 0000000..008a1cb Binary files /dev/null and b/toonz/sources/toonzqt/Resources/switchport_off.png differ diff --git a/toonz/sources/toonzqt/Resources/switchport_on.png b/toonz/sources/toonzqt/Resources/switchport_on.png new file mode 100644 index 0000000..fc23829 Binary files /dev/null and b/toonz/sources/toonzqt/Resources/switchport_on.png differ diff --git a/toonz/sources/toonzqt/Resources/switchport_over.png b/toonz/sources/toonzqt/Resources/switchport_over.png new file mode 100644 index 0000000..e403ff7 Binary files /dev/null and b/toonz/sources/toonzqt/Resources/switchport_over.png differ diff --git a/toonz/sources/toonzqt/schematicviewer.cpp b/toonz/sources/toonzqt/schematicviewer.cpp index a8e572a..0626838 100644 --- a/toonz/sources/toonzqt/schematicviewer.cpp +++ b/toonz/sources/toonzqt/schematicviewer.cpp @@ -595,7 +595,7 @@ void SchematicViewer::createActions() { // Create all actions QAction *addPegbar = 0, *addSpline = 0, *addCamera = 0, - *insertFx = 0, *addOutputFx = 0; + *insertFx = 0, *addOutputFx = 0, *switchPort = 0; { // Fit schematic QIcon fitSchematicIcon = createQIconOnOffPNG("fit", false); @@ -640,6 +640,14 @@ void SchematicViewer::createActions() addSpline->setIcon(addSplineIcon); connect(addSpline, SIGNAL(triggered()), m_stageScene, SLOT(onSplineAdded())); + //Switch display of stage schematic's output port + switchPort = new QAction(tr("&Swtich output port display mode"), m_stageToolbar); + switchPort->setCheckable(true); + switchPort->setChecked(m_stageScene->isShowLetterOnPortFlagEnabled()); + QIcon switchPortIcon = createQIconOnOffPNG("switchport"); + switchPort->setIcon(switchPortIcon); + connect(switchPort, SIGNAL(toggled(bool)), m_stageScene, SLOT(onSwitchPortModeToggled(bool))); + // InsertFx insertFx = CommandManager::instance()->getAction("MI_InsertFx"); if (insertFx) { @@ -675,6 +683,8 @@ void SchematicViewer::createActions() if (m_fullSchematic) { m_stageToolbar->addSeparator(); + m_stageToolbar->addAction(switchPort); + m_stageToolbar->addSeparator(); m_stageToolbar->addAction(addSpline); m_stageToolbar->addAction(addCamera); m_stageToolbar->addAction(addPegbar); diff --git a/toonz/sources/toonzqt/stageschematicnode.cpp b/toonz/sources/toonzqt/stageschematicnode.cpp index 1ced2f2..43e14cf 100644 --- a/toonz/sources/toonzqt/stageschematicnode.cpp +++ b/toonz/sources/toonzqt/stageschematicnode.cpp @@ -813,15 +813,35 @@ QRectF StageSchematicNodePort::boundingRect() const void StageSchematicNodePort::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - QPixmap redPm = QPixmap(":Resources/port_red.png"); - QPixmap redPm_HL = QPixmap(":Resources/port_red_highlight.png"); - QPixmap bluePm = QPixmap(":Resources/port_blue.png"); - QPixmap bluePm_HL = QPixmap(":Resources/port_blue_highlight.png"); - - if (getType() == eStageChildPort || getType() == eStageChildGroupPort) - painter->drawPixmap(QRect(0, 0, 18, 18), (isHighlighted()) ? redPm_HL : redPm); + //StageSchematicNode *node = dynamic_cast(getNode()); + StageSchematicScene* scene = dynamic_cast(this->scene()); + if (scene && scene->isShowLetterOnPortFlagEnabled()) + { + painter->setBrush(QColor(255, 255, 255, 255)); + painter->setPen(QColor(180, 180, 180, 255)); + painter->drawRect(boundingRect()); + if (m_type == 103 || m_type == 104 || m_type == 105) return; + painter->setPen(QColor(0, 0, 0, 255)); + QFont font("Verdana", 8); + painter->setFont(font); + QTextOption textOption(Qt::AlignCenter); + QString text = m_handle; + if (text.size()>1 && text.at(0) == 'H') + text.remove("H"); + painter->drawText(boundingRect(), text, textOption); + } else - painter->drawPixmap(QRect(0, 0, 18, 18), (isHighlighted()) ? bluePm_HL : bluePm); + { + QPixmap redPm = QPixmap(":Resources/port_red.png"); + QPixmap redPm_HL = QPixmap(":Resources/port_red_highlight.png"); + QPixmap bluePm = QPixmap(":Resources/port_blue.png"); + QPixmap bluePm_HL = QPixmap(":Resources/port_blue_highlight.png"); + + if (getType() == eStageParentPort || getType() == eStageParentGroupPort) + painter->drawPixmap(QRect(0, 0, 18, 18), (isHighlighted()) ? bluePm_HL : bluePm); + else + painter->drawPixmap(QRect(0, 0, 18, 18), (isHighlighted()) ? redPm_HL : redPm); + } } //-------------------------------------------------------- @@ -1115,6 +1135,24 @@ StageSchematicNodeDock::StageSchematicNodeDock(StageSchematicNode *parent, bool setFlag(QGraphicsItem::ItemIsFocusable, false); m_port = new StageSchematicNodePort(this, type); + m_handleSpinBox = new SchematicHandleSpinBox(this); + + m_port->setPos(0, 0); + if (isParentPort) + { + StageSchematicScene* stageScene = dynamic_cast(scene()); + if (stageScene && stageScene->isShowLetterOnPortFlagEnabled()) + m_port->setPos(m_handleSpinBox->boundingRect().width(), 0); + m_handleSpinBox->setPos(0, 1); + } + else + m_handleSpinBox->setPos(m_port->boundingRect().width(), 1); + + m_handleSpinBox->hide(); + connect(m_handleSpinBox, SIGNAL(modifyHandle(int)), this, SLOT(onModifyHandle(int))); + connect(m_handleSpinBox, SIGNAL(sceneChanged()), parent, SIGNAL(sceneChanged())); + connect(m_handleSpinBox, SIGNAL(handleReleased()), parent, SLOT(onHandleReleased())); + connect(this, SIGNAL(sceneChanged()), parent, SIGNAL(sceneChanged())); connect(m_port, SIGNAL(isClicked()), this, SLOT(onPortClicked())); @@ -1134,6 +1172,7 @@ StageSchematicNodeDock::StageSchematicNodeDock(StageSchematicNode *parent, bool #else setAcceptsHoverEvents(true); #endif + } //-------------------------------------------------------- @@ -1146,8 +1185,19 @@ StageSchematicNodeDock::~StageSchematicNodeDock() QRectF StageSchematicNodeDock::boundingRect() const { + StageSchematicScene* stageScene = dynamic_cast(scene()); QRectF portRect = m_port->boundingRect(); portRect.moveTopLeft(QPointF(0, 0)); + if (stageScene && stageScene->isShowLetterOnPortFlagEnabled()) + { + QRectF handleRect = m_handleSpinBox->boundingRect(); + handleRect.moveTopLeft(QPointF(portRect.width(), handleRect.topLeft().y())); +#if QT_VERSION >= 0x050000 + portRect = portRect.united(handleRect); +#else + portRect = portRect.unite(handleRect); +#endif + } return portRect; } @@ -1160,6 +1210,44 @@ void StageSchematicNodeDock::paint(QPainter *painter, //-------------------------------------------------------- +void StageSchematicNodeDock::onModifyHandle(int increase) +{ + StageSchematicScene* stageScene = dynamic_cast(scene()); + std::string handle(getPort()->getHandle().toStdString()); + + int index; + if (handle[0] == 'H' && handle.length()>1) + index = -(toInt(handle.substr(1))); + else + index = handle[0] - 'A'; + index += -increase;//==1 ? -1 : 1; + + int min = (getNode()->getStageObject()->getId().isColumn()) ? -HookSet::maxHooksCount : 0; + index = tcrop(index, min, 25); + + if (index >= 0) handle = string(1, (char)('A' + index)); + else handle = "H" + toString(-index); + + if (m_isParentPort) + TStageObjectCmd::setHandle(getNode()->getStageObject()->getId(), handle, stageScene->getXsheetHandle()); + else + { + int i, linkCount = getPort()->getLinkCount(); + vector ids; + for (i = 0; i(getPort()->getLinkedNode(i)); + if (node) + ids.push_back(node->getStageObject()->getId()); + } + TStageObjectCmd::setParentHandle(ids, handle, stageScene->getXsheetHandle()); + } + getPort()->setHandle(QString::fromStdString(handle)); + getPort()->update(); +} + +//-------------------------------------------------------- + void StageSchematicNodeDock::hoverEnterEvent(QGraphicsSceneHoverEvent *he) { QList items = scene()->items(he->scenePos()); @@ -1177,6 +1265,7 @@ void StageSchematicNodeDock::hoverLeaveEvent(QGraphicsSceneHoverEvent *he) { m_port->highLight(false); m_timer->stop(); + m_handleSpinBox->hide(); QGraphicsItem::hoverLeaveEvent(he); int i; for (i = 0; i < m_port->getLinkCount(); i++) @@ -1202,6 +1291,7 @@ void StageSchematicNodeDock::hoverMoveEvent(QGraphicsSceneHoverEvent *he) void StageSchematicNodeDock::onPortClicked() { + m_handleSpinBox->hide(); m_timer->stop(); int i; for (i = 0; i < m_port->getLinkCount(); i++) @@ -1222,6 +1312,9 @@ void StageSchematicNodeDock::onPortReleased(const QPointF &pos) void StageSchematicNodeDock::onTimeOut() { + StageSchematicScene* stageScene = dynamic_cast(scene()); + if (stageScene && stageScene->isShowLetterOnPortFlagEnabled()) + m_handleSpinBox->show(); StageSchematicNodePort *port = getPort(); int i; for (i = 0; i < port->getLinkCount(); i++) { @@ -1304,6 +1397,7 @@ StageSchematicNode::StageSchematicNode(StageSchematicScene *scene, TStageObject m_stageObject->addRef(); m_width = width; m_height = height; + // aggiunge le porte qreal y = m_height * 0.5 - 5; qreal x = m_width * 0.5 - 8; @@ -1342,13 +1436,16 @@ StageSchematicNode::StageSchematicNode(StageSchematicScene *scene, TStageObject m_pathToggle->hide(); m_cpToggle->hide(); } - + if (m_isGroup) m_parentDock = new StageSchematicNodeDock(this, true, eStageParentGroupPort); else m_parentDock = new StageSchematicNodeDock(this, true, eStageParentPort); addPort(0, m_parentDock->getPort()); - m_parentDock->setPos(0, 0); + if (scene->isShowLetterOnPortFlagEnabled()) + m_parentDock->setPos(-m_parentDock->boundingRect().width(), m_height - 15); + else + m_parentDock->setPos(0, 0); m_parentDock->getPort()->setHandle("B"); StageSchematicNodeDock *childDock; @@ -1358,7 +1455,10 @@ StageSchematicNode::StageSchematicNode(StageSchematicScene *scene, TStageObject childDock = new StageSchematicNodeDock(this, false, eStageChildPort); addPort(1, childDock->getPort()); m_childDocks.append(childDock); - childDock->setPos(m_width - 18, 0); + if (scene->isShowLetterOnPortFlagEnabled()) + childDock->setPos(m_width, m_height - 15); + else + childDock->setPos(m_width - 18, 0); childDock->getPort()->setHandle("B"); } @@ -1406,6 +1506,18 @@ StageSchematicNodePort *StageSchematicNode::makeChildPort(const QString &label) if (j == n) break; } + StageSchematicScene* stageScene = dynamic_cast(scene()); + if (stageScene && stageScene->isShowLetterOnPortFlagEnabled()) + { + StageSchematicNodeDock* newDock; + if (m_isGroup) + newDock = new StageSchematicNodeDock(this, false, eStageChildGroupPort); + else + newDock = new StageSchematicNodeDock(this, false, eStageChildPort); + addPort(m_childDocks.size() + 1, newDock->getPort()); + m_childDocks.append(newDock); + newDock->getPort()->setHandle(newPortName); + } updateChildDockPositions(); return dock->getPort(); } @@ -1435,12 +1547,26 @@ void StageSchematicNode::setPosition(const QPointF &newPos) void StageSchematicNode::updateChildDockPositions() { int i, size = m_childDocks.size(); - double height = size * m_childDocks.at(0)->getPort()->boundingRect().height(); - double y = (m_height * 0.5) + (height * 0.5); - for (i = 0; i < size; i++) { - y -= m_childDocks.at(0)->getPort()->boundingRect().height(); - m_childDocks[i]->setPos(m_width, y); - m_childDocks[i]->getPort()->updateLinksGeometry(); + StageSchematicScene *stageScene = dynamic_cast(scene()); + if (stageScene && stageScene->isShowLetterOnPortFlagEnabled()) + { + double portHeight = m_childDocks.at(0)->getPort()->boundingRect().height(); + double height = size * portHeight; + double y = (m_height - 15 - portHeight*0.5) + height * 0.5; + for (i = 0; i < size; i++) { + m_childDocks[i]->setPos(m_width, y); + m_childDocks[i]->getPort()->updateLinksGeometry(); + y -= portHeight; + } + } + else + { + double y = 18; + for (i = 0; i < size; i++) { + m_childDocks[i]->setPos(m_width - 18, m_height - y); + m_childDocks[i]->getPort()->updateLinksGeometry(); + y += m_childDocks.at(0)->getPort()->boundingRect().height(); + } } } @@ -1577,12 +1703,13 @@ void StageSchematicPegbarNode::paint(QPainter *painter, const QStyleOptionGraphi void StageSchematicPegbarNode::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) { - QRectF nameArea(5, 0, m_width - 10, 14); + QRectF nameArea(18, 0, m_width - 36, 14); if (nameArea.contains(me->pos())) { m_nameItem->setPlainText(m_name); m_nameItem->show(); m_nameItem->setFocus(); setFlag(QGraphicsItem::ItemIsSelectable, false); + return; } } @@ -1606,20 +1733,6 @@ void StageSchematicPegbarNode::onNameChanged() update(); } -//-------------------------------------------------------- - -void StageSchematicPegbarNode::updateChildDockPositions() -{ - int i, size = m_childDocks.size(); - double height = size * m_childDocks.at(0)->getPort()->boundingRect().height(); - double y = 9 + (height * 0.5); - for (i = 0; i < size; i++) { - y -= m_childDocks.at(0)->getPort()->boundingRect().height(); - m_childDocks[i]->setPos(m_width - 18, y); - m_childDocks[i]->getPort()->updateLinksGeometry(); - } -} - //======================================================== // //class StageSchematicTableNode @@ -1659,18 +1772,6 @@ void StageSchematicTableNode::paint(QPainter *painter, const QStyleOptionGraphic //-------------------------------------------------------- -void StageSchematicTableNode::updateChildDockPositions() -{ - int i, size = m_childDocks.size(); - double height = size * m_childDocks.at(0)->getPort()->boundingRect().height(); - double y = 0; - for (i = 0; i < size; i++) { - m_childDocks[i]->setPos(m_width - 18, y); - m_childDocks[i]->getPort()->updateLinksGeometry(); - y += 18; - } -} - //======================================================== // //class StageSchematicColumnNode @@ -1720,29 +1821,9 @@ StageSchematicColumnNode::StageSchematicColumnNode(StageSchematicScene *scene, T m_cameraStandToggle->setZValue(2); } - TXshColumn *column = scene->getXsheet()->getColumn(pegbar->getId().getIndex())->getLevelColumn(); - if (column) { - TXshSimpleLevel *simpleLevel = column->getLevelColumn()->getCell(column->getLevelColumn()->getFirstRow()).getSimpleLevel(); - if (simpleLevel) { - HookSet *hookSet = simpleLevel->getHookSet(); - for (int i = 0; i < hookSet->getHookCount(); i++) { - Hook *hook = hookSet->getHook(i); - if (hook && !hook->isEmpty()) { - StageSchematicNodeDock *hookDock = new StageSchematicNodeDock(this, false, eStageChildPort); - addPort(i + 2, hookDock->getPort()); - m_childDocks.append(hookDock); - hookDock->getPort()->setHandle(QString::fromStdString("H" + toString(hook->getId() + 1))); - } - } - } - } - qreal y = 14; - m_parentDock->setPos(0, y); - for (int i = 0; i < m_childDocks.size(); i++) { - m_childDocks[i]->setPos(m_width - m_childDocks[i]->boundingRect().width(), - y - i * m_childDocks[i]->boundingRect().height()); - } + m_parentDock->setY(y); + m_childDocks[0]->setY(y); m_columnPainter = new ColumnPainter(this, m_width, m_height, m_name); m_columnPainter->setZValue(1); @@ -1896,21 +1977,6 @@ void StageSchematicColumnNode::updatePortsPosition() //-------------------------------------------------------- -void StageSchematicColumnNode::updateChildDockPositions() -{ - int i, size = m_childDocks.size(); - double height = size * m_childDocks.at(0)->getPort()->boundingRect().height(); - double y = 14; - for (i = 0; i < size; i++) { - m_childDocks[i]->setPos(m_width - m_childDocks.at(0)->getPort()->boundingRect().width(), y); - y += m_childDocks.at(0)->getPort()->boundingRect().height(); - - m_childDocks[i]->getPort()->updateLinksGeometry(); - } -} - -//-------------------------------------------------------- - void StageSchematicColumnNode::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *me) { StageSchematicScene *stageScene = dynamic_cast(scene()); @@ -2017,10 +2083,7 @@ StageSchematicCameraNode::StageSchematicCameraNode(StageSchematicScene *scene, T connect(m_nameItem, SIGNAL(focusOut()), this, SLOT(onNameChanged())); m_nameItem->hide(); m_nameItem->setZValue(2); - - m_childDocks[0]->setPos(m_width - 18, 0); - m_parentDock->setPos(0, 0); - + m_cameraPainter = new CameraPainter(this, m_width, m_height, m_name); m_cameraPainter->setZValue(1); @@ -2080,20 +2143,6 @@ void StageSchematicCameraNode::onNameChanged() update(); } -//-------------------------------------------------------- - -void StageSchematicCameraNode::updateChildDockPositions() -{ - int i, size = m_childDocks.size(); - double height = size * m_childDocks.at(0)->getPort()->boundingRect().height(); - double y = 0; - for (i = 0; i < size; i++) { - m_childDocks[i]->setPos(m_width - 18, y); - m_childDocks[i]->getPort()->updateLinksGeometry(); - y += m_childDocks.at(0)->getPort()->boundingRect().height(); - } -} - //======================================================== // //class StageSchematicSplineNode @@ -2252,8 +2301,8 @@ StageSchematicGroupNode::StageSchematicGroupNode(StageSchematicScene *scene, TSt ret = ret && connect(m_nameItem, SIGNAL(focusOut()), this, SLOT(onNameChanged())); m_nameItem->hide(); - m_childDocks[0]->setPos(m_width - 18, 0); - m_parentDock->setPos(0, 0); + //m_childDocks[0]->setPos(m_width - 18, 0); + //m_parentDock->setPos(0, 0); m_painter = new GroupPainter(this, m_width, m_height, m_name); m_painter->setZValue(1); diff --git a/toonz/sources/toonzqt/stageschematicscene.cpp b/toonz/sources/toonzqt/stageschematicscene.cpp index 65fda46..12d334c 100644 --- a/toonz/sources/toonzqt/stageschematicscene.cpp +++ b/toonz/sources/toonzqt/stageschematicscene.cpp @@ -30,6 +30,7 @@ #include "tsystem.h" #include "tstream.h" #include "tstroke.h" +#include "tenv.h" // Qt includes #include @@ -37,6 +38,8 @@ #include #include +TEnv::IntVar ShowLetterOnOutputPortOfStageNode("ShowLetterOnOutputPortOfStageNode", 0); + namespace { @@ -129,7 +132,7 @@ void TreeStageNode::sortChildren(int startIndex, int lastIndex) //================================================================== StageSchematicScene::StageSchematicScene(QWidget *parent) - : SchematicScene(parent), m_nextNodePos(0, 0), m_xshHandle(0), m_objHandle(0), m_colHandle(0), m_sceneHandle(0), m_frameHandle(0), m_gridDimension(eSmall) + : SchematicScene(parent), m_nextNodePos(0, 0), m_xshHandle(0), m_objHandle(0), m_colHandle(0), m_sceneHandle(0), m_frameHandle(0), m_gridDimension(eSmall), m_showLetterOnPortFlag(ShowLetterOnOutputPortOfStageNode!=0) { QPointF sceneCenter = sceneRect().center(); m_firstPos = TPointD(sceneCenter.x(), sceneCenter.y()); @@ -704,7 +707,7 @@ void StageSchematicScene::placeNodes() for (i = 0; i < pegTree->getSplineCount(); i++) { TStageObjectSpline *spline = pegTree->getSpline(i); spline->setDagNodePos(TPointD(maxXPos, yFirstPos + step)); - maxXPos += 120; + maxXPos += (m_showLetterOnPortFlag) ? 150 : 120; } //delete the tree @@ -760,7 +763,7 @@ void StageSchematicScene::makeTree(TreeStageNode *treeNode) void StageSchematicScene::placeChildren(TreeStageNode *treeNode, double &xPos, double &yPos, bool isCameraTree) { int i; - xPos += 120; + xPos += (m_showLetterOnPortFlag)?150:120; double xChildPos = xPos; double xRefPos = xPos; bool firstChild = true; @@ -794,6 +797,7 @@ void StageSchematicScene::placeNode(StageSchematicNode *node) double xPos = xFirstPos; double yPos = yFirstPos; int step = m_gridDimension == eLarge ? 100 : 50; + int hStep = (m_showLetterOnPortFlag) ? 150 : 120; TStageObjectTree *pegTree = m_xshHandle->getXsheet()->getStageObjectTree(); QRectF nodeRect = node->boundingRect(); @@ -809,7 +813,7 @@ void StageSchematicScene::placeNode(StageSchematicNode *node) if (parentObj->getDagNodePos() != TConst::nowhere) { TPointD pos = parentObj->getDagNodePos(); yPos = pos.y; - xPos = pos.x + 120; + xPos = pos.x + hStep; } else { m_nodesToPlace[parentObjId].append(node); return; @@ -817,21 +821,21 @@ void StageSchematicScene::placeNode(StageSchematicNode *node) } else { yPos = yFirstPos; - xPos = xFirstPos + 120; + xPos = xFirstPos + hStep; } } else if (pegbar->getId().isColumn()) { if (parentObj) { if (parentObj->getDagNodePos() != TConst::nowhere) { TPointD pos = parentObj->getDagNodePos(); yPos = pos.y; - xPos = pos.x + 120; + xPos = pos.x + hStep; } else { m_nodesToPlace[parentObjId].append(node); return; } } else { yPos = yFirstPos; - xPos = xFirstPos + (120 * 2); + xPos = xFirstPos + (hStep * 2); } } QPointF initPos(xPos, yPos); @@ -843,8 +847,8 @@ void StageSchematicScene::placeNode(StageSchematicNode *node) QGraphicsView *view = views().at(0); QRectF visibleRect = view->mapToScene(0, 0, view->width(), view->height()).boundingRect(); while (visibleRect.left() > nodeRect.left()) { - nodeRect.translate(120, 0); - xPos += 120; + nodeRect.translate(hStep, 0); + xPos += hStep; } while (visibleRect.bottom() < nodeRect.bottom()) { nodeRect.translate(0, -step); @@ -861,7 +865,7 @@ void StageSchematicScene::placeNode(StageSchematicNode *node) found = true; break; } else { - xPos += 120; + xPos += hStep; yPos = tmpPos.y(); nodeRect.moveTopLeft(QPointF(xPos, yPos)); } @@ -900,7 +904,8 @@ void StageSchematicScene::placeSplineNode(StageSchematicSplineNode *splineNode) { double xFirstPos = m_firstPos.x - 500; double yFirstPos = m_firstPos.y + 500; - double xPos = xFirstPos + (120 * 2); + int hStep = (m_showLetterOnPortFlag) ? 150 : 120; + double xPos = xFirstPos + (hStep * 2); int step = m_gridDimension == eLarge ? 100 : 50; double yPos = yFirstPos + step; QRectF nodeRect = splineNode->boundingRect(); @@ -908,8 +913,8 @@ void StageSchematicScene::placeSplineNode(StageSchematicSplineNode *splineNode) nodeRect.translate(QPointF(xPos, yPos)); while (!isAnEmptyZone(nodeRect)) { - nodeRect.translate(120, 0); - xPos += 120; + nodeRect.translate(hStep, 0); + xPos += hStep; } spline->setDagNodePos(TPointD(xPos, yPos)); splineNode->setPos(xPos, yPos); @@ -950,6 +955,15 @@ void StageSchematicScene::onCameraAdded() //------------------------------------------------------------------ +void StageSchematicScene::onSwitchPortModeToggled(bool withLetter) +{ + m_showLetterOnPortFlag = withLetter; + ShowLetterOnOutputPortOfStageNode = (withLetter) ? 1 : 0; + updateScene(); +} + +//------------------------------------------------------------------ + void StageSchematicScene::onResetCenter() { TStageObjectId id = m_objHandle->getObjectId(); diff --git a/toonz/sources/toonzqt/toonzqt.qrc b/toonz/sources/toonzqt/toonzqt.qrc index dcce817..17f010b 100644 --- a/toonz/sources/toonzqt/toonzqt.qrc +++ b/toonz/sources/toonzqt/toonzqt.qrc @@ -301,5 +301,8 @@ Resources/keyframe_key.png Resources/keyframe_modified.png Resources/keyframe_inbetween.png + Resources/switchport_on.png + Resources/switchport_off.png + Resources/switchport_over.png