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 * Set the given bathymetry/type merge type to the current zone.
86 void onSetMergeType( int theMergeType, QString& theMergeObjectName );
88 * Selected zones are moved to the existing region.
90 void onMoveZones( SUIT_DataObject* theRegionItem,
91 const QList<SUIT_DataObject*>& theZonesList);
93 * Selected zones are moved to the new region to be created.
95 void onCreateRegion( const QList<SUIT_DataObject*>& theZonesList );
97 * Case objects must be splitted to zones if the case has been modified or new.
99 void onNext( const int );
100 void onLastViewClosed( SUIT_ViewManager* );
102 * The zone is selected in the browser on the second page of the wizard.
104 void onClickedInZonesBrowser( SUIT_DataObject* theItem );
106 * Slot called on back button click.
108 void onHideZones( const int );
110 * Geometry object is selected in the list on the first wizard page
112 void onObjectsSelected();
114 * Land cover map is selected in the list on the third wizard page
116 void onLandCoverMapSelected( const QString & theObjName );
118 * Boundary polyline is selected in the list on the first wizard page
120 void onBoundarySelected( const QString & theObjName );
122 * Strickler table name is selected in the list on the third wizard page
124 void onStricklerTableSelected( const QString & theObjName );
126 void onOrderChanged( bool& isConfirmed );
128 void onRuleChanged( bool& isConfirmed );
130 void onRegenerateColors();
133 void createPreview( const bool theLandCoverMap);
134 void closePreview( bool theRemoveViewManager = true );
135 void setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible );
136 void setZonesVisible( bool theIsVisible );
137 void setGeomObjectsVisible( bool theIsVisible );
138 void setLandCoverMapVisible( bool theIsVisible );
139 void getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq,
140 QStringList& theNames, QStringList& theEntries ) const;
143 * Internal method that used to assign unique default colors for zones
145 void AssignDefaultZonesColors();
147 * Internal method that used to generate default color for zone
148 * @param theIndex the index of color to be generated
149 * @param theSaturation the saturation of the color in the range 0 to 1,
150 * and the bigger it is, the stronger the color is. Grayish colors have
151 * saturation near 0, very strong colors have saturation near 1.
152 * The defalt value is 0.5.
153 * @param theValue the value in the range 0 to 1, represents lightness or
154 * brightness of the color. 0 is black, 1 is as far from black as possible.
155 * The defalt value is 0.95.
156 * \return the generated color
158 QColor GenerateDefaultZonesColor( int theIndex,
159 float theSaturation = 0.5,
160 float theValue = 0.95 ) const;
162 void setRules( HYDROData_CalculationCase::DataTag theDataTag );
164 bool createRegion( const QList<SUIT_DataObject*>& theZonesList );
166 bool confirmRegionsChange() const;
167 bool confirmModeChange() const;
168 bool confirmOrderChange() const;
169 bool confirmRuleChange() const;
170 bool confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
175 bool myShowGeomObjects;
176 bool myShowLandCoverMap;
177 Handle(HYDROData_CalculationCase) myEditedObject;
179 SUIT_ViewManager* myActiveViewManager;
180 OCCViewer_ViewManager* myPreviewViewManager;