| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include "lc_dimarrowblockpoly.h" |
| |
|
| | #include <boost/next_prior.hpp> |
| |
|
| | LC_DimArrowPoly::LC_DimArrowPoly(RS_EntityContainer* parent, const RS_Vector &pos, double angle, double size) |
| | : LC_DimArrow(parent,pos,angle,size) { |
| | } |
| |
|
| | RS_Vector LC_DimArrowPoly::getNearestEndpoint(const RS_Vector& coord, double* dist ) const { |
| | double minDist{RS_MAXDOUBLE}; |
| | double curDist{0.0}; |
| | RS_Vector ret; |
| |
|
| | for (const auto vertex : m_vertices) { |
| | curDist = vertex.distanceTo(coord); |
| | if (curDist < minDist) { |
| | ret = vertex; |
| | minDist = curDist; |
| | } |
| | } |
| |
|
| | auto pos = getPosition(); |
| | curDist = pos.distanceTo(coord); |
| | if (curDist < minDist) { |
| | ret = pos; |
| | minDist = curDist; |
| | } |
| | setDistPtr(dist, minDist); |
| | return ret; |
| | } |
| |
|
| | RS_Vector LC_DimArrowPoly::getNearestPointOnEntity(const RS_Vector& coord, bool onEntity, double* dist, |
| | [[maybe_unused]]RS_Entity** entity) const { |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | RS_Vector ret(false); |
| | double currDist {RS_MAXDOUBLE}; |
| | int next; |
| | size_t lastIndex = m_vertices.size() - 2; |
| | for (size_t i = 0; i <= lastIndex; i++) { |
| | next = i + 1; |
| | auto current = m_vertices[i]; |
| |
|
| | RS_Vector direction {m_vertices[next] - current}; |
| | RS_Vector vpc {coord-current}; |
| | double a {direction.squared()}; |
| | if( a < RS_TOLERANCE2) { |
| | |
| | vpc = current; |
| | } |
| | else{ |
| | |
| | vpc = current + direction * RS_Vector::dotP( vpc, direction) / a; |
| | } |
| | double tmpDist = vpc.distanceTo( coord); |
| | if (tmpDist < currDist) { |
| | currDist = tmpDist; |
| | ret = vpc; |
| | } |
| | } |
| | if (onEntity && !ret.isInWindowOrdered( minV, maxV)) { |
| | |
| | ret = getNearestEndpoint( coord, dist); |
| | currDist = ret.distanceTo( coord); |
| | } |
| | setDistPtr( dist, currDist); |
| | return ret; |
| | } |
| |
|
| | void LC_DimArrowPoly::positionFromZero() { |
| | RS_Vector angleVector(getAngle()); |
| | positionDimLinePointFromZero(angleVector); |
| | auto position = getPosition(); |
| | for (auto& vertex : m_vertices) { |
| | vertex.move(position); |
| | vertex.rotate(position, angleVector); |
| | } |
| |
|
| | calculateBorders(); |
| | } |
| |
|
| | void LC_DimArrowPoly::doCalculateBorders() { |
| | for (const auto vertex : m_vertices) { |
| | minV = RS_Vector::minimum(minV, vertex); |
| | maxV = RS_Vector::maximum(maxV, vertex); |
| | } |
| | } |
| |
|
| | void LC_DimArrowPoly::doMove(const RS_Vector& offset) { |
| | for (auto& vertex : m_vertices) { |
| | vertex.move(offset); |
| | } |
| | } |
| |
|
| | void LC_DimArrowPoly::doRotate(const RS_Vector& center, const RS_Vector& angleVector) { |
| | for (auto& vertex : m_vertices) { |
| | vertex.rotate(center, angleVector); |
| | } |
| | } |
| |
|
| | void LC_DimArrowPoly::doScale(const RS_Vector& center, const RS_Vector& factor) { |
| | for (auto& vertex : m_vertices) { |
| | vertex.scale(center, factor); |
| | } |
| | } |
| |
|
| | void LC_DimArrowPoly::doMirror(const RS_Vector& axisPoint1, const RS_Vector& axisPoint2) { |
| | for (auto& vertex : m_vertices) { |
| | vertex.mirror(axisPoint1, axisPoint2); |
| | } |
| | } |
| |
|