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

Base class for all entity classes. More...

#include <REntity.h>

Inheritance diagram for REntity:
RObject RArcEntity RBlockReferenceEntity RCircleEntity RDimensionEntity REllipseEntity RHatchEntity RImageEntity RLeaderEntity RLineEntity RPointEntity RPolylineEntity RRayEntity RSolidEntity RSplineEntity RTextBasedEntity RTraceEntity RViewportEntity RXLineEntity

List of all members.

Public Member Functions

virtual const RShapecastToConstShape () const
virtual RShapecastToShape ()
 
virtual REntityclone () const =0
void copyAttributesFrom (REntity *entity, bool copyBlockId=true)
 Copies all attributes (layer, block, color, line weight, line style) from the given entity.
void dump ()
virtual void exportEntity (RExporter &e, bool preview=false, bool forceSelected=false) const =0
 Exports the entity to the given exporter.
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) const
 
RColor getColor () const
 
RColor getColor (bool resolve, const QStack< REntity * > &blockRefStack)
 
virtual int getComplexity () const
virtual REntityDatagetData ()=0
virtual const REntityDatagetData () const =0
virtual double getDistanceTo (const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
 
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 REntity &other, bool limited=true, const RBox &queryBox=RDEFAULT_RBOX) const
 
virtual QList< RVectorgetIntersectionPoints (const RShape &shape, bool limited=true, const RBox &queryBox=RDEFAULT_RBOX) const
 
RLayer::Id getLayerId () const
 
QString getLayerName () const
 
RLinetype::Id getLinetypeId () const
 
RLinetype::Id getLinetypeId (bool resolve, const QStack< REntity * > &blockRefStack) const
 
RLinetypePattern getLinetypePattern () const
 
double getLinetypeScale () const
 
RLineweight::Lineweight getLineweight () const
 
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
 
REntity::Id getParentId () const
 
virtual RVector getPointOnEntity () const
 
virtual QList< RVectorgetPointsWithDistanceToEnd (double distance, RS::From from=RS::FromAny, const RBox &queryBox=RDEFAULT_RBOX) const
 
virtual QPair< QVariant,
RPropertyAttributes
getProperty (RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false)
virtual QList< RVectorgetReferencePoints (RS::ProjectionRenderingHint hint=RS::RenderTop) const
 
virtual QList< QSharedPointer
< RShape > > 
getShapes (const RBox &queryBox=RDEFAULT_RBOX) const
 
virtual RS::EntityType getType () const
virtual RVector getVectorTo (const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const
 
virtual bool intersectsWith (const RShape &shape) const
 
bool isEditable (bool allowInvisible=false) const
virtual bool isInside (const RBox &box) const
 
virtual bool isOnEntity (const RVector &point, bool limited=true) const
 
bool isSelected () const
 Reimplemented by entities that are part of a block reference but not stored as part of the block definition (currently only block attributes).
virtual bool isSelectedForPropertyEditing ()
bool isVisible () 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)
 Moves the given reference point to the given target point or does nothing if this entity has no reference point as the given location.
 REntity (RDocument *document, Id objectId=-1)
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)
 
void setBlockId (RBlock::Id blockId)
 
void setColor (const RColor &color)
 
void setDocument (RDocument *document)
void setDrawOrder (int drawOrder)
 Sets the draw order of this entity.
void setLayerId (RLayer::Id layerId)
 
void setLinetypeId (RLinetype::Id linetypeId)
 
void setLinetypePattern (const RLinetypePattern &linetypePattern)
 
void setLinetypeScale (double linetypeScale)
 
void setLineweight (RLineweight::Lineweight lineweight)
 
void setParentId (REntity::Id parentId)
 
virtual bool setProperty (RPropertyTypeId propertyTypeId, const QVariant &value, RTransaction *transaction=NULL)
 Sets the given property to the given value.
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.
void update () const
 Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty).
virtual ~REntity ()
- Public Member Functions inherited from RObject
QMap< QString, QVariantMap > getCustomProperties () const
QVariant getCustomProperty (const QString &title, const QString &key, const QVariant &defaultValue=RDEFAULT_QVARIANT)
QStringList getCustomPropertyKeys (const QString &title) const
QStringList getCustomPropertyTitles () const
virtual QSet< RPropertyTypeIdgetCustomPropertyTypeIds () const
RDocumentgetDocument ()
const RDocumentgetDocument () const
RObject::Handle getHandle () const
RObject::Id getId () const
virtual QSet< RPropertyTypeIdgetPropertyTypeIds () const
virtual bool hasPropertyType (RPropertyTypeId propertyTypeId)
bool isProtected () const
bool isUndone () const
void removeCustomProperty (const QString &title, const QString &key)
 Removes the custom property with the given name.
 RObject (RDocument *document=NULL, Id id=INVALID_ID)
void setCustomProperty (const QString &title, const QString &key, const QVariant &value)
 Sets a custom property with the given name.
void setProtected (bool on)
virtual void setUndone (bool on)
virtual ~RObject ()

Static Public Member Functions

static QSet< RPropertyTypeIdgetStaticPropertyTypeIds ()
static void init ()
- Static Public Member Functions inherited from RObject
template<class T >
static bool setMember (T &variable, const QVariant &value, bool condition=true)

Static Public Attributes

static RPropertyTypeId PropertyBlock
static RPropertyTypeId PropertyColor
static RPropertyTypeId PropertyCustom
 Copyright (c) 2011-2013 by Andrew Mustun.
static RPropertyTypeId PropertyDrawOrder
static RPropertyTypeId PropertyHandle
static RPropertyTypeId PropertyLayer
static RPropertyTypeId PropertyLinetype
static RPropertyTypeId PropertyLinetypeScale
static RPropertyTypeId PropertyLineweight
static RPropertyTypeId PropertyMaxX
static RPropertyTypeId PropertyMaxY
static RPropertyTypeId PropertyMinX
static RPropertyTypeId PropertyMinY
static RPropertyTypeId PropertyType
- Static Public Attributes inherited from RObject
static const Handle INVALID_HANDLE = -1
static const Id INVALID_ID = -1
 Copyright (c) 2011-2013 by Andrew Mustun.
static RPropertyTypeId PropertyProtected

Protected Member Functions

virtual void print (QDebug dbg) const
 Stream operator for QDebug.
- Protected Member Functions inherited from RObject
void setHandle (RObject::Handle h)
void setId (RObject::Id id)

Additional Inherited Members

- Public Types inherited from RObject
typedef int Handle
typedef int Id
enum  XYZ { X, Y, Z }
- Static Protected Member Functions inherited from RObject
static bool setMember (QString &variable, const QVariant &value, bool condition=true)
 Sets the given property.
static bool setMember (double &variable, const QVariant &value, bool condition=true)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
static bool setMember (int &variable, const QVariant &value, bool condition=true)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
static bool setMember (bool &variable, const QVariant &value, bool condition=true)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
static bool setMember (QList< double > &variable, const QVariant &value, bool condition)
static bool setMemberVector (QList< RVector > &variable, const QVariant &value, RObject::XYZ xyz)
static bool setMemberX (QList< RVector > &variable, const QVariant &value, bool condition=true)
static bool setMemberY (QList< RVector > &variable, const QVariant &value, bool condition=true)
static bool setMemberZ (QList< RVector > &variable, const QVariant &value, bool condition=true)

Detailed Description

Base class for all entity classes.

Entities can be exported using an implementor of the exporter interface by calling exportEntity.

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

Constructor & Destructor Documentation

REntity::REntity ( RDocument document,
Id  objectId = -1 
)
inline
REntity::~REntity ( )
virtual

Member Function Documentation

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

This function is not available in script environments.

virtual RShape* REntity::castToShape ( )
inlinevirtual

void REntity::copyAttributesFrom ( REntity entity,
bool  copyBlockId = true 
)

Copies all attributes (layer, block, color, line weight, line style) from the given entity.

void REntity::dump ( )
virtual void REntity::exportEntity ( RExporter e,
bool  preview = false,
bool  forceSelected = false 
) const
pure virtual

Exports the entity to the given exporter.

The exporter might be a file exporter, a graphics scene or any other platform one can export entities to.

Implemented in RLeaderEntity, RAttributeEntity, REllipseEntity, RDimensionEntity, RTextBasedEntity, RSplineEntity, RArcEntity, RSolidEntity, RTraceEntity, RHatchEntity, RBlockReferenceEntity, RRayEntity, RXLineEntity, RLineEntity, RPolylineEntity, RImageEntity, RCircleEntity, RViewportEntity, and RPointEntity.

virtual bool REntity::flipHorizontal ( )
inlinevirtual

virtual bool REntity::flipVertical ( )
inlinevirtual

RBlock::Id REntity::getBlockId ( ) const
inline

QString REntity::getBlockName ( ) const
inline

virtual RBox REntity::getBoundingBox ( bool  ignoreEmpty = false) const
inlinevirtual

Returns:
The bounding box that contains this entity.

virtual QList<RBox> REntity::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.

virtual QList<RVector> REntity::getCenterPoints ( const RBox queryBox = RDEFAULT_RBOX) const
inlinevirtual

Returns:
Vector of center points of this entity. Used for snap to center points.

virtual RVector REntity::getClosestPointOnEntity ( const RVector point,
double  range = RNANDOUBLE,
bool  limited = true 
) const
inlinevirtual

Returns:
Closest point to point on this entity. Used for snap to points on entity.

virtual QSharedPointer<RShape> REntity::getClosestShape ( const RVector pos,
double  range = RNANDOUBLE 
) const
inlinevirtual

Returns:
The one shape that is part of this entity which is the closest to the given position.

RColor REntity::getColor ( ) const
inline

RColor REntity::getColor ( bool  resolve,
const QStack< REntity * > &  blockRefStack 
)

virtual int REntity::getComplexity ( ) const
inlinevirtual

Reimplemented from RObject.

Reimplemented in RSplineEntity, RPolylineEntity, and RHatchEntity.

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

int REntity::getDrawOrder ( ) const
inline

Returns:
The draw order of this entity. Entities are usually drawn in ascending order of this number.

virtual QList<RVector> REntity::getEndPoints ( const RBox queryBox = RDEFAULT_RBOX) const
inlinevirtual

Returns:
Vector of end points of this entity. Used for snap to end points.

virtual QList<RVector> REntity::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().

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

QList< RVector > REntity::getIntersectionPoints ( const RShape shape,
bool  limited = true,
const RBox queryBox = RDEFAULT_RBOX 
) const
virtual

RLayer::Id REntity::getLayerId ( ) const
inline

QString REntity::getLayerName ( ) const
inline

RLinetype::Id REntity::getLinetypeId ( ) const
inline

RLinetype::Id REntity::getLinetypeId ( bool  resolve,
const QStack< REntity * > &  blockRefStack 
) const

RLinetypePattern REntity::getLinetypePattern ( ) const
inline

double REntity::getLinetypeScale ( ) const
inline

RLineweight::Lineweight REntity::getLineweight ( ) const
inline

RLineweight::Lineweight REntity::getLineweight ( bool  resolve,
const QStack< REntity * > &  blockRefStack 
) const

double REntity::getLineweightInUnits ( const QStack< REntity * > &  blockRefStack) const

virtual QList<RVector> REntity::getMiddlePoints ( const RBox queryBox = RDEFAULT_RBOX) const
inlinevirtual

Returns:
Vector of middle points of this entity. Used for snap to middle points.

REntity::Id REntity::getParentId ( ) const
inline

virtual RVector REntity::getPointOnEntity ( ) const
inlinevirtual

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

virtual QList<RVector> REntity::getPointsWithDistanceToEnd ( double  distance,
RS::From  from = RS::FromAny,
const RBox queryBox = RDEFAULT_RBOX 
) const
inlinevirtual

Returns:
Points on entity with given distance to either endpoint. Used for snap to points with distance on entity.

QPair< QVariant, RPropertyAttributes > REntity::getProperty ( RPropertyTypeId propertyTypeId,
bool  humanReadable = false,
bool  noAttributes = false 
)
virtual
virtual QList<RVector> REntity::getReferencePoints ( RS::ProjectionRenderingHint  hint = RS::RenderTop) const
inlinevirtual

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.

virtual QList<QSharedPointer<RShape> > REntity::getShapes ( const RBox queryBox = RDEFAULT_RBOX) const
inlinevirtual

Returns:
Shapes that represent the geometry of this entity.

Reimplemented in RHatchEntity, and RTextBasedEntity.

virtual RVector REntity::getVectorTo ( const RVector point,
bool  limited = true,
double  strictRange = RMAXDOUBLE 
) const
inlinevirtual

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).

virtual bool REntity::intersectsWith ( const RShape shape) const
inlinevirtual

Returns:
True if this entity intersects with the given shape, false otherwise.
Todo:
better to pass another entity data object?

bool REntity::isEditable ( bool  allowInvisible = false) const
Returns:
true if this entity can be edited (i.e. is not on a locked layer).
virtual bool REntity::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.

virtual bool REntity::isOnEntity ( const RVector point,
bool  limited = true 
) const
inlinevirtual

Returns:
True if the given point is on this entity.

bool REntity::isSelected ( ) const
inline

Reimplemented by entities that are part of a block reference but not stored as part of the block definition (currently only block attributes).

   The default implementation returns false.       
   Reimplemented by entities that do not want to be automatically painted       
   \copybrief REntityData::isSelected

Returns:
True if the entity is currently selected. This can for example influence the color in which the entity is exported.

virtual bool REntity::isSelectedForPropertyEditing ( )
inlinevirtual
Returns:
True if this object is selected for editing. This means that the properties of this object should for example be shown in a property editor.

Implements RObject.

bool REntity::isVisible ( ) const
Returns:
true if this entity is visible (i.e. is not on a frozen layer or in a frozen block).
virtual bool REntity::mirror ( const RLine axis)
inlinevirtual

virtual bool REntity::mirror ( const RVector axis1,
const RVector axis2 
)
inlinevirtual

virtual bool REntity::move ( const RVector offset)
inlinevirtual

Moves this entity by the given offset.

virtual bool REntity::moveReferencePoint ( const RVector referencePoint,
const RVector targetPoint 
)
inlinevirtual

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.

virtual bool REntity::rotate ( double  rotation,
const RVector center = RDEFAULT_RVECTOR 
)
inlinevirtual

virtual bool REntity::scale ( const RVector scaleFactors,
const RVector center = RDEFAULT_RVECTOR 
)
inlinevirtual

virtual bool REntity::scale ( double  scaleFactor,
const RVector center = RDEFAULT_RVECTOR 
)
inlinevirtual

void REntity::setBlockId ( RBlock::Id  blockId)
inline

void REntity::setColor ( const RColor color)
inline

void REntity::setDocument ( RDocument document)
inline

Reimplemented from RObject.

void REntity::setDrawOrder ( int  drawOrder)
inline

Sets the draw order of this entity.

void REntity::setLayerId ( RLayer::Id  layerId)
inline

void REntity::setLinetypeId ( RLinetype::Id  linetypeId)
inline

void REntity::setLinetypePattern ( const RLinetypePattern linetypePattern)
inline

void REntity::setLinetypeScale ( double  linetypeScale)
inline

void REntity::setLineweight ( RLineweight::Lineweight  lineweight)
inline

void REntity::setParentId ( REntity::Id  parentId)
inline

bool REntity::setProperty ( RPropertyTypeId  propertyTypeId,
const QVariant &  value,
RTransaction transaction = NULL 
)
virtual

Sets the given property to the given value.

If this property owner does not know a property with that ID, it is up to the property owner what happens. The property might be added into a list of dynamic properties or dropped.

Returns:
True if the property owner was modified in any way, false otherwise.

Reimplemented from RObject.

Reimplemented in RAttributeDefinitionEntity, RAttributeEntity, RDimAngularEntity, RDimRotatedEntity, RDimOrdinateEntity, REllipseEntity, RDimAlignedEntity, RDimDiametricEntity, RDimRadialEntity, RDimensionEntity, RTextBasedEntity, RSplineEntity, RArcEntity, RSolidEntity, RTraceEntity, RDimLinearEntity, RRayEntity, RXLineEntity, RBlockReferenceEntity, RHatchEntity, RLineEntity, RPolylineEntity, RImageEntity, RCircleEntity, RViewportEntity, RLeaderEntity, and RPointEntity.

void REntity::setSelected ( bool  on)
virtual

Selects or deselects this entity.

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

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

void REntity::update ( ) const
inline

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

Reimplemented in RBlockReferenceEntity.


Member Data Documentation

RPropertyTypeId REntity::PropertyCustom
static

Copyright (c) 2011-2013 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.

Reimplemented from RObject.

Reimplemented in RSplineEntity, RAttributeEntity, RAttributeDefinitionEntity, RDimAlignedEntity, RDimAngularEntity, RDimDiametricEntity, RDimensionEntity, RDimLinearEntity, RDimOrdinateEntity, RDimRadialEntity, RDimRotatedEntity, RPolylineEntity, RTextBasedEntity, RTextEntity, RArcEntity, REllipseEntity, RLeaderEntity, RBlockReferenceEntity, RViewportEntity, RCircleEntity, RHatchEntity, RImageEntity, RLineEntity, RPointEntity, RRayEntity, RSolidEntity, RTraceEntity, and RXLineEntity.

RPropertyTypeId REntity::PropertyMaxX
static
RPropertyTypeId REntity::PropertyMaxY
static
RPropertyTypeId REntity::PropertyMinX
static
RPropertyTypeId REntity::PropertyMinY
static

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