Fix overlap of line ends and arrowheads
This commit is contained in:
@@ -78,39 +78,35 @@ void QGISectionLine::draw()
|
||||
void QGISectionLine::makeLine()
|
||||
{
|
||||
QPainterPath pp;
|
||||
QPointF beginExtLineStart,beginExtLineEnd; //ext line start pts for measure Start side and measure End side
|
||||
QPointF endExtLineStart, endExtLineEnd;
|
||||
QPointF offset(m_arrowDir.x,-m_arrowDir.y);
|
||||
double arrowLen2 = 2.0 * Rez::guiX(QGIArrow::getPrefArrowSize());
|
||||
QPointF beginExtLine1,beginExtLine2; //ext line start pts for measure Start side and measure End side
|
||||
QPointF endExtLine1, endExtLine2;
|
||||
QPointF offsetDir(m_arrowDir.x,-m_arrowDir.y);
|
||||
int format = getPrefSectionFormat();
|
||||
if (format == 0) { //"ASME"
|
||||
//draw from section line endpoint to just short of arrow tip
|
||||
QPointF offsetBegin = m_extLen * offset;
|
||||
beginExtLineStart = m_start;
|
||||
beginExtLineEnd = m_end;
|
||||
endExtLineStart = m_start + offsetBegin;
|
||||
endExtLineEnd = m_end + offsetBegin;
|
||||
pp.moveTo(beginExtLineStart);
|
||||
pp.lineTo(endExtLineStart);
|
||||
pp.moveTo(beginExtLineEnd);
|
||||
pp.lineTo(endExtLineEnd);
|
||||
//draw from section line endpoint
|
||||
QPointF offsetBegin = m_extLen * offsetDir;
|
||||
beginExtLine1 = m_start; //from
|
||||
beginExtLine2 = m_end; //to
|
||||
endExtLine1 = m_start + offsetBegin;
|
||||
endExtLine2 = m_end + offsetBegin;
|
||||
pp.moveTo(beginExtLine1);
|
||||
pp.lineTo(endExtLine1);
|
||||
pp.moveTo(beginExtLine2);
|
||||
pp.lineTo(endExtLine2);
|
||||
} else { //"ISO"
|
||||
//draw from extension line end to just short of section line
|
||||
QPointF offsetBegin = arrowLen2 * offset;
|
||||
QPointF offsetEnd = (arrowLen2 - m_extLen) * offset;
|
||||
beginExtLineStart = m_start - offsetBegin;
|
||||
beginExtLineEnd = m_end - offsetBegin;
|
||||
endExtLineStart = m_start - offsetEnd;
|
||||
endExtLineEnd = m_end - offsetEnd;
|
||||
pp.moveTo(beginExtLineStart);
|
||||
pp.lineTo(endExtLineStart);
|
||||
pp.moveTo(beginExtLineEnd);
|
||||
pp.lineTo(endExtLineEnd);
|
||||
//draw from just short of section line away from section line
|
||||
QPointF offsetBegin = Rez::guiX(QGIArrow::getOverlapAdjust(0,QGIArrow::getPrefArrowSize())) * offsetDir;
|
||||
QPointF offsetEnd = offsetBegin + (m_extLen * offsetDir);
|
||||
beginExtLine1 = m_start - offsetBegin;
|
||||
beginExtLine2 = m_end - offsetBegin;
|
||||
endExtLine1 = m_start - offsetEnd;
|
||||
endExtLine2 = m_end - offsetEnd;
|
||||
pp.moveTo(beginExtLine1);
|
||||
pp.lineTo(endExtLine1);
|
||||
pp.moveTo(beginExtLine2);
|
||||
pp.lineTo(endExtLine2);
|
||||
}
|
||||
|
||||
// pp.moveTo(beginExtLineStart);
|
||||
// pp.lineTo(m_start); //arrow line
|
||||
// pp.moveTo(beginExtLineEnd);
|
||||
pp.moveTo(m_end);
|
||||
pp.lineTo(m_start); //sectionLine
|
||||
m_line->setPath(pp);
|
||||
@@ -125,6 +121,7 @@ void QGISectionLine::makeArrows()
|
||||
makeArrowsISO();
|
||||
}
|
||||
}
|
||||
|
||||
//make Euro (ISO) Arrows
|
||||
void QGISectionLine::makeArrowsISO()
|
||||
{
|
||||
@@ -136,12 +133,6 @@ void QGISectionLine::makeArrowsISO()
|
||||
}
|
||||
arrowRotation = 360.0 - angle * (180.0/M_PI); //convert to Qt rotation (clockwise degrees)
|
||||
|
||||
QPointF extLineStart,extLineEnd;
|
||||
QPointF offset(m_arrowDir.x,-m_arrowDir.y); //remember Y dir is flipped
|
||||
offset = (m_extLen + (2.0 * QGIArrow::getPrefArrowSize())) * offset * -1.0;
|
||||
extLineStart = m_start + offset;
|
||||
extLineEnd = m_end + offset;
|
||||
|
||||
m_arrow1->setStyle(0);
|
||||
m_arrow1->setSize(QGIArrow::getPrefArrowSize());
|
||||
m_arrow1->setPos(m_start);
|
||||
@@ -166,21 +157,22 @@ void QGISectionLine::makeArrowsTrad()
|
||||
}
|
||||
arrowRotation = 360.0 - angle * (180.0/M_PI); //convert to Qt rotation (clockwise degrees)
|
||||
|
||||
QPointF extLineStart,extLineEnd;
|
||||
QPointF offset(m_arrowDir.x,-m_arrowDir.y); //remember Y dir is flipped
|
||||
offset = (m_extLen + (2.0 * QGIArrow::getPrefArrowSize())) * offset;
|
||||
extLineStart = m_start + offset;
|
||||
extLineEnd = m_end + offset;
|
||||
QPointF posArrow1,posArrow2;
|
||||
QPointF offsetDir(m_arrowDir.x,-m_arrowDir.y); //remember Y dir is flipped
|
||||
double offsetLength = m_extLen + Rez::guiX(QGIArrow::getOverlapAdjust(0,QGIArrow::getPrefArrowSize()));
|
||||
QPointF offsetVec = offsetLength * offsetDir;
|
||||
posArrow1 = m_start + offsetVec;
|
||||
posArrow2 = m_end + offsetVec;
|
||||
|
||||
m_arrow1->setStyle(0);
|
||||
m_arrow1->setSize(QGIArrow::getPrefArrowSize());
|
||||
m_arrow1->setPos(extLineStart);
|
||||
m_arrow1->setPos(posArrow1);
|
||||
m_arrow1->draw();
|
||||
m_arrow1->setRotation(arrowRotation); //rotation = 0 ==> -> horizontal, pointing right
|
||||
|
||||
m_arrow2->setStyle(0);
|
||||
m_arrow2->setSize(QGIArrow::getPrefArrowSize());
|
||||
m_arrow2->setPos(extLineEnd);
|
||||
m_arrow2->setPos(posArrow2);
|
||||
m_arrow2->draw();
|
||||
m_arrow2->setRotation(arrowRotation);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user