Improve visualization for tool Point along perpendicular.
This commit is contained in:
parent
48b7c387a8
commit
de3179a37c
|
@ -35,21 +35,23 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
#include <QPointF>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
#include "../../tools/vabstracttool.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../../visualization/line/vistoolnormal.h"
|
#include "../../visualization/line/vistoolnormal.h"
|
||||||
#include "../../visualization/visualization.h"
|
#include "../../visualization/visualization.h"
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
#include "../ifc/xml/vdomdocument.h"
|
|
||||||
#include "../support/dialogeditwrongformula.h"
|
#include "../support/dialogeditwrongformula.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#include "ui_dialognormal.h"
|
#include "ui_dialognormal.h"
|
||||||
|
#include "../vwidgets/vabstractmainwindow.h"
|
||||||
|
#include "../vgeometry/vpointf.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -218,8 +220,11 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
line->setObject2Id(id);
|
line->setObject2Id(id);
|
||||||
line->RefreshGeometry();
|
line->RefreshGeometry();
|
||||||
prepare = true;
|
prepare = true;
|
||||||
this->setModal(true);
|
|
||||||
this->show();
|
auto *window = qobject_cast<VAbstractMainWindow *>(
|
||||||
|
VAbstractValApplication::VApp()->getMainWindow());
|
||||||
|
SCASSERT(window != nullptr)
|
||||||
|
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -415,3 +420,60 @@ auto DialogNormal::GetNotes() const -> QString
|
||||||
{
|
{
|
||||||
return ui->plainTextEditToolNotes->toPlainText();
|
return ui->plainTextEditToolNotes->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogNormal::ShowDialog(bool click)
|
||||||
|
{
|
||||||
|
if (not prepare)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto *lineVis = qobject_cast<VisToolNormal *>(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());
|
||||||
|
QLineF baseLine(static_cast<QPointF>(*p1), static_cast<QPointF>(*p2));
|
||||||
|
baseLine.setAngle(baseLine.angle() + 90);
|
||||||
|
|
||||||
|
QLineF line(static_cast<QPointF>(*p1), 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();
|
||||||
|
}
|
||||||
|
|
|
@ -76,6 +76,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;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,11 +37,11 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h"
|
#include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h"
|
||||||
#include "../ifc/ifcdef.h"
|
|
||||||
#include "../vgeometry/vpointf.h"
|
#include "../vgeometry/vpointf.h"
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../visualization.h"
|
#include "../visualization.h"
|
||||||
#include "visline.h"
|
#include "visline.h"
|
||||||
|
#include "../vmisc/vmodifierkey.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent)
|
VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
@ -82,13 +82,7 @@ void VisToolNormal::RefreshGeometry()
|
||||||
QLineF line_mouse(static_cast<QPointF>(*first), static_cast<QPointF>(*second));
|
QLineF line_mouse(static_cast<QPointF>(*first), static_cast<QPointF>(*second));
|
||||||
DrawLine(line, line_mouse, supportColor);
|
DrawLine(line, line_mouse, supportColor);
|
||||||
|
|
||||||
if (qFuzzyIsNull(length))
|
if (not qFuzzyIsNull(length))
|
||||||
{
|
|
||||||
QLineF normal = line_mouse.normalVector();
|
|
||||||
QPointF endRay = Ray(normal.p1(), normal.angle());
|
|
||||||
DrawLine(this, QLineF(normal.p1(), endRay), mainColor);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
QPointF fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second),
|
QPointF fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second),
|
||||||
length, angle);
|
length, angle);
|
||||||
|
@ -97,6 +91,37 @@ void VisToolNormal::RefreshGeometry()
|
||||||
|
|
||||||
DrawPoint(point, mainLine.p2(), mainColor);
|
DrawPoint(point, mainLine.p2(), mainColor);
|
||||||
}
|
}
|
||||||
|
else if (mode == Mode::Creation)
|
||||||
|
{
|
||||||
|
QLineF cursorLine (static_cast<QPointF>(*first), Visualization::scenePos);
|
||||||
|
QLineF normal = line_mouse.normalVector();
|
||||||
|
|
||||||
|
qreal len = cursorLine.length();
|
||||||
|
qreal angleTo = normal.angleTo(cursorLine);
|
||||||
|
if (angleTo > 90 && angleTo < 270)
|
||||||
|
{
|
||||||
|
len *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second),
|
||||||
|
len, angle);
|
||||||
|
QLineF mainLine = QLineF(static_cast<QPointF>(*first), fPoint);
|
||||||
|
DrawLine(this, mainLine, mainColor, lineStyle);
|
||||||
|
|
||||||
|
DrawPoint(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
|
||||||
|
{
|
||||||
|
QLineF normal = line_mouse.normalVector();
|
||||||
|
QPointF endRay = Ray(normal.p1(), normal.angle());
|
||||||
|
DrawLine(this, QLineF(normal.p1(), endRay), mainColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user