#include "HYDROGUI_DataObject.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_Zone.h"
+#include "HYDROGUI_Region.h"
#include <HYDROData_Bathymetry.h>
#include <HYDROData_CalculationCase.h>
const QString& theParentEntry,
const bool theIsBuildTree )
{
- HYDROGUI_DataObject* aResObj =
- new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
+ HYDROGUI_DataObject* aResObj = new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
if ( theIsBuildTree )
{
return aResObj;
}
+LightApp_DataObject* HYDROGUI_DataModel::buildObject( SUIT_DataObject* theParent,
+ HYDROGUI_DataObject* theObject,
+ const QString& theParentEntry,
+ const bool theIsBuildTree )
+{
+ if ( theIsBuildTree )
+ {
+ buildObjectTree( theParent, theObject, theParentEntry );
+ }
+ return theObject;
+}
+
+LightApp_DataObject* HYDROGUI_DataModel::createZone( SUIT_DataObject* theParent,
+ Handle(HYDROData_Zone) theModelObject,
+ const QString& theParentEntry,
+ const bool theIsBuildTree )
+{
+ return buildObject( theParent, new HYDROGUI_Zone( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
+}
+
+LightApp_DataObject* HYDROGUI_DataModel::createRegion( SUIT_DataObject* theParent,
+ Handle(HYDROData_Region) theModelObject,
+ const QString& theParentEntry,
+ const bool theIsBuildTree )
+{
+ return buildObject( theParent, new HYDROGUI_Region( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
+}
+
LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
const QString& theName,
const QString& theParentEntry )
Handle(HYDROData_Region) aCaseRegion =
Handle(HYDROData_Region)::DownCast( anIter.Value() );
if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
- createObject( aCaseRegionsSect, aCaseRegion, "", true );
+ createRegion( aCaseRegionsSect, aCaseRegion, "", true );
}
}
else if ( anObjectKind == KIND_REGION )
Handle(HYDROData_Zone) aRegionZone =
Handle(HYDROData_Zone)::DownCast( anIter.Value() );
if( !aRegionZone.IsNull() && !aRegionZone->IsRemoved() )
- createObject( aGuiObj, aRegionZone, "", true );
+ createZone( aGuiObj, aRegionZone, "", true );
+ }
+ }
+}
+
+void HYDROGUI_DataModel::buildCaseTree( SUIT_DataObject* theParent, Handle(HYDROData_CalculationCase) theCase )
+{
+ if ( !theCase.IsNull() )
+ {
+ new HYDROGUI_DropTargetObject( theParent, tr( "NEW_REGION" ), "" );
+
+ HYDROData_SequenceOfObjects aCaseRegions = theCase->GetRegions();
+ HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Region) aCaseRegion =
+ Handle(HYDROData_Region)::DownCast( anIter.Value() );
+ if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
+ createRegion( theParent, aCaseRegion, "", true );
}
}
}
}
return NULL; // not found
}
+
+bool HYDROGUI_DataModel::createNewRegion( Handle(HYDROData_CalculationCase) theCase,
+ const QList<HYDROGUI_Zone*>& theZonesList )
+{
+ bool isOk = !theCase.IsNull();
+ if ( isOk )
+ {
+ Handle(HYDROData_Region) aRegion;
+ Handle(HYDROData_Zone) aZone;
+ for (int i = 0; i < theZonesList.length(); i++ )
+ {
+ aZone = Handle(HYDROData_Zone)::DownCast( theZonesList.at(i)->modelObject() );
+ if ( !aZone.IsNull() )
+ {
+ if ( aRegion.IsNull() )
+ {
+ aRegion = theCase->AddNewRegion( aZone );
+ isOk = !aRegion.IsNull();
+ }
+ else
+ {
+ if ( !( aRegion->AddZone( aZone ) ) )
+ {
+ isOk = false;
+ }
+ }
+ }
+ }
+ }
+ return isOk;
+}