At least one arrow has to be present on a grainline

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-10-25 23:00:42 +02:00
parent 21cd56463c
commit 96cfc52202
13 changed files with 129 additions and 98 deletions

View file

@ -730,8 +730,9 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
detail.GetGrainlineGeometry().SetLength(qsLength);
QString qsRot = GetParametrString(element, VToolDetail::AttrRotation, "90");
detail.GetGrainlineGeometry().SetRotation(qsRot);
detail.GetGrainlineGeometry().SetFrontArrow(GetParametrBool(element, AttrFront, trueStr));
detail.GetGrainlineGeometry().SetRearArrow(GetParametrBool(element, AttrRear, trueStr));
VGrainlineGeometry::ArrowType eAT =
VGrainlineGeometry::ArrowType(GetParametrUInt(element, AttrArrows, "0"));
detail.GetGrainlineGeometry().SetArrowType(eAT);
}
}
}

View file

@ -384,9 +384,8 @@
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
<xs:attribute name="rotation" type="xs:string"></xs:attribute>
<xs:attribute name="front" type="xs:boolean"></xs:attribute>
<xs:attribute name="rear" type="xs:boolean"></xs:attribute>
</xs:complexType>
<xs:attribute name="arrows" type="arrowType"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
@ -600,4 +599,11 @@
<xs:enumeration value="1"/><!--Cut on Fold-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="arrowType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--Both-->
<xs:enumeration value="1"/><!--Front-->
<xs:enumeration value="2"/><!--Rear-->
</xs:restriction>
</xs:simpleType>
</xs:schema>

View file

@ -100,8 +100,7 @@ const QString VAbstractPattern::AttrMaterial = QStringLiteral("material")
const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef");
const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber");
const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement");
const QString VAbstractPattern::AttrFront = QStringLiteral("front");
const QString VAbstractPattern::AttrRear = QStringLiteral("rear");
const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows");
const QString VAbstractPattern::AttrAll = QStringLiteral("all");

View file

@ -205,8 +205,7 @@ public:
static const QString AttrUserDefined;
static const QString AttrCutNumber;
static const QString AttrPlacement;
static const QString AttrFront;
static const QString AttrRear;
static const QString AttrArrows;
static const QString AttrAll;

View file

@ -220,7 +220,7 @@ void VLayoutDetail::SetGrainline(const VGrainlineGeometry& geom, const VContaine
v << pt1;
if (geom.HasFrontArrow() == true) {
if (geom.GetArrowType() != VGrainlineGeometry::atRear) {
pt.setX(pt1.x() + dArrowLen * qCos(dAng + dArrowAng));
pt.setY(pt1.y() - dArrowLen * qSin(dAng + dArrowAng));
v << pt;
@ -233,7 +233,7 @@ void VLayoutDetail::SetGrainline(const VGrainlineGeometry& geom, const VContaine
v << pt2;
if (geom.HasRearArrow() == true)
if (geom.GetArrowType() != VGrainlineGeometry::atFront)
{
dAng += M_PI;

View file

@ -33,7 +33,7 @@
//---------------------------------------------------------------------------------------------------------------------
VGrainlineGeometry::VGrainlineGeometry()
:m_ptPos(0, 0), m_qsLength(), m_qsRotation(), m_bVisible(false), m_bFrontArrow(true), m_bRearArrow(true)
:m_ptPos(0, 0), m_qsLength(), m_qsRotation(), m_bVisible(false), m_eArrowType(atBoth)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -99,30 +99,16 @@ void VGrainlineGeometry::SetVisible(bool bVisible)
//---------------------------------------------------------------------------------------------------------------------
bool VGrainlineGeometry::HasFrontArrow() const
VGrainlineGeometry::ArrowType VGrainlineGeometry::GetArrowType() const
{
return m_bFrontArrow;
return m_eArrowType;
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineGeometry::SetFrontArrow(bool bVal)
void VGrainlineGeometry::SetArrowType(ArrowType eAT)
{
m_bFrontArrow = bVal;
}
//---------------------------------------------------------------------------------------------------------------------
bool VGrainlineGeometry::HasRearArrow() const
{
return m_bRearArrow;
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineGeometry::SetRearArrow(bool bVal)
{
m_bRearArrow = bVal;
m_eArrowType = eAT;
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -40,6 +40,15 @@ class QPointF;
*/
class VGrainlineGeometry
{
public:
// denotes the type of arrow for the grainline
enum ArrowType
{
atBoth,
atFront,
atRear
};
public:
VGrainlineGeometry();
~VGrainlineGeometry();
@ -53,10 +62,8 @@ public:
void SetRotation(const QString& qsRot);
bool IsVisible() const;
void SetVisible(bool bVisible);
bool HasFrontArrow() const;
void SetFrontArrow(bool bVal);
bool HasRearArrow() const;
void SetRearArrow(bool bVal);
ArrowType GetArrowType() const;
void SetArrowType(ArrowType eAT);
private:
/**
@ -76,13 +83,9 @@ private:
*/
bool m_bVisible;
/**
* @brief m_bFrontArrow front arrow flag
* @brief m_eArrowType type of arrow on the grainline
*/
bool m_bFrontArrow;
/**
* @brief m_bRearArrow back arrow flag
*/
bool m_bRearArrow;
ArrowType m_eArrowType;
};
#endif // VGRAINLINEGEOMETRY_H

View file

@ -168,6 +168,10 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
SetAddMode();
EnableGrainlineRotation();
ui.comboBoxArrow->addItem(tr("Both"));
ui.comboBoxArrow->addItem(tr("Just front"));
ui.comboBoxArrow->addItem(tr("Just rear"));
ui.tabWidget->setCurrentIndex(0);
m_iRotBaseHeight = ui.lineEditRotFormula->height();
@ -486,11 +490,9 @@ VDetail DialogDetail::CreateDetail() const
detail.GetGrainlineGeometry().SetVisible(ui.checkBoxGrainline->isChecked());
detail.GetGrainlineGeometry().SetRotation(ui.lineEditRotFormula->toPlainText());
detail.GetGrainlineGeometry().SetLength(ui.lineEditLenFormula->toPlainText());
detail.GetGrainlineGeometry().SetFrontArrow(ui.checkBoxFrontArrow->isChecked());
detail.GetGrainlineGeometry().SetRearArrow(ui.checkBoxRearArrow->isChecked());
VGrainlineGeometry::ArrowType eAT = VGrainlineGeometry::ArrowType(ui.comboBoxArrow->currentIndex());
detail.GetGrainlineGeometry().SetArrowType(eAT);
qDebug() << "DIALOG ARROWS" << detail.GetGrainlineGeometry().HasFrontArrow()
<< detail.GetGrainlineGeometry().HasRearArrow();
return detail;
}
@ -564,8 +566,7 @@ void DialogDetail::setDetail(const VDetail &value)
ui.checkBoxGrainline->setChecked(detail.GetGrainlineGeometry().IsVisible());
ui.lineEditRotFormula->setPlainText(detail.GetGrainlineGeometry().GetRotation());
ui.lineEditLenFormula->setPlainText(detail.GetGrainlineGeometry().GetLength());
ui.checkBoxFrontArrow->setChecked(detail.GetGrainlineGeometry().HasFrontArrow());
ui.checkBoxRearArrow->setChecked(detail.GetGrainlineGeometry().HasRearArrow());
ui.comboBoxArrow->setCurrentIndex(int(detail.GetGrainlineGeometry().GetArrowType()));
m_oldData = detail.GetPatternPieceData();
m_oldGeom = detail.GetPatternInfo();

View file

@ -977,30 +977,70 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="checkBoxFrontArrow">
<widget class="QLabel" name="labelEditLen_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Front arrow</string>
<string>Arrows:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_3">
<property name="geometry">
<rect>
<x>10</x>
<y>310</y>
<width>541</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QCheckBox" name="checkBoxRearArrow">
<property name="text">
<string>Rear arrow</string>
<widget class="QComboBox" name="comboBoxArrow"/>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>

View file

@ -54,7 +54,7 @@
VGrainlineItem::VGrainlineItem(QGraphicsItem* pParent)
:QGraphicsObject(pParent), m_eMode(VGrainlineItem::mNormal), m_bReleased(false), m_dRotation(0), m_dStartRotation(0),
m_dLength(0), m_rectBoundingBox(), m_polyBound(), m_ptStartPos(), m_ptStartMove(), m_dScale(1), m_polyResize(),
m_ptStart(), m_ptFinish(), m_ptCenter(), m_dAngle(0), m_bFrontArrow(false), m_bRearArrow(false)
m_ptStart(), m_ptFinish(), m_ptCenter(), m_dAngle(0), m_eArrowType(VGrainlineGeometry::atBoth)
{
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
setAcceptHoverEvents(true);
@ -97,7 +97,7 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption
QPolygonF poly;
QPointF ptA;
qreal dArrLen = ARROW_LENGTH*m_dScale;
if (m_bFrontArrow == true)
if (m_eArrowType != VGrainlineGeometry::atRear)
{
// first arrow
poly << pt1;
@ -109,7 +109,7 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption
poly << ptA;
pP->drawPolygon(poly);
}
if (m_bRearArrow == true)
if (m_eArrowType != VGrainlineGeometry::atFront)
{
// second arrow
poly.clear();
@ -177,7 +177,8 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption
* @param dRotation rotation of the grainline in [degrees]
* @param dLength length of the grainline in user's units
*/
void VGrainlineItem::UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, bool bFA, bool bRA)
void VGrainlineItem::UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength,
VGrainlineGeometry::ArrowType eAT)
{
m_dRotation = qDegreesToRadians(dRotation);
m_dLength = dLength;
@ -191,8 +192,7 @@ void VGrainlineItem::UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal
pt.setY(pt.y() + dY);
}
setPos(pt);
m_bFrontArrow = bFA;
m_bRearArrow = bRA;
m_eArrowType = eAT;
UpdateRectangle();
UpdateBox();

View file

@ -54,7 +54,8 @@ public:
virtual ~VGrainlineItem();
void paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption, QWidget* pWidget);
void UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, bool bFA, bool bRA);
void UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength,
VGrainlineGeometry::ArrowType eAT);
QRectF boundingRect() const;
void Reset();
@ -79,25 +80,24 @@ signals:
void SignalRotated(qreal dRot, const QPointF& ptNewPos);
private:
Mode m_eMode;
bool m_bReleased;
qreal m_dRotation;
qreal m_dStartRotation;
qreal m_dLength;
QRectF m_rectBoundingBox;
QPolygonF m_polyBound;
QPointF m_ptStartPos;
QPointF m_ptStartMove;
qreal m_dScale;
QPolygonF m_polyResize;
qreal m_dStartLength;
QPointF m_ptStart;
QPointF m_ptFinish;
QPointF m_ptCenter;
QPointF m_ptRotCenter;
qreal m_dAngle;
bool m_bFrontArrow;
bool m_bRearArrow;
Mode m_eMode;
bool m_bReleased;
qreal m_dRotation;
qreal m_dStartRotation;
qreal m_dLength;
QRectF m_rectBoundingBox;
QPolygonF m_polyBound;
QPointF m_ptStartPos;
QPointF m_ptStartMove;
qreal m_dScale;
QPolygonF m_polyResize;
qreal m_dStartLength;
QPointF m_ptStart;
QPointF m_ptFinish;
QPointF m_ptCenter;
QPointF m_ptRotCenter;
qreal m_dAngle;
VGrainlineGeometry::ArrowType m_eArrowType;
};
#endif // VGRAINLINEITEM_H

View file

@ -509,8 +509,7 @@ void VToolDetail::AddToFile()
doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y());
doc->SetAttribute(domData, AttrLength, glGeom.GetLength());
doc->SetAttribute(domData, AttrRotation, glGeom.GetRotation());
doc->SetAttribute(domData, VAbstractPattern::AttrFront, glGeom.HasFrontArrow() == true? trueStr : falseStr);
doc->SetAttribute(domData, VAbstractPattern::AttrRear, glGeom.HasRearArrow() == true? trueStr : falseStr);
doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType()));
qDebug() << "XML ROTATION" << glGeom.GetRotation();
// nodes
@ -590,8 +589,7 @@ void VToolDetail::RefreshDataInFile()
doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y());
doc->SetAttribute(domData, AttrLength, glGeom.GetLength());
doc->SetAttribute(domData, AttrRotation, glGeom.GetRotation());
doc->SetAttribute(domData, VAbstractPattern::AttrFront, glGeom.HasFrontArrow() == true? trueStr : falseStr);
doc->SetAttribute(domData, VAbstractPattern::AttrRear, glGeom.HasRearArrow() == true? trueStr : falseStr);
doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType()));
// nodes
for (int i = 0; i < det.CountNode(); ++i)
@ -954,8 +952,7 @@ void VToolDetail::UpdateGrainline()
}
grainLine->UpdateGeometry(geom.GetPos(), dRotation, ToPixel(dLength, *VDataTool::data.GetPatternUnit()),
geom.HasFrontArrow(), geom.HasRearArrow());
qDebug() << "ARROWS" << geom.HasFrontArrow() << geom.HasRearArrow();
geom.GetArrowType());
grainLine->show();
}
else

View file

@ -210,8 +210,7 @@ void SaveDetailOptions::SaveGrainline(QDomElement &domElement, const VDetail &de
doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y());
doc->SetAttribute(domData, AttrLength, glGeom.GetLength());
doc->SetAttribute(domData, VToolDetail::AttrRotation, glGeom.GetRotation());
doc->SetAttribute(domData, VAbstractPattern::AttrFront, glGeom.HasFrontArrow() == true? trueStr : falseStr);
doc->SetAttribute(domData, VAbstractPattern::AttrRear, glGeom.HasRearArrow() == true? trueStr : falseStr);
doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType()));
domElement.appendChild(domData);
}