Salome HOME
refs #514: add 'Cursor for specific operations' section into preferences of HYDRO...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CalculationOp.h
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
24 #ifndef HYDROGUI_CALCULATIONOP_H
25 #define HYDROGUI_CALCULATIONOP_H
26
27 #include "HYDROGUI_Operation.h"
28
29 #include "HYDROData_SplitToZonesTool.h"
30 #include "HYDROGUI_Shape.h"
31
32 #include <HYDROData_CalculationCase.h>
33 #include <HYDROData_Region.h>
34
35 class SUIT_ViewManager;
36 class OCCViewer_ViewManager;
37 class HYDROGUI_CalculationDlg;
38 class SUIT_DataObject;
39
40 class HYDROGUI_CalculationOp : public HYDROGUI_Operation
41 {
42   Q_OBJECT
43
44 public:
45   HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit );
46   virtual ~HYDROGUI_CalculationOp();
47
48 protected:
49   virtual void                    startOperation();
50   virtual void                    abortOperation();
51   virtual void                    commitOperation();
52
53   virtual HYDROGUI_InputPanel*    createInputPanel() const;
54
55   virtual void                    onApply();
56   virtual bool                    processApply( int& theUpdateFlags, QString& theErrorMsg,
57                                                 QStringList& theBrowseObjectsEntries );
58
59   void setAvailableGroups();
60
61 protected slots:
62
63   /**
64    * Change the creation mode.
65    * @param theMode the mode to set
66    */
67   void                            onChangeMode( int theMode );
68
69   /**
70    * Add geometry objects selected in the module browser to the calculation case.
71    */
72   void                            onAddObjects();
73   /**
74    * Remove selected objects from the calculation case.
75    */
76   void                            onRemoveObjects();
77
78   /**
79    * Add geometry groups selected in the module browser to the calculation case.
80    */
81   void                            onAddGroups();
82   /**
83    * Remove selected groups from the calculation case.
84    */
85   void                            onRemoveGroups();
86
87   /**
88    * Set the given bathymetry merge type to the current zone.
89    */
90   void                            onSetMergeType( int theMergeType, QString& theBathymetryName );
91   /**
92    * Selected zones are moved to the existing region.
93    */
94   void                            onMoveZones( SUIT_DataObject* theRegionItem, 
95                                                const QList<SUIT_DataObject*>& theZonesList );
96   /**
97    * Selected zones are moved to the new region to be created.
98    */
99   void                            onCreateRegion( const QList<SUIT_DataObject*>& theZonesList );
100   /**
101    * Case objects must be splitted to zones if the case has been modified or new.
102    */
103   void                            onNext( const int );
104   void                            onLastViewClosed( SUIT_ViewManager* );
105   /**
106    * The zone is selected in the browser on the second page of the wizard.
107    */
108   void                            onClickedInZonesBrowser( SUIT_DataObject* theItem );
109   /**
110    * Hide zones in the viewer.
111    */
112   void                            onHideZones();
113   /** 
114    * Geometry object is selected in the list on the first wizard page
115    */
116   void                            onObjectsSelected();
117   /** 
118    * Boundary polyline is selected in the list on the first wizard page
119    */
120   void                            onBoundarySelected ( const QString & theObjName );
121
122 private:
123   void                            createPreview();
124   void                            closePreview();
125   void                            setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible );
126   void                            setZonesVisible( bool theIsVisible );
127   void                            getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq, 
128                                                       QStringList& theNames, QStringList& theEntries ) const;
129
130   /**
131    * Internal method that used to assign unique default colors for zones
132    */
133   void                            AssignDefaultZonesColors();
134   /**
135    * Internal method that used to generate default color for zone
136    * @param theIndex the index of color to be generated
137    * @param theSaturation the saturation of the color in the range 0 to 1,
138    * and the bigger it is, the stronger the color is. Grayish colors have
139    * saturation near 0, very strong colors have saturation near 1.
140    * The defalt value is 0.5.
141    * @param theValue the value in the range 0 to 1, represents lightness or
142    * brightness of the color. 0 is black, 1 is as far from black as possible.
143    * The defalt value is 0.95.
144    * \return the generated color
145    */
146   QColor                          GenerateDefaultZonesColor( int theIndex,
147                                                              float theSaturation = 0.5,
148                                                              float theValue = 0.95 ) const;
149
150   /**
151    * Ask user to confirm splitting zones recalculation after regions list modification.
152    * \return true if confirmed
153    */
154   bool                            confirmRegionsChange() const;
155
156   /**
157    * Ask user to confirm splitting zones recalculation after mode change.
158    * \return true if confirmed
159    */
160   bool                            confirmModeChange() const;
161
162   /**
163    * Ask user to confirm the operation continuation with warning.
164    * @param theWarning the warning
165    * \return true if confirmed
166    */
167   bool                            confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
168
169 private:
170   bool                            myIsEdit;
171   bool                            myShowZones;
172   Handle(HYDROData_CalculationCase) myEditedObject;
173
174   SUIT_ViewManager*               myActiveViewManager;
175   OCCViewer_ViewManager*          myPreviewViewManager;
176 };
177
178 #endif
179
180