Salome HOME
isReadyToStart method added
authorsln <sln@opencascade.com>
Fri, 1 Jul 2005 13:51:56 +0000 (13:51 +0000)
committersln <sln@opencascade.com>
Fri, 1 Jul 2005 13:51:56 +0000 (13:51 +0000)
src/SMESHGUI/SMESHGUI_Operation.cxx
src/SMESHGUI/SMESHGUI_Operation.h
src/SMESHGUI/SMESH_msg_en.po

index f810298375be6f266953fb39caba55af79107a9a..6ebf2d2b7279e47dfc6534f19a384c306d90984d 100755 (executable)
@@ -8,12 +8,14 @@
 //  Author : Sergey LITONIN
 //  Module : SALOME
 
-#include <SMESHGUI_Operation.h>
-#include <SMESHGUI.h>
-#include <SMESHGUI_VTKUtils.h>
+#include "SMESHGUI_Operation.h"
+#include "SMESHGUI.h"
+#include "SMESHGUI_VTKUtils.h"
 
 #include <SVTK_ViewWindow.h>
 #include <SVTK_Selector.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
 
 
 /*
@@ -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<SMESHGUI*>( 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;
+  }
+}
+
+
+
+
+
index 9c6c303fd2d23bc938b42cee16cc7e4930bca9e4..cbda5f6d07d07c816df87037324cfc7b32af5e8d 100755 (executable)
@@ -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
index f1f419eb42500f6dd33e24afc016fedcea150f8e..fec81586073cc0ade0aa4af5225178c1d3187271 100644 (file)
@@ -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"
+