QCAD
Open Source 2D CAD
RObject Class Referenceabstract

Abstract base class for all objects. More...

#include <RObject.h>

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

Public Types

typedef int Handle
 
typedef int Id
 
enum  XYZ { X, Y, Z }
 

Public Member Functions

virtual RObjectclone () const =0
 
void dump ()
 
virtual int getComplexity () const
 
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 QPair< QVariant, RPropertyAttributesgetProperty (RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false)
 
virtual QSet< RPropertyTypeIdgetPropertyTypeIds () const
 
virtual bool hasPropertyType (RPropertyTypeId propertyTypeId)
 
bool isProtected () const
 
virtual bool isSelectedForPropertyEditing ()=0
 
bool isUndone () const
 
void removeCustomProperty (const QString &title, const QString &key)
 Removes the custom property with the given name. More...
 
 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. More...
 
void setDocument (RDocument *document)
 
virtual bool setProperty (RPropertyTypeId propertyTypeId, const QVariant &value, RTransaction *transaction=NULL)
 Sets the given property to the given value. More...
 
void setProtected (bool on)
 
virtual void setUndone (bool on)
 
virtual ~RObject ()
 

Static Public Member Functions

static void init ()
 
template<class T >
static bool setMember (T &variable, const QVariant &value, bool condition=true)
 

Static Public Attributes

static const Handle INVALID_HANDLE = -1
 
static const Id INVALID_ID = -1
 Copyright (c) 2011-2015 by Andrew Mustun. More...
 
static RPropertyTypeId PropertyCustom
 
static RPropertyTypeId PropertyHandle
 
static RPropertyTypeId PropertyProtected
 

Protected Member Functions

virtual void print (QDebug dbg) const
 Stream operator for QDebug. More...
 
void setHandle (RObject::Handle h)
 
void setId (RObject::Id id)
 

Static Protected Member Functions

static bool setMember (QString &variable, const QVariant &value, bool condition=true)
 Sets the given property. More...
 
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. More...
 
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. More...
 
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. More...
 
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)
 

Private Attributes

QMap< QString, QVariantMap > customProperties
 AppID -> key -> value e.g. More...
 
RDocumentdocument
 
Handle handle
 Handle of this object (from DXF / DWG). More...
 
Id objectId
 Unique ID of this object. More...
 
bool protect
 True if this object is protected (undeletable). More...
 
bool undone
 True if this object has been undone (deleted). More...
 

Friends

QDebug operator<< (QDebug dbg, const RObject &o)
 
class RStorage
 

Detailed Description

Abstract base class for all objects.

Objects have an unique ID. Object types may register property types. Objects manage their own set of properties. Example objects are entities, layers, user coordinate systems.

See also
RPropertyTypeId
Scriptable:
This class is available in script environments.
Shared Pointer Support:
Objects can be used in QSharedPointer.

Member Typedef Documentation

typedef int RObject::Handle
typedef int RObject::Id

Constructor & Destructor Documentation

RObject::RObject ( RDocument document = NULL,
Id  id = INVALID_ID 
)
inline
virtual RObject::~RObject ( )
inlinevirtual

Member Function Documentation

void RObject::dump ( )
inline
virtual int RObject::getComplexity ( ) const
inlinevirtual
QMap< QString, QVariantMap > RObject::getCustomProperties ( ) const
Non-Scriptable:
This function is not available in script environments.
Returns
Map of custom properties assigned to this object.
QVariant RObject::getCustomProperty ( const QString &  title,
const QString &  key,
const QVariant &  defaultValue = RDEFAULT_QVARIANT 
)
Returns
Value of given custom property.
QStringList RObject::getCustomPropertyKeys ( const QString &  title) const
Returns
List of custom property keys.
QStringList RObject::getCustomPropertyTitles ( ) const
QSet< RPropertyTypeId > RObject::getCustomPropertyTypeIds ( ) const
virtual
Returns
A set of all custom property IDs of properties that are available for this object.

Reimplemented in RDocumentVariables.

RDocument* RObject::getDocument ( )
inline
const RDocument* RObject::getDocument ( ) const
inline
RObject::Handle RObject::getHandle ( ) const
inline
RObject::Id RObject::getId ( ) const
inline
Returns
The ID of the object or -1 if the object has no ID. An object without ID is not stored in the DB and not part of a document.
QPair< QVariant, RPropertyAttributes > RObject::getProperty ( RPropertyTypeId propertyTypeId,
bool  humanReadable = false,
bool  noAttributes = false 
)
virtual
QSet< RPropertyTypeId > RObject::getPropertyTypeIds ( ) const
virtual
Returns
A set of all property IDs of properties that are available for this object. The IDs that are returned can be translated into a group title and a property title using getPropertyGroupTitle and getPropertyTitle.

Reimplemented in RBlockReferenceEntity.

virtual bool RObject::hasPropertyType ( RPropertyTypeId  propertyTypeId)
inlinevirtual
Returns
True if this property owner has a property with the given ID, false otherwise.
void RObject::init ( )
static
bool RObject::isProtected ( ) const
inline
virtual bool RObject::isSelectedForPropertyEditing ( )
pure virtual
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.

Implemented in REntity, RLayer, RLinetype, RView, RBlock, RUcs, and RDocumentVariables.

bool RObject::isUndone ( ) const
inline
void RObject::removeCustomProperty ( const QString &  title,
const QString &  key 
)

Removes the custom property with the given name.

void RObject::setCustomProperty ( const QString &  title,
const QString &  key,
const QVariant &  value 
)

Sets a custom property with the given name.

void RObject::setDocument ( RDocument document)
inline
void RObject::setHandle ( RObject::Handle  h)
inlineprotected
void RObject::setId ( RObject::Id  id)
inlineprotected
template<class T >
static bool RObject::setMember ( T &  variable,
const QVariant &  value,
bool  condition = true 
)
inlinestatic
Non-Scriptable:
This function is not available in script environments.
bool RObject::setMember ( QString &  variable,
const QVariant &  value,
bool  condition = true 
)
staticprotected

Sets the given property.

Non-Scriptable:
This function is not available in script environments.
Parameters
variablea reference to the (member) variable we want to set
valuethe new value
conditionthe variable is only set to the new value if condition is true
Return values
trueif condition is true and the value was successfully converted to the same type as the variable.
bool RObject::setMember ( double &  variable,
const QVariant &  value,
bool  condition = true 
)
staticprotected

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Non-Scriptable:
This function is not available in script environments.
bool RObject::setMember ( int &  variable,
const QVariant &  value,
bool  condition = true 
)
staticprotected

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Non-Scriptable:
This function is not available in script environments.
bool RObject::setMember ( bool &  variable,
const QVariant &  value,
bool  condition = true 
)
staticprotected

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Non-Scriptable:
This function is not available in script environments.
bool RObject::setMember ( QList< double > &  variable,
const QVariant &  value,
bool  condition 
)
staticprotected
Non-Scriptable:
This function is not available in script environments.
Parameters
valueA list for int / double pairs: QList<QPair<int, double> >
bool RObject::setMemberVector ( QList< RVector > &  variable,
const QVariant &  value,
RObject::XYZ  xyz 
)
staticprotected
Non-Scriptable:
This function is not available in script environments.
Parameters
valueA QList of QPairs of int and double where the int is the index and the double the value.
bool RObject::setMemberX ( QList< RVector > &  variable,
const QVariant &  value,
bool  condition = true 
)
staticprotected
Non-Scriptable:
This function is not available in script environments.
Parameters
valueA list of int / double pairs: QList<QPair<int, double> > representing indexes in the list and values.
bool RObject::setMemberY ( QList< RVector > &  variable,
const QVariant &  value,
bool  condition = true 
)
staticprotected
Non-Scriptable:
This function is not available in script environments.
Parameters
valueA list of int / double pairs: QList<QPair<int, double> > representing indexes in the list and values.
bool RObject::setMemberZ ( QList< RVector > &  variable,
const QVariant &  value,
bool  condition = true 
)
staticprotected
Non-Scriptable:
This function is not available in script environments.
Parameters
valueA list of int / double pairs: QList<QPair<int, double> > representing indexes in the list and values.
bool RObject::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 in REntity, RLayer, RLinetype, RAttributeDefinitionEntity, RAttributeEntity, RDimAngularEntity, RView, RDimRotatedEntity, RDimAlignedEntity, RDimOrdinateEntity, REllipseEntity, RDimDiametricEntity, RBlock, RDimRadialEntity, RDimensionEntity, RArcEntity, RSplineEntity, RBlockReferenceEntity, RTextBasedEntity, RUcs, RSolidEntity, RTraceEntity, RDimLinearEntity, RPolylineEntity, RRayEntity, RXLineEntity, RHatchEntity, RLineEntity, RImageEntity, RCircleEntity, RLeaderEntity, RViewportEntity, RPointEntity, and RDocumentVariables.

void RObject::setProtected ( bool  on)
inline
void RObject::setUndone ( bool  on)
virtual

Reimplemented in RSplineEntity.

Friends And Related Function Documentation

QDebug operator<< ( QDebug  dbg,
const RObject o 
)
friend
Non-Scriptable:
This function is not available in script environments.
friend class RStorage
friend

Member Data Documentation

QMap<QString, QVariantMap> RObject::customProperties
private

AppID -> key -> value e.g.

'QCAD' -> 'wall thickness' -> 12.0; or 'SomeApplication' -> '00001_1000' -> 'SomeString' where '00001' is the position in the list of values and 1000 is the original DXF code from the file.

RDocument* RObject::document
private
Handle RObject::handle
private

Handle of this object (from DXF / DWG).

const RObject::Handle RObject::INVALID_HANDLE = -1
static
const RObject::Id RObject::INVALID_ID = -1
static

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

Id RObject::objectId
private

Unique ID of this object.

RPropertyTypeId RObject::PropertyCustom
static
RPropertyTypeId RObject::PropertyHandle
static
RPropertyTypeId RObject::PropertyProtected
static
bool RObject::protect
private

True if this object is protected (undeletable).

bool RObject::undone
private

True if this object has been undone (deleted).


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