1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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_ImportSinusXOp.h"
25 #include "HYDROGUI_DataModel.h"
26 #include "HYDROGUI_Module.h"
27 #include "HYDROGUI_UpdateFlags.h"
28 #include "HYDROGUI_Tool.h"
29 #include <HYDROData_PolylineXY.h>
30 #include <HYDROData_Polyline3D.h>
31 #include <HYDROGUI_DataObject.h>
32 #include <HYDROData_Bathymetry.h>
33 #include <HYDROData_Iterator.h>
35 #include <HYDROData_Profile.h>
37 #include <SUIT_Desktop.h>
38 #include <SUIT_FileDlg.h>
39 #include <LightApp_Application.h>
41 #include <QApplication>
44 #include <QMessageBox>
46 #include <HYDROData_SinusX.h>
49 HYDROGUI_ImportSinusXOp::HYDROGUI_ImportSinusXOp( HYDROGUI_Module* theModule )
50 : HYDROGUI_Operation( theModule )
52 setName( tr( "IMPORT_SINUSX" ) );
55 HYDROGUI_ImportSinusXOp::~HYDROGUI_ImportSinusXOp()
59 void HYDROGUI_ImportSinusXOp::startOperation()
61 HYDROGUI_Operation::startOperation();
63 myFileDlg = new SUIT_FileDlg( module()->getApp()->desktop(), true );
64 myFileDlg->setWindowTitle( getName() );
65 myFileDlg->setFileMode( SUIT_FileDlg::ExistingFiles );
66 myFileDlg->setFilter( tr("SINUSX_FILTER") );
68 connect( myFileDlg, SIGNAL( accepted() ), this, SLOT( onApply() ) );
69 connect( myFileDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
74 void HYDROGUI_ImportSinusXOp::onApply()
82 QString aFileName = myFileDlg->selectedFile();
83 if ( aFileName.isEmpty() )
89 QString anExt = aFileName.split('.', QString::SkipEmptyParts).back();
93 QApplication::setOverrideCursor( Qt::WaitCursor );
97 HYDROData_SinusX aSinusXImporter;
98 NCollection_Sequence<Handle_HYDROData_Entity> anEntities;
99 if (aSinusXImporter.Import(aFileName, doc(), anEntities))
101 UpdateView(anEntities);
102 commitDocOperation();
111 module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
113 QApplication::restoreOverrideCursor();
116 void HYDROGUI_ImportSinusXOp::UpdateView( NCollection_Sequence<Handle_HYDROData_Entity>& anEntities)
118 size_t anActiveViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
119 if ( anActiveViewId == 0 )
120 anActiveViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() );
122 for (int i = 1; i <= anEntities.Size() ; i++)
124 anEntities(i)->Update();
125 module()->setObjectVisible( anActiveViewId, anEntities(i), true );
126 module()->setIsToUpdate( anEntities(i) );