Fix bugs. Wrong creation detail and wrong creation line.

--HG--
branch : develop
This commit is contained in:
dismine 2013-10-09 19:24:28 +03:00
parent bb0fed674b
commit b791ac648d
9 changed files with 58 additions and 20 deletions

View File

@ -73,8 +73,8 @@ void DialogDetail::DialogAccepted(){
details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole))); details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
} }
details.setName(ui.lineEditNameDetail->text()); details.setName(ui.lineEditNameDetail->text());
emit DialogClosed(QDialog::Accepted);
emit ToolTip(""); emit ToolTip("");
emit DialogClosed(QDialog::Accepted);
} }
void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode){ void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode){

View File

@ -87,7 +87,7 @@ QVector<QPointF> VSplinePath::GetPathPoints() const{
VSpline spl(points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(), VSpline spl(points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(),
path[i].KAsm1(), this->kCurve); path[i].KAsm1(), this->kCurve);
QVector<QPointF> splP = spl.GetPoints(); QVector<QPointF> splP = spl.GetPoints();
for(qint32 j = 0; i < splP.size(); ++j){ for(qint32 j = 0; j < splP.size(); ++j){
pathPoints.append(splP[j]); pathPoints.append(splP[j]);
} }
} }

View File

@ -51,19 +51,23 @@ void VToolLine::Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *s
Create(0, firstPoint, secondPoint, scene, doc, data, Document::FullParse, Tool::FromGui); Create(0, firstPoint, secondPoint, scene, doc, data, Document::FullParse, Tool::FromGui);
} }
void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint, void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation){ const Document::Documents &parse, Tool::Sources typeCreation){
Q_CHECK_PTR(scene); Q_CHECK_PTR(scene);
Q_CHECK_PTR(doc); Q_CHECK_PTR(doc);
Q_CHECK_PTR(data); Q_CHECK_PTR(data);
data->AddLine(firstPoint, secondPoint); qint64 id = _id;
if(parse != Document::FullParse){ if(typeCreation == Tool::FromGui){
doc->UpdateToolData(id, data); id = data->getNextId();
} else {
if(parse != Document::FullParse){
doc->UpdateToolData(id, data);
}
} }
data->AddLine(firstPoint, secondPoint);
VDrawTool::AddRecord(id, Tool::LineTool, doc); VDrawTool::AddRecord(id, Tool::LineTool, doc);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
qint64 id = data->getNextId();
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation); VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation);
Q_CHECK_PTR(line); Q_CHECK_PTR(line);
scene->addItem(line); scene->addItem(line);

View File

@ -34,7 +34,7 @@ public:
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, static void Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data); VContainer *data);
static void Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint, static void Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation); const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:

View File

@ -51,18 +51,22 @@ VModelingLine *VModelingLine::Create(QSharedPointer<DialogLine> &dialog, VDomDoc
return Create(0, firstPoint, secondPoint, doc, data, Document::FullParse, Tool::FromGui); return Create(0, firstPoint, secondPoint, doc, data, Document::FullParse, Tool::FromGui);
} }
VModelingLine *VModelingLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint, VModelingLine *VModelingLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation){ Tool::Sources typeCreation){
VModelingLine *line = 0; VModelingLine *line = 0;
Q_CHECK_PTR(doc); Q_CHECK_PTR(doc);
Q_CHECK_PTR(data); Q_CHECK_PTR(data);
data->AddLine(firstPoint, secondPoint, Draw::Modeling); qint64 id = _id;
if(parse != Document::FullParse){ if(typeCreation == Tool::FromGui){
doc->UpdateToolData(id, data); id = data->getNextId();
} else {
if(parse != Document::FullParse){
doc->UpdateToolData(id, data);
}
} }
data->AddLine(firstPoint, secondPoint, Draw::Modeling);
if(parse == Document::FullParse){ if(parse == Document::FullParse){
qint64 id = data->getNextId();
line = new VModelingLine(doc, data, id, firstPoint, secondPoint, typeCreation); line = new VModelingLine(doc, data, id, firstPoint, secondPoint, typeCreation);
doc->AddTool(id, line); doc->AddTool(id, line);
doc->IncrementReferens(firstPoint); doc->IncrementReferens(firstPoint);

View File

@ -34,7 +34,7 @@ public:
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static VModelingLine* Create(QSharedPointer<DialogLine> &dialog, VDomDocument *doc, VContainer *data); static VModelingLine* Create(QSharedPointer<DialogLine> &dialog, VDomDocument *doc, VContainer *data);
static VModelingLine* Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint, static VModelingLine* Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation); Tool::Sources typeCreation);
public slots: public slots:

View File

@ -35,7 +35,8 @@ VNodeSpline::VNodeSpline(VDomDocument *doc, VContainer *data, qint64 id, qint64
} }
VNodeSpline *VNodeSpline::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, VNodeSpline *VNodeSpline::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
Draw::Draws typeobject, const Document::Documents &parse, Tool::Sources typeCreation){ Draw::Draws typeobject, const Document::Documents &parse,
Tool::Sources typeCreation){
VNodeSpline *spl = 0; VNodeSpline *spl = 0;
if(parse == Document::FullParse){ if(parse == Document::FullParse){
spl = new VNodeSpline(doc, data, id, idSpline, typeobject, typeCreation); spl = new VNodeSpline(doc, data, id, idSpline, typeobject, typeCreation);

View File

@ -189,6 +189,8 @@ void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScen
point = data->GetModelingPoint(detail[i].getId()); point = data->GetModelingPoint(detail[i].getId());
} }
id = data->AddModelingPoint(point); id = data->AddModelingPoint(point);
VNodePoint::Create(doc, data, id, detail[i].getId(), detail[i].getMode(),
Document::FullParse, Tool::FromGui);
} }
break; break;
case(Tool::NodeArc):{ case(Tool::NodeArc):{
@ -199,6 +201,8 @@ void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScen
arc = data->GetModelingArc(detail[i].getId()); arc = data->GetModelingArc(detail[i].getId());
} }
id = data->AddModelingArc(arc); id = data->AddModelingArc(arc);
VNodeArc::Create(doc, data, id, detail[i].getId(), detail[i].getMode(),
Document::FullParse, Tool::FromGui);
} }
break; break;
case(Tool::NodeSpline):{ case(Tool::NodeSpline):{
@ -209,6 +213,8 @@ void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScen
spline = data->GetModelingSpline(detail[i].getId()); spline = data->GetModelingSpline(detail[i].getId());
} }
id = data->AddModelingSpline(spline); id = data->AddModelingSpline(spline);
VNodeSpline::Create(doc, data, id, detail[i].getId(), detail[i].getMode(),
Document::FullParse, Tool::FromGui);
} }
break; break;
case(Tool::NodeSplinePath):{ case(Tool::NodeSplinePath):{
@ -219,6 +225,8 @@ void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScen
splinePath = data->GetModelingSplinePath(detail[i].getId()); splinePath = data->GetModelingSplinePath(detail[i].getId());
} }
id = data->AddModelingSplinePath(splinePath); id = data->AddModelingSplinePath(splinePath);
VNodeSplinePath::Create(doc, data, id, detail[i].getId(), detail[i].getMode(),
Document::FullParse, Tool::FromGui);
} }
break; break;
default: default:
@ -328,19 +336,24 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
// dialog->show(); // dialog->show();
// } // }
if(selectedAction == actionRemove){ if(selectedAction == actionRemove){
//deincrement referens
RemoveReferens();
//remove form xml file //remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if(domElement.isElement()){
QDomNode element = domElement.parentNode(); QDomNode element = domElement.parentNode();
if(!element.isNull()){ if(!element.isNull()){
//deincrement referens
RemoveReferens();
element.removeChild(domElement); element.removeChild(domElement);
//update xml file //update xml file
emit FullUpdateTree(); emit FullUpdateTree();
//remove form scene //remove form scene
emit RemoveTool(this); emit RemoveTool(this);
} else {
qWarning()<<"parentNode isNull"<<Q_FUNC_INFO;
} }
} else {
qWarning()<<"Can't get element by id = "<<id<<Q_FUNC_INFO;
} }
} }
} }

View File

@ -34,6 +34,7 @@
#include "exception/vexceptionbadid.h" #include "exception/vexceptionbadid.h"
#include "exception/vexceptionobjecterror.h" #include "exception/vexceptionobjecterror.h"
#include "exception/vexceptionuniqueid.h" #include "exception/vexceptionuniqueid.h"
#include <QMessageBox>
VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode) : QDomDocument(), VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode) : QDomDocument(),
map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data), map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data),
@ -417,7 +418,8 @@ void VDomDocument::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphics
} }
void VDomDocument::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, void VDomDocument::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse, Draw::Draws mode){ const QDomNode& node, const Document::Documents &parse,
Draw::Draws mode){
Q_CHECK_PTR(sceneDraw); Q_CHECK_PTR(sceneDraw);
Q_CHECK_PTR(sceneDetail); Q_CHECK_PTR(sceneDetail);
VMainGraphicsScene *scene = 0; VMainGraphicsScene *scene = 0;
@ -545,7 +547,8 @@ void VDomDocument::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomEleme
} }
void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement, void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString& type, Draw::Draws mode){ const Document::Documents &parse, const QString& type,
Draw::Draws 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");
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");
@ -901,7 +904,7 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
spl.setMode(typeObject); spl.setMode(typeObject);
spl.setIdObject(idObject); spl.setIdObject(idObject);
data->UpdateModelingSpline(id, spl); data->UpdateModelingSpline(id, spl);
VNodeSpline::Create(this, data, id, idObject,mode, parse, Tool::FromFile); VNodeSpline::Create(this, data, id, idObject, mode, parse, Tool::FromFile);
return; return;
} }
catch(const VExceptionBadId &e){ catch(const VExceptionBadId &e){
@ -1000,10 +1003,23 @@ void VDomDocument::FullUpdateTree(){
data->ClearObject(); data->ClearObject();
Parse(Document::LiteParse, scene, scene); Parse(Document::LiteParse, scene, scene);
} }
catch (const std::bad_alloc &) {
delete scene;
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
msgBox.setText(tr("Error parsing file."));
msgBox.setInformativeText("std::bad_alloc");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.setIcon(QMessageBox::Warning);
msgBox.exec();
return;
}
catch(...){ catch(...){
delete scene; delete scene;
throw; throw;
} }
delete scene; delete scene;
setCurrentData(); setCurrentData();
emit FullUpdateFromFile(); emit FullUpdateFromFile();