X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_DataModel.cxx;h=97ec16079ae1c5b00aca7e54d2057fdf79135634;hb=de7cf9bb0a7a41d6487013c87f4a54d0664cd303;hp=180b2dd861fae6d8588d44b9fadfc0099b57cc39;hpb=84f8b4a57d3cdad820bc1333a5066699cd1c8ae3;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 180b2dd8..97ec1607 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -25,9 +25,11 @@ #include "HYDROGUI_DataObject.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" +#include "HYDROGUI_Zone.h" +#include "HYDROGUI_Region.h" #include -#include +#include #include #include #include @@ -222,7 +224,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) if( aDocument.IsNull() ) return; - LightApp_DataObject* anImageRootObj = createObject( aRootObj, partitionName( KIND_IMAGE ) ); + LightApp_DataObject* anImageRootObj = createObject( aRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) ); HYDROData_Iterator anIterator( aDocument, KIND_IMAGE ); for( ; anIterator.More(); anIterator.Next() ) @@ -233,7 +235,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) createObject( anImageRootObj, anImageObj ); } - LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, partitionName( KIND_BATHYMETRY ) ); + LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, tr( partitionName( KIND_BATHYMETRY ).toAscii() ) ); anIterator = HYDROData_Iterator( aDocument, KIND_BATHYMETRY ); for( ; anIterator.More(); anIterator.Next() ) @@ -244,7 +246,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) createObject( aBathymetryRootObj, aBathymetryObj ); } - LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, partitionName( KIND_POLYLINE ) ); + LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) ); anIterator = HYDROData_Iterator( aDocument, KIND_POLYLINE ); for( ; anIterator.More(); anIterator.Next() ) @@ -255,7 +257,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) createObject( aPolylineRootObj, aPolylineObj ); } - LightApp_DataObject* aZonesRootObj = createObject( aRootObj, partitionName( KIND_IMMERSIBLE_ZONE ) ); + LightApp_DataObject* aZonesRootObj = createObject( aRootObj, tr( partitionName( KIND_IMMERSIBLE_ZONE ).toAscii() ) ); anIterator = HYDROData_Iterator( aDocument, KIND_IMMERSIBLE_ZONE ); for( ; anIterator.More(); anIterator.Next() ) @@ -266,18 +268,18 @@ void HYDROGUI_DataModel::update( const int theStudyId ) createObject( aZonesRootObj, aZoneObj ); } - LightApp_DataObject* aCalculRootObj = createObject( aRootObj, partitionName( KIND_CALCULATION ) ); + LightApp_DataObject* aCalculRootObj = createObject( aRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) ); anIterator = HYDROData_Iterator( aDocument, KIND_CALCULATION ); for( ; anIterator.More(); anIterator.Next() ) { - Handle(HYDROData_Calculation) aCalculObj = - Handle(HYDROData_Calculation)::DownCast( anIterator.Current() ); + Handle(HYDROData_CalculationCase) aCalculObj = + Handle(HYDROData_CalculationCase)::DownCast( anIterator.Current() ); if( !aCalculObj.IsNull() ) createObject( aCalculRootObj, aCalculObj ); } - LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, partitionName( KIND_VISUAL_STATE ) ); + LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) ); anIterator = HYDROData_Iterator( aDocument, KIND_VISUAL_STATE ); for( ; anIterator.More(); anIterator.Next() ) @@ -527,8 +529,7 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* 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 ) { @@ -538,6 +539,34 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* 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 ) @@ -591,8 +620,8 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent, } else if ( anObjectKind == KIND_CALCULATION ) { - Handle(HYDROData_Calculation) aCaseObj = - Handle(HYDROData_Calculation)::DownCast( aDataObj ); + Handle(HYDROData_CalculationCase) aCaseObj = + Handle(HYDROData_CalculationCase)::DownCast( aDataObj ); LightApp_DataObject* aCaseRegionsSect = createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() ); @@ -604,7 +633,7 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent, Handle(HYDROData_Region) aCaseRegion = Handle(HYDROData_Region)::DownCast( anIter.Value() ); if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() ) - createObject( aCaseRegionsSect, aCaseRegion, aGuiObj->entry(), true ); + createRegion( aCaseRegionsSect, aCaseRegion, "", true ); } } else if ( anObjectKind == KIND_REGION ) @@ -619,7 +648,25 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent, Handle(HYDROData_Zone) aRegionZone = Handle(HYDROData_Zone)::DownCast( anIter.Value() ); if( !aRegionZone.IsNull() && !aRegionZone->IsRemoved() ) - createObject( aGuiObj, aRegionZone, aGuiObj->entry(), 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 ); } } } @@ -645,3 +692,34 @@ SUIT_DataObject* HYDROGUI_DataModel::findChildByName( const SUIT_DataObject* the } return NULL; // not found } + +bool HYDROGUI_DataModel::createNewRegion( Handle(HYDROData_CalculationCase) theCase, + const QList& 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; +}