Salome HOME
Editing of calculation zones corrected (Feature #10).
authoradv <adv@opencascade.com>
Mon, 23 Sep 2013 08:28:12 +0000 (08:28 +0000)
committeradv <adv@opencascade.com>
Mon, 23 Sep 2013 08:28:12 +0000 (08:28 +0000)
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h

index 5d4a465b695d194b9e13b965bfebd34e515d6ae5..71082b7e14b1287b3e4ab4e2c1d25f95b57df7eb 100644 (file)
 
 #include <HYDROData_Polyline.h>
 #include <HYDROData_Iterator.h>
-#include <HYDROData_Zone.h>
 
 #include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewWindow.h>
 
 #include <LightApp_Application.h>
 #include <LightApp_UpdateFlags.h>
@@ -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();
     }
   }
 }
index 46ab3bf0da50860ddc8d57352ec38722f37c5bd3..bc58e6f5d6f85b04e9f6fb707f88ccf42394273d 100644 (file)
@@ -29,6 +29,7 @@
 #include "HYDROGUI_Shape.h"
 
 #include <HYDROData_Calculation.h>
+#include <HYDROData_Zone.h>
 
 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 ),