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.
60 lines
1.0 KiB
60 lines
1.0 KiB
#ifndef GRAPHWIDGET_H
|
|
#define GRAPHWIDGET_H
|
|
|
|
#include <QGraphicsView>
|
|
#include <QGraphicsScene>
|
|
#include <QKeyEvent>
|
|
#include <QGraphicsSceneMouseEvent>
|
|
|
|
#include "graphlogic.h"
|
|
|
|
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:
|
|
|
|
GraphWidget(MainWindow *parent = 0);
|
|
|
|
void newScene();
|
|
void closeScene();
|
|
|
|
GraphLogic *graphLogic() const;
|
|
|
|
static const QColor m_paperColor;
|
|
|
|
public slots:
|
|
|
|
void zoomIn();
|
|
void zoomOut();
|
|
|
|
signals:
|
|
|
|
void notification(const QString &msg);
|
|
|
|
protected:
|
|
|
|
void keyPressEvent(QKeyEvent *event);
|
|
void wheelEvent(QWheelEvent *event);
|
|
void drawBackground(QPainter *painter, const QRectF &rect);
|
|
|
|
private:
|
|
|
|
void scaleView(qreal factor);
|
|
|
|
|
|
MainWindow *m_parent;
|
|
QGraphicsScene *m_scene;
|
|
GraphLogic *m_graphlogic;
|
|
};
|
|
|
|
#endif // GRAPHWIDGET_H
|