[TD]fix 4335 section line pos on rotated base
This commit is contained in:
@@ -296,36 +296,41 @@ std::pair<Base::Vector3d, Base::Vector3d> DrawUtil::boxIntersect2d(Base::Vector3
|
||||
dir.Normalize();
|
||||
// y = mx + b
|
||||
// m = (y1 - y0) / (x1 - x0)
|
||||
if (DrawUtil::fpCompare(dir.x, 0.0) ) {
|
||||
if (DrawUtil::fpCompare(dir.x, 0.0) ) { //vertical case
|
||||
p1 = Base::Vector3d(point.x, - yRange / 2.0, 0.0);
|
||||
p2 = Base::Vector3d(point.x, yRange / 2.0, 0.0);
|
||||
} else {
|
||||
double slope = dir.y / dir.x;
|
||||
double left = -xRange / 2.0;
|
||||
double right = xRange / 2.0;
|
||||
double top = yRange / 2.0;
|
||||
double bottom = -yRange / 2.0;
|
||||
double yLeft = point.y - slope * (point.x - left) ;
|
||||
double yRight = point.y - slope * (point.x - right);
|
||||
double xTop = point.x - ( (point.y - top) / slope );
|
||||
double xBottom = point.x - ( (point.y - bottom) / slope );
|
||||
if (DrawUtil::fpCompare(slope, 0.0)) { //horizontal case
|
||||
p1 = Base::Vector3d(left, point.y);
|
||||
p2 = Base::Vector3d(right, point.y);
|
||||
} else { //normal case
|
||||
double top = yRange / 2.0;
|
||||
double bottom = -yRange / 2.0;
|
||||
double yLeft = point.y - slope * (point.x - left) ;
|
||||
double yRight = point.y - slope * (point.x - right);
|
||||
double xTop = point.x - ( (point.y - top) / slope );
|
||||
double xBottom = point.x - ( (point.y - bottom) / slope );
|
||||
|
||||
if ( (bottom < yLeft) &&
|
||||
(top > yLeft) ) {
|
||||
p1 = Base::Vector3d(left, yLeft);
|
||||
} else if (yLeft <= bottom) {
|
||||
p1 = Base::Vector3d(xBottom, bottom);
|
||||
} else if (yLeft >= top) {
|
||||
p1 = Base::Vector3d(xTop, top);
|
||||
}
|
||||
if ( (bottom < yLeft) &&
|
||||
(top > yLeft) ) {
|
||||
p1 = Base::Vector3d(left, yLeft);
|
||||
} else if (yLeft <= bottom) {
|
||||
p1 = Base::Vector3d(xBottom, bottom);
|
||||
} else if (yLeft >= top) {
|
||||
p1 = Base::Vector3d(xTop, top);
|
||||
}
|
||||
|
||||
if ( (bottom < yRight) &&
|
||||
(top > yRight) ) {
|
||||
p2 = Base::Vector3d(right, yRight);
|
||||
} else if (yRight <= bottom) {
|
||||
p2 = Base::Vector3d(xBottom, bottom);
|
||||
} else if (yRight >= top) {
|
||||
p2 = Base::Vector3d(xTop, top);
|
||||
if ( (bottom < yRight) &&
|
||||
(top > yRight) ) {
|
||||
p2 = Base::Vector3d(right, yRight);
|
||||
} else if (yRight <= bottom) {
|
||||
p2 = Base::Vector3d(xBottom, bottom);
|
||||
} else if (yRight >= top) {
|
||||
p2 = Base::Vector3d(xTop, top);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.first = p1;
|
||||
|
||||
@@ -585,6 +585,11 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap
|
||||
std::pair<Base::Vector3d, Base::Vector3d> DrawViewSection::sectionLineEnds(void)
|
||||
{
|
||||
std::pair<Base::Vector3d, Base::Vector3d> result;
|
||||
Base::Vector3d stdZ(0.0, 0.0, 1.0);
|
||||
double baseRotation = getBaseDVP()->Rotation.getValue(); //Qt degrees
|
||||
Base::Rotation rotator(stdZ, baseRotation * M_PI / 180.0);
|
||||
Base::Rotation unrotator(stdZ, - baseRotation * M_PI / 180.0);
|
||||
|
||||
auto sNorm = SectionNormal.getValue();
|
||||
double angle = M_PI / 2.0;
|
||||
auto axis = getBaseDVP()->Direction.getValue();
|
||||
@@ -605,7 +610,12 @@ std::pair<Base::Vector3d, Base::Vector3d> DrawViewSection::sectionLineEnds(void)
|
||||
xRange /= getBaseDVP()->getScale();
|
||||
double yRange = bbx.MaxY - bbx.MinY;
|
||||
yRange /= getBaseDVP()->getScale();
|
||||
sOrgOnBase = rotator.multVec(sOrgOnBase);
|
||||
sLineOnBase = rotator.multVec(sLineOnBase);
|
||||
|
||||
result = DrawUtil::boxIntersect2d(sOrgOnBase, sLineOnBase, xRange, yRange); //unscaled
|
||||
result.first = unrotator.multVec(result.first);
|
||||
result.second = unrotator.multVec(result.second);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -106,6 +106,12 @@ QColor QGIDecoration::prefSelectColor()
|
||||
return PreferencesGui::selectQColor();
|
||||
}
|
||||
|
||||
QRectF QGIDecoration::boundingRect() const
|
||||
{
|
||||
return childrenBoundingRect();
|
||||
}
|
||||
|
||||
|
||||
void QGIDecoration::makeMark(double x, double y)
|
||||
{
|
||||
QGICMark* cmItem = new QGICMark(-1);
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
enum {Type = QGraphicsItem::UserType + 173};
|
||||
int type() const { return Type;}
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
virtual void draw();
|
||||
void setWidth(double w);
|
||||
|
||||
@@ -872,7 +872,7 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
|
||||
double fontSize = Preferences::dimFontSizeMM();
|
||||
sectionLine->setFont(m_font, fontSize);
|
||||
sectionLine->setZValue(ZVALUE::SECTIONLINE);
|
||||
sectionLine->setRotation(viewPart->Rotation.getValue());
|
||||
sectionLine->setRotation(- viewPart->Rotation.getValue());
|
||||
sectionLine->draw();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user