-// 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
-//
+// 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
#include <HYDROData_Digue.h>
#include <HYDROData_River.h>
#include <HYDROData_Stream.h>
+#include <HYDROData_StricklerTable.h>
+#include <HYDROData_LandCover.h>
#include <CAM_Module.h>
#include <CAM_Study.h>
{
}
+bool HYDROGUI_DataModel::create( CAM_Study* theStudy )
+{
+ bool status = LightApp_DataModel::create( theStudy );
+ if ( status )
+ updateDocument();
+ return status;
+}
+
bool HYDROGUI_DataModel::open( const QString& theURL,
CAM_Study* theStudy,
QStringList theFileList )
{
res = DocError_UnknownProblem;
}
- if( res != DocError_OK )
+
+ if ( res != DocError_OK )
{
module()->application()->putInfo( tr( "LOAD_ERROR" ) );
return false;
}
- if( !aStatesFullPath.isEmpty() )
+ if ( !aStatesFullPath.isEmpty() )
{
QFile aFile( aStatesFullPath );
if( aFile.open( QFile::ReadOnly ) )
aFile.close();
}
}
+
+ updateDocument();
}
// if the document open was successful, the data model update happens
// in the set mode of the module
- if( res == DocError_OK )
+ if ( res == DocError_OK )
update( aStudyId );
return true;
QString aTmpDir;
SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
bool isMultiFile = false;
- if( resMgr )
+ if ( resMgr )
isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
// save module data to temporary files
bool HYDROGUI_DataModel::close()
{
+ HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
+ if ( aModule )
+ aModule->clearCache();
return true;
}
// OBSTACLES
LightApp_DataObject* anObstaclesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) );
+ // STRICKLER TABLES
+ LightApp_DataObject* aStricklerTablesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_STRICKLER_TABLE ).toAscii() ) );
+
+ // LAND COVERS
+ LightApp_DataObject* aLandCoversRootObj = createObject( aNewRootObj, tr( partitionName( KIND_LAND_COVER ).toAscii() ) );
+
// CALCULATION CASES
LightApp_DataObject* aCalculRootObj = createObject( aNewRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
// VISUAL STATES
LightApp_DataObject* aVisualStateRootObj = createObject( aNewRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) );
+ int aNoStricklerTableObj = 0;
HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN );
for( ; anIterator.More(); anIterator.Next() ) {
LightApp_DataObject* obj = 0;
obj = createObject( anObstaclesRootObj, anObstacleObj );
}
+ break;
+ }
+ case KIND_STRICKLER_TABLE:
+ {
+ Handle(HYDROData_StricklerTable) aStricklerTableObj =
+ Handle(HYDROData_StricklerTable)::DownCast( anObj );
+ if( !aStricklerTableObj.IsNull() ) {
+ obj = createObject( aStricklerTablesRootObj, aStricklerTableObj );
+ }
+ aNoStricklerTableObj++;
+
+ break;
+ }
+ case KIND_LAND_COVER:
+ {
+ Handle(HYDROData_LandCover) aLandCoverObj =
+ Handle(HYDROData_LandCover)::DownCast( anObj );
+ if( !aLandCoverObj.IsNull() ) {
+ obj = createObject( aLandCoversRootObj, aLandCoverObj );
+ }
+
break;
}
case KIND_CALCULATION:
}
}
+ // Create default Strickler table object
+ if ( aNoStricklerTableObj == 0 )
+ createDefaultStricklerTable( aDocument, aStricklerTablesRootObj );
+
//if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() )
//{
// anObjectBrowser->setAutoOpenLevel( 3 );
Handle(HYDROData_Entity) aClone = getDocument()->CreateObject( aKind );
if( !aClone.IsNull() )
{
- anObject->CopyTo( aClone );
+ anObject->CopyTo( aClone, true );
anIsChanged = true;
// remove Z layer
case KIND_OBSTACLE: return "OBSTACLES";
case KIND_ARTIFICIAL_OBJECT: return "ARTIFICIAL_OBJECTS";
case KIND_NATURAL_OBJECT: return "NATURAL_OBJECTS";
+ case KIND_STRICKLER_TABLE: return "STRICKLER_TABLES";
+ case KIND_LAND_COVER: return "LAND_COVERS";
default: break;
}
return QString();
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;
+ aKind == KIND_DIGUE || aKind == KIND_DUMMY_3D || aKind == KIND_LAND_COVER;
if ( !visibility )
{
Handle(HYDROData_Profile) aProfObj = Handle(HYDROData_Profile)::DownCast( theModelObject );
if ( visibility )
{
- SUIT_AbstractModel* treeModel = 0;
- LightApp_Application* app = dynamic_cast<LightApp_Application*>( module()->application() );
- if ( app )
- treeModel = dynamic_cast<SUIT_AbstractModel*>( app->objectBrowser()->model() );
-
- if ( treeModel )
- treeModel->setVisibilityState( aResObj->text( aResObj->customData( Qtx::IdType ).toInt() ), Qtx::HiddenState, false );
+ setObjectVisibilityState( theModelObject, aResObj );
}
if ( theIsBuildTree )
const bool theIsBuildTree,
const bool theIsInOperation )
{
- return buildObject( theParent, new HYDROGUI_Zone( theParent, theModelObject, theParentEntry, theIsInOperation ),
- theParentEntry, theIsBuildTree, theIsInOperation );
+ HYDROGUI_Zone* aZone = new HYDROGUI_Zone( theParent, theModelObject, theParentEntry, theIsInOperation );
+ LightApp_DataObject* aDataObj = buildObject( theParent, aZone, theParentEntry, theIsBuildTree, theIsInOperation );
+
+ setObjectVisibilityState( theModelObject, aZone );
+
+ return aDataObj;
}
LightApp_DataObject* HYDROGUI_DataModel::createRegion( SUIT_DataObject* theParent,
theParentEntry, theIsBuildTree, theIsInOperation );
}
+void HYDROGUI_DataModel::createDefaultStricklerTable( const Handle(HYDROData_Document)& theDocument,
+ LightApp_DataObject* theParent )
+{
+ // Create default Strickler table object
+ Handle(HYDROData_StricklerTable) aStricklerTableObj =
+ Handle(HYDROData_StricklerTable)::DownCast( theDocument->CreateObject(KIND_STRICKLER_TABLE) );
+ if ( !aStricklerTableObj.IsNull() )
+ {
+ SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
+ QString defTablePath = resMgr->path( "resources", module()->name(), tr( "DEFAULT_STRICKLER_TABLE_FILE" ) );
+ aStricklerTableObj->Import( HYDROGUI_Tool::ToAsciiString( defTablePath ) );
+ // Set name
+ QString aStricklerTableName;
+ if ( aStricklerTableObj->GetName().isEmpty() )
+ {
+ HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
+ if ( aModule )
+ aStricklerTableName = HYDROGUI_Tool::GenerateObjectName( aModule, tr( "DEFAULT_STRICKLER_TABLE_NAME" ) );
+ }
+ if ( aStricklerTableObj->GetName() != aStricklerTableName )
+ aStricklerTableObj->SetName( aStricklerTableName );
+
+ aStricklerTableObj->Update();
+
+ LightApp_DataObject* obj = createObject( theParent, aStricklerTableObj );
+ }
+}
+
LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
const QString& theName,
const QString& theParentEntry )
LightApp_DataObject* aCaseRegionsSect =
createObject( aGuiObj, tr( "CASE_REGIONS" ), aGuiObj->entry() );
- HYDROData_SequenceOfObjects aCaseRegions = aCaseObj->GetRegions();
+ HYDROData_SequenceOfObjects aCaseRegions = aCaseObj->GetRegions( false );
HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
for ( ; anIter.More(); anIter.Next() )
{
createRegion( aCaseRegionsSect, aCaseRegion, "", true, theIsInOperation );
}
+ LightApp_DataObject* aCaseLandCoverRegionsSect =
+ createObject( aGuiObj, tr( "CASE_LAND_COVER_REGIONS" ), aGuiObj->entry() );
+
+ HYDROData_SequenceOfObjects aCaseLandCoverRegions = aCaseObj->GetRegions( true );
+ anIter.Init( aCaseLandCoverRegions );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Region) aCaseLCRegion =
+ Handle(HYDROData_Region)::DownCast( anIter.Value() );
+ if( !aCaseLCRegion.IsNull() && !aCaseLCRegion->IsRemoved() )
+ createRegion( aCaseLandCoverRegionsSect, aCaseLCRegion, "", true, theIsInOperation );
+ }
+
#ifdef DEB_GROUPS
HYDROData_SequenceOfObjects aCalcGroups = aCaseObj->GetGeometryGroups();
buildObjectPartition( aGuiObj, aCalcGroups, tr( "OBJECT_GROUPS" ), false );
createObject( aGuiObj, aBottomPolyline, aGuiObj->entry(), false );
}
}
+ else if ( anObjectKind == KIND_LAND_COVER )
+ {
+ Handle(HYDROData_LandCover) aLandCoverObj =
+ Handle(HYDROData_LandCover)::DownCast( aDataObj );
+
+ HYDROData_SequenceOfObjects aPolylines = aLandCoverObj->GetPolylines();
+ buildObjectPartition( aGuiObj, aPolylines, tr( "LAND_COVER_POLYLINES" ), true );
+ }
+
}
-void HYDROGUI_DataModel::buildCaseTree( SUIT_DataObject* theParent, Handle(HYDROData_CalculationCase) theCase )
+void HYDROGUI_DataModel::buildCaseTree( SUIT_DataObject* theParent, Handle(HYDROData_CalculationCase) theCase,
+ const bool theLandCover )
{
if ( !theCase.IsNull() )
{
new HYDROGUI_DropTargetObject( theParent, tr( "NEW_REGION" ), "", true );
- HYDROData_SequenceOfObjects aCaseRegions = theCase->GetRegions();
+ HYDROData_SequenceOfObjects aCaseRegions = theCase->GetRegions( theLandCover );
HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
for ( ; anIter.More(); anIter.Next() )
{
}
bool HYDROGUI_DataModel::createNewRegion( Handle(HYDROData_CalculationCase) theCase,
- const QList<HYDROGUI_Zone*>& theZonesList )
+ const QList<HYDROGUI_Zone*>& theZonesList,
+ const bool theLandCover )
{
bool isOk = !theCase.IsNull();
if ( isOk )
{
if ( aRegion.IsNull() )
{
- aRegion = theCase->AddNewRegion( aZone );
+ aRegion = theCase->AddNewRegion( aZone, theLandCover );
isOk = !aRegion.IsNull();
}
else
}
return true;
}
+
+void HYDROGUI_DataModel::updateDocument()
+{
+ // Sets the default strickler coefficient from preferences to document.
+ Handle(HYDROData_Document) aDoc = getDocument();
+ SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr();
+ if ( resMgr && !aDoc.IsNull() )
+ aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( "preferences", "default_strickler_coefficient", 0 ) );
+}
+
+void HYDROGUI_DataModel::setObjectVisibilityState( Handle(HYDROData_Entity) theModelObject,
+ HYDROGUI_DataObject* theObject )
+{
+ SUIT_AbstractModel* treeModel = 0;
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>( module()->application() );
+ if ( app )
+ treeModel = dynamic_cast<SUIT_AbstractModel*>( app->objectBrowser()->model() );
+
+ if ( treeModel )
+ {
+ HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
+ bool isVisible = aModule->isObjectVisible( -1, theModelObject );
+ Qtx::VisibilityState aVisState = isVisible ? Qtx::ShownState : Qtx::HiddenState;
+ treeModel->setVisibilityState( theObject->text( theObject->customData( Qtx::IdType ).toInt() ), aVisState, false );
+ }
+}