From 634a5100183085e0b5fe7fb67acc59de2f2e5dec Mon Sep 17 00:00:00 2001 From: adv Date: Mon, 23 Sep 2013 08:28:12 +0000 Subject: [PATCH] Editing of calculation zones corrected (Feature #10). --- src/HYDROGUI/HYDROGUI_CalculationOp.cxx | 50 +++++++++++++++++++++---- src/HYDROGUI/HYDROGUI_CalculationOp.h | 2 + 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 5d4a465b..71082b7e 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -30,10 +30,10 @@ #include #include -#include #include #include +#include #include #include @@ -114,6 +114,23 @@ void HYDROGUI_CalculationOp::startOperation() if ( aSplitZoneName.isEmpty() ) continue; + SplittedZone aSplittedZone; + aSplittedZone.SplitData.Path = aSplitZone->GetPainterPath(); + // aSplittedZone.SplitData.ZoneNames ??? + + aSplittedZone.FillingColor = aSplitZone->GetFillingColor(); + aSplittedZone.BorderColor = aSplitZone->GetBorderColor(); + + aSplittedZone.ZoneName = aSplitZoneName; + + Handle(HYDROData_Polyline) aZonePolyline = aSplitZone->GetPolyline(); + if ( !aZonePolyline.IsNull() ) + aSplittedZone.PolylineName = aZonePolyline->GetName(); + + aSplittedZone.DataZone = aSplitZone; + + mySplittedZones.append( aSplittedZone ); + aSplittedZones.append( aSplitZoneName ); } } @@ -142,6 +159,8 @@ void HYDROGUI_CalculationOp::startOperation() aPanel->setZones( aZones ); aPanel->setSelectedZones( aSelectedZones ); aPanel->setSplittedZones( aSplittedZones ); + + createPreview(); } void HYDROGUI_CalculationOp::abortOperation() @@ -222,12 +241,19 @@ bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, { const SplittedZone& aSplittedZone = *anIter; + if ( !aSplittedZone.DataZone.IsNull() ) + { + //No need to create new but use old zone + aSplittedZones.Append( aSplittedZone.DataZone ); + continue; + } + Handle(HYDROData_Polyline) aPolyline = Handle(HYDROData_Polyline)::DownCast( aDocument->CreateObject( KIND_POLYLINE ) ); - Handle(HYDROData_Zone) aDtaZone = + Handle(HYDROData_Zone) aDataZone = Handle(HYDROData_Zone)::DownCast( aDocument->CreateObject( KIND_ZONE ) ); - if( aPolyline.IsNull() || aDtaZone.IsNull() ) + if( aPolyline.IsNull() || aDataZone.IsNull() ) continue; // Fill the polyline data @@ -259,12 +285,12 @@ bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, aPolyline->setPolylineData( aPolylineData ); // Fill the zone data - aDtaZone->SetName( aSplittedZone.ZoneName ); - aDtaZone->SetPolyline( aPolyline ); - aDtaZone->SetBorderColor( aSplittedZone.BorderColor ); - aDtaZone->SetFillingColor( aSplittedZone.FillingColor ); + aDataZone->SetName( aSplittedZone.ZoneName ); + aDataZone->SetPolyline( aPolyline ); + aDataZone->SetBorderColor( aSplittedZone.BorderColor ); + aDataZone->SetFillingColor( aSplittedZone.FillingColor ); - aSplittedZones.Append( aDtaZone ); + aSplittedZones.Append( aDataZone ); } aCalculObj->SetSplittedZones( aSplittedZones ); @@ -334,6 +360,9 @@ void HYDROGUI_CalculationOp::createPreview() if ( !myActiveViewManager ) { + if ( mySplittedZones.isEmpty() ) + return; + myActiveViewManager = anApp->activeViewManager(); } @@ -372,6 +401,11 @@ void HYDROGUI_CalculationOp::createPreview() aSplittedZone.Shape->setBorderColor( aSplittedZone.BorderColor, false ); aSplittedZone.Shape->setPath( aSplittedZone.SplitData.Path, true ); } + + //Process the draw events for viewer + QApplication::processEvents(); + if ( OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)myPreviewViewManager->getActiveView() ) + vw->onTopView(); } } } diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 46ab3bf0..bc58e6f5 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -29,6 +29,7 @@ #include "HYDROGUI_Shape.h" #include +#include class SUIT_ViewManager; class OCCViewer_ViewManager; @@ -45,6 +46,7 @@ class HYDROGUI_CalculationOp : public HYDROGUI_Operation QColor BorderColor; HYDROGUI_SplitZonesTool::SplitData SplitData; HYDROGUI_Shape* Shape; + Handle(HYDROData_Zone) DataZone; SplittedZone() : Shape( NULL ), -- 2.39.2