]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
*** empty log message ***
authormkr <mkr@opencascade.com>
Wed, 11 Jan 2006 07:52:43 +0000 (07:52 +0000)
committermkr <mkr@opencascade.com>
Wed, 11 Jan 2006 07:52:43 +0000 (07:52 +0000)
src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx
src/SUPERVGUI/SUPERVGUI_Main.cxx
src/SUPERVGUI/SUPERVGUI_PrsNode.cxx
src/SUPERVGUI/SUPERVGUI_PrsNode.h

index 66bf49ba35e653b345c7e5f1d360c0c3d89f450c..f4570072f8f67492089a3a0f64ce9156bf3fb62f 100644 (file)
@@ -105,6 +105,14 @@ SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasNode::getPrs()
 
 SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasNode::createPrs() const
 {
+  //
+  //SUPERVGUI_PrsNode* glNode = new SUPERVGUI_PrsNode( (SUPERVGUI_CanvasNode*)this );
+  //glNode->setFirstPoint( new GLViewer_Pnt( 10, 10 ) );
+  //glNode->compute();
+  //glNode->update();
+  //getGLContext()->insertObject( glNode, true /*false*/ );
+  //
+  
   return new SUPERVGUI_CanvasNodePrs( myMgr, myMain->getCanvas(), (SUPERVGUI_CanvasNode*)this);
 }
 
index b943162b404ff6141188a3b85f2b11c6f9aad80c..ca8f88021a37b4b9113010cfb2a88dbc5641008f 100644 (file)
@@ -700,11 +700,11 @@ void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
       myCanvas->update();
 
 
-      SUPERVGUI_PrsNode* glNode = new SUPERVGUI_PrsNode();
+      SUPERVGUI_PrsNode* glNode = new SUPERVGUI_PrsNode( aNode );
       glNode->setFirstPoint( new GLViewer_Pnt( 10, 10 ) );
       glNode->compute();
       glNode->update();
-      getGLContext()->insertObject( glNode, false );
+      getGLContext()->insertObject( glNode, true /*false*/ );
       //      glNode->setVisible( true );
     }
     break;
index b1ae9b9af85471cab90f7a61d2af9ab612e9fd5c..b47ab929e23d9309ca6d6b826c811d9a14667ac1 100644 (file)
 
 #include <gp_XY.hxx>
 
+#define PORT_MARGIN 2
+
 //=======================================================================
 // name    : SUPERVGUI_PrsNode
 // Purpose : Constructor
 //=======================================================================
-SUPERVGUI_PrsNode::SUPERVGUI_PrsNode() :
-  SUPERVGUI_Prs()
+SUPERVGUI_PrsNode::SUPERVGUI_PrsNode( SUPERVGUI_CanvasNode* theNode ) :
+  SUPERVGUI_Prs(),
+  myNode(theNode)
 {
   myType = "SUPERVGUI_PrsNode";
   
   setScalable( true );
 
-  myWidth = INST_WIDTH;
-  myHeight = INST_HEIGHT;
+  //myWidth = INST_WIDTH;
+  myWidth = LABEL_WIDTH;
+  if (2*(PORT_WIDTH+PORT_MARGIN) > myWidth)
+    myWidth = 2*(PORT_WIDTH+PORT_MARGIN);
+
+  myTitleHeight = LABEL_HEIGHT;
+  myLabelHeight = LABEL_HEIGHT;
+  myStatusHeight = LABEL_HEIGHT;
+  myPortHeight = 2*PORT_MARGIN;
+  myStreamHeight = 0;
+  myGateHeight = PORT_HEIGHT + 2*PORT_MARGIN;
+
+  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
 
   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());
+  
+  //updatePorts(); // method for ports' presentations creation
 }
 
 //=======================================================================
@@ -41,7 +64,7 @@ SUPERVGUI_PrsNode::SUPERVGUI_PrsNode() :
 //=======================================================================
 SUPERVGUI_PrsNode::~SUPERVGUI_PrsNode()
 {
-  mySteamPorts.clear();
+  myPorts.clear();
   myConnections.clear();
 }
 
@@ -70,7 +93,7 @@ void SUPERVGUI_PrsNode::clear()
 {
   SUPERVGUI_Prs::clear();
   
-  mySteamPorts.clear();
+  myPorts.clear();
   myConnections.clear();
 }
 
@@ -188,37 +211,48 @@ GLboolean SUPERVGUI_PrsNode::unselect()
 }
 
 //================================================================
-// Function : getStreamPort
+// Function : getPort
 // Purpose  : 
 //================================================================
-SUPERVGUI_PrsPort* SUPERVGUI_PrsNode::getStreamPort( const int type ) const
+SUPERVGUI_PrsPort* SUPERVGUI_PrsNode::getPort( const int type ) const
 {
   SUPERVGUI_PrsPort* port = 0;
-  if ( mySteamPorts.contains( type ) )
-    port = mySteamPorts[ type ];
+  //  if ( myPorts.contains( type ) )
+  //    port = myPorts[ type ];
   return port;
 }
 
 //================================================================
-// Function : addStreamPort
+// Function : addPort
 // Purpose  : 
 //================================================================
-void SUPERVGUI_PrsNode::addStreamPort( const int type, SUPERVGUI_PrsPort* newPort )
+void SUPERVGUI_PrsNode::addPort( /*const int type, */SUPERVGUI_PrsPort* newPort )
+{
+  //SUPERVGUI_PrsPort* port = getPort( type );
+  //if ( port ) // should not be
+  //  delete port; 
+  //myPorts[ type ] = newPort;
+  if ( !myPorts.contains( newPort ) )
+    myPorts.append( newPort );
+}
+
+//================================================================
+// Function : removePort
+// Purpose  : returns the number of removed items
+//================================================================
+int SUPERVGUI_PrsNode::removePort( SUPERVGUI_PrsPort* newPort )
 {
-  SUPERVGUI_PrsPort* port = getStreamPort( type );
-  if ( port ) // should not be
-    delete port; 
-  mySteamPorts[ type ] = newPort;
+  return myPorts.remove( newPort );
 }
 
 //================================================================
 // Function : addConnection
-// Purpose  : 
+// Purpose  :
 //================================================================
 void SUPERVGUI_PrsNode::addConnection( const int type, SUPERVGUI_PrsPort* otherPort )
 {
   if ( !myConnections.contains( type ) ) {
-    StreamPortList list;
+    PortList list;
     myConnections.insert( type, list );
   }
   myConnections[ type ].append( otherPort );
@@ -254,6 +288,75 @@ GLuint SUPERVGUI_PrsNode::getIcon() const
   return myIcon;
 }
 
+//================================================================
+// Function : setState
+// Purpose  : 
+//================================================================
+void SUPERVGUI_PrsNode::setState(SUPERV::GraphState theState)
+{
+  switch(theState) {
+  case SUPERV_Waiting:
+    myStatus = "Waiting";
+    myStatusColor = QColor(35, 192, 255);
+    break;
+
+  case SUPERV_Running:
+  case SUPERV::ReadyState:
+    myStatus = "Running";
+    myStatusColor = QColor(32,210,32);
+    break;
+
+  case SUPERV_Suspend:
+  case SUPERV::SuspendReadyState:
+    myStatus = "Suspended";
+    myStatusColor = QColor(255,180, 0);
+    break;
+
+  case SUPERV_Done:
+    myStatus = "Finished";
+    myStatusColor = QColor(255, 158, 255);
+    break;
+
+  case SUPERV_Error: 
+    myStatus = "Aborted";
+    myStatusColor = red;
+    break;
+
+  case SUPERV_Kill:
+    myStatus = "Killed";
+    myStatusColor = red;
+    break;
+
+  case SUPERV::LoadingState:
+    myStatus = "Loading";
+    myStatusColor = QColor(56,255,56);
+    break;
+
+  default:
+    myStatus = "No Status";
+    myStatusColor = myColor;
+    break;
+  }
+
+  long sec = myNode->getEngine()->CpuUsed();
+  char hms[9];
+  long s = sec/3600;
+  hms[0]=(char)(((s/10)%10)+48);
+  hms[1]=(char)((s%10)+48);
+  hms[2]=':';
+  sec = sec%3600;
+  s = sec/60;
+  hms[3]=(char)((s/10)+48);
+  hms[4]=(char)((s%10)+48);
+  hms[5]=':';
+  sec = sec%60;
+  hms[6]=(char)((sec/10)+48);
+  hms[7]=(char)((sec%10)+48);
+  hms[8]='\0';
+  myTime = QString(hms);
+}
+
+
 /*
   Class       : SUPERVGUI_PrsNodeDrawer
   Description : Drawer for SUPERVGUI_PrsNode
@@ -339,15 +442,17 @@ void SUPERVGUI_PrsNodeDrawer::create( float xScale, float yScale, bool /*onlyUpd
     
     StreamPointsMap streamPoints = object->getStreamPoints();
     StreamPointsMap::iterator it = streamPoints.begin();
-    for ( ; it != streamPoints.end(); ++it ) {
-      GLViewer_Pnt* firstPoint = *it;
-      int type = it.key();
+    cout<<"We going to draw stream points . . ."<<endl;
+    //for ( ; it != streamPoints.end(); ++it ) {
+      cout<<"..stream point"<<endl;
+      GLViewer_Pnt* firstPoint = new GLViewer_Pnt( rect->left(), rect->top() );//*it;
+      int type = 1;//it.key();
       
       QString strType = "COSAC_ConnectionType";
       
       object->updateStreamPoint( firstPoint, type );
       // update rect of connection stream port
-      SUPERVGUI_PrsPort* objPort = object->getStreamPort( type );
+      SUPERVGUI_PrsPort* objPort = object->getPort( type );
       if ( objPort )
         objPort->updateRect( objXScale, objYScale );
 
@@ -364,6 +469,15 @@ 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 ) {
+       
+       
+      }
   }
 }
index 52d7be129389bbfaadff5356217d2e4f492edf85..20281e71ceea76cb44fb0931c891883b06d740e3 100644 (file)
@@ -9,11 +9,15 @@
 #ifndef SUPERVGUI_PrsNode_H
 #define SUPERVGUI_PrsNode_H
 
+#include "SUPERVGUI_Def.h"
 #include "SUPERVGUI_Prs.h"
 #include "SUPERVGUI_PrsPort.h"
+#include "SUPERVGUI_CanvasNode.h"
 
-class gp_XY;
-//class LineConn2d_Model;
+// connection data
+//typedef QMap<int, SUPERVGUI_PrsPort*>  PortMap;
+typedef QValueList<SUPERVGUI_PrsPort*> PortList;
+typedef QMap<int, PortList>      PortConnectionMap;
 
 /*
   Class       : SUPERVGUI_PrsNodeDrawer
@@ -39,7 +43,7 @@ class SUPERVGUI_PrsNode : public SUPERVGUI_Prs
   Q_OBJECT
 
 public:
-  SUPERVGUI_PrsNode();
+  SUPERVGUI_PrsNode( SUPERVGUI_CanvasNode* theNode );
   virtual ~SUPERVGUI_PrsNode();
 
 public:
@@ -66,14 +70,20 @@ public:
   GLuint                   getIcon() const;
   
   // connection data
-  SUPERVGUI_PrsPort*       getStreamPort( const int ) const;
-  void                     addStreamPort( const int, SUPERVGUI_PrsPort* );
+  SUPERVGUI_PrsPort*       getPort( const int ) const; // don't use
+  //void                     addPort( const int, SUPERVGUI_PrsPort* );
+  void                     addPort( SUPERVGUI_PrsPort* );
+  int                      removePort( SUPERVGUI_PrsPort* newPort );
+
   void                     addConnection( const int, SUPERVGUI_PrsPort* );
   void                     removeConnectons();
   
+  PortList                 getPorts() const { return myPorts; }
   QValueList<SUPERVGUI_PrsPort*>
                            getConnections( const int ) const;
 
+   virtual void            setState(SUPERV::GraphState theState);
+
 private:
   float                    myWidth;
   float                    myHeight;
@@ -82,13 +92,25 @@ private:
 
   GLint                    mySelElement;
 
-  // connection data
-  typedef QMap<int, SUPERVGUI_PrsPort*>  StreamPortMap;
-  typedef QValueList<SUPERVGUI_PrsPort*> StreamPortList;
-  typedef QMap<int, StreamPortList>      StreamPortConnectionMap;
+  //PortMap            myPorts;
+  PortList             myPorts;
+  PortConnectionMap    myConnections;
+
+  int myTitleHeight;
+  int myLabelHeight;
+  int myStatusHeight;
+  int myPortHeight;
+  int myStreamHeight; //???
+  int myGateHeight;
+
+  QString myStatus;
+  QString myTime;
+
+  QColor myColor;
+  QColor myStatusColor;
+
+  SUPERVGUI_CanvasNode* myNode;
 
-  StreamPortMap            mySteamPorts;
-  StreamPortConnectionMap  myConnections;
 };
 
 #endif