SymbolEditor  1.3.0
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
Commands.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2011 by Stephen Allewell *
3  * sallewell@users.sourceforge.net *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  ********************************************************************************/
10 
11 
18 #ifndef Commands_H
19 #define Commands_H
20 
21 
22 #include <QUndoCommand>
23 #include <QWidget>
24 
25 #include "SymbolLibrary.h"
26 
27 
28 class Editor;
29 
30 
40 class MoveToCommand : public QUndoCommand
41 {
42 public:
43  MoveToCommand(Editor *editor, const QPointF &to);
44  virtual ~MoveToCommand();
45 
46  virtual void undo();
47  virtual void redo();
48 
49 private:
51  QPointF m_to;
52  QPainterPath m_path;
53 };
54 
55 
64 class LineToCommand : public QUndoCommand
65 {
66 public:
67  LineToCommand(Editor *editor, const QPointF &to);
68  virtual ~LineToCommand();
69 
70  virtual void undo();
71  virtual void redo();
72 
73 private:
75  QPointF m_to;
76  QPainterPath m_path;
77 };
78 
79 
88 class CubicToCommand : public QUndoCommand
89 {
90 public:
91  CubicToCommand(Editor *editor, const QPointF &control1, const QPointF &control2, const QPointF &to);
92  virtual ~CubicToCommand();
93 
94  virtual void undo();
95  virtual void redo();
96 
97 private:
99  QPointF m_control1;
100  QPointF m_control2;
101  QPointF m_to;
102  QPainterPath m_path;
103 };
104 
105 
115 class RectangleCommand : public QUndoCommand
116 {
117 public:
118  RectangleCommand(Editor *editor, const QPointF &from, const QPointF &to);
119  virtual ~RectangleCommand();
120 
121  virtual void undo();
122  virtual void redo();
123 
124 private:
126  QPointF m_from;
127  QPointF m_to;
128  QPainterPath m_path;
129 };
130 
131 
141 class EllipseCommand : public QUndoCommand
142 {
143 public:
144  EllipseCommand(Editor *editor, const QPointF &from, const QPointF &to);
145  virtual ~EllipseCommand();
146 
147  virtual void undo();
148  virtual void redo();
149 
150 private:
152  QPointF m_from;
153  QPointF m_to;
154  QPainterPath m_path;
155 };
156 
157 
166 class MovePointCommand : public QUndoCommand
167 {
168 public:
169  MovePointCommand(Editor *editor, int index, const QPointF &from, const QPointF &to);
170  virtual ~MovePointCommand();
171 
172  virtual void undo();
173  virtual void redo();
174 
175 private:
177  int m_index;
178  QPointF m_from;
179  QPointF m_to;
180 };
181 
182 
191 class UpdateSymbolCommand : public QUndoCommand
192 {
193 public:
194  UpdateSymbolCommand(SymbolLibrary *library, qint16 index, const Symbol &symbol);
195  virtual ~UpdateSymbolCommand();
196 
197  virtual void undo();
198  virtual void redo();
199 
200 private:
202  qint16 m_index;
205 };
206 
207 
216 class ImportLibraryCommand : public QUndoCommand
217 {
218 public:
219  ImportLibraryCommand(SymbolLibrary *library, SymbolLibrary *imported);
220  virtual ~ImportLibraryCommand();
221 
222  virtual void undo();
223  virtual void redo();
224 
225 private:
228  QList<qint16> m_addedIndexes;
229 };
230 
231 
239 class RotateLeftCommand : public QUndoCommand
240 {
241 public:
242  explicit RotateLeftCommand(Editor *editor);
244 
245  virtual void undo();
246  virtual void redo();
247 
248 private:
250 };
251 
252 
260 class RotateRightCommand : public QUndoCommand
261 {
262 public:
263  explicit RotateRightCommand(Editor *editor);
265 
266  virtual void undo();
267  virtual void redo();
268 
269 private:
271 };
272 
273 
282 class FlipHorizontalCommand : public QUndoCommand
283 {
284 public:
285  explicit FlipHorizontalCommand(Editor *editor);
287 
288  virtual void undo();
289  virtual void redo();
290 
291 private:
293 };
294 
295 
304 class FlipVerticalCommand : public QUndoCommand
305 {
306 public:
307  explicit FlipVerticalCommand(Editor *editor);
309 
310  virtual void undo();
311  virtual void redo();
312 
313 private:
315 };
316 
317 
324 class ScalePreferredCommand : public QUndoCommand
325 {
326 public:
327  ScalePreferredCommand(Editor *editor, const QPainterPath &originlSymbol, int gridElements, int borderSize);
329 
330  virtual void undo();
331  virtual void redo();
332 
333 private:
335  QPainterPath m_originalSymbol;
338 };
339 
340 
348 class ChangeFilledCommand : public QUndoCommand
349 {
350 public:
351  ChangeFilledCommand(Editor *editor, bool from, bool to);
352  virtual ~ChangeFilledCommand();
353 
354  virtual void undo();
355  virtual void redo();
356 
357 private:
359  bool m_from;
360  bool m_to;
361 };
362 
363 
371 class ChangeFillRuleCommand : public QUndoCommand
372 {
373 public:
374  ChangeFillRuleCommand(Editor *editor, Qt::FillRule from, Qt::FillRule to);
375  virtual ~ChangeFillRuleCommand();
376 
377  virtual void undo();
378  virtual void redo();
379 
380 private:
382  Qt::FillRule m_from;
383  Qt::FillRule m_to;
384 };
385 
386 
394 class ChangeCapStyleCommand : public QUndoCommand
395 {
396 public:
397  ChangeCapStyleCommand(Editor *editor, Qt::PenCapStyle from, Qt::PenCapStyle to);
398  virtual ~ChangeCapStyleCommand();
399 
400  virtual void undo();
401  virtual void redo();
402 
403 private:
405  Qt::PenCapStyle m_from;
406  Qt::PenCapStyle m_to;
407 };
408 
409 
417 class ChangeJoinStyleCommand : public QUndoCommand
418 {
419 public:
420  ChangeJoinStyleCommand(Editor *editor, Qt::PenJoinStyle from, Qt::PenJoinStyle to);
421  virtual ~ChangeJoinStyleCommand();
422 
423  virtual void undo();
424  virtual void redo();
425 
426 private:
428  Qt::PenJoinStyle m_from;
429  Qt::PenJoinStyle m_to;
430 };
431 
432 
440 class DeleteSymbolCommand : public QUndoCommand
441 {
442 public:
443  DeleteSymbolCommand(SymbolLibrary *library, qint16 index);
444  virtual ~DeleteSymbolCommand();
445 
446  virtual void undo();
447  virtual void redo();
448 
449 private:
451  qint16 m_index;
453 };
454 
455 
464 class IncreaseLineWidthCommand : public QUndoCommand
465 {
466 public:
467  IncreaseLineWidthCommand(Editor *editor, qreal from, qreal to);
468  virtual ~IncreaseLineWidthCommand();
469 
470  virtual void redo();
471  virtual void undo();
472 
473  virtual int id() const;
474  virtual bool mergeWith(const QUndoCommand *command);
475 
476 private:
478  qreal m_from;
479  qreal m_to;
480 };
481 
482 
491 class DecreaseLineWidthCommand : public QUndoCommand
492 {
493 public:
494  DecreaseLineWidthCommand(Editor *editor, qreal from, qreal to);
495  virtual ~DecreaseLineWidthCommand();
496 
497  virtual void redo();
498  virtual void undo();
499 
500  virtual int id() const;
501  virtual bool mergeWith(const QUndoCommand *command);
502 
503 private:
505  qreal m_from;
506  qreal m_to;
507 };
508 
509 
515 class DragAndDropCommand : public QUndoCommand
516 {
517 public:
518  DragAndDropCommand(SymbolLibrary *library, const QMimeData *mimeData);
519 
520  virtual void redo();
521  virtual void undo();
522 
523 private:
525  QList<Symbol> m_symbols;
526  QList<qint16> m_indexes;
527 };
528 
529 
535 class AddCharacterCommand : public QUndoCommand
536 {
537 public:
538  AddCharacterCommand(Editor *editor, const QPainterPath &path);
539 
540  virtual void redo();
541  virtual void undo();
542 
543 private:
545  QPainterPath m_path;
546 };
547 
548 
549 #endif
550