File: mapeditor.h

package info (click to toggle)
vym 2.6.11-3
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 12,628 kB
  • sloc: cpp: 34,052; ruby: 846; xml: 278; sh: 187; makefile: 28
file content (228 lines) | stat: -rw-r--r-- 6,900 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#ifndef MAPEDITOR_H
#define MAPEDITOR_H

#include <QGraphicsView>
#include <QItemSelectionModel>
#include <QLineEdit>	
#include <QPropertyAnimation>	

#include "attribute.h"
#include "xlink.h"
#include "ornamentedobj.h"
#include "settings.h"
#include "vymmodel.h"


class XLinkItem;
class Winter;

/*! \brief Main widget in vym to display and edit a map */


class MapEditor : public QGraphicsView {    
    Q_OBJECT

public:
    enum EditorState {
	Neutral,
	EditingHeading,
	EditingLink,
	MovingObject,
	MovingView,
	PickingColor,
	CopyingObject,
	DrawingLink
    };

    MapEditor(VymModel *vm);
    ~MapEditor();
    VymModel* getModel();
    QGraphicsScene * getScene();
    MapEditor::EditorState getState();

// Animation of scrollbars
Q_PROPERTY(QPointF scrollBarPos READ getScrollBarPos WRITE setScrollBarPos)

protected:
    QPointF scrollBarPos;
    QPointF scrollBarPosTarget;
    QPropertyAnimation scrollBarPosAnimation;
    QTimer *panningTimer;
    QPointF vPan;		        //! Direction of panning during moving of object
    QPoint pointerPos;			//! Pointer position in widget coordinates
    Qt::KeyboardModifiers pointerMod;	//! modifiers of move event

private slots:
    void panView();

public:
    void scrollTo (const QModelIndex &index);
    void setScrollBarPosTarget (QRectF rect);	//!  ensureVisible of rect
    QPointF getScrollBarPosTarget ();
    void setScrollBarPos (const QPointF &p);
    QPointF getScrollBarPos();
    void animateScrollBars();

// Animation of zoom
Q_PROPERTY(qreal zoomFactor READ getZoomFactor WRITE setZoomFactor)

protected:
    qreal zoomFactor;
    qreal zoomFactorTarget;
    QPropertyAnimation zoomAnimation;

public:
    void setZoomFactorTarget (const qreal &zf);
    qreal getZoomFactorTarget();
    void setZoomFactor (const qreal &zf);
    qreal getZoomFactor();

// Animation of rotation
Q_PROPERTY(qreal angle READ getAngle WRITE setAngle)

protected:
    qreal angle;
    qreal angleTarget;
    QPropertyAnimation rotationAnimation;

public:
    void setAngleTarget (const qreal &a);
    qreal getAngleTarget();
    void setAngle (const qreal &a);
    qreal getAngle();


// Animation of viewCenter    
Q_PROPERTY (QPointF viewCenter READ getViewCenter WRITE setViewCenter)

protected:
    QPointF viewCenter;
    QPointF viewCenterTarget;

public:
    void setViewCenterTarget (
	const QPointF &p, 
	const qreal &zft, 
	const qreal &at,
	const int duration=2000,
	const QEasingCurve &easingCurve=QEasingCurve::OutQuint);
    void setViewCenterTarget ();    //! Convenience function, center on selected item
    QPointF getViewCenterTarget();
    void setViewCenter (const QPointF &p);
    QPointF getViewCenter();
    QPropertyAnimation viewCenterAnimation;

    void updateMatrix();	    //! Sets transformation matrix with current rotation and zoom values
    void minimizeView();

// xmas egg
protected:
    Winter *winter;

public:
    void print();		    //!< Print the map
    QRectF getTotalBBox();	    //!< Bounding box of all items in map
    QImage getImage (QPointF &offset);	//!< Get a pixmap of the map
    void setAntiAlias (bool);	    //!< Set or unset antialiasing
    void setSmoothPixmap(bool);	    //!< Set or unset smoothing of pixmaps
public slots:	
    void autoLayout();		    //!< Auto layout of map by using collision detection
    void testFunction1();		//! just testing new stuff
    void testFunction2();		//! just testing new stuff

public:
    TreeItem *findMapItem (QPointF p,TreeItem *exclude);    //! find item in map at position p. Ignore item exclude 

    AttributeTable* attributeTable();	// FIXME-3 Not used, testing only
    void toggleWinter();

    BranchItem* getBranchDirectAbove(BranchItem *bi);	//! get branch direct above bi (in TreeView) 
    BranchItem* getBranchAbove(BranchItem *bi);		//! get branch above bi (in TreeView) 
    BranchItem* getBranchDirectBelow(BranchItem *bi);	//! bet branch direct below bi (in TreeView)
    BranchItem* getBranchBelow(BranchItem *bi);		//! bet branch below bi (in TreeView)
    BranchItem* getLeftBranch(BranchItem *bi);		//! bet branch left of bi (in TreeView)
    BranchItem* getRightBranch(BranchItem *bi);		//! bet branch right of bi (in TreeView)

public slots:
    void cursorUp();
    void cursorDown();
    void cursorLeft();
    void cursorRight();
    void cursorFirst();
    void cursorLast();
    void editHeading();
    void editHeadingFinished();
private:
    QLineEdit *lineEdit;

protected:
    virtual void contextMenuEvent ( QContextMenuEvent *e );
    virtual void keyPressEvent(QKeyEvent*);
    virtual void keyReleaseEvent(QKeyEvent*);
    virtual void mousePressEvent(QMouseEvent*);
    virtual void mouseMoveEvent(QMouseEvent*);
    void moveObject ();
    virtual void mouseReleaseEvent(QMouseEvent*);
    virtual void mouseDoubleClickEvent(QMouseEvent*);
    virtual void wheelEvent(QWheelEvent*);
    virtual void focusOutEvent (QFocusEvent*);
    virtual void resizeEvent( QResizeEvent * );

    void dragEnterEvent (QDragEnterEvent *);
    void dragMoveEvent (QDragMoveEvent *);
    void dragLeaveEvent (QDragLeaveEvent *);
    void dropEvent (QDropEvent *);


private:
    QGraphicsScene *mapScene;
    VymModel *model;		//!< Vym Map, includding several mapCenters

    bool adjustCanvasRequested;	// collect requests until end of user event
    BranchObj *editingBO;	// entering Text into BO

    QCursor HandOpenCursor;	// cursor while moving canvas view
    QCursor PickColorCursor;	// cursor while picking color 
    QCursor CopyCursor;		// cursor while picking color 
    QCursor XLinkCursor;	// cursor while picking color 
    EditorState state; 

    void setState (EditorState);
    bool objectMoved;		// true if object was not clicked, but moved with mouse

    // Temporary used for linkx
    Link* tmpLink;

    MapObj* movingObj;		    // moving a MapObj
    QPointF movingObj_orgPos;	    // org. pos of mouse before move
    QPointF movingObj_orgRelPos;    // org. relative pos of mouse before move
    QPointF movingObj_offset;	    // offset of mousepointer to object
    QPointF movingCont_start;	    // inital pos of moving Content or
    QPointF movingVec;		    // how far has Content moved

    QPointF contextMenuPos;	    // position where context event was triggered

    AttributeTable *attrTable;

    bool printFrame;		// Print frame around map
    bool printFooter;		// Print footer below map

    QPoint exportOffset;	// set before export, used in save

//////////// Selection related
signals:
    void selectionChanged(const QItemSelection &, const QItemSelection &);

private:    
    QList <QGraphicsPathItem*> selPathList;
    QColor selectionColor;

public slots:
    void updateSelection(QItemSelection ,QItemSelection); // update selection
    void updateData (const QModelIndex&); // update data
public:
    void setSelectionColor (QColor c);
    QColor getSelectionColor ();
};
#endif