+
+TDF_Label HYDROData_Document::LabelOfLocalCS() const
+{
+ return myDoc->Main().FindChild(TAG_LOCAL_CS);
+}
+
+void HYDROData_Document::GetLocalCS( double& theLX, double& theLY ) const
+{
+ TDF_Label aLocalCSLab = LabelOfLocalCS();
+
+ Handle( TDataXtd_Position ) aLocalCS;
+ if( aLocalCSLab.FindAttribute( TDataXtd_Position::GetID(), aLocalCS ) )
+ {
+ gp_Pnt aLocalCS3d = aLocalCS->GetPosition();
+ theLX = aLocalCS3d.X();
+ theLY = aLocalCS3d.Y();
+ }
+ else
+ {
+ theLX = DEFAULT_LOCAL_CS.X();
+ theLY = DEFAULT_LOCAL_CS.Y();
+ }
+}
+
+void HYDROData_Document::SetLocalCS( double theLX, double theLY )
+{
+ UpdateLCSFields();
+
+ // update the local CS data in attribute
+ TDF_Label aLocalCSLab = LabelOfLocalCS();
+ Handle( TDataXtd_Position ) aLocalCS;
+ if( !aLocalCSLab.FindAttribute( TDataXtd_Position::GetID(), aLocalCS ) )
+ aLocalCS = TDataXtd_Position::Set( aLocalCSLab );
+
+ gp_Pnt aLocalCS3d( theLX, theLY, 0 );
+ aLocalCS->SetPosition( aLocalCS3d );
+
+ // calculate delta for coordinates
+ double aDX = myLX - theLX;
+ double aDY = myLY - theLY;
+
+ // update the local CS data in internal fields
+ myLX = theLX;
+ myLY = theLY;
+
+ //update all objects in the document
+ HYDROData_Iterator anIterator( this, KIND_UNKNOWN );
+ for( ; anIterator.More(); anIterator.Next() )
+ anIterator.Current()->UpdateLocalCS( aDX, aDY );
+}
+
+void HYDROData_Document::UpdateLCSFields() const
+{
+ if( myLX >= 0 && myLY >= 0 )
+ return;
+
+ double aLX, aLY;
+ GetLocalCS( aLX, aLY );
+ HYDROData_Document* aThat = const_cast<HYDROData_Document*>( this );
+ aThat->myLX = aLX;
+ aThat->myLY = aLY;
+}
+
+void HYDROData_Document::Transform( double& X, double& Y, bool IsToLocalCS ) const
+{
+ UpdateLCSFields();
+ if( IsToLocalCS )
+ {
+ X -= myLX;
+ Y -= myLY;
+ }
+ else
+ {
+ X += myLX;
+ Y += myLY;
+ }
+}
+
+void HYDROData_Document::Transform( gp_Pnt& thePnt, bool IsToLocalCS ) const
+{
+ double X = thePnt.X();
+ double Y = thePnt.Y();
+ double Z = thePnt.Z();
+ Transform( X, Y, IsToLocalCS );
+ thePnt = gp_Pnt( X, Y, Z );
+}
+
+void HYDROData_Document::Transform( gp_XYZ& thePnt, bool IsToLocalCS ) const
+{
+ double X = thePnt.X();
+ double Y = thePnt.Y();
+ double Z = thePnt.Z();
+ Transform( X, Y, IsToLocalCS );
+ thePnt = gp_XYZ( X, Y, Z );
+}
+
+void HYDROData_Document::Transform( double& X, double& Y, double& Z, bool IsToLocalCS ) const
+{
+ Transform( X, Y, IsToLocalCS );
+}
+
+void HYDROData_Document::Transform( gp_XY& thePnt, bool IsToLocalCS ) const
+{
+ double X = thePnt.X();
+ double Y = thePnt.Y();
+ Transform( X, Y, IsToLocalCS );
+ thePnt = gp_XY( X, Y );
+}
+
+HYDROData_InterpolatorsFactory* HYDROData_Document::GetInterpolatorsFactory()
+{
+ if ( !myInterpolatorsFactory ) {
+ myInterpolatorsFactory = new HYDROData_InterpolatorsFactory();
+ }
+
+ return myInterpolatorsFactory;
+}
+
+HYDROData_IProfilesInterpolator* HYDROData_Document::GetInterpolator( const TCollection_AsciiString& theName ) const
+{
+ HYDROData_IProfilesInterpolator* anInterpolator = NULL;
+
+ HYDROData_Document* aThat = const_cast<HYDROData_Document*>( this );
+ HYDROData_InterpolatorsFactory* aFactory = aThat->GetInterpolatorsFactory();
+ if ( aFactory ) {
+ anInterpolator = aFactory->GetInterpolator( theName );
+ }
+
+ return anInterpolator;
+}
+
+NCollection_Sequence<TCollection_AsciiString> HYDROData_Document::GetInterpolatorNames() const
+{
+ NCollection_Sequence<TCollection_AsciiString> aNames;
+
+ HYDROData_Document* aThat = const_cast<HYDROData_Document*>( this );
+ HYDROData_InterpolatorsFactory* aFactory = aThat->GetInterpolatorsFactory();
+ if ( aFactory ) {
+ aNames = aFactory->GetInterpolatorNames();
+ }
+
+ return aNames;
+}
+
+QColor HYDROData_Document::GetAssociatedColor( const QString& theStricklerType, const Handle(HYDROData_StricklerTable)& theTable ) const
+{
+ if( !theTable.IsNull() && theTable->HasType( theStricklerType ) )
+ return theTable->GetColor( theStricklerType );
+
+ HYDROData_Iterator anIt( this, KIND_STRICKLER_TABLE );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ Handle(HYDROData_StricklerTable) aTable = Handle(HYDROData_StricklerTable)::DownCast( anIt.Current() );
+ if( aTable->HasType( theStricklerType ) )
+ return aTable->GetColor( theStricklerType );
+ }
+ return QColor();
+}
+
+void HYDROData_Document::CollectQGISValues( const QString& theAttrName,
+ QStringList& theAttrValues,
+ QStringList& theStricklerTypes ) const
+{
+ HYDROData_Iterator It( this, KIND_STRICKLER_TABLE );
+ for( ; It.More(); It.Next() )
+ {
+ Handle(HYDROData_StricklerTable) aTable = Handle(HYDROData_StricklerTable)::DownCast( It.Current() );
+ if( !aTable.IsNull() && aTable->GetAttrName()==theAttrName )
+ {
+ theAttrValues.clear();
+ theStricklerTypes = aTable->GetTypes();
+ foreach( QString aType, theStricklerTypes )
+ {
+ QString anAttrValue = aTable->GetAttrValue( aType );
+ theAttrValues.append( anAttrValue );
+ }
+ }
+ }
+}