SUPERVGUI_Notification.cxx \
SUPERVGUI_ManagePortsDlg.cxx \
SUPERVGUI_Library.cxx \
- SUPERVGUI_Clipboard.cxx \
- SUPERVGUI_Prs.cxx \
- SUPERVGUI_PrsNode.cxx \
- SUPERVGUI_PrsPort.cxx
+ SUPERVGUI_Clipboard.cxx
LIB_MOC = SUPERVGUI.h \
SUPERVGUI_ArrayView.h \
SUPERVGUI_Notification.h \
SUPERVGUI_ManagePortsDlg.h \
SUPERVGUI_Library.h \
- SUPERVGUI_Clipboard.h \
- SUPERVGUI_Prs.h \
- SUPERVGUI_PrsNode.h \
- SUPERVGUI_PrsPort.h
-
+ SUPERVGUI_Clipboard.h
LIB_CLIENT_IDL = SALOMEDS.idl \
SALOMEDS_Attributes.idl \
#include <boost/shared_ptr.hpp>
using namespace boost;
-#include "GLViewer_ViewManager.h"
-
#include "CAM_Application.h"
#include "OB_Browser.h"
#include "OB_ListItem.h"
this,
SLOT( onGraphClosed( SUIT_ViewWindow* ) ) );
}
-
- // create GLViewer view manager
- GLViewer_ViewManager* glVM = new GLViewer_ViewManager( study, application()->desktop() );
- getApp()->addViewManager( glVM );
- glVM->createViewWindow();
-
return aVW;
}
#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");
{
Trace("SUPERVGUI_CanvasPort::~SUPERVGUI_CanvasPort");
if (myPrs) delete myPrs;
- if (myGLPrs) delete myGLPrs;
isIgnore = true;
QValueList<SUPERVGUI_CanvasLink*>::Iterator it;
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);
class SUPERVGUI_Main;
class SUPERVGUI_CanvasLink;
class SUPERVGUI_CanvasPortPrs;
-class SUPERVGUI_PrsPort;
class SUPERVGUI_CanvasPort : public QObject {
Q_OBJECT
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);
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;
};
#include "SUIT_Study.h"
#include "QtxDblSpinBox.h"
-#include "GLViewer_Viewer2d.h"
-#include "GLViewer_Context.h"
-#include "GLViewer_BaseObjects.h"
-#include "GLViewer_Group.h"
-
#include "SUPERVGUI.h"
#include "SUPERVGUI_Def.h"
#include "SUPERVGUI_Main.h"
#include "SUPERVGUI_Information.h"
#include "SUPERVGUI_CanvasControlNode.h"
#include "SUPERVGUI_CanvasPort.h"
-#include "SUPERVGUI_PrsNode.h"
#include <qvalidator.h>
#include <qlabel.h>
if (myCurrentView == CONTROLFLOW) aNode->hideAll();
aNode->show();
myCanvas->update();
-
-
- // SUPERVGUI_Node* aNode = new SUPERVGUI_ComputeNode( resMgr(), getGLViewer(), this, theNode);
-
- 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;
}
getCanvasArray()->resize( theEvent->size().width(), theEvent->size().height() );
}
-
-GLViewer_Viewer2d* SUPERVGUI_Main::getGLViewer()
-{
- if ( study )
- if ( STD_Application* app = dynamic_cast<STD_Application*>( study->application() ) )
- if ( SUIT_ViewManager* vm = app->viewManager( GLViewer_Viewer::Type() ) )
- return dynamic_cast<GLViewer_Viewer2d*>( vm->getViewModel() );
- return 0;
-}
-
-GLViewer_Context* SUPERVGUI_Main::getGLContext()
-{
- if ( GLViewer_Viewer2d* v2d = getGLViewer() )
- return v2d->getGLContext();
- return 0;
-}
-
-
/******************************* SUPERVGUI_Thread class ****************************************/
SUPERVGUI_Thread::SUPERVGUI_Thread()
:QThread()
class QComboBox;
class NOTIFICATION_Consumer;
class SUPERVGUI_Thread;
-class GLViewer_Viewer2d;
-class GLViewer_Context;
class SUPERVGUI_Main: public SUPERVGraph_View {
Q_OBJECT
virtual void resizeView( QResizeEvent* theEvent );
- GLViewer_Context* getGLContext();
-
signals:
void KillMyThread(bool theValue);
bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp);
void closeEvent(QCloseEvent*);
- GLViewer_Viewer2d* getGLViewer();
-
SUPERV_Graph dataflow;
QMap<QString, SUIT_ViewWindow*> mySubGraphs;
+++ /dev/null
-// SUPERV SUPERVGUI : GUI for Supervisor component
-//
-// Copyright (C) 2003 OPEN CASCADE
-//
-// File : SUPERVGUI_Prs.cxx
-// Author : Alexander SLADKOV
-// Module : SUPERV
-
-#include <SUPERVGUI_Prs.h>
-//#include <SUPERVGUI_PrsPort.h>
-
-//=======================================================================
-// name : SUPERVGUI_Prs
-// Purpose : Constructor
-//=======================================================================
-SUPERVGUI_Prs::SUPERVGUI_Prs()
-: GLViewer_Object(),
- myFirstPoint( 0 ),
- myLastPoint( 0 ),
- myIsToUpdate( false ),
- myIsInversed( false ),
- myIsScalable( true ),
- myIsSelectable( true ),
- myIsMoving( 0 )
-{
- myFirstPoint = new GLViewer_Pnt();
- myLastPoint = new GLViewer_Pnt();
-
- myIsInitial = true;
-
- myHighElement = -1;
- mySelElement = -1;
-
- myHighFlag = GL_TRUE;
-
- isToolTipHTML = true;
-}
-
-//=======================================================================
-// name : SUPERVGUI_Prs
-// Purpose : Destructor
-//=======================================================================
-SUPERVGUI_Prs::~SUPERVGUI_Prs()
-{
- if ( myFirstPoint )
- delete myFirstPoint;
- myFirstPoint = 0;
-
- if ( myLastPoint )
- delete myLastPoint;
- myLastPoint = 0;
-}
-
-//================================================================
-// Function : clear
-// Purpose : empty implementation. for clear() might not be needed
-// for some presentations
-//================================================================
-void SUPERVGUI_Prs::clear()
-{
- StreamPointsMap::iterator it = myStreamPoints.begin();
- for ( ; it != myStreamPoints.end(); ++it )
- delete (*it);
-
- myStreamPoints.clear();
-}
-
-//=======================================================================
-// name : setFirstPoint
-// Purpose :
-//=======================================================================
-void SUPERVGUI_Prs::setFirstPoint( GLViewer_Pnt* pnt )
-{
- // free previous used memory
- if ( myFirstPoint )
- delete myFirstPoint;
- myFirstPoint = pnt;
-}
-
-//================================================================
-// Function : getStreamPoint
-// Purpose :
-//================================================================
-GLViewer_Pnt* SUPERVGUI_Prs::getStreamPoint( int type ) const
-{
- GLViewer_Pnt* aRes = 0;
-
- if( myStreamPoints.contains( type ) )
- aRes = myStreamPoints[ type ];
-
- return aRes;
-}
-
-//================================================================
-// Function : finishMove
-// Purpose :
-//================================================================
-bool SUPERVGUI_Prs::finishMove()
-{
- if ( /*myObject.IsNull() || !myObject->IsAlive() || */!myFirstPoint )
- return false;
-
- // Handle(COSACData_Installation) anObject = Handle(COSACData_Installation)::DownCast( myObject );
- // if ( !anObject.IsNull() )
- // anObject->SetCoords( myFirstPoint->x(), myFirstPoint->y() );
-
- myIsMoving = false;
- emit moveFinished( true );
- return true;
-}
-
-//================================================================
-// Function : setInversed
-// Purpose :
-//================================================================
-void SUPERVGUI_Prs::setInversed( bool on )
-{ myIsInversed = on; }
-
-
-//================================================================
-// Function : getToolTipText
-// Purpose : redefined
-//================================================================
-QString SUPERVGUI_Prs::getToolTipText()
-{
- QString text;
-// if ( myObject.IsNull() || !myObject->IsAlive() )
-// return text;
-// text = tr( "PRS_NAME" ).arg( SUPERVGUI_Tool::ToQString( myObject->GetName() ) );
-// QStringList commentList = SUPERVGUI_Tool::ToStringList( myObject->GetComments() );
-// if ( !commentList.isEmpty() )
-// {
-// QString sep( "\n" );
-// text += sep;
-// text += tr( "PRS_COMMENT" ).arg( commentList.join( sep ) );
-// }
- return text;
-}
-
-//=======================================================================
-// name : SUPERVGUI_PrsDrawer
-// Purpose : Constructor
-//=======================================================================
-GLubyte rasterCross[7] = { 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82 };
-GLubyte rasterVertex[5] = { 0x70, 0xf8, 0xf8, 0xf8, 0x70 };
-
-SUPERVGUI_PrsDrawer::SUPERVGUI_PrsDrawer()
-:GLViewer_Drawer()
-{
- glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
- myNColor = Qt::black;
- myHColor = Qt::cyan;
- mySColor = Qt::yellow;
- myPrimingColor = QColor( 240, 240, 240 );
-
- myLineWidth = 1.5;
- myThinLineWidth = 1.0;
-
- myScalarPointRadius = 2.0;
- myVectorPointLength = 8.0;
-
- myStippleColor = Qt::black;
- myStippleWidth = 1.0;
- myStippleHPattern = 0x8888;
- myStippleSPattern = 0xF0F0;
- setAntialiasing( true );
-}
-
-//=======================================================================
-// name : SUPERVGUI_PrsDrawer
-// Purpose : Destructor
-//=======================================================================
-SUPERVGUI_PrsDrawer::~SUPERVGUI_PrsDrawer()
-{
-}
-
-void SUPERVGUI_PrsDrawer::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 );
-}
-
-void SUPERVGUI_PrsDrawer::drawPort( GLViewer_Pnt* pnt, GLfloat d, const QString& label )
-{
- drawPort( pnt, d, label, 0 );
-}
-
-void SUPERVGUI_PrsDrawer::drawPort( GLViewer_Pnt* pnt, GLfloat d,
- const QString& label, GLViewer_Pnt* textPnt )
-{
- if( !pnt )
- return;
-
- GLfloat x = pnt->x();
- GLfloat y = pnt->y();
-
- glColor3f( ( GLfloat )myPrimingColor.red() / 255,
- ( GLfloat )myPrimingColor.green() / 255,
- ( GLfloat )myPrimingColor.blue() / 255 );
- glBegin( GL_POLYGON );
- glVertex2f( x - d, y - d );
- glVertex2f( x - d, y + d );
- glVertex2f( x + d, y + d );
- glVertex2f( x + d, y - d );
- glEnd();
-
- glColor3f( ( GLfloat )myNColor.red() / 255,
- ( GLfloat )myNColor.green() / 255,
- ( GLfloat )myNColor.blue() / 255 );
- glLineWidth( myLineWidth );
- glBegin( GL_LINE_LOOP );
- glVertex2f( x - d, y - d );
- glVertex2f( x - d, y + d );
- glVertex2f( x + d, y + d );
- glVertex2f( x + d, y - d );
- glEnd();
-
- GLfloat textX = ( textPnt ? textPnt->x() : x + 10 / myXScale );
- GLfloat textY = ( textPnt ? textPnt->y() : y );
-
- drawGLText( label, textX , textY, GLText_Center, GLText_Center );
- //QFont aTmpFont( "Arial", 10, QFont::Bold );
- //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 );
-}*/
-
-
+++ /dev/null
-// SUPERV SUPERVGUI : GUI for Supervisor component
-//
-// Copyright (C) 2003 OPEN CASCADE
-//
-// File : SUPERVGUI_Prs.h
-// Author : Alexander SLADKOV
-// Module : SUPERV
-
-#ifndef SUPERVGUI_Prs_H
-#define SUPERVGUI_Prs_H
-
-#include <qobject.h>
-
-#include <GLViewer_Object.h>
-#include <GLViewer_Drawer.h>
-
-#define SP_GAP 15
-
-#define INST_WIDTH 100
-#define INST_HEIGHT 100
-
-typedef QMap<int,GLViewer_Pnt*> StreamPointsMap;
-
-//class SUPERVGUI_PrsPort;
-
-/*
- Class : SUPERVGUI_Prs
- Description : Base class for GLViewer presenataions of Nodes
-*/
-class SUPERVGUI_Prs : public QObject, public GLViewer_Object
-{
- Q_OBJECT
-
-public:
- SUPERVGUI_Prs();
- virtual ~SUPERVGUI_Prs();
-
-public:
- virtual void compute() = 0;
- virtual void update() = 0;
- virtual void clear();
-
- virtual GLViewer_Drawer* createDrawer() = 0;
-
- virtual GLViewer_Rect* getUpdateRect() { return new GLViewer_Rect( *myRect ); }
-
- virtual void moveObject( float, float, bool = false ) { myIsMoving = true; }
- virtual bool finishMove();
- bool isMoving() const { return myIsMoving; }
-
-
- virtual bool isScalable() const { return myIsScalable; }
- void setScalable( bool on ) { myIsScalable = on; }
-
- virtual bool isSelectable() const { return myIsSelectable; }
- void setSelectable( bool on ) { myIsSelectable = on; }
-
- void setInversed( bool on );
- bool isInversed() const { return myIsInversed; }
-
- virtual GLboolean highlight( GLfloat x, GLfloat y, GLfloat tol = 15.0, GLboolean isCircle = GL_FALSE ) { return GL_FALSE; }
- virtual GLboolean unhighlight() { return GL_FALSE; }
- virtual GLboolean select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull = GL_FALSE,
- GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE ) { return GL_FALSE; }
- virtual GLboolean unselect() { return GL_FALSE; }
-
- virtual GLViewer_Object* getOwner() { return this; }
-
- GLViewer_Pnt* getStreamPoint( int type ) const;
- StreamPointsMap getStreamPoints() const { return myStreamPoints; }
-
- GLViewer_Pnt* getFirstPoint() const { return myFirstPoint; }
- GLViewer_Pnt* getLastPoint() const { return myLastPoint; }
- void setFirstPoint( GLViewer_Pnt* pnt );
-
- bool isInitial() const { return myIsInitial; }
- void setInitial( bool b ) { myIsInitial = b; }
-
- bool isToUpdate() const { return myIsToUpdate; }
- void setIsToUpdate( bool b ) { myIsToUpdate = b; }
-
- int getMode() const { return myMode; }
- void setMode( int mode ) { myMode = mode; }
-
- GLint getHighElement() const { return myHighElement; }
- GLint getSelElement() const { return mySelElement; }
-
- 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; }
-
-#ifdef WIN32
- virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) { return true; }
-#endif
-
- //! Returns object tool tip text
- virtual QString getToolTipText();
-
-signals:
- void moveFinished( const bool );
-
-protected:
- StreamPointsMap myStreamPoints;
-
- GLViewer_Pnt* myFirstPoint;
- GLViewer_Pnt* myLastPoint;
-
- bool myIsInitial;
- bool myIsToUpdate;
- bool myIsInversed;
-
- int myMode;
- GLint myHighElement;
- GLint mySelElement;
-
- GLboolean myHighFlag;
-
- bool myIsScalable;
- bool myIsSelectable;
-private:
- bool myIsMoving;
-};
-
-typedef QValueList<SUPERVGUI_Prs*> SUPERVGUI_PrsList;
-typedef QValueList<GLViewer_Pnt*> SUPERVGUI_PntList;
-
-typedef QMap<int,SUPERVGUI_Prs*> SUPERVGUI_PrsMap;
-typedef QMap<int,SUPERVGUI_PrsMap> SUPERVGUI_PortMap;
-typedef QValueList<SUPERVGUI_PortMap> SUPERVGUI_PortMapList;
-
-
-/*
- Class : SUPERVGUI_PrsDrawer
- Description : Drawer for SUPERVGUI_Prs
-*/
-class SUPERVGUI_PrsDrawer : public GLViewer_Drawer
-{
-public:
- SUPERVGUI_PrsDrawer();
- virtual ~SUPERVGUI_PrsDrawer();
-
-public:
- virtual void create( float, float, bool ) = 0;
-
-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; }
- void setSColor( const QColor& color ) { mySColor = color; }
- void setPrimingColor( const QColor& color ) { myPrimingColor = color; }
- QColor getNColor() const { return myNColor; }
- QColor getHColor() const { return myHColor; }
- QColor getSColor() const { return mySColor; }
- QColor getPrimingColor() const { return myPrimingColor; }
-
-protected:
- QColor myNColor;
- QColor myHColor;
- QColor mySColor;
- QColor myPrimingColor;
-
- GLfloat myLineWidth;
- GLfloat myThinLineWidth;
-
- GLfloat myScalarPointRadius;
- GLfloat myVectorPointLength;
-
- QColor myStippleColor;
- GLfloat myStippleWidth;
- GLushort myStippleHPattern;
- GLushort myStippleSPattern;
-};
-
-#endif
+++ /dev/null
-// SUPERV SUPERVGUI : GUI for Supervisor component
-//
-// Copyright (C) 2003 OPEN CASCADE
-//
-// File : SUPERVGUI_PrsNode.cxx
-// Author : Alexander SLADKOV
-// 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>
-
-//#define PORT_MARGIN 2
-
-//=======================================================================
-// name : SUPERVGUI_PrsNode
-// Purpose : Constructor
-//=======================================================================
-SUPERVGUI_PrsNode::SUPERVGUI_PrsNode( SUPERVGUI_CanvasNode* theNode, GLViewer_Pnt* theFirstPnt ) :
- SUPERVGUI_Prs(),
- myNode(theNode)
-{
- myType = "SUPERVGUI_PrsNode";
- myName = myNode->getEngine()->Name();
-
- setScalable( true );
-
- //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
- // 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);
-
- setFirstPoint(theFirstPnt);
- createPorts(); // method for ports' presentations creation
-}
-
-//=======================================================================
-// name : SUPERVGUI_PrsNode
-// Purpose : Destructor
-//=======================================================================
-SUPERVGUI_PrsNode::~SUPERVGUI_PrsNode()
-{
- myPorts.clear();
- myConnections.clear();
-}
-
-void SUPERVGUI_PrsNode::compute()
-{
-}
-
-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() + getHeight() / myYScale;
-
- myRect->setLeft( x1 );
- myRect->setRight( x2 );
- myRect->setBottom( y1 );
- myRect->setTop( y2 );
-}
-
-//================================================================
-// Function : clear
-// Purpose :
-//================================================================
-void SUPERVGUI_PrsNode::clear()
-{
- SUPERVGUI_Prs::clear();
-
- myPorts.clear();
- myConnections.clear();
-}
-
-void SUPERVGUI_PrsNode::addStreamPoint( int type )
-{
- myStreamPoints.insert( type, new GLViewer_Pnt() );
-}
-
-void SUPERVGUI_PrsNode::updateStreamPoint( GLViewer_Pnt* streamPoint, int type )
-{
- float x = myFirstPoint->x();
- float y = myFirstPoint->y();
-
- int mirror = ( isInversed() ? -1 : 1 );
-
- float r = SP_GAP / myXScale;
- float w = myWidth / myXScale;
- float h = getHeight() / myYScale;
-
- switch( type )
- {
- case 1 : streamPoint->setXY( x - mirror * w / 2 - mirror * r, y + h / 2 ); break;
- case 2 : streamPoint->setXY( x - mirror * w / 4, y + h + r ); break;
- case 3 : streamPoint->setXY( x + mirror * w / 4, y + h + r ); break;
- case 4 : streamPoint->setXY( x + mirror * w / 2 + mirror * r, y + h / 2 ); break;
- case 5 : streamPoint->setXY( x - mirror * w / 4, y - r ); break;
- case 6 : streamPoint->setXY( x + mirror * w / 4, y - r ); break;
- default : break;
- }
-}
-
-
-void SUPERVGUI_PrsNode::moveObject( float theX, float theY, bool fromGroup )
-{
- SUPERVGUI_Prs::moveObject( theX, theY, fromGroup );
- if( !fromGroup && myGroup )
- {
- myGroup->dragingObjects( theX, theY );
- return;
- }
-
- myFirstPoint->move( theX, theY );
- myLastPoint->move( theX, theY );
-
- update();
-}
-
-GLboolean SUPERVGUI_PrsNode::highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle )
-{
- if( !myIsVisible )
- return false;
-
- GLboolean update;
- GLboolean highlighted = myIsHigh;
- myIsHigh = GL_FALSE;
-
- if( myRect->contains( GLViewer_Pnt( x, y ) ) )
- myIsHigh = GL_TRUE;
-
- update = ( GLboolean )( myIsHigh != highlighted );
-
- return update;
-}
-
-GLboolean SUPERVGUI_PrsNode::unhighlight()
-{
- if( myIsHigh ) {
- myIsHigh = GL_FALSE;
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-GLboolean SUPERVGUI_PrsNode::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect,
- GLboolean isFull, GLboolean isCircle, GLboolean isShift )
-{
- if( !myIsVisible )
- return false;
-
- GLboolean update;
- GLboolean selected = myIsSel;
- myIsSel = GL_FALSE;
- mySelElement = -1;
-
- if( !rect.isNull() && isInside( rect ) )
- myIsSel = GL_TRUE;
-
- if( myRect->contains( GLViewer_Pnt( x, y ) ) ) {
- myIsSel = GL_TRUE;
- mySelElement = 0;
- }
-
- if ( myIsSel ) {
- myHighFlag = GL_FALSE;
- myIsHigh = GL_FALSE;
- }
- else
- myHighFlag = GL_TRUE;
-
- update = ( GLboolean )( myIsSel != selected );
- return myIsSel;
-}
-
-GLboolean SUPERVGUI_PrsNode::unselect()
-{
- mySelElement = -1;
-
- if( myIsSel ) {
- myIsSel = GL_FALSE;
- return GL_TRUE;
- }
-
- return GL_FALSE;
-}
-
-//================================================================
-// Function : getPort
-// Purpose :
-//================================================================
-SUPERVGUI_PrsPort* SUPERVGUI_PrsNode::getPort( const int type ) const
-{
- SUPERVGUI_PrsPort* port = 0;
- // if ( myPorts.contains( type ) )
- // port = myPorts[ type ];
- return port;
-}
-
-//================================================================
-// Function : addPort
-// Purpose :
-//================================================================
-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 )
-{
- return myPorts.remove( newPort );
-}
-
-//================================================================
-// Function : addConnection
-// Purpose :
-//================================================================
-void SUPERVGUI_PrsNode::addConnection( const int type, SUPERVGUI_PrsPort* otherPort )
-{
- if ( !myConnections.contains( type ) ) {
- PortList list;
- myConnections.insert( type, list );
- }
- myConnections[ type ].append( otherPort );
-}
-
-//================================================================
-// Function : getConnections
-// Purpose :
-//================================================================
-QValueList<SUPERVGUI_PrsPort*> SUPERVGUI_PrsNode::getConnections( const int type ) const
-{
- QValueList<SUPERVGUI_PrsPort*> list;
- if ( myConnections.contains( type ) )
- list = myConnections[ type ];
- return list;
-}
-
-//================================================================
-// Function : removeConnectons
-// Purpose :
-//================================================================
-void SUPERVGUI_PrsNode::removeConnectons()
-{
- myConnections.clear();
-}
-
-//================================================================
-// Function : getIcon
-// Purpose :
-//================================================================
-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);
-}
-
-//================================================================
-// 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
- Description : Drawer for SUPERVGUI_PrsNode
-*/
-
-//=======================================================================
-// name : SUPERVGUI_PrsNodeDrawer
-// Purpose : Constructor
-//=======================================================================
-SUPERVGUI_PrsNodeDrawer::SUPERVGUI_PrsNodeDrawer() :
-SUPERVGUI_PrsDrawer()
-{
- myObjectType = "SUPERVGUI_PrsNode";
-
- setTextFormat( DTF_TEXTURE_SCALABLE );
-
- QFont aFont( "Helvetica", 10 );
- aFont.setStyleHint( QFont::Helvetica );
- aFont.setStyleStrategy( QFont::PreferQuality );
- setFont( aFont );
-}
-
-//=======================================================================
-// name : SUPERVGUI_PrsNodeDrawer
-// Purpose : Destructor
-//=======================================================================
-SUPERVGUI_PrsNodeDrawer::~SUPERVGUI_PrsNodeDrawer()
-{
- glDeleteLists( myTextList, 1 );
-}
-
-void SUPERVGUI_PrsNodeDrawer::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_PrsNode* object = ( SUPERVGUI_PrsNode* )( *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 );
-
- //---------------------
- 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 );
- frect.setTop( rect->top() - fieldHeight );
- frect.setBottom( rect->top() - 2*fieldHeight );
- drawRectangle( &frect, 1., 0., Qt::black, true, Qt::yellow );
- frect.setTop( rect->top() - 2*fieldHeight );
- frect.setBottom( rect->top() - 3*fieldHeight );
- drawRectangle( &frect, 1., 0., Qt::black, true, Qt::yellow );
- // drawing Gate ports must be moved down, after drawing ports..
- frect.setTop( rect->top() - 3*fieldHeight );
- 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 );*/
- //--------------------------------------------
-
- //float iconSize = 16;
- //drawTexture( object->getIcon(), (int)iconSize,
- // rect->left() + iconSize / 2, rect->top() - iconSize / 2 );
-
- /*StreamPointsMap streamPoints = object->getStreamPoints();
- StreamPointsMap::iterator it = streamPoints.begin();
- 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->getPort( type );
- if ( objPort )
- objPort->updateRect( objXScale, objYScale );
-
- if ( !firstPoint )
- continue;
- // compute the text coordinates
- GLViewer_Pnt* textPnt = new GLViewer_Pnt();
- GLfloat textX = firstPoint->x();
- GLfloat textY = firstPoint->y();
-
- textPnt->setXY( textX, textY );
-
- drawPort( firstPoint, SP_GAP / objXScale, strType, textPnt );
-
- // 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 ) {
- //}
-
- /*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());
- }
- }*/
- }
-}
+++ /dev/null
-// SUPERV SUPERVGUI : GUI for Supervisor component
-//
-// Copyright (C) 2003 OPEN CASCADE
-//
-// File : SUPERVGUI_PrsNode.h
-// Author : Alexander SLADKOV
-// Module : SUPERV
-
-#ifndef SUPERVGUI_PrsNode_H
-#define SUPERVGUI_PrsNode_H
-
-#include "SUPERVGUI_Def.h"
-#include "SUPERVGUI_Prs.h"
-#include "SUPERVGUI_PrsPort.h"
-#include "SUPERVGUI_CanvasNode.h"
-
-// connection data
-//typedef QMap<int, SUPERVGUI_PrsPort*> PortMap;
-typedef QValueList<SUPERVGUI_PrsPort*> PortList;
-typedef QMap<int, PortList> PortConnectionMap;
-
-/*
- Class : SUPERVGUI_PrsNodeDrawer
- Description : Drawer for SUPERVGUI_PrsNode
-*/
-class SUPERVGUI_PrsNodeDrawer : public SUPERVGUI_PrsDrawer
-{
-public:
- SUPERVGUI_PrsNodeDrawer();
- virtual ~SUPERVGUI_PrsNodeDrawer();
-
-public:
- virtual void create( float, float, bool );
-
-};
-
-/*
- Class : SUPERVGUI_PrsNode
- Description : Prs for Node Object
-*/
-class SUPERVGUI_PrsNode : public SUPERVGUI_Prs
-{
- Q_OBJECT
-
-public:
- 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();
-
- virtual GLViewer_Drawer* createDrawer() { return myDrawer = new SUPERVGUI_PrsNodeDrawer(); }
-
- virtual void addStreamPoint( int type );
- virtual void updateStreamPoint( GLViewer_Pnt* streamPoint, int type );
-
- virtual void moveObject( float, float, bool = false );
-
- 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();
-
- 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
- //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);
-
- void insertPorts();
-
-protected:
- virtual void createPorts();
-
-private:
- float myWidth;
- //float myHeight;
-
- GLuint myIcon;
-
- GLint mySelElement;
-
- //PortMap myPorts;
- PortList myPorts;
- PortConnectionMap myConnections;
-
- float myTitleHeight;
- float myLabelHeight;
- float myStatusHeight;
- float myPortHeight;
- float myStreamHeight; //???
- float myGateHeight;
-
- QString myStatus;
- QString myTime;
-
- QColor myColor;
- QColor myStatusColor;
-
- bool myPortVisible;
- bool myLabelVisible;
-
- SUPERVGUI_CanvasNode* myNode;
-
-};
-
-#endif
+++ /dev/null
-// SUPERV SUPERVGUI : GUI for Supervisor component
-//
-// Copyright (C) 2003 OPEN CASCADE
-//
-// File : SUPERVGUI_PrsPort.cxx
-// Author : Alexander SLADKOV
-// Module : SUPERV
-
-#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( SUPERVGUI_CanvasPort* thePort )
- : GLViewer_Object(),
- myPort(thePort)
-{
- 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;
-}
-
-//=======================================================================
-// name : SUPERVGUI_PrsStream
-// Purpose : Destructor
-//=======================================================================
-SUPERVGUI_PrsPort::~SUPERVGUI_PrsPort()
-{
- delete myRect;
-}
-
-//=======================================================================
-// name : getPoint
-// Purpose :
-//=======================================================================
-GLViewer_Pnt* SUPERVGUI_PrsPort::getPoint() const
-{
- //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 )
-{
- const GLViewer_Pnt* point = getPoint();
- if ( !point )
- return;
- myRect->setLeft( point->x() - SP_GAP / xScale );
- 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;
-}
-
-//================================================================
-// Function : locked
-// Purpose :
-//================================================================
-bool SUPERVGUI_PrsPort::locked( GLViewer_Pnt thePoint,
- SUPERVGUI_PrsPort* thePullingPort )
-{
-// Handle(SUPERVData_Installation) anInst =
-// Handle(SUPERVData_Installation)::DownCast( myPrs->getObject() );
-//
-// Handle(SUPERVData_Installation) aLockedInst =
-// Handle(SUPERVData_Installation)::DownCast( thePullingPort->getPrs()->getObject() );
-
- if( !myRect || !myRect->contains( thePoint ) )
- return false;
-
- return true;
-
-//
-// if ( anInst.IsNull() || aLockedInst.IsNull() || anInst == aLockedInst )
-// return false;
-// return ( anInst->IsConnectionAllowed( myType, aLockedInst->SUPERVType() ) &&
-// aLockedInst->IsConnectionAllowed( thePullingPort->getType(), anInst->SUPERVType() ) );
-
- //if( myPrs != thePullingPort->getPrs() )
- // 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 );
-}
+++ /dev/null
-// SUPERV SUPERVGUI : GUI for Supervisor component
-//
-// Copyright (C) 2003 OPEN CASCADE
-//
-// File : SUPERVGUI_PrsPort.h
-// Author : Alexander SLADKOV
-// Module : SUPERV
-
-#ifndef SUPERVGUI_PrsPort_H
-#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 : public GLViewer_Object
-{
-public:
- SUPERVGUI_PrsPort( SUPERVGUI_CanvasPort* );
- virtual ~SUPERVGUI_PrsPort();
-
-public:
- SUPERVGUI_CanvasPort* getPort() const { return myPort; }
-
- virtual void compute() {}
-
- virtual GLViewer_Drawer* createDrawer() { return myDrawer = new SUPERVGUI_PrsPortDrawer(); }
-
- 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();
-
- virtual void moveObject( float, float, bool = false );
-
- 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_Pnt* myPoint;
-
- QColor myColor;
- //bool myVisible;
-};
-
-#endif