Frapper  1.0a
PainterGraphicsView.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of FRAPPER
4 research.animationsinstitut.de
5 sourceforge.net/projects/frapper
6 
7 Copyright (c) 2008-2012 Filmakademie Baden-Wuerttemberg, Institute of Animation
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; version 2.1 of the License.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
21 -----------------------------------------------------------------------------
22 */
23 
32 
33 #ifndef PAINTERGRAPHICSVIEW_H
34 #define PAINTERGRAPHICSVIEW_H
35 
36 #include "FrapperPrerequisites.h"
37 #include "BaseGraphicsView.h"
38 #include "PainterGraphicsItems.h"
39 #include "PainterGraphicsScene.h"
40 
41 #include "ParameterGroup.h"
42 #include "NumberParameter.h"
43 #include <QtGui/QGraphicsView>
44 #include <QtGui/QPen>
45 #include <QtGui/QPainter>
46 #include <QtGui/QPainterPath>
47 
48 
49 namespace PainterPanel {
50 using namespace Frapper;
51 
52 
54 {
55  Q_OBJECT
56 
57 public: // constructors and destructors
58 
65  PainterGraphicsView ( QWidget *parent = 0, Qt::WindowFlags flags = 0 );
66 
74  virtual ~PainterGraphicsView ();
75 
76  enum DrawMode { NONE = 0, PAINT, LINE, RECT, CIRCLE, ELLIPSE, POLYGON, POLYLINE, CURVE, CLOSEDCURVE, NUM_MODES };
77 
78 public: // functions
79 
85  void renderToImage( QImage& image );
86 
93  void setDrawMode( DrawMode drawmode);
94 
101  void setCurrentScene( PainterGraphicsScene *scene);
102 
103 public slots: //
104 
108  void onSelectionChanged();
109 
116  void changeBrush( QBrush brush);
117 
124  void changePen( QPen pen);
125 
126 signals:
127 
131  void triggerRedraw();
132 
136  void sceneChanged( QGraphicsScene *scene );
137 
141  void drawModeChanged( int mode );
142 
147  void penChanged( QPen pen);
148 
153  void brushChanged( QBrush brush);
154 
158  void selectionChanged( QList<QGraphicsItem*> items );
159 
160 protected: // event handlers
161 
167  virtual void mouseMoveEvent ( QMouseEvent * event );
168 
174  virtual void mousePressEvent(QMouseEvent *event);
175 
181  virtual void mouseReleaseEvent(QMouseEvent *event);
182 
188  virtual void keyPressEvent ( QKeyEvent *event );
189 
190 protected: // functions
191 
192 
193 private: // functions
194 
198  void toggleDrawmode();
199 
203  void clearScene();
204 
211  BaseShapeItem* createGraphicsItem( QPointF pos );
212 
213 private: // data
214 
219 
223  QBrush m_brush;
224 
228  QPen m_pen;
229 
234 
235 };
236 
237 } // end namespace Frapper
238 
239 #endif