2013-07-13 12:51:31 +02:00
|
|
|
#include "vdomdocument.h"
|
2013-07-25 14:00:51 +02:00
|
|
|
#include <QDebug>
|
2013-08-05 10:37:56 +02:00
|
|
|
#include "../tools/vtoolsinglepoint.h"
|
2013-07-25 14:00:51 +02:00
|
|
|
#include "../tools/vtoolendline.h"
|
2013-07-25 20:39:51 +02:00
|
|
|
#include "../tools/vtoolline.h"
|
2013-07-28 00:18:06 +02:00
|
|
|
#include "../tools/vtoolalongline.h"
|
2013-07-29 14:55:40 +02:00
|
|
|
#include "../tools/vtoolshoulderpoint.h"
|
2013-07-30 15:09:34 +02:00
|
|
|
#include "../tools/vtoolnormal.h"
|
2013-07-30 20:46:40 +02:00
|
|
|
#include "../tools/vtoolbisector.h"
|
2013-07-31 13:34:39 +02:00
|
|
|
#include "../tools/vtoollineintersect.h"
|
2013-08-05 10:37:56 +02:00
|
|
|
#include "../tools/vtoolspline.h"
|
2013-08-06 09:56:09 +02:00
|
|
|
#include "../tools/vtoolarc.h"
|
2013-08-09 08:49:34 +02:00
|
|
|
#include "../tools/vtoolsplinepath.h"
|
2013-08-21 10:03:53 +02:00
|
|
|
#include "../tools/vtoolpointofcontact.h"
|
2013-08-28 10:55:11 +02:00
|
|
|
#include "../tools/vmodelingpoint.h"
|
|
|
|
#include "../tools/vtooldetail.h"
|
2013-07-13 12:51:31 +02:00
|
|
|
#include "../options.h"
|
2013-07-25 14:00:51 +02:00
|
|
|
#include "../container/calculator.h"
|
2013-08-09 08:49:34 +02:00
|
|
|
#include "../geometry/vsplinepoint.h"
|
2013-07-13 12:51:31 +02:00
|
|
|
|
|
|
|
|
2013-08-13 18:48:36 +02:00
|
|
|
|
2013-08-20 12:26:02 +02:00
|
|
|
VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws) : QDomDocument(),
|
|
|
|
map(QMap<QString, QDomElement>()), nameActivDraw(QString()), data(data),
|
|
|
|
tools(QMap<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
|
|
|
|
comboBoxDraws(comboBoxDraws){
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
2013-08-20 12:26:02 +02:00
|
|
|
VDomDocument::VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws) :
|
|
|
|
QDomDocument(name), map(QMap<QString, QDomElement>()), nameActivDraw(QString()), data(data),
|
|
|
|
tools(QMap<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
|
|
|
|
comboBoxDraws(comboBoxDraws){
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
2013-08-20 12:26:02 +02:00
|
|
|
VDomDocument::VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws) :
|
|
|
|
QDomDocument(doctype), map(QMap<QString, QDomElement>()), nameActivDraw(QString()), data(data),
|
|
|
|
tools(QMap<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
|
|
|
|
comboBoxDraws(comboBoxDraws){
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
2013-08-13 18:48:36 +02:00
|
|
|
VDomDocument::~VDomDocument(){
|
|
|
|
}
|
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomElement VDomDocument::elementById(const QString& id){
|
|
|
|
if (map.contains(id)) {
|
|
|
|
QDomElement e = map[id];
|
|
|
|
if (e.parentNode().nodeType() != QDomNode::BaseNode) {
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
map.remove(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool res = this->find(this->documentElement(), id);
|
|
|
|
if (res) {
|
|
|
|
return map[id];
|
|
|
|
}
|
|
|
|
|
|
|
|
return QDomElement();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VDomDocument::find(QDomElement node, const QString& id){
|
|
|
|
if (node.hasAttribute("id")) {
|
|
|
|
QString value = node.attribute("id");
|
|
|
|
this->map[value] = node;
|
|
|
|
if (value == id) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (qint32 i=0; i<node.childNodes().length(); ++i) {
|
|
|
|
QDomNode n = node.childNodes().at(i);
|
|
|
|
if (n.isElement()) {
|
|
|
|
bool res = this->find(n.toElement(), id);
|
|
|
|
if (res) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::CreateEmptyFile(){
|
|
|
|
QDomElement domElement = this->createElement("lekalo");
|
|
|
|
this->appendChild(domElement);
|
|
|
|
QDomNode xmlNode = this->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
|
|
|
|
this->insertBefore(xmlNode, this->firstChild());
|
2013-07-17 13:38:11 +02:00
|
|
|
QDomElement incrElement = this->createElement("increments");
|
|
|
|
domElement.appendChild(incrElement);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool VDomDocument::CheckNameDraw(const QString& name) const{
|
|
|
|
QDomNodeList elements = this->documentElement().elementsByTagName( "draw" );
|
|
|
|
if(elements.size() == 0){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for ( qint32 i = 0; i < elements.count(); i++ ){
|
|
|
|
QDomElement elem = elements.at( i ).toElement();
|
|
|
|
if(!elem.isNull()){
|
|
|
|
QString fieldName = elem.attribute( "name" );
|
|
|
|
if ( fieldName == name ){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VDomDocument::appendDraw(const QString& name){
|
|
|
|
if(name.isEmpty()){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(CheckNameDraw(name)== false){
|
|
|
|
QDomElement rootElement = this->documentElement();
|
|
|
|
|
|
|
|
QDomElement drawElement = this->createElement("draw");
|
|
|
|
QDomAttr drawAttr = this->createAttribute("name");
|
|
|
|
drawAttr.setValue(name);
|
|
|
|
drawElement.setAttributeNode(drawAttr);
|
|
|
|
|
|
|
|
QDomElement calculationElement = this->createElement("calculation");
|
|
|
|
QDomElement modelingElement = this->createElement("modeling");
|
2013-08-28 10:55:11 +02:00
|
|
|
QDomElement pathsElement = this->createElement("details");
|
2013-07-13 12:51:31 +02:00
|
|
|
drawElement.appendChild(calculationElement);
|
|
|
|
drawElement.appendChild(modelingElement);
|
|
|
|
drawElement.appendChild(pathsElement);
|
|
|
|
|
|
|
|
rootElement.appendChild(drawElement);
|
|
|
|
|
|
|
|
if(nameActivDraw.isEmpty()){
|
|
|
|
SetActivDraw(name);
|
|
|
|
} else {
|
|
|
|
ChangeActivDraw(name);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-08-15 22:39:00 +02:00
|
|
|
void VDomDocument::ChangeActivDraw(const QString& name, Document::Enum parse){
|
2013-07-13 12:51:31 +02:00
|
|
|
if(CheckNameDraw(name) == true){
|
|
|
|
this->nameActivDraw = name;
|
2013-08-15 22:39:00 +02:00
|
|
|
if(parse == Document::FullParse){
|
|
|
|
emit ChangedActivDraw(name);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::SetNameDraw(const QString& name){
|
|
|
|
QString oldName = nameActivDraw;
|
|
|
|
nameActivDraw = name;
|
|
|
|
emit ChangedNameDraw(oldName, nameActivDraw);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::SetActivDraw(const QString& name){
|
|
|
|
this->nameActivDraw = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString VDomDocument::GetNameActivDraw() const{
|
|
|
|
return nameActivDraw;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VDomDocument::GetActivDrawElement(QDomElement &element){
|
|
|
|
if(!nameActivDraw.isEmpty()){
|
|
|
|
QDomNodeList elements = this->documentElement().elementsByTagName( "draw" );
|
|
|
|
if(elements.size() == 0){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for ( qint32 i = 0; i < elements.count(); i++ ){
|
|
|
|
element = elements.at( i ).toElement();
|
|
|
|
if(!element.isNull()){
|
|
|
|
QString fieldName = element.attribute( "name" );
|
|
|
|
if ( fieldName == nameActivDraw ){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VDomDocument::GetActivCalculationElement(QDomElement &element){
|
|
|
|
bool ok = GetActivNodeElement("calculation", element);
|
|
|
|
if(ok){
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VDomDocument::GetActivModelingElement(QDomElement &element){
|
|
|
|
bool ok = GetActivNodeElement("modeling", element);
|
|
|
|
if(ok){
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
bool VDomDocument::GetActivDetailsElement(QDomElement &element){
|
|
|
|
bool ok = GetActivNodeElement("details", element);
|
2013-07-13 12:51:31 +02:00
|
|
|
if(ok){
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VDomDocument::GetActivNodeElement(const QString& name, QDomElement &element){
|
|
|
|
QDomElement drawElement;
|
|
|
|
bool drawOk = this->GetActivDrawElement(drawElement);
|
|
|
|
if(drawOk == true){
|
|
|
|
QDomNodeList listElement = drawElement.elementsByTagName(name);
|
|
|
|
if(listElement.size() == 0 || listElement.size() > 1){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
element = listElement.at( 0 ).toElement();
|
|
|
|
if(!element.isNull()){
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
void VDomDocument::Parse(Document::Enum parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail){
|
2013-07-13 12:51:31 +02:00
|
|
|
if(parse == Document::FullParse){
|
|
|
|
data->Clear();
|
|
|
|
nameActivDraw.clear();
|
2013-08-28 10:55:11 +02:00
|
|
|
sceneDraw->clear();
|
|
|
|
sceneDetail->clear();
|
2013-07-13 12:51:31 +02:00
|
|
|
comboBoxDraws->clear();
|
2013-08-13 18:48:36 +02:00
|
|
|
tools.clear();
|
2013-08-15 22:39:00 +02:00
|
|
|
cursor = 0;
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
data->ClearLengthLines();
|
|
|
|
data->ClearLengthArcs();
|
|
|
|
data->ClearLengthSplines();
|
2013-08-21 10:03:53 +02:00
|
|
|
data->ClearLineAngles();
|
2013-08-15 22:39:00 +02:00
|
|
|
history.clear();
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomElement rootElement = this->documentElement();
|
|
|
|
QDomNode domNode = rootElement.firstChild();
|
|
|
|
while(!domNode.isNull()){
|
|
|
|
if(domNode.isElement()){
|
|
|
|
QDomElement domElement = domNode.toElement();
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
if(domElement.tagName()=="draw"){
|
|
|
|
if(parse == Document::FullParse){
|
|
|
|
if(nameActivDraw.isEmpty()){
|
|
|
|
SetActivDraw(domElement.attribute("name"));
|
|
|
|
} else {
|
|
|
|
ChangeActivDraw(domElement.attribute("name"));
|
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
comboBoxDraws->addItem(domElement.attribute("name"));
|
|
|
|
} else {
|
|
|
|
ChangeActivDraw(domElement.attribute("name"), Document::LiteParse);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
ParseDrawElement(sceneDraw, sceneDetail, domElement, parse);
|
2013-07-17 13:38:11 +02:00
|
|
|
}
|
|
|
|
if(domElement.tagName()=="increments"){
|
|
|
|
ParseIncrementsElement(domElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-13 18:48:36 +02:00
|
|
|
QMap<qint64, VDataTool *> *VDomDocument::getTools(){
|
|
|
|
return &tools;
|
|
|
|
}
|
|
|
|
|
2013-08-15 22:39:00 +02:00
|
|
|
QVector<VToolRecord> *VDomDocument::getHistory(){
|
|
|
|
return &history;
|
|
|
|
}
|
|
|
|
|
2013-07-17 13:38:11 +02:00
|
|
|
void VDomDocument::ParseIncrementsElement(const QDomNode &node){
|
|
|
|
QDomNode domNode = node.firstChild();
|
|
|
|
while(!domNode.isNull()){
|
|
|
|
if(domNode.isElement()){
|
|
|
|
QDomElement domElement = domNode.toElement();
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
if(domElement.tagName() == "increment"){
|
|
|
|
QString name,desc;
|
2013-08-13 18:48:36 +02:00
|
|
|
qreal base;
|
2013-07-17 13:38:11 +02:00
|
|
|
qreal ksize, kgrowth;
|
|
|
|
qint64 id;
|
|
|
|
id = domElement.attribute("id", "").toLongLong();
|
|
|
|
name = domElement.attribute("name", "");
|
2013-08-13 18:48:36 +02:00
|
|
|
base = domElement.attribute("base","").toDouble();
|
2013-07-17 13:38:11 +02:00
|
|
|
ksize = domElement.attribute("ksize","").toDouble();
|
|
|
|
kgrowth = domElement.attribute("kgrowth","").toDouble();
|
|
|
|
desc = domElement.attribute("description","");
|
2013-08-13 18:48:36 +02:00
|
|
|
data->UpdateId(id);
|
2013-07-17 13:38:11 +02:00
|
|
|
data->AddIncrementTableRow(name,
|
|
|
|
VIncrementTableRow(id, base, ksize, kgrowth, desc));
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
void VDomDocument::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
|
|
|
const QDomNode& node, Document::Enum parse){
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomNode domNode = node.firstChild();
|
|
|
|
while(!domNode.isNull()){
|
|
|
|
if(domNode.isElement()){
|
|
|
|
QDomElement domElement = domNode.toElement();
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
if(domElement.tagName() == "calculation"){
|
2013-08-15 22:39:00 +02:00
|
|
|
data->ClearObject();
|
2013-08-28 10:55:11 +02:00
|
|
|
ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Calculation);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
if(domElement.tagName() == "modeling"){
|
2013-08-28 10:55:11 +02:00
|
|
|
ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Modeling);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
if(domElement.tagName() == "details"){
|
|
|
|
ParseDetails(sceneDetail, domElement, parse);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
domNode = domNode.nextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
void VDomDocument::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
|
|
|
const QDomNode& node, Document::Enum parse, Draw::Mode mode){
|
|
|
|
VMainGraphicsScene *scene = 0;
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
scene = sceneDraw;
|
|
|
|
} else {
|
|
|
|
scene = sceneDetail;
|
|
|
|
}
|
2013-07-13 12:51:31 +02:00
|
|
|
QDomNodeList nodeList = node.childNodes();
|
|
|
|
qint32 num = nodeList.size();
|
|
|
|
for(qint32 i = 0; i < num; ++i){
|
|
|
|
QDomElement domElement = nodeList.at(i).toElement();
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
if(domElement.tagName() == "point"){
|
2013-08-28 10:55:11 +02:00
|
|
|
ParsePointElement(scene, domElement, parse, domElement.attribute("type", ""), mode);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-07-25 20:39:51 +02:00
|
|
|
if(domElement.tagName() == "line"){
|
2013-08-28 10:55:11 +02:00
|
|
|
ParseLineElement(scene, domElement, parse, mode);
|
2013-07-25 20:39:51 +02:00
|
|
|
}
|
2013-08-05 10:37:56 +02:00
|
|
|
if(domElement.tagName() == "spline"){
|
2013-08-28 10:55:11 +02:00
|
|
|
ParseSplineElement(scene, domElement, parse, domElement.attribute("type", ""), mode);
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
if(domElement.tagName() == "arc"){
|
2013-08-28 10:55:11 +02:00
|
|
|
ParseArcElement(scene, domElement, parse, domElement.attribute("type", ""), mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
|
|
|
|
Document::Enum parse){
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
VDetail detail;
|
|
|
|
VDetail oldDetail;
|
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
detail.setName(domElement.attribute("name", ""));
|
|
|
|
detail.setMx(toPixel(domElement.attribute("mx","").toDouble()));
|
|
|
|
detail.setMy(toPixel(domElement.attribute("my","").toDouble()));
|
|
|
|
|
|
|
|
QDomNodeList nodeList = domElement.childNodes();
|
|
|
|
qint32 num = nodeList.size();
|
|
|
|
for(qint32 i = 0; i < num; ++i){
|
|
|
|
QDomElement element = nodeList.at(i).toElement();
|
|
|
|
if(!element.isNull()){
|
|
|
|
if(element.tagName() == "node"){
|
|
|
|
qint64 id = element.attribute("id","").toLongLong();
|
|
|
|
Scene::Type tool;
|
|
|
|
Draw::Mode mode;
|
|
|
|
QString t = element.attribute("type","");
|
|
|
|
if(t == "Point"){
|
|
|
|
tool = Scene::Point;
|
|
|
|
VPointF point = data->GetModelingPoint(id);
|
|
|
|
mode = point.getMode();
|
|
|
|
oldDetail.append(VNodeDetail(point.getIdObject(), tool, mode));
|
|
|
|
} else if(t == "Arc"){
|
|
|
|
tool = Scene::Arc;
|
|
|
|
VArc arc = data->GetModelingArc(id);
|
|
|
|
mode = arc.getMode();
|
|
|
|
oldDetail.append(VNodeDetail(arc.getIdObject(), tool, mode));
|
|
|
|
} else if(t == "Spline"){
|
|
|
|
tool = Scene::Spline;
|
|
|
|
VSpline spl = data->GetModelingSpline(id);
|
|
|
|
mode = spl.getMode();
|
|
|
|
oldDetail.append(VNodeDetail(spl.getIdObject(), tool, mode));
|
|
|
|
} else if(t == "SplinePath"){
|
|
|
|
tool = Scene::SplinePath;
|
|
|
|
VSplinePath splPath = data->GetModelingSplinePath(id);
|
|
|
|
mode = splPath.getMode();
|
|
|
|
oldDetail.append(VNodeDetail(splPath.getIdObject(), tool, mode));
|
|
|
|
}
|
|
|
|
detail.append(VNodeDetail(id, tool, mode));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VToolDetail::Create(id, detail, oldDetail, sceneDetail, this, data, parse, Tool::FromFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
|
|
|
|
Document::Enum parse){
|
|
|
|
QDomNode domNode = domElement.firstChild();
|
|
|
|
while(!domNode.isNull()){
|
|
|
|
if(domNode.isElement()){
|
|
|
|
QDomElement domElement = domNode.toElement();
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
if(domElement.tagName() == "detail"){
|
|
|
|
ParseDetailElement(sceneDetail, domElement, parse);
|
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
domNode = domNode.nextSibling();
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
2013-08-28 10:55:11 +02:00
|
|
|
Document::Enum parse, const QString& type, Draw::Mode mode){
|
2013-08-05 10:37:56 +02:00
|
|
|
if(type == "single"){
|
2013-07-13 12:51:31 +02:00
|
|
|
if(!domElement.isNull()){
|
|
|
|
QString name;
|
|
|
|
qreal mx=5, my=10, x, y;
|
|
|
|
qint64 id;
|
2013-08-09 08:49:34 +02:00
|
|
|
|
|
|
|
id = domElement.attribute("id", "").toLongLong();
|
|
|
|
name = domElement.attribute("name", "");
|
|
|
|
x = domElement.attribute("x","").toDouble()*PrintDPI/25.4;
|
|
|
|
y = domElement.attribute("y","").toDouble()*PrintDPI/25.4;
|
|
|
|
mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4;
|
|
|
|
my = domElement.attribute("my","").toDouble()*PrintDPI/25.4;
|
|
|
|
|
|
|
|
data->UpdatePoint(id, VPointF(x, y, name, mx, my));
|
2013-08-15 22:39:00 +02:00
|
|
|
VAbstractTool::AddRecord(id, Tools::SinglePointTool, this);
|
2013-08-13 18:48:36 +02:00
|
|
|
if(parse != Document::FullParse){
|
|
|
|
VToolSinglePoint *spoint = qobject_cast<VToolSinglePoint*>(tools[id]);
|
|
|
|
spoint->VDataTool::setData(data);
|
|
|
|
tools[id] = spoint;
|
|
|
|
}
|
2013-08-09 08:49:34 +02:00
|
|
|
if(parse == Document::FullParse){
|
|
|
|
VToolSinglePoint *spoint = new VToolSinglePoint(this, data, id, Tool::FromFile);
|
|
|
|
scene->addItem(spoint);
|
|
|
|
connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
2013-08-15 22:39:00 +02:00
|
|
|
tools[id] = spoint;
|
2013-07-25 14:00:51 +02:00
|
|
|
}
|
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
return;
|
2013-07-25 14:00:51 +02:00
|
|
|
}
|
|
|
|
if(type == "endLine"){
|
|
|
|
if(!domElement.isNull()){
|
2013-08-13 18:48:36 +02:00
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
QString name = domElement.attribute("name", "");
|
|
|
|
qreal mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4;
|
|
|
|
qreal my = domElement.attribute("my","").toDouble()*PrintDPI/25.4;
|
|
|
|
QString typeLine = domElement.attribute("typeLine", "");
|
|
|
|
QString formula = domElement.attribute("length", "");
|
|
|
|
qint64 basePointId = domElement.attribute("basePoint", "").toLongLong();
|
|
|
|
qint32 angle = domElement.attribute("angle", "").toInt();
|
|
|
|
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this, data,
|
2013-08-28 10:55:11 +02:00
|
|
|
parse, Tool::FromFile, mode);
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(type == "alongLine"){
|
|
|
|
if(!domElement.isNull()){
|
2013-08-13 18:48:36 +02:00
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
QString name = domElement.attribute("name", "");
|
|
|
|
qreal mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4;
|
|
|
|
qreal my = domElement.attribute("my","").toDouble()*PrintDPI/25.4;
|
|
|
|
QString typeLine = domElement.attribute("typeLine", "");
|
|
|
|
QString formula = domElement.attribute("length", "");
|
|
|
|
qint64 firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
|
|
|
qint64 secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
|
|
|
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my,
|
2013-08-28 10:55:11 +02:00
|
|
|
scene, this, data, parse, Tool::FromFile, mode);
|
2013-07-28 00:18:06 +02:00
|
|
|
}
|
|
|
|
return;
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-07-29 14:55:40 +02:00
|
|
|
if(type == "shoulder"){
|
|
|
|
if(!domElement.isNull()){
|
2013-08-13 18:48:36 +02:00
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
QString name = domElement.attribute("name", "");
|
|
|
|
qreal mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4;
|
|
|
|
qreal my = domElement.attribute("my","").toDouble()*PrintDPI/25.4;
|
|
|
|
QString typeLine = domElement.attribute("typeLine", "");
|
|
|
|
QString formula = domElement.attribute("length", "");
|
|
|
|
qint64 p1Line = domElement.attribute("p1Line", "").toLongLong();
|
|
|
|
qint64 p2Line = domElement.attribute("p2Line", "").toLongLong();
|
|
|
|
qint64 pShoulder = domElement.attribute("pShoulder", "").toLongLong();
|
|
|
|
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my,
|
2013-08-28 10:55:11 +02:00
|
|
|
scene, this, data, parse, Tool::FromFile, mode);
|
2013-07-29 14:55:40 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2013-07-30 15:09:34 +02:00
|
|
|
if(type == "normal"){
|
|
|
|
if(!domElement.isNull()){
|
2013-08-13 18:48:36 +02:00
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
QString name = domElement.attribute("name", "");
|
|
|
|
qreal mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4;
|
|
|
|
qreal my = domElement.attribute("my","").toDouble()*PrintDPI/25.4;
|
|
|
|
QString typeLine = domElement.attribute("typeLine", "");
|
|
|
|
QString formula = domElement.attribute("length", "");
|
|
|
|
qint64 firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
|
|
|
qint64 secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
2013-08-20 12:26:02 +02:00
|
|
|
qreal angle = domElement.attribute("angle", "").toDouble();
|
2013-08-13 18:48:36 +02:00
|
|
|
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle,
|
2013-08-28 10:55:11 +02:00
|
|
|
mx, my, scene, this, data, parse, Tool::FromFile, mode);
|
2013-07-30 15:09:34 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2013-07-30 20:46:40 +02:00
|
|
|
if(type == "bisector"){
|
|
|
|
if(!domElement.isNull()){
|
2013-08-13 18:48:36 +02:00
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
QString name = domElement.attribute("name", "");
|
|
|
|
qreal mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4;
|
|
|
|
qreal my = domElement.attribute("my","").toDouble()*PrintDPI/25.4;
|
|
|
|
QString typeLine = domElement.attribute("typeLine", "");
|
|
|
|
QString formula = domElement.attribute("length", "");
|
|
|
|
qint64 firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
|
|
|
qint64 secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
|
|
|
qint64 thirdPointId = domElement.attribute("thirdPoint", "").toLongLong();
|
|
|
|
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine,
|
2013-08-28 10:55:11 +02:00
|
|
|
name, mx, my, scene, this, data, parse, Tool::FromFile, mode);
|
2013-07-30 20:46:40 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2013-07-31 13:34:39 +02:00
|
|
|
if(type == "lineIntersect"){
|
|
|
|
if(!domElement.isNull()){
|
2013-08-13 18:48:36 +02:00
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
QString name = domElement.attribute("name", "");
|
|
|
|
qreal mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4;
|
|
|
|
qreal my = domElement.attribute("my","").toDouble()*PrintDPI/25.4;
|
|
|
|
qint64 p1Line1Id = domElement.attribute("p1Line1", "").toLongLong();
|
|
|
|
qint64 p2Line1Id = domElement.attribute("p2Line1", "").toLongLong();
|
|
|
|
qint64 p1Line2Id = domElement.attribute("p1Line2", "").toLongLong();
|
|
|
|
qint64 p2Line2Id = domElement.attribute("p2Line2", "").toLongLong();
|
|
|
|
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my, scene,
|
2013-08-28 10:55:11 +02:00
|
|
|
this, data, parse, Tool::FromFile, mode);
|
2013-07-31 13:34:39 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2013-08-21 10:03:53 +02:00
|
|
|
if(type == "pointOfContact"){
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
QString name = domElement.attribute("name", "");
|
|
|
|
qreal mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4;
|
|
|
|
qreal my = domElement.attribute("my","").toDouble()*PrintDPI/25.4;
|
|
|
|
QString radius = domElement.attribute("radius", "");
|
|
|
|
qint64 center = domElement.attribute("center", "").toLongLong();
|
|
|
|
qint64 firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
|
|
|
qint64 secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
|
|
|
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my,
|
2013-08-28 10:55:11 +02:00
|
|
|
scene, this, data, parse, Tool::FromFile, mode);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(type == "modeling"){
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
qint64 idObject = domElement.attribute("idObject", "").toLongLong();
|
|
|
|
QString tObject = domElement.attribute("typeObject", "");
|
|
|
|
VPointF point;
|
|
|
|
Draw::Mode typeObject;
|
|
|
|
if(tObject == "Calculation"){
|
|
|
|
typeObject = Draw::Calculation;
|
|
|
|
point = data->GetPoint(idObject );
|
|
|
|
} else {
|
|
|
|
typeObject = Draw::Modeling;
|
|
|
|
point = data->GetModelingPoint(idObject);
|
|
|
|
}
|
|
|
|
qreal mx = toPixel(domElement.attribute("mx","").toDouble());
|
|
|
|
qreal my = toPixel(domElement.attribute("my","").toDouble());
|
|
|
|
data->UpdateModelingPoint(id, VPointF(point.x(), point.y(), point.name(), mx, my, typeObject,
|
|
|
|
idObject ));
|
|
|
|
data->IncrementReferens(idObject, Scene::Point);
|
2013-08-21 10:03:53 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
|
|
|
|
2013-07-25 20:39:51 +02:00
|
|
|
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
2013-08-28 10:55:11 +02:00
|
|
|
Document::Enum parse, Draw::Mode mode){
|
2013-07-25 20:39:51 +02:00
|
|
|
if(!domElement.isNull()){
|
2013-08-13 18:48:36 +02:00
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
qint64 firstPoint = domElement.attribute("firstPoint", "").toLongLong();
|
|
|
|
qint64 secondPoint = domElement.attribute("secondPoint", "").toLongLong();
|
2013-08-28 10:55:11 +02:00
|
|
|
VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile, mode);
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
2013-08-28 10:55:11 +02:00
|
|
|
Document::Enum parse, const QString &type, Draw::Mode mode){
|
2013-08-05 10:37:56 +02:00
|
|
|
if(type == "simple"){
|
|
|
|
if(!domElement.isNull()){
|
2013-08-13 18:48:36 +02:00
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
qint64 point1 = domElement.attribute("point1", "").toLongLong();
|
|
|
|
qint64 point4 = domElement.attribute("point4", "").toLongLong();
|
|
|
|
qreal angle1 = domElement.attribute("angle1","").toDouble();
|
|
|
|
qreal angle2 = domElement.attribute("angle2","").toDouble();
|
|
|
|
qreal kAsm1 = domElement.attribute("kAsm1","").toDouble();
|
|
|
|
qreal kAsm2 = domElement.attribute("kAsm2","").toDouble();
|
|
|
|
qreal kCurve = domElement.attribute("kCurve","").toDouble();
|
|
|
|
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, data,
|
2013-08-28 10:55:11 +02:00
|
|
|
parse, Tool::FromFile, mode);
|
2013-08-09 08:49:34 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(type == "path"){
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
qreal kCurve = domElement.attribute("kCurve","").toDouble();
|
|
|
|
VSplinePath path(data->DataPoints(), kCurve);
|
|
|
|
|
|
|
|
QDomNodeList nodeList = domElement.childNodes();
|
|
|
|
qint32 num = nodeList.size();
|
|
|
|
for(qint32 i = 0; i < num; ++i){
|
|
|
|
QDomElement element = nodeList.at(i).toElement();
|
|
|
|
if(!element.isNull()){
|
|
|
|
if(element.tagName() == "pathPoint"){
|
|
|
|
qint64 pSpline = element.attribute("pSpline","").toLongLong();
|
|
|
|
qreal kAsm1 = element.attribute("kAsm1","").toDouble();
|
|
|
|
qreal angle = element.attribute("angle","").toDouble();
|
|
|
|
qreal kAsm2 = element.attribute("kAsm2","").toDouble();
|
|
|
|
VSplinePoint splPoint(pSpline, kAsm1, angle, kAsm2);
|
|
|
|
path.append(splPoint);
|
|
|
|
}
|
2013-08-05 10:37:56 +02:00
|
|
|
}
|
2013-07-25 20:39:51 +02:00
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile, mode);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(type == "modelingSpline"){
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
qint64 idObject = domElement.attribute("idObject", "").toLongLong();
|
|
|
|
QString tObject = domElement.attribute("typeObject", "");
|
|
|
|
VSpline spl;
|
|
|
|
Draw::Mode typeObject;
|
|
|
|
if(tObject == "Calculation"){
|
|
|
|
typeObject = Draw::Calculation;
|
|
|
|
spl = data->GetSpline(idObject);
|
|
|
|
} else {
|
|
|
|
typeObject = Draw::Modeling;
|
|
|
|
spl = data->GetModelingSpline(idObject);
|
|
|
|
}
|
|
|
|
spl.setMode(typeObject);
|
|
|
|
spl.setIdObject(idObject);
|
|
|
|
data->UpdateModelingSpline(id, spl);
|
|
|
|
data->IncrementReferens(spl.GetP1(), Scene::Point);
|
|
|
|
data->IncrementReferens(spl.GetP4(), Scene::Point);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(type == "modelingPath"){
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
qint64 idObject = domElement.attribute("idObject", "").toLongLong();
|
|
|
|
QString tObject = domElement.attribute("typeObject", "");
|
|
|
|
VSplinePath path;
|
|
|
|
Draw::Mode typeObject;
|
|
|
|
if(tObject == "Calculation"){
|
|
|
|
typeObject = Draw::Calculation;
|
|
|
|
path = data->GetSplinePath(idObject);
|
|
|
|
} else {
|
|
|
|
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){
|
|
|
|
data->IncrementReferens(points->at(i).P(), Scene::Point);
|
|
|
|
}
|
2013-07-25 20:39:51 +02:00
|
|
|
}
|
2013-08-05 10:37:56 +02:00
|
|
|
return;
|
2013-07-25 20:39:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-06 09:56:09 +02:00
|
|
|
void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
2013-08-28 10:55:11 +02:00
|
|
|
Document::Enum parse, const QString &type, Draw::Mode mode){
|
2013-08-06 09:56:09 +02:00
|
|
|
if(type == "simple"){
|
|
|
|
if(!domElement.isNull()){
|
2013-08-13 18:48:36 +02:00
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
qint64 center = domElement.attribute("center", "").toLongLong();
|
|
|
|
QString radius = domElement.attribute("radius", "");
|
|
|
|
QString f1 = domElement.attribute("angle1", "");
|
|
|
|
QString f2 = domElement.attribute("angle2","");
|
2013-08-28 10:55:11 +02:00
|
|
|
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile, mode);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(type == "modeling"){
|
|
|
|
if(!domElement.isNull()){
|
|
|
|
qint64 id = domElement.attribute("id", "").toLongLong();
|
|
|
|
qint64 idObject = domElement.attribute("idObject", "").toLongLong();
|
|
|
|
QString tObject = domElement.attribute("typeObject", "");
|
|
|
|
VArc arc;
|
|
|
|
Draw::Mode typeObject;
|
|
|
|
if(tObject == "Calculation"){
|
|
|
|
typeObject = Draw::Calculation;
|
|
|
|
arc = data->GetArc(idObject);
|
|
|
|
} else {
|
|
|
|
typeObject = Draw::Modeling;
|
|
|
|
arc = data->GetModelingArc(idObject);
|
|
|
|
}
|
|
|
|
arc.setMode(typeObject);
|
|
|
|
arc.setIdObject(idObject);
|
|
|
|
data->UpdateModelingArc(id, arc);
|
2013-08-06 09:56:09 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
void VDomDocument::FullUpdateTree(){
|
|
|
|
VMainGraphicsScene *scene = new VMainGraphicsScene();
|
2013-08-28 10:55:11 +02:00
|
|
|
data->ClearObject();
|
|
|
|
Parse(Document::LiteParse, scene, scene);
|
2013-07-13 12:51:31 +02:00
|
|
|
delete scene;
|
2013-08-15 22:39:00 +02:00
|
|
|
setCurrentData();
|
2013-07-13 12:51:31 +02:00
|
|
|
emit FullUpdateFromFile();
|
|
|
|
emit haveChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::haveLiteChange(){
|
|
|
|
emit haveChange();
|
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
|
|
|
|
void VDomDocument::ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable){
|
|
|
|
emit ShowTool(id, color, enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 VDomDocument::getCursor() const{
|
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::setCursor(const qint64 &value){
|
|
|
|
cursor = value;
|
|
|
|
emit ChangedCursor(cursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VDomDocument::setCurrentData(){
|
|
|
|
QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex());
|
2013-08-21 10:03:53 +02:00
|
|
|
if(nameActivDraw != nameDraw){
|
|
|
|
nameActivDraw = nameDraw;
|
|
|
|
qint64 id = 0;
|
|
|
|
if(history.size() == 0){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for(qint32 i = 0; i < history.size(); ++i){
|
|
|
|
VToolRecord tool = history.at(i);
|
|
|
|
if(tool.getNameDraw() == nameDraw){
|
|
|
|
id = tool.getId();
|
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
|
|
|
if(id == 0){
|
2013-08-21 10:03:53 +02:00
|
|
|
VToolRecord tool = history.at(history.size()-1);
|
|
|
|
id = tool.getId();
|
|
|
|
if(id == 0){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(tools.size() > 0){
|
|
|
|
VDataTool *vTool = tools.value(id);
|
|
|
|
data->setData(vTool->getData());
|
2013-08-15 22:39:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
|
|
|
|
void VDomDocument::GarbageCollector(){
|
|
|
|
const QMap<qint64, VPointF> *points = data->DataPoints();
|
|
|
|
QMapIterator<qint64, VPointF> p(*points);
|
|
|
|
while (p.hasNext()) {
|
|
|
|
p.next();
|
|
|
|
VPointF point = p.value();
|
|
|
|
if(point.referens() <= 0){
|
|
|
|
QDomElement domElement = elementById(QString().setNum(p.key()));
|
|
|
|
if(domElement.isElement()){
|
|
|
|
QDomElement element;
|
|
|
|
bool ok = GetActivModelingElement(element);
|
|
|
|
if(ok){
|
|
|
|
element.removeChild(domElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const QMap<qint64, VArc> *arc = data->DataArcs();
|
|
|
|
QMapIterator<qint64, VArc> a(*arc);
|
|
|
|
while (a.hasNext()) {
|
|
|
|
a.next();
|
|
|
|
VArc arc = a.value();
|
|
|
|
if(arc.referens() <= 0){
|
|
|
|
QDomElement domElement = elementById(QString().setNum(a.key()));
|
|
|
|
if(domElement.isElement()){
|
|
|
|
QDomElement element;
|
|
|
|
bool ok = GetActivModelingElement(element);
|
|
|
|
if(ok){
|
|
|
|
element.removeChild(domElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const QMap<qint64, VSpline> *spl = data->DataSplines();
|
|
|
|
QMapIterator<qint64, VSpline> s(*spl);
|
|
|
|
while (s.hasNext()) {
|
|
|
|
s.next();
|
|
|
|
VSpline spl = s.value();
|
|
|
|
if(spl.referens() <= 0){
|
|
|
|
QDomElement domElement = elementById(QString().setNum(s.key()));
|
|
|
|
if(domElement.isElement()){
|
|
|
|
QDomElement element;
|
|
|
|
bool ok = GetActivModelingElement(element);
|
|
|
|
if(ok){
|
|
|
|
element.removeChild(domElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const QMap<qint64, VSplinePath> *splPath = data->DataSplinePaths();
|
|
|
|
QMapIterator<qint64, VSplinePath> q(*splPath);
|
|
|
|
while (q.hasNext()) {
|
|
|
|
q.next();
|
|
|
|
VSplinePath splPath = q.value();
|
|
|
|
if(splPath.referens() <= 0){
|
|
|
|
QDomElement domElement = elementById(QString().setNum(q.key()));
|
|
|
|
if(domElement.isElement()){
|
|
|
|
QDomElement element;
|
|
|
|
bool ok = GetActivModelingElement(element);
|
|
|
|
if(ok){
|
|
|
|
element.removeChild(domElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|