X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_DataModel.cxx;h=bfb64ec4535a95ce647f323b26071d8775a58850;hb=60c1b803621af637e863bf91a54f59251a28552c;hp=63249c73daedf1b515ce767a6c1ffe8181ec9a77;hpb=54c517abf4fb5f89df90c75a71d8292eec4148d6;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 63249c73..bfb64ec4 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -59,6 +60,7 @@ #include #include #include +#include #include @@ -293,6 +295,9 @@ void HYDROGUI_DataModel::update( const int theStudyId ) // OBSTACLES LightApp_DataObject* anObstaclesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_OBSTACLE ).toLatin1() ) ); + //BC Polygons + LightApp_DataObject* aBCPolygonRootObj = createObject( aNewRootObj, tr( partitionName( KIND_BC_POLYGON ).toLatin1() ) ); + // STRICKLER TABLES LightApp_DataObject* aStricklerTablesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_STRICKLER_TABLE ).toLatin1() ) ); @@ -305,11 +310,19 @@ void HYDROGUI_DataModel::update( const int theStudyId ) // VISUAL STATES LightApp_DataObject* aVisualStateRootObj = createObject( aNewRootObj, tr( partitionName( KIND_VISUAL_STATE ).toLatin1() ) ); + int aNoStricklerTableObj = 0; + HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN ); - for( ; anIterator.More(); anIterator.Next() ) { + std::vector ents; + + for( ; anIterator.More(); anIterator.Next() ) + ents.push_back(anIterator.Current()); + + for (int i = 0; i< ents.size();i++) + { LightApp_DataObject* obj = 0; - Handle(HYDROData_Entity) anObj = anIterator.Current(); + Handle(HYDROData_Entity) anObj = ents[i]; if ( !anObj.IsNull() ) { @@ -463,6 +476,16 @@ void HYDROGUI_DataModel::update( const int theStudyId ) obj = createObject( aVisualStateRootObj, aVisualStateObj ); } + break; + } + case KIND_BC_POLYGON: + { + Handle(HYDROData_BCPolygon) aBCPolygonObj = + Handle(HYDROData_BCPolygon)::DownCast( anObj ); + if( !aBCPolygonObj.IsNull() ) { + obj = createObject( aBCPolygonRootObj, aBCPolygonObj ); + } + break; } } @@ -479,8 +502,79 @@ void HYDROGUI_DataModel::update( const int theStudyId ) // anObjectBrowser->openLevels(); //} - HYDROGUI_DataModelSync aSync( aNewRootObj ); SUIT_DataObject* aRoot = root(); + + if (aRoot) + { + std::map entry2ObjNewRoot; + SUIT_DataObjectIterator::DetourType dt = SUIT_DataObjectIterator::DepthLeft; + for ( SUIT_DataObjectIterator it( aNewRootObj, dt ); it.current(); ++it ) + { + LightApp_DataObject* aCurObjN = dynamic_cast(it.current()); + if (aCurObjN) + entry2ObjNewRoot[aCurObjN->entry().toStdString()] = it.current(); + } + + for ( SUIT_DataObjectIterator it( aRoot, dt ); it.current(); ++it ) + { + LightApp_DataObject* aCurObjO = dynamic_cast(it.current()); + if (aCurObjO && aCurObjO->childCount() > 0) + { + std::string entry = aCurObjO->entry().toStdString(); + SUIT_DataObject* newNode = entry2ObjNewRoot[entry]; + if (newNode && aCurObjO->childCount() > 0) + { + DataObjectList newchildren; + newNode->children(newchildren); + //new root - remove children + std::map newNode2Entries; + for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it ) + { + SUIT_DataObject* cc = *it; + LightApp_DataObject* obj = dynamic_cast(cc); + newNode2Entries[obj->entry().toStdString()] = cc; + newNode->removeChild(cc); + } + // + std::set objtemp; + + DataObjectList oldchildren; + aCurObjO->children(oldchildren); + for ( DataObjectList::const_iterator it = oldchildren.begin(); it != oldchildren.end(); ++it ) + { + SUIT_DataObject* old_ch = *it; + std::string entr = dynamic_cast(old_ch)->entry().toStdString(); + if (newNode2Entries.count(entr) > 0) + { + SUIT_DataObject* obj = newNode2Entries[entr]; + newNode->appendChild(obj); + objtemp.insert(obj); + } + } + // + for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it ) + { + SUIT_DataObject* ch = *it; + if (objtemp.count(ch) == 0) + newNode->appendChild(ch); + } + { //IF DEBUG + //add. check + DataObjectList newchildren2; + newNode->children(newchildren2); + std::set entries2, entries1; + for ( DataObjectList::const_iterator it = newchildren2.begin(); it != newchildren2.end(); ++it ) + entries2.insert((dynamic_cast(*it))->entry().toStdString()); + for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it ) + entries1.insert((dynamic_cast(*it))->entry().toStdString()); + assert(entries1 == entries2); + } + } + } + } + } + + HYDROGUI_DataModelSync aSync( aNewRootObj ); bool isNewDoc = aRoot==0; if( isNewDoc ) aRoot = createRootModuleObject( aStudyRoot ); @@ -713,6 +807,8 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind ) case KIND_NATURAL_OBJECT: return "NATURAL_OBJECTS"; case KIND_STRICKLER_TABLE: return "STRICKLER_TABLES"; case KIND_LAND_COVER_MAP: return "LAND_COVER_MAPS"; + case KIND_REGION: return "REGIONS"; + case KIND_BC_POLYGON: return "BOUNDARY_POLYGONS"; default: break; } return QString(); @@ -736,7 +832,8 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* aKind == KIND_SHAPES_GROUP || aKind == KIND_SPLIT_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 || aKind == KIND_LAND_COVER_MAP; + aKind == KIND_DIGUE || aKind == KIND_DUMMY_3D || aKind == KIND_LAND_COVER_MAP || + aKind == KIND_BC_POLYGON; if ( !visibility ) { Handle(HYDROData_Profile) aProfObj = Handle(HYDROData_Profile)::DownCast( theModelObject ); @@ -989,9 +1086,15 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent, aNObject = Handle(HYDROData_NaturalObject)::DownCast( anEntity ); if ( !aNObject.IsNull() ) createObject( aCaseNOSect, aNObject, aGuiObj->entry(), false ); - } + } } + LightApp_DataObject* aBoundaryPolygonSect = + createObject( aGuiObj, tr( "CASE_BOUNDARY_POLYGONS" ), aGuiObj->entry() ); + HYDROData_SequenceOfObjects aBCPolygons = aCaseObj->GetBoundaryPolygons(); + for (int i = 1; i <= aBCPolygons.Size(); i++ ) + createObject( aBoundaryPolygonSect, aBCPolygons(i), aGuiObj->entry(), false ); + LightApp_DataObject* aLandCoverMapSect = createObject( aGuiObj, tr( "CASE_LAND_COVER_MAP" ), aGuiObj->entry() ); @@ -1091,7 +1194,18 @@ void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent, HYDROData_SequenceOfObjects aPolylines = aLandCoverMapObj->GetPolylines(); buildObjectPartition( aGuiObj, aPolylines, tr( "LAND_COVER_POLYLINES" ), true );*/ } - + else if ( anObjectKind == KIND_BC_POLYGON ) + { + Handle(HYDROData_BCPolygon) aBCObj = + Handle(HYDROData_BCPolygon)::DownCast( aDataObj ); + + LightApp_DataObject* aPolylineSect = + createObject( aGuiObj, tr( "BC_POLYGON_POLYLINE" ), aGuiObj->entry() ); + + Handle(HYDROData_PolylineXY) aPolyline = aBCObj->GetPolyline(); + if ( !aPolyline.IsNull() && !aPolyline->IsRemoved() ) + createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false ); + } HYDROGUI_Module* aModule = dynamic_cast( module() ); if( aModule ) aModule->enableLCMActions();