1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include <HYDROData_Document.h>
20 #include <HYDROData_Application.h>
21 #include <HYDROData_Iterator.h>
22 #include <HYDROData_Tool.h>
23 #include <HYDROData_InterpolatorsFactory.h>
24 #include <HYDROData_StricklerTable.h>
25 #include <HYDROData_LandCoverMap.h>
27 #include <TDataStd_Real.hxx>
28 #include <TDataStd_Integer.hxx>
29 #include <TDataXtd_Position.hxx>
31 #include <TDF_Delta.hxx>
36 #include <QStringList>
37 #include <QTextStream>
40 IMPLEMENT_STANDARD_HANDLE(HYDROData_Document,MMgt_TShared)
41 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Document,MMgt_TShared)
43 #define PYTHON_DOC_NAME "hydro_doc"
45 static const int UNDO_LIMIT = 10; // number of possible undo operations in the module
47 static const int TAG_PROPS = 1; // general properties tag
48 static const int TAG_PROPS_NEW_ID = 1; // general properties: tag for storage of the new object ID
49 static const int TAG_OBJECTS = 2; // tag of the objects sub-tree
50 static const int TAG_HISTORY = 3; // tag of the history sub-tree (Root for History)
51 static const int TAG_LOCAL_CS = 4; // tag of local coordinate system information
52 static const int TAG_DEF_STRICKLER_COEFF = 5; // tag of default strickler coefficient
53 static const gp_Pnt2d DEFAULT_LOCAL_CS( 0, 0 );
57 typedef QMap<Standard_Integer,Handle_HYDROData_Entity> MapOfOrdered;
58 typedef QMap<QString,Handle_HYDROData_Entity> MapOfUnordered;
60 Handle(HYDROData_Document) HYDROData_Document::Document(const int theStudyID)
62 Handle(HYDROData_Document) aResult =
63 HYDROData_Application::GetApplication()->GetDocument(theStudyID);
64 if (aResult.IsNull()) {
65 aResult = new HYDROData_Document();
66 HYDROData_Application::GetApplication()->AddDocument(theStudyID, aResult);
71 Handle(HYDROData_Document) HYDROData_Document::Document(
72 const TDF_Label& theObjectLabel )
74 Handle(HYDROData_Document) aResDoc;
75 if ( theObjectLabel.IsNull() )
78 Handle(TDocStd_Document) anObjDoc;
81 anObjDoc = TDocStd_Document::Get( theObjectLabel );
87 if ( anObjDoc.IsNull() )
90 HYDROData_Application* anApp = HYDROData_Application::GetApplication();
92 DataMapOfStudyIDDocument::Iterator aMapIt( anApp->myDocuments );
93 for ( ; aMapIt.More(); aMapIt.Next() )
95 Handle(HYDROData_Document) anAppDoc = aMapIt.Value();
96 if ( anAppDoc.IsNull() || anAppDoc->myDoc != anObjDoc )
106 bool HYDROData_Document::HasDocument(const int theStudyID)
108 Handle(HYDROData_Document) aResult =
109 HYDROData_Application::GetApplication()->GetDocument(theStudyID);
110 return !aResult.IsNull();
113 bool HYDROData_Document::DocumentId(const Handle(HYDROData_Document)& theDocument,
116 return HYDROData_Application::GetApplication()->GetDocumentId(theDocument, theDocId);
119 Data_DocError HYDROData_Document::Load(const char* theFileName, const int theStudyID)
121 Handle(TDocStd_Document) aResult;
122 TCollection_ExtendedString aPath ((const Standard_CString)theFileName);
123 PCDM_ReaderStatus aStatus = (PCDM_ReaderStatus) -1;
126 aStatus = HYDROData_Application::GetApplication()->Open (aPath, aResult);
128 catch (Standard_Failure)
130 if (!aResult.IsNull()) {
131 aResult->SetUndoLimit(UNDO_LIMIT);
132 HYDROData_Application::GetApplication()->AddDocument(theStudyID, new HYDROData_Document(aResult));
135 Data_DocError anError;
138 anError = DocError_OK;
140 case PCDM_RS_NoDriver:
141 case PCDM_RS_UnknownFileDriver:
142 case PCDM_RS_NoSchema:
143 case PCDM_RS_DriverFailure:
144 case PCDM_RS_WrongResource:
145 anError = DocError_ResourcesProblem;
147 case PCDM_RS_OpenError:
148 case PCDM_RS_NoDocument:
149 case PCDM_RS_WrongStreamMode:
150 case PCDM_RS_PermissionDenied:
151 anError = DocError_CanNotOpen;
153 case PCDM_RS_NoVersion:
154 anError = DocError_InvalidVersion;
156 case PCDM_RS_ExtensionFailure:
157 case PCDM_RS_FormatFailure:
158 case PCDM_RS_TypeFailure:
159 case PCDM_RS_TypeNotFoundInSchema:
160 case PCDM_RS_UnrecognizedFileFormat:
161 anError = DocError_InvalidFormat;
163 case PCDM_RS_MakeFailure:
165 anError = DocError_UnknownProblem;
171 Data_DocError HYDROData_Document::Save(const char* theFileName)
173 TCollection_ExtendedString aPath ((const Standard_CString)theFileName);
174 PCDM_StoreStatus aStatus;
176 aStatus = HYDROData_Application::GetApplication()->SaveAs (myDoc, aPath);
178 catch (Standard_Failure) {}
179 myTransactionsAfterSave = 0;
180 Standard::Purge(); // Release free memory
183 Data_DocError anError;
186 anError = DocError_OK;
188 case PCDM_SS_DriverFailure:
189 anError = DocError_ResourcesProblem;
191 case PCDM_SS_WriteFailure:
192 //case PCDM_SS_DiskWritingFailure:
193 //case PCDM_SS_UserRightsFailure:
194 anError = DocError_CanNotOpen;
197 anError = DocError_UnknownProblem;
203 void HYDROData_Document::Close()
206 HYDROData_Application::GetApplication()->RemoveDocument(this);
209 double HYDROData_Document::GetDefaultStricklerCoefficient() const
212 TDF_Label aLabel = myDoc->Main().FindChild(TAG_DEF_STRICKLER_COEFF, Standard_False);
213 if ( !aLabel.IsNull() )
215 Handle(TDataStd_Real) anAttr;
216 if ( aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
217 aRes = anAttr->Get();
223 void HYDROData_Document::SetDefaultStricklerCoefficient( double theCoeff ) const
225 TDF_Label aLabel = myDoc->Main().FindChild(TAG_DEF_STRICKLER_COEFF);
226 if ( !aLabel.IsNull() )
228 Handle(TDataStd_Real) anAttr;
229 if ( !aLabel.FindAttribute( TDataStd_Real::GetID(), anAttr ) )
230 aLabel.AddAttribute( anAttr = new TDataStd_Real() );
231 anAttr->Set( theCoeff );
235 bool HYDROData_Document::DumpToPython( const QString& theFileName,
236 const bool theIsMultiFile ) const
238 // Try to open the file
239 QFile aFile( theFileName );
240 if ( !aFile.open( QIODevice::WriteOnly ) )
243 MapOfTreatedObjects aTreatedObjects;
245 // Dump header for python script
246 QStringList aHeaderDump = DumpToPython( aTreatedObjects, theIsMultiFile );
247 if ( aHeaderDump.isEmpty() )
250 HYDROData_Tool::WriteStringsToFile( aFile, aHeaderDump );
254 // Dump the local CS data to Python
256 QString aLCS = QString( "%1.SetLocalCS( %2, %3 )" ).arg( GetDocPyName() ).arg( myLX ).arg( myLY );
259 HYDROData_Tool::WriteStringsToFile( aFile, QStringList() << aLCS );
261 // Dump all model objects to Python script
262 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_IMAGE );
263 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_STRICKLER_TABLE );
264 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_POLYLINEXY );
265 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_BATHYMETRY );
266 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_PROFILE );
267 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_POLYLINE );
268 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_IMMERSIBLE_ZONE );
269 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_STREAM );
270 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_CHANNEL );
271 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_DIGUE );
272 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_OBSTACLE );
273 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_LAND_COVER_MAP );
274 aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_CALCULATION );
276 // Dump code to close python fuction
277 if ( aRes && theIsMultiFile )
279 QStringList aFooterScript;
280 aFooterScript << QString( "" );
281 aFooterScript << QString( " pass" );
282 HYDROData_Tool::WriteStringsToFile( aFile, aFooterScript );
288 QString HYDROData_Document::GetDocPyName() const
290 QString aDocName = PYTHON_DOC_NAME;
294 if ( DocumentId( this, aDocId ) )
295 aDocName += "_" + QString::number( aDocId );
301 QStringList HYDROData_Document::DumpToPython( MapOfTreatedObjects& theTreatedObjects,
302 const bool theIsMultiFile ) const
304 QString aDocName = GetDocPyName();
306 // Append document in to the map of treated objects to prevent names overlaping
307 theTreatedObjects.insert( aDocName, this );
310 if ( !DocumentId( this, aDocId ) )
313 QStringList aResScript;
315 aResScript << QString( "from HYDROPy import *" );
316 aResScript << QString( "from PyQt4.QtCore import *" );
317 aResScript << QString( "from PyQt4.QtGui import *" );
319 if ( theIsMultiFile )
321 aResScript << QString( "import salome" );
322 aResScript << QString( "" );
323 aResScript << QString( "def RebuildData( theStudy ):" );
324 aResScript << QString( " %1 = HYDROData_Document.Document( theStudy._get_StudyId() );" ).arg( aDocName );
328 aResScript << QString( "" );
329 aResScript << QString( "%1 = HYDROData_Document.Document( theStudy._get_StudyId() );" ).arg( aDocName );
335 bool HYDROData_Document::dumpPartitionToPython( QFile& theFile,
336 const bool theIsMultiFile,
337 MapOfTreatedObjects& theTreatedObjects,
338 const ObjectKind& theObjectKind ) const
340 if ( !theFile.isOpen() )
343 QTextStream anOutStream( &theFile );
347 HYDROData_Iterator anIterator( this, theObjectKind );
348 for( ; anIterator.More(); anIterator.Next() )
350 Handle(HYDROData_Entity) anObject = anIterator.Current();
351 if ( anObject.IsNull() )
354 QString anObjName = anObject->GetName();
355 if ( theTreatedObjects.contains( anObjName ) )
358 theTreatedObjects.insert( anObjName, anObject );
360 QStringList anObjDump = anObject->DumpToPython( theTreatedObjects );
362 if ( theIsMultiFile )
364 // For multifile dump we use the function, see the document dump header
365 QStringList::iterator anIt = anObjDump.begin();
366 for ( ; anIt != anObjDump.end(); ++anIt )
367 anIt->prepend( " " );
370 HYDROData_Tool::WriteStringsToFile( theFile, anObjDump );
376 bool takeLastDigits( QString& theStr, int& aRes )
381 for ( int i = theStr.length() - 1; i >= 0; --i )
383 const QChar& aChar = theStr.at( i );
384 if ( !aChar.isDigit() )
387 anStrNum.prepend( aChar );
390 if ( anStrNum.isEmpty() )
393 theStr.remove( theStr.length() - anStrNum.length(), anStrNum.length() );
394 aRes = anStrNum.toInt();
399 bool isObjectNameLessThan( const QString& theStr1, const QString& theStr2 )
401 QString aStr1 = theStr1, aStr2 = theStr2;
403 int aNum1 = -1, aNum2 = -1;
404 if ( takeLastDigits( aStr1, aNum1 ) && takeLastDigits( aStr2, aNum2 ) )
406 if ( aStr1 == aStr2 )
407 return aNum1 < aNum2;
410 return theStr1 < theStr2;
413 HYDROData_SequenceOfObjects HYDROData_Document::GetObjectsLayerOrder(
414 const Standard_Boolean theIsAll ) const
416 HYDROData_SequenceOfObjects anOrder;
418 MapOfOrdered aMapOfOrdered;
419 MapOfUnordered aMapOfUnordered;
421 HYDROData_Iterator anIter( this );
422 for ( ; anIter.More(); anIter.Next() )
424 Handle(HYDROData_Entity) anObject = anIter.Current();
425 if ( anObject.IsNull() || !anObject->IsHas2dPrs() )
428 Standard_Integer anObjZLevel = -1;
429 if ( anObject->GetZLevel( anObjZLevel ) )
431 aMapOfOrdered.insert( anObjZLevel, anObject );
435 QString anObjName = anObject->GetName();
436 if ( anObjName.isEmpty() )
439 aMapOfUnordered.insert( anObjName, anObject );
443 MapOfOrdered::const_iterator anOrderedMapIt = aMapOfOrdered.constBegin();
444 for ( ; anOrderedMapIt != aMapOfOrdered.constEnd(); anOrderedMapIt++ )
446 const Handle(HYDROData_Entity)& anObject = anOrderedMapIt.value();
447 anOrder.Prepend( anObject );
452 QStringList aSortedNames = aMapOfUnordered.keys();
453 qSort( aSortedNames.begin(), aSortedNames.end(), isObjectNameLessThan );
455 for ( int i = 0; i < aSortedNames.length(); ++i )
457 QString anObjName = aSortedNames.value( i );
459 const Handle(HYDROData_Entity)& anObject = aMapOfUnordered.value( anObjName );
460 anOrder.Append( anObject );
467 void HYDROData_Document::SetObjectsLayerOrder( const HYDROData_SequenceOfObjects& theOrder )
469 // At first we remove previous model order
470 RemoveObjectsLayerOrder();
472 // Make new objects order
473 Standard_Integer aLevel = 0;
474 for ( int i = theOrder.Length(), n = 1; i >= n; --i )
476 const Handle(HYDROData_Entity)& anObject = theOrder.Value( i );
477 if ( anObject.IsNull() || !anObject->IsHas2dPrs() )
480 anObject->SetZLevel( aLevel++ );
484 void HYDROData_Document::Show( const Handle_HYDROData_Entity& theObject )
486 HYDROData_SequenceOfObjects anOrder;
487 anOrder.Append( theObject );
491 void HYDROData_Document::Show( const HYDROData_SequenceOfObjects& theObjects )
493 MapOfUnordered aMapOfUnordered;
495 for ( int i = 1, n = theObjects.Length(); i <= n; ++i )
497 const Handle(HYDROData_Entity)& anObject = theObjects.Value( i );
498 if ( anObject.IsNull() || !anObject->IsHas2dPrs() )
501 Standard_Integer anObjZLevel = -1;
502 if ( anObject->GetZLevel( anObjZLevel ) )
504 continue; // Skip objects that already have the z-level
508 QString anObjName = anObject->GetName();
509 if ( anObjName.isEmpty() )
512 aMapOfUnordered.insert( anObjName, anObject );
516 if ( aMapOfUnordered.isEmpty() )
517 return; // Nothing to show
519 Standard_Integer aTopId = 0;
521 HYDROData_SequenceOfObjects aModelOrder = GetObjectsLayerOrder( Standard_False );
522 if ( !aModelOrder.IsEmpty() )
524 const Handle(HYDROData_Entity)& anObject = aModelOrder.First();
525 anObject->GetZLevel( aTopId );
529 aTopId += aMapOfUnordered.size() - 1;
531 QStringList aSortedNames = aMapOfUnordered.keys();
532 qSort( aSortedNames.begin(), aSortedNames.end(), isObjectNameLessThan );
534 for ( int i = 0; i < aSortedNames.length(); ++i )
536 QString anObjName = aSortedNames.value( i );
538 const Handle(HYDROData_Entity)& anObject = aMapOfUnordered.value( anObjName );
539 anObject->SetZLevel( aTopId-- );
543 void HYDROData_Document::RemoveObjectsLayerOrder()
545 HYDROData_Iterator anIter( this );
546 for ( ; anIter.More(); anIter.Next() )
548 Handle(HYDROData_Entity) anObject = anIter.Current();
549 if ( anObject.IsNull() || !anObject->IsHas2dPrs() )
552 anObject->RemoveZLevel();
556 void HYDROData_Document::StartOperation()
561 void HYDROData_Document::CommitOperation(const TCollection_ExtendedString& theName)
563 if( !myDoc->CommitCommand() ) // it means that there were no modifications done
566 NewID(); // workaround: do something just to modify the document
567 myDoc->CommitCommand();
569 myTransactionsAfterSave++;
571 if( theName.Length() != 0 )
573 const TDF_DeltaList& aList = GetUndos();
574 if( !aList.IsEmpty() )
576 Handle(TDF_Delta) aDelta = aList.Last();
577 if( !aDelta.IsNull() )
578 aDelta->SetName( theName );
583 void HYDROData_Document::AbortOperation()
585 myDoc->AbortCommand();
588 bool HYDROData_Document::IsOperation()
590 return myDoc->HasOpenCommand() != 0;
593 bool HYDROData_Document::IsModified()
595 return myTransactionsAfterSave != 0;
598 bool HYDROData_Document::CanUndo()
600 return myDoc->GetAvailableUndos() > 0;
603 const TDF_DeltaList& HYDROData_Document::GetUndos()
605 return myDoc->GetUndos();
608 void HYDROData_Document::ClearUndos()
610 return myDoc->ClearUndos();
613 void HYDROData_Document::Undo()
616 myTransactionsAfterSave--;
619 bool HYDROData_Document::CanRedo()
621 return myDoc->GetAvailableRedos() > 0;
624 const TDF_DeltaList& HYDROData_Document::GetRedos()
626 return myDoc->GetRedos();
629 void HYDROData_Document::ClearRedos()
631 return myDoc->ClearRedos();
634 void HYDROData_Document::Redo()
637 myTransactionsAfterSave++;
640 Handle(HYDROData_Entity) HYDROData_Document::CreateObject( const ObjectKind theKind )
642 return HYDROData_Iterator::CreateObject( this, theKind );
645 Handle(HYDROData_Entity) HYDROData_Document::FindObjectByName(
646 const QString& theName,
647 const ObjectKind theObjectKind ) const
649 Handle(HYDROData_Entity) anObject;
650 if ( theName.isEmpty() )
653 QStringList aNamesList;
654 aNamesList << theName;
656 HYDROData_SequenceOfObjects aSeqOfObjs = FindObjectsByNames( aNamesList, theObjectKind );
657 if( aSeqOfObjs.IsEmpty() )
660 anObject = aSeqOfObjs.First();
664 HYDROData_SequenceOfObjects HYDROData_Document::FindObjectsByNames(
665 const QStringList& theNames,
666 const ObjectKind theObjectKind ) const
668 HYDROData_SequenceOfObjects aResSeq;
670 QStringList aNamesList = theNames;
672 HYDROData_Iterator anIter( this, theObjectKind );
673 for( ; anIter.More(); anIter.Next() )
675 Handle(HYDROData_Entity) anObject = anIter.Current();
676 if( anObject.IsNull() )
679 QString anObjName = anObject->GetName();
680 if ( anObjName.isEmpty() || !aNamesList.contains( anObjName ) )
683 aResSeq.Append( anObject );
685 aNamesList.removeAll( anObjName );
686 if ( aNamesList.isEmpty() )
693 HYDROData_Document::HYDROData_Document()
695 HYDROData_Application::GetApplication()->NewDocument("BinOcaf", myDoc);
696 myDoc->SetUndoLimit(UNDO_LIMIT);
697 NewID(); // needed to have at least one attribute in initial document to avoid errors
698 myTransactionsAfterSave = 0;
702 myInterpolatorsFactory = 0;
705 HYDROData_Document::HYDROData_Document(const Handle(TDocStd_Document)& theDoc)
708 myTransactionsAfterSave = 0;
712 myInterpolatorsFactory = 0;
715 HYDROData_Document::~HYDROData_Document()
719 int HYDROData_Document::NewID()
721 TDF_Label anIDLab = myDoc->Main().FindChild(TAG_PROPS).
722 FindChild(TAG_PROPS_NEW_ID);
723 Handle(TDataStd_Integer) anInt;
724 if (!anIDLab.FindAttribute(TDataStd_Integer::GetID(), anInt)) {
725 anInt = TDataStd_Integer::Set(anIDLab, 0);
727 // just increment value and return
728 anInt->Set(anInt->Get() + 1);
732 TDF_Label HYDROData_Document::LabelOfObjects()
734 return myDoc->Main().FindChild(TAG_OBJECTS);
737 TDF_Label HYDROData_Document::LabelOfLocalCS() const
739 return myDoc->Main().FindChild(TAG_LOCAL_CS);
742 void HYDROData_Document::GetLocalCS( double& theLX, double& theLY ) const
744 TDF_Label aLocalCSLab = LabelOfLocalCS();
746 Handle( TDataXtd_Position ) aLocalCS;
747 if( aLocalCSLab.FindAttribute( TDataXtd_Position::GetID(), aLocalCS ) )
749 gp_Pnt aLocalCS3d = aLocalCS->GetPosition();
750 theLX = aLocalCS3d.X();
751 theLY = aLocalCS3d.Y();
755 theLX = DEFAULT_LOCAL_CS.X();
756 theLY = DEFAULT_LOCAL_CS.Y();
760 void HYDROData_Document::SetLocalCS( double theLX, double theLY )
764 // update the local CS data in attribute
765 TDF_Label aLocalCSLab = LabelOfLocalCS();
766 Handle( TDataXtd_Position ) aLocalCS;
767 if( !aLocalCSLab.FindAttribute( TDataXtd_Position::GetID(), aLocalCS ) )
768 aLocalCS = TDataXtd_Position::Set( aLocalCSLab );
770 gp_Pnt aLocalCS3d( theLX, theLY, 0 );
771 aLocalCS->SetPosition( aLocalCS3d );
773 // calculate delta for coordinates
774 double aDX = myLX - theLX;
775 double aDY = myLY - theLY;
777 // update the local CS data in internal fields
781 //update all objects in the document
782 HYDROData_Iterator anIterator( this, KIND_UNKNOWN );
783 for( ; anIterator.More(); anIterator.Next() )
784 anIterator.Current()->UpdateLocalCS( aDX, aDY );
787 void HYDROData_Document::UpdateLCSFields() const
789 if( myLX >= 0 && myLY >= 0 )
793 GetLocalCS( aLX, aLY );
794 HYDROData_Document* aThat = const_cast<HYDROData_Document*>( this );
799 void HYDROData_Document::Transform( double& X, double& Y, bool IsToLocalCS ) const
814 void HYDROData_Document::Transform( gp_Pnt& thePnt, bool IsToLocalCS ) const
816 double X = thePnt.X();
817 double Y = thePnt.Y();
818 double Z = thePnt.Z();
819 Transform( X, Y, IsToLocalCS );
820 thePnt = gp_Pnt( X, Y, Z );
823 void HYDROData_Document::Transform( gp_XYZ& thePnt, bool IsToLocalCS ) const
825 double X = thePnt.X();
826 double Y = thePnt.Y();
827 double Z = thePnt.Z();
828 Transform( X, Y, IsToLocalCS );
829 thePnt = gp_XYZ( X, Y, Z );
832 void HYDROData_Document::Transform( gp_XY& thePnt, bool IsToLocalCS ) const
834 double X = thePnt.X();
835 double Y = thePnt.Y();
836 Transform( X, Y, IsToLocalCS );
837 thePnt = gp_XY( X, Y );
840 HYDROData_InterpolatorsFactory* HYDROData_Document::GetInterpolatorsFactory()
842 if ( !myInterpolatorsFactory ) {
843 myInterpolatorsFactory = new HYDROData_InterpolatorsFactory();
846 return myInterpolatorsFactory;
849 HYDROData_IProfilesInterpolator* HYDROData_Document::GetInterpolator( const TCollection_AsciiString& theName ) const
851 HYDROData_IProfilesInterpolator* anInterpolator = NULL;
853 HYDROData_Document* aThat = const_cast<HYDROData_Document*>( this );
854 HYDROData_InterpolatorsFactory* aFactory = aThat->GetInterpolatorsFactory();
856 anInterpolator = aFactory->GetInterpolator( theName );
859 return anInterpolator;
862 NCollection_Sequence<TCollection_AsciiString> HYDROData_Document::GetInterpolatorNames() const
864 NCollection_Sequence<TCollection_AsciiString> aNames;
866 HYDROData_Document* aThat = const_cast<HYDROData_Document*>( this );
867 HYDROData_InterpolatorsFactory* aFactory = aThat->GetInterpolatorsFactory();
869 aNames = aFactory->GetInterpolatorNames();
875 QColor HYDROData_Document::GetAssociatedColor( const QString& theStricklerType, const Handle(HYDROData_StricklerTable)& theTable ) const
877 if( !theTable.IsNull() && theTable->HasType( theStricklerType ) )
878 return theTable->GetColor( theStricklerType );
880 HYDROData_Iterator anIt( this, KIND_STRICKLER_TABLE );
881 for( ; anIt.More(); anIt.Next() )
883 Handle(HYDROData_StricklerTable) aTable = Handle(HYDROData_StricklerTable)::DownCast( anIt.Current() );
884 if( aTable->HasType( theStricklerType ) )
885 return aTable->GetColor( theStricklerType );