Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
3rdparty
qwt
src
qwt_plot_graphicitem.cpp
Go to the documentation of this file.
1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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_graphicitem.h
"
11
#include "
qwt_scale_map.h
"
12
#include "
qwt_painter.h
"
13
#include "
qwt_text.h
"
14
#include "
qwt_graphic.h
"
15
16
class
QwtPlotGraphicItem::PrivateData
17
{
18
public
:
19
PrivateData
()
20
{
21
}
22
23
QRectF
boundingRect
;
24
QwtGraphic
graphic
;
25
};
26
36
QwtPlotGraphicItem::QwtPlotGraphicItem
(
const
QString&
title
):
37
QwtPlotItem
(
QwtText
( title ) )
38
{
39
init
();
40
}
41
51
QwtPlotGraphicItem::QwtPlotGraphicItem
(
const
QwtText
&
title
):
52
QwtPlotItem
( title )
53
{
54
init
();
55
}
56
58
QwtPlotGraphicItem::~QwtPlotGraphicItem
()
59
{
60
delete
d_data
;
61
}
62
63
void
QwtPlotGraphicItem::init
()
64
{
65
d_data
=
new
PrivateData
();
66
d_data
->
boundingRect
=
QwtPlotItem::boundingRect
();
67
68
setItemAttribute
(
QwtPlotItem::AutoScale
,
true
);
69
setItemAttribute
(
QwtPlotItem::Legend
,
false
);
70
71
setZ
( 8.0 );
72
}
73
75
int
QwtPlotGraphicItem::rtti
()
const
76
{
77
return
QwtPlotItem::Rtti_PlotGraphic
;
78
}
79
86
void
QwtPlotGraphicItem::setGraphic
(
87
const
QRectF &rect,
const
QwtGraphic
&
graphic
)
88
{
89
d_data
->
boundingRect
= rect;
90
d_data
->
graphic
=
graphic
;
91
92
legendChanged
();
93
itemChanged
();
94
}
95
100
QwtGraphic
QwtPlotGraphicItem::graphic
()
const
101
{
102
return
d_data
->
graphic
;
103
}
104
106
QRectF
QwtPlotGraphicItem::boundingRect
()
const
107
{
108
return
d_data
->
boundingRect
;
109
}
110
119
void
QwtPlotGraphicItem::draw
( QPainter *painter,
120
const
QwtScaleMap
&xMap,
const
QwtScaleMap
&yMap,
121
const
QRectF &canvasRect )
const
122
{
123
if
(
d_data
->
graphic
.
isEmpty
() )
124
return
;
125
126
QRectF r =
QwtScaleMap::transform
( xMap, yMap,
boundingRect
() );
127
128
if
( !r.intersects( canvasRect ) )
129
return
;
130
131
if
(
QwtPainter::roundingAlignment
( painter ) )
132
{
133
r.setLeft ( qRound( r.left() ) );
134
r.setRight ( qRound( r.right() ) );
135
r.setTop ( qRound( r.top() ) );
136
r.setBottom ( qRound( r.bottom() ) );
137
}
138
139
d_data
->
graphic
.
render
( painter, r );
140
}
QwtPlotItem::legendChanged
virtual void legendChanged()
Definition:
qwt_plot_item.cpp:491
QwtPlotItem::Rtti_PlotGraphic
For QwtPlotGraphicItem, QwtPlotSvgItem.
Definition:
qwt_plot_item.h:107
QwtPlotGraphicItem::rtti
virtual int rtti() const QWT_OVERRIDE
Definition:
qwt_plot_graphicitem.cpp:75
qwt_scale_map.h
QwtGraphic::render
void render(QPainter *) const
Replay all recorded painter commands.
Definition:
qwt_graphic.cpp:626
QwtPlotGraphicItem::PrivateData
Definition:
qwt_plot_graphicitem.cpp:16
QwtPlotGraphicItem::boundingRect
virtual QRectF boundingRect() const QWT_OVERRIDE
Bounding rectangle of the item.
Definition:
qwt_plot_graphicitem.cpp:106
QwtPlotGraphicItem::~QwtPlotGraphicItem
virtual ~QwtPlotGraphicItem()
Destructor.
Definition:
qwt_plot_graphicitem.cpp:58
QwtPlotItem::Legend
The item is represented on the legend.
Definition:
qwt_plot_item.h:149
QwtPlotGraphicItem::graphic
QwtGraphic graphic() const
Definition:
qwt_plot_graphicitem.cpp:100
QwtText
A class representing a text.
Definition:
qwt_text.h:51
QwtPlotItem::setZ
void setZ(double z)
Set the z value.
Definition:
qwt_plot_item.cpp:165
QwtGraphic
A paint device for scalable graphics.
Definition:
qwt_graphic.h:75
qwt_plot_graphicitem.h
QwtPlotGraphicItem::init
void init()
Definition:
qwt_plot_graphicitem.cpp:63
QwtScaleMap
A scale map.
Definition:
qwt_scale_map.h:26
QwtPlotItem::itemChanged
virtual void itemChanged()
Definition:
qwt_plot_item.cpp:481
QwtPlotGraphicItem::draw
virtual void draw(QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const QWT_OVERRIDE
Definition:
qwt_plot_graphicitem.cpp:119
QwtPlotGraphicItem::PrivateData::graphic
QwtGraphic graphic
Definition:
qwt_plot_graphicitem.cpp:24
QwtPlotItem::AutoScale
Definition:
qwt_plot_item.h:156
QwtPlotGraphicItem::QwtPlotGraphicItem
QwtPlotGraphicItem(const QString &title=QString())
Constructor.
Definition:
qwt_plot_graphicitem.cpp:36
QwtGraphic::isEmpty
bool isEmpty() const
Definition:
qwt_graphic.cpp:424
qwt_text.h
QwtPlotGraphicItem::PrivateData::boundingRect
QRectF boundingRect
Definition:
qwt_plot_graphicitem.cpp:23
qwt_painter.h
QwtPlotItem
Base class for items on the plot canvas.
Definition:
qwt_plot_item.h:65
QwtPlotItem::setItemAttribute
void setItemAttribute(ItemAttribute, bool on=true)
Definition:
qwt_plot_item.cpp:228
QwtScaleMap::transform
double transform(double s) const
Definition:
qwt_scale_map.h:137
QwtPlotGraphicItem::PrivateData::PrivateData
PrivateData()
Definition:
qwt_plot_graphicitem.cpp:19
qwt_graphic.h
QwtPlotGraphicItem::setGraphic
void setGraphic(const QRectF &rect, const QwtGraphic &)
Definition:
qwt_plot_graphicitem.cpp:86
QwtPainter::roundingAlignment
static bool roundingAlignment()
Definition:
qwt_painter.h:181
QwtPlotGraphicItem::d_data
PrivateData * d_data
Definition:
qwt_plot_graphicitem.h:51
QwtPlotItem::title
const QwtText & title() const
Definition:
qwt_plot_item.cpp:215
QwtPlotItem::boundingRect
virtual QRectF boundingRect() const
Definition:
qwt_plot_item.cpp:568
plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:10