Added support elliptical arc in other tools.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-12-20 13:04:56 +02:00
parent ead39f6c47
commit f0b35ddc11
20 changed files with 220 additions and 91 deletions

View File

@ -316,6 +316,7 @@ void MainWindow::InitScenes()
connect(this, &MainWindow::EnablePointSelection, sceneDraw, &VMainGraphicsScene::TogglePointSelection);
connect(this, &MainWindow::EnableLineSelection, sceneDraw, &VMainGraphicsScene::ToggleLineSelection);
connect(this, &MainWindow::EnableArcSelection, sceneDraw, &VMainGraphicsScene::ToggleArcSelection);
connect(this, &MainWindow::EnableElArcSelection, sceneDraw, &VMainGraphicsScene::ToggleElArcSelection);
connect(this, &MainWindow::EnableSplineSelection, sceneDraw, &VMainGraphicsScene::ToggleSplineSelection);
connect(this, &MainWindow::EnableSplinePathSelection, sceneDraw, &VMainGraphicsScene::ToggleSplinePathSelection);
@ -323,6 +324,7 @@ void MainWindow::InitScenes()
connect(this, &MainWindow::EnablePointHover, sceneDraw, &VMainGraphicsScene::TogglePointHover);
connect(this, &MainWindow::EnableLineHover, sceneDraw, &VMainGraphicsScene::ToggleLineHover);
connect(this, &MainWindow::EnableArcHover, sceneDraw, &VMainGraphicsScene::ToggleArcHover);
connect(this, &MainWindow::EnableElArcHover, sceneDraw, &VMainGraphicsScene::ToggleElArcHover);
connect(this, &MainWindow::EnableSplineHover, sceneDraw, &VMainGraphicsScene::ToggleSplineHover);
connect(this, &MainWindow::EnableSplinePathHover, sceneDraw, &VMainGraphicsScene::ToggleSplinePathHover);
@ -1973,6 +1975,7 @@ void MainWindow::ArrowTool()
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableElArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
emit EnableNodeLabelSelection(true);
@ -1984,6 +1987,7 @@ void MainWindow::ArrowTool()
emit EnablePointHover(true);
emit EnableLineHover(true);
emit EnableArcHover(true);
emit EnableElArcHover(true);
emit EnableSplineHover(true);
emit EnableSplinePathHover(true);
emit EnableNodeLabelHover(true);
@ -4712,6 +4716,7 @@ void MainWindow::ToolSelectPoint() const
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableElArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4720,6 +4725,7 @@ void MainWindow::ToolSelectPoint() const
emit EnablePointHover(true);
emit EnableLineHover(false);
emit EnableArcHover(false);
emit EnableElArcHover(false);
emit EnableSplineHover(false);
emit EnableSplinePathHover(false);
@ -4748,6 +4754,7 @@ void MainWindow::ToolSelectSpline() const
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableElArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4756,6 +4763,7 @@ void MainWindow::ToolSelectSpline() const
emit EnablePointHover(false);
emit EnableLineHover(false);
emit EnableArcHover(false);
emit EnableElArcHover(false);
emit EnableSplineHover(true);
emit EnableSplinePathHover(false);
@ -4772,6 +4780,7 @@ void MainWindow::ToolSelectSplinePath() const
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableElArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4780,6 +4789,7 @@ void MainWindow::ToolSelectSplinePath() const
emit EnablePointHover(false);
emit EnableLineHover(false);
emit EnableArcHover(false);
emit EnableElArcHover(false);
emit EnableSplineHover(false);
emit EnableSplinePathHover(true);
@ -4796,6 +4806,7 @@ void MainWindow::ToolSelectArc() const
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableElArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4804,6 +4815,33 @@ void MainWindow::ToolSelectArc() const
emit EnablePointHover(false);
emit EnableLineHover(false);
emit EnableArcHover(true);
emit EnableElArcHover(false);
emit EnableSplineHover(false);
emit EnableSplinePathHover(false);
emit ItemsSelection(SelectionType::ByMouseRelease);
ui->view->AllowRubberBand(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectElArc() const
{
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableElArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
// Hovering
emit EnableLabelHover(false);
emit EnablePointHover(false);
emit EnableLineHover(false);
emit EnableArcHover(false);
emit EnableElArcHover(true);
emit EnableSplineHover(false);
emit EnableSplinePathHover(false);
@ -4820,6 +4858,7 @@ void MainWindow::ToolSelectPointArc() const
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableElArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4828,6 +4867,7 @@ void MainWindow::ToolSelectPointArc() const
emit EnablePointHover(true);
emit EnableLineHover(false);
emit EnableArcHover(true);
emit EnableElArcHover(false);
emit EnableSplineHover(false);
emit EnableSplinePathHover(false);
@ -4844,6 +4884,7 @@ void MainWindow::ToolSelectCurve() const
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableElArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4852,6 +4893,7 @@ void MainWindow::ToolSelectCurve() const
emit EnablePointHover(false);
emit EnableLineHover(false);
emit EnableArcHover(true);
emit EnableElArcHover(true);
emit EnableSplineHover(true);
emit EnableSplinePathHover(true);
@ -4868,6 +4910,7 @@ void MainWindow::ToolSelectAllDrawObjects() const
emit EnablePointSelection(false);
emit EnableLineSelection(false);
emit EnableArcSelection(false);
emit EnableElArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
@ -4876,6 +4919,7 @@ void MainWindow::ToolSelectAllDrawObjects() const
emit EnablePointHover(true);
emit EnableLineHover(false);
emit EnableArcHover(true);
emit EnableElArcHover(true);
emit EnableSplineHover(true);
emit EnableSplinePathHover(true);
@ -4892,6 +4936,7 @@ void MainWindow::ToolSelectOperationObjects() const
emit EnablePointSelection(true);
emit EnableLineSelection(false);
emit EnableArcSelection(true);
emit EnableElArcSelection(true);
emit EnableSplineSelection(true);
emit EnableSplinePathSelection(true);
@ -4900,6 +4945,7 @@ void MainWindow::ToolSelectOperationObjects() const
emit EnablePointHover(true);
emit EnableLineHover(false);
emit EnableArcHover(true);
emit EnableElArcHover(true);
emit EnableSplineHover(true);
emit EnableSplinePathHover(true);

View File

@ -78,6 +78,7 @@ signals:
void EnablePointSelection(bool enable) const;
void EnableLineSelection(bool enable) const;
void EnableArcSelection(bool enable) const;
void EnableElArcSelection(bool enable) const;
void EnableSplineSelection(bool enable) const;
void EnableSplinePathSelection(bool enable) const;
void EnableNodeLabelSelection(bool enable) const;
@ -88,6 +89,7 @@ signals:
void EnablePointHover(bool enable) const;
void EnableLineHover(bool enable) const;
void EnableArcHover(bool enable) const;
void EnableElArcHover(bool enable) const;
void EnableSplineHover(bool enable) const;
void EnableSplinePathHover(bool enable) const;
void EnableNodeLabelHover(bool enable) const;
@ -346,6 +348,7 @@ private:
void ToolSelectSpline() const;
void ToolSelectSplinePath() const;
void ToolSelectArc() const;
void ToolSelectElArc() const;
void ToolSelectPointArc() const;
void ToolSelectCurve() const;
void ToolSelectAllDrawObjects() const;

View File

@ -382,25 +382,28 @@ void VContainer::AddLine(const quint32 &firstPointId, const quint32 &secondPoint
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::AddArc(const QSharedPointer<VArc> &arc, const quint32 &id, const quint32 &parentId)
void VContainer::AddArc(const QSharedPointer<VAbstractCurve> &arc, const quint32 &id, const quint32 &parentId)
{
AddCurve(arc, id, parentId);
VArcRadius *radius = new VArcRadius(id, parentId, arc.data(), *GetPatternUnit());
if (arc->getType() == GOType::Arc)
{
const QSharedPointer<VArc> casted = arc.staticCast<VArc>();
VArcRadius *radius = new VArcRadius(id, parentId, casted.data(), *GetPatternUnit());
AddVariable(radius->GetName(), radius);
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::AddEllipticalArc(const QSharedPointer<VEllipticalArc> &arc, const quint32 &id, const quint32 &parentId)
else if (arc->getType() == GOType::EllipticalArc)
{
AddCurve(arc, id, parentId);
const QSharedPointer<VEllipticalArc> casted = arc.staticCast<VEllipticalArc>();
VEllipticalArcRadius *radius1 = new VEllipticalArcRadius(id, parentId, arc.data(), 1, *GetPatternUnit());
VEllipticalArcRadius *radius1 = new VEllipticalArcRadius(id, parentId, casted.data(), 1, *GetPatternUnit());
AddVariable(radius1->GetName(), radius1);
VEllipticalArcRadius *radius2 = new VEllipticalArcRadius(id, parentId, arc.data(), 2, *GetPatternUnit());
VEllipticalArcRadius *radius2 = new VEllipticalArcRadius(id, parentId, casted.data(), 2, *GetPatternUnit());
AddVariable(radius2->GetName(), radius2);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::AddCurve(const QSharedPointer<VAbstractCurve> &curve, const quint32 &id, quint32 parentId)

View File

@ -146,8 +146,7 @@ public:
quint32 AddGObject(VGObject *obj);
quint32 AddDetail(const VDetail &detail);
void AddLine(const quint32 &firstPointId, const quint32 &secondPointId);
void AddArc(const QSharedPointer<VArc> &arc, const quint32 &arcId, const quint32 &parentId = NULL_ID);
void AddEllipticalArc(const QSharedPointer<VEllipticalArc> &arc, const quint32 &arcId,
void AddArc(const QSharedPointer<VAbstractCurve> &arc, const quint32 &arcId,
const quint32 &parentId = NULL_ID);
void AddSpline(const QSharedPointer<VAbstractBezier> &curve, quint32 id, quint32 parentId = NULL_ID);
void AddCurveWithSegments(const QSharedPointer<VAbstractCubicBezierPath> &curve, const quint32 &id,

View File

@ -222,9 +222,12 @@ void DialogTool::FillComboBoxCurves(QComboBox *box) const
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if ((obj->getType() == GOType::Arc || obj->getType() == GOType::Spline ||
obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezier ||
obj->getType() == GOType::CubicBezierPath) && obj->getMode() == Draw::Calculation)
if ((obj->getType() == GOType::Arc
|| obj->getType() == GOType::EllipticalArc
|| obj->getType() == GOType::Spline
|| obj->getType() == GOType::SplinePath
|| obj->getType() == GOType::CubicBezier
|| obj->getType() == GOType::CubicBezierPath) && obj->getMode() == Draw::Calculation)
{
PrepareList<VAbstractCurve>(list, i.key());
}

View File

@ -29,6 +29,7 @@
#include "vabstractflipping.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
#include "../vgeometry/vgobject.h"
@ -77,10 +78,10 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
dest.append(CreatePoint(id, idObject, fPoint, sPoint, suffix, data));
break;
case GOType::Arc:
dest.append(CreateArc(id, idObject, fPoint, sPoint, suffix, data));
dest.append(CreateArc<VArc>(id, idObject, fPoint, sPoint, suffix, data));
break;
case GOType::EllipticalArc:
//dest.append(CreateItem<VEllipticalArc>(id, idObject, fPoint, sPoint, suffix));
dest.append(CreateArc<VEllipticalArc>(id, idObject, fPoint, sPoint, suffix, data));
break;
case GOType::Spline:
dest.append(CreateCurve<VSpline>(id, idObject, fPoint, sPoint, suffix, data));
@ -119,10 +120,10 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
dest.at(i).my);
break;
case GOType::Arc:
UpdateArc(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
UpdateArc<VArc>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
break;
case GOType::EllipticalArc:
//dest.append(UpdateItem<VEllipticalArc>(id, idObject, fPoint, sPoint, suffix, data));
UpdateArc<VEllipticalArc>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
break;
case GOType::Spline:
UpdateCurve<VSpline>(id, idObject, fPoint, sPoint, suffix, data, dest.at(i).id);
@ -165,11 +166,12 @@ DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, quint32 idItem, c
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VAbstractFlipping::CreateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data)
{
const DestinationItem item = CreateItem<VArc>(idTool, idItem, firstPoint, secondPoint, suffix, data);
data->AddArc(data->GeometricObject<VArc>(item.id), item.id);
const DestinationItem item = CreateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data);
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
return item;
}
@ -187,9 +189,10 @@ void VAbstractFlipping::UpdatePoint(quint32 idTool, quint32 idItem, const QPoint
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VAbstractFlipping::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id)
{
UpdateItem<VArc>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
data->AddArc(data->GeometricObject<VArc>(id), id);
UpdateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
data->AddArc(data->GeometricObject<Item>(id), id);
}

View File

@ -54,6 +54,7 @@ protected:
template <class Item>
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
template <class Item>
@ -68,6 +69,7 @@ protected:
template <class Item>
static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id);
template <class Item>
static void UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id);
template <class Item>

View File

@ -329,6 +329,18 @@ void VAbstractOperation::AllowArcSelecting(bool enabled)
AllowCurveSelecting(enabled, GOType::Arc);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowElArcHover(bool enabled)
{
AllowCurveHover(enabled, GOType::EllipticalArc);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowElArcSelecting(bool enabled)
{
AllowCurveSelecting(enabled, GOType::EllipticalArc);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::Disable(bool disable, const QString &namePP)
{
@ -575,7 +587,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
case GOType::Arc:
case GOType::EllipticalArc:
{
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), GOType::Arc);
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType());
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
{
emit ChoosedTool(id, SceneObject::Arc);
@ -585,7 +597,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
case GOType::Spline:
case GOType::CubicBezier:
{
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), GOType::Spline);
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType());
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
{
emit ChoosedTool(id, SceneObject::Spline);
@ -595,7 +607,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
case GOType::SplinePath:
case GOType::CubicBezierPath:
{
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), GOType::SplinePath);
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType());
connect(curve, &VSimpleCurve::Choosed, [this](quint32 id)
{
emit ChoosedTool(id, SceneObject::SplinePath);

View File

@ -108,6 +108,9 @@ public slots:
void AllowArcHover(bool enabled);
void AllowArcSelecting(bool enabled);
void AllowElArcHover(bool enabled);
void AllowElArcSelecting(bool enabled);
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
void ObjectSelected(bool selected, quint32 objId);
void DeleteFromLabel();
@ -197,6 +200,9 @@ void VAbstractOperation::InitOperationToolConnections(VMainGraphicsScene *scene,
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemHover, tool, &T::AllowArcHover);
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemSelection, tool, &T::AllowArcSelecting);
QObject::connect(scene, &VMainGraphicsScene::EnableElArcItemHover, tool, &T::AllowElArcHover);
QObject::connect(scene, &VMainGraphicsScene::EnableElArcItemSelection, tool, &T::AllowElArcSelecting);
}
#endif // VABSTRACTOPERATION_H

View File

@ -48,6 +48,7 @@
#include "../../../visualization/visualization.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
#include "../vgeometry/vgobject.h"
@ -152,10 +153,10 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
dest.append(CreatePoint(id, idObject, calcAngle, calcLength, suffix, data));
break;
case GOType::Arc:
dest.append(CreateArc(id, idObject, calcAngle, calcLength, suffix, data));
dest.append(CreateArc<VArc>(id, idObject, calcAngle, calcLength, suffix, data));
break;
case GOType::EllipticalArc:
//dest.append(CreateItem<VEllipticalArc>(id, idObject, angle, suffix));
dest.append(CreateArc<VEllipticalArc>(id, idObject, calcAngle, calcLength, suffix, data));
break;
case GOType::Spline:
dest.append(CreateCurve<VSpline>(id, idObject, calcAngle, calcLength, suffix, data));
@ -196,10 +197,10 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
dest.at(i).my);
break;
case GOType::Arc:
UpdateArc(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
UpdateArc<VArc>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
break;
case GOType::EllipticalArc:
//dest.append(UpdateItem<VEllipticalArc>(id, idObject, oPoint, angle, suffix, data));
UpdateArc<VEllipticalArc>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
break;
case GOType::Spline:
UpdateCurve<VSpline>(id, idObject, calcAngle, calcLength, suffix, data, dest.at(i).id);
@ -385,11 +386,12 @@ DestinationItem VToolMove::CreatePoint(quint32 idTool, quint32 idItem, qreal ang
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VToolMove::CreateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data)
{
const DestinationItem item = CreateItem<VArc>(idTool, idItem, angle, length, suffix, data);
data->AddArc(data->GeometricObject<VArc>(item.id), item.id);
const DestinationItem item = CreateItem<Item>(idTool, idItem, angle, length, suffix, data);
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
return item;
}
@ -406,11 +408,12 @@ void VToolMove::UpdatePoint(quint32 idTool, quint32 idItem, qreal angle, qreal l
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VToolMove::UpdateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data, quint32 id)
{
UpdateItem<VArc>(idTool, idItem, angle, length, suffix, data, id);
data->AddArc(data->GeometricObject<VArc>(id), id);
UpdateItem<Item>(idTool, idItem, angle, length, suffix, data, id);
data->AddArc(data->GeometricObject<Item>(id), id);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -101,6 +101,7 @@ private:
template <class Item>
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data);
template <class Item>
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data);
template <class Item>
@ -115,6 +116,7 @@ private:
template <class Item>
static void UpdateItem(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data, quint32 id);
template <class Item>
static void UpdateArc(quint32 idTool, quint32 idItem, qreal angle, qreal length, const QString &suffix,
VContainer *data, quint32 id);
template <class Item>

View File

@ -48,6 +48,7 @@
#include "../../../visualization/visualization.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
#include "../vgeometry/vgobject.h"
@ -165,10 +166,10 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
dest.append(CreatePoint(id, idObject, oPoint, calcAngle, suffix, data));
break;
case GOType::Arc:
dest.append(CreateArc(id, idObject, oPoint, calcAngle, suffix, data));
dest.append(CreateArc<VArc>(id, idObject, oPoint, calcAngle, suffix, data));
break;
case GOType::EllipticalArc:
//dest.append(CreateItem<VEllipticalArc>(id, idObject, oPoint, angle, suffix));
dest.append(CreateArc<VEllipticalArc>(id, idObject, oPoint, calcAngle, suffix, data));
break;
case GOType::Spline:
dest.append(CreateCurve<VSpline>(id, idObject, oPoint, calcAngle, suffix, data));
@ -208,10 +209,10 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
dest.at(i).my);
break;
case GOType::Arc:
UpdateArc(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
UpdateArc<VArc>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
break;
case GOType::EllipticalArc:
//dest.append(UpdateItem<VEllipticalArc>(id, idObject, oPoint, angle, suffix, data));
UpdateArc<VEllipticalArc>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
break;
case GOType::Spline:
UpdateCurve<VSpline>(id, idObject, oPoint, calcAngle, suffix, data, dest.at(i).id);
@ -376,11 +377,12 @@ DestinationItem VToolRotation::CreateItem(quint32 idTool, quint32 idItem, const
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VToolRotation::CreateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
const QString &suffix, VContainer *data)
{
const DestinationItem item = CreateItem<VArc>(idTool, idItem, origin, angle, suffix, data);
data->AddArc(data->GeometricObject<VArc>(item.id), item.id);
const DestinationItem item = CreateItem<Item>(idTool, idItem, origin, angle, suffix, data);
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
return item;
}
@ -428,11 +430,12 @@ void VToolRotation::UpdateItem(quint32 idTool, quint32 idItem, const QPointF &or
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VToolRotation::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
const QString &suffix, VContainer *data, quint32 id)
{
UpdateItem<VArc>(idTool, idItem, origin, angle, suffix, data, id);
data->AddArc(data->GeometricObject<VArc>(id), id);
UpdateItem<Item>(idTool, idItem, origin, angle, suffix, data, id);
data->AddArc(data->GeometricObject<Item>(id), id);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -98,6 +98,7 @@ private:
template <class Item>
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data);
template <class Item>
@ -112,6 +113,7 @@ private:
template <class Item>
static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data, quint32 id);
template <class Item>
static void UpdateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal formulaAngle,
const QString &suffix, VContainer *data, quint32 id);
template <class Item>

View File

@ -133,6 +133,9 @@ protected:
template <typename T>
static void InitArcToolConnections(VMainGraphicsScene *scene, T *tool);
template <typename T>
static void InitElArcToolConnections(VMainGraphicsScene *scene, T *tool);
private:
Q_DISABLE_COPY(VAbstractSpline)
};
@ -212,4 +215,16 @@ void VAbstractSpline::InitArcToolConnections(VMainGraphicsScene *scene, T *tool)
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemSelection, tool, &T::AllowSelecting);
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VAbstractSpline::InitElArcToolConnections(VMainGraphicsScene *scene, T *tool)
{
SCASSERT(scene != nullptr);
SCASSERT(tool != nullptr);
InitDrawToolConnections(scene, tool);
QObject::connect(scene, &VMainGraphicsScene::EnableElArcItemHover, tool, &T::AllowHover);
QObject::connect(scene, &VMainGraphicsScene::EnableElArcItemSelection, tool, &T::AllowSelecting);
}
#endif // VABSTRACTSPLINE_H

View File

@ -173,12 +173,12 @@ VToolEllipticalArc* VToolEllipticalArc::Create(const quint32 _id, const quint32
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(elArc);
data->AddEllipticalArc(data->GeometricObject<VEllipticalArc>(id), id);
data->AddArc(data->GeometricObject<VEllipticalArc>(id), id);
}
else
{
data->UpdateGObject(id, elArc);
data->AddEllipticalArc(data->GeometricObject<VEllipticalArc>(id), id);
data->AddArc(data->GeometricObject<VEllipticalArc>(id), id);
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
@ -189,7 +189,7 @@ VToolEllipticalArc* VToolEllipticalArc::Create(const quint32 _id, const quint32
{
VToolEllipticalArc *toolEllipticalArc = new VToolEllipticalArc(doc, data, id, typeCreation);
scene->addItem(toolEllipticalArc);
InitArcToolConnections(scene, toolEllipticalArc);
InitElArcToolConnections(scene, toolEllipticalArc);
doc->AddTool(id, toolEllipticalArc);
doc->IncrementReferens(c.getIdTool());
return toolEllipticalArc;

View File

@ -59,8 +59,9 @@ public:
virtual void setDialog() Q_DECL_OVERRIDE;
static VToolEllipticalArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data);
static VToolEllipticalArc* Create(const quint32 _id, const quint32 &center, QString &radius1, QString &radius2, QString &f1, QString &f2, QString &rotationAngle,
const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
static VToolEllipticalArc* Create(const quint32 _id, const quint32 &center, QString &radius1, QString &radius2,
QString &f1, QString &f2, QString &rotationAngle, const QString &color,
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}

View File

@ -49,6 +49,7 @@
#include "../vgeometry/vabstractcubicbezierpath.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h"
#include "../vgeometry/vspline.h"
@ -327,21 +328,15 @@ void VToolCurveIntersectAxis::SetVisualization()
}
//---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLength, const VPointF *p, quint32 curveId,
VContainer *data)
template <class Item>
void VToolCurveIntersectAxis::InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId)
{
switch(curveType)
{
case GOType::Arc:
{
QSharedPointer<VArc> a1;
QSharedPointer<VArc> a2;
QSharedPointer<Item> a1;
QSharedPointer<Item> a2;
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(curveId);
VArc arc1;
VArc arc2;
const QSharedPointer<Item> arc = data->GeometricObject<Item>(curveId);
Item arc1;
Item arc2;
if (not VFuzzyComparePossibleNulls(segLength, -1))
{
@ -358,13 +353,13 @@ void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLen
if (not VFuzzyComparePossibleNulls(segLength, -1))
{
a1 = QSharedPointer<VArc>(new VArc(arc1));
a2 = QSharedPointer<VArc>(new VArc(arc2));
a1 = QSharedPointer<Item>(new Item(arc1));
a2 = QSharedPointer<Item>(new Item(arc2));
}
else
{
a1 = QSharedPointer<VArc>(new VArc());
a2 = QSharedPointer<VArc>(new VArc());
a1 = QSharedPointer<Item>(new Item());
a2 = QSharedPointer<Item>(new Item());
// Take names for empty arcs from donors.
a1->setName(arc1.name());
@ -373,8 +368,22 @@ void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLen
data->AddArc(a1, arc1.id(), p->id());
data->AddArc(a2, arc2.id(), p->id());
break;
}
//---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLength, const VPointF *p, quint32 curveId,
VContainer *data)
{
switch(curveType)
{
case GOType::EllipticalArc:
InitArc<VEllipticalArc>(data, segLength, p, curveId);
break;
case GOType::Arc:
InitArc<VArc>(data, segLength, p, curveId);
break;
case GOType::CubicBezier:
case GOType::Spline:
{
@ -462,7 +471,6 @@ void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLen
data->AddSpline(splP2, NULL_ID, p->id());
break;
}
case GOType::EllipticalArc:
case GOType::Point:
case GOType::Unknown:
Q_UNREACHABLE();

View File

@ -98,6 +98,8 @@ private:
const QString &lineColor, const QString &formulaAngle, const quint32 &basePointId,
const quint32 &curveId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
template <class Item>
static void InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId);
static void InitSegments(const GOType &curveType, qreal segLength, const VPointF *p, quint32 curveId,
VContainer *data);
};

View File

@ -333,6 +333,12 @@ void VMainGraphicsScene::ToggleArcSelection(bool enabled)
emit EnableArcItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleElArcSelection(bool enabled)
{
emit EnableElArcItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleSplineSelection(bool enabled)
{
@ -387,6 +393,12 @@ void VMainGraphicsScene::ToggleArcHover(bool enabled)
emit EnableArcItemHover(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleElArcHover(bool enabled)
{
emit EnableElArcItemHover(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleSplineHover(bool enabled)
{

View File

@ -81,6 +81,7 @@ public slots:
void TogglePointSelection(bool enabled);
void ToggleLineSelection(bool enabled);
void ToggleArcSelection(bool enabled);
void ToggleElArcSelection(bool enabled);
void ToggleSplineSelection(bool enabled);
void ToggleSplinePathSelection(bool enabled);
void ToggleNodeLabelSelection(bool enabled);
@ -91,6 +92,7 @@ public slots:
void TogglePointHover(bool enabled);
void ToggleLineHover(bool enabled);
void ToggleArcHover(bool enabled);
void ToggleElArcHover(bool enabled);
void ToggleSplineHover(bool enabled);
void ToggleSplinePathHover(bool enabled);
void ToggleNodeLabelHover(bool enabled);
@ -133,6 +135,7 @@ signals:
void EnablePointItemSelection(bool enable);
void EnableLineItemSelection(bool enable);
void EnableArcItemSelection(bool enable);
void EnableElArcItemSelection(bool enable);
void EnableSplineItemSelection(bool enable);
void EnableSplinePathItemSelection(bool enable);
void EnableNodeLabelItemSelection(bool enabled);
@ -142,6 +145,7 @@ signals:
void EnableLabelItemHover(bool enable);
void EnablePointItemHover(bool enable);
void EnableArcItemHover(bool enable);
void EnableElArcItemHover(bool enable);
void EnableSplineItemHover(bool enable);
void EnableSplinePathItemHover(bool enable);
void EnableNodeLabelItemHover(bool enabled);