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  void setCenters(const QList<RVector>& centers) {
51  this->centers = centers;
52  }
53 
54  void setOffset(const RVector& offset) {
55  if (this->offsets.isEmpty()) {
56  this->offsets << offset;
57  }
58  else {
59  this->offsets[0] = offset;
60  }
61  }
63  if (this->offsets.isEmpty()) {
64  return RVector::invalid;
65  }
66  else {
67  return this->offsets[0];
68  }
69  }
70  void setScale(double scale) {
71  this->scale = scale;
72  }
73  double getScale() {
74  return this->scale;
75  }
76  void setRotation(double rotation) {
77  if (this->rotations.isEmpty()) {
78  this->rotations << rotation;
79  }
80  else {
81  this->rotations[0] = rotation;
82  }
83  }
84  double getRotation() {
85  if (this->rotations.isEmpty()) {
86  return 0.0;
87  }
88  else {
89  return this->rotations[0];
90  }
91  }
92  void setCenter(const RVector& centers) {
93  if (this->centers.isEmpty()) {
94  this->centers << centers;
95  }
96  else {
97  this->centers[0] = centers;
98  }
99  }
101  if (this->centers.isEmpty()) {
102  return RVector(0,0);
103  }
104  else {
105  return this->centers[0];
106  }
107  }
108  void setFlipHorizontal(bool flipHorizontal) {
109  this->flipHorizontal = flipHorizontal;
110  }
112  return this->flipHorizontal;
113  }
114  void setFlipVertical(bool flipVertical) {
115  this->flipVertical = flipVertical;
116  }
118  return this->flipVertical;
119  }
120  void setToCurrentLayer(bool toCurrentLayer) {
121  this->toCurrentLayer = toCurrentLayer;
122  }
124  return this->toCurrentLayer;
125  }
126  void setOverwriteLayers(bool overwriteLayers) {
127  this->overwriteLayers = overwriteLayers;
128  }
130  return this->overwriteLayers;
131  }
132  void setOverwriteBlocks(bool overwriteBlocks) {
133  this->overwriteBlocks = overwriteBlocks;
134  }
136  return this->overwriteBlocks;
137  }
138  void setBlockName(const QString& blockName) {
139  this->blockName = blockName;
140  }
141  QString getBlockName() {
142  return this->blockName;
143  }
144  void setLayerName(const QString& layerName) {
145  this->layerName = layerName;
146  }
147  QString getLayerName() {
148  return this->layerName;
149  }
150  void setAttribute(const QString& tag, const QString& value) {
151  attributes.insert(tag, value);
152  }
153  void setProperty(const QString& name, const QString& value) {
154  properties.insert(name, value);
155  }
156  void setBlockProperty(const QString& name, const QString& value) {
157  blockProperties.insert(name, value);
158  }
159 
160  virtual RTransaction apply(RDocument& document, bool preview = false);
161 
162  RPolyline getBoundary(double unitFactor);
163 
164 private:
166  QList<RVector> offsets;
167  double scale;
168  QList<double> rotations;
169  QList<RVector> centers;
175  QString blockName;
176  QString layerName;
177  QMap<QString, QString> attributes;
178  QMap<QString, QString> properties;
179  QMap<QString, QString> blockProperties;
180 };
181 
183 
184 #endif
bool getFlipHorizontal()
Definition: RPasteOperation.h:111
bool getOverwriteLayers()
Definition: RPasteOperation.h:129
void setRotation(double rotation)
Definition: RPasteOperation.h:76
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RPasteOperation.h:38
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
double getScale()
Definition: RPasteOperation.h:73
RVector getCenter()
Definition: RPasteOperation.h:100
QString getLayerName()
Definition: RPasteOperation.h:147
double scale
Definition: RPasteOperation.h:167
bool overwriteBlocks
Definition: RPasteOperation.h:174
RDocument & sourceDocument
Definition: RPasteOperation.h:165
bool flipVertical
Definition: RPasteOperation.h:171
void setToCurrentLayer(bool toCurrentLayer)
Definition: RPasteOperation.h:120
Transaction implementation.
Definition: RTransaction.h:74
void setBlockName(const QString &blockName)
Definition: RPasteOperation.h:138
bool toCurrentLayer
Definition: RPasteOperation.h:172
void setOffsets(const QList< RVector > &offsets)
Definition: RPasteOperation.h:44
void setScale(double scale)
Definition: RPasteOperation.h:70
QList< RVector > offsets
Definition: RPasteOperation.h:166
QList< double > rotations
Definition: RPasteOperation.h:168
QMap< QString, QString > properties
Definition: RPasteOperation.h:178
double getRotation()
Definition: RPasteOperation.h:84
#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:50
QList< RVector > centers
Definition: RPasteOperation.h:169
virtual ~RPasteOperation()
Definition: RPasteOperation.h:41
bool flipHorizontal
Definition: RPasteOperation.h:170
void setLayerName(const QString &layerName)
Definition: RPasteOperation.h:144
QMap< QString, QString > blockProperties
Definition: RPasteOperation.h:179
RVector getOffset()
Definition: RPasteOperation.h:62
bool getToCurrentLayer()
Definition: RPasteOperation.h:123
void setProperty(const QString &name, const QString &value)
Definition: RPasteOperation.h:153
void setBlockProperty(const QString &name, const QString &value)
Definition: RPasteOperation.h:156
void setCenter(const RVector &centers)
Definition: RPasteOperation.h:92
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:54
bool getFlipVertical()
Definition: RPasteOperation.h:117
QString getBlockName()
Definition: RPasteOperation.h:141
void setOverwriteBlocks(bool overwriteBlocks)
Definition: RPasteOperation.h:132
void setFlipHorizontal(bool flipHorizontal)
Definition: RPasteOperation.h:108
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:126
bool getOverwriteBlocks()
Definition: RPasteOperation.h:135
QMap< QString, QString > attributes
Definition: RPasteOperation.h:177
bool overwriteLayers
Definition: RPasteOperation.h:173
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
QString layerName
Definition: RPasteOperation.h:176
QString blockName
Definition: RPasteOperation.h:175
void setAttribute(const QString &tag, const QString &value)
Definition: RPasteOperation.h:150
static const RVector invalid
invalid vector
Definition: RVector.h:322
void setRotations(const QList< double > &rotations)
Definition: RPasteOperation.h:47
void setCenters(const QList< RVector > &centers)
Definition: RPasteOperation.h:50
void setFlipVertical(bool flipVertical)
Definition: RPasteOperation.h:114
Base class for clipboard related operations (copy, cut, paste).
Definition: RClipboardOperation.h:45