Skip to content

RTextBasedData

Class in Entity Module
Header: #include <src/core/RTextBasedData.h>
Inherits: REntityData, RPainterPathSource
Inherited by: RAttributeData, RAttributeDefinitionData, RTextData

Stores and manages all data that defines the geometry and appearance of a text based entity (text, block attribute, block attribute definition).

Scriptable: This class is available in script environments.

Shared Pointer Support: Objects can be used in QSharedPointer.

Copyable: Objects are cleaned up automatically by the garbage collector of the script engine.

enum TextFlag { NoFlags, Bold, Italic, Simple, DimensionLabel, Highlighted, Backward, UpsideDown }
RTextBasedData(const RVector &position, const RVector &alignmentPoint, double textHeight, double textWidth, RS::VAlign verticalAlignment, RS::HAlign horizontalAlignment, RS::TextDrawingDirection drawingDirection, RS::TextLineSpacingStyle lineSpacingStyle, double lineSpacingFactor, const QString &text, const QString &fontName, bool bold, bool italic, double angle, bool simple)
RTextBasedData(RDocument *document=NULL)
virtual ~RTextBasedData()
virtual bool flipHorizontal()
virtual bool flipVertical()
RVector getAlignmentPoint() const
double getAngle() const
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
virtual QList< RVector > getCenterPoints(const RBox &queryBox=RDEFAULT_RBOX) const
virtual RVector getClosestPointOnEntity(const RVector &point, double range, bool limited) const
virtual QSharedPointer< RShape > getClosestShape(const RVector &pos, double range=RNANDOUBLE, bool ignoreComplex=false) const
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
RS::TextDrawingDirection getDrawingDirection() const
virtual QList< RVector > getEndPoints(const RBox &queryBox=RDEFAULT_RBOX) const
virtual QString getEscapedText(bool escapeUnicode=false) const
virtual QList< QSharedPointer< RShape > > getExploded() const
bool getFlag(RTextBasedData::TextFlag flag) const
QString getFontFile() const
QString getFontName() const
RS::HAlign getHAlign() const
double getHeight() const
Height of the text (this is not equal to the bounding box height as it is the height of the text at 0 angle).
double getLineSpacingFactor() const
RS::TextLineSpacingStyle getLineSpacingStyle() const
virtual QFont getMainFont() const
virtual QList< RVector > getMiddlePoints(const RBox &queryBox=RDEFAULT_RBOX) const
virtual QList< RPainterPath > getPainterPaths(bool draft=false, double pixelSizeHint=RDEFAULT_MIN1) const
virtual QString getPlainText() const
virtual RVector getPointOnEntity() const
virtual QList< RVector > getPointsWithDistanceToEnd(double distance, int from=RS::FromAny, const RBox &queryBox=RDEFAULT_RBOX) const
RVector getPosition() const
virtual QList< RRefPoint > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const
virtual QString getRenderedText(bool escapeUnicode=false) const
QList< RVector > getRotatedBoundingBox() const
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false, QList< RObject::Id > *entityIds=NULL) const
QList< RTextBasedData > getSimpleTextBlocks()
virtual QString getText() const
double getTextHeight() const
QList< RTextLayout > getTextLayouts() const
double getTextWidth() const
Width of the text box used for line wrapping.
virtual RS::EntityType getType() const
RS::VAlign getVAlign() const
double getWidth() const
Width of the text (this is not equal to the bounding box width as it is the width of the text at 0 angle).
double getXScale() const
virtual bool intersectsWith(const RShape &shape) const
bool isBackward() const
bool isBold() const
bool isDimensionLabel() const
virtual bool isDirty() const
bool isHighlighted() const
bool isItalic() const
virtual bool isSane() const
bool isSimple() const
bool isUpsideDown() const
virtual bool isValid() const
virtual bool mirror(const RLine &axis)
virtual bool move(const RVector &offset)
Moves this entity by the given offset.
virtual bool moveReferencePoint(const RVector &referencePoint, const RVector &targetPoint, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
Moves the given reference point to the given target point or does nothing if this entity has no reference point as the given location.
virtual bool rotate(double rotation, const RVector &center)
virtual bool scale(const RVector &scaleFactors, const RVector &center)
void setAlignmentPoint(const RVector &alignmentPoint)
void setAngle(double angle)
void setBackward(bool on)
void setBold(bool on)
void setDimensionLabel(bool on)
void setDrawingDirection(RS::TextDrawingDirection drawingDirection)
void setFlag(RTextBasedData::TextFlag flag, bool on=true)
void setFontFile(const QString &fontFile)
void setFontName(const QString &fontName)
void setHAlign(RS::HAlign halign)
void setHighlighted(bool on)
void setItalic(bool on)
void setLineSpacingFactor(double lineSpacingFactor)
void setLineSpacingStyle(RS::TextLineSpacingStyle lineSpacingStyle)
void setPosition(const RVector &position)
virtual void setSelected(bool on)
Selects or deselects this entity.
void setSimple(bool on)
void setText(const QString &text)
void setTextHeight(double h)
void setTextWidth(double w)
void setUpsideDown(bool on)
void setVAlign(RS::VAlign valign)
void setXScale(double xScale)
void sync(const RTextBasedData &other)
virtual void to2D()
virtual void update() const
Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty).
virtual void update(bool layout) const
static QString escapeUnicode(const QString &str)
static RS::EntityType getRtti()
static RTextProxy * getTextProxy()
static bool hasProxy()
static void setTextProxy(RTextProxy *p)
static QString toEscapedText(const QTextDocument &textDocument, const RColor &initialColor, double fontHeightFactor=1.0, bool simpleText=false)
Converts the given text document (typically from a QTextEdit) into CAD escaped text.
static QString toRichText(const QString &escapedText, const QFont &mainFont, double fontHeightFactor=1.0)
RTextBasedData(RDocument *document, const RTextBasedData &data)
RVector alignmentPoint
double angle
RBox boundingBox
bool dirty
RS::TextDrawingDirection drawingDirection
TextFlags flags
QString fontFile
QString fontName
bool gotDraft
double height
RS::HAlign horizontalAlignment
double lineSpacingFactor
RS::TextLineSpacingStyle lineSpacingStyle
QList< RPainterPath > painterPaths
RVector position
QString text
double textHeight
QList< RTextLayout > textLayouts
double textWidth
RS::VAlign verticalAlignment
double width
double xScale
static RTextProxy * textProxy
class RTextBasedEntity

enum TextFlag
Value Description
NoFlags = 0x000
Bold = 0x001
Italic = 0x002
Simple = 0x004
DimensionLabel = 0x008
Highlighted = 0x010
Backward = 0x020
UpsideDown = 0x040

RTextBasedData::RTextBasedData(const RVector &position, const RVector &alignmentPoint, double textHeight, double textWidth, RS::VAlign verticalAlignment, RS::HAlign horizontalAlignment, RS::TextDrawingDirection drawingDirection, RS::TextLineSpacingStyle lineSpacingStyle, double lineSpacingFactor, const QString &text, const QString &fontName, bool bold, bool italic, double angle, bool simple)

Parameters:

  • position: Insertion point (see DXF code 10 doc).
  • alignmentPoint: Alignment point of text (see DXF code 11 doc).
  • height: Nominal (initial) text height
  • textWidth: Reference rectangle width for wrapping (not supported)
  • valign: Vertical alignment
  • halign: Horizontal alignment
  • drawingDirection: Drawing direction
  • lineSpacingStyle: Line spacing style
  • lineSpacingFactor: Line spacing factor
  • text: Text string
  • fontName: Text font name
  • angle: Rotation angle in rad

RTextBasedData::RTextBasedData(RDocument *document=NULL)

virtual RTextBasedData::~RTextBasedData()

virtual inline

virtual bool RTextBasedData::flipHorizontal()

virtual

Reimplemented from flipHorizontal.

virtual bool RTextBasedData::flipVertical()

virtual

Reimplemented from flipVertical.

RVector RTextBasedData::getAlignmentPoint() const

inline const

Returns: Alignment point of the reference point of the text. This is usually the same as the position.

double RTextBasedData::getAngle() const

inline const

virtual RBox RTextBasedData::getBoundingBox(bool ignoreEmpty=false) const

virtual const

Returns: The bounding box that contains this entity.

Reimplemented from getBoundingBox.

virtual QList< RVector > RTextBasedData::getCenterPoints(const RBox &queryBox=RDEFAULT_RBOX) const

virtual inline const

virtual RVector RTextBasedData::getClosestPointOnEntity(const RVector &point, double range, bool limited) const

virtual const

virtual QSharedPointer< RShape > RTextBasedData::getClosestShape(const RVector &pos, double range=RNANDOUBLE, bool ignoreComplex=false) const

virtual inline const

virtual double RTextBasedData::getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const

virtual const

Returns: The shortest distance from this entity to the given point.

Parameters:

  • limited: Limit lines, arcs at end points, otherwise the orthogonal distance to the unlimited line / circle is returned.
  • range: This is returned for solid filled entities (solid filled or dense hatches, text entities) if the point is on the entity and the distance would be zero.
  • draft: Calculate based on draft mode representation of the entity.
  • strictRange: If limited, this is the maximum range from either end point of the entity. Zero to only return distances that are strictly orthogonal to the entity.

Reimplemented from getDistanceTo.

RS::TextDrawingDirection RTextBasedData::getDrawingDirection() const

inline const

virtual QList< RVector > RTextBasedData::getEndPoints(const RBox &queryBox=RDEFAULT_RBOX) const

virtual inline const

virtual QString RTextBasedData::getEscapedText(bool escapeUnicode=false) const

virtual const

virtual QList< QSharedPointer< RShape > > RTextBasedData::getExploded() const

virtual const

bool RTextBasedData::getFlag(RTextBasedData::TextFlag flag) const

inline const

QString RTextBasedData::getFontFile() const

inline const

QString RTextBasedData::getFontName() const

inline const

RS::HAlign RTextBasedData::getHAlign() const

inline const

double RTextBasedData::getHeight() const

const

Height of the text (this is not equal to the bounding box height as it is the height of the text at 0 angle).

double RTextBasedData::getLineSpacingFactor() const

inline const

RS::TextLineSpacingStyle RTextBasedData::getLineSpacingStyle() const

inline const

virtual QFont RTextBasedData::getMainFont() const

virtual const

virtual QList< RVector > RTextBasedData::getMiddlePoints(const RBox &queryBox=RDEFAULT_RBOX) const

virtual inline const

virtual QList< RPainterPath > RTextBasedData::getPainterPaths(bool draft=false, double pixelSizeHint=RDEFAULT_MIN1) const

virtual const

Reimplemented from getPainterPaths.

virtual QString RTextBasedData::getPlainText() const

virtual const

virtual RVector RTextBasedData::getPointOnEntity() const

virtual const

Returns: A point that is on the entity. Used to check if an entity is inside a polygon.

Reimplemented from getPointOnEntity.

virtual QList< RVector > RTextBasedData::getPointsWithDistanceToEnd(double distance, int from=RS::FromAny, const RBox &queryBox=RDEFAULT_RBOX) const

virtual inline const

RVector RTextBasedData::getPosition() const

inline const

Returns: Position of the reference point of the text.

virtual QList< RRefPoint > RTextBasedData::getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const

virtual const

Returns: Vector of reference points of this entity. Reference points can usually be moved around by the user to change the geometry of the entity.

Reimplemented from getReferencePoints.

Reimplemented in getReferencePoints.

virtual QString RTextBasedData::getRenderedText(bool escapeUnicode=false) const

virtual const

Reimplemented in getRenderedText, getRenderedText.

QList< RVector > RTextBasedData::getRotatedBoundingBox() const

const

virtual QList< QSharedPointer< RShape > > RTextBasedData::getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false, QList< RObject::Id > *entityIds=NULL) const

virtual const

Returns: Shapes that represent the geometry of this entity.

Parameters:

  • queryBox: Limit returned shapes to query box
  • ignoreComplex: Ignore complex shapes and explode those into simple shapes
  • segment: Split up splines into spline segments

Reimplemented from getShapes.

QList< RTextBasedData > RTextBasedData::getSimpleTextBlocks()

Returns: List of text data objects representing simple texts. Complex formatted texts are split up into smaller text blocks, each with unique formatting, color, etc.

virtual QString RTextBasedData::getText() const

virtual inline const

double RTextBasedData::getTextHeight() const

inline const

QList< RTextLayout > RTextBasedData::getTextLayouts() const

const

double RTextBasedData::getTextWidth() const

inline const

Width of the text box used for line wrapping.

virtual RS::EntityType RTextBasedData::getType() const

virtual inline const

Reimplemented from getType.

Reimplemented in getType, getType, getType.

RS::VAlign RTextBasedData::getVAlign() const

inline const

double RTextBasedData::getWidth() const

const

Width of the text (this is not equal to the bounding box width as it is the width of the text at 0 angle).

double RTextBasedData::getXScale() const

inline const

virtual bool RTextBasedData::intersectsWith(const RShape &shape) const

virtual const

Returns: True if this entity intersects with the given shape, false otherwise.

Reimplemented from intersectsWith.

bool RTextBasedData::isBackward() const

inline const

bool RTextBasedData::isBold() const

inline const

bool RTextBasedData::isDimensionLabel() const

inline const

virtual bool RTextBasedData::isDirty() const

virtual const

bool RTextBasedData::isHighlighted() const

inline const

bool RTextBasedData::isItalic() const

inline const

virtual bool RTextBasedData::isSane() const

virtual const

Reimplemented from isSane.

bool RTextBasedData::isSimple() const

inline const

bool RTextBasedData::isUpsideDown() const

inline const

virtual bool RTextBasedData::isValid() const

virtual inline const

Reimplemented from isValid.

virtual bool RTextBasedData::mirror(const RLine &axis)

virtual

Reimplemented from mirror.

virtual bool RTextBasedData::move(const RVector &offset)

virtual

Moves this entity by the given offset.

Reimplemented from move.

virtual bool RTextBasedData::moveReferencePoint(const RVector &referencePoint, const RVector &targetPoint, Qt::KeyboardModifiers modifiers=Qt::NoModifier)

virtual

Moves the given reference point to the given target point or does nothing if this entity has no reference point as the given location.

Returns: True if a reference point has been moved successfully, false otherwise.

Reimplemented from moveReferencePoint.

virtual bool RTextBasedData::rotate(double rotation, const RVector &center)

virtual

Reimplemented from rotate.

virtual bool RTextBasedData::scale(const RVector &scaleFactors, const RVector &center)

virtual

Reimplemented from scale.

void RTextBasedData::setAlignmentPoint(const RVector &alignmentPoint)

inline

void RTextBasedData::setAngle(double angle)

inline

void RTextBasedData::setBackward(bool on)

inline

void RTextBasedData::setBold(bool on)

inline

void RTextBasedData::setDimensionLabel(bool on)

inline

void RTextBasedData::setDrawingDirection(RS::TextDrawingDirection drawingDirection)

inline

void RTextBasedData::setFlag(RTextBasedData::TextFlag flag, bool on=true)

inline

void RTextBasedData::setFontFile(const QString &fontFile)

inline

void RTextBasedData::setFontName(const QString &fontName)

void RTextBasedData::setHAlign(RS::HAlign halign)

inline

void RTextBasedData::setHighlighted(bool on)

inline

void RTextBasedData::setItalic(bool on)

inline

void RTextBasedData::setLineSpacingFactor(double lineSpacingFactor)

inline

void RTextBasedData::setLineSpacingStyle(RS::TextLineSpacingStyle lineSpacingStyle)

inline

void RTextBasedData::setPosition(const RVector &position)

inline

virtual void RTextBasedData::setSelected(bool on)

virtual inline

Selects or deselects this entity.

Reimplemented from setSelected.

void RTextBasedData::setSimple(bool on)

inline

void RTextBasedData::setText(const QString &text)

void RTextBasedData::setTextHeight(double h)

inline

void RTextBasedData::setTextWidth(double w)

inline

void RTextBasedData::setUpsideDown(bool on)

inline

void RTextBasedData::setVAlign(RS::VAlign valign)

inline

void RTextBasedData::setXScale(double xScale)

inline

void RTextBasedData::sync(const RTextBasedData &other)

virtual void RTextBasedData::to2D()

virtual

HTML helper function.

HTML helper function.

HTML helper function.

HTML helper function.

HTML helper function.

HTML helper function.

HTML helper function.

HTML helper function.

Reimplemented from to2D.

virtual void RTextBasedData::update() const

virtual inline const

Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty).

Reimplemented from update.

virtual void RTextBasedData::update(bool layout) const

virtual const

static QString RTextBasedData::escapeUnicode(const QString &str)

static

static RS::EntityType RTextBasedData::getRtti()

static inline

static RTextProxy * RTextBasedData::getTextProxy()

static inline

Non-Scriptable: This function is not available in script environments.

static bool RTextBasedData::hasProxy()

static inline

static void RTextBasedData::setTextProxy(RTextProxy *p)

static inline

Non-Scriptable: This function is not available in script environments.

static QString RTextBasedData::toEscapedText(const QTextDocument &textDocument, const RColor &initialColor, double fontHeightFactor=1.0, bool simpleText=false)

static

Converts the given text document (typically from a QTextEdit) into CAD escaped text.

Parameters:

  • fontHeightFactor: factor applied to all font heights. This allows the text edit to use a bigger / smaller font that needed in the end.

static QString RTextBasedData::toRichText(const QString &escapedText, const QFont &mainFont, double fontHeightFactor=1.0)

static

Returns: HTML representing this text.

RTextBasedData::RTextBasedData(RDocument *document, const RTextBasedData &data)

protected

RVector RTextBasedData::alignmentPoint

protected

double RTextBasedData::angle

protected

RBox RTextBasedData::boundingBox

protected

bool RTextBasedData::dirty

protected

RS::TextDrawingDirection RTextBasedData::drawingDirection

protected

TextFlags RTextBasedData::flags

protected

QString RTextBasedData::fontFile

protected

QString RTextBasedData::fontName

protected

bool RTextBasedData::gotDraft

protected

double RTextBasedData::height

protected

RS::HAlign RTextBasedData::horizontalAlignment

protected

double RTextBasedData::lineSpacingFactor

protected

RS::TextLineSpacingStyle RTextBasedData::lineSpacingStyle

protected

QList<RPainterPath> RTextBasedData::painterPaths

protected

RVector RTextBasedData::position

protected

QString RTextBasedData::text

protected

double RTextBasedData::textHeight

protected

QList<RTextLayout> RTextBasedData::textLayouts

protected

double RTextBasedData::textWidth

protected

RS::VAlign RTextBasedData::verticalAlignment

protected

double RTextBasedData::width

protected

double RTextBasedData::xScale

protected

static RTextProxy * RTextBasedData::textProxy = NULL

static private

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.

friend class RTextBasedEntity

private