Salome HOME
workaround to improve: allow to read enbankement altitude given by a flat line
[modules/hydro.git] / src / HYDROData / HYDROData_Entity.cxx
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.
6 //
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.
11 //
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
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROData_Entity.h"
20
21 #include "HYDROData_Iterator.h"
22 #include "HYDROData_Tool.h"
23
24 #include <TDataStd_Name.hxx>
25 #include <TDataStd_ByteArray.hxx>
26 #include <TDataStd_UAttribute.hxx>
27 #include <TDataStd_IntegerArray.hxx>
28 #include <TDataStd_BooleanArray.hxx>
29 #include <TDataStd_Integer.hxx>
30 #include <TDataStd_RealArray.hxx>
31 #include <TDataStd_ReferenceList.hxx>
32
33 #include <TDF_CopyLabel.hxx>
34 #include <TDF_ListIteratorOfLabelList.hxx>
35
36 #include <QColor>
37 #include <QString>
38 #include <QStringList>
39 #include <QVariant>
40
41 #define _DEVDEBUG_
42 #include "HYDRO_trace.hxx"
43
44 static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000");
45
46 IMPLEMENT_STANDARD_HANDLE(HYDROData_Entity,MMgt_TShared)
47 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Entity,MMgt_TShared)
48
49 // is equal function for unique object mapping
50 bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Handle_HYDROData_Entity& theObj2)
51 {
52   if ( !theObj1.IsNull() && !theObj2.IsNull() )
53     return theObj1->Label() == theObj2->Label();
54   return false;
55 }
56
57 QString HYDROData_Entity::GetName() const
58 {
59   Handle(TDataStd_Name) aName;
60   if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) {
61     TCollection_AsciiString aStr(aName->Get());
62     return QString(aStr.ToCString());
63   }
64   return QString();
65 }
66
67 QString HYDROData_Entity::GetObjPyName() const
68 {
69   QString aName = GetName();
70   aName.replace(QRegExp("[\\W]"), "_");
71
72   return aName;
73 }
74
75 void HYDROData_Entity::SetName(const QString& theName)
76 {
77   TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData()));
78 }
79
80 QStringList HYDROData_Entity::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
81 {
82   QStringList anEmptyList;
83   return anEmptyList;
84 }
85
86 void HYDROData_Entity::Update()
87 {
88   SetToUpdate( false );
89 }
90
91 void HYDROData_Entity::UpdateLocalCS( double theDx, double theDy )
92 {
93   //On the base level no actions are necessary
94 }
95
96 bool HYDROData_Entity::IsHas2dPrs() const
97 {
98   return false;
99 }
100
101 void HYDROData_Entity::Show()
102 {
103   if ( !IsHas2dPrs() )
104     return;
105
106   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
107   if ( aDocument.IsNull() )
108     return;
109
110   aDocument->Show( this );
111 }
112
113 QVariant HYDROData_Entity::GetDataVariant()
114 {
115   return QVariant();
116 }
117
118 void HYDROData_Entity::SetToUpdate( bool theFlag )
119 {
120   if ( IsMustBeUpdated() == theFlag )
121     return;
122
123   if ( theFlag )
124   {
125     TDataStd_UAttribute::Set( myLab, GUID_MUST_BE_UPDATED );
126
127     Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
128     if ( !aDocument.IsNull() )
129     {
130       // Change the states of this and all depended objects
131       HYDROData_Tool::SetMustBeUpdatedObjects( aDocument );
132     }
133   }
134   else
135   {
136     myLab.ForgetAttribute( GUID_MUST_BE_UPDATED );
137   }
138 }
139
140 bool HYDROData_Entity::IsMustBeUpdated() const
141 {
142   return myLab.IsAttribute( GUID_MUST_BE_UPDATED );
143 }
144
145 bool HYDROData_Entity::CanBeUpdated() const
146 {
147   return true;
148 }
149
150 bool HYDROData_Entity::IsRemoved() const
151 {
152   return !myLab.HasAttribute();
153 }
154
155 void HYDROData_Entity::Remove()
156 {
157   return myLab.ForgetAllAttributes( true );
158 }
159
160 bool HYDROData_Entity::CanRemove()
161 {
162   return true;
163 }
164
165 HYDROData_Entity::HYDROData_Entity()
166 {
167 }
168
169 HYDROData_Entity::~HYDROData_Entity()
170 {
171 }
172
173 void HYDROData_Entity::CopyTo( const Handle(HYDROData_Entity)& theDestination ) const
174 {
175   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
176   if ( aDocument.IsNull() ) {
177     return;
178   }
179
180   TDF_CopyLabel aCopy(myLab, theDestination->Label());
181   aCopy.Perform();
182          
183   // generate a new unique name for the clone object:
184   // case 1: Image_1 -> Image_2
185   // case 2: ImageObj -> ImageObj_1
186   QString aName = theDestination->GetName();
187   QString aPrefix = aName;
188   if( aName.contains( '_' ) ) { // case 1
189     QString aSuffix = aName.section( '_', -1 );
190     bool anIsInteger = false;
191     aSuffix.toInt( &anIsInteger );
192     if( anIsInteger )
193       aPrefix = aName.section( '_', 0, -2 );
194   } else { // case 2
195     aPrefix = aName;
196   }
197
198   aName = HYDROData_Tool::GenerateObjectName( aDocument, aPrefix );
199   theDestination->SetName( aName );
200 }
201
202 Handle(HYDROData_Entity) HYDROData_Entity::GetFatherObject() const
203 {
204   Handle(HYDROData_Entity) aFather;
205
206   if ( !myLab.IsNull() )
207   {
208     TDF_Label aFatherLabel = myLab.Father();
209
210     while ( aFather.IsNull() && !aFatherLabel.IsNull() && !aFatherLabel.IsRoot() )
211     {
212       aFather = HYDROData_Iterator::Object( aFatherLabel );
213       aFatherLabel = aFatherLabel.Father();
214     }
215   }
216
217   return aFather;
218 }
219
220 HYDROData_SequenceOfObjects HYDROData_Entity::GetAllReferenceObjects() const
221 {
222   return HYDROData_SequenceOfObjects();
223 }
224
225 Standard_Boolean HYDROData_Entity::GetZLevel( Standard_Integer& theLevel ) const
226 {
227   theLevel = -1;
228
229   TDF_Label aLabel = myLab.FindChild( DataTag_ZLevel, false );
230   if ( !aLabel.IsNull() )
231   {
232     Handle(TDataStd_Integer) anIntVal;
233     if ( aLabel.FindAttribute( TDataStd_Integer::GetID(), anIntVal ) )
234     {
235       theLevel = anIntVal->Get();
236       return Standard_True;
237     }
238   }
239
240   return Standard_False;
241 }
242
243 void HYDROData_Entity::SetZLevel( const Standard_Integer& theLevel )
244 {
245   TDataStd_Integer::Set( myLab.FindChild( DataTag_ZLevel ), theLevel );
246 }
247
248 void HYDROData_Entity::RemoveZLevel()
249 {
250   TDF_Label aLabel = myLab.FindChild( DataTag_ZLevel, false );
251   if ( !aLabel.IsNull() )
252     aLabel.ForgetAllAttributes();
253 }
254
255 void HYDROData_Entity::SetLabel( const TDF_Label& theLabel )
256 {
257   myLab = theLabel;
258 }
259
260 void HYDROData_Entity::SaveByteArray( const int   theTag, 
261                                       const char* theData,
262                                       const int   theLen )
263 {
264   TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
265   // array is empty, remove the attribute
266   if (theLen <= 0) {
267     aLab.ForgetAttribute(TDataStd_ByteArray::GetID());
268     return;
269   }
270   // store data of image in byte array
271   Handle(TDataStd_ByteArray) aData;
272   if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData)) {
273     aData = TDataStd_ByteArray::Set(aLab, 1, theLen);
274   }
275   // copy bytes one by one
276   if (aData->Length() != theLen) {
277     Handle(TColStd_HArray1OfByte) aNewData = new TColStd_HArray1OfByte(1, theLen);
278     for(int a = 0; a < theLen; a++)
279       aNewData->SetValue(a + 1, theData[a]);
280     aData->ChangeArray(aNewData);
281   } else {
282     for(int a = 0; a < theLen; a++)
283       aData->SetValue(a + 1, theData[a]);
284   }
285 }
286
287 const char* HYDROData_Entity::ByteArray(const int theTag, int& theLen) const
288 {
289   TDF_Label aLab = theTag == 0 ? myLab : myLab.FindChild(theTag);
290   Handle(TDataStd_ByteArray) aData;
291   if (!aLab.FindAttribute(TDataStd_ByteArray::GetID(), aData))
292     return NULL; // return empty image if there is no array
293   theLen = aData->Length();
294   if (theLen)
295     return (const char*)(&(aData->InternalArray()->ChangeArray1().ChangeValue(1)));
296   return NULL;
297 }
298
299 int HYDROData_Entity::NbReferenceObjects( const int theTag ) const
300 {
301   Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
302   return aRefs.IsNull() ? 0 : aRefs->Extent();
303 }
304
305 bool HYDROData_Entity::HasReference( const Handle_HYDROData_Entity& theObj,
306                                      const int                      theTag ) const
307 {
308   if ( theObj.IsNull() )
309     return false;
310
311   Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
312   if ( aRefs.IsNull() || aRefs->IsEmpty() )
313     return false;
314
315   TDF_ListIteratorOfLabelList aListIt( aRefs->List() );
316   for ( ; aListIt.More(); aListIt.Next() )
317   {
318     const TDF_Label& aRefLabel = aListIt.Value();
319     if  ( theObj->Label() == aRefLabel )
320       return true;
321   }
322
323   return false;
324 }
325
326 void HYDROData_Entity::AddReferenceObject( const Handle_HYDROData_Entity& theObj,
327                                            const int                      theTag )
328 {
329   if ( theObj.IsNull() )
330     return;
331
332   Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
333   aRefs->Append( theObj->Label() );
334 }
335
336 void HYDROData_Entity::SetReferenceObject( const Handle_HYDROData_Entity& theObj,
337                                            const int                      theTag,
338                                            const int                      theIndex )
339 {
340   if ( theObj.IsNull() )
341   {
342     RemoveReferenceObject( theTag, theIndex );
343     return;
344   }
345
346   Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
347
348   if ( theIndex >= aRefs->Extent() )
349   {
350     aRefs->Append( theObj->Label() );
351   }
352   else if ( theIndex < 0 )
353   {
354     aRefs->Prepend( theObj->Label() );
355   }
356   else
357   {
358     RemoveReferenceObject( theTag, theIndex );
359
360     Handle(HYDROData_Entity) aBeforeObj = GetReferenceObject( theTag, theIndex );
361
362     aRefs = getReferenceList( theTag, true ); // because reference list can be removed
363     if ( !aBeforeObj.IsNull() )
364       aRefs->InsertBefore( theObj->Label(), aBeforeObj->Label() );
365     else 
366       aRefs->Append( theObj->Label() );
367   }
368 }
369
370 void HYDROData_Entity::InsertReferenceObject( const Handle_HYDROData_Entity& theObj,
371                                               const int                      theTag,
372                                               const int                      theBeforeIndex )
373 {
374   if ( theObj.IsNull() )
375     return;
376
377   Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, true );
378
379   if ( theBeforeIndex >= aRefs->Extent() )
380   {
381     aRefs->Append( theObj->Label() );
382   }
383   else if ( theBeforeIndex < 0 )
384   {
385     aRefs->Prepend( theObj->Label() );
386   }
387   else
388   {
389     Handle(HYDROData_Entity) aBeforeObj = GetReferenceObject( theTag, theBeforeIndex );
390     if ( !aBeforeObj.IsNull() )
391       aRefs->InsertBefore( theObj->Label(), aBeforeObj->Label() );
392     else 
393       aRefs->Append( theObj->Label() );
394   }
395 }
396
397 void HYDROData_Entity::SetReferenceObjects( const HYDROData_SequenceOfObjects& theObjects,
398                                             const int                          theTag )
399 {
400   ClearReferenceObjects( theTag );
401   if ( theObjects.IsEmpty() )
402     return;
403
404   HYDROData_SequenceOfObjects::Iterator anIter( theObjects );
405   for ( ; anIter.More(); anIter.Next() )
406     AddReferenceObject( anIter.Value(), theTag );
407 }
408
409 Handle(HYDROData_Entity) HYDROData_Entity::GetReferenceObject( const int theTag,
410                                                                const int theIndex ) const
411 {
412   Handle(HYDROData_Entity) aRes;
413
414   Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
415   if ( aRefs.IsNull() || theIndex < 0 || theIndex >= aRefs->Extent() )
416     return aRes;
417
418   TDF_ListIteratorOfLabelList anIter( aRefs->List() );
419   for ( int anIndex = 0; anIndex != theIndex && anIter.More(); anIter.Next(), ++anIndex );
420
421   const TDF_Label& aRefLabel = anIter.Value();
422   aRes = HYDROData_Iterator::Object( aRefLabel );
423
424   return aRes;
425 }
426
427 HYDROData_SequenceOfObjects HYDROData_Entity::GetReferenceObjects( const int theTag ) const
428 {
429   HYDROData_SequenceOfObjects aRes;
430
431   Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
432   if ( aRefs.IsNull() )
433     return aRes;
434
435   TDF_ListIteratorOfLabelList anIter( aRefs->List() );
436   for ( ; anIter.More(); anIter.Next() )
437   {
438     const TDF_Label& aRefLabel = anIter.Value();
439
440     Handle(HYDROData_Entity) aRefObject = HYDROData_Iterator::Object( aRefLabel );
441     if ( aRefObject.IsNull() )
442       continue;
443
444     aRes.Append( aRefObject );
445   }
446
447   return aRes;
448 }
449
450 void HYDROData_Entity::RemoveReferenceObject( const TDF_Label& theRefLabel,
451                                               const int        theTag )
452 {
453   Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
454   if ( aRefs.IsNull() )
455     return;
456
457   if ( aRefs->Extent() == 1 )
458   { 
459     // remove all if only one
460     ClearReferenceObjects( theTag );
461     return;
462   }
463
464   aRefs->Remove( theRefLabel );
465 }
466
467 void HYDROData_Entity::RemoveReferenceObject( const int theTag,
468                                               const int theIndex )
469 {
470   Handle(TDataStd_ReferenceList) aRefs = getReferenceList( theTag, false );
471   if ( aRefs.IsNull() )
472     return;
473
474   if ( aRefs->Extent() == 1 && theIndex == 0 )
475   { 
476     // remove all if only one
477     ClearReferenceObjects( theTag );
478     return;
479   }
480
481   int anIndex = 0;
482   TDF_ListIteratorOfLabelList anIter( aRefs->List() );
483   for ( ; anIndex != theIndex && anIter.More(); anIter.Next(), ++anIndex );
484
485   if ( anIndex != theIndex || !anIter.More() )
486     return;
487
488   const TDF_Label& aRefLabel = anIter.Value();
489   aRefs->Remove( aRefLabel );
490 }
491
492 void HYDROData_Entity::ClearReferenceObjects( const int theTag )
493 {
494   TDF_Label aSetLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
495   aSetLabel.ForgetAttribute( TDataStd_ReferenceList::GetID() );
496 }
497
498 Handle(TDataStd_ReferenceList) HYDROData_Entity::getReferenceList( const int theTag,
499                                                                    const bool theIsCreate ) const
500 {
501   TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
502
503   Handle(TDataStd_ReferenceList) aRefs;
504   if ( !aLabel.FindAttribute( TDataStd_ReferenceList::GetID(), aRefs ) && theIsCreate )
505     aRefs = TDataStd_ReferenceList::Set( aLabel );
506
507   return aRefs;
508 }
509
510 void HYDROData_Entity::SetColor( const QColor& theColor,
511                                  const int     theTag )
512 {
513   TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
514
515   Handle(TDataStd_IntegerArray) aColorArray;
516   if ( !aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
517     aColorArray = TDataStd_IntegerArray::Set( aLabel, 1, 4 );
518
519   aColorArray->SetValue( 1, theColor.red()   );
520   aColorArray->SetValue( 2, theColor.green() );
521   aColorArray->SetValue( 3, theColor.blue()  );
522   aColorArray->SetValue( 4, theColor.alpha() );
523 }
524
525 QColor HYDROData_Entity::GetColor( const QColor& theDefColor,
526                                    const int     theTag ) const
527 {
528   QColor aResColor = theDefColor;
529
530   TDF_Label aLabel = theTag == 0 ? myLab : myLab.FindChild( theTag );
531
532   Handle(TDataStd_IntegerArray) aColorArray;
533   if ( aLabel.FindAttribute( TDataStd_IntegerArray::GetID(), aColorArray ) )
534   {
535     aResColor.setRed(   aColorArray->Value( 1 ) );
536     aResColor.setGreen( aColorArray->Value( 2 ) );
537     aResColor.setBlue(  aColorArray->Value( 3 ) );
538     aResColor.setAlpha( aColorArray->Value( 4 ) );
539   }
540
541   return aResColor;
542 }
543
544 QStringList HYDROData_Entity::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const
545 {
546   QStringList aResList;
547
548   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
549   if ( aDocument.IsNull() )
550     return aResList;
551
552   QString aDocName = aDocument->GetDocPyName();
553   QString aName = GetObjPyName();
554
555   aResList << QString( "%1 = %2.CreateObject( %3 );" )
556               .arg( aName ).arg( aDocName ).arg( getPyTypeID() );
557   aResList << QString( "%1.SetName( \"%2\" );" )
558               .arg( aName ).arg( GetName() );
559   aResList << QString( "" );
560
561   if ( IsHas2dPrs() )
562   {
563     // Dump object z-level in viewer
564     Standard_Integer anObjZLevel = -1;
565     if ( GetZLevel( anObjZLevel ) )
566     {
567       aResList << QString( "%1.SetZLevel( %2 );" )
568                   .arg( aName ).arg( anObjZLevel );
569       aResList << QString( "" );
570     }
571   }
572
573   return aResList;
574 }
575
576 QString HYDROData_Entity::getPyTypeID() const
577 {
578   DEBTRACE("HYDROData_Entity::getPyTypeID " << GetKind());
579   switch( GetKind() )
580   {
581     case KIND_IMAGE:             return "KIND_IMAGE";
582     case KIND_POLYLINE:          return "KIND_POLYLINE";
583     case KIND_BATHYMETRY:        return "KIND_BATHYMETRY";
584     case KIND_ALTITUDE:          return "KIND_ALTITUDE";
585     case KIND_IMMERSIBLE_ZONE:   return "KIND_IMMERSIBLE_ZONE";
586     case KIND_RIVER:             return "KIND_RIVER";
587     case KIND_STREAM:            return "KIND_STREAM";
588     case KIND_CONFLUENCE:        return "KIND_CONFLUENCE";
589     case KIND_CHANNEL:           return "KIND_CHANNEL";
590     case KIND_OBSTACLE:          return "KIND_OBSTACLE";
591     case KIND_DIGUE:             return "KIND_DIGUE";
592     case KIND_PROFILE:           return "KIND_PROFILE";
593     case KIND_PROFILEUZ:         return "KIND_PROFILEUZ";
594     case KIND_POLYLINEXY:        return "KIND_POLYLINEXY";
595     case KIND_CALCULATION:       return "KIND_CALCULATION";
596     case KIND_ZONE:              return "KIND_ZONE";
597     case KIND_REGION:            return "KIND_REGION";
598     case KIND_VISUAL_STATE:      return "KIND_VISUAL_STATE";
599     case KIND_ARTIFICIAL_OBJECT: return "KIND_ARTIFICIAL_OBJECT";
600     case KIND_NATURAL_OBJECT:    return "KIND_NATURAL_OBJECT";
601     case KIND_DUMMY_3D:          return "KIND_DUMMY_3D";
602     case KIND_SHAPES_GROUP:      return "KIND_SHAPES_GROUP";
603     case KIND_SPLITTED_GROUP:    return "KIND_SPLITTED_GROUP";
604     case KIND_STREAM_ALTITUDE:   return "KIND_STREAM_ALTITUDE";
605     case KIND_OBSTACLE_ALTITUDE: return "KIND_OBSTACLE_ALTITUDE";
606     case KIND_STRICKLER_TABLE:   return "KIND_STRICKLER_TABLE";
607     case KIND_LAND_COVER:        return "KIND_LAND_COVER";
608     case KIND_CHANNEL_ALTITUDE:  return "KIND_CHANNEL_ALTITUDE";
609     default:                     return "KIND_UNKNOWN"; ///! Unrecognized object
610   }
611 }
612
613 void HYDROData_Entity::setPythonReferenceObject( MapOfTreatedObjects&            theTreatedObjects,
614                                                  QStringList&                    theScript,
615                                                  const Handle(HYDROData_Entity)& theRefObject,
616                                                  const QString&                  theMethod ) const
617 {
618   if ( !checkObjectPythonDefinition( theTreatedObjects, theScript, theRefObject ) )
619     return;
620
621   QString aRefObjName = theRefObject->GetObjPyName();
622
623   QString anObjName = GetObjPyName();
624   theScript << QString( "%1.%2( %3 );" )
625                .arg( anObjName ).arg( theMethod ).arg( aRefObjName );
626 }
627
628 bool HYDROData_Entity::checkObjectPythonDefinition( MapOfTreatedObjects&            theTreatedObjects,
629                                                     QStringList&                    theScript,
630                                                     const Handle(HYDROData_Entity)& theRefObject ) const
631 {
632   if ( theRefObject.IsNull() )
633     return false;
634
635   QString aRefObjName = theRefObject->GetName();
636   if ( aRefObjName.isEmpty() )
637     return false;
638
639   if ( theTreatedObjects.contains( aRefObjName ) )
640     return true;
641
642   // The definition of reference object must be dumped before this
643   QStringList aRefObjDump = theRefObject->DumpToPython( theTreatedObjects );
644   if ( aRefObjDump.isEmpty() )
645     return false;
646
647   QStringList aTmpList = theScript;
648   theScript = aRefObjDump;
649
650   theScript << QString( "" );
651   theScript << aTmpList;
652
653   theTreatedObjects.insert( aRefObjName, theRefObject );
654
655   return true;
656 }
657
658 void HYDROData_Entity::setPythonObjectColor( QStringList&         theScript,
659                                              const QColor&        theColor,
660                                              const QColor&        theDefaultColor,
661                                              const QString&       theMethod ) const
662 {
663   if ( theColor == theDefaultColor )
664     return; //Do not set the color for object if it like default
665
666   QString anObjName = GetObjPyName();
667   theScript << QString( "%1.%2( QColor( %3, %4, %5, %6 ) );" )
668               .arg( anObjName ).arg( theMethod )
669               .arg( theColor.red()  ).arg( theColor.green() )
670               .arg( theColor.blue() ).arg( theColor.alpha() );
671 }
672
673 void HYDROData_Entity::findPythonReferenceObject( MapOfTreatedObjects& theTreatedObjects,
674                                                   QStringList& theScript ) const
675 {
676   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
677   if ( aDocument.IsNull() )
678     return;
679     
680   theScript << QString( "%1 = %2.FindObjectByName( \"%3\" );" ).arg( GetObjPyName() )
681                                                                .arg( aDocument->GetDocPyName() )
682                                                                .arg( GetName() );
683 }