diff --git a/src/BasicGUI/BasicGUI.cxx b/src/BasicGUI/BasicGUI.cxx index 8c47c0f4b..2fad21a14 100644 --- a/src/BasicGUI/BasicGUI.cxx +++ b/src/BasicGUI/BasicGUI.cxx @@ -57,15 +57,6 @@ using namespace std; -//======================================================================= -// function : GetBasicGUI() -// purpose : Get the only BasicGUI object [ static ] -//======================================================================= -BasicGUI* BasicGUI::GetBasicGUI( GeometryGUI* parent ) -{ - return new BasicGUI( parent ); -} - //======================================================================= // function : BasicGUI() // purpose : Constructor @@ -146,38 +137,41 @@ bool BasicGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin QDialog* aDlg = getGeometryGUI()->GetActiveDialogBox(); // Create Point dialog, OCC viewer - if ( aDlg && aDlg->isA( "BasicGUI_PointDlg" ) && theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() && pe->state() != Qt::ControlButton ) + if ( aDlg && aDlg->isA( "BasicGUI_PointDlg" ) && + theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() && + pe->state() != Qt::ControlButton ) { BasicGUI_PointDlg* aPntDlg = (BasicGUI_PointDlg*) aDlg; if ( aPntDlg->acceptMouseEvent() ) + { + OCCViewer_Viewer* anOCCViewer = + ((OCCViewer_ViewManager*)(theViewWindow->getViewManager()))->getOCCViewer(); + Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext(); + + gp_Pnt aPnt; + + ic->InitSelected(); + if ( pe->state() == Qt::ShiftButton ) + ic->ShiftSelect(); // Append selection + else + ic->Select(); // New selection + + ic->InitSelected(); + if ( ic->MoreSelected() ) { - OCCViewer_Viewer* anOCCViewer = ((OCCViewer_ViewManager*)(theViewWindow->getViewManager()))->getOCCViewer(); - Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext(); - - gp_Pnt aPnt; + TopoDS_Shape aShape = ic->SelectedShape(); + if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) + aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) ); + } + else + { + OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort(); + aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() ); + } - ic->InitSelected(); - if( pe->state() == Qt::ShiftButton ) - ic->ShiftSelect(); // Append selection - else - ic->Select(); // New selection - - ic->InitSelected(); - if( ic->MoreSelected() ) - { - TopoDS_Shape aShape = ic->SelectedShape(); - if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) - aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) ); - } - else - { - OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort(); - aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() ); - } - - aPntDlg->OnPointSelected( aPnt ); // "feed" the point to point construction dialog - } // acceptMouseEvent() - } + aPntDlg->OnPointSelected( aPnt ); // "feed" the point to point construction dialog + } // acceptMouseEvent() + } return false; } @@ -218,6 +212,6 @@ extern "C" #endif GEOMGUI* GetLibGUI( GeometryGUI* parent ) { - return BasicGUI::GetBasicGUI( parent ); + return new BasicGUI( parent ); } } diff --git a/src/BasicGUI/BasicGUI.h b/src/BasicGUI/BasicGUI.h index 210a264e0..0e70833d7 100644 --- a/src/BasicGUI/BasicGUI.h +++ b/src/BasicGUI/BasicGUI.h @@ -44,15 +44,10 @@ //================================================================================= class BasicGUI : public GEOMGUI { -protected: - BasicGUI( GeometryGUI* parent ); // hide constructor to avoid direct creation - public: + BasicGUI( GeometryGUI* parent ); ~BasicGUI(); - // Get the only BasicGUI object - static BasicGUI* GetBasicGUI( GeometryGUI* parent ); - bool OnGUIEvent(int theCommandID, SUIT_Desktop* parent); bool OnMousePress(QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow); diff --git a/src/BlocksGUI/BlocksGUI.cxx b/src/BlocksGUI/BlocksGUI.cxx index e459a0937..b3126c101 100644 --- a/src/BlocksGUI/BlocksGUI.cxx +++ b/src/BlocksGUI/BlocksGUI.cxx @@ -41,20 +41,6 @@ #include "SalomeApp_Application.h" -BlocksGUI* BlocksGUI::myGUIObject = 0; - -//======================================================================= -// function : GetBlocksGUI() -// purpose : Get the only BlocksGUI object [ static ] -//======================================================================= -BlocksGUI* BlocksGUI::GetBlocksGUI( GeometryGUI* parent ) -{ - if ( myGUIObject == 0 ) - myGUIObject = new BlocksGUI( parent ); - - return myGUIObject; -} - //======================================================================= // function : BlocksGUI() // purpose : Constructor @@ -110,6 +96,6 @@ extern "C" #endif GEOMGUI* GetLibGUI( GeometryGUI* parent ) { - return BlocksGUI::GetBlocksGUI( parent ); + return new BlocksGUI( parent ); } } diff --git a/src/BlocksGUI/BlocksGUI.h b/src/BlocksGUI/BlocksGUI.h index 7a71822ed..48a975ca6 100644 --- a/src/BlocksGUI/BlocksGUI.h +++ b/src/BlocksGUI/BlocksGUI.h @@ -23,7 +23,6 @@ // File : BuildGUI.h // Author : Julia DOROVSKIKH // Module : GEOM -// $Header$ #ifndef BLOCKSGUI_H #define BLOCKSGUI_H @@ -36,19 +35,11 @@ //================================================================================= class BlocksGUI : public GEOMGUI { - protected: - BlocksGUI( GeometryGUI* parent ); // hide constructor to avoid direct creation - public: + BlocksGUI( GeometryGUI* parent ); ~BlocksGUI(); - // Get the only BuildGUI object - static BlocksGUI* GetBlocksGUI( GeometryGUI* parent ); - bool OnGUIEvent (int theCommandID, SUIT_Desktop* parent); - -private: - static BlocksGUI* myGUIObject; // the only BlocksGUI object }; #endif diff --git a/src/BooleanGUI/BooleanGUI.cxx b/src/BooleanGUI/BooleanGUI.cxx index 3f24a7017..10af70c48 100644 --- a/src/BooleanGUI/BooleanGUI.cxx +++ b/src/BooleanGUI/BooleanGUI.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -36,21 +36,6 @@ using namespace std; -BooleanGUI* BooleanGUI::myGUIObject = 0; - -//======================================================================= -// function : GetBooleanGUI() -// purpose : Get the only BooleanGUI object [ static ] -//======================================================================= -BooleanGUI* BooleanGUI::GetBooleanGUI( GeometryGUI* parent ) -{ - if ( myGUIObject == 0 ) { - // init BooleanGUI only once - myGUIObject = new BooleanGUI( parent ); - } - return myGUIObject; -} - //======================================================================= // function : BooleanGUI() // purpose : Constructor @@ -59,7 +44,6 @@ BooleanGUI::BooleanGUI( GeometryGUI* parent ) : GEOMGUI( parent ) { } - //======================================================================= // function : ~BooleanGUI() // purpose : Destructor @@ -91,7 +75,7 @@ bool BooleanGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) QDialog* aDlg = new BooleanGUI_Dialog( anOperation, getGeometryGUI(), parent, ""); aDlg->show(); - + return true; } @@ -105,6 +89,6 @@ extern "C" #endif GEOMGUI* GetLibGUI( GeometryGUI* parent ) { - return BooleanGUI::GetBooleanGUI( parent ); + return new BooleanGUI( parent ); } } diff --git a/src/BooleanGUI/BooleanGUI.h b/src/BooleanGUI/BooleanGUI.h index 6cd23d09d..9de8c7bd2 100644 --- a/src/BooleanGUI/BooleanGUI.h +++ b/src/BooleanGUI/BooleanGUI.h @@ -17,14 +17,13 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // // File : BooleanGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header$ #ifndef BOOLEANGUI_H #define BOOLEANGUI_H @@ -37,21 +36,13 @@ //================================================================================= class BooleanGUI : public GEOMGUI { -protected: - BooleanGUI( GeometryGUI* parent ); // hide constructor to avoid direct creation - public: enum BooleanOperation { COMMON = 1, CUT = 2, FUSE = 3, SECTION = 4 }; + BooleanGUI( GeometryGUI* parent ); ~BooleanGUI(); - // Get the only BooleanGUI object - static BooleanGUI* GetBooleanGUI( GeometryGUI* parent ); - bool OnGUIEvent(int theCommandID, SUIT_Desktop* parent); - -private: - static BooleanGUI* myGUIObject; // the only BooleanGUI object }; #endif diff --git a/src/BuildGUI/BuildGUI.cxx b/src/BuildGUI/BuildGUI.cxx index b6537c9ce..eebeee4b6 100644 --- a/src/BuildGUI/BuildGUI.cxx +++ b/src/BuildGUI/BuildGUI.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -31,6 +31,8 @@ #include "SUIT_Desktop.h" #include "SUIT_Session.h" +#include "SalomeApp_Application.h" + #include "BuildGUI_EdgeDlg.h" // Method EDGE #include "BuildGUI_WireDlg.h" // Method WIRE #include "BuildGUI_FaceDlg.h" // Method FACE @@ -40,20 +42,6 @@ #include "GeometryGUI.h" -BuildGUI* BuildGUI::myGUIObject = 0; - -//======================================================================= -// function : GetBuildGUI() -// purpose : Get the only BuildGUI object [ static ] -//======================================================================= -BuildGUI* BuildGUI::GetBuildGUI( GeometryGUI* parent ) -{ - if ( myGUIObject == 0 ) - myGUIObject = new BuildGUI( parent ); - - return myGUIObject; -} - //======================================================================= // function : BuildGUI() // purpose : Constructor @@ -63,7 +51,6 @@ BuildGUI::BuildGUI( GeometryGUI* parent ) { } - //======================================================================= // function : ~BuildGUI() // purpose : Destructor @@ -80,7 +67,7 @@ BuildGUI::~BuildGUI() bool BuildGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) { getGeometryGUI()->EmitSignalDeactivateDialog(); - + QDialog* aDlg = NULL; switch ( theCommandID ) @@ -91,15 +78,15 @@ bool BuildGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case 4084: aDlg = new BuildGUI_ShellDlg ( getGeometryGUI(), parent, "" ); break; case 4085: aDlg = new BuildGUI_SolidDlg ( getGeometryGUI(), parent, "" ); break; case 4086: aDlg = new BuildGUI_CompoundDlg( getGeometryGUI(), parent, "" ); break; - + default: - SUIT_Session::session()->activeApplication()->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); + getGeometryGUI()->getApp()->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; } - + if ( aDlg != NULL ) aDlg->show(); - + return true; } @@ -113,6 +100,6 @@ extern "C" #endif GEOMGUI* GetLibGUI( GeometryGUI* parent ) { - return BuildGUI::GetBuildGUI( parent ); + return new BuildGUI( parent ); } } diff --git a/src/BuildGUI/BuildGUI.h b/src/BuildGUI/BuildGUI.h index 4b50efd9a..0688cabb8 100644 --- a/src/BuildGUI/BuildGUI.h +++ b/src/BuildGUI/BuildGUI.h @@ -17,14 +17,13 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // // File : BuildGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header$ #ifndef BUILDGUI_H #define BUILDGUI_H @@ -37,19 +36,11 @@ //================================================================================= class BuildGUI : public GEOMGUI { -protected: - BuildGUI( GeometryGUI* parent ); // hide constructor to avoid direct creation - public : + BuildGUI( GeometryGUI* parent ); ~BuildGUI(); - // Get the only BuildGUI object - static BuildGUI* GetBuildGUI( GeometryGUI* parent ); - bool OnGUIEvent( int theCommandID, SUIT_Desktop* parent ); - -private: - static BuildGUI* myGUIObject; // the only BuildGUI object }; #endif diff --git a/src/DisplayGUI/DisplayGUI.cxx b/src/DisplayGUI/DisplayGUI.cxx index 3e7b44dd6..504f861f6 100644 --- a/src/DisplayGUI/DisplayGUI.cxx +++ b/src/DisplayGUI/DisplayGUI.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -59,21 +59,6 @@ #include -DisplayGUI* DisplayGUI::myGUIObject = 0; - -//======================================================================= -// function : DisplayGUI::GetDisplayGUI() -// purpose : Get the only DisplayGUI object [ static ] -//======================================================================= -DisplayGUI* DisplayGUI::GetDisplayGUI( GeometryGUI* parent ) -{ - if ( myGUIObject == 0 ) { - // init DisplayGUI only once - myGUIObject = new DisplayGUI( parent ); - } - return myGUIObject; -} - //======================================================================= // function : DisplayGUI::DisplayGUI() // purpose : Constructor @@ -82,7 +67,6 @@ DisplayGUI::DisplayGUI( GeometryGUI* parent ) : GEOMGUI( parent ) { } - //======================================================================= // function : DisplayGUI::~DisplayGUI() // purpose : Destructor @@ -98,63 +82,64 @@ DisplayGUI::~DisplayGUI() //======================================================================= bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) { - DisplayGUI* myDisplayGUI = GetDisplayGUI( getGeometryGUI() ); - LightApp_SelectionMgr *Sel = getGeometryGUI()->getApp()->selectionMgr(); + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if (!app) return false; + + LightApp_SelectionMgr *Sel = app->selectionMgr(); SALOME_ListIO selected; Sel->selectedObjects( selected ); switch (theCommandID) { case 211: // MENU VIEW - WIREFRAME/SHADING { - myDisplayGUI->InvertDisplayMode(); - int newMode = myDisplayGUI->GetDisplayMode(); - getGeometryGUI()->action( 211 )->setMenuText( newMode == 1 ? tr( "GEOM_MEN_WIREFRAME" ) : tr("GEOM_MEN_SHADING") ); + InvertDisplayMode(); + int newMode = GetDisplayMode(); + getGeometryGUI()->action( 211 )->setMenuText + ( newMode == 1 ? tr( "GEOM_MEN_WIREFRAME" ) : tr("GEOM_MEN_SHADING") ); getGeometryGUI()->menuMgr()->update(); -// SUIT_Session::session()->activeApplication()->desktop()->menuBar()-> -// changeItem( 211, newMode == 1 ? tr( "GEOM_MEN_WIREFRAME" ) : tr("GEOM_MEN_SHADING") ); break; } case 212: // MENU VIEW - DISPLAY ALL { getGeometryGUI()->EmitSignalDeactivateDialog(); - myDisplayGUI->DisplayAll(); + DisplayAll(); break; } case 213: // MENU VIEW - DISPLAY ONLY { getGeometryGUI()->EmitSignalDeactivateDialog(); - myDisplayGUI->DisplayOnly(); + DisplayOnly(); break; } case 214: // MENU VIEW - ERASE ALL { - myDisplayGUI->EraseAll(); + EraseAll(); break; } case 215: // MENU VIEW - ERASE { - myDisplayGUI->Erase(); + Erase(); break; } case 216: // MENU VIEW - DISPLAY { getGeometryGUI()->EmitSignalDeactivateDialog(); - myDisplayGUI->Display(); + Display(); break; } case 80311: // POPUP VIEWER - WIREFRAME { - myDisplayGUI->ChangeDisplayMode( 0 ); + ChangeDisplayMode( 0 ); break; } case 80312: // POPUP VIEWER - SHADING { - myDisplayGUI->ChangeDisplayMode( 1 ); + ChangeDisplayMode( 1 ); break; } default: { - SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); break; } } @@ -168,7 +153,10 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) //===================================================================================== void DisplayGUI::DisplayAll() { - SalomeApp_Study* appStudy = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return; + + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); if ( !appStudy ) return; _PTR(Study) aStudy = appStudy->studyDS(); if ( !aStudy ) return; @@ -186,7 +174,9 @@ void DisplayGUI::DisplayAll() _PTR(SObject) valSO ( anIter->Value() ); _PTR(SObject) refSO; if ( !valSO->ReferencedObject( refSO ) ) { - listIO.Append( new SALOME_InteractiveObject( valSO->GetID().c_str(), SC->ComponentDataType().c_str() ,valSO->GetName().c_str() ) ); + listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(), + SC->ComponentDataType().c_str(), + valSO->GetName().c_str()) ); } anIter->Next(); } @@ -201,7 +191,7 @@ void DisplayGUI::EraseAll() { SUIT_OverrideCursor(); - SUIT_Application* app = SUIT_Session::session()->activeApplication(); + SUIT_Application* app = getGeometryGUI()->getApp(); if ( app ) { SUIT_ViewWindow* vw = app->desktop()->activeWindow(); if ( vw ) { @@ -232,28 +222,28 @@ void DisplayGUI::DisplayOnly() void DisplayGUI::Display() { SALOME_ListIO listIO; - - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + + SalomeApp_Application* app = getGeometryGUI()->getApp(); if ( !app ) return; SalomeApp_Study* anActiveStudy = dynamic_cast( app->activeStudy() ); if ( !anActiveStudy ) return; - + //get SalomeApp selection manager LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); if ( !aSelMgr ) return; - + SALOME_ListIO aList; aSelMgr->selectedObjects( aList ); SALOME_ListIteratorOfListIO It( aList ); - + SUIT_OverrideCursor(); for( ;It.More();It.Next() ) { Handle(SALOME_InteractiveObject) anIObject = It.Value(); if ( anIObject->hasEntry() ) { _PTR(SObject) SO ( anActiveStudy->studyDS()->FindObjectID( anIObject->getEntry() ) ); - if ( SO && QString( SO->GetID().c_str() ) == QString( SO->GetFatherComponent()->GetID().c_str() ) ) { + if ( SO && QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str()) ) { _PTR(SComponent) SC ( SO->GetFatherComponent() ); // if component is selected listIO.Clear(); @@ -263,8 +253,10 @@ void DisplayGUI::Display() _PTR(SObject) valSO ( anIter->Value() ); _PTR(SObject) refSO; if ( !valSO->ReferencedObject( refSO ) ) { - listIO.Append( new SALOME_InteractiveObject( valSO->GetID().c_str(), SC->ComponentDataType().c_str() ,valSO->GetName().c_str() ) ); - } + listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(), + SC->ComponentDataType().c_str(), + valSO->GetName().c_str()) ); + } anIter->Next(); } break; @@ -289,27 +281,27 @@ void DisplayGUI::Erase() { SALOME_ListIO listIO; - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Application* app = getGeometryGUI()->getApp(); if ( !app ) return; SalomeApp_Study* anActiveStudy = dynamic_cast( app->activeStudy() ); if ( !anActiveStudy ) return; - + //get SalomeApp selection manager LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); if ( !aSelMgr ) return; - + SALOME_ListIO aList; aSelMgr->selectedObjects( aList ); SALOME_ListIteratorOfListIO It( aList ); SUIT_OverrideCursor(); - for( ;It.More();It.Next() ) { + for( ; It.More(); It.Next() ) { Handle(SALOME_InteractiveObject) anIObject = It.Value(); if ( anIObject->hasEntry() ) { _PTR(SObject) SO ( anActiveStudy->studyDS()->FindObjectID( anIObject->getEntry() ) ); - if ( SO && QString( SO->GetID().c_str() ) == QString( SO->GetFatherComponent()->GetID().c_str() ) ) { + if ( SO && QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str()) ) { _PTR(SComponent) SC ( SO->GetFatherComponent() ); // if component is selected listIO.Clear(); @@ -319,8 +311,10 @@ void DisplayGUI::Erase() _PTR(SObject) valSO ( anIter->Value() ); _PTR(SObject) refSO; if ( !valSO->ReferencedObject( refSO ) ) { - listIO.Append( new SALOME_InteractiveObject( valSO->GetID().c_str(), SC->ComponentDataType().c_str() ,valSO->GetName().c_str() ) ); - } + listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(), + SC->ComponentDataType().c_str(), + valSO->GetName().c_str()) ); + } anIter->Next(); } break; @@ -334,7 +328,7 @@ void DisplayGUI::Erase() } } GEOM_Displayer(anActiveStudy).Erase( listIO, true ); - ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->clearSelected(); + getGeometryGUI()->getApp()->selectionMgr()->clearSelected(); } //===================================================================================== @@ -346,7 +340,7 @@ void DisplayGUI::SetDisplayMode( const int mode, SUIT_ViewWindow* viewWindow ) SUIT_OverrideCursor(); if ( !viewWindow ) - viewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); + viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow(); if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) { SVTK_View* aView = ((SVTK_ViewWindow*)viewWindow)->getView(); aView->SetDisplayMode( mode ); @@ -360,7 +354,7 @@ void DisplayGUI::SetDisplayMode( const int mode, SUIT_ViewWindow* viewWindow ) AIS_ListOfInteractive List1; ic->ObjectsInCollector( List1 ); List.Append( List1 ); - + AIS_ListIteratorOfListOfInteractive ite( List ); while( ite.More() ) { if( ite.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) { @@ -369,7 +363,7 @@ void DisplayGUI::SetDisplayMode( const int mode, SUIT_ViewWindow* viewWindow ) } ite.Next(); } - + ic->SetDisplayMode( newmode, Standard_False ); } } @@ -382,7 +376,7 @@ int DisplayGUI::GetDisplayMode( SUIT_ViewWindow* viewWindow ) { int dispMode = 0; if ( !viewWindow ) - viewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); + viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow(); if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) { SVTK_View* aView = ((SVTK_ViewWindow*)viewWindow)->getView(); dispMode = aView->GetDisplayMode(); @@ -413,19 +407,19 @@ void DisplayGUI::InvertDisplayMode( SUIT_ViewWindow* viewWindow ) //===================================================================================== void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow ) { - if ( !viewWindow ) - viewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Application* app = getGeometryGUI()->getApp(); if ( !app ) return; + if ( !viewWindow ) + viewWindow = app->desktop()->activeWindow(); + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); if ( !aSelMgr ) return; - + SUIT_OverrideCursor(); SALOME_ListIO aList; - + if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) { SVTK_ViewWindow* vw = dynamic_cast( viewWindow ); SVTK_View* aView = vw->getView(); @@ -435,7 +429,8 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow for( ;It.More(); It.Next() ) { SVTK_Viewer* stvkViewer = dynamic_cast(vw->getViewManager()->getViewModel()); - SVTK_Prs* vtkPrs = stvkViewer ? dynamic_cast( stvkViewer->CreatePrs( It.Value()->getEntry() ) ) : 0; + SVTK_Prs* vtkPrs = + stvkViewer ? dynamic_cast( stvkViewer->CreatePrs( It.Value()->getEntry() ) ) : 0; if ( vtkPrs && !vtkPrs->IsNull() ) { if ( mode == 0 ) aView->ChangeRepresentationToWireframe( vtkPrs->GetObjects() ); @@ -480,6 +475,6 @@ extern "C" #endif GEOMGUI* GetLibGUI( GeometryGUI* parent ) { - return DisplayGUI::GetDisplayGUI( parent ); + return new DisplayGUI( parent ); } } diff --git a/src/DisplayGUI/DisplayGUI.h b/src/DisplayGUI/DisplayGUI.h index 2ed2ccad4..981c1c58f 100644 --- a/src/DisplayGUI/DisplayGUI.h +++ b/src/DisplayGUI/DisplayGUI.h @@ -17,30 +17,26 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // // File : DisplayGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header$ #ifndef DISPLAYGUI_H #define DISPLAYGUI_H #include "GEOMGUI.h" #include "GEOMBase.h" -//#ifdef WNT -//#include -//#else -//#define SALOME_WNT_EXPORT -//#endif + #if defined WNT && defined WIN32 && defined SALOME_WNT_EXPORTS #define DISPLAYGUI_WNT_EXPORT __declspec( dllexport ) #else #define DISPLAYGUI_WNT_EXPORT #endif + //================================================================================= // class : GEOMBase_Display // purpose : @@ -49,15 +45,10 @@ class SUIT_ViewWindow; class DisplayGUI : public GEOMGUI { -protected: - DisplayGUI( GeometryGUI* parent ); // hide constructor to avoid direct creation - -public : +public: + DisplayGUI( GeometryGUI* parent ); ~DisplayGUI(); - // Get the only DisplayGUI object - static DisplayGUI* GetDisplayGUI( GeometryGUI* parent ); - // Dispatch menu command bool OnGUIEvent(int theCommandID, SUIT_Desktop* parent); @@ -84,9 +75,6 @@ public : // Set display mode for selected objects in the viewer given // (current viewer if = 0 ) void ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindo = 0 ); - -private: - static DisplayGUI* myGUIObject; // the only DisplayGUI object }; #endif diff --git a/src/EntityGUI/EntityGUI.cxx b/src/EntityGUI/EntityGUI.cxx index 05a19038a..5fd229aaf 100644 --- a/src/EntityGUI/EntityGUI.cxx +++ b/src/EntityGUI/EntityGUI.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -37,6 +37,7 @@ #include "OCCViewer_ViewManager.h" #include "SalomeApp_Study.h" #include "SalomeApp_Tools.h" +#include "SalomeApp_Application.h" #include #include @@ -50,15 +51,6 @@ using namespace boost; using namespace std; -//======================================================================= -// function : GetEntityGUI() -// purpose : Get the only EntityGUI object [ static ] -//======================================================================= -EntityGUI* EntityGUI::GetEntityGUI( GeometryGUI* parent ) -{ - return new EntityGUI( parent ); -} - //======================================================================= // function : EntityGUI() // purpose : Constructor @@ -84,6 +76,9 @@ EntityGUI::~EntityGUI() //======================================================================= bool EntityGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) { + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + getGeometryGUI()->EmitSignalDeactivateDialog(); QDialog* aDlg = NULL; @@ -97,7 +92,7 @@ bool EntityGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) aDlg = new EntityGUI_SubShapeDlg(getGeometryGUI(), parent, ""); break; default: - SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); break; } if ( aDlg ) @@ -113,8 +108,10 @@ bool EntityGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) //===================================================================================== void EntityGUI::DisplaySimulationShape(const TopoDS_Shape& S1, const TopoDS_Shape& S2) { - SUIT_ViewManager* aVM = - SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager(); + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return; + + SUIT_ViewManager* aVM = app->desktop()->activeWindow()->getViewManager(); if (aVM->getType() != OCCViewer_Viewer::Type()) return; @@ -129,7 +126,7 @@ void EntityGUI::DisplaySimulationShape(const TopoDS_Shape& S1, const TopoDS_Shap mySimulationShape1 = new AIS_Shape(TopoDS_Shape()); mySimulationShape1->Set(S1); mySimulationShape1->SetColor(Quantity_NOC_RED); - + ic->Deactivate(mySimulationShape1); ic->Display(mySimulationShape1, Standard_False); mySimulationShape1->UnsetColor(); @@ -160,15 +157,18 @@ void EntityGUI::DisplaySimulationShape(const TopoDS_Shape& S1, const TopoDS_Shap //================================================================================== void EntityGUI::EraseSimulationShape() { + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return; + // get all view windows at the desktop - QPtrList aWndLst = SUIT_Session::session()->activeApplication()->desktop()->windows(); + QPtrList aWndLst = app->desktop()->windows(); //get all view windows, which belong to the active study QPtrList aWndLstAS; SUIT_ViewWindow* vw; for ( vw = aWndLst.first(); vw; vw = aWndLst.next() ) - if ( vw->getViewManager()->study() == SUIT_Session::session()->activeApplication()->activeStudy() ) + if ( vw->getViewManager()->study() == app->activeStudy() ) aWndLstAS.append( vw ); - + for ( vw = aWndLstAS.first(); vw; vw = aWndLstAS.next() ) { if ( vw->getViewManager()->getType() == OCCViewer_Viewer::Type() ) { OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(vw->getViewManager()))->getOCCViewer(); @@ -188,9 +188,11 @@ void EntityGUI::EraseSimulationShape() //===================================================================================== bool EntityGUI::SObjectExist(const _PTR(SObject)& theFatherObject, const char* IOR) { - SalomeApp_Study* appStudy = dynamic_cast - ( SUIT_Session::session()->activeApplication()->activeStudy() ); + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); if ( !appStudy ) return false; + _PTR(Study) aStudy = appStudy->studyDS(); _PTR(ChildIterator) it ( aStudy->NewChildIterator(theFatherObject) ); _PTR(SObject) RefSO; @@ -224,6 +226,6 @@ extern "C" #endif GEOMGUI* GetLibGUI( GeometryGUI* parent ) { - return EntityGUI::GetEntityGUI( parent ); + return new EntityGUI( parent ); } } diff --git a/src/EntityGUI/EntityGUI.h b/src/EntityGUI/EntityGUI.h index 560a8cae1..f69297f8f 100644 --- a/src/EntityGUI/EntityGUI.h +++ b/src/EntityGUI/EntityGUI.h @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -41,15 +41,10 @@ //================================================================================= class EntityGUI : public GEOMGUI { -protected: - EntityGUI( GeometryGUI* parent ); // hide constructor to avoid direct creation - public : + EntityGUI( GeometryGUI* parent ); // hide constructor to avoid direct creation ~EntityGUI(); - // Get the only EntityGUI object - static EntityGUI* GetEntityGUI( GeometryGUI* parent ); - bool OnGUIEvent(int theCommandID, SUIT_Desktop* parent); void DisplaySimulationShape(const TopoDS_Shape& S1, const TopoDS_Shape& S2); diff --git a/src/GenerationGUI/GenerationGUI.cxx b/src/GenerationGUI/GenerationGUI.cxx index 3b26e8aee..90abc0f50 100644 --- a/src/GenerationGUI/GenerationGUI.cxx +++ b/src/GenerationGUI/GenerationGUI.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -31,6 +31,8 @@ #include "SUIT_Session.h" #include "SUIT_Desktop.h" +#include "SalomeApp_Application.h" + #include "GenerationGUI_PrismDlg.h" // Method PRISM #include "GenerationGUI_RevolDlg.h" // Method REVOL #include "GenerationGUI_FillingDlg.h" // Method FILLING @@ -38,20 +40,6 @@ using namespace std; -GenerationGUI* GenerationGUI::myGUIObject = 0; - -//======================================================================= -// function : GetGenerationGUI() -// purpose : Get the only GenerationGUI object [ static ] -//======================================================================= -GenerationGUI* GenerationGUI::GetGenerationGUI(GeometryGUI* parent) -{ - if ( myGUIObject == 0 ) - myGUIObject = new GenerationGUI(parent); - - return myGUIObject; -} - //======================================================================= // function : GenerationGUI() // purpose : Constructor @@ -60,7 +48,6 @@ GenerationGUI::GenerationGUI(GeometryGUI* parent) : GEOMGUI(parent) { } - //======================================================================= // function : ~GenerationGUI() // purpose : Destructor @@ -76,23 +63,26 @@ GenerationGUI::~GenerationGUI() //======================================================================= bool GenerationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) { + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + getGeometryGUI()->EmitSignalDeactivateDialog(); - + QDialog* aDlg = NULL; - switch ( theCommandID ) + switch (theCommandID) { case 4031: aDlg = new GenerationGUI_PrismDlg ( getGeometryGUI(), parent, ""); break; case 4032: aDlg = new GenerationGUI_RevolDlg ( getGeometryGUI(), parent, ""); break; case 4033: aDlg = new GenerationGUI_FillingDlg ( getGeometryGUI(), parent, ""); break; case 4034: aDlg = new GenerationGUI_PipeDlg ( getGeometryGUI(), parent, ""); break; - default: SUIT_Session::session()->activeApplication()->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; + default: app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; } - if ( aDlg != NULL ) + if (aDlg != NULL) aDlg->show(); - + return true; } @@ -107,6 +97,6 @@ extern "C" #endif GEOMGUI* GetLibGUI(GeometryGUI* parent) { - return GenerationGUI::GetGenerationGUI(parent); + return new GenerationGUI(parent); } } diff --git a/src/GenerationGUI/GenerationGUI.h b/src/GenerationGUI/GenerationGUI.h index 2e1d41496..8f5f2d735 100644 --- a/src/GenerationGUI/GenerationGUI.h +++ b/src/GenerationGUI/GenerationGUI.h @@ -17,14 +17,13 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // // File : GenerationGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header$ #ifndef GENERATIONGUI_H #define GENERATIONGUI_H @@ -37,19 +36,11 @@ //================================================================================= class GenerationGUI : public GEOMGUI { -protected: - GenerationGUI(GeometryGUI* parent); // hide constructor to avoid direct creation - -public : +public: + GenerationGUI(GeometryGUI* parent); ~GenerationGUI(); - // Get the only GenerationGUI object - static GenerationGUI* GetGenerationGUI(GeometryGUI* parent); - bool OnGUIEvent( int theCommandID, SUIT_Desktop* parent ); - -private: - static GenerationGUI* myGUIObject; // the only GenerationGUI object }; #endif diff --git a/src/GroupGUI/GroupGUI.cxx b/src/GroupGUI/GroupGUI.cxx index fc0ebafe3..e335605c6 100644 --- a/src/GroupGUI/GroupGUI.cxx +++ b/src/GroupGUI/GroupGUI.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -38,20 +38,6 @@ #include "SalomeApp_Study.h" #include "LightApp_SelectionMgr.h" -GroupGUI* GroupGUI::myGUIObject = 0; - -//======================================================================= -// function : GetGroupGUI() -// purpose : Get the only GroupGUI object [ static ] -//======================================================================= -GroupGUI* GroupGUI::GetGroupGUI(GeometryGUI* parent) -{ - if ( myGUIObject == 0 ) - myGUIObject = new GroupGUI(parent); - - return myGUIObject; -} - //======================================================================= // function : GroupGUI() // purpose : Constructor @@ -76,12 +62,14 @@ GroupGUI::~GroupGUI() //======================================================================= bool GroupGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) { + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + getGeometryGUI()->EmitSignalDeactivateDialog(); QDialog* aDlg = NULL; - SUIT_Application* suitApp = SUIT_Session::session()->activeApplication(); - SalomeApp_Study* appStudy = dynamic_cast(suitApp->activeStudy()); + SalomeApp_Study* appStudy = dynamic_cast(app->activeStudy()); if ( !appStudy ) return false; _PTR(Study) aStudy = appStudy->studyDS(); @@ -103,12 +91,9 @@ bool GroupGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) SALOME_ListIO aList; aList.Clear(); - SalomeApp_Application* app = dynamic_cast(suitApp); - if (app) { - LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); - if (aSelMgr) - aSelMgr->selectedObjects(aList); - } + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if (aSelMgr) + aSelMgr->selectedObjects(aList); if (aList.Extent() == 1) { Standard_Boolean aResult = Standard_False; @@ -124,7 +109,7 @@ bool GroupGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) break; } default: - suitApp->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); break; } @@ -144,6 +129,6 @@ extern "C" #endif GEOMGUI* GetLibGUI(GeometryGUI* p) { - return GroupGUI::GetGroupGUI(p); + return new GroupGUI(p); } } diff --git a/src/GroupGUI/GroupGUI.h b/src/GroupGUI/GroupGUI.h index a699547ff..71bac9677 100644 --- a/src/GroupGUI/GroupGUI.h +++ b/src/GroupGUI/GroupGUI.h @@ -17,14 +17,13 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // // File : GroupGUI.h // Author : Sergey ANIKIN // Module : GEOM -// $Header$ #ifndef GROUPGUI_H #define GROUPGUI_H @@ -39,19 +38,11 @@ class GroupGUI : public GEOMGUI { Q_OBJECT -protected: - GroupGUI(GeometryGUI* parent); // hide constructor to avoid direct creation - -public : +public: + GroupGUI(GeometryGUI* parent); ~GroupGUI(); - // Get the only GroupGUI object - static GroupGUI* GetGroupGUI(GeometryGUI* parent); - bool OnGUIEvent( int theCommandID, SUIT_Desktop* parent ); - -private: - static GroupGUI* myGUIObject; // the only GroupGUI object }; #endif diff --git a/src/MeasureGUI/MeasureGUI.cxx b/src/MeasureGUI/MeasureGUI.cxx index 8e9bc31b9..2b2186d91 100644 --- a/src/MeasureGUI/MeasureGUI.cxx +++ b/src/MeasureGUI/MeasureGUI.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -31,6 +31,7 @@ #include "SUIT_Session.h" #include "SalomeApp_Tools.h" +#include "SalomeApp_Application.h" #include "MeasureGUI_PropertiesDlg.h" // Method PROPERTIES #include "MeasureGUI_CenterMassDlg.h" // Method CENTER MASS @@ -43,21 +44,6 @@ #include "MeasureGUI_CheckCompoundOfBlocksDlg.h" // Method CHECKCOMPOUND #include "MeasureGUI_PointDlg.h" // Method POINTCOORDINATES -MeasureGUI* MeasureGUI::myGUIObject = 0; - -//======================================================================= -// function : GetMeasureGUI() -// purpose : Get the only MeasureGUI object [ static ] -//======================================================================= -MeasureGUI* MeasureGUI::GetMeasureGUI( GeometryGUI* parent ) -{ - if ( myGUIObject == 0 ) { - // init MeasureGUI only once - myGUIObject = new MeasureGUI( parent ); - } - return myGUIObject; -} - //======================================================================= // function : MeasureGUI() // purpose : Constructor @@ -66,7 +52,6 @@ MeasureGUI::MeasureGUI( GeometryGUI* parent ) : GEOMGUI( parent ) { } - //======================================================================= // function : ~MeasureGUI() // purpose : Destructor @@ -82,7 +67,9 @@ MeasureGUI::~MeasureGUI() //======================================================================= bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) { - MeasureGUI* myMeasureGUI = GetMeasureGUI( getGeometryGUI() ); + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return false; + getGeometryGUI()->EmitSignalDeactivateDialog(); switch ( theCommandID ) @@ -99,7 +86,7 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case 708 : new MeasureGUI_PointDlg (getGeometryGUI(), parent); break; // POINT COORDINATES default: - SUIT_Session::session()->activeApplication()->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); + app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; } return true; @@ -116,6 +103,6 @@ extern "C" #endif GEOMGUI* GetLibGUI( GeometryGUI* parent ) { - return MeasureGUI::GetMeasureGUI( parent ); + return new MeasureGUI( parent ); } } diff --git a/src/MeasureGUI/MeasureGUI.h b/src/MeasureGUI/MeasureGUI.h index 36eaa6226..3d1596c37 100644 --- a/src/MeasureGUI/MeasureGUI.h +++ b/src/MeasureGUI/MeasureGUI.h @@ -17,14 +17,13 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // // File : MeasureGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header$ #ifndef MEASUREGUI_H #define MEASUREGUI_H @@ -37,16 +36,11 @@ //================================================================================= class MeasureGUI : public GEOMGUI { -protected: - MeasureGUI( GeometryGUI* parent ); +public: + MeasureGUI( GeometryGUI* parent ); + ~MeasureGUI(); -public : - ~MeasureGUI(); - static MeasureGUI* GetMeasureGUI( GeometryGUI* parent ); - bool OnGUIEvent( int , SUIT_Desktop* ); - -private: - static MeasureGUI* myGUIObject; + bool OnGUIEvent( int , SUIT_Desktop* ); }; #endif diff --git a/src/OperationGUI/OperationGUI.cxx b/src/OperationGUI/OperationGUI.cxx index e13817f64..1372e926d 100644 --- a/src/OperationGUI/OperationGUI.cxx +++ b/src/OperationGUI/OperationGUI.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -45,21 +45,6 @@ using namespace std; -OperationGUI* OperationGUI::myGUIObject = 0; - -//======================================================================= -// function : GetOperationGUI() -// purpose : Get the only OperationGUI object [ static ] -//======================================================================= -OperationGUI* OperationGUI::GetOperationGUI( GeometryGUI* parent ) -{ - if ( myGUIObject == 0 ) { - // init OperationGUI only once - myGUIObject = new OperationGUI( parent ); - } - return myGUIObject; -} - //======================================================================= // function : OperationGUI() // purpose : Constructor @@ -68,7 +53,6 @@ OperationGUI::OperationGUI(GeometryGUI* parent) : GEOMGUI(parent) { } - //======================================================================= // function : ~OperationGUI() // purpose : Destructor @@ -84,6 +68,9 @@ OperationGUI::~OperationGUI() //======================================================================= bool OperationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) { + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if (!app) return false; + getGeometryGUI()->EmitSignalDeactivateDialog(); switch (theCommandID) @@ -94,7 +81,7 @@ bool OperationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case 506: (new OperationGUI_ChamferDlg (getGeometryGUI(), parent))->show(); break; case 507: (new OperationGUI_ClippingDlg (getGeometryGUI(), parent))->show(); break; default: - getGeometryGUI()->getApp()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); } return true; @@ -110,6 +97,6 @@ extern "C" #endif GEOMGUI* GetLibGUI(GeometryGUI* parent) { - return OperationGUI::GetOperationGUI(parent); + return new OperationGUI(parent); } } diff --git a/src/OperationGUI/OperationGUI.h b/src/OperationGUI/OperationGUI.h index 2fc7059ef..d2bd5662b 100644 --- a/src/OperationGUI/OperationGUI.h +++ b/src/OperationGUI/OperationGUI.h @@ -17,14 +17,13 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // // File : OperationGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header$ #ifndef OPERATIONGUI_H #define OPERATIONGUI_H @@ -38,19 +37,11 @@ //================================================================================= class OperationGUI : public GEOMGUI { -protected: - OperationGUI( GeometryGUI* parent ); // hide constructor to avoid direct creation - public : + OperationGUI( GeometryGUI* parent ); ~OperationGUI(); - // Get the only OperationGUI object - static OperationGUI* GetOperationGUI( GeometryGUI* parent ); - bool OnGUIEvent(int theCommandID, SUIT_Desktop* parent); - -private: - static OperationGUI* myGUIObject; // the only OperationGUI object }; #endif diff --git a/src/PrimitiveGUI/PrimitiveGUI.cxx b/src/PrimitiveGUI/PrimitiveGUI.cxx index 218c832e6..45ca54db0 100644 --- a/src/PrimitiveGUI/PrimitiveGUI.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -33,26 +33,15 @@ #include "SUIT_Session.h" #include "SUIT_Desktop.h" +#include "SalomeApp_Application.h" + #include "PrimitiveGUI_BoxDlg.h" // Method BOX #include "PrimitiveGUI_CylinderDlg.h" // Method CYLINDER #include "PrimitiveGUI_SphereDlg.h" // Method SPHERE #include "PrimitiveGUI_TorusDlg.h" // Method TORUS #include "PrimitiveGUI_ConeDlg.h" // Method CONE -using namespace std; -PrimitiveGUI* PrimitiveGUI::myGUIObject = 0; -//======================================================================= -// function : GetPrimitiveGUI() -// purpose : Get the only PrimitiveGUI object [ static ] -//======================================================================= -PrimitiveGUI* PrimitiveGUI::GetPrimitiveGUI( GeometryGUI* parent ) -{ - if ( myGUIObject == 0 ) { - // init PrimitiveGUI only once - myGUIObject = new PrimitiveGUI( parent ); - } - return myGUIObject; -} +using namespace std; //======================================================================= // function : PrimitiveGUI() @@ -62,7 +51,6 @@ PrimitiveGUI::PrimitiveGUI(GeometryGUI* parent) : GEOMGUI(parent) { } - //======================================================================= // function : ~PrimitiveGUI // purpose : Destructor @@ -78,47 +66,38 @@ PrimitiveGUI::~PrimitiveGUI() //======================================================================= bool PrimitiveGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) { + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if (!app) return false; + getGeometryGUI()->EmitSignalDeactivateDialog(); - + QDialog* aDlg = NULL; switch (theCommandID) - { + { case 4021: // BOX - { aDlg = new PrimitiveGUI_BoxDlg(getGeometryGUI(), parent, ""); break; - } case 4022: // CYLINDER - { aDlg = new PrimitiveGUI_CylinderDlg(getGeometryGUI(), parent, ""); break; - } case 4023: // SPHERE - { aDlg = new PrimitiveGUI_SphereDlg(getGeometryGUI(), parent, ""); break; - } case 4024: // TORUS - { aDlg = new PrimitiveGUI_TorusDlg(getGeometryGUI(), parent, ""); break; - } case 4025: // CONE - { aDlg = new PrimitiveGUI_ConeDlg(getGeometryGUI(), parent, ""); break; - } default: - { - SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); break; - } } - if ( aDlg != NULL ) + if (aDlg != NULL) aDlg->show(); - + return true; } @@ -133,6 +112,6 @@ extern "C" #endif GEOMGUI* GetLibGUI( GeometryGUI* parent ) { - return PrimitiveGUI::GetPrimitiveGUI( parent ); + return new PrimitiveGUI( parent ); } } diff --git a/src/PrimitiveGUI/PrimitiveGUI.h b/src/PrimitiveGUI/PrimitiveGUI.h index 9bdef3508..ff2267323 100644 --- a/src/PrimitiveGUI/PrimitiveGUI.h +++ b/src/PrimitiveGUI/PrimitiveGUI.h @@ -17,14 +17,13 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // // File : PrimitiveGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header$ #ifndef PRIMITIVEGUI_H #define PRIMITIVEGUI_H @@ -38,19 +37,11 @@ //================================================================================= class PrimitiveGUI : public GEOMGUI { -protected: - PrimitiveGUI(GeometryGUI* parent); // hide constructor to avoid direct creation - -public : +public: + PrimitiveGUI(GeometryGUI* parent); ~PrimitiveGUI(); - // Get the only PrimitiveGUI object - static PrimitiveGUI* GetPrimitiveGUI(GeometryGUI* parent); - bool OnGUIEvent(int theCommandID, SUIT_Desktop* parent); - -private: - static PrimitiveGUI* myGUIObject; // the only PrimitiveGUI object }; #endif diff --git a/src/RepairGUI/RepairGUI.cxx b/src/RepairGUI/RepairGUI.cxx index 8e5f50a1e..32853a771 100644 --- a/src/RepairGUI/RepairGUI.cxx +++ b/src/RepairGUI/RepairGUI.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -31,6 +31,8 @@ #include "SUIT_Desktop.h" #include "SUIT_Session.h" +#include "SalomeApp_Application.h" + #include "RepairGUI_SewingDlg.h" // Method SEWING #include "RepairGUI_SuppressFacesDlg.h" // Method SUPPRESS FACES #include "RepairGUI_RemoveHolesDlg.h" // Method SUPPRESS HOLE @@ -46,21 +48,6 @@ using namespace std; -RepairGUI* RepairGUI::myGUIObject = 0; - -//======================================================================= -// function : GetRepairGUI() -// purpose : Get the only RepairGUI object [ static ] -//======================================================================= -RepairGUI* RepairGUI::GetRepairGUI( GeometryGUI* parent ) -{ - if ( myGUIObject == 0 ) { - // init RepairGUI only once - myGUIObject = new RepairGUI( parent ); - } - return myGUIObject; -} - //======================================================================= // function : RepairGUI() // purpose : Constructor @@ -69,7 +56,6 @@ RepairGUI::RepairGUI( GeometryGUI* parent ) : GEOMGUI( parent ) { } - //======================================================================= // function : ~RepairGUI() // purpose : Destructor @@ -85,6 +71,9 @@ RepairGUI::~RepairGUI() //======================================================================= bool RepairGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) { + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if (!app) return false; + getGeometryGUI()->EmitSignalDeactivateDialog(); QDialog* aDlg = NULL; @@ -100,7 +89,7 @@ bool RepairGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) case 609: aDlg = new RepairGUI_FreeBoundDlg (getGeometryGUI(), parent, ""); break; case 610: aDlg = new RepairGUI_FreeFacesDlg (getGeometryGUI(), parent, ""); break; default: - SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); break; } @@ -121,6 +110,6 @@ extern "C" #endif GEOMGUI* GetLibGUI( GeometryGUI* parent ) { - return RepairGUI::GetRepairGUI( parent ); + return new RepairGUI( parent ); } } diff --git a/src/RepairGUI/RepairGUI.h b/src/RepairGUI/RepairGUI.h index bbeadad2c..a99916239 100644 --- a/src/RepairGUI/RepairGUI.h +++ b/src/RepairGUI/RepairGUI.h @@ -17,14 +17,13 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // // File : RepairGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header$ #ifndef REPAIRGUI_H #define REPAIRGUI_H @@ -38,20 +37,11 @@ //================================================================================= class RepairGUI : public GEOMGUI { -protected: - RepairGUI( GeometryGUI* parent ); // hide constructor to avoid direct creation - -public : +public: + RepairGUI( GeometryGUI* parent ); ~RepairGUI(); - // Get the only RepairGUI object - static RepairGUI* GetRepairGUI( GeometryGUI* parent ); - bool OnGUIEvent(int theCommandID, SUIT_Desktop* parent); - -private: - static RepairGUI* myGUIObject; // the only RepairGUI object - }; #endif diff --git a/src/TransformationGUI/TransformationGUI.cxx b/src/TransformationGUI/TransformationGUI.cxx index cbeccad42..eb69c9037 100644 --- a/src/TransformationGUI/TransformationGUI.cxx +++ b/src/TransformationGUI/TransformationGUI.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -32,6 +32,8 @@ #include "SUIT_Session.h" #include "SUIT_Desktop.h" +#include "SalomeApp_Application.h" + #include "TransformationGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION #include "TransformationGUI_MultiRotationDlg.h" // Method MULTI ROTATION #include "TransformationGUI_TranslationDlg.h" // Method TRANSLATION @@ -43,21 +45,6 @@ using namespace std; -TransformationGUI* TransformationGUI::myGUIObject = 0; - -//======================================================================= -// function : GetTransformationGUI() -// purpose : Get the only TransformationGUI object [ static ] -//======================================================================= -TransformationGUI* TransformationGUI::GetTransformationGUI( GeometryGUI* parent ) -{ - if ( myGUIObject == 0 ) { - // init TransformationGUI only once - myGUIObject = new TransformationGUI( parent ); - } - return myGUIObject; -} - //======================================================================= // function : TransformationGUI() // purpose : Constructor @@ -66,7 +53,6 @@ TransformationGUI::TransformationGUI(GeometryGUI* parent) : GEOMGUI(parent) { } - //======================================================================= // function : ~TransformationGUI() // purpose : Destructor @@ -82,6 +68,9 @@ TransformationGUI::~TransformationGUI() //======================================================================= bool TransformationGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) { + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if (!app) return false; + getGeometryGUI()->EmitSignalDeactivateDialog(); QDialog* aDlg = NULL; @@ -112,11 +101,11 @@ bool TransformationGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) aDlg = new TransformationGUI_MultiRotationDlg( getGeometryGUI(), parent, "" ); break; default: - SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); break; } - if ( aDlg != NULL ) + if (aDlg != NULL) aDlg->show(); return true; @@ -133,6 +122,6 @@ extern "C" #endif GEOMGUI* GetLibGUI( GeometryGUI* parent ) { - return TransformationGUI::GetTransformationGUI( parent ); + return new TransformationGUI( parent ); } } diff --git a/src/TransformationGUI/TransformationGUI.h b/src/TransformationGUI/TransformationGUI.h index 77ef5de5f..87ba9b55d 100644 --- a/src/TransformationGUI/TransformationGUI.h +++ b/src/TransformationGUI/TransformationGUI.h @@ -17,14 +17,13 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // // File : TransformationGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header$ #ifndef TRANSFORMATIONGUI_H #define TRANSFORMATIONGUI_H @@ -38,19 +37,11 @@ //================================================================================= class TransformationGUI : public GEOMGUI { -protected: - TransformationGUI( GeometryGUI* parent ); // hide constructor to avoid direct creation - -public : +public: + TransformationGUI( GeometryGUI* parent ); ~TransformationGUI(); - // Get the only TransformationGUI object - static TransformationGUI* GetTransformationGUI( GeometryGUI* parent ); - bool OnGUIEvent(int theCommandID, SUIT_Desktop* parent); - -private: - static TransformationGUI* myGUIObject; // the only TransformationGUI object }; #endif