Salome HOME
Transaction mechanism for operations corrected.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ChannelOp.cxx
index 4ccd4df478abdb9737beb6b43446b3d897a977e9..fe4153171d39ec37f91261cc31417c2488687514 100644 (file)
 #include <LightApp_Application.h>
 #include <LightApp_UpdateFlags.h>
 
+#include <TopoDS.hxx>
 
 HYDROGUI_ChannelOp::HYDROGUI_ChannelOp( HYDROGUI_Module* theModule,
                                        const bool theIsEdit )
 : HYDROGUI_Operation( theModule ),
   myIsEdit( theIsEdit ),
-  myViewManager( 0 ),
   myPreviewPrs( 0 )
 {
   setName( theIsEdit ? tr( "EDIT_CHANNEL" ) : tr( "CREATE_CHANNEL" ) );
@@ -87,7 +87,24 @@ void HYDROGUI_ChannelOp::startOperation()
   }
 
   // collect information about existing 3d polylines
-  QStringList aGuideLines = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINE );
+  QStringList aGuideLines;
+  QStringList anAllGuideLines = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINE );
+  foreach( QString aGuideLine, anAllGuideLines )
+  {
+    Handle( HYDROData_Polyline3D ) aPolyline3d = 
+      Handle( HYDROData_Polyline3D )::DownCast( 
+    HYDROGUI_Tool::FindObjectByName( module(), aGuideLine, KIND_POLYLINE ) );
+    if( !aPolyline3d.IsNull() )
+    {
+      TopoDS_Shape aShape = aPolyline3d->GetShape3D();
+      if( aShape.ShapeType()==TopAbs_WIRE )
+      {
+        TopoDS_Wire aWire = TopoDS::Wire( aShape );
+        if( !aWire.Closed() )
+          aGuideLines.append( aGuideLine );
+      }
+    }
+  }
 
   // collect information about existing profiles
   QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE );
@@ -129,7 +146,7 @@ HYDROGUI_InputPanel* HYDROGUI_ChannelOp::createInputPanel() const
 }
 
 bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
-                                              QString& theErrorMsg )
+                                       QString& theErrorMsg )
 {
   HYDROGUI_ChannelDlg* aPanel = ::qobject_cast<HYDROGUI_ChannelDlg*>( inputPanel() );
   if ( !aPanel )
@@ -158,7 +175,8 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
 
   myEditedObject->SetName( anObjectName );
 
-  if ( !myIsEdit ) {
+  if ( !myIsEdit )
+  {
     myEditedObject->SetFillingColor( HYDROData_Channel::DefaultFillingColor() );
     myEditedObject->SetBorderColor( HYDROData_Channel::DefaultBorderColor() );
   }
@@ -168,7 +186,9 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
   if( !myIsEdit )
     module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
 
-  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+  module()->setIsToUpdate( myEditedObject );
+
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
 
   return true;
 }
@@ -216,24 +236,26 @@ void HYDROGUI_ChannelOp::onCreatePreview( const bool theIsInit )
   }
 
   LightApp_Application* anApp = module()->getApp();
-  if ( !myViewManager )
-    myViewManager = ::qobject_cast<OCCViewer_ViewManager*>( 
-      anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
+  
+  if ( !getPreviewManager() )
+    setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( 
+                       anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
 
-  if ( myViewManager && !myPreviewPrs )
+  OCCViewer_ViewManager* aViewManager = getPreviewManager();
+  if ( aViewManager && !myPreviewPrs )
   {
-    if ( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() )
+    if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
     {
       Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
       if ( !aCtx.IsNull() )
-        myPreviewPrs = new HYDROGUI_Shape( aCtx, myEditedObject );
+        myPreviewPrs = new HYDROGUI_Shape( aCtx, myEditedObject, getPreviewZLayer() );
     }
   }
 
-  if ( !myViewManager || !myPreviewPrs )
+  if ( !aViewManager || !myPreviewPrs )
     return;
 
-  myPreviewPrs->update();
+  myPreviewPrs->update( true );
 }
 
 void HYDROGUI_ChannelOp::erasePreview()