1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_DataModel.h"
25 #include "HYDROGUI_DataObject.h"
26 #include "HYDROGUI_Module.h"
27 #include "HYDROGUI_Tool.h"
28 #include "HYDROGUI_Zone.h"
29 #include "HYDROGUI_Region.h"
31 #include <HYDROData_Bathymetry.h>
32 #include <HYDROData_CalculationCase.h>
33 #include <HYDROData_Document.h>
34 #include <HYDROData_Image.h>
35 #include <HYDROData_ImmersibleZone.h>
36 #include <HYDROData_Iterator.h>
37 #include <HYDROData_Polyline.h>
38 #include <HYDROData_Profile.h>
39 #include <HYDROData_VisualState.h>
40 #include <HYDROData_Region.h>
41 #include <HYDROData_Zone.h>
42 #include <HYDROData_Obstacle.h>
44 #include <CAM_Application.h>
45 #include <CAM_DataObject.h>
46 #include <CAM_Module.h>
47 #include <CAM_Study.h>
49 #include <LightApp_Application.h>
50 #include <LightApp_DataObject.h>
51 #include <LightApp_Study.h>
53 #include <SUIT_DataObject.h>
54 #include <SUIT_DataBrowser.h>
55 #include <SUIT_ResourceMgr.h>
56 #include <SUIT_Study.h>
57 #include <SUIT_Tools.h>
59 #include <HYDROData_Document.h>
61 #include <TDF_Delta.hxx>
62 #include <TDF_ListIteratorOfDeltaList.hxx>
64 #include <QApplication>
67 static HYDROData_SequenceOfObjects myCopyingObjects;
69 HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule )
70 : LightApp_DataModel( theModule )
72 update( module()->application()->activeStudy()->id() );
75 HYDROGUI_DataModel::~HYDROGUI_DataModel()
79 bool HYDROGUI_DataModel::open( const QString& theURL,
81 QStringList theFileList )
83 LightApp_DataModel::open( theURL, theStudy, theFileList );
84 const int aStudyId = theStudy->id();
86 Data_DocError res = DocError_UnknownProblem;
87 if( theFileList.count() == 2 )
89 QString aTmpDir = theFileList[0];
90 QString aFileName = theFileList[1];
93 QString aFullPath = SUIT_Tools::addSlash( aTmpDir ) + aFileName;
97 res = HYDROData_Document::Load( (char*)aFullPath.toLatin1().constData(), aStudyId );
101 res = DocError_UnknownProblem;
103 if( res != DocError_OK )
105 module()->application()->putInfo( tr( "LOAD_ERROR" ) );
110 // if the document open was successful, the data model update happens
111 // in the set mode of the module
112 if( res == DocError_OK )
118 bool HYDROGUI_DataModel::save( QStringList& theFileList )
120 if( !module()->application()->activeStudy() )
123 LightApp_DataModel::save( theFileList );
127 SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
128 bool isMultiFile = false;
130 isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
132 // save data to temporary files
133 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy() );
134 aTmpDir = aStudy->GetTmpDir( myStudyURL.toLatin1().constData(), isMultiFile ).c_str();
135 aFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf";
137 QString aFullPath = aTmpDir + aFileName;
138 Data_DocError res = getDocument()->Save( (char*)aFullPath.toLatin1().constData() );
139 if( res != DocError_OK )
141 module()->application()->putInfo( tr( "SAVE_ERROR" ) );
145 theFileList.append( aTmpDir );
146 theFileList.append( aFileName );
151 bool HYDROGUI_DataModel::saveAs( const QString& theURL,
153 QStringList& theFileList )
156 return save( theFileList );
159 bool HYDROGUI_DataModel::close()
164 bool HYDROGUI_DataModel::dumpPython( const QString& theURL,
167 QStringList& theListOfFiles )
169 LightApp_DataModel::dumpPython( theURL, theStudy, isMultiFile, theListOfFiles );
171 int aStudyId = theStudy->id();
173 LightApp_Study* aStudy = ::qobject_cast<LightApp_Study*>( theStudy );
174 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
175 if ( aDocument.IsNull() || !aStudy )
178 QString aFileToExport = aStudy->GetTmpDir( theURL.toLatin1().constData(), isMultiFile ).c_str();
179 aFileToExport += QString( QDir::separator() ) + "HYDRO.py";
181 bool aRes = aDocument->DumpToPython( aFileToExport );
185 theListOfFiles.append( aFileToExport );
191 bool HYDROGUI_DataModel::isModified() const
193 return getDocument()->IsModified();
196 bool HYDROGUI_DataModel::isSaved() const
201 void HYDROGUI_DataModel::update( const int theStudyId )
203 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
207 SUIT_DataObject* aStudyRoot = anApp->activeStudy()->root();
211 // create root object if not exist
212 CAM_DataObject* aRootObj = root();
214 aRootObj = createRootModuleObject( aStudyRoot );
219 DataObjectList aList;
220 aRootObj->children( aList );
221 QListIterator<SUIT_DataObject*> anIter( aList );
222 while( anIter.hasNext() )
223 removeChild( aRootObj, anIter.next() );
225 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theStudyId );
226 if( aDocument.IsNull() )
229 LightApp_DataObject* anImageRootObj = createObject( aRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) );
231 HYDROData_Iterator anIterator( aDocument, KIND_IMAGE );
232 for( ; anIterator.More(); anIterator.Next() )
234 Handle(HYDROData_Image) anImageObj =
235 Handle(HYDROData_Image)::DownCast( anIterator.Current() );
236 if( !anImageObj.IsNull() )
237 createObject( anImageRootObj, anImageObj );
240 LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, tr( partitionName( KIND_BATHYMETRY ).toAscii() ) );
242 anIterator = HYDROData_Iterator( aDocument, KIND_BATHYMETRY );
243 for( ; anIterator.More(); anIterator.Next() )
245 Handle(HYDROData_Bathymetry) aBathymetryObj =
246 Handle(HYDROData_Bathymetry)::DownCast( anIterator.Current() );
247 if( !aBathymetryObj.IsNull() )
248 createObject( aBathymetryRootObj, aBathymetryObj );
251 LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) );
253 anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE );
254 for( ; anIterator.More(); anIterator.Next() )
256 Handle(HYDROData_Polyline) aPolylineObj =
257 Handle(HYDROData_Polyline)::DownCast( anIterator.Current() );
258 if( !aPolylineObj.IsNull() )
259 createObject( aPolylineRootObj, aPolylineObj );
262 LightApp_DataObject* aProfileRootObj = createObject( aRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) );
264 anIterator = HYDROData_Iterator( aDocument, KIND_PROFILE );
265 for( ; anIterator.More(); anIterator.Next() )
267 Handle(HYDROData_Profile) aProfileObj =
268 Handle(HYDROData_Profile)::DownCast( anIterator.Current() );
269 if( !aProfileObj.IsNull() )
270 createObject( aProfileRootObj, aProfileObj );
273 LightApp_DataObject* aZonesRootObj = createObject( aRootObj, tr( partitionName( KIND_IMMERSIBLE_ZONE ).toAscii() ) );
275 anIterator = HYDROData_Iterator( aDocument, KIND_IMMERSIBLE_ZONE );
276 for( ; anIterator.More(); anIterator.Next() )
278 Handle(HYDROData_ImmersibleZone) aZoneObj =
279 Handle(HYDROData_ImmersibleZone)::DownCast( anIterator.Current() );
280 if( !aZoneObj.IsNull() )
281 createObject( aZonesRootObj, aZoneObj );
284 LightApp_DataObject* anObstaclesRootObj = createObject( aRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) );
286 anIterator = HYDROData_Iterator( aDocument, KIND_OBSTACLE );
287 for( ; anIterator.More(); anIterator.Next() )
289 Handle(HYDROData_Obstacle) anObstacleObj =
290 Handle(HYDROData_Obstacle)::DownCast( anIterator.Current() );
291 if( !anObstacleObj.IsNull() )
292 createObject( anObstaclesRootObj, anObstacleObj );
295 LightApp_DataObject* aCalculRootObj = createObject( aRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
297 anIterator = HYDROData_Iterator( aDocument, KIND_CALCULATION );
298 for( ; anIterator.More(); anIterator.Next() )
300 Handle(HYDROData_CalculationCase) aCalculObj =
301 Handle(HYDROData_CalculationCase)::DownCast( anIterator.Current() );
302 if( !aCalculObj.IsNull() )
303 createObject( aCalculRootObj, aCalculObj );
306 LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) );
308 anIterator = HYDROData_Iterator( aDocument, KIND_VISUAL_STATE );
309 for( ; anIterator.More(); anIterator.Next() )
311 Handle(HYDROData_VisualState) aVisualStateObj =
312 Handle(HYDROData_VisualState)::DownCast( anIterator.Current() );
313 if( !aVisualStateObj.IsNull() )
314 createObject( aVisualStateRootObj, aVisualStateObj );
317 if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() )
319 anObjectBrowser->setAutoOpenLevel( 3 );
320 anObjectBrowser->openLevels();
324 HYDROGUI_DataObject* HYDROGUI_DataModel::getDataObject( const Handle(HYDROData_Entity)& theModelObject )
326 return NULL; // to do if necessary
329 HYDROGUI_DataObject* HYDROGUI_DataModel::getReferencedDataObject( HYDROGUI_DataObject* theObject )
331 return NULL; // to do if necessary
334 SUIT_DataObject* HYDROGUI_DataModel::findObject( const QString& theEntry ) const
336 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
337 return anApp ? anApp->findObject( theEntry ) : 0;
340 void HYDROGUI_DataModel::update( LightApp_DataObject* theObject,
341 LightApp_Study* theStudy )
344 theStudy = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy()) ;
346 update( theStudy->id() );
349 CAM_DataObject* HYDROGUI_DataModel::createRootModuleObject( SUIT_DataObject* theParent )
351 CAM_DataObject* aRootObj = createModuleObject( theParent );
356 void HYDROGUI_DataModel::updateModel()
358 HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
360 update( aModule->getStudyId() );
363 Handle(HYDROData_Entity) HYDROGUI_DataModel::objectByEntry( const QString& theEntry,
364 const ObjectKind theObjectKind )
366 QString anEntry = theEntry;
367 if( anEntry.indexOf( "_" ) != -1 ) // reference object
368 anEntry = anEntry.section( "_", -1 );
370 Handle(HYDROData_Document) aDocument = getDocument();
371 if( !aDocument.IsNull() )
373 HYDROData_Iterator anIterator( aDocument, theObjectKind );
374 for( ; anIterator.More(); anIterator.Next() )
376 Handle(HYDROData_Entity) anObject = anIterator.Current();
377 if( !anObject.IsNull() )
379 QString anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
380 if( anEntryRef == anEntry )
388 bool HYDROGUI_DataModel::canUndo() const
390 return getDocument()->CanUndo();
393 bool HYDROGUI_DataModel::canRedo() const
395 return getDocument()->CanRedo();
398 QStringList HYDROGUI_DataModel::undoNames() const
401 for( TDF_ListIteratorOfDeltaList anIter( getDocument()->GetUndos() ); anIter.More(); anIter.Next() )
402 aNames.prepend( HYDROGUI_Tool::ToQString( anIter.Value()->Name() ) );
406 QStringList HYDROGUI_DataModel::redoNames() const
409 for( TDF_ListIteratorOfDeltaList anIter( getDocument()->GetRedos() ); anIter.More(); anIter.Next() )
410 aNames.append( HYDROGUI_Tool::ToQString( anIter.Value()->Name() ) );
414 void HYDROGUI_DataModel::clearUndos()
416 getDocument()->ClearUndos();
419 void HYDROGUI_DataModel::clearRedos()
421 getDocument()->ClearRedos();
424 bool HYDROGUI_DataModel::undo()
428 getDocument()->Undo();
430 catch ( Standard_Failure )
437 bool HYDROGUI_DataModel::redo()
441 getDocument()->Redo();
443 catch ( Standard_Failure )
450 bool HYDROGUI_DataModel::canCopy()
452 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( (HYDROGUI_Module*)module() );
453 if( aSeq.Length() != 1 )
456 Handle(HYDROData_Entity) anObject = aSeq.First();
457 if( anObject.IsNull() )
460 ObjectKind aKind = anObject->GetKind();
461 if( aKind == KIND_IMAGE ||
462 aKind == KIND_POLYLINE ||
463 aKind == KIND_PROFILE ||
464 aKind == KIND_CALCULATION )
470 bool HYDROGUI_DataModel::canPaste()
472 for( int anIndex = 1, aLength = myCopyingObjects.Length(); anIndex <= aLength; anIndex++ )
474 Handle(HYDROData_Entity) anObject = myCopyingObjects.Value( anIndex );
475 if( !anObject.IsNull() && !anObject->IsRemoved() )
481 bool HYDROGUI_DataModel::copy()
483 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( (HYDROGUI_Module*)module() );
484 changeCopyingObjects( aSeq );
488 bool HYDROGUI_DataModel::paste()
490 bool anIsChanged = false;
491 for( int anIndex = 1, aLength = myCopyingObjects.Length(); anIndex <= aLength; anIndex++ )
493 Handle(HYDROData_Entity) anObject = myCopyingObjects.Value( anIndex );
494 if( !anObject.IsNull() && !anObject->IsRemoved() )
496 ObjectKind aKind = anObject->GetKind();
497 Handle(HYDROData_Entity) aClone = getDocument()->CreateObject( aKind );
498 if( !aClone.IsNull() )
500 anObject->CopyTo( aClone );
503 // generate a new unique name for the clone object:
504 // case 1: Image_1 -> Image_2
505 // case 2: ImageObj -> ImageObj_1
506 QString aName = aClone->GetName();
507 QString aPrefix = aName;
508 if( aName.contains( '_' ) ) // case 1
510 QString aSuffix = aName.section( '_', -1 );
511 bool anIsInteger = false;
512 aSuffix.toInt( &anIsInteger );
514 aPrefix = aName.section( '_', 0, -2 );
518 aName = HYDROGUI_Tool::GenerateObjectName( (HYDROGUI_Module*)module(), aPrefix );
519 aClone->SetName( aName );
526 void HYDROGUI_DataModel::changeCopyingObjects( const HYDROData_SequenceOfObjects& theSeq )
528 myCopyingObjects.Assign( theSeq );
531 QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind )
533 switch( theObjectKind )
535 case KIND_IMAGE: return "IMAGES";
536 case KIND_POLYLINE: return "POLYLINES";
537 case KIND_PROFILE: return "PROFILES";
538 case KIND_VISUAL_STATE: return "VISUAL_STATES";
539 case KIND_BATHYMETRY: return "BATHYMETRIES";
540 case KIND_CALCULATION: return "CALCULATION_CASES";
541 case KIND_IMMERSIBLE_ZONE: return "IMMERSIBLE_ZONES";
542 case KIND_OBSTACLE: return "OBSTACLES";
548 Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const
550 int aStudyId = module()->application()->activeStudy()->id();
551 return HYDROData_Document::Document( aStudyId );
554 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
555 Handle(HYDROData_Entity) theModelObject,
556 const QString& theParentEntry,
557 const bool theIsBuildTree )
559 HYDROGUI_DataObject* aResObj = new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
561 if ( theIsBuildTree )
563 buildObjectTree( theParent, aResObj, theParentEntry );
569 LightApp_DataObject* HYDROGUI_DataModel::buildObject( SUIT_DataObject* theParent,
570 HYDROGUI_DataObject* theObject,
571 const QString& theParentEntry,
572 const bool theIsBuildTree )
574 if ( theIsBuildTree )
576 buildObjectTree( theParent, theObject, theParentEntry );
581 LightApp_DataObject* HYDROGUI_DataModel::createZone( SUIT_DataObject* theParent,
582 Handle(HYDROData_Zone) theModelObject,
583 const QString& theParentEntry,
584 const bool theIsBuildTree )
586 return buildObject( theParent, new HYDROGUI_Zone( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
589 LightApp_DataObject* HYDROGUI_DataModel::createRegion( SUIT_DataObject* theParent,
590 Handle(HYDROData_Region) theModelObject,
591 const QString& theParentEntry,
592 const bool theIsBuildTree )
594 return buildObject( theParent, new HYDROGUI_Region( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
597 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
598 const QString& theName,
599 const QString& theParentEntry )
601 return new HYDROGUI_NamedObject( theParent, theName, theParentEntry );
604 void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
605 SUIT_DataObject* theObject,
606 const QString& theParentEntry )
608 HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>( theObject );
612 Handle(HYDROData_Entity) aDataObj = aGuiObj->modelObject();
613 if ( aDataObj.IsNull() )
616 ObjectKind anObjectKind = aDataObj->GetKind();
618 if ( anObjectKind == KIND_IMAGE )
620 Handle(HYDROData_Image) anImageObj =
621 Handle(HYDROData_Image)::DownCast( aDataObj );
622 for ( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ )
624 Handle(HYDROData_Entity) aRefObj = anImageObj->Reference( anIndex );
625 if ( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
626 createObject( aGuiObj, aRefObj, aGuiObj->entry(), false );
629 else if ( anObjectKind == KIND_IMMERSIBLE_ZONE )
631 Handle(HYDROData_ImmersibleZone) aZoneObj =
632 Handle(HYDROData_ImmersibleZone)::DownCast( aDataObj );
634 LightApp_DataObject* aPolylineSect =
635 createObject( aGuiObj, tr( "ZONE_POLYLINE" ), aGuiObj->entry() );
637 Handle(HYDROData_Polyline) aPolyline = aZoneObj->GetPolyline();
638 if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
639 createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
641 LightApp_DataObject* aBathSect =
642 createObject( aGuiObj, tr( "ZONE_BATHYMETRY" ), aGuiObj->entry() );
644 Handle(HYDROData_Bathymetry) aBathymetry = aZoneObj->GetBathymetry();
645 if ( !aBathymetry.IsNull() && !aBathymetry->IsRemoved() )
646 createObject( aBathSect, aBathymetry, aGuiObj->entry(), false );
648 else if ( anObjectKind == KIND_CALCULATION )
650 Handle(HYDROData_CalculationCase) aCaseObj =
651 Handle(HYDROData_CalculationCase)::DownCast( aDataObj );
653 LightApp_DataObject* aCaseRegionsSect =
654 createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() );
656 HYDROData_SequenceOfObjects aCaseRegions = aCaseObj->GetRegions();
657 HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
658 for ( ; anIter.More(); anIter.Next() )
660 Handle(HYDROData_Region) aCaseRegion =
661 Handle(HYDROData_Region)::DownCast( anIter.Value() );
662 if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
663 createRegion( aCaseRegionsSect, aCaseRegion, "", true );
666 else if ( anObjectKind == KIND_REGION )
668 Handle(HYDROData_Region) aRegionObj =
669 Handle(HYDROData_Region)::DownCast( aDataObj );
671 HYDROData_SequenceOfObjects aRegionZones = aRegionObj->GetZones();
672 HYDROData_SequenceOfObjects::Iterator anIter( aRegionZones );
673 for ( ; anIter.More(); anIter.Next() )
675 Handle(HYDROData_Zone) aRegionZone =
676 Handle(HYDROData_Zone)::DownCast( anIter.Value() );
677 if( !aRegionZone.IsNull() && !aRegionZone->IsRemoved() )
678 createZone( aGuiObj, aRegionZone, "", true );
683 void HYDROGUI_DataModel::buildCaseTree( SUIT_DataObject* theParent, Handle(HYDROData_CalculationCase) theCase )
685 if ( !theCase.IsNull() )
687 new HYDROGUI_DropTargetObject( theParent, tr( "NEW_REGION" ), "" );
689 HYDROData_SequenceOfObjects aCaseRegions = theCase->GetRegions();
690 HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
691 for ( ; anIter.More(); anIter.Next() )
693 Handle(HYDROData_Region) aCaseRegion =
694 Handle(HYDROData_Region)::DownCast( anIter.Value() );
695 if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
696 createRegion( theParent, aCaseRegion, "", true );
701 void HYDROGUI_DataModel::removeChild( SUIT_DataObject* theParent,
702 SUIT_DataObject* theChild )
704 SUIT_DataObject* aSubChild = theChild->firstChild();
705 for( ; aSubChild; aSubChild = aSubChild->nextBrother() )
706 removeChild( theChild, aSubChild );
707 theParent->removeChild( theChild );
710 SUIT_DataObject* HYDROGUI_DataModel::findChildByName( const SUIT_DataObject* theFather,
711 const QString& theName )
713 SUIT_DataObject* aChild = theFather->firstChild();
716 if( aChild->name() == theName )
717 return aChild; // found
718 aChild = aChild->nextBrother();
720 return NULL; // not found
723 bool HYDROGUI_DataModel::createNewRegion( Handle(HYDROData_CalculationCase) theCase,
724 const QList<HYDROGUI_Zone*>& theZonesList )
726 bool isOk = !theCase.IsNull();
729 Handle(HYDROData_Region) aRegion;
730 Handle(HYDROData_Zone) aZone;
731 for (int i = 0; i < theZonesList.length(); i++ )
733 aZone = Handle(HYDROData_Zone)::DownCast( theZonesList.at(i)->modelObject() );
734 if ( !aZone.IsNull() )
736 if ( aRegion.IsNull() )
738 aRegion = theCase->AddNewRegion( aZone );
739 isOk = !aRegion.IsNull();
743 if ( !( aRegion->AddZone( aZone ) ) )