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>
43 #include <HYDROData_Channel.h>
44 #include <HYDROData_Digue.h>
45 #include <HYDROData_River.h>
47 #include <CAM_Application.h>
48 #include <CAM_DataObject.h>
49 #include <CAM_Module.h>
50 #include <CAM_Study.h>
52 #include <LightApp_Application.h>
53 #include <LightApp_DataObject.h>
54 #include <LightApp_Study.h>
56 #include <SUIT_DataObject.h>
57 #include <SUIT_DataBrowser.h>
58 #include <SUIT_ResourceMgr.h>
59 #include <SUIT_Study.h>
60 #include <SUIT_Tools.h>
62 #include <HYDROData_Document.h>
64 #include <TDF_Delta.hxx>
65 #include <TDF_ListIteratorOfDeltaList.hxx>
67 #include <QApplication>
70 static HYDROData_SequenceOfObjects myCopyingObjects;
72 HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule )
73 : LightApp_DataModel( theModule )
75 update( module()->application()->activeStudy()->id() );
78 HYDROGUI_DataModel::~HYDROGUI_DataModel()
82 bool HYDROGUI_DataModel::open( const QString& theURL,
84 QStringList theFileList )
86 LightApp_DataModel::open( theURL, theStudy, theFileList );
87 const int aStudyId = theStudy->id();
89 Data_DocError res = DocError_UnknownProblem;
90 if( theFileList.count() == 2 )
92 QString aTmpDir = theFileList[0];
93 QString aFileName = theFileList[1];
96 QString aFullPath = SUIT_Tools::addSlash( aTmpDir ) + aFileName;
100 res = HYDROData_Document::Load( (char*)aFullPath.toLatin1().constData(), aStudyId );
104 res = DocError_UnknownProblem;
106 if( res != DocError_OK )
108 module()->application()->putInfo( tr( "LOAD_ERROR" ) );
113 // if the document open was successful, the data model update happens
114 // in the set mode of the module
115 if( res == DocError_OK )
121 bool HYDROGUI_DataModel::save( QStringList& theFileList )
123 if( !module()->application()->activeStudy() )
126 LightApp_DataModel::save( theFileList );
130 SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
131 bool isMultiFile = false;
133 isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
135 // save data to temporary files
136 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy() );
137 aTmpDir = aStudy->GetTmpDir( myStudyURL.toLatin1().constData(), isMultiFile ).c_str();
138 aFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf";
140 QString aFullPath = aTmpDir + aFileName;
141 Data_DocError res = getDocument()->Save( (char*)aFullPath.toLatin1().constData() );
142 if( res != DocError_OK )
144 module()->application()->putInfo( tr( "SAVE_ERROR" ) );
148 theFileList.append( aTmpDir );
149 theFileList.append( aFileName );
154 bool HYDROGUI_DataModel::saveAs( const QString& theURL,
156 QStringList& theFileList )
159 return save( theFileList );
162 bool HYDROGUI_DataModel::close()
167 bool HYDROGUI_DataModel::dumpPython( const QString& theURL,
170 QStringList& theListOfFiles )
172 LightApp_DataModel::dumpPython( theURL, theStudy, isMultiFile, theListOfFiles );
174 int aStudyId = theStudy->id();
176 LightApp_Study* aStudy = ::qobject_cast<LightApp_Study*>( theStudy );
177 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
178 if ( aDocument.IsNull() || !aStudy )
181 QString aFileToExport = aStudy->GetTmpDir( theURL.toLatin1().constData(), isMultiFile ).c_str();
182 aFileToExport += QString( QDir::separator() ) + "HYDRO.py";
184 bool aRes = aDocument->DumpToPython( aFileToExport );
188 theListOfFiles.append( aFileToExport );
194 bool HYDROGUI_DataModel::isModified() const
196 return getDocument()->IsModified();
199 bool HYDROGUI_DataModel::isSaved() const
204 void HYDROGUI_DataModel::update( const int theStudyId )
206 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
210 SUIT_DataObject* aStudyRoot = anApp->activeStudy()->root();
214 // create root object if not exist
215 CAM_DataObject* aRootObj = root();
217 aRootObj = createRootModuleObject( aStudyRoot );
222 DataObjectList aList;
223 aRootObj->children( aList );
224 QListIterator<SUIT_DataObject*> anIter( aList );
225 while( anIter.hasNext() )
226 removeChild( aRootObj, anIter.next() );
228 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theStudyId );
229 if( aDocument.IsNull() )
232 // Create root objects:
235 LightApp_DataObject* anImageRootObj = createObject( aRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) );
238 LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, tr( partitionName( KIND_BATHYMETRY ).toAscii() ) );
240 // ARTIFICIAL OBJECTS
241 LightApp_DataObject* anArtificialObjectsRootObj = createObject( aRootObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toAscii() ) );
244 LightApp_DataObject* aNaturalObjectsRootObj = createObject( aRootObj, tr( partitionName( KIND_NATURAL_OBJECT ).toAscii() ) );
247 LightApp_DataObject* anObstaclesRootObj = createObject( aRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) );
250 LightApp_DataObject* aCalculRootObj = createObject( aRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
253 LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) );
256 LightApp_DataObject* aProfileRootObj = createObject( aRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) );
259 LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) );
261 HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN );
262 for( ; anIterator.More(); anIterator.Next() ) {
263 Handle(HYDROData_Entity) anObj = anIterator.Current();
265 switch ( anObj->GetKind() ) {
268 Handle(HYDROData_Image) anImageObj =
269 Handle(HYDROData_Image)::DownCast( anObj );
270 if( !anImageObj.IsNull() ) {
271 createObject( anImageRootObj, anImageObj );
276 case KIND_BATHYMETRY:
278 Handle(HYDROData_Bathymetry) aBathymetryObj =
279 Handle(HYDROData_Bathymetry)::DownCast( anObj );
280 if( !aBathymetryObj.IsNull() ) {
281 createObject( aBathymetryRootObj, aBathymetryObj );
288 Handle(HYDROData_Channel) aChannelObj =
289 Handle(HYDROData_Channel)::DownCast( anObj );
290 if( !aChannelObj.IsNull() ) {
291 createObject( anArtificialObjectsRootObj, aChannelObj );
298 Handle(HYDROData_Digue) aDigueObj =
299 Handle(HYDROData_Digue)::DownCast( anObj );
300 if( !aDigueObj.IsNull() ) {
301 createObject( anArtificialObjectsRootObj, aDigueObj );
306 case KIND_IMMERSIBLE_ZONE:
308 Handle(HYDROData_ImmersibleZone) anImmersibleZoneObj =
309 Handle(HYDROData_ImmersibleZone)::DownCast( anObj );
310 if( !anImmersibleZoneObj.IsNull() ) {
311 createObject( aNaturalObjectsRootObj, anImmersibleZoneObj );
318 Handle(HYDROData_River) aRiverObj =
319 Handle(HYDROData_River)::DownCast( anObj );
320 if( !aRiverObj.IsNull() ) {
321 createObject( aNaturalObjectsRootObj, aRiverObj );
328 Handle(HYDROData_Obstacle) anObstacleObj =
329 Handle(HYDROData_Obstacle)::DownCast( anObj );
330 if( !anObstacleObj.IsNull() ) {
331 createObject( anObstaclesRootObj, anObstacleObj );
336 case KIND_CALCULATION:
338 Handle(HYDROData_CalculationCase) aCalculObj =
339 Handle(HYDROData_CalculationCase)::DownCast( anObj );
340 if( !aCalculObj.IsNull() ) {
341 createObject( aCalculRootObj, aCalculObj );
348 Handle(HYDROData_Polyline) aPolylineObj =
349 Handle(HYDROData_Polyline)::DownCast( anObj );
350 if( !aPolylineObj.IsNull() ) {
351 createObject( aPolylineRootObj, aPolylineObj );
358 Handle(HYDROData_Profile) aProfileObj =
359 Handle(HYDROData_Profile)::DownCast( anObj );
360 if( !aProfileObj.IsNull() ) {
361 createObject( aProfileRootObj, aProfileObj );
366 case KIND_VISUAL_STATE:
368 Handle(HYDROData_VisualState) aVisualStateObj =
369 Handle(HYDROData_VisualState)::DownCast( anObj );
370 if( !aVisualStateObj.IsNull() ) {
371 createObject( aVisualStateRootObj, aVisualStateObj );
379 if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() )
381 anObjectBrowser->setAutoOpenLevel( 3 );
382 anObjectBrowser->openLevels();
386 HYDROGUI_DataObject* HYDROGUI_DataModel::getDataObject( const Handle(HYDROData_Entity)& theModelObject )
388 return NULL; // to do if necessary
391 HYDROGUI_DataObject* HYDROGUI_DataModel::getReferencedDataObject( HYDROGUI_DataObject* theObject )
393 return NULL; // to do if necessary
396 SUIT_DataObject* HYDROGUI_DataModel::findObject( const QString& theEntry ) const
398 LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
399 return anApp ? anApp->findObject( theEntry ) : 0;
402 void HYDROGUI_DataModel::update( LightApp_DataObject* theObject,
403 LightApp_Study* theStudy )
406 theStudy = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy()) ;
408 update( theStudy->id() );
411 CAM_DataObject* HYDROGUI_DataModel::createRootModuleObject( SUIT_DataObject* theParent )
413 CAM_DataObject* aRootObj = createModuleObject( theParent );
418 void HYDROGUI_DataModel::updateModel()
420 HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
422 update( aModule->getStudyId() );
425 Handle(HYDROData_Entity) HYDROGUI_DataModel::objectByEntry( const QString& theEntry,
426 const ObjectKind theObjectKind )
428 QString anEntry = theEntry;
429 if( anEntry.indexOf( "_" ) != -1 ) // reference object
430 anEntry = anEntry.section( "_", -1 );
432 Handle(HYDROData_Document) aDocument = getDocument();
433 if( !aDocument.IsNull() )
435 HYDROData_Iterator anIterator( aDocument, theObjectKind );
436 for( ; anIterator.More(); anIterator.Next() )
438 Handle(HYDROData_Entity) anObject = anIterator.Current();
439 if( !anObject.IsNull() )
441 QString anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
442 if( anEntryRef == anEntry )
450 bool HYDROGUI_DataModel::canUndo() const
452 return getDocument()->CanUndo();
455 bool HYDROGUI_DataModel::canRedo() const
457 return getDocument()->CanRedo();
460 QStringList HYDROGUI_DataModel::undoNames() const
463 for( TDF_ListIteratorOfDeltaList anIter( getDocument()->GetUndos() ); anIter.More(); anIter.Next() )
464 aNames.prepend( HYDROGUI_Tool::ToQString( anIter.Value()->Name() ) );
468 QStringList HYDROGUI_DataModel::redoNames() const
471 for( TDF_ListIteratorOfDeltaList anIter( getDocument()->GetRedos() ); anIter.More(); anIter.Next() )
472 aNames.append( HYDROGUI_Tool::ToQString( anIter.Value()->Name() ) );
476 void HYDROGUI_DataModel::clearUndos()
478 getDocument()->ClearUndos();
481 void HYDROGUI_DataModel::clearRedos()
483 getDocument()->ClearRedos();
486 bool HYDROGUI_DataModel::undo()
490 getDocument()->Undo();
492 catch ( Standard_Failure )
499 bool HYDROGUI_DataModel::redo()
503 getDocument()->Redo();
505 catch ( Standard_Failure )
512 bool HYDROGUI_DataModel::canCopy()
514 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( (HYDROGUI_Module*)module() );
515 if( aSeq.Length() != 1 )
518 Handle(HYDROData_Entity) anObject = aSeq.First();
519 if( anObject.IsNull() )
522 ObjectKind aKind = anObject->GetKind();
523 if( aKind == KIND_IMAGE ||
524 aKind == KIND_POLYLINE ||
525 aKind == KIND_PROFILE ||
526 aKind == KIND_CALCULATION )
532 bool HYDROGUI_DataModel::canPaste()
534 for( int anIndex = 1, aLength = myCopyingObjects.Length(); anIndex <= aLength; anIndex++ )
536 Handle(HYDROData_Entity) anObject = myCopyingObjects.Value( anIndex );
537 if( !anObject.IsNull() && !anObject->IsRemoved() )
543 bool HYDROGUI_DataModel::copy()
545 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( (HYDROGUI_Module*)module() );
546 changeCopyingObjects( aSeq );
550 bool HYDROGUI_DataModel::paste()
552 bool anIsChanged = false;
553 for( int anIndex = 1, aLength = myCopyingObjects.Length(); anIndex <= aLength; anIndex++ )
555 Handle(HYDROData_Entity) anObject = myCopyingObjects.Value( anIndex );
556 if( !anObject.IsNull() && !anObject->IsRemoved() )
558 ObjectKind aKind = anObject->GetKind();
559 Handle(HYDROData_Entity) aClone = getDocument()->CreateObject( aKind );
560 if( !aClone.IsNull() )
562 anObject->CopyTo( aClone );
565 // generate a new unique name for the clone object:
566 // case 1: Image_1 -> Image_2
567 // case 2: ImageObj -> ImageObj_1
568 QString aName = aClone->GetName();
569 QString aPrefix = aName;
570 if( aName.contains( '_' ) ) // case 1
572 QString aSuffix = aName.section( '_', -1 );
573 bool anIsInteger = false;
574 aSuffix.toInt( &anIsInteger );
576 aPrefix = aName.section( '_', 0, -2 );
580 aName = HYDROGUI_Tool::GenerateObjectName( (HYDROGUI_Module*)module(), aPrefix );
581 aClone->SetName( aName );
588 void HYDROGUI_DataModel::changeCopyingObjects( const HYDROData_SequenceOfObjects& theSeq )
590 myCopyingObjects.Assign( theSeq );
593 QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind )
595 switch( theObjectKind )
597 case KIND_IMAGE: return "IMAGES";
598 case KIND_POLYLINE: return "POLYLINES";
599 case KIND_PROFILE: return "PROFILES";
600 case KIND_VISUAL_STATE: return "VISUAL_STATES";
601 case KIND_BATHYMETRY: return "BATHYMETRIES";
602 case KIND_CALCULATION: return "CALCULATION_CASES";
603 case KIND_OBSTACLE: return "OBSTACLES";
604 case KIND_ARTIFICIAL_OBJECT: return "ARTIFICIAL_OBJECTS";
605 case KIND_NATURAL_OBJECT: return "NATURAL_OBJECTS";
611 Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const
613 int aStudyId = module()->application()->activeStudy()->id();
614 return HYDROData_Document::Document( aStudyId );
617 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
618 Handle(HYDROData_Entity) theModelObject,
619 const QString& theParentEntry,
620 const bool theIsBuildTree )
622 HYDROGUI_DataObject* aResObj = new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
624 if ( theIsBuildTree )
626 buildObjectTree( theParent, aResObj, theParentEntry );
632 LightApp_DataObject* HYDROGUI_DataModel::buildObject( SUIT_DataObject* theParent,
633 HYDROGUI_DataObject* theObject,
634 const QString& theParentEntry,
635 const bool theIsBuildTree )
637 if ( theIsBuildTree )
639 buildObjectTree( theParent, theObject, theParentEntry );
644 LightApp_DataObject* HYDROGUI_DataModel::createZone( SUIT_DataObject* theParent,
645 Handle(HYDROData_Zone) theModelObject,
646 const QString& theParentEntry,
647 const bool theIsBuildTree )
649 return buildObject( theParent, new HYDROGUI_Zone( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
652 LightApp_DataObject* HYDROGUI_DataModel::createRegion( SUIT_DataObject* theParent,
653 Handle(HYDROData_Region) theModelObject,
654 const QString& theParentEntry,
655 const bool theIsBuildTree )
657 return buildObject( theParent, new HYDROGUI_Region( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
660 LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
661 const QString& theName,
662 const QString& theParentEntry )
664 return new HYDROGUI_NamedObject( theParent, theName, theParentEntry );
667 void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
668 SUIT_DataObject* theObject,
669 const QString& theParentEntry )
671 HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>( theObject );
675 Handle(HYDROData_Entity) aDataObj = aGuiObj->modelObject();
676 if ( aDataObj.IsNull() )
679 ObjectKind anObjectKind = aDataObj->GetKind();
681 if ( anObjectKind == KIND_IMAGE )
683 Handle(HYDROData_Image) anImageObj =
684 Handle(HYDROData_Image)::DownCast( aDataObj );
685 for ( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ )
687 Handle(HYDROData_Entity) aRefObj = anImageObj->Reference( anIndex );
688 if ( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
689 createObject( aGuiObj, aRefObj, aGuiObj->entry(), false );
692 else if ( anObjectKind == KIND_IMMERSIBLE_ZONE )
694 Handle(HYDROData_ImmersibleZone) aZoneObj =
695 Handle(HYDROData_ImmersibleZone)::DownCast( aDataObj );
697 LightApp_DataObject* aPolylineSect =
698 createObject( aGuiObj, tr( "ZONE_POLYLINE" ), aGuiObj->entry() );
700 Handle(HYDROData_Polyline) aPolyline = aZoneObj->GetPolyline();
701 if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
702 createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
704 LightApp_DataObject* aBathSect =
705 createObject( aGuiObj, tr( "ZONE_BATHYMETRY" ), aGuiObj->entry() );
707 Handle(HYDROData_Bathymetry) aBathymetry = aZoneObj->GetBathymetry();
708 if ( !aBathymetry.IsNull() && !aBathymetry->IsRemoved() )
709 createObject( aBathSect, aBathymetry, aGuiObj->entry(), false );
711 else if ( anObjectKind == KIND_CALCULATION )
713 Handle(HYDROData_CalculationCase) aCaseObj =
714 Handle(HYDROData_CalculationCase)::DownCast( aDataObj );
716 LightApp_DataObject* aCaseRegionsSect =
717 createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() );
719 HYDROData_SequenceOfObjects aCaseRegions = aCaseObj->GetRegions();
720 HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
721 for ( ; anIter.More(); anIter.Next() )
723 Handle(HYDROData_Region) aCaseRegion =
724 Handle(HYDROData_Region)::DownCast( anIter.Value() );
725 if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
726 createRegion( aCaseRegionsSect, aCaseRegion, "", true );
729 else if ( anObjectKind == KIND_REGION )
731 Handle(HYDROData_Region) aRegionObj =
732 Handle(HYDROData_Region)::DownCast( aDataObj );
734 HYDROData_SequenceOfObjects aRegionZones = aRegionObj->GetZones();
735 HYDROData_SequenceOfObjects::Iterator anIter( aRegionZones );
736 for ( ; anIter.More(); anIter.Next() )
738 Handle(HYDROData_Zone) aRegionZone =
739 Handle(HYDROData_Zone)::DownCast( anIter.Value() );
740 if( !aRegionZone.IsNull() && !aRegionZone->IsRemoved() )
741 createZone( aGuiObj, aRegionZone, "", true );
746 void HYDROGUI_DataModel::buildCaseTree( SUIT_DataObject* theParent, Handle(HYDROData_CalculationCase) theCase )
748 if ( !theCase.IsNull() )
750 new HYDROGUI_DropTargetObject( theParent, tr( "NEW_REGION" ), "" );
752 HYDROData_SequenceOfObjects aCaseRegions = theCase->GetRegions();
753 HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
754 for ( ; anIter.More(); anIter.Next() )
756 Handle(HYDROData_Region) aCaseRegion =
757 Handle(HYDROData_Region)::DownCast( anIter.Value() );
758 if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
759 createRegion( theParent, aCaseRegion, "", true );
764 void HYDROGUI_DataModel::removeChild( SUIT_DataObject* theParent,
765 SUIT_DataObject* theChild )
767 SUIT_DataObject* aSubChild = theChild->firstChild();
768 for( ; aSubChild; aSubChild = aSubChild->nextBrother() )
769 removeChild( theChild, aSubChild );
770 theParent->removeChild( theChild );
773 SUIT_DataObject* HYDROGUI_DataModel::findChildByName( const SUIT_DataObject* theFather,
774 const QString& theName )
776 SUIT_DataObject* aChild = theFather->firstChild();
779 if( aChild->name() == theName )
780 return aChild; // found
781 aChild = aChild->nextBrother();
783 return NULL; // not found
786 bool HYDROGUI_DataModel::createNewRegion( Handle(HYDROData_CalculationCase) theCase,
787 const QList<HYDROGUI_Zone*>& theZonesList )
789 bool isOk = !theCase.IsNull();
792 Handle(HYDROData_Region) aRegion;
793 Handle(HYDROData_Zone) aZone;
794 for (int i = 0; i < theZonesList.length(); i++ )
796 aZone = Handle(HYDROData_Zone)::DownCast( theZonesList.at(i)->modelObject() );
797 if ( !aZone.IsNull() )
799 if ( aRegion.IsNull() )
801 aRegion = theCase->AddNewRegion( aZone );
802 isOk = !aRegion.IsNull();
806 if ( !( aRegion->AddZone( aZone ) ) )