Salome HOME
refs #640: correct width for non-georeferenced profile
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ShapeLandCover.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_ShapeLandCover.h"
20 #include "HYDROGUI_OCCDisplayer.h"
21
22 #include <HYDROData_LandCover.h>
23
24 #include <AIS_InteractiveContext.hxx>
25
26 HYDROGUI_ShapeLandCover::HYDROGUI_ShapeLandCover( HYDROGUI_OCCDisplayer*                theDisplayer,
27                                                   const Handle(AIS_InteractiveContext)& theContext,
28                                                   const Handle_HYDROData_LandCover&     theLandCover,
29                                                   const int                             theZLayer,
30                                                   const bool                            theIsScalarMode )
31 : HYDROGUI_Shape( theContext, theLandCover, theZLayer ),
32   myDisplayer( theDisplayer ),
33   myIsScalarMapMode( theIsScalarMode )
34 {
35 }
36
37 HYDROGUI_ShapeLandCover::~HYDROGUI_ShapeLandCover()
38 {
39 }
40
41 void HYDROGUI_ShapeLandCover::update( bool theIsUpdateViewer, bool isDeactivateSelection )
42 {
43   setIsToUpdate( false );
44
45   Handle(HYDROData_LandCover) aLandCoverObj =
46     Handle(HYDROData_LandCover)::DownCast( getObject() );
47
48   TopoDS_Shape aLandCoverShape = aLandCoverObj->GetShape();
49   if ( !aLandCoverShape.IsNull() ) {
50     setShape( aLandCoverShape, false, false );
51   }
52
53   if ( !myIsScalarMapMode ) {
54     QColor aFillingColor = aLandCoverObj->GetFillingColor();
55     QColor aBorderColor = aLandCoverObj->GetBorderColor();
56
57     setFillingColor( aFillingColor, false, false );
58     setBorderColor( aBorderColor, false, false );
59   } else {
60     updateShape( false, false );
61   }
62
63   HYDROGUI_Shape::update( theIsUpdateViewer, isDeactivateSelection );
64 }
65
66 void HYDROGUI_ShapeLandCover::setScalarMapModeEnabled( const bool theIsToEnable )
67 {
68   myIsScalarMapMode = theIsToEnable;
69 }
70
71 void HYDROGUI_ShapeLandCover::setVisible( const bool theState,
72                                            const bool theIsUpdateViewer )
73 {
74   HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer );
75   myDisplayer->SetToUpdateColorScale();
76 }
77
78 void HYDROGUI_ShapeLandCover::displayShape( const bool theIsUpdateViewer )
79 {
80   HYDROGUI_Shape::displayShape( theIsUpdateViewer );
81   myDisplayer->SetToUpdateColorScale();
82 }
83
84 void HYDROGUI_ShapeLandCover::display( const bool theIsUpdateViewer )
85 {
86   HYDROGUI_Shape::display( theIsUpdateViewer );
87   myDisplayer->SetToUpdateColorScale();
88 }
89
90 void HYDROGUI_ShapeLandCover::erase( const bool theIsUpdateViewer )
91 {
92   HYDROGUI_Shape::erase( theIsUpdateViewer );
93   myDisplayer->SetToUpdateColorScale();
94 }