Salome HOME
refs #653, #665 - 669: start implementation of features.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ShapeLandCoverMap.cxx
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.
6 //
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.
11 //
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
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_ShapeLandCoverMap.h"
20 #include "HYDROGUI_OCCDisplayer.h"
21 #include "HYDROGUI_LandCoverMapPrs.h"
22
23 #include <HYDROData_LandCoverMap.h>
24
25 #include <AIS_InteractiveContext.hxx>
26
27 HYDROGUI_ShapeLandCoverMap::HYDROGUI_ShapeLandCoverMap( HYDROGUI_OCCDisplayer* theDisplayer,
28                                                         const Handle(AIS_InteractiveContext)& theContext,
29                                                         const Handle_HYDROData_LandCoverMap&  theLandCoverMap,
30                                                         const int                             theZLayer,
31                                                         const bool                            theIsScalarMode )
32 : HYDROGUI_Shape( theContext, theLandCoverMap, theZLayer ),
33   myDisplayer( theDisplayer ),
34   myIsScalarMapMode( theIsScalarMode )
35 {
36 }
37
38 HYDROGUI_ShapeLandCoverMap::~HYDROGUI_ShapeLandCoverMap()
39 {
40 }
41
42 void HYDROGUI_ShapeLandCoverMap::update( bool theIsUpdateViewer, bool isDeactivateSelection )
43 {
44   setIsToUpdate( false );
45
46   Handle(HYDROData_LandCoverMap) aLandCoverMapObj =
47     Handle(HYDROData_LandCoverMap)::DownCast( getObject() );
48
49   TopoDS_Shape aLandCoverMapShape = aLandCoverMapObj->GetShape();
50   if ( !aLandCoverMapShape.IsNull() ) {
51     setShape( aLandCoverMapShape, false, false );
52   }
53
54   if ( !myIsScalarMapMode ) {
55     // TODO
56     QColor aFillingColor = Qt::gray;//aLandCoverMapObj->GetFillingColor();
57     QColor aBorderColor = Qt::black;//aLandCoverMapObj->GetBorderColor();
58
59     setFillingColor( aFillingColor, false, false );
60     setBorderColor( aBorderColor, false, false );
61   } else {
62     updateShape( false, false );
63   }
64
65   HYDROGUI_Shape::update( theIsUpdateViewer, isDeactivateSelection );
66 }
67
68 void HYDROGUI_ShapeLandCoverMap::setScalarMapModeEnabled( const bool theIsToEnable )
69 {
70   myIsScalarMapMode = theIsToEnable;
71 }
72
73 void HYDROGUI_ShapeLandCoverMap::setVisible( const bool theState,
74                                              const bool theIsUpdateViewer )
75 {
76   HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer );
77   myDisplayer->SetToUpdateColorScale();
78 }
79
80 void HYDROGUI_ShapeLandCoverMap::displayShape( const bool theIsUpdateViewer )
81 {
82   HYDROGUI_Shape::displayShape( theIsUpdateViewer );
83   myDisplayer->SetToUpdateColorScale();
84 }
85
86 Handle_AIS_InteractiveObject HYDROGUI_ShapeLandCoverMap::createShape() const
87 {
88   Handle(HYDROData_LandCoverMap) aLandCoverMap = Handle(HYDROData_LandCoverMap)::DownCast( getObject() );
89   if ( !aLandCoverMap.IsNull() )
90     return new HYDROGUI_LandCoverMapPrs( aLandCoverMap );
91   return NULL;
92 }
93
94 void HYDROGUI_ShapeLandCoverMap::display( const bool theIsUpdateViewer )
95 {
96   HYDROGUI_Shape::display( theIsUpdateViewer );
97   myDisplayer->SetToUpdateColorScale();
98 }
99
100 void HYDROGUI_ShapeLandCoverMap::erase( const bool theIsUpdateViewer )
101 {
102   HYDROGUI_Shape::erase( theIsUpdateViewer );
103   myDisplayer->SetToUpdateColorScale();
104 }