Change in detail dialog. Show fractional number, current unit.

--HG--
branch : feature
This commit is contained in:
dismine 2014-06-12 19:56:24 +03:00
parent 60e5167400
commit 2e7e0e92f7
4 changed files with 91 additions and 28 deletions

View File

@ -34,6 +34,7 @@
#include "../../geometry/vpointf.h"
#include "../../geometry/vsplinepath.h"
#include "../../container/vcontainer.h"
#include "../../xml/vdomdocument.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -46,6 +47,9 @@ DialogDetail::DialogDetail(const VContainer *data, QWidget *parent)
{
ui.setupUi(this);
labelEditNamePoint = ui.labelEditNameDetail;
ui.labelUnit->setText( VDomDocument::UnitsToStr(qApp->patternUnit(), true));
ui.labelUnitX->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
ui.labelUnitY->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
SCASSERT(bOk != nullptr);
@ -61,9 +65,9 @@ DialogDetail::DialogDetail(const VContainer *data, QWidget *parent)
CheckState();
connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogDetail::ObjectChanged);
connect(ui.spinBoxBiasX, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
connect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasXChanged);
connect(ui.spinBoxBiasY, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
connect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
connect(ui.checkBoxSeams, &QCheckBox::clicked, this, &DialogDetail::ClickedSeams);
connect(ui.checkBoxClosed, &QCheckBox::clicked, this, &DialogDetail::ClickedClosed);
@ -119,7 +123,7 @@ void DialogDetail::DialogAccepted()
QListWidgetItem *item = ui.listWidget->item(i);
details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
}
details.setWidth(ui.spinBoxSeams->value());
details.setWidth(ui.doubleSpinBoxSeams->value());
details.setName(ui.lineEditNameDetail->text());
details.setSeamAllowance(supplement);
details.setClosed(closed);
@ -198,15 +202,15 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t
item->setData(Qt::UserRole, QVariant::fromValue(node));
ui.listWidget->addItem(item);
ui.listWidget->setCurrentRow(ui.listWidget->count()-1);
disconnect(ui.spinBoxBiasX, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
disconnect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasXChanged);
disconnect(ui.spinBoxBiasY, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
disconnect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
ui.spinBoxBiasX->setValue(static_cast<qint32>(qApp->fromPixel(node.getMx())));
ui.spinBoxBiasY->setValue(static_cast<qint32>(qApp->fromPixel(node.getMy())));
connect(ui.spinBoxBiasX, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx()));
ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy()));
connect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasXChanged);
connect(ui.spinBoxBiasY, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
connect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(qreal)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
}
@ -229,7 +233,7 @@ void DialogDetail::setDetails(const VDetail &value)
ui.checkBoxClosed->setChecked(details.getClosed());
ClickedClosed(details.getClosed());
ClickedSeams(details.getSeamAllowance());
ui.spinBoxSeams->setValue(static_cast<qint32>(details.getWidth()));
ui.doubleSpinBoxSeams->setValue(details.getWidth());
ui.listWidget->setCurrentRow(0);
ui.listWidget->setFocus(Qt::OtherFocusReason);
ui.toolButtonDelete->setEnabled(true);
@ -274,7 +278,7 @@ void DialogDetail::ClickedSeams(bool checked)
{
supplement = checked;
ui.checkBoxClosed->setEnabled(checked);
ui.spinBoxSeams->setEnabled(checked);
ui.doubleSpinBoxSeams->setEnabled(checked);
}
//---------------------------------------------------------------------------------------------------------------------
@ -300,8 +304,8 @@ void DialogDetail::ObjectChanged(int row)
}
QListWidgetItem *item = ui.listWidget->item( row );
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
ui.spinBoxBiasX->setValue(static_cast<qint32>(qApp->fromPixel(node.getMx())));
ui.spinBoxBiasY->setValue(static_cast<qint32>(qApp->fromPixel(node.getMy())));
ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx()));
ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy()));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -41,18 +41,37 @@
</property>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Bias X</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxBiasX">
<property name="minimum">
<number>-3000</number>
<widget class="QDoubleSpinBox" name="doubleSpinBoxBiasX">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>3000</number>
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelUnitX">
<property name="text">
<string>cm</string>
</property>
</widget>
</item>
@ -64,7 +83,7 @@
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
@ -74,12 +93,25 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxBiasY">
<property name="minimum">
<number>-3000</number>
<widget class="QDoubleSpinBox" name="doubleSpinBoxBiasY">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>3000</number>
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelUnitY">
<property name="text">
<string>cm</string>
</property>
</widget>
</item>
@ -177,7 +209,7 @@
<widget class="QLabel" name="labelEditWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
@ -190,9 +222,31 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxSeams">
<widget class="QDoubleSpinBox" name="doubleSpinBoxSeams">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>3000</number>
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelUnit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>cm</string>
</property>
</widget>
</item>

View File

@ -33,13 +33,13 @@
//---------------------------------------------------------------------------------------------------------------------
VDetail::VDetail()
:_id(0), nodes(QVector<VNodeDetail>()), name(QString()), mx(0), my(0), seamAllowance(true), closed(true),
width(10)
width(0)
{}
//---------------------------------------------------------------------------------------------------------------------
VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes)
:_id(0), nodes(QVector<VNodeDetail>()), name(name), mx(0), my(0), seamAllowance(true), closed(true),
width(10)
width(0)
{
this->nodes = nodes;
}
@ -73,7 +73,7 @@ void VDetail::Clear()
my = 0;
seamAllowance = true;
closed = true;
width = 10;
width = 0;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -271,6 +271,11 @@ QPainterPath VEquidistant::Equidistant(QVector<QPointF> points, const Equidistan
qDebug()<<"Not enough points for building the equidistant.\n";
return ekv;
}
if (width <= 0)
{
qDebug()<<"Width <= 0.\n";
return ekv;
}
for (qint32 i = 0; i < points.size(); ++i )
{
if (i != points.size()-1)