Cut arc tool.

--HG--
branch : feature
This commit is contained in:
dismine 2014-01-08 16:05:32 +02:00
parent e8d1c28a15
commit 55f44471cf
30 changed files with 1284 additions and 31 deletions

View File

@ -71,7 +71,7 @@ CONFIG(debug, debug|release){
-isystem "/usr/include/qt5/QtXml" -isystem "/usr/include/qt5/QtGui" \
-isystem "/usr/include/qt5/QtCore" -isystem "$${UI_DIR}" -isystem "$${MOC_DIR}" \
-isystem "$${RCC_DIR}" \
-Og -Wall -Wextra -pedantic -Weffc++ -Woverloaded-virtual -Wctor-dtor-privacy \
-O0 -Wall -Wextra -pedantic -Weffc++ -Woverloaded-virtual -Wctor-dtor-privacy \
-Wnon-virtual-dtor -Wold-style-cast -Wconversion -Winit-self \
-Wunreachable-code -Wcast-align -Wcast-qual -Wdisabled-optimization -Wfloat-equal \
-Wformat -Wformat=2 -Wformat-nonliteral -Wformat-security -Wformat-y2k \

View File

@ -18,5 +18,6 @@
<file>cursor/spline_cut_point_cursor.png</file>
<file>cursor/splinepath_cut_point_cursor.png</file>
<file>cursor/union_cursor.png</file>
<file>cursor/arc_cut_cursor.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -40,5 +40,6 @@
<file>icon/32x32/spline_cut_point.png</file>
<file>icon/32x32/splinePath_cut_point.png</file>
<file>icon/32x32/union.png</file>
<file>icon/32x32/arc_cut.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

View File

@ -609,13 +609,8 @@ void VContainer::AddLengthSpline(const QString &name, const qreal &value)
void VContainer::AddLengthArc(const qint64 &id)
{
const VArc * arc = GeometricObject<const VArc *>(id);
AddLengthArc(arc->name(), toMM(arc->GetLength()));
}
void VContainer::AddLengthArc(const QString &name, const qreal &value)
{
Q_ASSERT(name.isEmpty() == false);
lengthArcs[name] = value;
QString name = QString("%1_%2").arg(arc->name()).arg(id);
lengthArcs[name] = toMM(arc->GetLength());
}
void VContainer::AddLineAngle(const QString &name, const qreal &value)

View File

@ -185,12 +185,6 @@ public:
* @param id id of arc
*/
void AddLengthArc(const qint64 &id);
/**
* @brief AddLengthArc add length of arc
* @param name name of arc
* @param value length of arc
*/
void AddLengthArc(const QString &name, const qreal &value);
/**
* @brief AddLineAngle add angle of line to container
* @param name name of line angle

View File

@ -0,0 +1,114 @@
/************************************************************************
**
** @file dialogcutarc.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 7 1, 2014
**
** @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 "dialogcutarc.h"
#include "ui_dialogcutarc.h"
DialogCutArc::DialogCutArc(const VContainer *data, QWidget *parent) :
DialogTool(data, parent), ui(new Ui::DialogCutArc), pointName(QString()), formula(QString()), arcId(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, &DialogCutArc::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogCutArc::DialogRejected);
FillComboBoxArcs(ui->comboBoxArc);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutArc::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutArc::PutVal);
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogCutArc::ValChenged);
ShowVariable(data->DataBase());
connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogCutArc::SizeGrowth);
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogCutArc::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogCutArc::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogCutArc::LengthLines);
connect(ui->radioButtonLengthArc, &QRadioButton::clicked, this, &DialogCutArc::LengthArcs);
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogCutArc::LengthCurves);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutArc::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutArc::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogCutArc::FormulaChanged);
}
DialogCutArc::~DialogCutArc()
{
delete ui;
}
void DialogCutArc::ChoosedObject(qint64 id, const Scene::Scenes &type)
{
if (type == Scene::Arc)
{
const VArc *arc = data->GeometricObject<const VArc *>(id);
ChangeCurrentText(ui->comboBoxArc, arc->name());
emit ToolTip("");
this->show();
}
}
void DialogCutArc::DialogAccepted()
{
pointName = ui->lineEditNamePoint->text();
formula = ui->lineEditFormula->text();
arcId = getCurrentObjectId(ui->comboBoxArc);
emit DialogClosed(QDialog::Accepted);
}
void DialogCutArc::setArcId(const qint64 &value, const qint64 &id)
{
setCurrentArcId(ui->comboBoxArc, arcId, value, id, ComboMode::CutArc);
}
void DialogCutArc::setFormula(const QString &value)
{
formula = value;
ui->lineEditFormula->setText(formula);
}
void DialogCutArc::setPointName(const QString &value)
{
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}

View File

@ -0,0 +1,69 @@
/************************************************************************
**
** @file dialogcutarc.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 7 1, 2014
**
** @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 DIALOGCUTARC_H
#define DIALOGCUTARC_H
#include "dialogtool.h"
namespace Ui {
class DialogCutArc;
}
class DialogCutArc : public DialogTool
{
Q_OBJECT
public:
DialogCutArc(const VContainer *data, QWidget *parent = 0);
~DialogCutArc();
QString getPointName() const {return pointName;}
void setPointName(const QString &value);
QString getFormula() const {return formula;}
void setFormula(const QString &value);
qint64 getArcId() const {return arcId;}
void setArcId(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(DialogCutArc)
Ui::DialogCutArc *ui;
QString pointName;
QString formula;
qint64 arcId;
};
#endif // DIALOGCUTARC_H

360
src/dialogs/dialogcutarc.ui Normal file
View File

@ -0,0 +1,360 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogCutArc</class>
<widget class="QDialog" name="DialogCutArc">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>507</width>
<height>375</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 for the calculation of the spline</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>
<item>
<widget class="QToolButton" name="toolButtonEqual">
<property name="toolTip">
<string>Calculate value</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>Arc</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxArc">
<property name="toolTip">
<string>Selected curve</string>
</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>Point label</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 height</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandartTable">
<property name="text">
<string>Standard 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 insert into formula</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>DialogCutArc</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>DialogCutArc</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

@ -34,6 +34,7 @@
#include "../tools/vabstracttool.h"
#include "../tools/drawTools/vtoolcutspline.h"
#include "../tools/drawTools/vtoolcutsplinepath.h"
#include "../tools/drawTools/vtoolcutarc.h"
#include <QDebug>
#include <QPushButton>
@ -363,6 +364,20 @@ QString DialogHistory::Record(const VToolRecord &tool)
firstPointIdName, secondPointIdName);
break;
}
case Tool::CutArcTool:
{
qint64 arcId = 0;
domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement())
{
arcId = doc->GetParametrLongLong(domElement, VToolCutArc::AttrArc, "0");
}
const VArc *arc = data->GeometricObject<const VArc *>(arcId);
QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name();
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
record = QString(tr("%1 - cut arc with center %2")).arg(toolIdName, arcCenterName);
}
break;
case Tool::CutSplineTool:
{
qint64 splineId = 0;

View File

@ -21,7 +21,8 @@ HEADERS += \
src/dialogs/dialogalongline.h \
src/dialogs/dialogcutspline.h \
src/dialogs/dialogcutsplinepath.h \
src/dialogs/dialoguniondetails.h
src/dialogs/dialoguniondetails.h \
src/dialogs/dialogcutarc.h
SOURCES += \
src/dialogs/dialogtriangle.cpp \
@ -45,7 +46,8 @@ SOURCES += \
src/dialogs/dialogalongline.cpp \
src/dialogs/dialogcutspline.cpp \
src/dialogs/dialogcutsplinepath.cpp \
src/dialogs/dialoguniondetails.cpp
src/dialogs/dialoguniondetails.cpp \
src/dialogs/dialogcutarc.cpp
FORMS += \
src/dialogs/dialogtriangle.ui \
@ -68,4 +70,5 @@ FORMS += \
src/dialogs/dialogalongline.ui \
src/dialogs/dialogcutspline.ui \
src/dialogs/dialogcutsplinepath.ui \
src/dialogs/dialoguniondetails.ui
src/dialogs/dialoguniondetails.ui \
src/dialogs/dialogcutarc.ui

View File

@ -85,6 +85,43 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const
FillList(box, list);
}
void DialogTool::FillComboBoxArcs(QComboBox *box, const qint64 &id, ComboMode::ComboBoxCutArc cut) const
{
Q_ASSERT(box != 0);
const QHash<qint64, VGObject *> *objs = data->DataGObjects();
QHashIterator<qint64, VGObject*> i(*objs);
QMap<QString, qint64> list;
while (i.hasNext())
{
i.next();
if (cut == ComboMode::CutArc)
{
if (i.key() != id + 1 && i.key() != id + 2)
{
VGObject *obj = i.value();
if (obj->getType() == GObject::Arc && obj->getMode() == Draw::Calculation)
{
const VArc *arc = data->GeometricObject<const VArc *>(i.key());
list[arc->name()] = i.key();
}
}
}
else
{
if (i.key() != id)
{
VGObject *obj = i.value();
if (obj->getType() == GObject::Arc && obj->getMode() == Draw::Calculation)
{
const VArc *arc = data->GeometricObject<const VArc *>(i.key());
list[arc->name()] = i.key();
}
}
}
}
FillList(box, list);
}
void DialogTool::FillComboBoxSplines(QComboBox *box, const qint64 &id, ComboMode::ComboBoxCutSpline cut) const
{
Q_ASSERT(box != 0);
@ -301,6 +338,15 @@ void DialogTool::setCurrentSplineId(QComboBox *box, qint64 &splineId, const qint
ChangeCurrentData(box, value);
}
void DialogTool::setCurrentArcId(QComboBox *box, qint64 &arcId, const qint64 &value, const qint64 &id,
ComboMode::ComboBoxCutArc cut) const
{
Q_ASSERT(box != 0);
FillComboBoxArcs(box, id, cut);
arcId = value;
ChangeCurrentData(box, value);
}
void DialogTool::setCurrentSplinePathId(QComboBox *box, qint64 &splinePathId, const qint64 &value,
const qint64 &id, ComboMode::ComboBoxCutSpline cut) const
{

View File

@ -44,8 +44,12 @@ namespace ComboMode
*/
enum ComboBoxCutSpline { CutSpline, NoCutSpline };
Q_DECLARE_FLAGS(ComboBoxCutSplines, ComboBoxCutSpline)
enum ComboBoxCutArc { CutArc, NoCutArc};
Q_DECLARE_FLAGS(ComboBoxCutArcs, ComboBoxCutArc)
}
Q_DECLARE_OPERATORS_FOR_FLAGS( ComboMode::ComboBoxCutSplines )
Q_DECLARE_OPERATORS_FOR_FLAGS( ComboMode::ComboBoxCutArcs )
/**
* @brief The DialogTool class parent for all dialog of tools.
@ -267,6 +271,8 @@ protected:
* @param id don't show this id in list
*/
void FillComboBoxPoints(QComboBox *box, const qint64 &id = 0)const;
void FillComboBoxArcs(QComboBox *box, const qint64 &id = 0,
ComboMode::ComboBoxCutArc cut = ComboMode::NoCutArc)const;
/**
* @brief FillComboBoxSplines fill comboBox list of splines
* @param box comboBox
@ -353,6 +359,8 @@ protected:
*/
void setCurrentSplineId(QComboBox *box, qint64 &splineId, const qint64 &value, const qint64 &id,
ComboMode::ComboBoxCutSpline cut = ComboMode::NoCutSpline) const;
void setCurrentArcId(QComboBox *box, qint64 &arcId, const qint64 &value, const qint64 &id,
ComboMode::ComboBoxCutArc cut = ComboMode::NoCutArc) const;
/**
* @brief setCurrentSplinePathId set current splinePath id in combobox
* @param box combobox

View File

@ -43,7 +43,6 @@ VArc::VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QStri
: VGObject(GObject::Arc, idObject, mode), f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2),
radius(radius), formulaRadius(formulaRadius), center(center)
{
//TODO Change name of arc in formula. Name now not unique.
_name = QString ("Arc_%1").arg(this->GetCenter().name());
}
@ -190,3 +189,35 @@ QVector<QPointF> VArc::SplOfArc(qint32 number) const
}
return QVector<QPointF>();
}
QPointF VArc::CutArc(const qreal &length, VArc &arc1, VArc &arc2) const
{
//Always need return two arcs, so we must correct wrong length.
qreal len = 0;
if (length < this->GetLength()*0.02)
{
len = this->GetLength()*0.02;
}
else if ( length > this->GetLength()*0.98)
{
len = this->GetLength()*0.98;
}
else
{
len = length;
qDebug()<<len;
}
qreal n = (len*180)/(M_PI*radius);
qDebug()<<n;
QLineF line(GetCenter().toQPointF(), GetP1());
line.setAngle(line.angle()+n);
QPointF point = line.p2();
arc1 = VArc (center, radius, formulaRadius, f1, formulaF1, line.angle(), QString().setNum(line.angle()),
idObject, mode);
arc2 = VArc (center, radius, formulaRadius, line.angle(), QString().setNum(line.angle()), f2, formulaF2,
idObject, mode);
return point;
}

View File

@ -145,6 +145,7 @@ public:
*/
QVector<QPointF> SplOfArc( qint32 number ) const;
virtual QString name() const{return _name;}
QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const;
private:
/**
* @brief f1 початковий кут в градусах

View File

@ -58,7 +58,7 @@ MainWindow::MainWindow(QWidget *parent)
dialogTriangle(QSharedPointer<DialogTriangle>()),
dialogPointOfIntersection(QSharedPointer<DialogPointOfIntersection>()),
dialogCutSpline(QSharedPointer<DialogCutSpline>()), dialogCutSplinePath (QSharedPointer<DialogCutSplinePath>()),
dialogUnionDetails(QSharedPointer<DialogUnionDetails>()),
dialogUnionDetails(QSharedPointer<DialogUnionDetails>()), dialogCutArc(QSharedPointer<DialogCutArc>()),
dialogHistory(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
mode(Draw::Calculation), currentDrawIndex(0)
{
@ -122,6 +122,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->toolButtonSplineCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSpline);
connect(ui->toolButtonSplinePathCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSplinePath);
connect(ui->toolButtonUnionDetails, &QToolButton::clicked, this, &MainWindow::ToolUnionDetails);
connect(ui->toolButtonArcCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutArc);
pattern = new VContainer();
@ -522,6 +523,17 @@ void MainWindow::ToolUnionDetails(bool checked)
disconnect(doc, &VDomDocument::FullUpdateFromFile, dialogUnionDetails.data(), &DialogUnionDetails::UpdateList);
}
void MainWindow::ToolCutArc(bool checked)
{
SetToolButton(checked, Tool::CutArcTool, ":/cursor/arc_cut_cursor.png",
tr("Select arc"), dialogCutArc, &MainWindow::ClosedDialogCutArc);
}
void MainWindow::ClosedDialogCutArc(int result)
{
ClosedDialog<VToolCutArc>(dialogCutArc, result);
}
void MainWindow::ClosedDialogUnionDetails(int result)
{
ClosedDialog<VToolUnionDetails>(dialogUnionDetails, result);
@ -824,6 +836,12 @@ void MainWindow::CanselTool()
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::CutArcTool:
dialogCutArc.clear();
ui->toolButtonArcCutPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
default:
qWarning()<<"Got wrong tool type. Ignored.";
break;
@ -877,9 +895,9 @@ void MainWindow::ActionDraw(bool checked)
verScrollBar = view->verticalScrollBar();
verScrollBar->setValue(currentScene->getVerScrollBar());
mode = Draw::Calculation;
comboBoxDraws->setCurrentIndex(currentDrawIndex);//restore current pattern peace
mode = Draw::Calculation;
SetEnableTool(true);
doc->setCurrentData();
ui->toolBox->setCurrentIndex(0);
@ -1139,6 +1157,7 @@ void MainWindow::SetEnableTool(bool enable)
ui->toolButtonPointOfIntersection->setEnabled(drawTools);
ui->toolButtonSplineCutPoint->setEnabled(drawTools);
ui->toolButtonSplinePathCutPoint->setEnabled(drawTools);
ui->toolButtonArcCutPoint->setEnabled(drawTools);
//Modeling Tools
ui->toolButtonUnionDetails->setEnabled(modelingTools);

View File

@ -234,6 +234,7 @@ public slots:
*/
void ToolPointOfIntersection(bool checked);
void ToolUnionDetails(bool checked);
void ToolCutArc(bool checked);
/**
* @brief ClosedDialogEndLine
* @param result
@ -320,6 +321,7 @@ public slots:
* @param result result of working of dialog
*/
void ClosedDialogCutSpline(int result);
void ClosedDialogCutArc(int result);
/**
* @brief About
*/
@ -486,6 +488,7 @@ private:
* @brief dialogUnionDetails
*/
QSharedPointer<DialogUnionDetails> dialogUnionDetails;
QSharedPointer<DialogCutArc> dialogCutArc;
/**
* @brief dialogHistory
*/

View File

@ -40,14 +40,14 @@
<string/>
</property>
<property name="currentIndex">
<number>4</number>
<number>3</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>144</width>
<width>150</width>
<height>150</height>
</rect>
</property>
@ -302,7 +302,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<width>150</width>
<height>58</height>
</rect>
</property>
@ -378,7 +378,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<width>150</width>
<height>104</height>
</rect>
</property>
@ -549,6 +549,29 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="toolButtonArcCutPoint">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../share/resources/icon.qrc">
<normaloff>:/icon/32x32/arc_cut.png</normaloff>:/icon/32x32/arc_cut.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_5">

View File

@ -66,6 +66,7 @@ namespace Tool
LineIntersectTool,
SplineTool,
CutSplineTool,
CutArcTool,
ArcTool,
SplinePathTool,
CutSplinePathTool,

View File

@ -46,5 +46,6 @@
#include "vtoolpointofintersection.h"
#include "vtoolcutspline.h"
#include "vtoolcutsplinepath.h"
#include "vtoolcutarc.h"
#endif // DRAWTOOLS_H

View File

@ -111,17 +111,16 @@ void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &rad
if (typeCreation == Tool::FromGui)
{
id = data->AddGObject(arc);
data->AddLengthArc(arc->name(), toMM(arc->GetLength()));
}
else
{
data->UpdateGObject(id, arc);
data->AddLengthArc(arc->name(), toMM(arc->GetLength()));
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLengthArc(id);
VDrawTool::AddRecord(id, Tool::ArcTool, doc);
if (parse == Document::FullParse)
{

View File

@ -0,0 +1,269 @@
/************************************************************************
**
** @file vtoolcutarc.cpp
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 7 1, 2014
**
** @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 "vtoolcutarc.h"
#include "../../container/calculator.h"
const QString VToolCutArc::ToolType = QStringLiteral("cutArc");
const QString VToolCutArc::AttrArc = QStringLiteral("arc");
VToolCutArc::VToolCutArc(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula,
const qint64 &arcId, const qint64 &arc1id, const qint64 &arc2id,
const Tool::Sources &typeCreation, QGraphicsItem * parent)
:VToolPoint(doc, data, id, parent), formula(formula), arcId(arcId),
dialogCutArc(QSharedPointer<DialogCutArc>()), firstArc(), secondArc(), arc1id(arc1id), arc2id(arc2id)
{
Q_ASSERT_X(arcId > 0, Q_FUNC_INFO, "arcId <= 0");
Q_ASSERT_X(arc1id > 0, Q_FUNC_INFO, "arc1id <= 0");
Q_ASSERT_X(arc2id > 0, Q_FUNC_INFO, "arc2id <= 0");
firstArc = new VSimpleArc(arc1id, &currentColor, &factor);
Q_ASSERT(firstArc != 0);
RefreshArc(firstArc, arc1id, SimpleArc::ForthPoint);
firstArc->setParentItem(this);
connect(firstArc, &VSimpleArc::Choosed, this, &VToolCutArc::ArcChoosed);
secondArc = new VSimpleArc(arc2id, &currentColor, &factor);
Q_ASSERT(secondArc != 0);
RefreshArc(secondArc, arc2id, SimpleArc::FirstPoint);
secondArc->setParentItem(this);
connect(secondArc, &VSimpleArc::Choosed, this, &VToolCutArc::ArcChoosed);
if (typeCreation == Tool::FromGui)
{
AddToFile();
}
else
{
RefreshDataInFile();
}
}
void VToolCutArc::setDialog()
{
Q_ASSERT(dialogCutArc.isNull() == false);
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
dialogCutArc->setFormula(formula);
dialogCutArc->setArcId(arcId, id);
dialogCutArc->setPointName(point->name());
}
void VToolCutArc::Create(QSharedPointer<DialogCutArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data)
{
QString pointName = dialog->getPointName();
QString formula = dialog->getFormula();
qint64 arcId = dialog->getArcId();
Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse, Tool::FromGui);
}
void VToolCutArc::Create(const qint64 _id, const QString &pointName, const QString &formula, const qint64 &arcId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation)
{
const VArc *arc = data->GeometricObject<const VArc *>(arcId);
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if (errorMsg.isEmpty())
{
VArc arc1;
VArc arc2;
QPointF point = arc->CutArc(toPixel(result), arc1, arc2);
qint64 id = _id;
qint64 arc1id = 0;
qint64 arc2id = 0;
if (typeCreation == Tool::FromGui)
{
VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my);
Q_ASSERT(p != 0);
id = data->AddGObject(p);
VArc * ar1 = new VArc(arc1);
Q_ASSERT(ar1 != 0);
arc1id = data->AddGObject(ar1);
VArc * ar2 = new VArc(arc2);
Q_ASSERT(ar2 != 0);
arc2id = data->AddGObject(ar2);
}
else
{
VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my);
Q_ASSERT(p != 0);
data->UpdateGObject(id, p);
arc1id = id + 1;
arc2id = id + 2;
VArc * ar1 = new VArc(arc1);
Q_ASSERT(ar1 != 0);
data->UpdateGObject(arc1id, ar1);
VArc * ar2 = new VArc(arc2);
Q_ASSERT(ar2 != 0);
data->UpdateGObject(arc2id, ar2);
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
data->AddLengthArc(arc1id);
data->AddLengthArc(arc2id);
VDrawTool::AddRecord(id, Tool::CutArcTool, doc);
if (parse == Document::FullParse)
{
VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, arc1id, arc2id, typeCreation);
scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
doc->AddTool(id, point);
doc->AddTool(arc1id, point);
doc->AddTool(arc2id, point);
doc->IncrementReferens(arcId);
}
}
}
void VToolCutArc::FullUpdateFromFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
formula = domElement.attribute(AttrLength, "");
arcId = domElement.attribute(AttrArc, "").toLongLong();
}
RefreshGeometry();
}
void VToolCutArc::FullUpdateFromGui(int result)
{
if (result == QDialog::Accepted)
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, dialogCutArc->getPointName());
domElement.setAttribute(AttrLength, dialogCutArc->getFormula());
domElement.setAttribute(AttrArc, QString().setNum(dialogCutArc->getArcId()));
emit FullUpdateTree();
}
}
dialogCutArc.clear();
}
void VToolCutArc::ArcChoosed(qint64 id)
{
emit ChoosedTool(id, Scene::Arc);
}
void VToolCutArc::ChangedActivDraw(const QString &newName)
{
if (nameActivDraw == newName)
{
currentColor = Qt::black;
firstArc->setFlag(QGraphicsItem::ItemIsSelectable, true);
firstArc->setAcceptHoverEvents(true);
secondArc->setFlag(QGraphicsItem::ItemIsSelectable, true);
secondArc->setAcceptHoverEvents(true);
}
else
{
currentColor = Qt::gray;
firstArc->setFlag(QGraphicsItem::ItemIsSelectable, false);
firstArc->setAcceptHoverEvents(false);
secondArc->setFlag(QGraphicsItem::ItemIsSelectable, false);
secondArc->setAcceptHoverEvents(false);
}
firstArc->setPen(QPen(currentColor, widthHairLine/factor));
secondArc->setPen(QPen(currentColor, widthHairLine/factor));
VToolPoint::ChangedActivDraw(newName);
}
void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu(dialogCutArc, this, event);
}
void VToolCutArc::AddToFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(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, AttrArc, arcId);
AddToCalculation(domElement);
}
void VToolCutArc::RefreshDataInFile()
{
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute(AttrName, point->name());
domElement.setAttribute(AttrMx, toMM(point->mx()));
domElement.setAttribute(AttrMy, toMM(point->my()));
domElement.setAttribute(AttrLength, formula);
domElement.setAttribute(AttrArc, arcId);
}
}
void VToolCutArc::RefreshGeometry()
{
RefreshArc(firstArc, arc1id, SimpleArc::ForthPoint);
RefreshArc(secondArc, arc2id, SimpleArc::FirstPoint);
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
}
void VToolCutArc::RefreshArc(VSimpleArc *sArc, qint64 arcid, SimpleArc::Translation tr)
{
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(arcid);
QPainterPath path;
path.addPath(arc->GetPath());
path.setFillRule( Qt::WindingFill );
if (tr == SimpleArc::FirstPoint)
{
path.translate(-arc->GetP1().x(), -arc->GetP1().y());
}
else
{
path.translate(-arc->GetP2().x(), -arc->GetP2().y());
}
sArc->setPath(path);
}

View File

@ -0,0 +1,122 @@
/************************************************************************
**
** @file vtoolcutarc.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 7 1, 2014
**
** @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 VTOOLCUTARC_H
#define VTOOLCUTARC_H
#include "vtoolpoint.h"
#include "../../dialogs/dialogcutarc.h"
#include "../../widgets/vsimplearc.h"
class VToolCutArc : public VToolPoint
{
Q_OBJECT
public:
VToolCutArc(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula,
const qint64 &arcId, const qint64 &arc1id, const qint64 &arc2id,
const Tool::Sources &typeCreation, QGraphicsItem * parent = 0);
/**
* @brief setDialog
*/
virtual void setDialog();
static void Create(QSharedPointer<DialogCutArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
static void Create(const qint64 _id, const QString &pointName, const QString &formula, const qint64 &arcId,
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 AttrArc;
public slots:
/**
* @brief FullUpdateFromFile
*/
virtual void FullUpdateFromFile();
/**
* @brief FullUpdateFromGui
* @param result
*/
virtual void FullUpdateFromGui(int result);
/**
* @brief ArcChoosed
* @param id
*/
void ArcChoosed(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();
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile();
/**
* @brief RefreshGeometry
*/
void RefreshGeometry();
private:
Q_DISABLE_COPY(VToolCutArc)
/**
* @brief formula keep formula of length
*/
QString formula;
/**
* @brief arcId keep id of arc
*/
qint64 arcId;
/**
* @brief DialogCutSpline pointer to the tool's dialog
*/
QSharedPointer<DialogCutArc> dialogCutArc;
/**
* @brief firstArc
*/
VSimpleArc *firstArc;
/**
* @brief secondArc
*/
VSimpleArc *secondArc;
const qint64 arc1id;
const qint64 arc2id;
void RefreshArc(VSimpleArc *sArc, qint64 arcid, SimpleArc::Translation tr);
};
#endif // VTOOLCUTARC_H

View File

@ -65,7 +65,7 @@ void VNodePoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 i
VAbstractTool::AddRecord(id, Tool::NodePoint, doc);
if (parse == Document::FullParse)
{
//TODO Need create garbage collector and remove all nodes, that we don't use.
//TODO Need create garbage collector and remove all nodes, what we don't use.
//Better check garbage before each saving file. Check only modeling tags.
VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, idTool, parent);
Q_ASSERT(point != 0);

View File

@ -30,7 +30,8 @@ HEADERS += \
src/tools/nodeDetails/nodedetails.h \
src/tools/drawTools/vtoolcutspline.h \
src/tools/drawTools/vtoolcutsplinepath.h \
src/tools/vtooluniondetails.h
src/tools/vtooluniondetails.h \
src/tools/drawTools/vtoolcutarc.h
SOURCES += \
src/tools/vtooldetail.cpp \
@ -61,4 +62,5 @@ SOURCES += \
src/tools/nodeDetails/vabstractnode.cpp \
src/tools/drawTools/vtoolcutspline.cpp \
src/tools/drawTools/vtoolcutsplinepath.cpp \
src/tools/vtooluniondetails.cpp
src/tools/vtooluniondetails.cpp \
src/tools/drawTools/vtoolcutarc.cpp

View File

@ -318,6 +318,10 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
Q_ASSERT(path != 0);
path->setMode(Draw::Modeling);
const VSplinePath *splinePath = data->GeometricObject<const VSplinePath *>(det.at(i).getId());
Q_ASSERT(splinePath != 0);
qDebug()<<splinePath->Count();
qDebug()<<det.at(i).getId();
qDebug()<<"Початок циклу.";
for (qint32 i = 1; i <= splinePath->Count(); ++i)
{
VSpline spline(splinePath->at(i-1).P(), splinePath->at(i).P(),
@ -330,6 +334,7 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
angle);
++idCount;
data->UpdateGObject(idDetail+idCount, p1);
qDebug()<<idDetail+idCount;
VPointF p2 = VPointF(spline.GetP2());
BiasRotatePoint(&p2, dx, dy, data->GeometricObject<const VPointF *>(pRotate)->toQPointF(),
@ -345,6 +350,7 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
angle);
++idCount;
data->UpdateGObject(idDetail+idCount, p4);
qDebug()<<idDetail+idCount;
VSpline spl = VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline.GetKcurve());
if (i==1)
@ -355,8 +361,10 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
path->append(VSplinePoint(*p4, splinePath->at(i).KAsm1(), spl.GetAngle1(),
splinePath->at(i).KAsm1()));
}
++idCount;
data->UpdateGObject(idDetail+idCount, path);
qDebug()<<idDetail+idCount;
++idCount;
}

View File

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

87
src/widgets/vsimplearc.h Normal file
View File

@ -0,0 +1,87 @@
/************************************************************************
**
** @file vsimplearc.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 7 1, 2014
**
** @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 VSIMPLEARC_H
#define VSIMPLEARC_H
#include <QGraphicsPathItem>
namespace SimpleArc
{
/**
* @brief The Translation enum
*/
enum Translation { FirstPoint, ForthPoint };
Q_DECLARE_FLAGS(Translations, Translation)
}
Q_DECLARE_OPERATORS_FOR_FLAGS( SimpleArc::Translations )
class VSimpleArc : public QObject, public QGraphicsPathItem
{
Q_OBJECT
public:
VSimpleArc(qint64 id, Qt::GlobalColor *currentColor, qreal *factor = 0, 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:
Q_DISABLE_COPY(VSimpleArc)
/**
* @brief id
*/
qint64 id;
/**
* @brief factor
*/
qreal *factor;
/**
* @brief currentColor
*/
Qt::GlobalColor *currentColor;
};
#endif // VSIMPLEARC_H

View File

@ -8,7 +8,8 @@ HEADERS += \
src/widgets/vapplication.h \
src/widgets/doubledelegate.h \
src/widgets/vsimplespline.h \
src/widgets/vsimplesplinepath.h
src/widgets/vsimplesplinepath.h \
src/widgets/vsimplearc.h
SOURCES += \
src/widgets/vtablegraphicsview.cpp \
@ -20,4 +21,5 @@ SOURCES += \
src/widgets/vapplication.cpp \
src/widgets/doubledelegate.cpp \
src/widgets/vsimplespline.cpp \
src/widgets/vsimplesplinepath.cpp
src/widgets/vsimplesplinepath.cpp \
src/widgets/vsimplearc.cpp