Improve visualization for tool Segment a curved path.
This commit is contained in:
parent
c136a716f6
commit
94d46a4530
|
@ -47,6 +47,7 @@
|
|||
#include "ui_dialogcutsplinepath.h"
|
||||
#include "../vgeometry/vsplinepath.h"
|
||||
#include "../qmuparser/qmudef.h"
|
||||
#include "../vwidgets/vabstractmainwindow.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -180,8 +181,10 @@ void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type)
|
|||
vis->VisualMode(id);
|
||||
}
|
||||
prepare = true;
|
||||
this->setModal(true);
|
||||
this->show();
|
||||
|
||||
auto *window = qobject_cast<VAbstractMainWindow *>(VAbstractValApplication::VApp()->getMainWindow());
|
||||
SCASSERT(window != nullptr)
|
||||
connect(vis, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -354,3 +357,50 @@ auto DialogCutSplinePath::GetAliasSuffix2() const -> QString
|
|||
{
|
||||
return ui->lineEditAlias2->text();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutSplinePath::ShowDialog(bool click)
|
||||
{
|
||||
if (not prepare)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto FinishCreating = [this]()
|
||||
{
|
||||
vis->SetMode(Mode::Show);
|
||||
vis->RefreshGeometry();
|
||||
|
||||
emit ToolTip(QString());
|
||||
|
||||
setModal(true);
|
||||
show();
|
||||
};
|
||||
|
||||
if (click)
|
||||
{
|
||||
// The check need to ignore first release of mouse button.
|
||||
// User can select point by clicking on a label.
|
||||
if (not m_firstRelease)
|
||||
{
|
||||
m_firstRelease = true;
|
||||
return;
|
||||
}
|
||||
|
||||
auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
|
||||
const QSharedPointer<VAbstractCubicBezierPath> curve =
|
||||
data->GeometricObject<VAbstractCubicBezierPath>(getSplinePathId());
|
||||
QPointF p = curve->ClosestPoint(scene->getScenePos());
|
||||
qreal len = curve->GetLengthByPoint(p);
|
||||
if (len > 0)
|
||||
{
|
||||
SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit())));
|
||||
}
|
||||
|
||||
FinishCreating();
|
||||
}
|
||||
|
||||
FinishCreating();
|
||||
}
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
|
||||
void SetAliasSuffix2(const QString &alias);
|
||||
auto GetAliasSuffix2() const -> QString;
|
||||
|
||||
void ShowDialog(bool click) override;
|
||||
public slots:
|
||||
void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||
/**
|
||||
|
@ -111,6 +113,8 @@ private:
|
|||
|
||||
QString m_originAliasSuffix1{};
|
||||
QString m_originAliasSuffix2{};
|
||||
|
||||
bool m_firstRelease{false};
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../visualization.h"
|
||||
#include "vispath.h"
|
||||
#include "../vmisc/vmodifierkey.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolCutSplinePath::VisToolCutSplinePath(const VContainer *data, QGraphicsItem *parent)
|
||||
|
@ -85,6 +86,19 @@ void VisToolCutSplinePath::RefreshGeometry()
|
|||
delete spPath1;
|
||||
delete spPath2;
|
||||
}
|
||||
else if (mode == Mode::Creation)
|
||||
{
|
||||
QPointF p = splPath->ClosestPoint(Visualization::scenePos);
|
||||
qreal length = splPath->GetLengthByPoint(p);
|
||||
|
||||
DrawPoint(m_point, p, mainColor);
|
||||
|
||||
const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
Visualization::toolTip = tr("Length = %1%2; "
|
||||
"<b>Mouse click</b> - finish selecting the length, "
|
||||
"<b>%3</b> - skip")
|
||||
.arg(NumberToUser(length), prefix, VModifierKey::EnterKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user