Improve visualization for tool Segment an arc.
This commit is contained in:
parent
a5c8bab097
commit
4fb6dfbd92
|
@ -47,6 +47,7 @@
|
||||||
#include "ui_dialogcutarc.h"
|
#include "ui_dialogcutarc.h"
|
||||||
#include "../vgeometry/varc.h"
|
#include "../vgeometry/varc.h"
|
||||||
#include "../qmuparser/qmudef.h"
|
#include "../qmuparser/qmudef.h"
|
||||||
|
#include "../vwidgets/vabstractmainwindow.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -172,8 +173,10 @@ void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
vis->VisualMode(id);
|
vis->VisualMode(id);
|
||||||
}
|
}
|
||||||
prepare = true;
|
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,49 @@ auto DialogCutArc::GetAliasSuffix2() const -> QString
|
||||||
{
|
{
|
||||||
return ui->lineEditAlias2->text();
|
return ui->lineEditAlias2->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogCutArc::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<VArc> arc = data->GeometricObject<VArc>(getArcId());
|
||||||
|
QPointF p = arc->ClosestPoint(scene->getScenePos());
|
||||||
|
qreal len = arc->GetLengthByPoint(p);
|
||||||
|
if (len > 0)
|
||||||
|
{
|
||||||
|
SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit())));
|
||||||
|
}
|
||||||
|
|
||||||
|
FinishCreating();
|
||||||
|
}
|
||||||
|
|
||||||
|
FinishCreating();
|
||||||
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ public:
|
||||||
void SetAliasSuffix2(const QString &alias);
|
void SetAliasSuffix2(const QString &alias);
|
||||||
auto GetAliasSuffix2() const -> QString;
|
auto GetAliasSuffix2() const -> QString;
|
||||||
|
|
||||||
|
void ShowDialog(bool click) override;
|
||||||
public slots:
|
public slots:
|
||||||
void ChosenObject(quint32 id, const SceneObject &type) override;
|
void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
/**
|
/**
|
||||||
|
@ -113,6 +114,8 @@ private:
|
||||||
|
|
||||||
QString m_originAliasSuffix1{};
|
QString m_originAliasSuffix1{};
|
||||||
QString m_originAliasSuffix2{};
|
QString m_originAliasSuffix2{};
|
||||||
|
|
||||||
|
bool m_firstRelease{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "../visualization.h"
|
#include "../visualization.h"
|
||||||
#include "vispath.h"
|
#include "vispath.h"
|
||||||
#include "../vwidgets/scalesceneitems.h"
|
#include "../vwidgets/scalesceneitems.h"
|
||||||
|
#include "../vmisc/vmodifierkey.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent)
|
VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
@ -75,6 +76,19 @@ void VisToolCutArc::RefreshGeometry()
|
||||||
DrawPath(m_arc1, ar1.GetPath(), ar1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap);
|
DrawPath(m_arc1, ar1.GetPath(), ar1.DirectionArrows(), Qt::darkGreen, lineStyle, Qt::RoundCap);
|
||||||
DrawPath(m_arc2, ar2.GetPath(), ar2.DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap);
|
DrawPath(m_arc2, ar2.GetPath(), ar2.DirectionArrows(), Qt::darkRed, lineStyle, Qt::RoundCap);
|
||||||
}
|
}
|
||||||
|
else if (mode == Mode::Creation)
|
||||||
|
{
|
||||||
|
QPointF p = arc->ClosestPoint(Visualization::scenePos);
|
||||||
|
qreal length = arc->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