]> Shamusworld >> Repos - architektonas/blobdiff - src/base/entity.cpp
Major refactor of Architektonas: Jettisoning old cruft.
[architektonas] / src / base / entity.cpp
diff --git a/src/base/entity.cpp b/src/base/entity.cpp
deleted file mode 100644 (file)
index aa6abb7..0000000
+++ /dev/null
@@ -1,1095 +0,0 @@
-// entity.cpp
-//
-// Part of the Architektonas Project
-// Originally part of QCad Community Edition by Andrew Mustun
-// Extensively rewritten and refactored by James L. Hammons
-// Portions copyright (C) 2001-2003 RibbonSoft
-// Copyright (C) 2010 Underground Software
-// See the README and GPLv2 files for licensing and warranty information
-//
-// JLH = James L. Hammons <jlhamm@acm.org>
-//
-// Who  When        What
-// ---  ----------  -----------------------------------------------------------
-// JLH  05/28/2010  Added this text. :-)
-//
-
-#include "entity.h"
-
-#include <iostream>
-#include "arc.h"
-#include "circle.h"
-#include "debug.h"
-#include "document.h"
-#include "ellipse.h"
-#include "drawing.h"
-#include "graphicview.h"
-#include "insert.h"
-#include "layer.h"
-#include "line.h"
-#include "point.h"
-#include "polyline.h"
-#include "text.h"
-#include "units.h"
-
-/**
- * Default constructor.
- * @param parent The parent entity of this entity.
- *               E.g. a line might have a graphic entity or
- *               a polyline entity as parent.
- */
-Entity::Entity(EntityContainer * parent)
-{
-       this->parent = parent;
-       init();
-}
-
-/**
- * Copy constructor.
- */
-/*Entity::Entity(const Entity& e) : Flags(e.getFlags()) {
-       cout << "copy constructor called\n";
-       init();
-       parent = e.parent;
-       layer = e.layer;
-       //setFlag(e.getFlags());
-    minV = e.minV;
-    maxV = e.maxV;
-    pen = e.pen;
-}*/
-
-/**
- * Destructor.
- */
-Entity::~Entity()
-{
-}
-
-/*virtual*/ void Entity::reparent(EntityContainer * parent)
-{
-       this->parent = parent;
-}
-
-/**
- * Initialisation. Called from all constructors.
- */
-void Entity::init()
-{
-       resetBorders();
-
-       setFlag(RS2::FlagVisible);
-       //layer = NULL;
-       //pen = Pen();
-       updateEnabled = true;
-       setLayerToActive();
-       setPenToActive();
-       initId();
-}
-
-/**
- * Gives this entity a new unique id.
- */
-void Entity::initId()
-{
-       static unsigned long int idCounter = 0;
-       id = idCounter++;
-}
-
-/**
- * Resets the borders of this element.
- */
-void Entity::resetBorders()
-{
-       // TODO: Check that. windoze XP crashes with MAXDOUBLE
-       double maxd = RS_MAXDOUBLE;
-       double mind = RS_MINDOUBLE;
-
-       minV.set(maxd, maxd, maxd);
-       maxV.set(mind, mind, mind);
-}
-
-/**
- * Must be overwritten to return the rtti of this entity
- * (e.g. RS2::EntityArc).
- */
-/*virtual*/ RS2::EntityType Entity::rtti() const
-{
-       return RS2::EntityUnknown;
-}
-
-/**
- * Identify all entities as undoable entities.
- * @return RS2::UndoableEntity
- */
-/*virtual*/ RS2::UndoableType Entity::undoRtti()
-{
-       return RS2::UndoableEntity;
-}
-
-/**
- * @return Unique Id of this entity.
- */
-unsigned long int Entity::getId() const
-{
-       return id;
-}
-
-/**
- * Must be overwritten to return true if an entity type
- * is a potential edge entity of a contour. By default
- * this returns false.
- */
-/*virtual*/ bool Entity::isEdge() const
-{
-       return false;
-}
-
-/**
- * @return true for all document entities (e.g. Graphics or Blocks).
- * false otherwise.
- */
-/*virtual*/ bool Entity::isDocument() const
-{
-       return false;
-}
-
-/**
- * Selects or deselects this entity.
- *
- * @param select True to select, false to deselect.
- */
-bool Entity::setSelected(bool select)
-{
-       // layer is locked:
-       if (select && isLocked())
-               return false;
-
-       if (select)
-               setFlag(RS2::FlagSelected);
-       else
-               delFlag(RS2::FlagSelected);
-
-       return true;
-}
-
-/**
- * Toggles select on this entity.
- */
-bool Entity::toggleSelected()
-{
-       return setSelected(!isSelected());
-       //toggleFlag(RS2::FlagSelected);
-}
-
-/**
- * @return True if the entity is selected. Note that an entity might
- * not be selected but one of its parents is selected. In that case
- * this function returns false.
- */
-bool Entity::isSelected() const
-{
-       return getFlag(RS2::FlagSelected);
-}
-
-/**
- * @return true if a parent entity of this entity is selected.
- */
-bool Entity::isParentSelected()
-{
-       Entity * p = this;
-
-       do
-       {
-               p = p->getParent();
-
-               if (p && p->isSelected() == true)
-                       return true;
-       }
-       while (p);
-
-       return false;
-}
-
-/**
- * Sets or resets the processed flag of this entity.
- *
- * @param on True to set, false to reset.
- */
-void Entity::setProcessed(bool on)
-{
-       if (on)
-               setFlag(RS2::FlagProcessed);
-       else
-               delFlag(RS2::FlagProcessed);
-}
-
-/**
- * @return True if the processed flag is set.
- */
-bool Entity::isProcessed() const
-{
-       return getFlag(RS2::FlagProcessed);
-}
-
-/**
- * Called when the undo state changed.
- *
- * @param undone true: entity has become invisible.
- *               false: entity has become visible.
- */
-void Entity::undoStateChanged(bool /*undone*/)
-{
-       setSelected(false);
-       update();
-}
-
-/**
- * @return true if this entity or any parent entities are undone.
- */
-bool Entity::isUndone() const
-{
-       if (parent == NULL)
-               return Undoable::isUndone();
-
-       return Undoable::isUndone() || parent->isUndone();
-}
-
-/**
- * @return True if the entity is in the given range.
- */
-bool Entity::isInWindow(Vector v1, Vector v2)
-{
-       double right, left, top, bottom;
-
-       right = std::max(v1.x, v2.x);
-       left = std::min(v1.x, v2.x);
-       top = std::max(v1.y, v2.y);
-       bottom = std::min(v1.y, v2.y);
-
-       return (getMin().x >= left && getMax().x <= right
-               && getMin().y >= bottom && getMax().y <= top);
-}
-
-/**
- * @param tolerance Tolerance.
- *
- * @retval true if the given point is on this entity.
- * @retval false otherwise
- */
-bool Entity::isPointOnEntity(const Vector & coord, double tolerance)
-{
-       double dist = getDistanceToPoint(coord, NULL, RS2::ResolveNone);
-       return (dist <= tolerance);
-}
-
-/*virtual*/ bool Entity::hasEndpointsWithinWindow(Vector /*v1*/, Vector /*v2*/)
-{
-       return false;
-}
-
-/**
- * Is this entity visible?
- *
- * @return true Only if the entity and the layer it is on are visible.
- * The Layer might also be NULL. In that case the layer visiblity
-* is ignored.
- */
-/*virtual*/ bool Entity::isVisible()
-{
-       if (!getFlag(RS2::FlagVisible))
-               return false;
-
-       if (isUndone())
-               return false;
-
-       /*EntityCotnainer* parent = getParent();
-       if (parent!=NULL && parent->isUndone()) {
-               return false;
-       }*/
-
-       if (getLayer() == NULL)
-               return true;
-
-       // inserts are usually visible - the entities in them have their own
-       //   layers which might be frozen
-       // upd: i'm not sure if that is the best behaviour
-       //if (rtti()==RS2::EntityInsert) {
-       //      return true;
-       //}
-
-       if (layer != NULL /*&& layer->getName()!="ByBlock"*/)
-       {
-               if (!layer->isFrozen())
-                       return true;
-               else
-                       return false;
-       }
-
-       if (layer == NULL /*&& getLayer()->getName()!="ByBlock"*/)
-       {
-               if (getLayer() == NULL)
-                       return true;
-               else
-               {
-                       if (!getLayer()->isFrozen())
-                               return true;
-                       else
-                               return false;
-               }
-       }
-
-       if (getBlockOrInsert() == NULL)
-               return true;
-
-       if (getBlockOrInsert()->rtti() == RS2::EntityBlock)
-       {
-               if (getLayer(false) == NULL || !getLayer(false)->isFrozen())
-                       return true;
-               else
-                       return false;
-       }
-
-
-       if (getBlockOrInsert()->getLayer() == NULL)
-               return true;
-
-       if (!getBlockOrInsert()->getLayer()->isFrozen())
-               return true;
-
-       return false;
-}
-
-/*virtual*/ void Entity::setVisible(bool v)
-{
-       if (v)
-               setFlag(RS2::FlagVisible);
-       else
-               delFlag(RS2::FlagVisible);
-}
-
-/**
- * Sets the highlight status of the entity. Highlighted entities
- * usually indicate a feedback to a user action.
- */
-void Entity::setHighlighted(bool on)
-{
-       if (on)
-               setFlag(RS2::FlagHighlighted);
-       else
-               delFlag(RS2::FlagHighlighted);
-}
-
-/**
- * @return true if the entity is highlighted.
- */
-bool Entity::isHighlighted()
-{
-       return getFlag(RS2::FlagHighlighted);
-}
-
-/**
- * @return true if the layer this entity is on is locked.
- */
-bool Entity::isLocked()
-{
-       if (getLayer(true) != NULL && getLayer()->isLocked())
-               return true;
-
-       return false;
-}
-
-/**
- * Implementations must return the total length of the entity
- * or a negative number if the entity has no length (e.g. a text or hatch).
- */
-/*virtual*/ double Entity::getLength()
-{
-       return -1.0;
-}
-
-/**
- * @return Parent of this entity or NULL if this is a root entity.
- */
-EntityContainer * Entity::getParent() const
-{
-       return parent;
-}
-
-/**
- * Reparents this entity.
- */
-void Entity::setParent(EntityContainer * p)
-{
-       parent = p;
-}
-
-/**
- * @return The parent graphic in which this entity is stored
- * or the parent's parent graphic or NULL if none of the parents
- * are stored in a graphic.
- */
-Drawing * Entity::GetDrawing()
-{
-       if (rtti() == RS2::EntityDrawing)
-               return (Drawing *)this;
-       else if (parent == NULL)
-               return NULL;
-       else
-               return parent->GetDrawing();
-}
-
-/**
- * @return The parent block in which this entity is stored
- * or the parent's parent block or NULL if none of the parents
- * are stored in a block.
- */
-Block * Entity::getBlock()
-{
-       if (rtti() == RS2::EntityBlock)
-               return (Block *)this;
-       else if (parent == NULL)
-               return NULL;
-       else
-               return parent->getBlock();
-}
-
-/**
- * @return The parent insert in which this entity is stored
- * or the parent's parent block or NULL if none of the parents
- * are stored in a block.
- */
-Insert * Entity::getInsert()
-{
-       if (rtti() == RS2::EntityInsert)
-               return (Insert *)this;
-       else if (parent == NULL)
-               return NULL;
-       else
-               return parent->getInsert();
-}
-
-/**
- * @return The parent block or insert in which this entity is stored
- * or the parent's parent block or insert or NULL if none of the parents
- * are stored in a block or insert.
- */
-Entity * Entity::getBlockOrInsert()
-{
-       if (rtti() == RS2::EntityBlock || rtti() == RS2::EntityInsert)
-               return this;
-       else if (parent == NULL)
-               return NULL;
-       else
-               return parent->getBlockOrInsert();
-}
-
-/**
- * @return The parent document in which this entity is stored
- * or the parent's parent document or NULL if none of the parents
- * are stored in a document. Note that a document is usually
- * either a Graphic or a Block.
- */
-Document * Entity::getDocument()
-{
-       if (isDocument() == true)
-               return (Document *)this;
-       else if (parent == NULL)
-               return NULL;
-       else
-               return parent->getDocument();
-}
-
-/**
- * Can be implemented by child classes to update the entities
- * temporary subentities. update() is called if the entity's
- * paramters or undo state changed.
- */
-/*virtual*/ void Entity::update()
-{
-}
-
-/*virtual*/ void Entity::setUpdateEnabled(bool on)
-{
-       updateEnabled = on;
-}
-
-/**
- * This method doesn't do any calculations.
- * @return minimum coordinate of the entity.
- * @see calculateBorders()
- */
-Vector Entity::getMin() const
-{
-       return minV;
-}
-
-/**
- * This method doesn't do any calculations.
- * @return minimum coordinate of the entity.
- * @see calculateBorders()
- */
-Vector Entity::getMax() const
-{
-       return maxV;
-}
-
-/**
- * This method returns the difference of max and min returned
- * by the above functions.
- * @return size of the entity.
- * @see calculateBorders()
- * @see getMin()
- * @see getMax()
- */
-Vector Entity::getSize() const
-{
-       return maxV - minV;
-}
-
-/**
- * Sets a variable value for the parent graphic object.
- *
- * @param key Variable name (e.g. "$DIMASZ")
- * @param val Default value
- */
-void Entity::addGraphicVariable(const QString & key, double val, int code)
-{
-       Drawing * drawing = GetDrawing();
-
-       if (drawing)
-               drawing->addVariable(key, val, code);
-}
-
-/**
- * Sets a variable value for the parent graphic object.
- *
- * @param key Variable name (e.g. "$DIMASZ")
- * @param val Default value
- */
-void Entity::addGraphicVariable(const QString & key, int val, int code)
-{
-       Drawing * drawing = GetDrawing();
-
-       if (drawing)
-               drawing->addVariable(key, val, code);
-}
-
-/**
- * Sets a variable value for the parent graphic object.
- *
- * @param key Variable name (e.g. "$DIMASZ")
- * @param val Default value
- */
-void Entity::addGraphicVariable(const QString & key, const QString & val, int code)
-{
-       Drawing * drawing = GetDrawing();
-
-       if (drawing)
-               drawing->addVariable(key, val, code);
-}
-
-/**
- * A safe member function to return the given variable.
- *
- * @param key Variable name (e.g. "$DIMASZ")
- * @param def Default value
- *
- * @return value of variable or default value if the given variable
- *    doesn't exist.
- */
-double Entity::getGraphicVariableDouble(const QString & key, double def)
-{
-       Drawing * drawing = GetDrawing();
-       double ret = def;
-
-       if (drawing)
-               ret = drawing->getVariableDouble(key, def);
-
-       return ret;
-}
-
-/**
- * A safe member function to return the given variable.
- *
- * @param key Variable name (e.g. "$DIMASZ")
- * @param def Default value
- *
- * @return value of variable or default value if the given variable
- *    doesn't exist.
- */
-int Entity::getGraphicVariableInt(const QString & key, int def)
-{
-       Drawing * drawing = GetDrawing();
-       int ret = def;
-
-       if (drawing)
-               ret = drawing->getVariableInt(key, def);
-
-       return ret;
-}
-
-/**
- * A safe member function to return the given variable.
- *
- * @param key Variable name (e.g. "$DIMASZ")
- * @param def Default value
- *
- * @return value of variable or default value if the given variable
- *    doesn't exist.
- */
-QString Entity::getGraphicVariableString(const QString & key, const QString & def)
-{
-       Drawing * drawing = GetDrawing();
-       QString ret = def;
-
-       if (drawing)
-               ret = drawing->getVariableString(key, def);
-
-       return ret;
-}
-
-/**
- * @return The unit the parent graphic works on or None if there's no
- * parent graphic.
- */
-RS2::Unit Entity::getGraphicUnit()
-{
-       Drawing * drawing = GetDrawing();
-       RS2::Unit ret = RS2::None;
-
-       if (drawing)
-               ret = drawing->getUnit();
-
-       return ret;
-}
-
-/**
- * Must be overwritten to get all reference points of the entity.
- */
-/*virtual*/ VectorSolutions Entity::getRefPoints()
-{
-       return VectorSolutions();
-}
-
-/**
- * Must be overwritten to get the point with a given
- * distance to the start- or endpoint to the given coordinate for this entity.
- *
- * @param distance Distance to endpoint.
- * @param startp true = measured from Startpoint, false = measured from Endpoint
- *
- * @return The point with the given distance to the start- or endpoint.
- */
-/*virtual*/ Vector Entity::getNearestDist(double /*distance*/, bool /*startp*/)
-{
-       return Vector(false);
-}
-
-/**
- * Must be overwritten to get the nearest reference point for this entity.
- *
- * @param coord Coordinate (typically a mouse coordinate)
- * @param dist Pointer to a value which will contain the measured
- * distance between 'coord' and the closest point. The passed
- * pointer can also be NULL in which case the distance will be
- * lost.
- *
- * @return The closest point with the given distance to the endpoint.
- */
-/*virtual*/ Vector Entity::getNearestRef(const Vector & coord, double * dist/*= NULL*/)
-{
-       VectorSolutions s = getRefPoints();
-
-       return s.getClosest(coord, dist);
-}
-
-/**
- * Gets the nearest reference point of this entity if it is selected.
- * Containers re-implement this method to return the nearest reference
- * point of a selected sub entity.
- *
- * @param coord Coordinate (typically a mouse coordinate)
- * @param dist Pointer to a value which will contain the measured
- * distance between 'coord' and the closest point. The passed
- * pointer can also be NULL in which case the distance will be
- * lost.
- *
- * @return The closest point with the given distance to the endpoint.
- */
-/*virtual*/ Vector Entity::getNearestSelectedRef(const Vector & coord, double * dist/*= NULL*/)
-{
-       if (isSelected())
-               return getNearestRef(coord, dist);
-
-       return Vector(false);
-}
-
-/**
- * Acts like scale(Vector) but with equal factors.
- * Equal to scale(center, Vector(factor, factor)).
- */
-/*virtual*/ void Entity::scale(Vector center, double factor)
-{
-       scale(center, Vector(factor, factor));
-}
-
-/**
- * Implementations must drag the reference point(s) of all
- * (sub-)entities that are very close to ref by offset.
- */
-/*virtual*/ void Entity::moveRef(const Vector &/*ref*/, const Vector &/*offset*/)
-{
-       return;
-}
-
-/**
- * Implementations must drag the reference point(s) of selected
- * (sub-)entities that are very close to ref by offset.
- */
-/*virtual*/ void Entity::moveSelectedRef(const Vector &/*ref*/, const Vector &/*offset*/)
-{
-       return;
-}
-
-/**
- * Returns a pointer to the layer this entity is on or NULL.
- *
- * @para resolve true: if the layer is ByBlock, the layer of the
- *               block this entity is in is returned.
- *               false: the layer of the entity is returned.
- *
- * @return pointer to the layer this entity is on. If the layer
- * is set to NULL the layer of the next parent that is not on
- * layer NULL is returned. If all parents are on layer NULL, NULL
- * is returned.
- */
-Layer * Entity::getLayer(bool resolve) const
-{
-       if (resolve)
-       {
-               // we have no layer but a parent that might have one.
-               // return parent's layer instead:
-               if (layer == NULL /*|| layer->getName()=="ByBlock"*/)
-               {
-                       if (parent != NULL)
-                               return parent->getLayer(true);
-                       else
-                               return NULL;
-               }
-       }
-
-       // return our layer. might still be NULL:
-       return layer;
-}
-
-/**
- * Sets the layer of this entity to the layer with the given name
- */
-void Entity::setLayer(const QString & name)
-{
-       Drawing * drawing = GetDrawing();
-       layer = (drawing ? drawing->findLayer(name) : NULL);
-}
-
-/**
- * Sets the layer of this entity to the layer given.
- */
-void Entity::setLayer(Layer * l)
-{
-    layer = l;
-}
-
-/**
- * Sets the layer of this entity to the current layer of
- * the graphic this entity is in. If this entity (and none
- * of its parents) are in a graphic the layer is set to NULL.
- */
-void Entity::setLayerToActive()
-{
-       Drawing * drawing = GetDrawing();
-       layer = (drawing ? drawing->getActiveLayer() : NULL);
-}
-
-/**
- * Gets the pen needed to draw this entity.
- * The attributes can also come from the layer this entity is on
- * if the flags are set accordingly.
- *
- * @param resolve true: Resolve the pen to a drawable pen (e.g. the pen
- *         from the layer or parent..)
- *         false: Don't resolve and return a pen or ByLayer, ByBlock, ...
- *
- * @return Pen for this entity.
- */
-Pen Entity::getPen(bool resolve) const
-{
-       if (!resolve)
-               return pen;
-       else
-       {
-               Pen p = pen;
-               Layer * l = getLayer(true);
-
-               // use parental attributes (e.g. vertex of a polyline, block
-               // entities when they are drawn in block documents):
-               if (!p.isValid() || p.getColor().isByBlock())
-               {
-                       if (parent != NULL)
-                               p = parent->getPen();
-               }
-               // use layer attributes:
-               else if (l != NULL)
-               {
-                       // layer is "ByBlock":
-                       /*if (layer->getName()=="ByBlock" && getBlockOrInsert()!=NULL) {
-                               p = getBlockOrInsert()->getPen();
-               } else {*/
-
-                       // use layer's color:
-                       if (p.getColor().isByLayer())
-                               p.setColor(l->getPen().getColor());
-
-                       // use layer's width:
-                       if (p.getWidth() == RS2::WidthByLayer)
-                               p.setWidth(l->getPen().getWidth());
-
-                       // use layer's linetype:
-                       if (p.getLineType() == RS2::LineByLayer)
-                               p.setLineType(l->getPen().getLineType());
-                       //}
-               }
-
-               return p;
-       }
-}
-
-/**
- * Sets the explicit pen for this entity or a pen with special
- * attributes such as BY_LAYER, ..
- */
-void Entity::setPen(const Pen & pen)
-{
-       this->pen = pen;
-}
-
-/**
- * Sets the pen of this entity to the current pen of
- * the graphic this entity is in. If this entity (and none
- * of its parents) are in a graphic the pen is not changed.
- */
-void Entity::setPenToActive()
-{
-       Document * doc = getDocument();
-
-       if (doc != NULL)
-               pen = doc->getActivePen();
-       else
-       {
-               //DEBUG->print(Debug::D_WARNING, "Entity::setPenToActive(): "
-               //                "No document / active pen linked to this entity.");
-       }
-       //else {
-       //   pen = Pen();
-       //}
-}
-
-/**
- * Implementations must stretch the given range of the entity
- * by the given offset. This default implementation moves the
- * whole entity if it is completely inside the given range.
- */
-void Entity::stretch(Vector firstCorner, Vector secondCorner, Vector offset)
-{
-       //e->calculateBorders();
-       if (getMin().isInWindow(firstCorner, secondCorner)
-               && getMax().isInWindow(firstCorner, secondCorner))
-               move(offset);
-}
-
-/**
- * @return Factor for scaling the line styles considering the current
- * paper scaling and the fact that styles are stored in Millimeter.
- */
-double Entity::getStyleFactor(GraphicView * view)
-{
-       double styleFactor = 1.0;
-
-       if (view != NULL)
-       {
-               if (view->isPrinting() == false && view->isDraftMode())
-                       styleFactor = 1.0 / view->getFactor().x;
-               else
-               {
-                       //styleFactor = getStyleFactor();
-                       // the factor caused by the unit:
-                       RS2::Unit unit = RS2::None;
-                       Drawing * d = GetDrawing();
-
-                       if (d)
-                       {
-                               unit = d->getUnit();
-                               //double scale = d->getPaperScale();
-                               styleFactor = Units::convert(1.0, RS2::Millimeter, unit);
-                               // / scale;
-                       }
-
-                       // the factor caused by the line width:
-                       if (((int)getPen(true).getWidth()) > 0)
-                               styleFactor *= ((double)getPen(true).getWidth() / 100.0);
-                       else if (((int)getPen(true).getWidth()) == 0)
-                               styleFactor *= 0.01;
-               }
-
-               if (view->isPrinting() || view->isPrintPreview() || view->isDraftMode() == false)
-               {
-                       Drawing * drawing = GetDrawing();
-
-                       if (drawing && drawing->getPaperScale() > 1.0e-6)
-                               styleFactor /= drawing->getPaperScale();
-               }
-       }
-
-       //DEBUG->print("stylefactor: %f", styleFactor);
-       //DEBUG->print("viewfactor: %f", view->getFactor().x);
-
-       if (styleFactor * view->getFactor().x < 0.2)
-               styleFactor = -1.0;
-
-       return styleFactor;
-}
-
-/**
- * @return User defined variable connected to this entity.
- */
-QString * Entity::getUserDefVar(QString key)
-{
-//     return (this->varList.find(key));
-       return (this->varList.value(key));
-}
-
-/**
- * Add a user defined variable to this entity.
- */
-void Entity::setUserDefVar(QString key, QString val)
-{
-       varList.insert(key, new QString(val));
-}
-
-/**
- * Deletes the given user defined variable.
- */
-void Entity::delUserDefVar(QString key)
-{
-       varList.remove(key);
-}
-
-/**
- * @return A list of all keys connected to this entity.
- */
-QStringList Entity::getAllKeys()
-{
-       QStringList keys;
-//     Q3DictIterator<QString> it(varList);
-       QHashIterator<QString, QString *> it(varList);
-
-//     for(; it.current(); ++it)
-//             keys.append(it.currentKey());
-       while (it.hasNext())
-       {
-               it.next();
-               keys.append(it.key());
-       }
-
-       return keys;
-}
-
-/**
- * Dumps the elements data to stdout.
- */
-std::ostream & operator<<(std::ostream & os, Entity & e)
-{
-       //os << "Warning: Virtual entity!\n";
-       //return os;
-
-       os << " {Entity id: " << e.id;
-
-       if (e.parent !=  NULL)
-               os << " | parent id: " << e.parent->getId() << "\n";
-       else
-               os << " | no parent\n";
-
-       os << " flags: " << (e.getFlag(RS2::FlagVisible) ? "RS2::FlagVisible" : "");
-       os << (e.getFlag(RS2::FlagUndone) ? " RS2::FlagUndone" : "");
-       os << (e.getFlag(RS2::FlagSelected) ? " RS2::FlagSelected" : "");
-       os << "\n";
-
-       if (e.layer == NULL)
-               os << " layer: NULL ";
-       else
-               os << " layer: " << e.layer->getName().toLatin1().data() << " "
-                       << " layer address: " << (int)(e.layer) << " ";
-
-       os << e.pen << "\n";
-
-       os << "variable list:\n";
-//     Q3DictIterator<QString> it(e.varList); // See QDictIterator
-       QHashIterator<QString, QString *> it(e.varList);
-
-#if 0
-       for( ; it.current(); ++it )
-       {
-#warning "Removed output (Qt3 style iterator)... !!! FIX !!!"
-//        os << it.currentKey() << ": " << *it.current() << ", ";
-       }
-#else
-       while (it.hasNext())
-       {
-               it.next();
-               os << (it.key()).toAscii().data() << ": " << (*it.value()).toAscii().data() << ", ";
-       }
-#endif
-
-       // There should be a better way than this...
-       switch (e.rtti())
-       {
-       case RS2::EntityPoint:
-               os << (Point &)e;
-               break;
-
-       case RS2::EntityLine:
-               os << (Line &)e;
-               break;
-
-       case RS2::EntityPolyline:
-               os << (Polyline &)e;
-               break;
-
-       case RS2::EntityArc:
-               os << (Arc &)e;
-               break;
-
-       case RS2::EntityCircle:
-               os << (Circle &)e;
-               break;
-
-       case RS2::EntityEllipse:
-               os << (Ellipse &)e;
-               break;
-
-       case RS2::EntityInsert:
-               os << (Insert &)e;
-               break;
-
-       case RS2::EntityText:
-               os << (Text &)e;
-               break;
-
-       default:
-               os << "Unknown Entity";
-               break;
-       }
-
-       os << "}\n\n";
-
-       return os;
-}