From 4a74bf154bfa38329b4c31209b33511905b56a7e Mon Sep 17 00:00:00 2001 From: rkv Date: Tue, 5 Nov 2013 12:15:36 +0000 Subject: [PATCH] Preview of a calculation case for the first page of the wizard is implemented. --- src/HYDROGUI/HYDROGUI_CalculationOp.cxx | 112 +++++------------------- src/HYDROGUI/HYDROGUI_Module.cxx | 4 +- 2 files changed, 26 insertions(+), 90 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 2e8744cb..c37a2ffc 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -99,7 +99,6 @@ void HYDROGUI_CalculationOp::startOperation() aPanel->setObjectName( anObjectName ); aPanel->setEditedObject( myEditedObject ); -// aPanel->setSelectedGeomObjects( aSelectedObjects ); createPreview(); } @@ -258,6 +257,7 @@ void HYDROGUI_CalculationOp::onAddObjects() { updateGeomObjectsList( aPanel ); } + createPreview(); } void HYDROGUI_CalculationOp::onRemoveObjects() @@ -278,6 +278,7 @@ void HYDROGUI_CalculationOp::onRemoveObjects() anObject = Handle(HYDROData_Object)::DownCast( anEntity ); if ( !anObject.IsNull() ) { + module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject ); myEditedObject->RemoveGeometryObject( anObject ); } } @@ -294,37 +295,6 @@ bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, if ( !aPanel ) return false; - //QString anObjectName = aPanel->getObjectName().simplified(); - //if ( anObjectName.isEmpty() ) - //{ - // theErrorMsg = tr( "INCORRECT_OBJECT_NAME" ); - // return false; - //} - - //// check that there are no other objects with the same name in the document - //if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) ) - //{ - // Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName ); - // if ( !anObject.IsNull() ) - // { - // theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName ); - // return false; - // } - //} - - //Handle(HYDROData_Document) aDocument = doc(); - - //Handle(HYDROData_CalculationCase) aCalculObj = myIsEdit ? myEditedObject : - // Handle(HYDROData_CalculationCase)::DownCast( aDocument->CreateObject( KIND_CALCULATION ) ); - //if ( aCalculObj.IsNull() ) - // return false; - - //aCalculObj->SetName( anObjectName ); - - //QStringList aRefObjectNames = aPanel->getSelectedGeomObjects(); - //HYDROData_SequenceOfObjects aGeomObjects = - // HYDROGUI_Tool::FindObjectsByNames( module(), aRefObjectNames ); - theUpdateFlags = UF_Model; return true; @@ -375,8 +345,6 @@ void HYDROGUI_CalculationOp::onApply() void HYDROGUI_CalculationOp::onSplitZones() { - //myRegionsList.clear(); - HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) @@ -384,36 +352,6 @@ void HYDROGUI_CalculationOp::onSplitZones() QApplication::setOverrideCursor( Qt::WaitCursor ); - //QStringList aGeomObjectNames = aPanel->getSelectedGeomObjects(); - //HYDROData_SequenceOfObjects aGeomObjects = - // HYDROGUI_Tool::FindObjectsByNames( module(), aGeomObjectNames ); - - //QStringList aResSplittedZones; - - //HYDROData_SplitToZonesTool::SplitDataList aSplittedZones = - // HYDROData_SplitToZonesTool::SplitToZones( aGeomObjects ); - - //QStringList aUsedNames; - - //HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplittedZones ); - //while( anIter.hasNext() ) - //{ - // Region aRegion; - // aRegion.SplitData = anIter.next(); - - // aRegion.FillingColor = HYDROGUI_Tool::GenerateFillingColor( module(), aRegion.SplitData.ObjectNames ); - // aRegion.BorderColor = QColor( HYDROData_ImmersibleZone::DefaultBorderColor() ); - - // aRegion.RegionName = HYDROGUI_Tool::GenerateObjectName( module(), "Region", aUsedNames ); - - // aUsedNames.append( aRegion.RegionName ); - - // aResSplittedZones.append( aRegion.RegionName ); - - // myRegionsList.append( aRegion ); - //} - // - myEditedObject->SplitGeometryObjects(); aPanel->setEditedObject( myEditedObject ); createPreview(); @@ -424,10 +362,12 @@ void HYDROGUI_CalculationOp::onSplitZones() void HYDROGUI_CalculationOp::createPreview() { LightApp_Application* anApp = module()->getApp(); + HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects(); + module()->removeViewShapes( HYDROGUI_Module::VMR_PreviewCaseZones ); if ( !myActiveViewManager ) { - if ( myRegionsList.isEmpty() ) + if ( aSeq.IsEmpty() ) return; myActiveViewManager = anApp->activeViewManager(); @@ -455,21 +395,27 @@ void HYDROGUI_CalculationOp::createPreview() Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); if ( !aCtx.IsNull() ) { - RegionsList::iterator anIter = myRegionsList.begin(); - for ( ; anIter != myRegionsList.end(); ++anIter ) + HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); + Handle(HYDROData_Object) anObject; + Handle(HYDROData_Entity) anEntity; + HYDROGUI_Shape* aShape; + for ( ; anIter.More(); anIter.Next() ) { - Region& aRegion = *anIter; - if ( aRegion.Shape ) + anEntity = anIter.Value(); + if ( !anEntity.IsNull() ) { - aRegion.Shape->erase( false ); - delete aRegion.Shape; + 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 ); + } } - - aRegion.Shape = new HYDROGUI_Shape( aCtx, NULL ); - - aRegion.Shape->setFillingColor( aRegion.FillingColor, false, false ); - aRegion.Shape->setBorderColor( aRegion.BorderColor, false, false ); - aRegion.Shape->setFace( aRegion.SplitData.Face(), true, false ); } //Process the draw events for viewer @@ -487,18 +433,6 @@ void HYDROGUI_CalculationOp::onLastViewClosed( SUIT_ViewManager* theViewManager void HYDROGUI_CalculationOp::closePreview() { - RegionsList::iterator anIter= myRegionsList.begin(); - for ( ; anIter != myRegionsList.end(); ++anIter ) - { - Region& aRegion = *anIter; - if ( aRegion.Shape ) - { - aRegion.Shape->erase( false ); - delete aRegion.Shape; - aRegion.Shape = NULL; - } - } - if( myPreviewViewManager ) { disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index e5b3ded0..55d875bc 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -586,10 +586,12 @@ void HYDROGUI_Module::removeObjectShape( const int theView return; ListOfShapes& aViewShapes = myShapesMap[ theViewId ]; + Handle(HYDROData_Entity) anObject; for ( int i = 0; i < aViewShapes.length(); ) { HYDROGUI_Shape* aShape = aViewShapes.at( i ); - if ( aShape && IsEqual( aShape->getObject(), theObject ) ) + anObject = aShape->getObject(); + if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) ) { delete aShape; aViewShapes.removeAt( i ); -- 2.39.2