| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #include <iostream> |
| | #include <map> |
| | #include <utility> |
| |
|
| | #include <QPolygon> |
| | #include <QString> |
| |
|
| | #include "rs_arc.h" |
| | #include "rs_block.h" |
| | #include "rs_circle.h" |
| | #include "rs_ellipse.h" |
| | #include "rs_entity.h" |
| | #include "rs_graphic.h" |
| | #include "rs_information.h" |
| | #include "rs_insert.h" |
| | #include "rs_layer.h" |
| | #include "rs_line.h" |
| | #include "rs_math.h" |
| | #include "rs_mtext.h" |
| | #include "rs_pen.h" |
| | #include "rs_point.h" |
| | #include "rs_polyline.h" |
| | #include "rs_text.h" |
| | #include "rs_vector.h" |
| | #include "lc_quadratic.h" |
| |
|
| |
|
| | struct RS_Entity::Impl { |
| | |
| | RS_Pen pen{}; |
| | std::map<QString, QString> varList; |
| |
|
| | void fromOther(Impl* other) { |
| | if (other != nullptr) { |
| | pen = other->pen; |
| | varList = other->varList; |
| | } |
| | } |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | RS_Entity::RS_Entity(RS_EntityContainer *parent) |
| | : parent{parent} |
| | , m_pImpl{std::make_unique<Impl>()}{ |
| | init(true); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| |
|
| | RS_Entity::RS_Entity(const RS_Entity& other): |
| | parent{other.parent} |
| | , minV {other.minV} |
| | , maxV {other.maxV} |
| | , m_layer {other.m_layer} |
| | , updateEnabled {other.updateEnabled} |
| | , m_pImpl{std::make_unique<Impl>(*other.m_pImpl)}{ |
| | setFlag(RS2::FlagVisible); |
| | initId(); |
| | } |
| |
|
| | RS_Entity& RS_Entity::operator = (const RS_Entity& other){ |
| | if (this != &other) { |
| | parent = other.parent; |
| | minV = other.minV; |
| | maxV = other.maxV; |
| | m_layer = other.m_layer; |
| | updateEnabled = other.updateEnabled; |
| | m_pImpl = std::make_unique<Impl>(*other.m_pImpl); |
| | setFlag(RS2::FlagVisible); |
| | initId(); |
| | } |
| | return *this; |
| | } |
| |
|
| | RS_Entity::RS_Entity(RS_Entity&& other): |
| | parent{other.parent} |
| | , minV {other.minV} |
| | , maxV {other.maxV} |
| | , m_layer {other.m_layer} |
| | , updateEnabled {other.updateEnabled} |
| | , m_pImpl{std::move(other.m_pImpl)}{ |
| | setFlag(RS2::FlagVisible); |
| | initId(); |
| | } |
| |
|
| | RS_Entity& RS_Entity::operator = (RS_Entity&& other){ |
| | if (this != &other) { |
| | parent = other.parent; |
| | minV = other.minV; |
| | maxV = other.maxV; |
| | m_layer = other.m_layer; |
| | updateEnabled = other.updateEnabled; |
| | m_pImpl = std::move(other.m_pImpl); |
| | setFlag(RS2::FlagVisible); |
| | initId(); |
| | } |
| | return *this; |
| | } |
| |
|
| | RS_Entity::~RS_Entity() = default; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | void RS_Entity::init(bool setPenAndLayerToActive) { |
| | if (m_pImpl == nullptr) { |
| | m_pImpl = std::make_unique<Impl>(); |
| | } |
| | resetBorders(); |
| | setFlag(RS2::FlagVisible); |
| | updateEnabled = true; |
| | if (setPenAndLayerToActive) { |
| | setLayerToActive(); |
| | setPenToActive(); |
| | } |
| | initId(); |
| | } |
| |
|
| | |
| | |
| | |
| | void RS_Entity::initId() { |
| | static unsigned long long idCounter=0; |
| | m_id = ++idCounter; |
| | } |
| |
|
| | RS_Entity *RS_Entity::cloneProxy() const { |
| | return clone(); |
| | } |
| |
|
| | |
| | |
| | |
| | void RS_Entity::resetBorders() { |
| | |
| | double maxd = RS_MAXDOUBLE; |
| | double mind = RS_MINDOUBLE; |
| |
|
| | minV.set(maxd, maxd); |
| | maxV.set(mind, mind); |
| | } |
| |
|
| |
|
| | void RS_Entity::moveBorders(const RS_Vector& offset){ |
| | minV.move(offset); |
| | maxV.move(offset); |
| | } |
| |
|
| | void RS_Entity::scaleBorders(const RS_Vector& center, const RS_Vector& factor){ |
| | minV.scale(center,factor); |
| | maxV.scale(center,factor); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | bool RS_Entity::setSelected(bool select) { |
| | |
| | if (select && isLocked()) { |
| | return false; |
| | } |
| |
|
| | if (select) { |
| | setFlag(RS2::FlagSelected); |
| | } else { |
| | delFlag(RS2::FlagSelected); |
| | } |
| |
|
| | return true; |
| | } |
| |
|
| | |
| | |
| | |
| | bool RS_Entity::toggleSelected() { |
| | return setSelected(!isSelected()); |
| | |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | bool RS_Entity::isSelected() const { |
| | |
| | return getFlag(RS2::FlagSelected) && isVisible(); |
| | } |
| |
|
| | |
| | |
| | |
| | bool RS_Entity::isParentSelected() const{ |
| | RS_Entity const* p = this; |
| | while(p) { |
| | p = p->getParent(); |
| | if (p && p->isSelected()==true) { |
| | return true; |
| | } |
| | } |
| | return false; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | void RS_Entity::setProcessed(bool on) { |
| | if (on) { |
| | setFlag(RS2::FlagProcessed); |
| | } else { |
| | delFlag(RS2::FlagProcessed); |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | bool RS_Entity::isProcessed() const { |
| | return getFlag(RS2::FlagProcessed); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | void RS_Entity::undoStateChanged([[maybe_unused]] bool undone){ |
| | setSelected(false); |
| | update(); |
| | } |
| |
|
| | |
| | |
| | |
| | bool RS_Entity::isUndone() const { |
| | if (!parent) { |
| | return RS_Undoable::isUndone(); |
| | } |
| | else { |
| | return RS_Undoable::isUndone() || parent->isUndone(); |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | bool RS_Entity::isInWindow(RS_Vector v1, RS_Vector v2) const{ |
| | return |
| | RS_Math::inBetween(getMin().x, v1.x, v2.x) |
| | && RS_Math::inBetween(getMax().x, v1.x, v2.x) |
| | && RS_Math::inBetween(getMin().y, v1.y, v2.y) |
| | && RS_Math::inBetween(getMax().y, v1.y, v2.y); |
| | } |
| |
|
| | double RS_Entity::areaLineIntegral() const{ |
| | return 0.; |
| | } |
| |
|
| | bool RS_Entity::isArc() const{ |
| | switch (rtti()) { |
| | case RS2::EntityArc: |
| | case RS2::EntityCircle: |
| | |
| | case RS2::EntityEllipse: |
| | return true; |
| | default: |
| | return false; |
| | } |
| | } |
| |
|
| | bool RS_Entity::isArcCircleLine() const{ |
| | switch (rtti()) { |
| | case RS2::EntityArc: |
| | case RS2::EntityCircle: |
| | case RS2::EntityLine: |
| | case RS2::EntityPoint: |
| | return true; |
| | default: |
| | return false; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | bool RS_Entity::isPointOnEntity(const RS_Vector& coord, |
| | double tolerance) const { |
| | double dist = getDistanceToPoint(coord, nullptr, RS2::ResolveNone); |
| | return dist <= std::abs(tolerance); |
| | } |
| |
|
| | double RS_Entity::getDistanceToPoint(const RS_Vector& coord, |
| | RS_Entity** entity, |
| | RS2::ResolveLevel , |
| | double ) const{ |
| | if (entity) { |
| | *entity=const_cast<RS_Entity*>(this); |
| | } |
| | double dToEntity = RS_MAXDOUBLE; |
| | (void) getNearestPointOnEntity(coord, true, &dToEntity, entity); |
| |
|
| | |
| | if(getCenter().valid){ |
| | double dToCenter=getCenter().distanceTo(coord); |
| | return std::min(dToEntity,dToCenter); |
| | }else |
| | return dToEntity; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | bool RS_Entity::isVisible() const { |
| | if (!getFlag(RS2::FlagVisible)) { |
| | return false; |
| | } |
| |
|
| | if (isUndone()) { |
| | return false; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | if (isDocument() && (rtti() == RS2::EntityBlock || rtti() == RS2::EntityInsert)) { |
| | return true; |
| | } |
| | if (m_layer != nullptr) { |
| | return !m_layer->isFrozen(); |
| | } else { |
| | |
| | |
| | |
| | |
| | RS_Layer* resolvedLayer = getLayerResolved(); |
| | if (resolvedLayer == nullptr) { |
| | return true; |
| | } |
| | else { |
| | return !resolvedLayer ->isFrozen(); |
| | } |
| | } |
| | } |
| |
|
| | void RS_Entity::setVisible(bool v) { |
| | if (v) { |
| | setFlag(RS2::FlagVisible); |
| | } else { |
| | delFlag(RS2::FlagVisible); |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | void RS_Entity::setHighlighted(bool on) { |
| | if (on) { |
| | setFlag(RS2::FlagHighlighted); |
| | } else { |
| | delFlag(RS2::FlagHighlighted); |
| | } |
| | } |
| |
|
| | bool RS_Entity::isTransparent() const{ |
| | return getFlag(RS2::FlagTransparent); |
| | } |
| |
|
| | void RS_Entity::setTransparent(bool on) { |
| | if (on) { |
| | setFlag(RS2::FlagTransparent); |
| | } else { |
| | delFlag(RS2::FlagTransparent); |
| | } |
| | } |
| |
|
| | RS_Vector RS_Entity::getStartpoint() const { |
| | return RS_Vector{false}; |
| | } |
| |
|
| | RS_Vector RS_Entity::getEndpoint() const { |
| | return {}; |
| | } |
| |
|
| | RS_VectorSolutions RS_Entity::getTangentPoint(const RS_Vector& ) const { |
| | return {}; |
| | } |
| |
|
| | RS_Vector RS_Entity::getTangentDirection(const RS_Vector& )const{ |
| | return {}; |
| | } |
| | |
| | |
| | |
| | bool RS_Entity::isHighlighted() const{ |
| | return getFlag(RS2::FlagHighlighted); |
| | } |
| |
|
| | RS_Vector RS_Entity::getSize() const { |
| | return maxV-minV; |
| | } |
| |
|
| | |
| | |
| | |
| | bool RS_Entity::isLocked() const{ |
| | return getLayer(true) && getLayer()->isLocked(); |
| | } |
| |
|
| | RS_Vector RS_Entity::getCenter() const { |
| | return {}; |
| | } |
| |
|
| | double RS_Entity::getRadius() const { |
| | return RS_MAXDOUBLE; |
| | } |
| |
|
| | void RS_Entity::setRadius([[maybe_unused]] double r){} |
| |
|
| | |
| | |
| | |
| | |
| | |
| | RS_Graphic* RS_Entity::getGraphic() const{ |
| | if (rtti()==RS2::EntityGraphic) { |
| | auto const* ret=static_cast<RS_Graphic const*>(this); |
| | return const_cast<RS_Graphic*>(ret); |
| | } else if (!parent) { |
| | return nullptr; |
| | } |
| | return parent->getGraphic(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | RS_Block* RS_Entity::getBlock() const{ |
| | if (rtti()==RS2::EntityBlock) { |
| | RS_Block const* ret=static_cast<RS_Block const*>(this); |
| | return const_cast<RS_Block*>(ret); |
| | } else if (!parent) { |
| | return nullptr; |
| | } |
| | return parent->getBlock(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | LC_Quadratic RS_Entity::getQuadratic() const{ |
| | return LC_Quadratic{}; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | RS_Insert* RS_Entity::getInsert() const{ |
| | if (rtti()==RS2::EntityInsert) { |
| | RS_Insert const* ret=static_cast<RS_Insert const*>(this); |
| | return const_cast<RS_Insert*>(ret); |
| | } else if (!parent) { |
| | return nullptr; |
| | } else { |
| | return parent->getInsert(); |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | RS_Entity* RS_Entity::getBlockOrInsert() const{ |
| | RS_Entity* ret{nullptr}; |
| | switch(rtti()){ |
| | case RS2::EntityBlock: |
| | case RS2::EntityInsert: |
| | ret=const_cast<RS_Entity*>(this); |
| | break; |
| | default: |
| | if(parent) { |
| | return parent->getBlockOrInsert(); |
| | } |
| | } |
| | return ret; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | RS_Document* RS_Entity::getDocument() const{ |
| | if (isDocument()) { |
| | RS_Document const* ret=static_cast<RS_Document const*>(this); |
| | return const_cast<RS_Document*>(ret); |
| | } else if (!parent) { |
| | return nullptr; |
| | } |
| | return parent->getDocument(); |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | void RS_Entity::addGraphicVariable(const QString& key, double val, int code) { |
| | RS_Graphic* graphic = getGraphic(); |
| | if (graphic) { |
| | graphic->addVariable(key, val, code); |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | void RS_Entity::addGraphicVariable(const QString& key, int val, int code) { |
| | RS_Graphic* graphic = getGraphic(); |
| | if (graphic) { |
| | graphic->addVariable(key, val, code); |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | void RS_Entity::addGraphicVariable(const QString& key, |
| | const QString& val, int code) { |
| | RS_Graphic* graphic = getGraphic(); |
| | if (graphic) { |
| | graphic->addVariable(key, val, code); |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | double RS_Entity::getGraphicVariableDouble(const QString& key, double def) { |
| | RS_Graphic* graphic = getGraphic(); |
| | double ret=def; |
| | if (graphic) { |
| | ret = graphic->getVariableDouble(key, def); |
| | } |
| | return ret; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | int RS_Entity::getGraphicVariableInt(const QString& key, int def) const{ |
| | RS_Graphic* graphic = getGraphic(); |
| | int ret=def; |
| | if (graphic) { |
| | ret = graphic->getVariableInt(key, def); |
| | } |
| | return ret; |
| | } |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | QString RS_Entity::getGraphicVariableString(const QString& key, |
| | const QString& def) const |
| | { |
| | RS_Graphic* graphic = getGraphic(); |
| | QString ret=def; |
| | if (graphic) { |
| | ret = graphic->getVariableString(key, def); |
| | } |
| | return ret; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | RS2::Unit RS_Entity::getGraphicUnit() const |
| | { |
| | RS_Graphic* graphic = getGraphic(); |
| | RS2::Unit ret = RS2::None; |
| | if (graphic) { |
| | ret = graphic->getUnit(); |
| | } |
| | return ret; |
| | } |
| |
|
| | RS_Layer* RS_Entity::getLayerResolved() const { |
| | |
| | |
| | if (m_layer == nullptr ) { |
| | if (parent != nullptr) { |
| | return parent->getLayerResolved(); |
| | } else { |
| | return nullptr; |
| | } |
| | } |
| | else{ |
| | return m_layer; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | RS_Layer* RS_Entity::getLayer(bool resolve) const { |
| | if (resolve) { |
| | |
| | |
| | if (m_layer == nullptr ) { |
| | if (parent != nullptr) { |
| | return parent->getLayer(true); |
| | } else { |
| | return nullptr; |
| | } |
| | } |
| | } |
| |
|
| | |
| | return m_layer; |
| | } |
| |
|
| | |
| | |
| | |
| | void RS_Entity::setLayer(const QString& name) { |
| | RS_Graphic* graphic = getGraphic(); |
| | if (graphic) { |
| | m_layer = graphic->findLayer(name); |
| | } else { |
| | m_layer = nullptr; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | void RS_Entity::setLayer(RS_Layer* l) { |
| | m_layer = l; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | void RS_Entity::setLayerToActive() { |
| | RS_Graphic* graphic = getGraphic(); |
| |
|
| | if (graphic) { |
| | m_layer = graphic->getActiveLayer(); |
| | } else { |
| | m_layer = nullptr; |
| | } |
| | } |
| |
|
| | RS_Pen RS_Entity::getPenResolved() const { |
| | RS_Pen p = m_pImpl->pen; |
| | |
| | |
| | if (parent != nullptr && parent->rtti() != RS2::EntityGraphic) { |
| | |
| | if (!p.isValid()) { |
| | p = parent->getPen(false); |
| | } |
| | |
| | RS_EntityContainer *ep = parent; |
| | |
| | while (p.isColorByBlock()) { |
| | if (ep) { |
| | p.setColorFromPen(parent->getPen(false)); |
| | ep = ep->parent; |
| | } else |
| | break; |
| | } |
| | ep = parent; |
| | while (p.isWidthByBlock()) { |
| | if (ep) { |
| | p.setWidthFromPen(parent->getPen(false)); |
| | ep = ep->parent; |
| | } else |
| | break; |
| | } |
| | ep = parent; |
| | while (p.isLineTypeByBlock()) { |
| | if (ep) { |
| | p.setLineTypeFromPen(parent->getPen(false)); |
| | ep = ep->parent; |
| | } else |
| | break; |
| | } |
| | } |
| |
|
| | |
| | bool colorByLayer = p.isColorByLayer(); |
| | bool widthByLayer = p.isWidthByLayer(); |
| | bool lineByLayer = p.isLineTypeByLayer(); |
| | if (colorByLayer || widthByLayer || lineByLayer) { |
| | RS_Layer *l = getLayerResolved(); |
| | |
| | if (l != nullptr) { |
| | const RS_Pen &layerPen = l->getPen(); |
| | if (colorByLayer) { |
| | p.setColorFromPen(layerPen); |
| | } |
| |
|
| | |
| | if (widthByLayer) { |
| | p.setWidthFromPen(layerPen); |
| | } |
| |
|
| | |
| | if (lineByLayer) { |
| | p.setLineTypeFromPen(layerPen); |
| | } |
| | } |
| | } |
| | return p; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | RS_Pen RS_Entity::getPen(bool resolve) const { |
| | return resolve ? getPenResolved() : m_pImpl->pen; |
| | } |
| |
|
| | void RS_Entity::setPen(const RS_Pen& pen) { |
| | m_pImpl->pen = pen; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | void RS_Entity::setPenToActive() { |
| | RS_Document* doc = getDocument(); |
| | if (doc != nullptr) { |
| | m_pImpl->pen = doc->getActivePen(); |
| | } else { |
| | |
| | |
| | } |
| | |
| | |
| | |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | void RS_Entity::stretch(const RS_Vector& firstCorner, |
| | const RS_Vector& secondCorner, |
| | const RS_Vector& offset) { |
| |
|
| | |
| | if (getMin().isInWindow(firstCorner, secondCorner) && |
| | getMax().isInWindow(firstCorner, secondCorner)) { |
| |
|
| | move(offset); |
| | } |
| | } |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | QString RS_Entity::getUserDefVar(const QString& key) const { |
| | auto it=m_pImpl->varList.find(key); |
| | return (it == m_pImpl->varList.end()) ? QString{} : it->second; |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | RS_Vector RS_Entity::getNearestOrthTan(const RS_Vector& , |
| | const RS_Line& , |
| | bool ) const{ |
| | return RS_Vector(false); |
| | } |
| |
|
| |
|
| | |
| | |
| | |
| | void RS_Entity::setUserDefVar(QString key, QString val) { |
| | m_pImpl->varList.emplace(key, val); |
| | } |
| |
|
| | |
| | |
| | |
| | void RS_Entity::delUserDefVar(QString key) { |
| | m_pImpl->varList.erase(key); |
| | } |
| |
|
| | |
| | |
| | |
| | std::vector<QString> RS_Entity::getAllKeys() const{ |
| | std::vector<QString> ret; |
| | for(auto const& [key, val]: m_pImpl->varList){ |
| | ret.push_back(key); |
| | } |
| | return ret; |
| | } |
| |
|
| | |
| | bool RS_Entity::isConstruction(bool typeCheck) const{ |
| | if(typeCheck && getParent() && rtti() != RS2::EntityLine){ |
| | |
| | return false; |
| | } |
| |
|
| | |
| | if (getFlag(RS2::FlagHatchChild)){ |
| | return false; |
| | } |
| | |
| | |
| |
|
| | return (m_layer != nullptr) && m_layer->isConstruction(); |
| | } |
| |
|
| | |
| | bool RS_Entity::isPrint(void) const{ |
| | return nullptr == m_layer || m_layer->isPrint(); |
| | } |
| |
|
| | bool RS_Entity::trimmable() const{ |
| | switch(rtti()){ |
| | case RS2::EntityArc: |
| | case RS2::EntityCircle: |
| | case RS2::EntityEllipse: |
| | case RS2::EntityHyperbola: |
| | case RS2::EntityLine: |
| | case RS2::EntityParabola: |
| | case RS2::EntitySplinePoints: |
| | return true; |
| | default: |
| | return false; |
| | } |
| | } |
| |
|
| | RS_VectorSolutions RS_Entity::getRefPoints() const{ |
| | return RS_VectorSolutions(); |
| | } |
| |
|
| | RS_Vector RS_Entity::getNearestRef(const RS_Vector& coord,double* dist) const{ |
| | RS_VectorSolutions const&& s = getRefPoints(); |
| | return s.getClosest(coord, dist); |
| | } |
| |
|
| | RS_Vector RS_Entity::getNearestSelectedRef(const RS_Vector& coord, |
| | double* dist) const{ |
| | if (isSelected()) { |
| | return getNearestRef(coord, dist); |
| | } |
| | else { |
| | return RS_Vector(false); |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | std::ostream& operator << (std::ostream& os, RS_Entity& e) { |
| | |
| | |
| |
|
| | os << " {Entity id: " << e.m_id; |
| | if (e.parent) { |
| | 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.m_layer) { |
| | os << " layer: nullptr "; |
| | } else { |
| | os << " layer: " << e.m_layer->getName().toLatin1().data() << " "; |
| | os << " layer address: " << e.m_layer << " "; |
| | } |
| |
|
| | os << e.m_pImpl->pen << "\n"; |
| |
|
| | os << "variable list:\n"; |
| | for(auto const& v: e.m_pImpl->varList){ |
| | os << v.first.toLatin1().data()<< ": " |
| | << v.second.toLatin1().data() |
| | << ", "; |
| | } |
| |
|
| | |
| | switch(e.rtti()) { |
| | case RS2::EntityPoint: |
| | os << (RS_Point&)e; |
| | break; |
| |
|
| | case RS2::EntityLine: |
| | os << (RS_Line&)e; |
| | break; |
| |
|
| | case RS2::EntityPolyline: |
| | os << (RS_Polyline&)e; |
| | break; |
| |
|
| | case RS2::EntityArc: |
| | os << (RS_Arc&)e; |
| | break; |
| |
|
| | case RS2::EntityCircle: |
| | os << (RS_Circle&)e; |
| | break; |
| |
|
| | case RS2::EntityEllipse: |
| | os << (RS_Ellipse&)e; |
| | break; |
| |
|
| | case RS2::EntityInsert: |
| | os << (RS_Insert&)e; |
| | break; |
| |
|
| | case RS2::EntityMText: |
| | os << (RS_MText&)e; |
| | break; |
| |
|
| | case RS2::EntityText: |
| | os << (RS_Text&)e; |
| | break; |
| |
|
| | default: |
| | os << "Unknown Entity"; |
| | break; |
| | } |
| | os << "}\n\n"; |
| |
|
| | return os; |
| | } |
| |
|
| | bool RS_Entity::isParentIgnoredOnModifications() const { |
| | return parent != nullptr && parent->ignoredOnModification(); |
| | } |
| |
|
| |
|
| | unsigned long long RS_Entity::getId() const |
| | { |
| | return m_pImpl != nullptr ? m_id : 0ULL; |
| | } |
| |
|