Improve visualization for tool Special point on shoulder.
This commit is contained in:
parent
b9dd7d0ee9
commit
0f78ef8b05
|
@ -49,6 +49,8 @@
|
|||
#include "../vmisc/vcommonsettings.h"
|
||||
#include "ui_dialogshoulderpoint.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vwidgets/vabstractmainwindow.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -220,24 +222,7 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type)
|
|||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
QSet<quint32> set;
|
||||
set.insert(getCurrentObjectId(ui->comboBoxP3));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxP1Line));
|
||||
set.insert(id);
|
||||
|
||||
if (set.size() == 3)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxP2Line, QString()))
|
||||
{
|
||||
line->setLineP2Id(id);
|
||||
line->RefreshGeometry();
|
||||
prepare = true;
|
||||
this->setModal(true);
|
||||
this->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
ChosenThirdPoint(id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -269,6 +254,33 @@ void DialogShoulderPoint::closeEvent(QCloseEvent *event)
|
|||
DialogTool::closeEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogShoulderPoint::ChosenThirdPoint(quint32 id)
|
||||
{
|
||||
QSet<quint32> set;
|
||||
set.insert(getCurrentObjectId(ui->comboBoxP3));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxP1Line));
|
||||
set.insert(id);
|
||||
|
||||
if (set.size() == 3)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxP2Line, QString()))
|
||||
{
|
||||
auto *window = qobject_cast<VAbstractMainWindow *>(
|
||||
VAbstractValApplication::VApp()->getMainWindow());
|
||||
SCASSERT(window != nullptr)
|
||||
|
||||
auto *line = qobject_cast<VisToolShoulderPoint *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
|
||||
|
||||
line->setLineP2Id(id);
|
||||
line->RefreshGeometry();
|
||||
prepare = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setPShoulder set id shoulder point
|
||||
|
@ -428,3 +440,48 @@ auto DialogShoulderPoint::GetNotes() const -> QString
|
|||
{
|
||||
return ui->plainTextEditToolNotes->toPlainText();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogShoulderPoint::ShowDialog(bool click)
|
||||
{
|
||||
if (not prepare)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto *lineVis = qobject_cast<VisToolShoulderPoint *>(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> p3 = data->GeometricObject<VPointF>(GetP3());
|
||||
QLineF line(static_cast<QPointF>(*p3), scene->getScenePos());
|
||||
SetFormula(QString::number(FromPixel(line.length(), *data->GetPatternUnit())));
|
||||
|
||||
FinishCreating();
|
||||
}
|
||||
|
||||
FinishCreating();
|
||||
}
|
||||
|
|
|
@ -76,6 +76,8 @@ public:
|
|||
|
||||
void SetNotes(const QString ¬es);
|
||||
auto GetNotes() const -> QString;
|
||||
|
||||
void ShowDialog(bool click) override;
|
||||
public slots:
|
||||
void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||
/**
|
||||
|
@ -112,6 +114,10 @@ private:
|
|||
bool m_flagFormula{false};
|
||||
bool m_flagName{true};
|
||||
bool m_flagError{true};
|
||||
|
||||
bool m_firstRelease{false};
|
||||
|
||||
void ChosenThirdPoint(quint32 id);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../visualization.h"
|
||||
#include "visline.h"
|
||||
#include "../vmisc/vmodifierkey.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolShoulderPoint::VisToolShoulderPoint(const VContainer *data, QGraphicsItem *parent)
|
||||
|
@ -98,6 +99,26 @@ void VisToolShoulderPoint::RefreshGeometry()
|
|||
DrawPoint(m_point, mainLine.p2(), mainColor);
|
||||
DrawLine(m_line3, QLineF(static_cast<QPointF>(*first), mainLine.p2()), supportColor, Qt::DashLine);
|
||||
}
|
||||
else if (mode == Mode::Creation)
|
||||
{
|
||||
QLineF cursorLine (static_cast<QPointF>(*first), Visualization::scenePos);
|
||||
|
||||
qreal len = cursorLine.length();
|
||||
QPointF fPoint = VToolShoulderPoint::FindPoint(static_cast<QPointF>(*second),
|
||||
static_cast<QPointF>(*third),
|
||||
static_cast<QPointF>(*first), len);
|
||||
QLineF mainLine = QLineF(static_cast<QPointF>(*second), fPoint);
|
||||
DrawLine(this, mainLine, mainColor, lineStyle);
|
||||
|
||||
DrawPoint(m_point, mainLine.p2(), mainColor);
|
||||
DrawLine(m_line3, QLineF(static_cast<QPointF>(*first), mainLine.p2()), supportColor, Qt::DashLine);
|
||||
|
||||
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
|
||||
{
|
||||
qreal angle = QLineF(static_cast<QPointF>(*second), static_cast<QPointF>(*third)).angle();
|
||||
|
|
Loading…
Reference in New Issue
Block a user