QCAD
Open Source 2D CAD
RPasteOperation.h
Go to the documentation of this file.
1 
20 #ifndef RPASTEOPERATION_H
21 #define RPASTEOPERATION_H
22 
23 #include "operations_global.h"
24 
25 #include "RDocument.h"
26 #include "REntity.h"
27 #include "RExporter.h"
28 #include "RClipboardOperation.h"
29 #include "RVector.h"
30 
39 public:
40  RPasteOperation(RDocument& sourceDocument);
41  virtual ~RPasteOperation() {
42  }
43 
44  void setOffsets(const QList<RVector>& offsets) {
45  this->offsets = offsets;
46  }
47  void setRotations(const QList<double>& rotations) {
48  this->rotations = rotations;
49  }
50 
51  void setOffset(const RVector& offset) {
52  if (this->offsets.isEmpty()) {
53  this->offsets << offset;
54  }
55  else {
56  this->offsets[0] = offset;
57  }
58  }
60  if (this->offsets.isEmpty()) {
61  return RVector::invalid;
62  }
63  else {
64  return this->offsets[0];
65  }
66  }
67  void setScale(double scale) {
68  this->scale = scale;
69  }
70  double getScale() {
71  return this->scale;
72  }
73  void setRotation(double rotation) {
74  if (this->rotations.isEmpty()) {
75  this->rotations << rotation;
76  }
77  else {
78  this->rotations[0] = rotation;
79  }
80  }
81  double getRotation() {
82  if (this->rotations.isEmpty()) {
83  return 0.0;
84  }
85  else {
86  return this->rotations[0];
87  }
88  }
89  void setFlipHorizontal(bool flipHorizontal) {
90  this->flipHorizontal = flipHorizontal;
91  }
93  return this->flipHorizontal;
94  }
95  void setFlipVertical(bool flipVertical) {
96  this->flipVertical = flipVertical;
97  }
98  bool getFlipVertical() {
99  return this->flipVertical;
100  }
101  void setToCurrentLayer(bool toCurrentLayer) {
102  this->toCurrentLayer = toCurrentLayer;
103  }
105  return this->toCurrentLayer;
106  }
107  void setOverwriteLayers(bool overwriteLayers) {
108  this->overwriteLayers = overwriteLayers;
109  }
111  return this->overwriteLayers;
112  }
113  void setOverwriteBlocks(bool overwriteBlocks) {
114  this->overwriteBlocks = overwriteBlocks;
115  }
117  return this->overwriteBlocks;
118  }
119  void setBlockName(const QString& blockName) {
120  this->blockName = blockName;
121  }
122  QString getBlockName() {
123  return this->blockName;
124  }
125  void setLayerName(const QString& layerName) {
126  this->layerName = layerName;
127  }
128  QString getLayerName() {
129  return this->layerName;
130  }
131  void setAttribute(const QString& tag, const QString& value) {
132  attributes.insert(tag, value);
133  }
134  void setProperty(const QString& name, const QString& value) {
135  properties.insert(name, value);
136  }
137 
138  virtual RTransaction apply(RDocument& document, bool preview = false);
139 
140  RPolyline getBoundary(double unitFactor);
141 
142 private:
144  QList<RVector> offsets;
145  double scale;
146  QList<double> rotations;
152  QString blockName;
153  QString layerName;
154  QMap<QString, QString> attributes;
155  QMap<QString, QString> properties;
156 };
157 
159 
160 #endif
bool getFlipHorizontal()
Definition: RPasteOperation.h:92
bool getOverwriteLayers()
Definition: RPasteOperation.h:110
void setRotation(double rotation)
Definition: RPasteOperation.h:73
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RPasteOperation.h:38
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
double getScale()
Definition: RPasteOperation.h:70
QString getLayerName()
Definition: RPasteOperation.h:128
double scale
Definition: RPasteOperation.h:145
bool overwriteBlocks
Definition: RPasteOperation.h:151
RDocument & sourceDocument
Definition: RPasteOperation.h:143
bool flipVertical
Definition: RPasteOperation.h:148
void setToCurrentLayer(bool toCurrentLayer)
Definition: RPasteOperation.h:101
Transaction implementation.
Definition: RTransaction.h:74
void setBlockName(const QString &blockName)
Definition: RPasteOperation.h:119
bool toCurrentLayer
Definition: RPasteOperation.h:149
void setOffsets(const QList< RVector > &offsets)
Definition: RPasteOperation.h:44
void setScale(double scale)
Definition: RPasteOperation.h:67
QList< RVector > offsets
Definition: RPasteOperation.h:144
QList< double > rotations
Definition: RPasteOperation.h:146
QMap< QString, QString > properties
Definition: RPasteOperation.h:155
double getRotation()
Definition: RPasteOperation.h:81
#define QCADOPERATIONS_EXPORT
Definition: operations_global.h:10
virtual RTransaction apply(RDocument &document, bool preview=false)
Applies this operation to selection in the given document.
Definition: RClipboardOperation.h:48
virtual ~RPasteOperation()
Definition: RPasteOperation.h:41
bool flipHorizontal
Definition: RPasteOperation.h:147
void setLayerName(const QString &layerName)
Definition: RPasteOperation.h:125
RVector getOffset()
Definition: RPasteOperation.h:59
bool getToCurrentLayer()
Definition: RPasteOperation.h:104
void setProperty(const QString &name, const QString &value)
Definition: RPasteOperation.h:134
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
Q_DECLARE_METATYPE(RMath *)
void setOffset(const RVector &offset)
Definition: RPasteOperation.h:51
bool getFlipVertical()
Definition: RPasteOperation.h:98
QString getBlockName()
Definition: RPasteOperation.h:122
void setOverwriteBlocks(bool overwriteBlocks)
Definition: RPasteOperation.h:113
void setFlipHorizontal(bool flipHorizontal)
Definition: RPasteOperation.h:89
void scale(void e, void factor, void focusPoint)
Scales the given entity or shape by the given factor with the given focus point.
Definition: simple_modify.js:71
void setOverwriteLayers(bool overwriteLayers)
Definition: RPasteOperation.h:107
bool getOverwriteBlocks()
Definition: RPasteOperation.h:116
QMap< QString, QString > attributes
Definition: RPasteOperation.h:154
bool overwriteLayers
Definition: RPasteOperation.h:150
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
QString layerName
Definition: RPasteOperation.h:153
QString blockName
Definition: RPasteOperation.h:152
void setAttribute(const QString &tag, const QString &value)
Definition: RPasteOperation.h:131
static const RVector invalid
invalid vector
Definition: RVector.h:317
void setRotations(const QList< double > &rotations)
Definition: RPasteOperation.h:47
void setFlipVertical(bool flipVertical)
Definition: RPasteOperation.h:95
Base class for clipboard related operations (copy, cut, paste).
Definition: RClipboardOperation.h:43