Merge with feature

--HG--
branch : develop
This commit is contained in:
dismine 2014-09-08 11:24:28 +03:00
commit cfeaf2ffa0
245 changed files with 12057 additions and 1750 deletions

View File

@ -26,17 +26,61 @@ uic/
rcc/
man/
#Ignore Coverity Scan Build Tool
# Ignore Coverity Scan Build Tool
cov-int/
# Ignore file used QtCreator for user profile.
*.pro.user
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Ignore file Qt translation.
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# Qt-es
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.moc
moc_*.cpp
qrc_*.cpp
ui_*.h
Makefile*
*-build-*
# Ignore Qt translation file .
*.qm
# QtCreator
*.autosave
# Ignore Mercurial .orig files
*.orig
# Ignore Makefile
Makefile
*.rej
# QtCtreator Qml
*.qmlproject.user
*.qmlproject.user.*

View File

@ -620,29 +620,36 @@ INSTALLS += \
for(_translation_name, TRANSLATIONS) {
_translation_name_qm = $$section(_translation_name,".", 0, 0).qm
system($$shell_path($$[QT_INSTALL_BINS]/lrelease) $$shell_path($$PWD/$$_translation_name) -qm $$shell_path($$PWD/$$_translation_name_qm))
system($$shell_path($$[QT_INSTALL_BINS]/lrelease) $$shell_path($${PWD}/$$_translation_name) -qm $$shell_path($${PWD}/$$_translation_name_qm))
}
}
for(DIR, INSTALL_TRANSLATIONS) {
#add these absolute paths to a variable which
#ends up as 'mkcommands = path1 path2 path3 ...'
tr_path += $$PWD/$$DIR
tr_path += $${PWD}/$$DIR
}
copyToDestdir($$tr_path, $$shell_path($$OUT_PWD/$$DESTDIR/translations))
copyToDestdir($$tr_path, $$shell_path($${OUT_PWD}/$$DESTDIR/translations))
for(DIR, INSTALL_STANDARD_MEASHUREMENTS) {
#add these absolute paths to a variable which
#ends up as 'mkcommands = path1 path2 path3 ...'
st_path += $$PWD/$$DIR
st_path += $${PWD}/$$DIR
}
copyToDestdir($$st_path, $$shell_path($$OUT_PWD/$$DESTDIR/tables/standard))
copyToDestdir($$st_path, $$shell_path($${OUT_PWD}/$$DESTDIR/tables/standard))
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser2
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser2
else:unix: LIBS += -L$$OUT_PWD/../libs/qmuparser/bin -lqmuparser
win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../libs/qmuparser/$${DESTDIR} -lqmuparser2
else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../libs/qmuparser/$${DESTDIR} -lqmuparser2
else:unix: LIBS += -L$${OUT_PWD}/../libs/qmuparser/$${DESTDIR} -lqmuparser
INCLUDEPATH += $$PWD/../libs/qmuparser
DEPENDPATH += $$PWD/../libs/qmuparser
INCLUDEPATH += $${PWD}/../libs/qmuparser
DEPENDPATH += $${PWD}/../libs/qmuparser
win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer
else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer
else:unix: LIBS += -L$${OUT_PWD}/../libs/vpropertyexplorer/$${DESTDIR} -lvpropertyexplorer
INCLUDEPATH += $${PWD}/../libs/vpropertyexplorer
DEPENDPATH += $${PWD}/../libs/vpropertyexplorer

View File

@ -55,14 +55,7 @@ Calculator::Calculator(const VContainer *data)
:QmuParser(), vVarVal(nullptr), data(data)
{
InitCharacterSets();
// Add unary operators
DefinePostfixOprt(cm_Oprt, CmUnit);
DefinePostfixOprt(mm_Oprt, MmUnit);
DefinePostfixOprt(in_Oprt, InchUnit);
SetArgSep(',');
SetDecSep('.');
setAllowSubexpressions(false);//Only one expression per time
}
//---------------------------------------------------------------------------------------------------------------------
@ -85,15 +78,12 @@ Calculator::Calculator(const QString &formula, bool fromUser)
:QmuParser(), vVarVal(nullptr), data(nullptr)
{
InitCharacterSets();
setAllowSubexpressions(false);//Only one expression per time
SetVarFactory(AddVariable, this);
// Add unary operators
if (fromUser)
{
DefinePostfixOprt(qApp->PostfixOperator(cm_Oprt), CmUnit);
DefinePostfixOprt(qApp->PostfixOperator(mm_Oprt), MmUnit);
DefinePostfixOprt(qApp->PostfixOperator(in_Oprt), InchUnit);
bool osSeparatorValue = qApp->getSettings()->value("configuration/osSeparator", 1).toBool();
if (osSeparatorValue)
@ -111,16 +101,13 @@ Calculator::Calculator(const QString &formula, bool fromUser)
}
else
{
DefinePostfixOprt(cm_Oprt, CmUnit);
DefinePostfixOprt(mm_Oprt, MmUnit);
DefinePostfixOprt(in_Oprt, InchUnit);
SetArgSep(',');
SetDecSep('.');
}
SetExpr(formula);
//Need run for making tokens. Don't catch exception here, because because we want know if formula has error.
//Need run for making tokens. Don't catch exception here, because we want know if formula has error.
Eval();
}
@ -152,15 +139,12 @@ qreal Calculator::EvalFormula(const QString &formula)
}
// Add variables
InitVariables(data, tokens);
result = Eval();
return result;
InitVariables(data, tokens, formula);
return Eval();
}
//---------------------------------------------------------------------------------------------------------------------
void Calculator::InitVariables(const VContainer *data, const QMap<int, QString> &tokens)
void Calculator::InitVariables(const VContainer *data, const QMap<int, QString> &tokens, const QString &formula)
{
if (qApp->patternType() == MeasurementsType::Standard)
{
@ -169,9 +153,11 @@ void Calculator::InitVariables(const VContainer *data, const QMap<int, QString>
const QHash<QString, QSharedPointer<VInternalVariable> > *vars = data->DataVariables();
bool found = false;
QMap<int, QString>::const_iterator i = tokens.constBegin();
while (i != tokens.constEnd())
{
found = false;
if (vars->contains(i.value()))
{
QSharedPointer<VInternalVariable> var = vars->value(i.value());
@ -182,6 +168,7 @@ void Calculator::InitVariables(const VContainer *data, const QMap<int, QString>
m->SetValue(data->size(), data->height());
}
DefineVar(i.value(), var->GetValue());
found = true;
}
if (qApp->patternType() == MeasurementsType::Standard)
@ -190,14 +177,21 @@ void Calculator::InitVariables(const VContainer *data, const QMap<int, QString>
{
vVarVal[0] = data->size();
DefineVar(data->SizeName(), &vVarVal[0]);
found = true;
}
if (i.value() == data->HeightName())
{
vVarVal[1] = data->height();
DefineVar(data->HeightName(), &vVarVal[1]);
found = true;
}
}
if (found == false)
{
throw qmu::QmuParserError (ecUNASSIGNABLE_TOKEN , i.value(), formula, i.key());
}
++i;
}
}
@ -221,69 +215,6 @@ void Calculator::InitCharacterSets()
DefineOprtChars(symbols + QStringLiteral("+-*^/?<>=#!$%&|~'_"));
}
//---------------------------------------------------------------------------------------------------------------------
qreal Calculator::CmUnit(qreal val)
{
qreal unit = val;
switch (qApp->patternUnit())
{
case Unit::Mm:
unit = val * 10.0;
break;
case Unit::Cm:
break;
case Unit::Inch:
unit = val / 2.54;
break;
default:
break;
}
return unit;
}
//---------------------------------------------------------------------------------------------------------------------
qreal Calculator::MmUnit(qreal val)
{
qreal unit = val;
switch (qApp->patternUnit())
{
case Unit::Mm:
break;
case Unit::Cm:
unit = val / 10.0;
break;
case Unit::Inch:
unit = val / 25.4;
break;
default:
break;
}
return unit;
}
//---------------------------------------------------------------------------------------------------------------------
qreal Calculator::InchUnit(qreal val)
{
qreal unit = val;
switch (qApp->patternUnit())
{
case Unit::Mm:
unit = val * 25.4;
break;
case Unit::Cm:
unit = val * 2.54;
break;
case Unit::Inch:
break;
default:
break;
}
return unit;
}
//---------------------------------------------------------------------------
// Factory function for creating new parser variables
// This could as well be a function performing database queries.

View File

@ -64,11 +64,8 @@ private:
qreal *vVarVal;
static int iVal;
const VContainer *data;
void InitVariables(const VContainer *data, const QMap<int, QString> &tokens);
void InitVariables(const VContainer *data, const QMap<int, QString> &tokens, const QString &formula);
void InitCharacterSets();
static qreal CmUnit(qreal val);
static qreal MmUnit(qreal val);
static qreal InchUnit(qreal val);
static qreal* AddVariable(const QString &a_szName, void *a_pUserData);
};

View File

@ -9,7 +9,8 @@ SOURCES += \
container/varclength.cpp \
container/vcurvelength.cpp \
container/vlinelength.cpp \
container/vsplinelength.cpp
container/vsplinelength.cpp \
container/vformula.cpp
HEADERS += \
container/vcontainer.h \
@ -30,4 +31,5 @@ HEADERS += \
container/vcurvelength_p.h \
container/vlineangle_p.h \
container/vlinelength_p.h \
container/vmeasurement_p.h
container/vmeasurement_p.h \
container/vformula.h

View File

@ -37,6 +37,7 @@
quint32 VContainer::_id = NULL_ID;
qreal VContainer::_size = 50;
qreal VContainer::_height = 176;
QSet<const QString> VContainer::uniqueNames = QSet<const QString>();
//---------------------------------------------------------------------------------------------------------------------
/**
@ -138,6 +139,7 @@ quint32 VContainer::AddGObject(VGObject *obj)
{
SCASSERT(obj != nullptr);
QSharedPointer<VGObject> pointer(obj);
uniqueNames.insert(obj->name());
return AddObject(d->gObjects, pointer);
}
@ -210,6 +212,7 @@ void VContainer::Clear()
d->details.clear();
ClearVariables();
ClearGObjects();
ClearUniqueNames();
}
//---------------------------------------------------------------------------------------------------------------------
@ -334,6 +337,7 @@ void VContainer::UpdateGObject(quint32 id, VGObject* obj)
SCASSERT(obj != nullptr);
QSharedPointer<VGObject> pointer(obj);
UpdateObject(d->gObjects, id, pointer);
uniqueNames.insert(obj->name());
}
//---------------------------------------------------------------------------------------------------------------------
@ -407,6 +411,12 @@ const QMap<QString, QSharedPointer<VLineAngle> > VContainer::DataAngleLines() co
return DataVar<VLineAngle>(VarType::LineAngle);
}
//---------------------------------------------------------------------------------------------------------------------
bool VContainer::IsUnique(const QString &name)
{
return !uniqueNames.contains(name);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VariableExist check if exist variable this same name.
@ -442,6 +452,12 @@ void VContainer::ClearDetails()
d->details.clear();
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::ClearUniqueNames()
{
uniqueNames.clear();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetSize set value of size

View File

@ -37,6 +37,7 @@
#include <QCoreApplication>
#include <QHash>
#include <QSet>
#ifdef Q_CC_GNU
#pragma GCC diagnostic push
@ -186,6 +187,7 @@ public:
}
}
d->variables[name] = QSharedPointer<T>(var);
uniqueNames.insert(name);
}
void UpdateGObject(quint32 id, VGObject* obj);
@ -196,6 +198,7 @@ public:
void ClearCalculationGObjects();
void ClearVariables(const VarType &type = VarType::Unknown);
void ClearDetails();
static void ClearUniqueNames();
void SetSize(qreal size);
void SetSizeName(const QString &name);
@ -221,6 +224,7 @@ public:
const QMap<QString, QSharedPointer<VArcLength> > DataLengthArcs() const;
const QMap<QString, QSharedPointer<VLineAngle> > DataAngleLines() const;
static bool IsUnique(const QString &name);
private:
/**
@ -229,6 +233,7 @@ private:
static quint32 _id;
static qreal _size;
static qreal _height;
static QSet<const QString> uniqueNames;
QSharedDataPointer<VContainerData> d;

View File

@ -0,0 +1,266 @@
/************************************************************************
**
** @file vformula.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 28 8, 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) 2014 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 "vformula.h"
#include "../container/calculator.h"
#include "../container/vcontainer.h"
#include "../widgets/vapplication.h"
//VFormula
//---------------------------------------------------------------------------------------------------------------------
VFormula::VFormula()
:formula(QString()), value(QString(tr("Error"))), checkZero(true), data(nullptr), toolId(NULL_ID),
postfix(QStringLiteral("")), _error(true), dValue(0)
{}
//---------------------------------------------------------------------------------------------------------------------
VFormula::VFormula(const QString &formula, const VContainer *container)
:formula(qApp->FormulaToUser(formula)), value(QString(tr("Error"))), checkZero(true), data(container), toolId(NULL_ID),
postfix(QStringLiteral("")), _error(true), dValue(0)
{
this->formula.replace("\n", " ");// Replace line return with spaces for calc if exist
Eval();
}
//---------------------------------------------------------------------------------------------------------------------
VFormula &VFormula::operator=(const VFormula &formula)
{
if ( &formula == this )
{
return *this;
}
this->formula = formula.getFormula();
this->value = formula.getStringValue();
this->checkZero = formula.getCheckZero();
this->data = formula.getData();
this->toolId = formula.getToolId();
this->postfix = formula.getPostfix();
this->_error = formula.error();
this->dValue = formula.getDoubleValue();
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VFormula::VFormula(const VFormula &formula)
:formula(formula.getFormula()), value(formula.getStringValue()), checkZero(formula.getCheckZero()),
data(formula.getData()), toolId(formula.getToolId()), postfix(formula.getPostfix()), _error(formula.error()),
dValue(formula.getDoubleValue())
{}
//---------------------------------------------------------------------------------------------------------------------
bool VFormula::operator==(const VFormula &formula) const
{
bool isEqual = false;
if (this->formula == formula.getFormula() && this->value == formula.getStringValue() &&
this->checkZero == formula.getCheckZero() && this->data == formula.getData() &&
this->toolId == formula.getToolId() && this->postfix == formula.getPostfix() &&
this->_error == formula.error() && this->dValue == formula.getDoubleValue())
{
isEqual = true;
}
return isEqual;
}
bool VFormula::operator!=(const VFormula &formula) const
{
return !VFormula::operator==(formula);
}
//---------------------------------------------------------------------------------------------------------------------
QString VFormula::getFormula(FormulaType type) const
{
if (type == FormulaType::ToUser)
{
return formula;
}
else
{
return qApp->FormulaFromUser(formula);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VFormula::setFormula(const QString &value, FormulaType type)
{
if (formula != value)
{
if (type == FormulaType::ToUser)
{
formula = value;
}
else
{
formula = qApp->FormulaToUser(value);
}
formula.replace("\n", " ");// Replace line return with spaces for calc if exist
Eval();
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VFormula::getStringValue() const
{
return value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VFormula::getDoubleValue() const
{
return dValue;
}
//---------------------------------------------------------------------------------------------------------------------
bool VFormula::getCheckZero() const
{
return checkZero;
}
//---------------------------------------------------------------------------------------------------------------------
void VFormula::setCheckZero(bool value)
{
if (checkZero != value)
{
checkZero = value;
Eval();
}
}
//---------------------------------------------------------------------------------------------------------------------
const VContainer *VFormula::getData() const
{
return data;
}
//---------------------------------------------------------------------------------------------------------------------
void VFormula::setData(const VContainer *value)
{
if (data != value && value != nullptr)
{
data = value;
Eval();
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VFormula::getToolId() const
{
return toolId;
}
//---------------------------------------------------------------------------------------------------------------------
void VFormula::setToolId(const quint32 &value)
{
toolId = value;
}
//---------------------------------------------------------------------------------------------------------------------
QString VFormula::getPostfix() const
{
return postfix;
}
//---------------------------------------------------------------------------------------------------------------------
void VFormula::setPostfix(const QString &value)
{
if (postfix != value)
{
postfix = value;
Eval();
}
}
//---------------------------------------------------------------------------------------------------------------------
bool VFormula::error() const
{
return _error;
}
//---------------------------------------------------------------------------------------------------------------------
int VFormula::FormulaTypeId()
{
return qMetaTypeId<VFormula>();
}
//---------------------------------------------------------------------------------------------------------------------
void VFormula::Eval()
{
if (data == nullptr)
{
return;
}
if (formula.isEmpty())
{
value = QString(tr("Error"));
_error = true;
dValue = 0;
}
else
{
try
{
Calculator *cal = new Calculator(data);
QString expression = qApp->FormulaFromUser(formula);
const qreal result = cal->EvalFormula(expression);
delete cal;
//if result equal 0
if (checkZero && qFuzzyCompare(1 + result, 1 + 0))
{
value = QString("0");
_error = true;
dValue = 0;
}
else
{
QLocale loc;
if (qApp->getSettings()->value("configuration/osSeparator", 1).toBool())
{
loc = QLocale::system();
}
else
{
loc = QLocale(QLocale::C);
}
dValue = result;
value = QString(loc.toString(result) + " " + postfix);
_error = false;
}
}
catch (qmu::QmuParserError &e)
{
value = QString(tr("Error"));
_error = true;
dValue = 0;
qDebug() << "\nMath parser error:\n"
<< "--------------------------------------\n"
<< "Message: " << e.GetMsg() << "\n"
<< "Expression: " << e.GetExpr() << "\n"
<< "--------------------------------------";
}
}
}

View File

@ -0,0 +1,84 @@
/************************************************************************
**
** @file vformula.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 28 8, 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) 2014 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 VFORMULA_H
#define VFORMULA_H
#include <QCoreApplication>
enum class FormulaType : char{ToUser, FromUser};
class VContainer;
class VFormula
{
Q_DECLARE_TR_FUNCTIONS(VFormula)
public:
VFormula();
VFormula(const QString &formula, const VContainer *container);
VFormula &operator=(const VFormula &formula);
VFormula(const VFormula &formula);
bool operator==(const VFormula &formula) const;
bool operator!=(const VFormula &formula) const;
QString getFormula(FormulaType type = FormulaType::ToUser) const;
void setFormula(const QString &value, FormulaType type = FormulaType::ToUser);
QString getStringValue() const;
qreal getDoubleValue() const;
bool getCheckZero() const;
void setCheckZero(bool value);
const VContainer *getData() const;
void setData(const VContainer *value);
quint32 getToolId() const;
void setToolId(const quint32 &value);
QString getPostfix() const;
void setPostfix(const QString &value);
bool error() const;
static int FormulaTypeId();
private:
QString formula;
QString value;
bool checkZero;
const VContainer *data;
quint32 toolId;
QString postfix;
bool _error;
qreal dValue;
void Eval();
};
Q_DECLARE_METATYPE(VFormula)
#endif // VFORMULA_H

View File

@ -43,8 +43,8 @@
//---------------------------------------------------------------------------------------------------------------------
ConfigurationPage::ConfigurationPage(QWidget *parent)
: QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), unitCombo(nullptr),
osOptionCheck(nullptr), langChanged(false), unitChanged(false)
: QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), labelCombo(nullptr),
unitCombo(nullptr), osOptionCheck(nullptr), langChanged(false), unitChanged(false), labelLangChanged(false)
{
QGroupBox *saveGroup = SaveGroup();
QGroupBox *langGroup = LangGroup();
@ -93,6 +93,12 @@ void ConfigurationPage::Apply()
QString text = QString(tr("Default unit updated and will be used the next pattern creation"));
QMessageBox::information(this, QApplication::applicationName(), text);
}
if (labelLangChanged)
{
QString locale = qvariant_cast<QString>(labelCombo->itemData(labelCombo->currentIndex()));
qApp->getSettings()->setValue("configuration/label_language", locale);
labelLangChanged = false;
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -107,6 +113,12 @@ void ConfigurationPage::UnitChanged()
this->unitChanged = true;
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::LabelLangChanged()
{
labelLangChanged = true;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *ConfigurationPage::SaveGroup()
{
@ -227,13 +239,47 @@ QGroupBox *ConfigurationPage::LangGroup()
UnitLayout->addWidget(unitLabel);
UnitLayout->addWidget(this->unitCombo);
//----------------------- Unit setup
//----------------------- Label language
QLabel *labelName = new QLabel(tr("Label language"));
labelCombo = new QComboBox;
QString checkedLabelLocale = settings->value("configuration/label_language", defaultLocale).toString();
QStringList list{"de", "en" , "fr" , "ru" , "uk"};
SetLabelComboBox(list);
index = labelCombo->findData(checkedLabelLocale);
if (index != -1)
{
labelCombo->setCurrentIndex(index);
}
connect(labelCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&ConfigurationPage::LabelLangChanged);
QHBoxLayout *labelLangLayout = new QHBoxLayout;
labelLangLayout->addWidget(labelName);
labelLangLayout->addWidget(labelCombo);
//-----------------------
QVBoxLayout *langLayout = new QVBoxLayout;
langLayout->addLayout(guiLangLayout);
langLayout->addLayout(separatorLayout);
langLayout->addLayout(UnitLayout);
langLayout->addLayout(labelLangLayout);
langGroup->setLayout(langLayout);
return langGroup;
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::SetLabelComboBox(const QStringList &list)
{
for (int i = 0; i < list.size(); ++i)
{
QString lang = QLocale(list.at(i)).nativeLanguageName();
QIcon ico(QString("%1/%2.png").arg("://icon/flags").arg(list.at(i)));
labelCombo->addItem(ico, lang, list.at(i));
}
}

View File

@ -46,17 +46,22 @@ public:
public slots:
void LangChanged();
void UnitChanged();
void LabelLangChanged();
private:
Q_DISABLE_COPY(ConfigurationPage)
QCheckBox *autoSaveCheck;
QSpinBox *autoTime;
QComboBox *langCombo;
QComboBox *labelCombo;
QComboBox *unitCombo;
QCheckBox *osOptionCheck;
bool langChanged;
bool unitChanged;
bool labelLangChanged;
QGroupBox *SaveGroup();
QGroupBox *LangGroup();
void SetLabelComboBox(const QStringList &list);
};
#endif // CONFIGURATIONPAGE_H

View File

@ -213,44 +213,44 @@ QString DialogHistory::Record(const VToolRecord &tool)
{
switch ( tool.getTypeTool() )
{
case Tool::ArrowTool:
case Tool::Arrow:
Q_UNREACHABLE();
break;
case Tool::SinglePointTool:
case Tool::SinglePoint:
{
return QString(tr("%1 - Base point")).arg(PointName(tool.getId()));
}
case Tool::EndLineTool:
case Tool::EndLine:
{
return QString(tr("%1_%2 - Line from point %1 to point %2"))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrBasePoint)))
.arg(PointName(tool.getId()));
}
case Tool::LineTool:
case Tool::Line:
{
return QString(tr("%1_%2 - Line from point %1 to point %2"))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrFirstPoint)))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrSecondPoint)));
}
case Tool::AlongLineTool:
case Tool::AlongLine:
{
return QString(tr("%3 - Point along line %1_%2"))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrFirstPoint)))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrSecondPoint)))
.arg(PointName(tool.getId()));
}
case Tool::ShoulderPointTool:
case Tool::ShoulderPoint:
{
return QString(tr("%1 - Point of shoulder")).arg(PointName(tool.getId()));
}
case Tool::NormalTool:
case Tool::Normal:
{
return QString(tr("%3 - normal to line %1_%2"))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrFirstPoint)))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrSecondPoint)))
.arg(PointName(tool.getId()));
}
case Tool::BisectorTool:
case Tool::Bisector:
{
return QString(tr("%4 - bisector of angle %1_%2_%3"))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrFirstPoint)))
@ -258,7 +258,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrThirdPoint)))
.arg(PointName(tool.getId()));
}
case Tool::LineIntersectTool:
case Tool::LineIntersect:
{
return QString(tr("%5 - intersection of lines %1_%2 and %3_%4"))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrP1Line1)))
@ -267,19 +267,19 @@ QString DialogHistory::Record(const VToolRecord &tool)
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrP2Line2)))
.arg(PointName(tool.getId()));
}
case Tool::SplineTool:
case Tool::Spline:
{
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(tool.getId());
SCASSERT(spl != nullptr);
return QString(tr("Curve %1_%2")).arg(PointName(spl->GetP1().id())).arg(PointName(spl->GetP4().id()));
}
case Tool::ArcTool:
case Tool::Arc:
{
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(tool.getId());
SCASSERT(arc != nullptr);
return QString(tr("Arc with center in point %1")).arg(PointName(arc->GetCenter().id()));
}
case Tool::SplinePathTool:
case Tool::SplinePath:
{
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(tool.getId());
SCASSERT(splPath != nullptr);
@ -331,7 +331,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrFirstPoint)))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrSecondPoint)));
}
case Tool::CutArcTool:
case Tool::CutArc:
{
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(AttrUInt(domElem, VToolCutArc::AttrArc));
SCASSERT(arc != nullptr);
@ -339,7 +339,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
.arg(PointName(tool.getId()))
.arg(PointName(arc->GetCenter().id()));
}
case Tool::CutSplineTool:
case Tool::CutSpline:
{
const quint32 splineId = AttrUInt(domElem, VToolCutSpline::AttrSpline);
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(splineId);
@ -349,7 +349,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
.arg(PointName(spl->GetP1().id()))
.arg(PointName(spl->GetP4().id()));
}
case Tool::CutSplinePathTool:
case Tool::CutSplinePath:
{
const quint32 splinePathId = AttrUInt(domElem, VToolCutSplinePath::AttrSplinePath);
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(splinePathId);
@ -375,7 +375,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
}
//Because "history" not only show history of pattern, but help restore current data for each pattern's
//piece, we need add record about details and nodes, but don't show them.
case Tool::DetailTool:
case Tool::Detail:
break;
case Tool::UnionDetails:
break;

View File

@ -69,9 +69,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
}
}
//Same regex in pattern.xsd shema file. Don't forget synchronize.
TextDelegate *textDelegate = new TextDelegate("^([^0-9-*/^+=\\s\\(\\)%:;!.,]){1,1}([^-*/^+=\\s\\(\\)%:;!.,]){0,}$",
data, ui->tableWidgetIncrement);
TextDelegate *textDelegate = new TextDelegate(nameRegExp, data, ui->tableWidgetIncrement);
ui->tableWidgetIncrement->setItemDelegateForColumn(0, textDelegate);// name
DoubleSpinBoxDelegate *doubleDelegate = new DoubleSpinBoxDelegate(ui->tableWidgetIncrement);
ui->tableWidgetIncrement->setItemDelegateForColumn(2, doubleDelegate);// base value

View File

@ -41,19 +41,20 @@
* @param parent parent widget
*/
DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()),
:DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), number(0),
typeLine(QString()), formula(QString()), firstPointId(NULL_ID), secondPointId(NULL_ID), formulaBaseHeight(0),
line(nullptr)
{
ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui);
flagFormula = false;
flagName = false;
CheckState();
FillComboBoxPoints(ui->comboBoxFirstPoint);

View File

@ -87,9 +87,6 @@ private:
/** @brief number number of handled objects */
qint32 number;
/** @brief pointName name of point */
QString pointName;
/** @brief typeLine type of line */
QString typeLine;

View File

@ -220,43 +220,6 @@
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="labelEditNamePoint">
<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>

View File

@ -522,6 +522,9 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>9</number>
</property>
<item>
<widget class="QPlainTextEdit" name="plainTextEditF2">
<property name="sizePolicy">

View File

@ -42,19 +42,19 @@
* @param parent parent widget
*/
DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()), typeLine(QString()),
:DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), number(0), typeLine(QString()),
formula(QString()), firstPointId(NULL_ID), secondPointId(NULL_ID), thirdPointId(NULL_ID), formulaBaseHeight(0),
line(nullptr), prepare(false)
{
ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui);
flagFormula = false;
flagName = false;
CheckState();
FillComboBoxPoints(ui->comboBoxFirstPoint);

View File

@ -92,9 +92,6 @@ private:
/** @brief number number of handled objects */
qint32 number;
/** @brief pointName name of point */
QString pointName;
/** @brief typeLine type of line */
QString typeLine;

View File

@ -217,43 +217,6 @@
<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>

View File

@ -33,6 +33,7 @@
#include "../../container/vcontainer.h"
#include "../../visualization/vistoolcutarc.h"
#include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -41,18 +42,18 @@
* @param parent parent widget
*/
DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), pointName(QString()), formula(QString()),
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()),
arcId(NULL_ID), formulaBaseHeight(0), path(nullptr)
{
ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui);
flagFormula = false;
flagName = false;
CheckState();
FillComboBoxArcs(ui->comboBoxArc);

View File

@ -78,9 +78,6 @@ private:
/** @brief ui keeps information about user interface */
Ui::DialogCutArc *ui;
/** @brief pointName name of created point */
QString pointName;
/** @brief formula string with formula */
QString formula;

View File

@ -238,43 +238,6 @@
<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>

View File

@ -31,6 +31,8 @@
#include "../../geometry/vspline.h"
#include "../../container/vcontainer.h"
#include "../../xml/vpattern.h"
#include "../../visualization/vistoolcutspline.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -39,18 +41,18 @@
* @param parent parent widget
*/
DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), pointName(QString()), formula(QString()),
splineId(NULL_ID), formulaBaseHeight(0)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()),
splineId(NULL_ID), formulaBaseHeight(0), path(nullptr)
{
ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancel(ui);
InitOkCancelApply(ui);
flagFormula = false;
flagName = false;
CheckState();
FillComboBoxSplines(ui->comboBoxSpline);
@ -61,11 +63,14 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSpline::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSpline::FormulaChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit);
path = new VisToolCutSpline(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogCutSpline::~DialogCutSpline()
{
delete path;
delete ui;
}
@ -95,6 +100,7 @@ void DialogCutSpline::setFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
path->setLength(formula);
}
//---------------------------------------------------------------------------------------------------------------------
@ -105,6 +111,7 @@ void DialogCutSpline::setFormula(const QString &value)
void DialogCutSpline::setSplineId(const quint32 &value)
{
setCurrentSplineId(ui->comboBoxSpline, splineId, value, ComboBoxCutSpline::CutSpline);
path->setPoint1Id(splineId);
}
//---------------------------------------------------------------------------------------------------------------------
@ -121,6 +128,8 @@ void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type)
{
if (SetObject(id, ui->comboBoxSpline, ""))
{
path->VisualMode(id);
prepare = true;
this->setModal(true);
this->show();
}
@ -135,6 +144,10 @@ void DialogCutSpline::SaveData()
formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
splineId = getCurrentObjectId(ui->comboBoxSpline);
path->setPoint1Id(splineId);
path->setLength(formula);
path->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
@ -142,3 +155,15 @@ void DialogCutSpline::DeployFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSpline::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor);
scene->addItem(path);
path->RefreshGeometry();
}
}

View File

@ -36,6 +36,8 @@ namespace Ui
class DialogCutSpline;
}
class VisToolCutSpline;
/**
* @brief The DialogCutSpline class dialog for ToolCutSpline.
*/
@ -61,6 +63,7 @@ public slots:
*/
void DeployFormulaTextEdit();
protected:
virtual void ShowVisualization();
/**
* @brief SaveData Put dialog data in local variables
*/
@ -71,9 +74,6 @@ private:
/** @brief ui keeps information about user interface */
Ui::DialogCutSpline *ui;
/** @brief pointName name of created point */
QString pointName;
/** @brief formula string with formula */
QString formula;
@ -82,6 +82,8 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
VisToolCutSpline *path;
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -238,43 +238,6 @@
<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>
@ -429,7 +392,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

View File

@ -31,6 +31,8 @@
#include "../../geometry/vsplinepath.h"
#include "../../container/vcontainer.h"
#include "../../xml/vpattern.h"
#include "../../visualization/vistoolcutsplinepath.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -39,18 +41,18 @@
* @param parent parent widget
*/
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), pointName(QString()), formula(QString()),
splinePathId(NULL_ID), formulaBaseHeight(0)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()),
splinePathId(NULL_ID), formulaBaseHeight(0), path(nullptr)
{
ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancel(ui);
InitOkCancelApply(ui);
flagFormula = false;
flagName = false;
CheckState();
FillComboBoxSplinesPath(ui->comboBoxSplinePath);
@ -61,11 +63,14 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSplinePath::NamePointChanged);
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSplinePath::FormulaChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSplinePath::DeployFormulaTextEdit);
path = new VisToolCutSplinePath(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogCutSplinePath::~DialogCutSplinePath()
{
delete path;
delete ui;
}
@ -95,6 +100,7 @@ void DialogCutSplinePath::setFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
path->setLength(formula);
}
//---------------------------------------------------------------------------------------------------------------------
@ -105,6 +111,7 @@ void DialogCutSplinePath::setFormula(const QString &value)
void DialogCutSplinePath::setSplinePathId(const quint32 &value)
{
setCurrentSplinePathId(ui->comboBoxSplinePath, splinePathId, value, ComboBoxCutSpline::CutSpline);
path->setPoint1Id(splinePathId);
}
//---------------------------------------------------------------------------------------------------------------------
@ -121,6 +128,8 @@ void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type)
{
if (SetObject(id, ui->comboBoxSplinePath, ""))
{
path->VisualMode(id);
prepare = true;
this->setModal(true);
this->show();
}
@ -135,6 +144,10 @@ void DialogCutSplinePath::SaveData()
formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
splinePathId = getCurrentObjectId(ui->comboBoxSplinePath);
path->setPoint1Id(splinePathId);
path->setLength(formula);
path->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
@ -142,3 +155,15 @@ void DialogCutSplinePath::DeployFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor);
scene->addItem(path);
path->RefreshGeometry();
}
}

View File

@ -36,6 +36,8 @@ namespace Ui
class DialogCutSplinePath;
}
class VisToolCutSplinePath;
/**
* @brief The DialogCutSplinePath class dialog for ToolCutSplinePath.
*/
@ -61,6 +63,7 @@ public slots:
*/
void DeployFormulaTextEdit();
protected:
virtual void ShowVisualization();
/**
* @brief SaveData Put dialog data in local variables
*/
@ -71,9 +74,6 @@ private:
/** @brief ui keeps information about user interface */
Ui::DialogCutSplinePath *ui;
/** @brief pointName name of created point */
QString pointName;
/** @brief formula string with formula */
QString formula;
@ -82,6 +82,8 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
VisToolCutSplinePath *path;
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -238,43 +238,6 @@
<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>
@ -429,7 +392,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

View File

@ -31,7 +31,8 @@
//---------------------------------------------------------------------------------------------------------------------
DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()), formulaBaseHeight(0)
:DialogTool(data, toolId, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()), formulaBaseHeight(0),
checkZero(false), postfix(QStringLiteral("")), restoreCursor(false)
{
ui->setupUi(this);
InitVariables(ui);
@ -51,7 +52,14 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui
//Disable Qt::WaitCursor
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
if (QApplication::overrideCursor() != nullptr)
{
if (QApplication::overrideCursor()->shape() == Qt::WaitCursor)
{
restoreCursor = true;
QApplication::restoreOverrideCursor();
}
}
#endif
}
@ -59,7 +67,10 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui
DialogEditWrongFormula::~DialogEditWrongFormula()
{
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
if (restoreCursor)
{
QApplication::setOverrideCursor(Qt::WaitCursor);
}
#endif
delete ui;
}
@ -91,8 +102,7 @@ void DialogEditWrongFormula::EvalFormula()
{
SCASSERT(plainTextEditFormula != nullptr);
SCASSERT(labelResultCalculation != nullptr);
const QString postfix = QStringLiteral("");
Eval(plainTextEditFormula->toPlainText(), flagFormula, timerFormula, labelResultCalculation, postfix);
Eval(plainTextEditFormula->toPlainText(), flagFormula, timerFormula, labelResultCalculation, postfix, checkZero);
}
//---------------------------------------------------------------------------------------------------------------------
@ -115,6 +125,18 @@ void DialogEditWrongFormula::setFormula(const QString &value)
ui->plainTextEditFormula->setPlainText(formula);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::setCheckZero(bool value)
{
checkZero = value;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::setPostfix(const QString &value)
{
postfix = value;
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogEditWrongFormula::getFormula() const
{

View File

@ -53,6 +53,8 @@ public:
QString getFormula() const;
void setFormula(const QString &value);
void setCheckZero(bool value);
void setPostfix(const QString &value);
public slots:
virtual void DialogAccepted();
virtual void DialogRejected();
@ -72,6 +74,10 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
bool checkZero;
QString postfix;
bool restoreCursor;
};

View File

@ -14,7 +14,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Edit wrong formula</string>
<string>Edit formula</string>
</property>
<property name="windowIcon">
<iconset resource="../../share/resources/icon.qrc">

View File

@ -42,20 +42,20 @@
* @param parent parent widget
*/
DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()),
:DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), typeLine(QString()),
formulaLength(QString()), formulaAngle(QString()), basePointId(NULL_ID), formulaBaseHeight(0),
formulaBaseHeightAngle(0), line(nullptr)
{
ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
this->formulaBaseHeightAngle = ui->plainTextEditAngle->height();
InitOkCancelApply(ui);
flagFormula = false;
flagName = false;
CheckState();
FillComboBoxPoints(ui->comboBoxBasePoint);

View File

@ -89,9 +89,6 @@ private:
/** @brief ui keeps information about user interface */
Ui::DialogEndLine *ui;
/** @brief pointName name of point */
QString pointName;
/** @brief typeLine type of line */
QString typeLine;

View File

@ -323,7 +323,7 @@
</size>
</property>
<property name="toolTip">
<string>Value of length</string>
<string>Value of angle</string>
</property>
<property name="text">
<string>_</string>
@ -423,43 +423,6 @@
<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>

View File

@ -42,13 +42,13 @@
* @param parent parent widget
*/
DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), number(0), pointName(QString()),
:DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), number(0),
typeLine(QString()), basePointId(NULL_ID), p1LineId(NULL_ID), p2LineId(NULL_ID), line(nullptr)
{
ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
InitOkCancelApply(ui);
flagName = false;
CheckState();
FillComboBoxPoints(ui->comboBoxBasePoint);

View File

@ -81,9 +81,6 @@ private:
/** @brief number number of handled objects */
qint32 number;
/** @brief pointName name of point */
QString pointName;
/** @brief typeLine type of line */
QString typeLine;

View File

@ -31,43 +31,6 @@
<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>

View File

@ -33,6 +33,7 @@
#include "../../container/vcontainer.h"
#include "../../visualization/vistoollineintersect.h"
#include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -41,14 +42,14 @@
* @param parent parent widget
*/
DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), number(0),
p1Line1(NULL_ID), p2Line1(NULL_ID), p1Line2(NULL_ID), p2Line2(NULL_ID), flagPoint(true), line(nullptr)
{
ui->setupUi(this);
number = 0;
InitOkCancelApply(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
flagName = false;
FillComboBoxPoints(ui->comboBoxP1Line1);
FillComboBoxPoints(ui->comboBoxP2Line1);

View File

@ -85,9 +85,6 @@ private:
/** @brief number number of handled objects */
qint32 number;
/** @brief pointName name of point */
QString pointName;
/** @brief p1Line1 id first point of first line */
quint32 p1Line1;

View File

@ -31,43 +31,6 @@
<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>

View File

@ -39,18 +39,18 @@
* @param parent parent widget
*/
DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), typeLine(QString()),
:DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), number(0), typeLine(QString()),
formula(QString()), angle(0), firstPointId(NULL_ID), secondPointId(NULL_ID), formulaBaseHeight(0), line(nullptr)
{
ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui);
flagFormula = false;
flagName = false;
CheckState();
FillComboBoxPoints(ui->comboBoxFirstPoint);

View File

@ -91,9 +91,6 @@ private:
/** @brief number number of handled objects */
qint32 number;
/** @brief pointName name of point */
QString pointName;
/** @brief typeLine type of line */
QString typeLine;

View File

@ -220,43 +220,6 @@
<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>

View File

@ -32,6 +32,7 @@
#include "../../container/vcontainer.h"
#include "../../visualization/vistoolpointofcontact.h"
#include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -40,18 +41,18 @@
* @param parent parent widget
*/
DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), number(0), pointName(QString()),
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), number(0),
radius(QString()), center(NULL_ID), firstPoint(NULL_ID), secondPoint(NULL_ID), formulaBaseHeight(0), line(nullptr)
{
ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui);
flagFormula = false;
flagName = false;
CheckState();
FillComboBoxPoints(ui->comboBoxFirstPoint);

View File

@ -89,9 +89,6 @@ private:
/** @brief number number of handled objects */
qint32 number;
/** @brief pointName name of point */
QString pointName;
/** @brief radius radius of arc */
QString radius;

View File

@ -220,43 +220,6 @@
<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>

View File

@ -33,6 +33,7 @@
#include "../../container/vcontainer.h"
#include "../../visualization/vistoolpointofintersection.h"
#include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -41,14 +42,14 @@
* @param parent parent widget
*/
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), number(0), pointName(QString()),
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), number(0),
firstPointId(NULL_ID), secondPointId(NULL_ID), line(nullptr)
{
ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
InitOkCancelApply(ui);
flagName = false;
CheckState();
FillComboBoxPoints(ui->comboBoxFirstPoint);

View File

@ -75,9 +75,6 @@ private:
/** @brief number number of handled objects */
qint32 number;
/** @brief pointName name of point */
QString pointName;
/** @brief firstPointId id first point of line */
quint32 firstPointId;

View File

@ -28,43 +28,6 @@
<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>

View File

@ -42,19 +42,19 @@
* @param parent parent widget
*/
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
:DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), number(0),
typeLine(QString()), formula(QString()), p1Line(NULL_ID), p2Line(NULL_ID), pShoulder(NULL_ID), formulaBaseHeight(0),
line (nullptr)
{
ui->setupUi(this);
InitVariables(ui);
InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui);
flagFormula = false;
flagName = false;
CheckState();
FillComboBoxTypeLine(ui->comboBoxLineType);

View File

@ -91,9 +91,6 @@ private:
/** @brief number number of handled objects */
qint32 number;
/** @brief pointName name of point */
QString pointName;
/** @brief typeLine type of line */
QString typeLine;

View File

@ -220,43 +220,6 @@
<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>

View File

@ -73,43 +73,6 @@
<height>17</height>
</rect>
</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>

View File

@ -30,6 +30,7 @@
#include "ui_dialogsplinepath.h"
#include "../../geometry/vsplinepoint.h"
#include "../../container/vcontainer.h"
#include "../../visualization/vistoolsplinepath.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -38,10 +39,10 @@
* @param parent parent widget
*/
DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogSplinePath), path(VSplinePath())
:DialogTool(data, toolId, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()), visPath(nullptr)
{
ui->setupUi(this);
InitOkCancel(ui);
InitOkCancelApply(ui);
bOk->setEnabled(false);
FillComboBoxPoints(ui->comboBoxPoint);
@ -57,11 +58,14 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId
this, &DialogSplinePath::KAsm1Changed);
connect(ui->doubleSpinBoxKasm2, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogSplinePath::KAsm2Changed);
visPath = new VisToolSplinePath(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogSplinePath::~DialogSplinePath()
{
delete visPath;
delete ui;
}
@ -73,6 +77,7 @@ DialogSplinePath::~DialogSplinePath()
void DialogSplinePath::SetPath(const VSplinePath &value)
{
this->path = value;
ui->listWidget->blockSignals(true);
ui->listWidget->clear();
for (qint32 i = 0; i < path.CountPoint(); ++i)
{
@ -80,6 +85,9 @@ void DialogSplinePath::SetPath(const VSplinePath &value)
}
ui->listWidget->setFocus(Qt::OtherFocusReason);
ui->doubleSpinBoxKcurve->setValue(path.getKCurve());
visPath->setPath(path);
ui->listWidget->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
@ -94,20 +102,29 @@ void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type)
{
NewItem(id, 1, 0, 1, 180);
emit ToolTip(tr("Select point of curve path"));
this->show();
SavePath();
visPath->setPath(path);
if (path.CountPoint() == 1)
{
visPath->VisualMode(NULL_ID);
connect(visPath, &VisToolSplinePath::ToolTip, this, &DialogTool::ShowVisToolTip);
connect(visPath, &VisToolSplinePath::PathChanged, this, &DialogSplinePath::PathUpdated);
}
else
{
visPath->RefreshGeometry();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSplinePath::SaveData()
{
path.Clear();
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
{
QListWidgetItem *item = ui->listWidget->item(i);
path.append( qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)));
}
path.setKCurve(ui->doubleSpinBoxKcurve->value());
SavePath();
visPath->setPath(path);
visPath->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
@ -214,6 +231,35 @@ void DialogSplinePath::UpdateList()
*/
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSplinePath::ShowDialog(bool click)
{
if (click == false)
{
emit ToolTip("");
DialogAccepted();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSplinePath::PathUpdated(const VSplinePath &path)
{
SetPath(path);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSplinePath::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visPath, &Visualization::SetFactor);
scene->addItem(visPath);
visPath->setMode(Mode::Show);
visPath->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief NewItem add point to list
@ -228,7 +274,7 @@ void DialogSplinePath::NewItem(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(id);
QListWidgetItem *item = new QListWidgetItem(point->name());
item->setFont(QFont("Times", 12, QFont::Bold));
VSplinePoint p(*point, kAsm1, angle1, kAsm2, angle2);
VSplinePoint p(*point.data(), kAsm1, angle1, kAsm2, angle2);
DataPoint(point->id(), kAsm1, angle1, kAsm2, angle2);
item->setData(Qt::UserRole, QVariant::fromValue(p));
ui->listWidget->addItem(item);
@ -295,3 +341,15 @@ void DialogSplinePath::EnableFields()
return;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSplinePath::SavePath()
{
path.Clear();
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
{
QListWidgetItem *item = ui->listWidget->item(i);
path.append( qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)));
}
path.setKCurve(ui->doubleSpinBoxKcurve->value());
}

View File

@ -37,6 +37,8 @@ namespace Ui
class DialogSplinePath;
}
class VisToolSplinePath;
/**
* @brief The DialogSplinePath class dialog for ToolSplinePath. Help create spline path and edit option.
*/
@ -58,7 +60,10 @@ public slots:
void KAsm1Changed(qreal d);
void KAsm2Changed(qreal d);
virtual void UpdateList();
virtual void ShowDialog(bool click);
void PathUpdated(const VSplinePath &path);
protected:
virtual void ShowVisualization();
/**
* @brief SaveData Put dialog data in local variables
*/
@ -72,9 +77,12 @@ private:
/** @brief path spline path */
VSplinePath path;
VisToolSplinePath *visPath;
void NewItem(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2);
void DataPoint(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2);
void EnableFields();
void SavePath();
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -191,7 +191,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

View File

@ -63,7 +63,8 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), lineStyles(VAbstractTool::Styles()),
okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), toolId(toolId), prepare(false)
okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), toolId(toolId), prepare(false),
pointName(QString())
{
SCASSERT(data != nullptr);
timerFormula = new QTimer(this);
@ -377,11 +378,13 @@ void DialogTool::ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer *timer)
SCASSERT(edit != nullptr);
SCASSERT(timer != nullptr);
SCASSERT(labelEditFormula != nullptr);
SCASSERT(labelResultCalculation != nullptr);
if (edit->text().isEmpty())
{
flag = false;
CheckState();
ChangeColor(labelEditFormula, Qt::red);
labelResultCalculation->setText(tr("Error"));
return;
}
timer->start(1000);
@ -392,11 +395,13 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim
SCASSERT(edit != nullptr);
SCASSERT(timer != nullptr);
SCASSERT(labelEditFormula != nullptr);
SCASSERT(labelResultCalculation != nullptr);
if (edit->toPlainText().isEmpty())
{
flag = false;
CheckState();
ChangeColor(labelEditFormula, Qt::red);
labelResultCalculation->setText(tr("Error"));
return;
}
timer->setSingleShot(true);
@ -423,6 +428,8 @@ void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *la
{
flag = false;
ChangeColor(labelEditFormula, Qt::red);
label->setText(tr("Error"));
label->setToolTip(tr("Empty field"));
}
else
{
@ -441,6 +448,8 @@ void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *la
{
flag = false;
ChangeColor(labelEditFormula, Qt::red);
label->setText(tr("Error"));
label->setToolTip(tr("Value can't be 0"));
}
else
{
@ -456,6 +465,7 @@ void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *la
label->setText(loc.toString(result) + postfix);
flag = true;
ChangeColor(labelEditFormula, okColor);
label->setToolTip(tr("Value"));
emit ToolTip("");
}
}
@ -465,6 +475,7 @@ void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *la
flag = false;
ChangeColor(labelEditFormula, Qt::red);
emit ToolTip("Parser error: "+e.GetMsg());
label->setToolTip("Parser error: "+e.GetMsg());
qDebug() << "\nMath parser error:\n"
<< "--------------------------------------\n"
<< "Message: " << e.GetMsg() << "\n"
@ -653,7 +664,8 @@ void DialogTool::NamePointChanged()
if (edit)
{
QString name = edit->text();
if (name.isEmpty() || name.contains(" "))
name.replace(" ", "");
if (name.isEmpty() || (pointName != name && data->IsUnique(name) == false))
{
flagName = false;
ChangeColor(labelEditNamePoint, Qt::red);

View File

@ -200,6 +200,9 @@ protected:
/** @brief prepare show if we prepare. Show dialog after finish working with visual part of tool*/
bool prepare;
/** @brief pointName name of point */
QString pointName;
virtual void closeEvent ( QCloseEvent * event );
virtual void showEvent( QShowEvent *event );
void FillComboBoxPoints(QComboBox *box)const;

View File

@ -32,6 +32,7 @@
#include "../../container/vcontainer.h"
#include "../../visualization/vistooltriangle.h"
#include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -40,14 +41,14 @@
* @param parent parent widget
*/
DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), number(0), pointName(QString()), axisP1Id(NULL_ID),
:DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), number(0), axisP1Id(NULL_ID),
axisP2Id(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID), line (nullptr)
{
ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
InitOkCancelApply(ui);
flagName = false;
CheckState();
FillComboBoxPoints(ui->comboBoxAxisP1);

View File

@ -80,9 +80,6 @@ private:
/** @brief number number of handled objects */
qint32 number;
/** @brief pointName name of point */
QString pointName;
/** @brief axisP1Id id first point of axis */
quint32 axisP1Id;

View File

@ -31,43 +31,6 @@
<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>

View File

@ -37,6 +37,8 @@
# include <QtMath> // for M_PI on Windows
#endif /*Q_OS_WIN32*/
#include "../container/vformula.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -247,6 +249,13 @@ QString VArc::GetFormulaF1() const
return d->formulaF1;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaF1(const VFormula &value)
{
d->formulaF1 = value.getFormula(FormulaType::FromUser);
d->f1 = value.getDoubleValue();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF1 return formula for start angle.
@ -267,6 +276,13 @@ QString VArc::GetFormulaF2() const
return d->formulaF2;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaF2(const VFormula &value)
{
d->formulaF2 = value.getFormula(FormulaType::FromUser);
d->f2 = value.getDoubleValue();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF2 return formula for end angle.
@ -287,6 +303,13 @@ QString VArc::GetFormulaRadius() const
return d->formulaRadius;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaRadius(const VFormula &value)
{
d->formulaRadius = value.getFormula(FormulaType::FromUser);
d->radius = value.getDoubleValue();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetRadius return formula for radius.
@ -306,3 +329,9 @@ VPointF VArc::GetCenter() const
{
return d->center;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetCenter(const VPointF &value)
{
d->center = value;
}

View File

@ -35,6 +35,7 @@
class QPainterPath;
class VArcData;
class VFormula;
/**
* @brief VArc class for anticlockwise arc.
@ -52,13 +53,21 @@ public:
virtual ~VArc();
QString GetFormulaF1 () const;
void SetFormulaF1 (const VFormula &value);
qreal GetF1 () const;
QString GetFormulaF2 () const;
void SetFormulaF2 (const VFormula &value);
qreal GetF2 () const;
qreal GetLength () const;
QString GetFormulaRadius () const;
void SetFormulaRadius (const VFormula &value);
qreal GetRadius () const;
VPointF GetCenter () const;
void SetCenter (const VPointF &value);
qreal GetLength () const;
QPointF GetP1() const;
QPointF GetP2 () const;
qreal AngleArc() const;

View File

@ -241,6 +241,20 @@ QPointF VSpline::CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPo
return p1234;
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VSpline::CutSpline(qreal length, VSpline &spl1, VSpline &spl2) const
{
QPointF spl1p2;
QPointF spl1p3;
QPointF spl2p2;
QPointF spl2p3;
QPointF cutPoint = CutSpline (length, spl1p2, spl1p3, spl2p2, spl2p3 );
spl1 = VSpline(GetP1(), spl1p2, spl1p3, cutPoint, GetKcurve());
spl2 = VSpline(cutPoint, spl2p2, spl2p3, GetP4(), GetKcurve());
return cutPoint;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetPoints return list with spline points.
@ -750,3 +764,12 @@ qreal VSpline::GetKcurve() const
{
return d->kCurve;
}
//---------------------------------------------------------------------------------------------------------------------
void VSpline::SetKcurve(qreal factor)
{
if (factor > 0)
{
d->kCurve = factor;
}
}

View File

@ -63,10 +63,12 @@ public:
qreal GetKasm1() const;
qreal GetKasm2() const;
qreal GetKcurve() const;
void SetKcurve(qreal factor);
// cppcheck-suppress unusedFunction
QLineF::IntersectType CrossingSplLine(const QLineF &line, QPointF *intersectionPoint ) const;
qreal LengthT(qreal t) const;
QPointF CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const;
QPointF CutSpline ( qreal length, VSpline &spl1, VSpline &spl2) const;
QVector<QPointF> GetPoints () const;
// cppcheck-suppress unusedFunction
static QVector<QPointF> SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,

View File

@ -48,7 +48,7 @@ public:
VSplineData ( const VSplineData &spline )
:QSharedData(spline), p1(spline.p1), p2(spline.p2), p3(spline.p3), p4(spline.p4), angle1(spline.angle1),
angle2(spline.angle2), kAsm1(spline.angle2), kAsm2(spline.kAsm1), kCurve(spline.kCurve)
angle2(spline.angle2), kAsm1(spline.kAsm1), kAsm2(spline.kAsm2), kCurve(spline.kCurve)
{}
VSplineData (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve)

View File

@ -258,7 +258,10 @@ qreal VSplinePath::getKCurve() const
//---------------------------------------------------------------------------------------------------------------------
void VSplinePath::setKCurve(const qreal &value)
{
d->kCurve = value;
if (value > 0)
{
d->kCurve = value;
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -80,21 +80,21 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
case QtWarningMsg:
messageBox.setIcon(QMessageBox::Warning);
messageBox.setInformativeText(msg);
messageBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
messageBox.setStandardButtons(QMessageBox::Ok);
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;
case QtCriticalMsg:
messageBox.setIcon(QMessageBox::Critical);
messageBox.setInformativeText(msg);
messageBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
messageBox.setStandardButtons(QMessageBox::Ok);
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;
case QtFatalMsg:
messageBox.setIcon(QMessageBox::Critical);
messageBox.setInformativeText(msg);
messageBox.setStandardButtons(QMessageBox::Cancel);
messageBox.setStandardButtons(QMessageBox::Ok);
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function);
break;

View File

@ -41,6 +41,7 @@
#include "widgets/vapplication.h"
#include "widgets/undoevent.h"
#include "undocommands/renamepp.h"
#include "vtooloptionspropertybrowser.h"
#include <QInputDialog>
#include <QDebug>
@ -60,7 +61,7 @@
* @param parent parent widget.
*/
MainWindow::MainWindow(QWidget *parent)
:QMainWindow(parent), ui(new Ui::MainWindow), pattern(nullptr), doc(nullptr), tool(Tool::ArrowTool),
:QMainWindow(parent), ui(new Ui::MainWindow), pattern(nullptr), doc(nullptr), tool(Tool::Arrow),
currentScene(nullptr), sceneDraw(nullptr), sceneDetails(nullptr), mouseCoordinate(nullptr), helpLabel(nullptr),
isInitialized(false), dialogTable(nullptr), dialogTool(nullptr), dialogHistory(nullptr),
comboBoxDraws(nullptr), curFile(QString()), mode(Draw::Calculation), currentDrawIndex(0),
@ -104,6 +105,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile);
connect(doc, &VPattern::SetEnabledGUI, this, &MainWindow::SetEnabledGUI);
connect(doc, &VPattern::CheckLayout, this, &MainWindow::Layout);
qApp->setCurrentDocument(doc);
connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified);
@ -112,6 +114,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->toolBox->setCurrentIndex(0);
ReadSettings();
PropertyBrowser();
setCurrentFile("");
}
@ -192,15 +195,18 @@ void MainWindow::ActionNewPP()
pattern->ClearGObjects();
//Create single point
const quint32 id = pattern->AddGObject(new VPointF(20+comboBoxDraws->count()*5, 20, "А", 5, 10));
ui->view->itemClicked(nullptr);//hide options previous tool
QString label = doc->GenerateLabel(LabelType::NewPatternPiece);
const quint32 id = pattern->AddGObject(new VPointF(30+comboBoxDraws->count()*5, 40, label, 5, 10));
VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Source::FromGui, patternPieceName, path);
sceneDraw->addItem(spoint);
ui->view->itemClicked(spoint);
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
QHash<quint32, VDataTool*>* tools = doc->getTools();
SCASSERT(tools != nullptr);
tools->insert(id, spoint);
VDrawTool::AddRecord(id, Tool::SinglePointTool, doc);
VDrawTool::AddRecord(id, Tool::SinglePoint, doc);
SetEnableTool(true);
SetEnableWidgets(true);
@ -253,6 +259,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
QCursor cur(pixmap, 2, 3);
ui->view->setCursor(cur);
helpLabel->setText(toolTip);
ui->view->setShowToolOptions(false);
dialogTool = new Dialog(pattern, 0, this);
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject);
connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot);
@ -290,6 +297,7 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur
QPixmap pixmap(cursor);
QCursor cur(pixmap, 2, 3);
ui->view->setCursor(cur);
ui->view->setShowToolOptions(false);
helpLabel->setText(toolTip);
dialogTool = new Dialog(pattern, 0, this);
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject);
@ -319,7 +327,8 @@ void MainWindow::ClosedDialog(int result)
SCASSERT(dialogTool != nullptr);
if (result == QDialog::Accepted)
{
DrawTool::Create(dialogTool, currentScene, doc, pattern);
QGraphicsItem *tool = dynamic_cast<QGraphicsItem *>(DrawTool::Create(dialogTool, currentScene, doc, pattern));
ui->view->itemClicked(tool);
}
ArrowTool();
}
@ -347,9 +356,11 @@ void MainWindow::ClosedDialogWithApply(int result)
vtool->FullUpdateFromGuiApply();
}
}
QGraphicsItem *tool = dynamic_cast<QGraphicsItem *>(dialogTool->GetAssociatedTool());
ui->view->itemClicked(tool);
if (dialogTool->GetAssociatedTool() != nullptr)
{
VDrawTool * vtool= static_cast<VDrawTool *>(dialogTool->GetAssociatedTool());
VDrawTool *vtool= static_cast<VDrawTool *>(dialogTool->GetAssociatedTool());
vtool->DialogLinkDestroy();
}
ArrowTool();
@ -385,7 +396,7 @@ void MainWindow::ApplyDialog()
*/
void MainWindow::ToolEndLine(bool checked)
{
SetToolButtonWithApply<DialogEndLine>(checked, Tool::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"),
SetToolButtonWithApply<DialogEndLine>(checked, Tool::EndLine, ":/cursor/endline_cursor.png", tr("Select point"),
&MainWindow::ClosedDialogWithApply<VToolEndLine>,
&MainWindow::ApplyDialog<VToolEndLine>);
}
@ -397,7 +408,7 @@ void MainWindow::ToolEndLine(bool checked)
*/
void MainWindow::ToolLine(bool checked)
{
SetToolButtonWithApply<DialogLine>(checked, Tool::LineTool, ":/cursor/line_cursor.png", tr("Select first point"),
SetToolButtonWithApply<DialogLine>(checked, Tool::Line, ":/cursor/line_cursor.png", tr("Select first point"),
&MainWindow::ClosedDialogWithApply<VToolLine>,
&MainWindow::ApplyDialog<VToolLine>);
}
@ -409,7 +420,7 @@ void MainWindow::ToolLine(bool checked)
*/
void MainWindow::ToolAlongLine(bool checked)
{
SetToolButtonWithApply<DialogAlongLine>(checked, Tool::AlongLineTool, ":/cursor/alongline_cursor.png",
SetToolButtonWithApply<DialogAlongLine>(checked, Tool::AlongLine, ":/cursor/alongline_cursor.png",
tr("Select point"), &MainWindow::ClosedDialogWithApply<VToolAlongLine>,
&MainWindow::ApplyDialog<VToolAlongLine>);
}
@ -421,7 +432,7 @@ void MainWindow::ToolAlongLine(bool checked)
*/
void MainWindow::ToolShoulderPoint(bool checked)
{
SetToolButtonWithApply<DialogShoulderPoint>(checked, Tool::ShoulderPointTool, ":/cursor/shoulder_cursor.png",
SetToolButtonWithApply<DialogShoulderPoint>(checked, Tool::ShoulderPoint, ":/cursor/shoulder_cursor.png",
tr("Select point of shoulder"),
&MainWindow::ClosedDialogWithApply<VToolShoulderPoint>,
&MainWindow::ApplyDialog<VToolShoulderPoint>);
@ -434,7 +445,7 @@ void MainWindow::ToolShoulderPoint(bool checked)
*/
void MainWindow::ToolNormal(bool checked)
{
SetToolButtonWithApply<DialogNormal>(checked, Tool::NormalTool, ":/cursor/normal_cursor.png",
SetToolButtonWithApply<DialogNormal>(checked, Tool::Normal, ":/cursor/normal_cursor.png",
tr("Select first point of line"),
&MainWindow::ClosedDialogWithApply<VToolNormal>,
&MainWindow::ApplyDialog<VToolNormal>);
@ -447,7 +458,7 @@ void MainWindow::ToolNormal(bool checked)
*/
void MainWindow::ToolBisector(bool checked)
{
SetToolButtonWithApply<DialogBisector>(checked, Tool::BisectorTool, ":/cursor/bisector_cursor.png",
SetToolButtonWithApply<DialogBisector>(checked, Tool::Bisector, ":/cursor/bisector_cursor.png",
tr("Select first point of angle"),
&MainWindow::ClosedDialogWithApply<VToolBisector>,
&MainWindow::ApplyDialog<VToolBisector>);
@ -460,7 +471,7 @@ void MainWindow::ToolBisector(bool checked)
*/
void MainWindow::ToolLineIntersect(bool checked)
{
SetToolButtonWithApply<DialogLineIntersect>(checked, Tool::LineIntersectTool, ":/cursor/intersect_cursor.png",
SetToolButtonWithApply<DialogLineIntersect>(checked, Tool::LineIntersect, ":/cursor/intersect_cursor.png",
tr("Select first point of first line"),
&MainWindow::ClosedDialogWithApply<VToolLineIntersect>,
&MainWindow::ApplyDialog<VToolLineIntersect>);
@ -473,7 +484,7 @@ void MainWindow::ToolLineIntersect(bool checked)
*/
void MainWindow::ToolSpline(bool checked)
{
SetToolButtonWithApply<DialogSpline>(checked, Tool::SplineTool, ":/cursor/spline_cursor.png",
SetToolButtonWithApply<DialogSpline>(checked, Tool::Spline, ":/cursor/spline_cursor.png",
tr("Select first point curve"),
&MainWindow::ClosedDialogWithApply<VToolSpline>,
&MainWindow::ApplyDialog<VToolSpline>);
@ -486,8 +497,10 @@ void MainWindow::ToolSpline(bool checked)
*/
void MainWindow::ToolCutSpline(bool checked)
{
SetToolButton<DialogCutSpline>(checked, Tool::CutSplineTool, ":/cursor/spline_cut_point_cursor.png",
tr("Select simple curve"), &MainWindow::ClosedDialog<VToolCutSpline>);
SetToolButtonWithApply<DialogCutSpline>(checked, Tool::CutSpline, ":/cursor/spline_cut_point_cursor.png",
tr("Select simple curve"),
&MainWindow::ClosedDialogWithApply<VToolCutSpline>,
&MainWindow::ApplyDialog<VToolCutSpline>);
}
//---------------------------------------------------------------------------------------------------------------------
@ -497,7 +510,7 @@ void MainWindow::ToolCutSpline(bool checked)
*/
void MainWindow::ToolArc(bool checked)
{
SetToolButtonWithApply<DialogArc>(checked, Tool::ArcTool, ":/cursor/arc_cursor.png",
SetToolButtonWithApply<DialogArc>(checked, Tool::Arc, ":/cursor/arc_cursor.png",
tr("Select point of center of arc"), &MainWindow::ClosedDialogWithApply<VToolArc>,
&MainWindow::ApplyDialog<VToolArc>);
}
@ -509,8 +522,10 @@ void MainWindow::ToolArc(bool checked)
*/
void MainWindow::ToolSplinePath(bool checked)
{
SetToolButton<DialogSplinePath>(checked, Tool::SplinePathTool, ":/cursor/splinepath_cursor.png",
tr("Select point of curve path"), &MainWindow::ClosedDialog<VToolSplinePath>);
SetToolButtonWithApply<DialogSplinePath>(checked, Tool::SplinePath, ":/cursor/splinepath_cursor.png",
tr("Select point of curve path"),
&MainWindow::ClosedDialogWithApply<VToolSplinePath>,
&MainWindow::ApplyDialog<VToolSplinePath>);
}
//---------------------------------------------------------------------------------------------------------------------
@ -520,9 +535,10 @@ void MainWindow::ToolSplinePath(bool checked)
*/
void MainWindow::ToolCutSplinePath(bool checked)
{
SetToolButton<DialogCutSplinePath>(checked, Tool::CutSplinePathTool,
":/cursor/splinepath_cut_point_cursor.png", tr("Select curve path"),
&MainWindow::ClosedDialog<VToolCutSplinePath>);
SetToolButtonWithApply<DialogCutSplinePath>(checked, Tool::CutSplinePath,
":/cursor/splinepath_cut_point_cursor.png", tr("Select curve path"),
&MainWindow::ClosedDialogWithApply<VToolCutSplinePath>,
&MainWindow::ApplyDialog<VToolCutSplinePath>);
}
//---------------------------------------------------------------------------------------------------------------------
@ -545,7 +561,7 @@ void MainWindow::ToolPointOfContact(bool checked)
*/
void MainWindow::ToolDetail(bool checked)
{
SetToolButton<DialogDetail>(checked, Tool::DetailTool, "://cursor/new_detail_cursor.png",
SetToolButton<DialogDetail>(checked, Tool::Detail, "://cursor/new_detail_cursor.png",
tr("Select points, arcs, curves clockwise."), &MainWindow::ClosedDialogDetail);
}
@ -634,7 +650,7 @@ void MainWindow::ClosedDialogUnionDetails(int result)
*/
void MainWindow::ToolCutArc(bool checked)
{
SetToolButtonWithApply<DialogCutArc>(checked, Tool::CutArcTool, ":/cursor/arc_cut_cursor.png",
SetToolButtonWithApply<DialogCutArc>(checked, Tool::CutArc, ":/cursor/arc_cut_cursor.png",
tr("Select arc"), &MainWindow::ClosedDialogWithApply<VToolCutArc>,
&MainWindow::ApplyDialog<VToolCutArc>);
}
@ -942,60 +958,60 @@ void MainWindow::CancelTool()
dialogTool = nullptr;
switch ( tool )
{
case Tool::ArrowTool:
case Tool::Arrow:
ui->actionArrowTool->setChecked(false);
helpLabel->setText("");
break;
case Tool::SinglePointTool:
case Tool::SinglePoint:
Q_UNREACHABLE();
//Nothing to do here because we can't create this tool from main window.
break;
case Tool::EndLineTool:
case Tool::EndLine:
ui->toolButtonEndLine->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::LineTool:
case Tool::Line:
ui->toolButtonLine->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearFocus();
break;
case Tool::AlongLineTool:
case Tool::AlongLine:
ui->toolButtonAlongLine->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::ShoulderPointTool:
case Tool::ShoulderPoint:
ui->toolButtonShoulderPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::NormalTool:
case Tool::Normal:
ui->toolButtonNormal->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::BisectorTool:
case Tool::Bisector:
ui->toolButtonBisector->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::LineIntersectTool:
case Tool::LineIntersect:
ui->toolButtonLineIntersect->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::SplineTool:
case Tool::Spline:
ui->toolButtonSpline->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::ArcTool:
case Tool::Arc:
ui->toolButtonArc->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::SplinePathTool:
case Tool::SplinePath:
ui->toolButtonSplinePath->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
@ -1005,7 +1021,7 @@ void MainWindow::CancelTool()
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::DetailTool:
case Tool::Detail:
ui->toolButtonNewDetail->setChecked(false);
break;
case Tool::Height:
@ -1023,12 +1039,12 @@ void MainWindow::CancelTool()
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::CutSplineTool:
case Tool::CutSpline:
ui->toolButtonSplineCutPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::CutSplinePathTool:
case Tool::CutSplinePath:
ui->toolButtonSplinePathCutPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
@ -1038,7 +1054,7 @@ void MainWindow::CancelTool()
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::CutArcTool:
case Tool::CutArc:
ui->toolButtonArcCutPoint->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
@ -1061,10 +1077,11 @@ void MainWindow::ArrowTool()
{
CancelTool();
ui->actionArrowTool->setChecked(true);
tool = Tool::ArrowTool;
tool = Tool::Arrow;
QCursor cur(Qt::ArrowCursor);
ui->view->setCursor(cur);
helpLabel->setText("");
ui->view->setShowToolOptions(true);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1959,6 +1976,27 @@ void MainWindow::CreateMenus()
separatorAct = new QAction(this);
separatorAct->setSeparator(true);
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct);
AddDocks();
}
void MainWindow::AddDocks()
{
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, ui->dockWidgetHistory->toggleViewAction());
ui->dockWidgetHistory->close();//Default don't show hostory
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, ui->dockWidgetToolOptions->toggleViewAction());
separatorAct = new QAction(this);
separatorAct->setSeparator(true);
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::PropertyBrowser()
{
toolOptions = new VToolOptionsPropertyBrowser(ui->dockWidgetToolOptions);
connect(ui->view, &VMainGraphicsView::itemClicked, toolOptions, &VToolOptionsPropertyBrowser::itemClicked);
connect(doc, &VPattern::FullUpdateFromFile, toolOptions, &VToolOptionsPropertyBrowser::UpdateOptions);
}
//---------------------------------------------------------------------------------------------------------------------
@ -2213,6 +2251,7 @@ void MainWindow::ChangePP(int index, bool zoomBestFit)
ui->view->NewFactor(ui->view->transform().m11());
}
}
toolOptions->itemClicked(nullptr);//hide options for tool in previous pattern piece
}
}

View File

@ -44,6 +44,8 @@ namespace Ui
class MainWindow;
}
class VToolOptionsPropertyBrowser;
/**
* @brief The MainWindow class main windows.
*/
@ -194,6 +196,8 @@ private:
bool guiEnabled;
QComboBox *gradationHeights;
QComboBox *gradationSizes;
VToolOptionsPropertyBrowser *toolOptions;
void ToolBarOption();
void ToolBarDraws();
void ToolBarTools();
@ -243,6 +247,9 @@ private:
void UpdateSizesList(const QStringList &list);
void SetDefaultHeight(int value);
void SetDefaultSize(int value);
void AddDocks();
void PropertyBrowser();
};
#endif // MAINWINDOW_H

View File

@ -29,6 +29,9 @@
#include "options.h"
#include <QString>
//Same regexp in pattern.xsd shema file. Don't forget synchronize.
const QString nameRegExp = QStringLiteral("^([^0-9-*/^+=\\s\\(\\)%:;!.,]){1,1}([^-*/^+=\\s\\(\\)%:;!.,]){0,}$");
// Keep synchronize all names with initialization in VApllication class.
//measurements
const QString headGirth_M = QStringLiteral("head_girth");

View File

@ -37,30 +37,38 @@
class QString;
static const quint32 null_id = 0;
#define SceneSize 50000
#define DefPointRadius 2.0//mm
#define NULL_ID 0//use this value for initialization variables that keeps id values. 0 mean uknown id value.
#define NULL_ID null_id//use this value for initialization variables that keeps id values. 0 mean uknown id value.
extern const QString nameRegExp;
enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown };
enum class Tool : char
enum class Tool : unsigned char
{
ArrowTool,
SinglePointTool,
EndLineTool,
LineTool,
AlongLineTool,
ShoulderPointTool,
NormalTool,
BisectorTool,
LineIntersectTool,
SplineTool,
CutSplineTool,
CutArcTool,
ArcTool,
SplinePathTool,
CutSplinePathTool,
Arrow,
Point,
LinePoint,
AbstractSpline,
Cut,
SinglePoint,
EndLine,
Line,
AlongLine,
ShoulderPoint,
Normal,
Bisector,
LineIntersect,
Spline,
CutSpline,
CutArc,
Arc,
SplinePath,
CutSplinePath,
PointOfContact,
DetailTool,
Detail,
NodePoint,
NodeArc,
NodeSpline,
@ -71,6 +79,32 @@ enum class Tool : char
UnionDetails
};
enum class Vis : unsigned char
{
ControlPointSpline = 29, // increase this value if need more positions in Tool enum
GraphicsSimpleTextItem,
SimpleSplinePath,
Line,
Path,
ToolAlongLine,
ToolArc,
ToolBisector,
ToolCutArc,
ToolEndLine,
ToolHeight,
ToolLine,
ToolLineIntersect,
ToolNormal,
ToolPointOfContact,
ToolPointOfIntersection,
ToolShoulderPoint,
ToolSpline,
ToolTriangle,
ToolCutSpline,
ToolSplinePath,
ToolCutSplinePath
};
enum class Source : char { FromGui, FromFile, FromTool };
enum class Draw : char { Calculation, Modeling };
enum class Unit : char { Mm, Cm, Inch };

View File

@ -52,6 +52,12 @@ void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
QGraphicsPathItem::paint(painter, &myOption, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractSpline::getTagName() const
{
return VAbstractSpline::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
@ -211,3 +217,12 @@ QPainterPath VAbstractSpline::ToolPath(PathDirection direction) const
path.setFillRule( Qt::WindingFill );
return path;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::ShowFoot(bool show)
{
for (int i = 0; i < controlPoints.size(); ++i)
{
controlPoints.at(i)->setVisible(show);
}
}

View File

@ -40,6 +40,10 @@ public:
VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
static const QString TagName;
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::AbstractSpline)};
virtual QString getTagName() const;
void ShowFoot(bool show);
public slots:
virtual void FullUpdateFromFile ();
void Disable(bool disable);

View File

@ -148,6 +148,36 @@ void VDrawTool::SaveDialogChange()
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VDrawTool::AddToFile()
{
QDomElement domElement = doc->createElement(getTagName());
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOptions(domElement, obj);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VDrawTool::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOptions(domElement, obj);
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DialogLinkDestroy removes dialog pointer
@ -209,6 +239,7 @@ qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContaine
if (resultUndo == UndoButton::Fix)
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, qApp->getMainWindow());
dialog->setWindowTitle(tr("Edit wrong formula"));
dialog->setFormula(formula);
if (dialog->exec() == QDialog::Accepted)
{

View File

@ -36,6 +36,7 @@
#include "../../dialogs/tools/dialogtool.h"
#include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
#include "../../widgets/vmaingraphicsview.h"
/**
* @brief The VDrawTool abstract class for all draw tool.
@ -81,6 +82,8 @@ protected:
/** @brief SaveDialog save options into file after change in dialog. */
virtual void SaveDialog(QDomElement &domElement)=0;
void SaveDialogChange();
virtual void AddToFile();
virtual void RefreshDataInFile();
template <typename Dialog, typename Tool>
/**
@ -118,6 +121,7 @@ protected:
QAction *selectedAction = menu.exec(event->screenPos());
if (selectedAction == actionOption)
{
qApp->getSceneView()->itemClicked(nullptr);
dialog = new Dialog(getData(), id, qApp->getMainWindow());
dialog->setModal(true);
@ -134,6 +138,7 @@ protected:
}
if (selectedAction == actionRemove)
{
qApp->getSceneView()->itemClicked(nullptr);
DeleteTool();
}
}

View File

@ -31,6 +31,7 @@
#include "../../dialogs/tools/dialogalongline.h"
#include "../../geometry/vpointf.h"
#include "exception/vexceptionobjecterror.h"
#include "../../visualization/vistoolalongline.h"
const QString VToolAlongLine::ToolType = QStringLiteral("alongLine");
@ -79,6 +80,16 @@ void VToolAlongLine::FullUpdateFromFile()
secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt();
}
RefreshGeometry();
if (vis != nullptr)
{
VisToolAlongLine * visual = qobject_cast<VisToolAlongLine *>(vis);
visual->setPoint1Id(basePointId);
visual->setPoint2Id(secondPointId);
visual->setLength(formulaLength);
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -113,49 +124,6 @@ void VToolAlongLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogAlongLine>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolAlongLine::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrFirstPoint, basePointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolAlongLine::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrFirstPoint, basePointId);
doc->SetAttribute(domElement, AttrSecondPoint, secondPointId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -182,6 +150,77 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrSecondPoint, dialogTool->getSecondPointId());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrFirstPoint, basePointId);
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolAlongLine::getSecondPointId() const
{
return secondPointId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::setSecondPointId(const quint32 &value)
{
if (value != NULL_ID)
{
secondPointId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::ShowVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
VisToolAlongLine *visual = new VisToolAlongLine(getData());
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
visual->setPoint1Id(basePointId);
visual->setPoint2Id(secondPointId);
visual->setLength(formulaLength);
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
else
{
VisToolAlongLine * visual = qobject_cast<VisToolAlongLine *>(vis);
if (visual != nullptr)
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setDialog set dialog when user want change tool option.
@ -272,7 +311,7 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::AlongLineTool, doc);
VDrawTool::AddRecord(id, Tool::AlongLine, doc);
if (parse == Document::FullParse)
{
VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId,

View File

@ -49,16 +49,21 @@ public:
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::AlongLine)};
quint32 getSecondPointId() const;
void setSecondPointId(const quint32 &value);
virtual void ShowVisualization(bool show);
public slots:
virtual void FullUpdateFromFile();
virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief secondPointId id second point of line. */
quint32 secondPointId;

View File

@ -29,8 +29,11 @@
#include "vtoolarc.h"
#include "../../container/calculator.h"
#include "../../dialogs/tools/dialogarc.h"
#include <QKeyEvent>
#include "../../geometry/varc.h"
#include "../container/vformula.h"
#include "../../visualization/vistoolarc.h"
#include <QKeyEvent>
const QString VToolArc::TagName = QStringLiteral("arc");
const QString VToolArc::ToolType = QStringLiteral("simple");
@ -149,7 +152,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::ArcTool, doc);
VDrawTool::AddRecord(id, Tool::Arc, doc);
if (parse == Document::FullParse)
{
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
@ -165,12 +168,144 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
*/
void VToolArc::FullUpdateFromFile()
QString VToolArc::getTagName() const
{
RefreshGeometry();
return VToolArc::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolArc::getCenter() const
{
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
SCASSERT(arc.isNull() == false);
return arc->GetCenter().id();
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArc::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 VToolArc::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 VToolArc::setFormulaRadius(const VFormula &value)
{
if (value.error() == false)
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
arc->SetFormulaRadius(value);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolArc::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(QStringLiteral("°"));
return f1;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArc::setFormulaF1(const VFormula &value)
{
if (value.error() == false)
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
arc->SetFormulaF1(value);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolArc::getFormulaF2() const
{
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
SCASSERT(arc.isNull() == false);
VFormula f2(arc->GetFormulaF2(), getData());
f2.setCheckZero(false);
f2.setToolId(id);
f2.setPostfix(QStringLiteral("°"));
return f2;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArc::setFormulaF2(const VFormula &value)
{
if (value.error() == false)
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
arc->SetFormulaF2(value);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArc::ShowVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
VisToolArc * visual = new VisToolArc(getData());
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
visual->setPoint1Id(arc->GetCenter().id());
visual->setRadius(arc->GetFormulaRadius());
visual->setF1(arc->GetFormulaF1());
visual->setF2(arc->GetFormulaF2());
visual->RefreshGeometry();
vis = visual;
}
else
{
VisToolArc *visual = qobject_cast<VisToolArc *>(vis);
if (visual != nullptr)
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -183,42 +318,6 @@ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogArc>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolArc::AddToFile()
{
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrCenter, arc->GetCenter().id());
doc->SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius());
doc->SetAttribute(domElement, AttrAngle1, arc->GetFormulaF1());
doc->SetAttribute(domElement, AttrAngle2, arc->GetFormulaF2());
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolArc::RefreshDataInFile()
{
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrCenter, arc->GetCenter().id());
doc->SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius());
doc->SetAttribute(domElement, AttrAngle1, arc->GetFormulaF1());
doc->SetAttribute(domElement, AttrAngle2, arc->GetFormulaF2());
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -244,6 +343,20 @@ void VToolArc::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrAngle2, dialogTool->GetF2());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
SCASSERT(arc.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
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, AttrAngle2, arc->GetFormulaF2());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
@ -252,4 +365,16 @@ void VToolArc::RefreshGeometry()
{
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
this->setPath(ToolPath());
if (vis != nullptr)
{
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
VisToolArc *visual = qobject_cast<VisToolArc *>(vis);
visual->setPoint1Id(arc->GetCenter().id());
visual->setRadius(arc->GetFormulaRadius());
visual->setF1(arc->GetFormulaF1());
visual->setF2(arc->GetFormulaF2());
visual->RefreshGeometry();
}
}

View File

@ -31,6 +31,8 @@
#include "vabstractspline.h"
class VFormula;
/**
* @brief The VToolArc class tool for creation arc.
*/
@ -46,14 +48,28 @@ public:
const Source &typeCreation);
static const QString TagName;
static const QString ToolType;
public slots:
virtual void FullUpdateFromFile();
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Arc)};
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 getFormulaF2() const;
void setFormulaF2(const VFormula &value);
virtual void ShowVisualization(bool show);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
void RefreshGeometry();
};

View File

@ -30,6 +30,7 @@
#include "../../container/calculator.h"
#include "../../dialogs/tools/dialogbisector.h"
#include "../../geometry/vpointf.h"
#include "../../visualization/vistoolbisector.h"
const QString VToolBisector::ToolType = QStringLiteral("bisector");
@ -196,7 +197,7 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::BisectorTool, doc);
VDrawTool::AddRecord(id, Tool::Bisector, doc);
if (parse == Document::FullParse)
{
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId,
@ -230,6 +231,17 @@ void VToolBisector::FullUpdateFromFile()
thirdPointId = domElement.attribute(AttrThirdPoint, "").toUInt();
}
RefreshGeometry();
if (vis != nullptr)
{
VisToolBisector *visual = qobject_cast<VisToolBisector *>(vis);
visual->setPoint1Id(firstPointId);
visual->setPoint2Id(basePointId);
visual->setPoint3Id(thirdPointId);
visual->setLength(formulaLength);
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -263,51 +275,6 @@ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogBisector>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolBisector::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, basePointId);
doc->SetAttribute(domElement, AttrThirdPoint, thirdPointId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolBisector::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrFirstPoint, firstPointId);
doc->SetAttribute(domElement, AttrSecondPoint, basePointId);
doc->SetAttribute(domElement, AttrThirdPoint, thirdPointId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -335,3 +302,95 @@ void VToolBisector::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId()));
doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->getThirdPointId()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolBisector::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrFirstPoint, firstPointId);
doc->SetAttribute(tag, AttrSecondPoint, basePointId);
doc->SetAttribute(tag, AttrThirdPoint, thirdPointId);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolBisector::getThirdPointId() const
{
return thirdPointId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolBisector::setThirdPointId(const quint32 &value)
{
if (value != NULL_ID)
{
thirdPointId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolBisector::ShowVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
VisToolBisector * visual = new VisToolBisector(getData());
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
visual->setPoint1Id(firstPointId);
visual->setPoint2Id(basePointId);
visual->setPoint3Id(thirdPointId);
visual->setLength(formulaLength);
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
else
{
VisToolBisector *visual = qobject_cast<VisToolBisector *>(vis);
if (visual != nullptr)
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolBisector::getFirstPointId() const
{
return firstPointId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolBisector::setFirstPointId(const quint32 &value)
{
if (value != NULL_ID)
{
firstPointId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}

View File

@ -53,16 +53,25 @@ public:
VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Bisector)};
quint32 getFirstPointId() const;
void setFirstPointId(const quint32 &value);
quint32 getThirdPointId() const;
void setThirdPointId(const quint32 &value);
virtual void ShowVisualization(bool show);
public slots:
virtual void FullUpdateFromFile();
virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief firstPointId id first point of angle. */
quint32 firstPointId;

View File

@ -28,6 +28,7 @@
#include "vtoolcut.h"
#include "../../geometry/vpointf.h"
#include "../../container/vformula.h"
//---------------------------------------------------------------------------------------------------------------------
VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
@ -84,6 +85,45 @@ void VToolCut::HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirecti
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolCut::getCurveCutId() const
{
return curveCutId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCut::setCurveCutId(const quint32 &value)
{
if (value != NULL_ID)
{
curveCutId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolCut::getFormula() const
{
VFormula val(formula, getData());
val.setCheckZero(true);
val.setToolId(id);
val.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit()));
return val;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCut::setFormula(const VFormula &value)
{
if (value.error() == false)
{
formula = value.getFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.

View File

@ -32,12 +32,23 @@
#include "vtoolpoint.h"
#include "../../visualization/vsimplecurve.h"
class VFormula;
class VToolCut : public VToolPoint
{
Q_OBJECT
public:
VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &curveCutId,
const quint32 &curve1id, const quint32 &curve2id, QGraphicsItem * parent = nullptr);
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Cut)};
VFormula getFormula() const;
void setFormula(const VFormula &value);
quint32 getCurveCutId() const;
void setCurveCutId(const quint32 &value);
public slots:
virtual void ChangedActivDraw(const QString &newName);
virtual void CurveChoosed(quint32 id)=0;

View File

@ -31,6 +31,7 @@
#include "../../dialogs/tools/dialogcutarc.h"
#include "../../geometry/vpointf.h"
#include "../../geometry/varc.h"
#include "../../visualization/vistoolcutarc.h"
const QString VToolCutArc::ToolType = QStringLiteral("cutArc");
const QString VToolCutArc::AttrArc = QStringLiteral("arc");
@ -163,7 +164,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
}
}
VDrawTool::AddRecord(id, Tool::CutArcTool, doc);
VDrawTool::AddRecord(id, Tool::CutArc, doc);
if (parse == Document::FullParse)
{
VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, arc1id, arc2id, typeCreation);
@ -180,6 +181,39 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutArc::ShowVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
VisToolCutArc * visual = new VisToolCutArc(getData());
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
visual->setPoint1Id(curveCutId);
visual->setLength(formula);
visual->RefreshGeometry();
vis = visual;
}
else
{
VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis);
if (visual != nullptr)
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
@ -187,6 +221,14 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
void VToolCutArc::FullUpdateFromFile()
{
FullUpdateCurveFromFile(AttrArc);
if (vis != nullptr)
{
VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis);
visual->setPoint1Id(curveCutId);
visual->setLength(formula);
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -219,45 +261,6 @@ void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogCutArc>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolCutArc::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrArc, curveCutId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolCutArc::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrArc, curveCutId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -296,3 +299,19 @@ void VToolCutArc::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurve
}
curve->setPath(path);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrArc, curveCutId);
}

View File

@ -48,17 +48,19 @@ public:
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
static const QString AttrArc;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::CutArc)};
virtual void ShowVisualization(bool show);
public slots:
virtual void FullUpdateFromFile();
virtual void CurveChoosed(quint32 id);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolCutArc)
};

View File

@ -30,6 +30,8 @@
#include "../../container/calculator.h"
#include "../../dialogs/tools/dialogcutspline.h"
#include "../../geometry/vpointf.h"
#include "../../visualization/vistoolcutspline.h"
#include "vabstractspline.h"
#include <geometry/vspline.h>
@ -88,7 +90,7 @@ void VToolCutSpline::setDialog()
* @param doc dom document container.
* @param data container with variables.
*/
void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
VToolCutSpline* VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data)
{
SCASSERT(dialog != nullptr);
@ -97,7 +99,13 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula();
const quint32 splineId = dialogTool->getSplineId();
Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
VToolCutSpline* point = nullptr;
point = Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
}
return point;
}
//---------------------------------------------------------------------------------------------------------------------
@ -115,9 +123,10 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation)
VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splineId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
{
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(splineId);
@ -163,7 +172,7 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::CutSplineTool, doc);
VDrawTool::AddRecord(id, Tool::CutSpline, doc);
if (parse == Document::FullParse)
{
VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation);
@ -175,6 +184,45 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString
doc->AddTool(spl1id, point);
doc->AddTool(spl2id, point);
doc->IncrementReferens(splineId);
return point;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutSpline::ShowVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
VisToolCutSpline * visual = new VisToolCutSpline(getData());
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
visual->setPoint1Id(curveCutId);
visual->setLength(formula);
visual->RefreshGeometry();
vis = visual;
}
else
{
VisToolCutSpline * visual = qobject_cast<VisToolCutSpline *>(vis);
if (visual != nullptr)
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
if (VAbstractSpline *parentCurve = qobject_cast<VAbstractSpline *>(doc->getTool(curveCutId)))
{
parentCurve->ShowFoot(show);
}
}
@ -185,6 +233,14 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString
void VToolCutSpline::FullUpdateFromFile()
{
FullUpdateCurveFromFile(AttrSpline);
if (vis != nullptr)
{
VisToolCutSpline *visual = qobject_cast<VisToolCutSpline *>(vis);
visual->setPoint1Id(curveCutId);
visual->setLength(formula);
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -217,45 +273,6 @@ void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogCutSpline>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolCutSpline::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSpline, curveCutId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolCutSpline::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSpline, curveCutId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -294,3 +311,19 @@ void VToolCutSpline::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCu
}
curve->setPath(path);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrSpline, curveCutId);
}

View File

@ -43,23 +43,25 @@ public:
const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog();
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static VToolCutSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolCutSpline *Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
static const QString AttrSpline;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::CutSpline)};
virtual void ShowVisualization(bool show);
public slots:
virtual void FullUpdateFromFile();
virtual void CurveChoosed(quint32 id);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolCutSpline)
};

View File

@ -30,6 +30,8 @@
#include "../../container/calculator.h"
#include "../../dialogs/tools/dialogcutsplinepath.h"
#include "../../geometry/vpointf.h"
#include "../../visualization/vistoolcutsplinepath.h"
#include "vabstractspline.h"
#include "../../geometry/vsplinepath.h"
@ -91,7 +93,8 @@ void VToolCutSplinePath::setDialog()
* @param doc dom document container.
* @param data container with variables.
*/
void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
VToolCutSplinePath* VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
SCASSERT(dialog != nullptr);
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
@ -99,7 +102,13 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula();
const quint32 splinePathId = dialogTool->getSplinePathId();
Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
VToolCutSplinePath* point = nullptr;
point = Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui);
if (point != nullptr)
{
point->dialog=dialogTool;
}
return point;
}
//---------------------------------------------------------------------------------------------------------------------
@ -117,10 +126,10 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splinePathId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splinePathId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
{
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(splinePathId);
SCASSERT(splPath != nullptr);
@ -162,16 +171,16 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt
splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(),
spl1.GetAngle1()));
VSplinePoint cutPoint;
if (typeCreation == Source::FromGui)
{
cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl1.GetAngle2()+180,
spl1.GetAngle2());
}
else
{
// if (typeCreation == Source::FromGui)
// {
// cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl2.GetKasm1(),
// spl1.GetAngle2());
// }
// else
// {
cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl2.GetKasm1(),
spl1.GetAngle2()+180);
}
// }
splPath1->append(cutPoint);
continue;
}
@ -217,7 +226,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt
}
}
VDrawTool::AddRecord(id, Tool::CutSplinePathTool, doc);
VDrawTool::AddRecord(id, Tool::CutSplinePath, doc);
if (parse == Document::FullParse)
{
VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id,
@ -230,6 +239,45 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt
doc->AddTool(splPath1id, point);
doc->AddTool(splPath2id, point);
doc->IncrementReferens(splinePathId);
return point;
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutSplinePath::ShowVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
VisToolCutSplinePath *visual = new VisToolCutSplinePath(getData());
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
visual->setPoint1Id(curveCutId);
visual->setLength(formula);
visual->RefreshGeometry();
vis = visual;
}
else
{
VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis);
if (visual != nullptr)
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
if (VAbstractSpline *parentCurve = qobject_cast<VAbstractSpline *>(doc->getTool(curveCutId)))
{
parentCurve->ShowFoot(show);
}
}
@ -240,6 +288,14 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt
void VToolCutSplinePath::FullUpdateFromFile()
{
FullUpdateCurveFromFile(AttrSplinePath);
if (vis != nullptr)
{
VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis);
visual->setPoint1Id(curveCutId);
visual->setLength(formula);
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -272,45 +328,6 @@ void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogCutSplinePath>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolCutSplinePath::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSplinePath, curveCutId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolCutSplinePath::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrLength, formula);
doc->SetAttribute(domElement, AttrSplinePath, curveCutId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -351,3 +368,19 @@ void VToolCutSplinePath::RefreshCurve(VSimpleCurve *curve, quint32 curveId, Simp
}
curve->setPath(path);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrSplinePath, curveCutId);
}

View File

@ -44,23 +44,26 @@ public:
const quint32 &splinePathId, const quint32 &splPath1id, const quint32 &splPath2id,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog();
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splinePathId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static VToolCutSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolCutSplinePath *Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splinePathId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString ToolType;
static const QString AttrSplinePath;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::CutSplinePath)};
virtual void ShowVisualization(bool show);
public slots:
virtual void FullUpdateFromFile();
virtual void CurveChoosed(quint32 id);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
Q_DISABLE_COPY(VToolCutSplinePath)
};

View File

@ -32,6 +32,7 @@
#include "../../dialogs/tools/dialogendline.h"
#include "../../dialogs/tools/dialogeditwrongformula.h"
#include "../../geometry/vpointf.h"
#include "./../visualization/vistoolendline.h"
const QString VToolEndLine::ToolType = QStringLiteral("endLine");
@ -154,7 +155,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::EndLineTool, doc);
VDrawTool::AddRecord(id, Tool::EndLine, doc);
if (parse == Document::FullParse)
{
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formulaLength, formulaAngle, basePointId,
@ -185,6 +186,16 @@ void VToolEndLine::FullUpdateFromFile()
formulaAngle = domElement.attribute(AttrAngle, "");
}
RefreshGeometry();
if (vis != nullptr)
{
VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis);
visual->setPoint1Id(basePointId);
visual->setLength(formulaLength);
visual->setAngle(formulaAngle);
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -207,49 +218,6 @@ void VToolEndLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogEndLine>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolEndLine::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrAngle, formulaAngle);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolEndLine::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrLength, formulaLength);
doc->SetAttribute(domElement, AttrAngle, formulaAngle);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -265,3 +233,78 @@ void VToolEndLine::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrAngle, formulaAngle);
doc->SetAttribute(tag, AttrBasePoint, basePointId);
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolEndLine::getFormulaAngle() const
{
VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false);
fAngle.setToolId(id);
fAngle.setPostfix(QStringLiteral("°"));
return fAngle;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::setFormulaAngle(const VFormula &value)
{
if (value.error() == false)
{
formulaAngle = value.getFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::ShowVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
VisToolEndLine * visual = new VisToolEndLine(getData());
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
visual->setPoint1Id(basePointId);
visual->setLength(formulaLength);
visual->setAngle(formulaAngle);
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
else
{
VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis);
if (visual != nullptr)
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
}

View File

@ -49,14 +49,19 @@ public:
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::EndLine)};
VFormula getFormulaAngle() const;
void setFormulaAngle(const VFormula &value);
virtual void ShowVisualization(bool show);
public slots:
virtual void FullUpdateFromFile();
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
QString formulaAngle;
};

View File

@ -29,6 +29,7 @@
#include "vtoolheight.h"
#include "../../dialogs/tools/dialogheight.h"
#include "../../geometry/vpointf.h"
#include "../../visualization/vistoolheight.h"
const QString VToolHeight::ToolType = QStringLiteral("height");
@ -202,6 +203,15 @@ void VToolHeight::FullUpdateFromFile()
}
RefreshGeometry();
if (vis != nullptr)
{
VisToolHeight *visual = qobject_cast<VisToolHeight *>(vis);
visual->setPoint1Id(basePointId);
visual->setLineP1Id(p1LineId);
visual->setLineP2Id(p2LineId);
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -224,50 +234,6 @@ void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogHeight>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolHeight::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
doc->SetAttribute(domElement, AttrP1Line, p1LineId);
doc->SetAttribute(domElement, AttrP2Line, p2LineId);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolHeight::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
doc->SetAttribute(domElement, AttrBasePoint, basePointId);
doc->SetAttribute(domElement, AttrP1Line, p1LineId);
doc->SetAttribute(domElement, AttrP2Line, p2LineId);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.
@ -283,3 +249,93 @@ void VToolHeight::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1LineId()));
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2LineId()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolHeight::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrBasePoint, basePointId);
doc->SetAttribute(tag, AttrP1Line, p1LineId);
doc->SetAttribute(tag, AttrP2Line, p2LineId);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolHeight::getP2LineId() const
{
return p2LineId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolHeight::setP2LineId(const quint32 &value)
{
if (value != NULL_ID)
{
p2LineId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolHeight::ShowVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
VisToolHeight * visual = new VisToolHeight(getData());
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
visual->setPoint1Id(basePointId);
visual->setLineP1Id(p1LineId);
visual->setLineP2Id(p2LineId);
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
else
{
VisToolHeight *visual = qobject_cast<VisToolHeight *>(vis);
if (visual != nullptr)
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolHeight::getP1LineId() const
{
return p1LineId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolHeight::setP1LineId(const quint32 &value)
{
if (value != NULL_ID)
{
p1LineId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}

View File

@ -50,14 +50,23 @@ public:
VContainer *data, const Document &parse, const Source &typeCreation);
static QPointF FindPoint(const QLineF &line, const QPointF &point);
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Height)};
quint32 getP1LineId() const;
void setP1LineId(const quint32 &value);
quint32 getP2LineId() const;
void setP2LineId(const quint32 &value);
virtual void ShowVisualization(bool show);
public slots:
virtual void FullUpdateFromFile();
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief p1LineId id first point of line. */
quint32 p1LineId;

View File

@ -31,6 +31,7 @@
#include <QKeyEvent>
#include "../../geometry/vpointf.h"
#include "../../dialogs/tools/dialogline.h"
#include "../../visualization/vistoolline.h"
const QString VToolLine::TagName = QStringLiteral("line");
@ -147,7 +148,7 @@ VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, con
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::LineTool, doc);
VDrawTool::AddRecord(id, Tool::Line, doc);
if (parse == Document::FullParse)
{
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, typeCreation);
@ -176,6 +177,12 @@ void VToolLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QGraphicsLineItem::paint(painter, &myOption, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolLine::getTagName() const
{
return VToolLine::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
@ -183,6 +190,15 @@ void VToolLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
void VToolLine::FullUpdateFromFile()
{
RefreshGeometry();
if (vis != nullptr)
{
VisToolLine *visual = qobject_cast<VisToolLine *>(vis);
visual->setPoint1Id(firstPoint);
visual->setPoint2Id(secondPoint);
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -254,11 +270,8 @@ void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
void VToolLine::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrFirstPoint, firstPoint);
doc->SetAttribute(domElement, AttrSecondPoint, secondPoint);
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
QSharedPointer<VGObject> obj = QSharedPointer<VGObject> ();
SaveOptions(domElement, obj);
AddToCalculation(domElement);
}
@ -271,9 +284,12 @@ void VToolLine::RefreshDataInFile()
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrFirstPoint, firstPoint);
doc->SetAttribute(domElement, AttrSecondPoint, secondPoint);
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
QSharedPointer<VGObject> obj = QSharedPointer<VGObject> ();
SaveOptions(domElement, obj);
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
@ -366,6 +382,87 @@ void VToolLine::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
Q_UNUSED(obj)
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrFirstPoint, firstPoint);
doc->SetAttribute(tag, AttrSecondPoint, secondPoint);
doc->SetAttribute(tag, AttrTypeLine, typeLine);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLine::getSecondPoint() const
{
return secondPoint;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLine::setSecondPoint(const quint32 &value)
{
if (value != NULL_ID)
{
secondPoint = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLine::ShowVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
VisToolLine * visual = new VisToolLine(getData());
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
visual->setPoint1Id(firstPoint);
visual->setPoint2Id(secondPoint);
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
visual->RefreshGeometry();
vis = visual;
}
else
{
VisToolLine *visual = qobject_cast<VisToolLine *>(vis);
if (visual != nullptr)
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLine::getFirstPoint() const
{
return firstPoint;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLine::setFirstPoint(const quint32 &value)
{
if (value != NULL_ID)
{
firstPoint = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.

View File

@ -48,6 +48,16 @@ public:
const Document &parse, const Source &typeCreation);
static const QString TagName;
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Line)};
virtual QString getTagName() const;
quint32 getFirstPoint() const;
void setFirstPoint(const quint32 &value);
quint32 getSecondPoint() const;
void setSecondPoint(const quint32 &value);
virtual void ShowVisualization(bool show);
public slots:
virtual void FullUpdateFromFile();
virtual void ChangedActivDraw(const QString &newName);
@ -64,6 +74,7 @@ protected:
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief firstPoint id first line point. */
quint32 firstPoint;

View File

@ -29,6 +29,7 @@
#include "vtoollineintersect.h"
#include "../../dialogs/tools/dialoglineintersect.h"
#include "../../geometry/vpointf.h"
#include "../../visualization/vistoollineintersect.h"
const QString VToolLineIntersect::ToolType = QStringLiteral("lineIntersect");
@ -166,7 +167,7 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::LineIntersectTool, doc);
VDrawTool::AddRecord(id, Tool::LineIntersect, doc);
if (parse == Document::FullParse)
{
VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id,
@ -201,6 +202,16 @@ void VToolLineIntersect::FullUpdateFromFile()
p2Line2 = domElement.attribute(AttrP2Line2, "").toUInt();
}
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
if (vis != nullptr)
{
VisToolLineIntersect *visual = qobject_cast<VisToolLineIntersect *>(vis);
visual->setPoint1Id(p1Line1);
visual->setLine1P2Id(p2Line1);
visual->setLine2P1Id(p1Line2);
visual->setLine2P2Id(p2Line2);
vis->RefreshGeometry();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -234,49 +245,6 @@ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenu<DialogLineIntersect>(this, event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToFile add tag with informations about tool into file.
*/
void VToolLineIntersect::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrP1Line1, p1Line1);
doc->SetAttribute(domElement, AttrP2Line1, p2Line1);
doc->SetAttribute(domElement, AttrP1Line2, p1Line2);
doc->SetAttribute(domElement, AttrP2Line2, p2Line2);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolLineIntersect::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(domElement, AttrP1Line1, p1Line1);
doc->SetAttribute(domElement, AttrP2Line1, p2Line1);
doc->SetAttribute(domElement, AttrP1Line2, p1Line2);
doc->SetAttribute(domElement, AttrP2Line2, p2Line2);
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -304,3 +272,129 @@ void VToolLineIntersect::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->getP1Line2()));
doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->getP2Line2()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj);
SCASSERT(point.isNull() == false);
doc->SetAttribute(tag, VDomDocument::AttrId, id);
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrP1Line1, p1Line1);
doc->SetAttribute(tag, AttrP2Line1, p2Line1);
doc->SetAttribute(tag, AttrP1Line2, p1Line2);
doc->SetAttribute(tag, AttrP2Line2, p2Line2);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersect::getP2Line2() const
{
return p2Line2;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::setP2Line2(const quint32 &value)
{
if (value != NULL_ID)
{
p2Line2 = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::ShowVisualization(bool show)
{
if (show)
{
if (vis == nullptr)
{
VisToolLineIntersect * visual = new VisToolLineIntersect(getData());
VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
visual->setPoint1Id(p1Line1);
visual->setLine1P2Id(p2Line1);
visual->setLine2P1Id(p1Line2);
visual->setLine2P2Id(p2Line2);
visual->RefreshGeometry();
vis = visual;
}
else
{
VisToolLineIntersect *visual = qobject_cast<VisToolLineIntersect *>(vis);
if (visual != nullptr)
{
visual->show();
}
}
}
else
{
delete vis;
vis = nullptr;
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersect::getP1Line2() const
{
return p1Line2;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::setP1Line2(const quint32 &value)
{
if (value != NULL_ID)
{
p1Line2 = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersect::getP2Line1() const
{
return p2Line1;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::setP2Line1(const quint32 &value)
{
if (value != NULL_ID)
{
p2Line1 = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersect::getP1Line1() const
{
return p1Line1;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::setP1Line1(const quint32 &value)
{
if (value != NULL_ID)
{
p1Line1 = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}

View File

@ -48,16 +48,31 @@ public:
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType;
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::LineIntersect)};
quint32 getP1Line1() const;
void setP1Line1(const quint32 &value);
quint32 getP2Line1() const;
void setP2Line1(const quint32 &value);
quint32 getP1Line2() const;
void setP1Line2(const quint32 &value);
quint32 getP2Line2() const;
void setP2Line2(const quint32 &value);
virtual void ShowVisualization(bool show);
public slots:
virtual void FullUpdateFromFile();
virtual void SetFactor(qreal factor);
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
private:
/** @brief p1Line1 id first point first line. */
quint32 p1Line1;

View File

@ -107,3 +107,58 @@ void VToolLinePoint::SetFactor(qreal factor)
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
qreal VToolLinePoint::getAngle() const
{
return angle;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::setAngle(const qreal &value)
{
angle = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLinePoint::getBasePointId() const
{
return basePointId;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::setBasePointId(const quint32 &value)
{
if (value != NULL_ID)
{
basePointId = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}
//---------------------------------------------------------------------------------------------------------------------
VFormula VToolLinePoint::getFormulaLength() const
{
VFormula fLength(formulaLength, this->getData());
fLength.setCheckZero(true);
fLength.setToolId(id);
fLength.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit()));
return fLength;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::setFormulaLength(const VFormula &value)
{
if (value.error() == false)
{
formulaLength = value.getFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
}

Some files were not shown because too many files have changed in this diff Show More