]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROGUI/HYDROGUI_RiverBottomOp.cxx
Salome HOME
Merge branch 'master' into BR_RIVER
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_RiverBottomOp.cxx
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HYDROGUI_RiverBottomOp.h"
24
25 #include "HYDROGUI_RiverBottomDlg.h"
26
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"
33
34 #include <HYDROData_River.h>
35 #include <HYDROData_Iterator.h>
36
37 /*
38 #include <HYDROData_Profile.h>
39
40 #include <OCCViewer_ViewManager.h>
41 #include <OCCViewer_ViewModel.h>
42
43 #include <LightApp_Application.h>
44 #include <LightApp_UpdateFlags.h>
45
46 #include <TopoDS.hxx>
47 */
48
49 HYDROGUI_RiverBottomOp::HYDROGUI_RiverBottomOp( HYDROGUI_Module* theModule )
50 : HYDROGUI_Operation( theModule )
51 {
52   setName( tr( "FIND_RIVER_BOTTOM" ) );
53 }
54
55 HYDROGUI_RiverBottomOp::~HYDROGUI_RiverBottomOp()
56 {
57 }
58
59 void HYDROGUI_RiverBottomOp::startOperation()
60 {
61   HYDROGUI_Operation::startOperation();
62
63   HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast<HYDROGUI_RiverBottomDlg*>( inputPanel() );
64
65   aPanel->reset();
66   /*
67   QString aRiver;
68   Handle(HYDROData_River) aRiverObj = Handle(HYDROData_River)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
69   if ( !aRiverObj.IsNull() )
70       aRiver = aRiverObj->GetName();
71
72   aPanel->setRiverName( aRiver );
73   */
74 }
75
76 void HYDROGUI_RiverBottomOp::abortOperation()
77 {
78 //  erasePreview();
79   HYDROGUI_Operation::abortOperation();
80 }
81
82 void HYDROGUI_RiverBottomOp::commitOperation()
83 {
84 //  erasePreview();
85   HYDROGUI_Operation::commitOperation();
86 }
87
88 HYDROGUI_InputPanel* HYDROGUI_RiverBottomOp::createInputPanel() const
89 {
90   HYDROGUI_RiverBottomDlg* aPanel = new HYDROGUI_RiverBottomDlg( module(), getName() );
91   return aPanel;
92 }
93
94 bool HYDROGUI_RiverBottomOp::processApply( int& theUpdateFlags, QString& theErrorMsg,
95                                            QStringList& theBrowseObjectsEntries )
96 {
97   HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast<HYDROGUI_RiverBottomDlg*>( inputPanel() );
98   if ( !aPanel )
99     return false;
100
101   Handle(HYDROData_Stream) aRiver = riverObject( aPanel->getRiverName() );
102   if ( aRiver.IsNull() )
103   {
104     theErrorMsg = tr( "INCORRECT_RIVER_OBJECT" );
105     return false;
106   }
107
108   startDocOperation();
109
110   aRiver->GenerateBottomPolyline();
111   aRiver->Update();
112 //  Handle(HYDRO_RiverBottom) aBottom = createNewObject();
113 //  aBottom->SetName( QString( "%1_Bottom" ).arg( aRiver->GetName() ) );
114
115 //  erasePreview();
116
117 //    module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aBottom, true );
118 //    theBrowseObjectsEntries.append( HYDROGUI_DataObject::dataObjectEntry( aBottom ) );
119
120 //  module()->setIsToUpdate( aBottom );
121
122   theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
123
124   commitDocOperation();
125
126   return true;
127 }
128 /*
129 Handle(HYDROData_RiverBottom) HYDROGUI_RiverBottomOp::createNewObject()
130 {
131   return Handle(HYDROData_RiverBottom)::DownCast( doc()->CreateObject( KIND_RIVERBOTTOM ) );
132 }
133 */
134
135 Handle(HYDROData_Stream) HYDROGUI_RiverBottomOp::riverObject( const QString& theName ) const
136 {
137     return Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), theName ) );
138 }
139 QStringList HYDROGUI_RiverBottomOp::riverNames( bool all ) const
140 {
141     QStringList aNames;
142 /*
143     for ( HYDROData_Iterator it( HYDROData_Document::Document( module()->getStudyId() ), KIND_RIVER ); it.More(); it.Next() )
144     {
145         it.Current();
146         if ( !aRiver.IsNull() && ( all || !aRiver->HasBottom() )
147             aNames.append( aRiver->GetName() );
148     }
149 */
150     return aNames;
151 }