Salome HOME
table de Strickler complete
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_RiverBottomOp.cxx
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.
6 //
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.
11 //
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
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_RiverBottomOp.h"
20
21 #include "HYDROGUI_RiverBottomDlg.h"
22
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"
29
30 #include <HYDROData_River.h>
31 #include <HYDROData_Iterator.h>
32
33 /*
34 #include <HYDROData_Profile.h>
35
36 #include <OCCViewer_ViewManager.h>
37 #include <OCCViewer_ViewModel.h>
38
39 #include <LightApp_Application.h>
40 #include <LightApp_UpdateFlags.h>
41
42 #include <TopoDS.hxx>
43 */
44
45 HYDROGUI_RiverBottomOp::HYDROGUI_RiverBottomOp( HYDROGUI_Module* theModule )
46 : HYDROGUI_Operation( theModule )
47 {
48   setName( tr( "FIND_STREAM_BOTTOM" ) );
49 }
50
51 HYDROGUI_RiverBottomOp::~HYDROGUI_RiverBottomOp()
52 {
53 }
54
55 void HYDROGUI_RiverBottomOp::startOperation()
56 {
57   HYDROGUI_Operation::startOperation();
58
59   if ( isApplyAndClose() )
60   {
61     HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast<HYDROGUI_RiverBottomDlg*>( inputPanel() );
62
63     aPanel->reset();
64   }
65 }
66
67 void HYDROGUI_RiverBottomOp::abortOperation()
68 {
69   HYDROGUI_Operation::abortOperation();
70 }
71
72 void HYDROGUI_RiverBottomOp::commitOperation()
73 {
74   HYDROGUI_Operation::commitOperation();
75 }
76
77 HYDROGUI_InputPanel* HYDROGUI_RiverBottomOp::createInputPanel() const
78 {
79   HYDROGUI_RiverBottomDlg* aPanel = new HYDROGUI_RiverBottomDlg( module(), getName() );
80   return aPanel;
81 }
82
83 bool HYDROGUI_RiverBottomOp::processApply( int& theUpdateFlags, QString& theErrorMsg,
84                                            QStringList& theBrowseObjectsEntries )
85 {
86   HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast<HYDROGUI_RiverBottomDlg*>( inputPanel() );
87   if ( !aPanel )
88     return false;
89
90   Handle(HYDROData_Stream) aRiver = riverObject( aPanel->getRiverName() );
91   if ( aRiver.IsNull() )
92   {
93     theErrorMsg = tr( "INCORRECT_STREAM_OBJECT" );
94     return false;
95   }
96
97   startDocOperation();
98
99   aRiver->GenerateBottomPolyline();
100   aRiver->Update();
101
102   theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
103
104   commitDocOperation();
105
106   return true;
107 }
108 /*
109 Handle(HYDROData_RiverBottom) HYDROGUI_RiverBottomOp::createNewObject()
110 {
111   return Handle(HYDROData_RiverBottom)::DownCast( doc()->CreateObject( KIND_RIVERBOTTOM ) );
112 }
113 */
114
115 Handle(HYDROData_Stream) HYDROGUI_RiverBottomOp::riverObject( const QString& theName ) const
116 {
117     return Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), theName ) );
118 }
119 QStringList HYDROGUI_RiverBottomOp::riverNames( bool all ) const
120 {
121     QStringList aNames;
122 /*
123     for ( HYDROData_Iterator it( HYDROData_Document::Document( module()->getStudyId() ), KIND_RIVER ); it.More(); it.Next() )
124     {
125         it.Current();
126         if ( !aRiver.IsNull() && ( all || !aRiver->HasBottom() )
127             aNames.append( aRiver->GetName() );
128     }
129 */
130     return aNames;
131 }