X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Fentity.cpp;fp=src%2Fbase%2Fentity.cpp;h=b963731bf22d411f902d2d59b36c30a6ab4aa200;hb=16354e0421b316a62c6b9f7b0b4f3b8cf6f06284;hp=bf5be9cff0eaf6b824fcaf2cf9298756c9cc01d1;hpb=3239ef39dcee08fa6e8cd68cdf2727fc68cc7a8c;p=architektonas diff --git a/src/base/entity.cpp b/src/base/entity.cpp index bf5be9c..b963731 100644 --- a/src/base/entity.cpp +++ b/src/base/entity.cpp @@ -38,7 +38,7 @@ * 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(); @@ -47,7 +47,7 @@ RS_Entity::RS_Entity(RS_EntityContainer * parent) /** * 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; @@ -61,11 +61,11 @@ RS_Entity::RS_Entity(RS_EntityContainer * 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; } @@ -73,13 +73,13 @@ RS_Entity::~RS_Entity() /** * 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(); @@ -89,7 +89,7 @@ void RS_Entity::init() /** * Gives this entity a new unique id. */ -void RS_Entity::initId() +void Entity::initId() { static unsigned long int idCounter = 0; id = idCounter++; @@ -98,7 +98,7 @@ void RS_Entity::initId() /** * 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; @@ -112,7 +112,7 @@ void RS_Entity::resetBorders() * 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; } @@ -121,7 +121,7 @@ void RS_Entity::resetBorders() * Identify all entities as undoable entities. * @return RS2::UndoableEntity */ -/*virtual*/ RS2::UndoableType RS_Entity::undoRtti() +/*virtual*/ RS2::UndoableType Entity::undoRtti() { return RS2::UndoableEntity; } @@ -129,7 +129,7 @@ void RS_Entity::resetBorders() /** * @return Unique Id of this entity. */ -unsigned long int RS_Entity::getId() const +unsigned long int Entity::getId() const { return id; } @@ -139,7 +139,7 @@ unsigned long int RS_Entity::getId() const * 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; } @@ -148,7 +148,7 @@ unsigned long int RS_Entity::getId() const * @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; } @@ -158,7 +158,7 @@ unsigned long int RS_Entity::getId() const * * @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()) @@ -175,7 +175,7 @@ bool RS_Entity::setSelected(bool select) /** * Toggles select on this entity. */ -bool RS_Entity::toggleSelected() +bool Entity::toggleSelected() { return setSelected(!isSelected()); //toggleFlag(RS2::FlagSelected); @@ -186,7 +186,7 @@ bool RS_Entity::toggleSelected() * 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); } @@ -194,9 +194,9 @@ bool RS_Entity::isSelected() const /** * @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 { @@ -215,7 +215,7 @@ bool RS_Entity::isParentSelected() * * @param on True to set, false to reset. */ -void RS_Entity::setProcessed(bool on) +void Entity::setProcessed(bool on) { if (on) setFlag(RS2::FlagProcessed); @@ -226,7 +226,7 @@ void RS_Entity::setProcessed(bool on) /** * @return True if the processed flag is set. */ -bool RS_Entity::isProcessed() const +bool Entity::isProcessed() const { return getFlag(RS2::FlagProcessed); } @@ -237,7 +237,7 @@ bool RS_Entity::isProcessed() const * @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(); @@ -246,18 +246,18 @@ void RS_Entity::undoStateChanged(bool /*undone*/) /** * @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; @@ -276,13 +276,13 @@ bool RS_Entity::isInWindow(Vector v1, Vector v2) * @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; } @@ -294,7 +294,7 @@ bool RS_Entity::isPointOnEntity(const Vector & coord, double tolerance) * 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; @@ -302,7 +302,7 @@ bool RS_Entity::isPointOnEntity(const Vector & coord, double tolerance) if (isUndone()) return false; - /*RS_EntityCotnainer* parent = getParent(); + /*EntityCotnainer* parent = getParent(); if (parent!=NULL && parent->isUndone()) { return false; }*/ @@ -359,7 +359,7 @@ bool RS_Entity::isPointOnEntity(const Vector & coord, double tolerance) return false; } -/*virtual*/ void RS_Entity::setVisible(bool v) +/*virtual*/ void Entity::setVisible(bool v) { if (v) setFlag(RS2::FlagVisible); @@ -371,7 +371,7 @@ bool RS_Entity::isPointOnEntity(const Vector & coord, double tolerance) * 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); @@ -382,7 +382,7 @@ void RS_Entity::setHighlighted(bool on) /** * @return true if the entity is highlighted. */ -bool RS_Entity::isHighlighted() +bool Entity::isHighlighted() { return getFlag(RS2::FlagHighlighted); } @@ -390,7 +390,7 @@ bool RS_Entity::isHighlighted() /** * @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; @@ -402,7 +402,7 @@ bool RS_Entity::isLocked() * 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; } @@ -410,7 +410,7 @@ bool RS_Entity::isLocked() /** * @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; } @@ -418,7 +418,7 @@ RS_EntityContainer * RS_Entity::getParent() const /** * Reparents this entity. */ -void RS_Entity::setParent(RS_EntityContainer * p) +void Entity::setParent(EntityContainer * p) { parent = p; } @@ -428,7 +428,7 @@ void RS_Entity::setParent(RS_EntityContainer * 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; @@ -443,10 +443,10 @@ Drawing * RS_Entity::getGraphic() * 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 @@ -458,10 +458,10 @@ RS_Block * RS_Entity::getBlock() * 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 @@ -473,7 +473,7 @@ RS_Insert * RS_Entity::getInsert() * 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; @@ -489,10 +489,10 @@ RS_Entity * RS_Entity::getBlockOrInsert() * 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 @@ -504,11 +504,11 @@ RS_Document * RS_Entity::getDocument() * 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; } @@ -518,7 +518,7 @@ RS_Document * RS_Entity::getDocument() * @return minimum coordinate of the entity. * @see calculateBorders() */ -Vector RS_Entity::getMin() const +Vector Entity::getMin() const { return minV; } @@ -528,7 +528,7 @@ Vector RS_Entity::getMin() const * @return minimum coordinate of the entity. * @see calculateBorders() */ -Vector RS_Entity::getMax() const +Vector Entity::getMax() const { return maxV; } @@ -541,7 +541,7 @@ Vector RS_Entity::getMax() const * @see getMin() * @see getMax() */ -Vector RS_Entity::getSize() const +Vector Entity::getSize() const { return maxV - minV; } @@ -552,7 +552,7 @@ Vector RS_Entity::getSize() const * @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(); @@ -566,7 +566,7 @@ void RS_Entity::addGraphicVariable(const QString & key, double val, int code) * @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(); @@ -580,7 +580,7 @@ void RS_Entity::addGraphicVariable(const QString & key, int val, int code) * @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(); @@ -597,7 +597,7 @@ void RS_Entity::addGraphicVariable(const QString & key, const QString & val, int * @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; @@ -617,7 +617,7 @@ double RS_Entity::getGraphicVariableDouble(const QString & key, double 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; @@ -637,7 +637,7 @@ int RS_Entity::getGraphicVariableInt(const QString & key, int 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; @@ -652,7 +652,7 @@ QString RS_Entity::getGraphicVariableString(const QString & key, const QString & * @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; @@ -666,7 +666,7 @@ RS2::Unit RS_Entity::getGraphicUnit() /** * Must be overwritten to get all reference points of the entity. */ -/*virtual*/ VectorSolutions RS_Entity::getRefPoints() +/*virtual*/ VectorSolutions Entity::getRefPoints() { VectorSolutions ret; return ret; @@ -681,7 +681,7 @@ RS2::Unit RS_Entity::getGraphicUnit() * * @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); } @@ -697,7 +697,7 @@ RS2::Unit RS_Entity::getGraphicUnit() * * @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(); @@ -717,7 +717,7 @@ RS2::Unit RS_Entity::getGraphicUnit() * * @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); @@ -729,7 +729,7 @@ RS2::Unit RS_Entity::getGraphicUnit() * 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)); } @@ -738,7 +738,7 @@ RS2::Unit RS_Entity::getGraphicUnit() * 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; } @@ -747,7 +747,7 @@ RS2::Unit RS_Entity::getGraphicUnit() * 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; } @@ -764,7 +764,7 @@ RS2::Unit RS_Entity::getGraphicUnit() * 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) { @@ -786,7 +786,7 @@ RS_Layer * RS_Entity::getLayer(bool resolve) const /** * 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(); @@ -799,7 +799,7 @@ void RS_Entity::setLayer(const QString & name) /** * Sets the layer of this entity to the layer given. */ -void RS_Entity::setLayer(RS_Layer * l) +void Entity::setLayer(Layer * l) { layer = l; } @@ -809,7 +809,7 @@ void RS_Entity::setLayer(RS_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(); @@ -830,14 +830,14 @@ void RS_Entity::setLayerToActive() * * @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): @@ -876,7 +876,7 @@ RS_Pen RS_Entity::getPen(bool resolve) const * 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; } @@ -886,19 +886,19 @@ void RS_Entity::setPen(const RS_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(); //} } @@ -907,7 +907,7 @@ void RS_Entity::setPenToActive() * 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) @@ -919,7 +919,7 @@ void RS_Entity::stretch(Vector firstCorner, Vector secondCorner, Vector offset) * @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; @@ -938,7 +938,7 @@ double RS_Entity::getStyleFactor(GraphicView * view) { 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; } @@ -958,8 +958,8 @@ double RS_Entity::getStyleFactor(GraphicView * view) } } - //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; @@ -970,7 +970,7 @@ double RS_Entity::getStyleFactor(GraphicView * view) /** * @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)); @@ -979,7 +979,7 @@ QString * RS_Entity::getUserDefVar(QString 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)); } @@ -987,7 +987,7 @@ void RS_Entity::setUserDefVar(QString key, QString val) /** * Deletes the given user defined variable. */ -void RS_Entity::delUserDefVar(QString key) +void Entity::delUserDefVar(QString key) { varList.remove(key); } @@ -995,7 +995,7 @@ void RS_Entity::delUserDefVar(QString key) /** * @return A list of all keys connected to this entity. */ -QStringList RS_Entity::getAllKeys() +QStringList Entity::getAllKeys() { QStringList keys; // Q3DictIterator it(varList); @@ -1015,7 +1015,7 @@ QStringList RS_Entity::getAllKeys() /** * 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; @@ -1062,35 +1062,35 @@ std::ostream & operator<<(std::ostream & os, RS_Entity & e) 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: