From: adv Date: Wed, 30 Oct 2013 03:47:38 +0000 (+0000) Subject: Name calculation calss hass been changed in accordance with spec diagram of classes. X-Git-Tag: BR_hydro_v_0_3~72 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=acc1c9db1a80ae3f0152c5b88b8b8b658e05dbf0;p=modules%2Fhydro.git Name calculation calss hass been changed in accordance with spec diagram of classes. --- diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index 78eae8e3..9308991b 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -7,7 +7,7 @@ set(PROJECT_HEADERS HYDROData_ArtificialObject.h HYDROData_Bathymetry.h HYDROData_BSplineOperation.h - HYDROData_Calculation.h + HYDROData_CalculationCase.h HYDROData_Document.h HYDROData_Entity.h HYDROData_IAltitudeObject.h @@ -32,7 +32,7 @@ set(PROJECT_SOURCES HYDROData_ArtificialObject.cxx HYDROData_Bathymetry.cxx HYDROData_BSplineOperation.cxx - HYDROData_Calculation.cxx + HYDROData_CalculationCase.cxx HYDROData_Document.cxx HYDROData_Entity.cxx HYDROData_IAltitudeObject.cxx diff --git a/src/HYDROData/HYDROData_Calculation.cxx b/src/HYDROData/HYDROData_Calculation.cxx deleted file mode 100644 index ff8415a6..00000000 --- a/src/HYDROData/HYDROData_Calculation.cxx +++ /dev/null @@ -1,241 +0,0 @@ - -#include "HYDROData_Calculation.h" - -#include "HYDROData_ArtificialObject.h" -#include "HYDROData_Document.h" -#include "HYDROData_Iterator.h" -#include "HYDROData_NaturalObject.h" -#include "HYDROData_SplitToZonesTool.h" -#include "HYDROData_Region.h" -#include "HYDROData_Tool.h" -#include "HYDROData_Zone.h" - -#define PYTHON_CALCULATION_ID "KIND_CALCULATION" - -IMPLEMENT_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Entity) -IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Calculation, HYDROData_Entity) - -HYDROData_Calculation::HYDROData_Calculation() -: HYDROData_Entity() -{ -} - -HYDROData_Calculation::~HYDROData_Calculation() -{ -} - -QStringList HYDROData_Calculation::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const -{ - QStringList aResList; - - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); - if ( aDocument.IsNull() ) - return aResList; - - QString aDocName = aDocument->GetDocPyName(); - QString aCalculName = GetName(); - - aResList << QString( "%1 = %2.CreateObject( %3 );" ) - .arg( aCalculName ).arg( aDocName ).arg( PYTHON_CALCULATION_ID ); - aResList << QString( "%1.SetName( \"%2\" );" ) - .arg( aCalculName ).arg( aCalculName ); - aResList << QString( "" ); - - HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); - HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects ); - for ( ; anIter.More(); anIter.Next() ) - { - Handle(HYDROData_Object) aRefGeomObj = - Handle(HYDROData_Object)::DownCast( anIter.Value() ); - if ( !aRefGeomObj.IsNull() ) - setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" ); - } - aResList << QString( "" ); - - aResList << QString( "%1.SplitGeometryObjects();" ).arg( aCalculName ); - aResList << QString( "" ); - - // Now we restore the regions and zones order - HYDROData_SequenceOfObjects aRegions = GetRegions(); - anIter.Init( aRegions ); - for ( ; anIter.More(); anIter.Next() ) - { - Handle(HYDROData_Region) aRegion = - Handle(HYDROData_Region)::DownCast( anIter.Value() ); - if ( aRegion.IsNull() ) - continue; - - QString aRegionName = aRegion->GetName(); - // TODO - } - - return aResList; -} - -void HYDROData_Calculation::SplitGeometryObjects() -{ - // At first we remove previously created regions - RemoveRegions(); - - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); - if ( aDocument.IsNull() ) - return; - - HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); - if ( aGeomObjects.IsEmpty() ) - return; - - HYDROData_SplitToZonesTool::SplitDataList aSplitedZones = - HYDROData_SplitToZonesTool::SplitToZones( aGeomObjects ); - if ( aSplitedZones.isEmpty() ) - return; - - // Create result regions for case, by default one zone for one region - HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitedZones ); - while( anIter.hasNext() ) - { - const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next(); - - // Create new region - Handle(HYDROData_Region) aRegion = addNewRegion(); - - QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, "Region" ); - aRegion->SetName( aRegionName ); - - // Add the zone for region - Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone(); - - QString aZoneName = HYDROData_Tool::GenerateObjectName( aDocument, "Zone" ); - aRegionZone->SetName( aZoneName ); - - aRegionZone->SetShape( aSplitData.Face() ); - - // Add the reference object for zone - for ( int i = 0, n = aSplitData.ObjectNames.length(); i < n; ++i ) - { - const QString& anObjName = aSplitData.ObjectNames.at( i ); - - Handle(HYDROData_Object) aRefObject = Handle(HYDROData_Object)::DownCast( - HYDROData_Tool::FindObjectByName( aDocument, anObjName ) ); - if ( aRefObject.IsNull() ) - continue; - - aRegionZone->AddGeometryObject( aRefObject ); - } - } -} - -bool HYDROData_Calculation::AddGeometryObject( const Handle(HYDROData_Object)& theObject ) -{ - if ( theObject.IsNull() ) - return false; - - if ( !theObject->IsKind( STANDARD_TYPE(HYDROData_ArtificialObject) ) && - !theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ) ) - return false; // Wrong type of object - - if ( HasReference( theObject, DataTag_GeometryObject ) ) - return false; // Object is already in reference list - - AddReferenceObject( theObject, DataTag_GeometryObject ); - return true; -} - -HYDROData_SequenceOfObjects HYDROData_Calculation::GetGeometryObjects() const -{ - return GetReferenceObjects( DataTag_GeometryObject ); -} - -void HYDROData_Calculation::RemoveGeometryObject( const Handle(HYDROData_Object)& theObject ) -{ - if ( theObject.IsNull() ) - return; - - RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject ); -} - -void HYDROData_Calculation::RemoveGeometryObjects() -{ - ClearReferenceObjects( DataTag_GeometryObject ); -} - -Handle(HYDROData_Region) HYDROData_Calculation::AddNewRegion( const Handle(HYDROData_Zone)& theZone ) -{ - Handle(HYDROData_Region) aNewRegion = addNewRegion(); - if ( aNewRegion.IsNull() ) - return aNewRegion; - - // Generate new name for new region - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); - if ( !aDocument.IsNull() ) - { - QString aNewRegionName = HYDROData_Tool::GenerateObjectName( aDocument, "Region" ); - aNewRegion->SetName( aNewRegionName ); - } - - aNewRegion->AddZone( theZone ); - - return aNewRegion; -} - -bool HYDROData_Calculation::AddRegion( const Handle(HYDROData_Region)& theRegion ) -{ - if ( theRegion.IsNull() ) - return false; - - if ( HasReference( theRegion, DataTag_Region ) ) - return false; // Object is already in reference list - - // Move the region from other calculation - Handle(HYDROData_Calculation) aFatherCalc = - Handle(HYDROData_Calculation)::DownCast( theRegion->GetFatherObject() ); - if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab ) - { - Handle(HYDROData_Region) aNewRegion = addNewRegion(); - theRegion->CopyTo( aNewRegion ); - - aFatherCalc->RemoveRegion( theRegion ); - - theRegion->SetLabel( aNewRegion->Label() ); - } - - AddReferenceObject( theRegion, DataTag_Region ); - return true; -} - -HYDROData_SequenceOfObjects HYDROData_Calculation::GetRegions() const -{ - return GetReferenceObjects( DataTag_Region ); -} - -void HYDROData_Calculation::RemoveRegion( const Handle(HYDROData_Region)& theRegion ) -{ - if ( theRegion.IsNull() ) - return; - - RemoveReferenceObject( theRegion->Label(), DataTag_Region ); - - // Remove region from data model - Handle(HYDROData_Calculation) aFatherCalc = - Handle(HYDROData_Calculation)::DownCast( theRegion->GetFatherObject() ); - if ( !aFatherCalc.IsNull() && aFatherCalc->Label() == myLab ) - theRegion->Remove(); -} - -void HYDROData_Calculation::RemoveRegions() -{ - ClearReferenceObjects( DataTag_Region ); - myLab.FindChild( ChildTag_Region ).ForgetAllAttributes( true ); -} - -Handle(HYDROData_Region) HYDROData_Calculation::addNewRegion() -{ - TDF_Label aNewLab = myLab.FindChild( ChildTag_Region ).NewChild(); - - Handle(HYDROData_Region) aNewRegion = - Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) ); - AddRegion( aNewRegion ); - - return aNewRegion; -} - diff --git a/src/HYDROData/HYDROData_Calculation.h b/src/HYDROData/HYDROData_Calculation.h deleted file mode 100644 index 1590c257..00000000 --- a/src/HYDROData/HYDROData_Calculation.h +++ /dev/null @@ -1,143 +0,0 @@ - - -#ifndef HYDROData_Calculation_HeaderFile -#define HYDROData_Calculation_HeaderFile - -#include - -class Handle(HYDROData_Object); -class Handle(HYDROData_Region); -class Handle(HYDROData_Zone); - -DEFINE_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Entity) - - -/**\class HYDROData_Calculation - * \brief Calculation case is defined by selection of Geometry objects with or without “Zone of water”. - * - */ -class HYDROData_Calculation : public HYDROData_Entity -{ - -protected: - - /** - * Enumeration of tags corresponding to the persistent object parameters. - */ - enum DataTag - { - DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve - DataTag_GeometryObject, ///< reference geometry objects - DataTag_Region ///< reference regions - }; - - /** - * Enumeration of tags corresponding to the child sub-objects of object. - */ - enum ChildTag - { - ChildTag_First = HYDROData_Entity::ChildTag_First + 100, ///< first tag, to reserve - ChildTag_Region ///< child regions - }; - -public: - - DEFINE_STANDARD_RTTI(HYDROData_Calculation); - - /** - * Returns the kind of this object. Must be redefined in all objects of known type. - */ - HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; } - - - /** - * Dump Calculation object to Python script representation. - */ - HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; - -public: - // Public methods to work with Calculation - - /** - * Split reference geometry objects to non-intersected regions. - */ - HYDRODATA_EXPORT virtual void SplitGeometryObjects(); - - - /** - * Add new one reference geometry object for calculation case. - */ - HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject ); - - /** - * Returns all reference geometry objects of calculation case. - */ - HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const; - - /** - * Removes reference geometry object from calculation case. - */ - HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject ); - - /** - * Removes all reference geometry objects from calculation case. - */ - HYDRODATA_EXPORT virtual void RemoveGeometryObjects(); - - - /** - * Add new one child region for calculation case. - * The new region is added into the list of reference regions. - * The label of theZone is changed during this operation - * because of new region becomes the new parent for this zone. - */ - HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone ); - - - /** - * Add new one reference region for calculation case. - * The label of theRegion is changed in case if old parent is not this calculation. - */ - HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion ); - - /** - * Returns all reference regions of calculation case. - */ - HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const; - - /** - * Removes reference region from calculation case. - */ - HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion ); - - /** - * Removes all reference regions from calculation case. - */ - HYDRODATA_EXPORT virtual void RemoveRegions(); - -private: - - /** - * Add new one region for calculation case. - * The new region is added into the list of reference regions. - */ - HYDRODATA_EXPORT virtual Handle(HYDROData_Region) addNewRegion(); - - -protected: - - friend class HYDROData_Iterator; - - /** - * Creates new object in the internal data structure. Use higher level objects - * to create objects with real content. - */ - HYDROData_Calculation(); - - /** - * Destructs properties of the object and object itself, removes it from the document. - */ - ~HYDROData_Calculation(); -}; - -#endif diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx new file mode 100644 index 00000000..b62bcb5c --- /dev/null +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -0,0 +1,241 @@ + +#include "HYDROData_CalculationCase.h" + +#include "HYDROData_ArtificialObject.h" +#include "HYDROData_Document.h" +#include "HYDROData_Iterator.h" +#include "HYDROData_NaturalObject.h" +#include "HYDROData_SplitToZonesTool.h" +#include "HYDROData_Region.h" +#include "HYDROData_Tool.h" +#include "HYDROData_Zone.h" + +#define PYTHON_CALCULATION_ID "KIND_CALCULATION" + +IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity) +IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity) + +HYDROData_CalculationCase::HYDROData_CalculationCase() +: HYDROData_Entity() +{ +} + +HYDROData_CalculationCase::~HYDROData_CalculationCase() +{ +} + +QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +{ + QStringList aResList; + + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); + if ( aDocument.IsNull() ) + return aResList; + + QString aDocName = aDocument->GetDocPyName(); + QString aCalculName = GetName(); + + aResList << QString( "%1 = %2.CreateObject( %3 );" ) + .arg( aCalculName ).arg( aDocName ).arg( PYTHON_CALCULATION_ID ); + aResList << QString( "%1.SetName( \"%2\" );" ) + .arg( aCalculName ).arg( aCalculName ); + aResList << QString( "" ); + + HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); + HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Object) aRefGeomObj = + Handle(HYDROData_Object)::DownCast( anIter.Value() ); + if ( !aRefGeomObj.IsNull() ) + setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" ); + } + aResList << QString( "" ); + + aResList << QString( "%1.SplitGeometryObjects();" ).arg( aCalculName ); + aResList << QString( "" ); + + // Now we restore the regions and zones order + HYDROData_SequenceOfObjects aRegions = GetRegions(); + anIter.Init( aRegions ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Region) aRegion = + Handle(HYDROData_Region)::DownCast( anIter.Value() ); + if ( aRegion.IsNull() ) + continue; + + QString aRegionName = aRegion->GetName(); + // TODO + } + + return aResList; +} + +void HYDROData_CalculationCase::SplitGeometryObjects() +{ + // At first we remove previously created regions + RemoveRegions(); + + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); + if ( aDocument.IsNull() ) + return; + + HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects(); + if ( aGeomObjects.IsEmpty() ) + return; + + HYDROData_SplitToZonesTool::SplitDataList aSplitedZones = + HYDROData_SplitToZonesTool::SplitToZones( aGeomObjects ); + if ( aSplitedZones.isEmpty() ) + return; + + // Create result regions for case, by default one zone for one region + HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitedZones ); + while( anIter.hasNext() ) + { + const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next(); + + // Create new region + Handle(HYDROData_Region) aRegion = addNewRegion(); + + QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, "Region" ); + aRegion->SetName( aRegionName ); + + // Add the zone for region + Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone(); + + QString aZoneName = HYDROData_Tool::GenerateObjectName( aDocument, "Zone" ); + aRegionZone->SetName( aZoneName ); + + aRegionZone->SetShape( aSplitData.Face() ); + + // Add the reference object for zone + for ( int i = 0, n = aSplitData.ObjectNames.length(); i < n; ++i ) + { + const QString& anObjName = aSplitData.ObjectNames.at( i ); + + Handle(HYDROData_Object) aRefObject = Handle(HYDROData_Object)::DownCast( + HYDROData_Tool::FindObjectByName( aDocument, anObjName ) ); + if ( aRefObject.IsNull() ) + continue; + + aRegionZone->AddGeometryObject( aRefObject ); + } + } +} + +bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object)& theObject ) +{ + if ( theObject.IsNull() ) + return false; + + if ( !theObject->IsKind( STANDARD_TYPE(HYDROData_ArtificialObject) ) && + !theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ) ) + return false; // Wrong type of object + + if ( HasReference( theObject, DataTag_GeometryObject ) ) + return false; // Object is already in reference list + + AddReferenceObject( theObject, DataTag_GeometryObject ); + return true; +} + +HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetGeometryObjects() const +{ + return GetReferenceObjects( DataTag_GeometryObject ); +} + +void HYDROData_CalculationCase::RemoveGeometryObject( const Handle(HYDROData_Object)& theObject ) +{ + if ( theObject.IsNull() ) + return; + + RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject ); +} + +void HYDROData_CalculationCase::RemoveGeometryObjects() +{ + ClearReferenceObjects( DataTag_GeometryObject ); +} + +Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone ) +{ + Handle(HYDROData_Region) aNewRegion = addNewRegion(); + if ( aNewRegion.IsNull() ) + return aNewRegion; + + // Generate new name for new region + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this ); + if ( !aDocument.IsNull() ) + { + QString aNewRegionName = HYDROData_Tool::GenerateObjectName( aDocument, "Region" ); + aNewRegion->SetName( aNewRegionName ); + } + + aNewRegion->AddZone( theZone ); + + return aNewRegion; +} + +bool HYDROData_CalculationCase::AddRegion( const Handle(HYDROData_Region)& theRegion ) +{ + if ( theRegion.IsNull() ) + return false; + + if ( HasReference( theRegion, DataTag_Region ) ) + return false; // Object is already in reference list + + // Move the region from other calculation + Handle(HYDROData_CalculationCase) aFatherCalc = + Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() ); + if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab ) + { + Handle(HYDROData_Region) aNewRegion = addNewRegion(); + theRegion->CopyTo( aNewRegion ); + + aFatherCalc->RemoveRegion( theRegion ); + + theRegion->SetLabel( aNewRegion->Label() ); + } + + AddReferenceObject( theRegion, DataTag_Region ); + return true; +} + +HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetRegions() const +{ + return GetReferenceObjects( DataTag_Region ); +} + +void HYDROData_CalculationCase::RemoveRegion( const Handle(HYDROData_Region)& theRegion ) +{ + if ( theRegion.IsNull() ) + return; + + RemoveReferenceObject( theRegion->Label(), DataTag_Region ); + + // Remove region from data model + Handle(HYDROData_CalculationCase) aFatherCalc = + Handle(HYDROData_CalculationCase)::DownCast( theRegion->GetFatherObject() ); + if ( !aFatherCalc.IsNull() && aFatherCalc->Label() == myLab ) + theRegion->Remove(); +} + +void HYDROData_CalculationCase::RemoveRegions() +{ + ClearReferenceObjects( DataTag_Region ); + myLab.FindChild( ChildTag_Region ).ForgetAllAttributes( true ); +} + +Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion() +{ + TDF_Label aNewLab = myLab.FindChild( ChildTag_Region ).NewChild(); + + Handle(HYDROData_Region) aNewRegion = + Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) ); + AddRegion( aNewRegion ); + + return aNewRegion; +} + diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h new file mode 100644 index 00000000..916057be --- /dev/null +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -0,0 +1,143 @@ + + +#ifndef HYDROData_CalculationCase_HeaderFile +#define HYDROData_CalculationCase_HeaderFile + +#include + +class Handle(HYDROData_Object); +class Handle(HYDROData_Region); +class Handle(HYDROData_Zone); + +DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity) + + +/**\class HYDROData_CalculationCase + * \brief Calculation case is defined by selection of Geometry objects with or without “Zone of water”. + * + */ +class HYDROData_CalculationCase : public HYDROData_Entity +{ + +protected: + + /** + * Enumeration of tags corresponding to the persistent object parameters. + */ + enum DataTag + { + DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve + DataTag_GeometryObject, ///< reference geometry objects + DataTag_Region ///< reference regions + }; + + /** + * Enumeration of tags corresponding to the child sub-objects of object. + */ + enum ChildTag + { + ChildTag_First = HYDROData_Entity::ChildTag_First + 100, ///< first tag, to reserve + ChildTag_Region ///< child regions + }; + +public: + + DEFINE_STANDARD_RTTI(HYDROData_CalculationCase); + + /** + * Returns the kind of this object. Must be redefined in all objects of known type. + */ + HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; } + + + /** + * Dump Calculation object to Python script representation. + */ + HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; + +public: + // Public methods to work with Calculation + + /** + * Split reference geometry objects to non-intersected regions. + */ + HYDRODATA_EXPORT virtual void SplitGeometryObjects(); + + + /** + * Add new one reference geometry object for calculation case. + */ + HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject ); + + /** + * Returns all reference geometry objects of calculation case. + */ + HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const; + + /** + * Removes reference geometry object from calculation case. + */ + HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject ); + + /** + * Removes all reference geometry objects from calculation case. + */ + HYDRODATA_EXPORT virtual void RemoveGeometryObjects(); + + + /** + * Add new one child region for calculation case. + * The new region is added into the list of reference regions. + * The label of theZone is changed during this operation + * because of new region becomes the new parent for this zone. + */ + HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone ); + + + /** + * Add new one reference region for calculation case. + * The label of theRegion is changed in case if old parent is not this calculation. + */ + HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion ); + + /** + * Returns all reference regions of calculation case. + */ + HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const; + + /** + * Removes reference region from calculation case. + */ + HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion ); + + /** + * Removes all reference regions from calculation case. + */ + HYDRODATA_EXPORT virtual void RemoveRegions(); + +private: + + /** + * Add new one region for calculation case. + * The new region is added into the list of reference regions. + */ + HYDRODATA_EXPORT virtual Handle(HYDROData_Region) addNewRegion(); + + +protected: + + friend class HYDROData_Iterator; + + /** + * Creates new object in the internal data structure. Use higher level objects + * to create objects with real content. + */ + HYDROData_CalculationCase(); + + /** + * Destructs properties of the object and object itself, removes it from the document. + */ + ~HYDROData_CalculationCase(); +}; + +#endif diff --git a/src/HYDROData/HYDROData_Iterator.cxx b/src/HYDROData/HYDROData_Iterator.cxx index 43ab980c..7af624e8 100644 --- a/src/HYDROData/HYDROData_Iterator.cxx +++ b/src/HYDROData/HYDROData_Iterator.cxx @@ -3,7 +3,7 @@ #include "HYDROData_AltitudeObject.h" #include "HYDROData_Bathymetry.h" -#include "HYDROData_Calculation.h" +#include "HYDROData_CalculationCase.h" #include "HYDROData_Image.h" #include "HYDROData_ImmersibleZone.h" #include "HYDROData_Polyline.h" @@ -110,7 +110,7 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel ) aResult = new HYDROData_ImmersibleZone(); break; case KIND_CALCULATION: - aResult = new HYDROData_Calculation(); + aResult = new HYDROData_CalculationCase(); break; case KIND_REGION: aResult = new HYDROData_Region(); diff --git a/src/HYDROData/HYDROData_Region.h b/src/HYDROData/HYDROData_Region.h index 5a331837..09c69de6 100644 --- a/src/HYDROData/HYDROData_Region.h +++ b/src/HYDROData/HYDROData_Region.h @@ -81,7 +81,7 @@ protected: protected: - friend class HYDROData_Calculation; + friend class HYDROData_CalculationCase; friend class HYDROData_Iterator; /** diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 30292fac..733ab5d5 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -203,7 +203,7 @@ QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const return aResList; } -void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_Calculation) theCase ) +void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_CalculationCase) theCase ) { myEditedObject = theCase; diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index 0d46504f..55a98ca1 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -24,7 +24,7 @@ #define HYDROGUI_CALCULATIONDLG_H #include "HYDROGUI_Wizard.h" -#include +#include class HYDROGUI_ObjSelector; class QGroupBox; @@ -46,7 +46,7 @@ public: void setObjectName( const QString& theName ); QString getObjectName() const; - void setEditedObject( const Handle(HYDROData_Calculation) theCase ); + void setEditedObject( const Handle(HYDROData_CalculationCase) theCase ); void setGeomObjects( const QStringList& theObjects ); void setSelectedGeomObjects( const QStringList& theObjects ); @@ -63,7 +63,7 @@ private: QListWidget* myGeomObjects; HYDROGUI_DataBrowser* myBrowser; - Handle(HYDROData_Calculation) myEditedObject; + Handle(HYDROData_CalculationCase) myEditedObject; QComboBox* myBathymetryChoice; }; diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 14570182..621d9d75 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -80,7 +80,7 @@ void HYDROGUI_CalculationOp::startOperation() myEditedObject.Nullify(); if ( myIsEdit ) { - myEditedObject = Handle(HYDROData_Calculation)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + myEditedObject = Handle(HYDROData_CalculationCase)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if ( !myEditedObject.IsNull() ) { anObjectName = myEditedObject->GetName(); @@ -105,7 +105,7 @@ void HYDROGUI_CalculationOp::startOperation() else { myEditedObject = - Handle(HYDROData_Calculation)::DownCast( doc()->CreateObject( KIND_CALCULATION ) ); + Handle(HYDROData_CalculationCase)::DownCast( doc()->CreateObject( KIND_CALCULATION ) ); myEditedObject->SetName(anObjectName); } @@ -169,8 +169,8 @@ bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, //Handle(HYDROData_Document) aDocument = doc(); - //Handle(HYDROData_Calculation) aCalculObj = myIsEdit ? myEditedObject : - // Handle(HYDROData_Calculation)::DownCast( aDocument->CreateObject( KIND_CALCULATION ) ); + //Handle(HYDROData_CalculationCase) aCalculObj = myIsEdit ? myEditedObject : + // Handle(HYDROData_CalculationCase)::DownCast( aDocument->CreateObject( KIND_CALCULATION ) ); //if ( aCalculObj.IsNull() ) // return false; diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 52ae6935..ecdd145d 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -28,7 +28,7 @@ #include "HYDROData_SplitToZonesTool.h" #include "HYDROGUI_Shape.h" -#include +#include #include class SUIT_ViewManager; @@ -89,7 +89,7 @@ private: private: bool myIsEdit; - Handle(HYDROData_Calculation) myEditedObject; + Handle(HYDROData_CalculationCase) myEditedObject; SUIT_ViewManager* myActiveViewManager; diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 180b2dd8..8196df50 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -27,7 +27,7 @@ #include "HYDROGUI_Tool.h" #include -#include +#include #include #include #include @@ -271,8 +271,8 @@ void HYDROGUI_DataModel::update( const int theStudyId ) 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 ); } @@ -591,8 +591,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() );