Improve visualization for tool Point along bisector.
This commit is contained in:
parent
0aac23ec8e
commit
dd2eacd0d5
|
@ -343,6 +343,69 @@ auto DialogBisector::GetNotes() const -> QString
|
||||||
return ui->plainTextEditToolNotes->toPlainText();
|
return ui->plainTextEditToolNotes->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogBisector::ShowDialog(bool click)
|
||||||
|
{
|
||||||
|
if (not prepare)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto *lineVis = qobject_cast<VisToolBisector *>(vis);
|
||||||
|
SCASSERT(lineVis != nullptr)
|
||||||
|
|
||||||
|
auto FinishCreating = [this, lineVis]()
|
||||||
|
{
|
||||||
|
lineVis->SetMode(Mode::Show);
|
||||||
|
lineVis->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<VPointF> p1 = data->GeometricObject<VPointF>(GetFirstPointId());
|
||||||
|
const QSharedPointer<VPointF> p2 = data->GeometricObject<VPointF>(GetSecondPointId());
|
||||||
|
const QSharedPointer<VPointF> p3 = data->GeometricObject<VPointF>(GetThirdPointId());
|
||||||
|
|
||||||
|
qreal angle = VToolBisector::BisectorAngle(static_cast<QPointF>(*p1),
|
||||||
|
static_cast<QPointF>(*p2),
|
||||||
|
static_cast<QPointF>(*p3));
|
||||||
|
|
||||||
|
QLineF baseLine(static_cast<QPointF>(*p2), static_cast<QPointF>(*p3));
|
||||||
|
baseLine.setAngle(angle);
|
||||||
|
|
||||||
|
QLineF line(static_cast<QPointF>(*p2), scene->getScenePos());
|
||||||
|
|
||||||
|
qreal len = line.length();
|
||||||
|
qreal angleTo = baseLine.angleTo(line);
|
||||||
|
if (angleTo > 90 && angleTo < 270)
|
||||||
|
{
|
||||||
|
len *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetFormula(QString::number(FromPixel(len, *data->GetPatternUnit())));
|
||||||
|
|
||||||
|
FinishCreating();
|
||||||
|
}
|
||||||
|
|
||||||
|
FinishCreating();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogBisector::SaveData()
|
void DialogBisector::SaveData()
|
||||||
{
|
{
|
||||||
|
@ -379,11 +442,17 @@ void DialogBisector::ChosenThirdPoint(quint32 id)
|
||||||
{
|
{
|
||||||
if (SetObject(id, ui->comboBoxThirdPoint, QString()))
|
if (SetObject(id, ui->comboBoxThirdPoint, QString()))
|
||||||
{
|
{
|
||||||
|
auto *window = qobject_cast<VAbstractMainWindow *>(
|
||||||
|
VAbstractValApplication::VApp()->getMainWindow());
|
||||||
|
SCASSERT(window != nullptr)
|
||||||
|
|
||||||
|
auto *line = qobject_cast<VisToolBisector *>(vis);
|
||||||
|
SCASSERT(line != nullptr)
|
||||||
|
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
|
||||||
|
|
||||||
line->setObject3Id(id);
|
line->setObject3Id(id);
|
||||||
line->RefreshGeometry();
|
line->RefreshGeometry();
|
||||||
prepare = true;
|
prepare = true;
|
||||||
this->setModal(true);
|
|
||||||
this->show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,8 @@ public:
|
||||||
|
|
||||||
void SetNotes(const QString ¬es);
|
void SetNotes(const QString ¬es);
|
||||||
auto GetNotes() const -> QString;
|
auto GetNotes() 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;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../visualization.h"
|
#include "../visualization.h"
|
||||||
#include "visline.h"
|
#include "visline.h"
|
||||||
|
#include "../vmisc/vmodifierkey.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent)
|
VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
@ -113,6 +114,36 @@ void VisToolBisector::RefreshGeometry()
|
||||||
|
|
||||||
DrawPoint(m_point, mainLine.p2(), mainColor);
|
DrawPoint(m_point, mainLine.p2(), mainColor);
|
||||||
}
|
}
|
||||||
|
else if (mode == Mode::Creation)
|
||||||
|
{
|
||||||
|
QLineF cursorLine (static_cast<QPointF>(*second), Visualization::scenePos);
|
||||||
|
QLineF baseLine(static_cast<QPointF>(*second), static_cast<QPointF>(*third));
|
||||||
|
|
||||||
|
qreal angle = VToolBisector::BisectorAngle(static_cast<QPointF>(*first),
|
||||||
|
static_cast<QPointF>(*second),
|
||||||
|
static_cast<QPointF>(*third));
|
||||||
|
|
||||||
|
baseLine.setAngle(angle);
|
||||||
|
|
||||||
|
qreal len = cursorLine.length();
|
||||||
|
qreal angleTo = baseLine.angleTo(cursorLine);
|
||||||
|
if (angleTo > 90 && angleTo < 270)
|
||||||
|
{
|
||||||
|
len *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLineF mainLine = VGObject::BuildLine(static_cast<QPointF>(*second), len, angle);
|
||||||
|
|
||||||
|
DrawLine(this, mainLine, mainColor, lineStyle);
|
||||||
|
|
||||||
|
DrawPoint(m_point, mainLine.p2(), 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(len), prefix, VModifierKey::EnterKey());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qreal angle = VToolBisector::BisectorAngle(static_cast<QPointF>(*first),
|
qreal angle = VToolBisector::BisectorAngle(static_cast<QPointF>(*first),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user