QtiPlot
0.9.8.2
Main Page
Related Pages
Classes
Files
File List
File Members
qtiplot
src
plot2D
FrameWidget.h
Go to the documentation of this file.
1
/***************************************************************************
2
File : FrameWidget.h
3
Project : QtiPlot
4
--------------------------------------------------------------------
5
Copyright : (C) 2008 by Ion Vasilief
6
Email (use @ for *) : ion_vasilief*yahoo.fr
7
Description : Base class for tool widgets in 2D plots
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 FRAMEWIDGET_H
30
#define FRAMEWIDGET_H
31
32
#include <QWidget>
33
#include <QPen>
34
#include <qwt_plot.h>
35
36
class
Graph
;
37
38
class
FrameWidget
:
public
QWidget
39
{
40
Q_OBJECT
41
42
public
:
44
enum
Unit
{
Inch
,
Millimeter
,
Centimeter
,
Point
,
Pixel
,
Scale
};
45
46
FrameWidget
(
Graph
*);
47
48
Graph
*
plot
(){
return
d_plot
;};
49
51
enum
FrameStyle
{
None
= 0,
Line
= 1,
Shadow
= 2};
53
enum
AttachPolicy
{
Page
,
Scales
};
54
56
double
xValue
(){
return
d_x
;};
58
double
yValue
(){
return
d_y
;};
60
void
setOriginCoord
(
double
x,
double
y);
62
void
setOrigin
(
int
x,
int
y){
move
(QPoint(x, y));};
63
void
move
(
const
QPoint& pos);
64
66
QRectF
boundingRect
()
const
;
68
void
setCoordinates
(
double
left,
double
top,
double
right
,
double
bottom
);
70
void
setSize
(
int
w,
int
h){
setSize
(QSize(w, h));};
72
void
setSize
(
const
QSize& newSize);
74
void
setRect
(
int
x,
int
y,
int
w,
int
h);
75
76
double
right
(){
return
d_x_right
;};
77
double
bottom
(){
return
d_y_bottom
;};
78
79
static
double
xIn
(QWidget *w,
Unit
unit);
80
static
double
yIn
(QWidget *w,
Unit
unit);
81
static
double
widthIn
(QWidget *w,
Unit
unit);
82
static
double
heightIn
(QWidget *w,
Unit
unit);
84
static
void
setRect
(QWidget *,
double
x,
double
y,
double
w,
double
h,
Unit
unit =
Pixel
);
85
86
int
frameStyle
(){
return
d_frame
;};
87
void
setFrameStyle
(
int
style);
88
89
QPen
framePen
(){
return
d_frame_pen
;};
90
void
setFramePen
(
const
QPen& p){
d_frame_pen
= p;};
91
92
Qt::PenStyle
frameLineStyle
(){
return
d_frame_pen
.style();};
93
void
setFrameLineStyle
(
const
Qt::PenStyle& s){
d_frame_pen
.setStyle(s);};
94
95
QColor
frameColor
(){
return
d_frame_pen
.color();};
96
void
setFrameColor
(
const
QColor& c){
d_frame_pen
.setColor(c);};
97
98
double
frameWidth
(){
return
d_frame_pen
.widthF();};
99
void
setFrameWidth
(
double
w){
d_frame_pen
.setWidthF(w);};
100
101
QColor
backgroundColor
(){
return
palette().color(QPalette::Window);};
102
void
setBackgroundColor
(
const
QColor& c){QPalette pal = palette(); pal.setColor(QPalette::Window, c); setPalette(pal);};
103
104
QBrush
brush
(){
return
d_brush
;};
105
void
setBrush
(
const
QBrush& b){
d_brush
= b;};
106
107
int
angle
(){
return
d_angle
;};
108
void
setAngle
(
int
ang){
d_angle
= ang;};
109
110
void
showContextMenu
(){emit
showMenu
();};
111
void
showPropertiesDialog
(){emit
showDialog
();};
112
113
virtual
void
print
(QPainter *p,
const
QwtScaleMap map[QwtPlot::axisCnt]);
114
void
resetOrigin
(){
setOriginCoord
(
d_x
,
d_y
);};
115
void
resetCoordinates
(){
setCoordinates
(
d_x
,
d_y
,
d_x_right
,
d_y_bottom
);};
116
117
virtual
void
updateCoordinates
();
118
virtual
QString
saveToString
();
119
120
void
setAttachPolicy
(
AttachPolicy
attachTo);
121
AttachPolicy
attachPolicy
(){
return
d_attach_policy
;};
122
123
bool
isOnTop
(){
return
d_on_top
;};
124
void
setOnTop
(
bool
on =
true
);
125
126
void
mousePressEvent
(QMouseEvent *);
127
128
signals:
129
void
showDialog
();
130
void
showMenu
();
131
void
changedCoordinates
(
const
QRectF&);
132
133
protected
:
135
double
calculateXValue
();
137
double
calculateYValue
();
139
double
calculateRightValue
();
141
double
calculateBottomValue
();
142
143
virtual
void
drawFrame
(QPainter *p,
const
QRect& rect);
144
virtual
void
paintEvent
(QPaintEvent *e);
145
void
contextMenuEvent
(QContextMenuEvent * ){emit
showMenu
();};
146
148
Graph
*
d_plot
;
149
151
int
d_frame
;
153
QPen
d_frame_pen
;
155
QBrush
d_brush
;
156
158
int
d_angle
;
159
161
double
d_x
;
163
double
d_y
;
165
double
d_x_right
;
167
double
d_y_bottom
;
169
int
d_shadow_width
;
171
AttachPolicy
d_attach_policy
;
172
bool
d_on_top
;
173
};
174
175
#endif
Generated on Fri Mar 14 2014 22:59:34 for QtiPlot by
1.8.1.2