X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Ftext.cpp;h=e665958e21aaa92b24c6bd5b40ca4610e821b7f5;hb=5adb444f3e523d3fd028617ced72d1ea6661db21;hp=5a9df7aae4e19ceb6a6ab7b0d9536c66f28cd8f5;hpb=3239ef39dcee08fa6e8cd68cdf2727fc68cc7a8c;p=architektonas diff --git a/src/base/text.cpp b/src/base/text.cpp index 5a9df7a..e665958 100644 --- a/src/base/text.cpp +++ b/src/base/text.cpp @@ -23,20 +23,20 @@ /** * Constructor. */ -RS_Text::RS_Text(RS_EntityContainer * parent, const RS_TextData & d): RS_EntityContainer(parent), data(d) +Text::Text(EntityContainer * parent, const TextData & d): EntityContainer(parent), data(d) { usedTextHeight = 0.0; usedTextWidth = 0.0; setText(data.text); } -/*virtual*/ RS_Text::~RS_Text() +/*virtual*/ Text::~Text() { } -/*virtual*/ RS_Entity * RS_Text::clone() +/*virtual*/ Entity * Text::clone() { - RS_Text * t = new RS_Text(*this); + Text * t = new Text(*this); #warning "!!! Need to deal with setAutoDelete() Qt3->Qt4 !!!" // t->entities.setAutoDelete(entities.autoDelete()); t->initId(); @@ -45,13 +45,13 @@ RS_Text::RS_Text(RS_EntityContainer * parent, const RS_TextData & d): RS_EntityC } /** @return RS2::EntityText */ -/*virtual*/ RS2::EntityType RS_Text::rtti() const +/*virtual*/ RS2::EntityType Text::rtti() const { return RS2::EntityText; } /** @return Copy of data that defines the text. */ -RS_TextData RS_Text::getData() const +TextData Text::getData() const { return data; } @@ -59,7 +59,7 @@ RS_TextData RS_Text::getData() const /** * @return Number of lines in this text entity. */ -int RS_Text::getNumberOfLines() +int Text::getNumberOfLines() { int c = 1; @@ -77,12 +77,12 @@ int RS_Text::getNumberOfLines() * text or it's data, position, alignment, .. changes. * This method also updates the usedTextWidth / usedTextHeight property. */ -void RS_Text::update() +void Text::update() { #if 0 -printf("RS_Text::update(): "); +printf("Text::update(): "); #endif - RS_DEBUG->print("RS_Text::update"); + DEBUG->print("Text::update"); clear(); #if 0 @@ -97,7 +97,7 @@ printf("isUndone=%s, ", (isUndone() ? "true" : "false")); #if 0 printf("data.style=\"%s\", ", data.style.toAscii().data()); #endif - RS_Font * font = RS_FONTLIST->requestFont(data.style); + Font * font = FONTLIST->requestFont(data.style); #if 0 printf("font=%08X\n", (unsigned int)font); @@ -112,7 +112,7 @@ printf("font=%08X\n", (unsigned int)font); // Every single text line gets stored in this entity container // so we can move the whole line around easely: - RS_EntityContainer * oneLine = new RS_EntityContainer(this); + EntityContainer * oneLine = new EntityContainer(this); // First every text line is created with // alignement: top left @@ -128,7 +128,7 @@ printf("font=%08X\n", (unsigned int)font); case 0x0A: // line feed: updateAddLine(oneLine, lineCounter++); - oneLine = new RS_EntityContainer(this); + oneLine = new EntityContainer(this); letterPos = Vector(0.0, -9.0); break; @@ -147,7 +147,7 @@ printf("font=%08X\n", (unsigned int)font); { case 'P': updateAddLine(oneLine, lineCounter++); - oneLine = new RS_EntityContainer(this); + oneLine = new EntityContainer(this); letterPos = Vector(0.0, -9.0); break; @@ -183,20 +183,20 @@ printf("font=%08X\n", (unsigned int)font); } // add texts: - RS_Text * upper = new RS_Text(oneLine, - RS_TextData(letterPos + Vector(0.0, 9.0), 4.0, 100.0, + Text * upper = new Text(oneLine, + TextData(letterPos + Vector(0.0, 9.0), 4.0, 100.0, RS2::VAlignTop, RS2::HAlignLeft, RS2::LeftToRight, RS2::Exact, 1.0, up, data.style, 0.0, RS2::Update)); upper->setLayer(NULL); - upper->setPen(RS_Pen(RS2::FlagInvalid)); + upper->setPen(Pen(RS2::FlagInvalid)); oneLine->addEntity(upper); - RS_Text * lower = new RS_Text(oneLine, - RS_TextData(letterPos+Vector(0.0, 4.0), 4.0, 100.0, + Text * lower = new Text(oneLine, + TextData(letterPos+Vector(0.0, 4.0), 4.0, 100.0, RS2::VAlignTop, RS2::HAlignLeft, RS2::LeftToRight, RS2::Exact, 1.0, dw, data.style, 0.0, RS2::Update)); lower->setLayer(NULL); - lower->setPen(RS_Pen(RS2::FlagInvalid)); + lower->setPen(Pen(RS2::FlagInvalid)); oneLine->addEntity(lower); // move cursor: @@ -235,9 +235,9 @@ printf("font=%08X\n", (unsigned int)font); //We ain't getting here: /* About to draw TEXT entity... TEXT="107.25" -RS_Dimension::updateCreateDimensionLine()... +Dimension::updateCreateDimensionLine()... --> 107.25 -RS_Text::update(): isUndone=false, font=094C1020 +Text::update(): isUndone=false, font=094C1020 --> default: pos=0, char=0031 --> default: pos=1, char=0030 --> default: pos=2, char=0037 @@ -246,12 +246,12 @@ RS_Text::update(): isUndone=false, font=094C1020 --> default: pos=5, char=0035 */ //printf(" char=%s\n", QString(data.text.at(i)).toAscii().data()); - RS_DEBUG->print("RS_Text::update: insert a letter at pos: %f/%f", letterPos.x, letterPos.y); - RS_InsertData d(QString(data.text.at(i)), letterPos, Vector(1.0, 1.0), + DEBUG->print("Text::update: insert a letter at pos: %f/%f", letterPos.x, letterPos.y); + InsertData d(QString(data.text.at(i)), letterPos, Vector(1.0, 1.0), 0.0, 1, 1, Vector(0.0, 0.0), font->getLetterList(), RS2::NoUpdate); - RS_Insert * letter = new RS_Insert(this, d); - letter->setPen(RS_Pen(RS2::FlagInvalid)); + Insert * letter = new Insert(this, d); + letter->setPen(Pen(RS2::FlagInvalid)); letter->setLayer(NULL); letter->update(); letter->forcedCalculateBorders(); @@ -275,7 +275,7 @@ RS_Text::update(): isUndone=false, font=094C1020 usedTextHeight -= data.height * data.lineSpacingFactor * 1.6 - data.height; forcedCalculateBorders(); - RS_DEBUG->print("RS_Text::update: OK"); + DEBUG->print("Text::update: OK"); } /** @@ -285,12 +285,12 @@ RS_Text::update(): isUndone=false, font=094C1020 * @param textLine The text line. * @param lineCounter Line number. */ -void RS_Text::updateAddLine(RS_EntityContainer* textLine, int lineCounter) +void Text::updateAddLine(EntityContainer* textLine, int lineCounter) { - RS_DEBUG->print("RS_Text::updateAddLine: width: %f", textLine->getSize().x); + DEBUG->print("Text::updateAddLine: width: %f", textLine->getSize().x); //textLine->forcedCalculateBorders(); - //RS_DEBUG->print("RS_Text::updateAddLine: width 2: %f", textLine->getSize().x); + //DEBUG->print("Text::updateAddLine: width 2: %f", textLine->getSize().x); // Move to correct line position: textLine->move(Vector(0.0, -9.0 * lineCounter * data.lineSpacingFactor * 1.6)); @@ -298,13 +298,13 @@ void RS_Text::updateAddLine(RS_EntityContainer* textLine, int lineCounter) textLine->forcedCalculateBorders(); Vector textSize = textLine->getSize(); - RS_DEBUG->print("RS_Text::updateAddLine: width 2: %f", textSize.x); + DEBUG->print("Text::updateAddLine: width 2: %f", textSize.x); // Horizontal Align: switch (data.halign) { case RS2::HAlignCenter: - RS_DEBUG->print("RS_Text::updateAddLine: move by: %f", -textSize.x / 2.0); + DEBUG->print("Text::updateAddLine: move by: %f", -textSize.x / 2.0); textLine->move(Vector(-textSize.x / 2.0, 0.0)); break; @@ -349,29 +349,29 @@ void RS_Text::updateAddLine(RS_EntityContainer* textLine, int lineCounter) // Move: textLine->move(data.insertionPoint); - textLine->setPen(RS_Pen(RS2::FlagInvalid)); + textLine->setPen(Pen(RS2::FlagInvalid)); textLine->setLayer(NULL); textLine->forcedCalculateBorders(); addEntity(textLine); } -Vector RS_Text::getInsertionPoint() +Vector Text::getInsertionPoint() { return data.insertionPoint; } -double RS_Text::getHeight() +double Text::getHeight() { return data.height; } -void RS_Text::setHeight(double h) +void Text::setHeight(double h) { data.height = h; } -double RS_Text::getWidth() +double Text::getWidth() { return data.width; } @@ -381,7 +381,7 @@ double RS_Text::getWidth() * * @param a 1: top left ... 9: bottom right */ -void RS_Text::setAlignment(int a) +void Text::setAlignment(int a) { switch (a % 3) { @@ -417,7 +417,7 @@ void RS_Text::setAlignment(int a) * * @return 1: top left ... 9: bottom right */ -int RS_Text::getAlignment() +int Text::getAlignment() { if (data.valign == RS2::VAlignTop) { @@ -468,42 +468,42 @@ int RS_Text::getAlignment() return 1; } -RS2::VAlign RS_Text::getVAlign() +RS2::VAlign Text::getVAlign() { return data.valign; } -void RS_Text::setVAlign(RS2::VAlign va) +void Text::setVAlign(RS2::VAlign va) { data.valign = va; } -RS2::HAlign RS_Text::getHAlign() +RS2::HAlign Text::getHAlign() { return data.halign; } -void RS_Text::setHAlign(RS2::HAlign ha) +void Text::setHAlign(RS2::HAlign ha) { data.halign = ha; } -RS2::TextDrawingDirection RS_Text::getDrawingDirection() +RS2::TextDrawingDirection Text::getDrawingDirection() { return data.drawingDirection; } -RS2::TextLineSpacingStyle RS_Text::getLineSpacingStyle() +RS2::TextLineSpacingStyle Text::getLineSpacingStyle() { return data.lineSpacingStyle; } -void RS_Text::setLineSpacingFactor(double f) +void Text::setLineSpacingFactor(double f) { data.lineSpacingFactor = f; } -double RS_Text::getLineSpacingFactor() +double Text::getLineSpacingFactor() { return data.lineSpacingFactor; } @@ -512,7 +512,7 @@ double RS_Text::getLineSpacingFactor() * Sets a new text. The entities representing the * text are updated. */ -void RS_Text::setText(const QString & t) +void Text::setText(const QString & t) { data.text = t; @@ -540,71 +540,71 @@ void RS_Text::setText(const QString & t) } } -QString RS_Text::getText() +QString Text::getText() { return data.text; } -void RS_Text::setStyle(const QString & s) +void Text::setStyle(const QString & s) { data.style = s; } -QString RS_Text::getStyle() +QString Text::getStyle() { return data.style; } -void RS_Text::setAngle(double a) +void Text::setAngle(double a) { data.angle = a; } -double RS_Text::getAngle() +double Text::getAngle() { return data.angle; } -double RS_Text::getUsedTextWidth() +double Text::getUsedTextWidth() { return usedTextWidth; } -double RS_Text::getUsedTextHeight() +double Text::getUsedTextHeight() { return usedTextHeight; } -/*virtual*/ double RS_Text::getLength() +/*virtual*/ double Text::getLength() { return -1.0; } -VectorSolutions RS_Text::getRefPoints() +VectorSolutions Text::getRefPoints() { VectorSolutions ret(data.insertionPoint); return ret; } -Vector RS_Text::getNearestRef(const Vector & coord, double * dist) +Vector Text::getNearestRef(const Vector & coord, double * dist) { - return RS_Entity::getNearestRef(coord, dist); + return Entity::getNearestRef(coord, dist); } -void RS_Text::move(Vector offset) +void Text::move(Vector offset) { data.insertionPoint.move(offset); update(); } -void RS_Text::rotate(Vector center, double angle) +void Text::rotate(Vector center, double angle) { data.insertionPoint.rotate(center, angle); - data.angle = RS_Math::correctAngle(data.angle + angle); + data.angle = Math::correctAngle(data.angle + angle); update(); } -void RS_Text::scale(Vector center, Vector factor) +void Text::scale(Vector center, Vector factor) { data.insertionPoint.scale(center, factor); data.width *= factor.x; @@ -612,11 +612,11 @@ void RS_Text::scale(Vector center, Vector factor) update(); } -void RS_Text::mirror(Vector axisPoint1, Vector axisPoint2) +void Text::mirror(Vector axisPoint1, Vector axisPoint2) { data.insertionPoint.mirror(axisPoint1, axisPoint2); //double ang = axisPoint1.angleTo(axisPoint2); - bool readable = RS_Math::isAngleReadable(data.angle); + bool readable = Math::isAngleReadable(data.angle); Vector vec; vec.setPolar(1.0, data.angle); @@ -624,7 +624,7 @@ void RS_Text::mirror(Vector axisPoint1, Vector axisPoint2) data.angle = vec.angle(); bool corr; - data.angle = RS_Math::makeAngleReadable(data.angle, readable, &corr); + data.angle = Math::makeAngleReadable(data.angle, readable, &corr); if (corr) { @@ -652,7 +652,7 @@ void RS_Text::mirror(Vector axisPoint1, Vector axisPoint2) update(); } -bool RS_Text::hasEndpointsWithinWindow(Vector /*v1*/, Vector /*v2*/) +bool Text::hasEndpointsWithinWindow(Vector /*v1*/, Vector /*v2*/) { return false; } @@ -661,7 +661,7 @@ bool RS_Text::hasEndpointsWithinWindow(Vector /*v1*/, Vector /*v2*/) * Implementations must stretch the given range of the entity * by the given offset. */ -void RS_Text::stretch(Vector firstCorner, Vector secondCorner, Vector offset) +void Text::stretch(Vector firstCorner, Vector secondCorner, Vector offset) { if (getMin().isInWindow(firstCorner, secondCorner) && getMax().isInWindow(firstCorner, secondCorner)) @@ -671,7 +671,7 @@ void RS_Text::stretch(Vector firstCorner, Vector secondCorner, Vector offset) /** * Dumps the point's data to stdout. */ -std::ostream & operator<<(std::ostream & os, const RS_Text & p) +std::ostream & operator<<(std::ostream & os, const Text & p) { os << " Text: " << p.getData() << "\n"; return os;