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<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
69 
70  virtual bool moveReferencePoint(const RVector& referencePoint,
71  const RVector& targetPoint);
72 
73  virtual bool move(const RVector& offset);
74  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
75  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
76  virtual bool mirror(const RLine& axis);
77 
78  virtual RShape* castToShape() {
79  return NULL;
80  }
81 
82  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false) const;
83 
84  QString getFileName() const {
85  return fileName;
86  }
87  void setFileName(const QString& fn) {
88  fileName = fn;
89  }
90 
92  return insertionPoint;
93  }
94  void setInsertionPoint(const RVector& ip) {
95  insertionPoint = ip;
96  }
97  double getAngle() const {
98  return uVector.getAngle();
99  }
100  void setAngle(double a) {
101  uVector.setAngle(a);
102  vVector.setAngle(a + M_PI/2.0);
103  }
104  RVector getUVector() const {
105  return uVector;
106  }
107  RVector getVVector() const {
108  return vVector;
109  }
110  void setWidth(double w, bool keepRatio=false);
111  void setHeight(double h, bool keepRatio=false);
112  double getWidth() const;
113  double getHeight() const;
114  int getPixelWidth() const;
115  int getPixelHeight() const;
116  //RVector getScaleFactor() const {
117  // return scaleFactor;
118  //}
119  int getBrightness() const {
120  return brightness;
121  }
122  int getContrast() const {
123  return contrast;
124  }
125  int getFade() const {
126  return fade;
127  }
128  QImage getImage() const;
129 
130  void load() const;
131  void reload();
132 
133  QList<RLine> getEdges() const;
134 
135 private:
136  mutable QString fileName;
141  int contrast;
142  int fade;
143  mutable QImage image;
144 };
145 
149 Q_DECLARE_METATYPE(QSharedPointer<RImageData>)
150 
151 #endif
Represents a box e.g.
Definition: RBox.h:43
RImageData data
Definition: RImageEntity.h:168
Base class for all entity data classes.
Definition: REntityData.h:65
RVector getVVector() const
Definition: RImageData.h:107
virtual RVector getPointOnEntity() const
Definition: REntityData.cpp:288
void setInsertionPoint(const RVector &ip)
Definition: RImageData.h:94
double getWidth() const
Definition: RImageEntity.h:148
int getContrast() const
Definition: RImageData.h:122
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:519
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
void setHeight(double h, bool keepRatio=false)
Definition: RImageEntity.h:140
int getFade() const
Definition: RImageData.h:125
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RImageData.h:41
RVector uVector
Definition: RImageData.h:138
int brightness
Definition: RImageData.h:140
virtual bool move(const RVector &offset)
Moves this entity by the given offset.
Definition: REntityData.cpp:479
#define M_PI
Defines common DXF codes and constants.
Definition: dl_codes.h:55
RVector getInsertionPoint() const
Definition: RImageData.h:91
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:248
RVector vVector
Definition: RImageData.h:139
virtual bool intersectsWith(const RShape &shape) const
Definition: REntityData.cpp:418
QString fileName
Definition: RImageData.h:136
int getPixelHeight() const
Definition: RImageEntity.h:160
int fade
Definition: RImageData.h:142
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:129
void setFileName(const QString &fn)
Definition: RImageData.h:87
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:499
QString getFileName() const
Definition: RImageData.h:84
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:262
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
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:489
int contrast
Definition: RImageData.h:141
int getBrightness() const
Definition: RImageData.h:119
#define RMAXDOUBLE
Definition: RMath.h:63
virtual RShape * castToShape()
Definition: RImageData.h:78
void setWidth(double w, bool keepRatio=false)
Definition: RImageEntity.h:136
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false) const
Definition: REntityData.h:89
int getPixelWidth() const
Definition: RImageEntity.h:156
virtual QList< RRefPoint > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
Low-level mathematical representation of a line.
Definition: RLine.h:42
RVector insertionPoint
Definition: RImageData.h:137
Definition: RS.h:130
QImage image
Definition: RImageData.h:143
double getHeight() const
Definition: RImageEntity.h:152
void setAngle(double a)
Definition: RImageData.h:100
Interface for geometrical shape classes.
Definition: RShape.h:52
RVector getUVector() const
Definition: RImageData.h:104
#define RDEFAULT_RVECTOR
Definition: RVector.h:37
double getAngle() const
Definition: RImageData.h:97
RDocument * document
Definition: RObject.h:267