1 // SMESH SMDS : implementaion of Salome mesh data structure
3 // Copyright (C) 2003 OPEN CASCADE
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : SMESHGUI_Operation.h
22 // Author : Sergey LITONIN
25 #include "SMESHGUI_Operation.h"
27 #include <SMESHGUI_Dialog.h>
29 #include <SalomeApp_Study.h>
30 #include <LightApp_Application.h>
32 #include <SUIT_Session.h>
33 #include <SUIT_MessageBox.h>
34 #include <SUIT_Desktop.h>
36 #include <qstringlist.h>
39 Class : SMESHGUI_Operation
40 Description : Base class for all SMESH operations
43 //=======================================================================
44 // name : SMESHGUI_Operation
45 // Purpose : Constructor
46 //=======================================================================
47 SMESHGUI_Operation::SMESHGUI_Operation()
48 : LightApp_Operation()
53 //=======================================================================
54 // name : ~SMESHGUI_Operation
55 // Purpose : Destructor
56 //=======================================================================
57 SMESHGUI_Operation::~SMESHGUI_Operation()
61 //=======================================================================
63 // Purpose : Get SMESH module
64 //=======================================================================
65 SMESHGUI* SMESHGUI_Operation::getSMESHGUI() const
67 return dynamic_cast<SMESHGUI*>( module() );
70 //=======================================================================
71 // name : startOperation
72 // Purpose : Start opeartion
73 //=======================================================================
74 void SMESHGUI_Operation::startOperation()
78 disconnect( dlg(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
79 disconnect( dlg(), SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
80 disconnect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
81 disconnect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
82 disconnect( dlg(), SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
84 if( dlg()->testButtonFlags( QtxDialog::OK ) )
85 connect( dlg(), SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
87 if( dlg()->testButtonFlags( QtxDialog::Apply ) )
88 connect( dlg(), SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
90 if( dlg()->testButtonFlags( QtxDialog::Cancel ) )
91 connect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
93 if( dlg()->testButtonFlags( QtxDialog::Help ) )
94 connect( dlg(), SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
96 //if( dlg()->testButtonFlags( QtxDialog::Close ) )
97 //if dialog hasn't close, cancel, no and etc buttons, dlgClose will be emitted when dialog is closed not by OK
98 connect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
103 LightApp_Operation::startOperation();
106 //=======================================================================
107 // name : isReadyToStart
108 // Purpose : Verify whether operation is ready to start
109 //=======================================================================
110 bool SMESHGUI_Operation::isReadyToStart() const
112 if ( !LightApp_Operation::isReadyToStart() )
114 else if ( getSMESHGUI() == 0 )
116 SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
117 tr( "NO_MODULE" ), tr( "SMESH_BUT_OK" ) );
120 else if ( isStudyLocked() )
126 //=======================================================================
127 // name : setDialogActive
129 //=======================================================================
130 void SMESHGUI_Operation::setDialogActive( const bool active )
132 LightApp_Operation::setDialogActive( active );
134 SMESHGUI_Dialog* d = dynamic_cast<SMESHGUI_Dialog*>( dlg() );
136 d->setContentActive( active );
140 //=======================================================================
143 //=======================================================================
144 _PTR(Study) SMESHGUI_Operation::studyDS() const
146 SalomeApp_Study* s = dynamic_cast<SalomeApp_Study*>( study() );
150 //=======================================================================
153 //=======================================================================
154 void SMESHGUI_Operation::onOk()
162 //=======================================================================
165 //=======================================================================
166 bool SMESHGUI_Operation::onApply()
171 //=======================================================================
174 //=======================================================================
175 void SMESHGUI_Operation::onCancel()
180 //=======================================================================
183 //=======================================================================
184 void SMESHGUI_Operation::onHelp()
186 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
188 app->onHelpContextModule(getSMESHGUI() ? app->moduleName(getSMESHGUI()->moduleName()) : QString(""), myHelpFileName);
192 platform = "winapplication";
194 platform = "application";
196 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
197 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
198 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
199 QObject::tr("BUT_OK"));
203 //=======================================================================
206 //=======================================================================
207 void SMESHGUI_Operation::initDialog()
212 * \brief Verifies whether study of operation is locked
213 * \param theMess - specifies whether message box must be shown if study is locked
214 * \return State of study.
216 * Verifies whether study of operation is locked. If second parameter is TRUE and study
217 * is locked when corresponding message box appears
219 bool SMESHGUI_Operation::isStudyLocked( const bool theMess ) const
223 if ( studyDS()->GetProperties()->IsLocked() )
226 SUIT_MessageBox::warn1 ( SMESHGUI::desktop(), QObject::tr( "WRN_WARNING" ),
227 QObject::tr( "WRN_STUDY_LOCKED" ), QObject::tr( "BUT_OK" ) );
236 * \brief Verifies whether given operator is valid for this one
237 * \param theOtherOp - other operation
238 * \return Returns TRUE if the given operator is valid for this one, FALSE otherwise
240 * Virtual method redefined from base class verifies whether given operator is valid for
241 * this one (i.e. can be started "above" this operator). In current implementation method
242 * retuns false if theOtherOp operation is not intended for deleting objects or mesh
245 bool SMESHGUI_Operation::isValid( SUIT_Operation* theOtherOp ) const
247 static QStringList anOps;
248 if ( anOps.count() == 0 )
250 anOps.append( "SMESHGUI_DeleteOp" );
251 // to do add other operations here
254 return theOtherOp && theOtherOp->inherits( "SMESHGUI_Operation" ) &&
255 ( !anOps.contains( theOtherOp->className() ) || anOps.contains( className() ) );