* E.g. a line might have a graphic entity or
* a polyline entity as parent.
*/
-RS_Entity::RS_Entity(RS_EntityContainer * parent)
+Entity::Entity(EntityContainer * parent)
{
this->parent = parent;
init();
/**
* Copy constructor.
*/
-/*RS_Entity::RS_Entity(const RS_Entity& e) : RS_Flags(e.getFlags()) {
+/*Entity::Entity(const Entity& e) : Flags(e.getFlags()) {
cout << "copy constructor called\n";
init();
parent = e.parent;
/**
* Destructor.
*/
-RS_Entity::~RS_Entity()
+Entity::~Entity()
{
}
-/*virtual*/ void RS_Entity::reparent(RS_EntityContainer * parent)
+/*virtual*/ void Entity::reparent(EntityContainer * parent)
{
this->parent = parent;
}
/**
* Initialisation. Called from all constructors.
*/
-void RS_Entity::init()
+void Entity::init()
{
resetBorders();
setFlag(RS2::FlagVisible);
//layer = NULL;
- //pen = RS_Pen();
+ //pen = Pen();
updateEnabled = true;
setLayerToActive();
setPenToActive();
/**
* Gives this entity a new unique id.
*/
-void RS_Entity::initId()
+void Entity::initId()
{
static unsigned long int idCounter = 0;
id = idCounter++;
/**
* Resets the borders of this element.
*/
-void RS_Entity::resetBorders()
+void Entity::resetBorders()
{
// TODO: Check that. windoze XP crashes with MAXDOUBLE
double maxd = RS_MAXDOUBLE;
* Must be overwritten to return the rtti of this entity
* (e.g. RS2::EntityArc).
*/
-/*virtual*/ RS2::EntityType RS_Entity::rtti() const
+/*virtual*/ RS2::EntityType Entity::rtti() const
{
return RS2::EntityUnknown;
}
* Identify all entities as undoable entities.
* @return RS2::UndoableEntity
*/
-/*virtual*/ RS2::UndoableType RS_Entity::undoRtti()
+/*virtual*/ RS2::UndoableType Entity::undoRtti()
{
return RS2::UndoableEntity;
}
/**
* @return Unique Id of this entity.
*/
-unsigned long int RS_Entity::getId() const
+unsigned long int Entity::getId() const
{
return id;
}
* is a potential edge entity of a contour. By default
* this returns false.
*/
-/*virtual*/ bool RS_Entity::isEdge() const
+/*virtual*/ bool Entity::isEdge() const
{
return false;
}
* @return true for all document entities (e.g. Graphics or Blocks).
* false otherwise.
*/
-/*virtual*/ bool RS_Entity::isDocument() const
+/*virtual*/ bool Entity::isDocument() const
{
return false;
}
*
* @param select True to select, false to deselect.
*/
-bool RS_Entity::setSelected(bool select)
+bool Entity::setSelected(bool select)
{
// layer is locked:
if (select && isLocked())
/**
* Toggles select on this entity.
*/
-bool RS_Entity::toggleSelected()
+bool Entity::toggleSelected()
{
return setSelected(!isSelected());
//toggleFlag(RS2::FlagSelected);
* not be selected but one of its parents is selected. In that case
* this function returns false.
*/
-bool RS_Entity::isSelected() const
+bool Entity::isSelected() const
{
return getFlag(RS2::FlagSelected);
}
/**
* @return true if a parent entity of this entity is selected.
*/
-bool RS_Entity::isParentSelected()
+bool Entity::isParentSelected()
{
- RS_Entity * p = this;
+ Entity * p = this;
do
{
p = p->getParent();
- if (p != NULL && p->isSelected() == true)
+ if (p && p->isSelected() == true)
return true;
}
- while(p != NULL);
+ while (p);
return false;
}
*
* @param on True to set, false to reset.
*/
-void RS_Entity::setProcessed(bool on)
+void Entity::setProcessed(bool on)
{
if (on)
setFlag(RS2::FlagProcessed);
/**
* @return True if the processed flag is set.
*/
-bool RS_Entity::isProcessed() const
+bool Entity::isProcessed() const
{
return getFlag(RS2::FlagProcessed);
}
* @param undone true: entity has become invisible.
* false: entity has become visible.
*/
-void RS_Entity::undoStateChanged(bool /*undone*/)
+void Entity::undoStateChanged(bool /*undone*/)
{
setSelected(false);
update();
/**
* @return true if this entity or any parent entities are undone.
*/
-bool RS_Entity::isUndone() const
+bool Entity::isUndone() const
{
if (parent == NULL)
- return RS_Undoable::isUndone();
+ return Undoable::isUndone();
- return RS_Undoable::isUndone() || parent->isUndone();
+ return Undoable::isUndone() || parent->isUndone();
}
/**
* @return True if the entity is in the given range.
*/
-bool RS_Entity::isInWindow(Vector v1, Vector v2)
+bool Entity::isInWindow(Vector v1, Vector v2)
{
double right, left, top, bottom;
* @retval true if the given point is on this entity.
* @retval false otherwise
*/
-bool RS_Entity::isPointOnEntity(const Vector & coord, double tolerance)
+bool Entity::isPointOnEntity(const Vector & coord, double tolerance)
{
double dist = getDistanceToPoint(coord, NULL, RS2::ResolveNone);
return (dist <= tolerance);
}
-/*virtual*/ bool RS_Entity::hasEndpointsWithinWindow(Vector /*v1*/, Vector /*v2*/)
+/*virtual*/ bool Entity::hasEndpointsWithinWindow(Vector /*v1*/, Vector /*v2*/)
{
return false;
}
* The Layer might also be NULL. In that case the layer visiblity
* is ignored.
*/
-/*virtual*/ bool RS_Entity::isVisible()
+/*virtual*/ bool Entity::isVisible()
{
if (!getFlag(RS2::FlagVisible))
return false;
if (isUndone())
return false;
- /*RS_EntityCotnainer* parent = getParent();
+ /*EntityCotnainer* parent = getParent();
if (parent!=NULL && parent->isUndone()) {
return false;
}*/
return false;
}
-/*virtual*/ void RS_Entity::setVisible(bool v)
+/*virtual*/ void Entity::setVisible(bool v)
{
if (v)
setFlag(RS2::FlagVisible);
* Sets the highlight status of the entity. Highlighted entities
* usually indicate a feedback to a user action.
*/
-void RS_Entity::setHighlighted(bool on)
+void Entity::setHighlighted(bool on)
{
if (on)
setFlag(RS2::FlagHighlighted);
/**
* @return true if the entity is highlighted.
*/
-bool RS_Entity::isHighlighted()
+bool Entity::isHighlighted()
{
return getFlag(RS2::FlagHighlighted);
}
/**
* @return true if the layer this entity is on is locked.
*/
-bool RS_Entity::isLocked()
+bool Entity::isLocked()
{
if (getLayer(true) != NULL && getLayer()->isLocked())
return true;
* 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 RS_Entity::getLength()
+/*virtual*/ double Entity::getLength()
{
return -1.0;
}
/**
* @return Parent of this entity or NULL if this is a root entity.
*/
-RS_EntityContainer * RS_Entity::getParent() const
+EntityContainer * Entity::getParent() const
{
return parent;
}
/**
* Reparents this entity.
*/
-void RS_Entity::setParent(RS_EntityContainer * p)
+void Entity::setParent(EntityContainer * p)
{
parent = p;
}
* or the parent's parent graphic or NULL if none of the parents
* are stored in a graphic.
*/
-Drawing * RS_Entity::getGraphic()
+Drawing * Entity::getGraphic()
{
if (rtti() == RS2::EntityGraphic)
return (Drawing *)this;
* or the parent's parent block or NULL if none of the parents
* are stored in a block.
*/
-RS_Block * RS_Entity::getBlock()
+Block * Entity::getBlock()
{
if (rtti() == RS2::EntityBlock)
- return (RS_Block *)this;
+ return (Block *)this;
else if (parent == NULL)
return NULL;
else
* or the parent's parent block or NULL if none of the parents
* are stored in a block.
*/
-RS_Insert * RS_Entity::getInsert()
+Insert * Entity::getInsert()
{
if (rtti() == RS2::EntityInsert)
- return (RS_Insert *)this;
+ return (Insert *)this;
else if (parent == NULL)
return NULL;
else
* or the parent's parent block or insert or NULL if none of the parents
* are stored in a block or insert.
*/
-RS_Entity * RS_Entity::getBlockOrInsert()
+Entity * Entity::getBlockOrInsert()
{
if (rtti() == RS2::EntityBlock || rtti() == RS2::EntityInsert)
return this;
* are stored in a document. Note that a document is usually
* either a Graphic or a Block.
*/
-RS_Document * RS_Entity::getDocument()
+Document * Entity::getDocument()
{
if (isDocument() == true)
- return (RS_Document *)this;
+ return (Document *)this;
else if (parent == NULL)
return NULL;
else
* temporary subentities. update() is called if the entity's
* paramters or undo state changed.
*/
-/*virtual*/ void RS_Entity::update()
+/*virtual*/ void Entity::update()
{
}
-/*virtual*/ void RS_Entity::setUpdateEnabled(bool on)
+/*virtual*/ void Entity::setUpdateEnabled(bool on)
{
updateEnabled = on;
}
* @return minimum coordinate of the entity.
* @see calculateBorders()
*/
-Vector RS_Entity::getMin() const
+Vector Entity::getMin() const
{
return minV;
}
* @return minimum coordinate of the entity.
* @see calculateBorders()
*/
-Vector RS_Entity::getMax() const
+Vector Entity::getMax() const
{
return maxV;
}
* @see getMin()
* @see getMax()
*/
-Vector RS_Entity::getSize() const
+Vector Entity::getSize() const
{
return maxV - minV;
}
* @param key Variable name (e.g. "$DIMASZ")
* @param val Default value
*/
-void RS_Entity::addGraphicVariable(const QString & key, double val, int code)
+void Entity::addGraphicVariable(const QString & key, double val, int code)
{
Drawing * graphic = getGraphic();
* @param key Variable name (e.g. "$DIMASZ")
* @param val Default value
*/
-void RS_Entity::addGraphicVariable(const QString & key, int val, int code)
+void Entity::addGraphicVariable(const QString & key, int val, int code)
{
Drawing * graphic = getGraphic();
* @param key Variable name (e.g. "$DIMASZ")
* @param val Default value
*/
-void RS_Entity::addGraphicVariable(const QString & key, const QString & val, int code)
+void Entity::addGraphicVariable(const QString & key, const QString & val, int code)
{
Drawing * graphic = getGraphic();
* @return value of variable or default value if the given variable
* doesn't exist.
*/
-double RS_Entity::getGraphicVariableDouble(const QString & key, double def)
+double Entity::getGraphicVariableDouble(const QString & key, double def)
{
Drawing * graphic = getGraphic();
double ret = def;
* @return value of variable or default value if the given variable
* doesn't exist.
*/
-int RS_Entity::getGraphicVariableInt(const QString & key, int def)
+int Entity::getGraphicVariableInt(const QString & key, int def)
{
Drawing * graphic = getGraphic();
int ret = def;
* @return value of variable or default value if the given variable
* doesn't exist.
*/
-QString RS_Entity::getGraphicVariableString(const QString & key, const QString & def)
+QString Entity::getGraphicVariableString(const QString & key, const QString & def)
{
Drawing * graphic = getGraphic();
QString ret = def;
* @return The unit the parent graphic works on or None if there's no
* parent graphic.
*/
-RS2::Unit RS_Entity::getGraphicUnit()
+RS2::Unit Entity::getGraphicUnit()
{
Drawing * graphic = getGraphic();
RS2::Unit ret = RS2::None;
/**
* Must be overwritten to get all reference points of the entity.
*/
-/*virtual*/ VectorSolutions RS_Entity::getRefPoints()
+/*virtual*/ VectorSolutions Entity::getRefPoints()
{
VectorSolutions ret;
return ret;
*
* @return The point with the given distance to the start- or endpoint.
*/
-/*virtual*/ Vector RS_Entity::getNearestDist(double /*distance*/, bool /*startp*/)
+/*virtual*/ Vector Entity::getNearestDist(double /*distance*/, bool /*startp*/)
{
return Vector(false);
}
*
* @return The closest point with the given distance to the endpoint.
*/
-/*virtual*/ Vector RS_Entity::getNearestRef(const Vector & coord, double * dist/*= NULL*/)
+/*virtual*/ Vector Entity::getNearestRef(const Vector & coord, double * dist/*= NULL*/)
{
VectorSolutions s = getRefPoints();
*
* @return The closest point with the given distance to the endpoint.
*/
-/*virtual*/ Vector RS_Entity::getNearestSelectedRef(const Vector & coord, double * dist/*= NULL*/)
+/*virtual*/ Vector Entity::getNearestSelectedRef(const Vector & coord, double * dist/*= NULL*/)
{
if (isSelected())
return getNearestRef(coord, dist);
* Acts like scale(Vector) but with equal factors.
* Equal to scale(center, Vector(factor, factor)).
*/
-/*virtual*/ void RS_Entity::scale(Vector center, double 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 RS_Entity::moveRef(const Vector &/*ref*/, const Vector &/*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 RS_Entity::moveSelectedRef(const Vector &/*ref*/, const Vector &/*offset*/)
+/*virtual*/ void Entity::moveSelectedRef(const Vector &/*ref*/, const Vector &/*offset*/)
{
return;
}
* layer NULL is returned. If all parents are on layer NULL, NULL
* is returned.
*/
-RS_Layer * RS_Entity::getLayer(bool resolve) const
+Layer * Entity::getLayer(bool resolve) const
{
if (resolve)
{
/**
* Sets the layer of this entity to the layer with the given name
*/
-void RS_Entity::setLayer(const QString & name)
+void Entity::setLayer(const QString & name)
{
Drawing * graphic = getGraphic();
/**
* Sets the layer of this entity to the layer given.
*/
-void RS_Entity::setLayer(RS_Layer * l)
+void Entity::setLayer(Layer * l)
{
layer = l;
}
* 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 RS_Entity::setLayerToActive()
+void Entity::setLayerToActive()
{
Drawing * graphic = getGraphic();
*
* @return Pen for this entity.
*/
-RS_Pen RS_Entity::getPen(bool resolve) const
+Pen Entity::getPen(bool resolve) const
{
if (!resolve)
return pen;
else
{
- RS_Pen p = pen;
- RS_Layer * l = getLayer(true);
+ 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):
* Sets the explicit pen for this entity or a pen with special
* attributes such as BY_LAYER, ..
*/
-void RS_Entity::setPen(const RS_Pen & pen)
+void Entity::setPen(const Pen & pen)
{
this->pen = pen;
}
* the graphic this entity is in. If this entity (and none
* of its parents) are in a graphic the pen is not changed.
*/
-void RS_Entity::setPenToActive()
+void Entity::setPenToActive()
{
- RS_Document * doc = getDocument();
+ Document * doc = getDocument();
if (doc != NULL)
pen = doc->getActivePen();
else
{
- //RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Entity::setPenToActive(): "
+ //DEBUG->print(Debug::D_WARNING, "Entity::setPenToActive(): "
// "No document / active pen linked to this entity.");
}
//else {
- // pen = RS_Pen();
+ // pen = Pen();
//}
}
* by the given offset. This default implementation moves the
* whole entity if it is completely inside the given range.
*/
-void RS_Entity::stretch(Vector firstCorner, Vector secondCorner, Vector offset)
+void Entity::stretch(Vector firstCorner, Vector secondCorner, Vector offset)
{
//e->calculateBorders();
if (getMin().isInWindow(firstCorner, secondCorner)
* @return Factor for scaling the line styles considering the current
* paper scaling and the fact that styles are stored in Millimeter.
*/
-double RS_Entity::getStyleFactor(GraphicView * view)
+double Entity::getStyleFactor(GraphicView * view)
{
double styleFactor = 1.0;
{
unit = g->getUnit();
//double scale = g->getPaperScale();
- styleFactor = RS_Units::convert(1.0, RS2::Millimeter, unit);
+ styleFactor = Units::convert(1.0, RS2::Millimeter, unit);
// / scale;
}
}
}
- //RS_DEBUG->print("stylefactor: %f", styleFactor);
- //RS_DEBUG->print("viewfactor: %f", view->getFactor().x);
+ //DEBUG->print("stylefactor: %f", styleFactor);
+ //DEBUG->print("viewfactor: %f", view->getFactor().x);
if (styleFactor * view->getFactor().x < 0.2)
styleFactor = -1.0;
/**
* @return User defined variable connected to this entity.
*/
-QString * RS_Entity::getUserDefVar(QString key)
+QString * Entity::getUserDefVar(QString key)
{
// return (this->varList.find(key));
return (this->varList.value(key));
/**
* Add a user defined variable to this entity.
*/
-void RS_Entity::setUserDefVar(QString key, QString val)
+void Entity::setUserDefVar(QString key, QString val)
{
varList.insert(key, new QString(val));
}
/**
* Deletes the given user defined variable.
*/
-void RS_Entity::delUserDefVar(QString key)
+void Entity::delUserDefVar(QString key)
{
varList.remove(key);
}
/**
* @return A list of all keys connected to this entity.
*/
-QStringList RS_Entity::getAllKeys()
+QStringList Entity::getAllKeys()
{
QStringList keys;
// Q3DictIterator<QString> it(varList);
/**
* Dumps the elements data to stdout.
*/
-std::ostream & operator<<(std::ostream & os, RS_Entity & e)
+std::ostream & operator<<(std::ostream & os, Entity & e)
{
//os << "Warning: Virtual entity!\n";
//return os;
}
#endif
- // There should be a better way then this...
+ // There should be a better way than this...
switch (e.rtti())
{
case RS2::EntityPoint:
- os << (RS_Point &)e;
+ os << (Point &)e;
break;
case RS2::EntityLine:
- os << (RS_Line &)e;
+ os << (Line &)e;
break;
case RS2::EntityPolyline:
- os << (RS_Polyline &)e;
+ os << (Polyline &)e;
break;
case RS2::EntityArc:
- os << (RS_Arc &)e;
+ os << (Arc &)e;
break;
case RS2::EntityCircle:
- os << (RS_Circle &)e;
+ os << (Circle &)e;
break;
case RS2::EntityEllipse:
- os << (RS_Ellipse &)e;
+ os << (Ellipse &)e;
break;
case RS2::EntityInsert:
- os << (RS_Insert &)e;
+ os << (Insert &)e;
break;
case RS2::EntityText:
- os << (RS_Text &)e;
+ os << (Text &)e;
break;
default: