First successful build.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-05-27 13:48:21 +03:00
parent 086a2ebaa9
commit 71302fddf0
19 changed files with 1031 additions and 20 deletions

View file

@ -51,6 +51,7 @@
#include "tools/dialogpointofintersection.h"
#include "tools/dialoglineintersectaxis.h"
#include "tools/dialogcurveintersectaxis.h"
#include "tools/dialogpointofintersectionarcs.h"
#include "app/dialoghistory.h"
#include "app/dialogincrements.h"

View file

@ -44,7 +44,8 @@ HEADERS += \
$$PWD/tools/dialogcurveintersectaxis.h \
$$PWD/app/dialoglayoutsettings.h \
$$PWD/app/dialoglayoutprogress.h \
dialogs/app/dialogsavelayout.h
$$PWD/app/dialogsavelayout.h \
$$PWD/tools/dialogpointofintersectionarcs.h
SOURCES += \
$$PWD/tools/dialogtriangle.cpp \
@ -87,7 +88,8 @@ SOURCES += \
$$PWD/tools/dialogcurveintersectaxis.cpp \
$$PWD/app/dialoglayoutsettings.cpp \
$$PWD/app/dialoglayoutprogress.cpp \
dialogs/app/dialogsavelayout.cpp
$$PWD/app/dialogsavelayout.cpp \
$$PWD/tools/dialogpointofintersectionarcs.cpp
FORMS += \
$$PWD/tools/dialogtriangle.ui \
@ -124,4 +126,5 @@ FORMS += \
$$PWD/tools/dialogcurveintersectaxis.ui \
$$PWD/app/dialoglayoutsettings.ui \
$$PWD/app/dialoglayoutprogress.ui \
dialogs/app/dialogsavelayout.ui
$$PWD/app/dialogsavelayout.ui \
$$PWD/tools/dialogpointofintersectionarcs.ui

View file

@ -165,17 +165,7 @@ void DialogPointOfIntersection::PointNameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersection::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
VisToolPointOfIntersection *toolVis = qobject_cast<VisToolPointOfIntersection *>(vis);
SCASSERT(toolVis != nullptr);
connect(scene, &VMainGraphicsScene::NewFactor, toolVis, &Visualization::SetFactor);
toolVis->RefreshGeometry();
}
AddVisualization<VisToolPointOfIntersection>();
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -0,0 +1,234 @@
/************************************************************************
**
** @file dialogpointofintersectionarcs.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 25 5, 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 "dialogpointofintersectionarcs.h"
#include "ui_dialogpointofintersectionarcs.h"
#include "../../libs/vgeometry/vpointf.h"
#include "../../container/vcontainer.h"
#include "../../visualization/vistoolpointofintersectionarcs.h"
#include "../../widgets/vmaingraphicsscene.h"
//---------------------------------------------------------------------------------------------------------------------
DialogPointOfIntersectionArcs::DialogPointOfIntersectionArcs(const VContainer *data, const quint32 &toolId,
QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersectionArcs)
{
ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
InitOkCancelApply(ui);
CheckState();
FillComboBoxArcs(ui->comboBoxArc1);
FillComboBoxArcs(ui->comboBoxArc2);
FillComboBoxCrossArcPoints();
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionArcs::NamePointChanged);
connect(ui->comboBoxArc1, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogPointOfIntersectionArcs::ArcChanged);
connect(ui->comboBoxArc1, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogPointOfIntersectionArcs::ArcChanged);
vis = new VisToolPointOfIntersectionArcs(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogPointOfIntersectionArcs::~DialogPointOfIntersectionArcs()
{
DeleteVisualization<VisToolPointOfIntersectionArcs>();
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::SetPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogPointOfIntersectionArcs::GetFirstArcId() const
{
return getCurrentObjectId(ui->comboBoxArc1);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::SetFirstArcId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxArc1, value);
VisToolPointOfIntersectionArcs *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
SCASSERT(point != nullptr);
point->setArc1Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogPointOfIntersectionArcs::GetSecondArcId() const
{
return getCurrentObjectId(ui->comboBoxArc2);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::SetSecondArcId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxArc2, value);
VisToolPointOfIntersectionArcs *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
SCASSERT(point != nullptr);
point->setArc2Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
CrossArcPoint DialogPointOfIntersectionArcs::GetCrossArcPoint() const
{
int value;
bool ok = false;
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
value = ui->comboBoxResult->itemData(box->currentIndex()).toInt(&ok);
#else
value = ui->comboBoxResult->currentData().toInt(&ok);
#endif
if (not ok)
{
return CrossArcPoint::FirstPoint;
}
switch(value)
{
case 1:
return CrossArcPoint::FirstPoint;
break;
case 2:
return CrossArcPoint::SecondPoint;
break;
default:
return CrossArcPoint::FirstPoint;
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::SetCrossArcPoint(CrossArcPoint &p)
{
const qint32 index = ui->comboBoxResult->findData(static_cast<int>(p));
if (index != -1)
{
ui->comboBoxResult->setCurrentIndex(index);
VisToolPointOfIntersectionArcs *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
SCASSERT(point != nullptr);
point->setCrossPoint(p);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false)// After first choose we ignore all objects
{
if (type == SceneObject::Arc)
{
VisToolPointOfIntersectionArcs *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
SCASSERT(point != nullptr);
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxArc1, tr("Select second an arc")))
{
number++;
point->setArc1Id(id);
point->RefreshGeometry();
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxArc2) != id)
{
if (SetObject(id, ui->comboBoxArc2, ""))
{
point->setArc2Id(id);
point->RefreshGeometry();
prepare = true;
this->setModal(true);
this->show();
}
}
break;
default:
break;
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::ArcChanged()
{
QColor color = okColor;
if (getCurrentObjectId(ui->comboBoxArc1) == getCurrentObjectId(ui->comboBoxArc2))
{
flagError = false;
color = errorColor;
}
else
{
flagError = true;
color = okColor;
}
ChangeColor(ui->labelArc1, color);
ChangeColor(ui->labelArc2, color);
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::ShowVisualization()
{
AddVisualization<VisToolPointOfIntersectionArcs>();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::SaveData()
{
pointName = ui->lineEditNamePoint->text();
VisToolPointOfIntersectionArcs *point = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
SCASSERT(point != nullptr);
point->setArc1Id(GetFirstArcId());
point->setArc2Id(GetSecondArcId());
point->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionArcs::FillComboBoxCrossArcPoints()
{
ui->comboBoxResult->addItem(tr("First point"), QVariant(static_cast<int>(CrossArcPoint::FirstPoint)));
ui->comboBoxResult->addItem(tr("Second point"), QVariant(static_cast<int>(CrossArcPoint::SecondPoint)));
}

View file

@ -0,0 +1,78 @@
/************************************************************************
**
** @file dialogpointofintersectionarcs.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 25 5, 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 DIALOGPOINTOFINTERSECTIONARCS_H
#define DIALOGPOINTOFINTERSECTIONARCS_H
#include "dialogtool.h"
#include "../../xml/vpattern.h"
namespace Ui
{
class DialogPointOfIntersectionArcs;
}
class DialogPointOfIntersectionArcs : public DialogTool
{
Q_OBJECT
public:
explicit DialogPointOfIntersectionArcs(const VContainer *data, const quint32 &toolId, QWidget *parent = 0);
virtual ~DialogPointOfIntersectionArcs();
void SetPointName(const QString &value);
quint32 GetFirstArcId() const;
void SetFirstArcId(const quint32 &value);
quint32 GetSecondArcId() const;
void SetSecondArcId(const quint32 &value);
CrossArcPoint GetCrossArcPoint() const;
void SetCrossArcPoint(CrossArcPoint &p);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type);
virtual void ArcChanged();
protected:
virtual void ShowVisualization();
/**
* @brief SaveData Put dialog data in local variables
*/
virtual void SaveData();
private:
Q_DISABLE_COPY(DialogPointOfIntersectionArcs)
Ui::DialogPointOfIntersectionArcs *ui;
void FillComboBoxCrossArcPoints();
};
#endif // DIALOGPOINTOFINTERSECTIONARCS_H

View file

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogPointOfIntersectionArcs</class>
<widget class="QDialog" name="DialogPointOfIntersectionArcs">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>285</width>
<height>179</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>285</width>
<height>179</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>285</width>
<height>179</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<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="labelArc1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>First arc</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxArc1">
<property name="toolTip">
<string>Selected arc</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelArc2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Second arc</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxArc2">
<property name="toolTip">
<string>Selected 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/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogPointOfIntersectionArcs</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>DialogPointOfIntersectionArcs</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

@ -695,6 +695,16 @@ void MainWindow::ToolCurveIntersectAxis(bool checked)
&MainWindow::ApplyDialog<VToolCurveIntersectAxis>);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::PointOfIntersectionArcs(bool checked)
{
SetToolButtonWithApply<DialogPointOfIntersectionArcs>(checked, Tool::PointOfIntersectionArcs,
"://cursor/point_of_intersection_arcs.png",
tr("Select first an arc"),
&MainWindow::ClosedDialogWithApply<VToolPointOfIntersectionArcs>,
&MainWindow::ApplyDialog<VToolPointOfIntersectionArcs>);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief About show widows about.
@ -990,6 +1000,7 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonCurveIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis);
connect(ui->toolButtonArcIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis);
connect(ui->toolButtonLayoutSettings, &QToolButton::clicked, this, &MainWindow::ToolLayoutSettings);
connect(ui->toolButtonPointOfIntersectionArcs, &QToolButton::clicked, this, &MainWindow::PointOfIntersectionArcs);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1103,6 +1114,9 @@ void MainWindow::CancelTool()
ui->toolButtonCurveIntersectAxis->setChecked(false);
ui->toolButtonArcIntersectAxis->setChecked(false);
break;
case Tool::PointOfIntersectionArcs:
ui->toolButtonPointOfIntersectionArcs->setChecked(false);
break;
case Tool::NodePoint:
case Tool::NodeArc:
case Tool::NodeSpline:

View file

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

View file

@ -86,14 +86,15 @@ enum class Tool : unsigned char
Height,
Triangle,
LineIntersectAxis,
PointOfIntersectionArcs,
CurveIntersectAxis,
PointOfIntersection,
UnionDetails // 30
UnionDetails // 31
};
enum class Vis : unsigned char
{
ControlPointSpline = 31, // increase this value if need more positions in Tool enum
ControlPointSpline = 32, // increase this value if need more positions in Tool enum
GraphicsSimpleTextItem,
SimpleSplinePath,
Line,
@ -109,6 +110,7 @@ enum class Vis : unsigned char
ToolNormal,
ToolPointOfContact,
ToolPointOfIntersection,
ToolPointOfIntersectionArcs,
ToolShoulderPoint,
ToolSpline,
ToolTriangle,

View file

@ -44,6 +44,7 @@
#include "vtoolheight.h"
#include "vtooltriangle.h"
#include "vtoolpointofintersection.h"
#include "vtoolpointofintersectionarcs.h"
#include "vtoolcutspline.h"
#include "vtoolcutsplinepath.h"
#include "vtoolcutarc.h"

View file

@ -0,0 +1,290 @@
/************************************************************************
**
** @file vtoolpointofintersectionarcs.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 25 5, 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 "vtoolpointofintersectionarcs.h"
#include "../../dialogs/tools/dialogpointofintersectionarcs.h"
#include "../../libs/vgeometry/vpointf.h"
#include "../../libs/vgeometry/varc.h"
#include "../../visualization/vistoolpointofintersectionarcs.h"
const QString VToolPointOfIntersectionArcs::ToolType = QStringLiteral("pointOfIntersectionArcs");
//---------------------------------------------------------------------------------------------------------------------
VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id,
const quint32 &firstArcId, const quint32 &secondArcId,
CrossArcPoint pType, const Source &typeCreation,
QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), firstArcId(firstArcId), secondArcId(secondArcId), crossPoint(pType)
{
if (typeCreation == Source::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::setDialog()
{
SCASSERT(dialog != nullptr);
DialogPointOfIntersectionArcs *dialogTool = qobject_cast<DialogPointOfIntersectionArcs*>(dialog);
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->SetFirstArcId(firstArcId);
dialogTool->SetSecondArcId(secondArcId);
dialogTool->SetCrossArcPoint(crossPoint);
dialogTool->SetPointName(p->name());
}
//---------------------------------------------------------------------------------------------------------------------
VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(DialogTool *dialog, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogPointOfIntersectionArcs *dialogTool = qobject_cast<DialogPointOfIntersectionArcs*>(dialog);
SCASSERT(dialogTool != nullptr);
const quint32 firstArcId = dialogTool->GetFirstArcId();
const quint32 secondArcId = dialogTool->GetSecondArcId();
const CrossArcPoint pType = dialogTool->GetCrossArcPoint();
const QString pointName = dialogTool->getPointName();
VToolPointOfIntersectionArcs *point = nullptr;
point = Create(0, pointName, firstArcId, secondArcId, pType, 5, 10, scene, doc, data, Document::FullParse,
Source::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
}
return point;
}
//---------------------------------------------------------------------------------------------------------------------
VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 _id, const QString &pointName,
const quint32 &firstArcId,
const quint32 &secondArcId, CrossArcPoint pType,
const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse,
const Source &typeCreation)
{
const QSharedPointer<VArc> firstArc = data->GeometricObject<VArc>(firstArcId);
const QSharedPointer<VArc> secondArc = data->GeometricObject<VArc>(secondArcId);
const QPointF point = FindPoint(firstArc.data(), secondArc.data(), pType);
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::PointOfIntersectionArcs, doc);
if (parse == Document::FullParse)
{
VToolPointOfIntersectionArcs *point = new VToolPointOfIntersectionArcs(doc, data, id, firstArcId,
secondArcId, pType, typeCreation);
scene->addItem(point);
connect(point, &VToolPointOfIntersectionArcs::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersectionArcs::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionArcs::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionArcs::EnableToolMove);
doc->AddTool(id, point);
doc->IncrementReferens(firstArcId);
doc->IncrementReferens(secondArcId);
return point;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VToolPointOfIntersectionArcs::FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcPoint pType)
{
QPointF p1, p2;
const int res = VGObject::IntersectionCircles(arc1->GetCenter().toQPointF(), arc1->GetRadius(),
arc2->GetCenter().toQPointF(), arc2->GetRadius(), p1, p2);
switch(res)
{
case 2:
if (pType == CrossArcPoint::FirstPoint)
{
return p1;
}
else
{
return p2;
}
break;
case 1:
return p1;
break;
case 3:
case 0:
default:
return QPointF(0, 0);
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolPointOfIntersectionArcs::GetFirstArcId() const
{
return firstArcId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::SetFirstArcId(const quint32 &value)
{
if (value != NULL_ID)
{
firstArcId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolPointOfIntersectionArcs::GetSecondArcId() const
{
return secondArcId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::SetSecondArcId(const quint32 &value)
{
if (value != NULL_ID)
{
secondArcId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
CrossArcPoint VToolPointOfIntersectionArcs::GetCrossArcPoint() const
{
return crossPoint;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::SetCrossArcPoint(CrossArcPoint &value)
{
crossPoint = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::ShowVisualization(bool show)
{
ShowToolVisualization<VisToolPointOfIntersectionArcs>(show);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::FullUpdateFromFile()
{
ReadAttributes();
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
SetVisualization();
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::RemoveReferens()
{
doc->DecrementReferens(firstArcId);
doc->DecrementReferens(secondArcId);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogPointOfIntersectionArcs>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
DialogPointOfIntersectionArcs *dialogTool = qobject_cast<DialogPointOfIntersectionArcs*>(dialog);
SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrFirstArc, QString().setNum(dialogTool->GetFirstArcId()));
doc->SetAttribute(domElement, AttrSecondArc, QString().setNum(dialogTool->GetSecondArcId()));
doc->SetAttribute(domElement, AttrCrossPoint, QString().setNum(static_cast<int>(dialogTool->GetCrossArcPoint())));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrFirstArc, firstArcId);
doc->SetAttribute(tag, AttrSecondArc, secondArcId);
doc->SetAttribute(tag, AttrCrossPoint, static_cast<int>(crossPoint));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::ReadToolAttributes(const QDomElement &domElement)
{
firstArcId = doc->GetParametrUInt(domElement, AttrFirstArc, NULL_ID_STR);
secondArcId = doc->GetParametrUInt(domElement, AttrSecondArc, NULL_ID_STR);
crossPoint = static_cast<CrossArcPoint>(doc->GetParametrUInt(domElement, AttrCrossPoint, "1"));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfIntersectionArcs::SetVisualization()
{
if (vis != nullptr)
{
VisToolPointOfIntersectionArcs *visual = qobject_cast<VisToolPointOfIntersectionArcs *>(vis);
SCASSERT(visual != nullptr);
visual->setArc1Id(firstArcId);
visual->setArc2Id(secondArcId);
visual->setCrossPoint(crossPoint);
visual->RefreshGeometry();
}
}

View file

@ -0,0 +1,89 @@
/************************************************************************
**
** @file vtoolpointofintersectionarcs.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 25 5, 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 VTOOLPOINTOFINTERSECTIONARCS_H
#define VTOOLPOINTOFINTERSECTIONARCS_H
#include "vtoolpoint.h"
#include "../../xml/vpattern.h"
class VArc;
class VToolPointOfIntersectionArcs : public VToolPoint
{
Q_OBJECT
public:
VToolPointOfIntersectionArcs(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstArcId,
const quint32 &secondArcId, CrossArcPoint crossPoint, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog();
static VToolPointOfIntersectionArcs *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data);
static VToolPointOfIntersectionArcs *Create(const quint32 _id, const QString &pointName, const quint32 &firstArcId,
const quint32 &secondArcId, CrossArcPoint crossPoint,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static QPointF FindPoint(const VArc *arc1, const VArc *arc2, const CrossArcPoint crossPoint);
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::PointOfIntersectionArcs) };
quint32 GetFirstArcId() const;
void SetFirstArcId(const quint32 &value);
quint32 GetSecondArcId() const;
void SetSecondArcId(const quint32 &value);
CrossArcPoint GetCrossArcPoint() const;
void SetCrossArcPoint(CrossArcPoint &value);
virtual void ShowVisualization(bool show);
public slots:
virtual void FullUpdateFromFile();
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(VToolPointOfIntersectionArcs)
/** @brief firstArcId id first arc. */
quint32 firstArcId;
/** @brief secondArcId id second arc. */
quint32 secondArcId;
CrossArcPoint crossPoint;
};
#endif // VTOOLPOINTOFINTERSECTIONARCS_H

View file

@ -38,7 +38,8 @@ HEADERS += \
$$PWD/drawTools/vabstractspline.h \
$$PWD/drawTools/vtoolcut.h \
$$PWD/drawTools/vtoollineintersectaxis.h \
$$PWD/drawTools/vtoolcurveintersectaxis.h
$$PWD/drawTools/vtoolcurveintersectaxis.h \
$$PWD/drawTools/vtoolpointofintersectionarcs.h
SOURCES += \
$$PWD/vtooldetail.cpp \
@ -74,4 +75,5 @@ SOURCES += \
$$PWD/drawTools/vabstractspline.cpp \
$$PWD/drawTools/vtoolcut.cpp \
$$PWD/drawTools/vtoollineintersectaxis.cpp \
$$PWD/drawTools/vtoolcurveintersectaxis.cpp
$$PWD/drawTools/vtoolcurveintersectaxis.cpp \
$$PWD/drawTools/vtoolpointofintersectionarcs.cpp

View file

@ -76,6 +76,9 @@ const QString VAbstractTool::AttrAxisP2 = QStringLiteral("axisP2");
const QString VAbstractTool::AttrCurve = QStringLiteral("curve");
const QString VAbstractTool::AttrLineColor = QStringLiteral("lineColor");
const QString VAbstractTool::AttrColor = QStringLiteral("color");
const QString VAbstractTool::AttrFirstArc = QStringLiteral("firstArc");
const QString VAbstractTool::AttrSecondArc = QStringLiteral("secondArc");
const QString VAbstractTool::AttrCrossPoint = QStringLiteral("crossPoint");
const QString VAbstractTool::TypeLineNone = QStringLiteral("none");
const QString VAbstractTool::TypeLineLine = QStringLiteral("hair");

View file

@ -91,6 +91,9 @@ public:
static const QString AttrCurve;
static const QString AttrLineColor;
static const QString AttrColor;
static const QString AttrFirstArc;
static const QString AttrSecondArc;
static const QString AttrCrossPoint;
static const QString TypeLineNone;
static const QString TypeLineLine;

View file

@ -0,0 +1,88 @@
/************************************************************************
**
** @file vistoolpointofintersectionarcs.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 27 5, 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 "vistoolpointofintersectionarcs.h"
#include "../libs/vgeometry/varc.h"
#include "../container/vcontainer.h"
#include "../tools/drawTools/vtoolpointofintersectionarcs.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolPointOfIntersectionArcs::VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent)
: VisLine(data, parent), arc1Id(NULL_ID), arc2Id(NULL_ID), crossPoint(CrossArcPoint::FirstPoint), point(nullptr),
arc1Path(nullptr), arc2Path(nullptr)
{
arc1Path = InitItem<QGraphicsPathItem>(Qt::darkGreen, this);
arc1Path->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
arc2Path = InitItem<QGraphicsPathItem>(Qt::darkRed, this);
arc2Path->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
point = InitPoint(mainColor, this);
point->setZValue(2);
point->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolPointOfIntersectionArcs::~VisToolPointOfIntersectionArcs()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionArcs::RefreshGeometry()
{
if (arc1Id > NULL_ID)
{
const QSharedPointer<VArc> arc1 = Visualization::data->GeometricObject<VArc>(arc1Id);
DrawPath(arc1Path, arc1->GetPath(PathDirection::Hide), supportColor, Qt::SolidLine, Qt::RoundCap);
if (arc2Id > NULL_ID)
{
const QSharedPointer<VArc> arc2 = Visualization::data->GeometricObject<VArc>(arc2Id);
DrawPath(arc2Path, arc2->GetPath(PathDirection::Hide), supportColor, Qt::SolidLine, Qt::RoundCap);
const QPointF fPoint = VToolPointOfIntersectionArcs::FindPoint(arc1.data(), arc2.data(), crossPoint);
DrawPoint(point, fPoint, mainColor);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionArcs::setArc1Id(const quint32 &value)
{
arc1Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionArcs::setArc2Id(const quint32 &value)
{
arc2Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossArcPoint &value)
{
crossPoint = value;
}

View file

@ -0,0 +1,60 @@
/************************************************************************
**
** @file vistoolpointofintersectionarcs.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 27 5, 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 VISTOOLPOINTOFINTERSECTIONARCS_H
#define VISTOOLPOINTOFINTERSECTIONARCS_H
#include "visline.h"
#include "../xml/vpattern.h"
class VisToolPointOfIntersectionArcs : public VisLine
{
Q_OBJECT
public:
VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolPointOfIntersectionArcs();
virtual void RefreshGeometry();
void setArc1Id(const quint32 &value);
void setArc2Id(const quint32 &value);
void setCrossPoint(const CrossArcPoint &value);
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersection)};
private:
Q_DISABLE_COPY(VisToolPointOfIntersectionArcs)
quint32 arc1Id;
quint32 arc2Id;
CrossArcPoint crossPoint;
QGraphicsEllipseItem *point;
QGraphicsPathItem *arc1Path;
QGraphicsPathItem *arc2Path;
};
#endif // VISTOOLPOINTOFINTERSECTIONARCS_H

View file

@ -26,7 +26,8 @@ HEADERS += \
$$PWD/vistoolsplinepath.h \
$$PWD/vistoolcutsplinepath.h \
$$PWD/vistoollineintersectaxis.h \
$$PWD/vistoolcurveintersectaxis.h
$$PWD/vistoolcurveintersectaxis.h \
$$PWD/vistoolpointofintersectionarcs.h
SOURCES += \
$$PWD/vgraphicssimpletextitem.cpp \
@ -53,4 +54,5 @@ SOURCES += \
$$PWD/vistoolsplinepath.cpp \
$$PWD/vistoolcutsplinepath.cpp \
$$PWD/vistoollineintersectaxis.cpp \
$$PWD/vistoolcurveintersectaxis.cpp
$$PWD/vistoolcurveintersectaxis.cpp \
$$PWD/vistoolpointofintersectionarcs.cpp

View file

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