1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_PrsZone.h"
28 //=======================================================================
29 // name : HYDROGUI_PrsZone
30 // Purpose : Constructor
31 //=======================================================================
32 HYDROGUI_PrsZone::HYDROGUI_PrsZone( const Handle(HYDROData_Entity)& theObject )
33 : HYDROGUI_Prs( theObject ),
35 myFillingColor( Qt::transparent ),
36 myBorderColor( Qt::transparent )
40 //=======================================================================
41 // name : HYDROGUI_PrsZone
42 // Purpose : Destructor
43 //=======================================================================
44 HYDROGUI_PrsZone::~HYDROGUI_PrsZone()
48 //================================================================
51 //================================================================
52 void HYDROGUI_PrsZone::setPath( const QPainterPath& thePath )
57 //================================================================
60 //================================================================
61 QPainterPath HYDROGUI_PrsZone::getPath() const
66 //================================================================
67 // Function : setFillingColor
69 //================================================================
70 void HYDROGUI_PrsZone::setFillingColor( const QColor& theColor )
72 myFillingColor = theColor;
75 //================================================================
76 // Function : getFillingColor
78 //================================================================
79 QColor HYDROGUI_PrsZone::getFillingColor() const
81 return myFillingColor;
84 //================================================================
85 // Function : setBorderColor
87 //================================================================
88 void HYDROGUI_PrsZone::setBorderColor( const QColor& theColor )
90 myBorderColor = theColor;
93 //================================================================
94 // Function : getBorderColor
96 //================================================================
97 QColor HYDROGUI_PrsZone::getBorderColor() const
102 //================================================================
103 // Function : boundingRect
105 //================================================================
106 QRectF HYDROGUI_PrsZone::boundingRect() const
108 return myZoneItem->boundingRect();
111 //================================================================
112 // Function : compute
114 //================================================================
115 void HYDROGUI_PrsZone::compute()
119 myZoneItem = new QGraphicsPathItem( this );
120 addToGroup( myZoneItem );
123 QPainterPath aPath( myPath );
124 //aPath.setFillRule( Qt::WindingFill );
125 aPath.setFillRule( Qt::OddEvenFill ); // ouv: for correct drawing the paths with holes
127 myZoneItem->setPath( aPath );
128 myZoneItem->setBrush( QBrush( myFillingColor ) );
129 myZoneItem->setPen( QPen( myBorderColor ) );
132 //================================================================
133 // Function : checkHighlight
135 //================================================================
136 bool HYDROGUI_PrsZone::checkHighlight( double theX, double theY, QCursor& theCursor ) const
142 //================================================================
145 //================================================================
146 bool HYDROGUI_PrsZone::select( double theX, double theY, const QRectF& theRect )
148 return GraphicsView_Object::select( theX, theY, theRect );
151 //================================================================
152 // Function : unselect
154 //================================================================
155 void HYDROGUI_PrsZone::unselect()
157 GraphicsView_Object::unselect();
160 QPen aPen = myZoneItem->pen();
161 aPen.setColor( Qt::black );
163 myZoneItem->setPen( aPen );
166 //================================================================
167 // Function : setSelected
169 //================================================================
170 void HYDROGUI_PrsZone::setSelected( bool theState )
172 GraphicsView_Object::setSelected( theState );
175 QPen aPen = myZoneItem->pen();
176 aPen.setColor( theState ? Qt::red : Qt::black );
177 aPen.setWidth( theState ? 2 : 1 );
178 myZoneItem->setPen( aPen );