From 601ba929ac67172be1c1d9639c515c61e97010e8 Mon Sep 17 00:00:00 2001 From: asl Date: Mon, 19 Oct 2015 15:18:11 +0300 Subject: [PATCH] methods to get index and change Strickler type via the iterator --- src/HYDROData/HYDROData_LandCoverMap.cxx | 27 +++++++++++++++++++++++- src/HYDROData/HYDROData_LandCoverMap.h | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index 2e7ffffa..575f94d5 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -90,8 +90,9 @@ void HYDROData_LandCoverMap::Iterator::Init( const HYDROData_LandCoverMap& theMa myIterator = 0; else myIterator = new TopoDS_Iterator( aShape ); - myIndex = 0; + theMap.myLab.FindChild( DataTag_Types ).FindAttribute( TDataStd_ExtStringArray::GetID(), myArray ); + myIndex = myArray->Lower(); } /** @@ -102,6 +103,18 @@ HYDROData_LandCoverMap::Iterator::~Iterator() delete myIterator; } +/** + Return the current 0-based index of the iterator + @return the current index +*/ +int HYDROData_LandCoverMap::Iterator::Index() const +{ + if( myArray.IsNull() ) + return -1; + else + return myIndex - myArray->Lower(); +} + /** Return if the iterator has more elements @return if the iterator has more elements @@ -147,6 +160,18 @@ QString HYDROData_LandCoverMap::Iterator::StricklerType() const return HYDROData_Tool::toQString( myArray->Value( myIndex ) ); } +/** + Set the Strickler type for the current land cover + @param theType the Strickler type +*/ +void HYDROData_LandCoverMap::Iterator::SetStricklerType( const QString& theType ) +{ + if( myArray.IsNull() || myIndex < myArray->Lower() || myIndex > myArray->Upper() ) + return; + else + myArray->SetValue( myIndex, HYDROData_Tool::toExtString( theType ) ); +} + /** Constructor */ diff --git a/src/HYDROData/HYDROData_LandCoverMap.h b/src/HYDROData/HYDROData_LandCoverMap.h index fad2aceb..ce8fd88c 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@ -57,8 +57,10 @@ public: bool More() const; void Next(); + int Index() const; TopoDS_Face Face() const; QString StricklerType() const; + void SetStricklerType( const QString& ); private: TopoDS_Iterator* myIterator; -- 2.39.2