]> Shamusworld >> Repos - architektonas/blob - src/base/image.h
Initial removal of unnecessary rs_ prefixes from files.
[architektonas] / src / base / image.h
1 #ifndef __IMAGE_H__
2 #define __IMAGE_H__
3
4 #include <QtCore>
5 #include "atomicentity.h"
6
7 /**
8  * Holds the data that defines a line.
9  */
10 class RS_ImageData
11 {
12         public:
13                 /**
14                  * Default constructor. Leaves the data object uninitialized.
15                  */
16                 RS_ImageData()
17                 {
18                 }
19
20                 RS_ImageData(int handle,    const Vector & insertionPoint, const Vector & uVector, const Vector & vVector, const Vector & size, const QString & file, int brightness, int contrast, int fade)
21                 {
22                         this->handle = handle;
23                         this->insertionPoint = insertionPoint;
24                         this->uVector = uVector;
25                         this->vVector = vVector;
26                         this->size = size;
27                         this->file = file;
28                         this->brightness = brightness;
29                         this->contrast = contrast;
30                         this->fade = fade;
31                 }
32
33                 friend std::ostream & operator<<(std::ostream & os, const RS_ImageData & ld)
34                 {
35                         os << "(" << ld.insertionPoint << ")";
36                         return os;
37                 }
38
39         public:
40                 /** Handle of image definition. */
41                 int handle;
42                 /** Insertion point. */
43                 Vector insertionPoint;
44                 /** u vector. Points along visual bottom of image. */
45                 Vector uVector;
46                 /** v vector. Points along visual left of image. */
47                 Vector vVector;
48                 /** Image size in pixel. */
49                 Vector size;
50                 /** Path to image file. */
51                 QString file;
52                 /** Brightness (0..100, default: 50). */
53                 int brightness;
54                 /** Contrast (0..100, default: 50). */
55                 int contrast;
56                 /** Fade (0..100, default: 0). */
57                 int fade;
58 };
59
60 /**
61  * Class for a bitmap image entity.
62  *
63  * @author Andrew Mustun
64  */
65 class RS_Image: public RS_AtomicEntity
66 {
67         public:
68                 RS_Image(RS_EntityContainer * parent, const RS_ImageData & d);
69                 virtual ~RS_Image();
70
71                 virtual RS_Entity * clone();
72                 virtual RS2::EntityType rtti() const;
73                 virtual void update();
74                 RS_ImageData getData() const;
75                 virtual Vector getInsertionPoint() const;
76                 void setInsertionPoint(Vector ip);
77                 QString getFile() const;
78                 void setFile(const QString & file);
79                 Vector getUVector() const;
80                 Vector getVVector() const;
81                 int getWidth() const;
82                 int getHeight() const;
83                 int getBrightness() const;
84                 int getContrast() const;
85                 int getFade() const;
86                 int getHandle() const;
87                 void setHandle(int h);
88                 VectorSolutions getCorners();
89                 double getImageWidth();
90                 double getImageHeight();
91
92                 virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL);
93                 virtual Vector getNearestPointOnEntity(const Vector & coord, bool onEntity = true, double * dist = NULL, RS_Entity * * entity = NULL);
94                 virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL);
95                 virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL);
96                 virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL);
97                 virtual double getDistanceToPoint(const Vector & coord, RS_Entity * * entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE);
98                 virtual double getLength();
99                 virtual void move(Vector offset);
100                 virtual void rotate(Vector center, double angle);
101                 virtual void scale(Vector center, Vector factor);
102                 virtual void mirror(Vector axisPoint1, Vector axisPoint2);
103                 /*virtual void stretch(Vector firstCorner,Vector secondCorner, Vector offset);*/
104                 virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0);
105
106                 friend std::ostream & operator<<(std::ostream & os, const RS_Image & l);
107
108                 virtual void calculateBorders();
109
110         protected:
111                 RS_ImageData data;
112                 QImage img;
113 };
114
115 #endif