X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Frs_image.h;h=5076a3e543098a6b503616e2d2f2ede7fab18488;hb=d774c2655ba2c3657a565f325411144452392277;hp=3c16c779ca60354bc1c4c061ed0c9cb417d50f7d;hpb=16ce54abf01ca3032e42a5bb11a4afcf9014dcca;p=architektonas diff --git a/src/base/rs_image.h b/src/base/rs_image.h index 3c16c77..5076a3e 100644 --- a/src/base/rs_image.h +++ b/src/base/rs_image.h @@ -9,216 +9,107 @@ */ class RS_ImageData { -public: - /** - * Default constructor. Leaves the data object uninitialized. - */ - RS_ImageData() {} - - 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) { - - this->handle = handle; - this->insertionPoint = insertionPoint; - this->uVector = uVector; - this->vVector = vVector; - this->size = size; - this->file = file; - this->brightness = brightness; - this->contrast = contrast; - this->fade = fade; - } - - friend std::ostream& operator << (std::ostream& os, const RS_ImageData& ld) { - os << "(" << ld.insertionPoint << ")"; - return os; - } - -public: - /** Handle of image definition. */ - int handle; - /** Insertion point. */ - Vector insertionPoint; - /** u vector. Points along visual bottom of image. */ - Vector uVector; - /** v vector. Points along visual left of image. */ - Vector vVector; - /** Image size in pixel. */ - Vector size; - /** Path to image file. */ - QString file; - /** Brightness (0..100, default: 50). */ - int brightness; - /** Contrast (0..100, default: 50). */ - int contrast; - /** Fade (0..100, default: 0). */ - int fade; + public: + /** + * Default constructor. Leaves the data object uninitialized. + */ + RS_ImageData() + { + } + + 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) + { + this->handle = handle; + this->insertionPoint = insertionPoint; + this->uVector = uVector; + this->vVector = vVector; + this->size = size; + this->file = file; + this->brightness = brightness; + this->contrast = contrast; + this->fade = fade; + } + + friend std::ostream & operator<<(std::ostream & os, const RS_ImageData & ld) + { + os << "(" << ld.insertionPoint << ")"; + return os; + } + + public: + /** Handle of image definition. */ + int handle; + /** Insertion point. */ + Vector insertionPoint; + /** u vector. Points along visual bottom of image. */ + Vector uVector; + /** v vector. Points along visual left of image. */ + Vector vVector; + /** Image size in pixel. */ + Vector size; + /** Path to image file. */ + QString file; + /** Brightness (0..100, default: 50). */ + int brightness; + /** Contrast (0..100, default: 50). */ + int contrast; + /** Fade (0..100, default: 0). */ + int fade; }; - - /** - * Class for a line entity. + * Class for a bitmap image entity. * * @author Andrew Mustun */ -class RS_Image : public RS_AtomicEntity +class RS_Image: public RS_AtomicEntity { -public: - RS_Image(RS_EntityContainer* parent, - const RS_ImageData& d); - - virtual RS_Entity* clone(); - - virtual ~RS_Image(); - - /** @return RS2::EntityImage */ - virtual RS2::EntityType rtti() const { - return RS2::EntityImage; - } - - virtual void update(); - - /** @return Copy of data that defines the image. */ - RS_ImageData getData() const { - return data; - } - - /** @return Insertion point of the entity */ - virtual Vector getInsertionPoint() const { - return data.insertionPoint; - } - /** Sets the insertion point for the image. */ - void setInsertionPoint(Vector ip) { - data.insertionPoint = ip; - calculateBorders(); - } - - /** @return File name of the image. */ - QString getFile() const { - return data.file; - } - - /** Sets the file name of the image. */ - void setFile(const QString& file) { - data.file = file; - } - - /** @return u Vector. Points along bottom, 1 pixel long. */ - Vector getUVector() const { - return data.uVector; - } - /** @return v Vector. Points along left, 1 pixel long. */ - Vector getVVector() const { - return data.vVector; - } - /** @return Width of image in pixels. */ - int getWidth() const { - return (int)data.size.x; - } - /** @return Height of image in pixels. */ - int getHeight() const { - return (int)data.size.y; - } - /** @return Brightness. */ - int getBrightness() const { - return data.brightness; - } - /** @return Contrast. */ - int getContrast() const { - return data.contrast; - } - /** @return Fade. */ - int getFade() const { - return data.fade; - } - /** @return Image definition handle. */ - int getHandle() const { - return data.handle; - } - /** Sets the image definition handle. */ - void setHandle(int h) { - data.handle = h; - } - - - /** @return The four corners. **/ - VectorSolutions getCorners() { - VectorSolutions sol(4); - - sol.set(0, data.insertionPoint); - sol.set(1, - data.insertionPoint + data.uVector*RS_Math::round(data.size.x)); - sol.set(3, - data.insertionPoint + data.vVector*RS_Math::round(data.size.y)); - sol.set(2, sol.get(3) + data.uVector*RS_Math::round(data.size.x)); - - return sol; - } - - /** - * @return image with in graphic units. - */ - double getImageWidth() { - return data.size.x * data.uVector.magnitude(); - } - - /** - * @return image height in graphic units. - */ - double getImageHeight() { - return data.size.y * data.vVector.magnitude(); - } - - - virtual Vector getNearestEndpoint(const Vector& coord, - double* dist = NULL); - virtual Vector getNearestPointOnEntity(const Vector& coord, - bool onEntity=true, double* dist = NULL, RS_Entity** entity=NULL); - virtual Vector getNearestCenter(const Vector& coord, - double* dist = NULL); - virtual Vector getNearestMiddle(const Vector& coord, - double* dist = NULL); - virtual Vector getNearestDist(double distance, - const Vector& coord, - double* dist = NULL); - virtual double getDistanceToPoint(const Vector& coord, - RS_Entity** entity=NULL, - RS2::ResolveLevel level=RS2::ResolveNone, - double solidDist = RS_MAXDOUBLE); - - virtual double getLength() { - return -1.0; - } - - virtual void move(Vector offset); - virtual void rotate(Vector center, double angle); - virtual void scale(Vector center, Vector factor); - virtual void mirror(Vector axisPoint1, Vector axisPoint2); - /*virtual void stretch(Vector firstCorner, - Vector secondCorner, - Vector offset);*/ - -// virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset=0.0); - virtual void draw(PaintInterface * painter, RS_GraphicView * view, double patternOffset = 0.0); - - friend std::ostream & operator<<(std::ostream & os, const RS_Image & l); - - virtual void calculateBorders(); - -protected: - RS_ImageData data; - QImage img; - //RS_Img** img; - //int nx; - //int ny; + public: + RS_Image(RS_EntityContainer * parent, const RS_ImageData & d); + virtual ~RS_Image(); + + virtual RS_Entity * clone(); + virtual RS2::EntityType rtti() const; + virtual void update(); + RS_ImageData getData() const; + virtual Vector getInsertionPoint() const; + void setInsertionPoint(Vector ip); + QString getFile() const; + void setFile(const QString & file); + Vector getUVector() const; + Vector getVVector() const; + int getWidth() const; + int getHeight() const; + int getBrightness() const; + int getContrast() const; + int getFade() const; + int getHandle() const; + void setHandle(int h); + VectorSolutions getCorners(); + double getImageWidth(); + double getImageHeight(); + + virtual Vector getNearestEndpoint(const Vector & coord, double * dist = NULL); + virtual Vector getNearestPointOnEntity(const Vector & coord, bool onEntity = true, double * dist = NULL, RS_Entity * * entity = NULL); + virtual Vector getNearestCenter(const Vector & coord, double * dist = NULL); + virtual Vector getNearestMiddle(const Vector & coord, double * dist = NULL); + virtual Vector getNearestDist(double distance, const Vector & coord, double * dist = NULL); + virtual double getDistanceToPoint(const Vector & coord, RS_Entity * * entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE); + virtual double getLength(); + virtual void move(Vector offset); + virtual void rotate(Vector center, double angle); + virtual void scale(Vector center, Vector factor); + virtual void mirror(Vector axisPoint1, Vector axisPoint2); + /*virtual void stretch(Vector firstCorner,Vector secondCorner, Vector offset);*/ + virtual void draw(PaintInterface * painter, GraphicView * view, double patternOffset = 0.0); + + friend std::ostream & operator<<(std::ostream & os, const RS_Image & l); + + virtual void calculateBorders(); + + protected: + RS_ImageData data; + QImage img; }; #endif