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_ExportCalculationOp.h"
25 #include "HYDROGUI_DataModel.h"
26 #include "HYDROGUI_Module.h"
27 #include "HYDROGUI_Tool.h"
29 #include <HYDROData_CalculationCase.h>
31 #include <GeometryGUI.h>
33 #include <SalomeApp_Study.h>
35 #include <LightApp_Application.h>
36 #include <LightApp_UpdateFlags.h>
38 #include <SUIT_MessageBox.h>
39 #include <SUIT_Desktop.h>
41 #include <QApplication>
43 HYDROGUI_ExportCalculationOp::HYDROGUI_ExportCalculationOp( HYDROGUI_Module* theModule )
44 : HYDROGUI_Operation( theModule )
46 setName( tr( "EXPORT_CALCULATION" ) );
49 HYDROGUI_ExportCalculationOp::~HYDROGUI_ExportCalculationOp()
53 void HYDROGUI_ExportCalculationOp::startOperation()
55 HYDROGUI_Operation::startOperation();
60 void HYDROGUI_ExportCalculationOp::abortOperation()
62 HYDROGUI_Operation::abortOperation();
65 void HYDROGUI_ExportCalculationOp::commitOperation()
67 HYDROGUI_Operation::commitOperation();
70 bool HYDROGUI_ExportCalculationOp::processApply( int& theUpdateFlags,
71 QString& theErrorMsg )
73 // Get the selected calculation case
74 Handle(HYDROData_CalculationCase) aCalculation =
75 Handle(HYDROData_CalculationCase)::DownCast(
76 HYDROGUI_Tool::GetSelectedObject( module() ) );
78 if ( aCalculation.IsNull() ) {
79 theErrorMsg = tr( "NULL_DATA_OBJECT" );
86 SalomeApp_Study* aStudy =
87 dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
91 SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
92 GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
93 if ( aCalculation->Export( aGeomEngine, aDSStudy ) ) {
94 theUpdateFlags = UF_ObjBrowser;
102 void HYDROGUI_ExportCalculationOp::onApply()
104 QApplication::setOverrideCursor( Qt::WaitCursor );
106 int anUpdateFlags = 0;
109 bool aResult = false;
112 aResult = processApply( anUpdateFlags, anErrorMsg );
114 catch ( Standard_Failure )
116 Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
117 anErrorMsg = aFailure->GetMessageString();
125 QApplication::restoreOverrideCursor();
128 module()->update( anUpdateFlags );
132 SUIT_MessageBox::information( module()->getApp()->desktop(),
133 tr( "EXPORT_STATUS" ),
134 tr( "EXPORT_FINISHED") );
139 if ( anErrorMsg.isEmpty() )
140 anErrorMsg = tr( "EXPORT_DATA_FAILED" );
142 anErrorMsg.prepend( tr( "EXPORT_FAILED" ) + "\n" );
144 SUIT_MessageBox::critical( module()->getApp()->desktop(),
145 tr( "EXPORT_STATUS" ),