]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
lot 12 p.2
authorisn <isn@opencascade.com>
Tue, 5 Feb 2019 18:35:18 +0000 (21:35 +0300)
committerisn <isn@opencascade.com>
Tue, 19 Mar 2019 13:23:26 +0000 (16:23 +0300)
src/HYDROData/HYDROData_Channel.cxx
src/HYDROData/HYDROData_Channel.h
src/HYDROGUI/HYDROGUI_ChannelDlg.cxx
src/HYDROGUI/HYDROGUI_ChannelDlg.h
src/HYDROGUI/HYDROGUI_ChannelOp.cxx

index f489e803a6757607ca8d30c651ba4dcb03c2fbf1..1a08a52d628a515bc0150585f20937dffd3126ac 100644 (file)
@@ -30,6 +30,7 @@
 #include "HYDROData_ChannelAltitude.h"
 
 #include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepLib_MakePolygon.hxx>
 
 #include <BRepOffsetAPI_MakePipeShell.hxx>
 #include <BRepOffsetAPI_MakePipe.hxx>
@@ -127,18 +128,61 @@ bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)&
                                              PrsDefinition&                      thePrs,
                                              double                              theEquiDistance,
                                              bool                                ReverseXCoord)
+{
+  return internalCreatePresentations( true, theGuideLine, theProfile, TopoDS_Wire(), gp_Pnt(), thePrs, theEquiDistance, ReverseXCoord);
+}
+
+bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
+                                             double                              LC,
+                                             double                              deltaZ,
+                                             double                              coteZ,
+                                             PrsDefinition&                      thePrs,
+                                             double                              theEquiDistance,
+                                             bool                                ReverseXCoord)
+{
+  Handle(HYDROData_Profile) theProfile;
+  TopoDS_Wire W;
+  gp_Pnt MP;
+
+  gp_Pnt2d A1(-0.75*LC, coteZ-LC/2.0), A2(0.75*LC, coteZ -LC/2.0), B1(-LC/2.0, coteZ), B2(LC/2.0, coteZ), C(0, coteZ+deltaZ);
+  gp_Pnt A1_3d(A1.X(), 0, A1.Y()), A2_3d(A2.X(), 0, A2.Y()), B1_3d(B1.X(), 0, B1.Y()), B2_3d(B2.X(), 0, B2.Y()), C_3d(C.X(), 0, C.Y());
+  BRepLib_MakePolygon PM;
+  PM.Add(A1_3d);
+  PM.Add(B1_3d);
+  PM.Add(C_3d);
+  PM.Add(B2_3d);
+  PM.Add(A2_3d);
+  W = PM.Wire();
+  return internalCreatePresentations( false, theGuideLine, theProfile, W, MP, thePrs, theEquiDistance, ReverseXCoord);
+}
+
+bool HYDROData_Channel::internalCreatePresentations( bool mode,
+                                                     const Handle(HYDROData_Polyline3D)& theGuideLine,
+                                                     const Handle(HYDROData_Profile)&    theProfile,
+                                                     const TopoDS_Wire&                  theProfWire,
+                                                     const gp_Pnt&                       theMiddlePnt,
+                                                     PrsDefinition&                      thePrs,
+                                                     double                              theEquiDistance,
+                                                     bool                                ReverseXCoord)
 {
   // Check input parameters
-  if ( theGuideLine.IsNull() || theProfile.IsNull() ) {
+  if ( theGuideLine.IsNull() )
+  {
     return false;
   }
+  if (mode && theProfile.IsNull() || !mode && theProfWire.IsNull() )
+    return false;
 
   TopoDS_Wire aPathWire = TopoDS::Wire( theGuideLine->GetShape3D() );
-  TopoDS_Wire aProfileWire;
-  if (!ReverseXCoord)
-    aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, false) ); //temp force rebuild
-  else
-    aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, true));
+  TopoDS_Wire aProfileWire = theProfWire;
+  //ignore ReverseXCoord if mode is false
+  if (mode)
+  {
+    if (!ReverseXCoord)
+      aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, false) ); //temp force rebuild
+    else
+      aProfileWire = TopoDS::Wire( theProfile->GetShape3D(true, true));
+  }
   if ( aPathWire.IsNull() || aProfileWire.IsNull() ) {
     return false;
   }
@@ -231,7 +275,11 @@ bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)&
   }
 
   // Get the profile middle point ( 3D )
-  gp_Pnt aMiddlePoint( theProfile->GetMiddlePoint( true ) );
+  gp_Pnt aMiddlePoint = theMiddlePnt;
+  if (mode)
+  {
+    aMiddlePoint = theProfile->GetMiddlePoint( true );
+  }
 
   // Translate the profile to each point on the guide line ( 3D )
   Handle(TColgp_HArray1OfPnt) anArrayOfFPnt = new TColgp_HArray1OfPnt(1, aNbPoints );
@@ -315,7 +363,6 @@ void HYDROData_Channel::Update()
   HYDROData_ArtificialObject::Update();
 
   Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
-  Handle(HYDROData_Profile) aProfile = GetProfile();
 
   PrsDefinition aResultPrs;
   double anEquiDistance = GetEquiDistance();
@@ -326,8 +373,20 @@ void HYDROData_Channel::Update()
   if (!aChannelAlt.IsNull())
     invDirection = aChannelAlt->GetInvertDirection();
 
-  if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance, invDirection ) )
-    return;
+  if (GetProfileMode())
+  {
+    Handle(HYDROData_Profile) aProfile = GetProfile();
+    if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance, invDirection ) )
+      return;
+  }
+  else
+  {
+    double lc = GetLCValue();
+    double deltaz = GetDeltaZValue();
+    double cotez = GetCoteZValue();
+    if ( !CreatePresentations( aGuideLine, lc, deltaz, cotez, aResultPrs, anEquiDistance, invDirection ) )
+      return;
+  }
 
   SetShape3D( aResultPrs.myPrs3D );
   SetTopShape( aResultPrs.myPrs2D );
@@ -496,3 +555,43 @@ double HYDROData_Channel::GetEquiDistance() const
 {
   return GetDouble( DataTag_EquiDistance, 1.0 );
 }
+
+void HYDROData_Channel::SetLCValue( double val )
+{
+  SetDouble( DataTag_LC, val );
+}
+
+double HYDROData_Channel::GetLCValue() const
+{
+  return GetDouble( DataTag_LC, 1.0 );
+}
+
+void HYDROData_Channel::SetDeltaZValue( double val )
+{
+  SetDouble( DataTag_DeltaZ, val );
+}
+
+double HYDROData_Channel::GetDeltaZValue() const
+{
+  return GetDouble( DataTag_DeltaZ, 1.0 );
+}
+
+void HYDROData_Channel::SetCoteZValue( double val )
+{
+  SetDouble( DataTag_CoteZ, val );
+}
+
+double HYDROData_Channel::GetCoteZValue() const
+{
+  return GetDouble( DataTag_CoteZ, 1.0 );
+}
+
+void HYDROData_Channel::SetProfileMode( bool mode )
+{
+  SetInteger( DataTag_ProfileMode, (bool)mode );
+}
+
+bool HYDROData_Channel::GetProfileMode() const
+{
+  return (bool)GetInteger( DataTag_ProfileMode, 1 );
+}
index 914718e8690a9b8247897e742c30c5067abf72fb..36cd50620c4991c7cfa168f32495cef6e4e99db4 100644 (file)
@@ -55,6 +55,10 @@ protected:
     DataTag_GuideLine, 
     DataTag_Profile,
     DataTag_EquiDistance,
+    DataTag_ProfileMode,
+    DataTag_LC,
+    DataTag_DeltaZ,
+    DataTag_CoteZ
   };
 
 public:
@@ -65,12 +69,31 @@ public:
   /**
    * Creates the presentations(2D and 3D) by given guide line and profile.
    */
+
   HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
                                                     const Handle(HYDROData_Profile)&    theProfile,
                                                     PrsDefinition&                      thePrs,
-                                                    double                              theEquiDistance, 
+                                                    double                              theEquiDistance,
+                                                    bool                                ReverseXCoord = false);
+
+  HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
+                                                    double                              LC,
+                                                    double                              deltaZ,
+                                                    double                              coteZ,
+                                                    PrsDefinition&                      thePrs,
+                                                    double                              theEquiDistance,
                                                     bool                                ReverseXCoord = false);
 
+protected:
+  static bool internalCreatePresentations( bool mode,
+                                           const Handle(HYDROData_Polyline3D)& theGuideLine,
+                                           const Handle(HYDROData_Profile)&    theProfile,
+                                           const TopoDS_Wire&                  theProfWire,
+                                           const gp_Pnt&                       theMiddlePnt,
+                                           PrsDefinition&                      thePrs,
+                                           double                              theEquiDistance,
+                                           bool                                ReverseXCoord);
+
 public:
 
   /**
@@ -158,6 +181,19 @@ public:
   HYDRODATA_EXPORT void SetEquiDistance( double );
   HYDRODATA_EXPORT double GetEquiDistance() const;
 
+  
+  HYDRODATA_EXPORT void SetLCValue( double );
+  HYDRODATA_EXPORT double GetLCValue() const;
+  
+  HYDRODATA_EXPORT void SetDeltaZValue( double );
+  HYDRODATA_EXPORT double GetDeltaZValue() const;
+  
+  HYDRODATA_EXPORT void SetCoteZValue( double );
+  HYDRODATA_EXPORT double GetCoteZValue() const;
+
+  HYDRODATA_EXPORT void SetProfileMode( bool );
+  HYDRODATA_EXPORT bool GetProfileMode() const;
+
 protected:
   /**
    * Returns the type of child altitude object.
index c8fa95f374cdfd8d497a4f75dafbcccae4a57526..cf10670196a538306eaedc2d2ff4bac04e95d0dc 100644 (file)
@@ -122,6 +122,10 @@ HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QStr
   connect( myGuideLines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
   connect( myProfiles, SIGNAL(  currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
   
+  connect( myLCVal, SIGNAL( valueChanged( double ) ), this, SLOT( onChannelDefChanged() ) );
+  connect( myDeltaZVal, SIGNAL(  valueChanged( double ) ), this, SLOT( onChannelDefChanged() ) );
+  connect( myCoteZVal, SIGNAL( valueChanged( double ) ), this, SLOT( onChannelDefChanged() ) );
+
   connect( myProfileModeButton, SIGNAL( toggled( bool ) ), this, SLOT( onProfileModeChanged( bool ) ) );
   myProfileModeButton->setChecked(true);
 }
@@ -244,6 +248,7 @@ void HYDROGUI_ChannelDlg::onProfileModeChanged(bool mode)
     myCoteZValLabel->setVisible(true);
     myCoteZVal->setVisible(true);
   }
+  emit CreatePreview();
 }
 
 bool HYDROGUI_ChannelDlg::getProfileMode()
@@ -271,3 +276,31 @@ void HYDROGUI_ChannelDlg::setInvertDirection( bool isChecked )
   myInvertDirection->setChecked(isChecked);
 }
 
+double HYDROGUI_ChannelDlg::getLCValue() const
+{
+  return myLCVal->value();
+}
+
+void  HYDROGUI_ChannelDlg::setLCValue( double val )
+{
+  myLCVal->setValue( val );
+}  
+
+double HYDROGUI_ChannelDlg::getDeltaZValue() const
+{
+  return myDeltaZVal->value();
+}
+
+void HYDROGUI_ChannelDlg::setDeltaZValue( double val )
+{
+  myDeltaZVal->setValue( val );
+}
+double HYDROGUI_ChannelDlg::getCoteZValue() const
+{
+  return myCoteZVal->value();
+}
+
+void HYDROGUI_ChannelDlg::setCoteZValue( double val )
+{
+  myCoteZVal->setValue( val );
+}
\ No newline at end of file
index d651c44687ce658df0f63f62af9bda6bce99b140..5af01f6aee65fb5e46193c4e2b5c2147ef414f21 100644 (file)
@@ -58,8 +58,15 @@ public:
   void                       setInvertDirection( bool isChecked );
 
   bool                       getProfileMode();
-
-
+  
+  double                     getLCValue() const;
+  void                       setLCValue( double );
+  
+  double                     getDeltaZValue() const;
+  void                       setDeltaZValue( double );
+  
+  double                     getCoteZValue() const;
+  void                       setCoteZValue( double );
 
 signals:
   void                       CreatePreview();
index a0a699c031317e49f3d01689bfac69bcaf74667a..2a1ede2301d9fec763fdfda2f07b3ac07de2323c 100644 (file)
@@ -199,7 +199,23 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
   }
 
   QString aGuideLineName = aPanel->getGuideLineName();
-  QString aProfileName = aPanel->getProfileName();
+
+  bool profileMode = aPanel->getProfileMode();
+  QString aProfileName;
+  double lc=0, deltaz=0, cotez=0;
+  
+  if (profileMode)
+  {
+    aProfileName = aPanel->getProfileName();
+  }
+  else
+  {
+    lc = aPanel->getLCValue();
+    deltaz = aPanel->getDeltaZValue();
+    cotez = aPanel->getCoteZValue();
+  }
+
+
   /*if ( aGuideLineName.isEmpty() || aProfileName.isEmpty() )
   {
     myEditedObject->RemoveGuideLine();
@@ -218,16 +234,31 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
     myEditedObject->RemoveGuideLine();
     myEditedObject->SetGuideLine( aGuideLine );
 
-    Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
-      HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
-    if ( aProfile.IsNull() )
+    myEditedObject->SetProfileMode(profileMode);
+
+    if (profileMode)
     {
-      theErrorMsg = tr( "PROFILE_IS_NOT_SELECTED" );
-      return false;
+      Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
+        HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
+      if ( aProfile.IsNull() )
+      {
+        theErrorMsg = tr( "PROFILE_IS_NOT_SELECTED" );
+        return false;
+      }
+      myEditedObject->RemoveProfile();
+      myEditedObject->SetProfile( aProfile );
+      myEditedObject->SetLCValue(0);
+      myEditedObject->SetDeltaZValue(0);
+      myEditedObject->SetCoteZValue(0);
+    }
+    else
+    {
+      myEditedObject->RemoveProfile();
+      myEditedObject->SetLCValue(lc);
+      myEditedObject->SetDeltaZValue(deltaz);
+      myEditedObject->SetCoteZValue(cotez);
     }
 
-    myEditedObject->RemoveProfile();
-    myEditedObject->SetProfile( aProfile );
     myEditedObject->SetEquiDistance( aPanel->getEquiDistance() );
     ///
     Handle(HYDROData_IAltitudeObject) anObjAltitude = myEditedObject->GetAltitudeObject();
@@ -315,8 +346,20 @@ void HYDROGUI_ChannelOp::onCreatePreview()
   Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast(
     HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
 
+  bool aProfMode = aPanel->getProfileMode();
   HYDROData_Channel::PrsDefinition aPrsDef;
-  if ( !HYDROData_Channel::CreatePresentations( aGuideLine, aProfile, aPrsDef, aPanel->getEquiDistance() ) )
+  bool stat = false;
+  double eqDist = aPanel->getEquiDistance();
+  if (aProfMode)
+    stat = HYDROData_Channel::CreatePresentations( aGuideLine, aProfile, aPrsDef, eqDist);
+  else
+  {
+    double lc = aPanel->getLCValue();
+    double deltaz = aPanel->getDeltaZValue();
+    double cotez = aPanel->getCoteZValue();
+    stat = HYDROData_Channel::CreatePresentations( aGuideLine, lc, deltaz, cotez, aPrsDef, eqDist);
+  }
+  if ( !stat  )
   {
     erasePreview();
     return;