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 * Set the given Strickler merge type to the current zone.
105 void onSetMergeStricklerType( int theMergeType, QString& theStricklerTypeName );
107 * Selected zones are moved to the existing region.
109 void onMoveZones( SUIT_DataObject* theRegionItem,
110 const QList<SUIT_DataObject*>& theZonesList,
113 * Selected zones are moved to the new region to be created.
115 void onCreateRegion( const QList<SUIT_DataObject*>& theZonesList );
117 * Selected land cover zones are moved to the new region to be created.
119 void onCreateLandCoverRegion( const QList<SUIT_DataObject*>& theZonesList );
121 * Case objects must be splitted to zones if the case has been modified or new.
123 void onNext( const int );
124 void onLastViewClosed( SUIT_ViewManager* );
126 * The zone is selected in the browser on the second page of the wizard.
128 void onClickedInZonesBrowser( SUIT_DataObject* theItem );
130 * Hide zones in the viewer.
132 void onHideZones( const int );
134 * Geometry object is selected in the list on the first wizard page
136 void onObjectsSelected();
138 * Land cover is selected in the list on the third wizard page
140 void onLandCoversSelected();
142 * Boundary polyline is selected in the list on the first wizard page
144 void onBoundarySelected( const QString & theObjName );
146 * Strickler table name is selected in the list on the third wizard page
148 void onStricklerTableSelected( const QString & theObjName );
150 void onOrderChanged( bool& isConfirmed );
151 void onOrderLandCoverChanged( bool& isConfirmed );
154 void createPreview( const bool theLandCover);
156 void setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible );
157 void setZonesVisible( bool theIsVisible, const bool theLandCover );
158 void getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq,
159 QStringList& theNames, QStringList& theEntries ) const;
162 * Internal method that used to assign unique default colors for zones
164 void AssignDefaultZonesColors( const bool theLandCover );
166 * Internal method that used to generate default color for zone
167 * @param theIndex the index of color to be generated
168 * @param theSaturation the saturation of the color in the range 0 to 1,
169 * and the bigger it is, the stronger the color is. Grayish colors have
170 * saturation near 0, very strong colors have saturation near 1.
171 * The defalt value is 0.5.
172 * @param theValue the value in the range 0 to 1, represents lightness or
173 * brightness of the color. 0 is black, 1 is as far from black as possible.
174 * The defalt value is 0.95.
175 * \return the generated color
177 QColor GenerateDefaultZonesColor( int theIndex,
178 float theSaturation = 0.5,
179 float theValue = 0.95 ) const;
181 void setRules( HYDROData_CalculationCase::DataTag theDataTag );
183 bool createRegion( const QList<SUIT_DataObject*>& theZonesList,
184 const bool theLandCover );
186 bool confirmRegionsChange() const;
187 bool confirmModeChange() const;
188 bool confirmOrderChange() const;
189 bool confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
191 bool confirmLandCoverModeChange() const;
192 bool confirmLandCoverOrderChange() const;
197 Handle(HYDROData_CalculationCase) myEditedObject;
199 SUIT_ViewManager* myActiveViewManager;
200 OCCViewer_ViewManager* myPreviewViewManager;