Salome HOME
New files added.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_PrsZone.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HYDROGUI_PrsZone.h"
24
25 #include <QBrush>
26 #include <QPen>
27
28 //=======================================================================
29 // name    : HYDROGUI_PrsZone
30 // Purpose : Constructor
31 //=======================================================================
32 HYDROGUI_PrsZone::HYDROGUI_PrsZone( const Handle(HYDROData_Object)& theObject )
33 : HYDROGUI_Prs( theObject ),
34   myZoneItem( 0 ),
35   myFillingColor( Qt::transparent ),
36   myBorderColor( Qt::transparent )
37 {
38 }
39
40 //=======================================================================
41 // name    : HYDROGUI_PrsZone
42 // Purpose : Destructor
43 //=======================================================================
44 HYDROGUI_PrsZone::~HYDROGUI_PrsZone()
45 {
46 }
47
48 //================================================================
49 // Function : setPath
50 // Purpose  : 
51 //================================================================
52 void HYDROGUI_PrsZone::setPath( const QPainterPath& thePath )
53 {
54   myPath = thePath;
55 }
56
57 //================================================================
58 // Function : getPath
59 // Purpose  : 
60 //================================================================
61 QPainterPath HYDROGUI_PrsZone::getPath() const
62 {
63   return myPath;
64 }
65
66 //================================================================
67 // Function : setFillingColor
68 // Purpose  : 
69 //================================================================
70 void HYDROGUI_PrsZone::setFillingColor( const QColor& theColor )
71 {
72   myFillingColor = theColor;
73 }
74
75 //================================================================
76 // Function : getFillingColor
77 // Purpose  : 
78 //================================================================
79 QColor HYDROGUI_PrsZone::getFillingColor() const
80 {
81   return myFillingColor;
82 }
83
84 //================================================================
85 // Function : setBorderColor
86 // Purpose  : 
87 //================================================================
88 void HYDROGUI_PrsZone::setBorderColor( const QColor& theColor )
89 {
90   myBorderColor = theColor;
91 }
92
93 //================================================================
94 // Function : getBorderColor
95 // Purpose  : 
96 //================================================================
97 QColor HYDROGUI_PrsZone::getBorderColor() const
98 {
99   return myBorderColor;
100 }
101
102 //================================================================
103 // Function : boundingRect
104 // Purpose  : 
105 //================================================================
106 QRectF HYDROGUI_PrsZone::boundingRect() const
107 {
108   return myZoneItem->boundingRect();
109 }
110
111 //================================================================
112 // Function : compute
113 // Purpose  : 
114 //================================================================
115 void HYDROGUI_PrsZone::compute()
116 {
117   if( !myZoneItem )
118   {
119     myZoneItem = new QGraphicsPathItem( this );
120     addToGroup( myZoneItem );
121   }
122   
123   QPainterPath aPath( myPath );
124   aPath.setFillRule( Qt::WindingFill );
125
126   myZoneItem->setPath( aPath );
127   myZoneItem->setBrush( QBrush( myFillingColor ) );
128   myZoneItem->setPen( QPen( myBorderColor ) );
129 }
130
131 //================================================================
132 // Function : checkHighlight
133 // Purpose  : 
134 //================================================================
135 bool HYDROGUI_PrsZone::checkHighlight( double theX, double theY, QCursor& theCursor ) const
136 {
137   // to do
138   return false;
139 }
140
141 //================================================================
142 // Function : select
143 // Purpose  : 
144 //================================================================
145 bool HYDROGUI_PrsZone::select( double theX, double theY, const QRectF& theRect )
146 {
147   return GraphicsView_Object::select( theX, theY, theRect );
148 }
149
150 //================================================================
151 // Function : unselect
152 // Purpose  : 
153 //================================================================
154 void HYDROGUI_PrsZone::unselect()
155 {
156   GraphicsView_Object::unselect();
157 }
158
159 //================================================================
160 // Function : setSelected
161 // Purpose  : 
162 //================================================================
163 void HYDROGUI_PrsZone::setSelected( bool theState )
164 {
165   GraphicsView_Object::setSelected( theState );
166 }