#include "HYDROData_Iterator.h"
#include "HYDROData_NaturalObject.h"
#include "HYDROData_PolylineXY.h"
+#include "HYDROData_StricklerTable.h"
+#include "HYDROData_LandCover.h"
#include "HYDROData_SplittedShapesGroup.h"
#include "HYDROData_Region.h"
#include "HYDROData_Tool.h"
SetToUpdate( !aPrevPolyline.IsNull() || IsMustBeUpdated() );
}
+void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable )
+{
+ Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
+
+ SetReferenceObject( theStricklerTable, DataTag_StricklerTable );
+
+ // Indicate model of the need to update land covers partition
+ SetToUpdate( !IsEqual( aPrevStricklerTable, theStricklerTable ) || IsMustBeUpdated() );
+}
+
+Handle(HYDROData_StricklerTable) HYDROData_CalculationCase::GetStricklerTable() const
+{
+ return Handle(HYDROData_StricklerTable)::DownCast(
+ GetReferenceObject( DataTag_StricklerTable ) );
+}
+
+void HYDROData_CalculationCase::RemoveStricklerTable()
+{
+ Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
+
+ ClearReferenceObjects( DataTag_StricklerTable );
+
+ // Indicate model of the need to update land covers partition
+ SetToUpdate( !aPrevStricklerTable.IsNull() || IsMustBeUpdated() );
+}
+
+bool HYDROData_CalculationCase::AddLandCover( const Handle(HYDROData_LandCover)& theLandCover )
+{
+ if ( HasReference( theLandCover, DataTag_LandCover ) )
+ return false; // Land cover is already in reference list
+
+ AddReferenceObject( theLandCover, DataTag_LandCover );
+
+ // Indicate model of the need to update land covers partition
+ SetToUpdate( true );
+
+ return true;
+}
+
+HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetLandCovers() const
+{
+ return GetReferenceObjects( DataTag_LandCover );
+}
+
+void HYDROData_CalculationCase::RemoveLandCover( const Handle(HYDROData_LandCover)& theLandCover )
+{
+ if ( theLandCover.IsNull() )
+ return;
+
+ RemoveReferenceObject( theLandCover->Label(), DataTag_LandCover );
+
+ // Indicate model of the need to update land cover partition
+ SetToUpdate( true );
+}
+
+void HYDROData_CalculationCase::RemoveLandCovers()
+{
+ ClearReferenceObjects( DataTag_LandCover );
+
+ // Indicate model of the need to update land cover partition
+ SetToUpdate( true );
+}
+
Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone )
{
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
theObject1, thePriority, theObject2, theMergeType );
}
+
+void HYDROData_CalculationCase::SetAssignmentLandCoverMode( AssignmentMode theMode )
+{
+ TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentLandCoverMode );
+ TDataStd_Integer::Set( aModeLab, ( int ) theMode );
+
+ // Indicate model of the need to update land covers partition
+ SetToUpdate( true );
+}
+
+HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentLandCoverMode() const
+{
+ Handle(TDataStd_Integer) aModeAttr;
+ bool isOK = myLab.FindChild( DataTag_AssignmentLandCoverMode ).FindAttribute( TDataStd_Integer::GetID(), aModeAttr );
+ if( isOK )
+ return ( AssignmentMode ) aModeAttr->Get();
+ else
+ return MANUAL;
+}
+
+void HYDROData_CalculationCase::ClearLandCoverRules( const bool theIsSetToUpdate )
+{
+ TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules );
+ // TODO: adapt HYDROData_PriorityQueue to use with land covers
+ //HYDROData_PriorityQueue::ClearRules( aRulesLab );
+
+ // Indicate model of the need to update land covers partition
+ if ( theIsSetToUpdate ) {
+ SetToUpdate( true );
+ }
+}
+
+void HYDROData_CalculationCase::AddLandCoverRule( const Handle(HYDROData_LandCover)& theLandCover1,
+ HYDROData_PriorityType thePriority,
+ const Handle(HYDROData_LandCover)& theLandCover2/*,
+ HYDROData_LandCover::MergeStricklerCoefficientType theMergeType*/ )
+{
+ TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules );
+ // TODO: adapt HYDROData_PriorityQueue to use with land covers
+ //HYDROData_PriorityQueue::AddRule( aRulesLab, theLandCover1, thePriority, theLandCover2, theMergeType );
+
+ // Indicate model of the need to update splitting
+ SetToUpdate( true );
+}
+
+bool HYDROData_CalculationCase::GetLandCoverRule( int theIndex,
+ Handle(HYDROData_LandCover)& theLandCover1,
+ HYDROData_PriorityType& thePriority,
+ Handle(HYDROData_LandCover)& theLandCover2/*,
+ HYDROData_LandCover::MergeStricklerCoefficientType& theMergeType*/ ) const
+{
+ TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules );
+ // TODO: adapt HYDROData_PriorityQueue to use with land covers
+ //return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
+ // theLandCover1, thePriority, theLandCover2, theMergeType );
+ return true;
+}
class Handle(HYDROData_ShapesGroup);
class Handle(HYDROData_SplittedShapesGroup);
class Handle(HYDROData_Document);
+class Handle(HYDROData_StricklerTable);
+class Handle(HYDROData_LandCover);
DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
enum DataTag
{
DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
- DataTag_GeometryObject, ///< reference geometry objects
- DataTag_ChildRegion, ///< child regions
- DataTag_Region, ///< reference regions
- DataTag_Polyline, ///< reference boundary polyline
- DataTag_GeometryGroup, ///< reference geometry groups
- DataTag_SplittedGroups, ///< reference splitted groups
- DataTag_CustomRules, ///< custom rules
- DataTag_AssignmentMode, ///< assignment mode
+ DataTag_GeometryObject, ///< reference geometry objects
+ DataTag_ChildRegion, ///< child regions
+ DataTag_Region, ///< reference regions
+ DataTag_Polyline, ///< reference boundary polyline
+ DataTag_GeometryGroup, ///< reference geometry groups
+ DataTag_SplittedGroups, ///< reference splitted groups
+ DataTag_CustomRules, ///< custom rules
+ DataTag_AssignmentMode, ///< assignment mode
+ DataTag_StricklerTable, ///< reference Strickler table
+ DataTag_LandCover, ///< reference land covers
+ DataTag_CustomLandCoverRules, ///< custom rules for land covers priority
+ DataTag_AssignmentLandCoverMode ///< assignment mode of land covers priority
};
public:
HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
+ /**
+ * Sets reference Strickler table for calculation case.
+ */
+ HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
+
+ /**
+ * Returns reference Strickler table of calculation case.
+ */
+ HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
+
+ /**
+ * Remove reference Strickler table from calculation case.
+ */
+ HYDRODATA_EXPORT virtual void RemoveStricklerTable();
+
+
+ /**
+ * Add new one reference land cover for calculation case.
+ */
+ HYDRODATA_EXPORT virtual bool AddLandCover( const Handle(HYDROData_LandCover)& theLandCover );
+
+ /**
+ * Returns all reference land covers of calculation case.
+ */
+ HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetLandCovers() const;
+
+ /**
+ * Removes reference land cover from calculation case.
+ */
+ HYDRODATA_EXPORT virtual void RemoveLandCover( const Handle(HYDROData_LandCover)& theLandCover );
+
+ /**
+ * Removes all reference land covers from calculation case.
+ */
+ HYDRODATA_EXPORT virtual void RemoveLandCovers();
+
+
/**
* Add new one child region for calculation case.
* The new region is added into the list of reference regions.
Handle(HYDROData_Object)& theObject2,
HYDROData_Zone::MergeAltitudesType& theMergeType ) const;
+ HYDRODATA_EXPORT void SetAssignmentLandCoverMode( AssignmentMode theMode );
+ HYDRODATA_EXPORT AssignmentMode GetAssignmentLandCoverMode() const;
+
+ HYDRODATA_EXPORT void ClearLandCoverRules( const bool theIsSetToUpdate = true );
+ HYDRODATA_EXPORT void AddLandCoverRule( const Handle(HYDROData_LandCover)& theLandCover1,
+ HYDROData_PriorityType thePriority,
+ const Handle(HYDROData_LandCover)& theLandCover2/*,
+ HYDROData_LandCover::MergeStricklerCoefficientType theMergeType*/ );
+ HYDRODATA_EXPORT bool GetLandCoverRule( int theIndex,
+ Handle(HYDROData_LandCover)& theLandCover1,
+ HYDROData_PriorityType& thePriority,
+ Handle(HYDROData_LandCover)& theLandCover2/*,
+ HYDROData_LandCover::MergeStricklerCoefficientType& theMergeType*/ ) const;
+
HYDRODATA_EXPORT QString DumpRules() const;
HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
{
addPage( createObjectsPage() );
addPage( createGroupsPage() );
+ addPage( createLandCoversPage() );
addPage( createZonesPage() );
+ addPage( createLandCoversPartitionPage() );
}
HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList;
myGeomObjects->setObjects(anObject2VisibleList);
myPolylineName->clear();
+ myStricklerTableName->clear();
myAvailableGeomObjects->clear();
// Activate the automatic mode
setMode( HYDROData_CalculationCase::AUTOMATIC );
+ setLandCoverMode( HYDROData_CalculationCase::AUTOMATIC );
// Reset the priority widget state
QList<Handle(HYDROData_Object)> anObjects;
return aPage;
}
+QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() {
+ QWizardPage* aPage = new QWizardPage( mainFrame() );
+ QFrame* aFrame = new QFrame( aPage );
+
+ // Splitter
+ myLandCoverSplitter = new QSplitter(Qt::Vertical);
+
+ // Top of the page
+ QWidget* aTopContainer = new QWidget;
+
+ // Combo-box to choose Strickler table name
+ QLabel* aStricklerTableLabel = new QLabel( tr( "STRICKLER_TABLE" ), aPage );
+ myStricklerTableName = new QComboBox( aPage );
+ myStricklerTableName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ connect( myStricklerTableName, SIGNAL( activated( const QString & ) ),
+ SIGNAL( StricklerTableSelected( const QString & ) ) );
+
+ // mode selector (auto/manual)
+ QGroupBox* aModeGroup = new QGroupBox( tr( "MODE" ) );
+
+ QRadioButton* aManualRB = new QRadioButton( tr( "MANUAL" ), mainFrame() );
+ QRadioButton* anAutoRB = new QRadioButton( tr( "AUTO" ), mainFrame() );
+
+ myLandCoverModeButtons = new QButtonGroup( mainFrame() );
+ myLandCoverModeButtons->addButton( anAutoRB, HYDROData_CalculationCase::AUTOMATIC );
+ myLandCoverModeButtons->addButton( aManualRB, HYDROData_CalculationCase::MANUAL );
+
+ QBoxLayout* aModeSelectorLayout = new QHBoxLayout;
+ aModeSelectorLayout->setMargin( 5 );
+ aModeSelectorLayout->setSpacing( 5 );
+ aModeSelectorLayout->addWidget( anAutoRB );
+ aModeSelectorLayout->addWidget( aManualRB );
+ aModeGroup->setLayout( aModeSelectorLayout );
+
+ // land covers
+ QLabel* aLandCoversLabel = new QLabel( tr( "CALCULATION_REFERENCE_LAND_COVERS" ) );
+ myLandCovers = new HYDROGUI_OrderedListWidget( aPage, 16 );
+ myLandCovers->setHiddenObjectsShown(true);
+ myLandCovers->setVisibilityIconShown(false);
+ myLandCovers->setContentsMargins(QMargins());
+
+ // included land covers
+ QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_LAND_COVERS" ) );
+ myAvailableLandCovers = new QListWidget( aPage );
+ myAvailableLandCovers->setSelectionMode( QListWidget::ExtendedSelection );
+ myAvailableLandCovers->setEditTriggers( QListWidget::NoEditTriggers );
+ myAvailableLandCovers->setViewMode( QListWidget::ListMode );
+ myAvailableLandCovers->setSortingEnabled( true );
+
+ // buttons
+ QFrame* aBtnsFrame = new QFrame;
+ QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
+ aBtnsLayout->setMargin( 5 );
+ aBtnsLayout->setSpacing( 5 );
+ aBtnsFrame->setLayout( aBtnsLayout );
+ QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
+ QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
+
+ // fill the butons frame with two buttons
+ aBtnsLayout->addWidget( anAddBtn );
+ aBtnsLayout->addWidget( aRemoveBtn );
+ aBtnsLayout->addStretch( 1 );
+
+ // top of the page layout
+
+ // land covers frame
+ QFrame* aLandCoversFrame = new QFrame( aPage );
+ aLandCoversFrame->setFrameStyle( QFrame::Panel | QFrame::Raised );
+ QGridLayout* aLandCoversLayout = new QGridLayout( aLandCoversFrame );
+ aLandCoversLayout->setMargin( 5 );
+ aLandCoversLayout->setSpacing( 5 );
+ aLandCoversFrame->setLayout( aLandCoversLayout );
+
+ // fill the land covers frame with two lists, two labels and with buttons frame
+ aLandCoversLayout->addWidget( aLandCoversLabel, 0, 0, Qt::AlignHCenter );
+ aLandCoversLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
+ aLandCoversLayout->addWidget( myAvailableLandCovers, 1, 0 );
+ aLandCoversLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
+ aLandCoversLayout->addWidget( myLandCovers, 1, 2 );
+
+ // fill the top of the page
+ QGridLayout* aTopLayout = new QGridLayout;
+ aTopLayout->setMargin( 5 );
+ aTopLayout->setSpacing( 5 );
+ aTopLayout->setVerticalSpacing( 10 );
+ aTopLayout->addWidget( aStricklerTableLabel, 0, 0, Qt::AlignHCenter );
+ aTopLayout->addWidget( myStricklerTableName, 0, 1 );
+ aTopLayout->addWidget( aModeGroup, 1, 0, 1, 2 );
+ aTopLayout->addWidget( aLandCoversFrame, 2, 0, 1, 2 );
+
+ aTopContainer->setLayout( aTopLayout );
+
+ // add the top of the page to the splitter
+ myLandCoverSplitter->insertWidget(0, aTopContainer);
+ myLandCoverSplitter->setStretchFactor(0, 2);
+
+ // Bottom of the page
+ myLandCoverPriorityWidget = new HYDROGUI_PriorityWidget( mainFrame() );
+
+ QGroupBox* aPriorityGroup = new QGroupBox( tr( "PRIORITY" ) );
+ QBoxLayout* aPriorityLayout = new QHBoxLayout;
+ aPriorityLayout->setMargin( 5 );
+ aPriorityLayout->setSpacing( 5 );
+ aPriorityLayout->addWidget( myLandCoverPriorityWidget );
+ aPriorityGroup->setLayout( aPriorityLayout );
+
+ // add the bottom of the page to the splitter
+ myLandCoverSplitter->insertWidget(1, aPriorityGroup);
+ myLandCoverSplitter->setStretchFactor(1, 1);
+
+ // Page layout
+ QVBoxLayout* aPageLayout = new QVBoxLayout;
+ aPageLayout->setMargin( 5 );
+ aPageLayout->setSpacing( 5 );
+ aPageLayout->addWidget( myLandCoverSplitter );
+
+ aPage->setLayout( aPageLayout );
+
+ // Create selector
+ if ( module() ) {
+ HYDROGUI_ListSelector* aListSelector =
+ new HYDROGUI_ListSelector( myLandCovers, module()->getApp()->selectionMgr() );
+ aListSelector->setAutoBlock( true );
+ }
+
+ // Connections
+ connect( myLandCoverModeButtons, SIGNAL( buttonClicked( int ) ), SIGNAL( changeLandCoverMode( int ) ) );
+ connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addLandCovers() ) );
+ connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeLandCovers() ) );
+
+ connect( myLandCovers, SIGNAL( orderLandCoverChanged() ), SLOT( onOrderLandCoverChanged() ) );
+
+ return aPage;
+}
+
QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
QWizardPage* aPage = new QWizardPage( mainFrame() );
QFrame* aFrame = new QFrame( aPage );
return aPage;
}
+QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPartitionPage() {
+ QWizardPage* aPage = new QWizardPage( mainFrame() );
+ QFrame* aFrame = new QFrame( aPage );
+
+ QGridLayout* aLayout = new QGridLayout( aPage );
+
+ myLandCoverBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage );
+ myLandCoverBrowser->setAutoOpenLevel( 3 );
+ aLayout->setMargin( 5 );
+ aLayout->setSpacing( 5 );
+
+ aLayout->addWidget( myLandCoverBrowser, 0, 0, 1, 2 );
+
+ aPage->setLayout( aLayout );
+
+ // Connections
+ //...
+
+ return aPage;
+}
+
bool HYDROGUI_CalculationDlg::acceptCurrent() const
{
myPolylineName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
}
}
+
+void HYDROGUI_CalculationDlg::setStricklerTableNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
+{
+ myStricklerTableName->clear();
+
+ for ( int i = 0, n = theObjects.length(); i < n; ++i )
+ {
+ myStricklerTableName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
+ }
+}
+
void HYDROGUI_CalculationDlg::setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries )
{
myAvailableGeomObjects->clear();
}
}
+/**
+ Get creation mode for land covers panel.
+ @param theMode the mode
+*/
+int HYDROGUI_CalculationDlg::getLandCoverMode() const
+{
+ return myLandCoverModeButtons->checkedId();
+}
+
+/**
+ Set creation mode for land cover panel.
+ @param theMode the mode
+*/
+void HYDROGUI_CalculationDlg::setLandCoverMode( int theMode )
+{
+ bool isBlocked = myLandCoverModeButtons->blockSignals( true );
+ myLandCoverModeButtons->button( theMode )->setChecked( true );
+ myLandCoverModeButtons->blockSignals( isBlocked );
+
+ bool isAuto = ( theMode == HYDROData_CalculationCase::AUTOMATIC );
+
+ myLandCovers->setOrderingEnabled( isAuto );
+ QWidget* aWidget = myLandCoverSplitter->widget( 1 );
+ if ( aWidget ) {
+ aWidget->setVisible( isAuto );
+ }
+}
+
/**
Enable/disable zones drag'n'drop and renaming.
@param theIsEnabled if true - zones drag'n'drop and renaming will be enabled
myBrowser->setReadOnly( !theIsEnabled );
}
+/**
+ Enable/disable land covers drag'n'drop and renaming.
+ @param theIsEnabled if true - land covers drag'n'drop and renaming will be enabled
+*/
+void HYDROGUI_CalculationDlg::setEditLandCoversEnabled( const bool theIsEnabled )
+{
+ myLandCoverBrowser->setReadOnly( !theIsEnabled );
+}
+
/**
Get included geometry objects.
@return the list of geometry objects
return anObjects;
}
+/**
+ Get included land covers.
+ @return the list of land covers
+ */
+QList<Handle(HYDROData_LandCover)> HYDROGUI_CalculationDlg::getLandCovers()
+{
+ QList<Handle(HYDROData_Entity)> anEntities = myLandCovers->getObjects();
+ QList<Handle(HYDROData_LandCover)> aLandCovers;
+
+ foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
+ Handle(HYDROData_LandCover) aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
+ if ( aLandCover.IsNull() ) {
+ continue;
+ }
+
+ aLandCovers << aLandCover;
+ }
+
+ return aLandCovers;
+}
+
/**
Get rules.
@return the list of rules
else
myGeomObjects->undoLastMove();
}
+
+void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTableName )
+{
+ bool isBlocked = myStricklerTableName->blockSignals( true );
+ myStricklerTableName->setCurrentIndex( myStricklerTableName->findText( theStricklerTableName ) );
+ myStricklerTableName->blockSignals( isBlocked );
+}
+
+/**
+ Slot called when land covers order is changed.
+ */
+void HYDROGUI_CalculationDlg::onOrderLandCoverChanged()
+{
+ bool isConfirmed = true;
+ emit orderLandCoverChanged( isConfirmed );
+ /*if( isConfirmed )
+ myLandCoverPriorityWidget->setObjects( getLandCovers() );
+ else
+ myLandCovers->undoLastMove();
+ */
+}
#include "HYDROGUI_Wizard.h"
#include <HYDROData_CalculationCase.h>
+#include <HYDROData_LandCover.h>
class HYDROGUI_ObjSelector;
class HYDROGUI_DataBrowser;
void reset();
int getMode() const;
+ int getLandCoverMode() const;
void setObjectName( const QString& theName );
QString getObjectName() const;
void setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries );
QStringList getAllGeomObjects() const;
void setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries );
+ void setStricklerTableNames( const QStringList& theObjects, const QStringList& theObjectsEntries );
QStringList getSelectedGeomObjects() const;
QStringList getSelectedAvailableGeomObjects() const;
QStringList getSelectedGroups() const;
void setAvailableGroups( const QStringList& );
void setEditZonesEnabled( const bool theIsEnabled );
+ void setEditLandCoversEnabled( const bool theIsEnabled );
HYDROData_ListOfRules getRules() const;
void setRules( const HYDROData_ListOfRules& theRules ) const;
void onDataChanged();
void onOrderChanged();
+ void setLandCoverMode( int theMode );
+ void setStricklerTable( const QString& theStricklerTableName );
+ void onOrderLandCoverChanged();
+
/**
* Process items selection: hide/show bathymetry merge type selector.
*/
SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction );
signals:
- void changeMode( int theMode );
+ void changeMode( int theMode );
void addObjects();
void removeObjects();
void moveZones( SUIT_DataObject* theRegion, const QList<SUIT_DataObject*>& theZonesList );
void clickedInZonesBrowser( SUIT_DataObject* );
+ void changeLandCoverMode( int theMode );
+
+ void addLandCovers();
+ void removeLandCovers();
+ void orderLandCoverChanged( bool& isConfirmed );
+
+ void StricklerTableSelected( const QString & theObjName );
+
protected:
virtual bool acceptCurrent() const;
private:
QList<Handle(HYDROData_Object)> getGeometryObjects();
+ QList<Handle(HYDROData_LandCover)> getLandCovers();
QWizardPage* createObjectsPage();
QWizardPage* createGroupsPage();
+ QWizardPage* createLandCoversPage();
QWizardPage* createZonesPage();
+ QWizardPage* createLandCoversPartitionPage();
QSplitter* mySplitter;
+ QSplitter* myLandCoverSplitter;
QGroupBox* myObjectNameGroup;
QLineEdit* myObjectName;
HYDROGUI_NameValidator* myValidator;
QComboBox* myPolylineName;
+ QComboBox* myStricklerTableName;
QButtonGroup* myModeButtons;
+ QButtonGroup* myLandCoverModeButtons;
QListWidget* myAvailableGeomObjects;
HYDROGUI_OrderedListWidget* myGeomObjects;
HYDROGUI_PriorityWidget* myPriorityWidget;
+ HYDROGUI_PriorityWidget* myLandCoverPriorityWidget;
QListWidget* myAvailableGroups;
QListWidget* myGroups;
+ QListWidget* myAvailableLandCovers;
+ HYDROGUI_OrderedListWidget* myLandCovers;
+
HYDROGUI_DataBrowser* myBrowser;
Handle(HYDROData_CalculationCase) myEditedObject;
QComboBox* myBathymetryChoice;
QLabel* myBathymetryLabel;
HYDROGUI_Zone* myCurrentZone;
+
+ HYDROGUI_DataBrowser* myLandCoverBrowser;
};
#endif
#include <HYDROData_ImmersibleZone.h>
#include <HYDROData_Object.h>
#include <HYDROData_Tool.h>
+#include <HYDROData_StricklerTable.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
// Connect signals and slots
connect( aPanel, SIGNAL( changeMode( int ) ), SLOT( onChangeMode( int ) ) );
+ connect( aPanel, SIGNAL( changeLandCoverMode( int ) ), SLOT( onChangeLandCoverMode( int ) ) );
connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) );
connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
connect( aPanel, SIGNAL( addGroups() ), SLOT( onAddGroups() ) );
connect( aPanel, SIGNAL( removeGroups() ), SLOT( onRemoveGroups() ) );
connect( aPanel, SIGNAL( orderChanged( bool& ) ), SLOT( onOrderChanged( bool& ) ) );
+ connect( aPanel, SIGNAL( orderLandCoverChanged( bool& ) ), SLOT( onOrderLandCoverChanged( bool& ) ) );
connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones() ) );
//connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
SLOT( onObjectsSelected() ) );
connect( aPanel, SIGNAL( boundarySelected( const QString & ) ),
SLOT( onBoundarySelected( const QString & ) ) );
+ connect( aPanel, SIGNAL( StricklerTableSelected( const QString & ) ),
+ SLOT( onStricklerTableSelected( const QString & ) ) );
return aPanel;
}
}
}
+void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjName )
+{
+ bool anIsToUpdateViewer = false;
+
+ // Remove old presentations of land covers from the operation viewer
+ Handle(HYDROData_Entity) anEntity;
+ Handle(HYDROData_LandCover) aLandCover;
+ HYDROData_SequenceOfObjects aLandCovers;
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCovers();
+ HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ anEntity = anIter.Value();
+ if ( !anEntity.IsNull() )
+ {
+ aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
+ if ( !aLandCover.IsNull() )
+ {
+ aLandCovers.Append( aLandCover );
+ setObjectVisibility( aLandCover, false );
+ anIsToUpdateViewer = true;
+ }
+ }
+ }
+
+ // Set the selected Strickler table to the calculation case
+ Handle(HYDROData_StricklerTable) aNewStricklerTable = Handle(HYDROData_StricklerTable)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_STRICKLER_TABLE ) );
+ myEditedObject->SetStricklerTable( aNewStricklerTable );
+
+ if ( myPreviewViewManager )
+ {
+ OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
+ if ( aViewer )
+ {
+ if ( !aNewStricklerTable.IsNull() )
+ {
+ Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+ if ( !aCtx.IsNull() )
+ {
+ HYDROData_SequenceOfObjects::Iterator anIter( aLandCovers );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ anEntity = anIter.Value();
+ if ( !anEntity.IsNull() )
+ {
+ aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
+ if ( !aLandCover.IsNull() )
+ {
+ setObjectVisibility( aLandCover, true );
+ anIsToUpdateViewer = true;
+ }
+ }
+ }
+ }
+ }
+
+ if ( anIsToUpdateViewer )
+ module()->update( UF_OCCViewer );
+ }
+ }
+}
+
void HYDROGUI_CalculationOp::onObjectsSelected()
{
HYDROGUI_CalculationDlg* aPanel =
return ( anAnswer == QMessageBox::Yes );
}
+bool HYDROGUI_CalculationOp::confirmLandCoverModeChange() const
+{
+ // Check if the case is already modified or not
+ bool isConfirmed = myEditedObject->IsMustBeUpdated();
+ if ( !isConfirmed )
+ {
+ // If not modified check if the case has already defined regions with zones
+ // TODO: adapt HYDROData_CalculationCase class to process regions constructed for land covers
+ /*HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCoverRegions();
+ if ( aSeq.Length() > 0 )
+ {*/
+ // If there are already defined zones then ask a user to confirm zones recalculation
+ isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
+ tr( "MODE_CHANGED" ),
+ tr( "CONFIRM_LAND_COVER_PARTITION_RECALCULATION_MODE" ),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No ) == QMessageBox::Yes );
+ /*}
+ else
+ {
+ isConfirmed = true; // No regions - no zones - nothing to recalculate
+ }*/
+ }
+ return isConfirmed;
+}
+
bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags,
QString& theErrorMsg,
QStringList& theBrowseObjectsEntries )
if ( aPanel->getMode() == HYDROData_CalculationCase::MANUAL ) {
myEditedObject->ClearRules( false );
}
+ if ( aPanel->getLandCoverMode() == HYDROData_CalculationCase::MANUAL ) {
+ myEditedObject->ClearLandCoverRules( false );
+ }
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
setAvailableGroups();
}
else if( theIndex==2 )
+ {
+ // Land covers panel
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ QStringList aList;
+ QStringList anEntryList;
+
+ // Get all Strickler table objects to fill in combo-box
+ aList.clear();
+ anEntryList.clear();
+ HYDROData_Iterator anIter( doc(), KIND_STRICKLER_TABLE );
+ Handle(HYDROData_StricklerTable) aStricklerTableObj;
+ QString aStricklerTableName;
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIter.Current() );
+
+ if ( !aStricklerTableObj.IsNull() )
+ {
+ aStricklerTableName = aStricklerTableObj->GetName();
+ if ( !aStricklerTableName.isEmpty() )
+ {
+ aList.append( aStricklerTableName );
+ anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aStricklerTableObj ) );
+ }
+ }
+ }
+ aPanel->setStricklerTableNames( aList, anEntryList );
+
+ //HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetGeometryObjects( module() );
+ //getNamesAndEntries( aSeq, aList, anEntryList );
+ //aPanel->setAllGeomObjects( aList, anEntryList );
+
+ if ( !myEditedObject.IsNull() )
+ {
+ if ( myIsEdit )
+ {
+ // Select the certain Strickler table object in combo-box
+ aStricklerTableObj = myEditedObject->GetStricklerTable();
+ if ( aStricklerTableObj.IsNull() )
+ {
+ aPanel->setStricklerTable( QString() );
+ }
+ else
+ {
+ aStricklerTableName = aStricklerTableObj->GetName();
+ aPanel->setStricklerTable( aStricklerTableName );
+ }
+
+ // Set mode (Auto or Manual) to defined priority of land covers
+ aPanel->setLandCoverMode( myEditedObject->GetAssignmentLandCoverMode() );
+ }
+ else
+ {
+ myEditedObject->SetAssignmentLandCoverMode( (HYDROData_CalculationCase::AssignmentMode)aPanel->getLandCoverMode() );
+ }
+ }
+ }
+ else if( theIndex==3 )
{
HYDROGUI_CalculationDlg* aPanel =
::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
}
}
+ QApplication::restoreOverrideCursor();
+ }
+ else if( theIndex==4 )
+ {
+ // Partition of Land covers panel
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+
+ //...
+
+ // Set parameters for automatic mode
+ int aMode = aPanel->getLandCoverMode();
+ if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
+ {
+ // Set objects in the specified order
+ if( myEditedObject->IsMustBeUpdated() )
+ {
+ //...
+ }
+ }
+ aPanel->setEditLandCoversEnabled( aMode == HYDROData_CalculationCase::MANUAL );
+
QApplication::restoreOverrideCursor();
}
}
aPanel->setMode( theMode );
}
+void HYDROGUI_CalculationOp::onChangeLandCoverMode( int theMode )
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ if ( !confirmLandCoverModeChange() ) {
+ aPanel->setLandCoverMode( myEditedObject->GetAssignmentLandCoverMode() );
+ return;
+ }
+
+ myEditedObject->SetAssignmentLandCoverMode( (HYDROData_CalculationCase::AssignmentMode)theMode );
+ aPanel->setLandCoverMode( theMode );
+}
+
void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed )
{
HYDROGUI_CalculationDlg* aPanel =
if( isConfirmed )
myEditedObject->SetToUpdate( true );
}
+
+void HYDROGUI_CalculationOp::onOrderLandCoverChanged( bool& isConfirmed )
+{
+ /*HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ isConfirmed = confirmOrderChange();
+ if( isConfirmed )
+ myEditedObject->SetToUpdate( true );*/
+}
*/
void onChangeMode( int theMode );
+ /**
+ * Change the creation mode related to land covers.
+ * @param theMode the mode to set
+ */
+ void onChangeLandCoverMode( int theMode );
+
/**
* Add geometry objects selected in the module browser to the calculation case.
*/
/**
* Boundary polyline is selected in the list on the first wizard page
*/
- void onBoundarySelected ( const QString & theObjName );
+ void onBoundarySelected( const QString & theObjName );
+ /**
+ * Strickler table name is selected in the list on the third wizard page
+ */
+ void onStricklerTableSelected( const QString & theObjName );
void onOrderChanged( bool& isConfirmed );
+ void onOrderLandCoverChanged( bool& isConfirmed );
private:
void createPreview();
bool confirmOrderChange() const;
bool confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
+ bool confirmLandCoverModeChange() const;
+
private:
bool myIsEdit;
bool myShowZones;
<source>PRIORITY</source>
<translation>Priority</translation>
</message>
+ <message>
+ <source>STRICKLER_TABLE</source>
+ <translation>Strickler table</translation>
+ </message>
+ <message>
+ <source>CALCULATION_REFERENCE_LAND_COVERS</source>
+ <translation>Land covers</translation>
+ </message>
+ <message>
+ <source>INCLUDED_LAND_COVERS</source>
+ <translation>Included land covers</translation>
+ </message>
</context>
<context>
<source>CONFIRM_CONTINUE_WITH_OBJECTS_NOT_INCLUDED_TO_REGION</source>
<translation>Region(s): %1 do not contain any objects. Do you want to continue?</translation>
</message>
+ <message>
+ <source>CONFIRM_LAND_COVER_PARTITION_RECALCULATION_MODE</source>
+ <translation>Case land covers partition already exists and will be recalculated after mode change. Do you confirm the recalculation?</translation>
+ </message>
</context>
<context>