From 2bd09d7cc73f5f5355c61bfa194c168b3480677e Mon Sep 17 00:00:00 2001 From: sln Date: Fri, 1 Jul 2005 13:51:56 +0000 Subject: [PATCH] isReadyToStart method added --- src/SMESHGUI/SMESHGUI_Operation.cxx | 91 +++++++++++++++++++++++------ src/SMESHGUI/SMESHGUI_Operation.h | 21 +++---- src/SMESHGUI/SMESH_msg_en.po | 6 ++ 3 files changed, 89 insertions(+), 29 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_Operation.cxx b/src/SMESHGUI/SMESHGUI_Operation.cxx index f81029837..6ebf2d2b7 100755 --- a/src/SMESHGUI/SMESHGUI_Operation.cxx +++ b/src/SMESHGUI/SMESHGUI_Operation.cxx @@ -8,12 +8,14 @@ // Author : Sergey LITONIN // Module : SALOME -#include -#include -#include +#include "SMESHGUI_Operation.h" +#include "SMESHGUI.h" +#include "SMESHGUI_VTKUtils.h" #include #include +#include +#include /* @@ -26,9 +28,7 @@ // Purpose : Constructor //======================================================================= SMESHGUI_Operation::SMESHGUI_Operation( SalomeApp_Application* app ) -: SalomeApp_Operation( app ), - myViewWindow( 0 ), - mySelector( 0 ) +: SalomeApp_Operation( app ) { } @@ -38,44 +38,97 @@ SMESHGUI_Operation::~SMESHGUI_Operation() } +//======================================================================= +// name : setSelectionMode +// Purpose : Set selection mode +//======================================================================= void SMESHGUI_Operation::setSelectionMode( const Selection_Mode mode ) { - if( myViewWindow ) - myViewWindow->SetSelectionMode( mode ); + SVTK_ViewWindow* wnd = viewWindow(); + if( wnd ) + wnd->SetSelectionMode( mode ); } +//======================================================================= +// name : highlight +// Purpose : Highlight object in 3d viewer +//======================================================================= void SMESHGUI_Operation::highlight( const Handle( SALOME_InteractiveObject )& obj, const bool hilight, const bool immediately ) { - if( myViewWindow ) - myViewWindow->highlight( obj, hilight, immediately ); + SVTK_ViewWindow* wnd = viewWindow(); + if( wnd ) + wnd->highlight( obj, hilight, immediately ); } +//======================================================================= +// name : addOrRemoveIndex +// Purpose : Select/deselect cells of mesh +//======================================================================= void SMESHGUI_Operation::addOrRemoveIndex( const Handle( SALOME_InteractiveObject )& obj, - const TColStd_MapOfInteger& indices, const bool isModeShift ) + const TColStd_MapOfInteger& indices, + const bool isModeShift ) { - if( mySelector ) - mySelector->AddOrRemoveIndex( obj, indices, isModeShift ); + SVTK_Selector* sel = selector(); + if( sel ) + sel->AddOrRemoveIndex( obj, indices, isModeShift ); } +//======================================================================= +// name : getSMESHGUI +// Purpose : Get SMESH module +//======================================================================= SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const { return dynamic_cast( module() ); } -SVTK_ViewWindow* SMESHGUI_Operation::getViewWindow() const +//======================================================================= +// name : viewWindow +// Purpose : Get active view window +//======================================================================= +SVTK_ViewWindow* SMESHGUI_Operation::viewWindow() const { - return myViewWindow; + return SMESH::GetViewWindow( getSMESHGUI() ); } -SVTK_Selector* SMESHGUI_Operation::getSelector() const +//======================================================================= +// name : selector +// Purpose : Get selector +//======================================================================= +SVTK_Selector* SMESHGUI_Operation::selector() const { - return mySelector; + SVTK_ViewWindow* wnd = viewWindow(); + return wnd ? wnd->GetSelector() : 0; } +//======================================================================= +// name : startOperation +// Purpose : Start opeartion +//======================================================================= void SMESHGUI_Operation::startOperation() { SalomeApp_Operation::startOperation(); - myViewWindow = SMESH::GetViewWindow( getSMESHGUI() ); - mySelector = myViewWindow ? myViewWindow->GetSelector() : 0; } + +//======================================================================= +// name : isReadyToStart +// Purpose : Verify whether operation is ready to start +//======================================================================= +bool SMESHGUI_Operation::isReadyToStart() +{ + if ( !SalomeApp_Operation::isReadyToStart() ) + return false; + + if ( getSMESHGUI() == 0 ) + { + SUIT_MessageBox::warn1( SMESHGUI::desktop(), tr( "SMESH_WRN_WARNING" ), + tr( "NO_MODULE" ), tr( "SMESH_BUT_OK" ) ); + return false; + } +} + + + + + diff --git a/src/SMESHGUI/SMESHGUI_Operation.h b/src/SMESHGUI/SMESHGUI_Operation.h index 9c6c303fd..cbda5f6d0 100755 --- a/src/SMESHGUI/SMESHGUI_Operation.h +++ b/src/SMESHGUI/SMESHGUI_Operation.h @@ -36,19 +36,20 @@ public: virtual ~SMESHGUI_Operation(); protected: - void setSelectionMode( const Selection_Mode ); - void highlight( const Handle( SALOME_InteractiveObject )&, const bool, const bool = true ); - void addOrRemoveIndex( const Handle( SALOME_InteractiveObject )&, const TColStd_MapOfInteger&, const bool ); - virtual void startOperation(); + void setSelectionMode( const Selection_Mode ); + void highlight( const Handle( SALOME_InteractiveObject )&, + const bool, const bool = true ); + void addOrRemoveIndex( const Handle( SALOME_InteractiveObject )&, + const TColStd_MapOfInteger&, const bool ); + + virtual void startOperation(); + virtual bool isReadyToStart(); - SMESHGUI* getSMESHGUI() const; - SVTK_ViewWindow* getViewWindow() const; - SVTK_Selector* getSelector() const; + SMESHGUI* getSMESHGUI() const; + SVTK_ViewWindow* viewWindow() const; + SVTK_Selector* selector() const; -private: - SVTK_ViewWindow* myViewWindow; - SVTK_Selector* mySelector; }; #endif diff --git a/src/SMESHGUI/SMESH_msg_en.po b/src/SMESHGUI/SMESH_msg_en.po index f1f419eb4..fec815860 100644 --- a/src/SMESHGUI/SMESH_msg_en.po +++ b/src/SMESHGUI/SMESH_msg_en.po @@ -2800,3 +2800,9 @@ msgstr "Nodes" msgid "SMESHGUI::PREF_ELEMENTS" msgstr "Elements" + +# ===================================================== + +msgid "SMESHGUI_Operation::NO_MODULE" +msgstr "There is no MESH module to start operation" + -- 2.39.2