From: mkr Date: Fri, 20 Jan 2006 07:38:06 +0000 (+0000) Subject: 1) Fix for bug PAL8060 : Supervisor: Edit ports - existing links are deleted. X-Git-Tag: T_Supervisor_GUI_based_on_GLViewer_start~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aa563583f7970d91036ff0cf1d20a85b45967844;p=modules%2Fsuperv.git 1) Fix for bug PAL8060 : Supervisor: Edit ports - existing links are deleted. 2) Fix for bug PAL11273 : How to set the name of the container in a Factory Node. 3) Modifications concerning to GLViewer based version (ports creation). --- diff --git a/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx b/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx index 08477e5..1778cbd 100644 --- a/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx +++ b/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx @@ -12,6 +12,8 @@ using namespace std; #include "SUPERVGUI_ArrayView.h" #include "SUPERVGUI_Main.h" #include "SUPERVGUI_CanvasCellNodePrs.h" +#include "SUPERVGUI_CanvasLink.h" +#include "SUPERVGUI_CanvasPort.h" #include @@ -192,25 +194,63 @@ void SUPERVGUI_ToolTip::maybeTip(const QPoint& theP) { // compute collision rectangle QRect aSel(theP.x()-MARGIN, theP.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN); - QCanvasItemList l = ((SUPERVGUI_ArrayView*)parentWidget())->canvas()->collisions(aSel); + QCanvasItemList l = ((QCanvasView*)parentWidget())->canvas()->collisions(aSel); for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { + // tooltip for node if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) { - SUPERVGUI_CanvasCellNodePrs* aNodePrs = (SUPERVGUI_CanvasCellNodePrs*) (*it); + SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it); QObject* anObj = aNodePrs->getObject(theP); - if (anObj->inherits("SUPERVGUI_CanvasCellNode")) { + if (anObj->inherits("SUPERVGUI_CanvasNode")) { QRect aTitleRect = aNodePrs->getTitleRect(); + QRect aLabelRect = aNodePrs->getLabelRect(); + QRect aStatusRect = aNodePrs->getStatusRect(); + + if (aTitleRect.bottom()+1 == aLabelRect.top() && + aLabelRect.bottom()+1 == aStatusRect.top()) { + QRect aTipRect(aTitleRect.left(), aTitleRect.top(), aTitleRect.width(), + aTitleRect.height() + aLabelRect.height() + aStatusRect.height()); + tip(aTipRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText()); + return; + } + if (aTitleRect.contains(theP, true)) { - tip(aTitleRect, ((SUPERVGUI_CanvasCellNode*)anObj)->getEngine()->Name()); + tip(aTitleRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText()); return; } - QRect aLabelRect = aNodePrs->getLabelRect(); if (aLabelRect.contains(theP, true)) { - tip(aLabelRect, ((SUPERVGUI_CanvasCellNode*)anObj)->getLabelText()); + tip(aLabelRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText()); return; } + + if (aStatusRect.contains(theP, true)) { + tip(aStatusRect, ((SUPERVGUI_CanvasNode*)anObj)->getToolTipText()); + return; + } + } + // tooltip for nodes' port + if (anObj->inherits("SUPERVGUI_CanvasPort")) { + SUPERVGUI_CanvasPort* aPort = (SUPERVGUI_CanvasPort*)anObj; + tip(aPort->getPrs()->getPortRect(), + aPort->getEngine()->Type() + QString(" ") + aPort->getPrs()->getText()); + return; + } + } + // tootip for links' point + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkPoint) { + SUPERVGUI_CanvasPointPrs* aPrs = (SUPERVGUI_CanvasPointPrs*) (*it); + if (aPrs->getLink()->getMain()->getViewType() == CANVAS) + tip(aSel, aPrs->getLink()->getToolTipText()); + return; + } + // tooltip for links' edge + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) { + SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it); + if (aPrs->getLink()->getMain()->getViewType() == CANVAS) + tip(aSel, aPrs->getLink()->getToolTipText()); + return; } } } diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx index 955d3b8..e113914 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx @@ -271,6 +271,16 @@ void SUPERVGUI_CanvasLink::removePoint() { } } +QString SUPERVGUI_CanvasLink::getToolTipText() const { + QString aTTT; + if (myInputPort && myOutputPort) + aTTT = myOutputPort->getEngine()->Node()->Name() + QString(" : ") + + myOutputPort->getEngine()->Name() + QString(" => ") + + myInputPort->getEngine()->Node()->Name() + QString(" : ") + + myInputPort->getEngine()->Name(); + return aTTT; +} + /* //=============================================================================== // SUPERVGUI_CanvasStreamLink: new link to be created diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasLink.h b/src/SUPERVGUI/SUPERVGUI_CanvasLink.h index 3865950..a9e13f3 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasLink.h +++ b/src/SUPERVGUI/SUPERVGUI_CanvasLink.h @@ -42,6 +42,8 @@ class SUPERVGUI_CanvasLink : public QObject { void setSelectedObject(QCanvasItem* theItem, const QPoint& thePoint); virtual QPopupMenu* getPopupMenu(QWidget* theParent); + QString getToolTipText() const; + public slots: virtual void remove(); void addPoint(); diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx index f457007..e43ebd9 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx @@ -689,3 +689,12 @@ void SUPERVGUI_CanvasNode::exportToLib() { else SUIT_MessageBox::error1( SUIT_Session::session()->activeApplication()->desktop(), tr( "ERROR" ), tr( "MSG_BAD_INODE" ), tr( "OK" ) ); } + +QString SUPERVGUI_CanvasNode::getToolTipText() const { + if ( myNode->IsFactory() ) + return QString("Name : ") + SUPERV::FNode::_narrow(myNode)->Name() + + QString("\nContainer : ") + SUPERV::FNode::_narrow(myNode)->GetContainer() + + QString("\nComponentName : ") + SUPERV::FNode::_narrow(myNode)->GetComponentName() + + QString("\nInterfaceName : ") + SUPERV::FNode::_narrow(myNode)->GetInterfaceName(); + return QString("Name : ") + myNode->Name() + '\n' + getLabelText(); +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNode.h b/src/SUPERVGUI/SUPERVGUI_CanvasNode.h index 0be086d..4d7dbde 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNode.h +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNode.h @@ -72,6 +72,8 @@ class SUPERVGUI_CanvasNode : public QObject { QString getLabelText() const { return myLabelText; } + virtual QString getToolTipText() const; + public slots: void suspendResume(); void kill(); diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx index 75bd1b8..2849254 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx @@ -21,7 +21,7 @@ using namespace std; #include #endif -#define PORT_MARGIN 2 +//#define PORT_MARGIN 2 #undef PORT_HEIGHT // to avoid warning message #define PORT_HEIGHT LABEL_HEIGHT #define TEXT_MARGIN 5 diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx index 8274ca9..8701759 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx @@ -16,12 +16,15 @@ using namespace std; #include "SUPERVGUI.h" #include "SUPERVGUI_BrowseNodeDlg.h" +#include "SUPERVGUI_PrsPort.h" + #include "SalomeApp_Study.h" SUPERVGUI_CanvasPort::SUPERVGUI_CanvasPort(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV::Port_ptr thePort): QObject(theParent), myMain(theMain), myPrs(0), + myGLPrs(0), isIgnore(false) { Trace("SUPERVGUI_CanvasPort::SUPERVGUI_CanvasPort"); @@ -35,6 +38,7 @@ SUPERVGUI_CanvasPort::~SUPERVGUI_CanvasPort() { Trace("SUPERVGUI_CanvasPort::~SUPERVGUI_CanvasPort"); if (myPrs) delete myPrs; + if (myGLPrs) delete myGLPrs; isIgnore = true; QValueList::Iterator it; @@ -49,11 +53,22 @@ SUPERVGUI_CanvasPortPrs* SUPERVGUI_CanvasPort::getPrs() const return myPrs; } +SUPERVGUI_PrsPort* SUPERVGUI_CanvasPort::getGLPrs() const +{ + if (myGLPrs == 0) ((SUPERVGUI_CanvasPort*)this)->myGLPrs = createGLPrs(); + return myGLPrs; +} + SUPERVGUI_CanvasPortPrs* SUPERVGUI_CanvasPort::createPrs() const { return new SUPERVGUI_CanvasPortPrs(myMain->getCanvas(), (SUPERVGUI_CanvasPort*)this); } +SUPERVGUI_PrsPort* SUPERVGUI_CanvasPort::createGLPrs() const +{ + return new SUPERVGUI_PrsPort((SUPERVGUI_CanvasPort*)this); +} + QPopupMenu* SUPERVGUI_CanvasPort::getPopupMenu(QWidget* theParent) { QPopupMenu* popup = new QPopupMenu(theParent); diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasPort.h b/src/SUPERVGUI/SUPERVGUI_CanvasPort.h index 0d964ed..4a96984 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasPort.h +++ b/src/SUPERVGUI/SUPERVGUI_CanvasPort.h @@ -16,6 +16,7 @@ using namespace std; class SUPERVGUI_Main; class SUPERVGUI_CanvasLink; class SUPERVGUI_CanvasPortPrs; +class SUPERVGUI_PrsPort; class SUPERVGUI_CanvasPort : public QObject { Q_OBJECT @@ -32,6 +33,7 @@ class SUPERVGUI_CanvasPort : public QObject { SUPERV_Port getEngine() const { return myPort; } SUPERVGUI_Main* getMain() const { return myMain; } SUPERVGUI_CanvasPortPrs* getPrs() const; + SUPERVGUI_PrsPort* getGLPrs() const; virtual QPopupMenu* getPopupMenu(QWidget* theParent); @@ -50,12 +52,14 @@ class SUPERVGUI_CanvasPort : public QObject { protected: virtual SUPERVGUI_CanvasPortPrs* createPrs() const; + virtual SUPERVGUI_PrsPort* createGLPrs() const; private: SUPERV_Port myPort; SUPERVGUI_Main* myMain; SUPERVGUI_CanvasPortPrs* myPrs; + SUPERVGUI_PrsPort* myGLPrs; QValueList myLinks; bool isIgnore; }; diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx index c336716..66f622a 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx @@ -19,6 +19,8 @@ using namespace std; #include "SUPERVGUI_CanvasNodePrs.h" #include "SUPERVGUI_Clipboard.h" +#include "SUPERVGUI_ArrayView.h" //for tooltip testing + #include "SUIT_MessageBox.h" #include @@ -439,6 +441,10 @@ void SUPERVGUI_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent) setHilighted(0); } + // QToolTip for title and label for SUPERVGUI_CanvasNode + SUPERVGUI_ToolTip* aTT = new SUPERVGUI_ToolTip(this); + aTT->maybeTip(p); + busy = false; } diff --git a/src/SUPERVGUI/SUPERVGUI_Clipboard.cxx b/src/SUPERVGUI/SUPERVGUI_Clipboard.cxx index fab39c4..bffc222 100644 --- a/src/SUPERVGUI/SUPERVGUI_Clipboard.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Clipboard.cxx @@ -158,8 +158,9 @@ void SUPERVGUI_Clipboard::pasteNode() { case SUPERV::FactoryNode : { SUPERV::FNode_var aFNode = dataflow->FNode( SUPERV::FNode::_narrow(aNode)->GetComponentName(), - SUPERV::FNode::_narrow(aNode)->GetInterfaceName(), - *SUPERV::FNode::_narrow(aNode)->Service() ); + SUPERV::FNode::_narrow(aNode)->GetInterfaceName(), + *SUPERV::FNode::_narrow(aNode)->Service(), + SUPERV::FNode::_narrow(aNode)->IsCimpl()); // mkr : PAL11273 if (CORBA::is_nil(aFNode)) { QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; diff --git a/src/SUPERVGUI/SUPERVGUI_Def.h b/src/SUPERVGUI/SUPERVGUI_Def.h index 1abc0b8..a78b457 100644 --- a/src/SUPERVGUI/SUPERVGUI_Def.h +++ b/src/SUPERVGUI/SUPERVGUI_Def.h @@ -79,7 +79,8 @@ NODE_Editing "", NODE_RED, NODE_GREEN, NODE_BLUE, true, false, true // ----- #define PORT_WIDTH 75 -#define PORT_HEIGHT 28 +#define PORT_HEIGHT 20 +#define PORT_MARGIN 2 // Taille des points carres constituant les lignes entre les noeuds // ---------------------------------------------------------------- diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index ed059ae..02de18a 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -53,6 +53,7 @@ using namespace boost; #include "GLViewer_Viewer2d.h" #include "GLViewer_Context.h" #include "GLViewer_BaseObjects.h" +#include "GLViewer_Group.h" #include "SUPERVGUI.h" #include "SUPERVGUI_Def.h" @@ -701,12 +702,18 @@ void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) { // SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode( resMgr(), getGLViewer(), this, theNode); - SUPERVGUI_PrsNode* glNode = new SUPERVGUI_PrsNode( aNode ); - glNode->setFirstPoint( new GLViewer_Pnt( 10, 10 ) ); + + GLViewer_Pnt* aFirstPnt = new GLViewer_Pnt( 10, 10 ); + SUPERVGUI_PrsNode* glNode = new SUPERVGUI_PrsNode( aNode, aFirstPnt ); + //glNode->setFirstPoint( new GLViewer_Pnt( 10, 10 ) ); glNode->compute(); glNode->update(); + GLViewer_Group* aNodeGroup = new GLViewer_Group(); + //aNodeGroup->addObject( glNode ); + glNode->setGroup( aNodeGroup ); getGLContext()->insertObject( glNode, true /*false*/ ); // glNode->setVisible( true ); + glNode->insertPorts(); } break; } diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h index 9fe4cee..bea57b4 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.h +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -137,6 +137,8 @@ class SUPERVGUI_Main: public SUPERVGraph_View { virtual void resizeView( QResizeEvent* theEvent ); + GLViewer_Context* getGLContext(); + signals: void KillMyThread(bool theValue); @@ -172,8 +174,7 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void closeEvent(QCloseEvent*); GLViewer_Viewer2d* getGLViewer(); - GLViewer_Context* getGLContext(); - + SUPERV_Graph dataflow; QMap mySubGraphs; diff --git a/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx b/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx index fb4c557..9173dce 100644 --- a/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx +++ b/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx @@ -17,7 +17,7 @@ using namespace std; #include "SUPERVGUI_CanvasNode.h" #include "SUPERVGUI_CanvasPort.h" #include "SUPERVGUI_CanvasControlNode.h" -#include "SUPERVGUI.h" +#include "SUPERVGUI_CanvasLink.h" #include #include @@ -294,6 +294,33 @@ void SUPERVGUI_ManagePortsDlg::init() SUPERVGUI_ManagePortsDlg::~SUPERVGUI_ManagePortsDlg() { } +// mkr : PAL8060 +void SUPERVGUI_ManagePortsDlg::createLinkEngine( SUPERV::Port_ptr thePort, + QValueList< QPair< QString,QString > >& theOwnList, + QValueList< QPair< QString,QString > >& theCorrespList ) { + // pair for the given port + QPair anOwnPair(QString(thePort->Node()->Name()), QString(thePort->Name())); + int aNum = theOwnList.contains(anOwnPair); + while ( aNum > 0 ) { + int anId = theOwnList.findIndex(anOwnPair); // get index in theOwnList + QPair aCorrespPair = theCorrespList[anId]; // corresponding pair in theCorrespList + + theOwnList.remove(theOwnList.at(anId)); + theCorrespList.remove(theCorrespList.at(anId)); + + SUPERV_Port aCorrespPort = myNode->getMain()->getDataflow()->Node(aCorrespPair.first)->Port(aCorrespPair.second); + SUPERV_Link aLinkEngine; + if ( thePort->IsInput() ) + aLinkEngine = myNode->getMain()->getDataflow()->Link(aCorrespPort, thePort); + else + aLinkEngine = myNode->getMain()->getDataflow()->Link(thePort, aCorrespPort); + SUPERVGUI_CanvasLink* aLink = new SUPERVGUI_CanvasLink(myNode->getMain()->getCanvas(), myNode->getMain(), aLinkEngine); + aLink->show(); + + aNum--; + } +} + /** * Set the ports as entered by user (order, name/type, etc.) and close the dialog */ @@ -314,14 +341,55 @@ void SUPERVGUI_ManagePortsDlg::accept() { // automatically removes the corresponding Output Port. So for Loops the // oldPorts list should be filtered to include only Input Ports. // But I'll filter Gate-s as well.. + bool isAnyLinked = false; // check if any port from old ports is linked QObjectList portsToRemove; while ( (obj = it.current()) != 0 ) { ++it; SUPERV::Port_var aPort = ((SUPERVGUI_CanvasPort*)obj)->getEngine(); - if ( !aPort->IsGate() && ( !isLoop || aPort->IsInput() ) ) + if ( !aPort->IsGate() && ( !isLoop || aPort->IsInput() ) ) { portsToRemove.append( obj ); + } + // check if port has a link (output porst of Loop node are also checked) + if ( !aPort->IsGate() && aPort->IsLinked() && !isAnyLinked) + isAnyLinked = true; } delete oldPorts; // delete the list, not the objects + + // mkr : PAL8060 --> + QString aNodeName = myNode->getEngine()->Name(); + QValueList< QPair< QString,QString > > InPortsL, OutPortsL; + if ( isAnyLinked ) { + // if myNode has linked port(s), create two lists of In/Out ports (InPortsL, OutPortsL) to identify all links for myNode + QObjectList* list = myNode->getMain()->getCanvas()->queryList("SUPERVGUI_CanvasLink"); + QObjectListIt listit( *list ); + QObject *listobj; + while ( (listobj = listit.current()) != 0 ) { + ++listit; + SUPERV::Link_var aLink = ((SUPERVGUI_CanvasLink*)listobj)->getEngine(); + if ( aNodeName.compare(aLink->InPort()->Node()->Name()) == 0 + || + aNodeName.compare(aLink->OutPort()->Node()->Name()) == 0 ) { + QPair InPair(QString(aLink->InPort()->Node()->Name()), QString(aLink->InPort()->Name())); + QPair OutPair(QString(aLink->OutPort()->Node()->Name()), QString(aLink->OutPort()->Name())); + InPortsL.append(InPair); + OutPortsL.append(OutPair); + } + + if ( isLoop ) { + // put into In/Out lists all links for corresponding EndLoop node + QString aCoupledNodeName = ((SUPERVGUI_CanvasStartNode*)myNode)->getCoupled()->getEngine()->Name(); + if ( aCoupledNodeName.compare(aLink->InPort()->Node()->Name()) == 0 + || + aCoupledNodeName.compare(aLink->OutPort()->Node()->Name()) == 0 ) { + QPair InPair(QString(aLink->InPort()->Node()->Name()), QString(aLink->InPort()->Name())); + QPair OutPair(QString(aLink->OutPort()->Node()->Name()), QString(aLink->OutPort()->Name())); + InPortsL.append(InPair); + OutPortsL.append(OutPair); + } + } + } + } + // mkr : PAL8060 <-- // portsToRemove list contains: // for Loop node: all INPUT ports except Gates @@ -339,18 +407,66 @@ void SUPERVGUI_ManagePortsDlg::accept() { item = (PortListItem*)myInList->item( i ); aPort = aINode->InPort( item->PortName.latin1(), item->PortType.latin1() ); myNode->createPort( aPort.in() ); + + // mkr : PAL8060 + if ( !InPortsL.isEmpty() && !OutPortsL.isEmpty() ) + // create links for those input ports, which had links earlier + createLinkEngine( aPort, InPortsL, OutPortsL ); + } + + if ( isLoop ) { // asv : 11.01.05 : for Loop nodes do the same as in SUPERVGUI_CanvasStartNode::addInputPort() - if ( isLoop ) { - SUPERVGUI_CanvasStartNode* aStartLoopNode = (SUPERVGUI_CanvasStartNode*)myNode; - aStartLoopNode->merge(); - aStartLoopNode->getCoupled()->merge(); + SUPERVGUI_CanvasStartNode* aStartLoopNode = (SUPERVGUI_CanvasStartNode*)myNode; + aStartLoopNode->merge(); + aStartLoopNode->getCoupled()->merge(); + + // mkr : PAL8060 --> + if ( !InPortsL.isEmpty() && !OutPortsL.isEmpty() ) { + + // 1) create old links for output ports of Loop node + QObjectList* aPortsOut = aStartLoopNode->queryList("SUPERVGUI_CanvasPortOut"); + QObjectListIt aPorstOutit( *aPortsOut ); + QObject *listobj; + while ( (listobj = aPorstOutit.current()) != 0 ) { + ++aPorstOutit; + + SUPERV::Port_var aPortOut = ((SUPERVGUI_CanvasPort*)listobj)->getEngine(); + createLinkEngine( aPortOut, OutPortsL, InPortsL ); + } + + // 2) create old links for input ports of EndLoop node + QObjectList* aPortsIn = aStartLoopNode->getCoupled()->queryList("SUPERVGUI_CanvasPortIn"); + QObjectListIt aPorstInit( *aPortsIn ); + while ( (listobj = aPorstInit.current()) != 0 ) { + ++aPorstInit; + + SUPERV::Port_var aPortIn = ((SUPERVGUI_CanvasPort*)listobj)->getEngine(); + createLinkEngine( aPortIn, InPortsL, OutPortsL ); + } + + // 3) create old links for output ports of EndLoop node + aPortsOut = aStartLoopNode->getCoupled()->queryList("SUPERVGUI_CanvasPortOut"); + aPorstOutit = QObjectListIt( *aPortsOut ); + while ( (listobj = aPorstOutit.current()) != 0 ) { + ++aPorstOutit; + + SUPERV::Port_var aPortOut = ((SUPERVGUI_CanvasPort*)listobj)->getEngine(); + createLinkEngine( aPortOut, OutPortsL, InPortsL ); + } } + // mkr : PAL8060 <-- } + // creating Out-ports, except LoopNode-s for ( i = 0; i < myOutList->count() && !isLoop; i++ ) { item = (PortListItem*)myOutList->item( i ); aPort = aINode->OutPort( item->PortName.latin1(), item->PortType.latin1() ); myNode->createPort( aPort.in() ); + + // mkr : PAL8060 + if ( !InPortsL.isEmpty() && !OutPortsL.isEmpty() ) + // create links for those output ports, which had links earlier + createLinkEngine( aPort, OutPortsL, InPortsL ); } // 2. update the node's presentation diff --git a/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.h b/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.h index 345d1cb..1e3506b 100644 --- a/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.h +++ b/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.h @@ -11,11 +11,14 @@ #ifndef SUPERVGUI_ManagePortsDlg_H #define SUPERVGUI_ManagePortsDlg_H +#include "SUPERVGUI.h" + #include #include #include #include #include +#include class SUPERVGUI_CanvasNode; @@ -68,6 +71,10 @@ protected: void moveUp( QListBox* ); void moveDown( QListBox* ); void moveItem( QListBox* theLB, const int from, const int to ); + // mkr : PAL8060 + void createLinkEngine( SUPERV::Port_ptr thePort, + QValueList< QPair< QString,QString > >& theOwnList, + QValueList< QPair< QString,QString > >& theCorrespList ); private: void init(); diff --git a/src/SUPERVGUI/SUPERVGUI_Prs.cxx b/src/SUPERVGUI/SUPERVGUI_Prs.cxx index 85d241e..0e17d43 100644 --- a/src/SUPERVGUI/SUPERVGUI_Prs.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Prs.cxx @@ -7,6 +7,7 @@ // Module : SUPERV #include +//#include //======================================================================= // name : SUPERVGUI_Prs @@ -208,7 +209,7 @@ void SUPERVGUI_PrsDrawer::drawPort( GLViewer_Pnt* pnt, GLfloat d, const QString& } void SUPERVGUI_PrsDrawer::drawPort( GLViewer_Pnt* pnt, GLfloat d, - const QString& label, GLViewer_Pnt* textPnt ) + const QString& label, GLViewer_Pnt* textPnt ) { if( !pnt ) return; @@ -245,3 +246,34 @@ void SUPERVGUI_PrsDrawer::drawPort( GLViewer_Pnt* pnt, GLfloat d, //drawText( label, textX , textY, myNColor, &aTmpFont, 2 ); } +/*void SUPERVGUI_PrsDrawer::drawPort( SUPERVGUI_PrsPort* thePort ) +{ + // draw ports' contour + drawContour( thePort->getRect(), Qt::black, myLineWidth, 0, false ); + + // draw connection point + drawVertex( thePort->getPoint()->x(), thePort->getPoint()->y(), Qt::black ); + + // draw connection line + GLfloat x, y; + if ( thePort->getPort()->getEngine()->IsInput() ) + x = thePort->getRect()->left(); + else + x = thePort->getRect()->right(); + y = (thePort->getRect()->top() + thePort->getRect()->bottom())/2; + + GLViewer_Pnt aSecPoint( x, y ); + GLViewer_PntList pnts; + pnts.push_back( *(thePort->getPoint()) ); + pnts.push_back( aSecPoint ); + + drawContour( pnts, Qt::black, myLineWidth ); + + // draw ports' text + GLfloat textX = ( aSecPoint.x() ); + GLfloat textY = ( aSecPoint.y() ); + + drawGLText( thePort->getText(), textX , textY, GLText_Center, GLText_Center ); +}*/ + + diff --git a/src/SUPERVGUI/SUPERVGUI_Prs.h b/src/SUPERVGUI/SUPERVGUI_Prs.h index 77fa60f..97e364a 100644 --- a/src/SUPERVGUI/SUPERVGUI_Prs.h +++ b/src/SUPERVGUI/SUPERVGUI_Prs.h @@ -21,6 +21,8 @@ typedef QMap StreamPointsMap; +//class SUPERVGUI_PrsPort; + /* Class : SUPERVGUI_Prs Description : Base class for GLViewer presenataions of Nodes @@ -143,6 +145,7 @@ protected: void drawBoundaryBox( GLViewer_Rect*, GLfloat, GLushort ); void drawPort( GLViewer_Pnt*, GLfloat, const QString& ); void drawPort( GLViewer_Pnt*, GLfloat, const QString&, GLViewer_Pnt* ); + //void drawPort( SUPERVGUI_PrsPort* ); void setNColor( const QColor& color ) { myNColor = color; } void setHColor( const QColor& color ) { myHColor = color; } diff --git a/src/SUPERVGUI/SUPERVGUI_PrsNode.cxx b/src/SUPERVGUI/SUPERVGUI_PrsNode.cxx index 98578f5..e7b6944 100644 --- a/src/SUPERVGUI/SUPERVGUI_PrsNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_PrsNode.cxx @@ -7,25 +7,27 @@ // Module : SUPERV #include +#include +#include #include +#include #include #include -#include - -#define PORT_MARGIN 2 +//#define PORT_MARGIN 2 //======================================================================= // name : SUPERVGUI_PrsNode // Purpose : Constructor //======================================================================= -SUPERVGUI_PrsNode::SUPERVGUI_PrsNode( SUPERVGUI_CanvasNode* theNode ) : +SUPERVGUI_PrsNode::SUPERVGUI_PrsNode( SUPERVGUI_CanvasNode* theNode, GLViewer_Pnt* theFirstPnt ) : SUPERVGUI_Prs(), myNode(theNode) { myType = "SUPERVGUI_PrsNode"; + myName = myNode->getEngine()->Name(); setScalable( true ); @@ -41,21 +43,24 @@ SUPERVGUI_PrsNode::SUPERVGUI_PrsNode( SUPERVGUI_CanvasNode* theNode ) : myStreamHeight = 0; myGateHeight = PORT_HEIGHT + 2*PORT_MARGIN; - myHeight = INST_HEIGHT;// it will be defined when we'll know the number of ports exactly + //myHeight = INST_HEIGHT;// it will be defined when we'll know the number of ports exactly // and it will be different for different types of nodes, // i.e. for Compute, Loop, Switch, Goto ... nodes // So, it have to be defined in subclasses + // get height by using getHeight() method (it's have to be redefined in subclasses) SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); QString fileName = aResMgr->path( "resources", "SUPERVGUI", "ICO_NODE_INLINE" ); myIcon = GLViewer_Drawer::loadTexture( fileName ); + myColor = aResMgr->colorValue( "SUPERVGraph", "NodeBody", DEF_MAIN_BACK ); - // setState(myNode->getEngine()->State()); - setState(SUPERV_Running); + setState(myNode->getEngine()->State()); + //setState(SUPERV_Running); - //updatePorts(); // method for ports' presentations creation + setFirstPoint(theFirstPnt); + createPorts(); // method for ports' presentations creation } //======================================================================= @@ -76,8 +81,10 @@ void SUPERVGUI_PrsNode::update() { float x1 = myFirstPoint->x() - myWidth / 2 / myXScale; float x2 = myFirstPoint->x() + myWidth / 2 / myXScale; + //float x1 = myFirstPoint->x(); + //float x2 = myFirstPoint->x() + myWidth / myXScale; float y1 = myFirstPoint->y(); - float y2 = myFirstPoint->y() + myHeight / myYScale; + float y2 = myFirstPoint->y() + getHeight() / myYScale; myRect->setLeft( x1 ); myRect->setRight( x2 ); @@ -111,7 +118,7 @@ void SUPERVGUI_PrsNode::updateStreamPoint( GLViewer_Pnt* streamPoint, int type ) float r = SP_GAP / myXScale; float w = myWidth / myXScale; - float h = myHeight / myYScale; + float h = getHeight() / myYScale; switch( type ) { @@ -356,6 +363,254 @@ void SUPERVGUI_PrsNode::setState(SUPERV::GraphState theState) myTime = QString(hms); } +//================================================================ +// Function : getWidth +// Purpose : +//================================================================ +float SUPERVGUI_PrsNode::getWidth() const +{ + return myWidth; +} + +//================================================================ +// Function : getHeight +// Purpose : +//================================================================ +float SUPERVGUI_PrsNode::getHeight() const +{ + return getTitleHeight() + getLabelHeight() + getStatusHeight() + + getBodyHeight() + getGateHeight(); +} + +//================================================================ +// Function : getTitleHeight +// Purpose : +//================================================================ +float SUPERVGUI_PrsNode::getTitleHeight() const +{ + return myTitleHeight; +} + +//================================================================ +// Function : getLabelHeight +// Purpose : +//================================================================ +float SUPERVGUI_PrsNode::getLabelHeight() const +{ + if (isLabelVisible()) + return myLabelHeight; + return 0; +} + +//================================================================ +// Function : getStatusHeight +// Purpose : +//================================================================ +float SUPERVGUI_PrsNode::getStatusHeight() const +{ + return myStatusHeight; +} + +//================================================================ +// Function : getBodyHeight +// Purpose : +//================================================================ +float SUPERVGUI_PrsNode::getBodyHeight() const +{ + if (isPortVisible()) + return myPortHeight + myStreamHeight; + return 0; +} + +//================================================================ +// Function : getPortHeight +// Purpose : +//================================================================ +float SUPERVGUI_PrsNode::getPortHeight() const +{ + if (isPortVisible()) + return myPortHeight; + return 0; +} + +//================================================================ +// Function : getStreamHeight +// Purpose : +//================================================================ +float SUPERVGUI_PrsNode::getStreamHeight() const +{ + if (isPortVisible()) + return myStreamHeight; + return 0; +} + +//================================================================ +// Function : getGateHeight +// Purpose : +//================================================================ +float SUPERVGUI_PrsNode::getGateHeight() const +{ + if (isPortVisible()) + return myGateHeight; + return 0; +} + +//================================================================ +// Function : createPorts +// Purpose : create (not draw) presentations for ports' of this node object +//================================================================ +void SUPERVGUI_PrsNode::createPorts() +{ + //bool aDisp = getVisible(); + //if (aDisp) hide(); + + //QRect r = getBodyRect(); + float w = (int)(myWidth/2) - PORT_MARGIN; + if (w < PORT_WIDTH) w = PORT_WIDTH; + + //float ix = myFirstPoint->x() + PORT_MARGIN; + float ix = myFirstPoint->x() - myWidth / 2 / myXScale + PORT_MARGIN; + float ih = myFirstPoint->y() + PORT_MARGIN; + float ox = ix + w; + float oh = myFirstPoint->y() + PORT_MARGIN; + + const QObjectList* list = myNode->children(); + + cout<<"1 : myPortHeight = "<inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + if (!aPort->getEngine()->IsGate() && !aPort->isStream()) { + if (aPort->getEngine()->IsInput()) { + // create ports' presentation + SUPERVGUI_PrsPort* aPrsPort = aPort->getGLPrs(); + aPrsPort->setRect(ix, ih, w, PORT_HEIGHT); + ih += PORT_HEIGHT; + } + else { + SUPERVGUI_PrsPort* aPrsPort = aPort->getGLPrs(); + aPrsPort->setRect(ox, oh, w, PORT_HEIGHT); + oh += PORT_HEIGHT; + } + } + } + } + } + + myPortHeight = ( ih>oh ? ih : oh ) - myFirstPoint->y() + PORT_MARGIN; + cout<<"2 : myPortHeight = "<y() + myPortHeight; + cout<<"1 : sy = "<inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + if (!aPort->getEngine()->IsGate() && aPort->isStream()) { + if (aPort->getEngine()->IsInput()) { + SUPERVGUI_PrsPort* aPrsPort = aPort->getGLPrs(); + aPrsPort->setRect(ix, ih, w, PORT_HEIGHT); + ih += PORT_HEIGHT; + } + else { + SUPERVGUI_PrsPort* aPrsPort = aPort->getGLPrs(); + aPrsPort->setRect(ox, oh, w, PORT_HEIGHT); + oh += PORT_HEIGHT; + } + } + } + } + } + + cout<<"3 : myStreamHeight = "<oh ? ih : oh ) - sy + PORT_MARGIN; + if (myStreamHeight == 2*PORT_MARGIN) myStreamHeight = 0; + cout<<"4 : myStreamHeight = "<y() + myPortHeight + myStreamHeight; + cout<<"2 : sy = "<inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + if (aPort->getEngine()->IsGate()) { + if (aPort->getEngine()->IsInput()) { + SUPERVGUI_PrsPort* aPrsPort = aPort->getGLPrs(); + aPrsPort->setRect(ix, ih, w, PORT_HEIGHT); + ih += PORT_HEIGHT; + } + else { + SUPERVGUI_PrsPort* aPrsPort = aPort->getGLPrs(); + aPrsPort->setRect(ox, oh, w, PORT_HEIGHT); + oh += PORT_HEIGHT; + } + } + } + } + } + + cout<<"5 : myGateHeight = "<oh ? ih : oh ) - sy + PORT_MARGIN; + cout<<"6 : myGateHeight = "<inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + SUPERVGUI_PrsPort* aPrsPort = aPort->getGLPrs(); + aPrsPort->setRectBottom( aPrsPort->getRect()->bottom() + myFirstPoint->y()*2 + + getBodyHeight() + getGateHeight()); + aPrsPort->setRectTop( aPrsPort->getRect()->top() + myFirstPoint->y()*2 + + getBodyHeight() + getGateHeight()); + } + } + } +} + +//================================================================ +// Function : insertPorts +// Purpose : insert port objects of this node into the context +//================================================================ +void SUPERVGUI_PrsNode::insertPorts() +{ + const QObjectList* list = myNode->children(); + if (list) { + QObjectListIt it(*list); + SUPERVGUI_CanvasPort* aPort; + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) { + aPort = (SUPERVGUI_CanvasPort*) obj; + SUPERVGUI_PrsPort* aPrsPort = aPort->getGLPrs(); + aPrsPort->setGroup( getGroup() ); + myNode->getMain()->getGLContext()->insertObject( aPrsPort, true /*false*/ ); + } + } + } +} /* Class : SUPERVGUI_PrsNodeDrawer @@ -392,8 +647,6 @@ void SUPERVGUI_PrsNodeDrawer::create( float xScale, float yScale, bool /*onlyUpd { myXScale = xScale; myYScale = yScale; - - // GLViewer_Group* group = new GLViewer_Group(); QValueList::Iterator it; for( it = myObjects.begin(); it != myObjects.end(); it++ ) { @@ -415,7 +668,37 @@ void SUPERVGUI_PrsNodeDrawer::create( float xScale, float yScale, bool /*onlyUpd else if( object->isHighlighted() ) drawBoundaryBox( rect, gap, myStippleHPattern ); - const int fieldHeight = 30; + //--------------------- + GLViewer_PntList pnts; + pnts.push_back( GLViewer_Pnt( rect->left(), rect->top() ) ); + pnts.push_back( GLViewer_Pnt( rect->left(), rect->bottom() ) ); + pnts.push_back( GLViewer_Pnt( rect->right(), rect->bottom() ) ); + pnts.push_back( GLViewer_Pnt( rect->right(), rect->top() ) ); + drawPolygon( pnts, object->nodeColor() ); + + QColor primingColor = myPrimingColor; + + primingColor = Qt::white; + //drawRectangle( rect, myLineWidth, 0, myNColor, true, primingColor ); + + //QString name = "computing node";//object->getName(); + //if ( textFormat() == DTF_TEXTURE_SCALABLE && name.length() > 15 ) + // name = name.left( 12 ) + QString( "..." ); + + if ( textFormat() == DTF_TEXTURE_SCALABLE && object->getName().length() > 15 ) + drawGLText( object->getName().left( 12 ) + QString( "..." ), + rect->left()+rect->width()/2, rect->top()-5, GLText_Center, GLText_Center ); + else + drawGLText( object->getName(), rect->left()+rect->width()/2, rect->top()-5, GLText_Center, GLText_Center ); + + /*QFont* aFont = new QFont( "Helvetica", 12 ); + aFont->setStyleHint( QFont::Helvetica ); + aFont->setStyleStrategy( QFont::PreferQuality ); + drawText( name, (rect->left()-rect->right())/2, rect->top()-25, Qt::black, aFont, 0 );*/ + + + //-------------------------------------------- + /*const int fieldHeight = 30; GLViewer_Rect frect( *rect ); frect.setBottom( rect->top() - fieldHeight ); drawRectangle( &frect, 1., 0., Qt::black, true, Qt::cyan ); @@ -430,13 +713,14 @@ void SUPERVGUI_PrsNodeDrawer::create( float xScale, float yScale, bool /*onlyUpd frect.setBottom( rect->top() - 4*fieldHeight ); drawRectangle( &frect, 1., 0., Qt::black, true, Qt::green ); - drawGLText( "DTF_TEXTURE_SCALABLE text", rect->left()+5, rect->top()-5, GLText_Right, GLText_Center ); + drawGLText( "DTF_TEXTURE_SCALABLE text", rect->left()+5, rect->top()-5, GLText_Right, GLText_Center );*/ + //-------------------------------------------- - float iconSize = 16; - drawTexture( object->getIcon(), (int)iconSize, - rect->left() + iconSize / 2, rect->top() - iconSize / 2 ); + //float iconSize = 16; + //drawTexture( object->getIcon(), (int)iconSize, + // rect->left() + iconSize / 2, rect->top() - iconSize / 2 ); - StreamPointsMap streamPoints = object->getStreamPoints(); + /*StreamPointsMap streamPoints = object->getStreamPoints(); StreamPointsMap::iterator it = streamPoints.begin(); cout<<"We going to draw stream points . . ."<getPorts(); - PortList::iterator itP = Ports.begin(); - cout<<"We going to draw ports . . ."<getPorts(); + //PortList::iterator itP = Ports.begin(); + //cout<<"We going to draw ports . . ."<getNode()->children(); + if (list) { + QObjectListIt it(*list); + while (QObject* obj = it.current()) { + ++it; + if (obj->inherits("SUPERVGUI_CanvasPort")) + drawPort( ((SUPERVGUI_CanvasPort*)obj)->getGLPrs()); + } + }*/ } } diff --git a/src/SUPERVGUI/SUPERVGUI_PrsNode.h b/src/SUPERVGUI/SUPERVGUI_PrsNode.h index 20281e7..d3ad91d 100644 --- a/src/SUPERVGUI/SUPERVGUI_PrsNode.h +++ b/src/SUPERVGUI/SUPERVGUI_PrsNode.h @@ -43,10 +43,12 @@ class SUPERVGUI_PrsNode : public SUPERVGUI_Prs Q_OBJECT public: - SUPERVGUI_PrsNode( SUPERVGUI_CanvasNode* theNode ); + SUPERVGUI_PrsNode( SUPERVGUI_CanvasNode* theNode, GLViewer_Pnt* theFirstPnt ); virtual ~SUPERVGUI_PrsNode(); public: + SUPERVGUI_CanvasNode* getNode() const { return myNode; } + virtual void compute(); virtual void update(); virtual void clear(); @@ -64,10 +66,26 @@ public: GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE ); virtual GLboolean unselect(); - float getWidth() const { return myWidth; } - float getHeight() const { return myHeight; } + virtual float getWidth() const; + virtual float getHeight() const; + + virtual float getTitleHeight() const; + virtual float getLabelHeight() const; + virtual float getStatusHeight() const; + virtual float getBodyHeight() const; + virtual float getPortHeight() const; + virtual float getStreamHeight() const; + virtual float getGateHeight() const; GLuint getIcon() const; + + virtual void setNodeColor(const QColor& theColor) { myColor = theColor; } + virtual QColor nodeColor() const { return myColor; } + + virtual void setLabelVisible(bool b) { myLabelVisible = b; } + virtual void setPortVisible(bool b) { myPortVisible = b; } + bool isLabelVisible() const { return myLabelVisible; } + bool isPortVisible() const { return myPortVisible; } // connection data SUPERVGUI_PrsPort* getPort( const int ) const; // don't use @@ -82,26 +100,31 @@ public: QValueList getConnections( const int ) const; - virtual void setState(SUPERV::GraphState theState); + virtual void setState(SUPERV::GraphState theState); + + void insertPorts(); + +protected: + virtual void createPorts(); private: - float myWidth; - float myHeight; + float myWidth; + //float myHeight; - GLuint myIcon; + GLuint myIcon; - GLint mySelElement; + GLint mySelElement; //PortMap myPorts; PortList myPorts; PortConnectionMap myConnections; - int myTitleHeight; - int myLabelHeight; - int myStatusHeight; - int myPortHeight; - int myStreamHeight; //??? - int myGateHeight; + float myTitleHeight; + float myLabelHeight; + float myStatusHeight; + float myPortHeight; + float myStreamHeight; //??? + float myGateHeight; QString myStatus; QString myTime; @@ -109,6 +132,9 @@ private: QColor myColor; QColor myStatusColor; + bool myPortVisible; + bool myLabelVisible; + SUPERVGUI_CanvasNode* myNode; }; diff --git a/src/SUPERVGUI/SUPERVGUI_PrsPort.cxx b/src/SUPERVGUI/SUPERVGUI_PrsPort.cxx index fac1ed0..2842561 100644 --- a/src/SUPERVGUI/SUPERVGUI_PrsPort.cxx +++ b/src/SUPERVGUI/SUPERVGUI_PrsPort.cxx @@ -8,17 +8,28 @@ #include "SUPERVGUI_PrsPort.h" +#include + +#include +#include + //======================================================================= // name : SUPERVGUI_PrsStream // Purpose : Constructor //======================================================================= -SUPERVGUI_PrsPort::SUPERVGUI_PrsPort( int theType, SUPERVGUI_Prs* thePrs ) +SUPERVGUI_PrsPort::SUPERVGUI_PrsPort( SUPERVGUI_CanvasPort* thePort ) + : GLViewer_Object(), + myPort(thePort) { - myType = theType; - myPrs = thePrs; - + myType = "SUPERVGUI_PrsPort"; + myRect = new GLViewer_Rect(); + myPoint = new GLViewer_Pnt(); + myText = getText(); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + myColor = aResMgr->colorValue( "SUPERVGraph", "NodeBody", DEF_MAIN_BACK ); + //cout << myPrs->getName().data() << endl; //cout << myPoint->x() << " " << myPoint->y() << endl; } @@ -38,18 +49,83 @@ SUPERVGUI_PrsPort::~SUPERVGUI_PrsPort() //======================================================================= GLViewer_Pnt* SUPERVGUI_PrsPort::getPoint() const { - GLViewer_Pnt* point = 0; - if ( myPrs ) - point = myPrs->getStreamPoint( myType ); - return point; + //GLViewer_Pnt* point = 0; + //if ( myPrs ) + // point = myPrs->getStreamPoint( myType ); + //return point; + return myPoint; +} + +GLboolean SUPERVGUI_PrsPort::highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle ) +{ + return GL_TRUE; +} + +GLboolean SUPERVGUI_PrsPort::unhighlight() +{ + return GL_TRUE; +} + +GLboolean SUPERVGUI_PrsPort::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, + GLboolean isFull, GLboolean isCircle, GLboolean isShift ) +{ + return GL_TRUE; +} + +GLboolean SUPERVGUI_PrsPort::unselect() +{ + return GL_TRUE; +} + +void SUPERVGUI_PrsPort::moveObject( float theX, float theY, bool fromGroup ) +{ + if( !fromGroup && myGroup ) + { + myGroup->dragingObjects( theX, theY ); + return; + } + + update( theX, theY ); } +float SUPERVGUI_PrsPort::getConnectionPointX() const +{ + float x; + if (myPort->getEngine()->IsInput()) + x = myRect->left() - PORT_MARGIN - POINT_SIZE; + else + x = myRect->right() + PORT_MARGIN + POINT_SIZE; + return x; +} + +float SUPERVGUI_PrsPort::getConnectionPointY() const +{ + return (myRect->top() + myRect->bottom())/2; +} + +void SUPERVGUI_PrsPort::setRect( float theLeft , float theTop, float theWidth, float theHeight ) +{ + myRect->setCoords( theLeft, theLeft+theWidth, -(theTop+theHeight), -theTop/*+theHeight*/ ); + myPoint->setXY( getConnectionPointX(), getConnectionPointY() ); +} + +void SUPERVGUI_PrsPort::setRectBottom( float b) +{ + myRect->setBottom(b); + myPoint->setY( getConnectionPointY() ); +} + +void SUPERVGUI_PrsPort::setRectTop( float t) +{ + myRect->setTop(t); + myPoint->setY( getConnectionPointY() ); +} //================================================================ // Function : updateRect // Purpose : //================================================================ -void SUPERVGUI_PrsPort::updateRect( GLfloat xScale, GLfloat yScale ) +/*void SUPERVGUI_PrsPort::updateRect( GLfloat xScale, GLfloat yScale ) { const GLViewer_Pnt* point = getPoint(); if ( !point ) @@ -58,6 +134,29 @@ void SUPERVGUI_PrsPort::updateRect( GLfloat xScale, GLfloat yScale ) myRect->setRight( point->x() + SP_GAP / xScale ); myRect->setTop( point->y() + SP_GAP / yScale ); myRect->setBottom( point->y() - SP_GAP / yScale ); +}*/ + +//================================================================ +// Function : updateRect +// Purpose : +//================================================================ +void SUPERVGUI_PrsPort::update( GLfloat theDX, GLfloat theDY ) +{ + myPoint->move( theDX, theDY ); + myRect->move( theDX, theDY ); +} + +QString SUPERVGUI_PrsPort::getText() const +{ + SUPERV_Port aPort = myPort->getEngine(); + QString aText; + if ( !CORBA::is_nil( aPort ) ) { + aText = aPort->Name(); + if (aPort->IsParam() || aPort->IsInLine() || myPort->isStream()) + aText = aText + "=" + aPort->ToString(); + } + // printf( "--- return text of port : %s ---\n", aText.latin1() ); + return aText; } //================================================================ @@ -88,3 +187,144 @@ bool SUPERVGUI_PrsPort::locked( GLViewer_Pnt thePoint, // return true; //return false; } + +/* + Class : SUPERVGUI_PrsPortDrawer + Description : Drawer for SUPERVGUI_PrsPort +*/ + +//======================================================================= +// name : SUPERVGUI_PrsPortDrawer +// Purpose : Constructor +//======================================================================= +SUPERVGUI_PrsPortDrawer::SUPERVGUI_PrsPortDrawer() +:GLViewer_Drawer() +{ + myObjectType = "SUPERVGUI_PrsPort"; + + // for text scaling --> + //setTextFormat( DTF_TEXTURE_SCALABLE ); + + //QFont aFont( "Helvetica", 5 ); + //aFont.setStyleHint( QFont::Helvetica ); + //aFont.setStyleStrategy( QFont::PreferQuality ); + //setFont( aFont ); + // <-- + + myLineWidth = 1.5; + myStippleColor = Qt::black; + myStippleWidth = 1.0; + myStippleHPattern = 0x8888; + myStippleSPattern = 0xF0F0; +} + +//======================================================================= +// name : SUPERVGUI_PrsPortDrawer +// Purpose : Destructor +//======================================================================= +SUPERVGUI_PrsPortDrawer::~SUPERVGUI_PrsPortDrawer() +{ +} + +//================================================================ +// Function : create +// Purpose : +//================================================================ +void SUPERVGUI_PrsPortDrawer::create( float xScale, float yScale, bool /*onlyUpdate*/ ) +{ + myXScale = xScale; + myYScale = yScale; + + QValueList::Iterator it; + for( it = myObjects.begin(); it != myObjects.end(); it++ ) { + SUPERVGUI_PrsPort* object = ( SUPERVGUI_PrsPort* )( *it ); + if( !object->getVisible() ) + continue; + + float objXScale = object->isScalable() ? 1.0 : myXScale; + float objYScale = object->isScalable() ? 1.0 : myYScale; + + object->setScale( objXScale, objYScale ); + //object->update(); + + GLViewer_Rect* rect = object->getRect(); + GLfloat gap = 15 / myXScale; + + if( object->isSelected() ) + drawBoundaryBox( rect, gap, myStippleSPattern ); + else if( object->isHighlighted() ) + drawBoundaryBox( rect, gap, myStippleHPattern ); + + drawPort( object ); + + } +} + +//================================================================ +// Function : drawBoundaryBox +// Purpose : +//================================================================ +void SUPERVGUI_PrsPortDrawer::drawBoundaryBox( GLViewer_Rect* rect, GLfloat gap, GLushort pattern ) +{ + if( !rect ) + return; + + float x1 = rect->left() - gap; + float x2 = rect->right() + gap; + float y1 = rect->bottom() - gap; + float y2 = rect->top() + gap; + + glColor3f( ( GLfloat )myStippleColor.red() / 255, + ( GLfloat )myStippleColor.green() / 255, + ( GLfloat )myStippleColor.blue() / 255 ); + glLineWidth( myStippleWidth ); + + glEnable( GL_LINE_STIPPLE ); + glLineStipple( 1, pattern ); + + glBegin( GL_LINE_LOOP ); + glVertex2f( x1, y1 ); + glVertex2f( x1, y2 ); + glVertex2f( x2, y2 ); + glVertex2f( x2, y1 ); + glEnd(); + + glDisable( GL_LINE_STIPPLE ); +} + +//================================================================ +// Function : drawPort +// Purpose : +//================================================================ +void SUPERVGUI_PrsPortDrawer::drawPort( SUPERVGUI_PrsPort* thePort ) +{ + // draw ports' contour + drawContour( thePort->getRect(), Qt::black, myLineWidth, 0, false ); + + // draw connection point + drawVertex( thePort->getPoint()->x(), thePort->getPoint()->y(), Qt::black ); + + // draw connection line + GLfloat x, y; + if ( thePort->getPort()->getEngine()->IsInput() ) + x = thePort->getRect()->left(); + else + x = thePort->getRect()->right(); + y = (thePort->getRect()->top() + thePort->getRect()->bottom())/2; + + GLViewer_Pnt aSecPoint( x, y ); + GLViewer_PntList pnts; + pnts.push_back( *(thePort->getPoint()) ); + pnts.push_back( aSecPoint ); + + drawContour( pnts, Qt::black, myLineWidth ); + + // draw ports' text + GLfloat textX = ( aSecPoint.x() ); + GLfloat textY = ( aSecPoint.y() ); + + if ( thePort->getPort()->getEngine()->IsInput() ) + drawGLText( thePort->getText(), textX, textY, GLText_Right/*Center*/, GLText_Center ); + else + drawGLText( thePort->getText(), textX - thePort->getRect()->width() , textY, GLText_Right/*Center*/, GLText_Center ); +} diff --git a/src/SUPERVGUI/SUPERVGUI_PrsPort.h b/src/SUPERVGUI/SUPERVGUI_PrsPort.h index 342e0f2..7d84084 100644 --- a/src/SUPERVGUI/SUPERVGUI_PrsPort.h +++ b/src/SUPERVGUI/SUPERVGUI_PrsPort.h @@ -10,34 +10,91 @@ #define SUPERVGUI_PrsPort_H #include "SUPERVGUI_Prs.h" +#include "SUPERVGUI_CanvasPort.h" + +//class SUPERVGUI_PrsPortDrawer; + +/* + Class : SUPERVGUI_PrsPortDrawer + Description : Drawer for SUPERVGUI_PrsPort +*/ +class SUPERVGUI_PrsPortDrawer : public GLViewer_Drawer +{ +public: + SUPERVGUI_PrsPortDrawer(); + virtual ~SUPERVGUI_PrsPortDrawer(); + +public: + virtual void create( float, float, bool ); + +protected: + void drawBoundaryBox( GLViewer_Rect*, GLfloat, GLushort ); + void drawPort( SUPERVGUI_PrsPort* ); + + GLfloat myLineWidth; + QColor myStippleColor; + GLfloat myStippleWidth; + GLushort myStippleHPattern; + GLushort myStippleSPattern; + +}; /* Class : SUPERVGUI_PrsPortPort Description : Port of Port Object */ -class SUPERVGUI_PrsPort +class SUPERVGUI_PrsPort : public GLViewer_Object { public: - SUPERVGUI_PrsPort( int, SUPERVGUI_Prs* ); + SUPERVGUI_PrsPort( SUPERVGUI_CanvasPort* ); virtual ~SUPERVGUI_PrsPort(); public: - void updateRect( GLfloat xScale, GLfloat yScale ); + SUPERVGUI_CanvasPort* getPort() const { return myPort; } - bool locked( GLViewer_Pnt thePoint, - SUPERVGUI_PrsPort* thePullingPort ); + virtual void compute() {} + + virtual GLViewer_Drawer* createDrawer() { return myDrawer = new SUPERVGUI_PrsPortDrawer(); } - int getType() const { return myType; } - SUPERVGUI_Prs* getPrs() const { return myPrs; } + virtual GLboolean highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE ); + virtual GLboolean unhighlight(); + virtual GLboolean select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE, + GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE ); + virtual GLboolean unselect(); - GLViewer_Pnt* getPoint() const; - GLViewer_Rect* getRect() const { return myRect; } + virtual void moveObject( float, float, bool = false ); -protected: - int myType; - SUPERVGUI_Prs* myPrs; + virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) { return true; } + virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) { return true; } + + virtual GLViewer_Rect* getUpdateRect() { return new GLViewer_Rect( *myRect ); } + //void updateRect( GLfloat xScale, GLfloat yScale ); + void update( GLfloat theDX, GLfloat theDY ); + + bool locked( GLViewer_Pnt thePoint, + SUPERVGUI_PrsPort* thePullingPort ); + + GLViewer_Pnt* getPoint() const; + float getConnectionPointX() const; + float getConnectionPointY() const; + + void setRect( float theLeft , float theTop, float theWidth, float theHeight ); + void setRectBottom( float b); + void setRectTop( float t); + + virtual QString getText() const; + + void setPortColor(const QColor& theColor) { myColor = theColor; } + QColor portColor() const { return myColor; } + +private: + SUPERVGUI_CanvasPort* myPort; + QString myText; // or myGLText from GLViewer_Object - GLViewer_Rect* myRect; + GLViewer_Pnt* myPoint; + + QColor myColor; + //bool myVisible; }; #endif diff --git a/src/SUPERVGUI/SUPERVGUI_Service.cxx b/src/SUPERVGUI/SUPERVGUI_Service.cxx index 3afcebb..ccb9275 100644 --- a/src/SUPERVGUI/SUPERVGUI_Service.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Service.cxx @@ -471,7 +471,7 @@ void SUPERVGUI_Service::addFactoryNode() { } } else { // Factory Node - aNode = aMain->getDataflow()->FNode(component, interface, *myService); + aNode = aMain->getDataflow()->FNode(component, interface, *myService, myComponent->implementation_type()); // mkr : PAL11273 if ( CORBA::is_nil( aNode ) ) { QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; @@ -519,6 +519,12 @@ void SUPERVGUI_Service::addInlineNode() { return; } SUPERV::INode_var aDummyEndNode; + // here we have to + // 1) parse nodes' python function to find ports names + // 2) create ports for engine node with found names and "undefined" types + // ( aNode->InPort(name,type), aNode->OutPort(name,type) ) + // P.S. CanvasNode->createPort(...) for create presentation of port + // will be called from addNode(...) (inside CanvasNode constructor) addNode( aNode, aDummyEndNode, myX, myY ); } break;