SciDAVis  1.D4
SelectionMoveResizer.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : SelectionMoveResizer.h
3  Project : SciDAVis
4  --------------------------------------------------------------------
5  Copyright : (C) 2007 by Knut Franke
6  Email (use @ for *) : knut.franke*gmx.de
7  Description : Selection of Widgets and QwtPlotMarkers
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 
30 #ifndef SELECTION_MOVE_RESIZER_H
31 #define SELECTION_MOVE_RESIZER_H
32 
33 #include <QWidget>
34 #include <QList>
35 #include <QRect>
36 
37 class QPoint;
38 class QwtPlotMarker;
39 class Legend;
40 class ArrowMarker;
41 class ImageMarker;
42 
89 class SelectionMoveResizer : public QWidget
90 {
91  Q_OBJECT
92 
93  public:
101  SelectionMoveResizer(QWidget *target);
106  virtual bool eventFilter(QObject *o, QEvent *e);
108  bool contains(QWidget *w) const { return d_widgets.contains(w); };
110  bool contains(Legend *m) const { return d_legend_markers.contains(m); };
112  bool contains(ArrowMarker *m) const { return d_line_markers.contains(m); };
114  bool contains(ImageMarker *m) const { return d_image_markers.contains(m); };
115 
116  public slots:
118  void add(Legend *target);
120  void add(ArrowMarker *target);
122  void add(ImageMarker *target);
124  void add(QWidget *target);
126  int removeAll(Legend *target);
128  int removeAll(ArrowMarker *target);
130  int removeAll(ImageMarker *target);
132  int removeAll(QWidget *target);
134  void recalcBoundingRect();
135 
136  signals:
138  void targetsChanged();
139 
140  protected:
143 
149  virtual void paintEvent(QPaintEvent *e);
155  virtual void mousePressEvent(QMouseEvent *e);
161  virtual void mouseMoveEvent(QMouseEvent *e);
166  virtual void mouseReleaseEvent(QMouseEvent *e);
171  virtual void keyPressEvent(QKeyEvent *e);
173  virtual void mouseDoubleClickEvent(QMouseEvent *e);
174 
175  private:
177  static const int handler_size = 10;
179  static const QRect handlerRect(QRect rect, Operation op);
181  QRect operateOn(const QRect in);
183  void operateOnTargets();
185  void init();
187  QRect boundingRectOf(QwtPlotMarker *target) const;
188 
190  QList <Legend *> d_legend_markers;
192  QList <ArrowMarker *> d_line_markers;
194  QList <ImageMarker *> d_image_markers;
196  QList <QWidget *> d_widgets;
202  QPoint d_op_start;
204  QPoint d_op_dp;
205 
206  private slots:
208  void removeWidget(QObject* w) { removeAll((QWidget*) w); }
209 };
210 
211 #endif // ifndef SELECTION_MOVE_RESIZER_H