X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_OCCDisplayer.cxx;h=57d33b38a1e7a17178479d7fc181a2aca7731614;hb=cd6ea20d9a76665a24a533d0340385a335961f05;hp=43df09486392ad354db7731045661da9e197cf33;hpb=5065bfaaab947084a631e5db911f098c7ace8948;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index 43df0948..57d33b38 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// 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 @@ -6,7 +6,7 @@ // 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. +// 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 @@ -25,10 +25,12 @@ #include "HYDROGUI_DataModel.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" -#include "HYDROGUI_Shape.h" +#include +#include #include "HYDROGUI_Operation.h" #include "HYDROGUI_DataObject.h" #include "HYDROGUI_ZLayers.h" +#include #include #include @@ -49,6 +51,7 @@ HYDROGUI_OCCDisplayer::HYDROGUI_OCCDisplayer( HYDROGUI_Module* theModule ) : HYDROGUI_AbstractDisplayer( theModule ) { + myToUpdateColorScale = false; } HYDROGUI_OCCDisplayer::~HYDROGUI_OCCDisplayer() @@ -156,7 +159,13 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int if ( !HYDROGUI_Tool::IsObjectHasPresentation( theObject, OCCViewer_Viewer::Type() ) ) return aResShape; - aResShape = new HYDROGUI_Shape( theContext, theObject ); + if( theObject->IsKind( STANDARD_TYPE( HYDROData_Image ) ) ) + 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 + aResShape = new HYDROGUI_Shape( theContext, theObject ); + module()->setObjectShape( theViewerId, theObject, aResShape ); return aResShape; @@ -349,7 +358,7 @@ bool HYDROGUI_OCCDisplayer::Display( const Handle(HYDROData_Entity)& theObject, if ( anObjShape ) { // update if needed if ( anObjShape->getIsToUpdate() || theIsForced ) { - anObjShape->update( false ); + anObjShape->update( false, false ); } // Set visibility @@ -359,7 +368,6 @@ bool HYDROGUI_OCCDisplayer::Display( const Handle(HYDROData_Entity)& theObject, aRes = true; } - UpdateColorScale( theViewer ); return aRes; } @@ -389,15 +397,23 @@ void HYDROGUI_OCCDisplayer::SetZLayer( const OCCViewer_Viewer* theViewer, } } +void HYDROGUI_OCCDisplayer::SetToUpdateColorScale() +{ + myToUpdateColorScale = true; +} + void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer ) { + if( !myToUpdateColorScale ) + return; + OCCViewer_ViewWindow* aWnd = dynamic_cast( theViewer->getViewManager()->getActiveView() ); Handle(V3d_View) aView = aWnd->getViewPort()->getView(); int aViewerId = (size_t)theViewer;//TODO: check if viewer id is correct - QList aBaths = module()->getObjectShapes( aViewerId, KIND_BATHYMETRY ); + QList aShapes = module()->getObjectShapes( aViewerId, KIND_BATHYMETRY ); - bool isDisplayColorScale = !aBaths.empty(); + bool isDisplayColorScale = !aShapes.empty(); Standard_Real anXPos = 0.05; //TODO Standard_Real anYPos = 0.1; //TODO Standard_Real aWidth = 0.2; //TODO @@ -408,8 +424,12 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer Standard_Real aColorScaleMin = 0, aColorScaleMax = 1, aMin, aMax; bool isFirst = true; - foreach( HYDROGUI_Shape* aBathShape, aBaths ) + foreach( HYDROGUI_Shape* aShape, aShapes ) { + HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast( aShape ); + if( !aBathShape || !aBathShape->isVisible() ) + continue; + aBathShape->GetRange( aMin, aMax ); if( isFirst || aMin < aColorScaleMin ) @@ -436,8 +456,14 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer aColorScale->SetTitle( aColorScaleTitle ); aColorScale->SetRange( aColorScaleMin, aColorScaleMax ); - foreach( HYDROGUI_Shape* aBathShape, aBaths ) + foreach( HYDROGUI_Shape* aShape, aShapes ) + { + HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast( aShape ); + if( !aBathShape || !aBathShape->isVisible() ) + continue; + aBathShape->UpdateWithColorScale( aColorScale ); + } } if( !aView->ColorScaleIsDisplayed() ) aView->ColorScaleDisplay(); @@ -447,4 +473,6 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer if( aView->ColorScaleIsDisplayed() ) aView->ColorScaleErase(); } + + myToUpdateColorScale = false; }