Add base realization of equdistant. Fix two bugs.
This commit is contained in:
parent
46acd73b5b
commit
2ed982faeb
|
@ -256,15 +256,118 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
|
|||
break;
|
||||
}
|
||||
}
|
||||
QPainterPath ekv = Equidistant(points, Detail::CloseEquidistant, toPixel(10));
|
||||
QPainterPath path;
|
||||
path.moveTo(points[0]);
|
||||
for (qint32 i = 1; i < points.count(); ++i){
|
||||
path.lineTo(points[i]);
|
||||
}
|
||||
path.lineTo(points[0]);
|
||||
path.addPath(ekv);
|
||||
return path;
|
||||
}
|
||||
|
||||
QPainterPath VContainer::Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv,
|
||||
const qreal &width) const{
|
||||
QPainterPath ekv;
|
||||
QVector<QPointF> ekvPoints;
|
||||
if ( points.size() < 3 ){
|
||||
qDebug()<<"Not enough points for build equidistant.\n";
|
||||
return ekv;
|
||||
}
|
||||
for (qint32 i = 0; i < points.size(); ++i ){
|
||||
if(i != points.size()-1){
|
||||
if(points[i] == points[i+1]){
|
||||
points.remove(i+1);
|
||||
}
|
||||
} else {
|
||||
if(points[i] == points[0]){
|
||||
points.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(eqv == Detail::CloseEquidistant){
|
||||
points.append(points.at(0));
|
||||
}
|
||||
for (qint32 i = 0; i < points.size(); ++i ){
|
||||
if ( i == 0 && eqv == Detail::CloseEquidistant){//перша точка, ламана замкнена
|
||||
ekvPoints<<EkvPoint(QLineF(points[points.size()-2], points[points.size()-1]),
|
||||
QLineF(points[1], points[0]), width);
|
||||
continue;
|
||||
} else if(i == 0 && eqv == Detail::OpenEquidistant){//перша точка, ламана не замкнена
|
||||
ekvPoints.append(SingleParallelPoint(QLineF(points[0], points[1]), 90, width));
|
||||
continue;
|
||||
}
|
||||
if(i == points.size()-1 && eqv == Detail::CloseEquidistant){//остання точка, ламана замкнена
|
||||
ekvPoints.append(ekvPoints.at(0));
|
||||
continue;
|
||||
} else if(i == points.size()-1 && eqv == Detail::OpenEquidistant){//остання точка, ламана не замкнена
|
||||
ekvPoints.append(SingleParallelPoint(QLineF(points[points.size()-1],
|
||||
points[points.size()-2]), -90, width));
|
||||
continue;
|
||||
}
|
||||
//точка яка не лежить ні на початку ні в кінці
|
||||
ekvPoints<<EkvPoint(QLineF(points[i-1], points[i]), QLineF(points[i+1], points[i]), width);
|
||||
}
|
||||
ekv.moveTo(ekvPoints[0]);
|
||||
for (qint32 i = 1; i < ekvPoints.count(); ++i){
|
||||
ekv.lineTo(ekvPoints[i]);
|
||||
}
|
||||
return ekv;
|
||||
}
|
||||
|
||||
QLineF VContainer::ParallelLine(const QLineF &line, qreal width) const{
|
||||
Q_ASSERT(width > 0);
|
||||
QLineF paralel = QLineF (SingleParallelPoint(line, 90, width),
|
||||
SingleParallelPoint(QLineF(line.p2(), line.p1()), -90, width));
|
||||
return paralel;
|
||||
}
|
||||
|
||||
QPointF VContainer::SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width) const{
|
||||
Q_ASSERT(width > 0);
|
||||
QLineF l = line;
|
||||
l.setAngle( l.angle() + angle );
|
||||
l.setLength( width );
|
||||
return l.p2();
|
||||
}
|
||||
|
||||
QVector<QPointF> VContainer::EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width) const{
|
||||
Q_ASSERT(width > 0);
|
||||
QVector<QPointF> points;
|
||||
if(line1.p2() != line2.p2()){
|
||||
qWarning()<<"Last point of two lines must be equal.";
|
||||
}
|
||||
QPointF CrosPoint;
|
||||
QLineF bigLine1 = ParallelLine(line1, width );
|
||||
QLineF bigLine2 = ParallelLine(QLineF(line2.p2(), line2.p1()), width );
|
||||
QLineF::IntersectType type = bigLine1.intersect( bigLine2, &CrosPoint );
|
||||
switch(type){
|
||||
case(QLineF::BoundedIntersection):
|
||||
points.append(CrosPoint);
|
||||
return points;
|
||||
break;
|
||||
case(QLineF::UnboundedIntersection):{
|
||||
QLineF line( line1.p2(), CrosPoint );
|
||||
if(line.length() > width + toPixel(3)){
|
||||
points.append(bigLine1.p2());
|
||||
line.setLength( width );
|
||||
points.append(line.p2() );
|
||||
points.append(bigLine2.p1());
|
||||
} else {
|
||||
points.append(CrosPoint);
|
||||
return points;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(QLineF::NoIntersection):
|
||||
/*If we have correct lines this means lines lie on a line.*/
|
||||
points.append(bigLine1.p2());
|
||||
return points;
|
||||
break;
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
void VContainer::PrepareDetails(QVector<VItem *> &list) const{
|
||||
QMapIterator<qint64, VDetail> iDetail(details);
|
||||
while (iDetail.hasNext()) {
|
||||
|
@ -279,6 +382,7 @@ void VContainer::RemoveIncrementTableRow(const QString& name){
|
|||
|
||||
template <typename val>
|
||||
void VContainer::UpdateObject(QMap<qint64, val> &obj, const qint64 &id, const val& point){
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
obj[id] = point;
|
||||
UpdateId(id);
|
||||
}
|
||||
|
|
|
@ -122,6 +122,11 @@ public:
|
|||
void UpdateId(qint64 newId);
|
||||
void IncrementReferens(qint64 id, Scene::Type obj, Draw::Mode mode = Draw::Calculation);
|
||||
QPainterPath ContourPath(qint64 idDetail) const;
|
||||
QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv,
|
||||
const qreal &width)const;
|
||||
QLineF ParallelLine(const QLineF &line, qreal width ) const;
|
||||
QPointF SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width)const;
|
||||
QVector<QPointF> EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width)const;
|
||||
void PrepareDetails(QVector<VItem*> & list)const;
|
||||
private:
|
||||
static qint64 _id;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QCloseEvent>
|
||||
#include "container/calculator.h"
|
||||
#include "geometry/vdetail.h"
|
||||
#include <QDebug>
|
||||
|
||||
DialogTool::DialogTool(const VContainer *data, Draw::Mode mode, QWidget *parent):QDialog(parent), data(data),
|
||||
isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0), spinBoxAngle(0),
|
||||
|
|
|
@ -6,6 +6,20 @@
|
|||
#include <QString>
|
||||
#include <QPainterPath>
|
||||
|
||||
namespace Detail{
|
||||
enum Contour
|
||||
{
|
||||
OpenContour,
|
||||
CloseContour
|
||||
};
|
||||
|
||||
enum Equidistant
|
||||
{
|
||||
OpenEquidistant,
|
||||
CloseEquidistant
|
||||
};
|
||||
}
|
||||
|
||||
class VDetail
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -771,12 +771,27 @@ QVector<QPointF> VSpline::SplinePoints(QPointF p1, QPointF p4, qreal angle1, qre
|
|||
return GetPoints(p1, p2, p3, p4);
|
||||
}
|
||||
|
||||
qint64 VSpline::getIdObject() const
|
||||
{
|
||||
qint64 VSpline::getIdObject() const{
|
||||
return idObject;
|
||||
}
|
||||
|
||||
void VSpline::setIdObject(const qint64 &value)
|
||||
{
|
||||
void VSpline::setIdObject(const qint64 &value){
|
||||
idObject = value;
|
||||
}
|
||||
|
||||
const VSpline &VSpline::operator =(const VSpline &spline){
|
||||
this->p1 = spline.GetP1 ();
|
||||
this->p2 = spline.GetP2 ();
|
||||
this->p3 = spline.GetP3 ();
|
||||
this->p4 = spline.GetP4 ();
|
||||
this->angle1 = spline.GetAngle1 ();
|
||||
this->angle2 = spline.GetAngle2 ();
|
||||
this->kAsm1 = spline.GetKasm1();
|
||||
this->kAsm2 = spline.GetKasm2();
|
||||
this->kCurve = spline.GetKcurve();
|
||||
this->points = spline.GetDataPoints();
|
||||
this->_referens = 0;
|
||||
this->mode = spline.getMode();
|
||||
this->idObject = spline.getIdObject();
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ public:
|
|||
qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve);
|
||||
qint64 getIdObject() const;
|
||||
void setIdObject(const qint64 &value);
|
||||
|
||||
const VSpline &operator=(const VSpline &spl);
|
||||
protected:
|
||||
/**
|
||||
* @brief GetPoints повертає точки з яких складається сплайн.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "vdrawtool.h"
|
||||
#include <QDebug>
|
||||
|
||||
VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) :
|
||||
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false),
|
||||
|
|
|
@ -4,6 +4,7 @@ VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64
|
|||
const QString &typeLine, const QString &formula, const qint64 &basePointId,
|
||||
const qint32 &angle, QGraphicsItem *parent):VToolPoint(doc, data, id, parent),
|
||||
typeLine(typeLine), formula(formula), angle(angle), basePointId(basePointId), mainLine(0){
|
||||
Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0");
|
||||
//Лінія, що з'єднує дві точки
|
||||
QPointF point1 = data->GetPoint(basePointId).toQPointF();
|
||||
QPointF point2 = data->GetPoint(id).toQPointF();
|
||||
|
|
|
@ -78,10 +78,7 @@ VModelingSpline *VModelingSpline::Create(const qint64 _id, const qint64 &p1, con
|
|||
} else {
|
||||
data->UpdateModelingSpline(id, spline);
|
||||
if(parse != Document::FullParse){
|
||||
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||
VDataTool *tool = tools->value(id);
|
||||
Q_CHECK_PTR(tool);
|
||||
tool->VDataTool::setData(data);
|
||||
doc->UpdateToolData(id, data);
|
||||
data->IncrementReferens(id, Scene::Spline, Draw::Modeling);
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +133,7 @@ void VModelingSpline::FullUpdateFromGui(int result){
|
|||
}
|
||||
|
||||
void VModelingSpline::ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position,
|
||||
const QPointF pos){
|
||||
const QPointF pos){
|
||||
Q_UNUSED(indexSpline);
|
||||
VSpline spl = VAbstractTool::data.GetModelingSpline(id);
|
||||
if(position == SplinePoint::FirstPoint){
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "vmodelingtool.h"
|
||||
#include <QDebug>
|
||||
|
||||
VModelingTool::VModelingTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent):
|
||||
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false){
|
||||
|
|
|
@ -17,6 +17,5 @@ VContainer VDataTool::getData() const{
|
|||
}
|
||||
|
||||
void VDataTool::setData(const VContainer *value){
|
||||
data.Clear();
|
||||
data = *value;
|
||||
}
|
||||
|
|
|
@ -157,8 +157,8 @@ void VToolDetail::setDialog(){
|
|||
}
|
||||
}
|
||||
|
||||
void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data){
|
||||
void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScene *scene,
|
||||
VDomDocument *doc, VContainer *data){
|
||||
VDetail detail = dialog->getDetails();
|
||||
VDetail det;
|
||||
for(qint32 i = 0; i< detail.CountNode(); ++i){
|
||||
|
@ -302,7 +302,7 @@ void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
|
|||
void VToolDetail::AddNode(QDomElement &domElement, VNodeDetail &node){
|
||||
QDomElement nod = doc->createElement("node");
|
||||
|
||||
AddAttribute(nod, "id", node.getId());
|
||||
AddAttribute(nod, "idObject", node.getId());
|
||||
if(node.getTypeNode() == NodeDetail::Contour){
|
||||
AddAttribute(nod, "nodeType", "Contour");
|
||||
} else {
|
||||
|
|
|
@ -46,18 +46,8 @@ void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
|
|||
|
||||
QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value){
|
||||
if (change == ItemPositionChange && scene()) {
|
||||
// value - это новое положение.
|
||||
// value - new position.
|
||||
QPointF newPos = value.toPointF();
|
||||
// qDebug()<<this->rect();
|
||||
// QRectF rect = scene()->sceneRect();
|
||||
// if (!rect.contains(newPos)) {
|
||||
// // Сохраняем элемент внутри прямоугольника сцены.
|
||||
// newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
|
||||
// newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
|
||||
|
||||
// emit ControlPointChangePosition(indexSpline, position, newPos);
|
||||
// return newPos;
|
||||
// }
|
||||
emit ControlPointChangePosition(indexSpline, position, newPos);
|
||||
}
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
|
|
|
@ -82,6 +82,7 @@ void VDomDocument::CreateEmptyFile(){
|
|||
}
|
||||
|
||||
bool VDomDocument::CheckNameDraw(const QString& name) const{
|
||||
Q_ASSERT_X(!name.isEmpty(), "CheckNameDraw", "name draw is empty");
|
||||
QDomNodeList elements = this->documentElement().elementsByTagName( "draw" );
|
||||
if(elements.size() == 0){
|
||||
return false;
|
||||
|
@ -99,6 +100,7 @@ bool VDomDocument::CheckNameDraw(const QString& name) const{
|
|||
}
|
||||
|
||||
bool VDomDocument::appendDraw(const QString& name){
|
||||
Q_ASSERT_X(!name.isEmpty(), "appendDraw", "name draw is empty");
|
||||
if(name.isEmpty()){
|
||||
return false;
|
||||
}
|
||||
|
@ -132,6 +134,7 @@ bool VDomDocument::appendDraw(const QString& name){
|
|||
}
|
||||
|
||||
void VDomDocument::ChangeActivDraw(const QString& name, Document::Enum parse){
|
||||
Q_ASSERT_X(!name.isEmpty(), "ChangeActivDraw", "name draw is empty");
|
||||
if(CheckNameDraw(name) == true){
|
||||
this->nameActivDraw = name;
|
||||
if(parse == Document::FullParse){
|
||||
|
@ -141,12 +144,14 @@ void VDomDocument::ChangeActivDraw(const QString& name, Document::Enum parse){
|
|||
}
|
||||
|
||||
void VDomDocument::SetNameDraw(const QString& name){
|
||||
Q_ASSERT_X(!name.isEmpty(), "SetNameDraw", "name draw is empty");
|
||||
QString oldName = nameActivDraw;
|
||||
nameActivDraw = name;
|
||||
emit ChangedNameDraw(oldName, nameActivDraw);
|
||||
}
|
||||
|
||||
void VDomDocument::SetActivDraw(const QString& name){
|
||||
Q_ASSERT_X(!name.isEmpty(), "SetActivDraw", "name draw is empty");
|
||||
this->nameActivDraw = name;
|
||||
}
|
||||
|
||||
|
@ -201,6 +206,7 @@ bool VDomDocument::GetActivDetailsElement(QDomElement &element){
|
|||
}
|
||||
|
||||
bool VDomDocument::GetActivNodeElement(const QString& name, QDomElement &element){
|
||||
Q_ASSERT_X(!name.isEmpty(), "GetActivNodeElement", "name draw is empty");
|
||||
QDomElement drawElement;
|
||||
bool drawOk = this->GetActivDrawElement(drawElement);
|
||||
if(drawOk == true){
|
||||
|
@ -219,7 +225,10 @@ bool VDomDocument::GetActivNodeElement(const QString& name, QDomElement &element
|
|||
}
|
||||
}
|
||||
|
||||
void VDomDocument::Parse(Document::Enum parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail){
|
||||
void VDomDocument::Parse(Document::Enum parse, VMainGraphicsScene *sceneDraw,
|
||||
VMainGraphicsScene *sceneDetail){
|
||||
Q_CHECK_PTR(sceneDraw);
|
||||
Q_CHECK_PTR(sceneDetail);
|
||||
if(parse == Document::FullParse){
|
||||
data->Clear();
|
||||
nameActivDraw.clear();
|
||||
|
@ -277,16 +286,12 @@ void VDomDocument::ParseIncrementsElement(const QDomNode &node){
|
|||
QDomElement domElement = domNode.toElement();
|
||||
if(!domElement.isNull()){
|
||||
if(domElement.tagName() == "increment"){
|
||||
QString name,desc;
|
||||
qreal base;
|
||||
qreal ksize, kgrowth;
|
||||
qint64 id;
|
||||
id = domElement.attribute("id", "").toLongLong();
|
||||
name = domElement.attribute("name", "");
|
||||
base = domElement.attribute("base","").toDouble();
|
||||
ksize = domElement.attribute("ksize","").toDouble();
|
||||
kgrowth = domElement.attribute("kgrowth","").toDouble();
|
||||
desc = domElement.attribute("description","");
|
||||
qint64 id = GetParametrId(domElement);
|
||||
QString name = GetParametrString(domElement, "name");
|
||||
qreal base = GetParametrDouble(domElement, "base");
|
||||
qreal ksize = GetParametrDouble(domElement, "ksize");
|
||||
qreal kgrowth = GetParametrDouble(domElement, "kgrowth");
|
||||
QString desc = GetParametrString(domElement, "description");
|
||||
data->UpdateId(id);
|
||||
data->AddIncrementTableRow(name,
|
||||
VIncrementTableRow(id, base, ksize, kgrowth, desc));
|
||||
|
@ -297,6 +302,48 @@ void VDomDocument::ParseIncrementsElement(const QDomNode &node){
|
|||
}
|
||||
}
|
||||
|
||||
qint64 VDomDocument::GetParametrId(const QDomElement &domElement) const{
|
||||
qint64 id = GetParametrLongLong(domElement, "id");
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
return id;
|
||||
}
|
||||
|
||||
qint64 VDomDocument::GetParametrLongLong(const QDomElement &domElement, const QString &name) const{
|
||||
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "name of parametr is empty");
|
||||
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||
bool ok = false;
|
||||
QString parametr = GetParametrString(domElement, name);
|
||||
qint64 id = parametr.toLongLong(&ok);
|
||||
QString error("can't convert parametr ");
|
||||
error.append(name);
|
||||
Q_ASSERT_X(ok, Q_FUNC_INFO, error.toLatin1().data());
|
||||
return id;
|
||||
}
|
||||
|
||||
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(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||
QString parametr = domElement.attribute(name, "");
|
||||
QString error("get empty parametr ");
|
||||
error.append(name);
|
||||
Q_ASSERT_X(!parametr.isEmpty(), Q_FUNC_INFO, error.toLatin1().data());
|
||||
return parametr;
|
||||
}
|
||||
|
||||
qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QString &name) const{
|
||||
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "name of parametr is empty");
|
||||
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||
bool ok = false;
|
||||
QString parametr = GetParametrString(domElement, name);
|
||||
qreal param = parametr.toDouble(&ok);
|
||||
QString error("can't convert parametr ");
|
||||
error.append(name);
|
||||
Q_ASSERT_X(ok, Q_FUNC_INFO, error.toLatin1().data());
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VDomDocument::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
||||
const QDomNode& node, Document::Enum parse){
|
||||
QDomNode domNode = node.firstChild();
|
||||
|
@ -322,6 +369,8 @@ void VDomDocument::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphics
|
|||
|
||||
void VDomDocument::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
||||
const QDomNode& node, Document::Enum parse, Draw::Mode mode){
|
||||
Q_CHECK_PTR(sceneDraw);
|
||||
Q_CHECK_PTR(sceneDetail);
|
||||
VMainGraphicsScene *scene = 0;
|
||||
if(mode == Draw::Calculation){
|
||||
scene = sceneDraw;
|
||||
|
@ -351,78 +400,80 @@ void VDomDocument::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsSce
|
|||
|
||||
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()));
|
||||
Q_CHECK_PTR(sceneDetail);
|
||||
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||
VDetail detail;
|
||||
VDetail oldDetail;
|
||||
qint64 id = GetParametrId(domElement);
|
||||
detail.setName(GetParametrString(domElement, "name"));
|
||||
detail.setMx(toPixel(GetParametrDouble(domElement, "mx")));
|
||||
detail.setMy(toPixel(GetParametrDouble(domElement, "my")));
|
||||
|
||||
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();
|
||||
Tools::Enum tool;
|
||||
Draw::Mode mode;
|
||||
NodeDetail::Type nodeType = NodeDetail::Contour;
|
||||
QString t = element.attribute("type","");
|
||||
if(t == "NodePoint"){
|
||||
tool = Tools::NodePoint;
|
||||
VPointF point = data->GetModelingPoint(id);
|
||||
mode = point.getMode();
|
||||
oldDetail.append(VNodeDetail(point.getIdObject(), tool, mode, NodeDetail::Contour));
|
||||
} else if(t == "NodeArc"){
|
||||
tool = Tools::NodeArc;
|
||||
VArc arc = data->GetModelingArc(id);
|
||||
mode = arc.getMode();
|
||||
oldDetail.append(VNodeDetail(arc.getIdObject(), tool, mode, NodeDetail::Contour));
|
||||
} else if(t == "NodeSpline"){
|
||||
tool = Tools::NodeSpline;
|
||||
VSpline spl = data->GetModelingSpline(id);
|
||||
mode = spl.getMode();
|
||||
oldDetail.append(VNodeDetail(spl.getIdObject(), tool, mode, NodeDetail::Contour));
|
||||
} else if(t == "NodeSplinePath"){
|
||||
tool = Tools::NodeSplinePath;
|
||||
VSplinePath splPath = data->GetModelingSplinePath(id);
|
||||
mode = splPath.getMode();
|
||||
oldDetail.append(VNodeDetail(splPath.getIdObject(), tool, mode, NodeDetail::Contour));
|
||||
} else if(t == "AlongLineTool"){
|
||||
tool = Tools::AlongLineTool;
|
||||
} else if(t == "ArcTool"){
|
||||
tool = Tools::ArcTool;
|
||||
} else if(t == "BisectorTool"){
|
||||
tool = Tools::BisectorTool;
|
||||
} else if(t == "EndLineTool"){
|
||||
tool = Tools::EndLineTool;
|
||||
} else if(t == "LineIntersectTool"){
|
||||
tool = Tools::LineIntersectTool;
|
||||
} else if(t == "LineTool"){
|
||||
tool = Tools::LineTool;
|
||||
} else if(t == "NormalTool"){
|
||||
tool = Tools::NormalTool;
|
||||
} else if(t == "PointOfContact"){
|
||||
tool = Tools::PointOfContact;
|
||||
} else if(t == "ShoulderPointTool"){
|
||||
tool = Tools::ShoulderPointTool;
|
||||
} else if(t == "SplinePathTool"){
|
||||
tool = Tools::SplinePathTool;
|
||||
} else if(t == "SplineTool"){
|
||||
tool = Tools::SplineTool;
|
||||
}
|
||||
detail.append(VNodeDetail(id, tool, mode, nodeType));
|
||||
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 = GetParametrLongLong(element, "idObject");
|
||||
Tools::Enum tool;
|
||||
Draw::Mode mode;
|
||||
NodeDetail::Type nodeType = NodeDetail::Contour;
|
||||
QString t = GetParametrString(element, "type");
|
||||
if(t == "NodePoint"){
|
||||
tool = Tools::NodePoint;
|
||||
VPointF point = data->GetModelingPoint(id);
|
||||
mode = point.getMode();
|
||||
oldDetail.append(VNodeDetail(point.getIdObject(), tool, mode, NodeDetail::Contour));
|
||||
} else if(t == "NodeArc"){
|
||||
tool = Tools::NodeArc;
|
||||
VArc arc = data->GetModelingArc(id);
|
||||
mode = arc.getMode();
|
||||
oldDetail.append(VNodeDetail(arc.getIdObject(), tool, mode, NodeDetail::Contour));
|
||||
} else if(t == "NodeSpline"){
|
||||
tool = Tools::NodeSpline;
|
||||
VSpline spl = data->GetModelingSpline(id);
|
||||
mode = spl.getMode();
|
||||
oldDetail.append(VNodeDetail(spl.getIdObject(), tool, mode, NodeDetail::Contour));
|
||||
} else if(t == "NodeSplinePath"){
|
||||
tool = Tools::NodeSplinePath;
|
||||
VSplinePath splPath = data->GetModelingSplinePath(id);
|
||||
mode = splPath.getMode();
|
||||
oldDetail.append(VNodeDetail(splPath.getIdObject(), tool, mode, NodeDetail::Contour));
|
||||
} else if(t == "AlongLineTool"){
|
||||
tool = Tools::AlongLineTool;
|
||||
} else if(t == "ArcTool"){
|
||||
tool = Tools::ArcTool;
|
||||
} else if(t == "BisectorTool"){
|
||||
tool = Tools::BisectorTool;
|
||||
} else if(t == "EndLineTool"){
|
||||
tool = Tools::EndLineTool;
|
||||
} else if(t == "LineIntersectTool"){
|
||||
tool = Tools::LineIntersectTool;
|
||||
} else if(t == "LineTool"){
|
||||
tool = Tools::LineTool;
|
||||
} else if(t == "NormalTool"){
|
||||
tool = Tools::NormalTool;
|
||||
} else if(t == "PointOfContact"){
|
||||
tool = Tools::PointOfContact;
|
||||
} else if(t == "ShoulderPointTool"){
|
||||
tool = Tools::ShoulderPointTool;
|
||||
} else if(t == "SplinePathTool"){
|
||||
tool = Tools::SplinePathTool;
|
||||
} else if(t == "SplineTool"){
|
||||
tool = Tools::SplineTool;
|
||||
}
|
||||
detail.append(VNodeDetail(id, tool, mode, nodeType));
|
||||
}
|
||||
}
|
||||
VToolDetail::Create(id, detail, oldDetail, sceneDetail, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
VToolDetail::Create(id, detail, oldDetail, sceneDetail, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
|
||||
void VDomDocument::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
|
||||
Document::Enum parse){
|
||||
Q_CHECK_PTR(sceneDetail);
|
||||
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||
QDomNode domNode = domElement.firstChild();
|
||||
while(!domNode.isNull()){
|
||||
if(domNode.isElement()){
|
||||
|
@ -439,307 +490,285 @@ void VDomDocument::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomEleme
|
|||
|
||||
void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
||||
Document::Enum parse, const QString& type, Draw::Mode mode){
|
||||
Q_CHECK_PTR(scene);
|
||||
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||
Q_ASSERT_X(!type.isEmpty(), Q_FUNC_INFO, "type of point is empty");
|
||||
if(type == "single"){
|
||||
if(!domElement.isNull()){
|
||||
qint64 id = domElement.attribute("id", "").toLongLong();
|
||||
Q_ASSERT(id > 0);
|
||||
QString name = domElement.attribute("name", "");
|
||||
qreal x = domElement.attribute("x","").toDouble()*PrintDPI/25.4;
|
||||
qreal y = domElement.attribute("y","").toDouble()*PrintDPI/25.4;
|
||||
qreal mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4;
|
||||
qreal my = domElement.attribute("my","").toDouble()*PrintDPI/25.4;
|
||||
qint64 id = GetParametrId(domElement);
|
||||
QString name = GetParametrString(domElement, "name");
|
||||
qreal x = toPixel(GetParametrDouble(domElement, "x"));
|
||||
qreal y = toPixel(GetParametrDouble(domElement, "y"));
|
||||
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
|
||||
qreal my = toPixel(GetParametrDouble(domElement, "my"));
|
||||
|
||||
data->UpdatePoint(id, VPointF(x, y, name, mx, my));
|
||||
VDrawTool::AddRecord(id, Tools::SinglePointTool, this);
|
||||
if(parse != Document::FullParse){
|
||||
VDataTool *tool = tools.value(id);
|
||||
Q_CHECK_PTR(tool);
|
||||
tool->VDataTool::setData(data);
|
||||
}
|
||||
if(parse == Document::FullParse){
|
||||
VToolSinglePoint *spoint = new VToolSinglePoint(this, data, id, Tool::FromFile);
|
||||
scene->addItem(spoint);
|
||||
connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
tools[id] = spoint;
|
||||
}
|
||||
data->UpdatePoint(id, VPointF(x, y, name, mx, my));
|
||||
VDrawTool::AddRecord(id, Tools::SinglePointTool, this);
|
||||
if(parse != Document::FullParse){
|
||||
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(type == "endLine"){
|
||||
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 typeLine = domElement.attribute("typeLine", "");
|
||||
QString formula = domElement.attribute("length", "");
|
||||
qint64 basePointId = domElement.attribute("basePoint", "").toLongLong();
|
||||
qint32 angle = domElement.attribute("angle", "").toInt();
|
||||
if(mode == Draw::Calculation){
|
||||
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this,
|
||||
qint64 id = GetParametrId(domElement);
|
||||
QString name = GetParametrString(domElement, "name");
|
||||
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
|
||||
qreal my = toPixel(GetParametrDouble(domElement, "my"));
|
||||
QString typeLine = GetParametrString(domElement, "typeLine");
|
||||
QString formula = GetParametrString(domElement, "length");
|
||||
qint64 basePointId = GetParametrLongLong(domElement, "basePoint");
|
||||
qreal angle = GetParametrDouble(domElement, "angle");
|
||||
if(mode == Draw::Calculation){
|
||||
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this,
|
||||
data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, this,
|
||||
data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, this,
|
||||
data, parse, Tool::FromFile);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(type == "alongLine"){
|
||||
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 typeLine = domElement.attribute("typeLine", "");
|
||||
QString formula = domElement.attribute("length", "");
|
||||
qint64 firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||
qint64 secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||
if(mode == Draw::Calculation){
|
||||
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my,
|
||||
scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my,
|
||||
this, data, parse, Tool::FromFile);
|
||||
}
|
||||
qint64 id = GetParametrId(domElement);
|
||||
QString name = GetParametrString(domElement, "name");
|
||||
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
|
||||
qreal my = toPixel(GetParametrDouble(domElement, "my"));
|
||||
QString typeLine = GetParametrString(domElement, "typeLine");
|
||||
QString formula = GetParametrString(domElement, "length");
|
||||
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
|
||||
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
|
||||
if(mode == Draw::Calculation){
|
||||
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my,
|
||||
scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my,
|
||||
this, data, parse, Tool::FromFile);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(type == "shoulder"){
|
||||
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 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();
|
||||
if(mode == Draw::Calculation){
|
||||
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my,
|
||||
scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx,
|
||||
my, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
qint64 id = GetParametrId(domElement);
|
||||
QString name = GetParametrString(domElement, "name");
|
||||
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
|
||||
qreal my = toPixel(GetParametrDouble(domElement, "my"));
|
||||
QString typeLine = GetParametrString(domElement, "typeLine");
|
||||
QString formula = GetParametrString(domElement, "length");
|
||||
qint64 p1Line = GetParametrLongLong(domElement, "p1Line");
|
||||
qint64 p2Line = GetParametrLongLong(domElement, "p2Line");
|
||||
qint64 pShoulder = GetParametrLongLong(domElement, "pShoulder");
|
||||
if(mode == Draw::Calculation){
|
||||
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my,
|
||||
scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx,
|
||||
my, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(type == "normal"){
|
||||
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 typeLine = domElement.attribute("typeLine", "");
|
||||
QString formula = domElement.attribute("length", "");
|
||||
qint64 firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||
qint64 secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||
qreal angle = domElement.attribute("angle", "").toDouble();
|
||||
if(mode == Draw::Calculation){
|
||||
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle,
|
||||
mx, my, scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle,
|
||||
mx, my, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
qint64 id = GetParametrId(domElement);
|
||||
QString name = GetParametrString(domElement, "name");
|
||||
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
|
||||
qreal my = toPixel(GetParametrDouble(domElement, "my"));
|
||||
QString typeLine = GetParametrString(domElement, "typeLine");
|
||||
QString formula = GetParametrString(domElement, "length");
|
||||
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
|
||||
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
|
||||
qreal angle = GetParametrDouble(domElement, "angle");
|
||||
if(mode == Draw::Calculation){
|
||||
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle,
|
||||
mx, my, scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle,
|
||||
mx, my, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(type == "bisector"){
|
||||
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 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();
|
||||
if(mode == Draw::Calculation){
|
||||
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine,
|
||||
name, mx, my, scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine,
|
||||
name, mx, my, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
qint64 id = GetParametrId(domElement);
|
||||
QString name = GetParametrString(domElement, "name");
|
||||
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
|
||||
qreal my = toPixel(GetParametrDouble(domElement, "my"));
|
||||
QString typeLine = GetParametrString(domElement, "typeLine");
|
||||
QString formula = GetParametrString(domElement, "length");
|
||||
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
|
||||
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
|
||||
qint64 thirdPointId = GetParametrLongLong(domElement, "thirdPoint");
|
||||
if(mode == Draw::Calculation){
|
||||
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine,
|
||||
name, mx, my, scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine,
|
||||
name, mx, my, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(type == "lineIntersect"){
|
||||
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;
|
||||
qint64 p1Line1Id = domElement.attribute("p1Line1", "").toLongLong();
|
||||
qint64 p2Line1Id = domElement.attribute("p2Line1", "").toLongLong();
|
||||
qint64 p1Line2Id = domElement.attribute("p1Line2", "").toLongLong();
|
||||
qint64 p2Line2Id = domElement.attribute("p2Line2", "").toLongLong();
|
||||
if(mode == Draw::Calculation){
|
||||
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my,
|
||||
scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my,
|
||||
this, data, parse, Tool::FromFile);
|
||||
}
|
||||
qint64 id = GetParametrId(domElement);
|
||||
QString name = GetParametrString(domElement, "name");
|
||||
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
|
||||
qreal my = toPixel(GetParametrDouble(domElement, "my"));
|
||||
qint64 p1Line1Id = GetParametrLongLong(domElement, "p1Line1");
|
||||
qint64 p2Line1Id = GetParametrLongLong(domElement, "p2Line1");
|
||||
qint64 p1Line2Id = GetParametrLongLong(domElement, "p1Line2");
|
||||
qint64 p2Line2Id = GetParametrLongLong(domElement, "p2Line2");
|
||||
if(mode == Draw::Calculation){
|
||||
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my,
|
||||
scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my,
|
||||
this, data, parse, Tool::FromFile);
|
||||
}
|
||||
return;
|
||||
}
|
||||
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();
|
||||
if(mode == Draw::Calculation){
|
||||
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my,
|
||||
scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx,
|
||||
my, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
qint64 id = GetParametrId(domElement);
|
||||
QString name = GetParametrString(domElement, "name");
|
||||
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
|
||||
qreal my = toPixel(GetParametrDouble(domElement, "my"));
|
||||
QString radius = GetParametrString(domElement, "radius");
|
||||
qint64 center = GetParametrLongLong(domElement, "center");
|
||||
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
|
||||
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
|
||||
if(mode == Draw::Calculation){
|
||||
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my,
|
||||
scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx,
|
||||
my, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
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, typeObject);
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 idObject = GetParametrLongLong(domElement, "idObject");
|
||||
QString tObject = GetParametrString(domElement, "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(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;
|
||||
}
|
||||
}
|
||||
|
||||
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
||||
Document::Enum parse, Draw::Mode mode){
|
||||
if(!domElement.isNull()){
|
||||
qint64 id = domElement.attribute("id", "").toLongLong();
|
||||
qint64 firstPoint = domElement.attribute("firstPoint", "").toLongLong();
|
||||
qint64 secondPoint = domElement.attribute("secondPoint", "").toLongLong();
|
||||
if(mode == Draw::Calculation){
|
||||
VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingLine::Create(id, firstPoint, secondPoint, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
Q_CHECK_PTR(scene);
|
||||
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 firstPoint = GetParametrLongLong(domElement, "firstPoint");
|
||||
qint64 secondPoint = GetParametrLongLong(domElement, "secondPoint");
|
||||
if(mode == Draw::Calculation){
|
||||
VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingLine::Create(id, firstPoint, secondPoint, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
}
|
||||
|
||||
void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
||||
Document::Enum parse, const QString &type, Draw::Mode mode){
|
||||
Q_CHECK_PTR(scene);
|
||||
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||
Q_ASSERT_X(!type.isEmpty(), Q_FUNC_INFO, "type of spline is empty");
|
||||
if(type == "simple"){
|
||||
if(!domElement.isNull()){
|
||||
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();
|
||||
if(mode == Draw::Calculation){
|
||||
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this,
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 point1 = GetParametrLongLong(domElement, "point1");
|
||||
qint64 point4 = GetParametrLongLong(domElement, "point4");
|
||||
qreal angle1 = GetParametrDouble(domElement, "angle1");
|
||||
qreal angle2 = GetParametrDouble(domElement, "angle2");
|
||||
qreal kAsm1 = GetParametrDouble(domElement, "kAsm1");
|
||||
qreal kAsm2 = GetParametrDouble(domElement, "kAsm2");
|
||||
qreal kCurve = GetParametrDouble(domElement, "kCurve");
|
||||
if(mode == Draw::Calculation){
|
||||
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this,
|
||||
data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, this,
|
||||
data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, this,
|
||||
data, parse, Tool::FromFile);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(type == "path"){
|
||||
if(!domElement.isNull()){
|
||||
qint64 id = domElement.attribute("id", "").toLongLong();
|
||||
qreal kCurve = domElement.attribute("kCurve","").toDouble();
|
||||
VSplinePath path(data->DataPoints(), kCurve);
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qreal kCurve = GetParametrDouble(domElement, "kCurve");
|
||||
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);
|
||||
}
|
||||
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 = GetParametrLongLong(domElement, "pSpline");
|
||||
qreal kAsm1 = GetParametrDouble(domElement, "kAsm1");
|
||||
qreal angle = GetParametrDouble(domElement, "angle");
|
||||
qreal kAsm2 = GetParametrDouble(domElement, "kAsm2");
|
||||
VSplinePoint splPoint(pSpline, kAsm1, angle, kAsm2);
|
||||
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);
|
||||
}
|
||||
}
|
||||
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(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, Draw::Modeling);
|
||||
data->IncrementReferens(spl.GetP4(), Scene::Point, Draw::Modeling);
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 idObject = GetParametrLongLong(domElement, "idObject");
|
||||
QString tObject = GetParametrString(domElement, "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, Draw::Modeling);
|
||||
data->IncrementReferens(spl.GetP4(), Scene::Point, Draw::Modeling);
|
||||
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, Draw::Modeling);
|
||||
}
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 idObject = GetParametrLongLong(domElement, "idObject");
|
||||
QString tObject = GetParametrString(domElement, "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, Draw::Modeling);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -747,45 +776,45 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
|
|||
|
||||
void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
||||
Document::Enum parse, const QString &type, Draw::Mode mode){
|
||||
Q_CHECK_PTR(scene);
|
||||
Q_ASSERT_X(!domElement.isNull(), Q_FUNC_INFO, "domElement is null");
|
||||
Q_ASSERT_X(!type.isEmpty(), Q_FUNC_INFO, "type of spline is empty");
|
||||
if(type == "simple"){
|
||||
if(!domElement.isNull()){
|
||||
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","");
|
||||
if(mode == Draw::Calculation){
|
||||
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingArc::Create(id, center, radius, f1, f2, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 center = GetParametrLongLong(domElement, "center");
|
||||
QString radius = GetParametrString(domElement, "radius");
|
||||
QString f1 = GetParametrString(domElement, "angle1");
|
||||
QString f2 = GetParametrString(domElement, "angle2");
|
||||
if(mode == Draw::Calculation){
|
||||
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile);
|
||||
} else {
|
||||
VModelingArc::Create(id, center, radius, f1, f2, this, data, parse, Tool::FromFile);
|
||||
}
|
||||
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);
|
||||
qint64 id = GetParametrId(domElement);
|
||||
qint64 idObject = GetParametrLongLong(domElement, "idObject");
|
||||
QString tObject = GetParametrString(domElement, "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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void VDomDocument::FullUpdateTree(){
|
||||
VMainGraphicsScene *scene = new VMainGraphicsScene();
|
||||
Q_CHECK_PTR(scene);
|
||||
data->ClearObject();
|
||||
Parse(Document::LiteParse, scene, scene);
|
||||
delete scene;
|
||||
|
@ -843,6 +872,7 @@ void VDomDocument::setCurrentData(){
|
|||
|
||||
void VDomDocument::GarbageCollector(){
|
||||
const QMap<qint64, VPointF> *points = data->DataPoints();
|
||||
Q_CHECK_PTR(points);
|
||||
QMapIterator<qint64, VPointF> p(*points);
|
||||
while (p.hasNext()) {
|
||||
p.next();
|
||||
|
@ -860,6 +890,7 @@ void VDomDocument::GarbageCollector(){
|
|||
}
|
||||
|
||||
const QMap<qint64, VArc> *arc = data->DataArcs();
|
||||
Q_CHECK_PTR(arc);
|
||||
QMapIterator<qint64, VArc> a(*arc);
|
||||
while (a.hasNext()) {
|
||||
a.next();
|
||||
|
@ -877,6 +908,7 @@ void VDomDocument::GarbageCollector(){
|
|||
}
|
||||
|
||||
const QMap<qint64, VSpline> *spl = data->DataSplines();
|
||||
Q_CHECK_PTR(spl);
|
||||
QMapIterator<qint64, VSpline> s(*spl);
|
||||
while (s.hasNext()) {
|
||||
s.next();
|
||||
|
@ -894,6 +926,7 @@ void VDomDocument::GarbageCollector(){
|
|||
}
|
||||
|
||||
const QMap<qint64, VSplinePath> *splPath = data->DataSplinePaths();
|
||||
Q_CHECK_PTR(splPath);
|
||||
QMapIterator<qint64, VSplinePath> q(*splPath);
|
||||
while (q.hasNext()) {
|
||||
q.next();
|
||||
|
@ -912,15 +945,15 @@ void VDomDocument::GarbageCollector(){
|
|||
}
|
||||
|
||||
void VDomDocument::AddTool(const qint64 &id, VDataTool *tool){
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
Q_CHECK_PTR(tool);
|
||||
tools.insert(id, tool);
|
||||
}
|
||||
|
||||
void VDomDocument::UpdateToolData(const qint64 &id, VContainer *data){
|
||||
Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0");
|
||||
Q_CHECK_PTR(data);
|
||||
VDataTool *tool = tools.value(id);
|
||||
if(tool != 0){
|
||||
tool->VDataTool::setData(data);
|
||||
} else {
|
||||
qWarning()<<"Can't find tool with id ="<< id<<".";
|
||||
}
|
||||
Q_CHECK_PTR(tool);
|
||||
tool->VDataTool::setData(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,11 +78,11 @@ private:
|
|||
void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
||||
const QDomNode& node, Document::Enum parse);
|
||||
void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
||||
const QDomNode& node, Document::Enum parse, Draw::Mode mode);
|
||||
const QDomNode& node, Document::Enum parse, Draw::Mode mode);
|
||||
void ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
|
||||
Document::Enum parse);
|
||||
void ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
|
||||
Document::Enum parse);
|
||||
Document::Enum parse);
|
||||
void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
||||
Document::Enum parse, const QString &type, Draw::Mode mode);
|
||||
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
||||
|
@ -90,8 +90,12 @@ private:
|
|||
void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
||||
Document::Enum parse, const QString& type, Draw::Mode mode);
|
||||
void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
||||
Document::Enum parse, const QString& type, Draw::Mode mode);
|
||||
Document::Enum parse, const QString& type, Draw::Mode mode);
|
||||
void ParseIncrementsElement(const QDomNode& node);
|
||||
qint64 GetParametrId(const QDomElement& domElement) const;
|
||||
qint64 GetParametrLongLong(const QDomElement& domElement, const QString &name) const;
|
||||
QString GetParametrString(const QDomElement& domElement, const QString &name) const;
|
||||
qreal GetParametrDouble(const QDomElement& domElement, const QString &name) const;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
Loading…
Reference in New Issue
Block a user