QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
41 
42  friend class RImageEntity;
43 
44 protected:
46 
47 public:
48  RImageData();
49  RImageData(const RImageData& other);
50  RImageData(const QString& fileName,
51  const RVector& insertionPoint,
52  const RVector& uVector,
53  const RVector& vVector,
54  int brightness,
55  int contrast,
56  int fade);
57  virtual ~RImageData();
58 
59  RImageData& operator=(const RImageData& other);
60 
61  virtual RBox getBoundingBox() const;
62 
63  virtual RVector getPointOnEntity() const;
64  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false) const;
65  virtual bool intersectsWith(const RShape& shape) const;
66 
67  virtual QList<RVector> getReferencePoints(
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) 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