From: asv Date: Tue, 10 Jan 2006 08:38:05 +0000 (+0000) Subject: initial creation of GLViewer entities: presentations and its "drawers". X-Git-Tag: T_Supervisor_GUI_based_on_GLViewer_start~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b63396b29d4d63557bfae40184ce06f4c816d032;p=modules%2Fsuperv.git initial creation of GLViewer entities: presentations and its "drawers". --- diff --git a/src/SUPERVGUI/Makefile.in b/src/SUPERVGUI/Makefile.in index 0655a87..02b9d10 100644 --- a/src/SUPERVGUI/Makefile.in +++ b/src/SUPERVGUI/Makefile.in @@ -68,7 +68,10 @@ LIB_SRC = SUPERVGUI.cxx \ SUPERVGUI_Notification.cxx \ SUPERVGUI_ManagePortsDlg.cxx \ SUPERVGUI_Library.cxx \ - SUPERVGUI_Clipboard.cxx + SUPERVGUI_Clipboard.cxx \ + SUPERVGUI_Prs.cxx \ + SUPERVGUI_PrsNode.cxx \ + SUPERVGUI_PrsPort.cxx LIB_MOC = SUPERVGUI.h \ SUPERVGUI_ArrayView.h \ @@ -86,7 +89,11 @@ LIB_MOC = SUPERVGUI.h \ SUPERVGUI_Notification.h \ SUPERVGUI_ManagePortsDlg.h \ SUPERVGUI_Library.h \ - SUPERVGUI_Clipboard.h + SUPERVGUI_Clipboard.h \ + SUPERVGUI_Prs.h \ + SUPERVGUI_PrsNode.h \ + SUPERVGUI_PrsPort.h + LIB_CLIENT_IDL = SALOMEDS.idl \ SALOMEDS_Attributes.idl \ diff --git a/src/SUPERVGUI/SUPERVGUI.cxx b/src/SUPERVGUI/SUPERVGUI.cxx index 35c1474..aa837f8 100644 --- a/src/SUPERVGUI/SUPERVGUI.cxx +++ b/src/SUPERVGUI/SUPERVGUI.cxx @@ -50,6 +50,8 @@ using namespace boost; #include "SUIT_Session.h" #include "SUIT_Study.h" +#include "GLViewer_ViewManager.h" + #include "SUPERVGraph_ViewManager.h" #include "SUPERVGraph_ViewFrame.h" @@ -78,8 +80,7 @@ SUPERVGUI::SUPERVGUI() browser(0), myFirstActivation(true), myAllGraphsClosed(false), - myInitialViewFrame(0), - myIVFBackgroundColor(QColor()) + myInitialViewFrame(0) //info(0) { Trace("SUPERVGUI::SUPERVGUI") @@ -277,18 +278,21 @@ LightApp_Selection* SUPERVGUI::createSelection() const } SUIT_ViewWindow* SUPERVGUI::createGraph() { - SUPERVGraph_ViewManager* aVM = new SUPERVGraph_ViewManager( study, application()->desktop(), new SUPERVGraph_Viewer() ); - (( SalomeApp_Application* )application())->addViewManager( aVM ); + SUPERVGraph_ViewManager* aVM = new SUPERVGraph_ViewManager( study, application()->desktop(), new SUPERVGraph_Viewer() ); + getApp()->addViewManager( aVM ); SUPERVGraph_ViewFrame* aVW = dynamic_cast( aVM->createViewWindow() ); if ( aVW ) { - QColor back = getApp()->resourceMgr()->colorValue( "SUPERVGraph", "Background", DEF_MAIN_COLOR ); + QColor back = getApp()->resourceMgr()->colorValue( "SUPERVGraph", "Background", aVW->backgroundColor() ); qDebug( QString( "background: %1 %2 %3" ).arg( back.red() ).arg( back.green() ).arg( back.blue() ) ); aVW->setBackgroundColor( back ); - connect( aVM, - SIGNAL( deleteView( SUIT_ViewWindow* ) ), - this, - SLOT( onGraphClosed( SUIT_ViewWindow* ) ) ); + connect( aVM, SIGNAL( deleteView( SUIT_ViewWindow* ) ), this, SLOT( onGraphClosed( SUIT_ViewWindow* ) ) ); } + + // asv-debug + GLViewer_ViewManager* glVM = new GLViewer_ViewManager( study, application()->desktop() ); + getApp()->addViewManager( glVM ); + glVM->createViewWindow(); + return aVW; } @@ -421,7 +425,6 @@ void SUPERVGUI::onGraphClosed(SUIT_ViewWindow* theViewWindow) { myAllGraphsClosed = true; myFirstActivation = true; myInitialViewFrame = 0; - myIVFBackgroundColor = QColor(); main = 0; } } @@ -488,7 +491,8 @@ void SUPERVGUI::displayDataflow() { } else { // second case : get empty initial view frame as new ViewFrame object - aViewFrame = myInitialViewFrame; + aViewFrame = dynamic_cast( myInitialViewFrame ); + myInitialViewFrame = 0; } if( aViewFrame ) { @@ -496,11 +500,6 @@ void SUPERVGUI::displayDataflow() { registerGraph( aIORName, main ); aViewFrame->show(); } - - if ( myInitialViewFrame ) { - myInitialViewFrame = 0; - myIVFBackgroundColor = QColor(); - } } @@ -677,7 +676,8 @@ bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode, bool theInitialDF ) { } else { // 2. get empty initial view frame as new ViewFrame object - aViewFrame = myInitialViewFrame; + aViewFrame = dynamic_cast( myInitialViewFrame ); + myInitialViewFrame = 0; } if ( aViewFrame ) { @@ -685,7 +685,7 @@ bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode, bool theInitialDF ) { // 3. bind Graph and ViewFrame == create SUPERVGUI_Main object main = new SUPERVGUI_Main( aViewFrame, application()->desktop(), aGraph ); if ( mode == New ) { - if ( !theInitialDF ) + if ( !theInitialDF ) main->addNode(); else myInitialViewFrame = aViewFrame; @@ -694,14 +694,6 @@ bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode, bool theInitialDF ) { registerGraph( f, main ); main->resizeView( new QResizeEvent( aViewFrame->size(), aViewFrame->size() ) ); aViewFrame->show(); - QFileInfo inf( f ); - if( !f.isEmpty() ) - aViewFrame->setCaption( inf.fileName() ); - } - - if ( !theInitialDF ) { - myInitialViewFrame = 0; - myIVFBackgroundColor = QColor(); } return true; diff --git a/src/SUPERVGUI/SUPERVGUI.h b/src/SUPERVGUI/SUPERVGUI.h index 2092a9f..a632e9a 100644 --- a/src/SUPERVGUI/SUPERVGUI.h +++ b/src/SUPERVGUI/SUPERVGUI.h @@ -118,10 +118,6 @@ class SUPERVGUI: public SalomeApp_Module { */ void nullifyInitialVF() { if ( myInitialViewFrame ) myInitialViewFrame = 0; } - // mkr : IPAL10825 - QColor getIVFBackgroundColor() { return myIVFBackgroundColor; } - void setIVFBackgroundColor( QColor theColor ) { if ( myInitialViewFrame ) myIVFBackgroundColor = theColor; } - signals: void KillMainThread(bool theValue); @@ -169,8 +165,7 @@ class SUPERVGUI: public SalomeApp_Module { bool myFirstActivation; bool myAllGraphsClosed; - SUPERVGraph_ViewFrame* myInitialViewFrame; - QColor myIVFBackgroundColor; // mkr : IPAL10825 + SUIT_ViewWindow* myInitialViewFrame; }; #endif diff --git a/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx b/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx index 08477e5..b8c2be4 100644 --- a/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx +++ b/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx @@ -8,7 +8,6 @@ using namespace std; -#include "SUPERVGUI.h" #include "SUPERVGUI_ArrayView.h" #include "SUPERVGUI_Main.h" #include "SUPERVGUI_CanvasCellNodePrs.h" @@ -108,15 +107,6 @@ void SUPERVGUI_ArrayView::changeBackground() // change background color for canvas view getMain()->getCanvasView()->canvas()->setBackgroundColor(aColor); getMain()->getCanvasView()->setPaletteBackgroundColor(aColor.light(120)); - - // mkr : IPAL10825 --> - SUPERVGUI* aSupMod = SUPERVGUI::Supervision(); - if ( !aSupMod ) { - MESSAGE("NULL Supervision module!"); - return; - } - aSupMod->setIVFBackgroundColor(aColor); - // <-- } } diff --git a/src/SUPERVGUI/SUPERVGUI_Canvas.cxx b/src/SUPERVGUI/SUPERVGUI_Canvas.cxx index 776849d..a299cdd 100644 --- a/src/SUPERVGUI/SUPERVGUI_Canvas.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Canvas.cxx @@ -7,7 +7,6 @@ // Module : SUPERV using namespace std; -#include "SUPERVGUI.h" #include "SUPERVGUI_Def.h" #include "SUPERVGUI_Main.h" #include "SUPERVGUI_CanvasNode.h" @@ -90,17 +89,7 @@ SUPERVGUI_Canvas::SUPERVGUI_Canvas( SUPERVGUI_Main* m, SUIT_ResourceMgr* mgr ): resize(1050, 750); setDoubleBuffering(true); - // mkr : IPAL10825 --> - SUPERVGUI* aSupMod = SUPERVGUI::Supervision(); - if ( !aSupMod ) { - MESSAGE("NULL Supervision module!"); - return; - } - QColor aColor = aSupMod->getIVFBackgroundColor(); - if ( !aColor.isValid() ) - aColor = mgr->colorValue( "SUPERVGraph", "Background", DEF_MAIN_COLOR ); - // <-- - + QColor aColor = mgr->colorValue( "SUPERVGraph", "Background", DEF_MAIN_COLOR ); //aColor = QColor(SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorRed" ), // SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorGreen" ), // SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorBlue" ) ); diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx index 19d07d2..bd3d121 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx @@ -7,7 +7,6 @@ // Module : SUPERV using namespace std; -#include "SUPERVGUI.h" #include "SUPERVGUI_CanvasArray.h" #include "SUPERVGUI_Main.h" #include "SUPERVGUI_BrowseNodeDlg.h" @@ -87,17 +86,7 @@ SUPERVGUI_CanvasArray::SUPERVGUI_CanvasArray(SUPERVGUI_Main* m, SUIT_ResourceMgr resize(1000, 725); setDoubleBuffering(true); - // mkr : IPAL10825 --> - SUPERVGUI* aSupMod = SUPERVGUI::Supervision(); - if ( !aSupMod ) { - MESSAGE("NULL Supervision module!"); - return; - } - QColor aColor = aSupMod->getIVFBackgroundColor(); - if ( !aColor.isValid() ) - aColor = mgr->colorValue( "SUPERVGraph", "Background", DEF_MAIN_COLOR ); - // <-- - + QColor aColor = mgr->colorValue( "SUPERVGraph", "Background", DEF_MAIN_COLOR ); //aColor = QColor(SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorRed" ), // SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorGreen" ), // SUIT_Session::session()->resourceMgr()->integerValue( "SUPERVGraph", "BackgroundColorBlue" ) ); diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx index ccf9f06..b9eeaff 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx @@ -204,7 +204,7 @@ void SUPERVGUI_CanvasCellNodePrs::setState(SUPERV::GraphState theState) default: setStatus("No Status"); - setStatusColor( resMgr()->colorValue( "SUPERVGraph", "NodeBody", DEF_MAIN_BACK ) ); // mkr : IPAL10829 + setStatusColor( resMgr()->colorValue( "SUPERVGraph", "Background", DEF_MAIN_BACK ) ); break; } diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx index d82abd2..7eb774c 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx @@ -671,6 +671,11 @@ void SUPERVGUI_CanvasNodePrs::drawPort(QPainter& thePainter) ++it; if (obj->inherits("SUPERVGUI_CanvasPort")) { aPort = (SUPERVGUI_CanvasPort*) obj; + + SUPERV_Port aPortEng = aPort->getEngine(); + if ( CORBA::is_nil( aPortEng ) ) + printf ( "---\n port engine IS NIL ---\n\n" ); + if (!aPort->getEngine()->IsGate()) { aPort->getPrs()->draw(thePainter); } @@ -878,9 +883,13 @@ bool SUPERVGUI_CanvasPortPrs::isAlert() const QString SUPERVGUI_CanvasPortPrs::getText() const { SUPERV_Port aPort = myPort->getEngine(); - QString aText = aPort->Name(); - if (aPort->IsParam() || aPort->IsInLine() || myPort->isStream()) - aText = aText + "=" + aPort->ToString(); + 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; } diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx index c336716..3e52a41 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx @@ -10,7 +10,6 @@ using namespace std; -#include "SUPERVGUI.h" #include "SUPERVGUI_CanvasView.h" #include "SUPERVGUI_Main.h" #include "SUPERVGUI_CanvasNode.h" @@ -572,15 +571,6 @@ void SUPERVGUI_CanvasView::changeBackground() // change background color for array view getMain()->getArrayView()->canvas()->setBackgroundColor(aColor); getMain()->getArrayView()->setPaletteBackgroundColor(aColor.light(120)); - - // mkr : IPAL10825 --> - SUPERVGUI* aSupMod = SUPERVGUI::Supervision(); - if ( !aSupMod ) { - MESSAGE("NULL Supervision module!"); - return; - } - aSupMod->setIVFBackgroundColor(aColor); - // <-- } } diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index 3ffa305..b943162 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -50,6 +50,10 @@ using namespace boost; #include "SUIT_Study.h" #include "QtxDblSpinBox.h" +#include "GLViewer_Viewer2d.h" +#include "GLViewer_Context.h" +#include "GLViewer_BaseObjects.h" + #include "SUPERVGUI.h" #include "SUPERVGUI_Def.h" #include "SUPERVGUI_Main.h" @@ -57,6 +61,7 @@ using namespace boost; #include "SUPERVGUI_Information.h" #include "SUPERVGUI_CanvasControlNode.h" #include "SUPERVGUI_CanvasPort.h" +#include "SUPERVGUI_PrsNode.h" #include #include @@ -65,7 +70,8 @@ using namespace boost; #include #include -SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, SUIT_Desktop* theDesktop, SUPERV_Graph theDataFlow ) +SUPERVGUI_Main::SUPERVGUI_Main( SUPERVGraph_ViewFrame* theParent, + SUIT_Desktop* theDesktop, SUPERV_Graph theDataFlow ) : SUPERVGraph_View(theParent), myLogged( false ), myFiltered( false ), @@ -75,7 +81,7 @@ SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, SUIT_Desktop* t myStep( false ), myTrace( false ), myVerbose( false ) - //myExecuted( false ) + //myExecuted( false ) { Trace("SUPERVGUI_Main::SUPERVGUI_Main (copy)"); theParent->setViewWidget(this); @@ -692,6 +698,14 @@ void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) { if (myCurrentView == CONTROLFLOW) aNode->hideAll(); aNode->show(); myCanvas->update(); + + + SUPERVGUI_PrsNode* glNode = new SUPERVGUI_PrsNode(); + glNode->setFirstPoint( new GLViewer_Pnt( 10, 10 ) ); + glNode->compute(); + glNode->update(); + getGLContext()->insertObject( glNode, false ); + // glNode->setVisible( true ); } break; } @@ -1332,6 +1346,24 @@ void SUPERVGUI_Main::resizeView( QResizeEvent* theEvent ) getCanvasArray()->resize( theEvent->size().width(), theEvent->size().height() ); } + +GLViewer_Viewer2d* SUPERVGUI_Main::getGLViewer() +{ + if ( study ) + if ( STD_Application* app = dynamic_cast( study->application() ) ) + if ( SUIT_ViewManager* vm = app->viewManager( GLViewer_Viewer::Type() ) ) + return dynamic_cast( 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() diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h index 5fde3ae..9fe4cee 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.h +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -45,6 +45,8 @@ class QLineEdit; class QComboBox; class NOTIFICATION_Consumer; class SUPERVGUI_Thread; +class GLViewer_Viewer2d; +class GLViewer_Context; class SUPERVGUI_Main: public SUPERVGraph_View { Q_OBJECT @@ -169,15 +171,18 @@ class SUPERVGUI_Main: public SUPERVGraph_View { bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp); void closeEvent(QCloseEvent*); + GLViewer_Viewer2d* getGLViewer(); + GLViewer_Context* getGLContext(); + SUPERV_Graph dataflow; QMap mySubGraphs; - QMap mySubGraphMap; - SUIT_ViewWindow* myLastGraph; + QMap mySubGraphMap; + SUIT_ViewWindow* myLastGraph; - SUIT_Study* study; - OB_Browser* objectBrowser; - LogWindow* message; + SUIT_Study* study; + OB_Browser* objectBrowser; + LogWindow* message; GraphViewType myCurrentView; SUPERVGUI_CanvasArray* myArray; @@ -209,8 +214,8 @@ class SUPERVGUI_Main: public SUPERVGraph_View { SUPERVGUI_Thread* myThread; - QPtrList< char * > myEventNodes ; - QPtrList< SUPERV::GraphState > myStates ; + QPtrList myEventNodes ; + QPtrList myStates ; QTimer* myTimer; }; diff --git a/src/SUPERVGUI/SUPERVGUI_Prs.cxx b/src/SUPERVGUI/SUPERVGUI_Prs.cxx new file mode 100644 index 0000000..85d241e --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Prs.cxx @@ -0,0 +1,247 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_Prs.cxx +// Author : Alexander SLADKOV +// Module : SUPERV + +#include + +//======================================================================= +// 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 ); +} + diff --git a/src/SUPERVGUI/SUPERVGUI_Prs.h b/src/SUPERVGUI/SUPERVGUI_Prs.h new file mode 100644 index 0000000..77fa60f --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Prs.h @@ -0,0 +1,174 @@ +// 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 + +#include +#include + +#define SP_GAP 15 + +#define INST_WIDTH 100 +#define INST_HEIGHT 100 + +typedef QMap StreamPointsMap; + +/* + 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_PrsList; +typedef QValueList SUPERVGUI_PntList; + +typedef QMap SUPERVGUI_PrsMap; +typedef QMap SUPERVGUI_PortMap; +typedef QValueList 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 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 diff --git a/src/SUPERVGUI/SUPERVGUI_PrsNode.cxx b/src/SUPERVGUI/SUPERVGUI_PrsNode.cxx new file mode 100644 index 0000000..b1ae9b9 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_PrsNode.cxx @@ -0,0 +1,369 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_PrsNode.cxx +// Author : Alexander SLADKOV +// Module : SUPERV + +#include + +#include + +#include +#include + +#include + +//======================================================================= +// name : SUPERVGUI_PrsNode +// Purpose : Constructor +//======================================================================= +SUPERVGUI_PrsNode::SUPERVGUI_PrsNode() : + SUPERVGUI_Prs() +{ + myType = "SUPERVGUI_PrsNode"; + + setScalable( true ); + + myWidth = INST_WIDTH; + myHeight = INST_HEIGHT; + + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + + QString fileName = aResMgr->path( "resources", "SUPERVGUI", "ICO_NODE_INLINE" ); + myIcon = GLViewer_Drawer::loadTexture( fileName ); +} + +//======================================================================= +// name : SUPERVGUI_PrsNode +// Purpose : Destructor +//======================================================================= +SUPERVGUI_PrsNode::~SUPERVGUI_PrsNode() +{ + mySteamPorts.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 y1 = myFirstPoint->y(); + float y2 = myFirstPoint->y() + myHeight / myYScale; + + myRect->setLeft( x1 ); + myRect->setRight( x2 ); + myRect->setBottom( y1 ); + myRect->setTop( y2 ); +} + +//================================================================ +// Function : clear +// Purpose : +//================================================================ +void SUPERVGUI_PrsNode::clear() +{ + SUPERVGUI_Prs::clear(); + + mySteamPorts.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 = myHeight / 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 : getStreamPort +// Purpose : +//================================================================ +SUPERVGUI_PrsPort* SUPERVGUI_PrsNode::getStreamPort( const int type ) const +{ + SUPERVGUI_PrsPort* port = 0; + if ( mySteamPorts.contains( type ) ) + port = mySteamPorts[ type ]; + return port; +} + +//================================================================ +// Function : addStreamPort +// Purpose : +//================================================================ +void SUPERVGUI_PrsNode::addStreamPort( const int type, SUPERVGUI_PrsPort* newPort ) +{ + SUPERVGUI_PrsPort* port = getStreamPort( type ); + if ( port ) // should not be + delete port; + mySteamPorts[ type ] = newPort; +} + +//================================================================ +// Function : addConnection +// Purpose : +//================================================================ +void SUPERVGUI_PrsNode::addConnection( const int type, SUPERVGUI_PrsPort* otherPort ) +{ + if ( !myConnections.contains( type ) ) { + StreamPortList list; + myConnections.insert( type, list ); + } + myConnections[ type ].append( otherPort ); +} + +//================================================================ +// Function : getConnections +// Purpose : +//================================================================ +QValueList SUPERVGUI_PrsNode::getConnections( const int type ) const +{ + QValueList 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; +} + +/* + 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", 12 ); + 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::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 ); + + 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( "..." ); + + drawGLText( name, (rect->left()-rect->right())/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 ); + + 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, Qt::black ); + + 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(); + for ( ; it != streamPoints.end(); ++it ) { + GLViewer_Pnt* firstPoint = *it; + int type = it.key(); + + QString strType = "COSAC_ConnectionType"; + + object->updateStreamPoint( firstPoint, type ); + // update rect of connection stream port + SUPERVGUI_PrsPort* objPort = object->getStreamPort( 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; + } + } +} diff --git a/src/SUPERVGUI/SUPERVGUI_PrsNode.h b/src/SUPERVGUI/SUPERVGUI_PrsNode.h new file mode 100644 index 0000000..52d7be1 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_PrsNode.h @@ -0,0 +1,94 @@ +// 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_Prs.h" +#include "SUPERVGUI_PrsPort.h" + +class gp_XY; +//class LineConn2d_Model; + +/* + 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(); + virtual ~SUPERVGUI_PrsNode(); + +public: + 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(); + + float getWidth() const { return myWidth; } + float getHeight() const { return myHeight; } + + GLuint getIcon() const; + + // connection data + SUPERVGUI_PrsPort* getStreamPort( const int ) const; + void addStreamPort( const int, SUPERVGUI_PrsPort* ); + void addConnection( const int, SUPERVGUI_PrsPort* ); + void removeConnectons(); + + QValueList + getConnections( const int ) const; + +private: + float myWidth; + float myHeight; + + GLuint myIcon; + + GLint mySelElement; + + // connection data + typedef QMap StreamPortMap; + typedef QValueList StreamPortList; + typedef QMap StreamPortConnectionMap; + + StreamPortMap mySteamPorts; + StreamPortConnectionMap myConnections; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_PrsPort.cxx b/src/SUPERVGUI/SUPERVGUI_PrsPort.cxx new file mode 100644 index 0000000..fac1ed0 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_PrsPort.cxx @@ -0,0 +1,90 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_PrsPort.cxx +// Author : Alexander SLADKOV +// Module : SUPERV + +#include "SUPERVGUI_PrsPort.h" + +//======================================================================= +// name : SUPERVGUI_PrsStream +// Purpose : Constructor +//======================================================================= +SUPERVGUI_PrsPort::SUPERVGUI_PrsPort( int theType, SUPERVGUI_Prs* thePrs ) +{ + myType = theType; + myPrs = thePrs; + + myRect = new GLViewer_Rect(); + + //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; +} + + +//================================================================ +// 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 : 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; +} diff --git a/src/SUPERVGUI/SUPERVGUI_PrsPort.h b/src/SUPERVGUI/SUPERVGUI_PrsPort.h new file mode 100644 index 0000000..342e0f2 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_PrsPort.h @@ -0,0 +1,43 @@ +// 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" + +/* + Class : SUPERVGUI_PrsPortPort + Description : Port of Port Object +*/ +class SUPERVGUI_PrsPort +{ +public: + SUPERVGUI_PrsPort( int, SUPERVGUI_Prs* ); + virtual ~SUPERVGUI_PrsPort(); + +public: + void updateRect( GLfloat xScale, GLfloat yScale ); + + bool locked( GLViewer_Pnt thePoint, + SUPERVGUI_PrsPort* thePullingPort ); + + int getType() const { return myType; } + SUPERVGUI_Prs* getPrs() const { return myPrs; } + + GLViewer_Pnt* getPoint() const; + GLViewer_Rect* getRect() const { return myRect; } + +protected: + int myType; + SUPERVGUI_Prs* myPrs; + + GLViewer_Rect* myRect; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERV_images.po b/src/SUPERVGUI/SUPERV_images.po index 0d0e8a0..3277a1f 100644 --- a/src/SUPERVGUI/SUPERV_images.po +++ b/src/SUPERVGUI/SUPERV_images.po @@ -65,3 +65,6 @@ msgstr "kill.png" msgid "ICO_SUSPEND/RESUME" msgstr "suspend-resume.gif" + +msgid "ICO_NODE_INLINE" +msgstr "node_inline.png"