Salome HOME
refs #1813 ... lot 14 combined commit : parts : 1 - 16
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CalculationOp.h
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
20 #ifndef HYDROGUI_CALCULATIONOP_H
21 #define HYDROGUI_CALCULATIONOP_H
22
23 #include "HYDROGUI_Operation.h"
24
25 #include "HYDROData_SplitToZonesTool.h"
26 #include "HYDROGUI_Shape.h"
27
28 #include <HYDROData_CalculationCase.h>
29 #include <HYDROData_Region.h>
30
31 class SUIT_ViewManager;
32 class OCCViewer_ViewManager;
33 class HYDROGUI_CalculationDlg;
34 class SUIT_DataObject;
35
36 class HYDROGUI_CalculationOp : public HYDROGUI_Operation
37 {
38   Q_OBJECT
39
40 public:
41   HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit );
42   virtual ~HYDROGUI_CalculationOp();
43
44 protected:
45   virtual void                    startOperation();
46   virtual void                    abortOperation();
47   virtual void                    commitOperation();
48
49   virtual HYDROGUI_InputPanel*    createInputPanel() const;
50
51   virtual void                    onApply();
52   virtual bool                    processApply( int& theUpdateFlags, QString& theErrorMsg,
53                                                 QStringList& theBrowseObjectsEntries );
54
55   void setAvailableGroups();
56
57   void setAvailableBoundaryPolygons();
58
59 protected slots:
60
61   /**
62    * Change the creation mode.
63    * @param theMode the mode to set
64    */
65   void                            onChangeMode( int theMode );
66
67   /**
68    * Add geometry objects selected in the module browser to the calculation case.
69    */
70   void                            onAddObjects();
71   /**
72    * Remove selected objects from the calculation case.
73    */
74   void                            onRemoveObjects();
75
76   /**
77    * Add geometry groups selected in the module browser to the calculation case.
78    */
79   void                            onAddGroups();
80   /**
81    * Remove selected groups from the calculation case.
82    */
83   void                            onRemoveGroups();
84
85   void                            onAddBoundaryPolygons();
86
87   void                            onRemoveBoundaryPolygons();
88
89   /**
90    * Set the given bathymetry/type merge type to the current zone.
91    */
92   void                            onSetMergeType( int theMergeType, QString& theMergeObjectName );
93   /**
94    * Selected zones are moved to the existing region.
95    */
96   void                            onMoveZones( SUIT_DataObject* theRegionItem, 
97                                                const QList<SUIT_DataObject*>& theZonesList);
98   /**
99    * Selected zones are moved to the new region to be created.
100    */
101   void                            onCreateRegion( const QList<SUIT_DataObject*>& theZonesList );
102   /**
103    * Case objects must be split to zones if the case has been modified or new.
104    */
105   void                            onNext( const int );
106   void                            onLastViewClosed( SUIT_ViewManager* );
107   /**
108    * The zone is selected in the browser on the second page of the wizard.
109    */
110   void                            onClickedInZonesBrowser( SUIT_DataObject* theItem );
111   /**
112    * Slot called on back button click.
113    */
114   void                            onHideZones( const int );
115   /** 
116    * Geometry object is selected in the list on the first wizard page
117    */
118   void                            onObjectsSelected();
119   /** 
120    * Land cover map is selected in the list on the third wizard page
121    */
122   void                            onLandCoverMapSelected( const QString & theObjName );
123   /** 
124    * Boundary polyline is selected in the list on the first wizard page
125    */
126   void                            onBoundarySelected( const QString & theObjName );
127   /** 
128    * Strickler table name is selected in the list on the third wizard page
129    */
130   void                            onStricklerTableSelected( const QString & theObjName );
131
132   void onOrderChanged( bool& isConfirmed );
133
134   void onRuleChanged( bool& isConfirmed );
135
136   void onRegenerateColors();
137
138 private:
139   void                            createPreview( const bool theLandCoverMap, bool fitAllFlag = true, bool onTopViewAndFit = true);
140   void                            closePreview( bool theRemoveViewManager = true );
141   void                            setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible );
142   void                            setZonesVisible( bool theIsVisible );
143   void                            setGeomObjectsVisible( bool theIsVisible );
144   void                            setLandCoverMapVisible( bool theIsVisible );
145   void                            getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq, 
146                                                       QStringList& theNames, QStringList& theEntries ) const;
147
148   /**
149    * Internal method that used to assign unique default colors for zones
150    */
151   void                            AssignDefaultZonesColors();
152   void                            setRules( HYDROData_CalculationCase::DataTag theDataTag );
153
154   bool                            createRegion( const QList<SUIT_DataObject*>& theZonesList );
155
156   void                            AddInterPolylinesToList(QStringList& theList, QStringList& theEntryList);
157
158   bool confirmRegionsChange() const;
159   bool confirmModeChange() const;
160   bool confirmOrderChange() const;
161   bool confirmRuleChange() const;
162   bool confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
163
164 private:
165   bool                            myIsEdit;
166   bool                            myShowZones;
167   bool                            myShowGeomObjects;
168   bool                            myShowLandCoverMap;
169   Handle(HYDROData_CalculationCase) myEditedObject;
170
171   SUIT_ViewManager*               myActiveViewManager;
172   OCCViewer_ViewManager*          myPreviewViewManager;
173 };
174
175 #endif
176
177