#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
}
//=======================================================================
//=======================================================================
SUPERVGUI_PrsNode::~SUPERVGUI_PrsNode()
{
- mySteamPorts.clear();
+ myPorts.clear();
myConnections.clear();
}
{
SUPERVGUI_Prs::clear();
- mySteamPorts.clear();
+ myPorts.clear();
myConnections.clear();
}
}
//================================================================
-// 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 );
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
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 );
// 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 ) {
+
+
+ }
}
}
#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
Q_OBJECT
public:
- SUPERVGUI_PrsNode();
+ SUPERVGUI_PrsNode( SUPERVGUI_CanvasNode* theNode );
virtual ~SUPERVGUI_PrsNode();
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;
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