From: mzn Date: Wed, 24 Jun 2015 13:14:13 +0000 (+0300) Subject: refs #569: improve scalar map presentation of Land Covers. X-Git-Tag: v1.4.2~41 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9c28ded0907aad64e44b9ad85542d69d172aafde;p=modules%2Fhydro.git refs #569: improve scalar map presentation of Land Covers. --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index fce2c9e6..a77eff2c 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -131,6 +131,7 @@ set(PROJECT_HEADERS HYDROGUI_RecognizeContoursDlg.h HYDROGUI_RecognizeContoursOp.h HYDROGUI_LandCoverColoringOp.h + HYDROGUI_ShapeLandCover.h ) QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -265,6 +266,7 @@ set(PROJECT_SOURCES HYDROGUI_RecognizeContoursDlg.cxx HYDROGUI_RecognizeContoursOp.cxx HYDROGUI_LandCoverColoringOp.cxx + HYDROGUI_ShapeLandCover.cxx ) add_definitions( diff --git a/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx b/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx index 9cf2567e..2d2c5705 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" @@ -233,6 +234,7 @@ bool HYDROGUI_LandCoverOp::processApply( int& theUpdateFlags, } module()->setIsToUpdate( aZoneObj ); + module()->getOCCDisplayer()->SetToUpdateColorScale(); theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 25494cd8..b55b4a08 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -1050,6 +1050,8 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId, if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) { setLandCoversScalarMapModeOff( theViewId ); + } else if ( theObject->GetKind() == KIND_LAND_COVER && theState ) { + getOCCDisplayer()->SetToUpdateColorScale(); } } } diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index 5707d78b..6cfbf67e 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -23,6 +23,7 @@ #include "HYDROGUI_Tool.h" #include #include +#include #include "HYDROGUI_Operation.h" #include "HYDROGUI_DataObject.h" #include "HYDROGUI_ZLayers.h" @@ -144,7 +145,9 @@ void HYDROGUI_OCCDisplayer::Erase( const HYDROData_SequenceOfObjects& theObjs, module()->removeObjectShape( (size_t)aViewer, anObj ); } aViewer->update(); - UpdateColorScale( aViewer ); + if ( !module()->isLandCoversScalarMapModeOn( (size_t)aViewer ) ) { + UpdateColorScale( aViewer ); + } } HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int theViewerId, @@ -162,6 +165,10 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int aResShape = new HYDROGUI_ShapeImage( theContext, Handle_HYDROData_Image::DownCast( theObject ) ); else if( theObject->IsKind( STANDARD_TYPE( HYDROData_Bathymetry ) ) ) aResShape = new HYDROGUI_ShapeBathymetry( this, theContext, Handle_HYDROData_Bathymetry::DownCast( theObject ) ); + else if( theObject->IsKind( STANDARD_TYPE( HYDROData_LandCover ) ) ) { + bool isScalarMode = module()->isLandCoversScalarMapModeOn( theViewerId ); + aResShape = new HYDROGUI_ShapeLandCover( this, theContext, Handle_HYDROData_LandCover::DownCast( theObject ), -1, isScalarMode ); + } else aResShape = new HYDROGUI_Shape( theContext, theObject ); @@ -403,7 +410,7 @@ void HYDROGUI_OCCDisplayer::SetToUpdateColorScale() void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer ) { - if( !myToUpdateColorScale ) + if( !myToUpdateColorScale || !theViewer ) return; OCCViewer_ViewWindow* aWnd = dynamic_cast( theViewer->getViewManager()->getActiveView() ); @@ -492,19 +499,21 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer aView->ColorScaleErase(); } - bool isScaleColoringOn = isDisplayColorScale && !aColorScale.IsNull(); foreach( HYDROGUI_Shape* aShape, aLandCoverShapes ) { - if ( !aShape || !aShape->isVisible() ) { + HYDROGUI_ShapeLandCover* aLandCoverShape = + dynamic_cast( aShape ); + + if ( !aLandCoverShape || !aLandCoverShape->isVisible() ) { continue; } - + Handle(HYDROData_LandCover) aLandCover = - Handle(HYDROData_LandCover)::DownCast( aShape->getObject() ); + Handle(HYDROData_LandCover)::DownCast( aLandCoverShape->getObject() ); if ( aLandCover.IsNull() ) { continue; } - + QColor aUndefinedColor( Qt::gray ); QColor aColor = isLandCoverColoringOn ? aUndefinedColor : aLandCover->GetFillingColor(); @@ -523,8 +532,12 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer } } - //@MZN aShape->update( false, false ); - aShape->setFillingColor( aColor, true, true ); + aLandCoverShape->setFillingColor( aColor, true, true ); + aLandCoverShape->setScalarMapModeEnabled( isLandCoverColoringOn ); + theViewer->getAISContext()->Redisplay( aLandCoverShape->getAISObject() ); + //theViewer->getAISContext()->UpdateCurrentViewer(); //@MZN + //theViewer->getAISContext()->UpdateCurrent(); + //theViewer->getAISContext()->UpdateSelected( true ); } myToUpdateColorScale = false; diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index 4d015a5c..7e7f3314 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -300,22 +300,6 @@ void HYDROGUI_Shape::update( bool isUpdateViewer, setShape( aCompound, false, false ); } - else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_LandCover) ) ) - { - Handle(HYDROData_LandCover) aLandCoverObj = - Handle(HYDROData_LandCover)::DownCast( myObject ); - - TopoDS_Shape aLandCoverShape = aLandCoverObj->GetShape(); - if ( !aLandCoverShape.IsNull() ) { - setShape( aLandCoverShape, false, false ); - } - - QColor aFillingColor = aLandCoverObj->GetFillingColor(); - QColor aBorderColor = aLandCoverObj->GetBorderColor(); - - setFillingColor( aFillingColor, false, false ); - setBorderColor( aBorderColor, false, false ); - } } if ( myShape.IsNull() || !isVisible() ) diff --git a/src/HYDROGUI/HYDROGUI_ShapeLandCover.cxx b/src/HYDROGUI/HYDROGUI_ShapeLandCover.cxx new file mode 100644 index 00000000..635470ae --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ShapeLandCover.cxx @@ -0,0 +1,94 @@ +// 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, 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_ShapeLandCover.h" +#include "HYDROGUI_OCCDisplayer.h" + +#include + +#include + +HYDROGUI_ShapeLandCover::HYDROGUI_ShapeLandCover( HYDROGUI_OCCDisplayer* theDisplayer, + const Handle(AIS_InteractiveContext)& theContext, + const Handle_HYDROData_LandCover& theLandCover, + const int theZLayer, + const bool theIsScalarMode ) +: HYDROGUI_Shape( theContext, theLandCover, theZLayer ), + myDisplayer( theDisplayer ), + myIsScalarMapMode( theIsScalarMode ) +{ +} + +HYDROGUI_ShapeLandCover::~HYDROGUI_ShapeLandCover() +{ +} + +void HYDROGUI_ShapeLandCover::update( bool theIsUpdateViewer, bool isDeactivateSelection ) +{ + setIsToUpdate( false ); + + Handle(HYDROData_LandCover) aLandCoverObj = + Handle(HYDROData_LandCover)::DownCast( getObject() ); + + TopoDS_Shape aLandCoverShape = aLandCoverObj->GetShape(); + if ( !aLandCoverShape.IsNull() ) { + setShape( aLandCoverShape, false, false ); + } + + if ( !myIsScalarMapMode ) { + QColor aFillingColor = aLandCoverObj->GetFillingColor(); + QColor aBorderColor = aLandCoverObj->GetBorderColor(); + + setFillingColor( aFillingColor, false, false ); + setBorderColor( aBorderColor, false, false ); + } else { + updateShape( false, false ); + } + + HYDROGUI_Shape::update( theIsUpdateViewer, isDeactivateSelection ); +} + +void HYDROGUI_ShapeLandCover::setScalarMapModeEnabled( const bool theIsToEnable ) +{ + myIsScalarMapMode = theIsToEnable; +} + +void HYDROGUI_ShapeLandCover::setVisible( const bool theState, + const bool theIsUpdateViewer ) +{ + HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer ); + myDisplayer->SetToUpdateColorScale(); +} + +void HYDROGUI_ShapeLandCover::displayShape( const bool theIsUpdateViewer ) +{ + HYDROGUI_Shape::displayShape( theIsUpdateViewer ); + myDisplayer->SetToUpdateColorScale(); +} + +void HYDROGUI_ShapeLandCover::display( const bool theIsUpdateViewer ) +{ + HYDROGUI_Shape::display( theIsUpdateViewer ); + myDisplayer->SetToUpdateColorScale(); +} + +void HYDROGUI_ShapeLandCover::erase( const bool theIsUpdateViewer ) +{ + HYDROGUI_Shape::erase( theIsUpdateViewer ); + myDisplayer->SetToUpdateColorScale(); +} diff --git a/src/HYDROGUI/HYDROGUI_ShapeLandCover.h b/src/HYDROGUI/HYDROGUI_ShapeLandCover.h new file mode 100644 index 00000000..3f89307d --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ShapeLandCover.h @@ -0,0 +1,60 @@ +// 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, 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_SHAPE_LANDCOVER_H +#define HYDROGUI_SHAPE_LANDCOVER_H + +#include + +class Handle_HYDROData_LandCover; +class HYDROGUI_OCCDisplayer; + +class HYDROGUI_ShapeLandCover : public HYDROGUI_Shape +{ +public: + HYDROGUI_ShapeLandCover( HYDROGUI_OCCDisplayer* theDisplayer, + const Handle(AIS_InteractiveContext)& theContext, + const Handle_HYDROData_LandCover& theLandCover, + const int theZLayer = -1, + const bool theIsScalarMode = false ); + virtual ~HYDROGUI_ShapeLandCover(); + + virtual void update( bool isUpdateViewer, + bool isDeactivateSelection ); + + virtual void display( const bool theIsUpdateViewer = true ); + virtual void erase( const bool theIsUpdateViewer = true ); + + virtual void setVisible( const bool theState, + const bool theIsUpdateViewer = true ); + + /** + * Enable/disable scalar map coloring mode. + * @param theIsToEnable if true - scalar map coloring mode willbe enbaled, if false - disabled + */ + virtual void setScalarMapModeEnabled( const bool theIsToEnable ); + +protected: + virtual void displayShape( const bool theIsUpdateViewer ); + +private: + HYDROGUI_OCCDisplayer* myDisplayer; + bool myIsScalarMapMode; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx index 16be7aff..c3185734 100644 --- a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx @@ -172,8 +172,6 @@ void HYDROGUI_ShowHideOp::startOperation() anUpdateFlags |= UF_FitAll; } - aModule->getOCCDisplayer()->SetToUpdateColorScale(); //@MZN - // Set VTK viewer active if show a bathymetry if ( aVTKMgr ) {