You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
987 B

#ifndef GRAPHWIDGET_H
#define GRAPHWIDGET_H
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QKeyEvent>
#include <QGraphicsSceneMouseEvent>
#include "graphlogic.h"
14 years ago
class MainWindow;
class GraphLogic;
/** Responsibilities:
* - Handle scene zoom in/out events
* - Close scene (clean), new scene (clean & add first node)
* - Pass key events to GraphLogic
*/
class GraphWidget : public QGraphicsView
{
Q_OBJECT
public:
14 years ago
GraphWidget(MainWindow *parent = 0);
void newScene();
void closeScene();
GraphLogic *graphLogic() const;
static const QColor m_paperColor;
public slots:
void zoomIn();
void zoomOut();
protected:
void keyPressEvent(QKeyEvent *event);
void wheelEvent(QWheelEvent *event);
void drawBackground(QPainter *painter, const QRectF &rect);
private:
void scaleView(qreal scaleFactor);
14 years ago
MainWindow *m_parent;
QGraphicsScene *m_scene;
GraphLogic *m_graphlogic;
};
#endif // GRAPHWIDGET_H