New tool CutSpline (Drawing mode).

--HG--
branch : feature
This commit is contained in:
dismine 2013-12-18 13:13:32 +02:00
parent 58cfd595bd
commit 13bc690f67
48 changed files with 3181 additions and 146 deletions

View File

@ -142,8 +142,8 @@ void DialogAlongLine::DialogAccepted()
pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text();
firstPointId = getCurrentPointId(ui->comboBoxFirstPoint);
secondPointId = getCurrentPointId(ui->comboBoxSecondPoint);
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -156,7 +156,7 @@ void DialogArc::DialogAccepted()
radius = ui->lineEditRadius->text();
f1 = ui->lineEditF1->text();
f2 = ui->lineEditF2->text();
center = getCurrentPointId(ui->comboBoxBasePoint);
center = getCurrentObjectId(ui->comboBoxBasePoint);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -186,8 +186,8 @@ void DialogBisector::DialogAccepted()
pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text();
firstPointId = getCurrentPointId(ui->comboBoxFirstPoint);
secondPointId = getCurrentPointId(ui->comboBoxSecondPoint);
thirdPointId = getCurrentPointId(ui->comboBoxThirdPoint);
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
thirdPointId = getCurrentObjectId(ui->comboBoxThirdPoint);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -0,0 +1,136 @@
/************************************************************************
**
** @file dialogcutspline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 "dialogcutspline.h"
#include "ui_dialogcutspline.h"
DialogCutSpline::DialogCutSpline(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogCutSpline), pointName(QString()), formula(QString()),
splineId(0)
{
ui->setupUi(this);
listWidget = ui->listWidget;
labelResultCalculation = ui->labelResultCalculation;
labelDescription = ui->labelDescription;
radioButtonSizeGrowth = ui->radioButtonSizeGrowth;
radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint;
flagFormula = false;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogCutSpline::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogCutSpline::DialogRejected);
FillComboBoxSplines(ui->comboBoxSpline);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSpline::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSpline::PutVal);
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogCutSpline::ValChenged);
ShowVariable(data->DataBase());
connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogCutSpline::SizeGrowth);
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogCutSpline::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogCutSpline::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogCutSpline::LengthLines);
connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogCutSpline::LengthArcs);
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogCutSpline::LengthCurves);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutSpline::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSpline::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogCutSpline::FormulaChanged);
}
DialogCutSpline::~DialogCutSpline()
{
delete ui;
}
void DialogCutSpline::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}
void DialogCutSpline::setFormula(const QString &value)
{
formula = value;
ui->lineEditFormula->setText(formula);
}
void DialogCutSpline::setSplineId(const qint64 &value, const qint64 &id)
{
setCurrentSplineId(ui->comboBoxSpline, splineId, value, id, ComboMode::CutSpline);
}
void DialogCutSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Spline)
{
VSpline spl;
if (mode == Draw::Calculation)
{
spl = data->GetSpline(id);
}
else
{
spl = data->GetSplineModeling(id);
}
ChangeCurrentText(ui->comboBoxSpline, spl.name());
emit ToolTip("");
this->show();
}
}
void DialogCutSpline::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text();
formula = ui->lineEditFormula->text();
splineId = getCurrentObjectId(ui->comboBoxSpline);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -0,0 +1,94 @@
/************************************************************************
**
** @file dialogcutspline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 DIALOGCUTSPLINE_H
#define DIALOGCUTSPLINE_H
#include "dialogtool.h"
namespace Ui {
class DialogCutSpline;
}
class DialogCutSpline : public DialogTool
{
Q_OBJECT
public:
DialogCutSpline(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
~DialogCutSpline();
/**
* @brief getPointName return name of point
* @return name
*/
inline QString getPointName() const {return pointName;}
/**
* @brief setPointName set name of point
* @param value name
*/
void setPointName(const QString &value);
/**
* @brief getFormula return string of formula
* @return formula
*/
inline QString getFormula() const {return formula;}
/**
* @brief setFormula set string of formula
* @param value formula
*/
void setFormula(const QString &value);
/**
* @brief getSplineId return id base point of line
* @return id
*/
inline qint64 getSplineId() const {return splineId;}
/**
* @brief setSplineId set id spline
* @param value id
* @param id don't show this id in list
*/
void setSplineId(const qint64 &value, const qint64 &id);
public slots:
/**
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
* @param id id of point or detail
* @param type type of object
*/
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
/**
* @brief DialogAccepted save data and emit signal about closed dialog.
*/
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogCutSpline)
Ui::DialogCutSpline *ui;
QString pointName;
QString formula;
qint64 splineId;
};
#endif // DIALOGCUTSPLINE_H

View File

@ -0,0 +1,360 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogCutSpline</class>
<widget class="QDialog" name="DialogCutSpline">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>520</width>
<height>461</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labelEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Length</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Formula calculation of length of curve</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonEqual">
<property name="toolTip">
<string>Calculate formula</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/equal.png</normaloff>:/icon/24x24/equal.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResultCalculation">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value of length</string>
</property>
<property name="text">
<string>_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Curve</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxSpline">
<property name="toolTip">
<string>Selected curve</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonPutHere">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/putHere.png</normaloff>:/icon/24x24/putHere.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="labelEditNamePoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Name new point</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Input data</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="text">
<string>Size and growth</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandartTable">
<property name="text">
<string>Standart table</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="text">
<string>Increments</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Length of lines</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Length of curves</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<property name="toolTip">
<string>Variables. Click twice to select.</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelDescription">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>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>DialogCutSpline</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>DialogCutSpline</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

@ -0,0 +1,136 @@
/************************************************************************
**
** @file dialogcutsplinrpath.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 "dialogcutsplinepath.h"
#include "ui_dialogcutsplinepath.h"
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, Draw::Draws mode, QWidget *parent)
:DialogTool(data, mode, parent), ui(new Ui::DialogCutSplinePath), pointName(QString()), formula(QString()),
splinePathId(0)
{
ui->setupUi(this);
listWidget = ui->listWidget;
labelResultCalculation = ui->labelResultCalculation;
labelDescription = ui->labelDescription;
radioButtonSizeGrowth = ui->radioButtonSizeGrowth;
radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine;
radioButtonLengthArc = ui->radioButtonLengthArc;
radioButtonLengthCurve = ui->radioButtonLengthSpline;
lineEditFormula = ui->lineEditFormula;
labelEditFormula = ui->labelEditFormula;
labelEditNamePoint = ui->labelEditNamePoint;
flagFormula = false;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogCutSplinePath::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogCutSplinePath::DialogRejected);
FillComboBoxSplines(ui->comboBoxSplinePath);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSplinePath::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSplinePath::PutVal);
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogCutSplinePath::ValChenged);
ShowVariable(data->DataBase());
connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogCutSplinePath::SizeGrowth);
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogCutSplinePath::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogCutSplinePath::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogCutSplinePath::LengthLines);
connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogCutSplinePath::LengthArcs);
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogCutSplinePath::LengthCurves);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutSplinePath::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSplinePath::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogCutSplinePath::FormulaChanged);
}
DialogCutSplinePath::~DialogCutSplinePath()
{
delete ui;
}
void DialogCutSplinePath::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}
void DialogCutSplinePath::setFormula(const QString &value)
{
formula = value;
ui->lineEditFormula->setText(formula);
}
void DialogCutSplinePath::setSplinePathId(const qint64 &value, const qint64 &id)
{
setCurrentSplinePathId(ui->comboBoxSplinePath, splinePathId, value, id);
}
void DialogCutSplinePath::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (idDetail == 0 && mode == Draw::Modeling)
{
if (type == Scene::Detail)
{
idDetail = id;
return;
}
}
if (mode == Draw::Modeling)
{
if (CheckObject(id) == false)
{
return;
}
}
if (type == Scene::Spline)
{
VSplinePath splPath;
if (mode == Draw::Calculation)
{
splPath = data->GetSplinePath(id);
}
else
{
splPath = data->GetSplinePathModeling(id);
}
ChangeCurrentText(ui->comboBoxSplinePath, splPath.name());
emit ToolTip("");
this->show();
}
}
void DialogCutSplinePath::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text();
formula = ui->lineEditFormula->text();
splinePathId = getCurrentObjectId(ui->comboBoxSplinePath);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -0,0 +1,94 @@
/************************************************************************
**
** @file dialogcutsplinrpath.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 DIALOGCUTSPLINEPATH_H
#define DIALOGCUTSPLINEPATH_H
#include "dialogtool.h"
namespace Ui {
class DialogCutSplinePath;
}
class DialogCutSplinePath : public DialogTool
{
Q_OBJECT
public:
DialogCutSplinePath(const VContainer *data, Draw::Draws mode = Draw::Calculation, QWidget *parent = 0);
~DialogCutSplinePath();
/**
* @brief getPointName return name of point
* @return name
*/
inline QString getPointName() const {return pointName;}
/**
* @brief setPointName set name of point
* @param value name
*/
void setPointName(const QString &value);
/**
* @brief getFormula return string of formula
* @return formula
*/
inline QString getFormula() const {return formula;}
/**
* @brief setFormula set string of formula
* @param value formula
*/
void setFormula(const QString &value);
/**
* @brief getSplineId return id base point of line
* @return id
*/
inline qint64 getSplinePathId() const {return splinePathId;}
/**
* @brief setSplineId set id spline
* @param value id
* @param id don't show this id in list
*/
void setSplinePathId(const qint64 &value, const qint64 &id);
public slots:
/**
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
* @param id id of point or detail
* @param type type of object
*/
virtual void ChoosedObject(qint64 id, const Scene::Scenes &type);
/**
* @brief DialogAccepted save data and emit signal about closed dialog.
*/
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogCutSplinePath)
Ui::DialogCutSplinePath *ui;
QString pointName;
QString formula;
qint64 splinePathId;
};
#endif // DIALOGCUTSPLINEPATH_H

View File

@ -0,0 +1,360 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogCutSplinePath</class>
<widget class="QDialog" name="DialogCutSplinePath">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>605</width>
<height>397</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labelEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Length</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Formula calculation of length of curve</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonEqual">
<property name="toolTip">
<string>Calculate formula</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/equal.png</normaloff>:/icon/24x24/equal.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResultCalculation">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value of length</string>
</property>
<property name="text">
<string>_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Curve</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxSplinePath">
<property name="toolTip">
<string>Selected curve path</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonPutHere">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/putHere.png</normaloff>:/icon/24x24/putHere.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="labelEditNamePoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Name new point</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Input data</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="text">
<string>Size and growth</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandartTable">
<property name="text">
<string>Standart table</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="text">
<string>Increments</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Length of lines</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Length of arcs</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Length of curves</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<property name="toolTip">
<string>Variables. Click twice to select.</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelDescription">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>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>DialogCutSplinePath</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>DialogCutSplinePath</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

@ -160,7 +160,7 @@ void DialogEndLine::DialogAccepted()
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text();
angle = ui->doubleSpinBoxAngle->value();
basePointId = getCurrentPointId(ui->comboBoxBasePoint);
basePointId = getCurrentObjectId(ui->comboBoxBasePoint);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -144,8 +144,8 @@ void DialogHeight::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
basePointId = getCurrentPointId(ui->comboBoxBasePoint);
p1LineId = getCurrentPointId(ui->comboBoxP1Line);
p2LineId = getCurrentPointId(ui->comboBoxP2Line);
basePointId = getCurrentObjectId(ui->comboBoxBasePoint);
p1LineId = getCurrentObjectId(ui->comboBoxP1Line);
p2LineId = getCurrentObjectId(ui->comboBoxP2Line);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -155,10 +155,10 @@ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type)
void DialogLineIntersect::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text();
p1Line1 = getCurrentPointId(ui->comboBoxP1Line1);
p2Line1 = getCurrentPointId(ui->comboBoxP2Line1);
p1Line2 = getCurrentPointId(ui->comboBoxP1Line2);
p2Line2 = getCurrentPointId(ui->comboBoxP2Line2);
p1Line1 = getCurrentObjectId(ui->comboBoxP1Line1);
p2Line1 = getCurrentObjectId(ui->comboBoxP2Line1);
p1Line2 = getCurrentObjectId(ui->comboBoxP1Line2);
p2Line2 = getCurrentObjectId(ui->comboBoxP2Line2);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -159,8 +159,8 @@ void DialogNormal::DialogAccepted()
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text();
angle = ui->doubleSpinBoxAngle->value();
firstPointId = getCurrentPointId(ui->comboBoxFirstPoint);
secondPointId = getCurrentPointId(ui->comboBoxSecondPoint);
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -145,9 +145,9 @@ void DialogPointOfContact::DialogAccepted()
{
pointName = ui.lineEditNamePoint->text();
radius = ui.lineEditFormula->text();
center = getCurrentPointId(ui.comboBoxCenter);
firstPoint = getCurrentPointId(ui.comboBoxFirstPoint);
secondPoint = getCurrentPointId(ui.comboBoxSecondPoint);
center = getCurrentObjectId(ui.comboBoxCenter);
firstPoint = getCurrentObjectId(ui.comboBoxFirstPoint);
secondPoint = getCurrentObjectId(ui.comboBoxSecondPoint);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -118,8 +118,8 @@ void DialogPointOfIntersection::ChoosedObject(qint64 id, const Scene::Scenes &ty
void DialogPointOfIntersection::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text();
firstPointId = getCurrentPointId(ui->comboBoxFirstPoint);
secondPointId = getCurrentPointId(ui->comboBoxSecondPoint);
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -45,5 +45,7 @@
#include "dialogspline.h"
#include "dialogsplinepath.h"
#include "dialogheight.h"
#include "dialogcutspline.h"
#include "dialogcutsplinepath.h"
#endif // DIALOGS_H

View File

@ -18,7 +18,9 @@ HEADERS += \
src/dialogs/dialogdetail.h \
src/dialogs/dialogbisector.h \
src/dialogs/dialogarc.h \
src/dialogs/dialogalongline.h
src/dialogs/dialogalongline.h \
src/dialogs/dialogcutspline.h \
src/dialogs/dialogcutsplinepath.h
SOURCES += \
src/dialogs/dialogtriangle.cpp \
@ -39,7 +41,9 @@ SOURCES += \
src/dialogs/dialogdetail.cpp \
src/dialogs/dialogbisector.cpp \
src/dialogs/dialogarc.cpp \
src/dialogs/dialogalongline.cpp
src/dialogs/dialogalongline.cpp \
src/dialogs/dialogcutspline.cpp \
src/dialogs/dialogcutsplinepath.cpp
FORMS += \
src/dialogs/dialogtriangle.ui \
@ -59,4 +63,6 @@ FORMS += \
src/dialogs/dialogdetail.ui \
src/dialogs/dialogbisector.ui \
src/dialogs/dialogarc.ui \
src/dialogs/dialogalongline.ui
src/dialogs/dialogalongline.ui \
src/dialogs/dialogcutspline.ui \
src/dialogs/dialogcutsplinepath.ui

View File

@ -154,9 +154,9 @@ void DialogShoulderPoint::DialogAccepted()
pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text();
p1Line = getCurrentPointId(ui->comboBoxP1Line);
p2Line = getCurrentPointId(ui->comboBoxP2Line);
pShoulder = getCurrentPointId(ui->comboBoxPShoulder);
p1Line = getCurrentObjectId(ui->comboBoxP1Line);
p2Line = getCurrentObjectId(ui->comboBoxP2Line);
pShoulder = getCurrentObjectId(ui->comboBoxPShoulder);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -129,8 +129,8 @@ void DialogSpline::ChoosedObject(qint64 id, const Scene::Scenes &type)
void DialogSpline::DialogAccepted()
{
p1 = getCurrentPointId(ui->comboBoxP1);
p4 = getCurrentPointId(ui->comboBoxP4);
p1 = getCurrentObjectId(ui->comboBoxP1);
p4 = getCurrentObjectId(ui->comboBoxP4);
angle1 = ui->spinBoxAngle1->value();
angle2 = ui->spinBoxAngle2->value();
kAsm1 = ui->doubleSpinBoxKasm1->value();

View File

@ -65,6 +65,7 @@ void DialogTool::showEvent(QShowEvent *event)
void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const
{
Q_ASSERT(box != 0);
box->clear();
if (mode == Draw::Calculation)
{
@ -109,6 +110,99 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const
}
}
void DialogTool::FillComboBoxSplines(QComboBox *box, const qint64 &id, ComboMode::ComboBoxCutSpline cut) const
{
Q_ASSERT(box != 0);
box->clear();
if (mode == Draw::Calculation)
{
const QHash<qint64, VSpline> *spls = data->DataSplines();
QHashIterator<qint64, VSpline> i(*spls);
while (i.hasNext())
{
i.next();
if(cut == ComboMode::CutSpline)
{
if (i.key() != id + 1 && i.key() != id + 2)
{
VSpline spl = i.value();
box->addItem(spl.name(), i.key());
}
}
else
{
if (i.key() != id)
{
VSpline spl = i.value();
box->addItem(spl.name(), i.key());
}
}
}
}
else
{
if (idDetail <= 0)
{
qWarning()<<tr("Wrong details id.")<<Q_FUNC_INFO;
return;
}
VDetail det = data->GetDetail(idDetail);
for (ptrdiff_t i = 0; i< det.CountNode(); ++i)
{
if (det[i].getTypeTool() == Tool::SplineTool ||
det[i].getTypeTool() == Tool::NodeSpline )
{
if (det[i].getId() != id)
{
VSpline spl = data->GetSplineModeling(det[i].getId());
box->addItem(spl.name(), det[i].getId());
}
}
}
}
}
void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const qint64 &id) const
{
Q_ASSERT(box != 0);
box->clear();
if (mode == Draw::Calculation)
{
const QHash<qint64, VSplinePath> *splPaths = data->DataSplinePaths();
QHashIterator<qint64, VSplinePath> i(*splPaths);
while (i.hasNext())
{
i.next();
if (i.key() != id)
{
VSplinePath splPath = i.value();
box->addItem(splPath.name(), i.key());
}
}
}
else
{
if (idDetail <= 0)
{
qWarning()<<tr("Wrong details id.")<<Q_FUNC_INFO;
return;
}
VDetail det = data->GetDetail(idDetail);
for (ptrdiff_t i = 0; i< det.CountNode(); ++i)
{
if (det[i].getTypeTool() == Tool::SplinePathTool ||
det[i].getTypeTool() == Tool::NodeSplinePath )
{
if (det[i].getId() != id)
{
VSplinePath splPath = data->GetSplinePathModeling(det[i].getId());
box->addItem(splPath.name(), det[i].getId());
}
}
}
}
}
void DialogTool::FillComboBoxTypeLine(QComboBox *box) const
{
Q_ASSERT(box != 0);
@ -158,7 +252,7 @@ void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value)
}
else
{
qWarning()<<tr("Can't find point by name")<<value;
qWarning()<<tr("Can't find object by name")<<value;
}
}
@ -242,7 +336,25 @@ void DialogTool::setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64
ChangeCurrentData(box, value);
}
qint64 DialogTool::getCurrentPointId(QComboBox *box) const
void DialogTool::setCurrentSplineId(QComboBox *box, qint64 &splineId, const qint64 &value, const qint64 &id,
ComboMode::ComboBoxCutSpline cut) const
{
Q_ASSERT(box != 0);
FillComboBoxSplines(box, id, cut);
splineId = value;
ChangeCurrentData(box, value);
}
void DialogTool::setCurrentSplinePathId(QComboBox *box, qint64 &splinePathId, const qint64 &value,
const qint64 &id) const
{
Q_ASSERT(box != 0);
FillComboBoxSplinesPath(box, id);
splinePathId = value;
ChangeCurrentData(box, value);
}
qint64 DialogTool::getCurrentObjectId(QComboBox *box) const
{
Q_ASSERT(box != 0);
qint32 index = box->currentIndex();

View File

@ -37,6 +37,16 @@
#include <QRadioButton>
#include "../container/vcontainer.h"
namespace ComboMode
{
/**
* @brief The ComboBoxCutSpline enum
*/
enum ComboBoxCutSpline { CutSpline, NoCutSpline };
Q_DECLARE_FLAGS(ComboBoxCutSplines, ComboBoxCutSpline)
}
Q_DECLARE_OPERATORS_FOR_FLAGS( ComboMode::ComboBoxCutSplines )
/**
* @brief The DialogTool class parent for all dialog of tools.
*/
@ -282,6 +292,14 @@ protected:
* @param id don't show this id in list
*/
void FillComboBoxPoints(QComboBox *box, const qint64 &id = 0)const;
/**
* @brief FillComboBoxSplines fill comboBox list of splines
* @param box comboBox
* @param id don't show id+1 and id+2 in list
*/
void FillComboBoxSplines(QComboBox *box, const qint64 &id = 0,
ComboMode::ComboBoxCutSpline cut = ComboMode::NoCutSpline)const;
void FillComboBoxSplinesPath(QComboBox *box, const qint64 &id = 0)const;
/**
* @brief FillComboBoxTypeLine fill comboBox list of type lines
* @param box comboBox
@ -350,12 +368,30 @@ protected:
* @param id don't show this id in list
*/
void setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, const qint64 &id) const;
/**
* @brief setCurrentSplineId set current spline id in combobox
* @param box combobox
* @param splineId save current spline id
* @param value spline id
* @param id don't show this id in list
*/
void setCurrentSplineId(QComboBox *box, qint64 &splineId, const qint64 &value, const qint64 &id,
ComboMode::ComboBoxCutSpline cut = ComboMode::NoCutSpline) const;
/**
* @brief setCurrentSplinePathId set current splinePath id in combobox
* @param box combobox
* @param splinePathId save current splinePath id
* @param value splinePath id
* @param id don't show this id in list
*/
void setCurrentSplinePathId(QComboBox *box, qint64 &splinePathId, const qint64 &value,
const qint64 &id) const;
/**
* @brief getCurrentPointId return current point id in combobox
* @param box combobox
* @return id or -1 if combobox is empty
*/
qint64 getCurrentPointId(QComboBox *box) const;
qint64 getCurrentObjectId(QComboBox *box) const;
};
#endif // DIALOGTOOL_H

View File

@ -118,10 +118,10 @@ void DialogTriangle::ChoosedObject(qint64 id, const Scene::Scenes &type)
void DialogTriangle::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text();
firstPointId = getCurrentPointId(ui->comboBoxFirstPoint);
secondPointId = getCurrentPointId(ui->comboBoxSecondPoint);
axisP1Id = getCurrentPointId(ui->comboBoxAxisP1);
axisP2Id = getCurrentPointId(ui->comboBoxAxisP2);
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
axisP1Id = getCurrentObjectId(ui->comboBoxAxisP1);
axisP2Id = getCurrentObjectId(ui->comboBoxAxisP2);
emit DialogClosed(QDialog::Accepted);
}

View File

@ -207,32 +207,99 @@ QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *in
throw "Не можу знайти точку перетину сплайну з лінією.";
}
//void VSpline::CutSpline ( qreal length, VSpline* curFir, VSpline* curSec ) const{
// if ( length > GetLength()){
// throw"Не правильна довжина нового сплайну\n";
// }
// qreal parT = length / GetLength();
// QLineF seg1_2 ( GetPointP1 (), GetP2 () );
// seg1_2.setLength(seg1_2.length () * parT);
// QPointF p12 = seg1_2.p2();
// QLineF seg2_3 ( GetP2 (), GetP3 () );
// seg2_3.setLength(seg2_3.length () * parT);
// QPointF p23 = seg2_3.p2();
// QLineF seg12_23 ( p12, p23 );
// seg12_23.setLength(seg12_23.length () * parT);
// QPointF p123 = seg12_23.p2();
// QLineF seg3_4 ( GetP3 (), GetPointP4 () );
// seg3_4.setLength(seg3_4.length () * parT);
// QPointF p34 = seg3_4.p2();
// QLineF seg23_34 ( p23, p34 );
// seg23_34.setLength(seg23_34.length () * parT);
// QPointF p234 = seg23_34.p2();
// QLineF seg123_234 ( p123, p234 );
// seg123_234.setLength(seg123_234.length () * parT);
// QPointF p1234 = seg123_234.p2();
// curFir->ModifiSpl ( GetPointP1 (), p12, p123, p1234 );
// curSec->ModifiSpl ( p1234, p234, p34, GetPointP4 () );
//}
qreal VSpline::LengthT(qreal t) const
{
if(t < 0 || t > 1)
{
qWarning()<<"Wrong value t.";
return 0;
}
QLineF seg1_2 ( GetPointP1 ().toQPointF(), GetP2 () );
seg1_2.setLength(seg1_2.length () * t);
QPointF p12 = seg1_2.p2();
QLineF seg2_3 ( GetP2 (), GetP3 () );
seg2_3.setLength(seg2_3.length () * t);
QPointF p23 = seg2_3.p2();
QLineF seg12_23 ( p12, p23 );
seg12_23.setLength(seg12_23.length () * t);
QPointF p123 = seg12_23.p2();
QLineF seg3_4 ( GetP3 (), GetPointP4 ().toQPointF() );
seg3_4.setLength(seg3_4.length () * t);
QPointF p34 = seg3_4.p2();
QLineF seg23_34 ( p23, p34 );
seg23_34.setLength(seg23_34.length () * t);
QPointF p234 = seg23_34.p2();
QLineF seg123_234 ( p123, p234 );
seg123_234.setLength(seg123_234.length () * t);
QPointF p1234 = seg123_234.p2();
return LengthBezier ( GetPointP1().toQPointF(), p12, p123, p1234);
}
QPointF VSpline::CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3 ) const
{
//Always need return two splines, so we must correct wrong length.
if(length < GetLength()*0.02)
{
length = GetLength()*0.02;
qWarning()<<"Warning!!! Correction length of cutting. Length too small.";
}
else if ( length > GetLength()*0.98)
{
length = GetLength()*0.98;
qWarning()<<"Warning!!! Correction length of cutting. Length too small.";
}
// Very stupid way find correct value of t.
// Better first compare with t = 0.5. Find length of spline.
// If length larger, take t = 0.75 and so on.
// If length less, take t = 0.25 and so on.
qreal parT = 0;
qreal step = 0.001;
while (1)
{
parT = parT + step;
qreal splLength = LengthT(parT);
if(splLength >= length || parT > 1){
break;
}
}
QLineF seg1_2 ( GetPointP1 ().toQPointF(), GetP2 () );
seg1_2.setLength(seg1_2.length () * parT);
QPointF p12 = seg1_2.p2();
QLineF seg2_3 ( GetP2 (), GetP3 () );
seg2_3.setLength(seg2_3.length () * parT);
QPointF p23 = seg2_3.p2();
QLineF seg12_23 ( p12, p23 );
seg12_23.setLength(seg12_23.length () * parT);
QPointF p123 = seg12_23.p2();
QLineF seg3_4 ( GetP3 (), GetPointP4 ().toQPointF() );
seg3_4.setLength(seg3_4.length () * parT);
QPointF p34 = seg3_4.p2();
QLineF seg23_34 ( p23, p34 );
seg23_34.setLength(seg23_34.length () * parT);
QPointF p234 = seg23_34.p2();
QLineF seg123_234 ( p123, p234 );
seg123_234.setLength(seg123_234.length () * parT);
QPointF p1234 = seg123_234.p2();
spl1p2 = p12;
spl1p3 = p123;
spl2p2 = p234;
spl2p3 = p34;
return p1234;
}
//void VSpline::CutSpline ( QPointF point, VSpline* curFir, VSpline* curSec ) const{
// qreal t = param_t (point);

View File

@ -40,19 +40,22 @@ class QString;
#define M_2PI 6.28318530717958647692528676655900576
/**
* @brief VSpline клас, що реалізує сплайн.
* @brief VSpline class that implements the spline.
*/
class VSpline
{
public:
/**
* @brief VSpline default constructor
*/
VSpline();
/**
* @brief VSpline конструктор.
* @param spline сплайн з якого копіюємо.
* @brief VSpline constructor.
* @param spline spline from which the copy.
*/
VSpline (const VSpline &spline );
/**
* @brief VSpline конструктор.
* @brief VSpline constructor.
* @param p1 початкова точка сплайна.
* @param p4 кінцева точка сплайна.
* @param angle1 кут в градусах першої напрямної.
@ -62,8 +65,7 @@ public:
* @param kAsm2 коефіцієнт довжини другої напрямної.
*/
VSpline (const QHash<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode = Draw::Calculation,
qint64 idObject = 0);
qreal kAsm1, qreal kAsm2, qreal kCurve, Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
/**
* @brief VSpline конструктор.
* @param p1 початкова точка сплайну.
@ -94,17 +96,17 @@ public:
*/
void ModifiSpl (const qint64 &p1, const QPointF &p2, const QPointF &p3, const qint64 &p4,
const qreal &kCurve);
/**
* @brief RotationSpl поворот сплайна навколо точки на кут в градусах проти годиникової стрілки.
* @param pRotate точка навколо якої повертаємо.
* @param angle кут в градусах.
*/
// /**
// * @brief RotationSpl поворот сплайна навколо точки на кут в градусах проти годиникової стрілки.
// * @param pRotate точка навколо якої повертаємо.
// * @param angle кут в градусах.
// */
// void RotationSpl ( QPointF pRotate, qreal angle );
/**
* @brief BiasSpl зміщує сплайн.
* @param mx зміщення по х координаті.
* @param my зміщення по у координаті.
*/
// /**
// * @brief BiasSpl зміщує сплайн.
// * @param mx зміщення по х координаті.
// * @param my зміщення по у координаті.
// */
// void BiasSpl ( qreal mx, qreal my );
/**
* @brief GetP1 повертає першу точку сплайну.
@ -183,13 +185,18 @@ public:
* @return результат перевірки.
*/
QLineF::IntersectType CrossingSplLine(const QLineF &line, QPointF *intersectionPoint ) const;
qreal LengthT(qreal t) const;
/**
* @brief CutSpline розрізає сплайн.
* @param length дожина першого сплайну.
* @param curFir перший сплайн.
* @param curSec другий сплайн.
* @brief CutSpline cut spline. GetPointP1() of base spline will return first point for first spline, GetPointP4()
* of base spline will return forth point of second spline.
* @param length length first spline
* @param spl1p2 second point of first spline
* @param spl1p3 third point of first spline
* @param spl2p2 second point of second spline
* @param spl2p3 third point of second spline
* @return point of cutting. This point is forth point of first spline and first point of second spline.
*/
// void CutSpline ( qreal length, VSpline* curFir, VSpline* curSec ) const;
QPointF CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const;
/**
* @brief CutSpline розрізає сплайн.
* @param point точка що ділить сплайн.

View File

@ -169,3 +169,40 @@ VSplinePoint & VSplinePath::operator[](ptrdiff_t indx)
{
return path[indx];
}
QPointF VSplinePath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p3, QPointF &spl2p2) const
{
if(Count() < 2)
{
throw VException(tr("Can't cut spline path with one point"));
}
//Always need return two spline paths, so we must correct wrong length.
qreal fullLength = GetLength();
if(length < fullLength * 0.02)
{
length = fullLength * 0.02;
qWarning()<<"Warning!!! Correction length of cutting. Length too small.";
}
else if ( length > fullLength * 0.98)
{
length = fullLength * 0.98;
qWarning()<<"Warning!!! Correction length of cutting. Length too small.";
}
fullLength = 0;
for (qint32 i = 1; i <= Count(); ++i)
{
VSpline spl(&points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(),
path[i].KAsm1(), kCurve);
fullLength += spl.GetLength();
if(fullLength > length)
{
p1 = i-1;
p2 = i;
QPointF spl1p2, spl2p3;
return spl.CutSpline(length - (fullLength - spl.GetLength()), spl1p2, spl1p3, spl2p2, spl2p3);
}
}
return QPointF();
}

View File

@ -186,6 +186,16 @@ public:
* @param name
*/
void setName(const QString &name) {_name = name;}
/**
* @brief CutSplinePath
* @param length
* @param p1
* @param p2
* @param spl1p3
* @param spl2p2
* @return
*/
QPointF CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF &spl1p3, QPointF &spl2p2) const;
protected:
/**
* @brief path вектор з точок сплайна.

View File

@ -57,6 +57,7 @@ MainWindow::MainWindow(QWidget *parent)
dialogDetail(QSharedPointer<DialogDetail>()), dialogHeight(QSharedPointer<DialogHeight>()),
dialogTriangle(QSharedPointer<DialogTriangle>()),
dialogPointOfIntersection(QSharedPointer<DialogPointOfIntersection>()),
dialogCutSpline(QSharedPointer<DialogCutSpline>()), dialogCutSplinePath (QSharedPointer<DialogCutSplinePath>()),
dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
mode(Draw::Calculation)
{
@ -104,6 +105,8 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->toolButtonHeight, &QToolButton::clicked, this, &MainWindow::ToolHeight);
connect(ui->toolButtonTriangle, &QToolButton::clicked, this, &MainWindow::ToolTriangle);
connect(ui->toolButtonPointOfIntersection, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersection);
connect(ui->toolButtonSplineCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSpline);
connect(ui->toolButtonSplinePathCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSplinePath);
data = new VContainer;
@ -381,6 +384,17 @@ void MainWindow::ClosedDialogSpline(int result)
ClosedDialog<VToolSpline, VModelingSpline>(dialogSpline, result);
}
void MainWindow::ToolCutSpline(bool checked)
{
SetToolButton(checked, Tool::CutSplineTool, ":/cursor/spline_cut_point_cursor.png",
tr("Select simple curve"), dialogCutSpline, &MainWindow::ClosedDialogCutSpline);
}
void MainWindow::ClosedDialogCutSpline(int result)
{
ClosedDialog<VToolCutSpline, VModelingCutSpline>(dialogCutSpline, result);
}
void MainWindow::ToolArc(bool checked)
{
SetToolButton(checked, Tool::ArcTool, ":/cursor/arc_cursor.png",
@ -395,8 +409,7 @@ void MainWindow::ClosedDialogArc(int result)
void MainWindow::ToolSplinePath(bool checked)
{
SetToolButton(checked, Tool::SplinePathTool, ":/cursor/splinepath_cursor.png",
tr("Select point of curve path"), dialogSplinePath,
&MainWindow::ClosedDialogSplinePath);
tr("Select point of curve path"), dialogSplinePath, &MainWindow::ClosedDialogSplinePath);
}
void MainWindow::ClosedDialogSplinePath(int result)
@ -404,6 +417,17 @@ void MainWindow::ClosedDialogSplinePath(int result)
ClosedDialog<VToolSplinePath, VModelingSplinePath>(dialogSplinePath, result);
}
void MainWindow::ToolCutSplinePath(bool checked)
{
SetToolButton(checked, Tool::CutSplinePathTool, ":/cursor/splinepath_cut_point_cursor.png",
tr("Select curve path"), dialogCutSplinePath, &MainWindow::ClosedDialogCutSplinePath);
}
void MainWindow::ClosedDialogCutSplinePath(int result)
{
ClosedDialog<VToolCutSplinePath, VModelingCutSplinePath>(dialogCutSplinePath, result);
}
void MainWindow::ToolPointOfContact(bool checked)
{
SetToolButton(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png",
@ -762,6 +786,18 @@ void MainWindow::CanselTool()
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::CutSplineTool:
dialogCutSpline.clear();
ui->toolButtonSplineCutPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::CutSplinePathTool:
dialogCutSplinePath.clear();
ui->toolButtonSplinePathCutPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
default:
qWarning()<<"Get wrong tool type. Ignore.";
break;
@ -1054,6 +1090,8 @@ void MainWindow::SetEnableTool(bool enable)
ui->toolButtonHeight->setEnabled(enable);
ui->toolButtonTriangle->setEnabled(enable);
ui->toolButtonPointOfIntersection->setEnabled(enable);
ui->toolButtonSplineCutPoint->setEnabled(enable);
ui->toolButtonSplinePathCutPoint->setEnabled(enable);
}
void MainWindow::MinimumScrollBar()

View File

@ -188,6 +188,11 @@ public slots:
* @param checked
*/
void ToolSpline(bool checked);
/**
* @brief ToolCutSpline handler tool CutSpline
* @param checked true - button is checked
*/
void ToolCutSpline(bool checked);
/**
* @brief ToolArc
* @param checked
@ -198,6 +203,11 @@ public slots:
* @param checked
*/
void ToolSplinePath(bool checked);
/**
* @brief ToolCutSplinePath handler tool CutSplinePath
* @param checked true - button is checked
*/
void ToolCutSplinePath(bool checked);
/**
* @brief ToolPointOfContact
* @param checked
@ -273,6 +283,11 @@ public slots:
* @param result
*/
void ClosedDialogSplinePath(int result);
/**
* @brief ClosedDialogCutSplinePath handler close event tool CutSplinePath
* @param result result of working of dialog
*/
void ClosedDialogCutSplinePath(int result);
/**
* @brief ClosedDialogPointOfContact
* @param result
@ -298,6 +313,11 @@ public slots:
* @param result
*/
void ClosedDialogPointOfIntersection(int result);
/**
* @brief ClosedDialogCutSpline handler close event tool CutSpline
* @param result result of working of dialog
*/
void ClosedDialogCutSpline(int result);
/**
* @brief About
*/
@ -444,6 +464,14 @@ private:
* @brief dialogPointOfIntersection
*/
QSharedPointer<DialogPointOfIntersection> dialogPointOfIntersection;
/**
* @brief dialogCutSpline pointer to the dialog tool cut spline
*/
QSharedPointer<DialogCutSpline> dialogCutSpline;
/**
* @brief dialogCutSplinePath pointer to the dialog tool cut spline path
*/
QSharedPointer<DialogCutSplinePath> dialogCutSplinePath;
/**
* @brief dialogHistory
*/

View File

@ -14,7 +14,7 @@
<string>Valentina</string>
</property>
<property name="windowIcon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<property name="locale">
@ -40,7 +40,7 @@
<string/>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
@ -76,7 +76,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/segment.png</normaloff>:/icon/32x32/segment.png</iconset>
</property>
<property name="iconSize">
@ -102,7 +102,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/shoulder.png</normaloff>:/icon/32x32/shoulder.png</iconset>
</property>
<property name="iconSize">
@ -128,7 +128,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/point_of_contact.png</normaloff>:/icon/32x32/point_of_contact.png</iconset>
</property>
<property name="iconSize">
@ -154,7 +154,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/bisector.png</normaloff>:/icon/32x32/bisector.png</iconset>
</property>
<property name="iconSize">
@ -180,7 +180,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/normal.png</normaloff>:/icon/32x32/normal.png</iconset>
</property>
<property name="iconSize">
@ -206,7 +206,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/along_line.png</normaloff>:/icon/32x32/along_line.png</iconset>
</property>
<property name="iconSize">
@ -232,7 +232,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/height.png</normaloff>:/icon/32x32/height.png</iconset>
</property>
<property name="iconSize">
@ -258,7 +258,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/triangle.png</normaloff>:/icon/32x32/triangle.png</iconset>
</property>
<property name="iconSize">
@ -281,7 +281,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/point_of_intersection.png</normaloff>:/icon/32x32/point_of_intersection.png</iconset>
</property>
<property name="iconSize">
@ -331,7 +331,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/line.png</normaloff>:/icon/32x32/line.png</iconset>
</property>
<property name="iconSize">
@ -357,7 +357,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/intersect.png</normaloff>:/icon/32x32/intersect.png</iconset>
</property>
<property name="iconSize">
@ -379,7 +379,7 @@
<x>0</x>
<y>0</y>
<width>150</width>
<height>58</height>
<height>104</height>
</rect>
</property>
<property name="sizePolicy">
@ -407,7 +407,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/spline.png</normaloff>:/icon/32x32/spline.png</iconset>
</property>
<property name="iconSize">
@ -433,7 +433,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/splinePath.png</normaloff>:/icon/32x32/splinePath.png</iconset>
</property>
<property name="iconSize">
@ -447,6 +447,58 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="toolButtonSplinePathCutPoint">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Tool cut path curve.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/splinePath_cut_point.png</normaloff>:/icon/32x32/splinePath_cut_point.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="toolButtonSplineCutPoint">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Tool cut curve.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/spline_cut_point.png</normaloff>:/icon/32x32/spline_cut_point.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>
</widget>
<widget class="QWidget" name="page_4">
@ -483,7 +535,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/arc.png</normaloff>:/icon/32x32/arc.png</iconset>
</property>
<property name="iconSize">
@ -530,7 +582,7 @@
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/new_detail.png</normaloff>:/icon/32x32/new_detail.png</iconset>
</property>
<property name="iconSize">
@ -723,7 +775,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/draw.png</normaloff>:/icon/32x32/draw.png</iconset>
</property>
<property name="text">
@ -741,7 +793,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/kontur.png</normaloff>:/icon/32x32/kontur.png</iconset>
</property>
<property name="text">
@ -759,7 +811,7 @@
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
</property>
<property name="text">
@ -771,7 +823,7 @@
</action>
<action name="actionNewDraw">
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/new_draw.png</normaloff>:/icon/32x32/new_draw.png</iconset>
</property>
<property name="text">
@ -783,7 +835,7 @@
</action>
<action name="actionOptionDraw">
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/option_draw.png</normaloff>:/icon/32x32/option_draw.png</iconset>
</property>
<property name="text">
@ -798,7 +850,7 @@
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/table.png</normaloff>:/icon/32x32/table.png</iconset>
</property>
<property name="text">
@ -813,7 +865,7 @@
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/history.png</normaloff>:/icon/32x32/history.png</iconset>
</property>
<property name="text">
@ -822,7 +874,7 @@
</action>
<action name="actionLayout">
<property name="icon">
<iconset resource="icon.qrc">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/layout.png</normaloff>:/icon/32x32/layout.png</iconset>
</property>
<property name="text">
@ -864,7 +916,7 @@
<tabstop>toolButtonNewDetail</tabstop>
</tabstops>
<resources>
<include location="icon.qrc"/>
<include location="../share/resources/icon.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -65,8 +65,10 @@ namespace Tool
BisectorTool,
LineIntersectTool,
SplineTool,
CutSplineTool,
ArcTool,
SplinePathTool,
CutSplinePathTool,
PointOfContact,
Detail,
NodePoint,

View File

@ -44,5 +44,7 @@
#include "vtoolheight.h"
#include "vtooltriangle.h"
#include "vtoolpointofintersection.h"
#include "vtoolcutspline.h"
#include "vtoolcutsplinepath.h"
#endif // DRAWTOOLS_H

View File

@ -0,0 +1,247 @@
/************************************************************************
**
** @file vtoolcutspline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 "vtoolcutspline.h"
#include "../../container/calculator.h"
const QString VToolCutSpline::ToolType = QStringLiteral("cutSpline");
const QString VToolCutSpline::AttrSpline = QStringLiteral("spline");
VToolCutSpline::VToolCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula,
const qint64 &splineId, const qint64 &spl1id, const qint64 &spl2id,
const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), formula(formula), splineId(splineId),
dialogCutSpline(QSharedPointer<DialogCutSpline>()), firstSpline(), secondSpline(), spl1id(spl1id), spl2id(spl2id)
{
Q_ASSERT_X(splineId > 0, Q_FUNC_INFO, "splineId <= 0");
Q_ASSERT_X(spl1id > 0, Q_FUNC_INFO, "spl1id <= 0");
Q_ASSERT_X(spl2id > 0, Q_FUNC_INFO, "spl2id <= 0");
firstSpline = new VSimpleSpline(spl1id, &factor, &currentColor);
Q_ASSERT(firstSpline != 0);
RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint);
firstSpline->setParentItem(this);
connect(firstSpline, &VSimpleSpline::Choosed, this, &VToolCutSpline::SplineChoosed);
secondSpline = new VSimpleSpline(spl2id, &factor, &currentColor);
Q_ASSERT(secondSpline != 0);
RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint);
secondSpline->setParentItem(this);
connect(secondSpline, &VSimpleSpline::Choosed, this, &VToolCutSpline::SplineChoosed);
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VToolCutSpline::setDialog()
{
Q_ASSERT(dialogCutSpline.isNull() == false);
VPointF point = VAbstractTool::data.GetPoint(id);
dialogCutSpline->setFormula(formula);
dialogCutSpline->setSplineId(splineId, id);
dialogCutSpline->setPointName(point.name());
}
void VToolCutSpline::Create(QSharedPointer<DialogCutSpline> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data)
{
QString pointName = dialog->getPointName();
QString formula = dialog->getFormula();
qint64 splineId = dialog->getSplineId();
Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Tool::FromGui);
}
void VToolCutSpline::Create(const qint64 _id, const QString &pointName,
const QString &formula, const qint64 &splineId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation)
{
VSpline spl = data->GetSpline(splineId);
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if (errorMsg.isEmpty())
{
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
QPointF point = spl.CutSpline(toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);
qint64 id = _id;
qint64 spl1id = 0;
qint64 spl2id = 0;
if (typeCreation == Tool::FromGui)
{
id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my));
spl1id = id + 1;
spl2id = id + 2;
VSpline spline1 = VSpline(data->DataPoints(), spl.GetP1(), spl1p2, spl1p3, id, spl.GetKcurve());
spl1id = data->AddSpline(spline1);
data->AddLengthSpline(spline1.name(), toMM(spline1.GetLength()));
VSpline spline2 = VSpline(data->DataPoints(), id, spl2p2, spl2p3, spl.GetP4(), spl.GetKcurve());
spl2id = data->AddSpline(spline2);
data->AddLengthSpline(spline2.name(), toMM(spline2.GetLength()));
}
else
{
data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my));
spl1id = id + 1;
spl2id = id + 2;
VSpline spline1 = VSpline(data->DataPoints(), spl.GetP1(), spl1p2, spl1p3, id, spl.GetKcurve());
data->UpdateSpline(spl1id, spline1);
data->AddLengthSpline(spline1.name(), toMM(spline1.GetLength()));
VSpline spline2 = VSpline(data->DataPoints(), id, spl2p2, spl2p3, spl.GetP4(), spl.GetKcurve());
data->UpdateSpline(spl2id, spline2);
data->AddLengthSpline(spline2.name(), toMM(spline2.GetLength()));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
//VDrawTool::AddRecord(id, Tool::CutSplineTool, doc);
if (parse == Document::FullParse)
{
VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation);
scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
doc->AddTool(id, point);
doc->AddTool(spl1id, point);
doc->AddTool(spl2id, point);
doc->IncrementReferens(splineId);
}
}
}
void VToolCutSpline::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
formula = domElement.attribute(AttrLength, "");
splineId = domElement.attribute(AttrSpline, "").toLongLong();
}
RefreshGeometry();
}
void VToolCutSpline::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogCutSpline->getPointName());
domElement.setAttribute(AttrLength, dialogCutSpline->getFormula());
domElement.setAttribute(AttrSpline, QString().setNum(dialogCutSpline->getSplineId()));
emit FullUpdateTree();
}
}
dialogCutSpline.clear();
}
void VToolCutSpline::SplineChoosed(qint64 id)
{
emit ChoosedTool(id, Scene::Spline);
}
void VToolCutSpline::ChangedActivDraw(const QString &newName)
{
if (nameActivDraw == newName)
{
currentColor = Qt::black;
firstSpline->setFlag(QGraphicsItem::ItemIsSelectable, true);
firstSpline->setAcceptHoverEvents(true);
secondSpline->setFlag(QGraphicsItem::ItemIsSelectable, true);
secondSpline->setAcceptHoverEvents(true);
}
else
{
currentColor = Qt::gray;
firstSpline->setFlag(QGraphicsItem::ItemIsSelectable, false);
firstSpline->setAcceptHoverEvents(false);
secondSpline->setFlag(QGraphicsItem::ItemIsSelectable, false);
secondSpline->setAcceptHoverEvents(false);
}
firstSpline->setPen(QPen(currentColor, widthHairLine/factor));
secondSpline->setPen(QPen(currentColor, widthHairLine/factor));
VToolPoint::ChangedActivDraw(newName);
}
void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogCutSpline, this, event);
}
void VToolCutSpline::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrType, ToolType);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrLength, formula);
AddAttribute(domElement, AttrSpline, splineId);
AddToCalculation(domElement);
}
void VToolCutSpline::RefreshGeometry()
{
RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint);
RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint);
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
}
void VToolCutSpline::RefreshSpline(VSimpleSpline *spline, qint64 splid, SimpleSpline::Translation tr)
{
VSpline spl = VAbstractTool::data.GetSpline(splid);
QPainterPath path;
path.addPath(spl.GetPath());
path.setFillRule( Qt::WindingFill );
if(tr == SimpleSpline::FirstPoint)
{
path.translate(-spl.GetPointP1().toQPointF().x(), -spl.GetPointP1().toQPointF().y());
}
else
{
path.translate(-spl.GetPointP4().toQPointF().x(), -spl.GetPointP4().toQPointF().y());
}
spline->setPath(path);
}

View File

@ -0,0 +1,149 @@
/************************************************************************
**
** @file vtoolcutspline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 VTOOLCUTSPLINE_H
#define VTOOLCUTSPLINE_H
#include "vtoolpoint.h"
#include "../../dialogs/dialogcutspline.h"
#include "../../widgets/vsimplespline.h"
/**
* @brief The VToolCutSpline class for tool CutSpline. This tool find point on spline and cut spline on two.
*/
class VToolCutSpline : public VToolPoint
{
Q_OBJECT
public:
/**
* @brief VToolCutSpline
* @param doc
* @param data
* @param id
* @param formula
* @param splineId
* @param typeCreation
* @param parent
*/
VToolCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula,
const qint64 &splineId, const qint64 &spl1id, const qint64 &spl2id,
const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param scene
* @param doc dom document container
* @param data
*/
static void Create(QSharedPointer<DialogCutSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
/**
* @brief Create
* @param _id
* @param pointName
* @param formula
* @param splineId
* @param mx
* @param my
* @param scene
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
*/
static void Create(const qint64 _id, const QString &pointName,
const QString &formula, const qint64 &splineId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
static const QString AttrSpline;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
/**
* @brief SplineChoosed
* @param id
*/
void SplineChoosed(qint64 id);
/**
* @brief ChangedActivDraw
* @param newName
*/
virtual void ChangedActivDraw(const QString &newName);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
void RefreshGeometry();
private:
/**
* @brief formula keep formula of length
*/
QString formula;
/**
* @brief splineId keep id of spline
*/
qint64 splineId;
/**
* @brief DialogCutSpline pointer to the tool's dialog
*/
QSharedPointer<DialogCutSpline> dialogCutSpline;
/**
* @brief firstSpline
*/
VSimpleSpline *firstSpline;
/**
* @brief secondSpline
*/
VSimpleSpline *secondSpline;
const qint64 spl1id;
const qint64 spl2id;
void RefreshSpline(VSimpleSpline *spline, qint64 splid, SimpleSpline::Translation tr);
};
#endif // VTOOLCUTSPLINE_H

View File

@ -0,0 +1,124 @@
/************************************************************************
**
** @file vtoolcutsplinepath.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 "vtoolcutsplinepath.h"
const QString VToolCutSplinePath::ToolType = QStringLiteral("cutSplinePath");
const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath");
VToolCutSplinePath::VToolCutSplinePath(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &formula, const qint64 &splinePathId,
const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), formula(formula), splinePathId(splinePathId),
dialogCutSplinePath(QSharedPointer<DialogCutSplinePath>()), firstSplinePath(), secondSplinePath()
{
Q_ASSERT_X(splinePathId > 0, Q_FUNC_INFO, "splinePathId <= 0");
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VToolCutSplinePath::setDialog()
{
Q_ASSERT(dialogCutSplinePath.isNull() == false);
VPointF point = VAbstractTool::data.GetPoint(id);
dialogCutSplinePath->setFormula(formula);
dialogCutSplinePath->setSplinePathId(splinePathId, id);
dialogCutSplinePath->setPointName(point.name());
}
void VToolCutSplinePath::Create(QSharedPointer<DialogCutSplinePath> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data)
{
QString pointName = dialog->getPointName();
QString formula = dialog->getFormula();
qint64 splinePathId = dialog->getSplinePathId();
Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Tool::FromGui);
}
void VToolCutSplinePath::Create(const qint64 _id, const QString &pointName, const QString &formula,
const qint64 &splinePathId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation)
{
}
void VToolCutSplinePath::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
formula = domElement.attribute(AttrLength, "");
splinePathId = domElement.attribute(AttrSplinePath, "").toLongLong();
}
RefreshGeometry();
}
void VToolCutSplinePath::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogCutSplinePath->getPointName());
domElement.setAttribute(AttrLength, dialogCutSplinePath->getFormula());
domElement.setAttribute(AttrSplinePath, QString().setNum(dialogCutSplinePath->getSplinePathId()));
emit FullUpdateTree();
}
}
dialogCutSplinePath.clear();
}
void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogCutSplinePath, this, event);
}
void VToolCutSplinePath::AddToFile()
{
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrLength, formula);
AddAttribute(domElement, AttrSplinePath, splinePathId);
AddToCalculation(domElement);
}
void VToolCutSplinePath::RefreshGeometry()
{
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
}

View File

@ -0,0 +1,122 @@
/************************************************************************
**
** @file vtoolcutsplinepath.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 VTOOLCUTSPLINEPATH_H
#define VTOOLCUTSPLINEPATH_H
#include "vtoolpoint.h"
#include "../../dialogs/dialogcutsplinepath.h"
#include "../../widgets/vsimplesplinepath.h"
class VToolCutSplinePath : public VToolPoint
{
Q_OBJECT
public:
VToolCutSplinePath(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula,
const qint64 &splinePathId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param scene
* @param doc dom document container
* @param data
*/
static void Create(QSharedPointer<DialogCutSplinePath> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param pointName
* @param formula
* @param splineId
* @param mx
* @param my
* @param scene
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
*/
static void Create(const qint64 _id, const QString &pointName, const QString &formula,
const qint64 &splinePathId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
static const QString AttrSplinePath;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
void RefreshGeometry();
private:
/**
* @brief formula keep formula of length
*/
QString formula;
/**
* @brief splineId keep id of spline
*/
qint64 splinePathId;
/**
* @brief DialogCutSpline pointer to the tool's dialog
*/
QSharedPointer<DialogCutSplinePath> dialogCutSplinePath;
/**
* @brief firstSplinePath
*/
VSimpleSplinePath *firstSplinePath;
/**
* @brief secondSplinePath
*/
VSimpleSplinePath *secondSplinePath;
};
#endif // VTOOLCUTSPLINEPATH_H

View File

@ -113,7 +113,7 @@ protected:
virtual void AddToFile();
private:
/**
* @brief dialogEndLine
* @brief dialogEndLine pointer to the dialog
*/
QSharedPointer<DialogEndLine> dialogEndLine;
};

View File

@ -43,5 +43,7 @@
#include "vmodelingheight.h"
#include "vmodelingtriangle.h"
#include "vmodelingpointofintersection.h"
#include "vmodelingcutspline.h"
#include "vmodelingcutsplinepath.h"
#endif // MODELINGTOOLS_H

View File

@ -0,0 +1,124 @@
/************************************************************************
**
** @file vmodelingcutspline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 "vmodelingcutspline.h"
const QString VModelingCutSpline::ToolType = QStringLiteral("cutSpline");
const QString VModelingCutSpline::AttrSpline = QStringLiteral("spline");
VModelingCutSpline::VModelingCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &formula, const qint64 &splineId,
const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingPoint(doc, data, id, parent), formula(formula), splineId(splineId),
dialogCutSpline(QSharedPointer<DialogCutSpline>())
{
Q_ASSERT_X(splineId > 0, Q_FUNC_INFO, "splineId <= 0");
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingCutSpline::setDialog()
{
Q_ASSERT(dialogCutSpline.isNull() == false);
VSpline spl = VAbstractTool::data.GetSplineModeling(id);
dialogCutSpline->setFormula(formula);
dialogCutSpline->setSplineId(splineId, id);
dialogCutSpline->setPointName(spl.name());
}
VModelingCutSpline *VModelingCutSpline::Create(QSharedPointer<DialogCutSpline> &dialog,
VDomDocument *doc, VContainer *data)
{
QString pointName = dialog->getPointName();
QString formula = dialog->getFormula();
qint64 splineId = dialog->getSplineId();
return Create(0, pointName, formula, splineId, 5, 10, doc, data, Document::FullParse, Tool::FromGui);
}
VModelingCutSpline *VModelingCutSpline::Create(const qint64 _id, const QString &pointName, const QString &formula,
const qint64 &splineId, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
}
void VModelingCutSpline::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
formula = domElement.attribute(AttrLength, "");
splineId = domElement.attribute(AttrSpline, "").toLongLong();
}
RefreshGeometry();
}
void VModelingCutSpline::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogCutSpline->getPointName());
domElement.setAttribute(AttrLength, dialogCutSpline->getFormula());
domElement.setAttribute(AttrSpline, QString().setNum(dialogCutSpline->getSplineId()));
emit FullUpdateTree();
}
}
dialogCutSpline.clear();
}
void VModelingCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogCutSpline, this, event);
}
void VModelingCutSpline::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrLength, formula);
AddAttribute(domElement, AttrSpline, splineId);
AddToModeling(domElement);
}
void VModelingCutSpline::RefreshGeometry()
{
VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPointModeling(id));
}

View File

@ -0,0 +1,112 @@
/************************************************************************
**
** @file vmodelingcutspline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 VMODELINGCUTSPLINE_H
#define VMODELINGCUTSPLINE_H
#include "vmodelingpoint.h"
#include "../../dialogs/dialogcutspline.h"
class VModelingCutSpline: public VModelingPoint
{
Q_OBJECT
public:
VModelingCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id,const QString &formula,
const qint64 &splineId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param scene
* @param doc dom document container
* @param data
*/
static VModelingCutSpline* Create(QSharedPointer<DialogCutSpline> &dialog, VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param pointName
* @param formula
* @param splineId
* @param mx
* @param my
* @param scene
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
*/
static VModelingCutSpline* Create(const qint64 _id, const QString &pointName, const QString &formula,
const qint64 &splineId, const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
static const QString AttrSpline;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
void RefreshGeometry();
private:
/**
* @brief formula keep formula of length
*/
QString formula;
/**
* @brief splineId keep id of spline
*/
qint64 splineId;
/**
* @brief DialogCutSpline pointer to the tool's dialog
*/
QSharedPointer<DialogCutSpline> dialogCutSpline;
};
#endif // VMODELINGCUTSPLINE_H

View File

@ -0,0 +1,126 @@
/************************************************************************
**
** @file vmodelingcutsplinepath.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 "vmodelingcutsplinepath.h"
const QString VModelingCutSplinePath::ToolType = QStringLiteral("cutSplinePath");
const QString VModelingCutSplinePath::AttrSplinePath = QStringLiteral("splinePath");
VModelingCutSplinePath::VModelingCutSplinePath(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &formula, const qint64 &splinePathId,
const Tool::Sources &typeCreation, QGraphicsItem *parent)
:VModelingPoint(doc, data, id, parent), formula(formula), splinePathId(splinePathId),
dialogCutSplinePath(QSharedPointer<DialogCutSplinePath>())
{
Q_ASSERT_X(splinePathId > 0, Q_FUNC_INFO, "splinePathId <= 0");
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
}
void VModelingCutSplinePath::setDialog()
{
Q_ASSERT(dialogCutSplinePath.isNull() == false);
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
dialogCutSplinePath->setFormula(formula);
dialogCutSplinePath->setSplinePathId(splinePathId, id);
dialogCutSplinePath->setPointName(splPath.name());
}
VModelingCutSplinePath *VModelingCutSplinePath::Create(QSharedPointer<DialogCutSplinePath> &dialog,
VDomDocument *doc, VContainer *data)
{
QString pointName = dialog->getPointName();
QString formula = dialog->getFormula();
qint64 splinePathId = dialog->getSplinePathId();
return Create(0, pointName, formula, splinePathId, 5, 10, doc, data, Document::FullParse, Tool::FromGui);
}
VModelingCutSplinePath *VModelingCutSplinePath::Create(const qint64 _id, const QString &pointName,
const QString &formula, const qint64 &splinePathId,
const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data,
const Document::Documents &parse,
const Tool::Sources &typeCreation)
{
}
void VModelingCutSplinePath::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
formula = domElement.attribute(AttrLength, "");
splinePathId = domElement.attribute(AttrSplinePath, "").toLongLong();
}
RefreshGeometry();
}
void VModelingCutSplinePath::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogCutSplinePath->getPointName());
domElement.setAttribute(AttrLength, dialogCutSplinePath->getFormula());
domElement.setAttribute(AttrSplinePath, QString().setNum(dialogCutSplinePath->getSplinePathId()));
emit FullUpdateTree();
}
}
dialogCutSplinePath.clear();
}
void VModelingCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogCutSplinePath, this, event);
}
void VModelingCutSplinePath::AddToFile()
{
VPointF point = VAbstractTool::data.GetPointModeling(id);
QDomElement domElement = doc->createElement(TagName);
AddAttribute(domElement, AttrId, id);
AddAttribute(domElement, AttrName, point.name());
AddAttribute(domElement, AttrMx, toMM(point.mx()));
AddAttribute(domElement, AttrMy, toMM(point.my()));
AddAttribute(domElement, AttrLength, formula);
AddAttribute(domElement, AttrSplinePath, splinePathId);
AddToModeling(domElement);
}
void VModelingCutSplinePath::RefreshGeometry()
{
VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPointModeling(id));
}

View File

@ -0,0 +1,113 @@
/************************************************************************
**
** @file vmodelingcutsplinepath.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 15 12, 2013
**
** @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) 2013 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 VMODELINGCUTSPLINEPATH_H
#define VMODELINGCUTSPLINEPATH_H
#include "vmodelingpoint.h"
#include "../../dialogs/dialogcutsplinepath.h"
class VModelingCutSplinePath : public VModelingPoint
{
Q_OBJECT
public:
VModelingCutSplinePath(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula,
const qint64 &splinePathId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
/**
* @brief Create
* @param dialog
* @param scene
* @param doc dom document container
* @param data
*/
static VModelingCutSplinePath* Create(QSharedPointer<DialogCutSplinePath> &dialog,
VDomDocument *doc, VContainer *data);
/**
* @brief Create
* @param _id
* @param pointName
* @param formula
* @param splineId
* @param mx
* @param my
* @param scene
* @param doc dom document container
* @param data
* @param parse
* @param typeCreation
*/
static VModelingCutSplinePath* Create(const qint64 _id, const QString &pointName, const QString &formula,
const qint64 &splinePathId, const qreal &mx, const qreal &my,
VDomDocument *doc, VContainer *data,
const Document::Documents &parse, const Tool::Sources &typeCreation);
/**
* @brief ToolType
*/
static const QString ToolType;
static const QString AttrSplinePath;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
protected:
/**
* @brief contextMenuEvent
* @param event
*/
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
/**
* @brief AddToFile
*/
virtual void AddToFile();
void RefreshGeometry();
private:
/**
* @brief formula keep formula of length
*/
QString formula;
/**
* @brief splineId keep id of spline
*/
qint64 splinePathId;
/**
* @brief DialogCutSpline pointer to the tool's dialog
*/
QSharedPointer<DialogCutSplinePath> dialogCutSplinePath;
};
#endif // VMODELINGCUTSPLINEPATH_H

View File

@ -45,7 +45,11 @@ HEADERS += \
src/tools/nodeDetails/vnodepoint.h \
src/tools/nodeDetails/vnodearc.h \
src/tools/nodeDetails/vabstractnode.h \
src/tools/nodeDetails/nodedetails.h
src/tools/nodeDetails/nodedetails.h \
src/tools/drawTools/vtoolcutspline.h \
src/tools/modelingTools/vmodelingcutspline.h \
src/tools/drawTools/vtoolcutsplinepath.h \
src/tools/modelingTools/vmodelingcutsplinepath.h
SOURCES += \
src/tools/vtooldetail.cpp \
@ -90,4 +94,8 @@ SOURCES += \
src/tools/nodeDetails/vnodespline.cpp \
src/tools/nodeDetails/vnodepoint.cpp \
src/tools/nodeDetails/vnodearc.cpp \
src/tools/nodeDetails/vabstractnode.cpp
src/tools/nodeDetails/vabstractnode.cpp \
src/tools/drawTools/vtoolcutspline.cpp \
src/tools/modelingTools/vmodelingcutspline.cpp \
src/tools/drawTools/vtoolcutsplinepath.cpp \
src/tools/modelingTools/vmodelingcutsplinepath.cpp

View File

@ -0,0 +1,59 @@
/************************************************************************
**
** @file vsimplespline.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 17 12, 2013
**
** @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) 2013 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 "vsimplespline.h"
#include "../options.h"
VSimpleSpline::VSimpleSpline(qint64 id, qreal *factor, Qt::GlobalColor *currentColor, QObject *parent)
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor)
{
setPen(QPen(Qt::black, widthHairLine/ *factor));
setFlag(QGraphicsItem::ItemIsSelectable, true);
setAcceptHoverEvents(true);
}
void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
emit Choosed(id);
}
QGraphicsItem::mouseReleaseEvent(event);
}
void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(*currentColor, widthMainLine/ *factor));
}
void VSimpleSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(*currentColor, widthHairLine/ *factor));
}

View File

@ -0,0 +1,96 @@
/************************************************************************
**
** @file vsimplespline.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 17 12, 2013
**
** @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) 2013 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 VSIMPLESPLINE_H
#define VSIMPLESPLINE_H
#include <QGraphicsPathItem>
namespace SimpleSpline
{
/**
* @brief The Translation enum
*/
enum Translation { FirstPoint, ForthPoint };
Q_DECLARE_FLAGS(Translations, Translation)
}
Q_DECLARE_OPERATORS_FOR_FLAGS( SimpleSpline::Translations )
/**
* @brief The VSimpleSpline class
*/
class VSimpleSpline : public QObject, public QGraphicsPathItem
{
Q_OBJECT
public:
/**
* @brief VSimpleSpline
* @param id
* @param factor
* @param currentColor
* @param parent
*/
VSimpleSpline(qint64 id, qreal *factor, Qt::GlobalColor *currentColor, QObject *parent = 0);
signals:
/**
* @brief Choosed
* @param id
*/
void Choosed(qint64 id);
protected:
/**
* @brief mouseReleaseEvent
* @param event
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent
* @param event
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent
* @param event
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
/**
* @brief id
*/
qint64 id;
/**
* @brief factor
*/
qreal *factor;
/**
* @brief currentColor
*/
Qt::GlobalColor *currentColor;
};
#endif // VSIMPLESPLINE_H

View File

@ -0,0 +1,55 @@
/************************************************************************
**
** @file vsimplesplinepath.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 17 12, 2013
**
** @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) 2013 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 "vsimplesplinepath.h"
VSimpleSplinePath::VSimpleSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qreal *factor, QObject *parent)
:VAbstractTool(doc, data, id, parent), factor(factor)
{
}
void VSimpleSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
emit ChoosedTool(id, Scene::SplinePath);
}
QGraphicsItem::mouseReleaseEvent(event);
}
void VSimpleSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine/ *factor));
}
void VSimpleSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine/ *factor));
}

View File

@ -0,0 +1,60 @@
/************************************************************************
**
** @file vsimplesplinepath.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 17 12, 2013
**
** @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) 2013 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 VSIMPLESPLINEPATH_H
#define VSIMPLESPLINEPATH_H
#include <QGraphicsPathItem>
#include "../tools/vabstracttool.h"
class VSimpleSplinePath : public VAbstractTool, public QGraphicsPathItem
{
Q_OBJECT
public:
VSimpleSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qreal *factor, QObject *parent = 0);
protected:
/**
* @brief mouseReleaseEvent
* @param event
*/
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
/**
* @brief hoverMoveEvent
* @param event
*/
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
/**
* @brief hoverLeaveEvent
* @param event
*/
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
qreal *factor;
};
#endif // VSIMPLESPLINEPATH_H

View File

@ -6,7 +6,9 @@ HEADERS += \
src/widgets/vgraphicssimpletextitem.h \
src/widgets/vcontrolpointspline.h \
src/widgets/vapplication.h \
src/widgets/doubledelegate.h
src/widgets/doubledelegate.h \
src/widgets/vsimplespline.h \
src/widgets/vsimplesplinepath.h
SOURCES += \
src/widgets/vtablegraphicsview.cpp \
@ -16,4 +18,6 @@ SOURCES += \
src/widgets/vgraphicssimpletextitem.cpp \
src/widgets/vcontrolpointspline.cpp \
src/widgets/vapplication.cpp \
src/widgets/doubledelegate.cpp
src/widgets/doubledelegate.cpp \
src/widgets/vsimplespline.cpp \
src/widgets/vsimplesplinepath.cpp

View File

@ -31,15 +31,12 @@
#include "../exception/vexceptionconversionerror.h"
#include "../exception/vexceptionemptyparameter.h"
#include "../exception/vexceptionuniqueid.h"
#include "../tools/vtooldetail.h"
#include "../exception/vexceptionobjecterror.h"
#include "../exception/vexceptionbadid.h"
#include "../tools/vtooldetail.h"
#include "../tools/drawTools/drawtools.h"
#include "../tools/modelingTools/modelingtools.h"
#include "../tools/nodeDetails/vnodepoint.h"
#include "../tools/nodeDetails/vnodespline.h"
#include "../tools/nodeDetails/vnodesplinepath.h"
#include "../tools/nodeDetails/vnodearc.h"
#include "../tools/nodeDetails/nodedetails.h"
#include <QMessageBox>
@ -1104,6 +1101,64 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
throw excep;
}
}
if (type == "cutSpline")
{
try
{
qint64 id = GetParametrId(domElement);
QString name = GetParametrString(domElement, "name");
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
qreal my = toPixel(GetParametrDouble(domElement, "my"));
QString formula = GetParametrString(domElement, "length");
qint64 splineId = GetParametrLongLong(domElement, "spline");
if (mode == Draw::Calculation)
{
VToolCutSpline::Create(id, name, formula, splineId, mx, my, scene, this, data, parse,
Tool::FromFile);
}
else
{
VModelingCutSpline::Create(id, name, formula, splineId, mx, my, this, data, parse,
Tool::FromFile);
}
return;
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
if (type == "cutSplinePath")
{
try
{
qint64 id = GetParametrId(domElement);
QString name = GetParametrString(domElement, "name");
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
qreal my = toPixel(GetParametrDouble(domElement, "my"));
QString formula = GetParametrString(domElement, "length");
qint64 splinePathId = GetParametrLongLong(domElement, "splinePath");
if (mode == Draw::Calculation)
{
VToolCutSplinePath::Create(id, name, formula, splinePathId, mx, my, scene, this, data, parse,
Tool::FromFile);
}
else
{
VModelingCutSplinePath::Create(id, name, formula, splinePathId, mx, my, this, data, parse,
Tool::FromFile);
}
return;
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
}
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,