X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_DataModel.cxx;h=9b9863dbdf2c77a98fddf5016dbe062a81fa0a5e;hb=a53349567d67f4df0ef737798a25c24d9dc8f08e;hp=6f1adada33b9121c81a475262fb6489338014aa0;hpb=04135f487693a4a9a879af697b706526466583c0;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 6f1adada..9b9863db 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -1,12 +1,8 @@ -// Copyright (C) 2007-2013 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 -// +// Copyright (C) 2014-2015 EDF-R&D // 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 @@ -288,6 +284,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN ); for( ; anIterator.More(); anIterator.Next() ) { + LightApp_DataObject* obj = 0; Handle(HYDROData_Entity) anObj = anIterator.Current(); if ( !anObj.IsNull() ) @@ -298,7 +295,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast( anObj ); if( !anImageObj.IsNull() ) { - createObject( anImageRootObj, anImageObj ); + obj = createObject( anImageRootObj, anImageObj ); } break; @@ -308,7 +305,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Bathymetry) aBathymetryObj = Handle(HYDROData_Bathymetry)::DownCast( anObj ); if( !aBathymetryObj.IsNull() ) { - createObject( aBathymetryRootObj, aBathymetryObj ); + obj = createObject( aBathymetryRootObj, aBathymetryObj ); } break; @@ -318,7 +315,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Channel) aChannelObj = Handle(HYDROData_Channel)::DownCast( anObj ); if( !aChannelObj.IsNull() ) { - createObject( anArtificialObjectsRootObj, aChannelObj ); + obj = createObject( anArtificialObjectsRootObj, aChannelObj ); } break; @@ -328,7 +325,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Digue) aDigueObj = Handle(HYDROData_Digue)::DownCast( anObj ); if( !aDigueObj.IsNull() ) { - createObject( anArtificialObjectsRootObj, aDigueObj ); + obj = createObject( anArtificialObjectsRootObj, aDigueObj ); } break; @@ -338,7 +335,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_ImmersibleZone) anImmersibleZoneObj = Handle(HYDROData_ImmersibleZone)::DownCast( anObj ); if( !anImmersibleZoneObj.IsNull() ) { - createObject( aNaturalObjectsRootObj, anImmersibleZoneObj ); + obj = createObject( aNaturalObjectsRootObj, anImmersibleZoneObj ); } break; @@ -348,7 +345,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_River) aRiverObj = Handle(HYDROData_River)::DownCast( anObj ); if( !aRiverObj.IsNull() ) { - createObject( aNaturalObjectsRootObj, aRiverObj ); + obj = createObject( aNaturalObjectsRootObj, aRiverObj ); } break; @@ -358,7 +355,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Stream) aStreamObj = Handle(HYDROData_Stream)::DownCast( anObj ); if( !aStreamObj.IsNull() ) { - createObject( aNaturalObjectsRootObj, aStreamObj ); + obj = createObject( aNaturalObjectsRootObj, aStreamObj ); } break; @@ -368,7 +365,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Obstacle) anObstacleObj = Handle(HYDROData_Obstacle)::DownCast( anObj ); if( !anObstacleObj.IsNull() ) { - createObject( anObstaclesRootObj, anObstacleObj ); + obj = createObject( anObstaclesRootObj, anObstacleObj ); } break; @@ -378,7 +375,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_CalculationCase) aCalculObj = Handle(HYDROData_CalculationCase)::DownCast( anObj ); if( !aCalculObj.IsNull() ) { - createObject( aCalculRootObj, aCalculObj ); + obj = createObject( aCalculRootObj, aCalculObj ); } break; @@ -388,7 +385,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_PolylineXY) aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anObj ); if( !aPolylineObj.IsNull() ) { - createObject( aPolylineRootObj, aPolylineObj ); + obj = createObject( aPolylineRootObj, aPolylineObj ); } break; @@ -398,7 +395,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Polyline3D) aPolylineObj = Handle(HYDROData_Polyline3D)::DownCast( anObj ); if( !aPolylineObj.IsNull() ) { - createObject( aPolyline3DRootObj, aPolylineObj ); + obj = createObject( aPolyline3DRootObj, aPolylineObj ); } break; @@ -408,7 +405,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_Profile) aProfileObj = Handle(HYDROData_Profile)::DownCast( anObj ); if( !aProfileObj.IsNull() ) { - createObject( aProfileRootObj, aProfileObj ); + obj = createObject( aProfileRootObj, aProfileObj ); } break; @@ -418,7 +415,7 @@ void HYDROGUI_DataModel::update( const int theStudyId ) Handle(HYDROData_VisualState) aVisualStateObj = Handle(HYDROData_VisualState)::DownCast( anObj ); if( !aVisualStateObj.IsNull() ) { - createObject( aVisualStateRootObj, aVisualStateObj ); + obj = createObject( aVisualStateRootObj, aVisualStateObj ); } break; @@ -441,19 +438,21 @@ void HYDROGUI_DataModel::update( const int theStudyId ) ::synchronize < suitPtr, suitPtr, HYDROGUI_DataModelSync > ( aNewRootObj, aRoot, aSync ); + SUIT_DataBrowser* ob = anApp->objectBrowser(); - if( !myStates.isEmpty() ) + if ( !myStates.isEmpty() ) { - LightApp_Application* anApp = dynamic_cast( module()->application() ); - anApp->objectBrowser()->updateTree(); - anApp->objectBrowser()->setOpenStates( myStates, ENTRY_COLUMN ); + ob->updateTree(); + ob->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( + findObject( HYDROGUI_DataObject::dataObjectEntry( theModelObject ) ) ); + return aGuiObj; } HYDROGUI_DataObject* HYDROGUI_DataModel::getReferencedDataObject( HYDROGUI_DataObject* theObject ) @@ -637,24 +636,6 @@ bool HYDROGUI_DataModel::paste() // 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 - QString aName = aClone->GetName(); - QString aPrefix = aName; - if( aName.contains( '_' ) ) // case 1 - { - QString aSuffix = aName.section( '_', -1 ); - bool anIsInteger = false; - aSuffix.toInt( &anIsInteger ); - if( anIsInteger ) - aPrefix = aName.section( '_', 0, -2 ); - } - else // case 2 - aPrefix = aName; - aName = HYDROGUI_Tool::GenerateObjectName( (HYDROGUI_Module*)module(), aPrefix ); - aClone->SetName( aName ); } } } @@ -697,7 +678,36 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* const bool theIsBuildTree ) { HYDROGUI_DataObject* aResObj = new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry ); - + + const ObjectKind aKind = theModelObject->GetKind(); + bool visibility = aKind == KIND_IMAGE || aKind == KIND_POLYLINEXY || aKind == KIND_POLYLINE || + aKind == KIND_SHAPES_GROUP || aKind == KIND_SPLITTED_GROUP || aKind == KIND_ZONE || + aKind == KIND_IMMERSIBLE_ZONE || aKind == KIND_REGION || aKind == KIND_BATHYMETRY || + aKind == KIND_OBSTACLE || aKind == KIND_STREAM || aKind == KIND_CHANNEL || + aKind == KIND_DIGUE || aKind == KIND_DUMMY_3D; + if ( !visibility ) + { + Handle(HYDROData_Profile) aProfObj = Handle(HYDROData_Profile)::DownCast( theModelObject ); + visibility = !aProfObj.IsNull() && aProfObj->IsValid(); + } + + if ( aKind == KIND_REGION ) + { + QString an = aResObj->name(); + int a = 0; + } + + if ( visibility ) + { + SUIT_AbstractModel* treeModel = 0; + LightApp_Application* app = dynamic_cast( module()->application() ); + if ( app ) + treeModel = dynamic_cast( app->objectBrowser()->model() ); + + if ( treeModel ) + treeModel->setVisibilityState( aResObj->text( aResObj->customData( Qtx::IdType ).toInt() ), Qtx::HiddenState, false ); + } + if ( theIsBuildTree ) { buildObjectTree( theParent, aResObj, theParentEntry ); @@ -980,6 +990,11 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent, 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 ); + } } } @@ -1119,4 +1134,3 @@ bool HYDROGUI_DataModel::rename( Handle(HYDROData_Entity) theEntity, const QStri } return true; } -