Improve visualization for tool Point from circle and tangent.
This commit is contained in:
parent
c10279c7e1
commit
d7fc36e0d4
|
@ -49,6 +49,8 @@
|
|||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/vcommonsettings.h"
|
||||
#include "ui_dialogpointfromcircleandtangent.h"
|
||||
#include "../vwidgets/vabstractmainwindow.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContainer *data, quint32 toolId,
|
||||
|
@ -205,14 +207,60 @@ void DialogPointFromCircleAndTangent::SetCrossCirclesPoint(const CrossCirclesPoi
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointFromCircleAndTangent::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;
|
||||
}
|
||||
|
||||
/*We will ignore click if pointer is in point circle*/
|
||||
auto *scene = qobject_cast<VMainGraphicsScene *>(VAbstractValApplication::VApp()->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
const QSharedPointer<VPointF> center = data->GeometricObject<VPointF>(GetCircleCenterId());
|
||||
QLineF line = QLineF(static_cast<QPointF>(*center), scene->getScenePos());
|
||||
|
||||
SetCircleRadius(QString::number(FromPixel(line.length(), *data->GetPatternUnit())));
|
||||
|
||||
FinishCreating();
|
||||
}
|
||||
|
||||
FinishCreating();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject &type)
|
||||
{
|
||||
if (prepare == false)// After first choose we ignore all objects
|
||||
if (prepare)// After first choose we ignore all objects
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == SceneObject::Point)
|
||||
{
|
||||
VisToolPointFromCircleAndTangent *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
||||
auto *point = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
||||
SCASSERT(point != nullptr)
|
||||
|
||||
switch (number)
|
||||
|
@ -229,12 +277,15 @@ void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject
|
|||
{
|
||||
if (SetObject(id, ui->comboBoxCircleCenter, QString()))
|
||||
{
|
||||
auto *window = qobject_cast<VAbstractMainWindow *>(
|
||||
VAbstractValApplication::VApp()->getMainWindow());
|
||||
SCASSERT(window != nullptr)
|
||||
connect(vis.data(), &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
|
||||
|
||||
number = 0;
|
||||
point->SetCenterId(id);
|
||||
point->RefreshGeometry();
|
||||
prepare = true;
|
||||
this->setModal(true);
|
||||
this->show();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -242,7 +293,6 @@ void DialogPointFromCircleAndTangent::ChosenObject(quint32 id, const SceneObject
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
void SetNotes(const QString ¬es);
|
||||
QString GetNotes() const;
|
||||
|
||||
void ShowDialog(bool click) override;
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||
void PointChanged();
|
||||
|
@ -101,6 +102,7 @@ private:
|
|||
bool flagError;
|
||||
/** @brief number number of handled objects */
|
||||
qint32 number{0};
|
||||
bool m_firstRelease{false};
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -328,9 +328,12 @@ void VToolPointFromCircleAndTangent::SetVisualization()
|
|||
auto *visual = qobject_cast<VisToolPointFromCircleAndTangent *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
const bool osSeparator = VAbstractApplication::VApp()->Settings()->GetOsSeparator();
|
||||
const VTranslateVars *trVars = VAbstractApplication::VApp()->TrVars();
|
||||
|
||||
visual->SetPointId(tangentPointId);
|
||||
visual->SetCenterId(circleCenterId);
|
||||
visual->SetCRadius(circleRadius);
|
||||
visual->SetCRadius(trVars->FormulaToUser(circleRadius, osSeparator));
|
||||
visual->SetCrossPoint(crossPoint);
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "../visualization.h"
|
||||
#include "visline.h"
|
||||
#include "../vwidgets/global.h"
|
||||
#include "../vmisc/vmodifierkey.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolPointFromCircleAndTangent::VisToolPointFromCircleAndTangent(const VContainer *data, QGraphicsItem *parent)
|
||||
|
@ -78,6 +79,27 @@ void VisToolPointFromCircleAndTangent::RefreshGeometry()
|
|||
m_cRadius, m_crossPoint, &fPoint);
|
||||
DrawPoint(m_point, fPoint, Color(VColor::MainColor));
|
||||
}
|
||||
else if (GetMode() == Mode::Creation)
|
||||
{
|
||||
QLineF cursorLine (static_cast<QPointF>(*center), ScenePos());
|
||||
qreal len = cursorLine.length();
|
||||
|
||||
m_cPath->setRect(PointRect(len));
|
||||
DrawPoint(m_cPath, static_cast<QPointF>(*center), Qt::darkGreen, Qt::DashLine);
|
||||
|
||||
FindRays(static_cast<QPointF>(*tan), static_cast<QPointF>(*center), len);
|
||||
|
||||
QPointF fPoint;
|
||||
VToolPointFromCircleAndTangent::FindPoint(static_cast<QPointF>(*tan), static_cast<QPointF>(*center),
|
||||
len, m_crossPoint, &fPoint);
|
||||
DrawPoint(m_point, fPoint, Color(VColor::MainColor));
|
||||
|
||||
const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
SetToolTip(tr("Radius = %1%2; "
|
||||
"<b>Mouse click</b> - finish selecting the radius, "
|
||||
"<b>%3</b> - skip")
|
||||
.arg(NumberToUser(len), prefix, VModifierKey::EnterKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user