@@ -193,7 +193,7 @@ bool findLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat
193193
194194// ---------------------------------------------------------------------------------------------------------------------
195195bool findGrainlineGeometry (const VGrainlineData& data, const VContainer *pattern, qreal &length, qreal &rotationAngle,
196- QPointF &pos)
196+ qreal &arrowLength, QPointF &pos)
197197{
198198 SCASSERT (pattern != nullptr )
199199
@@ -211,6 +211,10 @@ bool findGrainlineGeometry(const VGrainlineData& data, const VContainer *pattern
211211 length = grainline.length ();
212212 rotationAngle = grainline.angle ();
213213
214+ Calculator cal3;
215+ arrowLength = cal3.EvalFormula (pattern->DataVariables (), data.getArrowLength ());
216+ arrowLength = ToPixel (arrowLength, *pattern->GetPatternUnit ());
217+
214218 if (!VFuzzyComparePossibleNulls (rotationAngle, 0 ))
215219 {
216220 grainline.setAngle (0 );
@@ -236,6 +240,10 @@ bool findGrainlineGeometry(const VGrainlineData& data, const VContainer *pattern
236240 Calculator cal2;
237241 length = cal2.EvalFormula (pattern->DataVariables (), data.getLength ());
238242 length = ToPixel (length, *pattern->GetPatternUnit ());
243+
244+ Calculator cal3;
245+ arrowLength = cal3.EvalFormula (pattern->DataVariables (), data.getArrowLength ());
246+ arrowLength = ToPixel (arrowLength, *pattern->GetPatternUnit ());
239247 }
240248 catch (qmu::QmuParserError &error)
241249 {
@@ -438,20 +446,20 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern
438446 }
439447
440448 const VPieceLabelData& pieceLabelData = piece.GetPatternPieceData ();
441- if (pieceLabelData.IsVisible () == true )
449+ if (pieceLabelData.IsVisible () & qApp-> Settings ()-> showLabels () )
442450 {
443451 layoutPiece.SetPieceText (piece.GetName (), pieceLabelData, qApp->Settings ()->getLabelFont (), pattern);
444452 }
445453
446454 const VPatternLabelData& patternLabelData = piece.GetPatternInfo ();
447- if (patternLabelData.IsVisible () == true )
455+ if (patternLabelData.IsVisible () & qApp-> Settings ()-> showLabels () )
448456 {
449457 VAbstractPattern* pDoc = qApp->getCurrentDocument ();
450458 layoutPiece.SetPatternInfo (pDoc, patternLabelData, qApp->Settings ()->getLabelFont (), pattern);
451459 }
452460
453461 const VGrainlineData& grainlineGeom = piece.GetGrainlineGeometry ();
454- if (grainlineGeom.IsVisible () == true )
462+ if (grainlineGeom.IsVisible () & qApp-> Settings ()-> showGrainlines () )
455463 {
456464 layoutPiece.setGrainline (grainlineGeom, pattern);
457465 }
@@ -633,47 +641,39 @@ void VLayoutPiece::setGrainline(const VGrainlineData& data, const VContainer* pa
633641 QPointF pt1;
634642 qreal rotationAngle = 0 ;
635643 qreal length = 0 ;
636- if (!findGrainlineGeometry (data, pattern, length, rotationAngle, pt1))
644+ qreal arrowLength = 0 ;
645+ if (!findGrainlineGeometry (data, pattern, length, rotationAngle, arrowLength, pt1))
637646 {
638647 return ;
639648 }
640649
641- const qreal arrowLength = 45 ;
642- const qreal arrowAngle = M_PI/9 ;
643-
644- QPointF pt2 (pt1.x () + arrowLength * qCos (rotationAngle),
645- pt1.y () - arrowLength * qSin (rotationAngle));
646- QPointF pt3 (pt1.x () + length * qCos (rotationAngle),
650+ QPointF pt2 (pt1.x () + length * qCos (rotationAngle),
647651 pt1.y () - length * qSin (rotationAngle));
648- QPointF pt4 (pt1.x () + (length - arrowLength) * qCos (rotationAngle),
649- pt1.y () - (length - arrowLength) * qSin (rotationAngle));
650652
651- QVector<QPointF> v ;
652- v << pt2 ;
653+ QVector<QPointF> path ;
654+ path << pt1 ;
653655 if (data.getArrowType () != ArrowType::Top)
654656 {
655- v << QPointF (pt1.x () + arrowLength * qCos (rotationAngle + arrowAngle),
656- pt1.y () - arrowLength * qSin (rotationAngle + arrowAngle));
657- v << pt1;
658- v << QPointF (pt1.x () + arrowLength * qCos (rotationAngle - arrowAngle),
659- pt1.y () - arrowLength * qSin (rotationAngle - arrowAngle));
660- v << pt2;
657+ path << QPointF (pt1.x () + arrowLength * cos (rotationAngle + M_PI / 9 ),
658+ pt1.y () - arrowLength * sin (rotationAngle + M_PI / 9 ));
659+
660+ path << QPointF (pt1.x () + arrowLength * cos (rotationAngle - M_PI / 9 ),
661+ pt1.y () - arrowLength * sin (rotationAngle - M_PI / 9 ));
661662 }
663+ path << pt1 << pt2;
662664
663- v << pt4;
664665 if (data.getArrowType () != ArrowType::Bottom)
665666 {
666- rotationAngle += M_PI;
667- v << QPointF (pt3.x () + arrowLength * qCos (rotationAngle + arrowAngle),
668- pt3.y () - arrowLength * qSin (rotationAngle + arrowAngle));
669- v << pt3;
670- v << QPointF (pt3.x () + arrowLength * qCos (rotationAngle - arrowAngle),
671- pt3.y () - arrowLength * qSin (rotationAngle - arrowAngle));
672- v << pt4;
667+ path << QPointF (pt2.x () + arrowLength * cos (M_PI + rotationAngle + M_PI / 9 ),
668+ pt2.y () - arrowLength * sin (M_PI + rotationAngle + M_PI / 9 ));
669+
670+ path << QPointF (pt2.x () + arrowLength * cos (M_PI + rotationAngle - M_PI / 9 ),
671+ pt2.y () - arrowLength * sin (M_PI + rotationAngle - M_PI / 9 ));
673672 }
673+ path << pt2;
674674
675675 QScopedPointer<QGraphicsItem> item (getMainPathItem ());
676- d->grainlinePoints = CorrectPosition (item->boundingRect (), v );
676+ d->grainlinePoints = CorrectPosition (item->boundingRect (), path );
677677}
678678
679679// ---------------------------------------------------------------------------------------------------------------------
0 commit comments