Successful show first point.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-05-27 19:24:20 +03:00
parent 2beac39ce1
commit e37e2d48f3
16 changed files with 189 additions and 66 deletions

View File

@ -106,7 +106,7 @@ void DialogPointOfIntersectionArcs::SetSecondArcId(const quint32 &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
CrossArcPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const CrossArcsPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const
{ {
int value; int value;
bool ok = false; bool ok = false;
@ -117,25 +117,25 @@ CrossArcPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const
#endif #endif
if (not ok) if (not ok)
{ {
return CrossArcPoint::FirstPoint; return CrossArcsPoint::FirstPoint;
} }
switch(value) switch(value)
{ {
case 1: case 1:
return CrossArcPoint::FirstPoint; return CrossArcsPoint::FirstPoint;
break; break;
case 2: case 2:
return CrossArcPoint::SecondPoint; return CrossArcsPoint::SecondPoint;
break; break;
default: default:
return CrossArcPoint::FirstPoint; return CrossArcsPoint::FirstPoint;
break; break;
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossArcPoint &p) void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossArcsPoint &p)
{ {
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p)); const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
if (index != -1) if (index != -1)
@ -164,15 +164,15 @@ void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject &
if (SetObject(id, ui->comboBoxArc1, tr("Select second an arc"))) if (SetObject(id, ui->comboBoxArc1, tr("Select second an arc")))
{ {
number++; number++;
point->setArc1Id(id); point->VisualMode(id);
point->RefreshGeometry();
} }
break; break;
case 1: case 1:
if (getCurrentObjectId(ui->comboBoxArc2) != id) if (getCurrentObjectId(ui->comboBoxArc1) != id)
{ {
if (SetObject(id, ui->comboBoxArc2, "")) if (SetObject(id, ui->comboBoxArc2, ""))
{ {
number = 0;
point->setArc2Id(id); point->setArc2Id(id);
point->RefreshGeometry(); point->RefreshGeometry();
prepare = true; prepare = true;
@ -229,6 +229,6 @@ void DialogPointOfIntersectionArcs::SaveData()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::FillComboBoxCrossArcPoints() void DialogPointOfIntersectionArcs::FillComboBoxCrossArcPoints()
{ {
ui->comboBoxResult->addItem(tr("First point"), QVariant(static_cast<int>(CrossArcPoint::FirstPoint))); ui->comboBoxResult->addItem(tr("First point"), QVariant(static_cast<int>(CrossArcsPoint::FirstPoint)));
ui->comboBoxResult->addItem(tr("Second point"), QVariant(static_cast<int>(CrossArcPoint::SecondPoint))); ui->comboBoxResult->addItem(tr("Second point"), QVariant(static_cast<int>(CrossArcsPoint::SecondPoint)));
} }

View File

@ -53,8 +53,8 @@ public:
quint32 GetSecondArcId() const; quint32 GetSecondArcId() const;
void SetSecondArcId(const quint32 &value); void SetSecondArcId(const quint32 &value);
CrossArcPoint GetCrossArcPoint() const; CrossArcsPoint GetCrossArcPoint() const;
void SetCrossArcPoint(CrossArcPoint &p); void SetCrossArcPoint(CrossArcsPoint &p);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);

View File

@ -6,19 +6,19 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>285</width> <width>300</width>
<height>179</height> <height>179</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>285</width> <width>300</width>
<height>179</height> <height>179</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>285</width> <width>300</width>
<height>179</height> <height>179</height>
</size> </size>
</property> </property>

View File

@ -696,7 +696,7 @@ void MainWindow::ToolCurveIntersectAxis(bool checked)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::PointOfIntersectionArcs(bool checked) void MainWindow::ToolPointOfIntersectionArcs(bool checked)
{ {
SetToolButtonWithApply<DialogPointOfIntersectionArcs>(checked, Tool::PointOfIntersectionArcs, SetToolButtonWithApply<DialogPointOfIntersectionArcs>(checked, Tool::PointOfIntersectionArcs,
"://cursor/point_of_intersection_arcs.png", "://cursor/point_of_intersection_arcs.png",
@ -1000,7 +1000,7 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonCurveIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); connect(ui->toolButtonCurveIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis);
connect(ui->toolButtonArcIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); connect(ui->toolButtonArcIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis);
connect(ui->toolButtonLayoutSettings, &QToolButton::clicked, this, &MainWindow::ToolLayoutSettings); connect(ui->toolButtonLayoutSettings, &QToolButton::clicked, this, &MainWindow::ToolLayoutSettings);
connect(ui->toolButtonPointOfIntersectionArcs, &QToolButton::clicked, this, &MainWindow::PointOfIntersectionArcs); connect(ui->toolButtonPointOfIntersectionArcs, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersectionArcs);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -2477,6 +2477,10 @@ void MainWindow::LastUsedTool()
ui->toolButtonPointOfIntersection->setChecked(true); ui->toolButtonPointOfIntersection->setChecked(true);
ToolPointOfIntersection(true); ToolPointOfIntersection(true);
break; break;
case Tool::PointOfIntersectionArcs:
ui->toolButtonPointOfIntersectionArcs->setChecked(true);
ToolPointOfIntersectionArcs(true);
break;
case Tool::CutSpline: case Tool::CutSpline:
ui->toolButtonSplineCutPoint->setChecked(true); ui->toolButtonSplineCutPoint->setChecked(true);
ToolCutSpline(true); ToolCutSpline(true);

View File

@ -115,7 +115,7 @@ public slots:
void ToolCutArc(bool checked); void ToolCutArc(bool checked);
void ToolLineIntersectAxis(bool checked); void ToolLineIntersectAxis(bool checked);
void ToolCurveIntersectAxis(bool checked); void ToolCurveIntersectAxis(bool checked);
void PointOfIntersectionArcs(bool checked); void ToolPointOfIntersectionArcs(bool checked);
void ClosedDialogDetail(int result); void ClosedDialogDetail(int result);
void ClosedDialogUnionDetails(int result); void ClosedDialogUnionDetails(int result);

View File

@ -50,7 +50,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>105</width> <width>100</width>
<height>272</height> <height>272</height>
</rect> </rect>
</property> </property>
@ -337,7 +337,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>105</width> <width>100</width>
<height>58</height> <height>58</height>
</rect> </rect>
</property> </property>
@ -413,7 +413,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>105</width> <width>100</width>
<height>156</height> <height>156</height>
</rect> </rect>
</property> </property>
@ -683,6 +683,9 @@
<height>32</height> <height>32</height>
</size> </size>
</property> </property>
<property name="checkable">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -692,7 +695,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>105</width> <width>100</width>
<height>58</height> <height>58</height>
</rect> </rect>
</property> </property>
@ -768,8 +771,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>105</width> <width>98</width>
<height>380</height> <height>58</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">

View File

@ -37,7 +37,7 @@ const QString VToolPointOfIntersectionArcs::ToolType = QStringLiteral("pointOfIn
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id, VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id,
const quint32 &firstArcId, const quint32 &secondArcId, const quint32 &firstArcId, const quint32 &secondArcId,
CrossArcPoint pType, const Source &typeCreation, CrossArcsPoint pType, const Source &typeCreation,
QGraphicsItem *parent) QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType) :VToolPoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType)
{ {
@ -73,7 +73,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(DialogTool *d
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const quint32 firstArcId = dialogTool->GetFirstArcId(); const quint32 firstArcId = dialogTool->GetFirstArcId();
const quint32 secondArcId = dialogTool->GetSecondArcId(); const quint32 secondArcId = dialogTool->GetSecondArcId();
const CrossArcPoint pType = dialogTool->GetCrossArcPoint(); const CrossArcsPoint pType = dialogTool->GetCrossArcPoint();
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
VToolPointOfIntersectionArcs *point = nullptr; VToolPointOfIntersectionArcs *point = nullptr;
point = Create(0, pointName, firstArcId, secondArcId, pType, 5, 10, scene, doc, data, Document::FullParse, point = Create(0, pointName, firstArcId, secondArcId, pType, 5, 10, scene, doc, data, Document::FullParse,
@ -88,7 +88,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(DialogTool *d
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 _id, const QString &pointName, VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 _id, const QString &pointName,
const quint32 &firstArcId, const quint32 &firstArcId,
const quint32 &secondArcId, CrossArcPoint pType, const quint32 &secondArcId, CrossArcsPoint pType,
const qreal &mx, const qreal &my, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, VContainer *data, const Document &parse,
@ -130,7 +130,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcPoint pType) QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcsPoint pType)
{ {
QPointF p1, p2; QPointF p1, p2;
const int res = VGObject::IntersectionCircles(arc1->GetCenter().toQPointF(), arc1->GetRadius(), const int res = VGObject::IntersectionCircles(arc1->GetCenter().toQPointF(), arc1->GetRadius(),
@ -139,7 +139,7 @@ QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *ar
switch(res) switch(res)
{ {
case 2: case 2:
if (pType == CrossArcPoint::FirstPoint) if (pType == CrossArcsPoint::FirstPoint)
{ {
return p1; return p1;
} }
@ -196,13 +196,13 @@ void VToolPointOfIntersectionArcs::SetSecondArcId(const quint32 &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
CrossArcPoint VToolPointOfIntersectionArcs::GetCrossArcPoint() const CrossArcsPoint VToolPointOfIntersectionArcs::GetCrossArcsPoint() const
{ {
return crossPoint; return crossPoint;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::SetCrossArcPoint(CrossArcPoint &value) void VToolPointOfIntersectionArcs::SetCrossArcsPoint(CrossArcsPoint &value)
{ {
crossPoint = value; crossPoint = value;
@ -271,7 +271,7 @@ void VToolPointOfIntersectionArcs::ReadToolAttributes(const QDomElement &domElem
{ {
firstArcId = doc->GetParametrUInt(domElement, AttrFirstArc, NULL_ID_STR); firstArcId = doc->GetParametrUInt(domElement, AttrFirstArc, NULL_ID_STR);
secondArcId = doc->GetParametrUInt(domElement, AttrSecondArc, NULL_ID_STR); secondArcId = doc->GetParametrUInt(domElement, AttrSecondArc, NULL_ID_STR);
crossPoint = static_cast<CrossArcPoint>(doc->GetParametrUInt(domElement, AttrCrossPoint, "1")); crossPoint = static_cast<CrossArcsPoint>(doc->GetParametrUInt(domElement, AttrCrossPoint, "1"));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -40,17 +40,17 @@ class VToolPointOfIntersectionArcs : public VToolPoint
public: public:
VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstArcId, VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstArcId,
const quint32 &secondArcId, CrossArcPoint crossPoint, const Source &typeCreation, const quint32 &secondArcId, CrossArcsPoint crossPoint, const Source &typeCreation,
QGraphicsItem * parent = nullptr); QGraphicsItem * parent = nullptr);
virtual void setDialog(); virtual void setDialog();
static VToolPointOfIntersectionArcs *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, static VToolPointOfIntersectionArcs *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data); VContainer *data);
static VToolPointOfIntersectionArcs *Create(const quint32 _id, const QString &pointName, const quint32 &firstArcId, static VToolPointOfIntersectionArcs *Create(const quint32 _id, const QString &pointName, const quint32 &firstArcId,
const quint32 &secondArcId, CrossArcPoint crossPoint, const quint32 &secondArcId, CrossArcsPoint crossPoint,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation); const Source &typeCreation);
static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcPoint crossPoint); static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcsPoint crossPoint);
static const QString ToolType; static const QString ToolType;
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::PointOfIntersectionArcs) }; enum { Type = UserType + static_cast<int>(Tool::PointOfIntersectionArcs) };
@ -61,8 +61,8 @@ public:
quint32 GetSecondArcId() const; quint32 GetSecondArcId() const;
void SetSecondArcId(const quint32 &value); void SetSecondArcId(const quint32 &value);
CrossArcPoint GetCrossArcPoint() const; CrossArcsPoint GetCrossArcsPoint() const;
void SetCrossArcPoint(CrossArcPoint &value); void SetCrossArcsPoint(CrossArcsPoint &value);
virtual void ShowVisualization(bool show); virtual void ShowVisualization(bool show);
public slots: public slots:
@ -83,7 +83,7 @@ private:
/** @brief secondArcId id second arc. */ /** @brief secondArcId id second arc. */
quint32 secondArcId; quint32 secondArcId;
CrossArcPoint crossPoint; CrossArcsPoint crossPoint;
}; };
#endif // VTOOLPOINTOFINTERSECTIONARCS_H #endif // VTOOLPOINTOFINTERSECTIONARCS_H

View File

@ -33,7 +33,7 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VisToolPointOfIntersectionArcs::VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent) VisToolPointOfIntersectionArcs::VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent)
: VisLine(data, parent), arc1Id(NULL_ID), arc2Id(NULL_ID), crossPoint(CrossArcPoint::FirstPoint), point(nullptr), : VisLine(data, parent), arc1Id(NULL_ID), arc2Id(NULL_ID), crossPoint(CrossArcsPoint::FirstPoint), point(nullptr),
arc1Path(nullptr), arc2Path(nullptr) arc1Path(nullptr), arc2Path(nullptr)
{ {
arc1Path = InitItem<QGraphicsPathItem>(Qt::darkGreen, this); arc1Path = InitItem<QGraphicsPathItem>(Qt::darkGreen, this);
@ -56,12 +56,12 @@ void VisToolPointOfIntersectionArcs::RefreshGeometry()
if (arc1Id > NULL_ID) if (arc1Id > NULL_ID)
{ {
const QSharedPointer<VArc> arc1 = Visualization::data->GeometricObject<VArc>(arc1Id); const QSharedPointer<VArc> arc1 = Visualization::data->GeometricObject<VArc>(arc1Id);
DrawPath(arc1Path, arc1->GetPath(PathDirection::Hide), supportColor, Qt::SolidLine, Qt::RoundCap); DrawPath(arc1Path, arc1->GetPath(PathDirection::Hide), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap);
if (arc2Id > NULL_ID) if (arc2Id > NULL_ID)
{ {
const QSharedPointer<VArc> arc2 = Visualization::data->GeometricObject<VArc>(arc2Id); const QSharedPointer<VArc> arc2 = Visualization::data->GeometricObject<VArc>(arc2Id);
DrawPath(arc2Path, arc2->GetPath(PathDirection::Hide), supportColor, Qt::SolidLine, Qt::RoundCap); DrawPath(arc2Path, arc2->GetPath(PathDirection::Hide), Qt::darkRed, Qt::SolidLine, Qt::RoundCap);
const QPointF fPoint = VToolPointOfIntersectionArcs::FindPoint(arc1.data(), arc2.data(), crossPoint); const QPointF fPoint = VToolPointOfIntersectionArcs::FindPoint(arc1.data(), arc2.data(), crossPoint);
DrawPoint(point, fPoint, mainColor); DrawPoint(point, fPoint, mainColor);
@ -69,6 +69,19 @@ void VisToolPointOfIntersectionArcs::RefreshGeometry()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionArcs::VisualMode(const quint32 &id)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
this->arc1Id = id;
Visualization::scenePos = scene->getScenePos();
RefreshGeometry();
AddOnScene();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionArcs::setArc1Id(const quint32 &value) void VisToolPointOfIntersectionArcs::setArc1Id(const quint32 &value)
{ {
@ -82,7 +95,7 @@ void VisToolPointOfIntersectionArcs::setArc2Id(const quint32 &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossArcPoint &value) void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossArcsPoint &value)
{ {
crossPoint = value; crossPoint = value;
} }

View File

@ -40,10 +40,11 @@ public:
virtual ~VisToolPointOfIntersectionArcs(); virtual ~VisToolPointOfIntersectionArcs();
virtual void RefreshGeometry(); virtual void RefreshGeometry();
virtual void VisualMode(const quint32 &id);
void setArc1Id(const quint32 &value); void setArc1Id(const quint32 &value);
void setArc2Id(const quint32 &value); void setArc2Id(const quint32 &value);
void setCrossPoint(const CrossArcPoint &value); void setCrossPoint(const CrossArcsPoint &value);
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersection)}; enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersection)};
@ -51,7 +52,7 @@ private:
Q_DISABLE_COPY(VisToolPointOfIntersectionArcs) Q_DISABLE_COPY(VisToolPointOfIntersectionArcs)
quint32 arc1Id; quint32 arc1Id;
quint32 arc2Id; quint32 arc2Id;
CrossArcPoint crossPoint; CrossArcsPoint crossPoint;
QGraphicsEllipseItem *point; QGraphicsEllipseItem *point;
QGraphicsPathItem *arc1Path; QGraphicsPathItem *arc1Path;
QGraphicsPathItem *arc2Path; QGraphicsPathItem *arc2Path;

View File

@ -52,7 +52,7 @@ public:
void setPoint1Id(const quint32 &value); void setPoint1Id(const quint32 &value);
void setLineStyle(const Qt::PenStyle &value); void setLineStyle(const Qt::PenStyle &value);
void setScenePos(const QPointF &value); void setScenePos(const QPointF &value);
void VisualMode(const quint32 &pointId); virtual void VisualMode(const quint32 &pointId);
void setMainColor(const QColor &value); void setMainColor(const QColor &value);
signals: signals:
void ToolTip(const QString &toolTip); void ToolTip(const QString &toolTip);

View File

@ -116,6 +116,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
case VToolPointOfIntersection::Type: case VToolPointOfIntersection::Type:
ShowOptionsToolPointOfIntersection(item); ShowOptionsToolPointOfIntersection(item);
break; break;
case VToolPointOfIntersectionArcs::Type:
ShowOptionsToolPointOfIntersectionArcs(item);
break;
case VToolShoulderPoint::Type: case VToolShoulderPoint::Type:
ShowOptionsToolShoulderPoint(item); ShowOptionsToolShoulderPoint(item);
break; break;
@ -203,6 +206,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
case VToolPointOfIntersection::Type: case VToolPointOfIntersection::Type:
UpdateOptionsToolPointOfIntersection(); UpdateOptionsToolPointOfIntersection();
break; break;
case VToolPointOfIntersectionArcs::Type:
UpdateOptionsToolPointOfIntersectionArcs();
break;
case VToolShoulderPoint::Type: case VToolShoulderPoint::Type:
UpdateOptionsToolShoulderPoint(); UpdateOptionsToolShoulderPoint();
break; break;
@ -305,6 +311,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
case VToolPointOfIntersection::Type: case VToolPointOfIntersection::Type:
ChangeDataToolPointOfIntersection(prop); ChangeDataToolPointOfIntersection(prop);
break; break;
case VToolPointOfIntersectionArcs::Type:
ChangeDataToolPointOfIntersectionArcs(prop);
break;
case VToolShoulderPoint::Type: case VToolShoulderPoint::Type:
ChangeDataToolShoulderPoint(prop); ChangeDataToolShoulderPoint(prop);
break; break;
@ -388,6 +397,16 @@ void VToolOptionsPropertyBrowser::AddPropertyPointName(Tool *i, const QString &p
AddProperty(itemName, VAbstractTool::AttrName); AddProperty(itemName, VAbstractTool::AttrName);
} }
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyCrossPoint(Tool *i, const QString &propertyName)
{
VEnumProperty* itemProperty = new VEnumProperty(propertyName);
itemProperty->setLiterals(QStringList()<< tr("First point") << tr("Second point"));
itemProperty->setValue(static_cast<int>(i->GetCrossArcsPoint())-1);
AddProperty(itemProperty, VAbstractTool::AttrCrossPoint);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template<class Tool> template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &propertyName, void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &propertyName,
@ -827,6 +846,49 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersection(VProperty *p
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolPointOfIntersectionArcs(VProperty *property)
{
SCASSERT(property != nullptr)
const QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
const QString id = propertyToId[property];
VToolPointOfIntersectionArcs *i = qgraphicsitem_cast<VToolPointOfIntersectionArcs *>(currentItem);
SCASSERT(i != nullptr);
switch (PropertiesList().indexOf(id))
{
case 0: // VAbstractTool::AttrName
SetPointName<VToolPointOfIntersectionArcs>(value.toString());
break;
case 28: // VAbstractTool::AttrCrossPoint
{
const QVariant value = property->data(VProperty::DPC_Data, Qt::EditRole);
bool ok = false;
const int val = value.toInt(&ok);
CrossArcsPoint cross = CrossArcsPoint::FirstPoint;
if (ok)
{
switch(val)
{
case 0:
cross = CrossArcsPoint::FirstPoint;
case 1:
cross = CrossArcsPoint::SecondPoint;
default:
cross = CrossArcsPoint::FirstPoint;
}
}
i->SetCrossArcsPoint(cross);
break;
}
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolShoulderPoint(VProperty *property) void VToolOptionsPropertyBrowser::ChangeDataToolShoulderPoint(VProperty *property)
{ {
@ -1171,6 +1233,17 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersection(QGraphicsIt
AddPropertyPointName(i, tr("Point label")); AddPropertyPointName(i, tr("Point label"));
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersectionArcs(QGraphicsItem *item)
{
VToolPointOfIntersectionArcs *i = qgraphicsitem_cast<VToolPointOfIntersectionArcs *>(item);
i->ShowVisualization(true);
formView->setTitle(tr("Tool to make point from intersection two arcs"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyCrossPoint(i, tr("Take"));
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *item)
{ {
@ -1485,6 +1558,15 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersection()
idToProperty[VAbstractTool::AttrName]->setValue(i->name()); idToProperty[VAbstractTool::AttrName]->setValue(i->name());
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionArcs()
{
VToolPointOfIntersectionArcs *i = qgraphicsitem_cast<VToolPointOfIntersectionArcs *>(currentItem);
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
idToProperty[VAbstractTool::AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossArcsPoint())-1);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint() void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint()
{ {
@ -1611,6 +1693,7 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const
<< VAbstractTool::AttrAxisP2 /* 24 */ << VAbstractTool::AttrAxisP2 /* 24 */
<< VAbstractTool::AttrKCurve /* 25 */ << VAbstractTool::AttrKCurve /* 25 */
<< VAbstractTool::AttrLineColor /* 26 */ << VAbstractTool::AttrLineColor /* 26 */
<< VAbstractTool::AttrColor; /* 27 */ << VAbstractTool::AttrColor /* 27 */
<< VAbstractTool::AttrCrossPoint; /* 28 */
return attr; return attr;
} }

View File

@ -71,6 +71,9 @@ private:
template<class Tool> template<class Tool>
void AddPropertyPointName(Tool *i, const QString &propertyName); void AddPropertyPointName(Tool *i, const QString &propertyName);
template<class Tool>
void AddPropertyCrossPoint(Tool *i, const QString &propertyName);
template<class Tool> template<class Tool>
void AddPropertyLineType(Tool *i, const QString &propertyName, const QMap<QString, QIcon> &styles); void AddPropertyLineType(Tool *i, const QString &propertyName, const QMap<QString, QIcon> &styles);
@ -96,6 +99,7 @@ private:
void ChangeDataToolNormal(VPE::VProperty *property); void ChangeDataToolNormal(VPE::VProperty *property);
void ChangeDataToolPointOfContact(VPE::VProperty *property); void ChangeDataToolPointOfContact(VPE::VProperty *property);
void ChangeDataToolPointOfIntersection(VPE::VProperty *property); void ChangeDataToolPointOfIntersection(VPE::VProperty *property);
void ChangeDataToolPointOfIntersectionArcs(VPE::VProperty *property);
void ChangeDataToolShoulderPoint(VPE::VProperty *property); void ChangeDataToolShoulderPoint(VPE::VProperty *property);
void ChangeDataToolSpline(VPE::VProperty *property); void ChangeDataToolSpline(VPE::VProperty *property);
void ChangeDataToolSplinePath(VPE::VProperty *property); void ChangeDataToolSplinePath(VPE::VProperty *property);
@ -117,6 +121,7 @@ private:
void ShowOptionsToolNormal(QGraphicsItem *item); void ShowOptionsToolNormal(QGraphicsItem *item);
void ShowOptionsToolPointOfContact(QGraphicsItem *item); void ShowOptionsToolPointOfContact(QGraphicsItem *item);
void ShowOptionsToolPointOfIntersection(QGraphicsItem *item); void ShowOptionsToolPointOfIntersection(QGraphicsItem *item);
void ShowOptionsToolPointOfIntersectionArcs(QGraphicsItem *item);
void ShowOptionsToolShoulderPoint(QGraphicsItem *item); void ShowOptionsToolShoulderPoint(QGraphicsItem *item);
void ShowOptionsToolSpline(QGraphicsItem *item); void ShowOptionsToolSpline(QGraphicsItem *item);
void ShowOptionsToolSplinePath(QGraphicsItem *item); void ShowOptionsToolSplinePath(QGraphicsItem *item);
@ -138,6 +143,7 @@ private:
void UpdateOptionsToolNormal(); void UpdateOptionsToolNormal();
void UpdateOptionsToolPointOfContact(); void UpdateOptionsToolPointOfContact();
void UpdateOptionsToolPointOfIntersection(); void UpdateOptionsToolPointOfIntersection();
void UpdateOptionsToolPointOfIntersectionArcs();
void UpdateOptionsToolShoulderPoint(); void UpdateOptionsToolShoulderPoint();
void UpdateOptionsToolSpline(); void UpdateOptionsToolSpline();
void UpdateOptionsToolSplinePath(); void UpdateOptionsToolSplinePath();

View File

@ -38,7 +38,7 @@ class VMainGraphicsScene;
enum class Document : char { LiteParse, LitePPParse, FullParse }; enum class Document : char { LiteParse, LitePPParse, FullParse };
enum class LabelType : char {NewPatternPiece, NewLabel}; enum class LabelType : char {NewPatternPiece, NewLabel};
enum class CrossArcPoint : char {FirstPoint = 1, SecondPoint = 2}; enum class CrossArcsPoint : char {FirstPoint = 1, SecondPoint = 2};
/** /**
* @brief The VPattern class working with pattern file. * @brief The VPattern class working with pattern file.

View File

@ -267,10 +267,36 @@ int VGObject::IntersectionCircles(const QPointF &c1, double r1, const QPointF &c
{ {
return 3;// Circles are equal return 3;// Circles are equal
} }
const double a = 2.0 * (c2.x() - c1.x()); const double a = - 2.0 * (c2.x() - c1.x());
const double b = 2.0 * (c2.y() - c1.y()); const double b = - 2.0 * (c2.y() - c1.y());
const double c = c1.x() * c1.x() + c1.y() * c1.y() - r1 * r1 - (c2.x() * c2.x() + c2.y() * c2.y() - r2 * r2); const double c = (c2.x() - c1.x())* (c2.x() - c1.x()) + (c2.y() - c1.y()) * (c2.y() - c1.y()) + r1 * r1 - r2 * r2;
return LineIntersectCircle (c1, r1, CreateSegment(a, b, c), p1, p2);
const double x0 = -a*c/(a*a+b*b);
const double y0 = -b*c/(a*a+b*b);
if (c*c > r1*r1*(a*a+b*b))
{
return 0;
}
else if (qFuzzyCompare(c*c, r1*r1*(a*a+b*b)))
{
p1 = QPointF(x0 + c1.x(), y0 + c1.y());
return 1;
}
else
{
const double d = r1*r1 - c*c/(a*a+b*b);
const double mult = sqrt (d / (a*a+b*b));
const double ax = x0 + b * mult;
const double bx = x0 - b * mult;
const double ay = y0 - a * mult;
const double by = y0 + a * mult;
p1 = QPointF(ax + c1.x(), ay + c1.y());
p2 = QPointF(bx + c1.x(), by + c1.y());
return 2;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -429,18 +455,6 @@ double VGObject::GetEpsilon(const QPointF &p1, const QPointF &p2)
return epsilon; return epsilon;
} }
//---------------------------------------------------------------------------------------------------------------------
QLineF VGObject::CreateSegment(double a, double b, double c)
{
const double x1 = 0;
const double y1 = (-a*x1-c)/b;
const double x2 = 1000;
const double y2 = (-a*x2-c)/b;
return QLineF(x1, y1, x2, y2);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief GetReversePoint return revers container of points. * @brief GetReversePoint return revers container of points.

View File

@ -90,7 +90,6 @@ private:
static bool IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QPointF &p2); static bool IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QPointF &p2);
static double PerpDotProduct(const QPointF &t, const QPointF &p1, const QPointF &p2); static double PerpDotProduct(const QPointF &t, const QPointF &p1, const QPointF &p2);
static double GetEpsilon(const QPointF &p1, const QPointF &p2); static double GetEpsilon(const QPointF &p1, const QPointF &p2);
static QLineF CreateSegment(double a, double b, double c);
}; };
#endif // VGOBJECT_H #endif // VGOBJECT_H