1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_Operation.h"
25 #include "HYDROGUI_InputPanel.h"
26 #include "HYDROGUI_Module.h"
27 #include "HYDROGUI_Tool.h"
29 #include <HYDROData_Document.h>
30 #include <HYDROData_Iterator.h>
32 #include <LightApp_Application.h>
33 #include <LightApp_SelectionMgr.h>
35 #include <SUIT_Desktop.h>
36 #include <SUIT_MessageBox.h>
37 #include <SUIT_Study.h>
39 HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule )
40 : LightApp_Operation(),
41 myModule( theModule ),
46 HYDROGUI_Operation::~HYDROGUI_Operation()
50 void HYDROGUI_Operation::setName( const QString& theName )
55 const QString& HYDROGUI_Operation::getName() const
60 HYDROGUI_InputPanel* HYDROGUI_Operation::inputPanel() const
64 ( ( HYDROGUI_Operation* )this )->myPanel = createInputPanel();
65 connect( myPanel, SIGNAL( panelApply() ), this, SLOT( onApply() ) );
66 connect( myPanel, SIGNAL( panelCancel() ), this, SLOT( onCancel() ) );
71 SUIT_SelectionMgr* HYDROGUI_Operation::selectionMgr() const
73 return myModule->getApp()->selectionMgr();
76 HYDROGUI_Module* HYDROGUI_Operation::module() const
81 void HYDROGUI_Operation::startOperation()
83 LightApp_Operation::startOperation();
85 doc()->StartOperation();
90 myModule->getApp()->desktop()->addDockWidget( Qt::RightDockWidgetArea, inputPanel() );
94 void HYDROGUI_Operation::abortOperation()
96 doc()->AbortOperation();
98 LightApp_Operation::abortOperation();
101 inputPanel()->hide();
104 void HYDROGUI_Operation::commitOperation()
106 doc()->CommitOperation( HYDROGUI_Tool::ToExtString( getName() ) );
108 LightApp_Operation::commitOperation();
111 inputPanel()->hide();
114 bool HYDROGUI_Operation::processApply( int& theUpdateFlags )
119 void HYDROGUI_Operation::processCancel()
123 Handle_HYDROData_Document HYDROGUI_Operation::doc() const
125 int aStudyId = myModule->application()->activeStudy()->id();
126 return HYDROData_Document::Document( aStudyId );
129 Handle_HYDROData_Object HYDROGUI_Operation::FindObjectByName( const QString& theName, int theKind ) const
131 HYDROData_Iterator anIt( doc(), theKind );
132 for( ; anIt.More(); anIt.Next() )
134 if( anIt.Current()->GetName() == theName )
135 return anIt.Current();
137 return Handle_HYDROData_Object();
140 void HYDROGUI_Operation::onApply()
142 int anUpdateFlags = 0;
143 if( processApply( anUpdateFlags ) )
145 module()->update( anUpdateFlags );
150 SUIT_MessageBox::critical( module()->getApp()->desktop(),
151 tr( "INSUFFICIENT_INPUT_DATA" ),
152 tr( "INPUT_VALID_DATA" ) );
156 void HYDROGUI_Operation::onCancel()