From: mkr Date: Thu, 12 Nov 2015 17:10:47 +0000 (+0300) Subject: refs #664: redesign of calculation case dialog and operation. X-Git-Tag: v1.5~52 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f893a91ca6b6bfa8cb8d7f58fb36b57251d1858d;p=modules%2Fhydro.git refs #664: redesign of calculation case dialog and operation. --- diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index a2d3c7dc..c1735274 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -85,6 +85,7 @@ void HYDROGUI_CalculationDlg::reset() HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList; myGeomObjects->setObjects(anObject2VisibleList); myPolylineName->clear(); + myLandCoverMapName->clear(); myStricklerTableName->clear(); myAvailableGeomObjects->clear(); @@ -315,7 +316,12 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoverMapPage() { // Top of the page QWidget* aTopContainer = new QWidget; - // TODO: add combo-box to choose land cover map object + // Combo-box to choose land cover map object + QLabel* aLandCoverMapLabel = new QLabel( tr( "LAND_COVER_MAP" ), aPage ); + myLandCoverMapName = new QComboBox( aPage ); + myLandCoverMapName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + connect( myLandCoverMapName, SIGNAL( activated( const QString & ) ), + SIGNAL( landCoverMapSelected( const QString & ) ) ); // Combo-box to choose Strickler table name QLabel* aStricklerTableLabel = new QLabel( tr( "STRICKLER_TABLE" ), aPage ); myStricklerTableName = new QComboBox( aPage ); @@ -324,25 +330,24 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoverMapPage() { SIGNAL( StricklerTableSelected( const QString & ) ) ); // Fill the top layout of the page - QGridLayout* aTopLayout = new QGridLayout; + QGridLayout* aGridLayout = new QGridLayout; + aGridLayout->setMargin( 5 ); + aGridLayout->setSpacing( 5 ); + aGridLayout->setVerticalSpacing( 10 ); + aGridLayout->addWidget( aLandCoverMapLabel, 0, 0 ); + aGridLayout->addWidget( myLandCoverMapName, 0, 1 ); + aGridLayout->addWidget( aStricklerTableLabel, 1, 0 ); + aGridLayout->addWidget( myStricklerTableName, 1, 1 ); + + QVBoxLayout* aTopLayout = new QVBoxLayout; aTopLayout->setMargin( 5 ); aTopLayout->setSpacing( 5 ); - aTopLayout->setVerticalSpacing( 10 ); - // TODO: add land cover map combo-box to the layout - aTopLayout->addWidget( aStricklerTableLabel, 0, 0, Qt::AlignHCenter ); - aTopLayout->addWidget( myStricklerTableName, 0, 1 ); + aTopLayout->addLayout( aGridLayout ); + aTopLayout->addStretch( 1 ); aTopContainer->setLayout( aTopLayout ); - // Page layout - QVBoxLayout* aPageLayout = new QVBoxLayout; - aPageLayout->setMargin( 5 ); - aPageLayout->setSpacing( 5 ); - - aPage->setLayout( aPageLayout ); - - // Connections - // TODO + aPage->setLayout( aTopLayout ); return aPage; } @@ -603,6 +608,16 @@ void HYDROGUI_CalculationDlg::setPolylineNames( const QStringList& theObjects, c } } +void HYDROGUI_CalculationDlg::setLandCoverMapsNames( const QStringList& theObjects, const QStringList& theObjectsEntries ) +{ + myLandCoverMapName->clear(); + + for ( int i = 0, n = theObjects.length(); i < n; ++i ) + { + myLandCoverMapName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) ); + } +} + void HYDROGUI_CalculationDlg::setStricklerTableNames( const QStringList& theObjects, const QStringList& theObjectsEntries ) { myStricklerTableName->clear(); @@ -666,17 +681,6 @@ void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_Calculatio myBrowser->adjustColumnsWidth(); myBrowser->setAutoUpdate( true ); myBrowser->setUpdateModified( true ); - - /*TODO - // Build the calculation case subtree for Land Cover regions - module()->getDataModel()->buildCaseTree( myLandCoverBrowser->root(), myEditedObject, true ); - - myLandCoverBrowser->updateTree(); - myLandCoverBrowser->openLevels(); - myLandCoverBrowser->adjustColumnsWidth(); - myLandCoverBrowser->setAutoUpdate( true ); - myLandCoverBrowser->setUpdateModified( true ); - */ } HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const @@ -785,31 +789,6 @@ QList HYDROGUI_CalculationDlg::getGeometryObjects() return anObjects; } -/** - Get chosen land cover map. - @return the land cover map object - */ -Handle(HYDROData_LandCoverMap) HYDROGUI_CalculationDlg::getLandCoverMap() -{ - /* TODO - QList anEntities = myLandCovers->getObjects(); - QList aLandCovers; - - foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) { - Handle(HYDROData_LandCover) aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity ); - if ( aLandCover.IsNull() ) { - continue; - } - - aLandCovers << aLandCover; - } - - return aLandCovers; - */ - Handle(HYDROData_LandCoverMap) aLandCoverMap = NULL; - return aLandCoverMap; -} - /** Get rules. @return the list of rules @@ -852,7 +831,6 @@ void HYDROGUI_CalculationDlg::onRuleChanged() myPriorityWidget->undoLastChange(); } -// TODO: setLandCoverMap(...) void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTableName, bool theBlockSignals ) { bool isBlocked; @@ -866,3 +844,17 @@ void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTabl else emit StricklerTableSelected( theStricklerTableName ); } + +void HYDROGUI_CalculationDlg::setLandCoverMap( const QString& theLandCoverMapName, bool theBlockSignals ) +{ + bool isBlocked; + if ( theBlockSignals ) + isBlocked = myLandCoverMapName->blockSignals( true ); + + myLandCoverMapName->setCurrentIndex( myLandCoverMapName->findText( theLandCoverMapName ) ); + + if ( theBlockSignals ) + myLandCoverMapName->blockSignals( isBlocked ); + else + emit landCoverMapSelected( theLandCoverMapName ); +} diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index 1c6acb8c..6b5a4463 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -63,7 +63,7 @@ public: void setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries ); QStringList getAllGeomObjects() const; void setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries ); - // TODO: setLandCoverMapsNames(...) + void setLandCoverMapsNames( const QStringList& theObjects, const QStringList& theObjectsEntries ); void setStricklerTableNames( const QStringList& theObjects, const QStringList& theObjectsEntries ); QStringList getSelectedGeomObjects() const; QStringList getSelectedAvailableGeomObjects() const; @@ -93,6 +93,7 @@ public slots: void onRuleChanged(); void setStricklerTable( const QString& theStricklerTableName, bool theBlockSignals = true ); + void setLandCoverMap( const QString& theLandCoverMapName, bool theBlockSignals = true ); /** * Process items selection: hide/show bathymetry merge type selector. @@ -127,7 +128,7 @@ signals: void moveZones( SUIT_DataObject* theRegion, const QList& theZonesList ); void clickedInZonesBrowser( SUIT_DataObject* ); - void landCoverMapSelected(); + void landCoverMapSelected( const QString & theObjName ); void StricklerTableSelected( const QString & theObjName ); @@ -143,8 +144,6 @@ protected slots: private: QList getGeometryObjects(); - Handle(HYDROData_LandCoverMap) getLandCoverMap(); - QWizardPage* createObjectsPage(); QWizardPage* createGroupsPage(); QWizardPage* createLandCoverMapPage(); @@ -157,7 +156,7 @@ private: HYDROGUI_NameValidator* myValidator; QComboBox* myPolylineName; - // TODO: myLandCoverMapName + QComboBox* myLandCoverMapName; QComboBox* myStricklerTableName; QButtonGroup* myModeButtons; diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 1987887c..01b65432 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -231,10 +231,8 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) ); connect( aPanel, SIGNAL( objectsSelected() ), SLOT( onObjectsSelected() ) ); - connect( aPanel, SIGNAL( landCoversSelected() ), - SLOT( onLandCoversSelected() ) ); - connect( aPanel, SIGNAL( createLandCoverRegion( const QList& ) ), - SLOT( onCreateLandCoverRegion( const QList& ) ) ); + connect( aPanel, SIGNAL( landCoverMapSelected( const QString & ) ), + SLOT( onLandCoverMapSelected( const QString & ) ) ); connect( aPanel, SIGNAL( boundarySelected( const QString & ) ), SLOT( onBoundarySelected( const QString & ) ) ); connect( aPanel, SIGNAL( StricklerTableSelected( const QString & ) ), @@ -289,26 +287,12 @@ void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjNa { bool anIsToUpdateViewer = false; - /* TODO - // 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() ) + // Remove old presentation of land cover map from the operation viewer + Handle(HYDROData_LandCoverMap) aLandCoverMap = myEditedObject->GetLandCoverMap(); + if ( !aLandCoverMap.IsNull() ) { - anEntity = anIter.Value(); - if ( !anEntity.IsNull() ) - { - aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity ); - if ( !aLandCover.IsNull() ) - { - aLandCovers.Append( aLandCover ); - setObjectVisibility( aLandCover, false ); - anIsToUpdateViewer = true; - } - } + setObjectVisibility( aLandCoverMap, false ); + anIsToUpdateViewer = true; } // Set the selected Strickler table to the calculation case @@ -326,19 +310,10 @@ void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjNa Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); if ( !aCtx.IsNull() ) { - HYDROData_SequenceOfObjects::Iterator anIter( aLandCovers ); - for ( ; anIter.More(); anIter.Next() ) + if ( !aLandCoverMap.IsNull() ) { - anEntity = anIter.Value(); - if ( !anEntity.IsNull() ) - { - aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity ); - if ( !aLandCover.IsNull() ) - { - setObjectVisibility( aLandCover, true ); - anIsToUpdateViewer = true; - } - } + setObjectVisibility( aLandCoverMap, true ); + anIsToUpdateViewer = true; } } } @@ -347,7 +322,6 @@ void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjNa module()->update( UF_OCCViewer ); } } - */ } void HYDROGUI_CalculationOp::onObjectsSelected() @@ -391,53 +365,27 @@ void HYDROGUI_CalculationOp::onObjectsSelected() aLastShape->update( true, false ); } -void HYDROGUI_CalculationOp::onLandCoverMapSelected() +void HYDROGUI_CalculationOp::onLandCoverMapSelected( const QString & theObjName ) { - HYDROGUI_CalculationDlg* aPanel = - ::qobject_cast( inputPanel() ); - - /* TODO: highlight the selected land cover map in the 3d viewer (synchronize slection in the dialog with a preview in the viewer) - QStringList aSelectedObjs = aPanel->getSelectedLandCovers(); - QMap aSelectedObjsMap; - foreach( QString aName, aSelectedObjs ) - aSelectedObjsMap[aName] = true; - */ - - - // Select the appropriate land cover shape in the viewer - selectionMgr()->clearSelected(); - - // Unhighlight all land covers except selected - HYDROGUI_Shape* aShape = 0, *aLastShape = 0; - Handle(HYDROData_Entity) anEntity; - /* TODO: highlight the selected land cover map in the 3d viewer (synchronize slection in the dialog with a preview in the viewer) - HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCovers(); - HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); - bool isSelected; - QString aName; - for ( ; anIter.More(); anIter.Next() ) + bool anIsToUpdateViewer = false; + + // Remove old presentation of land cover map from the operation viewer + Handle(HYDROData_LandCoverMap) aPrevLandCoverMap = myEditedObject->GetLandCoverMap(); + if ( !aPrevLandCoverMap.IsNull() ) { - anEntity = anIter.Value(); - if ( !anEntity.IsNull() ) - { - aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anEntity ); - if ( aShape ) - { - aName = anEntity->GetName(); - isSelected = aSelectedObjsMap.contains( aName ); - aShape->highlight( isSelected, false ); - aShape->update( false, false ); - aLastShape = aShape; - } - } + setObjectVisibility( aPrevLandCoverMap, false ); + anIsToUpdateViewer = true; } - */ - // TODO - //createPreview( true ); + // Select the appropriate land cover map shape in the viewer + selectionMgr()->clearSelected(); - if( aLastShape ) - aLastShape->update( true, false ); + // Set the selected land cover map to the calculation case + Handle(HYDROData_LandCoverMap) aNewLandCoverMap = Handle(HYDROData_LandCoverMap)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_LAND_COVER_MAP ) ); + myEditedObject->SetLandCoverMap( aNewLandCoverMap ); + + createPreview( true ); } void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem ) @@ -825,16 +773,47 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) QStringList aList; QStringList anEntryList; - HYDROData_SequenceOfObjects aSeq; - /* TODO: get all land cover map objects to fill in combo-box + // Get all land cover map objects to fill in combo-box + Handle(HYDROData_LandCoverMap) aLandCoverMapObj; + QString aLandCoverMapName; + + aList.clear(); + anEntryList.clear(); + HYDROData_Iterator anIter( doc(), KIND_LAND_COVER_MAP ); + for ( ; anIter.More(); anIter.Next() ) + { + aLandCoverMapObj = Handle(HYDROData_LandCoverMap)::DownCast( anIter.Current() ); + + if ( !aLandCoverMapObj.IsNull() ) + { + aLandCoverMapName = aLandCoverMapObj->GetName(); + if ( !aLandCoverMapName.isEmpty() ) + { + aList.append( aLandCoverMapName ); + anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aLandCoverMapObj ) ); + } + } + } + aPanel->setLandCoverMapsNames( aList, anEntryList ); + aLandCoverMapObj = myEditedObject->GetLandCoverMap(); + if ( !aList.isEmpty() ) + { + if ( aLandCoverMapObj.IsNull() ) + aPanel->setLandCoverMap( aList.at( 0 ), false ); + else if ( myIsEdit ) + aPanel->setLandCoverMap( aList.at( 0 ), true ); + else + aPanel->setLandCoverMap( aList.at( aList.indexOf( aLandCoverMapObj->GetName() ) ), true ); + } + + // Get all Strickler table objects to fill in combo-box Handle(HYDROData_StricklerTable) aStricklerTableObj; QString aStricklerTableName; - // Get all Strickler table objects to fill in combo-box aList.clear(); anEntryList.clear(); - HYDROData_Iterator anIter( doc(), KIND_STRICKLER_TABLE ); + anIter = HYDROData_Iterator( doc(), KIND_STRICKLER_TABLE ); for ( ; anIter.More(); anIter.Next() ) { aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIter.Current() ); @@ -870,9 +849,19 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) aStricklerTableName = aStricklerTableObj->GetName(); aPanel->setStricklerTable( aStricklerTableName ); } + + // Select the certain land cover map object in combo-box + if ( aLandCoverMapObj.IsNull() ) + { + aPanel->setLandCoverMap( QString() ); + } + else + { + aLandCoverMapName = aLandCoverMapObj->GetName(); + aPanel->setLandCoverMap( aLandCoverMapName ); + } } } - */ closePreview( false ); createPreview( true ); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index b6791f0d..a74d7b06 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -113,7 +113,7 @@ protected slots: /** * Land cover map is selected in the list on the third wizard page */ - void onLandCoverMapSelected(); + void onLandCoverMapSelected( const QString & theObjName ); /** * Boundary polyline is selected in the list on the first wizard page */ diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 23d8dc98..123f9758 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -989,6 +989,14 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent, createObject( aCaseNOSect, aNObject, aGuiObj->entry(), false ); } } + + LightApp_DataObject* aLandCoverMapSect = + createObject( aGuiObj, tr( "CASE_LAND_COVER_MAP" ), aGuiObj->entry() ); + + Handle(HYDROData_LandCoverMap) aLandCoverMap = aCaseObj->GetLandCoverMap(); + if ( !aLandCoverMap.IsNull() && !aLandCoverMap->IsRemoved() ) + createObject( aLandCoverMapSect, aLandCoverMap, aGuiObj->entry(), false ); + LightApp_DataObject* aCaseRegionsSect = createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() ); diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 1c10d4f4..4d904c49 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -116,8 +116,8 @@ REGIONS - CASE_LAND_COVER_REGIONS - LAND COVER REGIONS + CASE_LAND_COVER_MAP + LAND COVER MAP CASE_SPLITTED_GROUPS @@ -358,12 +358,8 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) Strickler table - CALCULATION_REFERENCE_LAND_COVERS - Land covers - - - INCLUDED_LAND_COVERS - Included land covers + LAND_COVER_MAP + Land cover map STRICKLER_TYPE