]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
lot 13 - GUI/VISUAL part
authorisn <isn@opencascade.com>
Mon, 21 Jan 2019 17:38:54 +0000 (20:38 +0300)
committerisn <isn@opencascade.com>
Fri, 1 Feb 2019 15:17:18 +0000 (18:17 +0300)
src/HYDROData/HYDROData_Channel.cxx
src/HYDROData/HYDROData_Channel.h
src/HYDROData/HYDROData_ChannelAltitude.cxx
src/HYDROData/HYDROData_ChannelAltitude.h
src/HYDROData/HYDROData_Profile.cxx
src/HYDROData/HYDROData_Profile.h
src/HYDROGUI/HYDROGUI_ChannelDlg.cxx
src/HYDROGUI/HYDROGUI_ChannelDlg.h
src/HYDROGUI/HYDROGUI_ChannelOp.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index d4645ea4e0f98d64f035f7dabb783373e2d4fe6a..f489e803a6757607ca8d30c651ba4dcb03c2fbf1 100644 (file)
@@ -27,6 +27,7 @@
 #include "HYDROData_ShapesTool.h"
 #include "HYDROData_Stream.h"
 #include "HYDROData_Tool.h"
+#include "HYDROData_ChannelAltitude.h"
 
 #include <BRepBuilderAPI_MakeWire.hxx>
 
@@ -124,7 +125,8 @@ HYDROData_SequenceOfObjects HYDROData_Channel::GetAllReferenceObjects() const
 bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
                                              const Handle(HYDROData_Profile)&    theProfile,
                                              PrsDefinition&                      thePrs,
-                                             double                              theEquiDistance )
+                                             double                              theEquiDistance,
+                                             bool                                ReverseXCoord)
 {
   // Check input parameters
   if ( theGuideLine.IsNull() || theProfile.IsNull() ) {
@@ -132,7 +134,11 @@ bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)&
   }
 
   TopoDS_Wire aPathWire = TopoDS::Wire( theGuideLine->GetShape3D() );
-  TopoDS_Wire aProfileWire = TopoDS::Wire( theProfile->GetShape3D() );
+  TopoDS_Wire aProfileWire;
+  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;
   }
@@ -313,7 +319,14 @@ void HYDROData_Channel::Update()
 
   PrsDefinition aResultPrs;
   double anEquiDistance = GetEquiDistance();
-  if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance ) )
+
+  bool invDirection = false;
+  Handle(HYDROData_IAltitudeObject) anObjAltitude = GetAltitudeObject();
+  Handle(HYDROData_ChannelAltitude) aChannelAlt = Handle(HYDROData_ChannelAltitude)::DownCast(anObjAltitude);
+  if (!aChannelAlt.IsNull())
+    invDirection = aChannelAlt->GetInvertDirection();
+
+  if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance, invDirection ) )
     return;
 
   SetShape3D( aResultPrs.myPrs3D );
index 3ba6e2c9a2e4cc15defffc426515226b706bc9f1..914718e8690a9b8247897e742c30c5067abf72fb 100644 (file)
@@ -68,7 +68,8 @@ public:
   HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
                                                     const Handle(HYDROData_Profile)&    theProfile,
                                                     PrsDefinition&                      thePrs,
-                                                    double                              theEquiDistance );
+                                                    double                              theEquiDistance, 
+                                                    bool                                ReverseXCoord = false);
 
 public:
 
index d3c0008ee321a7e5d799a34783767989797bf31d..214c6bf1287f465df31ca0039787cf57d8647202 100644 (file)
@@ -26,6 +26,7 @@
 #include "HYDROData_PolylineXY.h"
 #include "HYDROData_ProfileUZ.h"
 #include "HYDROData_Profile.h"
+#include <TDataStd_Integer.hxx>
 
 #define _DEVDEBUG_
 #include "HYDRO_trace.hxx"
@@ -287,7 +288,10 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint,
 
           distance *= aSign;
           DEBTRACE("distance to guideline " << distance);
-          
+
+          if (GetInvertDirection())
+            distance*=-1;
+
           // get delta altitude on section (supposed symmetric) from guideline distance (aParam)
           double delta = 0;
           int i1 = 0;
@@ -313,7 +317,7 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint,
             }
           if ((i1 == 0) && (i2 == 0))
             {
-              DEBTRACE("Projection aborted: non centered profile");
+              DEBTRACE("Projection aborted : non centered profile");
               return aResAltitude;
             }
           else if (i1 == 0)  // distance <  - profile width
@@ -346,5 +350,27 @@ double HYDROData_ChannelAltitude::GetAltitudeForPoint( const gp_XY& thePoint,
 }
 
 
+void HYDROData_ChannelAltitude::SetInvertDirection(bool IsInverted)
+{
+  if ( GetInvertDirection() == IsInverted )
+    return;
+
+  TDataStd_Integer::Set( myLab.FindChild( DataTag_InvertDirection ), (Standard_Integer)IsInverted );
+}
+
+bool HYDROData_ChannelAltitude::GetInvertDirection() const
+{
+  bool aRes = false;
+
+  TDF_Label aLabel = myLab.FindChild( DataTag_InvertDirection, false );
+  if ( !aLabel.IsNull() )
+  {
+    Handle(TDataStd_Integer) anIntVal;
+    if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anIntVal ) )
+      aRes = (bool)anIntVal->Get();
+  }
+
+  return aRes;
+}
 
 
index d65582e5f4d0976c20fecaca9a70ccd6506bf902..93fabb498ebe557505887fc4c2d1f224ad08cac7 100644 (file)
@@ -38,6 +38,7 @@ protected:
   enum DataTag
   {
     DataTag_First = HYDROData_IAltitudeObject::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_InvertDirection,                                        ///< flag for inversion of direction
   };
 
 public:
@@ -61,6 +62,10 @@ public:
   HYDRODATA_EXPORT virtual double           GetAltitudeForPoint( const gp_XY& thePoint,
                                                                  int theMethod =0) const;
 
+  HYDRODATA_EXPORT void                     SetInvertDirection(bool IsInverted);
+
+  HYDRODATA_EXPORT bool                     GetInvertDirection() const;
+
 protected:
 
   friend class HYDROData_Iterator;
index cd8bd084a4152aeaf8ee2bfd36f37e3fef3a9eb0..ae79ef48f73ccf1487d3de92993222db037fcda0 100644 (file)
@@ -162,15 +162,17 @@ TopoDS_Shape HYDROData_Profile::GetTopShape() const
   return aWire;
 }
 
-TopoDS_Shape HYDROData_Profile::GetShape3D() const
+TopoDS_Shape HYDROData_Profile::GetShape3D(bool forceRebuild, bool reverseXCoord) const
 {
+  if (forceRebuild)
+    return CreateProfileWire( true, reverseXCoord );
   TopoDS_Shape aShape = HYDROData_Object::GetShape3D();
   if( aShape.IsNull() )
-    aShape = CreateProfileWire( true );
+    aShape = CreateProfileWire( true, reverseXCoord );
   return aShape;
 }
 
-TopoDS_Shape HYDROData_Profile::CreateProfileWire( bool canUseDefaultPoints ) const
+TopoDS_Shape HYDROData_Profile::CreateProfileWire( bool canUseDefaultPoints, bool reverseXCoord ) const
 {
   TopoDS_Wire aWire;
   Handle(HYDROData_ProfileUZ) aProfile = GetProfileUZ( false );
@@ -178,7 +180,14 @@ TopoDS_Shape HYDROData_Profile::CreateProfileWire( bool canUseDefaultPoints ) co
   {
     ProfilePoints aProfilePoints = GetProfilePoints( false, canUseDefaultPoints );
     HYDROData_IPolyline::SectionType aSectionType = aProfile->GetSectionType( 0 );
-
+    if (reverseXCoord)
+    {
+      for ( int i = 1; i <= aProfilePoints.Size() ; i++ )
+      {
+        gp_XYZ& aPoint = aProfilePoints.ChangeValue(i);
+        aPoint.ChangeCoord(1) = -aPoint.X();
+      }
+    }
     aWire = HYDROData_PolylineXY::BuildWire( aSectionType, false, aProfilePoints );
   }
   return aWire;
index 79f241858325a73c177c0a86d3562d2aa8773c77..94ca5bb27491d031f73aad8ad7d6f74b50db9444 100644 (file)
@@ -72,7 +72,7 @@ public:
   /**
    * Returns the 3d shape of the object.
    */
-  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D(bool forceRebuild = false, bool reverseXCoord = false) const;
 
   /**
    * Updates profile 3D presentation.
@@ -261,7 +261,7 @@ protected:
    */
   HYDRODATA_EXPORT virtual void checkAndSetObject3D() {}
 
-  TopoDS_Shape CreateProfileWire( bool canUseDefaultPoints ) const;
+  TopoDS_Shape CreateProfileWire( bool canUseDefaultPoints, bool reverseXCoord = false) const;
 
   static void ProjectProfilePoints( ProfilePoints& thePoints );
 
index 9c8513ca679971b0e924683193717b8bd9dd6ccc..d2c66807160120a18b793d532e8503823118ab7a 100644 (file)
@@ -25,6 +25,7 @@
 #include <QLabel>
 #include <QLayout>
 #include <QLineEdit>
+#include <QCheckBox>
 #include <QtxDoubleSpinBox.h>
 
 HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle )
@@ -57,6 +58,9 @@ HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QStr
   myEquiDistance->setValue( 1.0 );
   myEquiDistance->setSingleStep( 1.0 );
 
+  myInvertDirection = new QCheckBox(aParamGroup);
+  myInvertDirection->setChecked(false);
+
   QGridLayout* aParamsLayout = new QGridLayout( aParamGroup );
   aParamsLayout->setMargin( 5 );
   aParamsLayout->setSpacing( 5 );
@@ -66,6 +70,8 @@ HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QStr
   aParamsLayout->addWidget( myProfiles, 1, 1 );
   aParamsLayout->addWidget( new QLabel( tr( "EQUI_DISTANCE" ), aParamGroup ), 2, 0 );
   aParamsLayout->addWidget( myEquiDistance, 2, 1 );
+  aParamsLayout->addWidget( new QLabel( tr( "INVERT_DIRECTION" ), aParamGroup ), 3, 0 );
+  aParamsLayout->addWidget( myInvertDirection, 3, 1 );
 
   // Common
   addWidget( myObjectNameGroup );
@@ -179,3 +185,14 @@ void HYDROGUI_ChannelDlg::setEquiDistance( double theValue )
 {
   myEquiDistance->setValue( theValue );
 }
+
+bool HYDROGUI_ChannelDlg::getInvertDirection() const
+{
+  return myInvertDirection->isChecked();
+}
+
+void HYDROGUI_ChannelDlg::setInvertDirection( bool isChecked )
+{
+  myInvertDirection->setChecked(isChecked);
+}
+
index e01a9f5e85b48e35a13afcf1e6e6b4a78343ae69..1501dc2fe97149126746f4a4f5c43d6c15547a46 100644 (file)
@@ -25,6 +25,7 @@
 class QComboBox;
 class QGroupBox;
 class QLineEdit;
+class QCheckBox;
 class QtxDoubleSpinBox;
 
 class HYDROGUI_ChannelDlg : public HYDROGUI_InputPanel
@@ -50,6 +51,10 @@ public:
 
   double                     getEquiDistance() const;
   void                       setEquiDistance( double );
+  
+  bool                       getInvertDirection() const;
+  void                       setInvertDirection( bool isChecked );
+
 
 signals:
   void                       CreatePreview();
@@ -66,6 +71,7 @@ protected:
   QComboBox*                 myProfiles;
 
   QtxDoubleSpinBox*          myEquiDistance;
+  QCheckBox*                 myInvertDirection;
 };
 
 #endif
index 8c3e73e469f05fa438f03d039ef3e31990548a51..a0a699c031317e49f3d01689bfac69bcaf74667a 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <LightApp_Application.h>
 #include <LightApp_UpdateFlags.h>
+#include <HYDROData_ChannelAltitude.h>
 
 #include <TopoDS.hxx>
 
@@ -123,6 +124,18 @@ void HYDROGUI_ChannelOp::startOperation()
   else
     aPanel->setEquiDistance( 1.0 );
 
+  if( !myEditedObject.IsNull() )
+  {
+    bool invDirection = false;
+    Handle(HYDROData_IAltitudeObject) anObjAltitude = myEditedObject->GetAltitudeObject();
+    Handle(HYDROData_ChannelAltitude) aChannelAlt = Handle(HYDROData_ChannelAltitude)::DownCast(anObjAltitude);
+    if (!aChannelAlt.IsNull())
+      invDirection = aChannelAlt->GetInvertDirection();
+    aPanel->setInvertDirection( invDirection );
+  }
+  else
+    aPanel->setInvertDirection( false );
+
   aPanel->blockSignals( false );
 
   onCreatePreview();
@@ -216,6 +229,11 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
     myEditedObject->RemoveProfile();
     myEditedObject->SetProfile( aProfile );
     myEditedObject->SetEquiDistance( aPanel->getEquiDistance() );
+    ///
+    Handle(HYDROData_IAltitudeObject) anObjAltitude = myEditedObject->GetAltitudeObject();
+    Handle(HYDROData_ChannelAltitude) aChannelAlt = Handle(HYDROData_ChannelAltitude)::DownCast(anObjAltitude);
+    if (!aChannelAlt.IsNull())
+      aChannelAlt->SetInvertDirection(aPanel->getInvertDirection());
   }
 
   if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
index 48bfb0a42a524358b203ca5ff87e416adb858755..e938a9e0fdb9f6ce8173c82aa56ae490350c49d7 100755 (executable)
@@ -3099,6 +3099,10 @@ Polyline should consist from one not closed curve.</translation>
       <source>EQUI_DISTANCE</source>\r
       <translation>Equidistance</translation>\r
     </message>\r
+    <message>
+      <source>INVERT_DIRECTION</source>
+      <translation>Invert direction</translation>
+    </message>
   </context>\r
 \r
   <context>\r