From b41c1a22cb8d6274d6cbcc07ce875d5bcf8f6cfe Mon Sep 17 00:00:00 2001 From: mkr Date: Wed, 11 Jan 2006 07:52:43 +0000 Subject: [PATCH] *** empty log message *** --- src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx | 8 ++ src/SUPERVGUI/SUPERVGUI_Main.cxx | 4 +- src/SUPERVGUI/SUPERVGUI_PrsNode.cxx | 160 +++++++++++++++++++++---- src/SUPERVGUI/SUPERVGUI_PrsNode.h | 44 +++++-- 4 files changed, 180 insertions(+), 36 deletions(-) diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx index 66bf49b..f457007 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx @@ -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); } diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index b943162..ca8f880 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -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; diff --git a/src/SUPERVGUI/SUPERVGUI_PrsNode.cxx b/src/SUPERVGUI/SUPERVGUI_PrsNode.cxx index b1ae9b9..b47ab92 100644 --- a/src/SUPERVGUI/SUPERVGUI_PrsNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_PrsNode.cxx @@ -15,24 +15,47 @@ #include +#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 . . ."<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 . . ."< PortMap; +typedef QValueList PortList; +typedef QMap 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 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 StreamPortMap; - typedef QValueList StreamPortList; - typedef QMap 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 -- 2.39.2