Salome HOME
lot 12 GUI p.1
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_PrsPolyline.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_PrsPolyline.h"
20
21 #include <QPen>
22
23 //=======================================================================
24 // name    : HYDROGUI_PrsPolyline
25 // Purpose : Constructor
26 //=======================================================================
27 HYDROGUI_PrsPolyline::HYDROGUI_PrsPolyline( const Handle(HYDROData_Entity)& theObject )
28 : HYDROGUI_Prs( theObject ),
29   myPolylineItem( 0 )
30 {
31 }
32
33 //=======================================================================
34 // name    : HYDROGUI_PrsPolyline
35 // Purpose : Destructor
36 //=======================================================================
37 HYDROGUI_PrsPolyline::~HYDROGUI_PrsPolyline()
38 {
39 }
40
41 //================================================================
42 // Function : setPath
43 // Purpose  : 
44 //================================================================
45 void HYDROGUI_PrsPolyline::setPath( const QPainterPath& thePath )
46 {
47   myPath = thePath;
48 }
49
50 //================================================================
51 // Function : getPath
52 // Purpose  : 
53 //================================================================
54 QPainterPath HYDROGUI_PrsPolyline::getPath() const
55 {
56   return myPath;
57 }
58
59 //================================================================
60 // Function : boundingRect
61 // Purpose  : 
62 //================================================================
63 QRectF HYDROGUI_PrsPolyline::boundingRect() const
64 {
65   return myPolylineItem->boundingRect();
66 }
67
68 //================================================================
69 // Function : compute
70 // Purpose  : 
71 //================================================================
72 void HYDROGUI_PrsPolyline::compute()
73 {
74   if( !myPolylineItem )
75   {
76     myPolylineItem = new QGraphicsPathItem( this );
77     addToGroup( myPolylineItem );
78   }
79   myPolylineItem->setPath( myPath );
80 }
81
82 //================================================================
83 // Function : checkHighlight
84 // Purpose  : 
85 //================================================================
86 bool HYDROGUI_PrsPolyline::checkHighlight( double theX, double theY, QCursor& theCursor ) const
87 {
88   // to do
89   return false;
90 }
91
92 //================================================================
93 // Function : select
94 // Purpose  : 
95 //================================================================
96 bool HYDROGUI_PrsPolyline::select( double theX, double theY, const QRectF& theRect )
97 {
98   return GraphicsView_Object::select( theX, theY, theRect );
99 }
100
101 //================================================================
102 // Function : unselect
103 // Purpose  : 
104 //================================================================
105 void HYDROGUI_PrsPolyline::unselect()
106 {
107   GraphicsView_Object::unselect();
108
109   // ouv: tmp
110   QPen aPen = myPolylineItem->pen();
111   aPen.setColor( Qt::black );
112   aPen.setWidth( 1 );
113   myPolylineItem->setPen( aPen );
114 }
115
116 //================================================================
117 // Function : setSelected
118 // Purpose  : 
119 //================================================================
120 void HYDROGUI_PrsPolyline::setSelected( bool theState )
121 {
122   GraphicsView_Object::setSelected( theState );
123
124   // ouv: tmp
125   QPen aPen = myPolylineItem->pen();
126   aPen.setColor( theState ? Qt::red : Qt::black );
127   aPen.setWidth( theState ? 2 : 1 );
128   myPolylineItem->setPen( aPen );
129 }