From: nri Date: Wed, 16 Jul 2003 10:47:36 +0000 (+0000) Subject: NRI : Merge from V1_2. X-Git-Tag: V_02092003~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7467fa6b4d1c728084256fc2b9a143b25da98426;p=modules%2Fsuperv.git NRI : Merge from V1_2. --- diff --git a/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx b/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx index 0449291..2636dbc 100644 --- a/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx @@ -184,6 +184,12 @@ void SUPERVGUI_StartControlNode::deletePort(SUPERVGUI_Port* thePort) { } +QPoint SUPERVGUI_StartControlNode::getOutConnectPnt() { + return QPoint(pos().x() + width() - LABEL_HEIGHT/2, + pos().y() + (height()/2)); +} + + //----------------------------------------------------------- //******************* End Node ****************************** //----------------------------------------------------------- @@ -294,6 +300,12 @@ void SUPERVGUI_EndControlNode::updateShape() { } +QPoint SUPERVGUI_EndControlNode::getInConnectPnt() { + return QPoint(pos().x() + LABEL_HEIGHT/2, + pos().y() + (height()/2)); +} + + //----------------------------------------------------------- //******************* GoTo Node ***************************** //----------------------------------------------------------- diff --git a/src/SUPERVGUI/SUPERVGUI_ControlNode.h b/src/SUPERVGUI/SUPERVGUI_ControlNode.h index fa2a3c7..5fa06bc 100644 --- a/src/SUPERVGUI/SUPERVGUI_ControlNode.h +++ b/src/SUPERVGUI/SUPERVGUI_ControlNode.h @@ -39,6 +39,8 @@ class SUPERVGUI_StartControlNode: public SUPERVGUI_GraphNode { void setEndNode(SUPERVGUI_EndControlNode* theEndNode); SUPERVGUI_EndControlNode* getEndNode(); + virtual QPoint getOutConnectPnt(); + public slots: void switchPorts(); virtual void rename(); @@ -71,6 +73,8 @@ class SUPERVGUI_EndControlNode: public SUPERVGUI_GraphNode { virtual void showAll(); virtual void updateShape(); + virtual QPoint getInConnectPnt(); + public slots: void switchPorts(); diff --git a/src/SUPERVGUI/SUPERVGUI_Graph.cxx b/src/SUPERVGUI/SUPERVGUI_Graph.cxx index d4f83cb..bd45007 100644 --- a/src/SUPERVGUI/SUPERVGUI_Graph.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Graph.cxx @@ -47,7 +47,7 @@ using namespace std; SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->NodesName[i]->Coupled()); \ ihmNode = (SUPERVGUI_Node *)child(aCNode->Name(), "SUPERVGUI_Node"); \ if (ihmNode == NULL) { \ - main->addControlNode(aCNode, aCNodeEnd); \ + main->addControlNode(aCNode, aCNodeEnd, false); \ } else { \ ResizeGraph(ihmNode, aCNode->X(), aCNode->Y()); \ moveChild(ihmNode, aCNode->X(), aCNode->Y()); \ @@ -83,6 +83,7 @@ SUPERVGUI_Graph::SUPERVGUI_Graph(SUPERVGUI_Main* m): myNewLink(0) { Trace("SUPERVGUI_Graph::SUPERVGUI_Graph"); + myIsControlView = false; myLinksList.setAutoDelete(true); viewport()->setMouseTracking(true); @@ -199,14 +200,23 @@ void SUPERVGUI_Graph::draw() { aPixmap.fill(viewport()->paletteBackgroundColor()); QPainter aPainter(&aPixmap); - SUPERVGUI_Link* aLink; QPoint aPos = viewportToContents(viewport()->pos()); - for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) { - aLink->isInRect(aPos.x(), aPos.y(), aWidth, aHeight); - if (aLink->isInRect(aPos.x(), aPos.y(), aWidth, aHeight)) { - aLink->paint(&aPainter, false); + + if (myIsControlView) { + SUPERVGUI_CtrlLink* aLink; + QMap::Iterator it; + for ( it = myCtrlLinks.begin(); it != myCtrlLinks.end(); ++it ) { + it.data().paint(&aPainter, false); } - } + } else { + SUPERVGUI_Link* aLink; + for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) { + aLink->isInRect(aPos.x(), aPos.y(), aWidth, aHeight); + if (aLink->isInRect(aPos.x(), aPos.y(), aWidth, aHeight)) { + aLink->paint(&aPainter, false); + } + } + } bitBlt(viewport(), 0, 0, &aPixmap, 0, 0, aWidth, aHeight, Qt::CopyROP, true); @@ -294,9 +304,17 @@ void SUPERVGUI_Graph::deletePoint() { void SUPERVGUI_Graph::deleteLink() { - deleteLink(mySelectedLink); - mySelectedLink = 0; - repaintContents(); + QString aName; + if (mySelectedLink->isESInputPort()) + aName = mySelectedLink->getInputPortES()->getPort()->Name(); + else + aName = mySelectedLink->getInputPort()->getPort()->Name(); + + if (aName != "Default") { + deleteLink(mySelectedLink); + mySelectedLink = 0; + repaintContents(); + } } @@ -374,7 +392,9 @@ void SUPERVGUI_Graph::sketchEnd(SUPERVGUI_Port* thePort) { && (aKind == SUPERV::InLineParameter || aKind == SUPERV::ServiceParameter)) { - myNewLink->setInputPortES(dynamic_cast(thePort)); + QString aName(aPort->Name()); + if (aName != "Default") + myNewLink->setInputPortES(dynamic_cast(thePort)); } else{ if (aPort->IsLinked()) return; @@ -384,10 +404,12 @@ void SUPERVGUI_Graph::sketchEnd(SUPERVGUI_Port* thePort) { && aPort->Kind() != SUPERV::InLineParameter) { return; } - else //connection like Gate <--> Gate + else { //connection like Gate <--> Gate myNewLink->setInputPort(dynamic_cast(thePort)); - } else + } + } else { myNewLink->setInputPort(dynamic_cast(thePort)); + } } } else { @@ -477,18 +499,31 @@ bool SUPERVGUI_Graph::createLinkPrs(SUPERV_Link theLink) { if (aInNode) { QString aName(theLink->InPort()->Name()); aName += "Input"; - SUPERVGUI_PortIn* aInPort =(SUPERVGUI_PortIn*) - aInNode->child(aName, "SUPERVGUI_PortIn"); - if (aInPort) - aNewLink->setInputPort(aInPort); - else { - delete aNewLink; - return false; + if (theLink->InPort()->Kind() == SUPERV::EndSwitchParameter) { + //If input port is EndSwitchParameter + SUPERVGUI_PortInESNode* aInPortES =(SUPERVGUI_PortInESNode*) + aInNode->child(aName, "SUPERVGUI_PortInESNode"); //returns null + if (aInPortES) + aNewLink->setInputPortES(aInPortES); + else { + delete aNewLink; + return false; + } + } else { + SUPERVGUI_PortIn* aInPort =(SUPERVGUI_PortIn*) + aInNode->child(aName, "SUPERVGUI_PortIn"); + if (aInPort) + aNewLink->setInputPort(aInPort); + else { + delete aNewLink; + return false; + } } } else { delete aNewLink; return false; } + aNewLink->setVisible(!myIsControlView); myLinksList.append(aNewLink); return true; } @@ -526,7 +561,14 @@ void SUPERVGUI_Graph::setFullView() { aNode->showAll(); } delete aNodeList; + + myCtrlLinks.clear(); + SUPERVGUI_Link* aLink; + for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) { + aLink->setVisible(true); + } draw(); + myIsControlView = false; } @@ -539,7 +581,28 @@ void SUPERVGUI_Graph::setControlView() { aNode->hideAll(); } delete aNodeList; + myCtrlLinks.clear(); + SUPERVGUI_Link* aLink; + for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) { + aLink->setVisible(false); + + QString aOutName(aLink->getEngineLink()->OutPort()->Node()->Name()); + QString aInName(aLink->getEngineLink()->InPort()->Node()->Name()); + QString aKey = aOutName + aInName; + + if (!myCtrlLinks.contains(aKey)) { + SUPERVGUI_GraphNode* aOutNode = (SUPERVGUI_GraphNode*) + child(aOutName, "SUPERVGUI_GraphNode"); + if (!aOutNode) continue; + SUPERVGUI_GraphNode* aInNode = (SUPERVGUI_GraphNode*) + child(aInName, "SUPERVGUI_GraphNode"); + if (!aInNode) continue; + + myCtrlLinks[aKey] = SUPERVGUI_CtrlLink(this, aOutNode, aInNode); + } + } draw(); + myIsControlView = true; } diff --git a/src/SUPERVGUI/SUPERVGUI_Graph.h b/src/SUPERVGUI/SUPERVGUI_Graph.h index bcec75c..dcde3ea 100644 --- a/src/SUPERVGUI/SUPERVGUI_Graph.h +++ b/src/SUPERVGUI/SUPERVGUI_Graph.h @@ -33,6 +33,9 @@ using namespace std; #include "SUPERVGUI_View.h" #include "SUPERVGUI_Node.h" #include "SUPERVGUI_Link.h" +#include "SUPERVGUI_CtrlLink.h" +#include + class SUPERVGUI_Main; @@ -58,6 +61,8 @@ class SUPERVGUI_Graph: public SUPERVGUI_View { void setFullView(); void setControlView(); + bool isControlView() { return myIsControlView; } + void deleteLink(SUPERVGUI_Link* theLink); void deleteNode(SUPERVGUI_Node* theNode); @@ -105,9 +110,10 @@ private slots: int myAddLinkPntItem; int myDelLinkItem; - + bool myIsControlView; SUPERVGUI_Link* myNewLink; QPtrList myLinksList; + QMap myCtrlLinks; }; #endif diff --git a/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx b/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx index 283cf0f..c3c6c6c 100644 --- a/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx @@ -288,6 +288,24 @@ void SUPERVGUI_GraphNode::updateLinksPrs(bool toCheckExisting) { } delete ihmList; + //Find PortInESNode + SUPERVGUI_PortInESNode* piES; + QObjectList* ihmListES = queryList("SUPERVGUI_PortInESNode"); + QObjectListIt iES(*ihmListES); + while ((piES=(SUPERVGUI_PortInESNode*)iES.current()) != 0) { + ++iES; + if (piES->getPort()->IsLinked()) { + SUPERV_Links aLinks = piES->getPort()->Links(); + for (int j=0; jlength(); j++) { + if (toCheckExisting) { + if (aGraph->isLinkPrsExists(aLinks[j])) + continue; + } + aGraph->createLinkPrs(aLinks[j]); + } + } + } + delete ihmListES; } @@ -402,3 +420,16 @@ void SUPERVGUI_GraphNode::updatePorts() { } } } + + +/** + * Returns coordinates of connection point in content coordinates + */ +QPoint SUPERVGUI_GraphNode::getInConnectPnt() { + return QPoint(pos().x(), + pos().y() + (height()/2)); +} +QPoint SUPERVGUI_GraphNode::getOutConnectPnt() { + return QPoint(pos().x() + width(), + pos().y() + (height()/2)); +} diff --git a/src/SUPERVGUI/SUPERVGUI_GraphNode.h b/src/SUPERVGUI/SUPERVGUI_GraphNode.h index f104b5c..ce756bc 100644 --- a/src/SUPERVGUI/SUPERVGUI_GraphNode.h +++ b/src/SUPERVGUI/SUPERVGUI_GraphNode.h @@ -32,6 +32,9 @@ class SUPERVGUI_GraphNode: public SUPERVGUI_Node { virtual void deletePort(SUPERVGUI_Port* thePort); + virtual QPoint getInConnectPnt(); + virtual QPoint getOutConnectPnt(); + virtual void updateShape() {}; virtual void updatePorts(); diff --git a/src/SUPERVGUI/SUPERVGUI_Link.cxx b/src/SUPERVGUI/SUPERVGUI_Link.cxx index 948ef6b..1dacbea 100644 --- a/src/SUPERVGUI/SUPERVGUI_Link.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Link.cxx @@ -45,6 +45,7 @@ SUPERVGUI_Link::SUPERVGUI_Link(SUPERVGUI_Graph* theGraph, SUPERV_Link theLink) { myHltPnt = -1; myPntMovingState = false; myPainter = 0; + myIsVisible = true; myTmpPen.setColor(SKETCH_CLR); myTmpPen.setWidth(LINE_WIDTH); myIsSelected = false; @@ -241,7 +242,7 @@ void SUPERVGUI_Link::repaint() { * if toErase = true then it draws link by background color */ void SUPERVGUI_Link::paint(bool toErase) { - if (!myGraph) return; + if ((!myGraph) || (!myIsVisible)) return; if (!myEngine && SUPERV_isNull(myEngine)) return; // if (!isCreationComplete()) return; @@ -267,7 +268,7 @@ void SUPERVGUI_Link::paint(bool toErase) { * Defines a pen and draws link using given painter */ void SUPERVGUI_Link::paint(QPainter* thePainter, bool toErase) { - if (!myGraph) return; + if ((!myGraph) || (!myIsVisible)) return; if (!myEngine && SUPERV_isNull(myEngine)) return; // if (!isCreationComplete()) return; thePainter->save(); @@ -294,6 +295,7 @@ void SUPERVGUI_Link::paint(QPainter* thePainter, bool toErase) { * Draws link using given painter */ void SUPERVGUI_Link::drawLink(QPainter* thePainter) { + if (!myIsVisible) return; if (!isESInputPort()) thePainter->moveTo(myPortIn->getConnectPnt()); else @@ -372,6 +374,20 @@ void SUPERVGUI_Link::drawTo(QPoint thePnt) { } +//********************************************************************** +/** + * Set link non visible + */ +void SUPERVGUI_Link::setVisible(bool theVisible) { + myIsVisible = theVisible; + if (myIsVisible) { + connectToEvents(); + } else { + disconnect(myGraph, 0, this, 0); + } +} + + //********************************************************************** /** * Checks full definition of the link diff --git a/src/SUPERVGUI/SUPERVGUI_Link.h b/src/SUPERVGUI/SUPERVGUI_Link.h index 0704832..34cfd6f 100644 --- a/src/SUPERVGUI/SUPERVGUI_Link.h +++ b/src/SUPERVGUI/SUPERVGUI_Link.h @@ -83,6 +83,8 @@ public: void removePoint(int thePnt); + void setVisible(bool theVisible); + static void setOrthoMode(bool theIsOrtho) { OrthoMode = theIsOrtho; }; @@ -131,6 +133,8 @@ private: // Selection of Link bool myIsSelected; + + bool myIsVisible; static bool OrthoMode; static bool LinkIsMoving; diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index 31b3801..f5b65bb 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -651,7 +651,7 @@ void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) { /** * Add Control node */ -void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode) { +void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) { switch (myCurrentView) { case GRAPH: { @@ -664,8 +664,10 @@ void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theE graph->addChild(aStartPrs, theStartNode->X(), theStartNode->Y()); graph->ResizeGraph(aEndPrs, theEndNode->X(), theEndNode->Y()); graph->addChild(aEndPrs, theEndNode->X(), theEndNode->Y()); - aStartPrs->updateLinksPrs(); - aEndPrs->updateLinksPrs(); + if (Update) { + aStartPrs->updateLinksPrs(); + aEndPrs->updateLinksPrs(); + } aStartPrs->sync(); aEndPrs->sync(); graph->repaintContents(); @@ -685,8 +687,10 @@ void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theE graph->addChild(aStartPrs, theStartNode->X(), theStartNode->Y()); graph->ResizeGraph(aEndPrs, theEndNode->X(), theEndNode->Y()); graph->addChild(aEndPrs, theEndNode->X(), theEndNode->Y()); - aStartPrs->updateLinksPrs(); - aEndPrs->updateLinksPrs(); + if (Update) { + aStartPrs->updateLinksPrs(); + aEndPrs->updateLinksPrs(); + } aStartPrs->sync(); aEndPrs->sync(); graph->repaintContents(); diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h index b274fa8..300b1c2 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.h +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -87,7 +87,7 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void checkIsInStudy(); void addComputeNode(SUPERV_CNode theNode); - void addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode); + void addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update); void addGOTONode(SUPERV_CNode theNode); void setPaletteBackgroundColor(const QColor& color); diff --git a/src/SUPERVGUI/SUPERVGUI_Node.cxx b/src/SUPERVGUI/SUPERVGUI_Node.cxx index ba1a479..3c4515a 100644 --- a/src/SUPERVGUI/SUPERVGUI_Node.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Node.cxx @@ -88,14 +88,15 @@ SUPERVGUI_Node::SUPERVGUI_Node(QWidget* theParent, SUPERVGUI_Main* theMain, SUPE if (myMain->isEditable() && (getNodeType() != SUPERV::FactoryNode) && (getNodeType() != SUPERV::ComputingNode)) { - if ((getNodeType() != SUPERV::EndLoopNode) /*&& (getNodeType() != SUPERV::EndSwitchNode)*/) { + if ((getNodeType() != SUPERV::EndLoopNode)) { QPopupMenu* aAddPortMnu = new QPopupMenu(this); aAddPortMnu->insertItem("Input", this, SLOT(addInputPort())); if (getNodeType() != SUPERV::LoopNode) aAddPortMnu->insertItem("Output", this, SLOT(addOutputPort())); myPopup->insertSeparator(); - myPopup->insertItem("Edit Function", this, SLOT(editFunction())); + if ((getNodeType() != SUPERV::EndSwitchNode)) + myPopup->insertItem("Edit Function", this, SLOT(editFunction())); myPopup->insertItem("Add Port", aAddPortMnu); } } diff --git a/src/SUPERVGUI/SUPERVGUI_Port.cxx b/src/SUPERVGUI/SUPERVGUI_Port.cxx index 27beac3..842687e 100644 --- a/src/SUPERVGUI/SUPERVGUI_Port.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Port.cxx @@ -269,11 +269,6 @@ void SUPERVGUI_PortIn::onDeleteLink(SUPERVGUI_Link*) { } } -void SUPERVGUI_PortIn::deletePort() { - - SUPERVGUI_Port::deletePort(); -} - //*********************************************************** @@ -397,11 +392,6 @@ void SUPERVGUI_PortOut::deleteLinks() { } -void SUPERVGUI_PortOut::deletePort() { - - SUPERVGUI_Port::deletePort(); -} - //*********************************************************** // Input Port of EndSwitch Node @@ -529,7 +519,3 @@ void SUPERVGUI_PortInESNode::onDeleteLink(SUPERVGUI_Link* theLink) { } } -void SUPERVGUI_PortInESNode::deletePort() { - - SUPERVGUI_Port::deletePort(); -} diff --git a/src/SUPERVGUI/SUPERVGUI_Port.h b/src/SUPERVGUI/SUPERVGUI_Port.h index e1bcd5e..99b8125 100644 --- a/src/SUPERVGUI/SUPERVGUI_Port.h +++ b/src/SUPERVGUI/SUPERVGUI_Port.h @@ -105,9 +105,6 @@ class SUPERVGUI_PortIn: public SUPERVGUI_Port { void onDeleteLink(SUPERVGUI_Link*); - protected slots: - virtual void deletePort(); - private: int psd; int psc; @@ -150,10 +147,6 @@ class SUPERVGUI_PortOut: public SUPERVGUI_Port { void onDeleteLink(SUPERVGUI_Link*); - protected slots: - virtual void deletePort(); - - private: int pls; bool study; @@ -191,9 +184,6 @@ class SUPERVGUI_PortInESNode: public SUPERVGUI_Port { void onDeleteLink(SUPERVGUI_Link*); - protected slots: - virtual void deletePort(); - private: // int psd; int psc; diff --git a/src/SUPERVGUI/SUPERVGUI_Service.cxx b/src/SUPERVGUI/SUPERVGUI_Service.cxx index f9cb9e9..2b13b08 100644 --- a/src/SUPERVGUI/SUPERVGUI_Service.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Service.cxx @@ -129,9 +129,11 @@ SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns): QPushButton* aComputeCBtn = new QPushButton(tr("TIT_ADDCNODE"), aCorbaPane); //!! connect(aComputeCBtn, SIGNAL(clicked()), this, SLOT(addComputeNode())); //!! + aComputeCBtn->setDefault(false); QPushButton* aComputeBtn = new QPushButton(tr("TIT_ADDFNODE"), aCorbaPane); connect(aComputeBtn, SIGNAL(clicked()), this, SLOT(addFactoryNode())); + aComputeBtn->setDefault(true); aBaseLayout->addWidget(aComputeBtn); aBaseLayout->addWidget(aComputeCBtn); //!! @@ -411,7 +413,7 @@ void SUPERVGUI_Service::addInlineNode() { aEndNode->Coords(myX + LABEL_WIDTH*2, myY); myX += NODE_DX; myY += NODE_DY; - aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode)); + aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode), true); } break; @@ -430,7 +432,7 @@ void SUPERVGUI_Service::addInlineNode() { aEndNode->Coords(myX + LABEL_WIDTH*2, myY); myX += NODE_DX; myY += NODE_DY; - aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode)); + aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode), true); } break;