From 09203a28a524e987ab86ad2c85026555e4f37c98 Mon Sep 17 00:00:00 2001 From: stv Date: Fri, 26 Jun 2015 10:56:18 +0300 Subject: [PATCH] #571 - Land Cover: calculation of Strickler coefficient #572 - Extraction of polylines #563 - Strickler table: dump to Python (bug fixing) #599 - Incorrect behavior of 'eyes' in Object browser after reloading python script --- src/HYDROData/HYDROData_CalculationCase.cxx | 32 ++++++++++ src/HYDROData/HYDROData_CalculationCase.h | 7 +++ src/HYDROData/HYDROData_Document.cxx | 28 +++++++++ src/HYDROData/HYDROData_Document.h | 8 ++- src/HYDROData/HYDROData_StricklerTable.cxx | 39 +++++++++--- src/HYDROData/HYDROData_StricklerTable.h | 10 ++- src/HYDROGUI/CMakeLists.txt | 14 +++-- src/HYDROGUI/HYDROGUI_DataModel.cxx | 31 +++++++-- src/HYDROGUI/HYDROGUI_DataModel.h | 7 +++ src/HYDROGUI/HYDROGUI_LandCoverOp.cxx | 9 +-- src/HYDROGUI/HYDROGUI_Module.cxx | 24 +++++++ src/HYDROGUI/HYDROGUI_Module.h | 5 ++ src/HYDROGUI/HYDROGUI_Operations.cxx | 5 ++ src/HYDROGUI/HYDROGUI_Operations.h | 4 +- src/HYDROGUI/HYDROGUI_StricklerTableOp.cxx | 9 ++- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 21 +++++++ src/HYDROPy/CMakeLists.txt | 4 +- src/HYDROPy/HYDROData.sip | 3 +- src/HYDROPy/HYDROData_CalculationCase.sip | 16 +++++ src/HYDROPy/HYDROData_Document.sip | 5 ++ src/HYDROPy/HYDROData_Entity.sip | 5 ++ src/HYDROPy/HYDROData_StricklerTable.sip | 69 +++++++++++++++++++++ 22 files changed, 320 insertions(+), 35 deletions(-) create mode 100644 src/HYDROPy/HYDROData_StricklerTable.sip diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 72db9915..f8640f81 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -893,6 +893,38 @@ NCollection_Sequence 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 { diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index 9d84b3d4..97c6a35c 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -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 diff --git a/src/HYDROData/HYDROData_Document.cxx b/src/HYDROData/HYDROData_Document.cxx index 44b9fb60..55912ca6 100644 --- a/src/HYDROData/HYDROData_Document.cxx +++ b/src/HYDROData/HYDROData_Document.cxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -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 { diff --git a/src/HYDROData/HYDROData_Document.h b/src/HYDROData/HYDROData_Document.h index 4c57cbc0..9394f1b6 100644 --- a/src/HYDROData/HYDROData_Document.h +++ b/src/HYDROData/HYDROData_Document.h @@ -218,8 +218,14 @@ public: //! Get list of registered interpolator names. HYDRODATA_EXPORT NCollection_Sequence 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; diff --git a/src/HYDROData/HYDROData_StricklerTable.cxx b/src/HYDROData/HYDROData_StricklerTable.cxx index 68995e82..279ecaea 100644 --- a/src/HYDROData/HYDROData_StricklerTable.cxx +++ b/src/HYDROData/HYDROData_StricklerTable.cxx @@ -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() ); +} diff --git a/src/HYDROData/HYDROData_StricklerTable.h b/src/HYDROData/HYDROData_StricklerTable.h index bbc553be..a70e9f71 100644 --- a/src/HYDROData/HYDROData_StricklerTable.h +++ b/src/HYDROData/HYDROData_StricklerTable.h @@ -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; }; diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 684e5634..2f647b72 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -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( diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 1eaef34b..aed8f8a7 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -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( 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 ) ); +} diff --git a/src/HYDROGUI/HYDROGUI_DataModel.h b/src/HYDROGUI/HYDROGUI_DataModel.h index a7e1ed7c..caaa234d 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.h +++ b/src/HYDROGUI/HYDROGUI_DataModel.h @@ -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; diff --git a/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx b/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx index 5240b42d..7923e485 100644 --- a/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx +++ b/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx @@ -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 ); diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index f84dcebf..d684d927 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -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 ); diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index a1a0bd54..28020c12 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -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(); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 0a96e798..109b1a55 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -61,6 +61,7 @@ #include "HYDROGUI_StricklerTableOp.h" #include "HYDROGUI_DuplicateOp.h" #include "HYDROGUI_LandCoverOp.h" +#include "HYDROGUI_PolylineExtractionOp.h" #include #include @@ -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 ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index e9d10c02..ab4219ac 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -117,7 +117,9 @@ enum OperationId DuplicateStricklerTableId, CreateLandCoverId, - EditLandCoverId + EditLandCoverId, + + PolylineExtraction }; #endif diff --git a/src/HYDROGUI/HYDROGUI_StricklerTableOp.cxx b/src/HYDROGUI/HYDROGUI_StricklerTableOp.cxx index 7f021249..289bfb90 100644 --- a/src/HYDROGUI/HYDROGUI_StricklerTableOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StricklerTableOp.cxx @@ -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 diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index cd000f86..75dfb7f2 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1014,6 +1014,11 @@ Would you like to remove all references from the image? DSK_EXPORT_POLYLINE Export Polyline + + DSK_POLYLINE_EXTRACTION + Extracts the polyline from selected object + + MEN_CREATE_CALCULATION Create calculation case @@ -1306,6 +1311,10 @@ Would you like to remove all references from the image? MEN_EXPORT_POLYLINE Export Polyline + + MEN_POLYLINE_EXTRACTION + Polyline extraction + STB_CREATE_CALCULATION @@ -1559,6 +1568,10 @@ Would you like to remove all references from the image? STB_EDIT_LOCAL_CS Change local CS + + STB_POLYLINE_EXTRACTION + Polyline extractions + MEN_CREATE_STREAM_BOTTOM @@ -2725,4 +2738,12 @@ Polyline should consist from one not closed curve. + + HYDROGUI_PolylineExtractionOp + + POLYLINE_EXTRACTION + Polyline extraction + + + diff --git a/src/HYDROPy/CMakeLists.txt b/src/HYDROPy/CMakeLists.txt index 9353e093..ffe3b625 100644 --- a/src/HYDROPy/CMakeLists.txt +++ b/src/HYDROPy/CMakeLists.txt @@ -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 diff --git a/src/HYDROPy/HYDROData.sip b/src/HYDROPy/HYDROData.sip index 4087df72..e0235298 100644 --- a/src/HYDROPy/HYDROData.sip +++ b/src/HYDROPy/HYDROData.sip @@ -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 diff --git a/src/HYDROPy/HYDROData_CalculationCase.sip b/src/HYDROPy/HYDROData_CalculationCase.sip index df0279af..e6d32a8d 100644 --- a/src/HYDROPy/HYDROData_CalculationCase.sip +++ b/src/HYDROPy/HYDROData_CalculationCase.sip @@ -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 diff --git a/src/HYDROPy/HYDROData_Document.sip b/src/HYDROPy/HYDROData_Document.sip index 5e5755ae..584b11dd 100644 --- a/src/HYDROPy/HYDROData_Document.sip +++ b/src/HYDROPy/HYDROData_Document.sip @@ -163,6 +163,11 @@ class HYDROData_Document aRes = new HYDROData_StreamAltitude( *dynamic_cast( theObject ) ); break; } + case KIND_STRICKLER_TABLE: + { + aRes = new HYDROData_StricklerTable( *dynamic_cast( theObject ) ); + break; + } } return aRes; diff --git a/src/HYDROPy/HYDROData_Entity.sip b/src/HYDROPy/HYDROData_Entity.sip index 9c4bf4fd..9dc1676e 100644 --- a/src/HYDROPy/HYDROData_Entity.sip +++ b/src/HYDROPy/HYDROData_Entity.sip @@ -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 index 00000000..60a03804 --- /dev/null +++ b/src/HYDROPy/HYDROData_StricklerTable.sip @@ -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 +#include +%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 +%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(); +}; + + -- 2.39.2