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