Salome HOME
f810298375be6f266953fb39caba55af79107a9a
[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
18
19 /*
20   Class       : SMESHGUI_Operation
21   Description : Base class for all SMESH operations
22 */
23
24 //=======================================================================
25 // name    : SMESHGUI_Operation
26 // Purpose : Constructor
27 //=======================================================================
28 SMESHGUI_Operation::SMESHGUI_Operation( SalomeApp_Application* app )
29 : SalomeApp_Operation( app ),
30   myViewWindow( 0 ),
31   mySelector( 0 )
32 {
33   
34 }
35
36 SMESHGUI_Operation::~SMESHGUI_Operation()
37 {
38   
39 }
40
41 void SMESHGUI_Operation::setSelectionMode( const Selection_Mode mode )
42 {
43   if( myViewWindow )
44     myViewWindow->SetSelectionMode( mode );
45 }
46
47 void SMESHGUI_Operation::highlight( const Handle( SALOME_InteractiveObject )& obj,
48                                     const bool hilight, const bool immediately )
49 {
50   if( myViewWindow )
51     myViewWindow->highlight( obj, hilight, immediately );
52 }
53
54 void SMESHGUI_Operation::addOrRemoveIndex( const Handle( SALOME_InteractiveObject )& obj,
55                                            const TColStd_MapOfInteger& indices, const bool isModeShift )
56 {
57   if( mySelector )
58     mySelector->AddOrRemoveIndex( obj, indices, isModeShift );
59 }
60
61 SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const
62 {
63   return dynamic_cast<SMESHGUI*>( module() );
64 }
65
66 SVTK_ViewWindow* SMESHGUI_Operation::getViewWindow() const
67 {
68   return myViewWindow;
69 }
70
71 SVTK_Selector* SMESHGUI_Operation::getSelector() const
72 {
73   return mySelector;
74 }
75
76 void SMESHGUI_Operation::startOperation()
77 {
78   SalomeApp_Operation::startOperation();
79   myViewWindow = SMESH::GetViewWindow( getSMESHGUI() );
80   mySelector = myViewWindow ? myViewWindow->GetSelector() : 0;
81 }