FrameWidget.h
Go to the documentation of this file.
/***************************************************************************
File : FrameWidget.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2008 by Ion Vasilief
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : Base class for tool widgets in 2D plots
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef FRAMEWIDGET_H
#define FRAMEWIDGET_H
#include <QWidget>
#include <QPen>
#include <qwt_plot.h>
class Graph;
class FrameWidget: public QWidget
{
Q_OBJECT
public:
enum Unit{Inch, Millimeter, Centimeter, Point, Pixel, Scale};
FrameWidget(Graph *);
Graph *plot(){return d_plot;};
enum FrameStyle{None = 0, Line = 1, Shadow = 2};
enum AttachPolicy {Page, Scales};
double xValue(){return d_x;};
double yValue(){return d_y;};
void setOriginCoord(double x, double y);
void setOrigin(int x, int y){move(QPoint(x, y));};
void move(const QPoint& pos);
QRectF boundingRect() const;
void setCoordinates(double left, double top, double right, double bottom);
void setSize(int w, int h){setSize(QSize(w, h));};
void setSize(const QSize& newSize);
void setRect(int x, int y, int w, int h);
double right(){return d_x_right;};
double bottom(){return d_y_bottom;};
static double xIn(QWidget *w, Unit unit);
static double yIn(QWidget *w, Unit unit);
static double widthIn(QWidget *w, Unit unit);
static double heightIn(QWidget *w, Unit unit);
static void setRect(QWidget *, double x, double y, double w, double h, Unit unit = Pixel);
int frameStyle(){return d_frame;};
void setFrameStyle(int style);
QPen framePen(){return d_frame_pen;};
void setFramePen(const QPen& p){d_frame_pen = p;};
Qt::PenStyle frameLineStyle(){return d_frame_pen.style();};
void setFrameLineStyle(const Qt::PenStyle& s){d_frame_pen.setStyle(s);};
QColor frameColor(){return d_frame_pen.color();};
void setFrameColor(const QColor& c){d_frame_pen.setColor(c);};
double frameWidth(){return d_frame_pen.widthF();};
void setFrameWidth(double w){d_frame_pen.setWidthF(w);};
QColor backgroundColor(){return palette().color(QPalette::Window);};
void setBackgroundColor(const QColor& c){QPalette pal = palette(); pal.setColor(QPalette::Window, c); setPalette(pal);};
QBrush brush(){return d_brush;};
void setBrush(const QBrush& b){d_brush = b;};
int angle(){return d_angle;};
void setAngle(int ang){d_angle = ang;};
void showContextMenu(){emit showMenu();};
void showPropertiesDialog(){emit showDialog();};
virtual void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt]);
void resetOrigin(){setOriginCoord(d_x, d_y);};
void resetCoordinates(){setCoordinates(d_x, d_y, d_x_right, d_y_bottom);};
virtual void updateCoordinates();
virtual QString saveToString();
void setAttachPolicy(AttachPolicy attachTo);
AttachPolicy attachPolicy(){return d_attach_policy;};
bool isOnTop(){return d_on_top;};
void setOnTop(bool on = true);
void mousePressEvent(QMouseEvent *);
signals:
void showDialog();
void showMenu();
void changedCoordinates(const QRectF&);
protected:
double calculateXValue();
double calculateYValue();
double calculateRightValue();
double calculateBottomValue();
virtual void drawFrame(QPainter *p, const QRect& rect);
virtual void paintEvent(QPaintEvent *e);
void contextMenuEvent(QContextMenuEvent * ){emit showMenu();};
Graph *d_plot;
int d_frame;
QPen d_frame_pen;
QBrush d_brush;
int d_angle;
double d_x;
double d_y;
double d_x_right;
double d_y_bottom;
int d_shadow_width;
AttachPolicy d_attach_policy;
bool d_on_top;
};
#endif
FrameWidget::showDialog
void showDialog()
FrameWidget::Centimeter
Definition: FrameWidget.h:44
FrameWidget::Millimeter
Definition: FrameWidget.h:44
FrameWidget::showPropertiesDialog
void showPropertiesDialog()
Definition: FrameWidget.h:111
FrameWidget::d_angle
int d_angle
Rotation angle: not implemented yet.
Definition: FrameWidget.h:158
FrameWidget::frameWidth
double frameWidth()
Definition: FrameWidget.h:98
FrameWidget::setOriginCoord
void setOriginCoord(double x, double y)
Sets the position of the top left corner in axis coordinates.
Definition: FrameWidget.cpp:116
FrameWidget::calculateXValue
double calculateXValue()
Returns the x axis coordinate of the top left corner based on the pixel value.
Definition: FrameWidget.cpp:175
FrameWidget::frameLineStyle
Qt::PenStyle frameLineStyle()
Definition: FrameWidget.h:92
FrameWidget::setFrameColor
void setFrameColor(const QColor &c)
Definition: FrameWidget.h:96
FrameWidget::angle
int angle()
Definition: FrameWidget.h:107
FrameWidget::print
virtual void print(QPainter *p, const QwtScaleMap map[QwtPlot::axisCnt])
Definition: FrameWidget.cpp:81
FrameWidget::yValue
double yValue()
Returns the y axis coordiante of the top left corner.
Definition: FrameWidget.h:58
FrameWidget::Scales
Definition: FrameWidget.h:53
FrameWidget::paintEvent
virtual void paintEvent(QPaintEvent *e)
Definition: FrameWidget.cpp:74
FrameWidget::calculateBottomValue
double calculateBottomValue()
Returns the y axis coordinate of the bottom right corner based on the pixel value.
Definition: FrameWidget.cpp:193
FrameWidget::showContextMenu
void showContextMenu()
Definition: FrameWidget.h:110
FrameWidget::mousePressEvent
void mousePressEvent(QMouseEvent *)
Definition: FrameWidget.cpp:255
FrameWidget::brush
QBrush brush()
Definition: FrameWidget.h:104
Graph
A 2D-plotting widget.
Definition: Graph.h:123
FrameWidget::d_frame_pen
QPen d_frame_pen
Pen used to draw the frame.
Definition: FrameWidget.h:153
FrameWidget::boundingRect
QRectF boundingRect() const
Return bounding rectangle in plot coordinates.
Definition: FrameWidget.cpp:199
FrameWidget::Page
Definition: FrameWidget.h:53
FrameWidget::setFramePen
void setFramePen(const QPen &p)
Definition: FrameWidget.h:90
FrameWidget::move
void move(const QPoint &pos)
Definition: FrameWidget.cpp:126
FrameWidget::d_x
double d_x
X axis coordinate of the top left corner.
Definition: FrameWidget.h:161
FrameWidget::setAngle
void setAngle(int ang)
Definition: FrameWidget.h:108
FrameWidget::setFrameWidth
void setFrameWidth(double w)
Definition: FrameWidget.h:99
FrameWidget::Inch
Definition: FrameWidget.h:44
FrameWidget::setRect
void setRect(int x, int y, int w, int h)
Set geometry, giving everything in paint coordinates.
Definition: FrameWidget.cpp:156
FrameWidget::setOnTop
void setOnTop(bool on=true)
Definition: FrameWidget.cpp:455
FrameWidget::isOnTop
bool isOnTop()
Definition: FrameWidget.h:123
FrameWidget::backgroundColor
QColor backgroundColor()
Definition: FrameWidget.h:101
FrameWidget::d_y_bottom
double d_y_bottom
The bottom side position in scale coordinates.
Definition: FrameWidget.h:167
FrameWidget::xValue
double xValue()
Returns the x axis coordiante of the top left corner.
Definition: FrameWidget.h:56
FrameWidget::FrameWidget
FrameWidget(Graph *)
Definition: FrameWidget.cpp:43
FrameWidget::calculateRightValue
double calculateRightValue()
Returns the x axis coordinate of the bottom right corner based on the pixel value.
Definition: FrameWidget.cpp:187
FrameWidget::plot
Graph * plot()
Definition: FrameWidget.h:48
FrameWidget::setBrush
void setBrush(const QBrush &b)
Definition: FrameWidget.h:105
FrameWidget::d_frame
int d_frame
Frame type.
Definition: FrameWidget.h:151
FrameWidget::d_y
double d_y
Y axis coordinate of the top left corner.
Definition: FrameWidget.h:163
FrameWidget::xIn
static double xIn(QWidget *w, Unit unit)
Definition: FrameWidget.cpp:279
FrameWidget::right
double right()
Definition: FrameWidget.h:76
FrameWidget::setFrameStyle
void setFrameStyle(int style)
Definition: FrameWidget.cpp:91
FrameWidget::bottom
double bottom()
Definition: FrameWidget.h:77
FrameWidget::calculateYValue
double calculateYValue()
Returns the y axis coordinate of the top left corner based on the pixel value.
Definition: FrameWidget.cpp:181
FrameWidget::None
Definition: FrameWidget.h:51
FrameWidget
Definition: FrameWidget.h:38
FrameWidget::resetCoordinates
void resetCoordinates()
Definition: FrameWidget.h:115
FrameWidget::changedCoordinates
void changedCoordinates(const QRectF &)
FrameWidget::Shadow
Definition: FrameWidget.h:51
FrameWidget::Unit
Unit
Length units.
Definition: FrameWidget.h:44
FrameWidget::AttachPolicy
AttachPolicy
The attach to policy.
Definition: FrameWidget.h:53
FrameWidget::Point
Definition: FrameWidget.h:44
FrameWidget::showMenu
void showMenu()
FrameWidget::updateCoordinates
virtual void updateCoordinates()
Definition: FrameWidget.cpp:108
FrameWidget::setSize
void setSize(int w, int h)
Set size in paint coordinates (pixels).
Definition: FrameWidget.h:70
FrameWidget::setOrigin
void setOrigin(int x, int y)
Sets the position of the top left corner in paint coordinates.
Definition: FrameWidget.h:62
FrameWidget::yIn
static double yIn(QWidget *w, Unit unit)
Definition: FrameWidget.cpp:308
FrameWidget::frameStyle
int frameStyle()
Definition: FrameWidget.h:86
FrameWidget::attachPolicy
AttachPolicy attachPolicy()
Definition: FrameWidget.h:121
FrameWidget::d_shadow_width
int d_shadow_width
Frame width in pixels.
Definition: FrameWidget.h:169
FrameWidget::d_plot
Graph * d_plot
Parent plot.
Definition: FrameWidget.h:145
FrameWidget::Pixel
Definition: FrameWidget.h:44
FrameWidget::setAttachPolicy
void setAttachPolicy(AttachPolicy attachTo)
Definition: FrameWidget.cpp:449
FrameWidget::setBackgroundColor
void setBackgroundColor(const QColor &c)
Definition: FrameWidget.h:102
FrameWidget::Scale
Definition: FrameWidget.h:44
FrameWidget::frameColor
QColor frameColor()
Definition: FrameWidget.h:95
FrameWidget::d_brush
QBrush d_brush
Background brush.
Definition: FrameWidget.h:155
FrameWidget::heightIn
static double heightIn(QWidget *w, Unit unit)
Definition: FrameWidget.cpp:366
FrameWidget::setFrameLineStyle
void setFrameLineStyle(const Qt::PenStyle &s)
Definition: FrameWidget.h:93
FrameWidget::framePen
QPen framePen()
Definition: FrameWidget.h:89
FrameWidget::Line
Definition: FrameWidget.h:51
FrameWidget::FrameStyle
FrameStyle
The kinds of frame a FrameWidget can draw around.
Definition: FrameWidget.h:51
FrameWidget::d_attach_policy
AttachPolicy d_attach_policy
The attach to policy.
Definition: FrameWidget.h:171
FrameWidget::resetOrigin
void resetOrigin()
Definition: FrameWidget.h:114
FrameWidget::d_on_top
bool d_on_top
Definition: FrameWidget.h:172
FrameWidget::contextMenuEvent
void contextMenuEvent(QContextMenuEvent *)
Definition: FrameWidget.h:145
FrameWidget::d_x_right
double d_x_right
The right side position in scale coordinates.
Definition: FrameWidget.h:165
FrameWidget::drawFrame
virtual void drawFrame(QPainter *p, const QRect &rect)
Definition: FrameWidget.cpp:204
FrameWidget::saveToString
virtual QString saveToString()
Definition: FrameWidget.cpp:262
FrameWidget::setCoordinates
void setCoordinates(double left, double top, double right, double bottom)
Set position (xValue() and yValue()), right and bottom values giving everything in plot coordinates...
Definition: FrameWidget.cpp:132
FrameWidget::widthIn
static double widthIn(QWidget *w, Unit unit)
Definition: FrameWidget.cpp:337