-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <HYDROData_Bathymetry.h>
#include <HYDROData_CalculationCase.h>
+#include <HYDROGUI_DataModelSync.h>
#include <HYDROData_Document.h>
+#include <HYDROData_DummyObject3D.h>
#include <HYDROData_Image.h>
#include <HYDROData_ImmersibleZone.h>
#include <HYDROData_Iterator.h>
#include <HYDROData_Channel.h>
#include <HYDROData_Digue.h>
#include <HYDROData_River.h>
+#include <HYDROData_Stream.h>
-#include <CAM_Application.h>
-#include <CAM_DataObject.h>
#include <CAM_Module.h>
#include <CAM_Study.h>
#include <LightApp_DataObject.h>
#include <LightApp_Study.h>
-#include <SUIT_DataObject.h>
#include <SUIT_DataBrowser.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Study.h>
#include <SUIT_Tools.h>
+#include <SUIT_TreeSync.h>
#include <HYDROData_Document.h>
#include <QApplication>
#include <QDir>
+// #define DEB_GROUPS 1
+#ifdef DEB_GROUPS
+#include <HYDROData_ShapesGroup.h>
+#endif
+
static HYDROData_SequenceOfObjects myCopyingObjects;
+const int ENTRY_COLUMN = 2;
+
+
HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule )
: LightApp_DataModel( theModule )
{
const int aStudyId = theStudy->id();
Data_DocError res = DocError_UnknownProblem;
- if( theFileList.count() == 2 )
+ if( theFileList.count() >= 2 )
{
QString aTmpDir = theFileList[0];
- QString aFileName = theFileList[1];
+ QString aDataFileName = theFileList[1];
+ QString aStatesFileName = theFileList.count() == 3 ? theFileList[2] : "";
myStudyURL = theURL;
- QString aFullPath = SUIT_Tools::addSlash( aTmpDir ) + aFileName;
+ QString aDataFullPath = SUIT_Tools::addSlash( aTmpDir ) + aDataFileName;
+ QString aStatesFullPath = aStatesFileName.isEmpty() ? "" : SUIT_Tools::addSlash( aTmpDir ) + aStatesFileName;
try
{
- res = HYDROData_Document::Load( (char*)aFullPath.toLatin1().constData(), aStudyId );
+ res = HYDROData_Document::Load( (char*)aDataFullPath.toLatin1().constData(), aStudyId );
}
catch(...)
{
module()->application()->putInfo( tr( "LOAD_ERROR" ) );
return false;
}
+
+ if( !aStatesFullPath.isEmpty() )
+ {
+ QFile aFile( aStatesFullPath );
+ if( aFile.open( QFile::ReadOnly ) )
+ {
+ myStates = aFile.readAll();
+ aFile.close();
+ }
+ }
}
// if the document open was successful, the data model update happens
LightApp_DataModel::save( theFileList );
QString aTmpDir;
- QString aFileName;
SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
bool isMultiFile = false;
if( resMgr )
isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
- // save data to temporary files
+ // save module data to temporary files
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy() );
aTmpDir = aStudy->GetTmpDir( myStudyURL.toLatin1().constData(), isMultiFile ).c_str();
- aFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf";
-
- QString aFullPath = aTmpDir + aFileName;
- Data_DocError res = getDocument()->Save( (char*)aFullPath.toLatin1().constData() );
+
+ // save OCAF data to a temporary file
+ QString aDataFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf";
+ QString aDataFullPath = aTmpDir + aDataFileName;
+ Data_DocError res = getDocument()->Save( (char*)aDataFullPath.toLatin1().constData() );
if( res != DocError_OK )
{
module()->application()->putInfo( tr( "SAVE_ERROR" ) );
return false;
}
+ // save tree state data to a temporary file
+ LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
+ QByteArray aStatesData = anApp->objectBrowser()->getOpenStates( ENTRY_COLUMN );
+ QString aStatesFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO_tree_states.txt";
+ QString aStatesFullPath = aTmpDir + aStatesFileName;
+ QFile aFile( aStatesFullPath );
+ if( aFile.open( QFile::WriteOnly ) )
+ {
+ aFile.write( aStatesData );
+ aFile.close();
+ }
+
+ // add temporary files to the list
theFileList.append( aTmpDir );
- theFileList.append( aFileName );
+ theFileList.append( aDataFileName );
+ theFileList.append( aStatesFileName );
return true;
}
if ( aDocument.IsNull() || !aStudy )
return false;
- QString aFileToExport = aStudy->GetTmpDir( theURL.toLatin1().constData(), isMultiFile ).c_str();
- aFileToExport += QString( QDir::separator() ) + "HYDRO.py";
-
- bool aRes = aDocument->DumpToPython( aFileToExport );
+ QString aDir = aStudy->GetTmpDir( theURL.toLatin1().constData(), isMultiFile ).c_str();
+ QString aFileToExport = aDir + QString( QDir::separator() ) + "HYDRO.py";
+ bool aRes = aDocument->DumpToPython( aFileToExport, isMultiFile );
if ( aRes )
{
+ theListOfFiles.append( aDir );
theListOfFiles.append( aFileToExport );
}
if( !aStudyRoot )
return;
- // create root object if not exist
- CAM_DataObject* aRootObj = root();
- if( !aRootObj )
- aRootObj = createRootModuleObject( aStudyRoot );
-
- if( !aRootObj )
- return;
-
- DataObjectList aList;
- aRootObj->children( aList );
- QListIterator<SUIT_DataObject*> anIter( aList );
- while( anIter.hasNext() )
- removeChild( aRootObj, anIter.next() );
+ // create a new root object
+ CAM_DataObject* aNewRootObj = new CAM_DataObject();
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theStudyId );
if( aDocument.IsNull() )
// Create root objects:
// IMAGES
- LightApp_DataObject* anImageRootObj = createObject( aRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) );
+ LightApp_DataObject* anImageRootObj = createObject( aNewRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) );
// BATHYMETRY
- LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, tr( partitionName( KIND_BATHYMETRY ).toAscii() ) );
+ LightApp_DataObject* aBathymetryRootObj = createObject( aNewRootObj, tr( partitionName( KIND_BATHYMETRY ).toAscii() ) );
// ARTIFICIAL OBJECTS
- LightApp_DataObject* anArtificialObjectsRootObj = createObject( aRootObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toAscii() ) );
+ LightApp_DataObject* anArtificialObjectsRootObj = createObject( aNewRootObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toAscii() ) );
// NATURAL OBJECTS
- LightApp_DataObject* aNaturalObjectsRootObj = createObject( aRootObj, tr( partitionName( KIND_NATURAL_OBJECT ).toAscii() ) );
+ LightApp_DataObject* aNaturalObjectsRootObj = createObject( aNewRootObj, tr( partitionName( KIND_NATURAL_OBJECT ).toAscii() ) );
// OBSTACLES
- LightApp_DataObject* anObstaclesRootObj = createObject( aRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) );
+ LightApp_DataObject* anObstaclesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) );
// CALCULATION CASES
- LightApp_DataObject* aCalculRootObj = createObject( aRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
+ LightApp_DataObject* aCalculRootObj = createObject( aNewRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
// POLYLINES
- LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINEXY ).toAscii() ) );
+ LightApp_DataObject* aPolylineRootObj = createObject( aNewRootObj, tr( partitionName( KIND_POLYLINEXY ).toAscii() ) );
// POLYLINES
- LightApp_DataObject* aPolyline3DRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) );
+ LightApp_DataObject* aPolyline3DRootObj = createObject( aNewRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) );
// PROFILES
- LightApp_DataObject* aProfileRootObj = createObject( aRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) );
+ LightApp_DataObject* aProfileRootObj = createObject( aNewRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) );
// VISUAL STATES
- LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) );
+ LightApp_DataObject* aVisualStateRootObj = createObject( aNewRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) );
HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN );
for( ; anIterator.More(); anIterator.Next() ) {
break;
}
+ case KIND_STREAM:
+ {
+ Handle(HYDROData_Stream) aStreamObj =
+ Handle(HYDROData_Stream)::DownCast( anObj );
+ if( !aStreamObj.IsNull() ) {
+ createObject( aNaturalObjectsRootObj, aStreamObj );
+ }
+
+ break;
+ }
case KIND_OBSTACLE:
{
Handle(HYDROData_Obstacle) anObstacleObj =
}
}
- if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() )
+ //if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() )
+ //{
+ // anObjectBrowser->setAutoOpenLevel( 3 );
+ // anObjectBrowser->openLevels();
+ //}
+
+ HYDROGUI_DataModelSync aSync( aNewRootObj );
+ SUIT_DataObject* aRoot = root();
+ bool isNewDoc = aRoot==0;
+ if( isNewDoc )
+ aRoot = createRootModuleObject( aStudyRoot );
+ ::synchronize < suitPtr, suitPtr, HYDROGUI_DataModelSync >
+ ( aNewRootObj, aRoot, aSync );
+
+
+ if( !myStates.isEmpty() )
{
- anObjectBrowser->setAutoOpenLevel( 3 );
- anObjectBrowser->openLevels();
+ LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
+ anApp->objectBrowser()->updateTree();
+ anApp->objectBrowser()->setOpenStates( myStates, ENTRY_COLUMN );
+ myStates.clear();
}
}
HYDROGUI_DataObject* HYDROGUI_DataModel::getDataObject( const Handle(HYDROData_Entity)& theModelObject )
{
- return NULL; // to do if necessary
+ HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>(
+ findObject( HYDROGUI_DataObject::dataObjectEntry( theModelObject ) ) );
+ return aGuiObj;
}
HYDROGUI_DataObject* HYDROGUI_DataModel::getReferencedDataObject( HYDROGUI_DataObject* theObject )
CAM_DataObject* HYDROGUI_DataModel::createRootModuleObject( SUIT_DataObject* theParent )
{
- CAM_DataObject* aRootObj = createModuleObject( theParent );
+ CAM_ModuleObject* aRootObj = createModuleObject( theParent );
+ aRootObj->setDataModel( this );
setRoot( aRootObj );
return aRootObj;
}
bool HYDROGUI_DataModel::canCopy()
{
HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( (HYDROGUI_Module*)module() );
- if( aSeq.Length() != 1 )
- return false;
-
- Handle(HYDROData_Entity) anObject = aSeq.First();
- if( anObject.IsNull() )
- return false;
+ bool isCanCopy = !aSeq.IsEmpty();
- ObjectKind aKind = anObject->GetKind();
- if( aKind == KIND_IMAGE ||
- aKind == KIND_POLYLINE ||
- aKind == KIND_PROFILE ||
- aKind == KIND_CALCULATION )
- return true;
-
- return false;
+ for ( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) {
+ Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
+ if( !anObject.IsNull() ) {
+ ObjectKind aKind = anObject->GetKind();
+ bool isUnrecognized = aKind <= KIND_UNKNOWN || aKind > KIND_LAST;
+ bool isChildObject = aKind == KIND_DUMMY_3D ||
+ aKind == KIND_ZONE ||
+ aKind == KIND_SHAPES_GROUP ||
+ aKind == KIND_SPLITTED_GROUP;
+ if ( isUnrecognized || isChildObject ) {
+ isCanCopy = false;
+ break;
+ }
+ }
+ }
+
+ return isCanCopy;
}
bool HYDROGUI_DataModel::canPaste()
anObject->CopyTo( aClone );
anIsChanged = true;
+ // remove Z layer
+ aClone->RemoveZLevel();
+
// generate a new unique name for the clone object:
// case 1: Image_1 -> Image_2
// case 2: ImageObj -> ImageObj_1
LightApp_DataObject* HYDROGUI_DataModel::buildObject( SUIT_DataObject* theParent,
HYDROGUI_DataObject* theObject,
const QString& theParentEntry,
- const bool theIsBuildTree )
+ const bool theIsBuildTree,
+ const bool theIsInOperation )
{
if ( theIsBuildTree )
{
- buildObjectTree( theParent, theObject, theParentEntry );
+ buildObjectTree( theParent, theObject, theParentEntry, theIsInOperation );
}
return theObject;
}
LightApp_DataObject* HYDROGUI_DataModel::createZone( SUIT_DataObject* theParent,
Handle(HYDROData_Zone) theModelObject,
const QString& theParentEntry,
- const bool theIsBuildTree )
+ const bool theIsBuildTree,
+ const bool theIsInOperation )
{
- return buildObject( theParent, new HYDROGUI_Zone( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
+ return buildObject( theParent, new HYDROGUI_Zone( theParent, theModelObject, theParentEntry, theIsInOperation ),
+ theParentEntry, theIsBuildTree, theIsInOperation );
}
LightApp_DataObject* HYDROGUI_DataModel::createRegion( SUIT_DataObject* theParent,
Handle(HYDROData_Region) theModelObject,
const QString& theParentEntry,
- const bool theIsBuildTree )
+ const bool theIsBuildTree,
+ const bool theIsInOperation )
{
- return buildObject( theParent, new HYDROGUI_Region( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
+ return buildObject( theParent, new HYDROGUI_Region( theParent, theModelObject, theParentEntry, theIsInOperation ),
+ theParentEntry, theIsBuildTree, theIsInOperation );
}
LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
return new HYDROGUI_NamedObject( theParent, theName, theParentEntry );
}
+void HYDROGUI_DataModel::buildObjectPartition( SUIT_DataObject* theObject,
+ const HYDROData_SequenceOfObjects& theObjects,
+ const QString& thePartName,
+ const bool theIsCreateEmpty )
+{
+ if ( theObjects.IsEmpty() && !theIsCreateEmpty )
+ return;
+
+ HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>( theObject );
+ if ( !aGuiObj )
+ return;
+
+ LightApp_DataObject* aPartSect =
+ createObject( aGuiObj, thePartName, aGuiObj->entry() );
+
+ HYDROData_SequenceOfObjects::Iterator anIter( theObjects );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Entity) anObj = anIter.Value();
+ if( !anObj.IsNull() && !anObj->IsRemoved() )
+ createObject( aPartSect, anObj, aGuiObj->entry(), false );
+ }
+}
+
void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
SUIT_DataObject* theObject,
- const QString& theParentEntry )
+ const QString& theParentEntry,
+ const bool theIsInOperation )
{
HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>( theObject );
if ( !aGuiObj )
if ( aDataObj.IsNull() )
return;
+ if ( aDataObj->IsKind( STANDARD_TYPE(HYDROData_Object) ) )
+ {
+ Handle(HYDROData_Object) aGeomObj =
+ Handle(HYDROData_Object)::DownCast( aDataObj );
+
+ Handle(HYDROData_DummyObject3D) anObject3D = aGeomObj->GetObject3D();
+ if ( !anObject3D.IsNull() )
+ createObject( aGuiObj, anObject3D, "", false );
+
+#ifdef DEB_GROUPS
+ HYDROData_SequenceOfObjects anObjGroups = aGeomObj->GetGroups();
+ buildObjectPartition( aGuiObj, anObjGroups, tr( "OBJECT_GROUPS" ), false );
+#endif
+ }
+
ObjectKind anObjectKind = aDataObj->GetKind();
if ( anObjectKind == KIND_IMAGE )
LightApp_DataObject* aBathSect =
createObject( aGuiObj, tr( "ZONE_BATHYMETRY" ), aGuiObj->entry() );
- Handle(HYDROData_Bathymetry) aBathymetry = aZoneObj->GetBathymetry();
- if ( !aBathymetry.IsNull() && !aBathymetry->IsRemoved() )
- createObject( aBathSect, aBathymetry, aGuiObj->entry(), false );
+ Handle(HYDROData_IAltitudeObject) anAltitudeObj = aZoneObj->GetAltitudeObject();
+ if ( !anAltitudeObj.IsNull() && !anAltitudeObj->IsRemoved() )
+ createObject( aBathSect, anAltitudeObj, aGuiObj->entry(), false );
+ }
+ else if ( anObjectKind == KIND_POLYLINE )
+ {
+ Handle(HYDROData_Polyline3D) aPolyline3D =
+ Handle(HYDROData_Polyline3D)::DownCast( aDataObj );
+
+ LightApp_DataObject* aPolylineSect =
+ createObject( aGuiObj, tr( "POLYLINE3D_POLYLINE" ), aGuiObj->entry() );
+
+ Handle(HYDROData_PolylineXY) aPolylineXY = aPolyline3D->GetPolylineXY();
+ if ( !aPolylineXY.IsNull() && !aPolylineXY->IsRemoved() )
+ createObject( aPolylineSect, aPolylineXY, aGuiObj->entry(), false );
+
+ LightApp_DataObject* aProfileSect =
+ createObject( aGuiObj, tr( "POLYLINE3D_PROFILE" ), aGuiObj->entry() );
+
+ Handle(HYDROData_ProfileUZ) aProfileUZ = aPolyline3D->GetProfileUZ();
+ if ( aProfileUZ.IsNull() || aProfileUZ->IsRemoved() )
+ aProfileUZ = aPolyline3D->GetChildProfileUZ( false );
+
+ if ( !aProfileUZ.IsNull() && !aProfileUZ->IsRemoved() )
+ {
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aProfileUZ->GetFatherObject() );
+ if ( !aProfile.IsNull() && !aProfile->IsRemoved() )
+ createObject( aProfileSect, aProfile, aGuiObj->entry(), false );
+ }
+
+ LightApp_DataObject* aBathSect =
+ createObject( aGuiObj, tr( "POLYLINE3D_BATHYMETRY" ), aGuiObj->entry() );
+
+ Handle(HYDROData_IAltitudeObject) anAltitudeObj = aPolyline3D->GetAltitudeObject();
+ if ( !anAltitudeObj.IsNull() && !anAltitudeObj->IsRemoved() )
+ createObject( aBathSect, anAltitudeObj, aGuiObj->entry(), false );
}
else if ( anObjectKind == KIND_CALCULATION )
{
Handle(HYDROData_CalculationCase) aCaseObj =
Handle(HYDROData_CalculationCase)::DownCast( aDataObj );
+ LightApp_DataObject* aPolylineSect =
+ createObject( aGuiObj, tr( "CASE_BOUNDARY" ), aGuiObj->entry() );
+
+ Handle(HYDROData_PolylineXY) aPolyline = aCaseObj->GetBoundaryPolyline();
+ if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() )
+ createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
+
+ LightApp_DataObject* aCaseAOSect =
+ createObject( aGuiObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toAscii() ),
+ aGuiObj->entry() );
+ LightApp_DataObject* aCaseNOSect =
+ createObject( aGuiObj, tr( partitionName( KIND_NATURAL_OBJECT ).toAscii() ),
+ aGuiObj->entry() );
+
+ HYDROData_SequenceOfObjects aSeq = aCaseObj->GetGeometryObjects();
+ HYDROData_SequenceOfObjects::Iterator aGOIter( aSeq );
+ Handle(HYDROData_Entity) anEntity;
+ Handle(HYDROData_ArtificialObject) anAObject;
+ Handle(HYDROData_NaturalObject) aNObject;
+ for ( ; aGOIter.More(); aGOIter.Next() )
+ {
+ anEntity = aGOIter.Value();
+ if ( anEntity.IsNull() )
+ continue;
+ anAObject = Handle(HYDROData_ArtificialObject)::DownCast( anEntity );
+ if ( !anAObject.IsNull() )
+ createObject( aCaseAOSect, anAObject, aGuiObj->entry(), false );
+ else
+ {
+ aNObject = Handle(HYDROData_NaturalObject)::DownCast( anEntity );
+ if ( !aNObject.IsNull() )
+ createObject( aCaseNOSect, aNObject, aGuiObj->entry(), false );
+ }
+ }
LightApp_DataObject* aCaseRegionsSect =
createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() );
Handle(HYDROData_Region) aCaseRegion =
Handle(HYDROData_Region)::DownCast( anIter.Value() );
if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
- createRegion( aCaseRegionsSect, aCaseRegion, "", true );
+ createRegion( aCaseRegionsSect, aCaseRegion, "", true, theIsInOperation );
}
+
+#ifdef DEB_GROUPS
+ HYDROData_SequenceOfObjects aCalcGroups = aCaseObj->GetGeometryGroups();
+ buildObjectPartition( aGuiObj, aCalcGroups, tr( "OBJECT_GROUPS" ), false );
+
+ HYDROData_SequenceOfObjects aCalcSplitGroups = aCaseObj->GetSplittedGroups();
+ buildObjectPartition( aGuiObj, aCalcSplitGroups, tr( "CASE_SPLITTED_GROUPS" ), false );
+#endif
+
}
else if ( anObjectKind == KIND_REGION )
{
Handle(HYDROData_Zone) aRegionZone =
Handle(HYDROData_Zone)::DownCast( anIter.Value() );
if( !aRegionZone.IsNull() && !aRegionZone->IsRemoved() )
- createZone( aGuiObj, aRegionZone, "", true );
+ createZone( aGuiObj, aRegionZone, "", true, theIsInOperation );
}
}
else if ( anObjectKind == KIND_PROFILE )
aGuiObj->setIsValid( aProfileObj->IsValid() );
}
+ else if ( anObjectKind == KIND_CHANNEL || anObjectKind == KIND_DIGUE )
+ {
+ Handle(HYDROData_Channel) aChannelObj =
+ Handle(HYDROData_Channel)::DownCast( aDataObj );
+
+ LightApp_DataObject* aGuideLineSect =
+ createObject( aGuiObj, tr( "CHANNEL_GUIDE_LINE" ), aGuiObj->entry() );
+ Handle(HYDROData_Polyline3D) aGuideLine = aChannelObj->GetGuideLine();
+ if ( !aGuideLine.IsNull() && !aGuideLine->IsRemoved() ) {
+ createObject( aGuideLineSect, aGuideLine, aGuiObj->entry(), false );
+ }
+
+ LightApp_DataObject* aProfileSect =
+ createObject( aGuiObj, tr( "CHANNEL_PROFILE" ), aGuiObj->entry() );
+ Handle(HYDROData_Profile) aProfile = aChannelObj->GetProfile();
+ if ( !aProfile.IsNull() && !aProfile->IsRemoved() ) {
+ createObject( aProfileSect, aProfile, aGuiObj->entry(), false );
+ }
+ }
+ else if ( anObjectKind == KIND_STREAM )
+ {
+ Handle(HYDROData_Stream) aStreamObj =
+ Handle(HYDROData_Stream)::DownCast( aDataObj );
+
+ LightApp_DataObject* aHydraulicAxisSect =
+ createObject( aGuiObj, tr( "STREAM_HYDRAULIC_AXIS" ), aGuiObj->entry() );
+ Handle(HYDROData_PolylineXY) aHydraulicAxis = aStreamObj->GetHydraulicAxis();
+ if ( !aHydraulicAxis.IsNull() && !aHydraulicAxis->IsRemoved() ) {
+ createObject( aHydraulicAxisSect, aHydraulicAxis, aGuiObj->entry(), false );
+ }
+
+ HYDROData_SequenceOfObjects aProfiles = aStreamObj->GetProfiles();
+ buildObjectPartition( aGuiObj, aProfiles, tr( "STREAM_PROFILES" ), true );
+
+ Handle(HYDROData_Polyline3D) aBottomPolyline = aStreamObj->GetBottomPolyline();
+ if ( !aBottomPolyline.IsNull() && !aBottomPolyline->IsRemoved() ) {
+ createObject( aGuiObj, aBottomPolyline, aGuiObj->entry(), false );
+ }
+ }
}
void HYDROGUI_DataModel::buildCaseTree( SUIT_DataObject* theParent, Handle(HYDROData_CalculationCase) theCase )
{
if ( !theCase.IsNull() )
{
- new HYDROGUI_DropTargetObject( theParent, tr( "NEW_REGION" ), "" );
+ if ( theParent )
+ {
+ // Remove previous objects tree
+ DataObjectList aList;
+ theParent->children( aList );
+ QListIterator<SUIT_DataObject*> anIter( aList );
+ while( anIter.hasNext() )
+ removeChild( theParent, anIter.next() );
+ }
+
+ new HYDROGUI_DropTargetObject( theParent, tr( "NEW_REGION" ), "", true );
HYDROData_SequenceOfObjects aCaseRegions = theCase->GetRegions();
HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
Handle(HYDROData_Region) aCaseRegion =
Handle(HYDROData_Region)::DownCast( anIter.Value() );
if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
- createRegion( theParent, aCaseRegion, "", true );
+ createRegion( theParent, aCaseRegion, "", true, true );
+ }
+ }
+}
+
+void HYDROGUI_DataModel::updateObjectTree( Handle(HYDROData_Entity)& theObj )
+{
+ if ( !theObj.IsNull() )
+ {
+ HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>(
+ findObject( HYDROGUI_DataObject::dataObjectEntry( theObj ) ) );
+ if ( aGuiObj )
+ {
+ // Remove previous objects tree
+ DataObjectList aList;
+ aGuiObj->children( aList );
+ QListIterator<SUIT_DataObject*> anIter( aList );
+ while( anIter.hasNext() )
+ removeChild( aGuiObj, anIter.next() );
+
+ // Rebuild the subtree
+ QString aParentEntry;
+ HYDROGUI_DataObject* aParent = dynamic_cast<HYDROGUI_DataObject*>( aGuiObj->parent() );
+ if ( aParent )
+ {
+ aParentEntry = aParent->entry();
+ }
+ buildObjectTree( aParent, aGuiObj, aParentEntry, aGuiObj->isInOperation() );
+ }
+ else
+ {
+ // workaround for the bug in SalomeApp_Study::findObjectByEntry - it can't find LightApp_DataObjects
+ HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
+ if( aModule )
+ {
+ aModule->getApp()->updateObjectBrowser();
+ }
}
}
}
}
return isOk;
}
+
+bool HYDROGUI_DataModel::rename( Handle(HYDROData_Entity) theEntity, const QString& theName )
+{
+ if ( theName.isEmpty() )
+ return false;
+
+ try
+ {
+ getDocument()->StartOperation();
+ theEntity->SetName( theName );
+ getDocument()->CommitOperation( HYDROGUI_Tool::ToExtString( tr("RENAME_TO").arg( theName ) ) );
+ module()->application()->activeStudy()->Modified();
+ }
+ catch ( Standard_Failure )
+ {
+ getDocument()->AbortOperation();
+ return false;
+ }
+ return true;
+}
+