Salome HOME
Ceration of objects from popup menu of main partitions.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Tool.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HYDROGUI_Tool.h"
24
25 #include "HYDROGUI_DataModel.h"
26 #include "HYDROGUI_DataObject.h"
27 #include "HYDROGUI_Module.h"
28 #include "HYDROGUI_Prs.h"
29
30 #include <HYDROData_Document.h>
31 #include <HYDROData_Iterator.h>
32 #include <HYDROData_ImmersibleZone.h>
33 #include <HYDROData_Tool.h>
34
35 #include <GEOMBase.h>
36
37 #include <GraphicsView_Viewer.h>
38
39 #include <SalomeApp_Study.h>
40
41 #include <LightApp_Application.h>
42 #include <LightApp_DataOwner.h>
43 #include <LightApp_SelectionMgr.h>
44
45 #include <OCCViewer_ViewModel.h>
46 #include <OCCViewer_ViewFrame.h>
47
48 #include <QtxWorkstack.h>
49 #include <QtxActionToolMgr.h>
50
51 #include <STD_TabDesktop.h>
52
53 #include <SUIT_Session.h>
54 #include <SUIT_Study.h>
55 #include <SUIT_ViewManager.h>
56 #include <SUIT_ViewWindow.h>
57
58 #include <SALOMEDSClient.hxx>
59
60 #include <QDir>
61 #include <QFileInfo>
62 #include <QDockWidget>
63 #include <QTextCodec>
64
65 // Definition of this id allows to use 'latin1' (Qt alias for 'ISO-8859-1')
66 // encoding instead of default 'System'
67 #define USE_LATIN1_ENCODING
68
69 QString HYDROGUI_Tool::ToQString( const TCollection_AsciiString& src )
70 {
71 #ifdef USE_LATIN1_ENCODING
72   QTextCodec* codec = QTextCodec::codecForName( "latin1" ); // alias for ISO-8859-1
73 #else
74   QTextCodec* codec = QTextCodec::codecForLocale();
75 #endif
76   QString res;
77   if ( !src.IsEmpty() )
78     res = codec ? codec->toUnicode( (char*)src.ToCString(), src.Length() ) :
79       QString( (char*)src.ToCString() );
80   return res;
81 }
82
83 QString HYDROGUI_Tool::ToQString( const TCollection_ExtendedString& src )
84 {
85   return QString( (QChar*)src.ToExtString(), src.Length() );
86 }
87
88 QString HYDROGUI_Tool::ToQString( const Handle(TCollection_HAsciiString)& src )
89 {
90   if( src.IsNull() )
91     return QString();
92   else
93     return ToQString( src->String() );
94 }
95
96 QString HYDROGUI_Tool::ToQString( const Handle(TCollection_HExtendedString)& src )
97 {
98   if( src.IsNull() )
99     return QString();
100   return ToQString( src->String() );
101 }
102
103 TCollection_AsciiString HYDROGUI_Tool::ToAsciiString( const QString& src )
104 {
105   TCollection_AsciiString res;
106   if( !src.isNull() )
107   {
108 #ifdef USE_LATIN1_ENCODING
109     QTextCodec* codec = QTextCodec::codecForName( "latin1" ); // alias for ISO-8859-1
110 #else
111     QTextCodec* codec = QTextCodec::codecForLocale();
112 #endif
113     if( codec )
114     {
115       QByteArray str = codec->fromUnicode( src );
116       res = TCollection_AsciiString( (Standard_CString)str.constData() );
117     }
118     else
119       res = TCollection_AsciiString( src.toLatin1().data() );
120   }
121   return res;
122 }
123
124 TCollection_ExtendedString HYDROGUI_Tool::ToExtString( const QString& src )
125 {
126   if( src.isEmpty() )
127     return TCollection_ExtendedString();
128
129   Standard_Integer len = src.length();
130   Standard_ExtString extStr = new Standard_ExtCharacter[ ( len + 1 ) * 2 ];
131   memcpy( (void*)extStr, src.unicode(), len * 2 );
132   ((short*)extStr)[ len ] = 0;
133
134   TCollection_ExtendedString trg( extStr );
135   delete [] extStr;
136   return trg;
137 }
138
139 Handle(TCollection_HAsciiString) HYDROGUI_Tool::ToHAsciiString( const QString& src )
140 {
141   return new TCollection_HAsciiString( ToAsciiString( src ) );
142 }
143
144 Handle(TCollection_HExtendedString) HYDROGUI_Tool::ToHExtString( const QString& src )
145 {
146   return new TCollection_HExtendedString( ToExtString( src ) );
147 }
148
149 int HYDROGUI_Tool::GetActiveStudyId()
150 {
151   if( SUIT_Session* aSession = SUIT_Session::session() )
152     if( SUIT_Application* anApp = aSession->activeApplication() )
153       if( SUIT_Study* aStudy = anApp->activeStudy() )
154         return aStudy->id();
155   return 0;
156 }
157
158 QString HYDROGUI_Tool::GetTempDir( const bool theToCreate )
159 {
160   QString aRes;
161
162   char* tmpdir = getenv ( "HYDRO_TMP_DIR" );
163   if ( tmpdir )
164   {
165     // try to create folder if it does not exist
166     QFileInfo fi( tmpdir );
167     if ( !fi.exists() && theToCreate )
168     {
169       if ( QDir().mkdir( tmpdir ) )
170         QFile::setPermissions( tmpdir, (QFile::Permissions)0x4FFFF );
171        QFileInfo fi( tmpdir );
172        if ( !fi.exists() || !fi.isWritable() )
173          tmpdir = 0;
174     }
175   }
176   if ( !tmpdir )
177     tmpdir = getenv ( "TEMP" );
178   if ( !tmpdir )
179     tmpdir = getenv ( "TMP" );
180   if ( !tmpdir )
181   {
182 #ifdef WNT
183     tmpdir = "C:\\";
184 #else
185     tmpdir = "/tmp";
186 #endif
187   }
188   aRes = tmpdir;
189   
190   QFileInfo fi( aRes );
191   if ( !fi.exists() || !fi.isWritable() )
192     aRes = QString::null;
193
194   return aRes;
195 }
196
197 void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule,
198                                           SUIT_ViewManager* theViewManager )
199 {
200   if( theViewManager )
201     if( SUIT_ViewWindow* aViewWindow = theViewManager->getActiveView() )
202       if( STD_TabDesktop* aTabDesktop = dynamic_cast<STD_TabDesktop*>( theModule->getApp()->desktop() ) )
203         if( QtxWorkstack* aWorkstack = aTabDesktop->workstack() )
204           aWorkstack->setActiveWindow( aViewWindow );
205 }
206
207 void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
208                                       HYDROData_SequenceOfObjects& theSeq )
209 {
210   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
211   if( !aDocument.IsNull() )
212   {
213     HYDROData_Iterator anIterator( aDocument );
214     for( ; anIterator.More(); anIterator.Next() )
215     {
216       Handle(HYDROData_Entity) anObject = anIterator.Current();
217       if( !anObject.IsNull() && ( 
218         ( anObject->GetKind() == KIND_IMAGE ) ||
219         ( anObject->GetKind() == KIND_POLYLINEXY ) ||
220         ( anObject->GetKind() == KIND_IMMERSIBLE_ZONE ) ||
221         ( anObject->GetKind() == KIND_REGION ) ||
222         ( anObject->GetKind() == KIND_BATHYMETRY ) ||
223         ( anObject->GetKind() == KIND_ZONE ) ||
224         ( anObject->GetKind() == KIND_OBSTACLE ) ||
225         ( anObject->GetKind() == KIND_PROFILE ) ||
226         ( anObject->GetKind() == KIND_STREAM ) ) )
227       {
228         theSeq.Append( anObject );
229       }
230     }
231   }
232 }
233
234 HYDROGUI_Prs* HYDROGUI_Tool::GetPresentation( const Handle(HYDROData_Entity)& theObj,
235                                               const GraphicsView_ObjectList& theObjects )
236 {
237   if( !theObj.IsNull() )
238   {
239     GraphicsView_ObjectListIterator anIter( theObjects );
240     while( anIter.hasNext() )
241     {
242       if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( anIter.next() ) )
243       {
244         Handle(HYDROData_Entity) anObj = aPrs->getObject();
245         if( IsEqual( anObj, theObj ) )
246           return aPrs;
247       }
248     }
249   }
250   return NULL;
251 }
252
253 GraphicsView_ObjectList HYDROGUI_Tool::GetPrsList( GraphicsView_ViewPort* theViewPort )
254 {
255   GraphicsView_ObjectList aList;
256   if( theViewPort )
257   {
258     GraphicsView_ObjectListIterator anIter( theViewPort->getObjects() );
259     while( anIter.hasNext() )
260       if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( anIter.next() ) )
261         aList.append( aPrs );
262   }
263   return aList;
264 }
265
266 HYDROData_SequenceOfObjects HYDROGUI_Tool::GetSelectedObjects( HYDROGUI_Module* theModule )
267 {
268   HYDROData_SequenceOfObjects aSeq;
269
270   HYDROGUI_DataModel* aModel = theModule->getDataModel();
271
272   SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr();
273   SUIT_DataOwnerPtrList anOwners;
274   aSelectionMgr->selected( anOwners );
275
276   QStringList aCollectedNameList; // to avoid duplication
277   foreach( SUIT_DataOwner* aSUITOwner, anOwners )
278   {
279     if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
280     {
281       Handle(HYDROData_Entity) anObject = aModel->objectByEntry( anOwner->entry() );
282       if( !anObject.IsNull() )
283       {
284         QString aName = anObject->GetName();
285         if( !aCollectedNameList.contains( aName ) )
286         {
287           aSeq.Append( anObject );
288           aCollectedNameList.append( aName );
289         }
290       }
291     }
292   }
293   return aSeq;
294 }
295
296 Handle(HYDROData_Entity) HYDROGUI_Tool::GetSelectedObject( HYDROGUI_Module* theModule )
297 {
298   HYDROData_SequenceOfObjects aSeq = GetSelectedObjects( theModule );
299   if( !aSeq.IsEmpty() )
300     return aSeq.First();
301   return NULL;
302 }
303
304 HYDROData_SequenceOfObjects HYDROGUI_Tool::GetGeometryObjects( 
305   HYDROGUI_Module* theModule )
306 {
307   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
308
309   HYDROData_SequenceOfObjects aResSeq;
310
311   HYDROData_Iterator anIter( aDocument );
312   for ( ; anIter.More(); anIter.Next() )
313   {
314     Handle(HYDROData_Entity) anObj = anIter.Current();
315     if ( !HYDROData_Tool::IsGeometryObject( anObj ) )
316       continue;
317
318     aResSeq.Append( anObj );
319   }
320   
321   return aResSeq;
322 }
323
324 ObjectKind HYDROGUI_Tool::GetSelectedPartition( HYDROGUI_Module* theModule )
325 {
326   HYDROGUI_DataModel* aModel = theModule->getDataModel();
327
328   SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr();
329   SUIT_DataOwnerPtrList anOwners;
330   aSelectionMgr->selected( anOwners );
331
332   if( anOwners.size() != 1 )
333     return KIND_UNKNOWN;
334
335   if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( anOwners.first().operator->() ) )
336   {
337     QString anEntry = anOwner->entry();
338     QString aPrefix = HYDROGUI_DataObject::entryPrefix();
339     if( anEntry.left( aPrefix.length() ) == aPrefix )
340     {
341       anEntry.remove( aPrefix );
342       for( ObjectKind anObjectKind = KIND_UNKNOWN + 1; anObjectKind <= KIND_LAST; anObjectKind++ )
343         if( HYDROGUI_DataModel::tr( HYDROGUI_DataModel::partitionName( anObjectKind ).toAscii() ) == anEntry )
344           return anObjectKind;
345     }
346   }
347   return KIND_UNKNOWN;
348 }
349
350 QStringList HYDROGUI_Tool::GetSelectedGeomObjects( HYDROGUI_Module* theModule )
351 {
352   QStringList anEntryList;
353
354   // Get active SalomeApp_Study
355   SalomeApp_Study* aStudy = NULL;
356   if ( theModule && theModule->getApp() ) {
357     aStudy = dynamic_cast<SalomeApp_Study*>( theModule->getApp()->activeStudy() );
358   }
359   if ( !aStudy ) {
360     return anEntryList;
361   }
362
363   // Get selection
364   SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr();
365   SUIT_DataOwnerPtrList anOwners;
366   aSelectionMgr->selected( anOwners );
367
368   // Check if the selected objects belong to GEOM and have a shape
369   foreach( SUIT_DataOwner* aSUITOwner, anOwners )
370   {
371     if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
372     {
373       QString anEntry = anOwner->entry();
374       _PTR(SObject) aSObject( aStudy->studyDS()->FindObjectID(qPrintable(anEntry)) );
375       if (aSObject) {
376          _PTR(SComponent) aSComponent = aSObject->GetFatherComponent();
377         if ( aSComponent && aSComponent->ComponentDataType() == "GEOM" ) {
378           GEOM::GEOM_Object_var aGeomObj = 
379             GEOMBase::GetObjectFromIOR( aSObject->GetIOR().c_str() );
380
381           if ( !aGeomObj->_is_nil() && aGeomObj->IsShape() ) {
382             anEntryList << anEntry;
383           }
384         }
385       }
386     }
387   }
388
389   return anEntryList;
390 }
391
392 Handle(HYDROData_Entity) HYDROGUI_Tool::FindObjectByName( HYDROGUI_Module* theModule,
393                                                           const QString&   theName,
394                                                           const ObjectKind theObjectKind )
395 {
396   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
397   return HYDROData_Tool::FindObjectByName( aDocument, theName, theObjectKind );
398 }
399
400 HYDROData_SequenceOfObjects HYDROGUI_Tool::FindObjectsByNames( HYDROGUI_Module*   theModule,
401                                                                const QStringList& theNames,
402                                                                const ObjectKind   theObjectKind )
403 {
404   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
405   return HYDROData_Tool::FindObjectsByNames( aDocument, theNames, theObjectKind );
406 }
407
408 QString HYDROGUI_Tool::GenerateObjectName( HYDROGUI_Module*   theModule,
409                                            const QString&     thePrefix,
410                                            const QStringList& theUsedNames,
411                                            const bool         theIsTryToUsePurePrefix)
412 {
413   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
414   return HYDROData_Tool::GenerateObjectName( aDocument, thePrefix, theUsedNames, theIsTryToUsePurePrefix );
415 }
416
417 size_t HYDROGUI_Tool::GetActiveViewId( HYDROGUI_Module* theModule,
418                                        const QString&   theViewId )
419 {
420   size_t aViewId = 0;
421   SUIT_ViewManager* aViewMgr = theModule->getApp()->activeViewManager();
422   if( !aViewMgr || ( !theViewId.isEmpty() && aViewMgr->getType() != theViewId ) )
423     return aViewId;
424
425   if( SUIT_ViewModel* aViewer = aViewMgr->getViewModel() )
426     aViewId = (size_t)aViewer;
427   return aViewId;
428 }
429
430 size_t HYDROGUI_Tool::GetActiveGraphicsViewId( HYDROGUI_Module* theModule )
431 {
432   return GetActiveViewId( theModule, GraphicsView_Viewer::Type() );
433 }
434
435 size_t HYDROGUI_Tool::GetActiveOCCViewId( HYDROGUI_Module* theModule )
436 {
437   return GetActiveViewId( theModule, OCCViewer_Viewer::Type() );
438 }
439
440 QList<size_t> getViewIdList( HYDROGUI_Module* theModule,
441                              const QString&   theViewId )
442 {
443   QList<size_t> aList;
444   ViewManagerList aViewMgrs;
445   theModule->getApp()->viewManagers( theViewId, aViewMgrs );
446   QListIterator<SUIT_ViewManager*> anIter( aViewMgrs );
447   while( anIter.hasNext() )
448   {
449     if( SUIT_ViewManager* aViewMgr = anIter.next() )
450     {
451       if( SUIT_ViewModel* aViewer = aViewMgr->getViewModel() )
452         aList.append( (size_t)aViewer );
453     }
454   }
455   return aList;
456 }
457
458 QList<size_t> HYDROGUI_Tool::GetGraphicsViewIdList( HYDROGUI_Module* theModule )
459 {
460   return getViewIdList( theModule, GraphicsView_Viewer::Type() );
461 }
462
463 QList<size_t> HYDROGUI_Tool::GetOCCViewIdList( HYDROGUI_Module* theModule )
464 {
465   return getViewIdList( theModule, OCCViewer_Viewer::Type() );
466 }
467
468 void HYDROGUI_Tool::setOCCActionShown( OCCViewer_ViewFrame* theViewFrame,
469                                        const int theActionId,
470                                        const bool isShown )
471 {
472   if ( !theViewFrame )
473     return;
474
475   OCCViewer_ViewWindow* aView = theViewFrame->getView( OCCViewer_ViewFrame::MAIN_VIEW );
476   if ( aView ) {
477     aView->toolMgr()->setShown( theActionId, isShown );
478     if ( theActionId == OCCViewer_ViewWindow::MaximizedId )
479       theViewFrame->onMaximizedView( aView, true );
480   }
481 }
482
483 void HYDROGUI_Tool::setOCCActionShown( HYDROGUI_Module* theModule,
484                                        const int theActionId,
485                                        const bool isShown )
486 {
487   QList<size_t> aList;
488   ViewManagerList aViewMgrs;
489   theModule->getApp()->viewManagers( OCCViewer_Viewer::Type(), aViewMgrs );
490   QListIterator<SUIT_ViewManager*> anIter( aViewMgrs );
491   while( anIter.hasNext() )
492   {
493     if( SUIT_ViewManager* aViewMgr = anIter.next() )
494     {
495       OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>
496                                                            ( aViewMgr->getActiveView() );
497       if ( aViewFrame )
498         setOCCActionShown( aViewFrame, theActionId, isShown );
499     }
500   }
501 }
502
503 void HYDROGUI_Tool::GetObjectReferences( const Handle(HYDROData_Image)& theImage,
504                                          HYDROData_SequenceOfObjects& theRefObjects,
505                                          QStringList& theRefNames )
506 {
507   if( theImage.IsNull() )
508     return;
509
510   for( int anIndex = 0, aNbRef = theImage->NbReferences(); anIndex < aNbRef; anIndex++ )
511   {
512     Handle(HYDROData_Entity) aRefObj = theImage->Reference( anIndex );
513     if( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
514     {
515       QString aName = aRefObj->GetName();
516       if( !theRefNames.contains( aName ) )
517       {
518         theRefObjects.Append( aRefObj );
519         theRefNames.append( aRefObj->GetName() );
520         if( aRefObj->GetKind() == KIND_IMAGE )
521         {
522           Handle(HYDROData_Image) aRefImage = Handle(HYDROData_Image)::DownCast( aRefObj );
523           if( !aRefImage.IsNull() )
524             GetObjectReferences( aRefImage, theRefObjects, theRefNames );
525         }
526       }
527     }
528   }
529 }
530
531 void HYDROGUI_Tool::GetObjectBackReferences( HYDROGUI_Module* theModule,
532                                              const Handle(HYDROData_Entity)& theObj,
533                                              HYDROData_SequenceOfObjects& theBackRefObjects,
534                                              QStringList& theBackRefNames )
535 {
536   if( theObj.IsNull() )
537     return;
538
539   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
540   if( aDocument.IsNull() )
541     return;
542
543   QString aName = theObj->GetName();
544
545   HYDROData_Iterator anIterator( aDocument, KIND_IMAGE );
546   for( ; anIterator.More(); anIterator.Next() )
547   {
548     Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anIterator.Current() );
549     if( !anImage.IsNull() )
550     {
551       HYDROData_SequenceOfObjects aRefObjects;
552       QStringList aRefNames;
553       GetObjectReferences( anImage, aRefObjects, aRefNames );
554       if( aRefNames.contains( aName ) )
555       {
556         theBackRefObjects.Append( anImage );
557         theBackRefNames.append( anImage->GetName() );
558       }
559     }
560   }
561 }
562
563
564 QDockWidget* HYDROGUI_Tool::WindowDock( QWidget* wid )
565 {
566   if ( !wid )
567     return 0;
568
569   QDockWidget* dock = 0;
570   QWidget* w = wid->parentWidget();
571   while ( w && !dock )
572   {
573     dock = ::qobject_cast<QDockWidget*>( w );
574     w = w->parentWidget();
575   }
576   return dock;
577 }
578
579 QColor HYDROGUI_Tool::GenerateFillingColor( HYDROGUI_Module*   theModule,
580                                             const QStringList& theZoneNames )
581 {
582   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
583   return GenerateFillingColor( aDocument, theZoneNames );
584 }
585
586 QColor HYDROGUI_Tool::GenerateFillingColor( const Handle(HYDROData_Document)& theDoc,
587                                             const QStringList&                theZoneNames )
588 {
589   QColor aFillingColor( HYDROData_ImmersibleZone::DefaultFillingColor() );
590
591   int aCounter = 0;
592   int aR = 0, aG = 0, aB = 0;
593   QStringListIterator aZoneNameIter( theZoneNames );
594   while( aZoneNameIter.hasNext() )
595   {
596     const QString& aZoneName = aZoneNameIter.next();
597     Handle(HYDROData_ImmersibleZone) aRefZone = 
598       Handle(HYDROData_ImmersibleZone)::DownCast(
599         HYDROData_Tool::FindObjectByName( theDoc, aZoneName, KIND_IMMERSIBLE_ZONE ) );
600     if( !aRefZone.IsNull() )
601     {
602       QColor aRefColor = aRefZone->GetFillingColor();
603       aR += aRefColor.red();
604       aG += aRefColor.green();
605       aB += aRefColor.blue();
606       aCounter++;
607     }
608   }
609   
610   if( aCounter > 0 )
611   {
612     aFillingColor = QColor( aR / aCounter, aG / aCounter, aB / aCounter );
613   }
614
615   return aFillingColor;
616 }
617
618 QStringList HYDROGUI_Tool::FindExistingObjectsNames( const Handle(HYDROData_Document)& theDoc, 
619                                                      const ObjectKind theObjectKind )
620 {
621   QStringList aNames;
622
623   HYDROData_Iterator anIter( theDoc, theObjectKind );
624   for ( ; anIter.More(); anIter.Next() ) {
625     Handle(HYDROData_Entity) anObject = anIter.Current();
626     if( !anObject.IsNull() ) {
627       aNames.append( anObject->GetName() );
628     }
629   }
630
631   return aNames;
632 }