SelectionMoveResizer.h
Go to the documentation of this file.
/***************************************************************************
File : SelectionMoveResizer.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2007 by Knut Franke, 2008 by Ion Vasilief
Email (use @ for *) : knut.franke*gmx.de, ion_vasilief*yahoo.fr
Description : Selection of Widgets and QwtPlotMarkers
***************************************************************************/
/***************************************************************************
* *
* 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 SELECTION_MOVE_RESIZER_H
#define SELECTION_MOVE_RESIZER_H
#include <QWidget>
#include <QList>
#include <QRect>
class QPoint;
class QwtPlotMarker;
class QwtPlotCanvas;
class LegendWidget;
class ArrowMarker;
class SelectionMoveResizer : public QWidget
{
Q_OBJECT
public:
SelectionMoveResizer(ArrowMarker *target);
SelectionMoveResizer(QWidget *target);
~SelectionMoveResizer();
virtual bool eventFilter(QObject *o, QEvent *e);
bool contains(QWidget *w) const { return d_widgets.contains(w); };
QList <QWidget *> widgetsList() const { return d_widgets; };
bool contains(ArrowMarker *m) const { return d_line_markers.contains(m); };
void raiseTargets(bool on = true);
void alignTargetsLeft();
void alignTargetsRight();
void alignTargetsTop();
void alignTargetsBottom();
public slots:
void add(ArrowMarker *target);
void add(QWidget *target);
int removeAll(ArrowMarker *target);
int removeAll(QWidget *target);
void recalcBoundingRect();
signals:
void targetsChanged();
protected:
enum Operation { None=-2, Move, Resize_N, Resize_NE, Resize_E, Resize_SE, Resize_S, Resize_SW, Resize_W, Resize_NW };
virtual void paintEvent(QPaintEvent *e);
virtual void mousePressEvent(QMouseEvent *e);
virtual void mouseMoveEvent(QMouseEvent *e);
virtual void mouseReleaseEvent(QMouseEvent *e);
virtual void keyPressEvent(QKeyEvent *e);
virtual void mouseDoubleClickEvent(QMouseEvent *e);
private:
static const int handler_size = 10;
static const QRect handlerRect(QRect rect, Operation op);
QRect operateOn(const QRect in);
void operateOnTargets();
void init();
QRect boundingRectOf(QwtPlotMarker *target) const;
QRect boundingRectOf(QwtPlotCanvas *canvas) const;
QList <ArrowMarker *> d_line_markers;
QList <QWidget *> d_widgets;
QRect d_bounding_rect;
Operation d_op;
QPoint d_op_start;
QPoint d_op_dp;
private slots:
void removeWidget(QObject* w) { removeAll((QWidget*) w); }
};
#endif // ifndef SELECTION_MOVE_RESIZER_H
SelectionMoveResizer::Resize_E
Definition: SelectionMoveResizer.h:132
SelectionMoveResizer::d_op_dp
QPoint d_op_dp
Difference between current and start position during operation.
Definition: SelectionMoveResizer.h:192
SelectionMoveResizer::alignTargetsRight
void alignTargetsRight()
Definition: SelectionMoveResizer.cpp:201
SelectionMoveResizer::Move
Definition: SelectionMoveResizer.h:132
SelectionMoveResizer::removeAll
int removeAll(ArrowMarker *target)
Remove target from the list of items to be moved/resized together and returns the number of occurence...
Definition: SelectionMoveResizer.cpp:141
SelectionMoveResizer::contains
bool contains(ArrowMarker *m) const
Returns true if m is one of targets, false else.
Definition: SelectionMoveResizer.h:107
SelectionMoveResizer::removeWidget
void removeWidget(QObject *w)
A non-typesafe version of remvoveAll(QWidget*) needed for QObject::destroyed().
Definition: SelectionMoveResizer.h:196
SelectionMoveResizer::Resize_NE
Definition: SelectionMoveResizer.h:132
SelectionMoveResizer::Resize_SW
Definition: SelectionMoveResizer.h:132
SelectionMoveResizer::widgetsList
QList< QWidget * > widgetsList() const
Definition: SelectionMoveResizer.h:105
SelectionMoveResizer::boundingRectOf
QRect boundingRectOf(QwtPlotMarker *target) const
Get the bounding rectangle of a marker in paint coordinates.
Definition: SelectionMoveResizer.cpp:128
SelectionMoveResizer::Resize_W
Definition: SelectionMoveResizer.h:132
ArrowMarker
Draws lines and arrows on a QwtPlot.
Definition: ArrowMarker.h:43
SelectionMoveResizer::handlerRect
static const QRect handlerRect(QRect rect, Operation op)
Return one of the rectangles to be filled for starting resize operations.
Definition: SelectionMoveResizer.cpp:302
SelectionMoveResizer::mouseDoubleClickEvent
virtual void mouseDoubleClickEvent(QMouseEvent *e)
Ignore double-clicks so that they can be used by my parent.
Definition: SelectionMoveResizer.cpp:527
SelectionMoveResizer::mouseReleaseEvent
virtual void mouseReleaseEvent(QMouseEvent *e)
Mouse releases end the current operation and apply it to the targets.
Definition: SelectionMoveResizer.cpp:553
SelectionMoveResizer::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *e)
Mouse movements need to be monitored for updating the frame during operation.
Definition: SelectionMoveResizer.cpp:501
SelectionMoveResizer::alignTargetsLeft
void alignTargetsLeft()
Definition: SelectionMoveResizer.cpp:178
SelectionMoveResizer::None
Definition: SelectionMoveResizer.h:132
SelectionMoveResizer::paintEvent
virtual void paintEvent(QPaintEvent *e)
Draw frame and resize handlers.
Definition: SelectionMoveResizer.cpp:434
SelectionMoveResizer::raiseTargets
void raiseTargets(bool on=true)
Definition: SelectionMoveResizer.cpp:166
SelectionMoveResizer::add
void add(ArrowMarker *target)
Add target to the list of items to be moved/resized together.
Definition: SelectionMoveResizer.cpp:92
SelectionMoveResizer::Operation
Operation
Available modes of operation.
Definition: SelectionMoveResizer.h:132
SelectionMoveResizer
Handler for modifying one or more QWidget and/or QwtPlotMarker with mouse or keyboard.
Definition: SelectionMoveResizer.h:89
SelectionMoveResizer::handler_size
static const int handler_size
Size of resize handle in pixels.
Definition: SelectionMoveResizer.h:167
SelectionMoveResizer::eventFilter
virtual bool eventFilter(QObject *o, QEvent *e)
React on geometry changes of parent and targets.
Definition: SelectionMoveResizer.cpp:635
SelectionMoveResizer::targetsChanged
void targetsChanged()
Emitted when the targets are modified (moved or resized).
LegendWidget
Definition: LegendWidget.h:42
SelectionMoveResizer::d_line_markers
QList< ArrowMarker * > d_line_markers
Target markers I&#39;m handling.
Definition: SelectionMoveResizer.h:182
SelectionMoveResizer::operateOn
QRect operateOn(const QRect in)
Apply operation specified by d_op and d_op_dp to in.
Definition: SelectionMoveResizer.cpp:334
SelectionMoveResizer::operateOnTargets
void operateOnTargets()
Apply operation specified by d_op and d_op_dp to all targets.
Definition: SelectionMoveResizer.cpp:384
SelectionMoveResizer::d_bounding_rect
QRect d_bounding_rect
Bounding rectangle of all targets taken together, in drawing coordinates.
Definition: SelectionMoveResizer.h:186
SelectionMoveResizer::SelectionMoveResizer
SelectionMoveResizer(ArrowMarker *target)
Construct a new MoveResizer with the given marker as the only target.
Definition: SelectionMoveResizer.cpp:44
SelectionMoveResizer::contains
bool contains(QWidget *w) const
Returns true if w is one of targets, false else.
Definition: SelectionMoveResizer.h:104
SelectionMoveResizer::keyPressEvent
virtual void keyPressEvent(QKeyEvent *e)
Allow keyboard-based moving of the selection.
Definition: SelectionMoveResizer.cpp:564
SelectionMoveResizer::Resize_NW
Definition: SelectionMoveResizer.h:132
SelectionMoveResizer::~SelectionMoveResizer
~SelectionMoveResizer()
Clean up after myself.
Definition: SelectionMoveResizer.cpp:78
SelectionMoveResizer::Resize_SE
Definition: SelectionMoveResizer.h:132
SelectionMoveResizer::init
void init()
The initialization part common to all constructors.
Definition: SelectionMoveResizer.cpp:62
SelectionMoveResizer::d_op_start
QPoint d_op_start
Mouse position where an operation started; (-1,-1) means started by keyboard.
Definition: SelectionMoveResizer.h:190
SelectionMoveResizer::d_widgets
QList< QWidget * > d_widgets
Target widgets I&#39;m handling.
Definition: SelectionMoveResizer.h:184
SelectionMoveResizer::recalcBoundingRect
void recalcBoundingRect()
Calculate d_bounding_rect based on the bounding rectangles of all targets.
Definition: SelectionMoveResizer.cpp:276
SelectionMoveResizer::Resize_N
Definition: SelectionMoveResizer.h:132
SelectionMoveResizer::alignTargetsBottom
void alignTargetsBottom()
Definition: SelectionMoveResizer.cpp:250
SelectionMoveResizer::mousePressEvent
virtual void mousePressEvent(QMouseEvent *e)
Mouse button presses start move/resize operations.
Definition: SelectionMoveResizer.cpp:453
SelectionMoveResizer::alignTargetsTop
void alignTargetsTop()
Definition: SelectionMoveResizer.cpp:227
SelectionMoveResizer::d_op
Operation d_op
The type of operation currently in progress.
Definition: SelectionMoveResizer.h:188
SelectionMoveResizer::Resize_S
Definition: SelectionMoveResizer.h:132