]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESHGUI/SMESHGUI_Operation.cxx
Salome HOME
*** empty log message ***
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Operation.cxx
1 //  SALOME SMESHGUI
2 //
3 //  Copyright (C) 2005  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : SMESHGUI_Operation.h
8 //  Author : Sergey LITONIN
9 //  Module : SALOME
10
11 #include "SMESHGUI_Operation.h"
12 #include "SMESHGUI.h"
13 #include "SMESHGUI_VTKUtils.h"
14
15 #include <SVTK_ViewWindow.h>
16 #include <SVTK_Selector.h>
17 #include <SUIT_MessageBox.h>
18 #include <SUIT_Desktop.h>
19
20
21 /*
22   Class       : SMESHGUI_Operation
23   Description : Base class for all SMESH operations
24 */
25
26 //=======================================================================
27 // name    : SMESHGUI_Operation
28 // Purpose : Constructor
29 //=======================================================================
30 SMESHGUI_Operation::SMESHGUI_Operation( SalomeApp_Application* app )
31 : SalomeApp_Operation( app )
32 {
33   
34 }
35
36 SMESHGUI_Operation::~SMESHGUI_Operation()
37 {
38   
39 }
40
41 //=======================================================================
42 // name    : setSelectionMode
43 // Purpose : Set selection mode
44 //=======================================================================
45 void SMESHGUI_Operation::setSelectionMode( const Selection_Mode mode )
46 {
47   SVTK_ViewWindow* wnd = viewWindow();
48   if( wnd )
49     wnd->SetSelectionMode( mode );
50 }
51
52 //=======================================================================
53 // name    : highlight
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 )
58 {
59   SVTK_ViewWindow* wnd = viewWindow();
60   if( wnd )
61     wnd->highlight( obj, hilight, immediately );
62 }
63
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 )
71 {
72   SVTK_Selector* sel = selector();
73   if( sel )
74     sel->AddOrRemoveIndex( obj, indices, isModeShift );
75 }
76
77 //=======================================================================
78 // name    : getSMESHGUI
79 // Purpose : Get SMESH module
80 //=======================================================================
81 SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const
82 {
83   return dynamic_cast<SMESHGUI*>( module() );
84 }
85
86 //=======================================================================
87 // name    : viewWindow
88 // Purpose : Get active view window
89 //=======================================================================
90 SVTK_ViewWindow* SMESHGUI_Operation::viewWindow() const
91 {
92   return SMESH::GetViewWindow( getSMESHGUI() );
93 }
94
95 //=======================================================================
96 // name    : selector
97 // Purpose : Get selector
98 //=======================================================================
99 SVTK_Selector* SMESHGUI_Operation::selector() const
100 {
101   SVTK_ViewWindow* wnd = viewWindow();
102   return wnd ? wnd->GetSelector() : 0;
103 }
104
105 //=======================================================================
106 // name    : startOperation
107 // Purpose : Start opeartion
108 //=======================================================================
109 void SMESHGUI_Operation::startOperation()
110 {
111   SalomeApp_Operation::startOperation();
112 }
113
114 //=======================================================================
115 // name    : isReadyToStart
116 // Purpose : Verify whether operation is ready to start
117 //=======================================================================
118 bool SMESHGUI_Operation::isReadyToStart()
119 {
120   if ( !SalomeApp_Operation::isReadyToStart() )
121     return false;
122     
123   if ( getSMESHGUI() == 0 )
124   {
125     SUIT_MessageBox::warn1( SMESHGUI::desktop(), tr( "SMESH_WRN_WARNING" ),
126       tr( "NO_MODULE" ), tr( "SMESH_BUT_OK" ) );
127     return false;
128   }
129 }
130
131
132
133
134