#include <HYDROData_Stream.h>
#include <HYDROData_StricklerTable.h>
#include <HYDROData_LandCoverMap.h>
+#include <HYDROData_BCPolygon.h>
#include <CAM_Module.h>
#include <CAM_Study.h>
#include <SUIT_Study.h>
#include <SUIT_Tools.h>
#include <SUIT_TreeSync.h>
+#include <SUIT_DataObjectIterator.h>
#include <HYDROData_Document.h>
// Create root objects:
// IMAGES
- LightApp_DataObject* anImageRootObj = createObject( aNewRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) );
+ LightApp_DataObject* anImageRootObj = createObject( aNewRootObj, tr( partitionName( KIND_IMAGE ).toLatin1() ) );
// BATHYMETRY
- LightApp_DataObject* aBathymetryRootObj = createObject( aNewRootObj, tr( partitionName( KIND_BATHYMETRY ).toAscii() ) );
+ LightApp_DataObject* aBathymetryRootObj = createObject( aNewRootObj, tr( partitionName( KIND_BATHYMETRY ).toLatin1() ) );
- // ARTIFICIAL OBJECTS
- LightApp_DataObject* anArtificialObjectsRootObj = createObject( aNewRootObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toAscii() ) );
+ // POLYLINES
+ LightApp_DataObject* aPolylineRootObj = createObject( aNewRootObj, tr( partitionName( KIND_POLYLINEXY ).toLatin1() ) );
+
+ // PROFILES
+ LightApp_DataObject* aProfileRootObj = createObject( aNewRootObj, tr( partitionName( KIND_PROFILE ).toLatin1() ) );
+
+ // POLYLINES 3D
+ LightApp_DataObject* aPolyline3DRootObj = createObject( aNewRootObj, tr( partitionName( KIND_POLYLINE ).toLatin1() ) );
// NATURAL OBJECTS
- LightApp_DataObject* aNaturalObjectsRootObj = createObject( aNewRootObj, tr( partitionName( KIND_NATURAL_OBJECT ).toAscii() ) );
+ LightApp_DataObject* aNaturalObjectsRootObj = createObject( aNewRootObj, tr( partitionName( KIND_NATURAL_OBJECT ).toLatin1() ) );
+
+ // ARTIFICIAL OBJECTS
+ LightApp_DataObject* anArtificialObjectsRootObj = createObject( aNewRootObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toLatin1() ) );
// OBSTACLES
- LightApp_DataObject* anObstaclesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) );
+ 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 ).toAscii() ) );
+ LightApp_DataObject* aStricklerTablesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_STRICKLER_TABLE ).toLatin1() ) );
// LAND COVER MAPS
- LightApp_DataObject* aLandCoversRootObj = createObject( aNewRootObj, tr( partitionName( KIND_LAND_COVER_MAP ).toAscii() ) );
+ LightApp_DataObject* aLandCoversRootObj = createObject( aNewRootObj, tr( partitionName( KIND_LAND_COVER_MAP ).toLatin1() ) );
// CALCULATION CASES
- LightApp_DataObject* aCalculRootObj = createObject( aNewRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
-
- // POLYLINES
- LightApp_DataObject* aPolylineRootObj = createObject( aNewRootObj, tr( partitionName( KIND_POLYLINEXY ).toAscii() ) );
-
- // POLYLINES
- LightApp_DataObject* aPolyline3DRootObj = createObject( aNewRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) );
-
- // PROFILES
- LightApp_DataObject* aProfileRootObj = createObject( aNewRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) );
+ LightApp_DataObject* aCalculRootObj = createObject( aNewRootObj, tr( partitionName( KIND_CALCULATION ).toLatin1() ) );
// VISUAL STATES
- LightApp_DataObject* aVisualStateRootObj = createObject( aNewRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) );
+ 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<Handle(HYDROData_Entity)> 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() )
{
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;
}
}
// anObjectBrowser->openLevels();
//}
- HYDROGUI_DataModelSync aSync( aNewRootObj );
SUIT_DataObject* aRoot = root();
+
+ if (aRoot)
+ {
+ std::map<std::string, SUIT_DataObject*> entry2ObjNewRoot;
+ SUIT_DataObjectIterator::DetourType dt = SUIT_DataObjectIterator::DepthLeft;
+ for ( SUIT_DataObjectIterator it( aNewRootObj, dt ); it.current(); ++it )
+ {
+ LightApp_DataObject* aCurObjN = dynamic_cast<LightApp_DataObject*>(it.current());
+ if (aCurObjN)
+ entry2ObjNewRoot[aCurObjN->entry().toStdString()] = it.current();
+ }
+
+ for ( SUIT_DataObjectIterator it( aRoot, dt ); it.current(); ++it )
+ {
+ LightApp_DataObject* aCurObjO = dynamic_cast<LightApp_DataObject*>(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<std::string, SUIT_DataObject*> newNode2Entries;
+ for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it )
+ {
+ SUIT_DataObject* cc = *it;
+ LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(cc);
+ newNode2Entries[obj->entry().toStdString()] = cc;
+ newNode->removeChild(cc);
+ }
+ //
+ std::set<SUIT_DataObject*> 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<LightApp_DataObject*>(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<std::string> entries2, entries1;
+ for ( DataObjectList::const_iterator it = newchildren2.begin(); it != newchildren2.end(); ++it )
+ entries2.insert((dynamic_cast<LightApp_DataObject*>(*it))->entry().toStdString());
+ for ( DataObjectList::const_iterator it = newchildren.begin(); it != newchildren.end(); ++it )
+ entries1.insert((dynamic_cast<LightApp_DataObject*>(*it))->entry().toStdString());
+ assert(entries1 == entries2);
+ }
+ }
+ }
+ }
+ }
+
+ HYDROGUI_DataModelSync aSync( aNewRootObj );
bool isNewDoc = aRoot==0;
if( isNewDoc )
aRoot = createRootModuleObject( aStudyRoot );
if ( !myStates.isEmpty() )
{
ob->updateTree();
- ob->setOpenStates( myStates, ENTRY_COLUMN );
+ ob->setAutoOpenLevel( 1 );
+ //ob->setOpenStates( myStates, ENTRY_COLUMN );
myStates.clear();
}
}
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();
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 );
createObject( aPolylineSect, aPolyline, aGuiObj->entry(), false );
LightApp_DataObject* aCaseAOSect =
- createObject( aGuiObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toAscii() ),
+ createObject( aGuiObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toLatin1() ),
aGuiObj->entry() );
LightApp_DataObject* aCaseNOSect =
- createObject( aGuiObj, tr( partitionName( KIND_NATURAL_OBJECT ).toAscii() ),
+ createObject( aGuiObj, tr( partitionName( KIND_NATURAL_OBJECT ).toLatin1() ),
aGuiObj->entry() );
HYDROData_SequenceOfObjects aSeq = aCaseObj->GetGeometryObjects();
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() );
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<HYDROGUI_Module*>( module() );
if( aModule )
aModule->enableLCMActions();