X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_LandCoverOp.cxx;h=17ac4487b9240f3af18e973d34092387fc4a8712;hb=00d0017f5e951fb3dd965140d1f16d07d9a49daa;hp=5240b42d86bdcbdbcd2879078db995073d854b55;hpb=d6e19029f8b41f295db878e9aecf451c2edda4af;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx b/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx index 5240b42d..17ac4487 100644 --- a/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx +++ b/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx @@ -20,6 +20,7 @@ #include "HYDROGUI_LandCoverDlg.h" #include "HYDROGUI_Module.h" +#include "HYDROGUI_OCCDisplayer.h" #include "HYDROGUI_Shape.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" @@ -106,15 +107,16 @@ void HYDROGUI_LandCoverOp::startOperation() if ( !aStricklerTableObj.IsNull() ) { // Get Strickler table data from the data model - TColStd_SequenceOfExtendedString aTypes = aStricklerTableObj->GetTypes(); - for ( int i = 1; i <= aTypes.Length(); i++ ) + QStringList aTypes = aStricklerTableObj->GetTypes(); + for ( QStringList::iterator it = aTypes.begin(); it != aTypes.end(); ++it ) { - QString aType = HYDROGUI_Tool::ToQString( aTypes.Value( i ) ); - if ( !aType.isEmpty() && !aStricklerTypes.contains( aType )) + QString aType = *it; + if ( !aType.isEmpty() && !aStricklerTypes.contains( aType ) ) aStricklerTypes.append( aType ); } } } + aStricklerTypes.sort(); aPanel->setAdditionalParams( aStricklerTypes ); @@ -189,17 +191,25 @@ bool HYDROGUI_LandCoverOp::processApply( int& theUpdateFlags, } } + if ( aZonePolylines.IsEmpty() ) + { + theErrorMsg = tr( "POLYLINES_NOT_DEFINED" ); + return false; + } + QString aSelectedStricklerType = aPanel->getSelectedAdditionalParamName(); - // TODO: Generate TopoDS_Shape based on the set of polylines, implement generateTopShape data model method - /* - if ( HYDROData_LandCover::generateTopShape( aZonePolylines ).IsNull() ) + TCollection_AsciiString anError; + if ( HYDROData_LandCover::buildShape( aZonePolylines, anError ).IsNull() ) { - theErrorMsg = tr( "ZONE_OBJECT_CANNOT_BE_CREATED" ); + if ( !anError.IsEmpty() ) { + theErrorMsg = HYDROGUI_Tool::ToQString( anError ); + } else { + theErrorMsg = tr( "LAND_COVER_OBJECT_CANNOT_BE_CREATED" ); + } return false; } - */ - + Handle(HYDROData_LandCover) aZoneObj = myIsEdit ? myEditedObject : Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) ); @@ -225,6 +235,7 @@ bool HYDROGUI_LandCoverOp::processApply( int& theUpdateFlags, } module()->setIsToUpdate( aZoneObj ); + module()->getOCCDisplayer()->SetToUpdateColorScale(); theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; @@ -239,7 +250,7 @@ void HYDROGUI_LandCoverOp::onCreatePreview( const QStringList& thePolylineNames QApplication::setOverrideCursor( Qt::WaitCursor ); - QList aZonePolylines; + HYDROData_SequenceOfObjects aZonePolylines; QStringList::const_iterator anIt = thePolylineNames.begin(), aLast = thePolylineNames.end(); for( ; anIt!=aLast; anIt++ ) { @@ -247,14 +258,11 @@ void HYDROGUI_LandCoverOp::onCreatePreview( const QStringList& thePolylineNames Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) ); if ( !aPolyline.IsNull() ) - aZonePolylines.append( aPolyline ); + aZonePolylines.Append( aPolyline ); } - - // TODO: Generate TopoDS_Shape based on the set of polylines, implement generateTopShape data model method - TopoDS_Shape aZoneShape;/* = HYDROData_LandCover::generateTopShape( aZonePolylines ); - if( aZoneShape.IsNull() ) - printErrorMessage( tr( "ZONE_OBJECT_CANNOT_BE_CREATED" ) ); - */ + + TCollection_AsciiString anError; + TopoDS_Shape aZoneShape = HYDROData_LandCover::buildShape( aZonePolylines, anError ); LightApp_Application* anApp = module()->getApp(); if ( !getPreviewManager() ) @@ -283,10 +291,8 @@ void HYDROGUI_LandCoverOp::onCreatePreview( const QStringList& thePolylineNames myPreviewPrs->setFillingColor( aFillingColor, false, false ); myPreviewPrs->setBorderColor( aBorderColor, false, false ); - TopoDS_Face aFace; if( !aZoneShape.IsNull() ) - aFace = TopoDS::Face( aZoneShape ); - myPreviewPrs->setFace( aFace, true, true, "" ); + myPreviewPrs->setShape( aZoneShape ); } QApplication::restoreOverrideCursor(); @@ -313,8 +319,11 @@ void HYDROGUI_LandCoverOp::onAddPolylines() aSelectedPolylines.append( HYDROGUI_ListModel::Object2Visible( aPolyXY, true ) ); } - aPanel->includePolylines( aSelectedPolylines ); - // TODO: create preview of included polylines + if ( aPanel->includePolylines( aSelectedPolylines ) ) + { + closePreview(); + onCreatePreview( aPanel->getPolylineNames() ); + } } void HYDROGUI_LandCoverOp::onRemovePolylines() @@ -340,7 +349,12 @@ void HYDROGUI_LandCoverOp::onRemovePolylines() } module()->update( UF_OCCViewer ); - aPanel->excludePolylines( aSelectedPolylines ); + + if ( aPanel->excludePolylines( aSelectedPolylines ) ) + { + closePreview(); + onCreatePreview( aPanel->getPolylineNames() ); + } } void HYDROGUI_LandCoverOp::closePreview()