Salome HOME
Merge remote-tracking branch 'origin/BR_LAND_COVER' into BR_v14_rc
[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 protected slots:
58
59   /**
60    * Change the creation mode.
61    * @param theMode the mode to set
62    */
63   void                            onChangeMode( int theMode );
64
65   /**
66    * Add geometry objects selected in the module browser to the calculation case.
67    */
68   void                            onAddObjects();
69   /**
70    * Remove selected objects from the calculation case.
71    */
72   void                            onRemoveObjects();
73
74   /**
75    * Add geometry groups selected in the module browser to the calculation case.
76    */
77   void                            onAddGroups();
78   /**
79    * Remove selected groups from the calculation case.
80    */
81   void                            onRemoveGroups();
82
83   /**
84    * Change the creation mode related to land covers.
85    * @param theMode the mode to set
86    */
87   void                            onChangeLandCoverMode( int theMode );
88
89   /**
90    * Add land covers selected in the module browser to the calculation case.
91    */
92   void                            onAddLandCovers();
93   /**
94    * Remove selected land covers from the calculation case.
95    */
96   void                            onRemoveLandCovers();
97
98   /**
99    * Set the given bathymetry merge type to the current zone.
100    */
101   void                            onSetMergeType( int theMergeType, QString& theBathymetryName );
102   /**
103    * Selected zones are moved to the existing region.
104    */
105   void                            onMoveZones( SUIT_DataObject* theRegionItem, 
106                                                const QList<SUIT_DataObject*>& theZonesList );
107   /**
108    * Selected zones are moved to the new region to be created.
109    */
110   void                            onCreateRegion( const QList<SUIT_DataObject*>& theZonesList );
111   /**
112    * Case objects must be splitted to zones if the case has been modified or new.
113    */
114   void                            onNext( const int );
115   void                            onLastViewClosed( SUIT_ViewManager* );
116   /**
117    * The zone is selected in the browser on the second page of the wizard.
118    */
119   void                            onClickedInZonesBrowser( SUIT_DataObject* theItem );
120   /**
121    * Slot called on back button click.
122    */
123   void                            onBack( const int );
124   /** 
125    * Geometry object is selected in the list on the first wizard page
126    */
127   void                            onObjectsSelected();
128   /** 
129    * Land cover is selected in the list on the third wizard page
130    */
131   void                            onLandCoversSelected();
132   /** 
133    * Boundary polyline is selected in the list on the first wizard page
134    */
135   void                            onBoundarySelected( const QString & theObjName );
136   /** 
137    * Strickler table name is selected in the list on the third wizard page
138    */
139   void                            onStricklerTableSelected( const QString & theObjName );
140
141   void onOrderChanged( bool& isConfirmed );
142   void onOrderLandCoverChanged( bool& isConfirmed );
143
144 private:
145   void                            createPreview();
146   void                            closePreview();
147   void                            setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible );
148   void                            setZonesVisible( bool theIsVisible );
149   void                            setGeomObjectsVisible( bool theIsVisible );
150   void                            getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq, 
151                                                       QStringList& theNames, QStringList& theEntries ) const;
152
153   /**
154    * Internal method that used to assign unique default colors for zones
155    */
156   void                            AssignDefaultZonesColors();
157   /**
158    * Internal method that used to generate default color for zone
159    * @param theIndex the index of color to be generated
160    * @param theSaturation the saturation of the color in the range 0 to 1,
161    * and the bigger it is, the stronger the color is. Grayish colors have
162    * saturation near 0, very strong colors have saturation near 1.
163    * The defalt value is 0.5.
164    * @param theValue the value in the range 0 to 1, represents lightness or
165    * brightness of the color. 0 is black, 1 is as far from black as possible.
166    * The defalt value is 0.95.
167    * \return the generated color
168    */
169   QColor                          GenerateDefaultZonesColor( int theIndex,
170                                                              float theSaturation = 0.5,
171                                                              float theValue = 0.95 ) const;
172
173   void                            setRules( HYDROData_CalculationCase::DataTag theDataTag );
174
175   bool confirmRegionsChange() const;
176   bool confirmModeChange() const;
177   bool confirmOrderChange() const;
178   bool confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
179
180   bool confirmLandCoverModeChange() const;
181   bool confirmLandCoverOrderChange() const;
182
183 private:
184   bool                            myIsEdit;
185   bool                            myShowZones;
186   bool                            myShowGeomObjects;
187   Handle(HYDROData_CalculationCase) myEditedObject;
188
189   SUIT_ViewManager*               myActiveViewManager;
190   OCCViewer_ViewManager*          myPreviewViewManager;
191 };
192
193 #endif
194
195