X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Fimage.cpp;h=202bd9af62b91d044223747e648b54bb3614af98;hb=5adb444f3e523d3fd028617ced72d1ea6661db21;hp=fa493ecde6a963cf707f3c7bcc47a805eb0049de;hpb=3239ef39dcee08fa6e8cd68cdf2727fc68cc7a8c;p=architektonas diff --git a/src/base/image.cpp b/src/base/image.cpp index fa493ec..202bd9a 100644 --- a/src/base/image.cpp +++ b/src/base/image.cpp @@ -25,8 +25,8 @@ /** * Constructor. */ -RS_Image::RS_Image(RS_EntityContainer * parent, const RS_ImageData & d): - RS_AtomicEntity(parent), data(d) +Image::Image(EntityContainer * parent, const ImageData & d): + AtomicEntity(parent), data(d) { update(); calculateBorders(); @@ -35,16 +35,16 @@ RS_Image::RS_Image(RS_EntityContainer * parent, const RS_ImageData & d): /** * Destructor. */ -RS_Image::~RS_Image() +Image::~Image() { /*if (img!=NULL) { delete[] img; }*/ } -RS_Entity * RS_Image::clone() +Entity * Image::clone() { - RS_Image * i = new RS_Image(*this); + Image * i = new Image(*this); i->setHandle(getHandle()); i->initId(); i->update(); @@ -52,14 +52,14 @@ RS_Entity * RS_Image::clone() } /** @return RS2::EntityImage */ -/*virtual*/ RS2::EntityType RS_Image::rtti() const +/*virtual*/ RS2::EntityType Image::rtti() const { return RS2::EntityImage; } -void RS_Image::update() +void Image::update() { - RS_DEBUG->print("RS_Image::update"); + DEBUG->print("Image::update"); // the whole image: //QImage image = QImage(data.file); @@ -68,7 +68,7 @@ void RS_Image::update() if (!img.isNull()) data.size = Vector(img.width(), img.height()); - RS_DEBUG->print("RS_Image::update: OK"); + DEBUG->print("Image::update: OK"); /* // number of small images: @@ -106,101 +106,101 @@ void RS_Image::update() } /** @return Copy of data that defines the image. */ -RS_ImageData RS_Image::getData() const +ImageData Image::getData() const { return data; } /** @return Insertion point of the entity */ -/*virtual*/ Vector RS_Image::getInsertionPoint() const +/*virtual*/ Vector Image::getInsertionPoint() const { return data.insertionPoint; } /** Sets the insertion point for the image. */ -void RS_Image::setInsertionPoint(Vector ip) +void Image::setInsertionPoint(Vector ip) { data.insertionPoint = ip; calculateBorders(); } /** @return File name of the image. */ -QString RS_Image::getFile() const +QString Image::getFile() const { return data.file; } /** Sets the file name of the image. */ -void RS_Image::setFile(const QString & file) +void Image::setFile(const QString & file) { data.file = file; } /** @return u Vector. Points along bottom, 1 pixel long. */ -Vector RS_Image::getUVector() const +Vector Image::getUVector() const { return data.uVector; } /** @return v Vector. Points along left, 1 pixel long. */ -Vector RS_Image::getVVector() const +Vector Image::getVVector() const { return data.vVector; } /** @return Width of image in pixels. */ -int RS_Image::getWidth() const +int Image::getWidth() const { return (int)data.size.x; } /** @return Height of image in pixels. */ -int RS_Image::getHeight() const +int Image::getHeight() const { return (int)data.size.y; } /** @return Brightness. */ -int RS_Image::getBrightness() const +int Image::getBrightness() const { return data.brightness; } /** @return Contrast. */ -int RS_Image::getContrast() const +int Image::getContrast() const { return data.contrast; } /** @return Fade. */ -int RS_Image::getFade() const +int Image::getFade() const { return data.fade; } /** @return Image definition handle. */ -int RS_Image::getHandle() const +int Image::getHandle() const { return data.handle; } /** Sets the image definition handle. */ -void RS_Image::setHandle(int h) +void Image::setHandle(int h) { data.handle = h; } /** @return The four corners. **/ -VectorSolutions RS_Image::getCorners() +VectorSolutions Image::getCorners() { VectorSolutions sol(4); sol.set(0, data.insertionPoint); sol.set(1, - data.insertionPoint + data.uVector * RS_Math::round(data.size.x)); + data.insertionPoint + data.uVector * 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)); + data.insertionPoint + data.vVector * Math::round(data.size.y)); + sol.set(2, sol.get(3) + data.uVector * Math::round(data.size.x)); return sol; } @@ -208,7 +208,7 @@ VectorSolutions RS_Image::getCorners() /** * @return image with in graphic units. */ -double RS_Image::getImageWidth() +double Image::getImageWidth() { return data.size.x * data.uVector.magnitude(); } @@ -216,12 +216,12 @@ double RS_Image::getImageWidth() /** * @return image height in graphic units. */ -double RS_Image::getImageHeight() +double Image::getImageHeight() { return data.size.y * data.vVector.magnitude(); } -void RS_Image::calculateBorders() +void Image::calculateBorders() { resetBorders(); VectorSolutions sol = getCorners(); @@ -233,13 +233,13 @@ void RS_Image::calculateBorders() } } -Vector RS_Image::getNearestEndpoint(const Vector & coord, double * dist) +Vector Image::getNearestEndpoint(const Vector & coord, double * dist) { VectorSolutions corners = getCorners(); return corners.getClosest(coord, dist); } -Vector RS_Image::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, RS_Entity * * entity) +Vector Image::getNearestPointOnEntity(const Vector & coord, bool onEntity, double * dist, Entity * * entity) { if (entity != NULL) *entity = this; @@ -247,11 +247,11 @@ Vector RS_Image::getNearestPointOnEntity(const Vector & coord, bool onEntity, do VectorSolutions corners = getCorners(); VectorSolutions points(4); - RS_Line l[] = { - RS_Line(NULL, RS_LineData(corners.get(0), corners.get(1))), - RS_Line(NULL, RS_LineData(corners.get(1), corners.get(2))), - RS_Line(NULL, RS_LineData(corners.get(2), corners.get(3))), - RS_Line(NULL, RS_LineData(corners.get(3), corners.get(0))) + Line l[] = { + Line(NULL, LineData(corners.get(0), corners.get(1))), + Line(NULL, LineData(corners.get(1), corners.get(2))), + Line(NULL, LineData(corners.get(2), corners.get(3))), + Line(NULL, LineData(corners.get(3), corners.get(0))) }; for (int i = 0; i < 4; ++i) @@ -260,7 +260,7 @@ Vector RS_Image::getNearestPointOnEntity(const Vector & coord, bool onEntity, do return points.getClosest(coord, dist); } -Vector RS_Image::getNearestCenter(const Vector & coord, double * dist) +Vector Image::getNearestCenter(const Vector & coord, double * dist) { VectorSolutions points(4); VectorSolutions corners = getCorners(); @@ -273,22 +273,22 @@ Vector RS_Image::getNearestCenter(const Vector & coord, double * dist) return points.getClosest(coord, dist); } -Vector RS_Image::getNearestMiddle(const Vector & coord, double * dist) +Vector Image::getNearestMiddle(const Vector & coord, double * dist) { return getNearestCenter(coord, dist); } -Vector RS_Image::getNearestDist(double distance, const Vector & coord, double * dist) +Vector Image::getNearestDist(double distance, const Vector & coord, double * dist) { VectorSolutions corners = getCorners(); VectorSolutions points(4); - RS_Line l[] = + Line l[] = { - RS_Line(NULL, RS_LineData(corners.get(0), corners.get(1))), - RS_Line(NULL, RS_LineData(corners.get(1), corners.get(2))), - RS_Line(NULL, RS_LineData(corners.get(2), corners.get(3))), - RS_Line(NULL, RS_LineData(corners.get(3), corners.get(0))) + Line(NULL, LineData(corners.get(0), corners.get(1))), + Line(NULL, LineData(corners.get(1), corners.get(2))), + Line(NULL, LineData(corners.get(2), corners.get(3))), + Line(NULL, LineData(corners.get(3), corners.get(0))) }; for (int i = 0; i < 4; ++i) @@ -297,7 +297,7 @@ Vector RS_Image::getNearestDist(double distance, const Vector & coord, double * return points.getClosest(coord, dist); } -double RS_Image::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, RS2::ResolveLevel /*level*/, double /*solidDist*/) +double Image::getDistanceToPoint(const Vector & coord, Entity * * entity, RS2::ResolveLevel /*level*/, double /*solidDist*/) { if (entity != NULL) *entity = this; @@ -306,12 +306,12 @@ double RS_Image::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, double dist; double minDist = RS_MAXDOUBLE; - RS_Line l[] = + Line l[] = { - RS_Line(NULL, RS_LineData(corners.get(0), corners.get(1))), - RS_Line(NULL, RS_LineData(corners.get(1), corners.get(2))), - RS_Line(NULL, RS_LineData(corners.get(2), corners.get(3))), - RS_Line(NULL, RS_LineData(corners.get(3), corners.get(0))) + Line(NULL, LineData(corners.get(0), corners.get(1))), + Line(NULL, LineData(corners.get(1), corners.get(2))), + Line(NULL, LineData(corners.get(2), corners.get(3))), + Line(NULL, LineData(corners.get(3), corners.get(0))) }; for (int i = 0; i < 4; ++i) @@ -325,18 +325,18 @@ double RS_Image::getDistanceToPoint(const Vector & coord, RS_Entity * * entity, return minDist; } -/*virtual*/ double RS_Image::getLength() +/*virtual*/ double Image::getLength() { return -1.0; } -void RS_Image::move(Vector offset) +void Image::move(Vector offset) { data.insertionPoint.move(offset); calculateBorders(); } -void RS_Image::rotate(Vector center, double angle) +void Image::rotate(Vector center, double angle) { data.insertionPoint.rotate(center, angle); data.uVector.rotate(angle); @@ -344,7 +344,7 @@ void RS_Image::rotate(Vector center, double angle) calculateBorders(); } -void RS_Image::scale(Vector center, Vector factor) +void Image::scale(Vector center, Vector factor) { data.insertionPoint.scale(center, factor); data.uVector.scale(factor); @@ -352,7 +352,7 @@ void RS_Image::scale(Vector center, Vector factor) calculateBorders(); } -void RS_Image::mirror(Vector axisPoint1, Vector axisPoint2) +void Image::mirror(Vector axisPoint1, Vector axisPoint2) { data.insertionPoint.mirror(axisPoint1, axisPoint2); data.uVector.mirror(Vector(0.0, 0.0), axisPoint2 - axisPoint1); @@ -360,7 +360,7 @@ void RS_Image::mirror(Vector axisPoint1, Vector axisPoint2) calculateBorders(); } -void RS_Image::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/) +void Image::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/) { if (painter == NULL || view == NULL || img.isNull()) return; @@ -431,7 +431,7 @@ void RS_Image::draw(PaintInterface * painter, GraphicView * view, double /*patte /** * Dumps the point's data to stdout. */ -std::ostream & operator<<(std::ostream & os, const RS_Image & i) +std::ostream & operator<<(std::ostream & os, const Image & i) { os << " Image: " << i.getData() << "\n"; return os;