Salome HOME
Fix for the bug #37: Error when import image with format not supported.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CalculationOp.cxx
index 2e5b2de48ea287f78f7c1750d764d9def52a432d..54241112d3d13930ca893eb7a8571d82a23b0ed2 100644 (file)
@@ -82,9 +82,29 @@ void HYDROGUI_CalculationOp::startOperation()
   getNamesAndEntries( aSeq, aList, anEntryList );
   aPanel->setAllGeomObjects( aList, anEntryList );
 
-  QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Case" );
+  // Get all polylines
+  aList.clear();
+  anEntryList.clear();
+  HYDROData_Iterator anIter( doc(), KIND_POLYLINE );
+  Handle(HYDROData_Polyline) aPolylineObj;
+  QString aPolylineName;
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    aPolylineObj = Handle(HYDROData_Polyline)::DownCast( anIter.Current() );
 
-  QStringList aSelectedObjects;
+    if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed() )
+    {
+      aPolylineName = aPolylineObj->GetName();
+      if ( !aPolylineName.isEmpty() )
+      {
+        aList.append( aPolylineName );
+        anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aPolylineObj ) );
+      }
+    }
+  }
+  aPanel->setPolylineNames( aList, anEntryList );
+
+  QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Case" );
 
   myEditedObject.Nullify();
   if ( myIsEdit )
@@ -93,6 +113,16 @@ void HYDROGUI_CalculationOp::startOperation()
     if ( !myEditedObject.IsNull() )
     {
       anObjectName = myEditedObject->GetName();
+      aPolylineObj = myEditedObject->GetBoundaryPolyline();
+      if ( aPolylineObj.IsNull() )
+      {
+        aPanel->setBoundary( QString() );
+      }
+      else
+      {
+        aPolylineName = aPolylineObj->GetName();
+        aPanel->setBoundary( aPolylineName );
+      }
       aSeq = myEditedObject->GetGeometryObjects();
       getNamesAndEntries( aSeq, aList, anEntryList );
       aPanel->includeGeomObjects( aList );
@@ -169,10 +199,56 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
     SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) );
   connect( aPanel, SIGNAL( objectSelected( const QString & ) ), 
     SLOT( onObjectSelected( const QString & ) ) );
+  connect( aPanel, SIGNAL( boundarySelected( const QString & ) ), 
+    SLOT( onBoundarySelected( const QString & ) ) );
 
   return aPanel;
 }
 
+void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
+{
+  // Set the selected boundary polyline to the calculation case
+  Handle(HYDROData_Polyline) anObject;
+  HYDROGUI_Shape* aShape;
+  Handle(AIS_InteractiveContext) aCtx;
+  if ( myPreviewViewManager ) 
+  {
+    if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
+    {
+      aCtx = aViewer->getAISContext();
+    }
+  }
+  // Remove the old boundary from the operation viewer
+  anObject = myEditedObject->GetBoundaryPolyline();
+  if ( !anObject.IsNull() )
+  {
+    module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject );
+  }
+
+  if ( theObjName.trimmed().isEmpty() )
+  {
+    // No polyline is selected
+    myEditedObject->RemoveBoundaryPolyline();
+  }
+  else
+  {
+    Handle(HYDROData_Entity) anEntity = 
+      HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_POLYLINE );
+    if ( !anEntity.IsNull() )
+    {
+      anObject = Handle(HYDROData_Polyline)::DownCast( anEntity );
+      if ( !anObject.IsNull() )
+      {
+        myEditedObject->SetBoundaryPolyline( anObject );
+        if ( !aCtx.IsNull() )
+        {
+          showObject( anEntity, aCtx );
+        }
+      }
+    }
+  }
+}
+
 void HYDROGUI_CalculationOp::onObjectSelected ( const QString & theObjName )
 {
   // Select the appropriate geometry object shape in the viewer
@@ -545,6 +621,9 @@ void HYDROGUI_CalculationOp::createPreview()
     }
   }
 
+  // Get a boundary polyline if any
+  aSeq.Append( myEditedObject->GetBoundaryPolyline() );
+
   module()->removeViewShapes( HYDROGUI_Module::VMR_PreviewCaseZones );
 
   if ( !myActiveViewManager )