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_Dialog.h>
15 #include <SalomeApp_Study.h>
17 #include <SUIT_MessageBox.h>
18 #include <SUIT_Desktop.h>
21 Class : SMESHGUI_Operation
22 Description : Base class for all SMESH operations
25 //=======================================================================
26 // name : SMESHGUI_Operation
27 // Purpose : Constructor
28 //=======================================================================
29 SMESHGUI_Operation::SMESHGUI_Operation()
30 : SalomeApp_Operation()
34 //=======================================================================
35 // name : ~SMESHGUI_Operation
36 // Purpose : Destructor
37 //=======================================================================
38 SMESHGUI_Operation::~SMESHGUI_Operation()
42 //=======================================================================
44 // Purpose : Get SMESH module
45 //=======================================================================
46 SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const
48 return dynamic_cast<SMESHGUI*>( module() );
51 //=======================================================================
52 // name : startOperation
53 // Purpose : Start opeartion
54 //=======================================================================
55 void SMESHGUI_Operation::startOperation()
59 disconnect( dlg(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
60 disconnect( dlg(), SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
61 disconnect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
62 disconnect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
64 if( dlg()->testButtonFlags( QtxDialog::OK ) )
65 connect( dlg(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
67 if( dlg()->testButtonFlags( QtxDialog::Apply ) )
68 connect( dlg(), SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
70 if( dlg()->testButtonFlags( QtxDialog::Cancel ) )
71 connect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
73 if( dlg()->testButtonFlags( QtxDialog::Close ) )
74 connect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
79 SalomeApp_Operation::startOperation();
82 //=======================================================================
83 // name : isReadyToStart
84 // Purpose : Verify whether operation is ready to start
85 //=======================================================================
86 bool SMESHGUI_Operation::isReadyToStart() const
88 if ( !SalomeApp_Operation::isReadyToStart() )
90 else if ( getSMESHGUI() == 0 )
92 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
93 tr( "NO_MODULE" ), tr( "SMESH_BUT_OK" ) );
100 //=======================================================================
101 // name : setDialogActive
103 //=======================================================================
104 void SMESHGUI_Operation::setDialogActive( const bool active )
106 SalomeApp_Operation::setDialogActive( active );
108 SMESHGUI_Dialog* d = dynamic_cast<SMESHGUI_Dialog*>( dlg() );
110 d->setContentActive( active );
114 //=======================================================================
117 //=======================================================================
118 _PTR(Study) SMESHGUI_Operation::studyDS() const
120 SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study() );
124 //=======================================================================
127 //=======================================================================
128 void SMESHGUI_Operation::onOk()
136 //=======================================================================
139 //=======================================================================
140 bool SMESHGUI_Operation::onApply()
145 //=======================================================================
148 //=======================================================================
149 void SMESHGUI_Operation::onCancel()
154 //=======================================================================
157 //=======================================================================
158 void SMESHGUI_Operation::initDialog()
163 * \brief Verifies whether study of operation is locked
164 * \param theMess - specifies whether message box must be shown if study is locked
165 * \return State of study.
167 * Verifies whether study of operation is locked. If second parameter is TRUE and study
168 * is locked when corresponding message box appears
170 bool SMESHGUI_Operation::isStudyLocked( const bool theMess ) const
174 if ( studyDS()->GetProperties()->IsLocked() )
177 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(), QObject::tr( "WRN_WARNING" ),
178 QObject::tr( "WRN_STUDY_LOCKED" ), QObject::tr( "BUT_OK" ) );