Salome HOME
refs #542: warning about changed objects order
[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   void onOrderChanged( bool& isConfirmed );
119
120 private:
121   void                            createPreview();
122   void                            closePreview();
123   void                            setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible );
124   void                            setZonesVisible( bool theIsVisible );
125   void                            getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq, 
126                                                       QStringList& theNames, QStringList& theEntries ) const;
127
128   /**
129    * Internal method that used to assign unique default colors for zones
130    */
131   void                            AssignDefaultZonesColors();
132   /**
133    * Internal method that used to generate default color for zone
134    * @param theIndex the index of color to be generated
135    * @param theSaturation the saturation of the color in the range 0 to 1,
136    * and the bigger it is, the stronger the color is. Grayish colors have
137    * saturation near 0, very strong colors have saturation near 1.
138    * The defalt value is 0.5.
139    * @param theValue the value in the range 0 to 1, represents lightness or
140    * brightness of the color. 0 is black, 1 is as far from black as possible.
141    * The defalt value is 0.95.
142    * \return the generated color
143    */
144   QColor                          GenerateDefaultZonesColor( int theIndex,
145                                                              float theSaturation = 0.5,
146                                                              float theValue = 0.95 ) const;
147
148   bool confirmRegionsChange() const;
149   bool confirmModeChange() const;
150   bool confirmOrderChange() const;
151   bool confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
152
153 private:
154   bool                            myIsEdit;
155   bool                            myShowZones;
156   Handle(HYDROData_CalculationCase) myEditedObject;
157
158   SUIT_ViewManager*               myActiveViewManager;
159   OCCViewer_ViewManager*          myPreviewViewManager;
160 };
161
162 #endif
163
164