From: rkv Date: Wed, 6 Nov 2013 07:50:42 +0000 (+0000) Subject: - Preview for Calculation case wizard is improved. X-Git-Tag: BR_hydro_v_0_3~42 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3cf649c8f69e51265ec7e37a514791a96355f6cf;p=modules%2Fhydro.git - Preview for Calculation case wizard is improved. - Zones are selectable now and visible only if the second page of the wizard is active. - When select a region all its zones are selected. - Split is done only if the case is modified. --- diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 0de08e8a..0c83743c 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -66,6 +66,8 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co aWizard->addPage( createObjectsPage() ); aWizard->addPage( createZonesPage() ); connect( aWizard->button( QWizard::NextButton ), SIGNAL( clicked() ), SIGNAL( splitZones() ) ); + connect( aWizard->button( QWizard::BackButton ), SIGNAL( clicked() ), SIGNAL( hideZones() ) ); + aWizard->show(); } @@ -167,6 +169,7 @@ QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() { aPage->setLayout( aLayout ); + connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ) ); connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) ); connect( myBathymetryChoice, SIGNAL( activated( int ) ), SLOT( onMergeTypeSelected( int ) ) ); connect( myBrowser, diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index 627c9fe7..6c533e70 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -80,9 +80,11 @@ signals: void addObjects(); void removeObjects(); void splitZones(); + void hideZones(); void setMergeType( int theMergeType, QString& theBathymetryName ); void createRegion( const QList& theZonesList ); void moveZones( SUIT_DataObject* theRegion, const QList& theZonesList ); + void clickedInZonesBrowser( SUIT_DataObject* ); private: diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index c37a2ffc..e826fb92 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -41,6 +41,8 @@ #include #include +#include +#include #include #include @@ -73,7 +75,6 @@ void HYDROGUI_CalculationOp::startOperation() if ( !aPanel ) return; - myRegionsList.clear(); aPanel->reset(); QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Case" ); @@ -150,16 +151,52 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) ); connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) ); connect( aPanel, SIGNAL( splitZones() ), SLOT( onSplitZones() ) ); + connect( aPanel, SIGNAL( hideZones() ), SLOT( onHideZones() ) ); connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) ); connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) ); connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList& ) ), SLOT( onMoveZones( SUIT_DataObject*, const QList& ) ) ); connect( aPanel, SIGNAL( createRegion( const QList& ) ), SLOT( onCreateRegion( const QList& ) ) ); + connect( aPanel, SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ), + SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) ); return aPanel; } +void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem ) +{ + HYDROGUI_Region* aRegionItem = dynamic_cast(theItem); + HYDROGUI_Zone* aZoneItem; + selectionMgr()->clearSelected(); + if ( aRegionItem ) + { + // Select a region in preview + SUIT_DataOwnerPtrList aList( true ); + DataObjectList aZones = aRegionItem->children(); + for ( int i = 0; i < aZones.length(); i++ ) + { + aZoneItem = dynamic_cast(aZones.at(i)); + if ( aZoneItem ) + { + aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) ); + } + } + selectionMgr()->setSelected( aList ); + } + else + { + // select a single zone + aZoneItem = dynamic_cast(theItem); + if ( aZoneItem ) + { + SUIT_DataOwnerPtrList aList( true ); + aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) ); + selectionMgr()->setSelected( aList ); + } + } +} + void HYDROGUI_CalculationOp::onMoveZones( SUIT_DataObject* theRegionItem, const QList& theZonesList ) { HYDROGUI_Region* aRegion = dynamic_cast(theRegionItem); @@ -185,6 +222,7 @@ void HYDROGUI_CalculationOp::onMoveZones( SUIT_DataObject* theRegionItem, const { aPanel->setEditedObject(myEditedObject); } + createPreview(); } } } @@ -211,6 +249,7 @@ void HYDROGUI_CalculationOp::onCreateRegion( const QList& theZ { aPanel->setEditedObject(myEditedObject); } + createPreview(); } } @@ -224,6 +263,11 @@ void HYDROGUI_CalculationOp::onSetMergeType( int theMergeType, QString& theBathy if ( aZone ) { aZone->setMergeType( theMergeType, theBathymetryName ); + HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZone->modelObject() ); + if ( aShape ) + { + aShape->update(); + } } aPanel->refreshZonesBrowser(); } @@ -345,24 +389,99 @@ void HYDROGUI_CalculationOp::onApply() void HYDROGUI_CalculationOp::onSplitZones() { - HYDROGUI_CalculationDlg* aPanel = - ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - QApplication::setOverrideCursor( Qt::WaitCursor ); - myEditedObject->SplitGeometryObjects(); - aPanel->setEditedObject( myEditedObject ); - createPreview(); + if ( myEditedObject->IsMustBeUpdated() ) + { + myShowZones = true; + myEditedObject->SplitGeometryObjects(); + + HYDROGUI_CalculationDlg* aPanel = + ::qobject_cast( inputPanel() ); + if ( aPanel ) + { + aPanel->setEditedObject( myEditedObject ); + } + + createPreview(); + } + else + { + setZonesVisible( true ); + } QApplication::restoreOverrideCursor(); } +void HYDROGUI_CalculationOp::onHideZones() +{ + setZonesVisible( false ); +} + +void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible ) +{ + myShowZones = theIsVisible; + HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions(); + HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions ); + HYDROData_SequenceOfObjects aZones; + Handle(HYDROData_Region) aRegion; + if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() ) + { + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if ( !aCtx.IsNull() ) + { + for ( ; aRegionsIter.More(); aRegionsIter.Next() ) + { + aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() ); + if ( !aRegion.IsNull() ) + { + aZones = aRegion->GetZones(); + HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones ); + for ( ; aZonesIter.More(); aZonesIter.Next() ) + { + if ( theIsVisible ) + { + showObject( aZonesIter.Value(), aCtx ); + } + else + { + module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZonesIter.Value() ); + } + } + } + } + } + } +} + void HYDROGUI_CalculationOp::createPreview() { LightApp_Application* anApp = module()->getApp(); HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects(); + Handle(HYDROData_Entity) anEntity; + + if ( myShowZones ) + { + // Gather zones for displaying + HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions(); + HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions ); + HYDROData_SequenceOfObjects aZones; + Handle(HYDROData_Region) aRegion; + for ( ; aRegionsIter.More(); aRegionsIter.Next() ) + { + anEntity = aRegionsIter.Value(); + if ( !anEntity.IsNull() ) + { + aRegion = Handle(HYDROData_Region)::DownCast( anEntity ); + if ( !aRegion.IsNull() ) + { + aZones = aRegion->GetZones(); + aSeq.Append( aZones ); + } + } + } + } + module()->removeViewShapes( HYDROGUI_Module::VMR_PreviewCaseZones ); if ( !myActiveViewManager ) @@ -396,26 +515,9 @@ void HYDROGUI_CalculationOp::createPreview() if ( !aCtx.IsNull() ) { HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); - Handle(HYDROData_Object) anObject; - Handle(HYDROData_Entity) anEntity; - HYDROGUI_Shape* aShape; for ( ; anIter.More(); anIter.Next() ) { - anEntity = anIter.Value(); - if ( !anEntity.IsNull() ) - { - anObject = Handle(HYDROData_Object)::DownCast( anEntity ); - if ( !anObject.IsNull() ) - { - aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject ); - if ( !aShape ) - { - aShape = new HYDROGUI_Shape( aCtx, anObject ); - } - aShape->update(); - module()->setObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject, aShape ); - } - } + showObject( anIter.Value(), aCtx ); } //Process the draw events for viewer @@ -426,6 +528,20 @@ void HYDROGUI_CalculationOp::createPreview() } } +void HYDROGUI_CalculationOp::showObject( Handle(HYDROData_Entity) theEntity, Handle(AIS_InteractiveContext) theCtx ) +{ + if ( !theEntity.IsNull() ) + { + HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, theEntity ); + if ( !aShape ) + { + aShape = new HYDROGUI_Shape( theCtx, theEntity ); + module()->setObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, theEntity, aShape ); + } + aShape->update(); + } +} + void HYDROGUI_CalculationOp::onLastViewClosed( SUIT_ViewManager* theViewManager ) { closePreview(); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 3cf13988..b5dec9d6 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -40,33 +40,6 @@ class HYDROGUI_CalculationOp : public HYDROGUI_Operation { Q_OBJECT - struct Region - { - QString RegionName; - QColor FillingColor; - QColor BorderColor; - HYDROData_SplitToZonesTool::SplitData SplitData; - HYDROGUI_Shape* Shape; - Handle(HYDROData_Region) DataRegion; - - Region() - : Shape( NULL ), - FillingColor( Qt::green ), - BorderColor( Qt::transparent ) - { } - - ~Region() - { - if ( Shape ) - { - delete Shape; - Shape = NULL; - } - } - }; - - typedef QList RegionsList; - public: HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit ); virtual ~HYDROGUI_CalculationOp(); @@ -99,20 +72,23 @@ protected slots: void onCreateRegion( const QList& theZonesList ); void onSplitZones(); void onLastViewClosed( SUIT_ViewManager* ); + void onClickedInZonesBrowser( SUIT_DataObject* theItem ); + void onHideZones(); private: void createPreview(); void closePreview(); void updateGeomObjectsList( HYDROGUI_CalculationDlg* thePanel ) const; + void showObject( Handle(HYDROData_Entity) theEntity, Handle(AIS_InteractiveContext) theCtx ); + void setZonesVisible( bool theIsVisible ); private: bool myIsEdit; + bool myShowZones; Handle(HYDROData_CalculationCase) myEditedObject; SUIT_ViewManager* myActiveViewManager; - OCCViewer_ViewManager* myPreviewViewManager; - RegionsList myRegionsList; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index 1ac88c74..9a6c0ca7 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -162,7 +162,15 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) } setFace( aZoneFace, false, false ); - setFillingColor( HYDROGUI_Tool::GenerateFillingColor( aDocument, aGeomObjectsNames ) ); + if (aZone->IsMergingNeed() && aZone->GetMergeType() == HYDROData_Zone::Merge_UNKNOWN ) + { + // Red color for a zone with bathymetry conflict + setFillingColor( Qt::red ); + } + else + { + setFillingColor( HYDROGUI_Tool::GenerateFillingColor( aDocument, aGeomObjectsNames ) ); + } } else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Image) ) ) { diff --git a/src/HYDROGUI/HYDROGUI_Wizard.h b/src/HYDROGUI/HYDROGUI_Wizard.h index 0349029b..1ddf93f1 100644 --- a/src/HYDROGUI/HYDROGUI_Wizard.h +++ b/src/HYDROGUI/HYDROGUI_Wizard.h @@ -39,7 +39,6 @@ public: void show(); -protected: QWizard* wizard() const; private: