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_RiverBottomOp.h"
25 #include "HYDROGUI_RiverBottomDlg.h"
27 #include "HYDROGUI_DataModel.h"
28 #include "HYDROGUI_DataObject.h"
29 #include "HYDROGUI_Module.h"
30 #include "HYDROGUI_Shape.h"
31 #include "HYDROGUI_Tool.h"
32 #include "HYDROGUI_UpdateFlags.h"
34 #include <HYDROData_River.h>
35 #include <HYDROData_Iterator.h>
38 #include <HYDROData_Profile.h>
40 #include <OCCViewer_ViewManager.h>
41 #include <OCCViewer_ViewModel.h>
43 #include <LightApp_Application.h>
44 #include <LightApp_UpdateFlags.h>
49 HYDROGUI_RiverBottomOp::HYDROGUI_RiverBottomOp( HYDROGUI_Module* theModule )
50 : HYDROGUI_Operation( theModule )
52 setName( tr( "FIND_STREAM_BOTTOM" ) );
55 HYDROGUI_RiverBottomOp::~HYDROGUI_RiverBottomOp()
59 void HYDROGUI_RiverBottomOp::startOperation()
61 HYDROGUI_Operation::startOperation();
63 if ( isApplyAndClose() )
65 HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast<HYDROGUI_RiverBottomDlg*>( inputPanel() );
71 void HYDROGUI_RiverBottomOp::abortOperation()
73 HYDROGUI_Operation::abortOperation();
76 void HYDROGUI_RiverBottomOp::commitOperation()
78 HYDROGUI_Operation::commitOperation();
81 HYDROGUI_InputPanel* HYDROGUI_RiverBottomOp::createInputPanel() const
83 HYDROGUI_RiverBottomDlg* aPanel = new HYDROGUI_RiverBottomDlg( module(), getName() );
87 bool HYDROGUI_RiverBottomOp::processApply( int& theUpdateFlags, QString& theErrorMsg,
88 QStringList& theBrowseObjectsEntries )
90 HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast<HYDROGUI_RiverBottomDlg*>( inputPanel() );
94 Handle(HYDROData_Stream) aRiver = riverObject( aPanel->getRiverName() );
95 if ( aRiver.IsNull() )
97 theErrorMsg = tr( "INCORRECT_STREAM_OBJECT" );
103 aRiver->GenerateBottomPolyline();
106 theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
108 commitDocOperation();
113 Handle(HYDROData_RiverBottom) HYDROGUI_RiverBottomOp::createNewObject()
115 return Handle(HYDROData_RiverBottom)::DownCast( doc()->CreateObject( KIND_RIVERBOTTOM ) );
119 Handle(HYDROData_Stream) HYDROGUI_RiverBottomOp::riverObject( const QString& theName ) const
121 return Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), theName ) );
123 QStringList HYDROGUI_RiverBottomOp::riverNames( bool all ) const
127 for ( HYDROData_Iterator it( HYDROData_Document::Document( module()->getStudyId() ), KIND_RIVER ); it.More(); it.Next() )
130 if ( !aRiver.IsNull() && ( all || !aRiver->HasBottom() )
131 aNames.append( aRiver->GetName() );