merge commit

--HG--
branch : develop
This commit is contained in:
MitSchoko 2014-11-19 11:39:27 +01:00
commit 15bc3f074a
100 changed files with 13947 additions and 9013 deletions

View File

@ -27,6 +27,8 @@ defineTest(copyToDestdir) {
DDIR = $$2
mkpath($$DDIR)
message("----------------------------------------------begin------------------------------------------------")
message("Copy to" $$DDIR "after link")
for(FILE, files) {
# Replace slashes in paths with backslashes for Windows
@ -35,9 +37,11 @@ defineTest(copyToDestdir) {
DDIR ~= s,/,\\,g
}
QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
message("Command:" $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t))
}
export(QMAKE_POST_LINK)
message("----------------------------------------------end---------------------------------------------------")
}
# We use precompiled headers for more fast compilation source code.
@ -525,10 +529,12 @@ GCC_DEBUG_CXXFLAGS += \
-Wall \
-Wextra \
-pedantic \
-fno-omit-frame-pointer # Need for exchndl.dll
CLANG_DEBUG_CXXFLAGS += \
-O0 \
-Wall \
-Wextra \
-pedantic \
-fno-omit-frame-pointer # Need for exchndl.dll
}

30
dist/nsis/headers/fileversion.nsh vendored Normal file
View File

@ -0,0 +1,30 @@
; fileversion.nsh
; Source http://nsis.sourceforge.net/GetDLLVersionLocal_as_define
;
; GetDLLVersionLocal only gives you two packed 32bit numbers, but
; sometimes you might need the unpacked numbers at compile time. This is
; where this ugly thing comes in.
;
; Example usage
; !insertmacro GetPEVersionLocal "$%windir%\system32\kernel32.dll" myver
; Outfile "$%temp%\hello ${myver_1}.${myver_2}.${myver_3}.${myver_4}.exe"
!macro GetPEVersionLocal file defbase
!verbose push
!verbose 2
!tempfile GetPEVersionLocal_nsi
!tempfile GetPEVersionLocal_exe
!define GetPEVersionLocal_doll "$"
!appendfile "${GetPEVersionLocal_nsi}" 'SilentInstall silent$\nRequestExecutionLevel user$\nOutFile "${GetPEVersionLocal_exe}"$\nPage instfiles$\nSection'
!appendfile "${GetPEVersionLocal_nsi}" '$\nFileOpen $0 "${GetPEVersionLocal_nsi}" w$\nGetDllVersion "${file}" $R0 $R1$\nIntOp $R2 $R0 / 0x00010000$\nIntOp $R3 $R0 & 0x0000FFFF$\nIntOp $R4 $R1 / 0x00010000$\nIntOp $R5 $R1 & 0x0000FFFF'
!appendfile "${GetPEVersionLocal_nsi}" '$\nFileWrite $0 "!define ${defbase}_1 $R2${GetPEVersionLocal_doll}\n"$\nFileWrite $0 "!define ${defbase}_2 $R3${GetPEVersionLocal_doll}\n"$\nFileWrite $0 "!define ${defbase}_3 $R4${GetPEVersionLocal_doll}\n"$\nFileWrite $0 "!define ${defbase}_4 $R5${GetPEVersionLocal_doll}\n"$\nFileClose $0$\nSectionEnd'
!system '"${NSISDIR}\makensis" /V2 "${GetPEVersionLocal_nsi}"' = 0
!system '"${GetPEVersionLocal_exe}"' = 0
!include "${GetPEVersionLocal_nsi}"
!delfile "${GetPEVersionLocal_nsi}"
!delfile "${GetPEVersionLocal_exe}"
!undef GetPEVersionLocal_nsi
!undef GetPEVersionLocal_exe
!undef GetPEVersionLocal_doll
!verbose pop
!macroend

View File

@ -2,6 +2,7 @@
; --------------- Headers --------------
!include "MUI2.nsh"
!include "headers\fileassoc.nsh"
!include "headers\fileversion.nsh"
!include "FileFunc.nsh"
; --------------- General --------------
@ -11,7 +12,10 @@ SetCompressor /FINAL /SOLID lzma
!define MUI_PRODUCT "Valentina"
!define MUI_FILE "valentina"
!define MUI_VERSION "0.2.8-alpha"
!insertmacro GetPEVersionLocal "c:\pack\valentina\valentina.exe" ver
!define MUI_VERSION "${ver_1}.${ver_2}.${ver_3}-alpha"
!define MUI_BRANDINGTEXT "Valentina ${MUI_VERSION}"
!define WEBSITE_LINK "http://www.valentina-project.org/"
!define PUBLISHER "Roman Telezhynskyi"
@ -20,7 +24,10 @@ InstallDir "$LOCALAPPDATA\${MUI_PRODUCT}" ; Default installation
Name "${MUI_BRANDINGTEXT}" ; Name displayed on installer
Icon "valentina\${MUI_FILE}.ico"
Caption "${MUI_BRANDINGTEXT}"
OutFile "${MUI_FILE}-install-v.${MUI_VERSION}_32bit.exe" ; Resulting installer filename
!define /date MYTIMESTAMP "%Y%m%d%H%M%S"
OutFile "${MUI_FILE}_${MUI_VERSION}-${MYTIMESTAMP}_i386.exe" ; Resulting installer filename
InstallDirRegKey HKCU "$LOCALAPPDATA\${MUI_PRODUCT}" "" ; Get installation folder from registry if available
LicenseData "valentina\LICENSE_GPL.txt"
RequestExecutionLevel user ; Request application privileges for Windows Vista

View File

@ -1,3 +1,4 @@
#-------------------------------------------------
#
# Project created by QtCreator 2013-06-18T12:36:43
@ -107,7 +108,7 @@ TRANSLATIONS += share/translations/valentina.ts \
share/translations/valentina_nl_NL.ts
# Set using ccache. Function enable_ccache() defined in Valentina.pri.
#$$enable_ccache()
$$enable_ccache()
# Set precompiled headers. Function set_PCH() defined in Valentina.pri.
$$set_PCH()
@ -145,9 +146,17 @@ CONFIG(debug, debug|release){
# Release mode
DEFINES += QT_NO_DEBUG_OUTPUT
!unix:*-g++{
QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll
}
# Turn on debug symbols in release mode on Unix systems.
# On Mac OS X temporarily disabled. Need find way how to strip binary file.
unix:!macx:QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3
!macx:!win32-msvc*{
QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3
QMAKE_CFLAGS_RELEASE += -g -gdwarf-3
QMAKE_LFLAGS_RELEASE =
}
#local revision number for using in version
HG_REV=$$system(hg parents --template '{rev}')
@ -174,20 +183,12 @@ message(Examples: $$[QT_INSTALL_EXAMPLES])
# Path to recource file.
win32:RC_FILE = share/resources/valentina.rc
# Set "make install" command for Unix-like systems.
unix{
isEmpty(PREFIX){
PREFIX = $$DEFAULT_PREFIX
}
# Keep path to all files with standard measurements we support right now
INSTALL_STANDARD_MEASHUREMENTS += share/resources/tables/standard/GOST_man_ru.vst
# Prefix for binary file.
unix:!macx{
# Add to this variable all translation files that you want install with program.
# For generation *.qm file first you need create *.ts. See section TRANSLATIONS.
INSTALL_TRANSLATIONS += \
# Add to this variable all translation files that you want install with program.
# For generation *.qm file first you need create *.ts. See section TRANSLATIONS.
INSTALL_TRANSLATIONS += \
share/translations/valentina_ru_RU.qm \
share/translations/valentina_uk_UA.qm \
share/translations/valentina_de_DE.qm \
@ -197,8 +198,14 @@ unix:!macx{
share/translations/valentina_it_IT.qm \
share/translations/valentina_nl_NL.qm
# Set "make install" command for Unix-like systems.
unix{
# Prefix for binary file.
isEmpty(PREFIX){
PREFIX = $$DEFAULT_PREFIX
}
unix:!macx{
DATADIR =$$PREFIX/share
DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\"
@ -228,8 +235,7 @@ unix:!macx{
translations \
standard
}
}
macx{
macx{
# Some macx stuff
QMAKE_MAC_SDK = macosx
@ -305,6 +311,7 @@ macx{
TRANSLATION_nl_NL.path = "$$RESOURCES_DIR/translations/nl_NL.lproj"
QMAKE_BUNDLE_DATA += TRANSLATION_nl_NL
}
qmuparser.path = $$FRAMEWORKS_DIR
qmuparser.files = $${OUT_PWD}/../libs/qmuparser/$${DESTDIR}/
vpropertyexplorer.path = $$FRAMEWORKS_DIR
@ -323,7 +330,7 @@ macx{
qmuparser \
vpropertyexplorer
}
}
# Run generation *.qm file for available *.ts files each time you run qmake.
@ -338,6 +345,7 @@ macx{
for(DIR, INSTALL_TRANSLATIONS) {
#add these absolute paths to a variable which
#ends up as 'mkcommands = path1 path2 path3 ...'
tr_path += $${PWD}/$$DIR
}
@ -371,11 +379,18 @@ DEPENDPATH += $${PWD}/../libs/vpropertyexplorer
# Strip after you link all libaries.
CONFIG(release, debug|release){
win32:!win32-msvc*{
# Strip debug symbols.
QMAKE_POST_LINK += objcopy --only-keep-debug bin/${TARGET} bin/${TARGET}.dbg &&
QMAKE_POST_LINK += objcopy --strip-debug bin/${TARGET} &&
QMAKE_POST_LINK += objcopy --add-gnu-debuglink="bin/${TARGET}.dbg" bin/${TARGET}
}
unix:!macx{
# Strip debug symbols.
QMAKE_POST_LINK += objcopy --only-keep-debug $(TARGET) $(TARGET).debug &&
QMAKE_POST_LINK += strip --strip-debug --strip-unneeded $(TARGET) &&
QMAKE_POST_LINK += objcopy --add-gnu-debuglink $(TARGET).debug $(TARGET)
QMAKE_POST_LINK += objcopy --only-keep-debug ${TARGET} ${TARGET}.dbg &&
QMAKE_POST_LINK += objcopy --strip-debug ${TARGET} &&
QMAKE_POST_LINK += objcopy --add-gnu-debuglink="${TARGET}.dbg" ${TARGET}
}
}

View File

@ -110,6 +110,10 @@ qreal Calculator::EvalFormula(const QString &formula)
result = Eval();
QMap<int, QString> tokens = this->GetTokens();
// Remove "-" from tokens list if exist. If don't do that unary minus operation will broken.
RemoveAll(tokens, "-");
if (tokens.isEmpty())
{
return result;
@ -194,7 +198,7 @@ void Calculator::InitCharacterSets()
// Defining identifier character sets
DefineNameChars(QStringLiteral("0123456789_") + symbols.join(""));
DefineOprtChars(symbols.join("") + QStringLiteral("+-*^/?<>=#!$%&|~'_"));
DefineOprtChars(symbols.join("") + QStringLiteral("+-*^/?<>=#!$%&|~_"));
}
//---------------------------------------------------------------------------------------------------------------------
@ -243,3 +247,16 @@ void Calculator::SetSepForTr(bool fromUser)
SetDecSep('.');
}
}
//---------------------------------------------------------------------------------------------------------------------
void Calculator::RemoveAll(QMap<int, QString> &map, const QString &val)
{
QList<int> listKeys = map.keys(val);
if (listKeys.size() > 0)
{
for (int i = 0; i < listKeys.size(); ++i)
{
map.remove(listKeys.at(i));
}
}
}

View File

@ -68,6 +68,7 @@ private:
static qreal* AddVariable(const QString &a_szName, void *a_pUserData);
void SetSepForEval();
void SetSepForTr(bool fromUser);
void RemoveAll(QMap<int, QString> &map, const QString &val);
};
#endif // CALCULATOR_H

View File

@ -34,6 +34,7 @@
#include "../exception/vexceptionwrongid.h"
#include "vmaingraphicsview.h"
#include "../container/calculator.h"
#include "../version.h"
#include <QDebug>
#include <QDir>
@ -45,6 +46,10 @@
const qreal VApplication::PrintDPI = 96.0;
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
const QString VApplication::GistFileName = QStringLiteral("gist.json");
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
#define DefWidth 1.2//mm
//---------------------------------------------------------------------------------------------------------------------
@ -1848,3 +1853,152 @@ bool VApplication::SafeCopy(const QString &source, const QString &destination, Q
return result;
}
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
//---------------------------------------------------------------------------------------------------------------------
// Catch exception and create report. Use if program build with Mingw compiler.
// See more about catcher https://github.com/jrfonseca/drmingw/blob/master/README.md
void VApplication::DrMingw()
{
QFile drmingw("exchndl.dll");
if(drmingw.exists())
{// If don't want create reports just delete exchndl.dll from installer
LoadLibrary(L"exchndl.dll");
}
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::CollectReports() const
{
// Seek file "binary_name.RPT"
const QString reportName = QString("%1/%2.RPT").arg(applicationDirPath())
.arg(QFileInfo(arguments().at(0)).baseName());
QFile reportFile(reportName);
if (reportFile.exists())
{ // Hooray we have found crash
if (settings == nullptr)
{
return;// Settings was not opened.
}
if (settings->value("configuration/send_report/state", 1).toBool())
{ // Try send report
// Remove gist.json file before close app.
connect(this, &VApplication::aboutToQuit, this, &VApplication::CleanGist, Qt::UniqueConnection);
SendReport(reportName);
}
else
{ // Just collect report to /reports directory
CollectReport(reportName);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::CollectReport(const QString &reportName) const
{
const QString reportsDir = QString("%1/reports").arg(qApp->applicationDirPath());
QDir reports(reportsDir);
if (reports.exists() == false)
{
reports.mkpath("."); // Create directory for reports if need
}
const QDateTime now = QDateTime::currentDateTime();
const QString timestamp = now.toString(QLatin1String("yyyyMMdd-hhmmsszzz"));
const QString filename = QString("%1/reports/crash-%2.RPT").arg(qApp->applicationDirPath()).arg(timestamp);
QFile reportFile(reportName);
reportFile.copy(filename); // Collect new crash
reportFile.remove(); // Clear after yourself
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::CleanGist() const
{
QFile gistFile(GistFileName);
if (gistFile.exists())
{
gistFile.remove();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VApplication::SendReport(const QString &reportName) const
{
QString content;
QFile reportFile(reportName);
if (!reportFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
return;
}
QTextStream in(&reportFile);
while (!in.atEnd())
{
content.append(in.readLine()+"\r\n");// Windows end of line
}
reportFile.close();
// Additional information
content.append(QString("-------------------------------")+"\r\n");
content.append(QString("Version:%1").arg(APP_VERSION)+"\r\n");
content.append(QString("Based on Qt %2 (32 bit)").arg(QT_VERSION_STR)+"\r\n");
content.append(QString("Built on %3 at %4").arg(__DATE__).arg(__TIME__)+"\r\n");
// Creating json with report
// Example:
//{
// "description":"Crash report",
// "public":"true",
// "files":{
// "file1.txt":{
// "content":"Report text here"
// }
// }
//}
// Useful to know when crash was created
const QDateTime now = QDateTime::currentDateTime();
const QString timestamp = now.toString(QLatin1String("yyyy/MM/dd hh:mm:ss:zzz"));
const QString report = QString("Crash report was created %2").arg(timestamp);
QJsonObject reportObject;
reportObject.insert(QStringLiteral("description"), QJsonValue(report));
reportObject.insert(QStringLiteral("public"), QJsonValue(QString("true")));
QJsonObject contentObject;
contentObject.insert(QStringLiteral("content"), QJsonValue(content));
QJsonObject fileObject;
fileObject.insert(QFileInfo(reportName).fileName(), QJsonValue(contentObject));
reportObject.insert(QStringLiteral("files"), QJsonValue(fileObject));
QFile gistFile(GistFileName);
if (!gistFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
{
qDebug("Couldn't open gist file.");
return;
}
// Save data to file
QJsonDocument saveRep(reportObject);
gistFile.write(saveRep.toJson());
gistFile.close();
QFile curlFile("curl.exe");
if (curlFile.exists())
{// Trying send report
// Change token 28df778e0ef75e3724f7b9622fb70b9c69187779 if need
QString arg = QString("curl.exe -k -H \"Authorization: bearer 28df778e0ef75e3724f7b9622fb70b9c69187779\" "
"-H \"Accept: application/json\" -H \"Content-type: application/json\" -X POST "
"--data @gist.json https://api.github.com/gists");
QProcess::startDetached(arg);
reportFile.remove();// Clear after yourself
}
else
{// We can not send than just collect
CollectReport(reportName);
}
}
#endif //defined(Q_OS_WIN) && defined(Q_CC_GNU)

View File

@ -103,6 +103,13 @@ public:
static QStringList LabelLanguages();
QString STDescription(const QString &id)const;
static bool SafeCopy(const QString &source, const QString &destination, QString &error);
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
static void DrMingw();
void CollectReports() const;
private slots:
void CleanGist() const;
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
private:
Q_DISABLE_COPY(VApplication)
Unit _patternUnit;
@ -153,6 +160,13 @@ private:
void BiasTokens(int position, int bias, QMap<int, QString> &tokens) const;
void InitMeasurement(const QString &name, const VTranslation &m, const VTranslation &g,
const VTranslation &d);
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
static const QString GistFileName;
void CollectReport(const QString &reportName) const;
void SendReport(const QString &reportName) const;
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -44,14 +44,17 @@
//---------------------------------------------------------------------------------------------------------------------
ConfigurationPage::ConfigurationPage(QWidget *parent)
: QWidget(parent), autoSaveCheck(nullptr), autoTime(nullptr), langCombo(nullptr), labelCombo(nullptr),
unitCombo(nullptr), osOptionCheck(nullptr), langChanged(false), unitChanged(false), labelLangChanged(false)
unitCombo(nullptr), osOptionCheck(nullptr), langChanged(false), unitChanged(false), labelLangChanged(false),
sendReportCheck(nullptr)
{
QGroupBox *saveGroup = SaveGroup();
QGroupBox *langGroup = LangGroup();
QGroupBox *sendGroup = SendGroup();
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(saveGroup);
mainLayout->addWidget(langGroup);
mainLayout->addWidget(sendGroup);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
@ -76,6 +79,8 @@ void ConfigurationPage::Apply()
qApp->getSettings()->setValue("configuration/osSeparator", osOptionCheck->isChecked());
qApp->getSettings()->setValue("configuration/send_report/state", sendReportCheck->isChecked());
if (langChanged)
{
QString locale = qvariant_cast<QString>(langCombo->itemData(langCombo->currentIndex()));
@ -273,6 +278,35 @@ QGroupBox *ConfigurationPage::LangGroup()
return langGroup;
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *ConfigurationPage::SendGroup()
{
QSettings *settings = qApp->getSettings();
SCASSERT(settings != nullptr);
QGroupBox *sendGroup = new QGroupBox(tr("Send crash reports"));
sendReportCheck = new QCheckBox(tr("Send crash reports (recommended)"));
bool sendReportValue = settings->value("configuration/send_report/state", 1).toBool();
sendReportCheck->setChecked(sendReportValue);
QLabel *description = new QLabel(tr("After each crash Valentina collect information that may help us fix a "
"problem. We do not collect any personal information. Find more about what "
"<a href=\"https://bitbucket.org/dismine/valentina/wiki/manual/"
"Crash_reports\">kind of information</a> we collect."));
description->setTextFormat(Qt::RichText);
description->setTextInteractionFlags(Qt::TextBrowserInteraction);
description->setOpenExternalLinks(true);
description->setWordWrap(true);
QVBoxLayout *sendLayout = new QVBoxLayout;
sendLayout->addWidget(sendReportCheck);
sendLayout->addWidget(description);
sendGroup->setLayout(sendLayout);
return sendGroup;
}
//---------------------------------------------------------------------------------------------------------------------
void ConfigurationPage::SetLabelComboBox(const QStringList &list)
{

View File

@ -58,9 +58,11 @@ private:
bool langChanged;
bool unitChanged;
bool labelLangChanged;
QCheckBox *sendReportCheck;
QGroupBox *SaveGroup();
QGroupBox *LangGroup();
QGroupBox *SendGroup();
void SetLabelComboBox(const QStringList &list);
};

View File

@ -57,7 +57,6 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent)
connect(this, &DialogHistory::ShowHistoryTool, doc, &VPattern::ShowHistoryTool);
connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor);
connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory);
connect(doc, &VPattern::ChangedActivPP, this, &DialogHistory::UpdateHistory);
ShowPoint();
}
@ -115,7 +114,7 @@ void DialogHistory::cellClicked(int row, int column)
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedCursor changed cursor of input. Cursor show after what record we will insert new object
* @brief ChangedCursor changed cursor of input. Cursor show after which record we will insert new object
* @param id id of object
*/
void DialogHistory::ChangedCursor(quint32 id)
@ -151,18 +150,13 @@ void DialogHistory::UpdateHistory()
void DialogHistory::FillTable()
{
ui->tableWidget->clear();
const QVector<VToolRecord> *history = doc->getHistory();
SCASSERT(history != nullptr);
QVector<VToolRecord> history = doc->getLocalHistory();
qint32 currentRow = -1;
qint32 count = 0;
ui->tableWidget->setRowCount(history->size());
for (qint32 i = 0; i< history->size(); ++i)
ui->tableWidget->setRowCount(history.size());//Make row count max possible number
for (qint32 i = 0; i< history.size(); ++i)
{
const VToolRecord tool = history->at(i);
if (tool.getNameDraw() != doc->GetNameActivPP())
{
continue;
}
const VToolRecord tool = history.at(i);
const QString historyRecord = Record(tool);
if (historyRecord.isEmpty() ==false)
{
@ -182,8 +176,8 @@ void DialogHistory::FillTable()
++count;
}
}
ui->tableWidget->setRowCount(count);
if (history->size()>0)
ui->tableWidget->setRowCount(count);//Real row count
if (count>0)
{
cursorRow = currentRow;
QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0);
@ -373,6 +367,20 @@ QString DialogHistory::Record(const VToolRecord &tool)
}
return record;
}
case Tool::LineIntersectAxis:
{
return QString(tr("%1 - point of intersection line %2_%3 and axis through point %4"))
.arg(PointName(tool.getId()))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrP1Line)))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrP2Line)))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrBasePoint)));
}
case Tool::CurveIntersectAxis:
{
return QString(tr("%1 - point of intersection curve and axis through point %2"))
.arg(PointName(tool.getId()))
.arg(PointName(AttrUInt(domElem, VAbstractTool::AttrBasePoint)));
}
//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::Detail:
@ -418,7 +426,7 @@ void DialogHistory::InitialTable()
*/
void DialogHistory::ShowPoint()
{
QVector<VToolRecord> *history = doc->getHistory();
const QVector<VToolRecord> *history = doc->getHistory();
if (history->size()>0)
{
QTableWidgetItem *item = ui->tableWidget->item(0, 1);

View File

@ -9,19 +9,19 @@
<rect>
<x>0</x>
<y>0</y>
<width>385</width>
<width>448</width>
<height>244</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>385</width>
<width>448</width>
<height>244</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>385</width>
<width>529</width>
<height>244</height>
</size>
</property>
@ -35,11 +35,13 @@
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -54,24 +56,9 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>13</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<item alignment="Qt::AlignHCenter">
<widget class="QToolButton" name="toolButtonStandard">
<property name="minimumSize">
<size>
@ -100,8 +87,14 @@
</property>
</widget>
</item>
<item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Use for creation pattern standard measurement table</string>
</property>
@ -114,22 +107,7 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<item alignment="Qt::AlignHCenter">
<widget class="QToolButton" name="toolButtonIndividual">
<property name="minimumSize">
<size>
@ -158,8 +136,14 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Use for creation pattern individual measurements</string>
</property>
@ -173,9 +157,10 @@
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>toolButtonIndividual</tabstop>
<tabstop>toolButtonStandard</tabstop>
</tabstops>
<resources>

View File

@ -52,6 +52,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId,
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
@ -138,10 +139,11 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
const QString toolTip = tr("Select second point of line");
switch (number)
{
case 0:
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of line")))
if (SetObject(id, ui->comboBoxFirstPoint, toolTip))
{
number++;
line->VisualMode(id);
@ -149,6 +151,8 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type)
break;
case 1:
if (SetObject(id, ui->comboBoxSecondPoint, ""))
{
if (flagError)
{
line->setPoint2Id(id);
line->RefreshGeometry();
@ -156,6 +160,11 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type)
this->setModal(true);
this->show();
}
else
{
emit ToolTip(toolTip);
}
}
break;
default:
break;
@ -218,6 +227,7 @@ void DialogAlongLine::setFormula(const QString &value)
}
ui->plainTextEditFormula->setPlainText(formula);
line->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -315,7 +315,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -443,13 +443,22 @@
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHere</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>pushButtonGrowLength</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxFirstPoint</tabstop>
<tabstop>comboBoxSecondPoint</tabstop>
<tabstop>comboBoxLineType</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>

View File

@ -57,6 +57,10 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par
this->formulaBaseHeightF1 = ui->plainTextEditF1->height();
this->formulaBaseHeightF2 = ui->plainTextEditF2->height();
ui->plainTextEditFormula->installEventFilter(this);
ui->plainTextEditF1->installEventFilter(this);
ui->plainTextEditF2->installEventFilter(this);
timerRadius = new QTimer(this);
connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius);
@ -143,6 +147,7 @@ void DialogArc::SetF2(const QString &value)
}
ui->plainTextEditF2->setPlainText(f2);
path->setF2(f2);
MoveCursorToEnd(ui->plainTextEditF2);
}
//---------------------------------------------------------------------------------------------------------------------
@ -160,6 +165,7 @@ void DialogArc::SetF1(const QString &value)
}
ui->plainTextEditF1->setPlainText(f1);
path->setF1(f1);
MoveCursorToEnd(ui->plainTextEditF1);
}
//---------------------------------------------------------------------------------------------------------------------
@ -177,6 +183,7 @@ void DialogArc::SetRadius(const QString &value)
}
ui->plainTextEditFormula->setPlainText(radius);
path->setRadius(radius);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -525,9 +525,6 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>9</number>
</property>
<item>
<widget class="QPlainTextEdit" name="plainTextEditF2">
<property name="sizePolicy">
@ -644,7 +641,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -775,6 +772,16 @@
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHereRadius</tabstop>
<tabstop>toolButtonEqualRadius</tabstop>
<tabstop>pushButtonGrowLength</tabstop>
<tabstop>plainTextEditF1</tabstop>
<tabstop>toolButtonPutHereF1</tabstop>
<tabstop>toolButtonEqualF1</tabstop>
<tabstop>pushButtonGrowLengthF1</tabstop>
<tabstop>toolButtonPutHereF2</tabstop>
<tabstop>toolButtonEqualF2</tabstop>
<tabstop>comboBoxBasePoint</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
@ -783,13 +790,8 @@
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>toolButtonPutHereRadius</tabstop>
<tabstop>toolButtonPutHereF1</tabstop>
<tabstop>toolButtonPutHereF2</tabstop>
<tabstop>toolButtonEqualRadius</tabstop>
<tabstop>toolButtonEqualF1</tabstop>
<tabstop>toolButtonEqualF2</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>

View File

@ -52,6 +52,7 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
@ -157,14 +158,25 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
{
if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle")))
{
number++;
line->setPoint2Id(id);
line->RefreshGeometry();
}
}
break;
case 2:
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstPoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
set.insert(id);
if (set.size() == 3)
{
if (SetObject(id, ui->comboBoxThirdPoint, ""))
{
line->setPoint3Id(id);
@ -173,6 +185,8 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type)
this->setModal(true);
this->show();
}
}
}
break;
default:
break;
@ -219,6 +233,7 @@ void DialogBisector::setFormula(const QString &value)
}
ui->plainTextEditFormula->setPlainText(formula);
line->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -341,7 +341,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -475,14 +475,24 @@
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHere</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>pushButtonGrowLength</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxFirstPoint</tabstop>
<tabstop>comboBoxSecondPoint</tabstop>
<tabstop>comboBoxThirdPoint</tabstop>
<tabstop>comboBoxLineType</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>

View File

@ -48,6 +48,7 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeightAngle = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
@ -120,6 +121,7 @@ void DialogCurveIntersectAxis::setAngle(const QString &value)
}
ui->plainTextEditFormula->setPlainText(formulaAngle);
line->setAngle(formulaAngle);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Curve intersect axis</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
@ -324,7 +324,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -460,6 +460,26 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHereAngle</tabstop>
<tabstop>toolButtonEqualAngle</tabstop>
<tabstop>pushButtonGrowLengthAngle</tabstop>
<tabstop>comboBoxAxisPoint</tabstop>
<tabstop>comboBoxCurve</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxLineType</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>

View File

@ -51,6 +51,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
@ -162,6 +163,7 @@ void DialogCutArc::setFormula(const QString &value)
}
ui->plainTextEditFormula->setPlainText(formula);
path->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -284,7 +284,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -414,6 +414,24 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHere</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>pushButtonGrowLength</tabstop>
<tabstop>comboBoxArc</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>

View File

@ -50,6 +50,7 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
@ -101,6 +102,7 @@ void DialogCutSpline::setFormula(const QString &value)
}
ui->plainTextEditFormula->setPlainText(formula);
path->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -284,7 +284,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -414,6 +414,24 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHere</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>pushButtonGrowLength</tabstop>
<tabstop>comboBoxSpline</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>

View File

@ -50,6 +50,7 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
@ -101,6 +102,7 @@ void DialogCutSplinePath::setFormula(const QString &value)
}
ui->plainTextEditFormula->setPlainText(formula);
path->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -284,7 +284,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -414,6 +414,24 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHere</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>pushButtonGrowLength</tabstop>
<tabstop>comboBoxSplinePath</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>

View File

@ -60,12 +60,18 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-900.990000000000009</double>
</property>
<property name="maximum">
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item>
@ -100,6 +106,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<double>-900.990000000000009</double>
</property>
<property name="maximum">
<double>900.990000000000009</double>
</property>
@ -295,8 +304,14 @@
</layout>
</widget>
<tabstops>
<tabstop>lineEditNameDetail</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>doubleSpinBoxBiasX</tabstop>
<tabstop>doubleSpinBoxBiasY</tabstop>
<tabstop>lineEditNameDetail</tabstop>
<tabstop>checkBoxSeams</tabstop>
<tabstop>doubleSpinBoxSeams</tabstop>
<tabstop>checkBoxClosed</tabstop>
<tabstop>toolButtonDelete</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>

View File

@ -38,6 +38,7 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui
InitVariables(ui);
InitFormulaUI(ui);
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancel(ui);
flagFormula = false;
@ -123,6 +124,7 @@ void DialogEditWrongFormula::setFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -259,7 +259,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -389,6 +389,22 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHere</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>pushButtonGrowLength</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>

View File

@ -55,6 +55,9 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid
this->formulaBaseHeight = ui->plainTextEditFormula->height();
this->formulaBaseHeightAngle = ui->plainTextEditAngle->height();
ui->plainTextEditFormula->installEventFilter(this);
ui->plainTextEditAngle->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
CheckState();
@ -189,6 +192,7 @@ void DialogEndLine::setFormula(const QString &value)
}
ui->plainTextEditFormula->setPlainText(formulaLength);
line->setLength(formulaLength);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------
@ -207,6 +211,7 @@ void DialogEndLine::setAngle(const QString &value)
}
ui->plainTextEditAngle->setPlainText(formulaAngle);
line->setAngle(formulaAngle);
MoveCursorToEnd(ui->plainTextEditAngle);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -495,7 +495,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -632,14 +632,26 @@
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHereLength</tabstop>
<tabstop>toolButtonEqualLength</tabstop>
<tabstop>pushButtonGrowLength</tabstop>
<tabstop>plainTextEditAngle</tabstop>
<tabstop>toolButtonPutHereAngle</tabstop>
<tabstop>toolButtonEqualAngle</tabstop>
<tabstop>pushButtonGrowLengthAngle</tabstop>
<tabstop>comboBoxBasePoint</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxLineType</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>toolButtonEqualLength</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>

View File

@ -151,14 +151,25 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case (1):
if (getCurrentObjectId(ui->comboBoxBasePoint) != id)
{
if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line")))
{
number++;
line->setLineP1Id(id);
line->RefreshGeometry();
}
}
break;
case (2):
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxBasePoint));
set.insert(getCurrentObjectId(ui->comboBoxP1Line));
set.insert(id);
if (set.size() == 3)
{
if (SetObject(id, ui->comboBoxP2Line, ""))
{
line->setLineP2Id(id);
@ -167,6 +178,8 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
this->setModal(true);
this->show();
}
}
}
break;
default:
break;

View File

@ -130,6 +130,14 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxBasePoint</tabstop>
<tabstop>comboBoxP1Line</tabstop>
<tabstop>comboBoxP2Line</tabstop>
<tabstop>comboBoxLineType</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>

View File

@ -145,6 +145,12 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>comboBoxFirstPoint</tabstop>
<tabstop>comboBoxSecondPoint</tabstop>
<tabstop>comboBoxLineType</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>

View File

@ -99,6 +99,8 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxP1Line1) != id)
{
if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line")))
{
number++;
@ -106,6 +108,7 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
line->setLine1P2Id(id);
line->RefreshGeometry();
}
}
break;
case 2:
if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line")))
@ -117,6 +120,15 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 3:
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxP1Line1));
set.insert(getCurrentObjectId(ui->comboBoxP2Line1));
set.insert(getCurrentObjectId(ui->comboBoxP1Line2));
set.insert(id);
if (set.size() >= 3)
{
if (SetObject(id, ui->comboBoxP2Line2, ""))
{
p2Line2 = id;
@ -140,6 +152,8 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::P2Line2Changed);
}
}
}
break;
default:
break;

View File

@ -48,6 +48,7 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const q
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeightAngle = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
@ -65,6 +66,14 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const q
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogLineIntersectAxis::AngleTextChanged);
connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::DeployAngleTextEdit);
connect(timerFormula, &QTimer::timeout, this, &DialogLineIntersectAxis::EvalAngle);
connect(ui->comboBoxFirstLinePoint,
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogLineIntersectAxis::PointNameChanged);
connect(ui->comboBoxSecondLinePoint,
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogLineIntersectAxis::PointNameChanged);
connect(ui->comboBoxAxisPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogLineIntersectAxis::PointNameChanged);
line = new VisToolLineIntersectAxis(data);
}
@ -121,6 +130,7 @@ void DialogLineIntersectAxis::setAngle(const QString &value)
}
ui->plainTextEditFormula->setPlainText(formulaAngle);
line->setAngle(formulaAngle);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------
@ -208,14 +218,25 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case (1):
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) != id)
{
if (SetObject(id, ui->comboBoxSecondLinePoint, tr("Select axis point")))
{
number++;
line->setPoint2Id(id);
line->RefreshGeometry();
}
}
break;
case (2):
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstLinePoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint));
set.insert(id);
if (set.size() == 3)
{
if (SetObject(id, ui->comboBoxAxisPoint, ""))
{
basePointId = id;
@ -223,6 +244,8 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
line->RefreshGeometry();
prepare = true;
}
}
}
break;
default:
break;
@ -255,6 +278,31 @@ void DialogLineIntersectAxis::DeployAngleTextEdit()
DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLengthAngle, formulaBaseHeightAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::PointNameChanged()
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstLinePoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondLinePoint));
set.insert(getCurrentObjectId(ui->comboBoxAxisPoint));
QColor color = okColor;
if (set.size() != 3)
{
flagError = false;
color = errorColor;
}
else
{
flagError = true;
color = okColor;
}
ChangeColor(ui->labelFirstLinePoint, color);
ChangeColor(ui->labelSecondLinePoint, color);
ChangeColor(ui->labelAxisPoint, color);
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::ShowVisualization()
{

View File

@ -70,6 +70,7 @@ public slots:
void EvalAngle();
void AngleTextChanged();
void DeployAngleTextEdit();
virtual void PointNameChanged();
protected:
virtual void ShowVisualization();
/**

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Line intersect axis</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
@ -211,7 +211,7 @@
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="labelAxisPoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -231,7 +231,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="labelFirstLinePoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -251,7 +251,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<widget class="QLabel" name="labelSecondLinePoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -341,7 +341,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -479,9 +479,9 @@
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>pushButtonGrowLengthAngle</tabstop>
<tabstop>toolButtonPutHereAngle</tabstop>
<tabstop>toolButtonEqualAngle</tabstop>
<tabstop>pushButtonGrowLengthAngle</tabstop>
<tabstop>comboBoxAxisPoint</tabstop>
<tabstop>comboBoxFirstLinePoint</tabstop>
<tabstop>comboBoxSecondLinePoint</tabstop>

View File

@ -48,6 +48,7 @@ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidge
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
@ -145,6 +146,8 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
{
if (SetObject(id, ui->comboBoxSecondPoint, ""))
{
line->setPoint2Id(id);
@ -153,6 +156,7 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
this->setModal(true);
this->show();
}
}
break;
default:
break;
@ -229,6 +233,7 @@ void DialogNormal::setFormula(const QString &value)
}
ui->plainTextEditFormula->setPlainText(formula);
line->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -524,7 +524,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -655,15 +655,22 @@
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHere</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>pushButtonGrowLength</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxFirstPoint</tabstop>
<tabstop>comboBoxSecondPoint</tabstop>
<tabstop>doubleSpinBoxAngle</tabstop>
<tabstop>toolButtonArrowRight</tabstop>
<tabstop>toolButtonArrowRightUp</tabstop>
<tabstop>toolButtonArrowUp</tabstop>
<tabstop>toolButtonArrowLeftUp</tabstop>
<tabstop>toolButtonArrowLeft</tabstop>
<tabstop>toolButtonArrowLeftDown</tabstop>
<tabstop>toolButtonArrowDown</tabstop>
<tabstop>toolButtonArrowRightUp</tabstop>
<tabstop>toolButtonArrowRight</tabstop>
<tabstop>toolButtonArrowRightDown</tabstop>
<tabstop>toolButtonArrowDown</tabstop>
<tabstop>toolButtonArrowLeftDown</tabstop>
<tabstop>toolButtonArrowLeft</tabstop>
<tabstop>toolButtonArrowLeftUp</tabstop>
<tabstop>comboBoxLineType</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
@ -671,8 +678,9 @@
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>

View File

@ -50,6 +50,7 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
@ -170,14 +171,25 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
{
if (SetObject(id, ui->comboBoxSecondPoint, tr("Select point of center of arc")))
{
number++;
line->setLineP2Id(id);
line->RefreshGeometry();
}
}
break;
case 2:
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxFirstPoint));
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
set.insert(id);
if (set.size() == 3)
{
if (SetObject(id, ui->comboBoxCenter, ""))
{
line->setRadiusId(id);
@ -186,6 +198,8 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type)
this->setModal(true);
this->show();
}
}
}
break;
default:
break;
@ -259,6 +273,7 @@ void DialogPointOfContact::setRadius(const QString &value)
}
ui->plainTextEditFormula->setPlainText(radius);
line->setRadius(radius);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -357,7 +357,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -488,14 +488,23 @@
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHere</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>pushButtonGrowLength</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxCenter</tabstop>
<tabstop>comboBoxFirstPoint</tabstop>
<tabstop>comboBoxSecondPoint</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>

View File

@ -104,6 +104,8 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
{
if (SetObject(id, ui->comboBoxSecondPoint, ""))
{
line->setPoint2Id(id);
@ -112,6 +114,7 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type
this->setModal(true);
this->show();
}
}
break;
default:
break;

View File

@ -103,6 +103,12 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxFirstPoint</tabstop>
<tabstop>comboBoxSecondPoint</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>

View File

@ -52,6 +52,7 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
labelEditNamePoint = ui->labelEditNamePoint;
this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this);
InitOkCancelApply(ui);
flagFormula = false;
@ -156,14 +157,25 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 1:
if (getCurrentObjectId(ui->comboBoxP3) != id)
{
if (SetObject(id, ui->comboBoxP1Line, tr("Select second point of line")))
{
number++;
line->setLineP1Id(id);
line->RefreshGeometry();
}
}
break;
case 2:
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxP3));
set.insert(getCurrentObjectId(ui->comboBoxP1Line));
set.insert(id);
if (set.size() == 3)
{
if (SetObject(id, ui->comboBoxP2Line, ""))
{
line->setLineP2Id(id);
@ -172,6 +184,8 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type)
this->setModal(true);
this->show();
}
}
}
break;
default:
break;
@ -247,6 +261,7 @@ void DialogShoulderPoint::setFormula(const QString &value)
}
ui->plainTextEditFormula->setPlainText(formula);
line->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -380,7 +380,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Standard table</string>
<string>Measurements</string>
</property>
</widget>
</item>
@ -511,14 +511,24 @@
</layout>
</widget>
<tabstops>
<tabstop>plainTextEditFormula</tabstop>
<tabstop>toolButtonPutHere</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>pushButtonGrowLength</tabstop>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxP1Line</tabstop>
<tabstop>comboBoxP2Line</tabstop>
<tabstop>comboBoxP3</tabstop>
<tabstop>comboBoxLineType</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop>
<tabstop>radioButtonLengthLine</tabstop>
<tabstop>radioButtonLengthArc</tabstop>
<tabstop>radioButtonLengthSpline</tabstop>
<tabstop>radioButtonAngleLine</tabstop>
<tabstop>checkBoxHideEmpty</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>toolButtonEqual</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>

View File

@ -96,6 +96,8 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 1:
{
if (getCurrentObjectId(ui->comboBoxP1) != id)
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(id);
qint32 index = ui->comboBoxP4->findText(point->name());
@ -121,6 +123,7 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type)
{
qWarning()<<"Can't find object by name"<<point->name();
}
}
break;
}
default:

View File

@ -210,10 +210,10 @@
</widget>
<tabstops>
<tabstop>comboBoxP1</tabstop>
<tabstop>comboBoxP4</tabstop>
<tabstop>doubleSpinBoxKasm1</tabstop>
<tabstop>doubleSpinBoxKasm2</tabstop>
<tabstop>spinBoxAngle1</tabstop>
<tabstop>comboBoxP4</tabstop>
<tabstop>doubleSpinBoxKasm2</tabstop>
<tabstop>spinBoxAngle2</tabstop>
<tabstop>doubleSpinBoxKcurve</tabstop>
<tabstop>buttonBox</tabstop>

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Curve path</string>
<string>Curved path</string>
</property>
<property name="windowIcon">
<iconset resource="../../share/resources/icon.qrc">
@ -203,8 +203,8 @@
<tabstop>doubleSpinBoxAngle1</tabstop>
<tabstop>doubleSpinBoxKasm2</tabstop>
<tabstop>doubleSpinBoxAngle2</tabstop>
<tabstop>doubleSpinBoxKcurve</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>doubleSpinBoxKcurve</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>

View File

@ -388,9 +388,40 @@ void DialogTool::PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidg
QTextCursor cursor = plainTextEdit->textCursor();
cursor.insertText(item->text());
plainTextEdit->setTextCursor(cursor);
plainTextEdit->setFocus();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit)
{
SCASSERT(plainTextEdit != nullptr);
QTextCursor cursor = plainTextEdit->textCursor();
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
plainTextEdit->setTextCursor(cursor);
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogTool::eventFilter(QObject *object, QEvent *event)
{
QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(object);
if (plainTextEdit != nullptr)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if ((keyEvent->key() == Qt::Key_Enter) || (keyEvent->key() == Qt::Key_Return))
{
// Ignore Enter key
return true;
}
}
else
{
// pass the event on to the parent class
return QDialog::eventFilter(object, event);
}
return false;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ValFormulaChanged handle change formula
@ -701,7 +732,10 @@ void DialogTool::NamePointChanged()
{
QString name = edit->text();
name.replace(" ", "");
if (name.isEmpty() || (pointName != name && data->IsUnique(name) == false))
QRegExpValidator v(QRegExp(nameRegExp), this);
int pos = 0;
if (name.isEmpty() || (pointName != name && data->IsUnique(name) == false) ||
v.validate(name, pos) == QValidator::Invalid)
{
flagName = false;
ChangeColor(labelEditNamePoint, Qt::red);

View File

@ -333,6 +333,8 @@ protected:
* @brief SaveData Put dialog data in local variables
*/
virtual void SaveData(){}
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit);
bool eventFilter(QObject *object, QEvent *event);
private:
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
};

View File

@ -98,22 +98,44 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case (1):
if (getCurrentObjectId(ui->comboBoxAxisP1) != id)
{
if (SetObject(id, ui->comboBoxAxisP2, tr("Select first point")))
{
number++;
line->setPoint2Id(id);
line->RefreshGeometry();
}
}
break;
case (2):
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxAxisP1));
set.insert(getCurrentObjectId(ui->comboBoxAxisP2));
set.insert(id);
if (set.size() == 3)
{
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point")))
{
number++;
line->setHypotenuseP1Id(id);
line->RefreshGeometry();
}
}
}
break;
case (3):
{
QSet<quint32> set;
set.insert(getCurrentObjectId(ui->comboBoxAxisP1));
set.insert(getCurrentObjectId(ui->comboBoxAxisP2));
set.insert(getCurrentObjectId(ui->comboBoxFirstPoint));
set.insert(id);
if (set.size() == 4)
{
if (SetObject(id, ui->comboBoxSecondPoint, ""))
{
line->setHypotenuseP2Id(id);
@ -122,6 +144,8 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type)
this->setModal(true);
this->show();
}
}
}
break;
default:
break;

View File

@ -133,6 +133,14 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>lineEditNamePoint</tabstop>
<tabstop>comboBoxAxisP1</tabstop>
<tabstop>comboBoxAxisP2</tabstop>
<tabstop>comboBoxFirstPoint</tabstop>
<tabstop>comboBoxSecondPoint</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>

View File

@ -55,6 +55,9 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources>
<include location="../../share/resources/icon.qrc"/>
</resources>

View File

@ -60,6 +60,6 @@ VExceptionConversionError::~VExceptionConversionError() V_NOEXCEPT_EXPR (true)
*/
QString VExceptionConversionError::ErrorMessage() const
{
QString error = QString("ExceptionConversionError: %1 %2").arg(what, str);
QString error = QString("ExceptionConversionError: %1 \"%2\"").arg(what, str);
return error;
}

View File

@ -33,6 +33,7 @@
#include <QPointF>
#include <QRectF>
#include <QtCore/qmath.h>
#include <climits>
//---------------------------------------------------------------------------------------------------------------------
/**
@ -183,25 +184,32 @@ QLineF VGObject::BuildLine(const QPointF &p1, const qreal &length, const qreal &
{
QLineF line = QLineF();
line.setP1(p1);
line.setAngle(angle);// First set angle than length. Length can have negative value.
line.setLength(length);
line.setAngle(angle);
return line;
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VGObject::BuildRay(const QPointF &firstPoint, const qreal &angle, const QRectF &scRect)
{
qreal diagonal = qSqrt(pow(scRect.height(), 2) + pow(scRect.width(), 2));
QLineF line = BuildLine(firstPoint, diagonal, angle);
QRectF rect = scRect;
if (rect.contains(firstPoint) == false)
{
// If point outside of scene rect use the biggest rect that can be.
QRectF rectangle(INT_MIN, INT_MIN, INT_MAX, INT_MAX);
rect = rect.united(rectangle);
}
const qreal diagonal = qSqrt(pow(rect.height(), 2) + pow(rect.width(), 2));
const QLineF line = BuildLine(firstPoint, diagonal, angle);
return LineIntersectRect(scRect, line);
return LineIntersectRect(rect, line);
}
//---------------------------------------------------------------------------------------------------------------------
QLineF VGObject::BuildAxis(const QPointF &p, const qreal &angle, const QRectF &scRect)
{
QPointF endP1 = BuildRay(p, angle+180, scRect);
QPointF endP2 = BuildRay(p, angle, scRect);
const QPointF endP1 = BuildRay(p, angle+180, scRect);
const QPointF endP2 = BuildRay(p, angle, scRect);
return QLineF(endP1, endP2);
}
@ -219,7 +227,7 @@ QLineF VGObject::BuildAxis(const QPointF &p1, const QPointF &p2, const QRectF &s
* @param line line.
* @return point intersection.
*/
QPointF VGObject::LineIntersectRect(QRectF rec, QLineF line)
QPointF VGObject::LineIntersectRect(const QRectF &rec, const QLineF &line)
{
qreal x1, y1, x2, y2;
rec.getCoords(&x1, &y1, &x2, &y2);
@ -244,7 +252,6 @@ QPointF VGObject::LineIntersectRect(QRectF rec, QLineF line)
{
return point;
}
Q_ASSERT_X(type != QLineF::BoundedIntersection, Q_FUNC_INFO, "There is no point of intersection.");
return point;
}

View File

@ -71,7 +71,7 @@ public:
static QLineF BuildAxis(const QPointF &p, const qreal &angle, const QRectF &scRect);
static QLineF BuildAxis(const QPointF &p1, const QPointF &p2, const QRectF &scRect);
static QPointF LineIntersectRect(QRectF rec, QLineF line);
static QPointF LineIntersectRect(const QRectF &rec, const QLineF &line);
static qint32 LineIntersectCircle(const QPointF &center, qreal radius, const QLineF &line, QPointF &p1,
QPointF &p2);
static QPointF ClosestPoint(const QLineF &line, const QPointF &point);

View File

@ -133,6 +133,7 @@ int main(int argc, char *argv[])
QT_REQUIRE_VERSION(argc, argv, "5.0.2");
VApplication app(argc, argv);
#ifdef QT_DEBUG
// Because our "noisy" message handler uses the GUI subsystem for message
// boxes, we can't install it until after the QApplication is constructed. But it
@ -150,6 +151,11 @@ int main(int argc, char *argv[])
app.OpenSettings();
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
VApplication::DrMingw();
app.CollectReports();
#endif
QString checkedLocale = qApp->getSettings()->value("configuration/locale", QLocale::system().name()).toString();
QTranslator qtTranslator;
@ -187,12 +193,12 @@ int main(int argc, char *argv[])
parser.addVersionOption();
parser.addPositionalArgument("filename", QCoreApplication::translate("main", "Pattern file."));
parser.process(app);
const QStringList args = parser.positionalArguments();
QStringList args = parser.positionalArguments();
//Before we load pattern show window.
w.show();
w.ReopenFilesAfterCrash();
w.ReopenFilesAfterCrash(args);
for (int i=0;i<args.size();++i)
{

View File

@ -58,6 +58,7 @@
#include <QTimer>
#include <QtGlobal>
#include <QDesktopWidget>
#include <QDesktopServices>
//---------------------------------------------------------------------------------------------------------------------
/**
@ -114,6 +115,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);
connect(doc, &VPattern::SetCurrentPP, this, &MainWindow::GlobalChangePP);
qApp->setCurrentDocument(doc);
connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified);
@ -164,6 +166,17 @@ void MainWindow::ActionNewPP()
}
else
{
QMessageBox::StandardButton ret;
ret = QMessageBox::question(this, tr("Individual measurements is under development"),
tr("There is no way create individual measurements file independent on the "
"pattern file.\nFor opening pattern need keep both files: pattern and "
"measurements. Do you want continue?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (ret == QMessageBox::No)
{
return;
}
qApp->setPatternType(MeasurementsType::Individual);
DialogIndividualMeasurements indMeasurements(pattern, patternPieceName, this);
if (indMeasurements.exec() == QDialog::Accepted)
@ -723,7 +736,6 @@ void MainWindow::ShowToolTip(const QString &toolTip)
void MainWindow::tableClosed()
{
show();
MinimumScrollBar();
}
//---------------------------------------------------------------------------------------------------------------------
@ -785,19 +797,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
{
if (MaybeSave())
{
WriteSettings();
//File was closed correct.
QStringList restoreFiles = qApp->getSettings()->value("restoreFileList").toStringList();
restoreFiles.removeAll(curFile);
qApp->getSettings()->setValue("restoreFileList", restoreFiles);
// Remove autosave file
QFile autofile(curFile +".autosave");
if (autofile.exists())
{
autofile.remove();
}
FileClosedCorrect();
event->accept();
qApp->closeAllWindows();
@ -1374,12 +1374,22 @@ void MainWindow::Preferences()
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::RepotBug()
{
QDesktopServices::openUrl(QUrl("https://bitbucket.org/dismine/valentina/issues/new"));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Clear reset to default window.
*/
void MainWindow::Clear()
{
ui->actionDetails->setChecked(false);
ui->actionDetails->setEnabled(false);
ui->actionDraw->setChecked(true);
ui->actionDraw->setEnabled(false);
setCurrentFile("");
pattern->Clear();
doc->clear();
@ -1389,9 +1399,15 @@ void MainWindow::Clear()
comboBoxDraws->clear();
ui->actionOptionDraw->setEnabled(false);
ui->actionSave->setEnabled(false);
ui->actionSaveAs->setEnabled(false);
ui->actionPattern_properties->setEnabled(false);
ui->actionZoomIn->setEnabled(false);
ui->actionZoomOut->setEnabled(false);
ui->actionZoomFitBest->setEnabled(false);
ui->actionZoomOriginal->setEnabled(false);
ui->actionHistory->setEnabled(false);
ui->actionTable->setEnabled(false);
ui->actionEdit_pattern_code->setEnabled(false);
SetEnableTool(false);
qApp->setPatternUnit(Unit::Cm);
qApp->setPatternType(MeasurementsType::Individual);
@ -1404,9 +1420,42 @@ void MainWindow::Clear()
#ifdef Q_OS_WIN32
qt_ntfs_permission_lookup--; // turn it off again
#endif /*Q_OS_WIN32*/
qApp->getUndoStack()->clear();
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::FileClosedCorrect()
{
WriteSettings();
//File was closed correct.
QStringList restoreFiles = qApp->getSettings()->value("restoreFileList").toStringList();
restoreFiles.removeAll(curFile);
qApp->getSettings()->setValue("restoreFileList", restoreFiles);
// Remove autosave file
QFile autofile(curFile +".autosave");
if (autofile.exists())
{
autofile.remove();
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ResetWindow()
{
if (MaybeSave())
{
FileClosedCorrect();
}
else
{
return;
}
Clear();
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::FullParseFile()
{
toolOptions->ClearPropertyBrowser();
@ -1478,7 +1527,23 @@ void MainWindow::FullParseFile()
comboBoxDraws->blockSignals(false);
ui->actionPattern_properties->setEnabled(true);
qint32 index = comboBoxDraws->findText(patternPiece);
GlobalChangePP(patternPiece);
if (comboBoxDraws->count() > 0)
{
SetEnableTool(true);
}
else
{
SetEnableTool(false);
}
SetEnableWidgets(true);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::GlobalChangePP(const QString &patternPiece)
{
const qint32 index = comboBoxDraws->findText(patternPiece);
try
{
if ( index != -1 )
@ -1502,19 +1567,8 @@ void MainWindow::FullParseFile()
SetEnabledGUI(false);
return;
}
if (comboBoxDraws->count() > 0)
{
SetEnableTool(true);
}
else
{
SetEnableTool(false);
}
SetEnableWidgets(true);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::SetEnabledGUI(bool enabled)
{
@ -1522,7 +1576,8 @@ void MainWindow::SetEnabledGUI(bool enabled)
{
if (enabled == false)
{
CancelTool();
ArrowTool();
qApp->getUndoStack()->clear();
}
comboBoxDraws->setEnabled(enabled);
ui->actionOptionDraw->setEnabled(enabled);
@ -1538,6 +1593,9 @@ void MainWindow::SetEnabledGUI(bool enabled)
ui->actionDraw->setEnabled(enabled);
ui->actionDetails->setEnabled(enabled);
ui->actionTable->setEnabled(enabled);
ui->actionLayout->setEnabled(enabled);
ui->actionZoomFitBest->setEnabled(enabled);
ui->actionZoomOriginal->setEnabled(enabled);
guiEnabled = enabled;
sceneDraw->SetDisable(!enabled);
@ -1741,6 +1799,7 @@ void MainWindow::ActionHistory(bool checked)
{
dialogHistory = new DialogHistory(pattern, doc, this);
dialogHistory->setWindowFlags(Qt::Window);
connect(this, &MainWindow::RefreshHistory, dialogHistory, &DialogHistory::UpdateHistory);
connect(dialogHistory, &DialogHistory::DialogClosed, this, &MainWindow::ClosedActionHistory);
dialogHistory->show();
}
@ -1856,7 +1915,6 @@ bool MainWindow::SavePattern(const QString &fileName)
{
setCurrentFile(fileName);
helpLabel->setText(tr("File saved"));
qApp->getUndoStack()->clear();
}
}
else
@ -2103,9 +2161,11 @@ void MainWindow::CreateActions()
connect(ui->actionAbout_Valentina, &QAction::triggered, this, &MainWindow::About);
connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close);
connect(ui->actionPreferences, &QAction::triggered, this, &MainWindow::Preferences);
connect(ui->actionRepotBug, &QAction::triggered, this, &MainWindow::RepotBug);
connect(ui->actionPattern_properties, &QAction::triggered, this, &MainWindow::PatternProperties);
ui->actionPattern_properties->setEnabled(false);
connect(ui->actionEdit_pattern_code, &QAction::triggered, this, &MainWindow::EditPatternCode);
connect(ui->actionCloseWindow, &QAction::triggered, this, &MainWindow::ResetWindow);
ui->actionEdit_pattern_code->setEnabled(false);
//Actions for recent files loaded by a main window application.
@ -2254,6 +2314,8 @@ void MainWindow::LoadPattern(const QString &fileName)
FullParseFile();
if (guiEnabled)
{ // No errors occurred
bool patternModified = this->isWindowModified();
setCurrentFile(fileName);
if (patternModified)
@ -2267,10 +2329,13 @@ void MainWindow::LoadPattern(const QString &fileName)
//Fit scene size to best size for first show
ZoomFirstShow();
ui->actionDraw->setChecked(true);
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ReopenFilesAfterCrash()
void MainWindow::ReopenFilesAfterCrash(QStringList &args)
{
QStringList files = qApp->getSettings()->value("restoreFileList").toStringList();
if (files.size() > 0)
@ -2304,6 +2369,7 @@ void MainWindow::ReopenFilesAfterCrash()
QFile autoFile(restoreFiles.at(i) +".autosave");
autoFile.remove();
LoadPattern(restoreFiles.at(i));
args.removeAll(restoreFiles.at(i));// Do not open file twice after we restore him.
}
else
{
@ -2389,6 +2455,7 @@ void MainWindow::ChangePP(int index, bool zoomBestFit)
{
doc->ChangeActivPP(comboBoxDraws->itemText(index));
doc->setCurrentData();
emit RefreshHistory();
if (drawMode)
{
ArrowTool();

View File

@ -56,7 +56,7 @@ public:
explicit MainWindow(QWidget *parent = nullptr);
virtual ~MainWindow();
void LoadPattern(const QString &curFile);
void ReopenFilesAfterCrash();
void ReopenFilesAfterCrash(QStringList &args);
public slots:
void mouseMove(const QPointF &scenePos);
void ArrowTool();
@ -76,10 +76,12 @@ public slots:
bool Save();
void Open();
void Preferences();
void RepotBug();
void NewPattern();
void ShowToolTip(const QString &toolTip);
void OpenRecentFile();
void Clear();
void ResetWindow();
void currentPPChanged(int index);
void OptionDraw();
@ -126,6 +128,7 @@ public slots:
void ClickEndVisualization();
void Layout();
void UpdateGradation();
void GlobalChangePP(const QString &patternPiece);
signals:
/**
* @brief ModelChosen emit after calculation all details.
@ -133,6 +136,7 @@ signals:
* @param description pattern description.
*/
void ModelChosen(QVector<VItem*> listDetails, const QString &curFile, const QString &description);
void RefreshHistory();
protected:
virtual void keyPressEvent(QKeyEvent *event);
virtual void showEvent(QShowEvent *event);
@ -253,6 +257,7 @@ private:
void AddDocks();
void PropertyBrowser();
void OpenNewValentina(const QString &fileName = QString())const;
void FileClosedCorrect();
};
#endif // MAINWINDOW_H

View File

@ -779,6 +779,7 @@
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="actionRepotBug"/>
<addaction name="actionAbout_Qt"/>
<addaction name="actionAbout_Valentina"/>
</widget>
@ -803,9 +804,16 @@
</property>
<addaction name="actionTable"/>
</widget>
<widget class="QMenu" name="menuWindow">
<property name="title">
<string>Window</string>
</property>
<addaction name="actionCloseWindow"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuPatternPiece"/>
<addaction name="menuMeasurements"/>
<addaction name="menuWindow"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
@ -1229,7 +1237,9 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset theme="process-stop"/>
<iconset theme="process-stop">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Stop</string>
@ -1238,6 +1248,19 @@
<string>Stop using tool</string>
</property>
</action>
<action name="actionRepotBug">
<property name="text">
<string>Repot Bug...</string>
</property>
<property name="toolTip">
<string>Report bug</string>
</property>
</action>
<action name="actionCloseWindow">
<property name="text">
<string>Close window</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

View File

@ -31,7 +31,7 @@
#include <QStringList>
//Same regexp in pattern.xsd shema file. Don't forget synchronize.
const QString nameRegExp = QStringLiteral("^([^0-9-*/^+=\\s\\(\\)%:;!.,]){1,1}([^-*/^+=\\s\\(\\)%:;!.,]){0,}$");
const QString nameRegExp = QStringLiteral("^([^0-9-*/^+=\\s\\(\\)%:;!.,`'\"]){1,1}([^-*/^+=\\s\\(\\)%:;!.,`'\"]){0,}$");
// From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This
// furthermore blows up the binary sizes.

View File

@ -51,6 +51,7 @@ static const quint32 null_id = 0;
#define SceneSize 50000
#define DefPointRadius 2.0//mm
#define NULL_ID null_id//use this value for initialization variables that keeps id values. 0 mean uknown id value.
#define NULL_ID_STR "0"
extern const QString nameRegExp;
extern const QString degreeSymbol;

View File

@ -98,7 +98,7 @@
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="name" type="shortName"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="thirdPoint" type="xs:unsignedInt"></xs:attribute>
@ -267,7 +267,7 @@
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="^([^0-9-*/^+=\s\(\)%:;!.,]){1,1}([^-*/^+=\s\(\)%:;!.,]){0,}$"/>
<xs:pattern value="^([^0-9-*/^+=\s\(\)%:;!.,`'\&quot;]){1,1}([^-*/^+=\s\(\)%:;!.,`'\&quot;]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -54,23 +54,7 @@
#endif
//In Windows you can't use same header in all modes.
#if defined(Q_OS_WIN)
# if defined(QT_NO_DEBUG)//release mode
# ifdef QT_WIDGETS_LIB
# include <QtWidgets>
# endif
# ifdef QT_SVG_LIB
# include <QtSvg/QtSvg>
# endif
# ifdef QT_PRINTSUPPORT_LIB
# include <QtPrintSupport>
# endif
# endif/*QT_NO_DEBUG*/
#else
#if !defined(Q_OS_WIN)
# ifdef QT_WIDGETS_LIB
# include <QtWidgets>
# endif

View File

@ -171,16 +171,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
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(), spl2.GetKasm1(),
// spl1.GetAngle2());
// }
// else
// {
cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl2.GetKasm1(),
spl1.GetAngle2()+180);
// }
cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl2.GetKasm1(), spl1.GetAngle2()+180);
splPath1->append(cutPoint);
continue;
}
@ -200,6 +191,8 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
splPath2->append(splPath->at(i));
}
}
splPath1->setKCurve(splPath->getKCurve());
splPath2->setKCurve(splPath->getKCurve());
splPath1->setMaxCountPoints(splPath->CountPoint());
splPath2->setMaxCountPoints(splPath->CountPoint());

View File

@ -142,8 +142,8 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y()));
line.setAngle(CheckFormula(_id, formulaAngle, data)); //First set angle.
line.setLength(qApp->toPixel(CheckFormula(_id, formulaLength, data)));
line.setAngle(CheckFormula(_id, formulaAngle, data));
quint32 id = _id;
if (typeCreation == Source::FromGui)
{

View File

@ -470,8 +470,8 @@ void VToolLine::RefreshGeometry()
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
firstPoint = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
secondPoint = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
firstPoint = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR);
secondPoint = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR);
typeLine = doc->GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine);
}
const QSharedPointer<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(firstPoint);

View File

@ -281,8 +281,8 @@ void VToolDetail::AddToFile()
doc->SetAttribute(domElement, AttrName, detail.getName());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(detail.getMx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(detail.getMy()));
doc->SetAttribute(domElement, AttrSupplement, detail.getSeamAllowance());
doc->SetAttribute(domElement, AttrClosed, detail.getClosed());
doc->SetAttribute(domElement, AttrSupplement, static_cast<quint8>(detail.getSeamAllowance()));
doc->SetAttribute(domElement, AttrClosed, static_cast<quint8>(detail.getClosed()));
doc->SetAttribute(domElement, AttrWidth, detail.getWidth());
for (int i = 0; i < detail.CountNode(); ++i)
@ -306,8 +306,8 @@ void VToolDetail::RefreshDataInFile()
{
VDetail det = VAbstractTool::data.GetDetail(id);
doc->SetAttribute(domElement, AttrName, det.getName());
doc->SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance()));
doc->SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed()));
doc->SetAttribute(domElement, AttrSupplement, QString().setNum(static_cast<quint8>(det.getSeamAllowance())));
doc->SetAttribute(domElement, AttrClosed, QString().setNum(static_cast<quint8>(det.getClosed())));
doc->SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth()));
doc->RemoveAllChild(domElement);
for (int i = 0; i < det.CountNode(); ++i)
@ -399,8 +399,8 @@ void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
QMenu menu;
QAction *actionOption = menu.addAction(tr("Options"));
QAction *actionRemove = menu.addAction(tr("Delete"));
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
if (_referens > 1)
{
actionRemove->setEnabled(false);

View File

@ -691,7 +691,7 @@ QVector<VDetail> VToolUnionDetails::GetDetailFromFile(VPattern *doc, const QDomE
{
if (element.tagName() == VToolUnionDetails::TagNode)
{
quint32 id = doc->GetParametrUInt(element, VToolDetail::AttrIdObject, "0");
quint32 id = doc->GetParametrUInt(element, VToolDetail::AttrIdObject, NULL_ID_STR);
qreal mx = qApp->toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMx, "0.0"));
qreal my = qApp->toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMy, "0.0"));
Tool tool = Tool::NodePoint;

View File

@ -48,7 +48,7 @@ AddToCalc::~AddToCalc()
//---------------------------------------------------------------------------------------------------------------------
void AddToCalc::undo()
{
doc->ChangeActivPP(nameActivDraw);
doc->ChangeActivPP(nameActivDraw);//User will not see this change
doc->setCursor(cursor);
QDomElement calcElement;
@ -80,12 +80,13 @@ void AddToCalc::undo()
}
emit NeedFullParsing();
VAbstractTool::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
}
//---------------------------------------------------------------------------------------------------------------------
void AddToCalc::redo()
{
doc->ChangeActivPP(nameActivDraw);
doc->ChangeActivPP(nameActivDraw);//User will not see this change
doc->setCursor(cursor);
QDomElement calcElement;
@ -118,3 +119,14 @@ void AddToCalc::redo()
RedoFullParsing();
VAbstractTool::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
}
//---------------------------------------------------------------------------------------------------------------------
void AddToCalc::RedoFullParsing()
{
if (redoFlag)
{
emit NeedFullParsing();
doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
}
redoFlag = true;
}

View File

@ -39,6 +39,8 @@ public:
virtual ~AddToCalc();
virtual void undo();
virtual void redo();
protected:
virtual void RedoFullParsing();
private:
Q_DISABLE_COPY(AddToCalc)
const QString nameActivDraw;

View File

@ -32,7 +32,7 @@
//---------------------------------------------------------------------------------------------------------------------
DeleteDetail::DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode())
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), siblingId(NULL_ID)
{
setText(tr("Delete tool"));
nodeId = id;
@ -41,6 +41,16 @@ DeleteDetail::DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent)
{
xml = domElement.cloneNode().toElement();
parentNode = domElement.parentNode();
QDomNode previousDetail = domElement.previousSibling();
if (previousDetail.isNull())
{
siblingId = NULL_ID;
}
else
{
// Better save id of previous detail instead of reference to node.
siblingId = doc->GetParametrUInt(previousDetail.toElement(), VPattern::AttrId, NULL_ID_STR);
}
}
else
{
@ -56,7 +66,7 @@ DeleteDetail::~DeleteDetail()
//---------------------------------------------------------------------------------------------------------------------
void DeleteDetail::undo()
{
parentNode.appendChild(xml);
UndoDeleteAfterSibling(parentNode, siblingId);
emit NeedFullParsing();
}
@ -68,14 +78,15 @@ void DeleteDetail::redo()
{
parentNode.removeChild(domElement);
//When UnionDetail delete detail we can't use FullParsing. So we hide detail on scene directly.
// UnionDetails delete two old details and create one new.
// So when UnionDetail delete detail we can't use FullParsing. So we hide detail on scene directly.
QHash<quint32, VDataTool*>* tools = doc->getTools();
SCASSERT(tools != nullptr);
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(nodeId));
SCASSERT(toolDet != nullptr);
toolDet->hide();
emit NeedFullParsing();
emit NeedFullParsing(); // Doesn't work when UnionDetail delete detail.
}
else
{

View File

@ -43,6 +43,7 @@ public:
private:
Q_DISABLE_COPY(DeleteDetail)
QDomNode parentNode;
quint32 siblingId;
};
#endif // DELETEDETAIL_H

View File

@ -33,21 +33,14 @@
//---------------------------------------------------------------------------------------------------------------------
DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), cursor(doc->getCursor())
: VUndoCommand(QDomElement(), doc, parent), parentNode(QDomNode()), siblingId(NULL_ID),
nameActivDraw(doc->GetNameActivPP())
{
setText(tr("Delete tool"));
nodeId = id;
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
xml = domElement.cloneNode().toElement();
parentNode = domElement.parentNode();
}
else
{
qDebug()<<"Can't get tool by id = "<<nodeId<<Q_FUNC_INFO;
return;
}
siblingId = doc->SiblingNodeId(nodeId);
parentNode = doc->ParentNodeById(nodeId);
xml = doc->CloneNodeById(nodeId);
}
//---------------------------------------------------------------------------------------------------------------------
@ -57,33 +50,16 @@ DelTool::~DelTool()
//---------------------------------------------------------------------------------------------------------------------
void DelTool::undo()
{
if (cursor <= 0)
{
parentNode.appendChild(xml);
}
else
{
QDomElement refElement = doc->elementById(QString().setNum(cursor));
if (refElement.isElement())
{
parentNode.insertAfter(xml, refElement);
}
}
UndoDeleteAfterSibling(parentNode, siblingId);
emit NeedFullParsing();
doc->SetCurrentPP(nameActivDraw);
}
//---------------------------------------------------------------------------------------------------------------------
void DelTool::redo()
{
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
if (domElement.isElement())
{
QDomElement domElement = doc->NodeById(nodeId);
parentNode.removeChild(domElement);
emit NeedFullParsing();
}
else
{
qDebug()<<"Can't get tool by id = "<<nodeId<<Q_FUNC_INFO;
return;
}
doc->SetCurrentPP(nameActivDraw);
}

View File

@ -43,7 +43,8 @@ public:
private:
Q_DISABLE_COPY(DelTool)
QDomNode parentNode;
quint32 cursor;
quint32 siblingId;
const QString nameActivDraw;
};
#endif // DELTOOL_H

View File

@ -49,3 +49,17 @@ void VUndoCommand::RedoFullParsing()
}
redoFlag = true;
}
//---------------------------------------------------------------------------------------------------------------------
void VUndoCommand::UndoDeleteAfterSibling(QDomNode &parentNode, const quint32 &siblingId) const
{
if (siblingId == NULL_ID)
{
parentNode.appendChild(xml);
}
else
{
const QDomElement refElement = doc->NodeById(siblingId);
parentNode.insertAfter(xml, refElement);
}
}

View File

@ -64,7 +64,8 @@ protected:
VPattern *doc;
quint32 nodeId;
bool redoFlag;
void RedoFullParsing();
virtual void RedoFullParsing();
void UndoDeleteAfterSibling(QDomNode &parentNode, const quint32 &siblingId) const;
private:
Q_DISABLE_COPY(VUndoCommand)
};

View File

@ -37,7 +37,6 @@ extern const int DEBUG_VERSION;
extern const QString APP_VERSION;
// Don't forget change version number in manifest file /src/app/share/resources/valentina.exe.manifest.
// Change version number in version.cpp also.
#define VER_FILEVERSION 0,2,8,0

View File

@ -61,6 +61,7 @@ void VisToolCutSplinePath::RefreshGeometry()
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
qint32 p1 = 0, p2 = 0;
// TODO make refactoring. CutSplPath repeat twice. Here and in VToolCutSpline.
const QPointF cutPoint = splPath->CutSplinePath(length, p1, p2, spl1p2, spl1p3, spl2p2, spl2p3);
VPointF p = VPointF(cutPoint);
@ -103,6 +104,9 @@ void VisToolCutSplinePath::RefreshGeometry()
}
}
spPath1.setKCurve(splPath->getKCurve());
spPath2.setKCurve(splPath->getKCurve());
DrawPoint(point, cutPoint, mainColor);
DrawPath(splPath1, spPath1.GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap);

View File

@ -62,7 +62,7 @@ VItem::VItem(int numInList, QGraphicsItem *parent):QGraphicsPathItem (parent), n
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief checkItemChange change item change. If detail create colission or moved out paper emit signal.
* @brief checkItemChange check item change. If detail create colission or moved out paper emit signal.
*/
void VItem::checkItemChange()
{

View File

@ -600,3 +600,28 @@ void VDomDocument::RemoveAllChild(QDomElement &domElement)
}
}
}
//---------------------------------------------------------------------------------------------------------------------
QDomNode VDomDocument::ParentNodeById(const quint32 &nodeId)
{
QDomElement domElement = NodeById(nodeId);
return domElement.parentNode();
}
//---------------------------------------------------------------------------------------------------------------------
QDomElement VDomDocument::CloneNodeById(const quint32 &nodeId)
{
QDomElement domElement = NodeById(nodeId);
return domElement.cloneNode().toElement();
}
//---------------------------------------------------------------------------------------------------------------------
QDomElement VDomDocument::NodeById(const quint32 &nodeId)
{
QDomElement domElement = elementById(QString().setNum(nodeId));
if (domElement.isNull() || domElement.isElement() == false)
{
throw VExceptionBadId(tr("Couldn't get node"), nodeId);
}
return domElement;
}

View File

@ -109,6 +109,10 @@ public:
QString Minor() const;
QString Patch() const;
static void RemoveAllChild(QDomElement &domElement);
QDomNode ParentNodeById(const quint32 &nodeId);
QDomElement CloneNodeById(const quint32 &nodeId);
QDomElement NodeById(const quint32 &nodeId);
protected:
/** @brief data container with data. */
VContainer *data;

View File

@ -211,6 +211,7 @@ bool VPattern::GetActivDrawElement(QDomElement &element) const
}
}
}
element = QDomElement();
}
return false;
}
@ -365,16 +366,18 @@ void VPattern::Parse(const Document &parse)
*/
VDataTool *VPattern::getTool(const quint32 &id)
{
if (tools.contains(id))
{
ToolExists(id);
return tools.value(id);
}
else
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ToolExists(const quint32 &id) const
{
if (tools.contains(id) == false)
{
const QString error = QString(tr("Can't find tool id = %1 in table.")).arg(id);
throw VException(error);
throw VExceptionBadId(tr("Can't find tool in table."), id);
}
return 0;
}
//---------------------------------------------------------------------------------------------------------------------
@ -429,6 +432,7 @@ void VPattern::setCurrentData()
}
if (tools.size() > 0)
{
ToolExists(id);
const VDataTool *vTool = tools.value(id);
*data = vTool->getData();
}
@ -459,6 +463,7 @@ void VPattern::UpdateToolData(const quint32 &id, VContainer *data)
{
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
SCASSERT(data != nullptr);
ToolExists(id);
VDataTool *tool = tools.value(id);
SCASSERT(tool != nullptr);
tool->VDataTool::setData(data);
@ -472,6 +477,7 @@ void VPattern::UpdateToolData(const quint32 &id, VContainer *data)
void VPattern::IncrementReferens(quint32 id) const
{
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
ToolExists(id);
VDataTool *tool = tools.value(id);
SCASSERT(tool != nullptr);
tool->incrementReferens();
@ -485,6 +491,7 @@ void VPattern::IncrementReferens(quint32 id) const
void VPattern::DecrementReferens(quint32 id) const
{
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
ToolExists(id);
VDataTool *tool = tools.value(id);
SCASSERT(tool != nullptr);
tool->decrementReferens();
@ -704,7 +711,6 @@ bool VPattern::SaveDocument(const QString &fileName, QString &error)
e.CriticalMessageBox(tr("Error no unique id."), qApp->getMainWindow());
return false;
}
GarbageCollector();
return VDomDocument::SaveDocument(fileName, error);
}
@ -792,6 +798,9 @@ void VPattern::LiteParseTree(const Document &parse)
nameActivPP = namePP;
setCurrentData();
emit FullUpdateFromFile();
// Recalculate scene rect
VAbstractTool::NewSceneRect(sceneDraw, qApp->getSceneView());
VAbstractTool::NewSceneRect(sceneDetail, qApp->getSceneView());
}
//---------------------------------------------------------------------------------------------------------------------
@ -959,7 +968,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
{
if (element.tagName() == VToolDetail::TagNode)
{
const quint32 id = GetParametrUInt(element, VToolDetail::AttrIdObject, "0");
const quint32 id = GetParametrUInt(element, VToolDetail::AttrIdObject, NULL_ID_STR);
const qreal mx = qApp->toPixel(GetParametrDouble(element, VAbstractTool::AttrMx, "0.0"));
const qreal my = qApp->toPixel(GetParametrDouble(element, VAbstractTool::AttrMy, "0.0"));
const NodeDetail nodeType = NodeDetail::Contour;
@ -1124,7 +1133,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, NULL_ID_STR);
const QString angle = GetParametrString(domElement, VAbstractTool::AttrAngle, "0.0");
QString angleFix = angle;
@ -1158,8 +1167,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR);
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR);
VToolAlongLine::Create(id, name, typeLine, f, firstPointId, secondPointId, mx, my, scene, this,
data, parse, Source::FromFile);
@ -1189,9 +1198,9 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
const quint32 p2Line = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
const quint32 pShoulder = GetParametrUInt(domElement, VAbstractTool::AttrPShoulder, "0");
const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, NULL_ID_STR);
const quint32 p2Line = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, NULL_ID_STR);
const quint32 pShoulder = GetParametrUInt(domElement, VAbstractTool::AttrPShoulder, NULL_ID_STR);
VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this,
data, parse, Source::FromFile);
@ -1221,8 +1230,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR);
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR);
const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
VToolNormal::Create(id, f, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene,
@ -1253,9 +1262,9 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const quint32 thirdPointId = GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR);
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR);
const quint32 thirdPointId = GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, NULL_ID_STR);
VToolBisector::Create(id, f, firstPointId, secondPointId, thirdPointId,
typeLine, name, mx, my, scene, this, data, parse, Source::FromFile);
@ -1283,10 +1292,10 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
try
{
PointsCommonAttributes(domElement, id, name, mx, my);
const quint32 p1Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0");
const quint32 p2Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0");
const quint32 p1Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0");
const quint32 p2Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line2, "0");
const quint32 p1Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, NULL_ID_STR);
const quint32 p2Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, NULL_ID_STR);
const quint32 p1Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, NULL_ID_STR);
const quint32 p2Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line2, NULL_ID_STR);
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name,
mx, my, scene, this, data, parse, Source::FromFile);
@ -1304,9 +1313,9 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
PointsCommonAttributes(domElement, id, name, mx, my);
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0");
QString f = radius;//need for saving fixed formula;
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, NULL_ID_STR);
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR);
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR);
VToolPointOfContact::Create(id, f, center, firstPointId, secondPointId, name, mx, my, scene, this,
data, parse, Source::FromFile);
@ -1334,8 +1343,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
try
{
PointsCommonAttributes(domElement, id, mx, my);
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idObject );
data->UpdateGObject(id, new VPointF(point->toQPointF(), point->name(), mx, my, idObject,
Draw::Modeling));
@ -1352,9 +1361,9 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
try
{
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
const quint32 p1LineId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
const quint32 p2LineId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, NULL_ID_STR);
const quint32 p1LineId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, NULL_ID_STR);
const quint32 p2LineId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, NULL_ID_STR);
VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId,
mx, my, scene, this, data, parse, Source::FromFile);
@ -1370,10 +1379,10 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
try
{
PointsCommonAttributes(domElement, id, name, mx, my);
const quint32 axisP1Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0");
const quint32 axisP2Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const quint32 axisP1Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, NULL_ID_STR);
const quint32 axisP2Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, NULL_ID_STR);
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR);
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR);
VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, scene, this,
data, parse, Source::FromFile);
@ -1389,8 +1398,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
try
{
PointsCommonAttributes(domElement, id, name, mx, my);
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR);
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR);
VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, scene, this, data,
parse, Source::FromFile);
@ -1408,7 +1417,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
PointsCommonAttributes(domElement, id, name, mx, my);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
QString f = formula;//need for saving fixed formula;
const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0");
const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR);
VToolCutSpline::Create(id, name, f, splineId, mx, my, scene, this, data, parse, Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
@ -1437,7 +1446,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
PointsCommonAttributes(domElement, id, name, mx, my);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
QString f = formula;//need for saving fixed formula;
const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0");
const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath,
NULL_ID_STR);
VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, scene, this, data, parse,
Source::FromFile);
@ -1467,7 +1477,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
PointsCommonAttributes(domElement, id, name, mx, my);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
QString f = formula;//need for saving fixed formula;
const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, "0");
const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, NULL_ID_STR);
VToolCutArc::Create(id, name, f, arcId, mx, my, scene, this, data, parse, Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
@ -1495,9 +1505,9 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
{
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, NULL_ID_STR);
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, NULL_ID_STR);
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, NULL_ID_STR);
const QString angle = GetParametrString(domElement, VAbstractTool::AttrAngle, "0.0");
QString angleFix = angle;
@ -1531,8 +1541,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
{
PointsCommonAttributes(domElement, id, name, mx, my, typeLine);
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
const quint32 curveId = GetParametrUInt(domElement, VAbstractTool::AttrCurve, "0");
const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, NULL_ID_STR);
const quint32 curveId = GetParametrUInt(domElement, VAbstractTool::AttrCurve, NULL_ID_STR);
const QString angle = GetParametrString(domElement, VAbstractTool::AttrAngle, "0.0");
QString angleFix = angle;
@ -1582,8 +1592,8 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do
try
{
ToolsCommonAttributes(domElement, id);
const quint32 firstPoint = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPoint = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const quint32 firstPoint = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR);
const quint32 secondPoint = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR);
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
@ -1601,8 +1611,8 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do
void VPattern::SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, quint32 &idTool)
{
ToolsCommonAttributes(domElement, id);
idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1791,8 +1801,8 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
try
{
ToolsCommonAttributes(domElement, id);
const quint32 point1 = GetParametrUInt(domElement, VAbstractTool::AttrPoint1, "0");
const quint32 point4 = GetParametrUInt(domElement, VAbstractTool::AttrPoint4, "0");
const quint32 point1 = GetParametrUInt(domElement, VAbstractTool::AttrPoint1, NULL_ID_STR);
const quint32 point4 = GetParametrUInt(domElement, VAbstractTool::AttrPoint4, NULL_ID_STR);
const qreal angle1 = GetParametrDouble(domElement, VAbstractTool::AttrAngle1, "270.0");
const qreal angle2 = GetParametrDouble(domElement, VAbstractTool::AttrAngle2, "90.0");
const qreal kAsm1 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm1, "1.0");
@ -1828,7 +1838,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
const qreal kAsm1 = GetParametrDouble(element, VAbstractTool::AttrKAsm1, "1.0");
const qreal angle = GetParametrDouble(element, VAbstractTool::AttrAngle, "0");
const qreal kAsm2 = GetParametrDouble(element, VAbstractTool::AttrKAsm2, "1.0");
const quint32 pSpline = GetParametrUInt(element, VAbstractTool::AttrPSpline, "0");
const quint32 pSpline = GetParametrUInt(element, VAbstractTool::AttrPSpline, NULL_ID_STR);
const VPointF p = *data->GeometricObject<VPointF>(pSpline);
QLineF line(0, 0, 100, 0);
@ -1917,7 +1927,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen
try
{
ToolsCommonAttributes(domElement, id);
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, NULL_ID_STR);
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10");
QString r = radius;//need for saving fixed formula;
const QString f1 = GetParametrString(domElement, VAbstractTool::AttrAngle1, "180");
@ -1952,8 +1962,8 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen
try
{
ToolsCommonAttributes(domElement, id);
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0");
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0");
const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, NULL_ID_STR);
const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, NULL_ID_STR);
VArc *arc = new VArc(*data->GeometricObject<VArc>(idObject));
arc->setIdObject(idObject);
arc->setMode(Draw::Modeling);
@ -2065,7 +2075,7 @@ quint32 VPattern::GetParametrId(const QDomElement &domElement) const
QString message = tr("Got wrong parameter id. Need only id > 0.");
try
{
id = GetParametrUInt(domElement, VDomDocument::AttrId, "0");
id = GetParametrUInt(domElement, VDomDocument::AttrId, NULL_ID_STR);
if (id <= 0)
{
throw VExceptionWrongId(message, domElement);
@ -2570,29 +2580,6 @@ void VPattern::UpdateMeasurements()
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::GarbageCollector()
{
QHashIterator<quint32, VDataTool*> t(tools);
while (t.hasNext())
{
t.next();
VDataTool *tool = t.value();
if (tool->referens() <= 1)
{
QDomElement domElement = elementById(QString().setNum(t.key()));
if (domElement.isElement())
{
QDomNode parent = domElement.parentNode();
if (parent.isNull() == false && parent.toElement().tagName() == TagModeling)
{
parent.removeChild(domElement);
}
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ToolsCommonAttributes(const QDomElement &domElement, quint32 &id)
{
@ -2751,3 +2738,62 @@ QRectF VPattern::ToolBoundingRect(const QRectF &rec, const quint32 &id) const
}
return recTool;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VToolRecord> VPattern::getLocalHistory() const
{
QVector<VToolRecord> historyPP;
for (qint32 i = 0; i< history.size(); ++i)
{
const VToolRecord tool = history.at(i);
if (tool.getNameDraw() != GetNameActivPP())
{
continue;
}
historyPP.append(tool);
}
return historyPP;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VPattern::SiblingNodeId(const quint32 &nodeId) const
{
quint32 siblingId = NULL_ID;
const QVector<VToolRecord> history = getLocalHistory();
for (qint32 i = 0; i < history.size(); ++i)
{
const VToolRecord tool = history.at(i);
if (nodeId == tool.getId())
{
if (i == 0)
{
siblingId = NULL_ID;
}
else
{
for (qint32 j = i; j > 0; --j)
{
const VToolRecord tool = history.at(j-1);
switch ( tool.getTypeTool() )
{
case Tool::Detail:
case Tool::UnionDetails:
case Tool::NodeArc:
case Tool::NodePoint:
case Tool::NodeSpline:
case Tool::NodeSplinePath:
continue;
break;
default:
siblingId = tool.getId();
j = 0;// break loop
break;
}
}
}
}
}
return siblingId;
}

View File

@ -72,6 +72,7 @@ public:
QHash<quint32, VDataTool*>* getTools();
VDataTool* getTool(const quint32 &id);
QVector<VToolRecord> *getHistory();
QVector<VToolRecord> getLocalHistory() const;
quint32 getCursor() const;
void setCursor(const quint32 &value);
void setCurrentData();
@ -182,6 +183,8 @@ public:
void SetVersion();
QString GenerateLabel(const LabelType &type)const;
quint32 SiblingNodeId(const quint32 &nodeId) const;
signals:
/**
* @brief ChangedActivDraw change active pattern peace.
@ -218,6 +221,7 @@ signals:
void UndoCommand();
void SetEnabledGUI(bool enabled);
void CheckLayout();
void SetCurrentPP(const QString &patterPiece);
public slots:
void LiteParseTree(const Document &parse);
void haveLiteChange();
@ -270,7 +274,6 @@ private:
void CollectId(const QDomElement &node, QVector<quint32> &vector)const;
void PrepareForParse(const Document &parse);
void UpdateMeasurements();
void GarbageCollector();
void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id);
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx,
qreal &my, QString &typeLine);
@ -284,6 +287,7 @@ private:
void ParseCurrentPP();
void CheckTagExists(const QString &tag);
QString GetLabelBase(unsigned int index)const;
void ToolExists(const quint32 &id) const;
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -71,3 +71,7 @@ VToolRecord &VToolRecord::operator=(const VToolRecord &record)
VToolRecord::VToolRecord(const VToolRecord &record)
:id(record.getId()), typeTool(record.getTypeTool()), nameDraw(record.getNameDraw())
{}
//---------------------------------------------------------------------------------------------------------------------
VToolRecord::~VToolRecord()
{}

View File

@ -50,6 +50,7 @@ public:
void setTypeTool(const Tool &value);
QString getNameDraw() const;
void setNameDraw(const QString &value);
~VToolRecord();
private:
/** @brief id tool id. */
quint32 id;

View File

@ -103,14 +103,20 @@ CONFIG(debug, debug|release){
# Release mode
DEFINES += QT_NO_DEBUG_OUTPUT
unix:!macx{
!unix:*-g++{
QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll
}
!macx:!win32-msvc*{
# Turn on debug symbols in release mode on Unix systems.
# On Mac OS X temporarily disabled. TODO: find way how to strip binary file.
QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3
QMAKE_CFLAGS_RELEASE += -g -gdwarf-3
QMAKE_LFLAGS_RELEASE =
# Strip debug symbols.
QMAKE_POST_LINK += objcopy --only-keep-debug $(DESTDIR)/$(TARGET) $(DESTDIR)/$(TARGET).debug &&
QMAKE_POST_LINK += strip --strip-debug --strip-unneeded $(DESTDIR)/$(TARGET) &&
QMAKE_POST_LINK += objcopy --add-gnu-debuglink $(DESTDIR)/$(TARGET).debug $(DESTDIR)/$(TARGET)
QMAKE_POST_LINK += objcopy --only-keep-debug bin/${TARGET} bin/${TARGET}.dbg &&
QMAKE_POST_LINK += objcopy --strip-debug bin/${TARGET} &&
QMAKE_POST_LINK += objcopy --add-gnu-debuglink="bin/${TARGET}.dbg" bin/${TARGET}
}
}

View File

@ -773,6 +773,10 @@ void QmuParserBase::ApplyFunc( QStack<token_type> &a_stOpt, QStack<token_type> &
QVector<token_type> stArg;
for (int i=0; i<iArgNumerical; ++i)
{
if (a_stVal.isEmpty())// Check if stack is empty like in origin muparser.
{
Error(ecUNASSIGNABLE_TOKEN, m_pTokenReader->GetPos(), funTok.GetAsString());
}
stArg.push_back( a_stVal.pop() );
if ( stArg.back().GetType()==tpSTR && funTok.GetType()!=tpSTR )
{

View File

@ -36,23 +36,6 @@
# include <QtCore>
#endif
//In Windows you can't use same header in all modes.
#if defined(Q_OS_WIN)
# if defined(QT_NO_DEBUG)//release mode
# ifdef QT_WIDGETS_LIB
# include <QtWidgets>
# endif
# endif/*QT_NO_DEBUG*/
#else
# ifdef QT_WIDGETS_LIB
# include <QtWidgets>
# endif
#endif/*Q_OS_WIN*/
#endif /*__cplusplus*/
#endif // STABLE_H

View File

@ -145,13 +145,20 @@ CONFIG(debug, debug|release){
# Release mode
DEFINES += QT_NO_DEBUG_OUTPUT
unix:!macx{
!unix:*-g++{
QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll
}
!macx:!win32-msvc*{
# Turn on debug symbols in release mode on Unix systems.
# On Mac OS X temporarily disabled. TODO: find way how to strip binary file.
QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3
# On Linux
QMAKE_POST_LINK += objcopy --only-keep-debug $(DESTDIR)/$(TARGET) $(DESTDIR)/$(TARGET).debug &&
QMAKE_POST_LINK += strip --strip-debug --strip-unneeded $(DESTDIR)/$(TARGET) &&
QMAKE_POST_LINK += objcopy --add-gnu-debuglink $(DESTDIR)/$(TARGET).debug $(DESTDIR)/$(TARGET)
QMAKE_CFLAGS_RELEASE += -g -gdwarf-3
QMAKE_LFLAGS_RELEASE =
# Strip debug symbols.
QMAKE_POST_LINK += objcopy --only-keep-debug bin/${TARGET} bin/${TARGET}.dbg &&
QMAKE_POST_LINK += objcopy --strip-debug bin/${TARGET} &&
QMAKE_POST_LINK += objcopy --add-gnu-debuglink="bin/${TARGET}.dbg" bin/${TARGET}
}
}