Added support exception for some situations.

This commit is contained in:
dismine 2013-09-23 15:08:06 +03:00
parent 91744b39b7
commit 1b7fc8df85
19 changed files with 1212 additions and 336 deletions

View File

@ -87,7 +87,14 @@ SOURCES += main.cpp\
tools/modelingTools/vmodelingpointofcontact.cpp \ tools/modelingTools/vmodelingpointofcontact.cpp \
tools/modelingTools/vmodelingshoulderpoint.cpp \ tools/modelingTools/vmodelingshoulderpoint.cpp \
tools/modelingTools/vmodelingspline.cpp \ tools/modelingTools/vmodelingspline.cpp \
tools/modelingTools/vmodelingsplinepath.cpp tools/modelingTools/vmodelingsplinepath.cpp \
exception/vexception.cpp \
exception/vexceptionbadid.cpp \
exception/vexceptionwrongparameterid.cpp \
exception/vexceptionconversionerror.cpp \
exception/vexceptionemptyparameter.cpp \
exception/vexceptionobjecterror.cpp \
widgets/vapplication.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
widgets/vmaingraphicsscene.h \ widgets/vmaingraphicsscene.h \
@ -170,7 +177,14 @@ HEADERS += mainwindow.h \
tools/modelingTools/vmodelingpointofcontact.h \ tools/modelingTools/vmodelingpointofcontact.h \
tools/modelingTools/vmodelingshoulderpoint.h \ tools/modelingTools/vmodelingshoulderpoint.h \
tools/modelingTools/vmodelingspline.h \ tools/modelingTools/vmodelingspline.h \
tools/modelingTools/vmodelingsplinepath.h tools/modelingTools/vmodelingsplinepath.h \
exception/vexception.h \
exception/vexceptionbadid.h \
exception/vexceptionwrongparameterid.h \
exception/vexceptionconversionerror.h \
exception/vexceptionemptyparameter.h \
exception/vexceptionobjecterror.h \
widgets/vapplication.h
FORMS += mainwindow.ui \ FORMS += mainwindow.ui \
dialogs/dialogsinglepoint.ui \ dialogs/dialogsinglepoint.ui \

View File

@ -22,6 +22,7 @@
#include "vcontainer.h" #include "vcontainer.h"
#include <QDebug> #include <QDebug>
#include "options.h" #include "options.h"
#include <exception/vexceptionbadid.h>
qint64 VContainer::_id = 0; qint64 VContainer::_id = 0;
@ -80,8 +81,7 @@ val VContainer::GetObject(const QMap<key,val> &obj, key id){
if(obj.contains(id)){ if(obj.contains(id)){
return obj.value(id); return obj.value(id);
} else { } else {
qCritical()<<"Не можу знайти key = "<<id<<" в таблиці."; throw VExceptionBadId(tr("Can't find object"), id);
throw"Не можу знайти об'єкт за ключем.";
} }
} }

View File

@ -33,12 +33,14 @@
#include "geometry/vsplinepath.h" #include "geometry/vsplinepath.h"
#include "geometry/vdetail.h" #include "geometry/vdetail.h"
#include "widgets/vitem.h" #include "widgets/vitem.h"
#include <QCoreApplication>
/** /**
* @brief The VContainer class * @brief The VContainer class
*/ */
class VContainer class VContainer
{ {
Q_DECLARE_TR_FUNCTIONS(VContainer)
public: public:
/** /**
* @brief VContainer * @brief VContainer

34
exception/vexception.cpp Normal file
View File

@ -0,0 +1,34 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#include "vexception.h"
VException::VException(const QString &what):QException(), what(what){
Q_ASSERT_X(!what.isEmpty(), Q_FUNC_INFO, "Error message is empty");
}
VException::VException(const VException &e):what(e.What()){
}
QString VException::ErrorMessage() const{
QString error = QString("Exception: %1").arg(what);
return error;
}

44
exception/vexception.h Normal file
View File

@ -0,0 +1,44 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#ifndef VEXCEPTION_H
#define VEXCEPTION_H
#include <QException>
#include <QString>
class VException : public QException
{
public:
VException(const QString &what);
VException(const VException &e);
virtual ~VException() noexcept(true){}
void raise() const { throw *this; }
VException *clone() const { return new VException(*this); }
virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const { return QString(); }
QString What() const {return what;}
protected:
QString what;
};
#endif // VEXCEPTION_H

View File

@ -0,0 +1,44 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#include "vexceptionbadid.h"
VExceptionBadId::VExceptionBadId(const QString &what, const qint64 &id):VException(what), id(id),
key(QString()){
}
VExceptionBadId::VExceptionBadId(const QString &what, const QString &key):VException(what), id(0), key(key)
{
}
VExceptionBadId::VExceptionBadId(const VExceptionBadId &e):VException(e), id(e.BadId()), key(e.BadKey()){
}
QString VExceptionBadId::ErrorMessage() const{
QString error;
if(key.isEmpty()){
error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(id);
} else {
error = QString("ExceptionBadId: %1, id = %2").arg(what).arg(key);
}
return error;
}

View File

@ -0,0 +1,42 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#ifndef VEXCEPTIONBADID_H
#define VEXCEPTIONBADID_H
#include "vexception.h"
class VExceptionBadId : public VException
{
public:
VExceptionBadId(const QString &what, const qint64 &id);
VExceptionBadId(const QString &what, const QString &key);
VExceptionBadId(const VExceptionBadId &e);
virtual ~VExceptionBadId() noexcept(true){}
virtual QString ErrorMessage() const;
qint64 BadId() const {return id; }
QString BadKey() const {return key; }
protected:
qint64 id;
QString key;
};
#endif // VEXCEPTIONBADID_H

View File

@ -0,0 +1,36 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#include "vexceptionconversionerror.h"
VExceptionConversionError::VExceptionConversionError(const QString &what, const QString &str)
:VException(what), str(str){
Q_ASSERT_X(!str.isEmpty(), Q_FUNC_INFO, "Error converting string is empty");
}
VExceptionConversionError::VExceptionConversionError(const VExceptionConversionError &e):
VException(e), str(e.String()){
}
QString VExceptionConversionError::ErrorMessage() const{
QString error = QString("ExceptionConversionError: %1 %2").arg(what, str);
return error;
}

View File

@ -0,0 +1,39 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#ifndef VEXCEPTIONCONVERSIONERROR_H
#define VEXCEPTIONCONVERSIONERROR_H
#include "vexception.h"
class VExceptionConversionError : public VException
{
public:
VExceptionConversionError(const QString &what, const QString &str);
VExceptionConversionError(const VExceptionConversionError &e);
virtual ~VExceptionConversionError() noexcept(true) {}
virtual QString ErrorMessage() const;
QString String() const {return str;}
protected:
QString str;
};
#endif // VEXCEPTIONCONVERSIONERROR_H

View File

@ -0,0 +1,50 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#include "vexceptionemptyparameter.h"
#include <QDebug>
VExceptionEmptyParameter::VExceptionEmptyParameter(const QString &what, const QString &name,
const QDomElement &domElement): VException(what), name(name),
tagText(QString()), tagName(QString()), lineNumber(-1){
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "Parameter name is empty");
if(domElement.isText()){
QDomText text = domElement.toText();
tagText = text.data();
}
tagName = domElement.tagName();
lineNumber = domElement.lineNumber();
}
VExceptionEmptyParameter::VExceptionEmptyParameter(const VExceptionEmptyParameter &e):VException(e),
name(e.Name()), tagName(e.TagName()), tagText(e.TagText()), lineNumber(e.LineNumber()){
}
QString VExceptionEmptyParameter::ErrorMessage() const{
QString error = QString("ExceptionEmptyParameter: %1 %2").arg(what, name);
return error;
}
QString VExceptionEmptyParameter::DetailedInformation() const{
QString detail = QString("tag: %1 in line %2\nFull tag:\n%3").arg(tagName).arg(lineNumber).arg(tagText);
return detail;
}

View File

@ -0,0 +1,47 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#ifndef VEXCEPTIONEMPTYPARAMETER_H
#define VEXCEPTIONEMPTYPARAMETER_H
#include "vexception.h"
#include "QDomElement"
class VExceptionEmptyParameter : public VException
{
public:
VExceptionEmptyParameter(const QString &what, const QString &name, const QDomElement &domElement);
VExceptionEmptyParameter(const VExceptionEmptyParameter &e);
virtual ~VExceptionEmptyParameter() noexcept(true) {}
virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const;
QString Name() const {return name;}
QString TagText() const {return tagText;}
QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;}
protected:
QString name;
QString tagText;
QString tagName;
qint32 lineNumber;
};
#endif // VEXCEPTIONEMPTYPARAMETER_H

View File

@ -0,0 +1,61 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#include "vexceptionobjecterror.h"
#include <QDebug>
VExceptionObjectError::VExceptionObjectError(const QString &what, const QDomElement &domElement):
VException(what), tagText(QString()), tagName(QString()), lineNumber(-1), moreInfo(QString()){
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
if(domElement.isText()){
QDomText text = domElement.toText();
tagText = text.data();
}
tagName = domElement.tagName();
lineNumber = domElement.lineNumber();
}
VExceptionObjectError::VExceptionObjectError(const VExceptionObjectError &e):VException(e),
tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()), moreInfo(e.MoreInformation()){
}
QString VExceptionObjectError::ErrorMessage() const{
QString error = QString("ExceptionObjectError: %1").arg(what);
return error;
}
QString VExceptionObjectError::DetailedInformation() const{
QString detail;
if(!moreInfo.isEmpty()){
QString i = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText);
detail = QString("%1\n%2").arg(moreInfo, i);
} else {
detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText);
}
return detail;
}
void VExceptionObjectError::AddMoreInformation(const QString &info){
if(info.isEmpty()){
qWarning()<<"Error additional information is empty."<<Q_FUNC_INFO;
}
this->moreInfo.append(info);
}

View File

@ -0,0 +1,48 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#ifndef VEXCEPTIONOBJECTERROR_H
#define VEXCEPTIONOBJECTERROR_H
#include "vexception.h"
#include <QDomElement>
class VExceptionObjectError : public VException
{
public:
VExceptionObjectError(const QString &what, const QDomElement &domElement);
VExceptionObjectError(const VExceptionObjectError &e);
virtual ~VExceptionObjectError() noexcept(true) {}
virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const;
QString TagText() const {return tagText;}
QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;}
void AddMoreInformation(const QString &info);
QString MoreInformation() const {return moreInfo;}
protected:
QString tagText;
QString tagName;
qint32 lineNumber;
QString moreInfo;
};
#endif // VEXCEPTIONOBJECTERROR_H

View File

@ -0,0 +1,48 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#include "vexceptionwrongparameterid.h"
#include <QDebug>
VExceptionWrongParameterId::VExceptionWrongParameterId(const QString &what, const QDomElement &domElement):
VException(what), tagText(QString()), tagName(QString()), lineNumber(-1){
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
if(domElement.isText()){
QDomText text = domElement.toText();
tagText = text.data();
}
tagName = domElement.tagName();
lineNumber = domElement.lineNumber();
}
VExceptionWrongParameterId::VExceptionWrongParameterId(const VExceptionWrongParameterId &e):VException(e),
tagText(e.TagText()), tagName(e.TagName()), lineNumber(e.LineNumber()){
}
QString VExceptionWrongParameterId::ErrorMessage() const{
QString error = QString("ExceptionWrongParameterId: %1").arg(what);
return error;
}
QString VExceptionWrongParameterId::DetailedInformation() const{
QString detail = QString("tag: %1 in line %2\n%3").arg(tagName).arg(lineNumber).arg(tagText);
return detail;
}

View File

@ -0,0 +1,45 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#ifndef VEXCEPTIONWRONGPARAMETERID_H
#define VEXCEPTIONWRONGPARAMETERID_H
#include "vexception.h"
#include <QDomElement>
class VExceptionWrongParameterId : public VException
{
public:
VExceptionWrongParameterId(const QString &what, const QDomElement &domElement);
VExceptionWrongParameterId(const VExceptionWrongParameterId &e);
virtual ~VExceptionWrongParameterId() noexcept(true){}
virtual QString ErrorMessage() const;
virtual QString DetailedInformation() const;
QString TagText() const {return tagText;}
QString TagName() const {return tagName;}
qint32 LineNumber() const {return lineNumber;}
protected:
QString tagText;
QString tagName;
qint32 lineNumber;
};
#endif // VEXCEPTIONWRONGPARAMETERID_H

View File

@ -30,6 +30,11 @@
#include <QFileDialog> #include <QFileDialog>
#include <QDebug> #include <QDebug>
#include "geometry/vspline.h" #include "geometry/vspline.h"
#include <QMessageBox>
#include "exception/vexceptionobjecterror.h"
#include "exception/vexceptionconversionerror.h"
#include "exception/vexceptionemptyparameter.h"
#include "exception/vexceptionwrongparameterid.h"
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow), tool(Tools::ArrowTool), currentScene(0), sceneDraw(0), QMainWindow(parent), ui(new Ui::MainWindow), tool(Tools::ArrowTool), currentScene(0), sceneDraw(0),
@ -732,17 +737,68 @@ void MainWindow::ActionOpen(){
QString fName = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter); QString fName = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter);
if(fName.isEmpty()) if(fName.isEmpty())
return; return;
fileName = fName; QFile file(fName);
QFileInfo info(fileName); QString errorMsg;
QString title(info.fileName()); qint32 errorLine = 0;
title.append("-Valentina"); qint32 errorColumn = 0;
setWindowTitle(title);
QFile file(fileName);
if(file.open(QIODevice::ReadOnly)){ if(file.open(QIODevice::ReadOnly)){
if(doc->setContent(&file)){ if(doc->setContent(&file, &errorMsg, &errorLine, &errorColumn)){
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MainWindow::currentDrawChanged); this, &MainWindow::currentDrawChanged);
try{
doc->Parse(Document::FullParse, sceneDraw, sceneDetails); doc->Parse(Document::FullParse, sceneDraw, sceneDetails);
}
catch(const VExceptionObjectError &e){
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error parsing file."));
msgBox.setInformativeText(e.ErrorMessage());
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setDetailedText(e.DetailedInformation());
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
file.close();
return;
}
catch(const VExceptionConversionError &e){
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error can't convert value."));
msgBox.setInformativeText(e.ErrorMessage());
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
file.close();
return;
}
catch(const VExceptionEmptyParameter &e){
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error empty parameter."));
msgBox.setInformativeText(e.ErrorMessage());
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setDetailedText(e.DetailedInformation());
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
file.close();
return;
}
catch(const VExceptionWrongParameterId &e){
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error wrong id."));
msgBox.setInformativeText(e.ErrorMessage());
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setDetailedText(e.DetailedInformation());
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
file.close();
return;
}
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MainWindow::currentDrawChanged); this, &MainWindow::currentDrawChanged);
QString nameDraw = doc->GetNameActivDraw(); QString nameDraw = doc->GetNameActivDraw();
@ -756,9 +812,26 @@ void MainWindow::ActionOpen(){
SetEnableTool(false); SetEnableTool(false);
} }
SetEnableWidgets(true); SetEnableWidgets(true);
} else {
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error parsing pattern file."));
msgBox.setInformativeText(errorMsg);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
QString error = QString(tr("Error in line %1 column %2")).arg(errorLine, errorColumn);
msgBox.setDetailedText(error);
msgBox.exec();
file.close();
return;
} }
file.close(); file.close();
} }
fileName = fName;
QFileInfo info(fileName);
QString title(info.fileName());
title.append("-Valentina");
setWindowTitle(title);
} }
void MainWindow::ActionNew(){ void MainWindow::ActionNew(){

102
widgets/vapplication.cpp Normal file
View File

@ -0,0 +1,102 @@
/****************************************************************************
**
** Copyright (C) 2013 Valentina project All Rights Reserved.
**
** This file is part of Valentina.
**
** Tox is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Tox is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#include "vapplication.h"
#include <QtGui>
#include <QMessageBox>
#include "exception/vexceptionobjecterror.h"
#include "exception/vexceptionbadid.h"
#include "exception/vexceptionconversionerror.h"
#include "exception/vexceptionemptyparameter.h"
#include "exception/vexceptionwrongparameterid.h"
VApplication::VApplication(int & argc, char ** argv) :
QApplication(argc, argv){
}
// reimplemented from QApplication so we can throw exceptions in slots
bool VApplication::notify(QObject *receiver, QEvent *event){
try {
return QApplication::notify(receiver, event);
}
catch(const VExceptionObjectError &e){
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error parsing file. Program will be terminated."));
msgBox.setInformativeText(e.ErrorMessage());
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setDetailedText(e.DetailedInformation());
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
abort();
}
catch(const VExceptionBadId &e){
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error bad id. Program will be terminated."));
msgBox.setInformativeText(e.ErrorMessage());
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
abort();
}
catch(const VExceptionConversionError &e){
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error can't convert value. Program will be terminated."));
msgBox.setInformativeText(e.ErrorMessage());
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
abort();
}
catch(const VExceptionEmptyParameter &e){
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error empty parameter. Program will be terminated."));
msgBox.setInformativeText(e.ErrorMessage());
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setDetailedText(e.DetailedInformation());
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
abort();
}
catch(const VExceptionWrongParameterId &e){
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error wrong id. Program will be terminated."));
msgBox.setInformativeText(e.ErrorMessage());
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setDetailedText(e.DetailedInformation());
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
abort();
}
catch(std::exception& e) {
qCritical() << "Exception thrown:" << e.what();
}
return false;
}

15
widgets/vapplication.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef VAPPLICATION_H
#define VAPPLICATION_H
#include <QApplication>
class VApplication : public QApplication
{
Q_OBJECT
public:
VApplication(int &argc, char ** argv);
virtual ~VApplication() { }
virtual bool notify(QObject * receiver, QEvent * event);
};
#endif // VAPPLICATION_H

View File

@ -28,7 +28,11 @@
#include "options.h" #include "options.h"
#include "container/calculator.h" #include "container/calculator.h"
#include "geometry/vsplinepoint.h" #include "geometry/vsplinepoint.h"
#include "exception/vexceptionwrongparameterid.h"
#include "exception/vexceptionconversionerror.h"
#include "exception/vexceptionemptyparameter.h"
#include "exception/vexceptionbadid.h"
#include "exception/vexceptionobjecterror.h"
VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Mode *mode) : QDomDocument(), VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Mode *mode) : QDomDocument(),
@ -324,8 +328,11 @@ void VDomDocument::ParseIncrementsElement(const QDomNode &node){
} }
qint64 VDomDocument::GetParametrId(const QDomElement &domElement) const{ qint64 VDomDocument::GetParametrId(const QDomElement &domElement) const{
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
qint64 id = GetParametrLongLong(domElement, "id"); qint64 id = GetParametrLongLong(domElement, "id");
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); if(id <= 0){
throw VExceptionWrongParameterId(tr("Got wrong parameter id. Need only id > 0."), domElement);
}
return id; return id;
} }
@ -335,20 +342,20 @@ qint64 VDomDocument::GetParametrLongLong(const QDomElement &domElement, const QS
bool ok = false; bool ok = false;
QString parametr = GetParametrString(domElement, name); QString parametr = GetParametrString(domElement, name);
qint64 id = parametr.toLongLong(&ok); qint64 id = parametr.toLongLong(&ok);
QString error("can't convert parametr "); if(ok == false){
error.append(name); throw VExceptionConversionError(tr("Can't convert toLongLong parameter"), name);
Q_ASSERT_X(ok, Q_FUNC_INFO, error.toLatin1().data()); }
return id; return id;
} }
QString VDomDocument::GetParametrString(const QDomElement &domElement, const QString &name) const{ QString VDomDocument::GetParametrString(const QDomElement &domElement, const QString &name) const{
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "name of parametr is empty"); Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "name of parametr is empty");
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
QString parametr = domElement.attribute(name, ""); QString parameter = domElement.attribute(name, "");
QString error("get empty parametr "); if(parameter.isEmpty()){
error.append(name); throw VExceptionEmptyParameter(tr("Got empty parameter"), name, domElement);
Q_ASSERT_X(!parametr.isEmpty(), Q_FUNC_INFO, error.toLatin1().data()); }
return parametr; return parameter;
} }
qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QString &name) const{ qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QString &name) const{
@ -357,9 +364,9 @@ qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QStri
bool ok = false; bool ok = false;
QString parametr = GetParametrString(domElement, name); QString parametr = GetParametrString(domElement, name);
qreal param = parametr.toDouble(&ok); qreal param = parametr.toDouble(&ok);
QString error("can't convert parametr "); if(ok == false){
error.append(name); throw VExceptionConversionError(tr("Can't convert toDouble parameter"), name);
Q_ASSERT_X(ok, Q_FUNC_INFO, error.toLatin1().data()); }
return param; return param;
} }
@ -423,72 +430,79 @@ void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDo
Document::Enum parse){ Document::Enum parse){
Q_CHECK_PTR(sceneDetail); Q_CHECK_PTR(sceneDetail);
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
VDetail detail; try{
VDetail oldDetail; VDetail detail;
qint64 id = GetParametrId(domElement); VDetail oldDetail;
detail.setName(GetParametrString(domElement, "name")); qint64 id = GetParametrId(domElement);
detail.setMx(toPixel(GetParametrDouble(domElement, "mx"))); detail.setName(GetParametrString(domElement, "name"));
detail.setMy(toPixel(GetParametrDouble(domElement, "my"))); detail.setMx(toPixel(GetParametrDouble(domElement, "mx")));
detail.setMy(toPixel(GetParametrDouble(domElement, "my")));
QDomNodeList nodeList = domElement.childNodes(); QDomNodeList nodeList = domElement.childNodes();
qint32 num = nodeList.size(); qint32 num = nodeList.size();
for(qint32 i = 0; i < num; ++i){ for(qint32 i = 0; i < num; ++i){
QDomElement element = nodeList.at(i).toElement(); QDomElement element = nodeList.at(i).toElement();
if(!element.isNull()){ if(!element.isNull()){
if(element.tagName() == "node"){ if(element.tagName() == "node"){
qint64 id = GetParametrLongLong(element, "idObject"); qint64 id = GetParametrLongLong(element, "idObject");
Tools::Enum tool; Tools::Enum tool;
Draw::Mode mode; Draw::Mode mode;
NodeDetail::Type nodeType = NodeDetail::Contour; NodeDetail::Type nodeType = NodeDetail::Contour;
QString t = GetParametrString(element, "type"); QString t = GetParametrString(element, "type");
if(t == "NodePoint"){ if(t == "NodePoint"){
tool = Tools::NodePoint; tool = Tools::NodePoint;
VPointF point = data->GetModelingPoint(id); VPointF point = data->GetModelingPoint(id);
mode = point.getMode(); mode = point.getMode();
oldDetail.append(VNodeDetail(point.getIdObject(), tool, mode, NodeDetail::Contour)); oldDetail.append(VNodeDetail(point.getIdObject(), tool, mode, NodeDetail::Contour));
} else if(t == "NodeArc"){ } else if(t == "NodeArc"){
tool = Tools::NodeArc; tool = Tools::NodeArc;
VArc arc = data->GetModelingArc(id); VArc arc = data->GetModelingArc(id);
mode = arc.getMode(); mode = arc.getMode();
oldDetail.append(VNodeDetail(arc.getIdObject(), tool, mode, NodeDetail::Contour)); oldDetail.append(VNodeDetail(arc.getIdObject(), tool, mode, NodeDetail::Contour));
} else if(t == "NodeSpline"){ } else if(t == "NodeSpline"){
tool = Tools::NodeSpline; tool = Tools::NodeSpline;
VSpline spl = data->GetModelingSpline(id); VSpline spl = data->GetModelingSpline(id);
mode = spl.getMode(); mode = spl.getMode();
oldDetail.append(VNodeDetail(spl.getIdObject(), tool, mode, NodeDetail::Contour)); oldDetail.append(VNodeDetail(spl.getIdObject(), tool, mode, NodeDetail::Contour));
} else if(t == "NodeSplinePath"){ } else if(t == "NodeSplinePath"){
tool = Tools::NodeSplinePath; tool = Tools::NodeSplinePath;
VSplinePath splPath = data->GetModelingSplinePath(id); VSplinePath splPath = data->GetModelingSplinePath(id);
mode = splPath.getMode(); mode = splPath.getMode();
oldDetail.append(VNodeDetail(splPath.getIdObject(), tool, mode, NodeDetail::Contour)); oldDetail.append(VNodeDetail(splPath.getIdObject(), tool, mode, NodeDetail::Contour));
} else if(t == "AlongLineTool"){ } else if(t == "AlongLineTool"){
tool = Tools::AlongLineTool; tool = Tools::AlongLineTool;
} else if(t == "ArcTool"){ } else if(t == "ArcTool"){
tool = Tools::ArcTool; tool = Tools::ArcTool;
} else if(t == "BisectorTool"){ } else if(t == "BisectorTool"){
tool = Tools::BisectorTool; tool = Tools::BisectorTool;
} else if(t == "EndLineTool"){ } else if(t == "EndLineTool"){
tool = Tools::EndLineTool; tool = Tools::EndLineTool;
} else if(t == "LineIntersectTool"){ } else if(t == "LineIntersectTool"){
tool = Tools::LineIntersectTool; tool = Tools::LineIntersectTool;
} else if(t == "LineTool"){ } else if(t == "LineTool"){
tool = Tools::LineTool; tool = Tools::LineTool;
} else if(t == "NormalTool"){ } else if(t == "NormalTool"){
tool = Tools::NormalTool; tool = Tools::NormalTool;
} else if(t == "PointOfContact"){ } else if(t == "PointOfContact"){
tool = Tools::PointOfContact; tool = Tools::PointOfContact;
} else if(t == "ShoulderPointTool"){ } else if(t == "ShoulderPointTool"){
tool = Tools::ShoulderPointTool; tool = Tools::ShoulderPointTool;
} else if(t == "SplinePathTool"){ } else if(t == "SplinePathTool"){
tool = Tools::SplinePathTool; tool = Tools::SplinePathTool;
} else if(t == "SplineTool"){ } else if(t == "SplineTool"){
tool = Tools::SplineTool; tool = Tools::SplineTool;
}
detail.append(VNodeDetail(id, tool, mode, nodeType));
} }
detail.append(VNodeDetail(id, tool, mode, nodeType));
} }
} }
VToolDetail::Create(id, detail, oldDetail, sceneDetail, this, data, parse, Tool::FromFile);
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating detail"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
VToolDetail::Create(id, detail, oldDetail, sceneDetail, this, data, parse, Tool::FromFile);
} }
void VDomDocument::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, void VDomDocument::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
@ -515,175 +529,238 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(!type.isEmpty(), Q_FUNC_INFO, "type of point is empty"); Q_ASSERT_X(!type.isEmpty(), Q_FUNC_INFO, "type of point is empty");
if(type == "single"){ if(type == "single"){
qint64 id = GetParametrId(domElement); try{
QString name = GetParametrString(domElement, "name"); qint64 id = GetParametrId(domElement);
qreal x = toPixel(GetParametrDouble(domElement, "x")); QString name = GetParametrString(domElement, "name");
qreal y = toPixel(GetParametrDouble(domElement, "y")); qreal x = toPixel(GetParametrDouble(domElement, "x"));
qreal mx = toPixel(GetParametrDouble(domElement, "mx")); qreal y = toPixel(GetParametrDouble(domElement, "y"));
qreal my = toPixel(GetParametrDouble(domElement, "my")); qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
qreal my = toPixel(GetParametrDouble(domElement, "my"));
data->UpdatePoint(id, VPointF(x, y, name, mx, my)); data->UpdatePoint(id, VPointF(x, y, name, mx, my));
VDrawTool::AddRecord(id, Tools::SinglePointTool, this); VDrawTool::AddRecord(id, Tools::SinglePointTool, this);
if(parse != Document::FullParse){ if(parse != Document::FullParse){
UpdateToolData(id, data); UpdateToolData(id, data);
}
if(parse == Document::FullParse){
VToolSinglePoint *spoint = new VToolSinglePoint(this, data, id, Tool::FromFile);
Q_CHECK_PTR(spoint);
scene->addItem(spoint);
connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
tools[id] = spoint;
}
return;
} }
if(parse == Document::FullParse){ catch(const VExceptionBadId &e){
VToolSinglePoint *spoint = new VToolSinglePoint(this, data, id, Tool::FromFile); VExceptionObjectError excep(tr("Error creating or updating single point"), domElement);
Q_CHECK_PTR(spoint); excep.AddMoreInformation(e.ErrorMessage());
scene->addItem(spoint); throw excep;
connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
tools[id] = spoint;
} }
return;
} }
if(type == "endLine"){ if(type == "endLine"){
qint64 id = GetParametrId(domElement); try{
QString name = GetParametrString(domElement, "name"); qint64 id = GetParametrId(domElement);
qreal mx = toPixel(GetParametrDouble(domElement, "mx")); QString name = GetParametrString(domElement, "name");
qreal my = toPixel(GetParametrDouble(domElement, "my")); qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
QString typeLine = GetParametrString(domElement, "typeLine"); qreal my = toPixel(GetParametrDouble(domElement, "my"));
QString formula = GetParametrString(domElement, "length"); QString typeLine = GetParametrString(domElement, "typeLine");
qint64 basePointId = GetParametrLongLong(domElement, "basePoint"); QString formula = GetParametrString(domElement, "length");
qreal angle = GetParametrDouble(domElement, "angle"); qint64 basePointId = GetParametrLongLong(domElement, "basePoint");
if(mode == Draw::Calculation){ qreal angle = GetParametrDouble(domElement, "angle");
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this, if(mode == Draw::Calculation){
data, parse, Tool::FromFile); VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this,
} else {
VModelingEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, this,
data, parse, Tool::FromFile); data, parse, Tool::FromFile);
} else {
VModelingEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, this,
data, parse, Tool::FromFile);
}
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
return;
} }
if(type == "alongLine"){ if(type == "alongLine"){
qint64 id = GetParametrId(domElement); try{
QString name = GetParametrString(domElement, "name"); qint64 id = GetParametrId(domElement);
qreal mx = toPixel(GetParametrDouble(domElement, "mx")); QString name = GetParametrString(domElement, "name");
qreal my = toPixel(GetParametrDouble(domElement, "my")); qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
QString typeLine = GetParametrString(domElement, "typeLine"); qreal my = toPixel(GetParametrDouble(domElement, "my"));
QString formula = GetParametrString(domElement, "length"); QString typeLine = GetParametrString(domElement, "typeLine");
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); QString formula = GetParametrString(domElement, "length");
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
if(mode == Draw::Calculation){ qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, if(mode == Draw::Calculation){
scene, this, data, parse, Tool::FromFile); VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my,
} else { scene, this, data, parse, Tool::FromFile);
VModelingAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, } else {
this, data, parse, Tool::FromFile); VModelingAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my,
this, data, parse, Tool::FromFile);
}
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
return;
} }
if(type == "shoulder"){ if(type == "shoulder"){
qint64 id = GetParametrId(domElement); try{
QString name = GetParametrString(domElement, "name"); qint64 id = GetParametrId(domElement);
qreal mx = toPixel(GetParametrDouble(domElement, "mx")); QString name = GetParametrString(domElement, "name");
qreal my = toPixel(GetParametrDouble(domElement, "my")); qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
QString typeLine = GetParametrString(domElement, "typeLine"); qreal my = toPixel(GetParametrDouble(domElement, "my"));
QString formula = GetParametrString(domElement, "length"); QString typeLine = GetParametrString(domElement, "typeLine");
qint64 p1Line = GetParametrLongLong(domElement, "p1Line"); QString formula = GetParametrString(domElement, "length");
qint64 p2Line = GetParametrLongLong(domElement, "p2Line"); qint64 p1Line = GetParametrLongLong(domElement, "p1Line");
qint64 pShoulder = GetParametrLongLong(domElement, "pShoulder"); qint64 p2Line = GetParametrLongLong(domElement, "p2Line");
if(mode == Draw::Calculation){ qint64 pShoulder = GetParametrLongLong(domElement, "pShoulder");
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, if(mode == Draw::Calculation){
scene, this, data, parse, Tool::FromFile); VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my,
} else { scene, this, data, parse, Tool::FromFile);
VModelingShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, } else {
my, this, data, parse, Tool::FromFile); VModelingShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx,
my, this, data, parse, Tool::FromFile);
}
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
return;
} }
if(type == "normal"){ if(type == "normal"){
qint64 id = GetParametrId(domElement); try{
QString name = GetParametrString(domElement, "name"); qint64 id = GetParametrId(domElement);
qreal mx = toPixel(GetParametrDouble(domElement, "mx")); QString name = GetParametrString(domElement, "name");
qreal my = toPixel(GetParametrDouble(domElement, "my")); qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
QString typeLine = GetParametrString(domElement, "typeLine"); qreal my = toPixel(GetParametrDouble(domElement, "my"));
QString formula = GetParametrString(domElement, "length"); QString typeLine = GetParametrString(domElement, "typeLine");
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); QString formula = GetParametrString(domElement, "length");
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
qreal angle = GetParametrDouble(domElement, "angle"); qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
if(mode == Draw::Calculation){ qreal angle = GetParametrDouble(domElement, "angle");
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, if(mode == Draw::Calculation){
mx, my, scene, this, data, parse, Tool::FromFile); VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle,
} else { mx, my, scene, this, data, parse, Tool::FromFile);
VModelingNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, } else {
mx, my, this, data, parse, Tool::FromFile); VModelingNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle,
mx, my, this, data, parse, Tool::FromFile);
}
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
return;
} }
if(type == "bisector"){ if(type == "bisector"){
qint64 id = GetParametrId(domElement); try{
QString name = GetParametrString(domElement, "name"); qint64 id = GetParametrId(domElement);
qreal mx = toPixel(GetParametrDouble(domElement, "mx")); QString name = GetParametrString(domElement, "name");
qreal my = toPixel(GetParametrDouble(domElement, "my")); qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
QString typeLine = GetParametrString(domElement, "typeLine"); qreal my = toPixel(GetParametrDouble(domElement, "my"));
QString formula = GetParametrString(domElement, "length"); QString typeLine = GetParametrString(domElement, "typeLine");
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); QString formula = GetParametrString(domElement, "length");
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
qint64 thirdPointId = GetParametrLongLong(domElement, "thirdPoint"); qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
if(mode == Draw::Calculation){ qint64 thirdPointId = GetParametrLongLong(domElement, "thirdPoint");
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine, if(mode == Draw::Calculation){
name, mx, my, scene, this, data, parse, Tool::FromFile); VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine,
} else { name, mx, my, scene, this, data, parse, Tool::FromFile);
VModelingBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine, } else {
name, mx, my, this, data, parse, Tool::FromFile); VModelingBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine,
name, mx, my, this, data, parse, Tool::FromFile);
}
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
return;
} }
if(type == "lineIntersect"){ if(type == "lineIntersect"){
qint64 id = GetParametrId(domElement); try{
QString name = GetParametrString(domElement, "name"); qint64 id = GetParametrId(domElement);
qreal mx = toPixel(GetParametrDouble(domElement, "mx")); QString name = GetParametrString(domElement, "name");
qreal my = toPixel(GetParametrDouble(domElement, "my")); qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
qint64 p1Line1Id = GetParametrLongLong(domElement, "p1Line1"); qreal my = toPixel(GetParametrDouble(domElement, "my"));
qint64 p2Line1Id = GetParametrLongLong(domElement, "p2Line1"); qint64 p1Line1Id = GetParametrLongLong(domElement, "p1Line1");
qint64 p1Line2Id = GetParametrLongLong(domElement, "p1Line2"); qint64 p2Line1Id = GetParametrLongLong(domElement, "p2Line1");
qint64 p2Line2Id = GetParametrLongLong(domElement, "p2Line2"); qint64 p1Line2Id = GetParametrLongLong(domElement, "p1Line2");
if(mode == Draw::Calculation){ qint64 p2Line2Id = GetParametrLongLong(domElement, "p2Line2");
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my, if(mode == Draw::Calculation){
scene, this, data, parse, Tool::FromFile); VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my,
} else { scene, this, data, parse, Tool::FromFile);
VModelingLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my, } else {
this, data, parse, Tool::FromFile); VModelingLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my,
this, data, parse, Tool::FromFile);
}
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating point of lineintersection"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
return;
} }
if(type == "pointOfContact"){ if(type == "pointOfContact"){
qint64 id = GetParametrId(domElement); try{
QString name = GetParametrString(domElement, "name"); qint64 id = GetParametrId(domElement);
qreal mx = toPixel(GetParametrDouble(domElement, "mx")); QString name = GetParametrString(domElement, "name");
qreal my = toPixel(GetParametrDouble(domElement, "my")); qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
QString radius = GetParametrString(domElement, "radius"); qreal my = toPixel(GetParametrDouble(domElement, "my"));
qint64 center = GetParametrLongLong(domElement, "center"); QString radius = GetParametrString(domElement, "radius");
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); qint64 center = GetParametrLongLong(domElement, "center");
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
if(mode == Draw::Calculation){ qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my, if(mode == Draw::Calculation){
scene, this, data, parse, Tool::FromFile); VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my,
} else { scene, this, data, parse, Tool::FromFile);
VModelingPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, } else {
my, this, data, parse, Tool::FromFile); VModelingPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx,
my, this, data, parse, Tool::FromFile);
}
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
return;
} }
if(type == "modeling"){ if(type == "modeling"){
qint64 id = GetParametrId(domElement); try{
qint64 idObject = GetParametrLongLong(domElement, "idObject"); qint64 id = GetParametrId(domElement);
QString tObject = GetParametrString(domElement, "typeObject"); qint64 idObject = GetParametrLongLong(domElement, "idObject");
VPointF point; QString tObject = GetParametrString(domElement, "typeObject");
Draw::Mode typeObject; VPointF point;
if(tObject == "Calculation"){ Draw::Mode typeObject;
typeObject = Draw::Calculation; if(tObject == "Calculation"){
point = data->GetPoint(idObject ); typeObject = Draw::Calculation;
} else { point = data->GetPoint(idObject );
typeObject = Draw::Modeling; } else {
point = data->GetModelingPoint(idObject); typeObject = Draw::Modeling;
point = data->GetModelingPoint(idObject);
}
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
qreal my = toPixel(GetParametrDouble(domElement, "my"));
data->UpdateModelingPoint(id, VPointF(point.x(), point.y(), point.name(), mx, my, typeObject,
idObject ));
data->IncrementReferens(idObject, Scene::Point, typeObject);
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating modeling point"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
qreal my = toPixel(GetParametrDouble(domElement, "my"));
data->UpdateModelingPoint(id, VPointF(point.x(), point.y(), point.name(), mx, my, typeObject,
idObject ));
data->IncrementReferens(idObject, Scene::Point, typeObject);
return;
} }
} }
@ -691,13 +768,20 @@ void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement
Document::Enum parse, Draw::Mode mode){ Document::Enum parse, Draw::Mode mode){
Q_CHECK_PTR(scene); Q_CHECK_PTR(scene);
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
qint64 id = GetParametrId(domElement); try{
qint64 firstPoint = GetParametrLongLong(domElement, "firstPoint"); qint64 id = GetParametrId(domElement);
qint64 secondPoint = GetParametrLongLong(domElement, "secondPoint"); qint64 firstPoint = GetParametrLongLong(domElement, "firstPoint");
if(mode == Draw::Calculation){ qint64 secondPoint = GetParametrLongLong(domElement, "secondPoint");
VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile); if(mode == Draw::Calculation){
} else { VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile);
VModelingLine::Create(id, firstPoint, secondPoint, this, data, parse, Tool::FromFile); } else {
VModelingLine::Create(id, firstPoint, secondPoint, this, data, parse, Tool::FromFile);
}
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating line"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
} }
@ -707,100 +791,128 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(!type.isEmpty(), Q_FUNC_INFO, "type of spline is empty"); Q_ASSERT_X(!type.isEmpty(), Q_FUNC_INFO, "type of spline is empty");
if(type == "simple"){ if(type == "simple"){
qint64 id = GetParametrId(domElement); try{
qint64 point1 = GetParametrLongLong(domElement, "point1"); qint64 id = GetParametrId(domElement);
qint64 point4 = GetParametrLongLong(domElement, "point4"); qint64 point1 = GetParametrLongLong(domElement, "point1");
qreal angle1 = GetParametrDouble(domElement, "angle1"); qint64 point4 = GetParametrLongLong(domElement, "point4");
qreal angle2 = GetParametrDouble(domElement, "angle2"); qreal angle1 = GetParametrDouble(domElement, "angle1");
qreal kAsm1 = GetParametrDouble(domElement, "kAsm1"); qreal angle2 = GetParametrDouble(domElement, "angle2");
qreal kAsm2 = GetParametrDouble(domElement, "kAsm2"); qreal kAsm1 = GetParametrDouble(domElement, "kAsm1");
qreal kCurve = GetParametrDouble(domElement, "kCurve"); qreal kAsm2 = GetParametrDouble(domElement, "kAsm2");
if(mode == Draw::Calculation){ qreal kCurve = GetParametrDouble(domElement, "kCurve");
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, if(mode == Draw::Calculation){
data, parse, Tool::FromFile); VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this,
} else {
VModelingSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, this,
data, parse, Tool::FromFile); data, parse, Tool::FromFile);
} else {
VModelingSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, this,
data, parse, Tool::FromFile);
}
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating simple curve"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
return;
} }
if(type == "path"){ if(type == "path"){
qint64 id = GetParametrId(domElement); try{
qreal kCurve = GetParametrDouble(domElement, "kCurve"); qint64 id = GetParametrId(domElement);
VSplinePath path(data->DataPoints(), kCurve); qreal kCurve = GetParametrDouble(domElement, "kCurve");
VSplinePath path(data->DataPoints(), kCurve);
QDomNodeList nodeList = domElement.childNodes(); QDomNodeList nodeList = domElement.childNodes();
qint32 num = nodeList.size(); qint32 num = nodeList.size();
for(qint32 i = 0; i < num; ++i){ for(qint32 i = 0; i < num; ++i){
QDomElement element = nodeList.at(i).toElement(); QDomElement element = nodeList.at(i).toElement();
if(!element.isNull()){ if(!element.isNull()){
if(element.tagName() == "pathPoint"){ if(element.tagName() == "pathPoint"){
qreal kAsm1 = GetParametrDouble(element, "kAsm1"); qreal kAsm1 = GetParametrDouble(element, "kAsm1");
qreal angle = GetParametrDouble(element, "angle"); qreal angle = GetParametrDouble(element, "angle");
qreal kAsm2 = GetParametrDouble(element, "kAsm2"); qreal kAsm2 = GetParametrDouble(element, "kAsm2");
qint64 pSpline = GetParametrLongLong(element, "pSpline"); qint64 pSpline = GetParametrLongLong(element, "pSpline");
VSplinePoint splPoint(pSpline, kAsm1, angle, kAsm2); VSplinePoint splPoint(pSpline, kAsm1, angle, kAsm2);
path.append(splPoint); path.append(splPoint);
}
} }
} }
if(mode == Draw::Calculation){
VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile);
} else {
VModelingSplinePath::Create(id, path, this, data, parse, Tool::FromFile);
}
return;
} }
if(mode == Draw::Calculation){ catch(const VExceptionBadId &e){
VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile); VExceptionObjectError excep(tr("Error creating or updating curve path"), domElement);
} else { excep.AddMoreInformation(e.ErrorMessage());
VModelingSplinePath::Create(id, path, this, data, parse, Tool::FromFile); throw excep;
} }
return;
} }
if(type == "modelingSpline"){ if(type == "modelingSpline"){
qint64 id = GetParametrId(domElement); try{
qint64 idObject = GetParametrLongLong(domElement, "idObject"); qint64 id = GetParametrId(domElement);
QString tObject = GetParametrString(domElement, "typeObject"); qint64 idObject = GetParametrLongLong(domElement, "idObject");
VSpline spl; QString tObject = GetParametrString(domElement, "typeObject");
Draw::Mode typeObject; VSpline spl;
if(tObject == "Calculation"){ Draw::Mode typeObject;
typeObject = Draw::Calculation; if(tObject == "Calculation"){
spl = data->GetSpline(idObject); typeObject = Draw::Calculation;
} else { spl = data->GetSpline(idObject);
typeObject = Draw::Modeling; } else {
spl = data->GetModelingSpline(idObject); typeObject = Draw::Modeling;
spl = data->GetModelingSpline(idObject);
}
spl.setMode(typeObject);
spl.setIdObject(idObject);
data->UpdateModelingSpline(id, spl);
if(typeObject == Draw::Calculation){
data->IncrementReferens(spl.GetP1(), Scene::Point, Draw::Calculation);
data->IncrementReferens(spl.GetP4(), Scene::Point, Draw::Calculation);
} else {
data->IncrementReferens(spl.GetP1(), Scene::Point, Draw::Modeling);
data->IncrementReferens(spl.GetP4(), Scene::Point, Draw::Modeling);
}
return;
} }
spl.setMode(typeObject); catch(const VExceptionBadId &e){
spl.setIdObject(idObject); VExceptionObjectError excep(tr("Error creating or updating modeling simple curve"), domElement);
data->UpdateModelingSpline(id, spl); excep.AddMoreInformation(e.ErrorMessage());
if(typeObject == Draw::Calculation){ throw excep;
data->IncrementReferens(spl.GetP1(), Scene::Point, Draw::Calculation);
data->IncrementReferens(spl.GetP4(), Scene::Point, Draw::Calculation);
} else {
data->IncrementReferens(spl.GetP1(), Scene::Point, Draw::Modeling);
data->IncrementReferens(spl.GetP4(), Scene::Point, Draw::Modeling);
} }
return;
} }
if(type == "modelingPath"){ if(type == "modelingPath"){
qint64 id = GetParametrId(domElement); try{
qint64 idObject = GetParametrLongLong(domElement, "idObject"); qint64 id = GetParametrId(domElement);
QString tObject = GetParametrString(domElement, "typeObject"); qint64 idObject = GetParametrLongLong(domElement, "idObject");
VSplinePath path; QString tObject = GetParametrString(domElement, "typeObject");
Draw::Mode typeObject; VSplinePath path;
if(tObject == "Calculation"){ Draw::Mode typeObject;
typeObject = Draw::Calculation; if(tObject == "Calculation"){
path = data->GetSplinePath(idObject); typeObject = Draw::Calculation;
} else { path = data->GetSplinePath(idObject);
typeObject = Draw::Modeling;
path = data->GetModelingSplinePath(idObject);
}
path.setMode(typeObject);
path.setIdObject(idObject);
data->UpdateModelingSplinePath(id, path);
const QVector<VSplinePoint> *points = path.GetPoint();
for(qint32 i = 0; i<points->size(); ++i){
if(typeObject == Draw::Calculation){
data->IncrementReferens(points->at(i).P(), Scene::Point, Draw::Calculation);
} else { } else {
data->IncrementReferens(points->at(i).P(), Scene::Point, Draw::Modeling); typeObject = Draw::Modeling;
path = data->GetModelingSplinePath(idObject);
} }
path.setMode(typeObject);
path.setIdObject(idObject);
data->UpdateModelingSplinePath(id, path);
const QVector<VSplinePoint> *points = path.GetPoint();
for(qint32 i = 0; i<points->size(); ++i){
if(typeObject == Draw::Calculation){
data->IncrementReferens(points->at(i).P(), Scene::Point, Draw::Calculation);
} else {
data->IncrementReferens(points->at(i).P(), Scene::Point, Draw::Modeling);
}
}
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating modeling curve path"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
return;
} }
} }
@ -810,43 +922,63 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
Q_ASSERT_X(!type.isEmpty(), Q_FUNC_INFO, "type of spline is empty"); Q_ASSERT_X(!type.isEmpty(), Q_FUNC_INFO, "type of spline is empty");
if(type == "simple"){ if(type == "simple"){
qint64 id = GetParametrId(domElement); try{
qint64 center = GetParametrLongLong(domElement, "center"); qint64 id = GetParametrId(domElement);
QString radius = GetParametrString(domElement, "radius"); qint64 center = GetParametrLongLong(domElement, "center");
QString f1 = GetParametrString(domElement, "angle1"); QString radius = GetParametrString(domElement, "radius");
QString f2 = GetParametrString(domElement, "angle2"); QString f1 = GetParametrString(domElement, "angle1");
if(mode == Draw::Calculation){ QString f2 = GetParametrString(domElement, "angle2");
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile); if(mode == Draw::Calculation){
} else { VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile);
VModelingArc::Create(id, center, radius, f1, f2, this, data, parse, Tool::FromFile); } else {
VModelingArc::Create(id, center, radius, f1, f2, this, data, parse, Tool::FromFile);
}
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
return;
} }
if(type == "modeling"){ if(type == "modeling"){
qint64 id = GetParametrId(domElement); try{
qint64 idObject = GetParametrLongLong(domElement, "idObject"); qint64 id = GetParametrId(domElement);
QString tObject = GetParametrString(domElement, "typeObject"); qint64 idObject = GetParametrLongLong(domElement, "idObject");
VArc arc; QString tObject = GetParametrString(domElement, "typeObject");
Draw::Mode typeObject; VArc arc;
if(tObject == "Calculation"){ Draw::Mode typeObject;
typeObject = Draw::Calculation; if(tObject == "Calculation"){
arc = data->GetArc(idObject); typeObject = Draw::Calculation;
} else { arc = data->GetArc(idObject);
typeObject = Draw::Modeling; } else {
arc = data->GetModelingArc(idObject); typeObject = Draw::Modeling;
arc = data->GetModelingArc(idObject);
}
arc.setMode(typeObject);
arc.setIdObject(idObject);
data->UpdateModelingArc(id, arc);
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating modeling arc"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
} }
arc.setMode(typeObject);
arc.setIdObject(idObject);
data->UpdateModelingArc(id, arc);
return;
} }
} }
void VDomDocument::FullUpdateTree(){ void VDomDocument::FullUpdateTree(){
VMainGraphicsScene *scene = new VMainGraphicsScene(); VMainGraphicsScene *scene = new VMainGraphicsScene();
Q_CHECK_PTR(scene); Q_CHECK_PTR(scene);
data->ClearObject(); try{
Parse(Document::LiteParse, scene, scene); data->ClearObject();
Parse(Document::LiteParse, scene, scene);
}
catch(...){
delete scene;
throw;
}
delete scene; delete scene;
setCurrentData(); setCurrentData();
emit FullUpdateFromFile(); emit FullUpdateFromFile();