New placelabel shape Circle.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-04-23 17:42:09 +03:00
parent 08bdeeedfe
commit 57d6d79a53
10 changed files with 1218 additions and 8 deletions

View File

@ -14,6 +14,7 @@
- Extend Label language to support Czech alphabet.
- [#916] Improve layout generation.
- [#965] Control passmark length with formula.
- New placelabel shape Circle.
# Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path.

View File

@ -55,6 +55,7 @@
<file>schema/pattern/v0.8.1.xsd</file>
<file>schema/pattern/v0.8.2.xsd</file>
<file>schema/pattern/v0.8.3.xsd</file>
<file>schema/pattern/v0.8.4.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file>

File diff suppressed because it is too large Load Diff

View File

@ -59,8 +59,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.3");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.3.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.4");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.4.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -233,7 +233,8 @@ QString VPatternConverter::XSDSchema(int ver) const
std::make_pair(FORMAT_VERSION(0, 8, 0), QStringLiteral("://schema/pattern/v0.8.0.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 1), QStringLiteral("://schema/pattern/v0.8.1.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 2), QStringLiteral("://schema/pattern/v0.8.2.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 3), CurrentSchema)
std::make_pair(FORMAT_VERSION(0, 8, 3), QStringLiteral("://schema/pattern/v0.8.3.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 4), CurrentSchema)
};
if (schemas.contains(ver))
@ -466,6 +467,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 3)), m_convertedFileName);
Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 8, 3)):
ToV0_8_4();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 4)), m_convertedFileName);
Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 8, 4)):
break;
default:
InvalidVersion(m_ver);
@ -483,7 +488,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const
{
// Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 3),
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 4),
"Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc.
@ -1083,6 +1088,16 @@ void VPatternConverter::ToV0_8_3()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_8_4()
{
// TODO. Delete if minimal supported version is 0.8.4
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 4),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.8.4"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View File

@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4);
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 3);
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 4);
protected:
virtual int MinVer() const override;
@ -126,6 +126,7 @@ private:
void ToV0_8_1();
void ToV0_8_2();
void ToV0_8_3();
void ToV0_8_4();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -700,7 +700,8 @@ void VDxfEngine::ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece &
const QVector<VLayoutPlaceLabel> labels = detail.GetPlaceLabels();
for(auto &label : labels)
{
if (label.type != PlaceLabelType::Doubletree && label.type != PlaceLabelType::Button)
if (label.type != PlaceLabelType::Doubletree && label.type != PlaceLabelType::Button
&& label.type != PlaceLabelType::Circle)
{
for(auto &p : qAsConst(label.shape))
{
@ -793,7 +794,8 @@ void VDxfEngine::ExportAAMADrill(dx_ifaceBlock *detailBlock, const VLayoutPiece
for(auto &label : labels)
{
if (label.type == PlaceLabelType::Doubletree || label.type == PlaceLabelType::Button)
if (label.type == PlaceLabelType::Doubletree || label.type == PlaceLabelType::Button
|| label.type == PlaceLabelType::Circle)
{
DRW_Point *point = new DRW_Point();
point->basePoint = DRW_Coord(FromPixel(label.center.x(), varInsunits),

View File

@ -57,7 +57,8 @@ enum class PlaceLabelType : unsigned char
Corner = 5,
Triangle = 6,
Hshaped = 7,
Button = 8
Button = 8,
Circle = 9
};
typedef QVector<QPolygonF> PlaceLabelImg;

View File

@ -341,6 +341,20 @@ PlaceLabelImg VPlaceLabelItem::LabelShape() const
return PlaceLabelImg({t.map(shape1), t.map(shape2), t.map(shape3)});
};
auto CircleShape = [t, this]()
{
const qreal radius = qMin(d->wValue/2.0, d->hValue/2.0);
VArc arc(*this, radius, 0, 360);
arc.SetApproximationScale(10);
QPolygonF circle(arc.GetPoints());
if (not circle.isClosed() && not circle.isEmpty())
{
circle << circle.first();
}
return PlaceLabelImg({t.map(circle)});
};
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(d->type)
@ -363,6 +377,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
return HshapedShape();
case PlaceLabelType::Button:
return ButtonShape();
case PlaceLabelType::Circle:
return CircleShape();
}
QT_WARNING_POP

View File

@ -499,6 +499,7 @@ void DialogPlaceLabel::FillPlaceLabelTypes()
ui->comboBoxLabelType->addItem(tr("Triangle"), static_cast<int>(PlaceLabelType::Triangle));
ui->comboBoxLabelType->addItem(tr("H-shaped"), static_cast<int>(PlaceLabelType::Hshaped));
ui->comboBoxLabelType->addItem(tr("Button"), static_cast<int>(PlaceLabelType::Button));
ui->comboBoxLabelType->addItem(tr("Circle"), static_cast<int>(PlaceLabelType::Circle));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -856,6 +856,7 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
QAction *actionTriangle = InitAction(tr("Triangle"), PlaceLabelType::Triangle);
QAction *actionHshaped = InitAction(tr("H-shaped"), PlaceLabelType::Hshaped);
QAction *actionButton = InitAction(tr("Button"), PlaceLabelType::Button);
QAction *actionCircle = InitAction(tr("Circle"), PlaceLabelType::Circle);
menu->addSeparator();
QAction *actionDelete = menu->addAction(QIcon::fromTheme(editDeleteIcon), tr("Delete"));
@ -917,6 +918,10 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
{
SaveType(PlaceLabelType::Button);
}
else if (selectedAction == actionCircle)
{
SaveType(PlaceLabelType::Circle);
}
}
//---------------------------------------------------------------------------------------------------------------------