3 // Copyright (C) 2005 CEA/DEN, EDF R&D
7 // File : SMESHGUI_Operation.h
8 // Author : Sergey LITONIN
11 #include "SMESHGUI_Operation.h"
13 #include "SMESHGUI_VTKUtils.h"
15 #include <SVTK_ViewWindow.h>
16 #include <SVTK_Selector.h>
17 #include <SUIT_MessageBox.h>
18 #include <SUIT_Desktop.h>
22 Class : SMESHGUI_Operation
23 Description : Base class for all SMESH operations
26 //=======================================================================
27 // name : SMESHGUI_Operation
28 // Purpose : Constructor
29 //=======================================================================
30 SMESHGUI_Operation::SMESHGUI_Operation( SalomeApp_Application* app )
31 : SalomeApp_Operation( app )
36 SMESHGUI_Operation::~SMESHGUI_Operation()
41 //=======================================================================
42 // name : setSelectionMode
43 // Purpose : Set selection mode
44 //=======================================================================
45 void SMESHGUI_Operation::setSelectionMode( const Selection_Mode mode )
47 SVTK_ViewWindow* wnd = viewWindow();
49 wnd->SetSelectionMode( mode );
52 //=======================================================================
54 // Purpose : Highlight object in 3d viewer
55 //=======================================================================
56 void SMESHGUI_Operation::highlight( const Handle( SALOME_InteractiveObject )& obj,
57 const bool hilight, const bool immediately )
59 SVTK_ViewWindow* wnd = viewWindow();
61 wnd->highlight( obj, hilight, immediately );
64 //=======================================================================
65 // name : addOrRemoveIndex
66 // Purpose : Select/deselect cells of mesh
67 //=======================================================================
68 void SMESHGUI_Operation::addOrRemoveIndex( const Handle( SALOME_InteractiveObject )& obj,
69 const TColStd_MapOfInteger& indices,
70 const bool isModeShift )
72 SVTK_Selector* sel = selector();
74 sel->AddOrRemoveIndex( obj, indices, isModeShift );
77 //=======================================================================
79 // Purpose : Get SMESH module
80 //=======================================================================
81 SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const
83 return dynamic_cast<SMESHGUI*>( module() );
86 //=======================================================================
88 // Purpose : Get active view window
89 //=======================================================================
90 SVTK_ViewWindow* SMESHGUI_Operation::viewWindow() const
92 return SMESH::GetViewWindow( getSMESHGUI() );
95 //=======================================================================
97 // Purpose : Get selector
98 //=======================================================================
99 SVTK_Selector* SMESHGUI_Operation::selector() const
101 SVTK_ViewWindow* wnd = viewWindow();
102 return wnd ? wnd->GetSelector() : 0;
105 //=======================================================================
106 // name : startOperation
107 // Purpose : Start opeartion
108 //=======================================================================
109 void SMESHGUI_Operation::startOperation()
111 SalomeApp_Operation::startOperation();
114 //=======================================================================
115 // name : isReadyToStart
116 // Purpose : Verify whether operation is ready to start
117 //=======================================================================
118 bool SMESHGUI_Operation::isReadyToStart()
120 if ( !SalomeApp_Operation::isReadyToStart() )
123 if ( getSMESHGUI() == 0 )
125 SUIT_MessageBox::warn1( SMESHGUI::desktop(), tr( "SMESH_WRN_WARNING" ),
126 tr( "NO_MODULE" ), tr( "SMESH_BUT_OK" ) );