Label cannot be moved outside of parent bounding box. Moving cursor is on when moving label. Name of detail moved to Pattern Piece Data tab. Hopefully all warnings removed

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-07-06 20:49:36 +02:00
parent cdd3e03e53
commit aa1d1f8ce1
12 changed files with 80 additions and 139 deletions

View File

@ -658,8 +658,6 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
}
else if (element.tagName() == TagData)
{
QString qsName = element.attribute(AttrName, "");
detail.GetPatternPieceData().SetName(qsName);
QString qsLetter = element.attribute(AttrLetter, "");
detail.GetPatternPieceData().SetLetter(qsLetter);
QPointF ptPos;

View File

@ -350,7 +350,6 @@
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="letter" type="xs:string"></xs:attribute>
<xs:attribute name="fontSize" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>

View File

@ -241,6 +241,8 @@ int VPoster::CountColumns(int width) const
//---------------------------------------------------------------------------------------------------------------------
PosterData VPoster::Cut(int i, int j, const QRect &imageRect) const
{
Q_UNUSED(imageRect);
const int x = j*PageRect().width() - j*static_cast<int>(allowence);
const int y = i*PageRect().height() - i*static_cast<int>(allowence);

View File

@ -29,15 +29,15 @@
#include "vpatternpiecedata.h"
//---------------------------------------------------------------------------------------------------------------------
VPatternPieceData::VPatternPieceData() :
m_ptPos(0, 0)
{
m_iFontSize = MIN_FONT_SIZE;
// 0 means unknown width
m_dLabelWidth = 0;
m_dLabelHeight = 0;
m_dRotation = 0;
}
MaterialCutPlacement::MaterialCutPlacement()
:m_eMaterial(MaterialType::mtFabric), m_qsMaterialUserDef(), m_iCutNumber(0), m_ePlacement(PlacementType::ptNone)
{}
//---------------------------------------------------------------------------------------------------------------------
VPatternPieceData::VPatternPieceData()
:m_qsLetter(), m_conMCP(), m_ptPos(0, 0), m_dLabelWidth(0), m_dLabelHeight(0),
m_iFontSize(MIN_FONT_SIZE), m_dRotation(0)
{}
//---------------------------------------------------------------------------------------------------------------------
VPatternPieceData::~VPatternPieceData()
@ -91,7 +91,6 @@ void VPatternPieceData::RemoveMCP(int i)
void VPatternPieceData::Clear()
{
m_qsLetter.clear();
m_qsName.clear();
m_conMCP.clear();
}
@ -107,18 +106,6 @@ void VPatternPieceData::SetLetter(QString qsLetter)
m_qsLetter = qsLetter.left(3);
}
//---------------------------------------------------------------------------------------------------------------------
const QString& VPatternPieceData::GetName() const
{
return m_qsName;
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternPieceData::SetName(QString qsName)
{
m_qsName = qsName;
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VPatternPieceData::GetPos() const
{

View File

@ -55,6 +55,8 @@ struct MaterialCutPlacement
QString m_qsMaterialUserDef;
int m_iCutNumber;
PlacementType m_ePlacement;
MaterialCutPlacement();
};
typedef QList<MaterialCutPlacement> MCPContainer;
@ -81,8 +83,6 @@ public:
// methods, which operate on other members
const QString& GetLetter() const;
void SetLetter(QString qsLetter);
const QString& GetName() const;
void SetName(QString qsName);
// methods, which set up label parameters
QPointF GetPos() const;
@ -97,9 +97,6 @@ public:
void SetRotation(qreal dRot);
private:
/** @brief Pattern piece name
*/
QString m_qsName;
/** @brief Pattern piece letter (should be no more than 3 letters)
*/
QString m_qsLetter;

View File

@ -44,15 +44,16 @@
* @param parent parent widget
*/
DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true), flagWidth(true)
:DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true), flagWidth(true),
m_bAddMode(true), m_qslMaterials(), m_qslPlacements(), m_conMCP(), m_oldData(), m_oldGeom()
{
ui.setupUi(this);
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
ui.lineEditNameDetail->setClearButtonEnabled(true);
ui.lineEditName->setClearButtonEnabled(true);
#endif
labelEditNamePoint = ui.labelEditNameDetail;
labelEditNamePoint = ui.labelEditName;
ui.labelUnit->setText( VDomDocument::UnitsToStr(qApp->patternUnit(), true));
ui.labelUnitX->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
ui.labelUnitY->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
@ -85,7 +86,7 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge
connect(ui.checkBoxSeams, &QCheckBox::clicked, this, &DialogDetail::ClickedSeams);
connect(ui.checkBoxClosed, &QCheckBox::clicked, this, &DialogDetail::ClickedClosed);
connect(ui.checkBoxReverse, &QCheckBox::clicked, this, &DialogDetail::ClickedReverse);
connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NameDetailChanged);
connect(ui.lineEditName, &QLineEdit::textChanged, this, &DialogDetail::NameDetailChanged);
connect(ui.toolButtonDelete, &QToolButton::clicked, this, &DialogDetail::DeleteItem);
connect(ui.toolButtonUp, &QToolButton::clicked, this, &DialogDetail::ScrollUp);
@ -355,19 +356,24 @@ VDetail DialogDetail::CreateDetail() const
detail.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
}
detail.setWidth(ui.doubleSpinBoxSeams->value());
detail.setName(ui.lineEditNameDetail->text());
detail.setName(ui.lineEditName->text());
detail.setSeamAllowance(supplement);
detail.setClosed(closed);
detail.GetPatternPieceData().SetLetter(ui.lineEditLetter->text());
detail.GetPatternPieceData().SetName(ui.lineEditName->text());
for (int i = 0; i < m_conMCP.count(); ++i)
{
detail.GetPatternPieceData().Append(m_conMCP[i]);
}
detail.GetPatternPieceData().SetPos(m_ptPos);
detail.GetPatternPieceData().SetPos(m_oldData.GetPos());
detail.GetPatternPieceData().SetLabelWidth(m_oldData.GetLabelWidth());
detail.GetPatternPieceData().SetLabelHeight(m_oldData.GetLabelHeight());
detail.GetPatternPieceData().SetFontSize(m_oldData.GetFontSize());
detail.GetPatternPieceData().SetRotation(m_oldData.GetRotation());
detail.GetPatternInfo() = m_oldGeom;
return detail;
}
@ -416,7 +422,7 @@ void DialogDetail::setDetail(const VDetail &value)
NewItem(node.getId(), node.getTypeTool(), node.getTypeNode(), node.getMx(),
node.getMy(), node.getReverse());
}
ui.lineEditNameDetail->setText(detail.getName());
ui.lineEditName->setText(detail.getName());
ui.checkBoxSeams->setChecked(detail.getSeamAllowance());
ui.checkBoxClosed->setChecked(detail.getClosed());
ClickedClosed(detail.getClosed());
@ -427,7 +433,6 @@ void DialogDetail::setDetail(const VDetail &value)
ui.toolButtonDelete->setEnabled(true);
ui.lineEditLetter->setText(detail.GetPatternPieceData().GetLetter());
ui.lineEditName->setText(detail.GetPatternPieceData().GetName());
m_conMCP.clear();
for (int i = 0; i < detail.GetPatternPieceData().GetMCPCount(); ++i)
@ -436,7 +441,8 @@ void DialogDetail::setDetail(const VDetail &value)
}
UpdateList();
m_ptPos = detail.GetPatternPieceData().GetPos();
m_oldData = detail.GetPatternPieceData();
m_oldGeom = detail.GetPatternInfo();
ValidObjects(DetailIsValid());
}

View File

@ -33,6 +33,7 @@
#include "dialogtool.h"
#include "../vpatterndb/vdetail.h"
#include "../vpatterndb/vpatternpiecedata.h"
#include "../vpatterndb/vpatterninfogeometry.h"
/**
* @brief The DialogDetail class dialog for ToolDetai. Help create detail and edit option.
@ -92,7 +93,8 @@ private:
QStringList m_qslPlacements;
// temporary container for Material/Cut/Placement 3-tuples
MCPContainer m_conMCP;
QPointF m_ptPos;
VPatternPieceData m_oldData;
VPatternInfoGeometry m_oldGeom;
bool DetailIsValid() const;

View File

@ -191,74 +191,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labelEditNameDetail">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" 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>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</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="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Name of detail:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNameDetail">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Detail</string>
</property>
</widget>
</item>
</layout>
<layout class="QHBoxLayout" name="horizontalLayout"/>
</item>
<item>
<widget class="QCheckBox" name="checkBoxSeams">
@ -457,25 +390,25 @@
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<widget class="QLabel" name="label_6">
<widget class="QLabel" name="labelEditName">
<property name="geometry">
<rect>
<x>9</x>
<y>38</y>
<width>40</width>
<x>10</x>
<y>40</y>
<width>101</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Name:</string>
<string>Name of detail:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEditName">
<property name="geometry">
<rect>
<x>55</x>
<y>38</y>
<width>125</width>
<x>110</x>
<y>40</y>
<width>151</width>
<height>23</height>
</rect>
</property>
@ -586,9 +519,9 @@
<widget class="QLineEdit" name="lineEditLetter">
<property name="geometry">
<rect>
<x>55</x>
<y>9</y>
<width>125</width>
<x>110</x>
<y>10</y>
<width>151</width>
<height>23</height>
</rect>
</property>
@ -633,7 +566,6 @@
<tabstop>doubleSpinBoxBiasX</tabstop>
<tabstop>doubleSpinBoxBiasY</tabstop>
<tabstop>checkBoxReverse</tabstop>
<tabstop>lineEditNameDetail</tabstop>
<tabstop>checkBoxSeams</tabstop>
<tabstop>doubleSpinBoxSeams</tabstop>
<tabstop>toolButtonDown</tabstop>

View File

@ -33,6 +33,7 @@
#include <QTransform>
#include <QDebug>
#include "../vmisc/def.h"
#include "vtextgraphicsitem.h"
#define RESIZE_SQUARE 30
@ -46,14 +47,20 @@
#define SPACING 2
#define TOP_Z 2
//---------------------------------------------------------------------------------------------------------------------
TextLine::TextLine()
:m_qsText(), m_iFontSize(MIN_FONT_SIZE), m_eFontWeight(QFont::Normal), m_eStyle(QFont::StyleNormal),
m_eAlign(Qt::AlignCenter), m_iHeight(0)
{}
//---------------------------------------------------------------------------------------------------------------------
VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent)
: QGraphicsObject(pParent)
:QGraphicsObject(pParent), m_eMode(VTextGraphicsItem::mNormal), m_bReleased(false),
m_ptStartPos(), m_ptStart(), m_ptRotCenter(), m_szStart(), m_dRotation(0), m_dAngle(0),
m_rectResize(), m_iMinH(MIN_H), m_rectBoundingBox(), m_font(), m_liLines(), m_liOutput()
{
m_eMode = mNormal;
m_bReleased = false;
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
m_iMinH = MIN_H;
SetSize(MIN_W, m_iMinH);
setZValue(TOP_Z);
}
@ -219,6 +226,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
else
{
m_eMode = mMove;
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
}
setZValue(TOP_Z + 1);
@ -232,14 +240,25 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
QPointF ptDiff = pME->scenePos() - m_ptStart;
if (m_eMode == mMove)
{
setPos(m_ptStartPos + ptDiff);
UpdateBox();
QPointF pt = m_ptStartPos + ptDiff;
pt.setX(pt.x() + m_rectBoundingBox.width()/2);
pt.setY(pt.y() + m_rectBoundingBox.height()/2);
if (parentItem()->boundingRect().contains(pt) == true)
{
setPos(m_ptStartPos + ptDiff);
UpdateBox();
}
}
else if (m_eMode == mResize)
{
SetSize(m_szStart.width() + ptDiff.x(), m_szStart.height() + ptDiff.y());
Update();
emit SignalShrink();
QPointF pt = m_ptStartPos;
pt.setX(pt.x() + (m_szStart.width() + ptDiff.x())/2);
pt.setY(pt.y() + (m_szStart.height() + ptDiff.y())/2);
if (parentItem()->boundingRect().contains(pt) == true) {
SetSize(m_szStart.width() + ptDiff.x(), m_szStart.height() + ptDiff.y());
Update();
emit SignalShrink();
}
}
else if (m_eMode == mRotate)
{
@ -260,6 +279,7 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
{
if (pME->button() == Qt::LeftButton)
{
RestoreOverrideCursor(cursorArrowCloseHand);
double dDist = fabs(pME->scenePos().x() - m_ptStart.x()) + fabs(pME->scenePos().y() - m_ptStart.y());
bool bShort = (dDist < 2);
@ -289,6 +309,7 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
if (bShort == true)
{
m_eMode = mMove;
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
UpdateBox();
}
else

View File

@ -41,6 +41,8 @@ struct TextLine
QFont::Style m_eStyle;
Qt::Alignment m_eAlign;
int m_iHeight;
TextLine();
};
class VTextGraphicsItem : public QGraphicsObject

View File

@ -81,7 +81,8 @@ const QString VToolDetail::NodeSplinePath = QStringLiteral("NodeSplinePath");
VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation,
VMainGraphicsScene *scene, const QString &drawName, QGraphicsItem *parent)
:VAbstractTool(doc, data, id), VNoBrushScalePathItem(parent), dialog(nullptr), sceneDetails(scene),
drawName(drawName), seamAllowance(new VNoBrushScalePathItem(this))
drawName(drawName), seamAllowance(new VNoBrushScalePathItem(this)), dataLabel(new VTextGraphicsItem(this)),
patternInfo(new VTextGraphicsItem(this))
{
VDetail detail = data->GetDetail(id);
for (int i = 0; i< detail.CountNode(); ++i)
@ -130,13 +131,11 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
}
setAcceptHoverEvents(true);
dataLabel = new VTextGraphicsItem(this);
connect(dataLabel, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMoveDetail);
connect(dataLabel, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizeDetail);
connect(dataLabel, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationDetail);
//connect(dataLabel, &VTextGraphicsItem::SignalShrink, this, &VToolDetail::UpdateAll);
patternInfo = new VTextGraphicsItem(this);
connect(patternInfo, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMovePattern);
connect(patternInfo, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizePattern);
connect(patternInfo, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationPattern);
@ -354,7 +353,6 @@ void VToolDetail::AddToFile()
QDomElement domData = doc->createElement(VAbstractPattern::TagData);
const VPatternPieceData& data = detail.GetPatternPieceData();
doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter());
doc->SetAttribute(domData, VAbstractPattern::AttrName, data.GetName());
doc->SetAttribute(domData, AttrMx, data.GetPos().x());
doc->SetAttribute(domData, AttrMy, data.GetPos().y());
doc->SetAttribute(domData, AttrWidth, data.GetLabelWidth());
@ -411,8 +409,6 @@ void VToolDetail::RefreshDataInFile()
QDomElement domData = doc->createElement(VAbstractPattern::TagData);
const VPatternPieceData& data = det.GetPatternPieceData();
doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter());
doc->SetAttribute(domData, VAbstractPattern::AttrName, data.GetName());
doc->SetAttribute(domData, AttrMx, data.GetPos().x());
doc->SetAttribute(domData, AttrMy, data.GetPos().y());
doc->SetAttribute(domData, AttrWidth, data.GetLabelWidth());
@ -675,7 +671,7 @@ void VToolDetail::UpdateLabel()
const VDetail detail = VAbstractTool::data.GetDetail(id);
const VPatternPieceData& data = detail.GetPatternPieceData();
if (data.GetLetter().isEmpty() == false || data.GetName().isEmpty() == false || data.GetMCPCount() > 0)
if (data.GetLetter().isEmpty() == false || detail.getName().isEmpty() == false || data.GetMCPCount() > 0)
{
//dataLabel->Reset();
@ -695,7 +691,7 @@ void VToolDetail::UpdateLabel()
tl.m_eStyle = QFont::StyleNormal;
tl.m_iFontSize = 6;
dataLabel->AddLine(tl);
tl.m_qsText = data.GetName();
tl.m_qsText = detail.getName();
tl.m_eAlign = Qt::AlignCenter;
tl.m_eFontWeight = QFont::DemiBold;
tl.m_iFontSize = 2;

View File

@ -139,7 +139,6 @@ void SaveDetailOptions::SavePatternPieceData(QDomElement &domElement, const VDet
QDomElement domData = doc->createElement(VAbstractPattern::TagData);
const VPatternPieceData& data = det.GetPatternPieceData();
doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter());
doc->SetAttribute(domData, VAbstractPattern::AttrName, data.GetName());
doc->SetAttribute(domData, AttrMx, data.GetPos().x());
doc->SetAttribute(domData, AttrMy, data.GetPos().y());
doc->SetAttribute(domData, VToolDetail::AttrWidth, data.GetLabelWidth());