QCAD
Open Source 2D CAD
RMixedOperation.h
Go to the documentation of this file.
1 
20 #ifndef RMIXEDOPERATION_H
21 #define RMIXEDOPERATION_H
22 
23 #include "operations_global.h"
24 
25 #include <QList>
26 #include <QSharedPointer>
27 #include <QFlags>
28 
29 #include "RDocument.h"
30 #include "RExporter.h"
31 #include "ROperation.h"
32 #include "RTransaction.h"
33 #include "RVector.h"
34 
35 class RObject;
36 
45 public:
46  enum Mode {
47  NoMode = 0x0,
48  UseCurrentAttributes = 0x1,
49  Delete = 0x2,
50  ForceNew = 0x4,
51  EndCycle = 0x8
52  };
53  Q_DECLARE_FLAGS(Modes, Mode)
54 
55 public:
56  RMixedOperation(bool undoable = true);
57  virtual ~RMixedOperation() {
58  RDebug::decCounter("RMixedOperation");
59  }
60 
61  QSharedPointer<RObject> addObject(const QSharedPointer<RObject>& obj,
62  bool useCurrentAttributes = true, bool forceNew=false);
63  void deleteObject(const QSharedPointer<RObject>& obj);
64  void endCycle();
65 
66  virtual RTransaction apply(RDocument& document, bool preview = false) const;
67 
68 // int getPreviewCounter() const {
69 // return previewCounter;
70 // }
71 
72 // void setLimitPreview(bool on) {
73 // limitPreview = on;
74 // }
75 
76 protected:
77  void setMode(RMixedOperation::Modes& modes, RMixedOperation::Mode mode, bool on = true);
78  bool getMode(const RMixedOperation::Modes& modes, RMixedOperation::Mode mode) const;
79 
80 private:
81  QList<QPair<QSharedPointer<RObject>, Modes> > list;
82 // int previewCounter;
83 // bool limitPreview;
84 };
85 
86 Q_DECLARE_OPERATORS_FOR_FLAGS(RMixedOperation::Modes)
89 
90 #endif
This abstract class is an interface for all operation implementations.
Definition: ROperation.h:44
Abstract base class for all objects.
Definition: RObject.h:48
Transaction implementation.
Definition: RTransaction.h:70
Deletes all selected entities of the current document.
Definition: Delete.js:10
Implementation of an operation that adds, modifies and deletes entities.
Definition: RMixedOperation.h:44
virtual RTransaction apply(RDocument &document, bool preview=false) const =0
Applies this operation to selection in the given document.
#define QCADOPERATIONS_EXPORT
Definition: operations_global.h:10
QList< QPair< QSharedPointer< RObject >, Modes > > list
Definition: RMixedOperation.h:81
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:63
Q_DECLARE_METATYPE(RMath *)
static void decCounter(const QString &id=RDEFAULT_QSTRING)
Definition: RDebug.cpp:104
Mode
Definition: RMixedOperation.h:46