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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef HYDROGUI_CALCULATIONOP_H
21 #define HYDROGUI_CALCULATIONOP_H
23 #include "HYDROGUI_Operation.h"
25 #include "HYDROData_SplitToZonesTool.h"
26 #include "HYDROGUI_Shape.h"
28 #include <HYDROData_CalculationCase.h>
29 #include <HYDROData_Region.h>
31 class SUIT_ViewManager;
32 class OCCViewer_ViewManager;
33 class HYDROGUI_CalculationDlg;
34 class SUIT_DataObject;
36 class HYDROGUI_CalculationOp : public HYDROGUI_Operation
41 HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit );
42 virtual ~HYDROGUI_CalculationOp();
45 virtual void startOperation();
46 virtual void abortOperation();
47 virtual void commitOperation();
49 virtual HYDROGUI_InputPanel* createInputPanel() const;
51 virtual void onApply();
52 virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
53 QStringList& theBrowseObjectsEntries );
55 void setAvailableGroups();
60 * Change the creation mode.
61 * @param theMode the mode to set
63 void onChangeMode( int theMode );
66 * Add geometry objects selected in the module browser to the calculation case.
70 * Remove selected objects from the calculation case.
72 void onRemoveObjects();
75 * Add geometry groups selected in the module browser to the calculation case.
79 * Remove selected groups from the calculation case.
81 void onRemoveGroups();
84 * Change the creation mode related to land covers.
85 * @param theMode the mode to set
87 void onChangeLandCoverMode( int theMode );
90 * Add land covers selected in the module browser to the calculation case.
92 void onAddLandCovers();
94 * Remove selected land covers from the calculation case.
96 void onRemoveLandCovers();
99 * Set the given bathymetry/type merge type to the current zone.
101 void onSetMergeType( int theMergeType, QString& theMergeObjectName );
103 * Selected zones are moved to the existing region.
105 void onMoveZones( SUIT_DataObject* theRegionItem,
106 const QList<SUIT_DataObject*>& theZonesList );
108 * Selected zones are moved to the new region to be created.
110 void onCreateRegion( const QList<SUIT_DataObject*>& theZonesList );
112 * Selected land cover zones are moved to the new region to be created.
114 void onCreateLandCoverRegion( const QList<SUIT_DataObject*>& theZonesList );
116 * Case objects must be splitted to zones if the case has been modified or new.
118 void onNext( const int );
119 void onLastViewClosed( SUIT_ViewManager* );
121 * The zone is selected in the browser on the second page of the wizard.
123 void onClickedInZonesBrowser( SUIT_DataObject* theItem );
125 * Hide zones in the viewer.
127 void onHideZones( const int );
129 * Geometry object is selected in the list on the first wizard page
131 void onObjectsSelected();
133 * Land cover is selected in the list on the third wizard page
135 void onLandCoversSelected();
137 * Boundary polyline is selected in the list on the first wizard page
139 void onBoundarySelected( const QString & theObjName );
141 * Strickler table name is selected in the list on the third wizard page
143 void onStricklerTableSelected( const QString & theObjName );
145 void onOrderChanged( bool& isConfirmed );
146 void onOrderLandCoverChanged( bool& isConfirmed );
149 void createPreview( const bool theLandCover);
151 void setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible );
152 void setZonesVisible( bool theIsVisible, const bool theLandCover );
153 void getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq,
154 QStringList& theNames, QStringList& theEntries ) const;
157 * Internal method that used to assign unique default colors for zones
159 void AssignDefaultZonesColors( const bool theLandCover );
161 * Internal method that used to generate default color for zone
162 * @param theIndex the index of color to be generated
163 * @param theSaturation the saturation of the color in the range 0 to 1,
164 * and the bigger it is, the stronger the color is. Grayish colors have
165 * saturation near 0, very strong colors have saturation near 1.
166 * The defalt value is 0.5.
167 * @param theValue the value in the range 0 to 1, represents lightness or
168 * brightness of the color. 0 is black, 1 is as far from black as possible.
169 * The defalt value is 0.95.
170 * \return the generated color
172 QColor GenerateDefaultZonesColor( int theIndex,
173 float theSaturation = 0.5,
174 float theValue = 0.95 ) const;
176 void setRules( HYDROData_CalculationCase::DataTag theDataTag );
178 bool createRegion( const QList<SUIT_DataObject*>& theZonesList,
179 const bool theLandCover );
181 bool confirmRegionsChange() const;
182 bool confirmModeChange() const;
183 bool confirmOrderChange() const;
184 bool confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
186 bool confirmLandCoverModeChange() const;
187 bool confirmLandCoverOrderChange() const;
192 Handle(HYDROData_CalculationCase) myEditedObject;
194 SUIT_ViewManager* myActiveViewManager;
195 OCCViewer_ViewManager* myPreviewViewManager;