]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #751: equidistance parameter is available in C++, OCAF, Python, GUI
authorasl <asl@opencascade.com>
Tue, 8 Dec 2015 07:48:57 +0000 (10:48 +0300)
committerasl <asl@opencascade.com>
Tue, 8 Dec 2015 07:48:57 +0000 (10:48 +0300)
src/HYDROData/HYDROData_Channel.cxx
src/HYDROData/HYDROData_Channel.h
src/HYDROData/HYDROData_Entity.cxx
src/HYDROData/HYDROData_Entity.h
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROGUI/HYDROGUI_ChannelDlg.cxx
src/HYDROGUI/HYDROGUI_ChannelDlg.h
src/HYDROGUI/HYDROGUI_ChannelOp.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROPy/HYDROData_Channel.sip

index 3d18e28d7a47f132750fdb242effd9fe188fe248..03013b3ee85cceabf71072839ced9e306d14a75c 100644 (file)
@@ -92,6 +92,8 @@ QStringList HYDROData_Channel::DumpToPython( const QString& thePyScriptPath,
   Handle(HYDROData_Profile) aRefProfile = GetProfile();
   setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefProfile, "SetProfile" );
 
+  aResList << QString( "%1.SetEquiDistance( %2 );" ).arg( aName ).arg( GetEquiDistance() );
+
   aResList << QString( "" );
   aResList << QString( "%1.Update();" ).arg( aName );
   aResList << QString( "" );
@@ -116,7 +118,8 @@ HYDROData_SequenceOfObjects HYDROData_Channel::GetAllReferenceObjects() const
 
 bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
                                              const Handle(HYDROData_Profile)&    theProfile,
-                                             PrsDefinition&                      thePrs )
+                                             PrsDefinition&                      thePrs,
+                                             double                              theEquiDistance )
 {
   // Check input parameters
   if ( theGuideLine.IsNull() || theProfile.IsNull() ) {
@@ -146,8 +149,7 @@ bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)&
   int aNbPoints = aPolylinePoints.Length();
   */
 
-  double aEqDistance = 1; // TODO: to pass via properties and OCAF
-  HYDROData_Polyline3D::Polyline3DPoints aPolylinePoints3D = theGuideLine->GetPoints( aEqDistance );
+  HYDROData_Polyline3D::Polyline3DPoints aPolylinePoints3D = theGuideLine->GetPoints( theEquiDistance );
   int aNbPoints = aPolylinePoints3D.Length();
   if ( aNbPoints < 2 )
     return false;
@@ -295,7 +297,8 @@ void HYDROData_Channel::Update()
   Handle(HYDROData_Profile) aProfile = GetProfile();
 
   PrsDefinition aResultPrs;
-  if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs ) )
+  double anEquiDistance = GetEquiDistance();
+  if ( !CreatePresentations( aGuideLine, aProfile, aResultPrs, anEquiDistance ) )
     return;
 
   SetShape3D( aResultPrs.myPrs3D );
@@ -452,3 +455,14 @@ TopoDS_Shape HYDROData_Channel::GetRightShape() const
   HYDROData_SequenceOfObjects aGroups = GetGroups();
   return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 2);
 }
+
+void HYDROData_Channel::SetEquiDistance( double theEquiDistance )
+{
+  double anEquiDistance = theEquiDistance > 0 ? theEquiDistance : 1E-3;
+  SetDouble( DataTag_EquiDistance, theEquiDistance );
+}
+
+double HYDROData_Channel::GetEquiDistance() const
+{
+  return GetDouble( DataTag_EquiDistance, 1.0 );
+}
index 372e57a7a46facbf470ec4881cf62f43562ad9cc..3e069097a2aab3e2dd6a101eaab2e4205f2a9f48 100644 (file)
@@ -58,6 +58,7 @@ protected:
     DataTag_First = HYDROData_ArtificialObject::DataTag_First + 100, ///< first tag, to reserve
     DataTag_GuideLine, 
     DataTag_Profile,
+    DataTag_EquiDistance,
   };
 
 public:
@@ -71,7 +72,8 @@ public:
    */
   HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_Polyline3D)& theGuideLine,
                                                     const Handle(HYDROData_Profile)&    theProfile,
-                                                    PrsDefinition&                      thePrs );
+                                                    PrsDefinition&                      thePrs,
+                                                    double                              theEquiDistance );
 
 public:
 
@@ -157,6 +159,8 @@ public:
    */
   HYDRODATA_EXPORT virtual void RemoveProfile();
 
+  HYDRODATA_EXPORT void SetEquiDistance( double );
+  HYDRODATA_EXPORT double GetEquiDistance() const;
 
 protected:
   /**
index d10c3b09eb00b4f5608d239c401749a1922ed6a9..8681cf1e675095a7dfd293161afb90691485adbc 100644 (file)
@@ -27,6 +27,7 @@
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_IntegerArray.hxx>
 #include <TDataStd_ReferenceList.hxx>
+#include <TDataStd_Real.hxx>
 #include <TDF_CopyLabel.hxx>
 #include <TDF_ListIteratorOfLabelList.hxx>
 #include <TNaming_Builder.hxx>
@@ -746,3 +747,22 @@ TopoDS_Shape HYDROData_Entity::GetShape( int theTag ) const
   }
   return TopoDS_Shape();
 }
+
+void HYDROData_Entity::SetDouble( int theTag, double theValue )
+{
+  Handle(TDataStd_Real) anAttr;
+  TDF_Label aLabel = myLab.FindChild( theTag );
+  if( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
+    aLabel.AddAttribute( anAttr = new TDataStd_Real() );
+  anAttr->Set( theValue );
+}
+
+double HYDROData_Entity::GetDouble( int theTag, double theDefValue ) const
+{
+  Handle(TDataStd_Real) anAttr;
+  TDF_Label aLabel = myLab.FindChild( theTag );
+  if( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
+    return theDefValue;
+
+  return anAttr->Get();
+}
index 44c34dfd81efe9ab1f9f58a324906c749d6da571..1e41b044d14dbe337e2390fe0f470e41c7003282 100644 (file)
@@ -434,6 +434,9 @@ protected:
   void SetShape( int theTag, const TopoDS_Shape& theShape );
   TopoDS_Shape GetShape( int theTag ) const;
 
+  void SetDouble( int theTag, double theValue );
+  double GetDouble( int theTag, double theDefValue = 0.0 ) const;
+
   int GetGeomChangeFlag() const;
 
 protected:
index 3cc968d5f179fef2cfce8ac62f39ff34b5434aab..e5dacdf560869235397b3065f0c32672152f8020 100644 (file)
@@ -48,7 +48,6 @@
 #include <TopExp_Explorer.hxx>
 #include <ShapeUpgrade_UnifySameDomain.hxx>
 #include <TopExp.hxx>
-#include <TDataStd_Real.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
 #include <ShapeBuild_ReShape.hxx>
 #include <ShapeFix_Shape.hxx>
@@ -1083,22 +1082,12 @@ TopoDS_Shape HYDROData_LandCoverMap::RemoveInternal(const TopoDS_Shape& InSh)
 
 void HYDROData_LandCoverMap::SetTransparency( double theTransparency )
 {
-  Handle(TDataStd_Real) anAttr;
-  TDF_Label aLabel = myLab.FindChild( DataTag_Transparency );
-  if( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
-    aLabel.AddAttribute( anAttr = new TDataStd_Real() );
-  anAttr->Set( theTransparency );
+  SetDouble( DataTag_Transparency, theTransparency );
 }
 
 double HYDROData_LandCoverMap::GetTransparency() const
 {
-  Handle(TDataStd_Real) anAttr;
-  TDF_Label aLabel = myLab.FindChild( DataTag_Transparency );
-  if( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
-    return 0.5;
-
-  return anAttr->Get();
-  
+  return GetDouble( DataTag_Transparency, 0.5 );
 }
 
 bool HYDROData_LandCoverMap::ImportSHP( const QString& theSHPFileName,
index cc08804e04e012bf7fa6d40af3cb82a358166664..0b55e800b7800adf611506b20b8121127277274f 100644 (file)
@@ -25,6 +25,7 @@
 #include <QLabel>
 #include <QLayout>
 #include <QLineEdit>
+#include <QtxDoubleSpinBox.h>
 
 HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle )
 : HYDROGUI_InputPanel( theModule, theTitle )
@@ -51,6 +52,11 @@ HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QStr
   myProfiles = new QComboBox( aParamGroup );
   myProfiles->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
 
+  myEquiDistance = new QtxDoubleSpinBox( aParamGroup );
+  myEquiDistance->setRange( 0.01, 100 );
+  myEquiDistance->setValue( 1.0 );
+  myEquiDistance->setSingleStep( 1.0 );
+
   QGridLayout* aParamsLayout = new QGridLayout( aParamGroup );
   aParamsLayout->setMargin( 5 );
   aParamsLayout->setSpacing( 5 );
@@ -58,6 +64,8 @@ HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QStr
   aParamsLayout->addWidget( myGuideLines, 0, 1 );
   aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_PROFILE" ), aParamGroup ), 1, 0 );
   aParamsLayout->addWidget( myProfiles, 1, 1 );
+  aParamsLayout->addWidget( new QLabel( tr( "EQUI_DISTANCE" ), aParamGroup ), 2, 0 );
+  aParamsLayout->addWidget( myEquiDistance, 2, 1 );
 
   // Common
   addWidget( myObjectNameGroup );
@@ -161,3 +169,13 @@ void HYDROGUI_ChannelDlg::onChannelDefChanged()
 
   emit CreatePreview();
 }
+
+double HYDROGUI_ChannelDlg::getEquiDistance() const
+{
+  return myEquiDistance->value();
+}
+
+void HYDROGUI_ChannelDlg::setEquiDistance( double theValue )
+{
+  myEquiDistance->setValue( theValue );
+}
index 9822928ad69a3deb2e55e00099c57389d1176abd..e01a9f5e85b48e35a13afcf1e6e6b4a78343ae69 100644 (file)
@@ -25,6 +25,7 @@
 class QComboBox;
 class QGroupBox;
 class QLineEdit;
+class QtxDoubleSpinBox;
 
 class HYDROGUI_ChannelDlg : public HYDROGUI_InputPanel
 {
@@ -47,6 +48,9 @@ public:
   void                       setProfileName( const QString& theProfile );
   QString                    getProfileName() const;
 
+  double                     getEquiDistance() const;
+  void                       setEquiDistance( double );
+
 signals:
   void                       CreatePreview();
 
@@ -60,6 +64,8 @@ protected:
 
   QComboBox*                 myGuideLines;
   QComboBox*                 myProfiles;
+
+  QtxDoubleSpinBox*          myEquiDistance;
 };
 
 #endif
index 99bf0cb70ca9fff56f3364274e98c3657bd11c72..8c3e73e469f05fa438f03d039ef3e31990548a51 100644 (file)
@@ -118,6 +118,11 @@ void HYDROGUI_ChannelOp::startOperation()
   aPanel->setGuideLineName( aSelectedGuideLine );
   aPanel->setProfileName( aSelectedProfile );
 
+  if( !myEditedObject.IsNull() )
+    aPanel->setEquiDistance( myEditedObject->GetEquiDistance() );
+  else
+    aPanel->setEquiDistance( 1.0 );
+
   aPanel->blockSignals( false );
 
   onCreatePreview();
@@ -210,6 +215,7 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
 
     myEditedObject->RemoveProfile();
     myEditedObject->SetProfile( aProfile );
+    myEditedObject->SetEquiDistance( aPanel->getEquiDistance() );
   }
 
   if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
@@ -292,7 +298,7 @@ void HYDROGUI_ChannelOp::onCreatePreview()
     HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) );
 
   HYDROData_Channel::PrsDefinition aPrsDef;
-  if ( !HYDROData_Channel::CreatePresentations( aGuideLine, aProfile, aPrsDef ) )
+  if ( !HYDROData_Channel::CreatePresentations( aGuideLine, aProfile, aPrsDef, aPanel->getEquiDistance() ) )
   {
     erasePreview();
     return;
index 76fc98571891ab4ef45fb6997d7e388a0db0316e..c7ca128b3d1a10865e8ca1fb83c52a6fb4230fca 100644 (file)
@@ -2758,6 +2758,10 @@ Polyline should consist from one not closed curve.</translation>
       <source>CHANNEL_PROFILE</source>
       <translation>Profile</translation>
     </message>
+    <message>
+      <source>EQUI_DISTANCE</source>
+      <translation>Equidistance</translation>
+    </message>
   </context>
 
   <context>
index 9c52de3d6fbf9df950d0fbdeafc98c9bf23a4f70..1ff170acce53a4222bea1ee22fb8426040c6d042 100644 (file)
@@ -136,7 +136,9 @@ public:
    */
   void RemoveProfile();
 
-
+  void SetEquiDistance( double );
+  double GetEquiDistance() const;
+  
 protected:
 
   /**