From 738ecbd5fad2b46836bfd6a94aeebf165ae2bbca Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Thu, 4 Jan 2018 16:00:52 +0100 Subject: relocated source code to the root --- src/gui/tikzscene.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/gui/tikzscene.h (limited to 'src/gui/tikzscene.h') diff --git a/src/gui/tikzscene.h b/src/gui/tikzscene.h new file mode 100644 index 0000000..6817792 --- /dev/null +++ b/src/gui/tikzscene.h @@ -0,0 +1,62 @@ +/** + * Manage the scene, which contains a single Graph, and respond to user input. This serves as + * the controller for the MVC (TikzDocument, TikzView, TikzScene). + */ + +#ifndef TIKZSCENE_H +#define TIKZSCENE_H + +#include "graph.h" +#include "nodeitem.h" +#include "edgeitem.h" +#include "tikzdocument.h" + +#include +#include +#include +#include +#include +#include +#include + +class TikzScene : public QGraphicsScene +{ + Q_OBJECT +public: + TikzScene(TikzDocument *tikzDocument, QObject *parent); + ~TikzScene(); + Graph *graph(); + QMap &nodeItems(); + QMap &edgeItems(); + void refreshAdjacentEdges(QList nodes); + void setBounds(QRectF bounds); + + TikzDocument *tikzDocument() const; + void setTikzDocument(TikzDocument *tikzDocument); + +public slots: + void graphReplaced(); + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *event) override; + void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; + void keyReleaseEvent(QKeyEvent *event) override; +private: + TikzDocument *_tikzDocument; + QMap _nodeItems; + QMap _edgeItems; + QGraphicsLineItem *_drawEdgeItem; + EdgeItem *_modifyEdgeItem; + bool _firstControlPoint; + + QMap _oldNodePositions; + float _oldWeight; + int _oldBend; + int _oldInAngle; + int _oldOutAngle; + + void getSelection(QSet &selNodes, QSet &selEdges); +}; + +#endif // TIKZSCENE_H -- cgit v1.2.3