Auto creation label.

--HG--
branch : feature
This commit is contained in:
dismine 2014-09-05 11:01:46 +03:00
parent 4c913f485d
commit a65faff8d9
34 changed files with 225 additions and 536 deletions

View File

@ -43,8 +43,8 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
ConfigurationPage::ConfigurationPage(QWidget *parent) ConfigurationPage::ConfigurationPage(QWidget *parent)
: QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), unitCombo(nullptr), : QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), labelCombo(nullptr),
osOptionCheck(nullptr), langChanged(false), unitChanged(false) unitCombo(nullptr), osOptionCheck(nullptr), langChanged(false), unitChanged(false), labelLangChanged(false)
{ {
QGroupBox *saveGroup = SaveGroup(); QGroupBox *saveGroup = SaveGroup();
QGroupBox *langGroup = LangGroup(); 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")); QString text = QString(tr("Default unit updated and will be used the next pattern creation"));
QMessageBox::information(this, QApplication::applicationName(), text); 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; this->unitChanged = true;
} }
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::LabelLangChanged()
{
labelLangChanged = true;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QGroupBox *ConfigurationPage::SaveGroup() QGroupBox *ConfigurationPage::SaveGroup()
{ {
@ -227,13 +239,47 @@ QGroupBox *ConfigurationPage::LangGroup()
UnitLayout->addWidget(unitLabel); UnitLayout->addWidget(unitLabel);
UnitLayout->addWidget(this->unitCombo); 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; QVBoxLayout *langLayout = new QVBoxLayout;
langLayout->addLayout(guiLangLayout); langLayout->addLayout(guiLangLayout);
langLayout->addLayout(separatorLayout); langLayout->addLayout(separatorLayout);
langLayout->addLayout(UnitLayout); langLayout->addLayout(UnitLayout);
langLayout->addLayout(labelLangLayout);
langGroup->setLayout(langLayout); langGroup->setLayout(langLayout);
return langGroup; 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: public slots:
void LangChanged(); void LangChanged();
void UnitChanged(); void UnitChanged();
void LabelLangChanged();
private: private:
Q_DISABLE_COPY(ConfigurationPage) Q_DISABLE_COPY(ConfigurationPage)
QCheckBox *autoSaveCheck; QCheckBox *autoSaveCheck;
QSpinBox *autoTime; QSpinBox *autoTime;
QComboBox *langCombo; QComboBox *langCombo;
QComboBox *labelCombo;
QComboBox *unitCombo; QComboBox *unitCombo;
QCheckBox *osOptionCheck; QCheckBox *osOptionCheck;
bool langChanged; bool langChanged;
bool unitChanged; bool unitChanged;
bool labelLangChanged;
QGroupBox *SaveGroup(); QGroupBox *SaveGroup();
QGroupBox *LangGroup(); QGroupBox *LangGroup();
void SetLabelComboBox(const QStringList &list);
}; };
#endif // CONFIGURATIONPAGE_H #endif // CONFIGURATIONPAGE_H

View File

@ -48,12 +48,13 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId,
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
InitFormulaUI(ui); InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui); InitOkCancelApply(ui);
flagFormula = false; flagFormula = false;
flagName = false;
CheckState(); CheckState();
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);

View File

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

View File

@ -49,12 +49,12 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
InitFormulaUI(ui); InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui); InitOkCancelApply(ui);
flagFormula = false; flagFormula = false;
flagName = false;
CheckState(); CheckState();
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);

View File

@ -217,43 +217,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -33,6 +33,7 @@
#include "../../container/vcontainer.h" #include "../../container/vcontainer.h"
#include "../../visualization/vistoolcutarc.h" #include "../../visualization/vistoolcutarc.h"
#include "../../widgets/vmaingraphicsscene.h" #include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -47,12 +48,12 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
InitFormulaUI(ui); InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui); InitOkCancelApply(ui);
flagFormula = false; flagFormula = false;
flagName = false;
CheckState(); CheckState();
FillComboBoxArcs(ui->comboBoxArc); FillComboBoxArcs(ui->comboBoxArc);

View File

@ -238,43 +238,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -31,6 +31,7 @@
#include "../../geometry/vspline.h" #include "../../geometry/vspline.h"
#include "../../container/vcontainer.h" #include "../../container/vcontainer.h"
#include "../../xml/vpattern.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -45,12 +46,12 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
InitFormulaUI(ui); InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancel(ui); InitOkCancel(ui);
flagFormula = false; flagFormula = false;
flagName = false;
CheckState(); CheckState();
FillComboBoxSplines(ui->comboBoxSpline); FillComboBoxSplines(ui->comboBoxSpline);

View File

@ -238,43 +238,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -31,6 +31,7 @@
#include "../../geometry/vsplinepath.h" #include "../../geometry/vsplinepath.h"
#include "../../container/vcontainer.h" #include "../../container/vcontainer.h"
#include "../../xml/vpattern.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -45,12 +46,12 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
InitFormulaUI(ui); InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancel(ui); InitOkCancel(ui);
flagFormula = false; flagFormula = false;
flagName = false;
CheckState(); CheckState();
FillComboBoxSplinesPath(ui->comboBoxSplinePath); FillComboBoxSplinesPath(ui->comboBoxSplinePath);

View File

@ -238,43 +238,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -49,13 +49,13 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
InitFormulaUI(ui); InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeight = ui->plainTextEditFormula->height();
this->formulaBaseHeightAngle = ui->plainTextEditAngle->height(); this->formulaBaseHeightAngle = ui->plainTextEditAngle->height();
InitOkCancelApply(ui); InitOkCancelApply(ui);
flagFormula = false; flagFormula = false;
flagName = false;
CheckState(); CheckState();
FillComboBoxPoints(ui->comboBoxBasePoint); FillComboBoxPoints(ui->comboBoxBasePoint);

View File

@ -423,43 +423,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -46,9 +46,9 @@ DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidge
typeLine(QString()), basePointId(NULL_ID), p1LineId(NULL_ID), p2LineId(NULL_ID), line(nullptr) typeLine(QString()), basePointId(NULL_ID), p1LineId(NULL_ID), p2LineId(NULL_ID), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
InitOkCancelApply(ui); InitOkCancelApply(ui);
flagName = false;
CheckState(); CheckState();
FillComboBoxPoints(ui->comboBoxBasePoint); FillComboBoxPoints(ui->comboBoxBasePoint);

View File

@ -31,43 +31,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -33,6 +33,7 @@
#include "../../container/vcontainer.h" #include "../../container/vcontainer.h"
#include "../../visualization/vistoollineintersect.h" #include "../../visualization/vistoollineintersect.h"
#include "../../widgets/vmaingraphicsscene.h" #include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -47,8 +48,8 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &
ui->setupUi(this); ui->setupUi(this);
number = 0; number = 0;
InitOkCancelApply(ui); InitOkCancelApply(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
flagName = false;
FillComboBoxPoints(ui->comboBoxP1Line1); FillComboBoxPoints(ui->comboBoxP1Line1);
FillComboBoxPoints(ui->comboBoxP2Line1); FillComboBoxPoints(ui->comboBoxP2Line1);

View File

@ -31,43 +31,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -45,12 +45,12 @@ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidge
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
InitFormulaUI(ui); InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui); InitOkCancelApply(ui);
flagFormula = false; flagFormula = false;
flagName = false;
CheckState(); CheckState();
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);

View File

@ -220,43 +220,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -32,6 +32,7 @@
#include "../../container/vcontainer.h" #include "../../container/vcontainer.h"
#include "../../visualization/vistoolpointofcontact.h" #include "../../visualization/vistoolpointofcontact.h"
#include "../../widgets/vmaingraphicsscene.h" #include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -46,12 +47,12 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
InitFormulaUI(ui); InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui); InitOkCancelApply(ui);
flagFormula = false; flagFormula = false;
flagName = false;
CheckState(); CheckState();
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);

View File

@ -220,43 +220,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -33,6 +33,7 @@
#include "../../container/vcontainer.h" #include "../../container/vcontainer.h"
#include "../../visualization/vistoolpointofintersection.h" #include "../../visualization/vistoolpointofintersection.h"
#include "../../widgets/vmaingraphicsscene.h" #include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -45,10 +46,10 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, con
firstPointId(NULL_ID), secondPointId(NULL_ID), line(nullptr) firstPointId(NULL_ID), secondPointId(NULL_ID), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
InitOkCancelApply(ui); InitOkCancelApply(ui);
flagName = false;
CheckState(); CheckState();
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);

View File

@ -28,43 +28,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -49,12 +49,12 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
InitFormulaUI(ui); InitFormulaUI(ui);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeight = ui->plainTextEditFormula->height();
InitOkCancelApply(ui); InitOkCancelApply(ui);
flagFormula = false; flagFormula = false;
flagName = false;
CheckState(); CheckState();
FillComboBoxTypeLine(ui->comboBoxLineType); FillComboBoxTypeLine(ui->comboBoxLineType);

View File

@ -220,43 +220,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -73,43 +73,6 @@
<height>17</height> <height>17</height>
</rect> </rect>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -32,6 +32,7 @@
#include "../../container/vcontainer.h" #include "../../container/vcontainer.h"
#include "../../visualization/vistooltriangle.h" #include "../../visualization/vistooltriangle.h"
#include "../../widgets/vmaingraphicsscene.h" #include "../../widgets/vmaingraphicsscene.h"
#include "../../xml/vpattern.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -44,10 +45,10 @@ DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QW
axisP2Id(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID), line (nullptr) axisP2Id(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID), line (nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
InitOkCancelApply(ui); InitOkCancelApply(ui);
flagName = false;
CheckState(); CheckState();
FillComboBoxPoints(ui->comboBoxAxisP1); FillComboBoxPoints(ui->comboBoxAxisP1);

View File

@ -31,43 +31,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </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"> <property name="text">
<string>Point label</string> <string>Point label</string>
</property> </property>

View File

@ -105,6 +105,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile); connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile);
connect(doc, &VPattern::SetEnabledGUI, this, &MainWindow::SetEnabledGUI); connect(doc, &VPattern::SetEnabledGUI, this, &MainWindow::SetEnabledGUI);
connect(doc, &VPattern::CheckLayout, this, &MainWindow::Layout); connect(doc, &VPattern::CheckLayout, this, &MainWindow::Layout);
qApp->setCurrentDocument(doc);
connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified); connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified);
@ -194,7 +195,8 @@ void MainWindow::ActionNewPP()
pattern->ClearGObjects(); pattern->ClearGObjects();
//Create single point //Create single point
const quint32 id = pattern->AddGObject(new VPointF(20+comboBoxDraws->count()*5, 20, "А", 5, 10)); 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); VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Source::FromGui, patternPieceName, path);
sceneDraw->addItem(spoint); sceneDraw->addItem(spoint);
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);

View File

@ -58,7 +58,7 @@ VApplication::VApplication(int &argc, char **argv)
guiTexts(QMap<QString, VTranslation>()), descriptions(QMap<QString, VTranslation>()), guiTexts(QMap<QString, VTranslation>()), descriptions(QMap<QString, VTranslation>()),
variables(QMap<QString, VTranslation>()), functions(QMap<QString, VTranslation>()), variables(QMap<QString, VTranslation>()), functions(QMap<QString, VTranslation>()),
postfixOperators(QMap<QString, VTranslation>()), undoStack(nullptr), sceneView(nullptr), currentScene(nullptr), postfixOperators(QMap<QString, VTranslation>()), undoStack(nullptr), sceneView(nullptr), currentScene(nullptr),
autoSaveTimer(nullptr), mainWindow(nullptr), openingPattern(false), settings(nullptr) autoSaveTimer(nullptr), mainWindow(nullptr), openingPattern(false), settings(nullptr), doc(nullptr)
{ {
undoStack = new QUndoStack(this); undoStack = new QUndoStack(this);

View File

@ -38,6 +38,7 @@ class VApplication;// used in define
class QUndoStack; class QUndoStack;
class VMainGraphicsView; class VMainGraphicsView;
class VMainGraphicsScene; class VMainGraphicsScene;
class VPattern;
#if defined(qApp) #if defined(qApp)
#undef qApp #undef qApp
@ -91,6 +92,9 @@ public:
QSettings *getSettings(); QSettings *getSettings();
VMainGraphicsScene *getCurrentScene() const; VMainGraphicsScene *getCurrentScene() const;
void setCurrentScene(VMainGraphicsScene *value); void setCurrentScene(VMainGraphicsScene *value);
void setCurrentDocument(VPattern *doc);
VPattern *getCurrentDocument()const;
private: private:
Q_DISABLE_COPY(VApplication) Q_DISABLE_COPY(VApplication)
Unit _patternUnit; Unit _patternUnit;
@ -121,6 +125,8 @@ private:
* @brief settings pointer to settings. Help hide constructor creation settings. Make make code more readable. * @brief settings pointer to settings. Help hide constructor creation settings. Make make code more readable.
*/ */
QSettings *settings; QSettings *settings;
VPattern *doc;
void InitLineWidth(); void InitLineWidth();
void InitMeasurements(); void InitMeasurements();
void InitVariables(); void InitVariables();
@ -197,4 +203,17 @@ inline void VApplication::setAutoSaveTimer(QTimer *value)
autoSaveTimer = value; autoSaveTimer = value;
} }
//---------------------------------------------------------------------------------------------------------------------
inline void VApplication::setCurrentDocument(VPattern *doc)
{
this->doc = doc;
}
//---------------------------------------------------------------------------------------------------------------------
inline VPattern *VApplication::getCurrentDocument() const
{
SCASSERT(doc != nullptr)
return doc;
}
#endif // VAPPLICATION_H #endif // VAPPLICATION_H

View File

@ -45,6 +45,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QUndoStack> #include <QUndoStack>
#include <QtMath>
const QString VPattern::TagPattern = QStringLiteral("pattern"); const QString VPattern::TagPattern = QStringLiteral("pattern");
const QString VPattern::TagCalculation = QStringLiteral("calculation"); const QString VPattern::TagCalculation = QStringLiteral("calculation");
@ -1619,6 +1620,68 @@ void VPattern::CheckTagExists(const QString &tag)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VPattern::GetLabelBase(unsigned int index) const
{
QString defaultLocale = QLocale::system().name(); // e.g. "de_DE"
defaultLocale.truncate(defaultLocale.lastIndexOf('_')); // e.g. "de"
QString checkedLocale = qApp->getSettings()->value("configuration/label_language", defaultLocale).toString();
QStringList list{"de", "en" , "fr" , "ru" , "uk"};
QStringList alphabet;
switch(list.indexOf(checkedLocale))
{
case 0: // de
{
QString al = QStringLiteral("A,Ä,B,C,D,E,F,G,H,I,J,K,L,M,N,O,Ö,P,Q,R,S,ß,T,U,Ü,V,W,X,Y,Z");
alphabet = al.split(",");
break;
}
case 1: // en
{
QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z");
alphabet = al.split(",");
break;
}
case 2: // fr
{
QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z");
alphabet = al.split(",");
break;
}
case 3: // ru
{
QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,И,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Э,Ю,Я");
alphabet = al.split(",");
break;
}
case 4: // uk
{
QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Є,Ю,Я");
alphabet = al.split(",");
break;
}
default: // en
{
QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z");
alphabet = al.split(",");
break;
}
}
QString base;
int count = qFloor(index/alphabet.size());
int number = index - alphabet.size() * count;
int i = 0;
do
{
base.append(alphabet.at(number));
++i;
} while (i < count);
return base;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief ParseSplineElement parse spline tag. * @brief ParseSplineElement parse spline tag.
@ -2280,6 +2343,66 @@ void VPattern::SetVersion()
emit patternChanged(false); emit patternChanged(false);
} }
//---------------------------------------------------------------------------------------------------------------------
QString VPattern::GenerateLabel(const LabelType &type) const
{
QDomNodeList drawList = elementsByTagName(TagDraw);
if (type == LabelType::NewPatternPiece)
{
QString name;
int i = 0;
for(;;)
{
name = GetLabelBase(drawList.size() + i);
if (data->IsUnique(name))
{
return name;
}
if (i == INT_MAX)
{
break;
}
++i;
}
return name;
}
else if (type == LabelType::NewLabel)
{
if (drawList.isEmpty())
{
return GetLabelBase(0);
}
int index = 0;
for (int i = 0; i < drawList.size(); ++i)
{
QDomElement node = drawList.at(i).toElement();
if (node.attribute(AttrName) == nameActivPP)
{
index = i;
break;
}
}
QString labelBase = GetLabelBase(index);
qint32 num = 1;
QString name;
do
{
name = QString("%1%2").arg(labelBase).arg(num);
num++;
if (num == INT_MAX)
{
break;
}
} while (data->IsUnique(name) == false);
return name;
}
return QString();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief CollectId recursive function, try find id attribute in file. Throw exclusion if find not unique. * @brief CollectId recursive function, try find id attribute in file. Throw exclusion if find not unique.

View File

@ -36,6 +36,7 @@ class VDataTool;
class VMainGraphicsScene; class VMainGraphicsScene;
enum class Document : char { LiteParse, LitePPParse, FullParse }; enum class Document : char { LiteParse, LitePPParse, FullParse };
enum class LabelType : char {NewPatternPiece, NewLabel};
/* /*
VAL_VERSION is (major << 16) + (minor << 8) + patch. VAL_VERSION is (major << 16) + (minor << 8) + patch.
@ -179,6 +180,8 @@ public:
QString GetVersion() const; QString GetVersion() const;
void SetVersion(); void SetVersion();
QString GenerateLabel(const LabelType &type)const;
signals: signals:
/** /**
* @brief ChangedActivDraw change active pattern peace. * @brief ChangedActivDraw change active pattern peace.
@ -280,6 +283,7 @@ private:
QRectF ToolBoundingRect(const QRectF &rec, const quint32 &id) const; QRectF ToolBoundingRect(const QRectF &rec, const quint32 &id) const;
void ParseCurrentPP(); void ParseCurrentPP();
void CheckTagExists(const QString &tag); void CheckTagExists(const QString &tag);
QString GetLabelBase(unsigned int index)const;
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------