Resolved issue #245 New tool "Arc with given length".

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-06-09 21:23:37 +03:00
parent 7143d9fe16
commit 4635593b5a
31 changed files with 2109 additions and 28 deletions

View File

@ -276,6 +276,13 @@ QString DialogHistory::Record(const VToolRecord &tool)
SCASSERT(arc != nullptr); SCASSERT(arc != nullptr);
return QString(tr("Arc with center in point %1")).arg(PointName(arc->GetCenter().id())); return QString(tr("Arc with center in point %1")).arg(PointName(arc->GetCenter().id()));
} }
case Tool::ArcWithLength:
{
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(tool.getId());
SCASSERT(arc != nullptr);
return QString(tr("Arc with center in point %1 and length %2")).arg(PointName(arc->GetCenter().id()))
.arg(arc->GetLength());
}
case Tool::SplinePath: case Tool::SplinePath:
{ {
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(tool.getId()); const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(tool.getId());

View File

@ -31,6 +31,7 @@
#include "tools/dialogalongline.h" #include "tools/dialogalongline.h"
#include "tools/dialogarc.h" #include "tools/dialogarc.h"
#include "tools/dialogarcwithlength.h"
#include "tools/dialogbisector.h" #include "tools/dialogbisector.h"
#include "tools/dialogdetail.h" #include "tools/dialogdetail.h"
#include "tools/dialogendline.h" #include "tools/dialogendline.h"

View File

@ -48,7 +48,8 @@ HEADERS += \
$$PWD/tools/dialogpointofintersectionarcs.h \ $$PWD/tools/dialogpointofintersectionarcs.h \
$$PWD/tools/dialogpointofintersectioncircles.h \ $$PWD/tools/dialogpointofintersectioncircles.h \
$$PWD/tools/dialogpointfromcircleandtangent.h \ $$PWD/tools/dialogpointfromcircleandtangent.h \
dialogs/tools/dialogpointfromarcandtangent.h $$PWD/tools/dialogpointfromarcandtangent.h \
$$PWD/tools/dialogarcwithlength.h
SOURCES += \ SOURCES += \
$$PWD/tools/dialogtriangle.cpp \ $$PWD/tools/dialogtriangle.cpp \
@ -95,7 +96,8 @@ SOURCES += \
$$PWD/tools/dialogpointofintersectionarcs.cpp \ $$PWD/tools/dialogpointofintersectionarcs.cpp \
$$PWD/tools/dialogpointofintersectioncircles.cpp \ $$PWD/tools/dialogpointofintersectioncircles.cpp \
$$PWD/tools/dialogpointfromcircleandtangent.cpp \ $$PWD/tools/dialogpointfromcircleandtangent.cpp \
dialogs/tools/dialogpointfromarcandtangent.cpp $$PWD/tools/dialogpointfromarcandtangent.cpp \
$$PWD/tools/dialogarcwithlength.cpp
FORMS += \ FORMS += \
$$PWD/tools/dialogtriangle.ui \ $$PWD/tools/dialogtriangle.ui \
@ -136,4 +138,5 @@ FORMS += \
$$PWD/tools/dialogpointofintersectionarcs.ui \ $$PWD/tools/dialogpointofintersectionarcs.ui \
$$PWD/tools/dialogpointofintersectioncircles.ui \ $$PWD/tools/dialogpointofintersectioncircles.ui \
$$PWD/tools/dialogpointfromcircleandtangent.ui \ $$PWD/tools/dialogpointfromcircleandtangent.ui \
dialogs/tools/dialogpointfromarcandtangent.ui $$PWD/tools/dialogpointfromarcandtangent.ui \
$$PWD/tools/dialogarcwithlength.ui

View File

@ -0,0 +1,381 @@
/************************************************************************
**
** @file dialogarcwithlength.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 9 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "dialogarcwithlength.h"
#include "ui_dialogarcwithlength.h"
#include <QPushButton>
#include <QTimer>
#include "../../libs/vgeometry/vpointf.h"
#include "../../container/vcontainer.h"
#include "../../libs/ifc/xml/vdomdocument.h"
#include "../../visualization/vistoolarcwithlength.h"
#include "dialogeditwrongformula.h"
//---------------------------------------------------------------------------------------------------------------------
DialogArcWithLength::DialogArcWithLength(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogArcWithLength), flagRadius(false), flagF1(false),
flagLength(false), timerRadius(nullptr), timerF1(nullptr), timerLength(nullptr), radius(QString()), f1(QString()),
length(QString()),formulaBaseHeightRadius(0), formulaBaseHeightF1(0), formulaBaseHeightLength(0), angleF1(INT_MIN)
{
ui->setupUi(this);
plainTextEditFormula = ui->plainTextEditRadius;
this->formulaBaseHeightLength = ui->plainTextEditRadius->height();
this->formulaBaseHeightF1 = ui->plainTextEditF1->height();
this->formulaBaseHeightLength = ui->plainTextEditLength->height();
ui->plainTextEditRadius->installEventFilter(this);
ui->plainTextEditF1->installEventFilter(this);
ui->plainTextEditLength->installEventFilter(this);
timerRadius = new QTimer(this);
connect(timerRadius, &QTimer::timeout, this, &DialogArcWithLength::Radius);
timerF1 = new QTimer(this);
connect(timerF1, &QTimer::timeout, this, &DialogArcWithLength::EvalF);
timerLength = new QTimer(this);
connect(timerLength, &QTimer::timeout, this, &DialogArcWithLength::Length);
InitOkCancelApply(ui);
FillComboBoxPoints(ui->comboBoxCenter);
FillComboBoxLineColors(ui->comboBoxColor);
CheckState();
connect(ui->toolButtonExprRadius, &QPushButton::clicked, this, &DialogArcWithLength::FXRadius);
connect(ui->toolButtonExprF1, &QPushButton::clicked, this, &DialogArcWithLength::FXF1);
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogArcWithLength::FXLength);
connect(ui->plainTextEditRadius, &QPlainTextEdit::textChanged, this, &DialogArcWithLength::RadiusChanged);
connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, &DialogArcWithLength::F1Changed);
connect(ui->plainTextEditLength, &QPlainTextEdit::textChanged, this, &DialogArcWithLength::LengthChanged);
connect(ui->pushButtonGrowLengthRadius, &QPushButton::clicked, this, &DialogArcWithLength::DeployRadiusTextEdit);
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArcWithLength::DeployF1TextEdit);
connect(ui->pushButtonGrowLengthArcLength, &QPushButton::clicked, this, &DialogArcWithLength::DeployLengthTextEdit);
vis = new VisToolArcWithLength(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogArcWithLength::~DialogArcWithLength()
{
DeleteVisualization<VisToolArcWithLength>();
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogArcWithLength::GetCenter() const
{
return getCurrentObjectId(ui->comboBoxCenter);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::SetCenter(const quint32 &value)
{
ChangeCurrentData(ui->comboBoxCenter, value);
vis->setPoint1Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogArcWithLength::GetRadius() const
{
return qApp->FormulaFromUser(radius);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::SetRadius(const QString &value)
{
radius = qApp->FormulaToUser(value);
// increase height if needed.
if (radius.length() > 80)
{
this->DeployRadiusTextEdit();
}
ui->plainTextEditRadius->setPlainText(radius);
VisToolArcWithLength *path = qobject_cast<VisToolArcWithLength *>(vis);
SCASSERT(path != nullptr);
path->setRadius(radius);
MoveCursorToEnd(ui->plainTextEditRadius);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogArcWithLength::GetF1() const
{
return qApp->FormulaFromUser(f1);
}
void DialogArcWithLength::SetF1(const QString &value)
{
f1 = qApp->FormulaToUser(value);
// increase height if needed.
if (f1.length() > 80)
{
this->DeployF1TextEdit();
}
ui->plainTextEditF1->setPlainText(f1);
VisToolArcWithLength *path = qobject_cast<VisToolArcWithLength *>(vis);
SCASSERT(path != nullptr);
path->setF1(f1);
MoveCursorToEnd(ui->plainTextEditF1);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogArcWithLength::GetLength() const
{
return qApp->FormulaFromUser(length);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::SetLength(const QString &value)
{
length = qApp->FormulaToUser(value);
// increase height if needed.
if (length.length() > 80)
{
this->DeployLengthTextEdit();
}
ui->plainTextEditLength->setPlainText(length);
VisToolArcWithLength *path = qobject_cast<VisToolArcWithLength *>(vis);
SCASSERT(path != nullptr);
path->setLength(radius);
MoveCursorToEnd(ui->plainTextEditLength);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogArcWithLength::GetColor() const
{
return GetComboBoxCurrentData(ui->comboBoxColor);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::SetColor(const QString &value)
{
ChangeCurrentData(ui->comboBoxColor, value);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false)// After first choose we ignore all objects
{
if (type == SceneObject::Point)
{
if (SetObject(id, ui->comboBoxCenter, ""))
{
vis->VisualMode(id);
prepare = true;
this->setModal(true);
this->show();
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::DeployRadiusTextEdit()
{
DeployFormula(ui->plainTextEditRadius, ui->pushButtonGrowLengthArcLength, formulaBaseHeightRadius);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::DeployF1TextEdit()
{
DeployFormula(ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::DeployLengthTextEdit()
{
DeployFormula(ui->plainTextEditLength, ui->pushButtonGrowLengthArcLength, formulaBaseHeightLength);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::RadiusChanged()
{
labelEditFormula = ui->labelEditRadius;
labelResultCalculation = ui->labelResultRadius;
ValFormulaChanged(flagRadius, ui->plainTextEditRadius, timerRadius);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::F1Changed()
{
labelEditFormula = ui->labelEditF1;
labelResultCalculation = ui->labelResultF1;
ValFormulaChanged(flagF1, ui->plainTextEditF1, timerF1);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::LengthChanged()
{
labelEditFormula = ui->labelEditLength;
labelResultCalculation = ui->labelResultLength;
ValFormulaChanged(flagLength, ui->plainTextEditLength, timerLength);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::FXRadius()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit radius"));
dialog->SetFormula(GetRadius());
if (dialog->exec() == QDialog::Accepted)
{
SetRadius(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::FXF1()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit the first angle"));
dialog->SetFormula(GetF1());
if (dialog->exec() == QDialog::Accepted)
{
SetF1(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::FXLength()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit the arc length"));
dialog->SetFormula(GetLength());
if (dialog->exec() == QDialog::Accepted)
{
SetLength(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::CheckState()
{
SCASSERT(bOk != nullptr);
bOk->setEnabled(flagRadius && flagF1 && flagLength);
// In case dialog hasn't apply button
if ( bApply != nullptr)
{
bApply->setEnabled(bOk->isEnabled());
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::ShowVisualization()
{
AddVisualization<VisToolArcWithLength>();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::SaveData()
{
radius = ui->plainTextEditRadius->toPlainText();
radius.replace("\n", " ");
f1 = ui->plainTextEditF1->toPlainText();
f1.replace("\n", " ");
length = ui->plainTextEditLength->toPlainText();
length.replace("\n", " ");
VisToolArcWithLength *path = qobject_cast<VisToolArcWithLength *>(vis);
SCASSERT(path != nullptr);
path->setPoint1Id(GetCenter());
path->setRadius(radius);
path->setF1(f1);
path->setLength(length);
path->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::closeEvent(QCloseEvent *event)
{
ui->plainTextEditRadius->blockSignals(true);
ui->plainTextEditF1->blockSignals(true);
ui->plainTextEditLength->blockSignals(true);
DialogTool::closeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::Radius()
{
labelEditFormula = ui->labelEditRadius;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
const qreal radius = Eval(ui->plainTextEditRadius->toPlainText(), flagRadius, ui->labelResultRadius, postfix);
if (radius < 0)
{
flagRadius = false;
ChangeColor(labelEditFormula, Qt::red);
ui->labelResultRadius->setText(tr("Error"));
ui->labelResultRadius->setToolTip(tr("Radius can't be negative"));
DialogArcWithLength::CheckState();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::Length()
{
labelEditFormula = ui->labelEditLength;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
const qreal length = Eval(ui->plainTextEditLength->toPlainText(), flagLength, ui->labelResultLength, postfix);
if (qFuzzyCompare(length+1, 0+1))
{
flagLength = false;
ChangeColor(labelEditFormula, Qt::red);
ui->labelResultLength->setText(tr("Error"));
ui->labelResultLength->setToolTip(tr("Length can't be equal 0"));
DialogArcWithLength::CheckState();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::EvalF()
{
labelEditFormula = ui->labelEditF1;
angleF1 = Eval(ui->plainTextEditF1->toPlainText(), flagF1, ui->labelResultF1, degreeSymbol, false);
}

View File

@ -0,0 +1,128 @@
/************************************************************************
**
** @file dialogarcwithlength.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 9 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef DIALOGARCWITHLENGTH_H
#define DIALOGARCWITHLENGTH_H
#include "dialogtool.h"
namespace Ui
{
class DialogArcWithLength;
}
class DialogArcWithLength : public DialogTool
{
Q_OBJECT
public:
DialogArcWithLength(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogArcWithLength();
quint32 GetCenter() const;
void SetCenter(const quint32 &value);
QString GetRadius() const;
void SetRadius(const QString &value);
QString GetF1() const;
void SetF1(const QString &value);
QString GetLength() const;
void SetLength(const QString &value);
QString GetColor() const;
void SetColor(const QString &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type);
/**
* @brief DeployFormulaTextEdit grow or shrink formula input
*/
void DeployRadiusTextEdit();
void DeployF1TextEdit();
void DeployLengthTextEdit();
void RadiusChanged();
void F1Changed();
void LengthChanged();
void FXRadius();
void FXF1();
void FXLength();
protected:
virtual void CheckState();
virtual void ShowVisualization();
/**
* @brief SaveData Put dialog data in local variables
*/
virtual void SaveData();
virtual void closeEvent(QCloseEvent *event);
private:
Q_DISABLE_COPY(DialogArcWithLength)
Ui::DialogArcWithLength *ui;
/** @brief flagRadius true if value of radius is correct */
bool flagRadius;
/** @brief flagF1 true if value of first angle is correct */
bool flagF1;
bool flagLength;
/** @brief timerRadius timer of check formula of radius */
QTimer *timerRadius;
/** @brief timerF1 timer of check formula of first angle */
QTimer *timerF1;
QTimer *timerLength;
/** @brief radius formula of radius */
QString radius;
/** @brief f1 formula of first angle */
QString f1;
QString length;
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeightRadius;
int formulaBaseHeightF1;
int formulaBaseHeightLength;
qreal angleF1;
void Radius();
void Length();
void EvalF();
};
#endif // DIALOGARCWITHLENGTH_H

View File

@ -0,0 +1,629 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogArcWithLength</class>
<widget class="QDialog" name="DialogArcWithLength">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>339</width>
<height>329</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="labelEditRadius">
<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>Radius</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButtonExprRadius">
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResultRadius">
<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 radius</string>
</property>
<property name="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QPlainTextEdit" name="plainTextEditRadius">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLengthRadius">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="labelEditF1">
<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>First angle</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButtonExprF1">
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResultF1">
<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 first angle</string>
</property>
<property name="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPlainTextEdit" name="plainTextEditF1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLengthF1">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="labelEditLength">
<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>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButtonExprLength">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResultLength">
<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>Arc length</string>
</property>
<property name="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QPlainTextEdit" name="plainTextEditLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowLengthArcLength">
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff/>
</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Center point</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxCenter">
<property name="toolTip">
<string>Select point of center of arc</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogArcWithLength</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>DialogArcWithLength</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

@ -137,7 +137,7 @@
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Value of first angle</string> <string>Radius</string>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">_</string> <string notr="true">_</string>

View File

@ -137,7 +137,7 @@
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Value of radius</string> <string>Radius of the first circle</string>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">_</string> <string notr="true">_</string>
@ -312,7 +312,7 @@
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Value of first angle</string> <string>Radius of the second circle</string>
</property> </property>
<property name="text"> <property name="text">
<string notr="true">_</string> <string notr="true">_</string>

View File

@ -735,6 +735,16 @@ void MainWindow::ToolPointFromArcAndTangent(bool checked)
&MainWindow::ApplyDialog<VToolPointFromArcAndTangent>); &MainWindow::ApplyDialog<VToolPointFromArcAndTangent>);
} }
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolArcWithLength(bool checked)
{
SetToolButtonWithApply<DialogArcWithLength>(checked, Tool::ArcWithLength,
"://cursor/arc_with_length_cursor.png",
tr("Select point of the center of the arc"),
&MainWindow::ClosedDialogWithApply<VToolArcWithLength>,
&MainWindow::ApplyDialog<VToolArcWithLength>);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief About show widows about. * @brief About show widows about.
@ -1037,6 +1047,7 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonPointFromCircleAndTangent, &QToolButton::clicked, this, connect(ui->toolButtonPointFromCircleAndTangent, &QToolButton::clicked, this,
&MainWindow::ToolPointFromCircleAndTangent); &MainWindow::ToolPointFromCircleAndTangent);
connect(ui->toolButtonPointFromArcAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromArcAndTangent); connect(ui->toolButtonPointFromArcAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromArcAndTangent);
connect(ui->toolButtonArcWithLength, &QToolButton::clicked, this, &MainWindow::ToolArcWithLength);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1113,6 +1124,9 @@ void MainWindow::CancelTool()
case Tool::Arc: case Tool::Arc:
ui->toolButtonArc->setChecked(false); ui->toolButtonArc->setChecked(false);
break; break;
case Tool::ArcWithLength:
ui->toolButtonArcWithLength->setChecked(false);
break;
case Tool::SplinePath: case Tool::SplinePath:
ui->toolButtonSplinePath->setChecked(false); ui->toolButtonSplinePath->setChecked(false);
break; break;
@ -1156,6 +1170,12 @@ void MainWindow::CancelTool()
case Tool::PointOfIntersectionCircles: case Tool::PointOfIntersectionCircles:
ui->toolButtonPointOfIntersectionCircles->setChecked(false); ui->toolButtonPointOfIntersectionCircles->setChecked(false);
break; break;
case Tool::PointFromCircleAndTangent:
ui->toolButtonPointFromCircleAndTangent->setChecked(false);
break;
case Tool::PointFromArcAndTangent:
ui->toolButtonPointFromArcAndTangent->setChecked(false);
break;
case Tool::NodePoint: case Tool::NodePoint:
case Tool::NodeArc: case Tool::NodeArc:
case Tool::NodeSpline: case Tool::NodeSpline:
@ -2185,6 +2205,7 @@ void MainWindow::SetEnableTool(bool enable)
ui->toolButtonPointOfIntersectionCircles->setEnabled(drawTools); ui->toolButtonPointOfIntersectionCircles->setEnabled(drawTools);
ui->toolButtonPointFromCircleAndTangent->setEnabled(drawTools); ui->toolButtonPointFromCircleAndTangent->setEnabled(drawTools);
ui->toolButtonPointFromArcAndTangent->setEnabled(drawTools); ui->toolButtonPointFromArcAndTangent->setEnabled(drawTools);
ui->toolButtonArcWithLength->setEnabled(drawTools);
ui->actionLast_tool->setEnabled(drawTools); ui->actionLast_tool->setEnabled(drawTools);
@ -2559,6 +2580,10 @@ void MainWindow::LastUsedTool()
ui->toolButtonPointFromArcAndTangent->setChecked(true); ui->toolButtonPointFromArcAndTangent->setChecked(true);
ToolPointFromArcAndTangent(true); ToolPointFromArcAndTangent(true);
break; break;
case Tool::ArcWithLength:
ui->toolButtonArcWithLength->setChecked(true);
ToolArcWithLength(true);
break;
case Tool::NodePoint: case Tool::NodePoint:
case Tool::NodeArc: case Tool::NodeArc:
case Tool::NodeSpline: case Tool::NodeSpline:

View File

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

View File

@ -48,14 +48,14 @@
<string/> <string/>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>130</width> <width>100</width>
<height>272</height> <height>272</height>
</rect> </rect>
</property> </property>
@ -346,7 +346,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>145</width> <width>100</width>
<height>58</height> <height>58</height>
</rect> </rect>
</property> </property>
@ -429,8 +429,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>145</width> <width>100</width>
<height>104</height> <height>156</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -590,8 +590,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>145</width> <width>130</width>
<height>150</height> <height>196</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -796,6 +796,32 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1">
<widget class="QToolButton" name="toolButtonArcWithLength">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Arc with given length</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/toolicon.qrc">
<normaloff>:/toolicon/32x32/arc_with_length.png</normaloff>:/toolicon/32x32/arc_with_length.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="page_5"> <widget class="QWidget" name="page_5">
@ -803,7 +829,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>145</width> <width>100</width>
<height>58</height> <height>58</height>
</rect> </rect>
</property> </property>
@ -886,8 +912,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>145</width> <width>98</width>
<height>386</height> <height>58</height>
</rect> </rect>
</property> </property>
<attribute name="icon"> <attribute name="icon">

View File

@ -75,6 +75,7 @@ enum class Tool : unsigned char
CutSpline, CutSpline,
CutArc, CutArc,
Arc, Arc,
ArcWithLength,
SplinePath, SplinePath,
CutSplinePath, CutSplinePath,
PointOfContact, PointOfContact,
@ -92,18 +93,19 @@ enum class Tool : unsigned char
PointOfIntersection, PointOfIntersection,
PointFromCircleAndTangent, PointFromCircleAndTangent,
PointFromArcAndTangent, PointFromArcAndTangent,
UnionDetails // 34 UnionDetails // 35
}; };
enum class Vis : unsigned char enum class Vis : unsigned char
{ {
ControlPointSpline = 35, // increase this value if need more positions in Tool enum ControlPointSpline = 36, // increase this value if need more positions in Tool enum
GraphicsSimpleTextItem, GraphicsSimpleTextItem,
SimpleSplinePath, SimpleSplinePath,
Line, Line,
Path, Path,
ToolAlongLine, ToolAlongLine,
ToolArc, ToolArc,
ToolArcWithLength,
ToolBisector, ToolBisector,
ToolCutArc, ToolCutArc,
ToolEndLine, ToolEndLine,

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -26,5 +26,6 @@
<file>toolicon/32x32/triangle.png</file> <file>toolicon/32x32/triangle.png</file>
<file>toolicon/32x32/union.png</file> <file>toolicon/32x32/union.png</file>
<file>toolicon/32x32/new_detail.png</file> <file>toolicon/32x32/new_detail.png</file>
<file>toolicon/32x32/arc_with_length.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,230 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="32"
height="32"
id="svg5205"
inkscape:version="0.48.4 r9939"
sodipodi:docname="arc_with_length.svg">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1619"
inkscape:window-height="981"
id="namedview10"
showgrid="false"
inkscape:zoom="11.189427"
inkscape:cx="7.9947615"
inkscape:cy="12.822271"
inkscape:window-x="75"
inkscape:window-y="34"
inkscape:window-maximized="0"
inkscape:current-layer="svg5205" />
<defs
id="defs5207">
<marker
inkscape:stockid="Tail"
orient="auto"
refY="0.0"
refX="0.0"
id="Tail"
style="overflow:visible">
<g
id="g3796"
transform="scale(-1.2)">
<path
id="path3798"
d="M -3.8048674,-3.9585227 L 0.54352094,0"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round" />
<path
id="path3800"
d="M -1.2866832,-3.9585227 L 3.0617053,0"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round" />
<path
id="path3802"
d="M 1.3053582,-3.9585227 L 5.6537466,0"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round" />
<path
id="path3804"
d="M -3.8048674,4.1775838 L 0.54352094,0.21974226"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round" />
<path
id="path3806"
d="M -1.2866832,4.1775838 L 3.0617053,0.21974226"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round" />
<path
id="path3808"
d="M 1.3053582,4.1775838 L 5.6537466,0.21974226"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.8;stroke-linecap:round" />
</g>
</marker>
<marker
inkscape:stockid="CurveIn"
orient="auto"
refY="0.0"
refX="0.0"
id="CurveIn"
style="overflow:visible">
<path
id="path3944"
d="M 4.6254930,-5.0456926 C 1.8654930,-5.0456926 -0.37450702,-2.8056926 -0.37450702,-0.045692580 C -0.37450702,2.7143074 1.8654930,4.9543074 4.6254930,4.9543074"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;fill:none"
transform="scale(0.6)" />
</marker>
<marker
inkscape:stockid="DiamondS"
orient="auto"
refY="0.0"
refX="0.0"
id="DiamondS"
style="overflow:visible">
<path
id="path3845"
d="M 0,-7.0710768 L -7.0710894,0 L 0,7.0710589 L 7.0710462,0 L 0,-7.0710768 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
transform="scale(0.2)" />
</marker>
<marker
inkscape:stockid="Arrow2Mend"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow2Mend"
style="overflow:visible;">
<path
id="path3787"
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="scale(0.6) rotate(180) translate(0,0)" />
</marker>
<marker
inkscape:stockid="Arrow2Mstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow2Mstart"
style="overflow:visible">
<path
id="path3784"
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="scale(0.6) translate(0,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Sstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Sstart"
style="overflow:visible">
<path
id="path3772"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
transform="scale(0.2) translate(6,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Mstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Mstart"
style="overflow:visible">
<path
id="path3766"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
transform="scale(0.4) translate(10,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Lend"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Lend"
style="overflow:visible;">
<path
id="path3763"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;"
transform="scale(0.8) rotate(180) translate(12.5,0)" />
</marker>
<marker
inkscape:stockid="Arrow1Lstart"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow1Lstart"
style="overflow:visible">
<path
id="path3760"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
transform="scale(0.8) translate(12.5,0)" />
</marker>
</defs>
<metadata
id="metadata5210">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<path
inkscape:connector-curvature="0"
style="fill:#f73208;fill-opacity:1;stroke:#f73208;stroke-width:1.56599998;stroke-linejoin:round;stroke-miterlimit:4.9000001;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
id="path2985-2-9-1-5-9"
d="m 18.240651,16.568519 a 1.6940329,1.7299054 0 0 1 -3.388065,0 1.6940329,1.7299054 0 1 1 3.388065,0 z" />
<path
sodipodi:type="arc"
style="fill:none;stroke:#00cb00;stroke-width:0.94700181;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-start:none;marker-mid:url(#Arrow1Sstart)"
id="path2991-4"
sodipodi:cx="11.864407"
sodipodi:cy="10.542373"
sodipodi:rx="10.033898"
sodipodi:ry="9.525424"
d="M 1.8381392,10.170947 A 10.033898,9.525424 0 1 1 13.901493,19.869425"
sodipodi:start="3.1805956"
sodipodi:end="7.64954"
transform="matrix(-0.03598447,-0.86544207,0.94694609,-0.03724699,6.6647436,27.068831)"
sodipodi:open="true" />
<path
inkscape:connector-curvature="0"
style="fill:none;stroke:#ff0034;stroke-width:0.84799999;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.696, 0.848;stroke-dashoffset:2.11999993;marker-start:none"
id="path3013-6"
d="M 31.396605,12.724316 16.570111,16.398724"
sodipodi:nodetypes="cc" />
<path
sodipodi:type="arc"
style="fill:none;stroke:#000000;stroke-width:0.94664948999999998;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker-start:none;marker-mid:none"
id="path2991"
sodipodi:cx="11.864407"
sodipodi:cy="10.542373"
sodipodi:rx="10.033898"
sodipodi:ry="9.525424"
d="M 1.8620691,9.7874595 A 10.033898,9.525424 0 1 1 13.901493,19.869425"
sodipodi:start="3.2209283"
sodipodi:end="7.64954"
transform="matrix(-0.05802193,-1.4391377,1.526871,-0.06193777,1.1416073,34.007693)"
sodipodi:open="true" />
</svg>

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -31,6 +31,7 @@
#include "vtoolalongline.h" #include "vtoolalongline.h"
#include "vtoolarc.h" #include "vtoolarc.h"
#include "vtoolarcwithlength.h"
#include "vtoolbisector.h" #include "vtoolbisector.h"
#include "vtoolendline.h" #include "vtoolendline.h"
#include "vtoolline.h" #include "vtoolline.h"

View File

@ -0,0 +1,319 @@
/************************************************************************
**
** @file vtoolarcwithlength.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 9 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vtoolarcwithlength.h"
#include "../../container/calculator.h"
#include "../../dialogs/tools/dialogarcwithlength.h"
#include "../../libs/vgeometry/varc.h"
#include "../container/vformula.h"
#include "../../visualization/vistoolarcwithlength.h"
#include <QKeyEvent>
const QString VToolArcWithLength::TagName = QStringLiteral("arc");
const QString VToolArcWithLength::ToolType = QStringLiteral("arcWithLength");
//---------------------------------------------------------------------------------------------------------------------
VToolArcWithLength::VToolArcWithLength(VPattern *doc, VContainer *data, quint32 id, const QString &color,
const Source &typeCreation, QGraphicsItem *parent)
:VAbstractSpline(doc, data, id, parent)
{
sceneType = SceneObject::Arc;
lineColor = color;
this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::setDialog()
{
SCASSERT(dialog != nullptr);
DialogArcWithLength *dialogTool = qobject_cast<DialogArcWithLength*>(dialog);
SCASSERT(dialogTool != nullptr);
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
dialogTool->SetCenter(arc->GetCenter().id());
dialogTool->SetF1(arc->GetFormulaF1());
dialogTool->SetLength(arc->GetFormulaLength());
dialogTool->SetRadius(arc->GetFormulaRadius());
dialogTool->SetColor(lineColor);
}
//---------------------------------------------------------------------------------------------------------------------
VToolArcWithLength *VToolArcWithLength::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogArcWithLength *dialogTool = qobject_cast<DialogArcWithLength*>(dialog);
SCASSERT(dialogTool != nullptr);
const quint32 center = dialogTool->GetCenter();
QString radius = dialogTool->GetRadius();
QString f1 = dialogTool->GetF1();
QString length = dialogTool->GetLength();
const QString color = dialogTool->GetColor();
VToolArcWithLength* point = nullptr;
point=Create(0, center, radius, f1, length, color, scene, doc, data, Document::FullParse, Source::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
}
return point;
}
//---------------------------------------------------------------------------------------------------------------------
VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1,
QString &length, const QString &color, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation)
{
qreal calcRadius = 0, calcF1 = 0, calcLength = 0;
calcRadius = qApp->toPixel(CheckFormula(_id, radius, data));
calcLength = qApp->toPixel(CheckFormula(_id, length, data));
calcF1 = CheckFormula(_id, f1, data);
VPointF c = *data->GeometricObject<VPointF>(center);
VArc *arc = new VArc(calcLength, length, c, calcRadius, radius, calcF1, f1);
quint32 id = _id;
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(arc);
data->AddArc(id);
}
else
{
data->UpdateGObject(id, arc);
data->AddArc(id);
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::ArcWithLength, doc);
if (parse == Document::FullParse)
{
VToolArcWithLength *toolArc = new VToolArcWithLength(doc, data, id, color, typeCreation);
scene->addItem(toolArc);
connect(toolArc, &VToolArcWithLength::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, toolArc, &VToolArcWithLength::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, toolArc, &VToolArcWithLength::Disable);
doc->AddTool(id, toolArc);
doc->IncrementReferens(center);
return toolArc;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolArcWithLength::getTagName() const
{
return VToolArcWithLength::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolArcWithLength::getCenter() const
{
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
SCASSERT(arc.isNull() == false);
return arc->GetCenter().id();
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::setCenter(const quint32 &value)
{
if (value != NULL_ID)
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(value);
arc->SetCenter(*point.data());
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolArcWithLength::GetFormulaRadius() const
{
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
SCASSERT(arc.isNull() == false);
VFormula radius(arc->GetFormulaRadius(), getData());
radius.setCheckZero(true);
radius.setToolId(id);
radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit()));
return radius;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::SetFormulaRadius(const VFormula &value)
{
if (value.error() == false)
{
if (value.getDoubleValue() > 0)// Formula don't check this, but radius can't be 0 or negative
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
arc->SetFormulaRadius(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
SaveOption(obj);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolArcWithLength::GetFormulaF1() const
{
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
SCASSERT(arc.isNull() == false);
VFormula f1(arc->GetFormulaF1(), getData());
f1.setCheckZero(false);
f1.setToolId(id);
f1.setPostfix(degreeSymbol);
return f1;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::SetFormulaF1(const VFormula &value)
{
if (value.error() == false)
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetEndAngle() + 1)==false)// Angles can't be equal
{
arc->SetFormulaF1(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
SaveOption(obj);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolArcWithLength::GetFormulaLength() const
{
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
SCASSERT(arc.isNull() == false);
VFormula radius(arc->GetFormulaLength(), getData());
radius.setCheckZero(true);
radius.setToolId(id);
radius.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit()));
return radius;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::SetFormulaLength(const VFormula &value)
{
if (value.error() == false)
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
arc->SetFormulaLength(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::ShowVisualization(bool show)
{
ShowToolVisualization<VisToolArcWithLength>(show);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
ContextMenu<DialogArcWithLength>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::RemoveReferens()
{
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
doc->DecrementReferens(arc->GetCenter().id());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::SaveDialog(QDomElement &domElement)
{
SCASSERT(dialog != nullptr);
DialogArcWithLength *dialogTool = qobject_cast<DialogArcWithLength*>(dialog);
SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetCenter()));
doc->SetAttribute(domElement, AttrRadius, dialogTool->GetRadius());
doc->SetAttribute(domElement, AttrAngle1, dialogTool->GetF1());
doc->SetAttribute(domElement, AttrLength, dialogTool->GetLength());
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
VAbstractSpline::SaveOptions(tag, obj);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
SCASSERT(arc.isNull() == false);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrCenter, arc->GetCenter().id());
doc->SetAttribute(tag, AttrRadius, arc->GetFormulaRadius());
doc->SetAttribute(tag, AttrAngle1, arc->GetFormulaF1());
doc->SetAttribute(tag, AttrLength, arc->GetFormulaLength());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::SetVisualization()
{
if (vis != nullptr)
{
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
VisToolArcWithLength *visual = qobject_cast<VisToolArcWithLength *>(vis);
SCASSERT(visual != nullptr)
visual->setPoint1Id(arc->GetCenter().id());
visual->setRadius(qApp->FormulaToUser(arc->GetFormulaRadius()));
visual->setF1(qApp->FormulaToUser(arc->GetFormulaF1()));
visual->setLength(qApp->FormulaToUser(arc->GetFormulaLength()));
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArcWithLength::RefreshGeometry()
{
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
this->setPath(ToolPath());
SetVisualization();
}

View File

@ -0,0 +1,78 @@
/************************************************************************
**
** @file vtoolarcwithlength.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 9 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VTOOLARCWITHLENGTH_H
#define VTOOLARCWITHLENGTH_H
#include "vabstractspline.h"
class VFormula;
class VToolArcWithLength : public VAbstractSpline
{
Q_OBJECT
public:
VToolArcWithLength(VPattern *doc, VContainer *data, quint32 id, const QString &color, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual void setDialog();
static VToolArcWithLength* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolArcWithLength* Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1,
QString &length, const QString &color, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString TagName;
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::ArcWithLength)};
virtual QString getTagName() const;
quint32 getCenter() const;
void setCenter(const quint32 &value);
VFormula GetFormulaRadius() const;
void SetFormulaRadius(const VFormula &value);
VFormula GetFormulaF1() const;
void SetFormulaF1(const VFormula &value);
VFormula GetFormulaLength() const;
void SetFormulaLength(const VFormula &value);
virtual void ShowVisualization(bool show);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void SetVisualization();
private:
void RefreshGeometry();
};
#endif // VTOOLARCWITHLENGTH_H

View File

@ -42,7 +42,8 @@ HEADERS += \
$$PWD/drawTools/vtoolpointofintersectionarcs.h \ $$PWD/drawTools/vtoolpointofintersectionarcs.h \
$$PWD/drawTools/vtoolpointofintersectioncircles.h \ $$PWD/drawTools/vtoolpointofintersectioncircles.h \
$$PWD/drawTools/vtoolpointfromcircleandtangent.h \ $$PWD/drawTools/vtoolpointfromcircleandtangent.h \
tools/drawTools/vtoolpointfromarcandtangent.h $$PWD/drawTools/vtoolpointfromarcandtangent.h \
$$PWD/drawTools/vtoolarcwithlength.h
SOURCES += \ SOURCES += \
$$PWD/vtooldetail.cpp \ $$PWD/vtooldetail.cpp \
@ -82,4 +83,5 @@ SOURCES += \
$$PWD/drawTools/vtoolpointofintersectionarcs.cpp \ $$PWD/drawTools/vtoolpointofintersectionarcs.cpp \
$$PWD/drawTools/vtoolpointofintersectioncircles.cpp \ $$PWD/drawTools/vtoolpointofintersectioncircles.cpp \
$$PWD/drawTools/vtoolpointfromcircleandtangent.cpp \ $$PWD/drawTools/vtoolpointfromcircleandtangent.cpp \
tools/drawTools/vtoolpointfromarcandtangent.cpp $$PWD/drawTools/vtoolpointfromarcandtangent.cpp \
$$PWD/drawTools/vtoolarcwithlength.cpp

View File

@ -29,7 +29,6 @@
#ifndef VISTOOLARC_H #ifndef VISTOOLARC_H
#define VISTOOLARC_H #define VISTOOLARC_H
#include "vispath.h" #include "vispath.h"
class VisToolArc : public VisPath class VisToolArc : public VisPath

View File

@ -0,0 +1,77 @@
/************************************************************************
**
** @file vistoolarcwithlength.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 9 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vistoolarcwithlength.h"
#include "../libs/vgeometry/vpointf.h"
#include "../libs/vgeometry/varc.h"
#include "../container/vcontainer.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolArcWithLength::VisToolArcWithLength(const VContainer *data, QGraphicsItem *parent)
:VisPath(data, parent), arcCenter(nullptr), radius(0), f1(0), length(0)
{
arcCenter = InitPoint(mainColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolArcWithLength::~VisToolArcWithLength()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArcWithLength::RefreshGeometry()
{
if (point1Id > NULL_ID)
{
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(point1Id);
DrawPoint(arcCenter, first->toQPointF(), supportColor);
if (qFuzzyCompare(1 + radius, 1 + 0) == false && f1 >= 0 && qFuzzyCompare(1 + length, 1 + 0) == false)
{
VArc arc = VArc (length, *first, radius, f1);
DrawPath(this, arc.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArcWithLength::setRadius(const QString &expression)
{
radius = FindLength(expression);
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArcWithLength::setF1(const QString &expression)
{
f1 = FindVal(expression);
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolArcWithLength::setLength(const QString &expression)
{
length = FindLength(expression);
}

View File

@ -0,0 +1,55 @@
/************************************************************************
**
** @file vistoolarcwithlength.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 9 6, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VISTOOLARCWITHLENGTH_H
#define VISTOOLARCWITHLENGTH_H
#include "vispath.h"
class VisToolArcWithLength : public VisPath
{
Q_OBJECT
public:
VisToolArcWithLength(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolArcWithLength();
virtual void RefreshGeometry();
void setRadius(const QString &expression);
void setF1(const QString &expression);
void setLength(const QString &expression);
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolArcWithLength)};
private:
Q_DISABLE_COPY(VisToolArcWithLength)
QGraphicsEllipseItem *arcCenter;
qreal radius;
qreal f1;
qreal length;
};
#endif // VISTOOLARCWITHLENGTH_H

View File

@ -30,7 +30,8 @@ HEADERS += \
$$PWD/vistoolpointofintersectionarcs.h \ $$PWD/vistoolpointofintersectionarcs.h \
$$PWD/vistoolpointofintersectioncircles.h \ $$PWD/vistoolpointofintersectioncircles.h \
$$PWD/vistoolpointfromcircleandtangent.h \ $$PWD/vistoolpointfromcircleandtangent.h \
visualization/vistoolpointfromarcandtangent.h $$PWD/vistoolpointfromarcandtangent.h \
$$PWD/vistoolarcwithlength.h
SOURCES += \ SOURCES += \
$$PWD/vgraphicssimpletextitem.cpp \ $$PWD/vgraphicssimpletextitem.cpp \
@ -61,4 +62,5 @@ SOURCES += \
$$PWD/vistoolpointofintersectionarcs.cpp \ $$PWD/vistoolpointofintersectionarcs.cpp \
$$PWD/vistoolpointofintersectioncircles.cpp \ $$PWD/vistoolpointofintersectioncircles.cpp \
$$PWD/vistoolpointfromcircleandtangent.cpp \ $$PWD/vistoolpointfromcircleandtangent.cpp \
visualization/vistoolpointfromarcandtangent.cpp $$PWD/vistoolpointfromarcandtangent.cpp \
$$PWD/vistoolarcwithlength.cpp

View File

@ -86,6 +86,9 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
case VToolArc::Type: case VToolArc::Type:
ShowOptionsToolArc(item); ShowOptionsToolArc(item);
break; break;
case VToolArcWithLength::Type:
ShowOptionsToolArcWithLength(item);
break;
case VToolBisector::Type: case VToolBisector::Type:
ShowOptionsToolBisector(item); ShowOptionsToolBisector(item);
break; break;
@ -185,6 +188,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
case VToolArc::Type: case VToolArc::Type:
UpdateOptionsToolArc(); UpdateOptionsToolArc();
break; break;
case VToolArcWithLength::Type:
UpdateOptionsToolArcWithLength();
break;
case VToolBisector::Type: case VToolBisector::Type:
UpdateOptionsToolBisector(); UpdateOptionsToolBisector();
break; break;
@ -299,6 +305,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
case VToolArc::Type: case VToolArc::Type:
ChangeDataToolArc(prop); ChangeDataToolArc(prop);
break; break;
case VToolArcWithLength::Type:
ChangeDataToolArcWithLength(prop);
break;
case VToolBisector::Type: case VToolBisector::Type:
ChangeDataToolBisector(prop); ChangeDataToolBisector(prop);
break; break;
@ -650,6 +659,36 @@ void VToolOptionsPropertyBrowser::ChangeDataToolArc(VProperty *property)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolArcWithLength(VProperty *property)
{
SCASSERT(property != nullptr)
QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
const QString id = propertyToId[property];
VToolArcWithLength *i = qgraphicsitem_cast<VToolArcWithLength *>(currentItem);
SCASSERT(i != nullptr);
switch (PropertiesList().indexOf(id))
{
case 8: // VAbstractTool::AttrRadius
i->SetFormulaRadius(value.value<VFormula>());
break;
case 9: // VAbstractTool::AttrAngle1
i->SetFormulaF1(value.value<VFormula>());
break;
case 4: // VAbstractTool::AttrLength
i->SetFormulaLength(value.value<VFormula>());
break;
case 27: // VAbstractTool::AttrTypeColor
i->SetLineColor(value.toString());
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolBisector(VProperty *property) void VToolOptionsPropertyBrowser::ChangeDataToolBisector(VProperty *property)
{ {
@ -1239,6 +1278,19 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolArc(QGraphicsItem *item)
AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), VAbstractTool::AttrColor); AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), VAbstractTool::AttrColor);
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolArcWithLength(QGraphicsItem *item)
{
VToolArcWithLength *i = qgraphicsitem_cast<VToolArcWithLength *>(item);
i->ShowVisualization(true);
formView->setTitle(tr("Arc with given length"));
AddPropertyFormula(tr("Radius"), i->GetFormulaRadius(), VAbstractTool::AttrRadius);
AddPropertyFormula(tr("First angle"), i->GetFormulaF1(), VAbstractTool::AttrAngle1);
AddPropertyFormula(tr("Length"), i->GetFormulaLength(), VAbstractTool::AttrLength);
AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), VAbstractTool::AttrColor);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item)
{ {
@ -1555,7 +1607,6 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArc()
{ {
VToolArc *i = qgraphicsitem_cast<VToolArc *>(currentItem); VToolArc *i = qgraphicsitem_cast<VToolArc *>(currentItem);
QVariant valueRadius; QVariant valueRadius;
valueRadius.setValue(i->GetFormulaRadius()); valueRadius.setValue(i->GetFormulaRadius());
idToProperty[VAbstractTool::AttrRadius]->setValue(valueRadius); idToProperty[VAbstractTool::AttrRadius]->setValue(valueRadius);
@ -1572,6 +1623,27 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArc()
idToProperty[VAbstractTool::AttrColor]->setValue(index); idToProperty[VAbstractTool::AttrColor]->setValue(index);
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolArcWithLength()
{
VToolArcWithLength *i = qgraphicsitem_cast<VToolArcWithLength *>(currentItem);
QVariant valueRadius;
valueRadius.setValue(i->GetFormulaRadius());
idToProperty[VAbstractTool::AttrRadius]->setValue(valueRadius);
QVariant valueFirstAngle;
valueFirstAngle.setValue(i->GetFormulaF1());
idToProperty[VAbstractTool::AttrAngle1]->setValue(valueFirstAngle);
QVariant valueLength;
valueLength.setValue(i->GetFormulaLength());
idToProperty[VAbstractTool::AttrLength]->setValue(valueLength);
const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor());
idToProperty[VAbstractTool::AttrColor]->setValue(index);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolBisector() void VToolOptionsPropertyBrowser::UpdateOptionsToolBisector()
{ {

View File

@ -92,6 +92,7 @@ private:
void ChangeDataToolEndLine(VPE::VProperty *property); void ChangeDataToolEndLine(VPE::VProperty *property);
void ChangeDataToolAlongLine(VPE::VProperty *property); void ChangeDataToolAlongLine(VPE::VProperty *property);
void ChangeDataToolArc(VPE::VProperty *property); void ChangeDataToolArc(VPE::VProperty *property);
void ChangeDataToolArcWithLength(VPE::VProperty *property);
void ChangeDataToolBisector(VPE::VProperty *property); void ChangeDataToolBisector(VPE::VProperty *property);
void ChangeDataToolCutArc(VPE::VProperty *property); void ChangeDataToolCutArc(VPE::VProperty *property);
void ChangeDataToolCutSpline(VPE::VProperty *property); void ChangeDataToolCutSpline(VPE::VProperty *property);
@ -117,6 +118,7 @@ private:
void ShowOptionsToolEndLine(QGraphicsItem *item); void ShowOptionsToolEndLine(QGraphicsItem *item);
void ShowOptionsToolAlongLine(QGraphicsItem *item); void ShowOptionsToolAlongLine(QGraphicsItem *item);
void ShowOptionsToolArc(QGraphicsItem *item); void ShowOptionsToolArc(QGraphicsItem *item);
void ShowOptionsToolArcWithLength(QGraphicsItem *item);
void ShowOptionsToolBisector(QGraphicsItem *item); void ShowOptionsToolBisector(QGraphicsItem *item);
void ShowOptionsToolCutArc(QGraphicsItem *item); void ShowOptionsToolCutArc(QGraphicsItem *item);
void ShowOptionsToolCutSpline(QGraphicsItem *item); void ShowOptionsToolCutSpline(QGraphicsItem *item);
@ -142,6 +144,7 @@ private:
void UpdateOptionsToolEndLine(); void UpdateOptionsToolEndLine();
void UpdateOptionsToolAlongLine(); void UpdateOptionsToolAlongLine();
void UpdateOptionsToolArc(); void UpdateOptionsToolArc();
void UpdateOptionsToolArcWithLength();
void UpdateOptionsToolBisector(); void UpdateOptionsToolBisector();
void UpdateOptionsToolCutArc(); void UpdateOptionsToolCutArc();
void UpdateOptionsToolCutSpline(); void UpdateOptionsToolCutSpline();

View File

@ -2091,7 +2091,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen
Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty");
quint32 id = 0; quint32 id = 0;
QStringList arcs = QStringList() << VToolArc::ToolType << VNodeArc::ToolType; QStringList arcs = QStringList() << VToolArc::ToolType << VNodeArc::ToolType << VToolArcWithLength::ToolType;
switch (arcs.indexOf(type)) switch (arcs.indexOf(type))
{ {
@ -2151,6 +2151,44 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen
throw excep; throw excep;
} }
break; break;
case 2: //VToolArcWithLength::ToolType
try
{
ToolsCommonAttributes(domElement, id);
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, NULL_ID_STR);
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10");
QString r = radius;//need for saving fixed formula;
const QString f1 = GetParametrString(domElement, VAbstractTool::AttrAngle1, "180");
QString f1Fix = f1;//need for saving fixed formula;
const QString length = GetParametrString(domElement, VAbstractTool::AttrLength, "10");
QString lengthFix = length;//need for saving fixed length;
const QString color = GetParametrString(domElement, VAbstractTool::AttrColor,
VAbstractTool::ColorBlack);
VToolArcWithLength::Create(id, center, r, f1Fix, lengthFix, color, scene, this, data, parse,
Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (r != radius || f1Fix != f1 || lengthFix != length)
{
SetAttribute(domElement, VAbstractTool::AttrRadius, r);
SetAttribute(domElement, VAbstractTool::AttrAngle1, f1Fix);
SetAttribute(domElement, VAbstractTool::AttrLength, lengthFix);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
catch (qmu::QmuParserError &e)
{
VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr()));
throw excep;
}
break;
default: default:
qDebug() << "Illegal arc type in VDomDocument::ParseArcElement()."; qDebug() << "Illegal arc type in VDomDocument::ParseArcElement().";
break; break;

View File

@ -153,6 +153,7 @@
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute> <xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute> <xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded"> <xs:element name="spline" minOccurs="0" maxOccurs="unbounded">

View File

@ -185,7 +185,7 @@ QPainterPath VAbstractCurve::ShowDirection(const QVector<QPointF> &points) const
{ {
/*Need find coordinate midle of curve. /*Need find coordinate midle of curve.
Universal way is take all points and find sum.*/ Universal way is take all points and find sum.*/
const qreal seek_length = GetLength()/2.0; const qreal seek_length = qAbs(GetLength())/2.0;
qreal found_length = 0; qreal found_length = 0;
QLineF arrow; QLineF arrow;
for (qint32 i = 1; i <= points.size()-1; ++i) for (qint32 i = 1; i <= points.size()-1; ++i)

View File

@ -216,8 +216,7 @@ QVector<QPointF> VArc::GetPoints() const
points.append(line.p2()); points.append(line.p2());
} }
} while (i <= angle); } while (i <= angle);
// Detail points clockwise, but arc we draw counterclockwise. Main contour need reverse. return points;
return GetReversePoints(points);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------