Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
Enumerator
a
b
c
d
f
g
h
i
l
m
n
o
p
r
s
t
u
v
x
y
Classes
Class List
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
k
l
m
o
p
r
s
t
u
w
x
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
Properties
a
b
c
d
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
i
m
o
q
r
s
v
w
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
x
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
b
c
d
e
f
h
k
l
o
p
r
s
t
u
x
z
Enumerator
b
c
d
f
h
i
k
l
n
o
p
r
s
t
u
v
w
x
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
3rdparty
qwt
src
qwt_plot_zoneitem.cpp
Go to the documentation of this file.
1
/******************************************************************************
2
* Qwt Widget Library
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2002 Uwe Rathmann
5
*
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the Qwt License, Version 1.0
8
*****************************************************************************/
9
10
#include "
qwt_plot_zoneitem.h
"
11
#include "
qwt_painter.h
"
12
#include "
qwt_scale_map.h
"
13
#include "
qwt_text.h
"
14
#include "
qwt_interval.h
"
15
16
#include <qpainter.h>
17
18
class
QwtPlotZoneItem::PrivateData
19
{
20
public
:
21
PrivateData
()
22
:
orientation
( Qt::Vertical )
23
,
pen
( Qt::NoPen )
24
{
25
QColor c( Qt::darkGray );
26
c.setAlpha( 100 );
27
brush
= QBrush( c );
28
}
29
30
Qt::Orientation
orientation
;
31
QPen
pen
;
32
QBrush
brush
;
33
QwtInterval
interval
;
34
};
35
50
QwtPlotZoneItem::QwtPlotZoneItem
()
51
:
QwtPlotItem
(
QwtText
(
"Zone"
) )
52
{
53
m_data
=
new
PrivateData
;
54
55
setItemAttribute
(
QwtPlotItem::AutoScale
,
false
);
56
setItemAttribute
(
QwtPlotItem::Legend
,
false
);
57
58
setZ
( 5 );
59
}
60
62
QwtPlotZoneItem::~QwtPlotZoneItem
()
63
{
64
delete
m_data
;
65
}
66
68
int
QwtPlotZoneItem::rtti
()
const
69
{
70
return
QwtPlotItem::Rtti_PlotZone
;
71
}
72
86
void
QwtPlotZoneItem::setPen
(
const
QColor&
color
, qreal width, Qt::PenStyle style )
87
{
88
setPen
( QPen(
color
, width, style ) );
89
}
90
99
void
QwtPlotZoneItem::setPen
(
const
QPen& pen )
100
{
101
if
(
m_data
->
pen
!=
pen
)
102
{
103
m_data
->
pen
=
pen
;
104
itemChanged
();
105
}
106
}
107
112
const
QPen&
QwtPlotZoneItem::pen
()
const
113
{
114
return
m_data
->
pen
;
115
}
116
125
void
QwtPlotZoneItem::setBrush
(
const
QBrush& brush )
126
{
127
if
(
m_data
->
brush
!=
brush
)
128
{
129
m_data
->
brush
=
brush
;
130
itemChanged
();
131
}
132
}
133
138
const
QBrush&
QwtPlotZoneItem::brush
()
const
139
{
140
return
m_data
->
brush
;
141
}
142
152
void
QwtPlotZoneItem::setOrientation
( Qt::Orientation orientation )
153
{
154
if
(
m_data
->
orientation
!=
orientation
)
155
{
156
m_data
->
orientation
=
orientation
;
157
itemChanged
();
158
}
159
}
160
165
Qt::Orientation
QwtPlotZoneItem::orientation
()
const
166
{
167
return
m_data
->
orientation
;
168
}
169
181
void
QwtPlotZoneItem::setInterval
(
double
min,
double
max )
182
{
183
setInterval
(
QwtInterval
( min, max ) );
184
}
185
196
void
QwtPlotZoneItem::setInterval
(
const
QwtInterval
& interval )
197
{
198
if
(
m_data
->
interval
!=
interval
)
199
{
200
m_data
->
interval
=
interval
;
201
itemChanged
();
202
}
203
}
204
209
QwtInterval
QwtPlotZoneItem::interval
()
const
210
{
211
return
m_data
->
interval
;
212
}
213
223
void
QwtPlotZoneItem::draw
( QPainter* painter,
224
const
QwtScaleMap
& xMap,
const
QwtScaleMap
& yMap,
225
const
QRectF& canvasRect )
const
226
{
227
if
( !
m_data
->
interval
.
isValid
() )
228
return
;
229
230
QPen
pen
=
m_data
->
pen
;
231
pen
.setCapStyle( Qt::FlatCap );
232
233
const
bool
doAlign =
QwtPainter::roundingAlignment
( painter );
234
235
if
(
m_data
->
orientation
== Qt::Horizontal )
236
{
237
double
y1 = yMap.
transform
(
m_data
->
interval
.
minValue
() );
238
double
y2 = yMap.
transform
(
m_data
->
interval
.
maxValue
() );
239
240
if
( doAlign )
241
{
242
y1 = qRound( y1 );
243
y2 = qRound( y2 );
244
}
245
246
QRectF r( canvasRect.left(), y1, canvasRect.width(), y2 - y1 );
247
r = r.normalized();
248
249
if
( (
m_data
->
brush
.style() != Qt::NoBrush ) && ( y1 != y2 ) )
250
{
251
QwtPainter::fillRect
( painter, r,
m_data
->
brush
);
252
}
253
254
if
(
m_data
->
pen
.style() != Qt::NoPen )
255
{
256
painter->setPen(
m_data
->
pen
);
257
258
QwtPainter::drawLine
( painter, r.left(), r.top(), r.right(), r.top() );
259
QwtPainter::drawLine
( painter, r.left(), r.bottom(), r.right(), r.bottom() );
260
}
261
}
262
else
263
{
264
double
x1 = xMap.
transform
(
m_data
->
interval
.
minValue
() );
265
double
x2 = xMap.
transform
(
m_data
->
interval
.
maxValue
() );
266
267
if
( doAlign )
268
{
269
x1 = qRound( x1 );
270
x2 = qRound( x2 );
271
}
272
273
QRectF r( x1, canvasRect.top(), x2 - x1, canvasRect.height() );
274
r = r.normalized();
275
276
if
( (
m_data
->
brush
.style() != Qt::NoBrush ) && ( x1 != x2 ) )
277
{
278
QwtPainter::fillRect
( painter, r,
m_data
->
brush
);
279
}
280
281
if
(
m_data
->
pen
.style() != Qt::NoPen )
282
{
283
painter->setPen(
m_data
->
pen
);
284
285
QwtPainter::drawLine
( painter, r.left(), r.top(), r.left(), r.bottom() );
286
QwtPainter::drawLine
( painter, r.right(), r.top(), r.right(), r.bottom() );
287
}
288
}
289
}
290
297
QRectF
QwtPlotZoneItem::boundingRect
()
const
298
{
299
QRectF br =
QwtPlotItem::boundingRect
();
300
301
const
QwtInterval
& intv =
m_data
->
interval
;
302
303
if
( intv.
isValid
() )
304
{
305
if
(
m_data
->
orientation
== Qt::Horizontal )
306
{
307
br.setTop( intv.
minValue
() );
308
br.setBottom( intv.
maxValue
() );
309
}
310
else
311
{
312
br.setLeft( intv.
minValue
() );
313
br.setRight( intv.
maxValue
() );
314
}
315
}
316
317
return
br;
318
}
QwtInterval::isValid
bool isValid() const
Definition:
qwt_interval.h:210
color
color
Definition:
color.h:16
QwtPlotZoneItem::PrivateData::PrivateData
PrivateData()
Definition:
qwt_plot_zoneitem.cpp:28
QwtPlotZoneItem::pen
const QPen & pen() const
Definition:
qwt_plot_zoneitem.cpp:112
QwtPlotZoneItem::draw
virtual void draw(QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRectF &canvasRect) const QWT_OVERRIDE
Definition:
qwt_plot_zoneitem.cpp:223
QwtInterval::minValue
double minValue() const
Definition:
qwt_interval.h:192
QwtPlotZoneItem::setOrientation
void setOrientation(Qt::Orientation)
Set the orientation of the zone.
Definition:
qwt_plot_zoneitem.cpp:152
qwt_interval.h
QwtPlotZoneItem::PrivateData::interval
QwtInterval interval
Definition:
qwt_plot_zoneitem.cpp:40
QwtPlotItem::Legend
@ Legend
The item is represented on the legend.
Definition:
qwt_plot_item.h:150
QwtPlotZoneItem::interval
QwtInterval interval() const
Definition:
qwt_plot_zoneitem.cpp:209
QwtPainter::roundingAlignment
static bool roundingAlignment()
Definition:
qwt_painter.h:183
QwtPlotZoneItem::orientation
Qt::Orientation orientation() const
Definition:
qwt_plot_zoneitem.cpp:165
QwtPlotZoneItem::setInterval
void setInterval(double min, double max)
Definition:
qwt_plot_zoneitem.cpp:181
QwtPlotItem::boundingRect
virtual QRectF boundingRect() const
Definition:
qwt_plot_item.cpp:568
QwtPlotItem::AutoScale
@ AutoScale
Definition:
qwt_plot_item.h:157
QwtInterval
A class representing an interval.
Definition:
qwt_interval.h:22
qwt_plot_zoneitem.h
QwtPainter::fillRect
static void fillRect(QPainter *, const QRectF &, const QBrush &)
Wrapper for QPainter::fillRect()
Definition:
qwt_painter.cpp:382
qwt_scale_map.h
QwtText
A class representing a text.
Definition:
qwt_text.h:51
QwtPlotZoneItem::PrivateData::brush
QBrush brush
Definition:
qwt_plot_zoneitem.cpp:39
QwtPlotItem::setZ
void setZ(double z)
Set the z value.
Definition:
qwt_plot_item.cpp:165
QwtPainter::drawLine
static void drawLine(QPainter *, qreal x1, qreal y1, qreal x2, qreal y2)
Wrapper for QPainter::drawLine()
Definition:
qwt_painter.h:154
QwtPlotItem
Base class for items on the plot canvas.
Definition:
qwt_plot_item.h:66
QwtPlotZoneItem::QwtPlotZoneItem
QwtPlotZoneItem()
Constructor.
Definition:
qwt_plot_zoneitem.cpp:50
QwtPlotZoneItem::PrivateData::orientation
Qt::Orientation orientation
Definition:
qwt_plot_zoneitem.cpp:37
QwtScaleMap::transform
double transform(double s) const
Definition:
qwt_scale_map.h:137
QwtPlotItem::itemChanged
virtual void itemChanged()
Definition:
qwt_plot_item.cpp:481
QwtScaleMap
A scale map.
Definition:
qwt_scale_map.h:26
qwt_painter.h
QwtPlotZoneItem::setPen
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
Definition:
qwt_plot_zoneitem.cpp:86
QwtPlotItem::setItemAttribute
void setItemAttribute(ItemAttribute, bool on=true)
Definition:
qwt_plot_item.cpp:228
QwtPlotZoneItem::brush
const QBrush & brush() const
Definition:
qwt_plot_zoneitem.cpp:138
QwtPlotZoneItem::PrivateData
Definition:
qwt_plot_zoneitem.cpp:18
QwtPlotZoneItem::setBrush
void setBrush(const QBrush &)
Assign a brush.
Definition:
qwt_plot_zoneitem.cpp:125
QwtPlotZoneItem::m_data
PrivateData * m_data
Definition:
qwt_plot_zoneitem.h:63
QwtInterval::maxValue
double maxValue() const
Definition:
qwt_interval.h:198
qwt_text.h
QwtPlotItem::Rtti_PlotZone
@ Rtti_PlotZone
For QwtPlotZoneItem.
Definition:
qwt_plot_item.h:126
QwtPlotZoneItem::~QwtPlotZoneItem
virtual ~QwtPlotZoneItem()
Destructor.
Definition:
qwt_plot_zoneitem.cpp:62
QwtPlotZoneItem::rtti
virtual int rtti() const QWT_OVERRIDE
Definition:
qwt_plot_zoneitem.cpp:68
QwtPlotZoneItem::boundingRect
virtual QRectF boundingRect() const QWT_OVERRIDE
Definition:
qwt_plot_zoneitem.cpp:297
QwtPlotZoneItem::PrivateData::pen
QPen pen
Definition:
qwt_plot_zoneitem.cpp:38
plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Jan 26 2025 03:23:25