QCAD
Open Source 2D CAD
RImageData.h
Go to the documentation of this file.
1 
20 #ifndef RIMAGEDATA_H
21 #define RIMAGEDATA_H
22 
23 #include "entity_global.h"
24 
25 #include "RBox.h"
26 #include "RDocument.h"
27 #include "REntity.h"
28 #include "RLine.h"
29 #include "RPainterPath.h"
30 #include "RPoint.h"
31 #include "RVector.h"
32 
42 
43  friend class RImageEntity;
44 
45 protected:
47 
48 public:
49  RImageData();
50  RImageData(const RImageData& other);
51  RImageData(const QString& fileName,
52  const RVector& insertionPoint,
53  const RVector& uVector,
54  const RVector& vVector,
55  int brightness,
56  int contrast,
57  int fade);
58  virtual ~RImageData();
59 
60  RImageData& operator=(const RImageData& other);
61 
62  virtual RBox getBoundingBox(bool ignoreEmpty=false) const;
63 
64  virtual RVector getPointOnEntity() const;
65  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const;
66  virtual bool intersectsWith(const RShape& shape) const;
67 
68  virtual QList<RVector> getReferencePoints(
70 
71  virtual bool moveReferencePoint(const RVector& referencePoint,
72  const RVector& targetPoint);
73 
74  virtual bool move(const RVector& offset);
75  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
76  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
77  virtual bool mirror(const RLine& axis);
78 
79  virtual RShape* castToShape() {
80  return NULL;
81  }
82 
83  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false) const;
84 
85  QString getFileName() const {
86  return fileName;
87  }
88  void setFileName(const QString& fn) {
89  fileName = fn;
90  }
91 
93  return insertionPoint;
94  }
95  void setInsertionPoint(const RVector& ip) {
96  insertionPoint = ip;
97  }
98  double getAngle() const {
99  return uVector.getAngle();
100  }
101  void setAngle(double a) {
102  uVector.setAngle(a);
103  vVector.setAngle(a + M_PI/2.0);
104  }
105  RVector getUVector() const {
106  return uVector;
107  }
108  RVector getVVector() const {
109  return vVector;
110  }
111  void setWidth(double w, bool keepRatio=false);
112  void setHeight(double h, bool keepRatio=false);
113  double getWidth() const;
114  double getHeight() const;
115  int getPixelWidth() const;
116  int getPixelHeight() const;
117  //RVector getScaleFactor() const {
118  // return scaleFactor;
119  //}
120  int getBrightness() const {
121  return brightness;
122  }
123  int getContrast() const {
124  return contrast;
125  }
126  int getFade() const {
127  return fade;
128  }
129  QImage getImage() const;
130 
131  void load() const;
132  void reload();
133 
134  QList<RLine> getEdges() const;
135 
136 private:
137  mutable QString fileName;
142  int contrast;
143  int fade;
144  mutable QImage image;
145 };
146 
150 Q_DECLARE_METATYPE(QSharedPointer<RImageData>)
151 
152 #endif
Represents a box e.g.
Definition: RBox.h:43
RImageData data
Definition: RImageEntity.h:166
Base class for all entity data classes.
Definition: REntityData.h:64
RVector getVVector() const
Definition: RImageData.h:108
virtual RVector getPointOnEntity() const
Definition: REntityData.cpp:260
void setInsertionPoint(const RVector &ip)
Definition: RImageData.h:95
double getWidth() const
Definition: RImageEntity.h:146
int getContrast() const
Definition: RImageData.h:123
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
Point entity.
Definition: RImageEntity.h:38
#define RDEFAULT_RBOX
Definition: RBox.h:32
virtual bool mirror(const RLine &axis)
Definition: REntityData.cpp:477
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
void setHeight(double h, bool keepRatio=false)
Definition: RImageEntity.h:138
int getFade() const
Definition: RImageData.h:126
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RImageData.h:41
RVector uVector
Definition: RImageData.h:139
int brightness
Definition: RImageData.h:141
virtual bool move(const RVector &offset)
Moves this entity by the given offset.
Definition: REntityData.cpp:443
#define M_PI
Defines common DXF codes and constants.
Definition: dl_codes.h:55
RVector getInsertionPoint() const
Definition: RImageData.h:92
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:216
RVector vVector
Definition: RImageData.h:140
virtual bool intersectsWith(const RShape &shape) const
Definition: REntityData.cpp:390
QString fileName
Definition: RImageData.h:137
int getPixelHeight() const
Definition: RImageEntity.h:158
int fade
Definition: RImageData.h:143
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:118
void setFileName(const QString &fn)
Definition: RImageData.h:88
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:463
QString getFileName() const
Definition: RImageData.h:85
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:230
virtual QList< RVector > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:63
virtual bool moveReferencePoint(const RVector &referencePoint, const RVector &targetPoint)=0
Moves the given reference point to the given target point or does nothing if this entity has no refer...
Q_DECLARE_METATYPE(RMath *)
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:453
int contrast
Definition: RImageData.h:142
int getBrightness() const
Definition: RImageData.h:120
#define RMAXDOUBLE
Definition: RMath.h:50
virtual RShape * castToShape()
Definition: RImageData.h:79
void setWidth(double w, bool keepRatio=false)
Definition: RImageEntity.h:134
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false) const
Definition: REntityData.h:88
int getPixelWidth() const
Definition: RImageEntity.h:154
Low-level mathematical representation of a line.
Definition: RLine.h:42
RVector insertionPoint
Definition: RImageData.h:138
Definition: RS.h:119
QImage image
Definition: RImageData.h:144
double getHeight() const
Definition: RImageEntity.h:150
void setAngle(double a)
Definition: RImageData.h:101
Interface for geometrical shape classes.
Definition: RShape.h:52
RVector getUVector() const
Definition: RImageData.h:105
#define RDEFAULT_RVECTOR
Definition: RVector.h:37
double getAngle() const
Definition: RImageData.h:98
RDocument * document
Definition: RObject.h:251