New tool point from arc and tangent.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-06-06 09:33:19 +03:00
parent a327bc4985
commit 717e95e672
30 changed files with 1276 additions and 15 deletions

View File

@ -392,6 +392,14 @@ QString DialogHistory::Record(const VToolRecord &tool)
{ {
return QString(tr("%1 - point of circles intersection")).arg(PointName(tool.getId())); return QString(tr("%1 - point of circles intersection")).arg(PointName(tool.getId()));
} }
case Tool::PointFromCircleAndTangent:
{
return QString(tr("%1 - point from circle and tangent")).arg(PointName(tool.getId()));
}
case Tool::PointFromArcAndTangent:
{
return QString(tr("%1 - point from arc and tangent")).arg(PointName(tool.getId()));
}
//Because "history" not only show history of pattern, but help restore current data for each pattern's //Because "history" not only show history of pattern, but help restore current data for each pattern's
//piece, we need add record about details and nodes, but don't show them. //piece, we need add record about details and nodes, but don't show them.
case Tool::Detail: case Tool::Detail:

View File

@ -54,6 +54,7 @@
#include "tools/dialogpointofintersectionarcs.h" #include "tools/dialogpointofintersectionarcs.h"
#include "tools/dialogpointofintersectioncircles.h" #include "tools/dialogpointofintersectioncircles.h"
#include "tools/dialogpointfromcircleandtangent.h" #include "tools/dialogpointfromcircleandtangent.h"
#include "tools/dialogpointfromarcandtangent.h"
#include "app/dialoghistory.h" #include "app/dialoghistory.h"
#include "app/dialogincrements.h" #include "app/dialogincrements.h"

View File

@ -47,7 +47,8 @@ HEADERS += \
$$PWD/app/dialogsavelayout.h \ $$PWD/app/dialogsavelayout.h \
$$PWD/tools/dialogpointofintersectionarcs.h \ $$PWD/tools/dialogpointofintersectionarcs.h \
$$PWD/tools/dialogpointofintersectioncircles.h \ $$PWD/tools/dialogpointofintersectioncircles.h \
$$PWD/tools/dialogpointfromcircleandtangent.h $$PWD/tools/dialogpointfromcircleandtangent.h \
dialogs/tools/dialogpointfromarcandtangent.h
SOURCES += \ SOURCES += \
$$PWD/tools/dialogtriangle.cpp \ $$PWD/tools/dialogtriangle.cpp \
@ -93,7 +94,8 @@ SOURCES += \
$$PWD/app/dialogsavelayout.cpp \ $$PWD/app/dialogsavelayout.cpp \
$$PWD/tools/dialogpointofintersectionarcs.cpp \ $$PWD/tools/dialogpointofintersectionarcs.cpp \
$$PWD/tools/dialogpointofintersectioncircles.cpp \ $$PWD/tools/dialogpointofintersectioncircles.cpp \
$$PWD/tools/dialogpointfromcircleandtangent.cpp $$PWD/tools/dialogpointfromcircleandtangent.cpp \
dialogs/tools/dialogpointfromarcandtangent.cpp
FORMS += \ FORMS += \
$$PWD/tools/dialogtriangle.ui \ $$PWD/tools/dialogtriangle.ui \
@ -133,4 +135,5 @@ FORMS += \
$$PWD/app/dialogsavelayout.ui \ $$PWD/app/dialogsavelayout.ui \
$$PWD/tools/dialogpointofintersectionarcs.ui \ $$PWD/tools/dialogpointofintersectionarcs.ui \
$$PWD/tools/dialogpointofintersectioncircles.ui \ $$PWD/tools/dialogpointofintersectioncircles.ui \
$$PWD/tools/dialogpointfromcircleandtangent.ui $$PWD/tools/dialogpointfromcircleandtangent.ui \
dialogs/tools/dialogpointfromarcandtangent.ui

View File

@ -0,0 +1,186 @@
/************************************************************************
**
** @file dialogpointfromarcandtangent.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 5 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "dialogpointfromarcandtangent.h"
#include "ui_dialogpointfromarcandtangent.h"
#include "../../libs/vgeometry/vpointf.h"
#include "../../container/vcontainer.h"
#include "../../visualization/vistoolpointfromarcandtangent.h"
#include "../../widgets/vmaingraphicsscene.h"
//---------------------------------------------------------------------------------------------------------------------
DialogPointFromArcAndTangent::DialogPointFromArcAndTangent(const VContainer *data, const quint32 &toolId,
QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointFromArcAndTangent)
{
ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
InitOkCancelApply(ui);
CheckState();
FillComboBoxPoints(ui->comboBoxTangentPoint);
FillComboBoxArcs(ui->comboBoxArc);
FillComboBoxCrossCirclesPoints(ui->comboBoxResult);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointFromArcAndTangent::NamePointChanged);
vis = new VisToolPointFromArcAndTangent(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogPointFromArcAndTangent::~DialogPointFromArcAndTangent()
{
DeleteVisualization<VisToolPointFromArcAndTangent>();
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointFromArcAndTangent::SetPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogPointFromArcAndTangent::GetArcId() const
{
return getCurrentObjectId(ui->comboBoxArc);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointFromArcAndTangent::SetArcId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxArc, value);
VisToolPointFromArcAndTangent *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
SCASSERT(point != nullptr);
point->setArcId(value);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogPointFromArcAndTangent::GetTangentPointId() const
{
return getCurrentObjectId(ui->comboBoxTangentPoint);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointFromArcAndTangent::SetTangentPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxTangentPoint, value);
VisToolPointFromArcAndTangent *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
SCASSERT(point != nullptr);
point->setPoint1Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
CrossCirclesPoint DialogPointFromArcAndTangent::GetCrossCirclesPoint() const
{
return getCurrentCrossPoint(ui->comboBoxResult);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointFromArcAndTangent::SetCrossCirclesPoint(CrossCirclesPoint &p)
{
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
if (index != -1)
{
ui->comboBoxResult->setCurrentIndex(index);
VisToolPointFromArcAndTangent *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
SCASSERT(point != nullptr);
point->setCrossPoint(p);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointFromArcAndTangent::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false)// After first choose we ignore all objects
{
if (type == SceneObject::Point || type == SceneObject::Arc)
{
VisToolPointFromArcAndTangent *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
SCASSERT(point != nullptr);
switch (number)
{
case 0:
if (type == SceneObject::Point)
{
if (SetObject(id, ui->comboBoxTangentPoint, tr("Select an arc")))
{
number++;
point->VisualMode(id);
}
}
break;
case 1:
if (type == SceneObject::Arc)
{
if (SetObject(id, ui->comboBoxArc, ""))
{
number = 0;
point->setArcId(id);
point->RefreshGeometry();
prepare = true;
this->setModal(true);
this->show();
}
}
break;
default:
break;
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointFromArcAndTangent::ShowVisualization()
{
AddVisualization<VisToolPointFromArcAndTangent>();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointFromArcAndTangent::SaveData()
{
pointName = ui->lineEditNamePoint->text();
VisToolPointFromArcAndTangent *point = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
SCASSERT(point != nullptr);
point->setPoint1Id(GetTangentPointId());
point->setArcId(GetArcId());
point->setCrossPoint(GetCrossCirclesPoint());
point->RefreshGeometry();
}

View File

@ -0,0 +1,75 @@
/************************************************************************
**
** @file dialogpointfromarcandtangent.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 5 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef DIALOGPOINTFROMARCANDTANGENT_H
#define DIALOGPOINTFROMARCANDTANGENT_H
#include "dialogtool.h"
namespace Ui
{
class DialogPointFromArcAndTangent;
}
class DialogPointFromArcAndTangent : public DialogTool
{
Q_OBJECT
public:
DialogPointFromArcAndTangent(const VContainer *data, const quint32 &toolId, QWidget *parent = 0);
~DialogPointFromArcAndTangent();
void SetPointName(const QString &value);
quint32 GetArcId() const;
void SetArcId(const quint32 &value);
quint32 GetTangentPointId() const;
void SetTangentPointId(const quint32 &value);
CrossCirclesPoint GetCrossCirclesPoint() const;
void SetCrossCirclesPoint(CrossCirclesPoint &p);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type);
protected:
virtual void ShowVisualization();
/**
* @brief SaveData Put dialog data in local variables
*/
virtual void SaveData();
private:
Q_DISABLE_COPY(DialogPointFromArcAndTangent)
Ui::DialogPointFromArcAndTangent *ui;
};
#endif // DIALOGPOINTFROMARCANDTANGENT_H

View File

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogPointFromArcAndTangent</class>
<widget class="QDialog" name="DialogPointFromArcAndTangent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>370</width>
<height>179</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>370</width>
<height>179</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>370</width>
<height>179</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="labelEditNamePoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Point label</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelTangentPoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Tangent point</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxTangentPoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>143</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelArc">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Arc</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxArc">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>145</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Select point of center of arc</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Take</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboBoxResult"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogPointFromArcAndTangent</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogPointFromArcAndTangent</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -725,6 +725,16 @@ void MainWindow::ToolPointFromCircleAndTangent(bool checked)
&MainWindow::ApplyDialog<VToolPointFromCircleAndTangent>); &MainWindow::ApplyDialog<VToolPointFromCircleAndTangent>);
} }
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolPointFromArcAndTangent(bool checked)
{
SetToolButtonWithApply<DialogPointFromArcAndTangent>(checked, Tool::PointFromArcAndTangent,
"://cursor/point_from_arc_and_tangent_cursor.png",
tr("Select point on tangent "),
&MainWindow::ClosedDialogWithApply<VToolPointFromArcAndTangent>,
&MainWindow::ApplyDialog<VToolPointFromArcAndTangent>);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief About show widows about. * @brief About show widows about.
@ -1026,6 +1036,7 @@ void MainWindow::InitToolButtons()
&MainWindow::ToolPointOfIntersectionCircles); &MainWindow::ToolPointOfIntersectionCircles);
connect(ui->toolButtonPointFromCircleAndTangent, &QToolButton::clicked, this, connect(ui->toolButtonPointFromCircleAndTangent, &QToolButton::clicked, this,
&MainWindow::ToolPointFromCircleAndTangent); &MainWindow::ToolPointFromCircleAndTangent);
connect(ui->toolButtonPointFromArcAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromArcAndTangent);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -2173,6 +2184,7 @@ void MainWindow::SetEnableTool(bool enable)
ui->toolButtonPointOfIntersectionArcs->setEnabled(drawTools); ui->toolButtonPointOfIntersectionArcs->setEnabled(drawTools);
ui->toolButtonPointOfIntersectionCircles->setEnabled(drawTools); ui->toolButtonPointOfIntersectionCircles->setEnabled(drawTools);
ui->toolButtonPointFromCircleAndTangent->setEnabled(drawTools); ui->toolButtonPointFromCircleAndTangent->setEnabled(drawTools);
ui->toolButtonPointFromArcAndTangent->setEnabled(drawTools);
ui->actionLast_tool->setEnabled(drawTools); ui->actionLast_tool->setEnabled(drawTools);
@ -2543,6 +2555,10 @@ void MainWindow::LastUsedTool()
ui->toolButtonPointFromCircleAndTangent->setChecked(true); ui->toolButtonPointFromCircleAndTangent->setChecked(true);
ToolPointFromCircleAndTangent(true); ToolPointFromCircleAndTangent(true);
break; break;
case Tool::PointFromArcAndTangent:
ui->toolButtonPointFromArcAndTangent->setChecked(true);
ToolPointFromArcAndTangent(true);
break;
case Tool::NodePoint: case Tool::NodePoint:
case Tool::NodeArc: case Tool::NodeArc:
case Tool::NodeSpline: case Tool::NodeSpline:

View File

@ -118,6 +118,7 @@ public slots:
void ToolPointOfIntersectionArcs(bool checked); void ToolPointOfIntersectionArcs(bool checked);
void ToolPointOfIntersectionCircles(bool checked); void ToolPointOfIntersectionCircles(bool checked);
void ToolPointFromCircleAndTangent(bool checked); void ToolPointFromCircleAndTangent(bool checked);
void ToolPointFromArcAndTangent(bool checked);
void ClosedDialogDetail(int result); void ClosedDialogDetail(int result);
void ClosedDialogUnionDetails(int result); void ClosedDialogUnionDetails(int result);

View File

@ -573,7 +573,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>120</width> <width>120</width>
<height>150</height> <height>196</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -745,6 +745,32 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QToolButton" name="toolButtonPointFromArcAndTangent">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Point from arc and tangent</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/icon.qrc">
<normaloff>:/icon/32x32/point_from_arc_and_tangent.png</normaloff>:/icon/32x32/point_from_arc_and_tangent.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="page_5"> <widget class="QWidget" name="page_5">

View File

@ -91,12 +91,13 @@ enum class Tool : unsigned char
CurveIntersectAxis, CurveIntersectAxis,
PointOfIntersection, PointOfIntersection,
PointFromCircleAndTangent, PointFromCircleAndTangent,
UnionDetails // 33 PointFromArcAndTangent,
UnionDetails // 34
}; };
enum class Vis : unsigned char enum class Vis : unsigned char
{ {
ControlPointSpline = 34, // increase this value if need more positions in Tool enum ControlPointSpline = 35, // increase this value if need more positions in Tool enum
GraphicsSimpleTextItem, GraphicsSimpleTextItem,
SimpleSplinePath, SimpleSplinePath,
Line, Line,
@ -115,6 +116,7 @@ enum class Vis : unsigned char
ToolPointOfIntersectionArcs, ToolPointOfIntersectionArcs,
ToolPointOfIntersectionCircles, ToolPointOfIntersectionCircles,
ToolPointFromCircleAndTangent, ToolPointFromCircleAndTangent,
ToolPointFromArcAndTangent,
ToolShoulderPoint, ToolShoulderPoint,
ToolSpline, ToolSpline,
ToolTriangle, ToolTriangle,

View File

@ -27,5 +27,6 @@
<file>cursor/point_of_intersection_arcs.png</file> <file>cursor/point_of_intersection_arcs.png</file>
<file>cursor/point_of_intersection_circles.png</file> <file>cursor/point_of_intersection_circles.png</file>
<file>cursor/point_from_circle_and_tangent_cursor.png</file> <file>cursor/point_from_circle_and_tangent_cursor.png</file>
<file>cursor/point_from_arc_and_tangent_cursor.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -64,5 +64,6 @@
<file>icon/32x32/point_of_intersection_arcs.png</file> <file>icon/32x32/point_of_intersection_arcs.png</file>
<file>icon/32x32/point_of_intersection_circles.png</file> <file>icon/32x32/point_of_intersection_circles.png</file>
<file>icon/32x32/point_from_circle_and_tangent.png</file> <file>icon/32x32/point_from_circle_and_tangent.png</file>
<file>icon/32x32/point_from_arc_and_tangent.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="32"
height="32"
id="svg5205"
inkscape:version="0.48.4 r9939"
sodipodi:docname="point_from_arc_and_tangent.svg">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1619"
inkscape:window-height="981"
id="namedview10"
showgrid="false"
inkscape:zoom="16"
inkscape:cx="10.021247"
inkscape:cy="8.5525684"
inkscape:window-x="75"
inkscape:window-y="34"
inkscape:window-maximized="0"
inkscape:current-layer="svg5205" />
<defs
id="defs5207" />
<metadata
id="metadata5210">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#ff0034;stroke-width:1.29792571;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:2.59585104, 1.29792552;stroke-dashoffset:3.24481394;marker-start:none"
id="path3013"
d="M 30.314961,22.638167 5.170055,0.78764325" />
<path
sodipodi:type="arc"
style="fill:none;stroke:#00b400;stroke-width:0.9467746;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="path2991"
sodipodi:cx="11.864407"
sodipodi:cy="10.542373"
sodipodi:rx="10.033898"
sodipodi:ry="9.525424"
d="M 4.5903992,3.9811793 A 10.033898,9.525424 0 0 1 19.441042,16.78729"
sodipodi:start="3.9014369"
sodipodi:end="6.9981691"
transform="matrix(1.3042606,0,0,1.3971853,-5.159831,7.7411372)"
sodipodi:open="true" />
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:#370000;stroke-width:1.56599998;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-opacity:0.93950177;stroke-dasharray:none;stroke-dashoffset:0"
id="path2985-2-9-1"
d="m 31.330061,21.966676 a 1.6940329,1.7299054 0 0 1 -3.388065,0 1.6940329,1.7299054 0 1 1 3.388065,0 z" />
<path
inkscape:connector-curvature="0"
style="fill:#f73208;fill-opacity:1;stroke:#f73208;stroke-width:1.56599998;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="path2985-2-9-1-5"
d="m 20.113634,11.834888 a 1.6940329,1.7299054 0 0 1 -3.388065,0 1.6940329,1.7299054 0 1 1 3.388065,0 z" />
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -52,5 +52,6 @@
#include "vtoollineintersectaxis.h" #include "vtoollineintersectaxis.h"
#include "vtoolcurveintersectaxis.h" #include "vtoolcurveintersectaxis.h"
#include "vtoolpointfromcircleandtangent.h" #include "vtoolpointfromcircleandtangent.h"
#include "vtoolpointfromarcandtangent.h"
#endif // DRAWTOOLS_H #endif // DRAWTOOLS_H

View File

@ -34,7 +34,6 @@
#include "../../visualization/vistoolcutarc.h" #include "../../visualization/vistoolcutarc.h"
const QString VToolCutArc::ToolType = QStringLiteral("cutArc"); const QString VToolCutArc::ToolType = QStringLiteral("cutArc");
const QString VToolCutArc::AttrArc = QStringLiteral("arc");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**

View File

@ -47,7 +47,6 @@ public:
const qreal &mx, const qreal &my, const QString &color, VMainGraphicsScene *scene, const qreal &mx, const qreal &my, const QString &color, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType; static const QString ToolType;
static const QString AttrArc;
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::CutArc)}; enum { Type = UserType + static_cast<int>(Tool::CutArc)};
virtual void ShowVisualization(bool show); virtual void ShowVisualization(bool show);

View File

@ -0,0 +1,319 @@
/************************************************************************
**
** @file vtoolpointfromarcandtangent.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 6 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vtoolpointfromarcandtangent.h"
#include "../../dialogs/tools/dialogpointfromarcandtangent.h"
#include "../../libs/vgeometry/vpointf.h"
#include "../../libs/vgeometry/varc.h"
#include "../../visualization/vistoolpointfromarcandtangent.h"
const QString VToolPointFromArcAndTangent::ToolType = QStringLiteral("pointFromArcAndTangent");
//---------------------------------------------------------------------------------------------------------------------
VToolPointFromArcAndTangent::VToolPointFromArcAndTangent(VPattern *doc, VContainer *data, const quint32 &id,
quint32 arcId, quint32 tangentPointId,
CrossCirclesPoint crossPoint, const Source &typeCreation,
QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), arcId(arcId), tangentPointId(tangentPointId), crossPoint(crossPoint)
{
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointFromArcAndTangent::setDialog()
{
SCASSERT(dialog != nullptr);
DialogPointFromArcAndTangent *dialogTool = qobject_cast<DialogPointFromArcAndTangent*>(dialog);
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->SetArcId(arcId);
dialogTool->SetCrossCirclesPoint(crossPoint);
dialogTool->SetTangentPointId(tangentPointId);
dialogTool->SetPointName(p->name());
}
//---------------------------------------------------------------------------------------------------------------------
VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(DialogTool *dialog, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogPointFromArcAndTangent *dialogTool = qobject_cast<DialogPointFromArcAndTangent*>(dialog);
SCASSERT(dialogTool != nullptr);
const quint32 arcId = dialogTool->GetArcId();
const quint32 tangentPointId = dialogTool->GetTangentPointId();
const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint();
const QString pointName = dialogTool->getPointName();
VToolPointFromArcAndTangent *point = nullptr;
point = Create(0, pointName, arcId, tangentPointId, pType, 5, 10, scene, doc, data, Document::FullParse,
Source::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
}
return point;
}
//---------------------------------------------------------------------------------------------------------------------
VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(const quint32 _id, const QString &pointName,
quint32 arcId, quint32 tangentPointId,
CrossCirclesPoint crossPoint, const qreal &mx,
const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
{
const VArc arc = *data->GeometricObject<VArc>(arcId);
const VPointF tPoint = *data->GeometricObject<VPointF>(tangentPointId);
const QPointF point = VToolPointFromArcAndTangent::FindPoint(tPoint.toQPointF(), &arc, crossPoint);
quint32 id = _id;
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(new VPointF(point, pointName, mx, my));
}
else
{
data->UpdateGObject(id, new VPointF(point, pointName, mx, my));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::PointFromArcAndTangent, doc);
if (parse == Document::FullParse)
{
VToolPointFromArcAndTangent *point = new VToolPointFromArcAndTangent(doc, data, id, arcId, tangentPointId,
crossPoint, typeCreation);
scene->addItem(point);
connect(point, &VToolPointFromArcAndTangent::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointFromArcAndTangent::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointFromArcAndTangent::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointFromArcAndTangent::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(arcId);
doc->IncrementReferens(tangentPointId);
return point;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VToolPointFromArcAndTangent::FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType)
{
QPointF p1, p2;
const QPointF center = arc->GetCenter().toQPointF();
const qreal radius = arc->GetRadius();
const int res = VGObject::ContactPoints (p, center, radius, p1, p2);
QLineF r1Arc(center, p1);
r1Arc.setLength(radius+10);
QLineF r2Arc(center, p2);
r2Arc.setLength(radius+10);
switch(res)
{
case 2:
{
int localRes = 0;
bool flagP1 = false;
if (arc->IsIntersectLine(r1Arc))
{
++localRes;
flagP1 = true;
}
if (arc->IsIntersectLine(r2Arc))
{
++localRes;
}
switch(localRes)
{
case 2:
if (pType == CrossCirclesPoint::FirstPoint)
{
return p1;
}
else
{
return p2;
}
break;
case 1:
if (flagP1)
{
return p1;
}
else
{
return p2;
}
break;
case 0:
default:
return QPointF(0, 0);
break;
}
break;
}
case 1:
if (arc->IsIntersectLine(r1Arc))
{
return p1;
}
else
{
return QPointF(0, 0);
}
break;
case 3:
case 0:
default:
return QPointF(0, 0);
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolPointFromArcAndTangent::GetTangentPointId() const
{
return tangentPointId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointFromArcAndTangent::SetTangentPointId(const quint32 &value)
{
if (value != NULL_ID)
{
tangentPointId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolPointFromArcAndTangent::GetArcId() const
{
return arcId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointFromArcAndTangent::SetArcId(const quint32 &value)
{
if (value != NULL_ID)
{
arcId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
CrossCirclesPoint VToolPointFromArcAndTangent::GetCrossCirclesPoint() const
{
return crossPoint;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointFromArcAndTangent::SetCrossCirclesPoint(CrossCirclesPoint &value)
{
crossPoint = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointFromArcAndTangent::ShowVisualization(bool show)
{
ShowToolVisualization<VisToolPointFromArcAndTangent>(show);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointFromArcAndTangent::RemoveReferens()
{
doc->DecrementReferens(arcId);
doc->DecrementReferens(tangentPointId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointFromArcAndTangent::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogPointFromArcAndTangent>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointFromArcAndTangent::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
DialogPointFromArcAndTangent *dialogTool = qobject_cast<DialogPointFromArcAndTangent*>(dialog);
SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->GetArcId()));
doc->SetAttribute(domElement, AttrTangent, QString().setNum(dialogTool->GetTangentPointId()));
doc->SetAttribute(domElement, AttrCrossPoint,
QString().setNum(static_cast<int>(dialogTool->GetCrossCirclesPoint())));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointFromArcAndTangent::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
VToolPoint::SaveOptions(tag, obj);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrArc, arcId);
doc->SetAttribute(tag, AttrTangent, tangentPointId);
doc->SetAttribute(tag, AttrCrossPoint, static_cast<int>(crossPoint));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointFromArcAndTangent::ReadToolAttributes(const QDomElement &domElement)
{
arcId = doc->GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
tangentPointId = doc->GetParametrUInt(domElement, AttrTangent, NULL_ID_STR);
crossPoint = static_cast<CrossCirclesPoint>(doc->GetParametrUInt(domElement, AttrCrossPoint, "1"));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointFromArcAndTangent::SetVisualization()
{
if (vis != nullptr)
{
VisToolPointFromArcAndTangent *visual = qobject_cast<VisToolPointFromArcAndTangent *>(vis);
SCASSERT(visual != nullptr);
visual->setPoint1Id(tangentPointId);
visual->setArcId(arcId);
visual->setCrossPoint(crossPoint);
visual->RefreshGeometry();
}
}

View File

@ -0,0 +1,79 @@
/************************************************************************
**
** @file vtoolpointfromarcandtangent.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 6 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VTOOLPOINTFROMARCANDTANGENT_H
#define VTOOLPOINTFROMARCANDTANGENT_H
#include "vtoolpoint.h"
#include "../../xml/vpattern.h"
class VToolPointFromArcAndTangent : public VToolPoint
{
Q_OBJECT
public:
VToolPointFromArcAndTangent(VPattern *doc, VContainer *data, const quint32 &id, quint32 arcId,
quint32 tangentPointId, CrossCirclesPoint crossPoint, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog();
static VToolPointFromArcAndTangent *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data);
static VToolPointFromArcAndTangent *Create(const quint32 _id, const QString &pointName, quint32 arcId,
quint32 tangentPointId, CrossCirclesPoint crossPoint, const qreal &mx,
const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static QPointF FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType);
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::PointFromArcAndTangent) };
quint32 GetTangentPointId() const;
void SetTangentPointId(const quint32 &value);
quint32 GetArcId() const;
void SetArcId(const quint32 &value);
CrossCirclesPoint GetCrossCirclesPoint() const;
void SetCrossCirclesPoint(CrossCirclesPoint &value);
virtual void ShowVisualization(bool show);
protected:
virtual void RemoveReferens();
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private:
Q_DISABLE_COPY(VToolPointFromArcAndTangent)
quint32 arcId;
quint32 tangentPointId;
CrossCirclesPoint crossPoint;
};
#endif // VTOOLPOINTFROMARCANDTANGENT_H

View File

@ -56,6 +56,7 @@ void VToolPointFromCircleAndTangent::setDialog()
dialogTool->SetCircleCenterId(circleCenterId); dialogTool->SetCircleCenterId(circleCenterId);
dialogTool->SetCircleRadius(circleRadius); dialogTool->SetCircleRadius(circleRadius);
dialogTool->SetCrossCirclesPoint(crossPoint); dialogTool->SetCrossCirclesPoint(crossPoint);
dialogTool->SetTangentPointId(tangentPointId);
dialogTool->SetPointName(p->name()); dialogTool->SetPointName(p->name());
} }
@ -110,7 +111,7 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(const qui
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);
} }
} }
VDrawTool::AddRecord(id, Tool::PointOfIntersectionCircles, doc); VDrawTool::AddRecord(id, Tool::PointFromCircleAndTangent, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
{ {
VToolPointFromCircleAndTangent *point = new VToolPointFromCircleAndTangent(doc, data, id, circleCenterId, VToolPointFromCircleAndTangent *point = new VToolPointFromCircleAndTangent(doc, data, id, circleCenterId,

View File

@ -41,7 +41,8 @@ HEADERS += \
$$PWD/drawTools/vtoolcurveintersectaxis.h \ $$PWD/drawTools/vtoolcurveintersectaxis.h \
$$PWD/drawTools/vtoolpointofintersectionarcs.h \ $$PWD/drawTools/vtoolpointofintersectionarcs.h \
$$PWD/drawTools/vtoolpointofintersectioncircles.h \ $$PWD/drawTools/vtoolpointofintersectioncircles.h \
$$PWD/drawTools/vtoolpointfromcircleandtangent.h $$PWD/drawTools/vtoolpointfromcircleandtangent.h \
tools/drawTools/vtoolpointfromarcandtangent.h
SOURCES += \ SOURCES += \
$$PWD/vtooldetail.cpp \ $$PWD/vtooldetail.cpp \
@ -80,4 +81,5 @@ SOURCES += \
$$PWD/drawTools/vtoolcurveintersectaxis.cpp \ $$PWD/drawTools/vtoolcurveintersectaxis.cpp \
$$PWD/drawTools/vtoolpointofintersectionarcs.cpp \ $$PWD/drawTools/vtoolpointofintersectionarcs.cpp \
$$PWD/drawTools/vtoolpointofintersectioncircles.cpp \ $$PWD/drawTools/vtoolpointofintersectioncircles.cpp \
$$PWD/drawTools/vtoolpointfromcircleandtangent.cpp $$PWD/drawTools/vtoolpointfromcircleandtangent.cpp \
tools/drawTools/vtoolpointfromarcandtangent.cpp

View File

@ -86,6 +86,7 @@ const QString VAbstractTool::AttrC2Radius = QStringLiteral("c2Radius");
const QString VAbstractTool::AttrCCenter = QStringLiteral("cCenter"); const QString VAbstractTool::AttrCCenter = QStringLiteral("cCenter");
const QString VAbstractTool::AttrTangent = QStringLiteral("tangent"); const QString VAbstractTool::AttrTangent = QStringLiteral("tangent");
const QString VAbstractTool::AttrCRadius = QStringLiteral("cRadius"); const QString VAbstractTool::AttrCRadius = QStringLiteral("cRadius");
const QString VAbstractTool::AttrArc = QStringLiteral("arc");
const QString VAbstractTool::TypeLineNone = QStringLiteral("none"); const QString VAbstractTool::TypeLineNone = QStringLiteral("none");
const QString VAbstractTool::TypeLineLine = QStringLiteral("hair"); const QString VAbstractTool::TypeLineLine = QStringLiteral("hair");

View File

@ -101,6 +101,7 @@ public:
static const QString AttrCCenter; static const QString AttrCCenter;
static const QString AttrTangent; static const QString AttrTangent;
static const QString AttrCRadius; static const QString AttrCRadius;
static const QString AttrArc;
static const QString TypeLineNone; static const QString TypeLineNone;
static const QString TypeLineLine; static const QString TypeLineLine;

View File

@ -0,0 +1,145 @@
/************************************************************************
**
** @file vistoolpointfromarcandtangent.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 6 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vistoolpointfromarcandtangent.h"
#include "../container/vcontainer.h"
#include "../tools/drawTools/vtoolpointfromarcandtangent.h"
#include "../libs/vgeometry/vpointf.h"
#include "../libs/vgeometry/varc.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolPointFromArcAndTangent::VisToolPointFromArcAndTangent(const VContainer *data, QGraphicsItem *parent)
: VisLine(data, parent), arcId(NULL_ID), crossPoint(CrossCirclesPoint::FirstPoint),
point(nullptr), tangent(nullptr), arcPath(nullptr), tangentLine2(nullptr)
{
arcPath = InitItem<QGraphicsPathItem>(Qt::darkGreen, this);
point = InitPoint(mainColor, this);
tangent = InitPoint(supportColor, this);
tangentLine2 = InitItem<QGraphicsLineItem>(supportColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolPointFromArcAndTangent::~VisToolPointFromArcAndTangent()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromArcAndTangent::RefreshGeometry()
{
if (point1Id > NULL_ID)// tangent point
{
const QSharedPointer<VPointF> tan = Visualization::data->GeometricObject<VPointF>(point1Id);
DrawPoint(tangent, tan->toQPointF(), supportColor);
if (arcId > NULL_ID)// circle center
{
const QSharedPointer<VArc> arc = Visualization::data->GeometricObject<VArc>(arcId);
DrawPath(arcPath, arc->GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap);
FindRays(tan->toQPointF(), arc.data());
const QPointF fPoint = VToolPointFromArcAndTangent::FindPoint(tan->toQPointF(), arc.data(), crossPoint);
DrawPoint(point, fPoint, mainColor);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromArcAndTangent::setArcId(const quint32 &value)
{
arcId = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromArcAndTangent::setCrossPoint(const CrossCirclesPoint &value)
{
crossPoint = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromArcAndTangent::FindRays(const QPointF &p, const VArc *arc)
{
QPointF p1, p2;
const QPointF center = arc->GetCenter().toQPointF();
const qreal radius = arc->GetRadius();
const int res = VGObject::ContactPoints (p, center, radius, p1, p2);
QLineF r1Arc(center, p1);
r1Arc.setLength(radius+10);
QLineF r2Arc(center, p2);
r2Arc.setLength(radius+10);
switch(res)
{
case 2:
{
int localRes = 0;
bool flagP1 = false;
if (arc->IsIntersectLine(r1Arc))
{
++localRes;
flagP1 = true;
}
if (arc->IsIntersectLine(r2Arc))
{
++localRes;
}
switch(localRes)
{
case 2:
DrawRay(this, p, p1, supportColor, Qt::DashLine);
DrawRay(tangentLine2, p, p2, supportColor, Qt::DashLine);
break;
case 1:
DrawRay(this, p, p1, supportColor, Qt::DashLine);
tangentLine2->setVisible(false);
break;
case 0:
default:
this->setVisible(false);
tangentLine2->setVisible(false);
break;
}
break;
}
case 1:
DrawRay(this, p, p1, supportColor, Qt::DashLine);
tangentLine2->setVisible(false);
break;
case 3:
case 0:
default:
this->setVisible(false);
tangentLine2->setVisible(false);
break;
}
}

View File

@ -0,0 +1,61 @@
/************************************************************************
**
** @file vistoolpointfromarcandtangent.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 6 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VISTOOLPOINTFROMARCANDTANGENT_H
#define VISTOOLPOINTFROMARCANDTANGENT_H
#include "visline.h"
#include "../xml/vpattern.h"
class VisToolPointFromArcAndTangent : public VisLine
{
Q_OBJECT
public:
VisToolPointFromArcAndTangent(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolPointFromArcAndTangent();
virtual void RefreshGeometry();
void setArcId(const quint32 &value);
void setCrossPoint(const CrossCirclesPoint &value);
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromArcAndTangent)};
private:
Q_DISABLE_COPY(VisToolPointFromArcAndTangent)
quint32 arcId;
CrossCirclesPoint crossPoint;
QGraphicsEllipseItem *point;
QGraphicsEllipseItem *tangent;
QGraphicsPathItem *arcPath;
QGraphicsLineItem *tangentLine2;
void FindRays(const QPointF &p, const VArc *arc);
};
#endif // VISTOOLPOINTFROMARCANDTANGENT_H

View File

@ -29,7 +29,8 @@ HEADERS += \
$$PWD/vistoolcurveintersectaxis.h \ $$PWD/vistoolcurveintersectaxis.h \
$$PWD/vistoolpointofintersectionarcs.h \ $$PWD/vistoolpointofintersectionarcs.h \
$$PWD/vistoolpointofintersectioncircles.h \ $$PWD/vistoolpointofintersectioncircles.h \
$$PWD/vistoolpointfromcircleandtangent.h $$PWD/vistoolpointfromcircleandtangent.h \
visualization/vistoolpointfromarcandtangent.h
SOURCES += \ SOURCES += \
$$PWD/vgraphicssimpletextitem.cpp \ $$PWD/vgraphicssimpletextitem.cpp \
@ -59,4 +60,5 @@ SOURCES += \
$$PWD/vistoolcurveintersectaxis.cpp \ $$PWD/vistoolcurveintersectaxis.cpp \
$$PWD/vistoolpointofintersectionarcs.cpp \ $$PWD/vistoolpointofintersectionarcs.cpp \
$$PWD/vistoolpointofintersectioncircles.cpp \ $$PWD/vistoolpointofintersectioncircles.cpp \
$$PWD/vistoolpointfromcircleandtangent.cpp $$PWD/vistoolpointfromcircleandtangent.cpp \
visualization/vistoolpointfromarcandtangent.cpp

View File

@ -155,6 +155,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
case VToolPointFromCircleAndTangent::Type: case VToolPointFromCircleAndTangent::Type:
ShowOptionsToolPointFromCircleAndTangent(item); ShowOptionsToolPointFromCircleAndTangent(item);
break; break;
case VToolPointFromArcAndTangent::Type:
ShowOptionsToolPointFromArcAndTangent(item);
break;
default: default:
break; break;
} }
@ -245,6 +248,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
case VToolPointFromCircleAndTangent::Type: case VToolPointFromCircleAndTangent::Type:
UpdateOptionsToolPointFromCircleAndTangent(); UpdateOptionsToolPointFromCircleAndTangent();
break; break;
case VToolPointFromArcAndTangent::Type:
UpdateOptionsToolPointFromArcAndTangent();
break;
default: default:
break; break;
} }
@ -350,6 +356,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
case VToolPointFromCircleAndTangent::Type: case VToolPointFromCircleAndTangent::Type:
ChangeDataToolPointFromCircleAndTangent(prop); ChangeDataToolPointFromCircleAndTangent(prop);
break; break;
case VToolPointFromArcAndTangent::Type:
ChangeDataToolPointFromArcAndTangent(prop);
break;
default: default:
break; break;
} }
@ -986,6 +995,31 @@ void VToolOptionsPropertyBrowser::ChangeDataToolPointFromCircleAndTangent(VPrope
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolPointFromArcAndTangent(VProperty *property)
{
SCASSERT(property != nullptr)
const QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
const QString id = propertyToId[property];
switch (PropertiesList().indexOf(id))
{
case 0: // VAbstractTool::AttrName
SetPointName<VToolPointFromArcAndTangent>(value.toString());
break;
case 28: // VAbstractTool::AttrCrossPoint
{
const QVariant value = property->data(VProperty::DPC_Data, Qt::EditRole);
SetCrossCirclesPoint<VToolPointFromArcAndTangent>(value);
break;
}
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolShoulderPoint(VProperty *property) void VToolOptionsPropertyBrowser::ChangeDataToolShoulderPoint(VProperty *property)
{ {
@ -1366,6 +1400,17 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointFromCircleAndTangent(QGrap
AddPropertyCrossPoint(i, tr("Take")); AddPropertyCrossPoint(i, tr("Take"));
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolPointFromArcAndTangent(QGraphicsItem *item)
{
VToolPointFromArcAndTangent *i = qgraphicsitem_cast<VToolPointFromArcAndTangent *>(item);
i->ShowVisualization(true);
formView->setTitle(tr("Tool to make point from arc and tangent"));
AddPropertyPointName(i, tr("Point label"));
AddPropertyCrossPoint(i, tr("Take"));
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *item)
{ {
@ -1719,6 +1764,15 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromCircleAndTangent()
idToProperty[VAbstractTool::AttrCRadius]->setValue(cRadius); idToProperty[VAbstractTool::AttrCRadius]->setValue(cRadius);
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromArcAndTangent()
{
VToolPointFromArcAndTangent *i = qgraphicsitem_cast<VToolPointFromArcAndTangent *>(currentItem);
idToProperty[VAbstractTool::AttrName]->setValue(i->name());
idToProperty[VAbstractTool::AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossCirclesPoint())-1);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint() void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint()
{ {

View File

@ -105,6 +105,7 @@ private:
void ChangeDataToolPointOfIntersectionArcs(VPE::VProperty *property); void ChangeDataToolPointOfIntersectionArcs(VPE::VProperty *property);
void ChangeDataToolPointOfIntersectionCircles(VPE::VProperty *property); void ChangeDataToolPointOfIntersectionCircles(VPE::VProperty *property);
void ChangeDataToolPointFromCircleAndTangent(VPE::VProperty *property); void ChangeDataToolPointFromCircleAndTangent(VPE::VProperty *property);
void ChangeDataToolPointFromArcAndTangent(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);
@ -129,6 +130,7 @@ private:
void ShowOptionsToolPointOfIntersectionArcs(QGraphicsItem *item); void ShowOptionsToolPointOfIntersectionArcs(QGraphicsItem *item);
void ShowOptionsToolPointOfIntersectionCircles(QGraphicsItem *item); void ShowOptionsToolPointOfIntersectionCircles(QGraphicsItem *item);
void ShowOptionsToolPointFromCircleAndTangent(QGraphicsItem *item); void ShowOptionsToolPointFromCircleAndTangent(QGraphicsItem *item);
void ShowOptionsToolPointFromArcAndTangent(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);
@ -153,6 +155,7 @@ private:
void UpdateOptionsToolPointOfIntersectionArcs(); void UpdateOptionsToolPointOfIntersectionArcs();
void UpdateOptionsToolPointOfIntersectionCircles(); void UpdateOptionsToolPointOfIntersectionCircles();
void UpdateOptionsToolPointFromCircleAndTangent(); void UpdateOptionsToolPointFromCircleAndTangent();
void UpdateOptionsToolPointFromArcAndTangent();
void UpdateOptionsToolShoulderPoint(); void UpdateOptionsToolShoulderPoint();
void UpdateOptionsToolSpline(); void UpdateOptionsToolSpline();
void UpdateOptionsToolSplinePath(); void UpdateOptionsToolSplinePath();

View File

@ -1145,7 +1145,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
<< VToolLineIntersectAxis::ToolType << VToolCurveIntersectAxis::ToolType << VToolLineIntersectAxis::ToolType << VToolCurveIntersectAxis::ToolType
<< VToolPointOfIntersectionArcs::ToolType << VToolPointOfIntersectionArcs::ToolType
<< VToolPointOfIntersectionCircles::ToolType << VToolPointOfIntersectionCircles::ToolType
<< VToolPointFromCircleAndTangent::ToolType; << VToolPointFromCircleAndTangent::ToolType
<< VToolPointFromArcAndTangent::ToolType;
switch (points.indexOf(type)) switch (points.indexOf(type))
{ {
case 0: //VToolSinglePoint::ToolType case 0: //VToolSinglePoint::ToolType
@ -1715,6 +1716,26 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
throw excep; throw excep;
} }
break; break;
case 20: //VToolPointFromArcAndTangent::ToolType
try
{
PointsCommonAttributes(domElement, id, name, mx, my);
const quint32 arcId = GetParametrUInt(domElement, VAbstractTool::AttrArc, NULL_ID_STR);
const quint32 tangentId = GetParametrUInt(domElement, VAbstractTool::AttrTangent, NULL_ID_STR);
const CrossCirclesPoint crossPoint = static_cast<CrossCirclesPoint>(GetParametrUInt(domElement,
VAbstractTool::AttrCrossPoint,
"1"));
VToolPointFromArcAndTangent::Create(id, name, arcId, tangentId, crossPoint, mx, my,
scene, this, data, parse, Source::FromFile);
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating point from arc and tangent"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
break;
default: default:
qDebug() << "Illegal point type in VDomDocument::ParsePointElement()."; qDebug() << "Illegal point type in VDomDocument::ParsePointElement().";
break; break;