1 /* 2 * Patchbay Canvas engine using QGraphicsView/Scene 3 * Copyright (C) 2010-2012 Filipe Coelho <falktx@falktx.com> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * For a full copy of the GNU General Public License see the COPYING file 16 */ 17 18 #ifndef PATCHSCENE_H 19 #define PATCHSCENE_H 20 21 #include <QtGui/QGraphicsScene> 22 23 class QKeyEvent; 24 class QGraphicsRectItem; 25 class QGraphicsSceneMouseEvent; 26 class QGraphicsSceneWheelEvent; 27 class QGraphicsView; 28 29 class PatchScene : public QGraphicsScene 30 { 31 Q_OBJECT 32 33 public: 34 PatchScene(QObject* parent, QGraphicsView* view); 35 36 void fixScaleFactor(); 37 void updateTheme(); 38 39 void zoom_fit(); 40 void zoom_in(); 41 void zoom_out(); 42 void zoom_reset(); 43 44 signals: 45 void scaleChanged(double); 46 void sceneGroupMoved(int, int, QPointF); 47 48 private: 49 bool m_ctrl_down; 50 bool m_mouse_down_init; 51 bool m_mouse_rubberband; 52 53 QGraphicsRectItem* m_rubberband; 54 bool m_rubberband_selection; 55 QPointF m_rubberband_orig_point; 56 57 QGraphicsView* m_view; 58 59 virtual void keyPressEvent(QKeyEvent* event); 60 virtual void keyReleaseEvent(QKeyEvent* event); 61 virtual void mousePressEvent(QGraphicsSceneMouseEvent* event); 62 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event); 63 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); 64 virtual void wheelEvent(QGraphicsSceneWheelEvent* event); 65 }; 66 67 #endif // PATCHSCENE_H 68