QtiPlot
0.9.8.2
Main Page
Related Pages
Classes
Files
File List
File Members
qtiplot
src
plot2D
PlotCurve.h
Go to the documentation of this file.
1
/***************************************************************************
2
File : PlotCurve.h
3
Project : QtiPlot
4
--------------------------------------------------------------------
5
Copyright : (C) 2007 by Ion Vasilief
6
Email (use @ for *) : ion_vasilief*yahoo.fr
7
Description : AbstractPlotCurve and DataCurve classes
8
9
***************************************************************************/
10
11
/***************************************************************************
12
* *
13
* This program is free software; you can redistribute it and/or modify *
14
* it under the terms of the GNU General Public License as published by *
15
* the Free Software Foundation; either version 2 of the License, or *
16
* (at your option) any later version. *
17
* *
18
* This program is distributed in the hope that it will be useful, *
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21
* GNU General Public License for more details. *
22
* *
23
* You should have received a copy of the GNU General Public License *
24
* along with this program; if not, write to the Free Software *
25
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26
* Boston, MA 02110-1301 USA *
27
* *
28
***************************************************************************/
29
#ifndef PLOTCURVE_H
30
#define PLOTCURVE_H
31
32
#include <qwt_plot_curve.h>
33
#include <qwt_plot_marker.h>
34
#include <
Table.h
>
35
36
class
PlotMarker
;
37
class
Table
;
38
class
ErrorBarsCurve
;
39
41
class
PlotCurve
:
public
QwtPlotCurve
42
{
43
44
public
:
45
PlotCurve
(
const
QString& name = QString());
46
48
int
type
(){
return
d_type
;};
49
void
setType
(
int
t){
d_type
= t;};
50
54
int
plotStyle
(){
return
d_plot_style
;};
55
void
setPlotStyle
(
int
s){
d_plot_style
= s;};
56
57
double
xOffset
(){
return
d_x_offset
;};
58
void
setXOffset
(
double
dx){
d_x_offset
= dx;};
59
60
double
yOffset
(){
return
d_y_offset
;};
61
void
setYOffset
(
double
dy){
d_y_offset
= dy;};
62
63
bool
sideLinesEnabled
(){
return
d_side_lines
;};
64
void
enableSideLines
(
bool
on){
d_side_lines
= on;};
65
66
QString
saveCurveSymbolImage
();
67
QString
saveCurveLayout
();
68
void
restoreCurveLayout
(
const
QStringList& lst);
69
71
void
setSkipSymbolsCount
(
int
count);
73
int
skipSymbolsCount
(){
return
d_skip_symbols
;};
74
75
protected
:
76
virtual
void
drawCurve
(QPainter *p,
int
style,
const
QwtScaleMap &xMap,
const
QwtScaleMap &yMap,
int
from,
int
to)
const
;
77
void
drawSideLines
(QPainter *p,
const
QwtScaleMap &xMap,
const
QwtScaleMap &yMap,
int
from,
int
to)
const
;
78
79
virtual
void
drawSymbols
(QPainter *p,
const
QwtSymbol &,
80
const
QwtScaleMap &xMap,
const
QwtScaleMap &yMap,
int
from,
int
to)
const
;
81
82
void
drawSticks
(QPainter *p,
83
const
QwtScaleMap &xMap,
const
QwtScaleMap &yMap,
int
from,
int
to)
const
;
84
85
QwtDoubleRect
boundingRect
()
const
;
86
87
// Rtti
88
int
d_type
;
89
// The plot style of the curve
90
int
d_plot_style
;
91
double
d_x_offset
,
d_y_offset
;
92
bool
d_side_lines
;
93
int
d_skip_symbols
;
94
};
95
96
class
DataCurve
:
public
PlotCurve
97
{
98
99
public
:
100
101
struct
DataRange
102
{
103
unsigned
int
from
;
104
unsigned
int
to
;
105
};
106
107
DataCurve
(
Table
*t,
const
QString& xColName,
const
QString& name,
int
startRow
= 0,
int
endRow
= -1);
108
DataCurve
(
Table
*xt,
const
QString& xColName,
Table
*yt,
const
QString& name,
int
startRow
= 0,
int
endRow
= -1);
109
void
clone
(
DataCurve
* c);
110
111
virtual
QString
saveToString
();
112
void
restoreLabels
(
const
QStringList& lst);
113
114
QString
xColumnName
(){
return
d_x_column
;};
115
void
setXColumnName
(
const
QString& name){
d_x_column
= name;};
116
117
bool
hasLabels
(){
return
!
d_labels_list
.isEmpty();};
118
QString
labelsColumnName
(){
return
d_labels_column
;};
119
void
setLabelsColumnName
(
const
QString& name);
120
121
int
labelsAlignment
(){
return
d_labels_align
;};
122
void
setLabelsAlignment
(
int
flags);
123
124
int
labelsXOffset
(){
return
d_labels_x_offset
;};
125
int
labelsYOffset
(){
return
d_labels_y_offset
;};
126
void
setLabelsOffset
(
int
x,
int
y);
127
128
double
labelsRotation
(){
return
d_labels_angle
;};
129
void
setLabelsRotation
(
double
angle);
130
131
QFont
labelsFont
(){
return
d_labels_font
;};
132
void
setLabelsFont
(
const
QFont& font);
133
134
QColor
labelsColor
(){
return
d_labels_color
;};
135
void
setLabelsColor
(
const
QColor& c);
136
137
bool
labelsWhiteOut
(){
return
d_white_out_labels
;};
138
void
setLabelsWhiteOut
(
bool
whiteOut =
true
);
139
140
Table
*
table
(){
return
d_table
;};
141
Table
*
xTable
(){
return
d_x_table
;};
142
void
setDataSource
(
Table
*yt,
int
ycol = 1,
Table
*xt = NULL,
int
xcol = 0);
143
144
int
startRow
(){
return
d_start_row
;};
145
int
endRow
(){
return
d_end_row
;};
146
void
setRowRange
(
int
startRow
,
int
endRow
);
147
148
bool
isFullRange
();
149
void
setFullRange
();
150
151
virtual
bool
updateData
(
Table
*t,
const
QString& colName);
152
virtual
void
loadData
();
153
void
enableSpeedMode
();
154
156
int
tableRow
(
int
point);
157
158
void
remove
();
159
172
virtual
QStringList
plotAssociation
();
173
virtual
void
updateColumnNames
(
const
QString& oldName,
const
QString& newName,
bool
updateTableName);
174
176
QList<ErrorBarsCurve *>
errorBarsList
(){
return
d_error_bars
;};
178
void
addErrorBars
(
ErrorBarsCurve
*c){
if
(c)
d_error_bars
<< c;};
180
void
removeErrorBars
(
ErrorBarsCurve
*c);
182
void
clearErrorBars
();
184
void
clearLabels
();
185
186
void
setVisible
(
bool
on);
187
188
void
setVisibleLabels
(
bool
on =
true
){
d_show_labels
= on;};
189
bool
hasVisibleLabels
(){
return
d_show_labels
;};
190
bool
selectedLabels
(
const
QPoint& pos);
191
bool
hasSelectedLabels
();
192
void
setLabelsSelected
(
bool
on =
true
);
193
194
void
moveLabels
(
const
QPoint& pos);
195
virtual
void
updateLabelsPosition
();
196
197
protected
:
198
virtual
void
drawCurve
(QPainter *p,
int
style,
const
QwtScaleMap &xMap,
const
QwtScaleMap &yMap,
int
from,
int
to)
const
;
199
200
bool
validCurveType
();
201
virtual
void
loadLabels
();
202
204
QList <ErrorBarsCurve *>
d_error_bars
;
206
Table
*
d_table
;
208
Table
*
d_x_table
;
210
/*
211
*The column name used for Y values is stored in title().text().
212
*/
213
QString
d_x_column
;
214
215
int
d_start_row
;
216
int
d_end_row
;
217
219
QString
d_labels_column
;
220
222
QList <PlotMarker *>
d_labels_list
;
224
double
d_click_pos_x
,
d_click_pos_y
;
225
226
QColor
d_labels_color
;
227
QFont
d_labels_font
;
228
double
d_labels_angle
;
229
bool
d_white_out_labels
;
230
bool
d_show_labels
;
231
int
d_labels_align
,
d_labels_x_offset
,
d_labels_y_offset
;
233
PlotMarker
*
d_selected_label
;
234
std::vector<DataRange>
d_data_ranges
;
235
};
236
237
class
PlotMarker
:
public
QwtPlotMarker
238
{
239
public
:
240
PlotMarker
(
int
index
,
double
angle
);
241
242
int
index
(){
return
d_index
;};
243
void
setIndex
(
int
i){
d_index
= i;};
244
245
double
angle
(){
return
d_angle
;};
246
void
setAngle
(
double
a){
d_angle
= a;};
247
248
double
xLabelOffset
(){
return
d_label_x_offset
;};
249
double
yLabelOffset
(){
return
d_label_y_offset
;};
250
void
setLabelOffset
(
double
xOffset,
double
yOffset){
d_label_x_offset
= xOffset;
d_label_y_offset
= yOffset;};
251
252
protected
:
254
void
draw
(QPainter *p,
const
QwtScaleMap &xMap,
const
QwtScaleMap &yMap,
const
QRect &r)
const
;
255
256
int
d_index
;
257
double
d_angle
;
259
double
d_label_x_offset
;
261
double
d_label_y_offset
;
262
};
263
#endif
Generated on Sat Jun 8 2013 23:27:27 for QtiPlot by
1.8.3.1