Menu

[efa3d9]: / src / mapeditor.h  Maximize  Restore  History

Download this file

290 lines (237 with data), 9.0 kB

  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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#ifndef MAPEDITOR_H
#define MAPEDITOR_H
#include <QGraphicsView>
#include <QItemSelectionModel>
#include <QLineEdit>
#include <QPropertyAnimation>
#include "tmp-parent-container.h"
#include "settings.h"
#include "vymmodel.h"
class XLink;
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,
CreatingXLink,
EditingXLink,
MovingObject,
MovingObjectTmpLinked,
MovingObjectWithoutLinking,
PanningView,
PickingColor
};
MapEditor(VymModel *vm);
~MapEditor();
VymModel *getModel();
QGraphicsScene *getScene();
// 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
private slots:
void panView();
public:
void ensureAreaVisibleAnimated(
const QRectF &area,
bool scaled = false,
bool rotated = false,
qreal new_angle = 0) ;
void ensureSelectionVisibleAnimated(bool scaled = false, bool rotated = false);
void setScrollBarPosTarget(QRectF rect); //! ensureVisible of rect
QPointF getScrollBarPosTarget();
void setScrollBarPos(const QPointF &p);
QPointF getScrollBarPos();
void animateScrollBars();
// Animation of containers
private:
QTimer *animationTimer;
bool animationUse;
uint animationTicks;
uint animationInterval;
int timerId; // animation timer
QList<Container*> animatedContainers;
private slots:
void animate(); //!< Called by timer to animate stuff
public:
void startAnimation(Container *c, const QPointF &v);
void startAnimation(Container *c, const QPointF &start, const QPointF &dest);
void stopContainerAnimation(Container *c);
void stopContainerAnimations();
void stopViewAnimations();
// Animation of zoom
Q_PROPERTY(qreal zoomFactorInt READ zoomFactor WRITE setZoomFactor)
protected:
qreal zoomDelta;
qreal zoomFactorInt;
qreal zoomFactorTargetInt;
QPropertyAnimation zoomAnimation;
public:
void zoomIn();
void zoomOut();
void setZoomFactorTarget(const qreal &zf);
qreal zoomFactorTarget();
void setZoomFactor(const qreal &zf);
qreal zoomFactor();
// Animation of rotation
Q_PROPERTY(qreal rotationInt READ rotation WRITE setRotation)
protected:
qreal rotationInt;
qreal rotationTargetInt;
QPropertyAnimation rotationAnimation;
bool useTransformationOrigin;
QPointF transformationOrigin;
QPointF vp_center; // Calculated before transformation to center on later
public:
void setRotationTarget(const qreal &a);
qreal rotationTarget();
void setRotation(const qreal &a);
qreal rotation();
// 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,
const QList <TreeItem*> &excludedItems = QList<TreeItem*>(),
bool findNearCenter = false); //! find item in map at position
//! p. Ignore item exclude
BranchItem *findMapBranchItem(
QPointF p,
const QList <TreeItem*> &excludedItems = QList<TreeItem*>(),
bool findNearCenter = false); //! only return BranchItem
void toggleWinter();
enum RadarDirection {
UpDirection,
DownDirection,
LeftDirection,
RightDirection
};
bool isContainerCloserInDirection(Container *c1, Container *c2, const qreal &d_min, const QPoint &v, RadarDirection radarDir);
TreeItem* getItemInDirection(TreeItem *ti, RadarDirection);
TreeItem* getItemFromGeometry(TreeItem *ti, RadarDirection);
TreeItem* getItemFromOrgChart(TreeItem *ti, RadarDirection);
TreeItem* getItemFromClassicMap(TreeItem *ti, RadarDirection);
TreeItem* getItemDirectAbove(TreeItem *ti);
TreeItem* getItemDirectBelow( TreeItem *ti);
private:
// Toggle objects by moving the cursor up/down with shift modifier
// (needs to consider the current direction of movement)
enum ToggleDirection {toggleUndefined, toggleUp, toggleDown};
ToggleDirection lastToggleDirection;
public slots:
void cursorUp();
void cursorUpToggleSelection();
void cursorDown();
void cursorDownToggleSelection();
void cursorLeft();
void cursorRight();
void cursorFirst();
void cursorLast();
void editHeading(BranchItem *selbi = nullptr);
void editHeadingFinished();
private:
QLineEdit *lineEdit;
private:
void contextMenuEvent(QContextMenuEvent *e);
void keyPressEvent(QKeyEvent *);
void keyReleaseEvent(QKeyEvent *);
void startPanningView(QMouseEvent *);
void mousePressEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void moveObject(QMouseEvent *, const QPointF &p_event); // Called from mouseMoveEvent
void mouseReleaseEvent(QMouseEvent *);
void mouseDoubleClickEvent(QMouseEvent *);
void wheelEvent(QWheelEvent *);
void focusOutEvent(QFocusEvent *);
void resizeEvent(QResizeEvent *);
void dragEnterEvent(QDragEnterEvent *);
void dragMoveEvent(QDragMoveEvent *);
void dragLeaveEvent(QDragLeaveEvent *);
void dropEvent(QDropEvent *);
void updateCursor();
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
// Various states of the MapEditor
public:
MapEditor::EditorState state();
private:
EditorState editorState;
void setState(EditorState);
bool objectMoved; // true if object was not clicked, but moved with mouse
// Temporary used for linkx
XLink *tmpXLink;
// Temporary used for panning view
QPoint panning_initialPointerPos; // initial pos in pointer coordinates
QPoint panning_initialScrollBarValues; // inital values of scrollbars
// Moving containers
QList <TreeItem*> movingItems; // selected items which are currently moved
QPointF movingObj_initialScenePos; // coord when button was pressed
QPointF movingObj_initialContainerOffset; // offset from above coordinates to object
TmpParentContainer *tmpParentContainer;
QPointF contextMenuPos; // position where context event was triggered
bool printFrame; // Print frame around map
bool printFooter; // Print footer below map
QPoint exportOffset; // set before export, used in save
//////////// Selection related
public:
enum SelectionMode {
AutoSelection,
ClassicSelection,
OrgChartSelection,
GeometricSelection
};
SelectionMode currentSelectionMode(TreeItem *);
private:
SelectionMode selectionMode;
signals:
void selectionChanged(const QItemSelection &, const QItemSelection &);
public slots:
void updateData(const QModelIndex &); // update data
void togglePresentationMode();
};
#endif
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.