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);
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
RTransaction.h
RDebug::decCounter
static void decCounter(const QString &id=RDEFAULT_QSTRING)
Definition: RDebug.cpp:105
RObject
Abstract base class for all objects.
Definition: RObject.h:61
operations_global.h
ROperation.h
ROperation::apply
virtual RTransaction apply(RDocument &document, bool preview=false)=0
Applies this operation to selection in the given document.
QCADOPERATIONS_EXPORT
#define QCADOPERATIONS_EXPORT
Definition: operations_global.h:10
RDocument.h
RVector.h
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(RMath *)
RMixedOperation
Implementation of an operation that adds, modifies and deletes entities.
Definition: RMixedOperation.h:44
Delete
Deletes all selected entities of the current document.
Definition: Delete.js:11
RDocument
A graphics document contains and owns entities, layers, user coordinate systems, variables,...
Definition: RDocument.h:72
RExporter.h
RMixedOperation::list
QList< QPair< QSharedPointer< RObject >, Modes > > list
Definition: RMixedOperation.h:81
ROperation
This abstract class is an interface for all operation implementations.
Definition: ROperation.h:44
RMixedOperation::Mode
Mode
Definition: RMixedOperation.h:46
deleteObject
void deleteObject(void obj)
Deletes the given RObject from the drawing.
Definition: simple_create.js:199
RTransaction
Transaction implementation.
Definition: RTransaction.h:74
RMixedOperation::~RMixedOperation
virtual ~RMixedOperation()
Definition: RMixedOperation.h:57
addObject
void addObject(void obj)
Adds the given RObject to the drawing.
Definition: simple_create.js:208