QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
REntityData Class Reference

Base class for all entity data classes. More...

#include <REntityData.h>

Inheritance diagram for REntityData:
RArcData RBlockReferenceData RCircleData RDimensionData REllipseData RHatchData RImageData RLeaderData RLineData RPointData RPolylineData RRayData RSolidData RSplineData RTextBasedData RViewportData RXLineData

List of all members.

Public Member Functions

virtual const RShapecastToConstShape () const
virtual RShapecastToShape ()
virtual bool flipHorizontal ()
virtual bool flipVertical ()
RBlock::Id getBlockId () const
QString getBlockName () const
virtual RBox getBoundingBox (bool ignoreEmpty=false) const
virtual QList< RBoxgetBoundingBoxes (bool ignoreEmpty=false) const
virtual QList< RVectorgetCenterPoints (const RBox &queryBox=RDEFAULT_RBOX) const
virtual RVector getClosestPointOnEntity (const RVector &point, double range=RNANDOUBLE, bool limited=true) const
virtual QSharedPointer< RShapegetClosestShape (const RVector &pos, double range=RNANDOUBLE, bool ignoreComplex=false) const
virtual RColor getColor () const
virtual RColor getColor (bool resolve, const QStack< REntity * > &blockRefStack) const
virtual double getDistanceTo (const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
RDocumentgetDocument ()
const RDocumentgetDocument () const
virtual int getDrawOrder () const
virtual QList< RVectorgetEndPoints (const RBox &queryBox=RDEFAULT_RBOX) const
virtual QList< RVectorgetInternalReferencePoints (RS::ProjectionRenderingHint hint=RS::RenderTop) const
 Can be overwritten to return internal, resolved reference points.
virtual QList< RVectorgetIntersectionPoints (const REntityData &other, bool limited=true, bool same=false, const RBox &queryBox=RDEFAULT_RBOX) const
 Override to disable intersection point.
virtual QList< RVectorgetIntersectionPoints (const RShape &shape, bool limited=true, const RBox &queryBox=RDEFAULT_RBOX) const
RLayer::Id getLayerId () const
QString getLayerName () const
virtual RLinetype::Id getLinetypeId () const
virtual RLinetype::Id getLinetypeId (bool resolve, const QStack< REntity * > &blockRefStack) const
virtual RLinetypePattern getLinetypePattern () const
virtual double getLinetypeScale () const
virtual RLineweight::Lineweight getLineweight () const
virtual RLineweight::Lineweight getLineweight (bool resolve, const QStack< REntity * > &blockRefStack) const
double getLineweightInUnits (const QStack< REntity * > &blockRefStack) const
virtual QList< RVectorgetMiddlePoints (const RBox &queryBox=RDEFAULT_RBOX) const
RObject::Id getParentId () const
virtual RVector getPointOnEntity () const
virtual QList< RVectorgetPointsWithDistanceToEnd (double distance, RS::From from=RS::FromAny, const RBox &queryBox=RDEFAULT_RBOX) const
virtual QList< RVectorgetReferencePoints (RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
virtual QList< QSharedPointer
< RShape > > 
getShapes (const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false) const
virtual RVector getVectorTo (const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const
virtual bool intersectsWith (const RShape &shape) const
virtual bool isInside (const RBox &box) const
virtual bool isOnEntity (const RVector &point, bool limited=true) const
virtual bool isSelected () const
virtual bool mirror (const RLine &axis)
virtual bool mirror (const RVector &axis1, const RVector &axis2)
virtual bool move (const RVector &offset)
 Moves this entity by the given offset.
virtual bool moveReferencePoint (const RVector &referencePoint, const RVector &targetPoint)=0
 Moves the given reference point to the given target point or does nothing if this entity has no reference point as the given location.
 REntityData (RDocument *document=NULL)
 Copyright (c) 2011-2014 by Andrew Mustun.
virtual bool rotate (double rotation, const RVector &center=RDEFAULT_RVECTOR)
virtual bool scale (const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
virtual bool scale (double scaleFactor, const RVector &center=RDEFAULT_RVECTOR)
virtual void setBlockId (RBlock::Id blockId)
void setColor (const RColor &color)
void setDocument (RDocument *document)
virtual void setDrawOrder (int drawOrder)
 Sets the draw order of this entity.
virtual void setLayerId (RLayer::Id layerId)
virtual void setLinetypeId (RLinetype::Id linetypeId)
virtual void setLinetypePattern (const RLinetypePattern &p)
virtual void setLinetypeScale (double linetypeScale)
void setLineweight (RLineweight::Lineweight lineweight)
virtual void setParentId (RObject::Id parentId)
virtual void setSelected (bool on)
 Selects or deselects this entity.
virtual bool stretch (const RPolyline &area, const RVector &offset)
 Stretches the end points of this entity that are inside area by offset.
virtual void update () const
 Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty).
virtual ~REntityData ()

Protected Attributes

RBlock::Id blockId
RColor color
RDocumentdocument
int drawOrder
RLayer::Id layerId
RLinetype::Id linetypeId
double linetypeScale
RLineweight::Lineweight lineweight
RObject::Id parentId
bool selectionStatus

Friends

class REntity

Detailed Description

Base class for all entity data classes.

Such classes are used to separate functionality from data. Data objects may for example be used to perform certain calculations. A custom entity might use the same data class as a standard entity to provide similar behavior (e.g. a wall might behave similar like a line entity).

Scriptable:
This class is wrapped for script environments.
Shared Pointer Support:
Script wrappers of this class support wrapping in QSharedPointer.

Constructor & Destructor Documentation

REntityData::REntityData ( RDocument document = NULL)

Copyright (c) 2011-2014 by Andrew Mustun.

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.

virtual REntityData::~REntityData ( )
inlinevirtual

Member Function Documentation

virtual const RShape* REntityData::castToConstShape ( ) const
inlinevirtual
   \par Non-Scriptable:

This function is not available in script environments.

virtual RShape* REntityData::castToShape ( )
inlinevirtual
bool REntityData::flipHorizontal ( )
virtual

Reimplemented in RTextBasedData.

bool REntityData::flipVertical ( )
virtual

Reimplemented in RTextBasedData.

RBlock::Id REntityData::getBlockId ( ) const
inline
QString REntityData::getBlockName ( ) const
RBox REntityData::getBoundingBox ( bool  ignoreEmpty = false) const
virtual
Returns:
The bounding box that contains this entity.

Reimplemented in RTextBasedData, RImageData, RDimensionData, RHatchData, RViewportData, RBlockReferenceData, and RSplineData.

virtual QList<RBox> REntityData::getBoundingBoxes ( bool  ignoreEmpty = false) const
inlinevirtual
Returns:
Vector of bounding boxes that contain this entity. This is used for complex entities such as block references to further optimize algorithms that depend on bounding boxes (e.g. spatial index algorithms). The default implementation returns the bounding box that contains the whole entity.

Reimplemented in RPolylineData.

QList< RVector > REntityData::getCenterPoints ( const RBox queryBox = RDEFAULT_RBOX) const
virtual
Returns:
Vector of center points of this entity. Used for snap to center points.

Reimplemented in RTextBasedData.

RVector REntityData::getClosestPointOnEntity ( const RVector point,
double  range = RNANDOUBLE,
bool  limited = true 
) const
virtual
Returns:
Closest point to point on this entity. Used for snap to points on entity.

Reimplemented in RTextBasedData.

QSharedPointer< RShape > REntityData::getClosestShape ( const RVector pos,
double  range = RNANDOUBLE,
bool  ignoreComplex = false 
) const
virtual
Returns:
The one shape that is part of this entity which is the closest to the given position.

Reimplemented in RTextBasedData.

virtual RColor REntityData::getColor ( ) const
inlinevirtual

Reimplemented in RAttributeData.

RColor REntityData::getColor ( bool  resolve,
const QStack< REntity * > &  blockRefStack 
) const
virtual
Returns:
Color of this entity.
Parameters:
resolveResolve color if ByLayer or ByBlock.

Reimplemented in RAttributeData.

double REntityData::getDistanceTo ( const RVector point,
bool  limited = true,
double  range = 0.0,
bool  draft = false,
double  strictRange = RMAXDOUBLE 
) const
virtual
Returns:
The shortest distance from this entity to the given point.
Parameters:
limitedLimit lines, arcs at end points, otherwise the orthogonal distance to the unlimited line / circle is returned.
rangeThis 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.
draftCalculate based on draft mode representation of the entity.
strictRangeIf 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 in RDimensionData, RTextBasedData, RImageData, RBlockReferenceData, and RHatchData.

RDocument* REntityData::getDocument ( )
inline
const RDocument* REntityData::getDocument ( ) const
inline
virtual int REntityData::getDrawOrder ( ) const
inlinevirtual
Returns:
The draw order of this entity. Entities are usually drawn in ascending order of this number.
QList< RVector > REntityData::getEndPoints ( const RBox queryBox = RDEFAULT_RBOX) const
virtual
Returns:
Vector of end points of this entity. Used for snap to end points.

Reimplemented in RTextBasedData.

virtual QList<RVector> REntityData::getInternalReferencePoints ( RS::ProjectionRenderingHint  hint = RS::RenderTop) const
inlinevirtual

Can be overwritten to return internal, resolved reference points.

This is used for example for block references in combination with snap to reference points. Default implementation returns same as getReferencePoints().

Reimplemented in RBlockReferenceData.

QList< RVector > REntityData::getIntersectionPoints ( const REntityData other,
bool  limited = true,
bool  same = false,
const RBox queryBox = RDEFAULT_RBOX 
) const
virtual

Override to disable intersection point.

Returns:
Points on entity which are intersection points with the given other entity. If same is true, the two datas originate from the same entity.

Reimplemented in RPolylineData.

QList< RVector > REntityData::getIntersectionPoints ( const RShape shape,
bool  limited = true,
const RBox queryBox = RDEFAULT_RBOX 
) const
virtual
Returns:
Points on entity which are intersection points with the given shape.
RLayer::Id REntityData::getLayerId ( ) const
inline
QString REntityData::getLayerName ( ) const
virtual RLinetype::Id REntityData::getLinetypeId ( ) const
inlinevirtual
RLinetype::Id REntityData::getLinetypeId ( bool  resolve,
const QStack< REntity * > &  blockRefStack 
) const
virtual

Reimplemented in RAttributeData.

RLinetypePattern REntityData::getLinetypePattern ( ) const
virtual
virtual double REntityData::getLinetypeScale ( ) const
inlinevirtual
virtual RLineweight::Lineweight REntityData::getLineweight ( ) const
inlinevirtual
RLineweight::Lineweight REntityData::getLineweight ( bool  resolve,
const QStack< REntity * > &  blockRefStack 
) const
virtual
Parameters:
resolveTrue: resolve ByLayer / ByBlock and always return a lineweight in 1/100 mm.
layerLayer to use for resolving if known, NULL otherwise.
blockRefBlock reference to use for resolving if known, NULL otherwise.

Reimplemented in RAttributeData.

double REntityData::getLineweightInUnits ( const QStack< REntity * > &  blockRefStack) const
QList< RVector > REntityData::getMiddlePoints ( const RBox queryBox = RDEFAULT_RBOX) const
virtual
Returns:
Vector of middle points of this entity. Used for snap to middle points.

Reimplemented in RTextBasedData.

RObject::Id REntityData::getParentId ( ) const
inline
RVector REntityData::getPointOnEntity ( ) const
virtual
Returns:
A point that is on the entity. Used to check if an entity is inside a polygon.

Reimplemented in RTextBasedData, RImageData, and RHatchData.

QList< RVector > REntityData::getPointsWithDistanceToEnd ( double  distance,
RS::From  from = RS::FromAny,
const RBox queryBox = RDEFAULT_RBOX 
) const
virtual
Returns:
Points on entity with given distance to either endpoint. Used for snap to points with distance on entity.

Reimplemented in RTextBasedData.

virtual QList<RVector> REntityData::getReferencePoints ( RS::ProjectionRenderingHint  hint = RS::RenderTop) const
pure virtual
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.

Implemented in RTextBasedData, RDimensionData, RViewportData, REllipseData, RArcData, RDimAngularData, RLineData, RDimOrdinateData, RLeaderData, RSolidData, RXLineData, RRayData, RImageData, RDimDiametricData, RDimRadialData, RCircleData, RHatchData, RDimRotatedData, RBlockReferenceData, RPointData, RPolylineData, RSplineData, and RDimAlignedData.

virtual QList<QSharedPointer<RShape> > REntityData::getShapes ( const RBox queryBox = RDEFAULT_RBOX,
bool  ignoreComplex = false 
) const
inlinevirtual
RVector REntityData::getVectorTo ( const RVector point,
bool  limited = true,
double  strictRange = RMAXDOUBLE 
) const
virtual
Returns:
The distance vector from this entity to the given point.
Parameters:
pointthe point to which the distance was measured
limited,:If true, an invalid vector is returned if the closest point on the entity is outside of the entity (e.g. in the extension line of a line or outside the start / end angle of an arc).

Reimplemented in RBlockReferenceData.

bool REntityData::intersectsWith ( const RShape shape) const
virtual
Returns:
True if this entity intersects with the given shape, false otherwise.
Todo:
better to pass another entity data object?

Reimplemented in RDimensionData, RTextBasedData, RImageData, and RHatchData.

virtual bool REntityData::isInside ( const RBox box) const
inlinevirtual
Returns:
True if this entity is completely inside the given box, false otherwise. Only geometry is accounted for, not the line width.
bool REntityData::isOnEntity ( const RVector point,
bool  limited = true 
) const
virtual
Returns:
True if the given point is on this entity.
virtual bool REntityData::isSelected ( ) const
inlinevirtual
Returns:
True if the entity is currently selected. This can for example influence the color in which the entity is exported.
bool REntityData::mirror ( const RVector axis1,
const RVector axis2 
)
virtual
bool REntityData::move ( const RVector offset)
virtual
virtual bool REntityData::moveReferencePoint ( const RVector referencePoint,
const RVector targetPoint 
)
pure 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.

Implemented in RTextBasedData, RDimensionData, RViewportData, REllipseData, RArcData, RDimAngularData, RLineData, RDimOrdinateData, RLeaderData, RSolidData, RXLineData, RRayData, RDimLinearData, RImageData, RDimDiametricData, RDimRadialData, RBlockReferenceData, RCircleData, RHatchData, RPointData, RPolylineData, RSplineData, and RDimAlignedData.

bool REntityData::rotate ( double  rotation,
const RVector center = RDEFAULT_RVECTOR 
)
virtual
bool REntityData::scale ( const RVector scaleFactors,
const RVector center = RDEFAULT_RVECTOR 
)
virtual
bool REntityData::scale ( double  scaleFactor,
const RVector center = RDEFAULT_RVECTOR 
)
virtual
virtual void REntityData::setBlockId ( RBlock::Id  blockId)
inlinevirtual
void REntityData::setColor ( const RColor color)
inline
void REntityData::setDocument ( RDocument document)
inline
virtual void REntityData::setDrawOrder ( int  drawOrder)
inlinevirtual

Sets the draw order of this entity.

virtual void REntityData::setLayerId ( RLayer::Id  layerId)
inlinevirtual
virtual void REntityData::setLinetypeId ( RLinetype::Id  linetypeId)
inlinevirtual
void REntityData::setLinetypePattern ( const RLinetypePattern p)
virtual
virtual void REntityData::setLinetypeScale ( double  linetypeScale)
inlinevirtual
void REntityData::setLineweight ( RLineweight::Lineweight  lineweight)
inline
virtual void REntityData::setParentId ( RObject::Id  parentId)
inlinevirtual
virtual void REntityData::setSelected ( bool  on)
inlinevirtual

Selects or deselects this entity.

bool REntityData::stretch ( const RPolyline area,
const RVector offset 
)
virtual

Stretches the end points of this entity that are inside area by offset.

Reimplemented in RDimOrdinateData, RDimLinearData, and RHatchData.

virtual void REntityData::update ( ) const
inlinevirtual

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

Reimplemented in RTextBasedData, RSplineData, RDimensionData, RHatchData, and RBlockReferenceData.


Friends And Related Function Documentation

friend class REntity
friend

Member Data Documentation

RBlock::Id REntityData::blockId
protected
RColor REntityData::color
protected
RDocument* REntityData::document
protected
int REntityData::drawOrder
protected
RLayer::Id REntityData::layerId
protected
RLinetype::Id REntityData::linetypeId
protected
double REntityData::linetypeScale
protected
RLineweight::Lineweight REntityData::lineweight
protected
RObject::Id REntityData::parentId
protected
bool REntityData::selectionStatus
protected

The documentation for this class was generated from the following files: