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 RLayerState RLayout RLinetype RUcs RView

Public Types

typedef int Handle
 
typedef int Id
 
enum  ObjectFlag {
  NoFlags = 0x000, Undone = 0x001, Protect = 0x002, Selected = 0x004,
  Invisible = 0x008, WorkingSet = 0x010
}
 
enum  XYZ { X, Y, Z }
 

Public Member Functions

virtual RObjectclone () const =0
 
void copyCustomPropertiesFrom (RObject *other, const QString &title=RDEFAULT_QSTRING, bool overwrite=false, const QStringList &ignoreList=RDEFAULT_QSTRINGLIST, const QString &mapKeyFrom=RDEFAULT_QSTRING, const QString &mapKeyTo=RDEFAULT_QSTRING)
 Copies all custom properties from the given object. More...
 
void dump () const
 
virtual int getComplexity () const
 
virtual bool getCustomBoolProperty (const QString &title, const QString &key, bool defaultValue) const
 
virtual double getCustomDoubleProperty (const QString &title, const QString &key, double defaultValue) const
 
virtual int getCustomIntProperty (const QString &title, const QString &key, int defaultValue) const
 
QMap< QString, QVariantMap > getCustomProperties () const
 
virtual QVariant getCustomProperty (const QString &title, const QString &key, const QVariant &defaultValue=RDEFAULT_QVARIANT) const
 
QStringList getCustomPropertyKeys (const QString &title) const
 
QStringList getCustomPropertyTitles () const
 
virtual QSet< RPropertyTypeIdgetCustomPropertyTypeIds () const
 
RDocumentgetDocument ()
 
const RDocumentgetDocument () const
 
bool getFlag (int flag) const
 
RObject::Handle getHandle () const
 
RObject::Id getId () const
 
virtual QPair< QVariant, RPropertyAttributesgetProperty (RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false, bool showOnRequest=false)
 
virtual QSet< RPropertyTypeIdgetPropertyTypeIds (RPropertyAttributes::Option option=RPropertyAttributes::NoOptions) const
 
virtual RS::EntityType getType () const =0
 
bool hasCustomProperties () const
 
bool hasCustomProperty (const QString &title, const QRegExp &key) const
 
bool hasCustomProperty (const QString &title, const QString &key) const
 
virtual bool hasPropertyType (RPropertyTypeId propertyTypeId)
 
bool isInvisible () const
 
bool isProtected () const
 
virtual bool isSelected () const
 
bool isUndone () const
 
virtual bool isWorkingSet () const
 
virtual bool mustAlwaysClone () const
 
virtual void removeCustomProperty (const QString &title, const QString &key)
 Removes the custom property with the given name. More...
 
 RObject (const RObject &other)
 
 RObject (RDocument *document=NULL)
 
virtual void setAutoUpdatesBlocked (bool on)
 
virtual void setCustomProperties (const RQMapQStringQString &properties)
 
virtual void setCustomProperty (const QString &title, const QString &key, const QVariant &value)
 Sets a custom property with the given name. More...
 
void setDocument (RDocument *document)
 
void setFlag (int flag, bool on=true)
 
void setInvisible (bool on)
 
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 setSelected (bool on)
 
virtual void setWorkingSet (bool on)
 
virtual bool validate ()
 
virtual ~RObject ()
 

Static Public Member Functions

static RPropertyAttributes getCustomPropertyAttributes (const QString &title, const QString &key)
 
static void init ()
 
static void setCustomPropertyAttributes (const QString &title, const QString &key, const RPropertyAttributes &att)
 Set attributes (read-only, invisible, ...) for the given custom property. More...
 
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-2018 by Andrew Mustun. More...
 
static RPropertyTypeId PropertyCustom
 
static RPropertyTypeId PropertyHandle
 
static RPropertyTypeId PropertyInvisible
 
static RPropertyTypeId PropertyProtected
 
static RPropertyTypeId PropertySelected
 
static RPropertyTypeId PropertyType
 
static RPropertyTypeId PropertyWorkingSet
 

Protected Member Functions

virtual void print (QDebug dbg) const
 Stream operator for QDebug. More...
 
void setHandle (RObject::Handle h)
 
void setId (RObject::Id id)
 
bool setMemberFlag (int flag, 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...
 
void setUndone (bool on)
 

Static Protected Member Functions

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 (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 (QList< double > &variable, const QVariant &value, bool condition)
 
static bool setMember (QString &variable, const QVariant &value, bool condition=true)
 Sets the given property. More...
 
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
 
Flags flags
 Object flags (undone, protected, ...) More...
 
Handle handle
 Handle of this object (from DXF / DWG). More...
 
Id objectId
 Unique ID of this object. More...
 

Static Private Attributes

static QMap< QString, QMap< QString, RPropertyAttributes > > customPropertyAttributes
 Attributes of custom properties (read-only, invisible, ...). 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:\nThis class is available in script environments.\n
Shared Pointer Support:\nObjects can be used in QSharedPointer.\n

Member Typedef Documentation

◆ Handle

typedef int RObject::Handle

◆ Id

typedef int RObject::Id

Member Enumeration Documentation

◆ ObjectFlag

Enumerator
NoFlags 
Undone 

object is undone

Protect 

object is protected

Selected 

object is selected

Invisible 

object is invisible

WorkingSet 

object is part of the current working set

◆ XYZ

Enumerator

Constructor & Destructor Documentation

◆ RObject() [1/2]

RObject::RObject ( RDocument document = NULL)

◆ RObject() [2/2]

RObject::RObject ( const RObject other)

◆ ~RObject()

RObject::~RObject ( )
virtual

Member Function Documentation

◆ clone()

◆ copyCustomPropertiesFrom()

void RObject::copyCustomPropertiesFrom ( RObject other,
const QString &  title = RDEFAULT_QSTRING,
bool  overwrite = false,
const QStringList &  ignoreList = RDEFAULT_QSTRINGLIST,
const QString &  mapKeyFrom = RDEFAULT_QSTRING,
const QString &  mapKeyTo = RDEFAULT_QSTRING 
)

Copies all custom properties from the given object.

Existing properties can be overwritten.

◆ dump()

void RObject::dump ( ) const
inline

◆ getComplexity()

virtual int RObject::getComplexity ( ) const
inlinevirtual

◆ getCustomBoolProperty()

bool RObject::getCustomBoolProperty ( const QString &  title,
const QString &  key,
bool  defaultValue 
) const
virtual

◆ getCustomDoubleProperty()

double RObject::getCustomDoubleProperty ( const QString &  title,
const QString &  key,
double  defaultValue 
) const
virtual

◆ getCustomIntProperty()

int RObject::getCustomIntProperty ( const QString &  title,
const QString &  key,
int  defaultValue 
) const
virtual

◆ getCustomProperties()

QMap< QString, QVariantMap > RObject::getCustomProperties ( ) const
Non-Scriptable:\nThis function is not available in script environments.\n
Returns
Map of custom properties assigned to this object.

◆ getCustomProperty()

QVariant RObject::getCustomProperty ( const QString &  title,
const QString &  key,
const QVariant &  defaultValue = RDEFAULT_QVARIANT 
) const
virtual
Returns
Value of given custom property or the given default value if no such property exists.

◆ getCustomPropertyAttributes()

RPropertyAttributes RObject::getCustomPropertyAttributes ( const QString &  title,
const QString &  key 
)
static
Returns
attributes (read-only, invisible, ...) for the given custom property.

◆ getCustomPropertyKeys()

QStringList RObject::getCustomPropertyKeys ( const QString &  title) const
Returns
List of custom property keys for the given title (application).

◆ getCustomPropertyTitles()

QStringList RObject::getCustomPropertyTitles ( ) const
Returns
List of custom property titles. These are typically names of applications which have assigned custom properties to this object.

◆ getCustomPropertyTypeIds()

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.

◆ getDocument() [1/2]

RDocument* RObject::getDocument ( )
inline

◆ getDocument() [2/2]

const RDocument* RObject::getDocument ( ) const
inline

◆ getFlag()

bool RObject::getFlag ( int  flag) const
inline

◆ getHandle()

RObject::Handle RObject::getHandle ( ) const
inline

◆ getId()

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.

◆ getProperty()

QPair< QVariant, RPropertyAttributes > RObject::getProperty ( RPropertyTypeId propertyTypeId,
bool  humanReadable = false,
bool  noAttributes = false,
bool  showOnRequest = false 
)
virtual

◆ getPropertyTypeIds()

QSet< RPropertyTypeId > RObject::getPropertyTypeIds ( RPropertyAttributes::Option  option = RPropertyAttributes::NoOptions) 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.

◆ getType()

virtual RS::EntityType RObject::getType ( ) const
pure virtual

◆ hasCustomProperties()

bool RObject::hasCustomProperties ( ) const

◆ hasCustomProperty() [1/2]

bool RObject::hasCustomProperty ( const QString &  title,
const QRegExp &  key 
) const
Non-Scriptable:\nThis function is not available in script environments.\n

◆ hasCustomProperty() [2/2]

bool RObject::hasCustomProperty ( const QString &  title,
const QString &  key 
) const

◆ hasPropertyType()

virtual bool RObject::hasPropertyType ( RPropertyTypeId  propertyTypeId)
inlinevirtual
Returns
True if this property owner has a property with the given ID, false otherwise.

◆ init()

void RObject::init ( )
static

◆ isInvisible()

bool RObject::isInvisible ( ) const
inline

◆ isProtected()

bool RObject::isProtected ( ) const
inline

◆ isSelected()

virtual bool RObject::isSelected ( ) const
inlinevirtual

Reimplemented in REntity.

◆ isUndone()

bool RObject::isUndone ( ) const
inline

◆ isWorkingSet()

virtual bool RObject::isWorkingSet ( ) const
inlinevirtual

◆ mustAlwaysClone()

virtual bool RObject::mustAlwaysClone ( ) const
inlinevirtual
Returns
True to always clone object instead of saving diff when object changes. This can be used for complex object types which cannot be modified using properties.

Reimplemented in RLayerState.

◆ print()

◆ removeCustomProperty()

void RObject::removeCustomProperty ( const QString &  title,
const QString &  key 
)
virtual

Removes the custom property with the given name.

◆ setAutoUpdatesBlocked()

virtual void RObject::setAutoUpdatesBlocked ( bool  on)
inlinevirtual

Reimplemented in REntity.

◆ setCustomProperties()

void RObject::setCustomProperties ( const RQMapQStringQString properties)
virtual
Non-Scriptable:\nThis function is not available in script environments.\n

◆ setCustomProperty()

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

Sets a custom property with the given name.

Reimplemented in RBlock.

◆ setCustomPropertyAttributes()

void RObject::setCustomPropertyAttributes ( const QString &  title,
const QString &  key,
const RPropertyAttributes att 
)
static

Set attributes (read-only, invisible, ...) for the given custom property.

◆ setDocument()

void RObject::setDocument ( RDocument document)

◆ setFlag()

void RObject::setFlag ( int  flag,
bool  on = true 
)
inline

◆ setHandle()

void RObject::setHandle ( RObject::Handle  h)
inlineprotected

◆ setId()

void RObject::setId ( RObject::Id  id)
inlineprotected

◆ setInvisible()

void RObject::setInvisible ( bool  on)
inline

◆ setMember() [1/6]

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:\nThis function is not available in script environments.\n

◆ setMember() [2/6]

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:\nThis function is not available in script environments.\n

◆ setMember() [3/6]

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:\nThis function is not available in script environments.\n

◆ setMember() [4/6]

bool RObject::setMember ( QList< double > &  variable,
const QVariant &  value,
bool  condition 
)
staticprotected
Non-Scriptable:\nThis function is not available in script environments.\n
Parameters
valueA list for int / double pairs: QList<QPair<int, double> >

◆ setMember() [5/6]

bool RObject::setMember ( QString &  variable,
const QVariant &  value,
bool  condition = true 
)
staticprotected

Sets the given property.

Non-Scriptable:\nThis function is not available in script environments.\n
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.

◆ setMember() [6/6]

template<class T >
static bool RObject::setMember ( T &  variable,
const QVariant &  value,
bool  condition = true 
)
inlinestatic
Non-Scriptable:\nThis function is not available in script environments.\n

◆ setMemberFlag()

bool RObject::setMemberFlag ( int  flag,
const QVariant &  value,
bool  condition = true 
)
protected

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

Non-Scriptable:\nThis function is not available in script environments.\n

◆ setMemberVector()

bool RObject::setMemberVector ( QList< RVector > &  variable,
const QVariant &  value,
RObject::XYZ  xyz 
)
staticprotected
Non-Scriptable:\nThis function is not available in script environments.\n
Parameters
valueA QList of QPairs of int and double where the int is the index and the double the value.

◆ setMemberX()

bool RObject::setMemberX ( QList< RVector > &  variable,
const QVariant &  value,
bool  condition = true 
)
staticprotected
Non-Scriptable:\nThis function is not available in script environments.\n
Parameters
valueA list of int / double pairs: QList<QPair<int, double> > representing indexes in the list and values.

◆ setMemberY()

bool RObject::setMemberY ( QList< RVector > &  variable,
const QVariant &  value,
bool  condition = true 
)
staticprotected
Non-Scriptable:\nThis function is not available in script environments.\n
Parameters
valueA list of int / double pairs: QList<QPair<int, double> > representing indexes in the list and values.

◆ setMemberZ()

bool RObject::setMemberZ ( QList< RVector > &  variable,
const QVariant &  value,
bool  condition = true 
)
staticprotected
Non-Scriptable:\nThis function is not available in script environments.\n
Parameters
valueA list of int / double pairs: QList<QPair<int, double> > representing indexes in the list and values.

◆ setProperty()

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, RLayout, RLayer, RBlock, RLinetype, RView, RDimAngular2LEntity, RDimArcLengthEntity, RAttributeEntity, RDimAngular3PEntity, RDimRotatedEntity, RPolylineEntity, RDimOrdinateEntity, RAttributeDefinitionEntity, RDimAlignedEntity, RDimDiametricEntity, RDimRadialEntity, RHatchEntity, RDimensionEntity, RSplineEntity, RDimLinearEntity, REllipseEntity, RTextBasedEntity, RArcEntity, RUcs, RImageEntity, RBlockReferenceEntity, RFaceEntity, RSolidEntity, RTraceEntity, RViewportEntity, RRayEntity, RXLineEntity, RToleranceEntity, RLineEntity, RCircleEntity, RLeaderEntity, RPointEntity, RDocumentVariables, and RLayerState.

◆ setProtected()

void RObject::setProtected ( bool  on)
inline

◆ setSelected()

virtual void RObject::setSelected ( bool  on)
inlinevirtual

Reimplemented in REntity.

◆ setUndone()

void RObject::setUndone ( bool  on)
protected

◆ setWorkingSet()

virtual void RObject::setWorkingSet ( bool  on)
inlinevirtual

◆ validate()

virtual bool RObject::validate ( )
inlinevirtual

Reimplemented in RPolylineEntity.

Friends And Related Function Documentation

◆ operator<<

QDebug operator<< ( QDebug  dbg,
const RObject o 
)
friend
Non-Scriptable:\nThis function is not available in script environments.\n

◆ RStorage

friend class RStorage
friend

Member Data Documentation

◆ customProperties

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.

◆ customPropertyAttributes

QMap< QString, QMap< QString, RPropertyAttributes > > RObject::customPropertyAttributes
staticprivate

Attributes of custom properties (read-only, invisible, ...).

◆ document

RDocument* RObject::document
private

◆ flags

Flags RObject::flags
private

Object flags (undone, protected, ...)

◆ handle

Handle RObject::handle
private

Handle of this object (from DXF / DWG).

◆ INVALID_HANDLE

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

◆ INVALID_ID

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

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

◆ objectId

Id RObject::objectId
private

Unique ID of this object.

◆ PropertyCustom

RPropertyTypeId RObject::PropertyCustom
static

◆ PropertyHandle

RPropertyTypeId RObject::PropertyHandle
static

◆ PropertyInvisible

RPropertyTypeId RObject::PropertyInvisible
static

◆ PropertyProtected

RPropertyTypeId RObject::PropertyProtected
static

◆ PropertySelected

RPropertyTypeId RObject::PropertySelected
static

◆ PropertyType

RPropertyTypeId RObject::PropertyType
static

◆ PropertyWorkingSet

RPropertyTypeId RObject::PropertyWorkingSet
static

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