5 #include "rs_atomicentity.h"
8 * Holds the data that defines a line.
14 * Default constructor. Leaves the data object uninitialized.
18 RS_ImageData(int handle,
19 const Vector& insertionPoint,
20 const Vector& uVector,
21 const Vector& vVector,
28 this->handle = handle;
29 this->insertionPoint = insertionPoint;
30 this->uVector = uVector;
31 this->vVector = vVector;
34 this->brightness = brightness;
35 this->contrast = contrast;
39 friend std::ostream& operator << (std::ostream& os, const RS_ImageData& ld) {
40 os << "(" << ld.insertionPoint << ")";
45 /** Handle of image definition. */
47 /** Insertion point. */
48 Vector insertionPoint;
49 /** u vector. Points along visual bottom of image. */
51 /** v vector. Points along visual left of image. */
53 /** Image size in pixel. */
55 /** Path to image file. */
57 /** Brightness (0..100, default: 50). */
59 /** Contrast (0..100, default: 50). */
61 /** Fade (0..100, default: 0). */
68 * Class for a line entity.
70 * @author Andrew Mustun
72 class RS_Image : public RS_AtomicEntity
75 RS_Image(RS_EntityContainer* parent,
76 const RS_ImageData& d);
78 virtual RS_Entity* clone();
82 /** @return RS2::EntityImage */
83 virtual RS2::EntityType rtti() const {
84 return RS2::EntityImage;
87 virtual void update();
89 /** @return Copy of data that defines the image. */
90 RS_ImageData getData() const {
94 /** @return Insertion point of the entity */
95 virtual Vector getInsertionPoint() const {
96 return data.insertionPoint;
98 /** Sets the insertion point for the image. */
99 void setInsertionPoint(Vector ip) {
100 data.insertionPoint = ip;
104 /** @return File name of the image. */
105 QString getFile() const {
109 /** Sets the file name of the image. */
110 void setFile(const QString& file) {
114 /** @return u Vector. Points along bottom, 1 pixel long. */
115 Vector getUVector() const {
118 /** @return v Vector. Points along left, 1 pixel long. */
119 Vector getVVector() const {
122 /** @return Width of image in pixels. */
123 int getWidth() const {
124 return (int)data.size.x;
126 /** @return Height of image in pixels. */
127 int getHeight() const {
128 return (int)data.size.y;
130 /** @return Brightness. */
131 int getBrightness() const {
132 return data.brightness;
134 /** @return Contrast. */
135 int getContrast() const {
136 return data.contrast;
139 int getFade() const {
142 /** @return Image definition handle. */
143 int getHandle() const {
146 /** Sets the image definition handle. */
147 void setHandle(int h) {
152 /** @return The four corners. **/
153 VectorSolutions getCorners() {
154 VectorSolutions sol(4);
156 sol.set(0, data.insertionPoint);
158 data.insertionPoint + data.uVector*RS_Math::round(data.size.x));
160 data.insertionPoint + data.vVector*RS_Math::round(data.size.y));
161 sol.set(2, sol.get(3) + data.uVector*RS_Math::round(data.size.x));
167 * @return image with in graphic units.
169 double getImageWidth() {
170 return data.size.x * data.uVector.magnitude();
174 * @return image height in graphic units.
176 double getImageHeight() {
177 return data.size.y * data.vVector.magnitude();
181 virtual Vector getNearestEndpoint(const Vector& coord,
182 double* dist = NULL);
183 virtual Vector getNearestPointOnEntity(const Vector& coord,
184 bool onEntity=true, double* dist = NULL, RS_Entity** entity=NULL);
185 virtual Vector getNearestCenter(const Vector& coord,
186 double* dist = NULL);
187 virtual Vector getNearestMiddle(const Vector& coord,
188 double* dist = NULL);
189 virtual Vector getNearestDist(double distance,
191 double* dist = NULL);
192 virtual double getDistanceToPoint(const Vector& coord,
193 RS_Entity** entity=NULL,
194 RS2::ResolveLevel level=RS2::ResolveNone,
195 double solidDist = RS_MAXDOUBLE);
197 virtual double getLength() {
201 virtual void move(Vector offset);
202 virtual void rotate(Vector center, double angle);
203 virtual void scale(Vector center, Vector factor);
204 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
205 /*virtual void stretch(Vector firstCorner,
209 // virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0);
210 virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0);
212 friend std::ostream & operator<<(std::ostream & os, const RS_Image & l);
214 virtual void calculateBorders();