Skip to content

Commit

Permalink
fix notch and path line weights in pattern pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
DSCaskey authored and Onetchou committed Dec 30, 2024
1 parent 1aa7148 commit b08abd8
Show file tree
Hide file tree
Showing 9 changed files with 1,106 additions and 37 deletions.
6 changes: 5 additions & 1 deletion src/libs/ifc/ifcdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ QMap<QString, QString> lineWeightList()
const QStringList lineWeights = QStringList() << "0" << "0.05" << "0.09" << "0.13" << "0.15" << "0.18"
<< "0.2" << "0.25" << "0.3" << "0.35" << "0.4" << "0.5"
<< "0.53" << "0.6" << "0.7" << "0.8" << "0.9" << "1"
<< "1.06" << "1.2" << "1.4" << "1.58" << "2" << "2.11";
<< "1.06" << "1.2" << "1.4" << "1.58" << "2" << "2.11"
<< "3";

for (int i = 0; i < lineWeights.size(); ++i)
{
Expand Down Expand Up @@ -357,6 +358,9 @@ QMap<QString, QString> lineWeightList()
case 23:
name = "2.11mm";
break;
case 24:
name = "3.00mm";
break;
case 0:
default:
name = "0.00mm";
Expand Down
1 change: 1 addition & 0 deletions src/libs/ifc/schema.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
<file>schema/pattern/v0.6.9.xsd</file>
<file>schema/pattern/v0.7.0.xsd</file>
<file>schema/pattern/v0.7.1.xsd</file>
<file>schema/pattern/v0.7.2.xsd</file>
</qresource>
</RCC>
1,042 changes: 1,042 additions & 0 deletions src/libs/ifc/schema/pattern/v0.7.2.xsd

Large diffs are not rendered by default.

24 changes: 20 additions & 4 deletions src/libs/ifc/xml/vpatternconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ Q_LOGGING_CATEGORY(PatternConverter, "patternConverter")
*/

const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.1");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.1.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.2");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.2.xsd");

//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
Expand Down Expand Up @@ -350,7 +350,9 @@ QString VPatternConverter::getSchema(int ver) const
case (0x000700):
return QStringLiteral("://schema/pattern/v0.7.0.xsd");;
case (0x000701):
qCDebug(PatternConverter, "Current schema - ://schema/pattern/v0.7.1.xsd");
return QStringLiteral("://schema/pattern/v0.7.1.xsd");;
case (0x000702):
qCDebug(PatternConverter, "Current schema - ://schema/pattern/v0.7.2.xsd");
return CurrentSchema;
default:
InvalidVersion(ver);
Expand Down Expand Up @@ -545,6 +547,10 @@ void VPatternConverter::applyPatches()
ValidateXML(getSchema(0x000701), m_convertedFileName);
V_FALLTHROUGH
case (0x000701):
toVersion0_7_2();
ValidateXML(getSchema(0x000702), m_convertedFileName);
V_FALLTHROUGH
case (0x000702):
break;
default:
InvalidVersion(m_ver);
Expand All @@ -563,7 +569,7 @@ void VPatternConverter::downgradeToCurrentMaxVersion()
bool VPatternConverter::isReadOnly() const
{
// Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 1),
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 2),
"Check attribute readOnly.");

// Possibly in future attribute readOnly will change position etc.
Expand Down Expand Up @@ -1409,6 +1415,16 @@ void VPatternConverter::toVersion0_7_1()
Save();
}

//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::toVersion0_7_2()
{
// TODO. Delete if minimal supported version is 0.7.2
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 2),
"Time to refactor the code.");
setVersion(QStringLiteral("0.7.2"));
Save();
}

//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{
Expand Down
3 changes: 2 additions & 1 deletion src/libs/ifc/xml/vpatternconverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class VPatternConverter : public VAbstractConverter
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 1);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 2);

protected:
virtual int minVer() const override;
Expand Down Expand Up @@ -144,6 +144,7 @@ class VPatternConverter : public VAbstractConverter
void toVersion0_6_9();
void toVersion0_7_0();
void toVersion0_7_1();
void toVersion0_7_2();


void TagUnitToV0_2_0();
Expand Down
5 changes: 3 additions & 2 deletions src/libs/vlayout/vlayoutpiece.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,11 +1281,12 @@ void VLayoutPiece::createAllowanceItem(QGraphicsItem *parent) const
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::createNotchesItem(QGraphicsItem *parent) const
{
QColor color = QColor(qApp->Settings()->getDefaultNotchColor());
QColor color = QColor(qApp->Settings()->getDefaultNotchColor());
qreal lineWeight = ToPixel(qApp->Settings()->getDefaultCutLineweight(), Unit::Mm);

QGraphicsPathItem *item = new QGraphicsPathItem(parent);
item->setPath(createNotchesPath());
item->setPen(QPen(color, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
item->setPen(QPen(color, lineWeight, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
}

//---------------------------------------------------------------------------------------------------------------------
Expand Down
39 changes: 21 additions & 18 deletions src/libs/vtools/tools/pattern_piece_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,19 +911,23 @@ void PatternPieceTool::paint(QPainter *painter, const QStyleOptionGraphicsItem *
lineWeight = ToPixel(qApp->Settings()->getDefaultCutLineweight(), Unit::Mm);
}

m_seamLine->setPen(QPen(color, scaleWidth(lineWeight, sceneScale(scene())),
this->setPen(QPen(color, scaleWidth(lineWeight, sceneScale(scene())),
lineTypeToPenStyle(lineType), Qt::RoundCap, Qt::RoundJoin));

QBrush brush = QBrush(QColor(piece.getColor()));
brush.setStyle(static_cast<Qt::BrushStyle>(fills().indexOf(QRegExp(piece.getFill()))));
brush.setTransform(brush.transform().scale(150.0, 150.0));
brush.setTransform(painter->combinedTransform().inverted());
m_seamLine->setBrush(brush);
this->setBrush(brush);
}

//set allowance brush
m_allowanceFill->setPen(Qt::NoPen);

//set notches pen
color = QColor(qApp->Settings()->getDefaultNotchColor());
color = QColor(qApp->Settings()->getDefaultNotchColor());
lineWeight = ToPixel(qApp->Settings()->getDefaultCutLineweight(), Unit::Mm);

m_notches->setPen(QPen(color, scaleWidth(lineWeight, sceneScale(scene())),
Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));

Expand Down Expand Up @@ -1433,7 +1437,7 @@ PatternPieceTool::PatternPieceTool(VAbstractPattern *doc, VContainer *data, cons
, m_pieceScene(scene)
, m_blockName(blockName)
, m_cutLine(new NonScalingFillPathItem(this))
, m_seamLine(new NonScalingFillPathItem(this))
, m_allowanceFill(new NonScalingFillPathItem(this))
, m_dataLabel(new VTextGraphicsItem(this))
, m_patternInfo(new VTextGraphicsItem(this))
, m_grainLine(new VGrainlineItem(this))
Expand Down Expand Up @@ -1508,15 +1512,13 @@ void PatternPieceTool::RefreshGeometry()
if (!piece.isHideSeamLine() || !piece.IsSeamAllowance() || piece.IsSeamAllowanceBuiltIn())
{
m_mainPath = QPainterPath();
m_seamLine->setPath(m_mainPath);
m_cutLine->setBrush(QBrush(QColor(qApp->Settings()->getDefaultCutColor()), Qt::Dense7Pattern));
m_allowanceFill->setBrush(QBrush(QColor(qApp->Settings()->getDefaultCutColor()), Qt::Dense7Pattern));
}
else
{
m_mainPath = path; // need for returning a bounding rect when main path is not visible
path = QPainterPath();
m_seamLine->setPath(QPainterPath());
m_cutLine->setBrush(QBrush(Qt::NoBrush)); // Disable if the main path was hidden
m_allowanceFill->setBrush(QBrush(Qt::NoBrush)); // Disable if the main path was hidden
}

this->setPath(path);
Expand All @@ -1528,28 +1530,29 @@ void PatternPieceTool::RefreshGeometry()
seamAllowancePoints = piece.SeamAllowancePoints(this->getData());
}

m_notches->setPath(piece.getNotchesPath(this->getData(), seamAllowancePoints));

if (piece.IsSeamAllowance() && !piece.IsSeamAllowanceBuiltIn() && qApp->Settings()->showSeamAllowances())
{
path.addPath(piece.SeamAllowancePath(seamAllowancePoints));
path.setFillRule(Qt::OddEvenFill);
m_cutPath = path;
m_cutPath = piece.SeamAllowancePath(seamAllowancePoints);
m_cutLine->setPath(m_cutPath);

QPainterPath allowancePath = path;
allowancePath.addPath(m_cutPath);
allowancePath.setFillRule(Qt::OddEvenFill);
m_allowanceFill->setPath(allowancePath);

if (piece.isHideSeamLine())
{
m_seamLine->setPath(QPainterPath());
}
else
{
m_seamLine->setPath(m_mainPath);
this->setPath(QPainterPath());
}
}
else
{
m_cutLine->setPath(QPainterPath());
m_allowanceFill->setPath(QPainterPath());
}

m_notches->setPath(piece.getNotchesPath(this->getData(), seamAllowancePoints));

m_pieceRect = path.boundingRect();
this->setPos(piece.GetMx(), piece.GetMy());
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
Expand Down
20 changes: 10 additions & 10 deletions src/libs/vtools/tools/pattern_piece_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,17 @@ protected slots:
private:
Q_DISABLE_COPY(PatternPieceTool)

QPainterPath m_mainPath; // Must be first to prevent crash
QRectF m_pieceRect;
QPainterPath m_cutPath;
VMainGraphicsScene *m_pieceScene; /** @brief pieceScene pointer to the scene. */
QString m_blockName;
QPainterPath m_mainPath; // Must be first to prevent crash
QRectF m_pieceRect;
QPainterPath m_cutPath;
VMainGraphicsScene *m_pieceScene; /// @brief pieceScene pointer to the scene. */
QString m_blockName;
NonScalingFillPathItem *m_cutLine;
NonScalingFillPathItem *m_seamLine;
VTextGraphicsItem *m_dataLabel;
VTextGraphicsItem *m_patternInfo;
VGrainlineItem *m_grainLine;
QGraphicsPathItem *m_notches;
NonScalingFillPathItem *m_allowanceFill;
VTextGraphicsItem *m_dataLabel;
VTextGraphicsItem *m_patternInfo;
VGrainlineItem *m_grainLine;
QGraphicsPathItem *m_notches;

PatternPieceTool(VAbstractPattern *doc, VContainer *data, const quint32 &id,
const Source &typeCreation, VMainGraphicsScene *scene,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/vwidgets/lineweight_combobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ void LineWeightComboBox::init()
addItem(createIcon(7.00), "1.58mm", 1.58);
addItem(createIcon(8.00), "2.00mm (ISO)", 2.00);
addItem(createIcon(8.00), "2.11mm", 2.11);
setMaxVisibleItems(24);
addItem(createIcon(9.00), "3.00mm", 3.00);
setMaxVisibleItems(25);

this->blockSignals(false);
connect(this, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LineWeightComboBox::updateLineWeight);
Expand Down

0 comments on commit b08abd8

Please sign in to comment.