Improve tool Point on middle visualization.

Show point on middle position when creating a point.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-11-11 11:24:30 +02:00
parent ec3750e087
commit c180a26e09
3 changed files with 28 additions and 4 deletions

View File

@ -189,11 +189,11 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type)
if (flagError) if (flagError)
{ {
line->setObject2Id(id); line->setObject2Id(id);
line->RefreshGeometry();
if (buildMidpoint) if (buildMidpoint)
{ {
SetFormula(currentLength + QLatin1String("/2")); SetFormula(currentLength + QLatin1String("/2"));
} }
line->RefreshGeometry();
prepare = true; prepare = true;
this->setModal(true); this->setModal(true);
this->show(); this->show();
@ -270,6 +270,9 @@ void DialogAlongLine::Build(const Tool &type)
if (type == Tool::Midpoint) if (type == Tool::Midpoint)
{ {
buildMidpoint = true; buildMidpoint = true;
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
SCASSERT(line != nullptr)
line->setMidPointMode(buildMidpoint);
} }
} }

View File

@ -45,8 +45,14 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent) VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent)
: VisLine(data, parent), object2Id(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), line(nullptr), : VisLine(data, parent),
length(0) object2Id(NULL_ID),
point(nullptr),
lineP1(nullptr),
lineP2(nullptr),
line(nullptr),
length(0),
m_midPointMode(false)
{ {
this->mainColor = Qt::red; this->mainColor = Qt::red;
this->setZValue(2);// Show on top real tool this->setZValue(2);// Show on top real tool
@ -69,6 +75,12 @@ void VisToolAlongLine::setLength(const QString &expression)
length = FindLengthFromUser(expression, Visualization::data->DataVariables()); length = FindLengthFromUser(expression, Visualization::data->DataVariables());
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolAlongLine::setMidPointMode(bool midPointMode)
{
m_midPointMode = midPointMode;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolAlongLine::RefreshGeometry() void VisToolAlongLine::RefreshGeometry()
{ {
@ -79,7 +91,14 @@ void VisToolAlongLine::RefreshGeometry()
if (object2Id <= NULL_ID) if (object2Id <= NULL_ID)
{ {
DrawLine(line, QLineF(static_cast<QPointF>(*first), Visualization::scenePos), supportColor); QLineF cursorLine (static_cast<QPointF>(*first), Visualization::scenePos);
DrawLine(line, cursorLine, supportColor);
if (m_midPointMode)
{
cursorLine.setLength(cursorLine.length()/2.0);
DrawPoint(lineP2, cursorLine.p2(), supportColor);
}
} }
else else
{ {

View File

@ -49,6 +49,7 @@ public:
virtual void RefreshGeometry() Q_DECL_OVERRIDE; virtual void RefreshGeometry() Q_DECL_OVERRIDE;
void setObject2Id(const quint32 &value); void setObject2Id(const quint32 &value);
void setLength(const QString &expression); void setLength(const QString &expression);
void setMidPointMode(bool midPointMode);
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolAlongLine)}; enum { Type = UserType + static_cast<int>(Vis::ToolAlongLine)};
private: private:
@ -59,6 +60,7 @@ private:
VScaledEllipse *lineP2; VScaledEllipse *lineP2;
VScaledLine *line; VScaledLine *line;
qreal length; qreal length;
bool m_midPointMode;
}; };
#endif // VISTOOLALONGLINE_H #endif // VISTOOLALONGLINE_H