]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
#571 - Land Cover: calculation of Strickler coefficient
authorstv <stv@opencascade.com>
Fri, 26 Jun 2015 07:56:18 +0000 (10:56 +0300)
committerstv <stv@opencascade.com>
Fri, 26 Jun 2015 07:56:18 +0000 (10:56 +0300)
#572 - Extraction of polylines
#563 - Strickler table: dump to Python (bug fixing)
#599 - Incorrect behavior of 'eyes' in Object browser after reloading python script

22 files changed:
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_Document.cxx
src/HYDROData/HYDROData_Document.h
src/HYDROData/HYDROData_StricklerTable.cxx
src/HYDROData/HYDROData_StricklerTable.h
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_DataModel.h
src/HYDROGUI/HYDROGUI_LandCoverOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_StricklerTableOp.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROPy/CMakeLists.txt
src/HYDROPy/HYDROData.sip
src/HYDROPy/HYDROData_CalculationCase.sip
src/HYDROPy/HYDROData_Document.sip
src/HYDROPy/HYDROData_Entity.sip
src/HYDROPy/HYDROData_StricklerTable.sip [new file with mode: 0644]

index 72db9915e3f64ed73f3daf582a71ee1252c0d45d..f8640f813db6e919e8599a72bc4114aa716b3894 100644 (file)
@@ -893,6 +893,38 @@ NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
   return aResSeq;
 }
 
+double HYDROData_CalculationCase::GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const
+{
+    double aCoeff = 0;
+    Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+    if ( !aDocument.IsNull() )
+        aCoeff = aDocument->GetDefaultStricklerCoefficient();
+
+    Handle(HYDROData_LandCover) aLandCover;
+    Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint, Standard_True );
+    if ( !aZone.IsNull() )
+    {
+        HYDROData_SequenceOfObjects anObjList = aZone->GetObjects();
+        if ( anObjList.Length() == 1 )
+            aLandCover = Handle(HYDROData_LandCover)::DownCast( anObjList.First() );
+        else
+            aLandCover = Handle(HYDROData_LandCover)::DownCast( aZone->GetMergeObject() );
+    }
+
+    if ( !aLandCover.IsNull() )
+    {
+        QString aType = aLandCover->GetStricklerType();
+        Handle(HYDROData_StricklerTable) aTable = GetStricklerTable();
+        if ( !aTable.IsNull() )
+        {
+            if ( aTable->GetTypes().contains( aType ) )
+                aCoeff = aTable->Get( aType, aCoeff );
+        }
+    }
+
+    return aCoeff;
+}
+
 Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint,
                                                                         const bool theLandCover ) const
 {
index 9d84b3d4f596dba35ba27a92fd6d4b4c4f4048bd..97c6a35cc15146d518492b2a2e0913b69906f1e3 100644 (file)
@@ -331,6 +331,13 @@ public:
   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                  thePoint,
                                                        const Handle(HYDROData_Zone)& theZone ) const;
 
+  /**
+   * Returns strickler coefficient for given point.
+   * \param thePoint the point to examine
+   * \return result strickler coefficient
+   */
+  HYDRODATA_EXPORT double GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const;
+
   /**
    * Returns altitudes for given points on given region.
    * \param thePoints the points to examine
index 44b9fb605e4fa29962c2f86230e4410a67b32dae..55912ca6dc1cac3fb48044bc26e75200a27996f4 100644 (file)
@@ -22,6 +22,7 @@
 #include <HYDROData_Tool.h>
 #include <HYDROData_InterpolatorsFactory.h>
 
+#include <TDataStd_Real.hxx>
 #include <TDataStd_Integer.hxx>
 #include <TDataXtd_Position.hxx>
 
@@ -45,6 +46,7 @@ static const int TAG_PROPS_NEW_ID = 1; // general properties: tag for storage of
 static const int TAG_OBJECTS = 2; // tag of the objects sub-tree
 static const int TAG_HISTORY = 3; // tag of the history sub-tree (Root for History)
 static const int TAG_LOCAL_CS = 4; // tag of local coordinate system information
+static const int TAG_DEF_STRICKLER_COEFF = 5; // tag of default strickler coefficient
 static const gp_Pnt2d DEFAULT_LOCAL_CS( 0, 0 );
 
 using namespace std;
@@ -201,6 +203,32 @@ void HYDROData_Document::Close()
   HYDROData_Application::GetApplication()->RemoveDocument(this);
 }
 
+double HYDROData_Document::GetDefaultStricklerCoefficient() const
+{
+    double aRes = 0;
+    TDF_Label aLabel = myDoc->Main().FindChild(TAG_DEF_STRICKLER_COEFF, Standard_False);
+    if ( !aLabel.IsNull() )
+    {
+        Handle(TDataStd_Real) anAttr;
+        if ( aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
+            aRes = anAttr->Get();
+    }
+
+    return aRes;
+}
+
+void HYDROData_Document::SetDefaultStricklerCoefficient( double theCoeff ) const
+{
+    TDF_Label aLabel = myDoc->Main().FindChild(TAG_DEF_STRICKLER_COEFF);
+    if ( !aLabel.IsNull() )
+    {
+        Handle(TDataStd_Real) anAttr;
+        if ( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
+            aLabel.AddAttribute( anAttr = new TDataStd_Real() );
+        anAttr->Set( theCoeff );
+    }
+}
+
 bool HYDROData_Document::DumpToPython( const QString& theFileName,
                                        const bool     theIsMultiFile ) const
 {
index 4c57cbc0a6378261374dd78186944c8ae105b709..9394f1b60552e99ad12695169843338d5350c274 100644 (file)
@@ -218,8 +218,14 @@ public:
   //! Get list of registered interpolator names.
   HYDRODATA_EXPORT NCollection_Sequence<TCollection_AsciiString> GetInterpolatorNames() const;
 
-protected:
+public:
+  //! Returns default strickler coefficient
+  HYDRODATA_EXPORT double GetDefaultStricklerCoefficient() const;
 
+  //! Sets default strickler coefficient
+  HYDRODATA_EXPORT void SetDefaultStricklerCoefficient( double ) const;
+
+protected:
   friend class HYDROData_Iterator;
   friend class test_HYDROData_Document;
 
index 68995e824be7ab26e9824459bf25e8a1567d3a3c..279ecaea75d844343183b49c4fa9d3566432a05b 100644 (file)
@@ -81,7 +81,7 @@ bool HYDROData_StricklerTable::Import( const TCollection_AsciiString& theFileNam
             else
             {
                 Standard_Real aValue = TCollection_AsciiString( aValueStr ).RealValue();
-                Set( aStr, aValue );
+                Set( QString( (QChar*)aStr.ToExtString(), aStr.Length() ), aValue );
             }
         }
     }
@@ -115,29 +115,30 @@ bool HYDROData_StricklerTable::Export( const TCollection_AsciiString& theFileNam
     return aRes;
 }
 
-double HYDROData_StricklerTable::Get( const TCollection_ExtendedString& theType, double theDefault ) const
+double HYDROData_StricklerTable::Get( const QString& theType, double theDefault ) const
 {
     Handle( TDataStd_NamedData ) aMap = Map();
-    if( aMap->HasReal( theType ) )
-        return aMap->GetReal( theType );
+    TCollection_ExtendedString aType = toExtString( theType );
+    if( aMap->HasReal( aType ) )
+        return aMap->GetReal( aType );
     else
         return theDefault;
 }
 
-void HYDROData_StricklerTable::Set( const TCollection_ExtendedString& theType, double theCoefficient )
+void HYDROData_StricklerTable::Set( const QString& theType, double theCoefficient )
 {
     Handle(TDataStd_NamedData) aMap = Map();
-    aMap->SetReal( theType, theCoefficient );
+    aMap->SetReal( toExtString( theType ), theCoefficient );
 }
 
-TColStd_SequenceOfExtendedString HYDROData_StricklerTable::GetTypes() const
+QStringList HYDROData_StricklerTable::GetTypes() const
 {
-    TColStd_SequenceOfExtendedString aSeq;
+    QStringList aSeq;
     Handle(TDataStd_NamedData) aMap = Map();
     if ( !aMap.IsNull() )
     {
         for ( TDataStd_DataMapIteratorOfDataMapOfStringReal it( aMap->GetRealsContainer() ); it.More(); it.Next() )
-            aSeq.Append( it.Key() );
+            aSeq.append( toQString( it.Key() ) );
     }
     return aSeq;
 }
@@ -179,3 +180,23 @@ Handle(TDataStd_NamedData) HYDROData_StricklerTable::Map() const
         aMap = TDataStd_NamedData::Set( aLabel );
     return aMap;
 }
+
+TCollection_ExtendedString HYDROData_StricklerTable::toExtString( const QString& theStr ) const
+{
+    TCollection_ExtendedString aRes;
+    if( !theStr.isEmpty() )
+    {
+           Standard_ExtString extStr = new Standard_ExtCharacter[ ( theStr.length() + 1 ) * 2 ];
+           memcpy( (void*)extStr, theStr.unicode(), theStr.length() * 2 );
+           ((short*)extStr)[theStr.length()] = '\0';
+
+           aRes = TCollection_ExtendedString( extStr );
+           delete [] extStr;
+    }
+    return aRes;
+}
+
+QString HYDROData_StricklerTable::toQString( const TCollection_ExtendedString& theStr ) const
+{
+    return QString( (QChar*)theStr.ToExtString(), theStr.Length() );
+}
index bbc553bec135c93187bd1ffeaf9fd418205d750a..a70e9f71e86d68a11870126515cd8fb75e637c30 100644 (file)
@@ -48,15 +48,19 @@ public:
   HYDRODATA_EXPORT bool Import( const TCollection_AsciiString& theFileName );
   HYDRODATA_EXPORT bool Export( const TCollection_AsciiString& theFileName );
 
-  HYDRODATA_EXPORT double Get( const TCollection_ExtendedString& theType, double theDefault ) const;
-  HYDRODATA_EXPORT void Set( const TCollection_ExtendedString& theType, double theCoefficient );
+  HYDRODATA_EXPORT double Get( const QString& theType, double theDefault ) const;
+  HYDRODATA_EXPORT void Set( const QString& theType, double theCoefficient );
 
-  HYDRODATA_EXPORT TColStd_SequenceOfExtendedString GetTypes() const;
+  HYDRODATA_EXPORT QStringList GetTypes() const;
 
   HYDRODATA_EXPORT void Clear();
 
   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
 
+private:
+    TCollection_ExtendedString     toExtString( const QString& ) const;
+    QString                        toQString( const TCollection_ExtendedString& ) const;
+
 private:
   Handle(TDataStd_NamedData) Map() const;
 };
index 684e5634e628121f82ed146c86e44f22468b3924..2f647b72d98b389919c0ee7059faa2290de1653b 100644 (file)
@@ -28,7 +28,7 @@ set(PROJECT_HEADERS
     HYDROGUI_ExportFileOp.h
     HYDROGUI_GVSelector.h
     HYDROGUI_ImagePrs.h
-       HYDROGUI_BasicZoneDlg.h
+    HYDROGUI_BasicZoneDlg.h
     HYDROGUI_ImmersibleZoneDlg.h
     HYDROGUI_ImmersibleZoneOp.h
     HYDROGUI_ImportBathymetryDlg.h
@@ -76,8 +76,8 @@ set(PROJECT_HEADERS
     HYDROGUI_LineEditDoubleValidator.h
     HYDROGUI_StricklerTableDlg.h
     HYDROGUI_StricklerTableOp.h
-       HYDROGUI_LandCoverDlg.h
-       HYDROGUI_LandCoverOp.h
+    HYDROGUI_LandCoverDlg.h
+    HYDROGUI_LandCoverOp.h
     HYDROGUI_SubmersibleOp.h
     HYDROGUI_Tool.h
     HYDROGUI_TwoImagesDlg.h
@@ -119,6 +119,7 @@ set(PROJECT_HEADERS
     HYDROGUI_RiverBottomOp.h
     HYDROGUI_ViewerDlg.h
     HYDROGUI_ObjComboBox.h
+    HYDROGUI_PolylineExtractionOp.h
 )
 
 QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
@@ -149,7 +150,7 @@ set(PROJECT_SOURCES
     HYDROGUI_ExportFileOp.cxx
     HYDROGUI_GVSelector.cxx
     HYDROGUI_ImagePrs.cxx
-       HYDROGUI_BasicZoneDlg.cxx
+    HYDROGUI_BasicZoneDlg.cxx
     HYDROGUI_ImmersibleZoneDlg.cxx
     HYDROGUI_ImmersibleZoneOp.cxx
     HYDROGUI_ImportBathymetryDlg.cxx
@@ -197,8 +198,8 @@ set(PROJECT_SOURCES
     HYDROGUI_LineEditDoubleValidator.cxx
     HYDROGUI_StricklerTableDlg.cxx
     HYDROGUI_StricklerTableOp.cxx
-       HYDROGUI_LandCoverDlg.cxx
-       HYDROGUI_LandCoverOp.cxx
+    HYDROGUI_LandCoverDlg.cxx
+    HYDROGUI_LandCoverOp.cxx
     HYDROGUI_SubmersibleOp.cxx
     HYDROGUI_Tool.cxx
     HYDROGUI_TwoImagesDlg.cxx
@@ -241,6 +242,7 @@ set(PROJECT_SOURCES
     HYDROGUI_RiverBottomOp.cxx
     HYDROGUI_ViewerDlg.cxx
     HYDROGUI_ObjComboBox.cxx
+    HYDROGUI_PolylineExtractionOp.cxx
 )
 
 add_definitions(
index 1eaef34b3e651d28b06e4c9486396ca7ff0fca56..aed8f8a7a4227a6b7c982ff4f853cd0dc40c6c6a 100644 (file)
@@ -87,6 +87,14 @@ HYDROGUI_DataModel::~HYDROGUI_DataModel()
 {
 }
 
+bool HYDROGUI_DataModel::create( CAM_Study* theStudy )
+{
+    bool status = LightApp_DataModel::create( theStudy );
+    if ( status )
+        updateDocument();
+    return status;
+}
+
 bool HYDROGUI_DataModel::open( const QString& theURL,
                                CAM_Study* theStudy,
                                QStringList theFileList )
@@ -113,13 +121,14 @@ bool HYDROGUI_DataModel::open( const QString& theURL,
     {
       res = DocError_UnknownProblem;
     }
-    if( res != DocError_OK )
+    
+    if ( res != DocError_OK )
     {
       module()->application()->putInfo( tr( "LOAD_ERROR" ) );
       return false;
     }
 
-    if( !aStatesFullPath.isEmpty() )
+    if ( !aStatesFullPath.isEmpty() )
     {
       QFile aFile( aStatesFullPath );
       if( aFile.open( QFile::ReadOnly ) )
@@ -128,11 +137,13 @@ bool HYDROGUI_DataModel::open( const QString& theURL,
         aFile.close();
       }
     }
+
+    updateDocument();
   }
 
   // if the document open was successful, the data model update happens
   // in the set mode of the module
-  if( res == DocError_OK )
+  if ( res == DocError_OK )
     update( aStudyId );
 
   return true;
@@ -148,7 +159,7 @@ bool HYDROGUI_DataModel::save( QStringList& theFileList )
   QString aTmpDir;
   SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
   bool isMultiFile = false;
-  if( resMgr )
+  if ( resMgr )
     isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
 
   // save module data to temporary files
@@ -195,6 +206,9 @@ bool HYDROGUI_DataModel::saveAs( const QString& theURL,
 
 bool HYDROGUI_DataModel::close()
 {
+  HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
+  if ( aModule )
+      aModule->clearCache();
   return true;
 }
 
@@ -1218,3 +1232,12 @@ bool HYDROGUI_DataModel::rename( Handle(HYDROData_Entity) theEntity, const QStri
   }
   return true;
 }
+
+void HYDROGUI_DataModel::updateDocument()
+{
+    // Sets the default strickler coefficient from preferences to document.
+    Handle(HYDROData_Document) aDoc = getDocument();
+    SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
+    if ( resMgr && !aDoc.IsNull() )
+        aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( "preferences", "default_strickler_coefficient", 0 ) );
+}
index a7e1ed7c0783ed7d5ce53a5383bf9b06c2e11e28..caaa234d82b14a59dedb8f9d12a08168be34c674 100644 (file)
@@ -51,6 +51,11 @@ public:
   HYDROGUI_DataModel( CAM_Module* theModule );
   virtual ~HYDROGUI_DataModel();
 
+  /**
+   * Creates the document into the data model. Reimplemented.
+   */
+  virtual bool create( CAM_Study* );
+
   /**
    * Open the document into the data model. Reimplemented.
    * \param theURL opened study path
@@ -369,6 +374,8 @@ protected:
   static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather,
                                            const QString& theName );
 
+  void updateDocument();
+
 protected:
   QString myStudyURL; ///< the saved/opened document URL
   QByteArray myStates;
index 5240b42d86bdcbdbcd2879078db995073d854b55..7923e48587e211572b9fcfe33657435713a37d24 100644 (file)
@@ -106,15 +106,16 @@ void HYDROGUI_LandCoverOp::startOperation()
     if ( !aStricklerTableObj.IsNull() )
     {
       // Get Strickler table data from the data model
-      TColStd_SequenceOfExtendedString aTypes = aStricklerTableObj->GetTypes();
-      for ( int i = 1; i <= aTypes.Length(); i++ )
+      QStringList aTypes = aStricklerTableObj->GetTypes();
+      for ( QStringList::iterator it = aTypes.begin(); it != aTypes.end(); ++it )
       {
-        QString aType = HYDROGUI_Tool::ToQString( aTypes.Value( i ) );
-        if ( !aType.isEmpty() && !aStricklerTypes.contains( aType ))
+        QString aType = *it;
+        if ( !aType.isEmpty() && !aStricklerTypes.contains( aType ) )
           aStricklerTypes.append( aType );
       }
     }
   }
+
   aStricklerTypes.sort();
   aPanel->setAdditionalParams( aStricklerTypes );
 
index f84dcebf8d79af10b4d97c896f4ad2ec7b0e8421..d684d927846e2ee1a89c3f978727d74ec3f421bf 100644 (file)
@@ -664,6 +664,12 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         theMenu->addSeparator();
       }
 
+      if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
+      {
+        theMenu->addAction( action( PolylineExtraction ) );
+        theMenu->addSeparator();
+      }
+
       // Add set color action for geometrical objects
       if ( anIsObjectCanBeColored )
       {
@@ -786,6 +792,19 @@ void HYDROGUI_Module::createPreferences()
   setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
 }
 
+void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref )
+{
+    if ( theSection == "preferences" && thePref == "default_strickler_coefficient" )
+    {
+        SUIT_ResourceMgr* resMgr = application()->resourceMgr();
+        Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
+        if ( resMgr && !aDoc.IsNull() )
+            aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) );
+    }
+    else
+        LightApp_Module::preferencesChanged( theSection, thePref );
+}
+
 QCursor HYDROGUI_Module::getPrefEditCursor() const
 {
   int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
@@ -1316,6 +1335,11 @@ void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
 }
 /////////////////// END OF VTKPrs PROCESSING
 
+void HYDROGUI_Module::clearCache()
+{
+    myObjectStateMap.clear();
+}
+
 CAM_DataModel* HYDROGUI_Module::createDataModel()
 {
   return new HYDROGUI_DataModel( this );
index a1a0bd540b92a5e0e6dfa4a5cc640d0ab14738fa..28020c12cbfb20f58f610608fd0a2e9a74872eff 100644 (file)
@@ -147,6 +147,9 @@ public:
   void                            setObjectVisible( const int theViewId,
                                                     const Handle(HYDROData_Entity)& theObject,
                                                     const bool theState );
+
+  virtual void                    preferencesChanged( const QString&, const QString& );
+
   /** 
    * Set IsToUpdate flag for all presentations of the given object to recompute them during 
    * the next viewer(s) updating.
@@ -204,6 +207,8 @@ public:
    */
   QCursor                         getPrefEditCursor() const;
 
+  void                            clearCache();
+
 protected:
   CAM_DataModel*                  createDataModel();
 
index 0a96e7986f8f9afffa28f14b8c0a29c913bfe757..109b1a55de78cfa9fd7a981e8e9bab284b91ed1a 100644 (file)
@@ -61,6 +61,7 @@
 #include "HYDROGUI_StricklerTableOp.h"
 #include "HYDROGUI_DuplicateOp.h"
 #include "HYDROGUI_LandCoverOp.h"
+#include "HYDROGUI_PolylineExtractionOp.h"
 
 #include <HYDROData_Document.h>
 #include <HYDROData_Obstacle.h>
@@ -202,6 +203,7 @@ void HYDROGUI_Module::createActions()
   createAction( SubmersibleId, "SUBMERSIBLE", "SUBMERSIBLE_ICO" );
   createAction( ExportPolylineId, "EXPORT_POLYLINE", "EXPORT_POLYLINE_ICO" );
 
+  createAction( PolylineExtraction, "POLYLINE_EXTRACTION" );
 }
 
 void HYDROGUI_Module::createMenus()
@@ -573,6 +575,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case SubmersibleId:
     anOp = new HYDROGUI_SubmersibleOp( aModule );
     break;
+  case PolylineExtraction:
+    anOp = new HYDROGUI_PolylineExtractionOp( aModule );
+    break;
   }
 
   if( !anOp )
index e9d10c02a64d6113ea30002b101de3dde8bfdd95..ab4219acb90604c3f56ab15a1d83f66d488daf97 100644 (file)
@@ -117,7 +117,9 @@ enum OperationId
   DuplicateStricklerTableId,
 
   CreateLandCoverId,
-  EditLandCoverId
+  EditLandCoverId,
+
+  PolylineExtraction
 };
 
 #endif
index 7f021249af4ac11fc8a8be0fdbb1fcebf164a77d..289bfb90625257bd8eae50fad2c0abfe1ffd4d5d 100644 (file)
@@ -60,10 +60,9 @@ void HYDROGUI_StricklerTableOp::startOperation()
 
             // Get Strickler table data from the data model
             HYDROGUI_StricklerTableDlg::StricklerCoefficientList aData;
-            TColStd_SequenceOfExtendedString aTypes = myObject->GetTypes();
-            for ( int i = 1; i <= aTypes.Length(); i++ )
-                aData.append( HYDROGUI_StricklerTableDlg::StricklerCoefficient( HYDROGUI_Tool::ToQString( aTypes.Value( i ) ),
-                myObject->Get( aTypes.Value( i ), 0 ) ) );
+            QStringList aTypes = myObject->GetTypes();
+            for ( QStringList::iterator it = aTypes.begin(); it != aTypes.end(); ++it )
+                aData.append( HYDROGUI_StricklerTableDlg::StricklerCoefficient( *it, myObject->Get( *it, 0 ) ) );
 
             aPanel->setData( aData );
         }
@@ -164,7 +163,7 @@ bool HYDROGUI_StricklerTableOp::processApply( int& theUpdateFlags, QString& theE
         for ( HYDROGUI_StricklerTableDlg::StricklerCoefficientList::iterator it = aData.begin(); it != aData.end(); ++it )
         {
             const HYDROGUI_StricklerTableDlg::StricklerCoefficient& anInfo = *it;
-            aStricklerTableObj->Set( HYDROGUI_Tool::ToExtString( anInfo.myType ), anInfo.myCoefficient );
+            aStricklerTableObj->Set( anInfo.myType, anInfo.myCoefficient );
         }
     }
     else
index cd000f86aa7706eb24c603910449c4a0d6b148e3..75dfb7f26ff96b7c7aed04ca0a855b2f698a6d42 100644 (file)
@@ -1014,6 +1014,11 @@ Would you like to remove all references from the image?</translation>
       <source>DSK_EXPORT_POLYLINE</source>
       <translation>Export Polyline</translation>
     </message>
+    <message>
+      <source>DSK_POLYLINE_EXTRACTION</source>
+      <translation>Extracts the polyline from selected object</translation>
+    </message>
+
     <message>
       <source>MEN_CREATE_CALCULATION</source>
       <translation>Create calculation case</translation>
@@ -1306,6 +1311,10 @@ Would you like to remove all references from the image?</translation>
       <source>MEN_EXPORT_POLYLINE</source>
       <translation>Export Polyline</translation>
     </message>
+    <message>
+      <source>MEN_POLYLINE_EXTRACTION</source>
+      <translation>Polyline extraction</translation>
+    </message>
 
     <message>
       <source>STB_CREATE_CALCULATION</source>
@@ -1559,6 +1568,10 @@ Would you like to remove all references from the image?</translation>
       <source>STB_EDIT_LOCAL_CS</source>
       <translation>Change local CS</translation>
     </message>
+    <message>
+      <source>STB_POLYLINE_EXTRACTION</source>
+      <translation>Polyline extractions</translation>
+    </message>
 
     <message>
       <source>MEN_CREATE_STREAM_BOTTOM</source>
@@ -2725,4 +2738,12 @@ Polyline should consist from one not closed curve.</translation>
     </message>
   </context>
 
+  <context>
+    <name>HYDROGUI_PolylineExtractionOp</name>
+    <message>
+      <source>POLYLINE_EXTRACTION</source>
+      <translation>Polyline extraction</translation>
+    </message>
+  </context>
+
 </TS>
index 9353e093bac8cd998cbd5f26e2e2441ebb0e15c0..ffe3b6250f710dd6250b52d2cb9866b19931ab45 100644 (file)
@@ -44,6 +44,7 @@ SET(_link_LIBRARIES
 #   HYDROData_ImmersibleZone.sip
 #   HYDROData_Zone.sip
 #   HYDROData_Region.sip
+#   HYDROData_StricklerTable.sip
 #   HYDROData_CalculationCase.sip
 #   HYDROData_Document.sip
 # )
@@ -56,8 +57,8 @@ SET(_sip_files
 SET(_sip_files2
   CAS/gp_XY.sip
   CAS/gp_XYZ.sip
-  CAS/TCollection_AsciiString.sip
   CAS/NCollection_Sequence.sip
+  CAS/TCollection_AsciiString.sip
   HYDROData_SequenceOfObjects.sip
   HYDROData_IInterpolator.sip
   HYDROData_Entity.sip
@@ -86,6 +87,7 @@ SET(_sip_files2
   HYDROData_ImmersibleZone.sip
   HYDROData_Zone.sip
   HYDROData_Region.sip
+  HYDROData_StricklerTable.sip
   HYDROData_CalculationCase.sip
   HYDROData_Document.sip
   HYDROData_Application.sip
index 4087df721bfb62d55d6605ebccf4f2e36e55161f..e0235298104c1c8a62653d7ec2941cc0dcc183a1 100644 (file)
@@ -45,8 +45,8 @@
 
 %Include CAS/gp_XY.sip
 %Include CAS/gp_XYZ.sip
-%Include CAS/TCollection_AsciiString.sip
 %Include CAS/NCollection_Sequence.sip
+%Include CAS/TCollection_AsciiString.sip
 %Include HYDROData_SequenceOfObjects.sip
 %Include HYDROData_IInterpolator.sip
 %Include HYDROData_Entity.sip
@@ -78,6 +78,7 @@
 %Include HYDROData_Region.sip
 %Include HYDROData_CalculationCase.sip
 %Include HYDROData_IProfilesInterpolator.sip
+%Include HYDROData_StricklerTable.sip
 
 %Include HYDROData_Document.sip
 %Include HYDROData_Application.sip
index df0279af4021698366809d39d33d57365f2ebad2..e6d32a8d4744e581d57c2a6a9abcd935f9aba6bf 100644 (file)
@@ -316,6 +316,22 @@ public:
 public:      
   // Public methods to work with Calculation services
 
+  /**
+   * Returns strickler coefficient for given point.
+   * \param thePoint the point to examine
+   * \return result strickler coefficient
+   */
+  double GetStricklerCoefficientForPoint( const double theCoordX,
+                                          const double theCoordY ) const [double ( const gp_XY& ) ];
+  %MethodCode
+    gp_XY aPnt( a0, a1 );
+  
+    Py_BEGIN_ALLOW_THREADS
+    sipRes = sipSelfWasArg ? sipCpp->HYDROData_CalculationCase::GetStricklerCoefficientForPoint( aPnt ) : 
+                             sipCpp->GetStricklerCoefficientForPoint( aPnt );
+    Py_END_ALLOW_THREADS
+  %End
+
   /**
    * Returns altitude for given point.
    * \param thePoint the point to examine
index 5e5755ae8c2a581c58acb5ff5e50767079e3af3a..584b11dd5e0fb5485a37a97443101c225f61cc5a 100644 (file)
@@ -163,6 +163,11 @@ class HYDROData_Document
         aRes = new HYDROData_StreamAltitude( *dynamic_cast<HYDROData_StreamAltitude*>( theObject ) );
         break;
       }
+      case KIND_STRICKLER_TABLE:
+      {
+        aRes = new HYDROData_StricklerTable( *dynamic_cast<HYDROData_StricklerTable*>( theObject ) );
+        break;
+      }
     }
     
     return aRes;
index 9c4bf4fd013772f42f924ddb09c2b24ac2e65fb3..9dc1676ed2653049d725949cfc06f4b36fcfdd28 100644 (file)
@@ -43,6 +43,7 @@ const ObjectKind KIND_REGION;
 const ObjectKind KIND_SHAPES_GROUP;
 const ObjectKind KIND_SPLITTED_GROUP;
 const ObjectKind KIND_OBSTACLE_ALTITUDE;
+const ObjectKind KIND_STRICKLER_TABLE;
 
 class HYDROData_Entity
 {
@@ -138,6 +139,10 @@ class HYDROData_Entity
         sipClass = sipClass_HYDROData_ObstacleAltitude;
         break;
 
+      case KIND_STRICKLER_TABLE:
+        sipClass = sipClass_HYDROData_StricklerTable;
+        break;
+
       case KIND_UNKNOWN:
         sipClass = sipClass_HYDROData_Entity;
         break;
diff --git a/src/HYDROPy/HYDROData_StricklerTable.sip b/src/HYDROPy/HYDROData_StricklerTable.sip
new file mode 100644 (file)
index 0000000..60a0380
--- /dev/null
@@ -0,0 +1,69 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%ExportedHeaderCode
+#include <HYDROData_StricklerTable.h>
+#include <TColStd_SequenceOfExtendedString.hxx>
+%End
+
+class HYDROData_StricklerTable : public HYDROData_Entity
+{
+
+%ConvertToSubClassCode
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_STRICKLER_TABLE:
+        sipClass = sipClass_HYDROData_StricklerTable;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
+%End
+
+%TypeHeaderCode
+#include <HYDROData_StricklerTable.h>
+%End
+
+public:      
+
+  bool Import( const TCollection_AsciiString& theFileName );
+  bool Export( const TCollection_AsciiString& theFileName );
+
+  double Get( const QString& theType, double theDefault ) const;
+  void Set( const QString& theType, double theCoefficient );
+
+  QStringList GetTypes() const;
+
+  void Clear();
+
+protected:
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDROData_StricklerTable();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  ~HYDROData_StricklerTable();
+};
+
+