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