From a8a5de888cfc087b13db88108b9d2c729a13c5d2 Mon Sep 17 00:00:00 2001 From: rkv Date: Wed, 6 Nov 2013 10:12:52 +0000 Subject: [PATCH] - Geometry objects selected in Calculation case wizard are highlighted now in the preview. --- src/HYDROGUI/HYDROGUI_CalculationDlg.cxx | 11 +++--- src/HYDROGUI/HYDROGUI_CalculationDlg.h | 2 +- src/HYDROGUI/HYDROGUI_CalculationOp.cxx | 49 +++++++++++++++++++++++- src/HYDROGUI/HYDROGUI_CalculationOp.h | 19 +++++++++ 4 files changed, 73 insertions(+), 8 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 0c83743c..6345e5f5 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -90,8 +90,8 @@ QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() { myValidator = new HYDROGUI_NameValidator(module(), myObjectName); myObjectName->setValidator( myValidator ); - connect( myValidator, SIGNAL( emptyName() ), this, SLOT( onEmptyName() ) ); - connect( myValidator, SIGNAL( alreadyExists( QString ) ), this, SLOT( onAlreadyExists( QString ) ) ); + connect( myValidator, SIGNAL( emptyName() ), SLOT( onEmptyName() ) ); + connect( myValidator, SIGNAL( alreadyExists( QString ) ), SLOT( onAlreadyExists( QString ) ) ); myGeomObjects = new QListWidget( aPage ); myGeomObjects->setSelectionMode( QListWidget::SingleSelection ); @@ -99,6 +99,9 @@ QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() { myGeomObjects->setViewMode( QListWidget::ListMode ); myGeomObjects->setSortingEnabled( true ); + connect( myGeomObjects, SIGNAL( currentTextChanged( const QString & ) ), + SIGNAL( objectSelected( const QString & ) ) ); + QFrame* aBtnsFrame = new QFrame( aPage ); QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame ); aBtnsLayout->setMargin( 5 ); @@ -278,10 +281,6 @@ QString HYDROGUI_CalculationDlg::getObjectName() const } void HYDROGUI_CalculationDlg::setGeomObjects( const QStringList& theObjects ) -{ -} - -void HYDROGUI_CalculationDlg::setSelectedGeomObjects( const QStringList& theObjects ) { myGeomObjects->clear(); diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index 6c533e70..11d38363 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -54,7 +54,6 @@ public: void setEditedObject( const Handle(HYDROData_CalculationCase) theCase ); void setGeomObjects( const QStringList& theObjects ); - void setSelectedGeomObjects( const QStringList& theObjects ); QStringList getSelectedGeomObjects() const; HYDROGUI_Zone* getCurrentZone() const; @@ -79,6 +78,7 @@ public slots: signals: void addObjects(); void removeObjects(); + void objectSelected( const QString & theObjName ); void splitZones(); void hideZones(); void setMergeType( int theMergeType, QString& theBathymetryName ); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index e826fb92..5607f4f4 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -124,7 +124,7 @@ void HYDROGUI_CalculationOp::updateGeomObjectsList( HYDROGUI_CalculationDlg* the } } } - thePanel->setSelectedGeomObjects( aList ); + thePanel->setGeomObjects( aList ); } void HYDROGUI_CalculationOp::abortOperation() @@ -160,10 +160,57 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const SLOT( onCreateRegion( const QList& ) ) ); connect( aPanel, SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ), SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) ); + connect( aPanel, SIGNAL( objectSelected( const QString & ) ), + SLOT( onObjectSelected( const QString & ) ) ); return aPanel; } +void HYDROGUI_CalculationOp::onObjectSelected ( const QString & theObjName ) +{ + // Select the appropriate geometry object shape in the viewer + selectionMgr()->clearSelected(); + + // Unhighlight all objects except selected + HYDROGUI_Shape* aShape; + HYDROGUI_Shape* aSelectedShape = 0; + Handle(HYDROData_Entity) anEntity; + HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects(); + HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); + bool isSelected; + QString aName; + for ( ; anIter.More(); anIter.Next() ) + { + anEntity = anIter.Value(); + if ( !anEntity.IsNull() ) + { + aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anEntity ); + if ( aShape ) + { + aName = anEntity->GetName(); + isSelected = ( aName == theObjName ); + if ( isSelected ) + { + aSelectedShape = aShape; + } + if ( aShape->isHighlighted() != isSelected ) + { + if ( !isSelected ) + { + aShape->highlight( isSelected ); + aShape->update(); + } + } + } + } + } + if ( aSelectedShape ) + { + aSelectedShape->highlight( true ); + aSelectedShape->update(); + } +} + void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem ) { HYDROGUI_Region* aRegionItem = dynamic_cast(theItem); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index b5dec9d6..cba6529c 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -67,13 +67,32 @@ protected slots: * Set the given bathymetry merge type to the current zone. */ void onSetMergeType( int theMergeType, QString& theBathymetryName ); + /** + * Selected zones are moved to the existing region. + */ void onMoveZones( SUIT_DataObject* theRegionItem, const QList& theZonesList ); + /** + * Selected zones are moved to the new region to be created. + */ void onCreateRegion( const QList& theZonesList ); + /** + * Case objects must be splitted to zones if the case has been modified or new. + */ void onSplitZones(); void onLastViewClosed( SUIT_ViewManager* ); + /** + * The zone is selected in the browser on the second page of the wizard. + */ void onClickedInZonesBrowser( SUIT_DataObject* theItem ); + /** + * Hide zones in the viewer. + */ void onHideZones(); + /** + * Geometry object is selected in the list on the first wizard page + */ + void onObjectSelected ( const QString & theObjName ); private: void createPreview(); -- 2.39.2