]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Bug #141: show confirmation message on axis change, take the OB selection into accoun...
authormzn <mzn@opencascade.com>
Fri, 13 Dec 2013 08:10:10 +0000 (08:10 +0000)
committermzn <mzn@opencascade.com>
Fri, 13 Dec 2013 08:10:10 +0000 (08:10 +0000)
src/HYDROData/HYDROData_Stream.cxx
src/HYDROData/HYDROData_Stream.h
src/HYDROGUI/HYDROGUI_StreamDlg.cxx
src/HYDROGUI/HYDROGUI_StreamOp.cxx

index e49b2b795583bbe69d612a933165b53a64748f63..426159b29adf1e15e97278bae879334e21bbfa6b 100644 (file)
@@ -354,14 +354,15 @@ void HYDROData_Stream::RemoveHydraulicAxis()
   SetToUpdate( true );
 }
 
-bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
-                                                                          Standard_Real& outPar ) const
+bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_PolylineXY)& theHydAxis, 
+                                        const Handle(HYDROData_Profile)& theProfile, 
+                                        const TopoDS_Face& thePlane,
+                                                                                                         Standard_Real& outPar)
 {
-  Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
-  if ( theProfile.IsNull() || aHydAxis.IsNull() )
+  if ( theProfile.IsNull() || theHydAxis.IsNull() )
     return false; 
 
-  TopoDS_Wire aHydraulicWire = TopoDS::Wire( aHydAxis->GetShape() ); //guide line
+  TopoDS_Wire aHydraulicWire = TopoDS::Wire( theHydAxis->GetShape() ); //guide line
   TopoDS_Wire aProfileWire = TopoDS::Wire( theProfile->GetTopShape() );
   if ( aHydraulicWire.IsNull() || aProfileWire.IsNull() )
     return false;
@@ -455,6 +456,14 @@ bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_Profile)& theProf
   return false;
 }
 
+bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
+                                                                          Standard_Real& outPar ) const
+{
+  Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
+
+  return HasIntersection( aHydAxis, theProfile, thePlane, outPar );
+}
+
 
 bool HYDROData_Stream::AddProfile( const Handle(HYDROData_Profile)& theProfile )
 {
index e7bec1950525accfbaba3acdfa31092779f17533..149c2a6feee426cb7d519bc117fb0aecb98ff134 100644 (file)
@@ -92,6 +92,14 @@ public:
    */
   HYDRODATA_EXPORT virtual void RemoveHydraulicAxis();
 
+  /**
+   * Returns true if profile has the intersection with the given hydraulic axis.
+   * Returns the parameter of inresection point on axis if axis is presented by one curve,
+   * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point. 
+   */
+  HYDRODATA_EXPORT static bool HasIntersection( const Handle(HYDROData_PolylineXY)& theHydAxis, 
+                                                const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
+                                                                                                                       Standard_Real& outPar);
 
   /**
    * Returns true if profile has the intersection with reference hydraulic axis.
@@ -99,7 +107,7 @@ public:
    * if axis presented by set of edges the <outPar> returns a common length of segments till the intersection point. 
    */
   HYDRODATA_EXPORT virtual bool HasIntersection( const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
-                                                                                               Standard_Real& outPar) const;
+                                                                                                                        Standard_Real& outPar) const;
 
    /**
    * Builds a planar face
index b1a208a88ae35365146341bd62238da0f640de20..3147907597fb5552849e775b6dc9dfc45c12c037 100644 (file)
@@ -178,7 +178,5 @@ void HYDROGUI_StreamDlg::onRemoveProfiles()
     }
   }
 
-  if ( !aSelectedProfiles.isEmpty() ) {
-    emit RemoveProfiles( aSelectedProfiles );
-  }
+  emit RemoveProfiles( aSelectedProfiles );
 }
index 1557a79444f00e2eea7d37579aa3afd5d784a1a7..5882c2f868ac21fb9d092cc03a0c5d17f7ab7af7 100755 (executable)
@@ -319,19 +319,39 @@ void HYDROGUI_StreamOp::onRemoveProfiles( const QStringList& theProfilesToRemove
     return;
   }
 
+  bool isRemoved = false;
+
+  // Take the Object Browser selection into account
+  HYDROData_SequenceOfObjects aSelectedObjects = HYDROGUI_Tool::GetSelectedObjects( module() ); 
+  for( int i = 1, n = aSelectedObjects.Length(); i <= n; i++ ) {
+    Handle(HYDROData_Profile) aProfile = 
+      Handle(HYDROData_Profile)::DownCast( aSelectedObjects.Value( i ) );
+    if ( !aProfile.IsNull() && !theProfilesToRemove.contains(aProfile->GetName()) ) {
+      if ( myEditedObject->RemoveProfile( aProfile ) ) {
+        isRemoved = true;
+      }
+    }
+  }
+
   // Remove profiles
   foreach( const QString& aProfileName, theProfilesToRemove ) {
     Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
       HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
-    myEditedObject->RemoveProfile( aProfile );
+    if ( myEditedObject->RemoveProfile( aProfile ) ) {
+      isRemoved = true;
+    }
   }
-  myEditedObject->Update();
 
-  // Update the panel
-  updatePanelData();
+  if ( isRemoved ) {
+    // Update the edited stream object
+    myEditedObject->Update();
 
-  // Update preview
-  createPreview();
+    // Update the panel
+    updatePanelData();
+
+    // Update preview
+    createPreview();
+  }
 }
 
 void HYDROGUI_StreamOp::onAxisChanged( const QString& theNewAxis )
@@ -344,6 +364,15 @@ void HYDROGUI_StreamOp::onAxisChanged( const QString& theNewAxis )
   Handle(HYDROData_PolylineXY) anAxis = Handle(HYDROData_PolylineXY)::DownCast(
     HYDROGUI_Tool::FindObjectByName( module(), theNewAxis, KIND_POLYLINEXY ) );
 
+  // Prepare data for intersection check
+  TopoDS_Face aPlane;
+  if ( anAxis.IsNull() || !myEditedObject->BuildFace(anAxis, aPlane) ) {
+    // To restore the old axis
+    updatePanelData();
+    return;
+  }
+  Standard_Real aPar(.0);
+
   // Get list of profiles which do not intersect the axis
   QStringList aHasNoIntersectionProfiles;
   HYDROData_SequenceOfObjects aCurrentProfiles = myEditedObject->GetProfiles();
@@ -351,7 +380,9 @@ void HYDROGUI_StreamOp::onAxisChanged( const QString& theNewAxis )
     Handle(HYDROData_Profile) aProfile =
       Handle(HYDROData_Profile)::DownCast( aCurrentProfiles.Value( anIndex ) );
     if ( !aProfile.IsNull() ) {
-      // TODO check intersection
+      if ( !HYDROData_Stream::HasIntersection( anAxis, aProfile, aPlane, aPar ) ) {
+        aHasNoIntersectionProfiles << aProfile->GetName();
+      }
     }
   }