~ubuntu-branches/ubuntu/saucy/rocs/saucy

« back to all changes in this revision

Viewing changes to VisualEditor/Scene/GraphScene.h

  • Committer: Package Import Robot
  • Author(s): Rohan Garg, Rohan Garg, Philip Muškovac
  • Date: 2013-06-21 02:04:20 UTC
  • mfrom: (1.1.27)
  • Revision ID: package-import@ubuntu.com-20130621020420-lzlui9y7qc6w3xog
Tags: 4:4.10.80-0ubuntu1
[ Rohan Garg ]
* New upstream release

[ Philip Muškovac ]
* Build-depend on libgrantlee-dev and libx11-dev
* Update rocs.install and not-installed 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
    This file is part of Rocs,
3
3
    Copyright 2004-2011  Tomaz Canabrava <tomaz.canabrava@gmail.com>
 
4
    Copyright 2013       Andreas Cord-Landwehr <cola@uni-paderborn.de>
4
5
 
5
6
    This library is free software; you can redistribute it and/or
6
7
    modify it under the terms of the GNU Lesser General Public
25
26
#include "CoreTypes.h"
26
27
 
27
28
class AbstractAction;
 
29
class Document;
28
30
class QAction;
29
 
class Data;
30
 
class Pointer;
31
31
class QGraphicsItem;
32
 
class Document;
33
 
class DataStructure;
34
32
class QGraphicsSceneMouseEvent;
35
33
class QGraphicsSceneWheelEvent;
36
34
class QGraphicsSceneContextMenuEvent;
37
35
class QKeyEvent;
38
36
class QMenu;
39
37
 
40
 
// TODO this interface should not be public
41
 
// need to refactor VisualGraphEditor to allow that
42
38
class VISUALEDITOR_EXPORT GraphScene : public QGraphicsScene
43
39
{
44
40
    Q_OBJECT
45
41
public:
46
 
    explicit GraphScene(QObject *parent = 0);
47
 
    void updateMinSize(qreal minWidth, qreal minHeight);
 
42
    explicit GraphScene(QObject *parent);
48
43
    void setAction(QAction *action);
49
44
    void updateGraph(DataStructurePtr g);
50
45
    void updateDocument();
51
46
    void setActiveGraph(DataStructurePtr g);
52
47
    void clearGraph();
53
 
    qreal zoomFactor();
 
48
    qreal zoomFactor() const;
54
49
    void zoomBy(qreal scaleFactor);
55
50
    void zoomTo(qreal scaleFactor);
56
 
    void zoomToRect(QRectF rect);
 
51
    void zoomToRect(const QRectF &rect);
57
52
    void resetZoom();
58
 
    void centerOn(QPointF pos);
59
 
 
60
 
    void setHideEdges(bool h);
61
 
    bool hideEdges();
62
 
    void updateAfter(QGraphicsItem *item);
63
 
    bool fade() const {
64
 
        return _fade;
65
 
    }
66
 
    void fade(bool b) {
67
 
        _fade = b;
68
 
    }
 
53
    void centerOn(const QPointF &pos);
69
54
 
70
55
public slots:
71
 
    QGraphicsItem* createData(DataPtr n);
72
 
    QGraphicsItem* createEdge(PointerPtr e);
 
56
    QGraphicsItem * createData(DataPtr n);
 
57
    QGraphicsItem * createEdge(PointerPtr e);
73
58
    void connectGraphSignals(DataStructurePtr g);
74
59
 
75
60
    /**
86
71
 
87
72
signals:
88
73
    void resized();
89
 
    void keyPressed(QKeyEvent* key);
90
 
    void keyReleased(QKeyEvent* key);
91
 
    void addData(QPointF pos);
 
74
    void keyPressed(QKeyEvent *key);
 
75
    void keyReleased(QKeyEvent *key);
 
76
    void addData(const QPointF &pos);
92
77
    void removeSelected();
93
78
    void zoomFactorChanged(qreal zoomFactor);
94
79
 
99
84
    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* mouseEvent);
100
85
    void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
101
86
    void wheelEvent(QGraphicsSceneWheelEvent* wheelEvent);
102
 
    void keyPressEvent(QKeyEvent* keyEvent);
103
 
    void keyReleaseEvent(QKeyEvent* keyEvent);
 
87
    void keyPressEvent(QKeyEvent *keyEvent);
 
88
    void keyReleaseEvent(QKeyEvent *keyEvent);
104
89
 
105
90
private:
106
 
    QMenu * createContextMenu(QPointF scenePosition, QPointF screenPosition);
 
91
    QMenu * createContextMenu(const QPointF &scenePosition, const QPointF &screenPosition);
107
92
    QMenu *_contextMenu;
108
93
    Document *_graphDocument;
109
94
    DataStructurePtr _graph;
110
95
    AbstractAction *_action;
111
96
    QMultiHash<DataStructure*, QGraphicsItem* > _hashGraphs;
112
 
    QList<QGraphicsItem*> _hidedEdges;
113
97
    QGraphicsRectItem *_whiteboard;
114
 
    bool _hideEdges;
115
 
    bool _fade;
116
98
    void releaseDocument();
117
 
    qreal _minWidth;
118
 
    qreal _minHeight;
119
99
    qreal _zoomFactor;
120
100
};
121
101