Salome HOME
ba15923855300b568f22dfb160d1ca30602d7581
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataModel.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_DataModel.h"
24
25 #include "HYDROGUI_DataObject.h"
26 #include "HYDROGUI_Module.h"
27 #include "HYDROGUI_Tool.h"
28
29 #include <HYDROData_Bathymetry.h>
30 #include <HYDROData_Calculation.h>
31 #include <HYDROData_Document.h>
32 #include <HYDROData_Image.h>
33 #include <HYDROData_Iterator.h>
34 #include <HYDROData_Polyline.h>
35 #include <HYDROData_VisualState.h>
36 #include <HYDROData_Region.h>
37 #include <HYDROData_Zone.h>
38
39 #include <CAM_Application.h>
40 #include <CAM_DataObject.h>
41 #include <CAM_Module.h>
42 #include <CAM_Study.h>
43
44 #include <LightApp_Application.h>
45 #include <LightApp_DataObject.h>
46 #include <LightApp_Study.h>
47
48 #include <SUIT_DataObject.h>
49 #include <SUIT_DataBrowser.h>
50 #include <SUIT_ResourceMgr.h>
51 #include <SUIT_Study.h>
52 #include <SUIT_Tools.h>
53
54 #include <HYDROData_Document.h>
55
56 #include <TDF_Delta.hxx>
57 #include <TDF_ListIteratorOfDeltaList.hxx>
58
59 #include <QApplication>
60 #include <QDir>
61
62 static HYDROData_SequenceOfObjects myCopyingObjects;
63
64 HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule )
65 : LightApp_DataModel( theModule )
66 {
67   update( module()->application()->activeStudy()->id() );
68 }
69
70 HYDROGUI_DataModel::~HYDROGUI_DataModel()
71 {
72 }
73
74 bool HYDROGUI_DataModel::open( const QString& theURL,
75                                CAM_Study* theStudy,
76                                QStringList theFileList )
77 {
78   LightApp_DataModel::open( theURL, theStudy, theFileList );
79   const int aStudyId = theStudy->id();
80
81   Data_DocError res = DocError_UnknownProblem;
82   if( theFileList.count() == 2 )
83   {
84     QString aTmpDir = theFileList[0];
85     QString aFileName = theFileList[1];
86
87     myStudyURL = theURL;
88     QString aFullPath = SUIT_Tools::addSlash( aTmpDir ) + aFileName;
89
90     try
91     {
92       res = HYDROData_Document::Load( (char*)aFullPath.toLatin1().constData(), aStudyId );
93     }
94     catch(...)
95     {
96       res = DocError_UnknownProblem;
97     }
98     if( res != DocError_OK )
99     {
100       module()->application()->putInfo( tr( "LOAD_ERROR" ) );
101       return false;
102     }
103   }
104
105   // if the document open was successful, the data model update happens
106   // in the set mode of the module
107   if( res == DocError_OK )
108     update( aStudyId );
109
110   return true;
111 }
112
113 bool HYDROGUI_DataModel::save( QStringList& theFileList )
114 {
115   if( !module()->application()->activeStudy() )
116     return false;
117   
118   LightApp_DataModel::save( theFileList );
119
120   QString aTmpDir;
121   QString aFileName;
122   SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
123   bool isMultiFile = false;
124   if( resMgr )
125     isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
126
127   // save data to temporary files
128   LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy() );
129   aTmpDir = aStudy->GetTmpDir( myStudyURL.toLatin1().constData(), isMultiFile ).c_str();
130   aFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf";
131
132   QString aFullPath = aTmpDir + aFileName;
133   Data_DocError res = getDocument()->Save( (char*)aFullPath.toLatin1().constData() );
134   if( res != DocError_OK )
135   {
136     module()->application()->putInfo( tr( "SAVE_ERROR" ) );
137     return false;
138   }
139
140   theFileList.append( aTmpDir );
141   theFileList.append( aFileName );
142
143   return true;
144 }
145
146 bool HYDROGUI_DataModel::saveAs( const QString& theURL,
147                                  CAM_Study*,
148                                  QStringList& theFileList )
149 {
150   myStudyURL = theURL;
151   return save( theFileList );
152 }
153
154 bool HYDROGUI_DataModel::close()
155 {
156   return true;
157 }
158
159 bool HYDROGUI_DataModel::dumpPython( const QString& theURL,
160                                      CAM_Study*     theStudy,
161                                      bool           isMultiFile,
162                                      QStringList&   theListOfFiles )
163 {
164   LightApp_DataModel::dumpPython( theURL, theStudy, isMultiFile, theListOfFiles );
165
166   int aStudyId = theStudy->id();
167
168   LightApp_Study* aStudy = ::qobject_cast<LightApp_Study*>( theStudy );
169   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
170   if ( aDocument.IsNull() || !aStudy )
171     return false;
172
173   QString aFileToExport = aStudy->GetTmpDir( theURL.toLatin1().constData(), isMultiFile ).c_str();
174   aFileToExport += QString( QDir::separator() ) + "HYDRO.py";
175
176   bool aRes = aDocument->DumpToPython( aFileToExport );
177
178   if ( aRes )
179   {
180     theListOfFiles.append( aFileToExport );
181   }
182
183   return aRes;
184 }
185
186 bool HYDROGUI_DataModel::isModified() const
187 {
188   return getDocument()->IsModified();
189 }
190
191 bool HYDROGUI_DataModel::isSaved() const
192 {
193   return true;
194 }
195
196 void HYDROGUI_DataModel::update( const int theStudyId )
197 {
198   LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
199   if( !anApp )
200     return;
201
202   SUIT_DataObject* aStudyRoot = anApp->activeStudy()->root();
203   if( !aStudyRoot )
204     return;
205
206   // create root object if not exist
207   CAM_DataObject* aRootObj = root();
208   if( !aRootObj )
209     aRootObj = createRootModuleObject( aStudyRoot );
210
211   if( !aRootObj )
212     return;
213
214   DataObjectList aList;
215   aRootObj->children( aList );
216   QListIterator<SUIT_DataObject*> anIter( aList );
217   while( anIter.hasNext() )
218     removeChild( aRootObj, anIter.next() );
219
220   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theStudyId );
221   if( aDocument.IsNull() )
222     return;
223
224   LightApp_DataObject* anImageRootObj = createObject( aRootObj, partitionName( KIND_IMAGE ) );
225
226   HYDROData_Iterator anIterator( aDocument, KIND_IMAGE );
227   for( ; anIterator.More(); anIterator.Next() )
228   {
229     Handle(HYDROData_Image) anImageObj =
230       Handle(HYDROData_Image)::DownCast( anIterator.Current() );
231     if( !anImageObj.IsNull() )
232       createObject( anImageRootObj, anImageObj );
233   }
234
235   LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, partitionName( KIND_BATHYMETRY ) );
236
237   anIterator = HYDROData_Iterator( aDocument, KIND_BATHYMETRY );
238   for( ; anIterator.More(); anIterator.Next() )
239   {
240     Handle(HYDROData_Bathymetry) aBathymetryObj =
241       Handle(HYDROData_Bathymetry)::DownCast( anIterator.Current() );
242     if( !aBathymetryObj.IsNull() )
243       createObject( aBathymetryRootObj, aBathymetryObj );
244   }
245
246   LightApp_DataObject* aCalculRootObj = createObject( aRootObj, partitionName( KIND_CALCULATION ) );
247
248   anIterator = HYDROData_Iterator( aDocument, KIND_CALCULATION );
249   for( ; anIterator.More(); anIterator.Next() )
250   {
251     Handle(HYDROData_Calculation) aCalculObj =
252       Handle(HYDROData_Calculation)::DownCast( anIterator.Current() );
253     if( !aCalculObj.IsNull() )
254       createObject( aCalculRootObj, aCalculObj );
255   }
256
257   LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, partitionName( KIND_POLYLINE ) );
258
259   anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE );
260   for( ; anIterator.More(); anIterator.Next() )
261   {
262     Handle(HYDROData_Polyline) aPolylineObj =
263       Handle(HYDROData_Polyline)::DownCast( anIterator.Current() );
264     if( !aPolylineObj.IsNull() )
265       createObject( aPolylineRootObj, aPolylineObj );
266   }
267
268   LightApp_DataObject* aZonesRootObj = createObject( aRootObj, partitionName( KIND_ZONE ) );
269
270   anIterator = HYDROData_Iterator( aDocument, KIND_ZONE );
271   for( ; anIterator.More(); anIterator.Next() )
272   {
273     Handle(HYDROData_Zone) aZoneObj =
274       Handle(HYDROData_Zone)::DownCast( anIterator.Current() );
275     if( !aZoneObj.IsNull() )
276       createObject( aZonesRootObj, aZoneObj );
277   }
278
279   LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, partitionName( KIND_VISUAL_STATE ) );
280
281   anIterator = HYDROData_Iterator( aDocument, KIND_VISUAL_STATE );
282   for( ; anIterator.More(); anIterator.Next() )
283   {
284     Handle(HYDROData_VisualState) aVisualStateObj =
285       Handle(HYDROData_VisualState)::DownCast( anIterator.Current() );
286     if( !aVisualStateObj.IsNull() )
287       createObject( aVisualStateRootObj, aVisualStateObj );
288   }
289
290   if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() )
291   {
292     anObjectBrowser->setAutoOpenLevel( 3 );
293     anObjectBrowser->openLevels();
294   }
295 }
296
297 HYDROGUI_DataObject* HYDROGUI_DataModel::getDataObject( const Handle(HYDROData_Object)& theModelObject )
298 {
299   return NULL; // to do if necessary
300 }
301
302 HYDROGUI_DataObject* HYDROGUI_DataModel::getReferencedDataObject( HYDROGUI_DataObject* theObject )
303 {
304   return NULL; // to do if necessary
305 }
306
307 SUIT_DataObject* HYDROGUI_DataModel::findObject( const QString& theEntry ) const
308 {
309   LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
310   return anApp ? anApp->findObject( theEntry ) : 0;
311 }
312
313 void HYDROGUI_DataModel::update( LightApp_DataObject* theObject,
314                                  LightApp_Study* theStudy )
315 {
316   if( !theStudy )
317     theStudy = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy()) ;
318   if( theStudy )
319     update( theStudy->id() );
320 }
321
322 CAM_DataObject* HYDROGUI_DataModel::createRootModuleObject( SUIT_DataObject* theParent )
323 {
324   CAM_DataObject* aRootObj = createModuleObject( theParent );
325   setRoot( aRootObj );
326   return aRootObj;
327 }
328
329 void HYDROGUI_DataModel::updateModel()
330 {
331   HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
332   if( aModule )
333     update( aModule->getStudyId() );
334 }
335
336 Handle(HYDROData_Object) HYDROGUI_DataModel::objectByEntry( const QString& theEntry,
337                                                             const ObjectKind theObjectKind )
338 {
339   QString anEntry = theEntry;
340   if( anEntry.indexOf( "_" ) != -1 ) // reference object
341     anEntry = anEntry.section( "_", -1 );
342
343   Handle(HYDROData_Document) aDocument = getDocument();
344   if( !aDocument.IsNull() )
345   {
346     HYDROData_Iterator anIterator( aDocument, theObjectKind );
347     for( ; anIterator.More(); anIterator.Next() )
348     {
349       Handle(HYDROData_Object) anObject = anIterator.Current();
350       if( !anObject.IsNull() )
351       {
352         QString anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
353         if( anEntryRef == anEntry )
354           return anObject;
355       }
356     }
357   }
358   return NULL;
359 }
360
361 bool HYDROGUI_DataModel::canUndo() const
362 {
363   return getDocument()->CanUndo();
364 }
365
366 bool HYDROGUI_DataModel::canRedo() const
367 {
368   return getDocument()->CanRedo();
369 }
370
371 QStringList HYDROGUI_DataModel::undoNames() const
372 {
373   QStringList aNames;
374   for( TDF_ListIteratorOfDeltaList anIter( getDocument()->GetUndos() ); anIter.More(); anIter.Next() )
375     aNames.prepend( HYDROGUI_Tool::ToQString( anIter.Value()->Name() ) );
376   return aNames;
377 }
378
379 QStringList HYDROGUI_DataModel::redoNames() const
380 {
381   QStringList aNames;
382   for( TDF_ListIteratorOfDeltaList anIter( getDocument()->GetRedos() ); anIter.More(); anIter.Next() )
383     aNames.append( HYDROGUI_Tool::ToQString( anIter.Value()->Name() ) );
384   return aNames;
385 }
386
387 void HYDROGUI_DataModel::clearUndos()
388 {
389   getDocument()->ClearUndos();
390 }
391
392 void HYDROGUI_DataModel::clearRedos()
393 {
394   getDocument()->ClearRedos();
395 }
396
397 bool HYDROGUI_DataModel::undo()
398 {
399   try 
400   {
401     getDocument()->Undo();
402   }
403   catch ( Standard_Failure )
404   {
405     return false;
406   }
407   return true;
408 }
409
410 bool HYDROGUI_DataModel::redo()
411 {
412   try 
413   {
414     getDocument()->Redo();
415   }
416   catch ( Standard_Failure )
417   {
418     return false;
419   }
420   return true;
421 }
422
423 bool HYDROGUI_DataModel::canCopy()
424 {
425   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( (HYDROGUI_Module*)module() );
426   if( aSeq.Length() != 1 )
427     return false;
428
429   Handle(HYDROData_Object) anObject = aSeq.First();
430   if( anObject.IsNull() )
431     return false;
432
433   ObjectKind aKind = anObject->GetKind();
434   if( aKind == KIND_IMAGE ||
435       aKind == KIND_POLYLINE ||
436       aKind == KIND_CALCULATION )
437     return true;
438
439   return false;
440 }
441
442 bool HYDROGUI_DataModel::canPaste()
443 {
444   for( int anIndex = 1, aLength = myCopyingObjects.Length(); anIndex <= aLength; anIndex++ )
445   {
446     Handle(HYDROData_Object) anObject = myCopyingObjects.Value( anIndex );
447     if( !anObject.IsNull() && !anObject->IsRemoved() )
448       return true;
449   }
450   return false;
451 }
452
453 bool HYDROGUI_DataModel::copy()
454 {
455   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( (HYDROGUI_Module*)module() );
456   changeCopyingObjects( aSeq );
457   return true;
458 }
459
460 bool HYDROGUI_DataModel::paste()
461 {
462   bool anIsChanged = false;
463   for( int anIndex = 1, aLength = myCopyingObjects.Length(); anIndex <= aLength; anIndex++ )
464   {
465     Handle(HYDROData_Object) anObject = myCopyingObjects.Value( anIndex );
466     if( !anObject.IsNull() && !anObject->IsRemoved() )
467     {
468       ObjectKind aKind = anObject->GetKind();
469       Handle(HYDROData_Object) aClone = getDocument()->CreateObject( aKind );
470       if( !aClone.IsNull() )
471       {
472         anObject->CopyTo( aClone );
473         anIsChanged = true;
474
475         // generate a new unique name for the clone object:
476         // case 1: Image_1 -> Image_2
477         // case 2: ImageObj -> ImageObj_1
478         QString aName = aClone->GetName();
479         QString aPrefix = aName;
480         if( aName.contains( '_' ) ) // case 1
481         {
482           QString aSuffix = aName.section( '_', -1 );
483           bool anIsInteger = false;
484           aSuffix.toInt( &anIsInteger );
485           if( anIsInteger )
486             aPrefix = aName.section( '_', 0, -2 );
487         }
488         else // case 2
489           aPrefix = aName;
490         aName = HYDROGUI_Tool::GenerateObjectName( (HYDROGUI_Module*)module(), aPrefix );
491         aClone->SetName( aName );
492       }
493     }
494   }
495   return anIsChanged;
496 }
497
498 void HYDROGUI_DataModel::changeCopyingObjects( const HYDROData_SequenceOfObjects& theSeq )
499 {
500   myCopyingObjects.Assign( theSeq );
501 }
502
503 QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind )
504 {
505   switch( theObjectKind )
506   {
507     case KIND_IMAGE:        return "IMAGES";
508     case KIND_POLYLINE:     return "POLYLINES";
509     case KIND_VISUAL_STATE: return "VISUAL_STATES";
510     case KIND_BATHYMETRY:   return "BATHYMETRIES";
511     case KIND_CALCULATION:  return "CALCULATION_CASES";
512     case KIND_ZONE:         return "ZONES";
513     default: break;
514   }
515   return QString();
516 }
517
518 Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const
519 {
520   int aStudyId = module()->application()->activeStudy()->id();
521   return HYDROData_Document::Document( aStudyId );
522 }
523
524 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject*         theParent,
525                                                        Handle(HYDROData_Object) theModelObject,
526                                                        const QString&           theParentEntry,
527                                                        const bool               theIsBuildTree )
528 {
529   HYDROGUI_DataObject* aResObj = 
530     new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
531   
532   if ( theIsBuildTree )
533   {
534     buildObjectTree( theParent, aResObj, theParentEntry );
535   }
536
537   return aResObj;
538 }
539
540 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
541                                                        const QString&   theName,
542                                                        const QString&   theParentEntry )
543 {
544   return new HYDROGUI_NamedObject( theParent, theName, theParentEntry );
545 }
546
547 void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
548                                           SUIT_DataObject* theObject,
549                                           const QString&   theParentEntry )
550 {
551   HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>( theObject );
552   if ( !aGuiObj )
553     return;
554
555   Handle(HYDROData_Object) aDataObj = aGuiObj->modelObject();
556   if ( aDataObj.IsNull() )
557     return;
558
559   ObjectKind anObjectKind = aDataObj->GetKind();
560
561   if ( anObjectKind == KIND_IMAGE )
562   {
563     Handle(HYDROData_Image) anImageObj =
564       Handle(HYDROData_Image)::DownCast( aDataObj );
565     for ( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ )
566     {
567       Handle(HYDROData_Object) aRefObj = anImageObj->Reference( anIndex );
568       if ( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
569         createObject( aGuiObj, aRefObj, aGuiObj->entry(), false );
570     }
571   }
572   else if ( anObjectKind == KIND_ZONE )
573   {
574     Handle(HYDROData_Zone) aZoneObj =
575       Handle(HYDROData_Zone)::DownCast( aDataObj );
576
577     LightApp_DataObject* aPolylineSect = 
578       createObject( aGuiObj, tr( "ZONE_POLYLINE" ), aGuiObj->entry() );
579
580     Handle(HYDROData_Polyline) aPolyline = aZoneObj->GetPolyline();
581     if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
582       createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
583
584     LightApp_DataObject* aBathsSect = 
585       createObject( aGuiObj, tr( "ZONE_BATHYMETRIES" ), aGuiObj->entry() );
586
587     HYDROData_SequenceOfObjects aZoneBaths = aZoneObj->GetBathymetries();
588     HYDROData_SequenceOfObjects::Iterator aBathsIter( aZoneBaths );
589     for ( ; aBathsIter.More(); aBathsIter.Next() )
590     {
591       Handle(HYDROData_Bathymetry) aRefBath =
592         Handle(HYDROData_Bathymetry)::DownCast( aBathsIter.Value() );
593       if( !aRefBath.IsNull() && !aRefBath->IsRemoved() )
594         createObject( aBathsSect, aRefBath, aGuiObj->entry(), false );
595     }
596   }
597   else if ( anObjectKind == KIND_CALCULATION )
598   {
599     Handle(HYDROData_Calculation) aCaseObj =
600       Handle(HYDROData_Calculation)::DownCast( aDataObj );
601
602     LightApp_DataObject* aPolylineSect = 
603       createObject( aGuiObj, tr( "CASE_BND_POLYLINE" ), aGuiObj->entry() );
604
605     Handle(HYDROData_Polyline) aPolyline = aCaseObj->GetBoundaryPolyline();
606     if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
607       createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
608
609     LightApp_DataObject* aRefZonesSect = 
610       createObject( aGuiObj, tr( "CASE_REFERENCE_ZONES" ), aGuiObj->entry() );
611
612     HYDROData_SequenceOfObjects aRefZones = aCaseObj->GetZones();
613     HYDROData_SequenceOfObjects::Iterator anIter( aRefZones );
614     for ( ; anIter.More(); anIter.Next() )
615     {
616       Handle(HYDROData_Zone) aRefZone =
617         Handle(HYDROData_Zone)::DownCast( anIter.Value() );
618       if( !aRefZone.IsNull() && !aRefZone->IsRemoved() )
619         createObject( aRefZonesSect, aRefZone, aGuiObj->entry(), false );
620     }
621
622     LightApp_DataObject* aCaseRegionsSect = 
623       createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() );
624
625     HYDROData_SequenceOfObjects aCaseRegions = aCaseObj->GetRegions();
626     anIter.Init( aCaseRegions );
627     for ( ; anIter.More(); anIter.Next() )
628     {
629       Handle(HYDROData_Region) aCaseRegion =
630         Handle(HYDROData_Region)::DownCast( anIter.Value() );
631       if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
632         createObject( aCaseRegionsSect, aCaseRegion, aGuiObj->entry(), false );
633     }
634   }
635 }
636
637 void HYDROGUI_DataModel::removeChild( SUIT_DataObject* theParent,
638                                       SUIT_DataObject* theChild )
639 {
640   SUIT_DataObject* aSubChild = theChild->firstChild();
641   for( ; aSubChild; aSubChild = aSubChild->nextBrother() )
642     removeChild( theChild, aSubChild );
643   theParent->removeChild( theChild );
644 }
645
646 SUIT_DataObject* HYDROGUI_DataModel::findChildByName( const SUIT_DataObject* theFather,
647                                                       const QString& theName )
648 {
649   SUIT_DataObject* aChild = theFather->firstChild();
650   while( aChild )
651   {
652     if( aChild->name() == theName )
653       return aChild; // found
654     aChild = aChild->nextBrother();
655   }
656   return NULL; // not found
657 }