Changes in dialog: reverse and internal move update the visualization
automatically. --HG-- branch : feature
This commit is contained in:
parent
b7def444ef
commit
bff5462ef3
|
@ -52,6 +52,7 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
|
||||||
|
|
||||||
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogSeamAllowance::ShowContextMenu);
|
connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogSeamAllowance::ShowContextMenu);
|
||||||
|
connect(ui->listWidget->model(), &QAbstractItemModel::rowsMoved, this, &DialogSeamAllowance::ListChanged);
|
||||||
|
|
||||||
vis = new VisToolPiece(data);
|
vis = new VisToolPiece(data);
|
||||||
}
|
}
|
||||||
|
@ -97,50 +98,53 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
|
||||||
*/
|
*/
|
||||||
void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type)
|
void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
{
|
{
|
||||||
bool reverse = false;
|
if (not prepare)
|
||||||
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
|
||||||
{
|
{
|
||||||
reverse = true;
|
bool reverse = false;
|
||||||
}
|
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
||||||
switch (type)
|
{
|
||||||
{
|
reverse = true;
|
||||||
case SceneObject::Arc:
|
}
|
||||||
NewItem(VPieceNode(id, Tool::NodeArc, reverse));
|
switch (type)
|
||||||
break;
|
{
|
||||||
case SceneObject::Point:
|
case SceneObject::Arc:
|
||||||
NewItem(VPieceNode(id, Tool::NodePoint));
|
NewItem(VPieceNode(id, Tool::NodeArc, reverse));
|
||||||
break;
|
break;
|
||||||
case SceneObject::Spline:
|
case SceneObject::Point:
|
||||||
NewItem(VPieceNode(id, Tool::NodeSpline, reverse));
|
NewItem(VPieceNode(id, Tool::NodePoint));
|
||||||
break;
|
break;
|
||||||
case SceneObject::SplinePath:
|
case SceneObject::Spline:
|
||||||
NewItem(VPieceNode(id, Tool::NodeSplinePath, reverse));
|
NewItem(VPieceNode(id, Tool::NodeSpline, reverse));
|
||||||
break;
|
break;
|
||||||
case (SceneObject::Line):
|
case SceneObject::SplinePath:
|
||||||
case (SceneObject::Detail):
|
NewItem(VPieceNode(id, Tool::NodeSplinePath, reverse));
|
||||||
case (SceneObject::Unknown):
|
break;
|
||||||
default:
|
case (SceneObject::Line):
|
||||||
qDebug() << "Got wrong scene object. Ignore.";
|
case (SceneObject::Detail):
|
||||||
break;
|
case (SceneObject::Unknown):
|
||||||
}
|
default:
|
||||||
|
qDebug() << "Got wrong scene object. Ignore.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ValidObjects(MainPathIsValid());
|
ValidObjects(MainPathIsValid());
|
||||||
|
|
||||||
auto visPath = qobject_cast<VisToolPiece *>(vis);
|
auto visPath = qobject_cast<VisToolPiece *>(vis);
|
||||||
SCASSERT(visPath != nullptr);
|
SCASSERT(visPath != nullptr);
|
||||||
const VPiece p = CreatePiece();
|
const VPiece p = CreatePiece();
|
||||||
visPath->SetPiece(p);
|
visPath->SetPiece(p);
|
||||||
|
|
||||||
if (p.CountNode() == 1)
|
if (p.CountNode() == 1)
|
||||||
{
|
{
|
||||||
emit ToolTip(tr("Select main path objects clockwise, <b>Shift</b> - reverse direction curve, "
|
emit ToolTip(tr("Select main path objects clockwise, <b>Shift</b> - reverse direction curve, "
|
||||||
"<b>Enter</b> - finish creation"));
|
"<b>Enter</b> - finish creation"));
|
||||||
|
|
||||||
visPath->VisualMode(NULL_ID);
|
visPath->VisualMode(NULL_ID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
visPath->RefreshGeometry();
|
visPath->RefreshGeometry();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +154,15 @@ void DialogSeamAllowance::ShowDialog(bool click)
|
||||||
if (click == false)
|
if (click == false)
|
||||||
{
|
{
|
||||||
emit ToolTip("");
|
emit ToolTip("");
|
||||||
setModal(true);
|
prepare = true;
|
||||||
|
|
||||||
|
auto visPath = qobject_cast<VisToolPiece *>(vis);
|
||||||
|
SCASSERT(visPath != nullptr);
|
||||||
|
visPath->SetMode(Mode::Show);
|
||||||
|
visPath->RefreshGeometry();
|
||||||
|
|
||||||
|
// Fix issue #526. Dialog Detail is not on top after selection second object on Mac.
|
||||||
|
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,6 +223,17 @@ void DialogSeamAllowance::ShowContextMenu(const QPoint &pos)
|
||||||
rowItem->setText(GetNodeName(rowNode));
|
rowItem->setText(GetNodeName(rowNode));
|
||||||
ValidObjects(MainPathIsValid());
|
ValidObjects(MainPathIsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSeamAllowance::ListChanged()
|
||||||
|
{
|
||||||
|
auto visPath = qobject_cast<VisToolPiece *>(vis);
|
||||||
|
SCASSERT(visPath != nullptr);
|
||||||
|
visPath->SetPiece(CreatePiece());
|
||||||
|
visPath->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -61,6 +61,7 @@ protected:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ShowContextMenu(const QPoint &pos);
|
void ShowContextMenu(const QPoint &pos);
|
||||||
|
void ListChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogSeamAllowance)
|
Q_DISABLE_COPY(DialogSeamAllowance)
|
||||||
|
|
|
@ -47,6 +47,8 @@ VisToolPiece::~VisToolPiece()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolPiece::RefreshGeometry()
|
void VisToolPiece::RefreshGeometry()
|
||||||
{
|
{
|
||||||
|
HideAllItems();
|
||||||
|
|
||||||
if (m_piece.CountNode() > 0)
|
if (m_piece.CountNode() > 0)
|
||||||
{
|
{
|
||||||
DrawPath(this, m_piece.MainPathPath(Visualization::data), mainColor, Qt::SolidLine, Qt::RoundCap);
|
DrawPath(this, m_piece.MainPathPath(Visualization::data), mainColor, Qt::SolidLine, Qt::RoundCap);
|
||||||
|
@ -59,12 +61,15 @@ void VisToolPiece::RefreshGeometry()
|
||||||
DrawPoint(point, nodes.at(i), supportColor);
|
DrawPoint(point, nodes.at(i), supportColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<QPointF> points = m_piece.MainPathPoints(Visualization::data);
|
if (mode == Mode::Creation)
|
||||||
DrawLine(m_line1, QLineF(points.first(), Visualization::scenePos), supportColor, Qt::DashLine);
|
|
||||||
|
|
||||||
if (points.size() > 1)
|
|
||||||
{
|
{
|
||||||
DrawLine(m_line2, QLineF(points.last(), Visualization::scenePos), supportColor, Qt::DashLine);
|
const QVector<QPointF> points = m_piece.MainPathPoints(Visualization::data);
|
||||||
|
DrawLine(m_line1, QLineF(points.first(), Visualization::scenePos), supportColor, Qt::DashLine);
|
||||||
|
|
||||||
|
if (points.size() > 1)
|
||||||
|
{
|
||||||
|
DrawLine(m_line2, QLineF(points.last(), Visualization::scenePos), supportColor, Qt::DashLine);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,3 +85,26 @@ QGraphicsEllipseItem *VisToolPiece::GetPoint(quint32 i, const QColor &color)
|
||||||
{
|
{
|
||||||
return GetPointItem(Visualization::data, factor, m_points, i, color, this);
|
return GetPointItem(Visualization::data, factor, m_points, i, color, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VisToolPiece::HideAllItems()
|
||||||
|
{
|
||||||
|
if (m_line1)
|
||||||
|
{
|
||||||
|
m_line1->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_line2)
|
||||||
|
{
|
||||||
|
m_line2->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<QGraphicsEllipseItem *> m_points;
|
||||||
|
for (int i=0; i < m_points.size(); ++i)
|
||||||
|
{
|
||||||
|
if (QGraphicsEllipseItem *item = m_points.at(i))
|
||||||
|
{
|
||||||
|
item->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ private:
|
||||||
VPiece m_piece;
|
VPiece m_piece;
|
||||||
|
|
||||||
QGraphicsEllipseItem* GetPoint(quint32 i, const QColor &color);
|
QGraphicsEllipseItem* GetPoint(quint32 i, const QColor &color);
|
||||||
|
|
||||||
|
void HideAllItems();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISTOOLPIECE_H
|
#endif // VISTOOLPIECE_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user