]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
1) Fix for bug PAL8060 : Supervisor: Edit ports - existing links are deleted.
authormkr <mkr@opencascade.com>
Fri, 20 Jan 2006 07:38:06 +0000 (07:38 +0000)
committermkr <mkr@opencascade.com>
Fri, 20 Jan 2006 07:38:06 +0000 (07:38 +0000)
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).

22 files changed:
src/SUPERVGUI/SUPERVGUI_ArrayView.cxx
src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx
src/SUPERVGUI/SUPERVGUI_CanvasLink.h
src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx
src/SUPERVGUI/SUPERVGUI_CanvasNode.h
src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx
src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx
src/SUPERVGUI/SUPERVGUI_CanvasPort.h
src/SUPERVGUI/SUPERVGUI_CanvasView.cxx
src/SUPERVGUI/SUPERVGUI_Clipboard.cxx
src/SUPERVGUI/SUPERVGUI_Def.h
src/SUPERVGUI/SUPERVGUI_Main.cxx
src/SUPERVGUI/SUPERVGUI_Main.h
src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx
src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.h
src/SUPERVGUI/SUPERVGUI_Prs.cxx
src/SUPERVGUI/SUPERVGUI_Prs.h
src/SUPERVGUI/SUPERVGUI_PrsNode.cxx
src/SUPERVGUI/SUPERVGUI_PrsNode.h
src/SUPERVGUI/SUPERVGUI_PrsPort.cxx
src/SUPERVGUI/SUPERVGUI_PrsPort.h
src/SUPERVGUI/SUPERVGUI_Service.cxx

index 08477e5477f5cf04eed7ef11b2bf72a2c168c4d1..1778cbd749708219f977a61870530f324db6dcac 100644 (file)
@@ -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 <qcolordialog.h>
 
@@ -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;
     }
   }
 }
index 955d3b89698ce8f31daf577d3e557866e4610c7a..e1139143303ea9b5d2ae18a04009df2284801bb1 100644 (file)
@@ -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
index 3865950d8cf953d8cf54e37b7dd40f3588334239..a9e13f3ad9a2a5774dede56dcecccba89aa9d28f 100644 (file)
@@ -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();
index f4570072f8f67492089a3a0f64ce9156bf3fb62f..e43ebd9df4ec604efedb69ea02a8fa9c579dbe15 100644 (file)
@@ -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();
+}
index 0be086ddd806ba398cf1cf975615d046ce000ca5..4d7dbde0c8ae4ece7c05035ba979dbb343038b96 100644 (file)
@@ -72,6 +72,8 @@ class SUPERVGUI_CanvasNode : public QObject {
 
     QString getLabelText() const { return myLabelText; }
 
+    virtual QString getToolTipText() const;
+
   public slots:
     void suspendResume();
     void kill();
index 75bd1b8b5be4509d4ce2dc97517ab5f83c8c9871..2849254d87ae8887625607de1163be3d8cbf5f3d 100644 (file)
@@ -21,7 +21,7 @@ using namespace std;
 #include <sys/timeb.h>
 #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
index 8274ca96bc9b49a57c437f9c0e7e68e8bf3768d8..87017596b0ccee37b0e6309f079b411c76dca987 100644 (file)
@@ -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<SUPERVGUI_CanvasLink*>::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);
index 0d964ed9b9fadfcf3d347c54339b9641e7cf8b3f..4a96984bdba3ff5c0db14951b06379273be315f0 100644 (file)
@@ -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<SUPERVGUI_CanvasLink*> myLinks;
     bool isIgnore;
 };
index c33671658d7ee0419d38d0ac5c85d2243ea95aca..66f622aa6f5ae9915bb107dcc3967408c96cf5e5 100644 (file)
@@ -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 <qpixmap.h>
@@ -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;
 }
 
index fab39c44289777637a3fc794a7e9b8a44e536d08..bffc222096e147401b5174202b2c4836febde40b 100644 (file)
@@ -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;
index 1abc0b8ffaf8389f36d05fc38cd3bd015c32af6b..a78b457d811cb4270a5cfaeb4c7c1bb2d9666da7 100644 (file)
@@ -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
 // ----------------------------------------------------------------
index ed059aebc7655dd4c5d4fed1c5fdb9d582968d56..02de18aed228df605c52488932a08841a5300a98 100644 (file)
@@ -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;
   }
index 9fe4ceee6a7e1655677639af2613075df2bdfec2..bea57b4c272309cbba295be42197f90df9f9090c 100644 (file)
@@ -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<QString, SUIT_ViewWindow*> mySubGraphs;
index fb4c5573d30bbf820b4cda2f891f9e3fc019c70d..9173dcec974f66e50dce8c640f5c03bb3c742276 100644 (file)
@@ -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 <qlayout.h>
 #include <qlabel.h>
@@ -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 <NodeName, PortName> for the given port
+  QPair<QString, QString> 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<QString, QString> 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<QString, QString> InPair(QString(aLink->InPort()->Node()->Name()), QString(aLink->InPort()->Name()));
+         QPair<QString, QString> 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<QString, QString> InPair(QString(aLink->InPort()->Node()->Name()), QString(aLink->InPort()->Name()));
+           QPair<QString, QString> 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
index 345d1cb424f8b3819e5476761b41638aaa50d810..1e3506b75e07eb8f76448607134a2b19cb56adeb 100644 (file)
 #ifndef SUPERVGUI_ManagePortsDlg_H
 #define SUPERVGUI_ManagePortsDlg_H
 
+#include "SUPERVGUI.h"
+
 #include <qdialog.h>
 #include <qlistbox.h>
 #include <qstringlist.h>
 #include <qlineedit.h>
 #include <qcombobox.h>
+#include <qpair.h>
 
 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();
index 85d241e6dfac4ea71e0d3945806d2b04cfd7197c..0e17d43625d355aa7ec52d81992aa48d98d8f3dc 100644 (file)
@@ -7,6 +7,7 @@
 //  Module : SUPERV
 
 #include <SUPERVGUI_Prs.h>
+//#include <SUPERVGUI_PrsPort.h>
 
 //=======================================================================
 // 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 );
+}*/
+    
+
index 77fa60f80d3c618311aa234f8bdfd87c1bd48aae..97e364a4febc26ccb328b047f08adf1271a45048 100644 (file)
@@ -21,6 +21,8 @@
 
 typedef QMap<int,GLViewer_Pnt*> 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; }
index 98578f5dd89f09c94010f3e77f7ba8b4598a8d2b..e7b694485c1852b516d04fae7fe2fa812a207df4 100644 (file)
@@ -7,25 +7,27 @@
 //  Module : SUPERV
 
 #include <SUPERVGUI_PrsNode.h>
+#include <SUPERVGUI_CanvasPort.h>
+#include <SUPERVGUI_Main.h>
 
 #include <GLViewer_Group.h>
+#include <GLViewer_Context.h>
 
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_Session.h>
 
-#include <gp_XY.hxx>
-
-#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 = "<<myPortHeight<<endl;
+  // input/output ports creation
+  if (list) {
+    QObjectListIt it(*list);
+    SUPERVGUI_CanvasPort* aPort;
+    while (QObject* obj = it.current()) {
+      ++it;
+      if (obj->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 = "<<myPortHeight<<endl;
+
+  // stream ports creation
+  float sy = myFirstPoint->y() + myPortHeight;
+  cout<<"1 : sy = "<<sy<<endl;
+  ih = sy + PORT_MARGIN;
+  oh = sy + PORT_MARGIN;
+
+  if (list) {
+    QObjectListIt it(*list);
+    SUPERVGUI_CanvasPort* aPort;
+    while (QObject* obj = it.current()) {
+      ++it;
+      if (obj->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 = "<<myStreamHeight<<endl;
+  myStreamHeight = ( ih>oh ? ih : oh ) - sy + PORT_MARGIN;
+  if (myStreamHeight == 2*PORT_MARGIN) myStreamHeight = 0;
+  cout<<"4 : myStreamHeight = "<<myStreamHeight<<endl;
+
+  // gate ports creation
+  sy = myFirstPoint->y() + myPortHeight + myStreamHeight;
+  cout<<"2 : sy = "<<sy<<endl;
+  ih = sy + PORT_MARGIN;
+  oh = sy + PORT_MARGIN;
+
+  if (list) {
+    QObjectListIt it(*list);
+    SUPERVGUI_CanvasPort* aPort;
+    while (QObject* obj = it.current()) {
+      ++it;
+      if (obj->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 = "<<myGateHeight<<endl;
+  myGateHeight = ( ih>oh ? ih : oh ) - sy + PORT_MARGIN;
+  cout<<"6 : myGateHeight = "<<myGateHeight<<endl;
+
+  // shift ports
+  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->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<GLViewer_Object*>::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 . . ."<<endl;
     //for ( ; it != streamPoints.end(); ++it ) {
@@ -466,14 +750,23 @@ void SUPERVGUI_PrsNodeDrawer::create( float xScale, float yScale, bool /*onlyUpd
       // remove temporary created point
       delete textPnt;
       //}
+      */
 
       // draw ports of the node
-      PortList Ports = object->getPorts();
-      PortList::iterator itP = Ports.begin();
-      cout<<"We going to draw ports . . ."<<endl;
-      for ( ; itP != Ports.end(); ++itP ) {
-       
-       
-      }
+      //PortList Ports = object->getPorts();
+      //PortList::iterator itP = Ports.begin();
+      //cout<<"We going to draw ports . . ."<<endl;
+      //for ( ; itP != Ports.end(); ++itP ) {
+      //}
+
+      /*const QObjectList* list = object->getNode()->children();
+      if (list) {
+       QObjectListIt it(*list);
+       while (QObject* obj = it.current()) {
+         ++it;
+         if (obj->inherits("SUPERVGUI_CanvasPort"))
+           drawPort( ((SUPERVGUI_CanvasPort*)obj)->getGLPrs());
+       }
+       }*/
   }
 }
index 20281e71ceea76cb44fb0931c891883b06d740e3..d3ad91db09d6470fe3cd42b2e516771a1419f270 100644 (file)
@@ -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<SUPERVGUI_PrsPort*>
                            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;
 
 };
index fac1ed003d1b6358703e4d2052983ad58aa66dfb..28425617ff8edb8be123f270e9b110f792928345 100644 (file)
@@ -8,17 +8,28 @@
 
 #include "SUPERVGUI_PrsPort.h"
 
+#include <GLViewer_Group.h>
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
 //=======================================================================
 // 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<GLViewer_Object*>::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 );
+}
index 342e0f28b01e642815162d3879866f413cd6dc24..7d8408414b3fa0229e4475ea16928c95ff543d61 100644 (file)
 #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
index 3afcebbf2ff55fe2c6be16c0feac03eb04271a4e..ccb9275cbae71aff65fd8c56e37ad6a8a31f314d 100644 (file)
@@ -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;