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)
{
line->setObject2Id(id);
line->RefreshGeometry();
if (buildMidpoint)
{
SetFormula(currentLength + QLatin1String("/2"));
}
line->RefreshGeometry();
prepare = true;
this->setModal(true);
this->show();
@ -270,6 +270,9 @@ void DialogAlongLine::Build(const Tool &type)
if (type == Tool::Midpoint)
{
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)
: VisLine(data, parent), object2Id(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), line(nullptr),
length(0)
: VisLine(data, parent),
object2Id(NULL_ID),
point(nullptr),
lineP1(nullptr),
lineP2(nullptr),
line(nullptr),
length(0),
m_midPointMode(false)
{
this->mainColor = Qt::red;
this->setZValue(2);// Show on top real tool
@ -69,6 +75,12 @@ void VisToolAlongLine::setLength(const QString &expression)
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolAlongLine::setMidPointMode(bool midPointMode)
{
m_midPointMode = midPointMode;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolAlongLine::RefreshGeometry()
{
@ -79,7 +91,14 @@ void VisToolAlongLine::RefreshGeometry()
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
{

View file

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