Salome HOME
9213bee1d2a723f72188298e233c1caf2b68b000
[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    * Set the given bathymetry merge type to the current zone.
85    */
86   void                            onSetMergeType( int theMergeType, QString& theBathymetryName );
87   /**
88    * Selected zones are moved to the existing region.
89    */
90   void                            onMoveZones( SUIT_DataObject* theRegionItem, 
91                                                const QList<SUIT_DataObject*>& theZonesList );
92   /**
93    * Selected zones are moved to the new region to be created.
94    */
95   void                            onCreateRegion( const QList<SUIT_DataObject*>& theZonesList );
96   /**
97    * Case objects must be splitted to zones if the case has been modified or new.
98    */
99   void                            onNext( const int );
100   void                            onLastViewClosed( SUIT_ViewManager* );
101   /**
102    * The zone is selected in the browser on the second page of the wizard.
103    */
104   void                            onClickedInZonesBrowser( SUIT_DataObject* theItem );
105   /**
106    * Hide zones in the viewer.
107    */
108   void                            onHideZones();
109   /** 
110    * Geometry object is selected in the list on the first wizard page
111    */
112   void                            onObjectsSelected();
113   /** 
114    * Boundary polyline is selected in the list on the first wizard page
115    */
116   void                            onBoundarySelected ( const QString & theObjName );
117
118 private:
119   void                            createPreview();
120   void                            closePreview();
121   void                            setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible );
122   void                            setZonesVisible( bool theIsVisible );
123   void                            getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq, 
124                                                       QStringList& theNames, QStringList& theEntries ) const;
125
126   /**
127    * Internal method that used to assign unique default colors for zones
128    */
129   void                            AssignDefaultZonesColors();
130   /**
131    * Internal method that used to generate default color for zone
132    * @param theIndex the index of color to be generated
133    * @param theSaturation the saturation of the color in the range 0 to 1,
134    * and the bigger it is, the stronger the color is. Grayish colors have
135    * saturation near 0, very strong colors have saturation near 1.
136    * The defalt value is 0.5.
137    * @param theValue the value in the range 0 to 1, represents lightness or
138    * brightness of the color. 0 is black, 1 is as far from black as possible.
139    * The defalt value is 0.95.
140    * \return the generated color
141    */
142   QColor                          GenerateDefaultZonesColor( int theIndex,
143                                                              float theSaturation = 0.5,
144                                                              float theValue = 0.95 ) const;
145
146   /**
147    * Ask user to confirm splitting zones recalculation after regions list modification.
148    * \return true if confirmed
149    */
150   bool                            confirmRegionsChange() const;
151
152   /**
153    * Ask user to confirm splitting zones recalculation after mode change.
154    * \return true if confirmed
155    */
156   bool                            confirmModeChange() const;
157
158   /**
159    * Ask user to confirm the operation continuation with warning.
160    * @param theWarning the warning
161    * \return true if confirmed
162    */
163   bool                            confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
164
165 private:
166   bool                            myIsEdit;
167   bool                            myShowZones;
168   Handle(HYDROData_CalculationCase) myEditedObject;
169
170   SUIT_ViewManager*               myActiveViewManager;
171   OCCViewer_ViewManager*          myPreviewViewManager;
172 };
173
174 #endif
175
176