1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_RiverBottomOp.h"
21 #include "HYDROGUI_RiverBottomDlg.h"
23 #include "HYDROGUI_DataModel.h"
24 #include "HYDROGUI_DataObject.h"
25 #include "HYDROGUI_Module.h"
26 #include "HYDROGUI_Shape.h"
27 #include "HYDROGUI_Tool2.h"
28 #include "HYDROGUI_UpdateFlags.h"
30 #include <HYDROData_River.h>
31 #include <HYDROData_Iterator.h>
34 #include <HYDROData_Profile.h>
36 #include <OCCViewer_ViewManager.h>
37 #include <OCCViewer_ViewModel.h>
39 #include <LightApp_Application.h>
40 #include <LightApp_UpdateFlags.h>
45 HYDROGUI_RiverBottomOp::HYDROGUI_RiverBottomOp( HYDROGUI_Module* theModule )
46 : HYDROGUI_Operation( theModule )
48 setName( tr( "FIND_STREAM_BOTTOM" ) );
51 HYDROGUI_RiverBottomOp::~HYDROGUI_RiverBottomOp()
55 void HYDROGUI_RiverBottomOp::startOperation()
57 HYDROGUI_Operation::startOperation();
59 if ( isApplyAndClose() )
61 HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast<HYDROGUI_RiverBottomDlg*>( inputPanel() );
67 void HYDROGUI_RiverBottomOp::abortOperation()
69 HYDROGUI_Operation::abortOperation();
72 void HYDROGUI_RiverBottomOp::commitOperation()
74 HYDROGUI_Operation::commitOperation();
77 HYDROGUI_InputPanel* HYDROGUI_RiverBottomOp::createInputPanel() const
79 HYDROGUI_RiverBottomDlg* aPanel = new HYDROGUI_RiverBottomDlg( module(), getName() );
83 bool HYDROGUI_RiverBottomOp::processApply( int& theUpdateFlags, QString& theErrorMsg,
84 QStringList& theBrowseObjectsEntries )
86 HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast<HYDROGUI_RiverBottomDlg*>( inputPanel() );
90 Handle(HYDROData_Stream) aRiver = riverObject( aPanel->getRiverName() );
91 if ( aRiver.IsNull() )
93 theErrorMsg = tr( "INCORRECT_STREAM_OBJECT" );
99 aRiver->GenerateBottomPolyline();
102 theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
104 commitDocOperation();
109 Handle(HYDROData_RiverBottom) HYDROGUI_RiverBottomOp::createNewObject()
111 return Handle(HYDROData_RiverBottom)::DownCast( doc()->CreateObject( KIND_RIVERBOTTOM ) );
115 Handle(HYDROData_Stream) HYDROGUI_RiverBottomOp::riverObject( const QString& theName ) const
117 return Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), theName ) );
119 QStringList HYDROGUI_RiverBottomOp::riverNames( bool all ) const
123 for ( HYDROData_Iterator it( HYDROData_Document::Document( module()->getStudyId() ), KIND_RIVER ); it.More(); it.Next() )
126 if ( !aRiver.IsNull() && ( all || !aRiver->HasBottom() )
127 aNames.append( aRiver->GetName() );