Improve visualization for tool Point of intersection circle and segment.

This commit is contained in:
Roman Telezhynskyi 2022-08-24 19:44:09 +03:00
parent 35eedc0a44
commit 8a94ed2645
3 changed files with 118 additions and 44 deletions

View File

@ -45,11 +45,12 @@
#include "../../visualization/visualization.h"
#include "../../visualization/line/vistoolpointofcontact.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../ifc/xml/vdomdocument.h"
#include "../support/dialogeditwrongformula.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#include "ui_dialogpointofcontact.h"
#include "../vwidgets/vabstractmainwindow.h"
#include "../vgeometry/vpointf.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -186,6 +187,50 @@ void DialogPointOfContact::DeployFormulaTextEdit()
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::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<VPointF> center = data->GeometricObject<VPointF>(getCenter());
QLineF line(static_cast<QPointF>(*center), scene->getScenePos());
setRadius(QString::number(FromPixel(line.length(), *data->GetPatternUnit())));
FinishCreating();
}
FinishCreating();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
@ -194,8 +239,11 @@ void DialogPointOfContact::DeployFormulaTextEdit()
*/
void DialogPointOfContact::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)
{
VisToolPointOfContact *line = qobject_cast<VisToolPointOfContact *>(vis);
@ -232,11 +280,14 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type)
{
if (SetObject(id, ui->comboBoxCenter, QString()))
{
auto *window = qobject_cast<VAbstractMainWindow *>(
VAbstractValApplication::VApp()->getMainWindow());
SCASSERT(window != nullptr)
connect(line, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
line->SetRadiusId(id);
line->RefreshGeometry();
prepare = true;
this->setModal(true);
this->show();
}
}
}
@ -246,7 +297,6 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type)
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::SaveData()

View File

@ -71,6 +71,8 @@ public:
void SetNotes(const QString &notes);
QString GetNotes() const;
void ShowDialog(bool click) override;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
/**
@ -110,6 +112,8 @@ private:
/** @brief number number of handled objects */
qint32 number{0};
bool m_firstRelease{false};
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -41,6 +41,7 @@
#include "../visualization.h"
#include "visline.h"
#include "../vwidgets/global.h"
#include "../vmisc/vmodifierkey.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolPointOfContact::VisToolPointOfContact(const VContainer *data, QGraphicsItem *parent)
@ -88,6 +89,25 @@ void VisToolPointOfContact::RefreshGeometry()
m_circle->setRect(PointRect(m_radius));
DrawPoint(m_circle, static_cast<QPointF>(*third), Color(VColor::SupportColor), Qt::DashLine);
}
else if (GetMode() == Mode::Creation)
{
QLineF cursorLine (static_cast<QPointF>(*third), ScenePos());
qreal radius = cursorLine.length();
QPointF fPoint;
VToolPointOfContact::FindPoint(radius, static_cast<QPointF>(*third), static_cast<QPointF>(*first),
static_cast<QPointF>(*second), &fPoint);
DrawPoint(m_point, fPoint, Color(VColor::MainColor));
m_circle->setRect(PointRect(radius));
DrawPoint(m_circle, static_cast<QPointF>(*third), Color(VColor::SupportColor), Qt::DashLine);
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(LengthToUser(radius), prefix, VModifierKey::EnterKey()));
}
}
}
}