1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_ShapeLandCoverMap.h"
20 #include "HYDROGUI_OCCDisplayer.h"
21 #include "HYDROGUI_LandCoverMapPrs.h"
23 #include <HYDROData_LandCoverMap.h>
25 #include <AIS_InteractiveContext.hxx>
27 HYDROGUI_ShapeLandCoverMap::HYDROGUI_ShapeLandCoverMap( HYDROGUI_OCCDisplayer* theDisplayer,
28 const Handle(AIS_InteractiveContext)& theContext,
29 const Handle_HYDROData_LandCoverMap& theLandCoverMap,
31 const bool theIsScalarMode )
32 : HYDROGUI_Shape( theContext, theLandCoverMap, theZLayer ),
33 myDisplayer( theDisplayer ),
34 myIsScalarMapMode( theIsScalarMode )
38 HYDROGUI_ShapeLandCoverMap::~HYDROGUI_ShapeLandCoverMap()
42 void HYDROGUI_ShapeLandCoverMap::update( bool theIsUpdateViewer, bool isDeactivateSelection )
44 setIsToUpdate( false );
46 Handle(HYDROData_LandCoverMap) aLandCoverMapObj =
47 Handle(HYDROData_LandCoverMap)::DownCast( getObject() );
49 TopoDS_Shape aLandCoverMapShape = aLandCoverMapObj->GetShape();
50 if ( !aLandCoverMapShape.IsNull() ) {
51 setShape( aLandCoverMapShape, false, false );
55 if ( !myIsScalarMapMode ) {
56 QColor aFillingColor = aLandCoverMapObj->GetFillingColor();
57 QColor aBorderColor = aLandCoverMapObj->GetBorderColor();
59 setFillingColor( aFillingColor, false, false );
60 setBorderColor( aBorderColor, false, false );
62 updateShape( false, false );
65 Handle(HYDROGUI_LandCoverMapPrs) aLandCoverMapPrs = Handle(HYDROGUI_LandCoverMapPrs)::DownCast( getAISObject() );
66 if ( !aLandCoverMapPrs.IsNull() )
67 aLandCoverMapPrs->UpdateColors();
69 HYDROGUI_Shape::update( theIsUpdateViewer, isDeactivateSelection );
72 void HYDROGUI_ShapeLandCoverMap::setScalarMapModeEnabled( const bool theIsToEnable )
74 myIsScalarMapMode = theIsToEnable;
77 void HYDROGUI_ShapeLandCoverMap::setVisible( const bool theState,
78 const bool theIsUpdateViewer )
80 HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer );
81 myDisplayer->SetToUpdateColorScale();
84 void HYDROGUI_ShapeLandCoverMap::displayShape( const bool theIsUpdateViewer )
86 HYDROGUI_Shape::displayShape( theIsUpdateViewer );
87 myDisplayer->SetToUpdateColorScale();
90 Handle_AIS_InteractiveObject HYDROGUI_ShapeLandCoverMap::createShape() const
92 Handle(HYDROData_LandCoverMap) aLandCoverMap = Handle(HYDROData_LandCoverMap)::DownCast( getObject() );
93 if ( !aLandCoverMap.IsNull() )
94 return new HYDROGUI_LandCoverMapPrs( aLandCoverMap );
98 void HYDROGUI_ShapeLandCoverMap::display( const bool theIsUpdateViewer )
100 HYDROGUI_Shape::display( theIsUpdateViewer );
101 myDisplayer->SetToUpdateColorScale();
104 void HYDROGUI_ShapeLandCoverMap::erase( const bool theIsUpdateViewer )
106 HYDROGUI_Shape::erase( theIsUpdateViewer );
107 myDisplayer->SetToUpdateColorScale();