Big change in architecture of tools. Add modeling tools.
This commit is contained in:
parent
759afeedd7
commit
6956d309bd
121
Valentina.pro
121
Valentina.pro
|
@ -10,7 +10,8 @@ QT += core gui widgets xml svg printsupport
|
||||||
|
|
||||||
TARGET = Valentina
|
TARGET = Valentina
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
CONFIG += precompile_header
|
CONFIG += precompile_header
|
||||||
|
CONFIG -= debug_and_release debug_and_release_target
|
||||||
|
|
||||||
SOURCES += main.cpp\
|
SOURCES += main.cpp\
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
|
@ -19,7 +20,7 @@ SOURCES += main.cpp\
|
||||||
xml/vdomdocument.cpp \
|
xml/vdomdocument.cpp \
|
||||||
container/vpointf.cpp \
|
container/vpointf.cpp \
|
||||||
container/vcontainer.cpp \
|
container/vcontainer.cpp \
|
||||||
tools/vtoolpoint.cpp \
|
tools/drawTools/vtoolpoint.cpp \
|
||||||
container/calculator.cpp \
|
container/calculator.cpp \
|
||||||
dialogs/dialogincrements.cpp \
|
dialogs/dialogincrements.cpp \
|
||||||
container/vstandarttablecell.cpp \
|
container/vstandarttablecell.cpp \
|
||||||
|
@ -27,52 +28,68 @@ SOURCES += main.cpp\
|
||||||
widgets/delegate.cpp \
|
widgets/delegate.cpp \
|
||||||
widgets/doubledelegate.cpp \
|
widgets/doubledelegate.cpp \
|
||||||
dialogs/dialogendline.cpp \
|
dialogs/dialogendline.cpp \
|
||||||
tools/vtoolendline.cpp \
|
tools/drawTools/vtoolendline.cpp \
|
||||||
tools/vtoolline.cpp \
|
tools/drawTools/vtoolline.cpp \
|
||||||
tools/vabstracttool.cpp \
|
tools/vabstracttool.cpp \
|
||||||
dialogs/dialogline.cpp \
|
dialogs/dialogline.cpp \
|
||||||
tools/vtoolalongline.cpp \
|
tools/drawTools/vtoolalongline.cpp \
|
||||||
dialogs/dialogtool.cpp \
|
dialogs/dialogtool.cpp \
|
||||||
dialogs/dialogalongline.cpp \
|
dialogs/dialogalongline.cpp \
|
||||||
tools/vtoolshoulderpoint.cpp \
|
tools/drawTools/vtoolshoulderpoint.cpp \
|
||||||
dialogs/dialogshoulderpoint.cpp \
|
dialogs/dialogshoulderpoint.cpp \
|
||||||
tools/vtoolnormal.cpp \
|
tools/drawTools/vtoolnormal.cpp \
|
||||||
dialogs/dialognormal.cpp \
|
dialogs/dialognormal.cpp \
|
||||||
tools/vtoolbisector.cpp \
|
tools/drawTools/vtoolbisector.cpp \
|
||||||
dialogs/dialogbisector.cpp \
|
dialogs/dialogbisector.cpp \
|
||||||
tools/vtoollinepoint.cpp \
|
tools/drawTools/vtoollinepoint.cpp \
|
||||||
tools/vtoollineintersect.cpp \
|
tools/drawTools/vtoollineintersect.cpp \
|
||||||
dialogs/dialoglineintersect.cpp \
|
dialogs/dialoglineintersect.cpp \
|
||||||
geometry/vspline.cpp \
|
geometry/vspline.cpp \
|
||||||
tools/vtoolsinglepoint.cpp \
|
tools/drawTools/vtoolsinglepoint.cpp \
|
||||||
geometry/varc.cpp \
|
geometry/varc.cpp \
|
||||||
widgets/vcontrolpointspline.cpp \
|
widgets/vcontrolpointspline.cpp \
|
||||||
tools/vtoolspline.cpp \
|
tools/drawTools/vtoolspline.cpp \
|
||||||
dialogs/dialogspline.cpp \
|
dialogs/dialogspline.cpp \
|
||||||
tools/vtoolarc.cpp \
|
tools/drawTools/vtoolarc.cpp \
|
||||||
dialogs/dialogarc.cpp \
|
dialogs/dialogarc.cpp \
|
||||||
geometry/vsplinepoint.cpp \
|
geometry/vsplinepoint.cpp \
|
||||||
geometry/vsplinepath.cpp \
|
geometry/vsplinepath.cpp \
|
||||||
tools/vtoolsplinepath.cpp \
|
tools/drawTools/vtoolsplinepath.cpp \
|
||||||
dialogs/dialogsplinepath.cpp \
|
dialogs/dialogsplinepath.cpp \
|
||||||
widgets/vmaingraphicsscene.cpp \
|
widgets/vmaingraphicsscene.cpp \
|
||||||
widgets/vmaingraphicsview.cpp \
|
widgets/vmaingraphicsview.cpp \
|
||||||
tools/vdatatool.cpp \
|
tools/vdatatool.cpp \
|
||||||
xml/vtoolrecord.cpp \
|
xml/vtoolrecord.cpp \
|
||||||
dialogs/dialoghistory.cpp \
|
dialogs/dialoghistory.cpp \
|
||||||
tools/vtoolpointofcontact.cpp \
|
tools/drawTools/vtoolpointofcontact.cpp \
|
||||||
dialogs/dialogpointofcontact.cpp \
|
dialogs/dialogpointofcontact.cpp \
|
||||||
geometry/vnodedetail.cpp \
|
geometry/vnodedetail.cpp \
|
||||||
geometry/vdetail.cpp \
|
geometry/vdetail.cpp \
|
||||||
dialogs/dialogdetail.cpp \
|
dialogs/dialogdetail.cpp \
|
||||||
tools/vtooldetail.cpp \
|
tools/vtooldetail.cpp \
|
||||||
tools/vmodelingpoint.cpp \
|
|
||||||
tools/vmodelingspline.cpp \
|
|
||||||
tools/vmodelingarc.cpp \
|
|
||||||
tools/vmodelingsplinepath.cpp \
|
|
||||||
widgets/vtablegraphicsview.cpp \
|
widgets/vtablegraphicsview.cpp \
|
||||||
widgets/vitem.cpp \
|
widgets/vitem.cpp \
|
||||||
tablewindow.cpp
|
tablewindow.cpp \
|
||||||
|
tools/nodeDetails/vnodearc.cpp \
|
||||||
|
tools/nodeDetails/vnodepoint.cpp \
|
||||||
|
tools/nodeDetails/vnodespline.cpp \
|
||||||
|
tools/nodeDetails/vnodesplinepath.cpp \
|
||||||
|
tools/drawTools/vdrawtool.cpp \
|
||||||
|
tools/nodeDetails/vabstractnode.cpp \
|
||||||
|
tools/modelingTools/vmodelingtool.cpp \
|
||||||
|
tools/modelingTools/vmodelingalongline.cpp \
|
||||||
|
tools/modelingTools/vmodelingarc.cpp \
|
||||||
|
tools/modelingTools/vmodelingbisector.cpp \
|
||||||
|
tools/modelingTools/vmodelingendline.cpp \
|
||||||
|
tools/modelingTools/vmodelingline.cpp \
|
||||||
|
tools/modelingTools/vmodelinglineintersect.cpp \
|
||||||
|
tools/modelingTools/vmodelinglinepoint.cpp \
|
||||||
|
tools/modelingTools/vmodelingnormal.cpp \
|
||||||
|
tools/modelingTools/vmodelingpoint.cpp \
|
||||||
|
tools/modelingTools/vmodelingpointofcontact.cpp \
|
||||||
|
tools/modelingTools/vmodelingshoulderpoint.cpp \
|
||||||
|
tools/modelingTools/vmodelingspline.cpp \
|
||||||
|
tools/modelingTools/vmodelingsplinepath.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
widgets/vmaingraphicsscene.h \
|
widgets/vmaingraphicsscene.h \
|
||||||
|
@ -82,7 +99,7 @@ HEADERS += mainwindow.h \
|
||||||
xml/vdomdocument.h \
|
xml/vdomdocument.h \
|
||||||
container/vpointf.h \
|
container/vpointf.h \
|
||||||
container/vcontainer.h \
|
container/vcontainer.h \
|
||||||
tools/vtoolpoint.h \
|
tools/drawTools/vtoolpoint.h \
|
||||||
container/calculator.h \
|
container/calculator.h \
|
||||||
dialogs/dialogincrements.h \
|
dialogs/dialogincrements.h \
|
||||||
container/vstandarttablecell.h \
|
container/vstandarttablecell.h \
|
||||||
|
@ -90,51 +107,73 @@ HEADERS += mainwindow.h \
|
||||||
widgets/delegate.h \
|
widgets/delegate.h \
|
||||||
widgets/doubledelegate.h \
|
widgets/doubledelegate.h \
|
||||||
dialogs/dialogendline.h \
|
dialogs/dialogendline.h \
|
||||||
tools/vtoolendline.h \
|
tools/drawTools/vtoolendline.h \
|
||||||
tools/vtoolline.h \
|
tools/drawTools/vtoolline.h \
|
||||||
tools/vabstracttool.h \
|
tools/vabstracttool.h \
|
||||||
dialogs/dialogline.h \
|
dialogs/dialogline.h \
|
||||||
tools/vtoolalongline.h \
|
tools/drawTools/vtoolalongline.h \
|
||||||
dialogs/dialogtool.h \
|
dialogs/dialogtool.h \
|
||||||
dialogs/dialogalongline.h \
|
dialogs/dialogalongline.h \
|
||||||
tools/vtoolshoulderpoint.h \
|
tools/drawTools/vtoolshoulderpoint.h \
|
||||||
dialogs/dialogshoulderpoint.h \
|
dialogs/dialogshoulderpoint.h \
|
||||||
tools/vtoolnormal.h \
|
tools/drawTools/vtoolnormal.h \
|
||||||
dialogs/dialognormal.h \
|
dialogs/dialognormal.h \
|
||||||
tools/vtoolbisector.h \
|
tools/drawTools/vtoolbisector.h \
|
||||||
dialogs/dialogbisector.h \
|
dialogs/dialogbisector.h \
|
||||||
tools/vtoollinepoint.h \
|
tools/drawTools/vtoollinepoint.h \
|
||||||
tools/vtoollineintersect.h \
|
tools/drawTools/vtoollineintersect.h \
|
||||||
dialogs/dialoglineintersect.h \
|
dialogs/dialoglineintersect.h \
|
||||||
geometry/vspline.h \
|
geometry/vspline.h \
|
||||||
tools/vtoolsinglepoint.h \
|
tools/drawTools/vtoolsinglepoint.h \
|
||||||
geometry/varc.h \
|
geometry/varc.h \
|
||||||
widgets/vcontrolpointspline.h \
|
widgets/vcontrolpointspline.h \
|
||||||
tools/vtoolspline.h \
|
tools/drawTools/vtoolspline.h \
|
||||||
dialogs/dialogspline.h \
|
dialogs/dialogspline.h \
|
||||||
tools/vtoolarc.h \
|
tools/drawTools/vtoolarc.h \
|
||||||
dialogs/dialogarc.h \
|
dialogs/dialogarc.h \
|
||||||
geometry/vsplinepoint.h \
|
geometry/vsplinepoint.h \
|
||||||
geometry/vsplinepath.h \
|
geometry/vsplinepath.h \
|
||||||
tools/vtoolsplinepath.h \
|
tools/drawTools/vtoolsplinepath.h \
|
||||||
dialogs/dialogsplinepath.h \
|
dialogs/dialogsplinepath.h \
|
||||||
widgets/vmaingraphicsview.h \
|
widgets/vmaingraphicsview.h \
|
||||||
tools/vdatatool.h \
|
tools/vdatatool.h \
|
||||||
xml/vtoolrecord.h \
|
xml/vtoolrecord.h \
|
||||||
dialogs/dialoghistory.h \
|
dialogs/dialoghistory.h \
|
||||||
tools/vtoolpointofcontact.h \
|
tools/drawTools/vtoolpointofcontact.h \
|
||||||
dialogs/dialogpointofcontact.h \
|
dialogs/dialogpointofcontact.h \
|
||||||
geometry/vnodedetail.h \
|
geometry/vnodedetail.h \
|
||||||
geometry/vdetail.h \
|
geometry/vdetail.h \
|
||||||
dialogs/dialogdetail.h \
|
dialogs/dialogdetail.h \
|
||||||
tools/vtooldetail.h \
|
tools/vtooldetail.h \
|
||||||
tools/vmodelingpoint.h \
|
|
||||||
tools/vmodelingspline.h \
|
|
||||||
tools/vmodelingarc.h \
|
|
||||||
tools/vmodelingsplinepath.h \
|
|
||||||
widgets/vtablegraphicsview.h \
|
widgets/vtablegraphicsview.h \
|
||||||
widgets/vitem.h \
|
widgets/vitem.h \
|
||||||
tablewindow.h
|
tablewindow.h \
|
||||||
|
tools/tools.h \
|
||||||
|
tools/drawTools/drawtools.h \
|
||||||
|
tools/nodeDetails/nodedetails.h \
|
||||||
|
tools/nodeDetails/vnodearc.h \
|
||||||
|
tools/nodeDetails/vnodepoint.h \
|
||||||
|
tools/nodeDetails/vnodespline.h \
|
||||||
|
tools/nodeDetails/vnodesplinepath.h \
|
||||||
|
stable.h \
|
||||||
|
tools/drawTools/vdrawtool.h \
|
||||||
|
tools/nodeDetails/vabstractnode.h \
|
||||||
|
dialogs/dialogs.h \
|
||||||
|
tools/modelingTools/modelingtools.h \
|
||||||
|
tools/modelingTools/vmodelingtool.h \
|
||||||
|
tools/modelingTools/vmodelingalongline.h \
|
||||||
|
tools/modelingTools/vmodelingarc.h \
|
||||||
|
tools/modelingTools/vmodelingbisector.h \
|
||||||
|
tools/modelingTools/vmodelingendline.h \
|
||||||
|
tools/modelingTools/vmodelingline.h \
|
||||||
|
tools/modelingTools/vmodelinglineintersect.h \
|
||||||
|
tools/modelingTools/vmodelinglinepoint.h \
|
||||||
|
tools/modelingTools/vmodelingnormal.h \
|
||||||
|
tools/modelingTools/vmodelingpoint.h \
|
||||||
|
tools/modelingTools/vmodelingpointofcontact.h \
|
||||||
|
tools/modelingTools/vmodelingshoulderpoint.h \
|
||||||
|
tools/modelingTools/vmodelingspline.h \
|
||||||
|
tools/modelingTools/vmodelingsplinepath.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
dialogs/dialogsinglepoint.ui \
|
dialogs/dialogsinglepoint.ui \
|
||||||
|
@ -158,8 +197,6 @@ RESOURCES += \
|
||||||
icon.qrc \
|
icon.qrc \
|
||||||
cursor.qrc
|
cursor.qrc
|
||||||
|
|
||||||
CONFIG -= debug_and_release debug_and_release_target
|
|
||||||
|
|
||||||
# directory for executable file
|
# directory for executable file
|
||||||
DESTDIR = bin
|
DESTDIR = bin
|
||||||
|
|
||||||
|
@ -176,7 +213,7 @@ RCC_DIR = rcc
|
||||||
UI_DIR = uic
|
UI_DIR = uic
|
||||||
|
|
||||||
# Use Precompiled headers (PCH)
|
# Use Precompiled headers (PCH)
|
||||||
PRECOMPILED_HEADER = stable.h
|
PRECOMPILED_HEADER = stable.h
|
||||||
|
|
||||||
CONFIG(debug, debug|release){
|
CONFIG(debug, debug|release){
|
||||||
# Debug
|
# Debug
|
||||||
|
|
|
@ -26,12 +26,12 @@ qreal Calculator::eval(QString prog, QString *errorMsg){
|
||||||
this->errorMsg->clear();
|
this->errorMsg->clear();
|
||||||
debugFormula.clear();
|
debugFormula.clear();
|
||||||
this->prog = prog;
|
this->prog = prog;
|
||||||
qDebug()<<"Формула: "<<prog;
|
//qDebug()<<"Формула: "<<prog;
|
||||||
index = 0;
|
index = 0;
|
||||||
qreal result = get_exp();
|
qreal result = get_exp();
|
||||||
QString str = QString(" = %1").arg(result, 0, 'f', 3);
|
QString str = QString(" = %1").arg(result, 0, 'f', 3);
|
||||||
debugFormula.append(str);
|
debugFormula.append(str);
|
||||||
qDebug()<<"Результат:"<<debugFormula;
|
//qDebug()<<"Результат:"<<debugFormula;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
#include "vcontainer.h"
|
#include "vcontainer.h"
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#pragma GCC diagnostic pop
|
#include "options.h"
|
||||||
#include "../options.h"
|
|
||||||
|
|
||||||
qint64 VContainer::_id = 0;
|
qint64 VContainer::_id = 0;
|
||||||
|
|
||||||
|
@ -150,32 +144,68 @@ void VContainer::UpdateId(qint64 newId){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VContainer::IncrementReferens(qint64 id, Scene::Type obj){
|
void VContainer::IncrementReferens(qint64 id, Scene::Type obj, Draw::Mode mode){
|
||||||
switch( obj ){
|
switch( obj ){
|
||||||
case(Scene::Line):
|
case(Scene::Line):
|
||||||
break;
|
break;
|
||||||
case(Scene::Point):{
|
case(Scene::Point):{
|
||||||
VPointF point = GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = GetModelingPoint(id);
|
||||||
|
}
|
||||||
point.incrementReferens();
|
point.incrementReferens();
|
||||||
UpdatePoint(id, point);
|
if(mode == Draw::Calculation){
|
||||||
|
UpdatePoint(id, point);
|
||||||
|
} else {
|
||||||
|
UpdateModelingPoint(id, point);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case(Scene::Arc):{
|
case(Scene::Arc):{
|
||||||
VArc arc = GetArc(id);
|
VArc arc;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
arc = GetArc(id);
|
||||||
|
} else {
|
||||||
|
arc = GetModelingArc(id);
|
||||||
|
}
|
||||||
arc.incrementReferens();
|
arc.incrementReferens();
|
||||||
UpdateArc(id, arc);
|
if(mode == Draw::Calculation){
|
||||||
|
UpdateArc(id, arc);
|
||||||
|
} else {
|
||||||
|
UpdateModelingArc(id, arc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case(Scene::Spline):{
|
case(Scene::Spline):{
|
||||||
VSpline spl = GetSpline(id);
|
VSpline spl;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
spl = GetSpline(id);
|
||||||
|
} else {
|
||||||
|
spl = GetModelingSpline(id);
|
||||||
|
}
|
||||||
spl.incrementReferens();
|
spl.incrementReferens();
|
||||||
UpdateSpline(id, spl);
|
if(mode == Draw::Calculation){
|
||||||
|
UpdateSpline(id, spl);
|
||||||
|
} else {
|
||||||
|
UpdateModelingSpline(id, spl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case(Scene::SplinePath):{
|
case(Scene::SplinePath):{
|
||||||
VSplinePath splPath = GetSplinePath(id);
|
VSplinePath splPath;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
splPath = GetSplinePath(id);
|
||||||
|
} else {
|
||||||
|
splPath = GetModelingSplinePath(id);
|
||||||
|
}
|
||||||
splPath.incrementReferens();
|
splPath.incrementReferens();
|
||||||
UpdateSplinePath(id, splPath);
|
if(mode == Draw::Calculation){
|
||||||
|
UpdateSplinePath(id, splPath);
|
||||||
|
} else {
|
||||||
|
UpdateModelingSplinePath(id, splPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -186,26 +216,42 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
|
||||||
QVector<QPointF> points;
|
QVector<QPointF> points;
|
||||||
for(qint32 i = 0; i< detail.CountNode(); ++i){
|
for(qint32 i = 0; i< detail.CountNode(); ++i){
|
||||||
switch(detail[i].getTypeTool()){
|
switch(detail[i].getTypeTool()){
|
||||||
case(Scene::Line):
|
case(Tools::NodePoint):{
|
||||||
break;
|
|
||||||
case(Scene::Point):{
|
|
||||||
VPointF point = GetModelingPoint(detail[i].getId());
|
VPointF point = GetModelingPoint(detail[i].getId());
|
||||||
points.append(point.toQPointF());
|
points.append(point.toQPointF());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case(Scene::Arc):{
|
case(Tools::NodeArc):{
|
||||||
VArc arc = GetModelingArc(detail[i].getId());
|
VArc arc = GetModelingArc(detail[i].getId());
|
||||||
points << arc.GetPoints();
|
qreal len1 = GetLengthContour(points, arc.GetPoints());
|
||||||
|
qreal lenReverse = GetLengthContour(points, GetReversePoint(arc.GetPoints()));
|
||||||
|
if(len1 <= lenReverse){
|
||||||
|
points << arc.GetPoints();
|
||||||
|
} else {
|
||||||
|
points << GetReversePoint(arc.GetPoints());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case(Scene::Spline):{
|
case(Tools::NodeSpline):{
|
||||||
VSpline spline = GetModelingSpline(detail[i].getId());
|
VSpline spline = GetModelingSpline(detail[i].getId());
|
||||||
points << spline.GetPoints();
|
qreal len1 = GetLengthContour(points, spline.GetPoints());
|
||||||
|
qreal lenReverse = GetLengthContour(points, GetReversePoint(spline.GetPoints()));
|
||||||
|
if(len1 <= lenReverse){
|
||||||
|
points << spline.GetPoints();
|
||||||
|
} else {
|
||||||
|
points << GetReversePoint(spline.GetPoints());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case(Scene::SplinePath):{
|
case(Tools::NodeSplinePath):{
|
||||||
VSplinePath splinePath = GetModelingSplinePath(detail[i].getId());
|
VSplinePath splinePath = GetModelingSplinePath(detail[i].getId());
|
||||||
points << splinePath.GetPathPoints();
|
qreal len1 = GetLengthContour(points, splinePath.GetPathPoints());
|
||||||
|
qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath.GetPathPoints()));
|
||||||
|
if(len1 <= lenReverse){
|
||||||
|
points << splinePath.GetPathPoints();
|
||||||
|
} else {
|
||||||
|
points << GetReversePoint(splinePath.GetPathPoints());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -473,13 +519,20 @@ const QMap<qint64, VDetail> *VContainer::DataDetails() const{
|
||||||
return &details;
|
return &details;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId){
|
void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId, Draw::Mode mode){
|
||||||
QString nameLine = GetNameLine(firstPointId, secondPointId);
|
QString nameLine = GetNameLine(firstPointId, secondPointId, mode);
|
||||||
VPointF firstPoint = GetPoint(firstPointId);
|
VPointF first;
|
||||||
VPointF secondPoint = GetPoint(secondPointId);
|
VPointF second;
|
||||||
AddLengthLine(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).length()/PrintDPI*25.4);
|
if(mode == Draw::Calculation){
|
||||||
nameLine = GetNameLineAngle(firstPointId, secondPointId);
|
first = GetPoint(firstPointId);
|
||||||
AddLineAngle(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).angle());
|
second = GetPoint(secondPointId);
|
||||||
|
} else {
|
||||||
|
first = GetModelingPoint(firstPointId);
|
||||||
|
second = GetModelingPoint(secondPointId);
|
||||||
|
}
|
||||||
|
AddLengthLine(nameLine, QLineF(first.toQPointF(), second.toQPointF()).length()/PrintDPI*25.4);
|
||||||
|
nameLine = GetNameLineAngle(firstPointId, secondPointId, mode);
|
||||||
|
AddLineAngle(nameLine, QLineF(first.toQPointF(), second.toQPointF()).angle());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename key, typename val>
|
template <typename key, typename val>
|
||||||
|
@ -525,41 +578,76 @@ qint64 VContainer::AddModelingArc(const VArc &arc){
|
||||||
return AddObject(modelingArcs, arc);
|
return AddObject(modelingArcs, arc);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const{
|
QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint, Draw::Mode mode) const{
|
||||||
VPointF first = GetPoint(firstPoint);
|
VPointF first;
|
||||||
VPointF second = GetPoint(secondPoint);
|
VPointF second;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
first = GetPoint(firstPoint);
|
||||||
|
second = GetPoint(secondPoint);
|
||||||
|
} else {
|
||||||
|
first = GetModelingPoint(firstPoint);
|
||||||
|
second = GetModelingPoint(secondPoint);
|
||||||
|
}
|
||||||
return QString("Line_%1_%2").arg(first.name(), second.name());
|
return QString("Line_%1_%2").arg(first.name(), second.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint) const{
|
QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint,
|
||||||
VPointF first = GetPoint(firstPoint);
|
Draw::Mode mode) const{
|
||||||
VPointF second = GetPoint(secondPoint);
|
VPointF first;
|
||||||
|
VPointF second;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
first = GetPoint(firstPoint);
|
||||||
|
second = GetPoint(secondPoint);
|
||||||
|
} else {
|
||||||
|
first = GetModelingPoint(firstPoint);
|
||||||
|
second = GetModelingPoint(secondPoint);
|
||||||
|
}
|
||||||
return QString("AngleLine_%1_%2").arg(first.name(), second.name());
|
return QString("AngleLine_%1_%2").arg(first.name(), second.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VContainer::GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint) const{
|
QString VContainer::GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint,
|
||||||
VPointF first = GetPoint(firstPoint);
|
Draw::Mode mode) const{
|
||||||
VPointF second = GetPoint(secondPoint);
|
VPointF first;
|
||||||
|
VPointF second;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
first = GetPoint(firstPoint);
|
||||||
|
second = GetPoint(secondPoint);
|
||||||
|
} else {
|
||||||
|
first = GetModelingPoint(firstPoint);
|
||||||
|
second = GetModelingPoint(secondPoint);
|
||||||
|
}
|
||||||
return QString("Spl_%1_%2").arg(first.name(), second.name());
|
return QString("Spl_%1_%2").arg(first.name(), second.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VContainer::GetNameSplinePath(const VSplinePath &path) const{
|
QString VContainer::GetNameSplinePath(const VSplinePath &path, Draw::Mode mode) const{
|
||||||
if(path.Count() == 0){
|
if(path.Count() == 0){
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
QString name("SplPath");
|
QString name("SplPath");
|
||||||
for(qint32 i = 1; i <= path.Count(); ++i){
|
for(qint32 i = 1; i <= path.Count(); ++i){
|
||||||
VSpline spl = path.GetSpline(i);
|
VSpline spl = path.GetSpline(i);
|
||||||
VPointF first = GetPoint(spl.GetP1());
|
VPointF first;
|
||||||
VPointF second = GetPoint(spl.GetP4());
|
VPointF second;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
first = GetPoint(spl.GetP1());
|
||||||
|
second = GetPoint(spl.GetP4());
|
||||||
|
} else {
|
||||||
|
first = GetModelingPoint(spl.GetP1());
|
||||||
|
second = GetModelingPoint(spl.GetP4());
|
||||||
|
}
|
||||||
QString splName = QString("_%1_%2").arg(first.name(), second.name());
|
QString splName = QString("_%1_%2").arg(first.name(), second.name());
|
||||||
name.append(splName);
|
name.append(splName);
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VContainer::GetNameArc(const qint64 ¢er, const qint64 &id) const{
|
QString VContainer::GetNameArc(const qint64 ¢er, const qint64 &id, Draw::Mode mode) const{
|
||||||
VPointF centerPoint = GetPoint(center);
|
VPointF centerPoint;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
centerPoint = GetPoint(center);
|
||||||
|
} else {
|
||||||
|
centerPoint = GetModelingPoint(center);
|
||||||
|
}
|
||||||
return QString ("Arc(%1)%2").arg(centerPoint.name()).arg(id);
|
return QString ("Arc(%1)%2").arg(centerPoint.name()).arg(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,11 +656,18 @@ void VContainer::AddLengthLine(const QString &name, const qreal &value){
|
||||||
lengthLines[name] = value;
|
lengthLines[name] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VContainer::AddLengthSpline(const qint64 &firstPointId, const qint64 &secondPointId){
|
void VContainer::AddLengthSpline(const qint64 &firstPointId, const qint64 &secondPointId, Draw::Mode mode){
|
||||||
QString nameLine = GetNameSpline(firstPointId, secondPointId);
|
QString nameLine = GetNameSpline(firstPointId, secondPointId, mode);
|
||||||
VPointF firstPoint = GetPoint(firstPointId);
|
VPointF first;
|
||||||
VPointF secondPoint = GetPoint(secondPointId);
|
VPointF second;
|
||||||
AddLengthSpline(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).length());
|
if(mode == Draw::Calculation){
|
||||||
|
first = GetPoint(firstPointId);
|
||||||
|
second = GetPoint(secondPointId);
|
||||||
|
} else {
|
||||||
|
first = GetModelingPoint(firstPointId);
|
||||||
|
second = GetModelingPoint(secondPointId);
|
||||||
|
}
|
||||||
|
AddLengthSpline(nameLine, QLineF(first.toQPointF(), second.toQPointF()).length());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VContainer::CreateManTableIGroup (){
|
void VContainer::CreateManTableIGroup (){
|
||||||
|
@ -632,3 +727,23 @@ void VContainer::CreateManTableIGroup (){
|
||||||
AddStandartTableCell("DbII", VStandartTableCell(1020, 0, 44));
|
AddStandartTableCell("DbII", VStandartTableCell(1020, 0, 44));
|
||||||
AddStandartTableCell("Sb", VStandartTableCell(504, 15, 4));
|
AddStandartTableCell("Sb", VStandartTableCell(504, 15, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<QPointF> VContainer::GetReversePoint(const QVector<QPointF> &points) const{
|
||||||
|
Q_ASSERT(points.size() > 0);
|
||||||
|
QVector<QPointF> reversePoints;
|
||||||
|
for (qint32 i = points.size() - 1; i >= 0; --i) {
|
||||||
|
reversePoints.append(points.at(i));
|
||||||
|
}
|
||||||
|
return reversePoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal VContainer::GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints) const{
|
||||||
|
qreal length = 0;
|
||||||
|
QVector<QPointF> points;
|
||||||
|
points << contour << newPoints;
|
||||||
|
for (qint32 i = 0; i < points.size()-1; ++i) {
|
||||||
|
QLineF line(points.at(i), points.at(i+1));
|
||||||
|
length += line.length();
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
#ifndef VCONTAINER_H
|
#ifndef VCONTAINER_H
|
||||||
#define VCONTAINER_H
|
#define VCONTAINER_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
#pragma GCC diagnostic pop
|
#include "options.h"
|
||||||
#include "../options.h"
|
|
||||||
#include "vpointf.h"
|
#include "vpointf.h"
|
||||||
#include "vstandarttablecell.h"
|
#include "vstandarttablecell.h"
|
||||||
#include "vincrementtablerow.h"
|
#include "vincrementtablerow.h"
|
||||||
#include "../geometry/vspline.h"
|
#include "geometry/vspline.h"
|
||||||
#include "../geometry/varc.h"
|
#include "geometry/varc.h"
|
||||||
#include "../geometry/vsplinepath.h"
|
#include "geometry/vsplinepath.h"
|
||||||
#include "../geometry/vdetail.h"
|
#include "geometry/vdetail.h"
|
||||||
#include "../widgets/vitem.h"
|
#include "widgets/vitem.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VContainer class
|
* @brief The VContainer class
|
||||||
|
@ -57,23 +51,30 @@ public:
|
||||||
void AddStandartTableCell(const QString& name, const VStandartTableCell& cell);
|
void AddStandartTableCell(const QString& name, const VStandartTableCell& cell);
|
||||||
void AddIncrementTableRow(const QString& name, const VIncrementTableRow &cell);
|
void AddIncrementTableRow(const QString& name, const VIncrementTableRow &cell);
|
||||||
void AddLengthLine(const QString &name, const qreal &value);
|
void AddLengthLine(const QString &name, const qreal &value);
|
||||||
void AddLengthSpline(const qint64 &firstPointId, const qint64 &secondPointId);
|
void AddLengthSpline(const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
Draw::Mode mode = Draw::Calculation);
|
||||||
void AddLengthSpline(const QString &name, const qreal &value);
|
void AddLengthSpline(const QString &name, const qreal &value);
|
||||||
void AddLengthArc(const qint64 ¢er, const qint64 &id);
|
void AddLengthArc(const qint64 ¢er, const qint64 &id);
|
||||||
void AddLengthArc(const QString &name, const qreal &value);
|
void AddLengthArc(const QString &name, const qreal &value);
|
||||||
void AddLineAngle(const QString &name, const qreal &value);
|
void AddLineAngle(const QString &name, const qreal &value);
|
||||||
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId);
|
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
Draw::Mode mode = Draw::Calculation);
|
||||||
qint64 AddSpline(const VSpline& spl);
|
qint64 AddSpline(const VSpline& spl);
|
||||||
qint64 AddModelingSpline(const VSpline& spl);
|
qint64 AddModelingSpline(const VSpline& spl);
|
||||||
qint64 AddSplinePath(const VSplinePath& splPath);
|
qint64 AddSplinePath(const VSplinePath& splPath);
|
||||||
qint64 AddModelingSplinePath(const VSplinePath& splPath);
|
qint64 AddModelingSplinePath(const VSplinePath& splPath);
|
||||||
qint64 AddArc(const VArc& arc);
|
qint64 AddArc(const VArc& arc);
|
||||||
qint64 AddModelingArc(const VArc& arc);
|
qint64 AddModelingArc(const VArc& arc);
|
||||||
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const;
|
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint,
|
||||||
QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint) const;
|
Draw::Mode mode = Draw::Calculation) const;
|
||||||
QString GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint) const;
|
QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint,
|
||||||
QString GetNameSplinePath(const VSplinePath &path) const;
|
Draw::Mode mode = Draw::Calculation) const;
|
||||||
QString GetNameArc(const qint64 ¢er, const qint64 &id) const;
|
QString GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint,
|
||||||
|
Draw::Mode mode = Draw::Calculation) const;
|
||||||
|
QString GetNameSplinePath(const VSplinePath &path,
|
||||||
|
Draw::Mode mode = Draw::Calculation) const;
|
||||||
|
QString GetNameArc(const qint64 ¢er, const qint64 &id,
|
||||||
|
Draw::Mode mode = Draw::Calculation) const;
|
||||||
void UpdatePoint(qint64 id, const VPointF& point);
|
void UpdatePoint(qint64 id, const VPointF& point);
|
||||||
void UpdateModelingPoint(qint64 id, const VPointF& point);
|
void UpdateModelingPoint(qint64 id, const VPointF& point);
|
||||||
void UpdateDetail(qint64 id, const VDetail& detail);
|
void UpdateDetail(qint64 id, const VDetail& detail);
|
||||||
|
@ -119,7 +120,7 @@ public:
|
||||||
const QMap<qint64, VSplinePath> *DataModelingSplinePaths() const;
|
const QMap<qint64, VSplinePath> *DataModelingSplinePaths() const;
|
||||||
const QMap<qint64, VDetail> *DataDetails() const;
|
const QMap<qint64, VDetail> *DataDetails() const;
|
||||||
void UpdateId(qint64 newId);
|
void UpdateId(qint64 newId);
|
||||||
void IncrementReferens(qint64 id, Scene::Type obj);
|
void IncrementReferens(qint64 id, Scene::Type obj, Draw::Mode mode = Draw::Calculation);
|
||||||
QPainterPath ContourPath(qint64 idDetail) const;
|
QPainterPath ContourPath(qint64 idDetail) const;
|
||||||
void PrepareDetails(QVector<VItem*> & list)const;
|
void PrepareDetails(QVector<VItem*> & list)const;
|
||||||
private:
|
private:
|
||||||
|
@ -144,6 +145,8 @@ private:
|
||||||
template <typename val> void UpdateObject(QMap<qint64, val> &obj, const qint64 &id, const val& point);
|
template <typename val> void UpdateObject(QMap<qint64, val> &obj, const qint64 &id, const val& point);
|
||||||
template <typename key, typename val> qint64 AddObject(QMap<key, val> &obj, const val& value);
|
template <typename key, typename val> qint64 AddObject(QMap<key, val> &obj, const val& value);
|
||||||
void CreateManTableIGroup ();
|
void CreateManTableIGroup ();
|
||||||
|
QVector<QPointF> GetReversePoint(const QVector<QPointF> &points)const;
|
||||||
|
qreal GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints)const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VCONTAINER_H
|
#endif // VCONTAINER_H
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "dialogalongline.h"
|
#include "dialogalongline.h"
|
||||||
#include "ui_dialogalongline.h"
|
#include "ui_dialogalongline.h"
|
||||||
|
|
||||||
DialogAlongLine::DialogAlongLine(const VContainer *data, QWidget *parent) :
|
DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()),
|
DialogTool(data, mode, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()),
|
||||||
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0){
|
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
listWidget = ui->listWidget;
|
listWidget = ui->listWidget;
|
||||||
|
@ -44,8 +44,24 @@ DialogAlongLine::~DialogAlongLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogAlongLine::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogAlongLine::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(type == Scene::Point){
|
if(type == Scene::Point){
|
||||||
VPointF point = data->GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
if(number == 0){
|
if(number == 0){
|
||||||
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||||
if ( index != -1 ) { // -1 for not found
|
if ( index != -1 ) { // -1 for not found
|
||||||
|
|
|
@ -14,7 +14,8 @@ class DialogAlongLine : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogAlongLine(const VContainer *data, QWidget *parent = 0);
|
explicit DialogAlongLine(const VContainer *data, Draw::Mode mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
~DialogAlongLine();
|
~DialogAlongLine();
|
||||||
QString getPointName() const;
|
QString getPointName() const;
|
||||||
void setPointName(const QString &value);
|
void setPointName(const QString &value);
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include "ui_dialogarc.h"
|
#include "ui_dialogarc.h"
|
||||||
#include "../container/calculator.h"
|
#include "../container/calculator.h"
|
||||||
|
|
||||||
DialogArc::DialogArc(const VContainer *data, QWidget *parent) :
|
DialogArc::DialogArc(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
|
DialogTool(data, mode, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
|
||||||
timerRadius(0), timerF1(0), timerF2(0), center(0), radius(QString()), f1(QString()), f2(QString()){
|
timerRadius(0), timerF1(0), timerF2(0), center(0), radius(QString()), f1(QString()), f2(QString()){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -94,8 +94,24 @@ delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogArc::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogArc::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(type == Scene::Point){
|
if(type == Scene::Point){
|
||||||
VPointF point = data->GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
ChangeCurrentText(ui->comboBoxBasePoint, point.name());
|
ChangeCurrentText(ui->comboBoxBasePoint, point.name());
|
||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class DialogArc : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogArc(const VContainer *data, QWidget *parent = 0);
|
explicit DialogArc(const VContainer *data, Draw::Mode mode = Draw::Calculation, QWidget *parent = 0);
|
||||||
~DialogArc();
|
~DialogArc();
|
||||||
qint64 GetCenter() const;
|
qint64 GetCenter() const;
|
||||||
void SetCenter(const qint64 &value);
|
void SetCenter(const qint64 &value);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "dialogbisector.h"
|
#include "dialogbisector.h"
|
||||||
#include "ui_dialogbisector.h"
|
#include "ui_dialogbisector.h"
|
||||||
|
|
||||||
DialogBisector::DialogBisector(const VContainer *data, QWidget *parent) :
|
DialogBisector::DialogBisector(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()),
|
DialogTool(data, mode, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()),
|
||||||
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0){
|
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
listWidget = ui->listWidget;
|
listWidget = ui->listWidget;
|
||||||
|
@ -44,8 +44,24 @@ DialogBisector::~DialogBisector(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogBisector::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogBisector::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(type == Scene::Point){
|
if(type == Scene::Point){
|
||||||
VPointF point = data->GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
if(number == 0){
|
if(number == 0){
|
||||||
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||||
if ( index != -1 ) { // -1 for not found
|
if ( index != -1 ) { // -1 for not found
|
||||||
|
|
|
@ -5,10 +5,9 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include "options.h"
|
||||||
#include "../options.h"
|
#include "container/vcontainer.h"
|
||||||
#include "../container/vcontainer.h"
|
#include "container/calculator.h"
|
||||||
#include "../container/calculator.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DialogBisector;
|
class DialogBisector;
|
||||||
|
@ -19,7 +18,8 @@ class DialogBisector : public DialogTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DialogBisector(const VContainer *data, QWidget *parent = 0);
|
explicit DialogBisector(const VContainer *data, Draw::Mode mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
~DialogBisector();
|
~DialogBisector();
|
||||||
QString getPointName() const;
|
QString getPointName() const;
|
||||||
void setPointName(const QString &value);
|
void setPointName(const QString &value);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "dialogdetail.h"
|
#include "dialogdetail.h"
|
||||||
|
|
||||||
DialogDetail::DialogDetail(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
DialogDetail::DialogDetail(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(), details(VDetail()), mode(mode){
|
DialogTool(data, mode, parent), ui(), details(VDetail()){
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
|
bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
|
||||||
connect(bOk, &QPushButton::clicked, this, &DialogDetail::DialogAccepted);
|
connect(bOk, &QPushButton::clicked, this, &DialogDetail::DialogAccepted);
|
||||||
|
@ -11,8 +11,32 @@ DialogDetail::DialogDetail(const VContainer *data, Draw::Mode mode, QWidget *par
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogDetail::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogDetail::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
if(type != Scene::Line){
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
NewItem(id, type, mode);
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(type != Scene::Line && type != Scene::Detail){
|
||||||
|
switch(type){
|
||||||
|
case(Scene::Arc):
|
||||||
|
NewItem(id, Tools::NodeArc, mode, NodeDetail::Contour);
|
||||||
|
break;
|
||||||
|
case(Scene::Point):
|
||||||
|
NewItem(id, Tools::NodePoint, mode, NodeDetail::Contour);
|
||||||
|
break;
|
||||||
|
case(Scene::Spline):
|
||||||
|
NewItem(id, Tools::NodeSpline, mode, NodeDetail::Contour);
|
||||||
|
break;
|
||||||
|
case(Scene::SplinePath):
|
||||||
|
NewItem(id, Tools::NodeSplinePath, mode, NodeDetail::Contour);
|
||||||
|
break;
|
||||||
|
}
|
||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,36 +51,54 @@ void DialogDetail::DialogAccepted(){
|
||||||
emit DialogClosed(QDialog::Accepted);
|
emit DialogClosed(QDialog::Accepted);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogDetail::NewItem(qint64 id, Scene::Type typeTool, Draw::Mode mode){
|
void DialogDetail::NewItem(qint64 id, Tools::Enum typeTool, Draw::Mode mode, NodeDetail::Type typeNode){
|
||||||
QString name;
|
QString name;
|
||||||
switch(typeTool){
|
switch(typeTool){
|
||||||
case(Scene::Line):
|
case(Tools::NodePoint):{
|
||||||
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
|
name = point.name();
|
||||||
break;
|
break;
|
||||||
case(Scene::Point):{
|
}
|
||||||
VPointF point = data->GetPoint(id);
|
case(Tools::NodeArc):{
|
||||||
name = point.name();
|
VArc arc;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
arc = data->GetArc(id);
|
||||||
|
} else {
|
||||||
|
arc = data->GetModelingArc(id);
|
||||||
}
|
}
|
||||||
break;
|
name = data->GetNameArc(arc.GetCenter(), id, mode);
|
||||||
case(Scene::Arc):{
|
break;
|
||||||
VArc arc = data->GetArc(id);
|
}
|
||||||
name = data->GetNameArc(arc.GetCenter(), id);
|
case(Tools::NodeSpline):{
|
||||||
|
VSpline spl;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
spl = data->GetSpline(id);
|
||||||
|
} else {
|
||||||
|
spl = data->GetModelingSpline(id);
|
||||||
}
|
}
|
||||||
break;
|
name = spl.GetName();
|
||||||
case(Scene::Spline):{
|
break;
|
||||||
VSpline spl = data->GetSpline(id);
|
}
|
||||||
name = spl.GetName();
|
case(Tools::NodeSplinePath):{
|
||||||
|
VSplinePath splPath;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
splPath = data->GetSplinePath(id);
|
||||||
|
} else {
|
||||||
|
splPath = data->GetModelingSplinePath(id);
|
||||||
}
|
}
|
||||||
break;
|
name = data->GetNameSplinePath(splPath, mode);
|
||||||
case(Scene::SplinePath):{
|
break;
|
||||||
VSplinePath splPath = data->GetSplinePath(id);
|
}
|
||||||
name = data->GetNameSplinePath(splPath);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QListWidgetItem *item = new QListWidgetItem(name);
|
QListWidgetItem *item = new QListWidgetItem(name);
|
||||||
item->setFont(QFont("Times", 12, QFont::Bold));
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
||||||
VNodeDetail node(id, typeTool, mode);
|
VNodeDetail node(id, typeTool, mode, typeNode);
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
||||||
ui.listWidget->addItem(item);
|
ui.listWidget->addItem(item);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +111,7 @@ void DialogDetail::setDetails(const VDetail &value){
|
||||||
details = value;
|
details = value;
|
||||||
ui.listWidget->clear();
|
ui.listWidget->clear();
|
||||||
for(qint32 i = 0; i < details.CountNode(); ++i){
|
for(qint32 i = 0; i < details.CountNode(); ++i){
|
||||||
NewItem(details[i].getId(), details[i].getTypeTool(),details[i].getMode());
|
NewItem(details[i].getId(), details[i].getTypeTool(),details[i].getMode(), details[i].getTypeNode());
|
||||||
}
|
}
|
||||||
details.setName(ui.lineEditNameDetail->text());
|
details.setName(ui.lineEditNameDetail->text());
|
||||||
ui.listWidget->setFocus(Qt::OtherFocusReason);
|
ui.listWidget->setFocus(Qt::OtherFocusReason);
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#include "ui_dialogdetail.h"
|
#include "ui_dialogdetail.h"
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include "../container/vcontainer.h"
|
#include "container/vcontainer.h"
|
||||||
#include "../geometry/vdetail.h"
|
#include "geometry/vdetail.h"
|
||||||
|
|
||||||
class DialogDetail : public DialogTool
|
class DialogDetail : public DialogTool
|
||||||
{
|
{
|
||||||
|
@ -20,8 +20,7 @@ public slots:
|
||||||
private:
|
private:
|
||||||
Ui::DialogDetail ui;
|
Ui::DialogDetail ui;
|
||||||
VDetail details;
|
VDetail details;
|
||||||
Draw::Mode mode;
|
void NewItem(qint64 id, Tools::Enum typeTool, Draw::Mode mode, NodeDetail::Type typeNode);
|
||||||
void NewItem(qint64 id, Scene::Type typeTool, Draw::Mode mode);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOGDETAIL_H
|
#endif // DIALOGDETAIL_H
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#include "dialogendline.h"
|
#include "dialogendline.h"
|
||||||
#include "ui_dialogendline.h"
|
#include "ui_dialogendline.h"
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#pragma GCC diagnostic pop
|
#include "container/vpointf.h"
|
||||||
#include "../container/vpointf.h"
|
#include "container/calculator.h"
|
||||||
#include "../container/calculator.h"
|
|
||||||
|
|
||||||
DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent) :
|
DialogEndLine::DialogEndLine(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()),
|
DialogTool(data, mode, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()),
|
||||||
formula(QString()), angle(0), basePointId(0){
|
formula(QString()), angle(0), basePointId(0){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
spinBoxAngle = ui->spinBoxAngle;
|
spinBoxAngle = ui->spinBoxAngle;
|
||||||
|
@ -63,8 +59,24 @@ DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogEndLine::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogEndLine::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(type == Scene::Point){
|
if(type == Scene::Point){
|
||||||
VPointF point = data->GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
ChangeCurrentText(ui->comboBoxBasePoint, point.name());
|
ChangeCurrentText(ui->comboBoxBasePoint, point.name());
|
||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
#ifndef DIALOGENDLINE_H
|
#ifndef DIALOGENDLINE_H
|
||||||
#define DIALOGENDLINE_H
|
#define DIALOGENDLINE_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#pragma GCC diagnostic pop
|
#include "options.h"
|
||||||
|
#include "container/vcontainer.h"
|
||||||
#include "../options.h"
|
#include "container/calculator.h"
|
||||||
#include "../container/vcontainer.h"
|
|
||||||
#include "../container/calculator.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DialogEndLine;
|
class DialogEndLine;
|
||||||
|
@ -21,7 +17,8 @@ class DialogEndLine : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogEndLine(const VContainer *data, QWidget *parent = 0);
|
explicit DialogEndLine(const VContainer *data, Draw::Mode mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
~DialogEndLine();
|
~DialogEndLine();
|
||||||
QString getPointName() const;
|
QString getPointName() const;
|
||||||
void setPointName(const QString &value);
|
void setPointName(const QString &value);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "geometry/vsplinepath.h"
|
#include "geometry/vsplinepath.h"
|
||||||
|
|
||||||
DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent) :
|
DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0), cursorToolRecordRow(0){
|
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogHistory), doc(doc), cursorRow(0), cursorToolRecordRow(0){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted);
|
connect(bOk, &QPushButton::clicked, this, &DialogHistory::DialogAccepted);
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#include "dialogincrements.h"
|
#include "dialogincrements.h"
|
||||||
#include "ui_dialogincrements.h"
|
#include "ui_dialogincrements.h"
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include "../widgets/delegate.h"
|
#include "widgets/delegate.h"
|
||||||
#include "../widgets/doubledelegate.h"
|
#include "widgets/doubledelegate.h"
|
||||||
#pragma GCC diagnostic pop
|
#include "container/vincrementtablerow.h"
|
||||||
#include "../container/vincrementtablerow.h"
|
|
||||||
|
|
||||||
DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent) :
|
DialogIncrements::DialogIncrements(VContainer *data, VDomDocument *doc, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogIncrements), data(data), doc(doc){
|
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogIncrements), data(data), doc(doc){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitialStandartTable();
|
InitialStandartTable();
|
||||||
InitialIncrementTable();
|
InitialIncrementTable();
|
||||||
|
|
|
@ -5,10 +5,8 @@
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
#pragma GCC diagnostic ignored "-Weffc++"
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include "../xml/vdomdocument.h"
|
#include "xml/vdomdocument.h"
|
||||||
#pragma GCC diagnostic pop
|
#include "container/vcontainer.h"
|
||||||
#include "../container/vcontainer.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DialogIncrements;
|
class DialogIncrements;
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialogline.h"
|
#include "dialogline.h"
|
||||||
#include "ui_dialogline.h"
|
#include "ui_dialogline.h"
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
DialogLine::DialogLine(const VContainer *data, QWidget *parent) :
|
DialogLine::DialogLine(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0){
|
DialogTool(data, mode, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted);
|
connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted);
|
||||||
|
@ -61,8 +55,24 @@ void DialogLine::DialogAccepted(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogLine::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogLine::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(type == Scene::Point){
|
if(type == Scene::Point){
|
||||||
VPointF point = data->GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
if(number == 0){
|
if(number == 0){
|
||||||
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||||
if ( index != -1 ) { // -1 for not found
|
if ( index != -1 ) { // -1 for not found
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
#ifndef DIALOGLINE_H
|
#ifndef DIALOGLINE_H
|
||||||
#define DIALOGLINE_H
|
#define DIALOGLINE_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#pragma GCC diagnostic pop
|
#include "container/vcontainer.h"
|
||||||
#include "../container/vcontainer.h"
|
#include "options.h"
|
||||||
#include "../options.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -21,7 +15,8 @@ class DialogLine : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogLine(const VContainer *data, QWidget *parent = 0);
|
explicit DialogLine(const VContainer *data, Draw::Mode mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
~DialogLine();
|
~DialogLine();
|
||||||
qint64 getFirstPoint() const;
|
qint64 getFirstPoint() const;
|
||||||
void setFirstPoint(const qint64 &value);
|
void setFirstPoint(const qint64 &value);
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialoglineintersect.h"
|
#include "dialoglineintersect.h"
|
||||||
#include "ui_dialoglineintersect.h"
|
#include "ui_dialoglineintersect.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
DialogLineIntersect::DialogLineIntersect(const VContainer *data, QWidget *parent) :
|
DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()), p1Line1(0),
|
DialogTool(data, mode, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
|
||||||
p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true){
|
p1Line1(0), p2Line1(0), p1Line2(0), p2Line2(0), flagPoint(true){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
number = 0;
|
number = 0;
|
||||||
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
@ -31,8 +25,24 @@ DialogLineIntersect::~DialogLineIntersect()
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogLineIntersect::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(type == Scene::Point){
|
if(type == Scene::Point){
|
||||||
VPointF point = data->GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
if(number == 0){
|
if(number == 0){
|
||||||
qint32 index = ui->comboBoxP1Line1->findText(point.name());
|
qint32 index = ui->comboBoxP1Line1->findText(point.name());
|
||||||
if ( index != -1 ) { // -1 for not found
|
if ( index != -1 ) { // -1 for not found
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
#ifndef DIALOGLINEINTERSECT_H
|
#ifndef DIALOGLINEINTERSECT_H
|
||||||
#define DIALOGLINEINTERSECT_H
|
#define DIALOGLINEINTERSECT_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DialogLineIntersect;
|
class DialogLineIntersect;
|
||||||
|
@ -17,7 +11,8 @@ class DialogLineIntersect : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogLineIntersect(const VContainer *data, QWidget *parent = 0);
|
explicit DialogLineIntersect(const VContainer *data, Draw::Mode mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
~DialogLineIntersect();
|
~DialogLineIntersect();
|
||||||
qint64 getP1Line1() const;
|
qint64 getP1Line1() const;
|
||||||
void setP1Line1(const qint64 &value);
|
void setP1Line1(const qint64 &value);
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialognormal.h"
|
#include "dialognormal.h"
|
||||||
#include "ui_dialognormal.h"
|
#include "ui_dialognormal.h"
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
DialogNormal::DialogNormal(const VContainer *data, QWidget *parent) :
|
DialogNormal::DialogNormal(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), typeLine(QString()),
|
DialogTool(data, mode, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()),
|
||||||
formula(QString()), angle(0), firstPointId(0), secondPointId(0){
|
typeLine(QString()), formula(QString()), angle(0), firstPointId(0), secondPointId(0){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
spinBoxAngle = ui->spinBoxAngle;
|
spinBoxAngle = ui->spinBoxAngle;
|
||||||
listWidget = ui->listWidget;
|
listWidget = ui->listWidget;
|
||||||
|
@ -68,8 +62,24 @@ DialogNormal::~DialogNormal()
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogNormal::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogNormal::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(type == Scene::Point){
|
if(type == Scene::Point){
|
||||||
VPointF point = data->GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
if(number == 0){
|
if(number == 0){
|
||||||
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||||
if ( index != -1 ) { // -1 for not found
|
if ( index != -1 ) { // -1 for not found
|
||||||
|
|
|
@ -1,19 +1,13 @@
|
||||||
#ifndef DIALOGNORMAL_H
|
#ifndef DIALOGNORMAL_H
|
||||||
#define DIALOGNORMAL_H
|
#define DIALOGNORMAL_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#pragma GCC diagnostic pop
|
#include "options.h"
|
||||||
#include "../options.h"
|
#include "container/vcontainer.h"
|
||||||
#include "../container/vcontainer.h"
|
#include "container/calculator.h"
|
||||||
#include "../container/calculator.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DialogNormal;
|
class DialogNormal;
|
||||||
|
@ -23,7 +17,8 @@ class DialogNormal : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogNormal(const VContainer *data, QWidget *parent = 0);
|
explicit DialogNormal(const VContainer *data, Draw::Mode mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
~DialogNormal();
|
~DialogNormal();
|
||||||
QString getPointName() const;
|
QString getPointName() const;
|
||||||
void setPointName(const QString &value);
|
void setPointName(const QString &value);
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialogpointofcontact.h"
|
#include "dialogpointofcontact.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *parent) :
|
DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0),
|
DialogTool(data, mode, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0),
|
||||||
firstPoint(0), secondPoint(0){
|
firstPoint(0), secondPoint(0){
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
listWidget = ui.listWidget;
|
listWidget = ui.listWidget;
|
||||||
|
@ -44,8 +38,24 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *pare
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(type == Scene::Point){
|
if(type == Scene::Point){
|
||||||
VPointF point = data->GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
if(number == 0){
|
if(number == 0){
|
||||||
qint32 index = ui.comboBoxFirstPoint->findText(point.name());
|
qint32 index = ui.comboBoxFirstPoint->findText(point.name());
|
||||||
if ( index != -1 ) { // -1 for not found
|
if ( index != -1 ) { // -1 for not found
|
||||||
|
|
|
@ -1,24 +1,19 @@
|
||||||
#ifndef DIALOGPOINTOFCONTACT_H
|
#ifndef DIALOGPOINTOFCONTACT_H
|
||||||
#define DIALOGPOINTOFCONTACT_H
|
#define DIALOGPOINTOFCONTACT_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "ui_dialogpointofcontact.h"
|
#include "ui_dialogpointofcontact.h"
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#pragma GCC diagnostic pop
|
#include "options.h"
|
||||||
#include "../options.h"
|
#include "container/vcontainer.h"
|
||||||
#include "../container/vcontainer.h"
|
#include "container/calculator.h"
|
||||||
#include "../container/calculator.h"
|
|
||||||
|
|
||||||
class DialogPointOfContact : public DialogTool
|
class DialogPointOfContact : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DialogPointOfContact(const VContainer *data, QWidget *parent = 0);
|
explicit DialogPointOfContact(const VContainer *data, Draw::Mode mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
QString getPointName() const;
|
QString getPointName() const;
|
||||||
void setPointName(const QString &value);
|
void setPointName(const QString &value);
|
||||||
|
|
||||||
|
|
20
dialogs/dialogs.h
Normal file
20
dialogs/dialogs.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef DIALOGS_H
|
||||||
|
#define DIALOGS_H
|
||||||
|
|
||||||
|
#include "dialogalongline.h"
|
||||||
|
#include "dialogarc.h"
|
||||||
|
#include "dialogbisector.h"
|
||||||
|
#include "dialogdetail.h"
|
||||||
|
#include "dialogendline.h"
|
||||||
|
#include "dialoghistory.h"
|
||||||
|
#include "dialogincrements.h"
|
||||||
|
#include "dialogline.h"
|
||||||
|
#include "dialoglineintersect.h"
|
||||||
|
#include "dialognormal.h"
|
||||||
|
#include "dialogpointofcontact.h"
|
||||||
|
#include "dialogshoulderpoint.h"
|
||||||
|
#include "dialogsinglepoint.h"
|
||||||
|
#include "dialogspline.h"
|
||||||
|
#include "dialogsplinepath.h"
|
||||||
|
|
||||||
|
#endif // DIALOGS_H
|
|
@ -1,14 +1,8 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialogshoulderpoint.h"
|
#include "dialogshoulderpoint.h"
|
||||||
#include "ui_dialogshoulderpoint.h"
|
#include "ui_dialogshoulderpoint.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, QWidget *parent) :
|
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
|
DialogTool(data, mode, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
|
||||||
typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0){
|
typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
number = 0;
|
number = 0;
|
||||||
|
@ -52,8 +46,24 @@ DialogShoulderPoint::~DialogShoulderPoint()
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogShoulderPoint::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogShoulderPoint::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(type == Scene::Point){
|
if(type == Scene::Point){
|
||||||
VPointF point = data->GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
if(number == 0){
|
if(number == 0){
|
||||||
qint32 index = ui->comboBoxP1Line->findText(point.name());
|
qint32 index = ui->comboBoxP1Line->findText(point.name());
|
||||||
if ( index != -1 ) { // -1 for not found
|
if ( index != -1 ) { // -1 for not found
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
#ifndef DIALOGSHOULDERPOINT_H
|
#ifndef DIALOGSHOULDERPOINT_H
|
||||||
#define DIALOGSHOULDERPOINT_H
|
#define DIALOGSHOULDERPOINT_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#pragma GCC diagnostic pop
|
#include "options.h"
|
||||||
#include "../options.h"
|
#include "container/vcontainer.h"
|
||||||
#include "../container/vcontainer.h"
|
#include "container/calculator.h"
|
||||||
#include "../container/calculator.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DialogShoulderPoint;
|
class DialogShoulderPoint;
|
||||||
|
@ -20,7 +14,8 @@ class DialogShoulderPoint : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogShoulderPoint(const VContainer *data, QWidget *parent = 0);
|
explicit DialogShoulderPoint(const VContainer *data, Draw::Mode mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
~DialogShoulderPoint();
|
~DialogShoulderPoint();
|
||||||
QString getPointName() const;
|
QString getPointName() const;
|
||||||
void setPointName(const QString &value);
|
void setPointName(const QString &value);
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialogsinglepoint.h"
|
#include "dialogsinglepoint.h"
|
||||||
#include "ui_dialogsinglepoint.h"
|
#include "ui_dialogsinglepoint.h"
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#pragma GCC diagnostic pop
|
#include "options.h"
|
||||||
#include "../options.h"
|
|
||||||
|
|
||||||
DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) :
|
DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogSinglePoint), name(QString()), point(QPointF()){
|
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()),
|
||||||
|
point(QPointF()){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->doubleSpinBoxX->setRange(0,PaperSize/PrintDPI*25.4);
|
ui->doubleSpinBoxX->setRange(0,PaperSize/PrintDPI*25.4);
|
||||||
ui->doubleSpinBoxY->setRange(0,PaperSize/PrintDPI*25.4);
|
ui->doubleSpinBoxY->setRange(0,PaperSize/PrintDPI*25.4);
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#ifndef DIALOGSINGLEPOINT_H
|
#ifndef DIALOGSINGLEPOINT_H
|
||||||
#define DIALOGSINGLEPOINT_H
|
#define DIALOGSINGLEPOINT_H
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#pragma GCC diagnostic warning "-Weffc++"
|
#include "container/vcontainer.h"
|
||||||
#include "../container/vcontainer.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DialogSinglePoint;
|
class DialogSinglePoint;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "dialogspline.h"
|
#include "dialogspline.h"
|
||||||
#include "ui_dialogspline.h"
|
#include "ui_dialogspline.h"
|
||||||
|
|
||||||
DialogSpline::DialogSpline(const VContainer *data, QWidget *parent) :
|
DialogSpline::DialogSpline(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0),
|
DialogTool(data, mode, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0),
|
||||||
kAsm1(1), kAsm2(1), kCurve(1){
|
kAsm1(1), kAsm2(1), kCurve(1){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
@ -10,18 +10,37 @@ DialogSpline::DialogSpline(const VContainer *data, QWidget *parent) :
|
||||||
|
|
||||||
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||||
connect(bCansel, &QPushButton::clicked, this, &DialogSpline::DialogRejected);
|
connect(bCansel, &QPushButton::clicked, this, &DialogSpline::DialogRejected);
|
||||||
FillComboBoxPoints(ui->comboBoxP1);
|
if(mode == Draw::Calculation){
|
||||||
FillComboBoxPoints(ui->comboBoxP4);
|
FillComboBoxPoints(ui->comboBoxP1);
|
||||||
|
FillComboBoxPoints(ui->comboBoxP4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogSpline::~DialogSpline()
|
DialogSpline::~DialogSpline(){
|
||||||
{
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogSpline::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogSpline::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
FillComboBoxPoints(ui->comboBoxP1);
|
||||||
|
FillComboBoxPoints(ui->comboBoxP4);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(type == Scene::Point){
|
if(type == Scene::Point){
|
||||||
VPointF point = data->GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
if(number == 0){
|
if(number == 0){
|
||||||
qint32 index = ui->comboBoxP1->findText(point.name());
|
qint32 index = ui->comboBoxP1->findText(point.name());
|
||||||
if ( index != -1 ) { // -1 for not found
|
if ( index != -1 ) { // -1 for not found
|
||||||
|
@ -37,8 +56,15 @@ void DialogSpline::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
number = 0;
|
number = 0;
|
||||||
index = ui->comboBoxP1->currentIndex();
|
index = ui->comboBoxP1->currentIndex();
|
||||||
qint64 p1Id = qvariant_cast<qint64>(ui->comboBoxP1->itemData(index));
|
qint64 p1Id = qvariant_cast<qint64>(ui->comboBoxP1->itemData(index));
|
||||||
QPointF p1 = data->GetPoint(p1Id).toQPointF();
|
QPointF p1;
|
||||||
QPointF p4 = data->GetPoint(id).toQPointF();
|
QPointF p4;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
p1 = data->GetPoint(p1Id).toQPointF();
|
||||||
|
p4 = data->GetPoint(id).toQPointF();
|
||||||
|
} else {
|
||||||
|
p1 = data->GetModelingPoint(p1Id).toQPointF();
|
||||||
|
p4 = data->GetModelingPoint(id).toQPointF();
|
||||||
|
}
|
||||||
ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle()));
|
ui->spinBoxAngle1->setValue(static_cast<qint32>(QLineF(p1, p4).angle()));
|
||||||
ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle()));
|
ui->spinBoxAngle2->setValue(static_cast<qint32>(QLineF(p4, p1).angle()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define DIALOGSPLINE_H
|
#define DIALOGSPLINE_H
|
||||||
|
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include "../container/vcontainer.h"
|
#include "container/vcontainer.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DialogSpline;
|
class DialogSpline;
|
||||||
|
@ -12,7 +12,8 @@ class DialogSpline : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogSpline(const VContainer *data, QWidget *parent = 0);
|
explicit DialogSpline(const VContainer *data, Draw::Mode mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
~DialogSpline();
|
~DialogSpline();
|
||||||
qint64 getP1() const;
|
qint64 getP1() const;
|
||||||
void setP1(const qint64 &value);
|
void setP1(const qint64 &value);
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialogsplinepath.h"
|
#include "dialogsplinepath.h"
|
||||||
#include "ui_dialogsplinepath.h"
|
#include "ui_dialogsplinepath.h"
|
||||||
#pragma GCC diagnostic pop
|
#include "geometry/vsplinepoint.h"
|
||||||
#include "../geometry/vsplinepoint.h"
|
|
||||||
|
|
||||||
DialogSplinePath::DialogSplinePath(const VContainer *data, QWidget *parent) :
|
DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Mode mode, QWidget *parent) :
|
||||||
DialogTool(data, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()){
|
DialogTool(data, mode, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
connect(bOk, &QPushButton::clicked, this, &DialogSplinePath::DialogAccepted);
|
connect(bOk, &QPushButton::clicked, this, &DialogSplinePath::DialogAccepted);
|
||||||
|
@ -54,6 +48,17 @@ void DialogSplinePath::SetPath(const VSplinePath &value){
|
||||||
|
|
||||||
|
|
||||||
void DialogSplinePath::ChoosedObject(qint64 id, Scene::Type type){
|
void DialogSplinePath::ChoosedObject(qint64 id, Scene::Type type){
|
||||||
|
if(idDetail == 0 && mode == Draw::Modeling){
|
||||||
|
if(type == Scene::Detail){
|
||||||
|
idDetail = id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(mode == Draw::Modeling){
|
||||||
|
if(!CheckObject(id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(type == Scene::Point){
|
if(type == Scene::Point){
|
||||||
NewItem(id, 1, 0, 1);
|
NewItem(id, 1, 0, 1);
|
||||||
this->show();
|
this->show();
|
||||||
|
@ -116,7 +121,12 @@ void DialogSplinePath::KAsm2Changed(qreal d){
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2){
|
void DialogSplinePath::NewItem(qint64 id, qreal kAsm1, qreal angle, qreal kAsm2){
|
||||||
VPointF point = data->GetPoint(id);
|
VPointF point;
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
point = data->GetPoint(id);
|
||||||
|
} else {
|
||||||
|
point = data->GetModelingPoint(id);
|
||||||
|
}
|
||||||
QListWidgetItem *item = new QListWidgetItem(point.name());
|
QListWidgetItem *item = new QListWidgetItem(point.name());
|
||||||
item->setFont(QFont("Times", 12, QFont::Bold));
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
||||||
VSplinePoint p(id, kAsm1, angle, kAsm2);
|
VSplinePoint p(id, kAsm1, angle, kAsm2);
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
#ifndef DIALOGSPLINEPATH_H
|
#ifndef DIALOGSPLINEPATH_H
|
||||||
#define DIALOGSPLINEPATH_H
|
#define DIALOGSPLINEPATH_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#pragma GCC diagnostic pop
|
#include "container/vcontainer.h"
|
||||||
#include "../container/vcontainer.h"
|
#include "geometry/vsplinepath.h"
|
||||||
#include "../geometry/vsplinepath.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DialogSplinePath;
|
class DialogSplinePath;
|
||||||
|
@ -19,7 +13,8 @@ class DialogSplinePath : public DialogTool
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogSplinePath(const VContainer *data, QWidget *parent = 0);
|
explicit DialogSplinePath(const VContainer *data, Draw::Mode mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
~DialogSplinePath();
|
~DialogSplinePath();
|
||||||
VSplinePath GetPath() const;
|
VSplinePath GetPath() const;
|
||||||
void SetPath(const VSplinePath &value);
|
void SetPath(const VSplinePath &value);
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#pragma GCC diagnostic pop
|
#include "container/calculator.h"
|
||||||
#include "../container/calculator.h"
|
#include "geometry/vdetail.h"
|
||||||
|
|
||||||
DialogTool::DialogTool(const VContainer *data, QWidget *parent):QDialog(parent), data(data),
|
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),
|
isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0), spinBoxAngle(0),
|
||||||
lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0), radioButtonSizeGrowth(0),
|
lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0),
|
||||||
radioButtonStandartTable(0), radioButtonIncrements(0), radioButtonLengthLine(0){
|
radioButtonSizeGrowth(0), radioButtonStandartTable(0), radioButtonIncrements(0),
|
||||||
|
radioButtonLengthLine(0), idDetail(0), mode(mode){
|
||||||
Q_CHECK_PTR(data);
|
Q_CHECK_PTR(data);
|
||||||
timerFormula = new QTimer(this);
|
timerFormula = new QTimer(this);
|
||||||
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
|
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
|
||||||
|
@ -39,13 +35,36 @@ void DialogTool::showEvent(QShowEvent *event){
|
||||||
|
|
||||||
void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{
|
void DialogTool::FillComboBoxPoints(QComboBox *box, const qint64 &id) const{
|
||||||
box->clear();
|
box->clear();
|
||||||
const QMap<qint64, VPointF> *points = data->DataPoints();
|
if(mode == Draw::Calculation){
|
||||||
QMapIterator<qint64, VPointF> i(*points);
|
const QMap<qint64, VPointF> *points = data->DataPoints();
|
||||||
while (i.hasNext()) {
|
QMapIterator<qint64, VPointF> i(*points);
|
||||||
i.next();
|
while (i.hasNext()) {
|
||||||
if(i.key() != id){
|
i.next();
|
||||||
VPointF point = i.value();
|
if(i.key() != id){
|
||||||
box->addItem(point.name(), i.key());
|
VPointF point = i.value();
|
||||||
|
box->addItem(point.name(), i.key());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(idDetail <= 0){
|
||||||
|
qWarning()<<"Wrong details id."<<Q_FUNC_INFO;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
VDetail det = data->GetDetail(idDetail);
|
||||||
|
for(qint32 i = 0; i< det.CountNode(); ++i){
|
||||||
|
if(det[i].getTypeTool() == Tools::NodePoint ||
|
||||||
|
det[i].getTypeTool() == Tools::AlongLineTool ||
|
||||||
|
det[i].getTypeTool() == Tools::BisectorTool ||
|
||||||
|
det[i].getTypeTool() == Tools::EndLineTool ||
|
||||||
|
det[i].getTypeTool() == Tools::LineIntersectTool ||
|
||||||
|
det[i].getTypeTool() == Tools::NormalTool ||
|
||||||
|
det[i].getTypeTool() == Tools::PointOfContact ||
|
||||||
|
det[i].getTypeTool() == Tools::ShoulderPointTool){
|
||||||
|
if(det[i].getId() != id){
|
||||||
|
VPointF point = data->GetModelingPoint(det[i].getId());
|
||||||
|
box->addItem(point.name(), det[i].getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,6 +342,14 @@ void DialogTool::UpdateList(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DialogTool::CheckObject(const qint64 &id){
|
||||||
|
if(mode == Draw::Calculation || idDetail == 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
VDetail det = data->GetDetail(idDetail);
|
||||||
|
return det.Containes(id);
|
||||||
|
}
|
||||||
|
|
||||||
template <class key, class val>
|
template <class key, class val>
|
||||||
void DialogTool::ShowVariable(const QMap<key, val> *var){
|
void DialogTool::ShowVariable(const QMap<key, val> *var){
|
||||||
Q_CHECK_PTR(listWidget);
|
Q_CHECK_PTR(listWidget);
|
||||||
|
@ -338,3 +365,11 @@ void DialogTool::ShowVariable(const QMap<key, val> *var){
|
||||||
}
|
}
|
||||||
listWidget->setCurrentRow (0);
|
listWidget->setCurrentRow (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qint64 DialogTool::getIdDetail() const{
|
||||||
|
return idDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTool::setIdDetail(const qint64 &value){
|
||||||
|
idDetail = value;
|
||||||
|
}
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
#ifndef DIALOGTOOL_H
|
#ifndef DIALOGTOOL_H
|
||||||
#define DIALOGTOOL_H
|
#define DIALOGTOOL_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
@ -15,16 +10,18 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#pragma GCC diagnostic pop
|
#include "container/vcontainer.h"
|
||||||
#include "../container/vcontainer.h"
|
#include "options.h"
|
||||||
#include "../options.h"
|
|
||||||
|
|
||||||
class DialogTool : public QDialog
|
class DialogTool : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DialogTool(const VContainer *data, QWidget *parent = 0);
|
DialogTool(const VContainer *data, Draw::Mode mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
virtual ~DialogTool();
|
virtual ~DialogTool();
|
||||||
|
qint64 getIdDetail() const;
|
||||||
|
void setIdDetail(const qint64 &value);
|
||||||
signals:
|
signals:
|
||||||
void DialogClosed(int result);
|
void DialogClosed(int result);
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -66,6 +63,9 @@ protected:
|
||||||
QRadioButton *radioButtonStandartTable;
|
QRadioButton *radioButtonStandartTable;
|
||||||
QRadioButton *radioButtonIncrements;
|
QRadioButton *radioButtonIncrements;
|
||||||
QRadioButton *radioButtonLengthLine;
|
QRadioButton *radioButtonLengthLine;
|
||||||
|
qint64 idDetail;
|
||||||
|
Draw::Mode mode;
|
||||||
|
bool CheckObject(const qint64 &id);
|
||||||
virtual void closeEvent ( QCloseEvent * event );
|
virtual void closeEvent ( QCloseEvent * event );
|
||||||
virtual void showEvent( QShowEvent *event );
|
virtual void showEvent( QShowEvent *event );
|
||||||
void FillComboBoxPoints(QComboBox *box, const qint64 &id = 0)const;
|
void FillComboBoxPoints(QComboBox *box, const qint64 &id = 0)const;
|
||||||
|
@ -81,7 +81,7 @@ protected:
|
||||||
void Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label);
|
void Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label);
|
||||||
void setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, const qint64 &id) const;
|
void setCurrentPointId(QComboBox *box, qint64 &pointId, const qint64 &value, const qint64 &id) const;
|
||||||
qint64 getCurrentPointId(QComboBox *box) const;
|
qint64 getCurrentPointId(QComboBox *box) const;
|
||||||
DialogTool(const DialogTool &dialog);
|
DialogTool(const DialogTool &dialog);
|
||||||
const DialogTool &operator=(const DialogTool &dialog);
|
const DialogTool &operator=(const DialogTool &dialog);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,16 @@ qint32 VDetail::CountNode() const{
|
||||||
return nodes.size();
|
return nodes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VDetail::Containes(const qint64 &id) const{
|
||||||
|
for(qint32 i = 0; i < nodes.size(); ++i){
|
||||||
|
VNodeDetail node = nodes[i];
|
||||||
|
if(node.getId() == id){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
VNodeDetail &VDetail::operator [](int indx){
|
VNodeDetail &VDetail::operator [](int indx){
|
||||||
return nodes[indx];
|
return nodes[indx];
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ public:
|
||||||
void append(const VNodeDetail &node);
|
void append(const VNodeDetail &node);
|
||||||
void Clear();
|
void Clear();
|
||||||
qint32 CountNode() const;
|
qint32 CountNode() const;
|
||||||
|
bool Containes(const qint64 &id)const;
|
||||||
VNodeDetail & operator[](int indx);
|
VNodeDetail & operator[](int indx);
|
||||||
QString getName() const;
|
QString getName() const;
|
||||||
void setName(const QString &value);
|
void setName(const QString &value);
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
#include "vnodedetail.h"
|
#include "vnodedetail.h"
|
||||||
|
|
||||||
VNodeDetail::VNodeDetail():id(0), typeTool(Scene::Point), mode(Draw::Calculation){
|
VNodeDetail::VNodeDetail():id(0), typeTool(Tools::NodePoint), mode(Draw::Calculation),
|
||||||
|
typeNode(NodeDetail::Contour){
|
||||||
}
|
}
|
||||||
|
|
||||||
VNodeDetail::VNodeDetail(qint64 id, Scene::Type typeTool, Draw::Mode mode):id(id), typeTool(typeTool),
|
VNodeDetail::VNodeDetail(qint64 id, Tools::Enum typeTool, Draw::Mode mode, NodeDetail::Type typeNode):id(id),
|
||||||
mode(mode){
|
typeTool(typeTool), mode(mode), typeNode(typeNode){
|
||||||
}
|
}
|
||||||
|
|
||||||
VNodeDetail::VNodeDetail(const VNodeDetail &node):id(node.getId()), typeTool(node.getTypeTool()),
|
VNodeDetail::VNodeDetail(const VNodeDetail &node):id(node.getId()), typeTool(node.getTypeTool()),
|
||||||
mode(node.getMode()){
|
mode(node.getMode()), typeNode(node.getTypeNode()){
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene::Type VNodeDetail::getTypeTool() const{
|
Tools::Enum VNodeDetail::getTypeTool() const{
|
||||||
return typeTool;
|
return typeTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNodeDetail::setTypeTool(const Scene::Type &value){
|
void VNodeDetail::setTypeTool(const Tools::Enum &value){
|
||||||
typeTool = value;
|
typeTool = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,3 +35,11 @@ Draw::Mode VNodeDetail::getMode() const{
|
||||||
void VNodeDetail::setMode(const Draw::Mode &value){
|
void VNodeDetail::setMode(const Draw::Mode &value){
|
||||||
mode = value;
|
mode = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NodeDetail::Type VNodeDetail::getTypeNode() const{
|
||||||
|
return typeNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VNodeDetail::setTypeNode(const NodeDetail::Type &value){
|
||||||
|
typeNode = value;
|
||||||
|
}
|
||||||
|
|
|
@ -3,24 +3,36 @@
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include "../options.h"
|
#include "options.h"
|
||||||
|
|
||||||
|
namespace NodeDetail{
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
Contour,
|
||||||
|
Modeling
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class VNodeDetail
|
class VNodeDetail
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VNodeDetail();
|
VNodeDetail();
|
||||||
VNodeDetail(qint64 id, Scene::Type typeTool, Draw::Mode mode);
|
VNodeDetail(qint64 id, Tools::Enum typeTool, Draw::Mode mode, NodeDetail::Type typeNode);
|
||||||
VNodeDetail(const VNodeDetail &node);
|
VNodeDetail(const VNodeDetail &node);
|
||||||
qint64 getId() const;
|
qint64 getId() const;
|
||||||
void setId(const qint64 &value);
|
void setId(const qint64 &value);
|
||||||
Scene::Type getTypeTool() const;
|
Tools::Enum getTypeTool() const;
|
||||||
void setTypeTool(const Scene::Type &value);
|
void setTypeTool(const Tools::Enum &value);
|
||||||
Draw::Mode getMode() const;
|
Draw::Mode getMode() const;
|
||||||
void setMode(const Draw::Mode &value);
|
void setMode(const Draw::Mode &value);
|
||||||
|
NodeDetail::Type getTypeNode() const;
|
||||||
|
void setTypeNode(const NodeDetail::Type &value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint64 id;
|
qint64 id;
|
||||||
Scene::Type typeTool;
|
Tools::Enum typeTool;
|
||||||
Draw::Mode mode;
|
Draw::Mode mode;
|
||||||
|
NodeDetail::Type typeNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(VNodeDetail)
|
Q_DECLARE_METATYPE(VNodeDetail)
|
||||||
|
|
|
@ -260,6 +260,26 @@ void VSpline::PutAlongSpl (QPointF &moveP, qreal move ) const{
|
||||||
|
|
||||||
QVector<QPointF> VSpline::GetPoints () const{
|
QVector<QPointF> VSpline::GetPoints () const{
|
||||||
return GetPoints(GetPointP1().toQPointF(), p2, p3, GetPointP4().toQPointF());
|
return GetPoints(GetPointP1().toQPointF(), p2, p3, GetPointP4().toQPointF());
|
||||||
|
// QLineF line1(points.at(0).toPoint(), points.at(1).toPoint());
|
||||||
|
// line1.setLength(500);
|
||||||
|
// QLineF line2 = line1;
|
||||||
|
// line2.setAngle(line2.angle()+90);
|
||||||
|
// qreal xk1 = line1.p2().x();
|
||||||
|
// qreal xk0 = line1.p1().x();
|
||||||
|
// qreal y = line2.p2().y();
|
||||||
|
// qreal yk0 = line1.p1().y();
|
||||||
|
// qreal yk1 = line1.p2().y();
|
||||||
|
// qreal x = line2.p2().x();
|
||||||
|
// qreal check = (xk1 - xk0) * (y - yk0) - (yk1 - yk0) * (x - xk0);
|
||||||
|
// if(check > 0){
|
||||||
|
// return points;
|
||||||
|
// } else {
|
||||||
|
// QVector<QPointF> reversePoints;
|
||||||
|
// for (qint32 i = points.size() - 1; i >= 0; --i) {
|
||||||
|
// reversePoints.append(points.at(i));
|
||||||
|
// }
|
||||||
|
// return reversePoints;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QPointF> VSpline::GetPoints (QPointF p1, QPointF p2, QPointF p3, QPointF p4){
|
QVector<QPointF> VSpline::GetPoints (QPointF p1, QPointF p2, QPointF p3, QPointF p4){
|
||||||
|
|
112
mainwindow.cpp
112
mainwindow.cpp
|
@ -1,8 +1,3 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
@ -13,19 +8,6 @@
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "tools/vtoolendline.h"
|
|
||||||
#include "tools/vtoolline.h"
|
|
||||||
#include "tools/vtoolalongline.h"
|
|
||||||
#include "tools/vtoolshoulderpoint.h"
|
|
||||||
#include "tools/vtoolnormal.h"
|
|
||||||
#include "tools/vtoolbisector.h"
|
|
||||||
#include "tools/vtoollineintersect.h"
|
|
||||||
#include "tools/vtoolspline.h"
|
|
||||||
#include "tools/vtoolarc.h"
|
|
||||||
#include "tools/vtoolsplinepath.h"
|
|
||||||
#include "tools/vtoolpointofcontact.h"
|
|
||||||
#include "tools/vtooldetail.h"
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#include "geometry/vspline.h"
|
#include "geometry/vspline.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
|
@ -145,7 +127,7 @@ void MainWindow::ActionNewDraw(){
|
||||||
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
|
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
|
||||||
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
tools->insert(id, spoint);
|
tools->insert(id, spoint);
|
||||||
VAbstractTool::AddRecord(id, Tools::SinglePointTool, doc);
|
VDrawTool::AddRecord(id, Tools::SinglePointTool, doc);
|
||||||
SetEnableTool(true);
|
SetEnableTool(true);
|
||||||
SetEnableWidgets(true);
|
SetEnableWidgets(true);
|
||||||
}
|
}
|
||||||
|
@ -193,7 +175,7 @@ void MainWindow::SetToolButton(bool checked, Tools::Enum t, const QString &curso
|
||||||
QCursor cur(pixmap, 2, 3);
|
QCursor cur(pixmap, 2, 3);
|
||||||
view->setCursor(cur);
|
view->setCursor(cur);
|
||||||
helpLabel->setText("Виберіть точки.");
|
helpLabel->setText("Виберіть точки.");
|
||||||
dialog = QSharedPointer<Dialog>(new Dialog(data));
|
dialog = QSharedPointer<Dialog>(new Dialog(data, mode));
|
||||||
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
|
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
|
||||||
connect(dialog.data(), &Dialog::DialogClosed, this, closeDialogSlot);
|
connect(dialog.data(), &Dialog::DialogClosed, this, closeDialogSlot);
|
||||||
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
|
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
|
||||||
|
@ -204,6 +186,15 @@ void MainWindow::SetToolButton(bool checked, Tools::Enum t, const QString &curso
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Tool>
|
||||||
|
void MainWindow::AddToolToDetail(Tool *tool, const qint64 &id, Tools::Enum typeTool,
|
||||||
|
const qint64 &idDetail){
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
VToolDetail *det = qobject_cast<VToolDetail*>(tools->value(idDetail));
|
||||||
|
Q_CHECK_PTR(det);
|
||||||
|
det->AddTool(tool, id, typeTool);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::ToolEndLine(bool checked){
|
void MainWindow::ToolEndLine(bool checked){
|
||||||
SetToolButton(checked, Tools::EndLineTool, ":/cursor/endline_cursor.png", dialogEndLine,
|
SetToolButton(checked, Tools::EndLineTool, ":/cursor/endline_cursor.png", dialogEndLine,
|
||||||
&MainWindow::ClosedDialogEndLine);
|
&MainWindow::ClosedDialogEndLine);
|
||||||
|
@ -211,7 +202,12 @@ void MainWindow::ToolEndLine(bool checked){
|
||||||
|
|
||||||
void MainWindow::ClosedDialogEndLine(int result){
|
void MainWindow::ClosedDialogEndLine(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
VToolEndLine::Create(dialogEndLine, currentScene, doc, data, mode);
|
if(mode == Draw::Calculation){
|
||||||
|
VToolEndLine::Create(dialogEndLine, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingEndLine *endLine = VModelingEndLine::Create(dialogEndLine, doc, data);
|
||||||
|
AddToolToDetail(endLine, endLine->getId(), Tools::EndLineTool, dialogEndLine->getIdDetail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
@ -223,7 +219,12 @@ void MainWindow::ToolLine(bool checked){
|
||||||
|
|
||||||
void MainWindow::ClosedDialogLine(int result){
|
void MainWindow::ClosedDialogLine(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
VToolLine::Create(dialogLine, currentScene, doc, data, mode);
|
if(mode == Draw::Calculation){
|
||||||
|
VToolLine::Create(dialogLine, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingLine *line = VModelingLine::Create(dialogLine, doc, data);
|
||||||
|
AddToolToDetail(line, line->getId(), Tools::LineTool, dialogLine->getIdDetail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
@ -235,7 +236,12 @@ void MainWindow::ToolAlongLine(bool checked){
|
||||||
|
|
||||||
void MainWindow::ClosedDialogAlongLine(int result){
|
void MainWindow::ClosedDialogAlongLine(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
VToolAlongLine::Create(dialogAlongLine, currentScene, doc, data, mode);
|
if(mode == Draw::Calculation){
|
||||||
|
VToolAlongLine::Create(dialogAlongLine, currentScene, doc, data);
|
||||||
|
} else{
|
||||||
|
VModelingAlongLine *point = VModelingAlongLine::Create(dialogAlongLine, doc, data);
|
||||||
|
AddToolToDetail(point, point->getId(), Tools::AlongLineTool, dialogAlongLine->getIdDetail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
@ -247,7 +253,13 @@ void MainWindow::ToolShoulderPoint(bool checked){
|
||||||
|
|
||||||
void MainWindow::ClosedDialogShoulderPoint(int result){
|
void MainWindow::ClosedDialogShoulderPoint(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
VToolShoulderPoint::Create(dialogShoulderPoint, currentScene, doc, data, mode);
|
if(mode == Draw::Calculation){
|
||||||
|
VToolShoulderPoint::Create(dialogShoulderPoint, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingShoulderPoint *point = VModelingShoulderPoint::Create(dialogShoulderPoint, doc, data);
|
||||||
|
AddToolToDetail(point, point->getId(), Tools::ShoulderPointTool,
|
||||||
|
dialogShoulderPoint->getIdDetail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
@ -259,7 +271,12 @@ void MainWindow::ToolNormal(bool checked){
|
||||||
|
|
||||||
void MainWindow::ClosedDialogNormal(int result){
|
void MainWindow::ClosedDialogNormal(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
VToolNormal::Create(dialogNormal, currentScene, doc, data, mode);
|
if(mode == Draw::Calculation){
|
||||||
|
VToolNormal::Create(dialogNormal, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingNormal *point = VModelingNormal::Create(dialogNormal, doc, data);
|
||||||
|
AddToolToDetail(point, point->getId(), Tools::NormalTool, dialogNormal->getIdDetail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
@ -271,7 +288,12 @@ void MainWindow::ToolBisector(bool checked){
|
||||||
|
|
||||||
void MainWindow::ClosedDialogBisector(int result){
|
void MainWindow::ClosedDialogBisector(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
VToolBisector::Create(dialogBisector, currentScene, doc, data, mode);
|
if(mode == Draw::Calculation){
|
||||||
|
VToolBisector::Create(dialogBisector, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingBisector *point = VModelingBisector::Create(dialogBisector, doc, data);
|
||||||
|
AddToolToDetail(point, point->getId(), Tools::BisectorTool, dialogBisector->getIdDetail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
@ -283,7 +305,13 @@ void MainWindow::ToolLineIntersect(bool checked){
|
||||||
|
|
||||||
void MainWindow::ClosedDialogLineIntersect(int result){
|
void MainWindow::ClosedDialogLineIntersect(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
VToolLineIntersect::Create(dialogLineIntersect, currentScene, doc, data, mode);
|
if(mode == Draw::Calculation){
|
||||||
|
VToolLineIntersect::Create(dialogLineIntersect, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingLineIntersect *point = VModelingLineIntersect::Create(dialogLineIntersect, doc, data);
|
||||||
|
AddToolToDetail(point, point->getId(), Tools::LineIntersectTool,
|
||||||
|
dialogLineIntersect->getIdDetail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
@ -295,7 +323,12 @@ void MainWindow::ToolSpline(bool checked){
|
||||||
|
|
||||||
void MainWindow::ClosedDialogSpline(int result){
|
void MainWindow::ClosedDialogSpline(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
VToolSpline::Create(dialogSpline, currentScene, doc, data, mode);
|
if(mode == Draw::Calculation){
|
||||||
|
VToolSpline::Create(dialogSpline, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingSpline *spl = VModelingSpline::Create(dialogSpline, doc, data);
|
||||||
|
AddToolToDetail(spl, spl->getId(), Tools::SplineTool, dialogSpline->getIdDetail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
@ -307,7 +340,12 @@ void MainWindow::ToolArc(bool checked){
|
||||||
|
|
||||||
void MainWindow::ClosedDialogArc(int result){
|
void MainWindow::ClosedDialogArc(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
VToolArc::Create(dialogArc, currentScene, doc, data, mode);
|
if(mode == Draw::Calculation){
|
||||||
|
VToolArc::Create(dialogArc, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingArc *arc = VModelingArc::Create(dialogArc, doc, data);
|
||||||
|
AddToolToDetail(arc, arc->getId(), Tools::ArcTool, dialogArc->getIdDetail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
@ -319,7 +357,12 @@ void MainWindow::ToolSplinePath(bool checked){
|
||||||
|
|
||||||
void MainWindow::ClosedDialogSplinePath(int result){
|
void MainWindow::ClosedDialogSplinePath(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
VToolSplinePath::Create(dialogSplinePath, currentScene, doc, data, mode);
|
if(mode == Draw::Calculation){
|
||||||
|
VToolSplinePath::Create(dialogSplinePath, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingSplinePath *spl = VModelingSplinePath::Create(dialogSplinePath, doc, data);
|
||||||
|
AddToolToDetail(spl, spl->getId(), Tools::SplinePathTool, dialogSplinePath->getIdDetail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
@ -331,7 +374,14 @@ void MainWindow::ToolPointOfContact(bool checked){
|
||||||
|
|
||||||
void MainWindow::ClosedDialogPointOfContact(int result){
|
void MainWindow::ClosedDialogPointOfContact(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
VToolPointOfContact::Create(dialogPointOfContact, currentScene, doc, data, mode);
|
if(mode == Draw::Calculation){
|
||||||
|
VToolPointOfContact::Create(dialogPointOfContact, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingPointOfContact *point = VModelingPointOfContact::Create(dialogPointOfContact, doc,
|
||||||
|
data);
|
||||||
|
AddToolToDetail(point, point->getId(), Tools::PointOfContact,
|
||||||
|
dialogPointOfContact->getIdDetail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
|
208
mainwindow.h
208
mainwindow.h
|
@ -1,12 +1,6 @@
|
||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
|
@ -15,26 +9,14 @@
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include "widgets/vmaingraphicsscene.h"
|
#include "widgets/vmaingraphicsscene.h"
|
||||||
#include "widgets/vmaingraphicsview.h"
|
#include "widgets/vmaingraphicsview.h"
|
||||||
#include "dialogs/dialogincrements.h"
|
#include "widgets/vitem.h"
|
||||||
#include "dialogs/dialogline.h"
|
#include "dialogs/dialogs.h"
|
||||||
#include "dialogs/dialogalongline.h"
|
#include "tools/drawTools/drawtools.h"
|
||||||
#include "dialogs/dialogshoulderpoint.h"
|
#include "tools/modelingTools/modelingtools.h"
|
||||||
#include "dialogs/dialogendline.h"
|
|
||||||
#include "dialogs/dialognormal.h"
|
|
||||||
#include "dialogs/dialogbisector.h"
|
|
||||||
#include "dialogs/dialoglineintersect.h"
|
|
||||||
#include "dialogs/dialogspline.h"
|
|
||||||
#include "dialogs/dialogarc.h"
|
|
||||||
#include "dialogs/dialogsplinepath.h"
|
|
||||||
#include "dialogs/dialoghistory.h"
|
|
||||||
#include "dialogs/dialogpointofcontact.h"
|
|
||||||
#include "dialogs/dialogdetail.h"
|
|
||||||
#include "tools/vtoolsinglepoint.h"
|
|
||||||
#include "xml/vdomdocument.h"
|
#include "xml/vdomdocument.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#include "container/vcontainer.h"
|
#include "container/vcontainer.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "widgets/vitem.h"
|
#include "tools/vtooldetail.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
@ -44,108 +26,112 @@ class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = 0);
|
explicit MainWindow(QWidget *parent = 0);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
public slots:
|
public slots:
|
||||||
void mouseMove(QPointF scenePos);
|
void mouseMove(QPointF scenePos);
|
||||||
void ActionAroowTool();
|
void ActionAroowTool();
|
||||||
void ActionDraw(bool checked);
|
void ActionDraw(bool checked);
|
||||||
void ActionDetails(bool checked);
|
void ActionDetails(bool checked);
|
||||||
void ActionNewDraw();
|
void ActionNewDraw();
|
||||||
void currentDrawChanged( int index );
|
void ActionSaveAs();
|
||||||
void OptionDraw();
|
void ActionSave();
|
||||||
void ActionSaveAs();
|
void ActionOpen();
|
||||||
void ActionSave();
|
void ActionNew();
|
||||||
void ActionOpen();
|
void ActionTable(bool checked);
|
||||||
void ActionNew();
|
void ActionHistory(bool checked);
|
||||||
void haveChange();
|
void ActionLayout(bool checked);
|
||||||
void ChangedSize(const QString &text);
|
void currentDrawChanged( int index );
|
||||||
void ChangedGrowth(const QString & text);
|
void OptionDraw();
|
||||||
void ActionTable(bool checked);
|
void haveChange();
|
||||||
void ClosedActionTable();
|
void ChangedSize(const QString &text);
|
||||||
void ActionHistory(bool checked);
|
void ChangedGrowth(const QString & text);
|
||||||
void ActionLayout(bool checked);
|
void ClosedActionTable();
|
||||||
void ClosedActionHistory();
|
void ClosedActionHistory();
|
||||||
void ToolEndLine(bool checked);
|
void ToolEndLine(bool checked);
|
||||||
void ClosedDialogEndLine(int result);
|
void ToolLine(bool checked);
|
||||||
void ToolLine(bool checked);
|
void ToolAlongLine(bool checked);
|
||||||
void ClosedDialogLine(int result);
|
void ToolShoulderPoint(bool checked);
|
||||||
void ToolAlongLine(bool checked);
|
void ToolNormal(bool checked);
|
||||||
void ClosedDialogAlongLine(int result);
|
void ToolBisector(bool checked);
|
||||||
void ToolShoulderPoint(bool checked);
|
void ToolLineIntersect(bool checked);
|
||||||
void ClosedDialogShoulderPoint(int result);
|
void ToolSpline(bool checked);
|
||||||
void ToolNormal(bool checked);
|
void ToolArc(bool checked);
|
||||||
void ClosedDialogNormal(int result);
|
void ToolSplinePath(bool checked);
|
||||||
void ToolBisector(bool checked);
|
void ToolPointOfContact(bool checked);
|
||||||
void ClosedDialogBisector(int result);
|
void ToolDetail(bool checked);
|
||||||
void ToolLineIntersect(bool checked);
|
void ClosedDialogEndLine(int result);
|
||||||
void ClosedDialogLineIntersect(int result);
|
void ClosedDialogLine(int result);
|
||||||
void ToolSpline(bool checked);
|
void ClosedDialogAlongLine(int result);
|
||||||
void ClosedDialogSpline(int result);
|
void ClosedDialogShoulderPoint(int result);
|
||||||
void ToolArc(bool checked);
|
void ClosedDialogNormal(int result);
|
||||||
void ClosedDialogArc(int result);
|
void ClosedDialogBisector(int result);
|
||||||
void ToolSplinePath(bool checked);
|
void ClosedDialogLineIntersect(int result);
|
||||||
void ClosedDialogSplinePath(int result);
|
void ClosedDialogSpline(int result);
|
||||||
void ToolPointOfContact(bool checked);
|
void ClosedDialogArc(int result);
|
||||||
void ClosedDialogPointOfContact(int result);
|
void ClosedDialogSplinePath(int result);
|
||||||
void ToolDetail(bool checked);
|
void ClosedDialogPointOfContact(int result);
|
||||||
void ClosedDialogDetail(int result);
|
void ClosedDialogDetail(int result);
|
||||||
/**
|
/**
|
||||||
* @brief tableClosed Слот, що виконується при отриманні сигналу закриття вікна укладання
|
* @brief tableClosed Слот, що виконується при отриманні сигналу закриття вікна укладання
|
||||||
*деталей моделі.
|
*деталей моделі.
|
||||||
*/
|
*/
|
||||||
void tableClosed();
|
void tableClosed();
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief ModelChosen Сигнал, що висилається після розрахунку всіх деталей моделі.
|
* @brief ModelChosen Сигнал, що висилається після розрахунку всіх деталей моделі.
|
||||||
* @param listDetails Список детайле моделі.
|
* @param listDetails Список детайле моделі.
|
||||||
*/
|
*/
|
||||||
void ModelChosen(QVector<VItem*> listDetails);
|
void ModelChosen(QVector<VItem*> listDetails);
|
||||||
protected:
|
protected:
|
||||||
virtual void keyPressEvent ( QKeyEvent * event );
|
virtual void keyPressEvent ( QKeyEvent * event );
|
||||||
virtual void showEvent( QShowEvent *event );
|
virtual void showEvent( QShowEvent *event );
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
Tools::Enum tool;
|
Tools::Enum tool;
|
||||||
VMainGraphicsScene *currentScene;
|
VMainGraphicsScene *currentScene;
|
||||||
VMainGraphicsScene *sceneDraw;
|
VMainGraphicsScene *sceneDraw;
|
||||||
VMainGraphicsScene *sceneDetails;
|
VMainGraphicsScene *sceneDetails;
|
||||||
QLabel *mouseCoordinate;
|
QLabel *mouseCoordinate;
|
||||||
QLabel *helpLabel;
|
QLabel *helpLabel;
|
||||||
VMainGraphicsView *view;
|
VMainGraphicsView *view;
|
||||||
bool isInitialized;
|
bool isInitialized;
|
||||||
DialogIncrements *dialogTable;
|
DialogIncrements *dialogTable;
|
||||||
QSharedPointer<DialogEndLine> dialogEndLine;
|
QSharedPointer<DialogEndLine> dialogEndLine;
|
||||||
QSharedPointer<DialogLine> dialogLine;
|
QSharedPointer<DialogLine> dialogLine;
|
||||||
QSharedPointer<DialogAlongLine> dialogAlongLine;
|
QSharedPointer<DialogAlongLine> dialogAlongLine;
|
||||||
QSharedPointer<DialogShoulderPoint> dialogShoulderPoint;
|
QSharedPointer<DialogShoulderPoint> dialogShoulderPoint;
|
||||||
QSharedPointer<DialogNormal> dialogNormal;
|
QSharedPointer<DialogNormal> dialogNormal;
|
||||||
QSharedPointer<DialogBisector> dialogBisector;
|
QSharedPointer<DialogBisector> dialogBisector;
|
||||||
QSharedPointer<DialogLineIntersect> dialogLineIntersect;
|
QSharedPointer<DialogLineIntersect> dialogLineIntersect;
|
||||||
QSharedPointer<DialogSpline> dialogSpline;
|
QSharedPointer<DialogSpline> dialogSpline;
|
||||||
QSharedPointer<DialogArc> dialogArc;
|
QSharedPointer<DialogArc> dialogArc;
|
||||||
QSharedPointer<DialogSplinePath> dialogSplinePath;
|
QSharedPointer<DialogSplinePath> dialogSplinePath;
|
||||||
QSharedPointer<DialogPointOfContact> dialogPointOfContact;
|
QSharedPointer<DialogPointOfContact> dialogPointOfContact;
|
||||||
QSharedPointer<DialogDetail> dialogDetail;
|
QSharedPointer<DialogDetail> dialogDetail;
|
||||||
DialogHistory *dialogHistory;
|
DialogHistory *dialogHistory;
|
||||||
VDomDocument *doc;
|
VDomDocument *doc;
|
||||||
VContainer *data;
|
VContainer *data;
|
||||||
QComboBox *comboBoxDraws;
|
QComboBox *comboBoxDraws;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
bool changeInFile;
|
bool changeInFile;
|
||||||
Draw::Mode mode;
|
Draw::Mode mode;
|
||||||
MainWindow(const MainWindow &window);
|
MainWindow(const MainWindow &window);
|
||||||
const MainWindow &operator=(const MainWindow &window);
|
const MainWindow &operator=(const MainWindow &window);
|
||||||
void ToolBarOption();
|
void ToolBarOption();
|
||||||
void ToolBarDraws();
|
void ToolBarDraws();
|
||||||
void CanselTool();
|
void CanselTool();
|
||||||
void ArrowTool();
|
void ArrowTool();
|
||||||
void SetEnableWidgets(bool enable);
|
void SetEnableWidgets(bool enable);
|
||||||
void SetEnableTool(bool enable);
|
void SetEnableTool(bool enable);
|
||||||
template <typename Dialog, typename Func>
|
template <typename Dialog, typename Func>
|
||||||
void SetToolButton(bool checked, Tools::Enum t, const QString &cursor, QSharedPointer<Dialog> &dialog,
|
void SetToolButton(bool checked, Tools::Enum t, const QString &cursor,
|
||||||
|
QSharedPointer<Dialog> &dialog,
|
||||||
Func closeDialogSlot);
|
Func closeDialogSlot);
|
||||||
void MinimumScrollBar();
|
void MinimumScrollBar();
|
||||||
|
template <typename Tool>
|
||||||
|
void AddToolToDetail(Tool *tool, const qint64 &id, Tools::Enum typeTool,
|
||||||
|
const qint64 &idDetail);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -18,7 +18,8 @@ namespace Scene{
|
||||||
Line,
|
Line,
|
||||||
Spline,
|
Spline,
|
||||||
Arc,
|
Arc,
|
||||||
SplinePath
|
SplinePath,
|
||||||
|
Detail
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +39,11 @@ namespace Tools{
|
||||||
ArcTool,
|
ArcTool,
|
||||||
SplinePathTool,
|
SplinePathTool,
|
||||||
PointOfContact,
|
PointOfContact,
|
||||||
Detail
|
Detail,
|
||||||
|
NodePoint,
|
||||||
|
NodeArc,
|
||||||
|
NodeSpline,
|
||||||
|
NodeSplinePath
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
stable.h
36
stable.h
|
@ -1,13 +1,27 @@
|
||||||
/* Add C includes here */
|
/* Add C includes here */
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
/* Add C++ includes here */
|
/* Add C++ includes here */
|
||||||
#include <QApplication>
|
#include <QObject>
|
||||||
#include <QtXml>
|
#include <QApplication>
|
||||||
#include <QSharedPointer>
|
#include <QtGlobal>
|
||||||
#include <QMainWindow>
|
#include <QtXml>
|
||||||
#include "options.h"
|
#include <QSharedPointer>
|
||||||
#include <QMap>
|
#include <QMainWindow>
|
||||||
#include <QString>
|
#include "options.h"
|
||||||
#include <QDialog>
|
#include <QMap>
|
||||||
#endif
|
#include <QString>
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include <QGraphicsPathItem>
|
||||||
|
#include <QGraphicsLineItem>
|
||||||
|
#include <QGraphicsEllipseItem>
|
||||||
|
#include <QPen>
|
||||||
|
#include <QBrush>
|
||||||
|
#include <QGraphicsSceneContextMenuEvent>
|
||||||
|
#include <QDomDocument>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsSimpleTextItem>
|
||||||
|
#endif
|
||||||
|
|
17
tools/drawTools/drawtools.h
Normal file
17
tools/drawTools/drawtools.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef DRAWTOOLS_H
|
||||||
|
#define DRAWTOOLS_H
|
||||||
|
|
||||||
|
#include "vtoolalongline.h"
|
||||||
|
#include "vtoolarc.h"
|
||||||
|
#include "vtoolbisector.h"
|
||||||
|
#include "vtoolendline.h"
|
||||||
|
#include "vtoolline.h"
|
||||||
|
#include "vtoollineintersect.h"
|
||||||
|
#include "vtoolnormal.h"
|
||||||
|
#include "vtoolpointofcontact.h"
|
||||||
|
#include "vtoolshoulderpoint.h"
|
||||||
|
#include "vtoolsinglepoint.h"
|
||||||
|
#include "vtoolspline.h"
|
||||||
|
#include "vtoolsplinepath.h"
|
||||||
|
|
||||||
|
#endif // DRAWTOOLS_H
|
79
tools/drawTools/vdrawtool.cpp
Normal file
79
tools/drawTools/vdrawtool.cpp
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
#include "vdrawtool.h"
|
||||||
|
|
||||||
|
VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) :
|
||||||
|
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false),
|
||||||
|
nameActivDraw(doc->GetNameActivDraw()){
|
||||||
|
connect(this->doc, &VDomDocument::ChangedActivDraw, this, &VDrawTool::ChangedActivDraw);
|
||||||
|
connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw);
|
||||||
|
connect(this->doc, &VDomDocument::ShowTool, this, &VDrawTool::ShowTool);
|
||||||
|
}
|
||||||
|
|
||||||
|
VDrawTool::~VDrawTool(){
|
||||||
|
}
|
||||||
|
|
||||||
|
void VDrawTool::setDialog(){
|
||||||
|
}
|
||||||
|
|
||||||
|
void VDrawTool::AddRecord(const qint64 id, Tools::Enum toolType, VDomDocument *doc){
|
||||||
|
qint64 cursor = doc->getCursor();
|
||||||
|
QVector<VToolRecord> *history = doc->getHistory();
|
||||||
|
if(cursor <= 0){
|
||||||
|
history->append(VToolRecord(id, toolType, doc->GetNameActivDraw()));
|
||||||
|
} else {
|
||||||
|
qint32 index = 0;
|
||||||
|
for(qint32 i = 0; i<history->size(); ++i){
|
||||||
|
VToolRecord rec = history->at(i);
|
||||||
|
if(rec.getId() == cursor){
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
history->insert(index+1, VToolRecord(id, toolType, doc->GetNameActivDraw()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VDrawTool::ignoreContextMenu(bool enable){
|
||||||
|
ignoreContextMenuEvent = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VDrawTool::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){
|
||||||
|
Q_UNUSED(id);
|
||||||
|
Q_UNUSED(color);
|
||||||
|
Q_UNUSED(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VDrawTool::ChangedActivDraw(const QString newName){
|
||||||
|
if(nameActivDraw == newName){
|
||||||
|
ignoreContextMenuEvent = false;
|
||||||
|
} else {
|
||||||
|
ignoreContextMenuEvent = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VDrawTool::ChangedNameDraw(const QString oldName, const QString newName){
|
||||||
|
if(nameActivDraw == oldName){
|
||||||
|
nameActivDraw = newName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VDrawTool::AddToCalculation(const QDomElement &domElement){
|
||||||
|
QDomElement calcElement;
|
||||||
|
bool ok = doc->GetActivCalculationElement(calcElement);
|
||||||
|
if(ok){
|
||||||
|
qint64 id = doc->getCursor();
|
||||||
|
if(id <= 0){
|
||||||
|
calcElement.appendChild(domElement);
|
||||||
|
} else {
|
||||||
|
QDomElement refElement = doc->elementById(QString().setNum(doc->getCursor()));
|
||||||
|
if(refElement.isElement()){
|
||||||
|
calcElement.insertAfter(domElement,refElement);
|
||||||
|
doc->setCursor(0);
|
||||||
|
} else {
|
||||||
|
qCritical()<<"Не можу знайти елемент після якого потрібно вставляти."<< Q_FUNC_INFO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qCritical()<<"Can't find tag Calculation"<< Q_FUNC_INFO;
|
||||||
|
}
|
||||||
|
emit toolhaveChange();
|
||||||
|
}
|
70
tools/drawTools/vdrawtool.h
Normal file
70
tools/drawTools/vdrawtool.h
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#ifndef VDRAWTOOL_H
|
||||||
|
#define VDRAWTOOL_H
|
||||||
|
|
||||||
|
#include "../vabstracttool.h"
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
class VDrawTool : public VAbstractTool
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0);
|
||||||
|
virtual ~VDrawTool();
|
||||||
|
virtual void setDialog();
|
||||||
|
static void AddRecord(const qint64 id, Tools::Enum toolType, VDomDocument *doc);
|
||||||
|
void ignoreContextMenu(bool enable);
|
||||||
|
public slots:
|
||||||
|
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
|
||||||
|
virtual void ChangedActivDraw(const QString newName);
|
||||||
|
void ChangedNameDraw(const QString oldName, const QString newName);
|
||||||
|
virtual void FullUpdateFromGui(int result)=0;
|
||||||
|
signals:
|
||||||
|
void RemoveTool(QGraphicsItem *tool);
|
||||||
|
protected:
|
||||||
|
bool ignoreContextMenuEvent;
|
||||||
|
QString nameActivDraw;
|
||||||
|
void AddToCalculation(const QDomElement &domElement);
|
||||||
|
template <typename Dialog, typename Tool>
|
||||||
|
void ContextMenu(QSharedPointer<Dialog> &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event,
|
||||||
|
bool showRemove = true){
|
||||||
|
if(!ignoreContextMenuEvent){
|
||||||
|
QMenu menu;
|
||||||
|
QAction *actionOption = menu.addAction("Властивості");
|
||||||
|
QAction *actionRemove;
|
||||||
|
if(showRemove){
|
||||||
|
actionRemove = menu.addAction("Видалити");
|
||||||
|
}
|
||||||
|
QAction *selectedAction = menu.exec(event->screenPos());
|
||||||
|
if(selectedAction == actionOption){
|
||||||
|
dialog = QSharedPointer<Dialog>(new Dialog(getData()));
|
||||||
|
|
||||||
|
connect(qobject_cast< VMainGraphicsScene * >(tool->scene()), &VMainGraphicsScene::ChoosedObject,
|
||||||
|
dialog.data(), &Dialog::ChoosedObject);
|
||||||
|
connect(dialog.data(), &Dialog::DialogClosed, tool,
|
||||||
|
&Tool::FullUpdateFromGui);
|
||||||
|
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
|
||||||
|
|
||||||
|
tool->setDialog();
|
||||||
|
|
||||||
|
dialog->show();
|
||||||
|
}
|
||||||
|
if(selectedAction == actionRemove){
|
||||||
|
//remove form xml file
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
QDomElement element;
|
||||||
|
bool ok = doc->GetActivCalculationElement(element);
|
||||||
|
if(ok){
|
||||||
|
element.removeChild(domElement);
|
||||||
|
//update xml file
|
||||||
|
emit FullUpdateTree();
|
||||||
|
//remove form scene
|
||||||
|
emit RemoveTool(tool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VDRAWTOOL_H
|
|
@ -1,17 +1,14 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#include "vtoolalongline.h"
|
#include "vtoolalongline.h"
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#pragma GCC diagnostic pop
|
#include "container/calculator.h"
|
||||||
#include "../container/calculator.h"
|
|
||||||
|
|
||||||
VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, const QString &formula,
|
VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
|
||||||
const qint64 &firstPointId, const qint64 &secondPointId,
|
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
const QString &typeLine, Tool::Enum typeCreation,
|
const QString &typeLine, Tool::Enum typeCreation,
|
||||||
QGraphicsItem *parent):
|
QGraphicsItem *parent):
|
||||||
VToolLinePoint(doc, data, id, mode, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId),
|
VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId),
|
||||||
dialogAlongLine(QSharedPointer<DialogAlongLine>()){
|
dialogAlongLine(QSharedPointer<DialogAlongLine>()){
|
||||||
|
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
|
@ -51,12 +48,7 @@ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolAlongLine::AddToFile(){
|
void VToolAlongLine::AddToFile(){
|
||||||
VPointF point;
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
if(mode == Draw::Calculation){
|
|
||||||
point = VAbstractTool::data.GetPoint(id);
|
|
||||||
} else {
|
|
||||||
point = VAbstractTool::data.GetModelingPoint(id);
|
|
||||||
}
|
|
||||||
QDomElement domElement = doc->createElement("point");
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
|
@ -70,7 +62,7 @@ void VToolAlongLine::AddToFile(){
|
||||||
AddAttribute(domElement, "firstPoint", basePointId);
|
AddAttribute(domElement, "firstPoint", basePointId);
|
||||||
AddAttribute(domElement, "secondPoint", secondPointId);
|
AddAttribute(domElement, "secondPoint", secondPointId);
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolAlongLine::setDialog(){
|
void VToolAlongLine::setDialog(){
|
||||||
|
@ -86,20 +78,20 @@ void VToolAlongLine::setDialog(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolAlongLine::Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene,
|
void VToolAlongLine::Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Draw::Mode mode){
|
VDomDocument *doc, VContainer *data){
|
||||||
QString formula = dialog->getFormula();
|
QString formula = dialog->getFormula();
|
||||||
qint64 firstPointId = dialog->getFirstPointId();
|
qint64 firstPointId = dialog->getFirstPointId();
|
||||||
qint64 secondPointId = dialog->getSecondPointId();
|
qint64 secondPointId = dialog->getSecondPointId();
|
||||||
QString typeLine = dialog->getTypeLine();
|
QString typeLine = dialog->getTypeLine();
|
||||||
QString pointName = dialog->getPointName();
|
QString pointName = dialog->getPointName();
|
||||||
Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, scene, doc, data,
|
Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, scene, doc, data,
|
||||||
Document::FullParse, Tool::FromGui, mode);
|
Document::FullParse, Tool::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||||
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
|
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
|
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){
|
||||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||||
VPointF secondPoint = data->GetPoint(secondPointId);
|
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||||
QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF());
|
QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF());
|
||||||
|
@ -107,7 +99,7 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
|
||||||
QString errorMsg;
|
QString errorMsg;
|
||||||
qreal result = cal.eval(formula, &errorMsg);
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
if(errorMsg.isEmpty()){
|
if(errorMsg.isEmpty()){
|
||||||
line.setLength(result*PrintDPI/25.4);
|
line.setLength(toPixel(result));
|
||||||
qint64 id = _id;
|
qint64 id = _id;
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||||
|
@ -122,15 +114,11 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VAbstractTool::AddRecord(id, Tools::AlongLineTool, doc);
|
VDrawTool::AddRecord(id, Tools::AlongLineTool, doc);
|
||||||
data->AddLine(firstPointId, id);
|
data->AddLine(firstPointId, id);
|
||||||
data->AddLine(id, secondPointId);
|
data->AddLine(id, secondPointId);
|
||||||
if(mode == Draw::Modeling){
|
|
||||||
data->IncrementReferens(firstPointId, Scene::Point);
|
|
||||||
data->IncrementReferens(secondPointId, Scene::Point);
|
|
||||||
}
|
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
VToolAlongLine *point = new VToolAlongLine(doc, data, id, mode, formula, firstPointId,
|
VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId,
|
||||||
secondPointId, typeLine, typeCreation);
|
secondPointId, typeLine, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
|
@ -1,26 +1,23 @@
|
||||||
#ifndef VTOOLALONGLINE_H
|
#ifndef VTOOLALONGLINE_H
|
||||||
#define VTOOLALONGLINE_H
|
#define VTOOLALONGLINE_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#include "vtoollinepoint.h"
|
#include "vtoollinepoint.h"
|
||||||
#include "../dialogs/dialogalongline.h"
|
#include "dialogs/dialogalongline.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
class VToolAlongLine : public VToolLinePoint
|
class VToolAlongLine : public VToolLinePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, const QString &formula,
|
VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
|
||||||
const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine,
|
const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine,
|
||||||
Tool::Enum typeCreation, QGraphicsItem * parent = 0);
|
Tool::Enum typeCreation, QGraphicsItem * parent = 0);
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static void Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
static void Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Draw::Mode mode);
|
VContainer *data);
|
||||||
static void Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
static void Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||||
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
|
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode);
|
VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile();
|
virtual void FullUpdateFromFile();
|
||||||
virtual void FullUpdateFromGui(int result);
|
virtual void FullUpdateFromGui(int result);
|
|
@ -1,15 +1,9 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vtoolarc.h"
|
#include "vtoolarc.h"
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#pragma GCC diagnostic pop
|
#include "../../container/calculator.h"
|
||||||
#include "../container/calculator.h"
|
|
||||||
|
|
||||||
VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, Tool::Enum typeCreation,
|
VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
|
||||||
QGraphicsItem *parent):VAbstractTool(doc, data, id, mode), QGraphicsPathItem(parent),
|
QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsPathItem(parent),
|
||||||
dialogArc(QSharedPointer<DialogArc>()){
|
dialogArc(QSharedPointer<DialogArc>()){
|
||||||
VArc arc = data->GetArc(id);
|
VArc arc = data->GetArc(id);
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
@ -37,17 +31,17 @@ void VToolArc::setDialog(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolArc::Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
void VToolArc::Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Draw::Mode mode){
|
VContainer *data){
|
||||||
qint64 center = dialog->GetCenter();
|
qint64 center = dialog->GetCenter();
|
||||||
QString radius = dialog->GetRadius();
|
QString radius = dialog->GetRadius();
|
||||||
QString f1 = dialog->GetF1();
|
QString f1 = dialog->GetF1();
|
||||||
QString f2 = dialog->GetF2();
|
QString f2 = dialog->GetF2();
|
||||||
Create(0, center, radius, f1, f2, scene, doc, data, Document::FullParse, Tool::FromGui, mode);
|
Create(0, center, radius, f1, f2, scene, doc, data, Document::FullParse, Tool::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolArc::Create(const qint64 _id, const qint64 ¢er, const QString &radius, const QString &f1,
|
void VToolArc::Create(const qint64 _id, const qint64 ¢er, const QString &radius, const QString &f1,
|
||||||
const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc,
|
const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
|
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){
|
||||||
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
|
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
|
||||||
|
|
||||||
Calculator cal(data);
|
Calculator cal(data);
|
||||||
|
@ -85,12 +79,9 @@ void VToolArc::Create(const qint64 _id, const qint64 ¢er, const QString &rad
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data->AddLengthArc(data->GetNameArc(center,id), arc.GetLength());
|
data->AddLengthArc(data->GetNameArc(center,id), arc.GetLength());
|
||||||
VAbstractTool::AddRecord(id, Tools::ArcTool, doc);
|
VDrawTool::AddRecord(id, Tools::ArcTool, doc);
|
||||||
if(mode == Draw::Modeling){
|
|
||||||
data->IncrementReferens(center, Scene::Point);
|
|
||||||
}
|
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
VToolArc *toolArc = new VToolArc(doc, data, id, mode, typeCreation);
|
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
|
||||||
scene->addItem(toolArc);
|
scene->addItem(toolArc);
|
||||||
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(toolArc, &VToolArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
connect(toolArc, &VToolArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
||||||
|
@ -122,12 +113,12 @@ void VToolArc::ChangedActivDraw(const QString newName){
|
||||||
this->setPen(QPen(Qt::black, widthHairLine));
|
this->setPen(QPen(Qt::black, widthHairLine));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
VAbstractTool::ChangedActivDraw(newName);
|
VDrawTool::ChangedActivDraw(newName);
|
||||||
} else {
|
} else {
|
||||||
this->setPen(QPen(Qt::gray, widthHairLine));
|
this->setPen(QPen(Qt::gray, widthHairLine));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||||
this->setAcceptHoverEvents (false);
|
this->setAcceptHoverEvents (false);
|
||||||
VAbstractTool::ChangedActivDraw(newName);
|
VDrawTool::ChangedActivDraw(newName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,12 +139,7 @@ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolArc::AddToFile(){
|
void VToolArc::AddToFile(){
|
||||||
VArc arc;
|
VArc arc = VAbstractTool::data.GetArc(id);
|
||||||
if(mode == Draw::Calculation){
|
|
||||||
arc = VAbstractTool::data.GetArc(id);
|
|
||||||
} else {
|
|
||||||
arc = VAbstractTool::data.GetModelingArc(id);
|
|
||||||
}
|
|
||||||
QDomElement domElement = doc->createElement("arc");
|
QDomElement domElement = doc->createElement("arc");
|
||||||
|
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
|
@ -163,7 +149,7 @@ void VToolArc::AddToFile(){
|
||||||
AddAttribute(domElement, "angle1", arc.GetFormulaF1());
|
AddAttribute(domElement, "angle1", arc.GetFormulaF1());
|
||||||
AddAttribute(domElement, "angle2", arc.GetFormulaF2());
|
AddAttribute(domElement, "angle2", arc.GetFormulaF2());
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
|
void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
|
39
tools/drawTools/vtoolarc.h
Normal file
39
tools/drawTools/vtoolarc.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#ifndef VTOOLARC_H
|
||||||
|
#define VTOOLARC_H
|
||||||
|
|
||||||
|
#include "vdrawtool.h"
|
||||||
|
#include "../../xml/vdomdocument.h"
|
||||||
|
#include <QGraphicsPathItem>
|
||||||
|
#include "../../dialogs/dialogarc.h"
|
||||||
|
#include "../../widgets/vcontrolpointspline.h"
|
||||||
|
#include "../../container/vcontainer.h"
|
||||||
|
|
||||||
|
class VToolArc :public VDrawTool, public QGraphicsPathItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
|
||||||
|
QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static void Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
|
VContainer *data);
|
||||||
|
static void Create(const qint64 _id, const qint64 ¢er, const QString &radius,
|
||||||
|
const QString &f1, const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
|
VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
virtual void ChangedActivDraw(const QString newName);
|
||||||
|
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
private:
|
||||||
|
QSharedPointer<DialogArc> dialogArc;
|
||||||
|
void RefreshGeometry();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VTOOLARC_H
|
|
@ -1,13 +1,11 @@
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#include "vtoolbisector.h"
|
#include "vtoolbisector.h"
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#pragma GCC diagnostic warning "-Weffc++"
|
|
||||||
|
|
||||||
VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
|
VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const QString &typeLine, const QString &formula, const qint64 &firstPointId,
|
const QString &typeLine, const QString &formula, const qint64 &firstPointId,
|
||||||
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Enum typeCreation,
|
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Enum typeCreation,
|
||||||
QGraphicsItem *parent):
|
QGraphicsItem *parent):
|
||||||
VToolLinePoint(doc, data, id, mode, typeLine, formula, secondPointId, 0, parent), firstPointId(0),
|
VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(0),
|
||||||
thirdPointId(0), dialogBisector(QSharedPointer<DialogBisector>()){
|
thirdPointId(0), dialogBisector(QSharedPointer<DialogBisector>()){
|
||||||
this->firstPointId = firstPointId;
|
this->firstPointId = firstPointId;
|
||||||
this->thirdPointId = thirdPointId;
|
this->thirdPointId = thirdPointId;
|
||||||
|
@ -44,7 +42,7 @@ void VToolBisector::setDialog(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolBisector::Create(QSharedPointer<DialogBisector> &dialog, VMainGraphicsScene *scene,
|
void VToolBisector::Create(QSharedPointer<DialogBisector> &dialog, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Draw::Mode mode){
|
VDomDocument *doc, VContainer *data){
|
||||||
QString formula = dialog->getFormula();
|
QString formula = dialog->getFormula();
|
||||||
qint64 firstPointId = dialog->getFirstPointId();
|
qint64 firstPointId = dialog->getFirstPointId();
|
||||||
qint64 secondPointId = dialog->getSecondPointId();
|
qint64 secondPointId = dialog->getSecondPointId();
|
||||||
|
@ -52,14 +50,14 @@ void VToolBisector::Create(QSharedPointer<DialogBisector> &dialog, VMainGraphics
|
||||||
QString typeLine = dialog->getTypeLine();
|
QString typeLine = dialog->getTypeLine();
|
||||||
QString pointName = dialog->getPointName();
|
QString pointName = dialog->getPointName();
|
||||||
Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data,
|
Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data,
|
||||||
Document::FullParse, Tool::FromGui, mode);
|
Document::FullParse, Tool::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolBisector::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
void VToolBisector::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||||
const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine,
|
const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine,
|
||||||
const QString &pointName, const qreal &mx, const qreal &my,
|
const QString &pointName, const qreal &mx, const qreal &my,
|
||||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||||
Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
|
Document::Enum parse, Tool::Enum typeCreation){
|
||||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||||
VPointF secondPoint = data->GetPoint(secondPointId);
|
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||||
VPointF thirdPoint = data->GetPoint(thirdPointId);
|
VPointF thirdPoint = data->GetPoint(thirdPointId);
|
||||||
|
@ -85,14 +83,9 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data->AddLine(firstPointId, id);
|
data->AddLine(firstPointId, id);
|
||||||
VAbstractTool::AddRecord(id, Tools::BisectorTool, doc);
|
VDrawTool::AddRecord(id, Tools::BisectorTool, doc);
|
||||||
if(mode == Draw::Modeling){
|
|
||||||
data->IncrementReferens(firstPointId, Scene::Point);
|
|
||||||
data->IncrementReferens(secondPointId, Scene::Point);
|
|
||||||
data->IncrementReferens(thirdPointId, Scene::Point);
|
|
||||||
}
|
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
VToolBisector *point = new VToolBisector(doc, data, id, mode, typeLine, formula,
|
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula,
|
||||||
firstPointId, secondPointId, thirdPointId,
|
firstPointId, secondPointId, thirdPointId,
|
||||||
typeCreation);
|
typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
|
@ -137,12 +130,7 @@ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolBisector::AddToFile(){
|
void VToolBisector::AddToFile(){
|
||||||
VPointF point;
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
if(mode == Draw::Calculation){
|
|
||||||
point = VAbstractTool::data.GetPoint(id);
|
|
||||||
} else {
|
|
||||||
point = VAbstractTool::data.GetModelingPoint(id);
|
|
||||||
}
|
|
||||||
QDomElement domElement = doc->createElement("point");
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
|
@ -157,5 +145,5 @@ void VToolBisector::AddToFile(){
|
||||||
AddAttribute(domElement, "secondPoint", basePointId);
|
AddAttribute(domElement, "secondPoint", basePointId);
|
||||||
AddAttribute(domElement, "thirdPoint", thirdPointId);
|
AddAttribute(domElement, "thirdPoint", thirdPointId);
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
|
@ -1,16 +1,14 @@
|
||||||
#ifndef VTOOLBISECTOR_H
|
#ifndef VTOOLBISECTOR_H
|
||||||
#define VTOOLBISECTOR_H
|
#define VTOOLBISECTOR_H
|
||||||
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include "vtoollinepoint.h"
|
#include "vtoollinepoint.h"
|
||||||
#include "../dialogs/dialogbisector.h"
|
#include "../../dialogs/dialogbisector.h"
|
||||||
#pragma GCC diagnostic warning "-Weffc++"
|
|
||||||
|
|
||||||
class VToolBisector : public VToolLinePoint
|
class VToolBisector : public VToolLinePoint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
|
VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const QString &typeLine, const QString &formula, const qint64 &firstPointId,
|
const QString &typeLine, const QString &formula, const qint64 &firstPointId,
|
||||||
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Enum typeCreation,
|
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Enum typeCreation,
|
||||||
QGraphicsItem * parent = 0);
|
QGraphicsItem * parent = 0);
|
||||||
|
@ -18,12 +16,11 @@ public:
|
||||||
const QPointF &thirdPoint, const qreal& length);
|
const QPointF &thirdPoint, const qreal& length);
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static void Create(QSharedPointer<DialogBisector> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
static void Create(QSharedPointer<DialogBisector> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Draw::Mode mode);
|
VContainer *data);
|
||||||
static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||||
const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine,
|
const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine,
|
||||||
const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation,
|
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
|
||||||
Draw::Mode mode);
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile();
|
virtual void FullUpdateFromFile();
|
||||||
virtual void FullUpdateFromGui(int result);
|
virtual void FullUpdateFromGui(int result);
|
|
@ -1,15 +1,12 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#include "vtoolendline.h"
|
#include "vtoolendline.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include "../widgets/vmaingraphicsscene.h"
|
#include "../../widgets/vmaingraphicsscene.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode, const QString &typeLine,
|
VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
|
||||||
const QString &formula, const qint32 &angle, const qint64 &basePointId,
|
const QString &formula, const qint32 &angle, const qint64 &basePointId,
|
||||||
Tool::Enum typeCreation, QGraphicsItem *parent):
|
Tool::Enum typeCreation, QGraphicsItem *parent):
|
||||||
VToolLinePoint(doc, data, id, mode, typeLine, formula, basePointId, angle, parent),
|
VToolLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent),
|
||||||
dialogEndLine(QSharedPointer<DialogEndLine>()){
|
dialogEndLine(QSharedPointer<DialogEndLine>()){
|
||||||
|
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
|
@ -30,20 +27,20 @@ void VToolEndLine::setDialog(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
void VToolEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Draw::Mode mode){
|
VContainer *data){
|
||||||
QString pointName = dialog->getPointName();
|
QString pointName = dialog->getPointName();
|
||||||
QString typeLine = dialog->getTypeLine();
|
QString typeLine = dialog->getTypeLine();
|
||||||
QString formula = dialog->getFormula();
|
QString formula = dialog->getFormula();
|
||||||
qint32 angle = dialog->getAngle();
|
qint32 angle = dialog->getAngle();
|
||||||
qint64 basePointId = dialog->getBasePointId();
|
qint64 basePointId = dialog->getBasePointId();
|
||||||
Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse,
|
Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse,
|
||||||
Tool::FromGui, mode);
|
Tool::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||||
const QString &formula, const qint32 &angle, const qint64 &basePointId,
|
const QString &formula, const qint32 &angle, const qint64 &basePointId,
|
||||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
|
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){
|
||||||
|
|
||||||
VPointF basePoint = data->GetPoint(basePointId);
|
VPointF basePoint = data->GetPoint(basePointId);
|
||||||
QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y()));
|
QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y()));
|
||||||
|
@ -68,12 +65,9 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data->AddLine(basePointId, id);
|
data->AddLine(basePointId, id);
|
||||||
VAbstractTool::AddRecord(id, Tools::EndLineTool, doc);
|
VDrawTool::AddRecord(id, Tools::EndLineTool, doc);
|
||||||
if(mode == Draw::Modeling){
|
|
||||||
data->IncrementReferens(basePointId, Scene::Point);
|
|
||||||
}
|
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
VToolEndLine *point = new VToolEndLine(doc, data, id, mode, typeLine, formula, angle,
|
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formula, angle,
|
||||||
basePointId, typeCreation);
|
basePointId, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
@ -115,25 +109,20 @@ void VToolEndLine::FullUpdateFromGui(int result){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolEndLine::AddToFile(){
|
void VToolEndLine::AddToFile(){
|
||||||
VPointF point;
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
if(mode == Draw::Calculation){
|
|
||||||
point = VAbstractTool::data.GetPoint(id);
|
|
||||||
} else {
|
|
||||||
point = VAbstractTool::data.GetModelingPoint(id);
|
|
||||||
}
|
|
||||||
QDomElement domElement = doc->createElement("point");
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
AddAttribute(domElement, "type", "endLine");
|
AddAttribute(domElement, "type", "endLine");
|
||||||
AddAttribute(domElement, "name", point.name());
|
AddAttribute(domElement, "name", point.name());
|
||||||
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
|
AddAttribute(domElement, "mx", toMM(point.mx()));
|
||||||
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
|
AddAttribute(domElement, "my", toMM(point.my()));
|
||||||
|
|
||||||
AddAttribute(domElement, "typeLine", typeLine);
|
AddAttribute(domElement, "typeLine", typeLine);
|
||||||
AddAttribute(domElement, "length", formula);
|
AddAttribute(domElement, "length", formula);
|
||||||
AddAttribute(domElement, "angle", angle);
|
AddAttribute(domElement, "angle", angle);
|
||||||
AddAttribute(domElement, "basePoint", basePointId);
|
AddAttribute(domElement, "basePoint", basePointId);
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,25 @@
|
||||||
#ifndef VTOOLENDLINE_H
|
#ifndef VTOOLENDLINE_H
|
||||||
#define VTOOLENDLINE_H
|
#define VTOOLENDLINE_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include "vtoollinepoint.h"
|
#include "vtoollinepoint.h"
|
||||||
#include "../dialogs/dialogendline.h"
|
#include "dialogs/dialogendline.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
class VToolEndLine : public VToolLinePoint
|
class VToolEndLine : public VToolLinePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
|
VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const QString &typeLine, const QString &formula, const qint32 &angle,
|
const QString &typeLine, const QString &formula, const qint32 &angle,
|
||||||
const qint64 &basePointId, Tool::Enum typeCreation,
|
const qint64 &basePointId, Tool::Enum typeCreation,
|
||||||
QGraphicsItem * parent = 0);
|
QGraphicsItem * parent = 0);
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static void Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
static void Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Draw::Mode mode);
|
VContainer *data);
|
||||||
static void Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
static void Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||||
const QString &formula, const qint32 &angle, const qint64 &basePointId, const qreal &mx, const qreal &my,
|
const QString &formula, const qint32 &angle, const qint64 &basePointId, const qreal &mx, const qreal &my,
|
||||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
|
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
Tool::Enum typeCreation, Draw::Mode mode);
|
Tool::Enum typeCreation);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile();
|
virtual void FullUpdateFromFile();
|
||||||
virtual void FullUpdateFromGui(int result);
|
virtual void FullUpdateFromGui(int result);
|
|
@ -1,15 +1,9 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vtoolline.h"
|
#include "vtoolline.h"
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, qint64 firstPoint, qint64 secondPoint,
|
VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint,
|
||||||
Tool::Enum typeCreation, QGraphicsItem *parent):VAbstractTool(doc, data, id, mode),
|
Tool::Enum typeCreation, QGraphicsItem *parent):VDrawTool(doc, data, id),
|
||||||
QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint),
|
QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint),
|
||||||
dialogLine(QSharedPointer<DialogLine>()){
|
dialogLine(QSharedPointer<DialogLine>()){
|
||||||
//Лінія
|
//Лінія
|
||||||
|
@ -31,15 +25,15 @@ void VToolLine::setDialog(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolLine::Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
void VToolLine::Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Draw::Mode mode){
|
VContainer *data){
|
||||||
qint64 firstPoint = dialog->getFirstPoint();
|
qint64 firstPoint = dialog->getFirstPoint();
|
||||||
qint64 secondPoint = dialog->getSecondPoint();
|
qint64 secondPoint = dialog->getSecondPoint();
|
||||||
Create(0, firstPoint, secondPoint, scene, doc, data, Document::FullParse, Tool::FromGui, mode);
|
Create(0, firstPoint, secondPoint, scene, doc, data, Document::FullParse, Tool::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
|
void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
|
||||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
|
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
Tool::Enum typeCreation, Draw::Mode mode){
|
Tool::Enum typeCreation){
|
||||||
Q_CHECK_PTR(scene);
|
Q_CHECK_PTR(scene);
|
||||||
Q_CHECK_PTR(doc);
|
Q_CHECK_PTR(doc);
|
||||||
Q_CHECK_PTR(data);
|
Q_CHECK_PTR(data);
|
||||||
|
@ -51,14 +45,10 @@ void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64
|
||||||
Q_CHECK_PTR(tool);
|
Q_CHECK_PTR(tool);
|
||||||
tool->VDataTool::setData(data);
|
tool->VDataTool::setData(data);
|
||||||
}
|
}
|
||||||
VAbstractTool::AddRecord(id, Tools::LineTool, doc);
|
VDrawTool::AddRecord(id, Tools::LineTool, doc);
|
||||||
if(mode == Draw::Modeling){
|
|
||||||
data->IncrementReferens(firstPoint, Scene::Point);
|
|
||||||
data->IncrementReferens(secondPoint, Scene::Point);
|
|
||||||
}
|
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
qint64 id = data->getNextId();
|
qint64 id = data->getNextId();
|
||||||
VToolLine *line = new VToolLine(doc, data, id, mode, firstPoint, secondPoint, typeCreation);
|
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation);
|
||||||
Q_CHECK_PTR(line);
|
Q_CHECK_PTR(line);
|
||||||
scene->addItem(line);
|
scene->addItem(line);
|
||||||
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
@ -107,11 +97,11 @@ void VToolLine::ChangedActivDraw(const QString newName){
|
||||||
if(nameActivDraw == newName){
|
if(nameActivDraw == newName){
|
||||||
this->setPen(QPen(Qt::black, widthHairLine));
|
this->setPen(QPen(Qt::black, widthHairLine));
|
||||||
this->setAcceptHoverEvents (true);
|
this->setAcceptHoverEvents (true);
|
||||||
VAbstractTool::ChangedActivDraw(newName);
|
VDrawTool::ChangedActivDraw(newName);
|
||||||
} else {
|
} else {
|
||||||
this->setPen(QPen(Qt::gray, widthHairLine));
|
this->setPen(QPen(Qt::gray, widthHairLine));
|
||||||
this->setAcceptHoverEvents (false);
|
this->setAcceptHoverEvents (false);
|
||||||
VAbstractTool::ChangedActivDraw(newName);
|
VDrawTool::ChangedActivDraw(newName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +116,7 @@ void VToolLine::AddToFile(){
|
||||||
AddAttribute(domElement, "firstPoint", firstPoint);
|
AddAttribute(domElement, "firstPoint", firstPoint);
|
||||||
AddAttribute(domElement, "secondPoint", secondPoint);
|
AddAttribute(domElement, "secondPoint", secondPoint);
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
|
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
|
|
@ -1,28 +1,22 @@
|
||||||
#ifndef VTOOLLINE_H
|
#ifndef VTOOLLINE_H
|
||||||
#define VTOOLLINE_H
|
#define VTOOLLINE_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#include "vdrawtool.h"
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vabstracttool.h"
|
|
||||||
#include "QGraphicsLineItem"
|
#include "QGraphicsLineItem"
|
||||||
#include "../dialogs/dialogline.h"
|
#include "../../dialogs/dialogline.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
class VToolLine: public VAbstractTool, public QGraphicsLineItem
|
class VToolLine: public VDrawTool, public QGraphicsLineItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, qint64 firstPoint,
|
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
|
||||||
qint64 secondPoint, Tool::Enum typeCreation, QGraphicsItem * parent = 0);
|
qint64 secondPoint, Tool::Enum typeCreation, QGraphicsItem * parent = 0);
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static void Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
static void Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Draw::Mode mode);
|
VContainer *data);
|
||||||
static void Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
|
static void Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
|
||||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
|
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
Tool::Enum typeCreation, Draw::Mode mode);
|
Tool::Enum typeCreation);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile();
|
virtual void FullUpdateFromFile();
|
||||||
virtual void ChangedActivDraw(const QString newName);
|
virtual void ChangedActivDraw(const QString newName);
|
|
@ -1,16 +1,10 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vtoollineintersect.h"
|
#include "vtoollineintersect.h"
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
|
VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2,
|
const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2,
|
||||||
const qint64 &p2Line2, Tool::Enum typeCreation, QGraphicsItem *parent):
|
const qint64 &p2Line2, Tool::Enum typeCreation, QGraphicsItem *parent):
|
||||||
VToolPoint(doc, data, id, mode, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
|
VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
|
||||||
p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){
|
p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
AddToFile();
|
AddToFile();
|
||||||
|
@ -30,20 +24,20 @@ void VToolLineIntersect::setDialog(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolLineIntersect::Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene,
|
void VToolLineIntersect::Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Draw::Mode mode){
|
VDomDocument *doc, VContainer *data){
|
||||||
qint64 p1Line1Id = dialog->getP1Line1();
|
qint64 p1Line1Id = dialog->getP1Line1();
|
||||||
qint64 p2Line1Id = dialog->getP2Line1();
|
qint64 p2Line1Id = dialog->getP2Line1();
|
||||||
qint64 p1Line2Id = dialog->getP1Line2();
|
qint64 p1Line2Id = dialog->getP1Line2();
|
||||||
qint64 p2Line2Id = dialog->getP2Line2();
|
qint64 p2Line2Id = dialog->getP2Line2();
|
||||||
QString pointName = dialog->getPointName();
|
QString pointName = dialog->getPointName();
|
||||||
Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data,
|
Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data,
|
||||||
Document::FullParse, Tool::FromGui, mode);
|
Document::FullParse, Tool::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id,
|
void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id,
|
||||||
const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName,
|
const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName,
|
||||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
|
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){
|
||||||
VPointF p1Line1 = data->GetPoint(p1Line1Id);
|
VPointF p1Line1 = data->GetPoint(p1Line1Id);
|
||||||
VPointF p2Line1 = data->GetPoint(p2Line1Id);
|
VPointF p2Line1 = data->GetPoint(p2Line1Id);
|
||||||
VPointF p1Line2 = data->GetPoint(p1Line2Id);
|
VPointF p1Line2 = data->GetPoint(p1Line2Id);
|
||||||
|
@ -72,15 +66,9 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
|
||||||
data->AddLine(id, p2Line1Id);
|
data->AddLine(id, p2Line1Id);
|
||||||
data->AddLine(p1Line2Id, id);
|
data->AddLine(p1Line2Id, id);
|
||||||
data->AddLine(id, p2Line2Id);
|
data->AddLine(id, p2Line2Id);
|
||||||
if(mode == Draw::Modeling){
|
VDrawTool::AddRecord(id, Tools::LineIntersectTool, doc);
|
||||||
data->IncrementReferens(p1Line1Id, Scene::Point);
|
|
||||||
data->IncrementReferens(p2Line1Id, Scene::Point);
|
|
||||||
data->IncrementReferens(p1Line2Id, Scene::Point);
|
|
||||||
data->IncrementReferens(p2Line2Id, Scene::Point);
|
|
||||||
}
|
|
||||||
VAbstractTool::AddRecord(id, Tools::LineIntersectTool, doc);
|
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, mode, p1Line1Id,
|
VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id,
|
||||||
p2Line1Id, p1Line2Id,
|
p2Line1Id, p1Line2Id,
|
||||||
p2Line2Id, typeCreation);
|
p2Line2Id, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
|
@ -100,7 +88,7 @@ void VToolLineIntersect::FullUpdateFromFile(){
|
||||||
p1Line2 = domElement.attribute("p1Line2", "").toLongLong();
|
p1Line2 = domElement.attribute("p1Line2", "").toLongLong();
|
||||||
p2Line2 = domElement.attribute("p2Line2", "").toLongLong();
|
p2Line2 = domElement.attribute("p2Line2", "").toLongLong();
|
||||||
}
|
}
|
||||||
RefreshGeometry();
|
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolLineIntersect::FullUpdateFromGui(int result){
|
void VToolLineIntersect::FullUpdateFromGui(int result){
|
||||||
|
@ -123,12 +111,7 @@ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolLineIntersect::AddToFile(){
|
void VToolLineIntersect::AddToFile(){
|
||||||
VPointF point;
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
if(mode == Draw::Calculation){
|
|
||||||
point = VAbstractTool::data.GetPoint(id);
|
|
||||||
} else {
|
|
||||||
point = VAbstractTool::data.GetModelingPoint(id);
|
|
||||||
}
|
|
||||||
QDomElement domElement = doc->createElement("point");
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
|
@ -142,5 +125,5 @@ void VToolLineIntersect::AddToFile(){
|
||||||
AddAttribute(domElement, "p1Line2", p1Line2);
|
AddAttribute(domElement, "p1Line2", p1Line2);
|
||||||
AddAttribute(domElement, "p2Line2", p2Line2);
|
AddAttribute(domElement, "p2Line2", p2Line2);
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
|
@ -1,31 +1,26 @@
|
||||||
#ifndef VTOOLLINEINTERSECT_H
|
#ifndef VTOOLLINEINTERSECT_H
|
||||||
#define VTOOLLINEINTERSECT_H
|
#define VTOOLLINEINTERSECT_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vtoolpoint.h"
|
#include "vtoolpoint.h"
|
||||||
#include "../dialogs/dialoglineintersect.h"
|
#include "dialogs/dialoglineintersect.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
class VToolLineIntersect:public VToolPoint
|
class VToolLineIntersect:public VToolPoint
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VToolLineIntersect(VDomDocument *doc, VContainer *data,
|
VToolLineIntersect(VDomDocument *doc, VContainer *data,
|
||||||
const qint64 &id, Draw::Mode mode,
|
const qint64 &id,
|
||||||
const qint64 &p1Line1,
|
const qint64 &p1Line1,
|
||||||
const qint64 &p2Line1, const qint64 &p1Line2,
|
const qint64 &p2Line1, const qint64 &p1Line2,
|
||||||
const qint64 &p2Line2, Tool::Enum typeCreation,
|
const qint64 &p2Line2, Tool::Enum typeCreation,
|
||||||
QGraphicsItem * parent = 0);
|
QGraphicsItem * parent = 0);
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static void Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene,
|
static void Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc,VContainer *data, Draw::Mode mode);
|
VDomDocument *doc,VContainer *data);
|
||||||
static void Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id,
|
static void Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id,
|
||||||
const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName,
|
const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName,
|
||||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode);
|
VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile();
|
virtual void FullUpdateFromFile();
|
||||||
virtual void FullUpdateFromGui(int result);
|
virtual void FullUpdateFromGui(int result);
|
|
@ -1,15 +1,9 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vtoollinepoint.h"
|
#include "vtoollinepoint.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode, const QString &typeLine,
|
VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const QString &formula, const qint64 &basePointId, const qint32 &angle,
|
const QString &typeLine, const QString &formula, const qint64 &basePointId,
|
||||||
QGraphicsItem *parent): VToolPoint(doc, data, id, mode, parent), typeLine(typeLine), formula(formula),
|
const qint32 &angle, QGraphicsItem *parent):VToolPoint(doc, data, id, parent),
|
||||||
angle(angle), basePointId(basePointId), mainLine(0){
|
typeLine(typeLine), formula(formula), angle(angle), basePointId(basePointId), mainLine(0){
|
||||||
//Лінія, що з'єднує дві точки
|
//Лінія, що з'єднує дві точки
|
||||||
QPointF point1 = data->GetPoint(basePointId).toQPointF();
|
QPointF point1 = data->GetPoint(basePointId).toQPointF();
|
||||||
QPointF point2 = data->GetPoint(id).toQPointF();
|
QPointF point2 = data->GetPoint(id).toQPointF();
|
||||||
|
@ -34,9 +28,9 @@ void VToolLinePoint::ChangedActivDraw(const QString newName){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolLinePoint::RefreshGeometry(){
|
void VToolLinePoint::RefreshGeometry(){
|
||||||
VToolPoint::RefreshGeometry();
|
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
|
||||||
QPointF point = VAbstractTool::data.GetPoint(id).toQPointF();
|
QPointF point = VDrawTool::data.GetPoint(id).toQPointF();
|
||||||
QPointF basePoint = VAbstractTool::data.GetPoint(basePointId).toQPointF();
|
QPointF basePoint = VDrawTool::data.GetPoint(basePointId).toQPointF();
|
||||||
mainLine->setLine(QLineF(basePoint - point, point - point));
|
mainLine->setLine(QLineF(basePoint - point, point - point));
|
||||||
if(typeLine == "none"){
|
if(typeLine == "none"){
|
||||||
mainLine->setVisible(false);
|
mainLine->setVisible(false);
|
|
@ -1,29 +1,27 @@
|
||||||
#ifndef VTOOLLINEPOINT_H
|
#ifndef VTOOLLINEPOINT_H
|
||||||
#define VTOOLLINEPOINT_H
|
#define VTOOLLINEPOINT_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#include "vtoolpoint.h"
|
#include "vtoolpoint.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
class VToolLinePoint : public VToolPoint
|
class VToolLinePoint : public VToolPoint
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
|
VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const QString &typeLine, const QString &formula,
|
const QString &typeLine, const QString &formula,
|
||||||
const qint64 &basePointId, const qint32 &angle, QGraphicsItem * parent = 0);
|
const qint64 &basePointId, const qint32 &angle, QGraphicsItem * parent = 0);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChangedActivDraw(const QString newName);
|
virtual void ChangedActivDraw(const QString newName);
|
||||||
virtual void RefreshGeometry();
|
|
||||||
protected:
|
protected:
|
||||||
QString typeLine;
|
QString typeLine;
|
||||||
QString formula;
|
QString formula;
|
||||||
qint32 angle;
|
qint32 angle;
|
||||||
qint64 basePointId;
|
qint64 basePointId;
|
||||||
QGraphicsLineItem *mainLine;
|
QGraphicsLineItem *mainLine;
|
||||||
|
virtual void RefreshGeometry();
|
||||||
private:
|
private:
|
||||||
VToolLinePoint(const VToolLinePoint &tool);
|
VToolLinePoint(const VToolLinePoint &tool);
|
||||||
const VToolLinePoint &operator=(const VToolLinePoint &tool);
|
const VToolLinePoint &operator=(const VToolLinePoint &tool);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLLINEPOINT_H
|
#endif // VTOOLLINEPOINT_H
|
|
@ -1,17 +1,11 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vtoolnormal.h"
|
#include "vtoolnormal.h"
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
|
VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const QString &typeLine,
|
const QString &typeLine,
|
||||||
const QString &formula, const qreal &angle, const qint64 &firstPointId,
|
const QString &formula, const qreal &angle, const qint64 &firstPointId,
|
||||||
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem *parent):
|
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem *parent):
|
||||||
VToolLinePoint(doc, data, id, mode, typeLine, formula, firstPointId, angle, parent),
|
VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent),
|
||||||
secondPointId(secondPointId), dialogNormal(QSharedPointer<DialogNormal>()){
|
secondPointId(secondPointId), dialogNormal(QSharedPointer<DialogNormal>()){
|
||||||
|
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
|
@ -34,7 +28,7 @@ void VToolNormal::setDialog(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolNormal::Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
void VToolNormal::Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Draw::Mode mode){
|
VContainer *data){
|
||||||
QString formula = dialog->getFormula();
|
QString formula = dialog->getFormula();
|
||||||
qint64 firstPointId = dialog->getFirstPointId();
|
qint64 firstPointId = dialog->getFirstPointId();
|
||||||
qint64 secondPointId = dialog->getSecondPointId();
|
qint64 secondPointId = dialog->getSecondPointId();
|
||||||
|
@ -42,14 +36,13 @@ void VToolNormal::Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScen
|
||||||
QString pointName = dialog->getPointName();
|
QString pointName = dialog->getPointName();
|
||||||
qint32 angle = dialog->getAngle();
|
qint32 angle = dialog->getAngle();
|
||||||
Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data,
|
Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data,
|
||||||
Document::FullParse, Tool::FromGui, mode);
|
Document::FullParse, Tool::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||||
const qint64 &secondPointId, const QString typeLine, const QString pointName,
|
const qint64 &secondPointId, const QString typeLine, const QString pointName,
|
||||||
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation,
|
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation){
|
||||||
Draw::Mode mode){
|
|
||||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||||
VPointF secondPoint = data->GetPoint(secondPointId);
|
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||||
Calculator cal(data);
|
Calculator cal(data);
|
||||||
|
@ -73,13 +66,9 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data->AddLine(firstPointId, id);
|
data->AddLine(firstPointId, id);
|
||||||
VAbstractTool::AddRecord(id, Tools::NormalTool, doc);
|
VDrawTool::AddRecord(id, Tools::NormalTool, doc);
|
||||||
if(mode == Draw::Modeling){
|
|
||||||
data->IncrementReferens(firstPointId, Scene::Point);
|
|
||||||
data->IncrementReferens(secondPointId, Scene::Point);
|
|
||||||
}
|
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
VToolNormal *point = new VToolNormal(doc, data, id, mode, typeLine, formula, angle,
|
VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle,
|
||||||
firstPointId, secondPointId, typeCreation);
|
firstPointId, secondPointId, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
@ -132,12 +121,7 @@ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolNormal::AddToFile(){
|
void VToolNormal::AddToFile(){
|
||||||
VPointF point;
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
if(mode == Draw::Calculation){
|
|
||||||
point = VAbstractTool::data.GetPoint(id);
|
|
||||||
} else {
|
|
||||||
point = VAbstractTool::data.GetModelingPoint(id);
|
|
||||||
}
|
|
||||||
QDomElement domElement = doc->createElement("point");
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
|
@ -152,5 +136,5 @@ void VToolNormal::AddToFile(){
|
||||||
AddAttribute(domElement, "firstPoint", basePointId);
|
AddAttribute(domElement, "firstPoint", basePointId);
|
||||||
AddAttribute(domElement, "secondPoint", secondPointId);
|
AddAttribute(domElement, "secondPoint", secondPointId);
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
|
@ -1,33 +1,26 @@
|
||||||
#ifndef VTOOLNORMAL_H
|
#ifndef VTOOLNORMAL_H
|
||||||
#define VTOOLNORMAL_H
|
#define VTOOLNORMAL_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include "vtoollinepoint.h"
|
#include "vtoollinepoint.h"
|
||||||
#include "../dialogs/dialognormal.h"
|
#include "dialogs/dialognormal.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
class VToolNormal : public VToolLinePoint
|
class VToolNormal : public VToolLinePoint
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
|
VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
Draw::Mode mode,
|
|
||||||
const QString &typeLine, const QString &formula,
|
const QString &typeLine, const QString &formula,
|
||||||
const qreal &angle, const qint64 &firstPointId,
|
const qreal &angle, const qint64 &firstPointId,
|
||||||
const qint64 &secondPointId, Tool::Enum typeCreation,
|
const qint64 &secondPointId, Tool::Enum typeCreation,
|
||||||
QGraphicsItem * parent = 0);
|
QGraphicsItem * parent = 0);
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static void Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
static void Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Draw::Mode mode);
|
VContainer *data);
|
||||||
static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||||
const qint64 &secondPointId, const QString typeLine, const QString pointName,
|
const qint64 &secondPointId, const QString typeLine, const QString pointName,
|
||||||
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation,
|
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
|
||||||
Draw::Mode mode);
|
|
||||||
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||||
const qreal &length, const qreal &angle = 0);
|
const qreal &length, const qreal &angle = 0);
|
||||||
public slots:
|
public slots:
|
125
tools/drawTools/vtoolpoint.cpp
Normal file
125
tools/drawTools/vtoolpoint.cpp
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
#include "vtoolpoint.h"
|
||||||
|
#include <QPen>
|
||||||
|
#include <QBrush>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include "container/vpointf.h"
|
||||||
|
|
||||||
|
|
||||||
|
VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id,
|
||||||
|
QGraphicsItem *parent):VDrawTool(doc, data, id),
|
||||||
|
QGraphicsEllipseItem(parent), radius(toPixel(1.5)), namePoint(0), lineName(0){
|
||||||
|
namePoint = new VGraphicsSimpleTextItem(this);
|
||||||
|
lineName = new QGraphicsLineItem(this);
|
||||||
|
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
||||||
|
&VToolPoint::NameChangePosition);
|
||||||
|
this->setPen(QPen(Qt::black, widthHairLine));
|
||||||
|
this->setBrush(QBrush(Qt::NoBrush));
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
|
this->setAcceptHoverEvents(true);
|
||||||
|
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolPoint::NameChangePosition(const QPointF pos){
|
||||||
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
|
QPointF p = pos - this->pos();
|
||||||
|
point.setMx(p.x());
|
||||||
|
point.setMy(p.y());
|
||||||
|
RefreshLine();
|
||||||
|
UpdateNamePosition(point.mx(), point.my());
|
||||||
|
VAbstractTool::data.UpdatePoint(id, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolPoint::UpdateNamePosition(qreal mx, qreal my){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("mx", QString().setNum(toMM(mx)));
|
||||||
|
domElement.setAttribute("my", QString().setNum(toMM(my)));
|
||||||
|
emit toolhaveChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolPoint::ChangedActivDraw(const QString newName){
|
||||||
|
if(nameActivDraw == newName){
|
||||||
|
this->setPen(QPen(Qt::black, widthHairLine));
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
|
this->setAcceptHoverEvents(true);
|
||||||
|
namePoint->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
|
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
|
namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
|
namePoint->setBrush(QBrush(Qt::black));
|
||||||
|
namePoint->setAcceptHoverEvents(true);
|
||||||
|
lineName->setPen(QPen(Qt::black, widthHairLine));
|
||||||
|
VDrawTool::ChangedActivDraw(newName);
|
||||||
|
} else {
|
||||||
|
this->setPen(QPen(Qt::gray, widthHairLine));
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||||
|
this->setAcceptHoverEvents (false);
|
||||||
|
namePoint->setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||||
|
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||||
|
namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||||
|
namePoint->setBrush(QBrush(Qt::gray));
|
||||||
|
namePoint->setAcceptHoverEvents(false);
|
||||||
|
lineName->setPen(QPen(Qt::gray, widthHairLine));
|
||||||
|
VDrawTool::ChangedActivDraw(newName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolPoint::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){
|
||||||
|
if(id == this->id){
|
||||||
|
if(enable == false){
|
||||||
|
this->setPen(QPen(baseColor, widthHairLine));
|
||||||
|
currentColor = baseColor;
|
||||||
|
} else {
|
||||||
|
this->setPen(QPen(color, widthHairLine));
|
||||||
|
currentColor = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
|
||||||
|
if(event->button() == Qt::LeftButton){
|
||||||
|
emit ChoosedTool(id, Scene::Point);
|
||||||
|
}
|
||||||
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
|
||||||
|
Q_UNUSED(event);
|
||||||
|
this->setPen(QPen(currentColor, widthMainLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
|
||||||
|
Q_UNUSED(event);
|
||||||
|
this->setPen(QPen(currentColor, widthHairLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolPoint::RefreshPointGeometry(const VPointF &point){
|
||||||
|
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
||||||
|
rec.translate(-rec.center().x(), -rec.center().y());
|
||||||
|
this->setRect(rec);
|
||||||
|
this->setPos(point.toQPointF());
|
||||||
|
disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
||||||
|
&VToolPoint::NameChangePosition);
|
||||||
|
namePoint->setText(point.name());
|
||||||
|
namePoint->setPos(QPointF(point.mx(), point.my()));
|
||||||
|
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
||||||
|
&VToolPoint::NameChangePosition);
|
||||||
|
RefreshLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolPoint::RefreshLine(){
|
||||||
|
QRectF nameRec = namePoint->sceneBoundingRect();
|
||||||
|
QPointF p1, p2;
|
||||||
|
LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2);
|
||||||
|
QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
|
||||||
|
lineName->setLine(QLineF(p1, pRec - scenePos()));
|
||||||
|
if(QLineF(p1, pRec - scenePos()).length() <= toPixel(4)){
|
||||||
|
lineName->setVisible(false);
|
||||||
|
} else {
|
||||||
|
lineName->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VToolPoint::~VToolPoint(){
|
||||||
|
}
|
34
tools/drawTools/vtoolpoint.h
Normal file
34
tools/drawTools/vtoolpoint.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef VTOOLPOINT_H
|
||||||
|
#define VTOOLPOINT_H
|
||||||
|
|
||||||
|
#include "vdrawtool.h"
|
||||||
|
#include "widgets/vgraphicssimpletextitem.h"
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
|
class VToolPoint: public VDrawTool, public QGraphicsEllipseItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem * parent = 0);
|
||||||
|
virtual ~VToolPoint();
|
||||||
|
public slots:
|
||||||
|
void NameChangePosition(const QPointF pos);
|
||||||
|
virtual void ChangedActivDraw(const QString newName);
|
||||||
|
virtual void FullUpdateFromGui(int result) = 0;
|
||||||
|
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
|
||||||
|
protected:
|
||||||
|
qreal radius;
|
||||||
|
VGraphicsSimpleTextItem *namePoint;
|
||||||
|
QGraphicsLineItem *lineName;
|
||||||
|
virtual void UpdateNamePosition(qreal mx, qreal my);
|
||||||
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
virtual void RefreshPointGeometry(const VPointF &point);
|
||||||
|
void RefreshLine();
|
||||||
|
private:
|
||||||
|
VToolPoint(const VToolPoint &tool);
|
||||||
|
const VToolPoint &operator=(const VToolPoint &tool);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VTOOLPOINT_H
|
|
@ -1,11 +1,10 @@
|
||||||
#include "vtoolpointofcontact.h"
|
#include "vtoolpointofcontact.h"
|
||||||
|
|
||||||
VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
|
VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
Draw::Mode mode,
|
|
||||||
const QString &radius, const qint64 ¢er,
|
const QString &radius, const qint64 ¢er,
|
||||||
const qint64 &firstPointId, const qint64 &secondPointId,
|
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
Tool::Enum typeCreation, QGraphicsItem *parent)
|
Tool::Enum typeCreation, QGraphicsItem *parent)
|
||||||
: VToolPoint(doc, data, id, mode, parent), radius(radius), center(center), firstPointId(firstPointId),
|
: VToolPoint(doc, data, id, parent), radius(radius), center(center), firstPointId(firstPointId),
|
||||||
secondPointId(secondPointId), dialogPointOfContact(QSharedPointer<DialogPointOfContact>()){
|
secondPointId(secondPointId), dialogPointOfContact(QSharedPointer<DialogPointOfContact>()){
|
||||||
|
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
|
@ -48,21 +47,21 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢e
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolPointOfContact::Create(QSharedPointer<DialogPointOfContact> &dialog, VMainGraphicsScene *scene,
|
void VToolPointOfContact::Create(QSharedPointer<DialogPointOfContact> &dialog, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Draw::Mode mode){
|
VDomDocument *doc, VContainer *data){
|
||||||
QString radius = dialog->getRadius();
|
QString radius = dialog->getRadius();
|
||||||
qint64 center = dialog->getCenter();
|
qint64 center = dialog->getCenter();
|
||||||
qint64 firstPointId = dialog->getFirstPoint();
|
qint64 firstPointId = dialog->getFirstPoint();
|
||||||
qint64 secondPointId = dialog->getSecondPoint();
|
qint64 secondPointId = dialog->getSecondPoint();
|
||||||
QString pointName = dialog->getPointName();
|
QString pointName = dialog->getPointName();
|
||||||
Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data,
|
Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data,
|
||||||
Document::FullParse, Tool::FromGui, mode);
|
Document::FullParse, Tool::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const qint64 ¢er,
|
void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const qint64 ¢er,
|
||||||
const qint64 &firstPointId, const qint64 &secondPointId,
|
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
const QString &pointName, const qreal &mx, const qreal &my,
|
const QString &pointName, const qreal &mx, const qreal &my,
|
||||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||||
Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
|
Document::Enum parse, Tool::Enum typeCreation){
|
||||||
VPointF centerP = data->GetPoint(center);
|
VPointF centerP = data->GetPoint(center);
|
||||||
VPointF firstP = data->GetPoint(firstPointId);
|
VPointF firstP = data->GetPoint(firstPointId);
|
||||||
VPointF secondP = data->GetPoint(secondPointId);
|
VPointF secondP = data->GetPoint(secondPointId);
|
||||||
|
@ -87,14 +86,9 @@ void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VAbstractTool::AddRecord(id, Tools::PointOfContact, doc);
|
VDrawTool::AddRecord(id, Tools::PointOfContact, doc);
|
||||||
if(mode == Draw::Modeling){
|
|
||||||
data->IncrementReferens(center, Scene::Point);
|
|
||||||
data->IncrementReferens(firstPointId, Scene::Point);
|
|
||||||
data->IncrementReferens(secondPointId, Scene::Point);
|
|
||||||
}
|
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, mode, radius, center,
|
VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center,
|
||||||
firstPointId, secondPointId, typeCreation);
|
firstPointId, secondPointId, typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
@ -113,7 +107,7 @@ void VToolPointOfContact::FullUpdateFromFile(){
|
||||||
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||||
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
}
|
}
|
||||||
RefreshGeometry();
|
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolPointOfContact::FullUpdateFromGui(int result){
|
void VToolPointOfContact::FullUpdateFromGui(int result){
|
||||||
|
@ -136,12 +130,7 @@ void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolPointOfContact::AddToFile(){
|
void VToolPointOfContact::AddToFile(){
|
||||||
VPointF point;
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
if(mode == Draw::Calculation){
|
|
||||||
point = VAbstractTool::data.GetPoint(id);
|
|
||||||
} else {
|
|
||||||
point = VAbstractTool::data.GetModelingPoint(id);
|
|
||||||
}
|
|
||||||
QDomElement domElement = doc->createElement("point");
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
|
@ -155,5 +144,5 @@ void VToolPointOfContact::AddToFile(){
|
||||||
AddAttribute(domElement, "firstPoint", firstPointId);
|
AddAttribute(domElement, "firstPoint", firstPointId);
|
||||||
AddAttribute(domElement, "secondPoint", secondPointId);
|
AddAttribute(domElement, "secondPoint", secondPointId);
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
|
@ -2,23 +2,23 @@
|
||||||
#define VTOOLPOINTOFCONTACT_H
|
#define VTOOLPOINTOFCONTACT_H
|
||||||
|
|
||||||
#include "vtoolpoint.h"
|
#include "vtoolpoint.h"
|
||||||
#include "../dialogs/dialogpointofcontact.h"
|
#include "dialogs/dialogpointofcontact.h"
|
||||||
|
|
||||||
class VToolPointOfContact : public VToolPoint
|
class VToolPointOfContact : public VToolPoint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
|
VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const QString &radius, const qint64 ¢er, const qint64 &firstPointId,
|
const QString &radius, const qint64 ¢er, const qint64 &firstPointId,
|
||||||
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem * parent = 0);
|
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem * parent = 0);
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static QPointF FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint,
|
static QPointF FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint,
|
||||||
const QPointF &secondPoint);
|
const QPointF &secondPoint);
|
||||||
static void Create(QSharedPointer<DialogPointOfContact> &dialog, VMainGraphicsScene *scene,
|
static void Create(QSharedPointer<DialogPointOfContact> &dialog, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Draw::Mode mode);
|
VDomDocument *doc, VContainer *data);
|
||||||
static void Create(const qint64 _id, const QString &radius, const qint64 ¢er, const qint64 &firstPointId,
|
static void Create(const qint64 _id, const QString &radius, const qint64 ¢er, const qint64 &firstPointId,
|
||||||
const qint64 &secondPointId, const QString &pointName,
|
const qint64 &secondPointId, const QString &pointName,
|
||||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode);
|
VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile();
|
virtual void FullUpdateFromFile();
|
||||||
virtual void FullUpdateFromGui(int result);
|
virtual void FullUpdateFromGui(int result);
|
|
@ -1,18 +1,12 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vtoolshoulderpoint.h"
|
#include "vtoolshoulderpoint.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
|
VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const QString &typeLine, const QString &formula, const qint64 &p1Line,
|
const QString &typeLine, const QString &formula, const qint64 &p1Line,
|
||||||
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation,
|
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation,
|
||||||
QGraphicsItem * parent):
|
QGraphicsItem * parent):
|
||||||
VToolLinePoint(doc, data, id, mode, typeLine, formula, p1Line, 0, parent), p2Line(p2Line), pShoulder(pShoulder),
|
VToolLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent), p2Line(p2Line), pShoulder(pShoulder),
|
||||||
dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>()){
|
dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>()){
|
||||||
|
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
|
@ -56,7 +50,7 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolShoulderPoint::Create(QSharedPointer<DialogShoulderPoint> &dialog, VMainGraphicsScene *scene,
|
void VToolShoulderPoint::Create(QSharedPointer<DialogShoulderPoint> &dialog, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Draw::Mode mode){
|
VDomDocument *doc, VContainer *data){
|
||||||
QString formula = dialog->getFormula();
|
QString formula = dialog->getFormula();
|
||||||
qint64 p1Line = dialog->getP1Line();
|
qint64 p1Line = dialog->getP1Line();
|
||||||
qint64 p2Line = dialog->getP2Line();
|
qint64 p2Line = dialog->getP2Line();
|
||||||
|
@ -64,14 +58,14 @@ void VToolShoulderPoint::Create(QSharedPointer<DialogShoulderPoint> &dialog, VMa
|
||||||
QString typeLine = dialog->getTypeLine();
|
QString typeLine = dialog->getTypeLine();
|
||||||
QString pointName = dialog->getPointName();
|
QString pointName = dialog->getPointName();
|
||||||
Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data,
|
Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data,
|
||||||
Document::FullParse, Tool::FromGui, mode);
|
Document::FullParse, Tool::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const qint64 &p1Line,
|
void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const qint64 &p1Line,
|
||||||
const qint64 &p2Line, const qint64 &pShoulder, const QString &typeLine,
|
const qint64 &p2Line, const qint64 &pShoulder, const QString &typeLine,
|
||||||
const QString &pointName, const qreal &mx, const qreal &my,
|
const QString &pointName, const qreal &mx, const qreal &my,
|
||||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||||
Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
|
Document::Enum parse, Tool::Enum typeCreation){
|
||||||
VPointF firstPoint = data->GetPoint(p1Line);
|
VPointF firstPoint = data->GetPoint(p1Line);
|
||||||
VPointF secondPoint = data->GetPoint(p2Line);
|
VPointF secondPoint = data->GetPoint(p2Line);
|
||||||
VPointF shoulderPoint = data->GetPoint(pShoulder);
|
VPointF shoulderPoint = data->GetPoint(pShoulder);
|
||||||
|
@ -98,14 +92,9 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
|
||||||
}
|
}
|
||||||
data->AddLine(p1Line, id);
|
data->AddLine(p1Line, id);
|
||||||
data->AddLine(p2Line, id);
|
data->AddLine(p2Line, id);
|
||||||
VAbstractTool::AddRecord(id, Tools::ShoulderPointTool, doc);
|
VDrawTool::AddRecord(id, Tools::ShoulderPointTool, doc);
|
||||||
if(mode == Draw::Modeling){
|
|
||||||
data->IncrementReferens(p1Line, Scene::Point);
|
|
||||||
data->IncrementReferens(p2Line, Scene::Point);
|
|
||||||
data->IncrementReferens(pShoulder, Scene::Point);
|
|
||||||
}
|
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, mode, typeLine, formula,
|
VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, formula,
|
||||||
p1Line, p2Line, pShoulder,
|
p1Line, p2Line, pShoulder,
|
||||||
typeCreation);
|
typeCreation);
|
||||||
scene->addItem(point);
|
scene->addItem(point);
|
||||||
|
@ -150,12 +139,7 @@ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolShoulderPoint::AddToFile(){
|
void VToolShoulderPoint::AddToFile(){
|
||||||
VPointF point;
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
if(mode == Draw::Calculation){
|
|
||||||
point = VAbstractTool::data.GetPoint(id);
|
|
||||||
} else {
|
|
||||||
point = VAbstractTool::data.GetModelingPoint(id);
|
|
||||||
}
|
|
||||||
QDomElement domElement = doc->createElement("point");
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
|
@ -170,5 +154,5 @@ void VToolShoulderPoint::AddToFile(){
|
||||||
AddAttribute(domElement, "p2Line", p2Line);
|
AddAttribute(domElement, "p2Line", p2Line);
|
||||||
AddAttribute(domElement, "pShoulder", pShoulder);
|
AddAttribute(domElement, "pShoulder", pShoulder);
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
|
@ -1,19 +1,13 @@
|
||||||
#ifndef VTOOLSHOULDERPOINT_H
|
#ifndef VTOOLSHOULDERPOINT_H
|
||||||
#define VTOOLSHOULDERPOINT_H
|
#define VTOOLSHOULDERPOINT_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vtoollinepoint.h"
|
#include "vtoollinepoint.h"
|
||||||
#include "../dialogs/dialogshoulderpoint.h"
|
#include "dialogs/dialogshoulderpoint.h"
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
class VToolShoulderPoint : public VToolLinePoint
|
class VToolShoulderPoint : public VToolLinePoint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
|
VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const QString &typeLine, const QString &formula, const qint64 &p1Line,
|
const QString &typeLine, const QString &formula, const qint64 &p1Line,
|
||||||
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation,
|
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation,
|
||||||
QGraphicsItem * parent = 0);
|
QGraphicsItem * parent = 0);
|
||||||
|
@ -21,11 +15,11 @@ public:
|
||||||
static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
|
static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
|
||||||
const qreal &length);
|
const qreal &length);
|
||||||
static void Create(QSharedPointer<DialogShoulderPoint> &dialog, VMainGraphicsScene *scene,
|
static void Create(QSharedPointer<DialogShoulderPoint> &dialog, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Draw::Mode mode);
|
VDomDocument *doc, VContainer *data);
|
||||||
static void Create(const qint64 _id, const QString &formula, const qint64 &p1Line, const qint64 &p2Line,
|
static void Create(const qint64 _id, const QString &formula, const qint64 &p1Line, const qint64 &p2Line,
|
||||||
const qint64 &pShoulder, const QString &typeLine, const QString &pointName,
|
const qint64 &pShoulder, const QString &typeLine, const QString &pointName,
|
||||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode);
|
VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile();
|
virtual void FullUpdateFromFile();
|
||||||
virtual void FullUpdateFromGui(int result);
|
virtual void FullUpdateFromGui(int result);
|
|
@ -1,8 +1,3 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vtoolsinglepoint.h"
|
#include "vtoolsinglepoint.h"
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
|
@ -10,14 +5,12 @@
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QGraphicsSceneContextMenuEvent>
|
#include <QGraphicsSceneContextMenuEvent>
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "../options.h"
|
#include "options.h"
|
||||||
#include "../container/vpointf.h"
|
#include "container/vpointf.h"
|
||||||
|
|
||||||
VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
|
VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
|
||||||
QGraphicsItem * parent ):VToolPoint(doc, data, id, Draw::Calculation,
|
QGraphicsItem * parent ):VToolPoint(doc, data, id, parent),
|
||||||
parent),
|
|
||||||
dialogSinglePoint(QSharedPointer<DialogSinglePoint>()){
|
dialogSinglePoint(QSharedPointer<DialogSinglePoint>()){
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
|
@ -41,12 +34,12 @@ void VToolSinglePoint::AddToFile(){
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
AddAttribute(domElement, "type", "single");
|
AddAttribute(domElement, "type", "single");
|
||||||
AddAttribute(domElement, "name", point.name());
|
AddAttribute(domElement, "name", point.name());
|
||||||
AddAttribute(domElement, "x", point.x()/PrintDPI*25.4);
|
AddAttribute(domElement, "x", toMM(point.x()));
|
||||||
AddAttribute(domElement, "y", point.y()/PrintDPI*25.4);
|
AddAttribute(domElement, "y", toMM(point.y()));
|
||||||
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
|
AddAttribute(domElement, "mx", toMM(point.mx()));
|
||||||
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
|
AddAttribute(domElement, "my", toMM(point.my()));
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value){
|
QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value){
|
||||||
|
@ -66,8 +59,8 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change,
|
||||||
QPointF newPos = value.toPointF();
|
QPointF newPos = value.toPointF();
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
if(domElement.isElement()){
|
if(domElement.isElement()){
|
||||||
domElement.setAttribute("x", QString().setNum(newPos.x()/PrintDPI*25.4));
|
domElement.setAttribute("x", QString().setNum(toMM(newPos.x())));
|
||||||
domElement.setAttribute("y", QString().setNum(newPos.y()/PrintDPI*25.4));
|
domElement.setAttribute("y", QString().setNum(toMM(newPos.y())));
|
||||||
//I don't now why but signal does not work.
|
//I don't now why but signal does not work.
|
||||||
doc->FullUpdateTree();
|
doc->FullUpdateTree();
|
||||||
}
|
}
|
||||||
|
@ -80,7 +73,7 @@ void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolSinglePoint::FullUpdateFromFile(){
|
void VToolSinglePoint::FullUpdateFromFile(){
|
||||||
RefreshGeometry();
|
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolSinglePoint::FullUpdateFromGui(int result){
|
void VToolSinglePoint::FullUpdateFromGui(int result){
|
||||||
|
@ -90,8 +83,8 @@ void VToolSinglePoint::FullUpdateFromGui(int result){
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
if(domElement.isElement()){
|
if(domElement.isElement()){
|
||||||
domElement.setAttribute("name", name);
|
domElement.setAttribute("name", name);
|
||||||
domElement.setAttribute("x", QString().setNum(p.x()/PrintDPI*25.4));
|
domElement.setAttribute("x", QString().setNum(toMM(p.x())));
|
||||||
domElement.setAttribute("y", QString().setNum(p.y()/PrintDPI*25.4));
|
domElement.setAttribute("y", QString().setNum(toMM(p.y())));
|
||||||
//I don't now why but signal does not work.
|
//I don't now why but signal does not work.
|
||||||
doc->FullUpdateTree();
|
doc->FullUpdateTree();
|
||||||
}
|
}
|
30
tools/drawTools/vtoolsinglepoint.h
Normal file
30
tools/drawTools/vtoolsinglepoint.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef VTOOLSINGLEPOINT_H
|
||||||
|
#define VTOOLSINGLEPOINT_H
|
||||||
|
|
||||||
|
#include "container/vcontainer.h"
|
||||||
|
#include "xml/vdomdocument.h"
|
||||||
|
#include "dialogs/dialogsinglepoint.h"
|
||||||
|
#include "vtoolpoint.h"
|
||||||
|
|
||||||
|
class VToolSinglePoint : public VToolPoint
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id,
|
||||||
|
Tool::Enum typeCreation, QGraphicsItem * parent = 0 );
|
||||||
|
virtual void setDialog();
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
virtual void ChangedActivDraw(const QString newName);
|
||||||
|
signals:
|
||||||
|
void FullUpdateTree();
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
||||||
|
private:
|
||||||
|
QSharedPointer<DialogSinglePoint> dialogSinglePoint;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VTOOLSINGLEPOINT_H
|
|
@ -1,18 +1,12 @@
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vtoolspline.h"
|
#include "vtoolspline.h"
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#pragma GCC diagnostic pop
|
#include "geometry/vspline.h"
|
||||||
#include "../geometry/vspline.h"
|
|
||||||
|
|
||||||
|
|
||||||
VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode,
|
VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id,
|
||||||
Tool::Enum typeCreation,
|
Tool::Enum typeCreation,
|
||||||
QGraphicsItem *parent):VAbstractTool(doc, data, id, mode), QGraphicsPathItem(parent),
|
QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsPathItem(parent),
|
||||||
dialogSpline(QSharedPointer<DialogSpline>()), controlPoints(QVector<VControlPointSpline *>()){
|
dialogSpline(QSharedPointer<DialogSpline>()), controlPoints(QVector<VControlPointSpline *>()){
|
||||||
|
|
||||||
VSpline spl = data->GetSpline(id);
|
VSpline spl = data->GetSpline(id);
|
||||||
|
@ -60,7 +54,7 @@ void VToolSpline::setDialog(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolSpline::Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
void VToolSpline::Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Draw::Mode mode){
|
VContainer *data){
|
||||||
qint64 p1 = dialog->getP1();
|
qint64 p1 = dialog->getP1();
|
||||||
qint64 p4 = dialog->getP4();
|
qint64 p4 = dialog->getP4();
|
||||||
qreal kAsm1 = dialog->getKAsm1();
|
qreal kAsm1 = dialog->getKAsm1();
|
||||||
|
@ -69,13 +63,13 @@ void VToolSpline::Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScen
|
||||||
qreal angle2 = dialog->getAngle2();
|
qreal angle2 = dialog->getAngle2();
|
||||||
qreal kCurve = dialog->getKCurve();
|
qreal kCurve = dialog->getKCurve();
|
||||||
Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse,
|
Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse,
|
||||||
Tool::FromGui, mode);
|
Tool::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1,
|
void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1,
|
||||||
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
|
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
|
||||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
|
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
Tool::Enum typeCreation, Draw::Mode mode){
|
Tool::Enum typeCreation){
|
||||||
VSpline spline = VSpline(data->DataPoints(), p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve);
|
VSpline spline = VSpline(data->DataPoints(), p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve);
|
||||||
qint64 id = _id;
|
qint64 id = _id;
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
|
@ -92,13 +86,9 @@ void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data->AddLengthSpline(data->GetNameSpline(p1, p4), spline.GetLength());
|
data->AddLengthSpline(data->GetNameSpline(p1, p4), spline.GetLength());
|
||||||
VAbstractTool::AddRecord(id, Tools::SplineTool, doc);
|
VDrawTool::AddRecord(id, Tools::SplineTool, doc);
|
||||||
if(mode == Draw::Modeling){
|
|
||||||
data->IncrementReferens(p1, Scene::Point);
|
|
||||||
data->IncrementReferens(p4, Scene::Point);
|
|
||||||
}
|
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
VToolSpline *spl = new VToolSpline(doc, data, id, mode, typeCreation);
|
VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation);
|
||||||
scene->addItem(spl);
|
scene->addItem(spl);
|
||||||
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(spl, &VToolSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
connect(spl, &VToolSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
||||||
|
@ -170,12 +160,7 @@ void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolSpline::AddToFile(){
|
void VToolSpline::AddToFile(){
|
||||||
VSpline spl;
|
VSpline spl = VAbstractTool::data.GetSpline(id);
|
||||||
if(mode == Draw::Calculation){
|
|
||||||
spl = VAbstractTool::data.GetSpline(id);
|
|
||||||
} else {
|
|
||||||
spl = VAbstractTool::data.GetModelingSpline(id);
|
|
||||||
}
|
|
||||||
QDomElement domElement = doc->createElement("spline");
|
QDomElement domElement = doc->createElement("spline");
|
||||||
|
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
|
@ -188,7 +173,7 @@ void VToolSpline::AddToFile(){
|
||||||
AddAttribute(domElement, "kAsm2", spl.GetKasm2());
|
AddAttribute(domElement, "kAsm2", spl.GetKasm2());
|
||||||
AddAttribute(domElement, "kCurve", spl.GetKcurve());
|
AddAttribute(domElement, "kCurve", spl.GetKcurve());
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
|
void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
|
||||||
|
@ -240,13 +225,13 @@ void VToolSpline::ChangedActivDraw(const QString newName){
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
emit setEnabledPoint(true);
|
emit setEnabledPoint(true);
|
||||||
VAbstractTool::ChangedActivDraw(newName);
|
VDrawTool::ChangedActivDraw(newName);
|
||||||
} else {
|
} else {
|
||||||
this->setPen(QPen(Qt::gray, widthHairLine));
|
this->setPen(QPen(Qt::gray, widthHairLine));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||||
this->setAcceptHoverEvents (false);
|
this->setAcceptHoverEvents (false);
|
||||||
emit setEnabledPoint(false);
|
emit setEnabledPoint(false);
|
||||||
VAbstractTool::ChangedActivDraw(newName);
|
VDrawTool::ChangedActivDraw(newName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,27 @@
|
||||||
#ifndef VTOOLSPLINE_H
|
#ifndef VTOOLSPLINE_H
|
||||||
#define VTOOLSPLINE_H
|
#define VTOOLSPLINE_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#include "vdrawtool.h"
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
#include "xml/vdomdocument.h"
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vabstracttool.h"
|
|
||||||
#include "../xml/vdomdocument.h"
|
|
||||||
#include <QGraphicsPathItem>
|
#include <QGraphicsPathItem>
|
||||||
#include "../dialogs/dialogspline.h"
|
#include "dialogs/dialogspline.h"
|
||||||
#include "../widgets/vcontrolpointspline.h"
|
#include "widgets/vcontrolpointspline.h"
|
||||||
#include "../container/vcontainer.h"
|
#include "container/vcontainer.h"
|
||||||
#pragma GCC diagnostic pop
|
#include "geometry/vsplinepath.h"
|
||||||
#include "../geometry/vsplinepath.h"
|
|
||||||
|
|
||||||
class VToolSpline:public VAbstractTool, public QGraphicsPathItem
|
class VToolSpline:public VDrawTool, public QGraphicsPathItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VToolSpline (VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode,
|
VToolSpline (VDomDocument *doc, VContainer *data, qint64 id,
|
||||||
Tool::Enum typeCreation, QGraphicsItem * parent = 0 );
|
Tool::Enum typeCreation, QGraphicsItem * parent = 0 );
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static void Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
static void Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
VContainer *data, Draw::Mode mode);
|
VContainer *data);
|
||||||
static void Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1,
|
static void Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1,
|
||||||
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
|
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
|
||||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
|
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
Tool::Enum typeCreation, Draw::Mode mode);
|
Tool::Enum typeCreation);
|
||||||
signals:
|
signals:
|
||||||
void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position,
|
void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position,
|
||||||
const QPointF &controlPoint, const QPointF &splinePoint );
|
const QPointF &controlPoint, const QPointF &splinePoint );
|
|
@ -1,9 +1,9 @@
|
||||||
#include "vtoolsplinepath.h"
|
#include "vtoolsplinepath.h"
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode,
|
VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
|
||||||
Tool::Enum typeCreation,
|
Tool::Enum typeCreation,
|
||||||
QGraphicsItem *parent):VAbstractTool(doc, data, id, mode),
|
QGraphicsItem *parent):VDrawTool(doc, data, id),
|
||||||
QGraphicsPathItem(parent), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
|
QGraphicsPathItem(parent), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
|
||||||
controlPoints(QVector<VControlPointSpline *>()){
|
controlPoints(QVector<VControlPointSpline *>()){
|
||||||
VSplinePath splPath = data->GetSplinePath(id);
|
VSplinePath splPath = data->GetSplinePath(id);
|
||||||
|
@ -47,14 +47,14 @@ void VToolSplinePath::setDialog(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolSplinePath::Create(QSharedPointer<DialogSplinePath> &dialog, VMainGraphicsScene *scene,
|
void VToolSplinePath::Create(QSharedPointer<DialogSplinePath> &dialog, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Draw::Mode mode){
|
VDomDocument *doc, VContainer *data){
|
||||||
VSplinePath path = dialog->GetPath();
|
VSplinePath path = dialog->GetPath();
|
||||||
Create(0, path, scene, doc, data, Document::FullParse, Tool::FromGui, mode);
|
Create(0, path, scene, doc, data, Document::FullParse, Tool::FromGui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolSplinePath::Create(const qint64 _id, const VSplinePath &path, VMainGraphicsScene *scene,
|
void VToolSplinePath::Create(const qint64 _id, const VSplinePath &path, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Document::Enum parse,
|
VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
Tool::Enum typeCreation, Draw::Mode mode){
|
Tool::Enum typeCreation){
|
||||||
qint64 id = _id;
|
qint64 id = _id;
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
id = data->AddSplinePath(path);
|
id = data->AddSplinePath(path);
|
||||||
|
@ -70,15 +70,9 @@ void VToolSplinePath::Create(const qint64 _id, const VSplinePath &path, VMainGra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data->AddLengthSpline(data->GetNameSplinePath(path), path.GetLength());
|
data->AddLengthSpline(data->GetNameSplinePath(path), path.GetLength());
|
||||||
VAbstractTool::AddRecord(id, Tools::SplinePathTool, doc);
|
VDrawTool::AddRecord(id, Tools::SplinePathTool, doc);
|
||||||
if(mode == Draw::Modeling){
|
|
||||||
const QVector<VSplinePoint> *points = path.GetPoint();
|
|
||||||
for(qint32 i = 0; i<points->size(); ++i){
|
|
||||||
data->IncrementReferens(points->at(i).P(), Scene::Point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, mode, typeCreation);
|
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation);
|
||||||
scene->addItem(spl);
|
scene->addItem(spl);
|
||||||
connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(spl, &VToolSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
connect(spl, &VToolSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
||||||
|
@ -178,13 +172,13 @@ void VToolSplinePath::ChangedActivDraw(const QString newName){
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
emit setEnabledPoint(true);
|
emit setEnabledPoint(true);
|
||||||
VAbstractTool::ChangedActivDraw(newName);
|
VDrawTool::ChangedActivDraw(newName);
|
||||||
} else {
|
} else {
|
||||||
this->setPen(QPen(Qt::gray, widthHairLine));
|
this->setPen(QPen(Qt::gray, widthHairLine));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||||
this->setAcceptHoverEvents (false);
|
this->setAcceptHoverEvents (false);
|
||||||
emit setEnabledPoint(false);
|
emit setEnabledPoint(false);
|
||||||
VAbstractTool::ChangedActivDraw(newName);
|
VDrawTool::ChangedActivDraw(newName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +210,7 @@ void VToolSplinePath::AddToFile(){
|
||||||
AddPathPoint(domElement, splPath[i]);
|
AddPathPoint(domElement, splPath[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddToDraw(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint){
|
void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint){
|
|
@ -1,33 +1,25 @@
|
||||||
#ifndef VTOOLSPLINEPATH_H
|
#ifndef VTOOLSPLINEPATH_H
|
||||||
#define VTOOLSPLINEPATH_H
|
#define VTOOLSPLINEPATH_H
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#include "vdrawtool.h"
|
||||||
#pragma GCC diagnostic ignored "-Weffc++"
|
#include "xml/vdomdocument.h"
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
||||||
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
|
|
||||||
#include "vabstracttool.h"
|
|
||||||
#include "../xml/vdomdocument.h"
|
|
||||||
#include <QGraphicsPathItem>
|
#include <QGraphicsPathItem>
|
||||||
#include "../dialogs/dialogsplinepath.h"
|
#include "dialogs/dialogsplinepath.h"
|
||||||
#include "../widgets/vcontrolpointspline.h"
|
#include "widgets/vcontrolpointspline.h"
|
||||||
#pragma GCC diagnostic pop
|
#include "container/vcontainer.h"
|
||||||
#include "../container/vcontainer.h"
|
|
||||||
|
|
||||||
class VToolSplinePath:public VAbstractTool, public QGraphicsPathItem
|
class VToolSplinePath:public VDrawTool, public QGraphicsPathItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
|
VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
|
||||||
Draw::Mode mode,
|
|
||||||
Tool::Enum typeCreation,
|
Tool::Enum typeCreation,
|
||||||
QGraphicsItem * parent = 0);
|
QGraphicsItem * parent = 0);
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static void Create(QSharedPointer<DialogSplinePath> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
static void Create(QSharedPointer<DialogSplinePath> &dialog, VMainGraphicsScene *scene,
|
||||||
VContainer *data, Draw::Mode mode);
|
VDomDocument *doc, VContainer *data);
|
||||||
static void Create(const qint64 _id, const VSplinePath &path, VMainGraphicsScene *scene,
|
static void Create(const qint64 _id, const VSplinePath &path, VMainGraphicsScene *scene,
|
||||||
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation,
|
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
|
||||||
Draw::Mode mode);
|
|
||||||
signals:
|
signals:
|
||||||
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos,
|
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos,
|
||||||
const QPointF &controlPoint, const QPointF &splinePoint);
|
const QPointF &controlPoint, const QPointF &splinePoint);
|
17
tools/modelingTools/modelingtools.h
Normal file
17
tools/modelingTools/modelingtools.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef MODELINGTOOLS_H
|
||||||
|
#define MODELINGTOOLS_H
|
||||||
|
|
||||||
|
#include "vmodelingalongline.h"
|
||||||
|
#include "vmodelingarc.h"
|
||||||
|
#include "vmodelingbisector.h"
|
||||||
|
#include "vmodelingendline.h"
|
||||||
|
#include "vmodelingline.h"
|
||||||
|
#include "vmodelinglineintersect.h"
|
||||||
|
#include "vmodelingnormal.h"
|
||||||
|
#include "vmodelingpointofcontact.h"
|
||||||
|
#include "vmodelingshoulderpoint.h"
|
||||||
|
#include "vmodelingsinglepoint.h"
|
||||||
|
#include "vmodelingspline.h"
|
||||||
|
#include "vmodelingsplinepath.h"
|
||||||
|
|
||||||
|
#endif // MODELINGTOOLS_H
|
133
tools/modelingTools/vmodelingalongline.cpp
Normal file
133
tools/modelingTools/vmodelingalongline.cpp
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
#include "vmodelingalongline.h"
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "container/calculator.h"
|
||||||
|
|
||||||
|
VModelingAlongLine::VModelingAlongLine(VDomDocument *doc, VContainer *data, qint64 id,
|
||||||
|
const QString &formula, const qint64 &firstPointId,
|
||||||
|
const qint64 &secondPointId, const QString &typeLine,
|
||||||
|
Tool::Enum typeCreation, QGraphicsItem *parent):
|
||||||
|
VModelingLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent),
|
||||||
|
secondPointId(secondPointId), dialogAlongLine(QSharedPointer<DialogAlongLine>()){
|
||||||
|
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingAlongLine::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
typeLine = domElement.attribute("typeLine", "");
|
||||||
|
formula = domElement.attribute("length", "");
|
||||||
|
basePointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||||
|
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
|
}
|
||||||
|
RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingAlongLine::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogAlongLine->getPointName());
|
||||||
|
domElement.setAttribute("typeLine", dialogAlongLine->getTypeLine());
|
||||||
|
domElement.setAttribute("length", dialogAlongLine->getFormula());
|
||||||
|
domElement.setAttribute("firstPoint", QString().setNum(dialogAlongLine->getFirstPointId()));
|
||||||
|
domElement.setAttribute("secondPoint", QString().setNum(dialogAlongLine->getSecondPointId()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
dialogAlongLine.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogAlongLine, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingAlongLine::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "alongLine");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
|
||||||
|
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
|
||||||
|
|
||||||
|
AddAttribute(domElement, "typeLine", typeLine);
|
||||||
|
AddAttribute(domElement, "length", formula);
|
||||||
|
AddAttribute(domElement, "firstPoint", basePointId);
|
||||||
|
AddAttribute(domElement, "secondPoint", secondPointId);
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingAlongLine::setDialog(){
|
||||||
|
Q_ASSERT(!dialogAlongLine.isNull());
|
||||||
|
if(!dialogAlongLine.isNull()){
|
||||||
|
VPointF p = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
dialogAlongLine->setTypeLine(typeLine);
|
||||||
|
dialogAlongLine->setFormula(formula);
|
||||||
|
dialogAlongLine->setFirstPointId(basePointId, id);
|
||||||
|
dialogAlongLine->setSecondPointId(secondPointId, id);
|
||||||
|
dialogAlongLine->setPointName(p.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingAlongLine *VModelingAlongLine::Create(QSharedPointer<DialogAlongLine> &dialog,
|
||||||
|
VDomDocument *doc, VContainer *data){
|
||||||
|
QString formula = dialog->getFormula();
|
||||||
|
qint64 firstPointId = dialog->getFirstPointId();
|
||||||
|
qint64 secondPointId = dialog->getSecondPointId();
|
||||||
|
QString typeLine = dialog->getTypeLine();
|
||||||
|
QString pointName = dialog->getPointName();
|
||||||
|
return Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, doc, data,
|
||||||
|
Document::FullParse, Tool::FromGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingAlongLine *VModelingAlongLine::Create(const qint64 _id, const QString &pointName,
|
||||||
|
const QString &typeLine, const QString &formula,
|
||||||
|
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
const qreal &mx, const qreal &my, VDomDocument *doc,
|
||||||
|
VContainer *data, Document::Enum parse,
|
||||||
|
Tool::Enum typeCreation){
|
||||||
|
VModelingAlongLine *point = 0;
|
||||||
|
VPointF firstPoint = data->GetModelingPoint(firstPointId);
|
||||||
|
VPointF secondPoint = data->GetModelingPoint(secondPointId);
|
||||||
|
QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF());
|
||||||
|
Calculator cal(data);
|
||||||
|
QString errorMsg;
|
||||||
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
|
if(errorMsg.isEmpty()){
|
||||||
|
line.setLength(toPixel(result));
|
||||||
|
qint64 id = _id;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
id = data->AddModelingPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||||
|
} else {
|
||||||
|
data->UpdateModelingPoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||||
|
if(parse != Document::FullParse){
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
VDataTool *tool = tools->value(id);
|
||||||
|
if(tool != 0){
|
||||||
|
tool->VDataTool::setData(data);
|
||||||
|
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data->AddLine(firstPointId, id);
|
||||||
|
data->AddLine(id, secondPointId);
|
||||||
|
data->IncrementReferens(firstPointId, Scene::Point, Draw::Modeling);
|
||||||
|
data->IncrementReferens(secondPointId, Scene::Point, Draw::Modeling);
|
||||||
|
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
point = new VModelingAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine,
|
||||||
|
typeCreation);
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
tools->insert(id,point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return point;
|
||||||
|
}
|
34
tools/modelingTools/vmodelingalongline.h
Normal file
34
tools/modelingTools/vmodelingalongline.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef VMODELINGALONGLINE_H
|
||||||
|
#define VMODELINGALONGLINE_H
|
||||||
|
|
||||||
|
#include "vmodelinglinepoint.h"
|
||||||
|
#include "dialogs/dialogalongline.h"
|
||||||
|
|
||||||
|
class VModelingAlongLine : public VModelingLinePoint
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
|
||||||
|
const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine,
|
||||||
|
Tool::Enum typeCreation, QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static VModelingAlongLine* Create(QSharedPointer<DialogAlongLine> &dialog, VDomDocument *doc,
|
||||||
|
VContainer *data);
|
||||||
|
static VModelingAlongLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||||
|
const QString &formula, const qint64 &firstPointId,
|
||||||
|
const qint64 &secondPointId, const qreal &mx, const qreal &my,
|
||||||
|
VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
|
Tool::Enum typeCreation);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
|
||||||
|
private:
|
||||||
|
qint64 secondPointId;
|
||||||
|
QSharedPointer<DialogAlongLine> dialogAlongLine;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGALONGLINE_H
|
150
tools/modelingTools/vmodelingarc.cpp
Normal file
150
tools/modelingTools/vmodelingarc.cpp
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
#include "vmodelingarc.h"
|
||||||
|
#include <QMenu>
|
||||||
|
#include "container/calculator.h"
|
||||||
|
|
||||||
|
VModelingArc::VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
|
||||||
|
QGraphicsItem *parent):VModelingTool(doc, data, id), QGraphicsPathItem(parent),
|
||||||
|
dialogArc(QSharedPointer<DialogArc>()){
|
||||||
|
VArc arc = data->GetModelingArc(id);
|
||||||
|
QPainterPath path;
|
||||||
|
path.addPath(arc.GetPath());
|
||||||
|
path.setFillRule( Qt::WindingFill );
|
||||||
|
this->setPath(path);
|
||||||
|
this->setPen(QPen(Qt::black, widthHairLine));
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
|
this->setAcceptHoverEvents(true);
|
||||||
|
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingArc::setDialog(){
|
||||||
|
Q_ASSERT(!dialogArc.isNull());
|
||||||
|
if(!dialogArc.isNull()){
|
||||||
|
VArc arc = VAbstractTool::data.GetModelingArc(id);
|
||||||
|
dialogArc->SetCenter(arc.GetCenter());
|
||||||
|
dialogArc->SetRadius(arc.GetFormulaRadius());
|
||||||
|
dialogArc->SetF1(arc.GetFormulaF1());
|
||||||
|
dialogArc->SetF2(arc.GetFormulaF2());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingArc* VModelingArc::Create(QSharedPointer<DialogArc> &dialog, VDomDocument *doc, VContainer *data){
|
||||||
|
qint64 center = dialog->GetCenter();
|
||||||
|
QString radius = dialog->GetRadius();
|
||||||
|
QString f1 = dialog->GetF1();
|
||||||
|
QString f2 = dialog->GetF2();
|
||||||
|
return Create(0, center, radius, f1, f2, doc, data, Document::FullParse, Tool::FromGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingArc* VModelingArc::Create(const qint64 _id, const qint64 ¢er, const QString &radius,
|
||||||
|
const QString &f1, const QString &f2, VDomDocument *doc,
|
||||||
|
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){
|
||||||
|
VModelingArc *toolArc = 0;
|
||||||
|
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
|
||||||
|
|
||||||
|
Calculator cal(data);
|
||||||
|
QString errorMsg;
|
||||||
|
qreal result = cal.eval(radius, &errorMsg);
|
||||||
|
if(errorMsg.isEmpty()){
|
||||||
|
calcRadius = result*PrintDPI/25.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
errorMsg.clear();
|
||||||
|
result = cal.eval(f1, &errorMsg);
|
||||||
|
if(errorMsg.isEmpty()){
|
||||||
|
calcF1 = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
errorMsg.clear();
|
||||||
|
result = cal.eval(f2, &errorMsg);
|
||||||
|
if(errorMsg.isEmpty()){
|
||||||
|
calcF2 = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
VArc arc = VArc(data->DataModelingPoints(), center, calcRadius, radius, calcF1, f1, calcF2, f2 );
|
||||||
|
qint64 id = _id;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
id = data->AddModelingArc(arc);
|
||||||
|
} else {
|
||||||
|
data->UpdateModelingArc(id, arc);
|
||||||
|
if(parse != Document::FullParse){
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
VDataTool *tool = tools->value(id);
|
||||||
|
if(tool != 0){
|
||||||
|
tool->VDataTool::setData(data);
|
||||||
|
data->IncrementReferens(id, Scene::Arc, Draw::Modeling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data->AddLengthArc(data->GetNameArc(center,id, Draw::Modeling), arc.GetLength());
|
||||||
|
data->IncrementReferens(center, Scene::Point, Draw::Modeling);
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
toolArc = new VModelingArc(doc, data, id, typeCreation);
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
tools->insert(id,toolArc);
|
||||||
|
}
|
||||||
|
return toolArc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingArc::FullUpdateFromFile(){
|
||||||
|
RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingArc::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("center", QString().setNum(dialogArc->GetCenter()));
|
||||||
|
domElement.setAttribute("radius", dialogArc->GetRadius());
|
||||||
|
domElement.setAttribute("angle1", dialogArc->GetF1());
|
||||||
|
domElement.setAttribute("angle2", dialogArc->GetF2());
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogArc.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogArc, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingArc::AddToFile(){
|
||||||
|
VArc arc = VAbstractTool::data.GetModelingArc(id);
|
||||||
|
QDomElement domElement = doc->createElement("arc");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "simple");
|
||||||
|
AddAttribute(domElement, "center", arc.GetCenter());
|
||||||
|
AddAttribute(domElement, "radius", arc.GetFormulaRadius());
|
||||||
|
AddAttribute(domElement, "angle1", arc.GetFormulaF1());
|
||||||
|
AddAttribute(domElement, "angle2", arc.GetFormulaF2());
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
|
||||||
|
if(event->button() == Qt::LeftButton){
|
||||||
|
emit ChoosedTool(id, Scene::Arc);
|
||||||
|
}
|
||||||
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
|
||||||
|
Q_UNUSED(event);
|
||||||
|
this->setPen(QPen(currentColor, widthMainLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
|
||||||
|
Q_UNUSED(event);
|
||||||
|
this->setPen(QPen(currentColor, widthHairLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingArc::RefreshGeometry(){
|
||||||
|
VArc arc = VAbstractTool::data.GetModelingArc(id);
|
||||||
|
QPainterPath path;
|
||||||
|
path.addPath(arc.GetPath());
|
||||||
|
path.setFillRule( Qt::WindingFill );
|
||||||
|
this->setPath(path);
|
||||||
|
}
|
36
tools/modelingTools/vmodelingarc.h
Normal file
36
tools/modelingTools/vmodelingarc.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#ifndef VMODELINGARC_H
|
||||||
|
#define VMODELINGARC_H
|
||||||
|
|
||||||
|
#include "vmodelingtool.h"
|
||||||
|
#include "xml/vdomdocument.h"
|
||||||
|
#include <QGraphicsPathItem>
|
||||||
|
#include "dialogs/dialogarc.h"
|
||||||
|
#include "widgets/vcontrolpointspline.h"
|
||||||
|
#include "container/vcontainer.h"
|
||||||
|
|
||||||
|
class VModelingArc :public VModelingTool, public QGraphicsPathItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
|
||||||
|
QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static VModelingArc* Create(QSharedPointer<DialogArc> &dialog, VDomDocument *doc, VContainer *data);
|
||||||
|
static VModelingArc* Create(const qint64 _id, const qint64 ¢er, const QString &radius,
|
||||||
|
const QString &f1, const QString &f2, VDomDocument *doc, VContainer *data,
|
||||||
|
Document::Enum parse, Tool::Enum typeCreation);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
private:
|
||||||
|
QSharedPointer<DialogArc> dialogArc;
|
||||||
|
void RefreshGeometry();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGARC_H
|
150
tools/modelingTools/vmodelingbisector.cpp
Normal file
150
tools/modelingTools/vmodelingbisector.cpp
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
#include "vmodelingbisector.h"
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
VModelingBisector::VModelingBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine, const QString &formula, const qint64 &firstPointId,
|
||||||
|
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Enum typeCreation,
|
||||||
|
QGraphicsItem *parent):
|
||||||
|
VModelingLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(0),
|
||||||
|
thirdPointId(0), dialogBisector(QSharedPointer<DialogBisector>()){
|
||||||
|
this->firstPointId = firstPointId;
|
||||||
|
this->thirdPointId = thirdPointId;
|
||||||
|
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF VModelingBisector::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||||
|
const QPointF &thirdPoint, const qreal &length){
|
||||||
|
QLineF line1(secondPoint, firstPoint);
|
||||||
|
QLineF line2(secondPoint, thirdPoint);
|
||||||
|
qreal angle = line1.angleTo(line2);
|
||||||
|
if(angle>180){
|
||||||
|
angle = 360 - angle;
|
||||||
|
}
|
||||||
|
line1.setAngle(line1.angle()-angle/2);
|
||||||
|
line1.setLength(length);
|
||||||
|
return line1.p2();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingBisector::setDialog(){
|
||||||
|
Q_ASSERT(!dialogBisector.isNull());
|
||||||
|
if(!dialogBisector.isNull()){
|
||||||
|
VPointF p = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
dialogBisector->setTypeLine(typeLine);
|
||||||
|
dialogBisector->setFormula(formula);
|
||||||
|
dialogBisector->setFirstPointId(firstPointId, id);
|
||||||
|
dialogBisector->setSecondPointId(basePointId, id);
|
||||||
|
dialogBisector->setThirdPointId(thirdPointId, id);
|
||||||
|
dialogBisector->setPointName(p.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingBisector *VModelingBisector::Create(QSharedPointer<DialogBisector> &dialog, VDomDocument *doc,
|
||||||
|
VContainer *data){
|
||||||
|
QString formula = dialog->getFormula();
|
||||||
|
qint64 firstPointId = dialog->getFirstPointId();
|
||||||
|
qint64 secondPointId = dialog->getSecondPointId();
|
||||||
|
qint64 thirdPointId = dialog->getThirdPointId();
|
||||||
|
QString typeLine = dialog->getTypeLine();
|
||||||
|
QString pointName = dialog->getPointName();
|
||||||
|
return Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, doc,
|
||||||
|
data, Document::FullParse, Tool::FromGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingBisector *VModelingBisector::Create(const qint64 _id, const QString &formula,
|
||||||
|
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
const qint64 &thirdPointId, const QString &typeLine,
|
||||||
|
const QString &pointName, const qreal &mx, const qreal &my,
|
||||||
|
VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
|
Tool::Enum typeCreation){
|
||||||
|
VModelingBisector *point = 0;
|
||||||
|
VPointF firstPoint = data->GetModelingPoint(firstPointId);
|
||||||
|
VPointF secondPoint = data->GetModelingPoint(secondPointId);
|
||||||
|
VPointF thirdPoint = data->GetModelingPoint(thirdPointId);
|
||||||
|
|
||||||
|
Calculator cal(data);
|
||||||
|
QString errorMsg;
|
||||||
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
|
if(errorMsg.isEmpty()){
|
||||||
|
QPointF fPoint = VModelingBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||||
|
thirdPoint.toQPointF(), result*PrintDPI/25.4);
|
||||||
|
qint64 id = _id;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
id = data->AddModelingPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||||
|
} else {
|
||||||
|
data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||||
|
if(parse != Document::FullParse){
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
VDataTool *tool = tools->value(id);
|
||||||
|
if(tool != 0){
|
||||||
|
tool->VDataTool::setData(data);
|
||||||
|
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data->AddLine(firstPointId, id, Draw::Modeling);
|
||||||
|
data->IncrementReferens(firstPointId, Scene::Point, Draw::Modeling);
|
||||||
|
data->IncrementReferens(secondPointId, Scene::Point, Draw::Modeling);
|
||||||
|
data->IncrementReferens(thirdPointId, Scene::Point, Draw::Modeling);
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
point = new VModelingBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId,
|
||||||
|
thirdPointId, typeCreation);
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
tools->insert(id,point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingBisector::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
typeLine = domElement.attribute("typeLine", "");
|
||||||
|
formula = domElement.attribute("length", "");
|
||||||
|
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||||
|
basePointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
|
thirdPointId = domElement.attribute("thirdPoint", "").toLongLong();
|
||||||
|
}
|
||||||
|
RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingBisector::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogBisector->getPointName());
|
||||||
|
domElement.setAttribute("typeLine", dialogBisector->getTypeLine());
|
||||||
|
domElement.setAttribute("length", dialogBisector->getFormula());
|
||||||
|
domElement.setAttribute("firstPoint", QString().setNum(dialogBisector->getFirstPointId()));
|
||||||
|
domElement.setAttribute("secondPoint", QString().setNum(dialogBisector->getSecondPointId()));
|
||||||
|
domElement.setAttribute("thirdPoint", QString().setNum(dialogBisector->getThirdPointId()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogBisector.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogBisector, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingBisector::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "bisector");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
|
||||||
|
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
|
||||||
|
|
||||||
|
AddAttribute(domElement, "typeLine", typeLine);
|
||||||
|
AddAttribute(domElement, "length", formula);
|
||||||
|
AddAttribute(domElement, "firstPoint", firstPointId);
|
||||||
|
AddAttribute(domElement, "secondPoint", basePointId);
|
||||||
|
AddAttribute(domElement, "thirdPoint", thirdPointId);
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
38
tools/modelingTools/vmodelingbisector.h
Normal file
38
tools/modelingTools/vmodelingbisector.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef VMODELINGBISECTOR_H
|
||||||
|
#define VMODELINGBISECTOR_H
|
||||||
|
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include "vmodelinglinepoint.h"
|
||||||
|
#include "dialogs/dialogbisector.h"
|
||||||
|
|
||||||
|
class VModelingBisector : public VModelingLinePoint
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine, const QString &formula, const qint64 &firstPointId,
|
||||||
|
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Enum typeCreation,
|
||||||
|
QGraphicsItem * parent = 0);
|
||||||
|
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||||
|
const QPointF &thirdPoint, const qreal& length);
|
||||||
|
virtual void setDialog();
|
||||||
|
static VModelingBisector* Create(QSharedPointer<DialogBisector> &dialog, VDomDocument *doc,
|
||||||
|
VContainer *data);
|
||||||
|
static VModelingBisector* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||||
|
const qint64 &secondPointId, const qint64 &thirdPointId,
|
||||||
|
const QString &typeLine, const QString &pointName, const qreal &mx,
|
||||||
|
const qreal &my, VDomDocument *doc, VContainer *data,
|
||||||
|
Document::Enum parse, Tool::Enum typeCreation);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
private:
|
||||||
|
qint64 firstPointId;
|
||||||
|
qint64 thirdPointId;
|
||||||
|
QSharedPointer<DialogBisector> dialogBisector;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGBISECTOR_H
|
125
tools/modelingTools/vmodelingendline.cpp
Normal file
125
tools/modelingTools/vmodelingendline.cpp
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
#include "vmodelingendline.h"
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QMenu>
|
||||||
|
#include "widgets/vmaingraphicsscene.h"
|
||||||
|
|
||||||
|
VModelingEndLine::VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
|
||||||
|
const QString &formula, const qint32 &angle, const qint64 &basePointId,
|
||||||
|
Tool::Enum typeCreation, QGraphicsItem *parent):
|
||||||
|
VModelingLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent),
|
||||||
|
dialogEndLine(QSharedPointer<DialogEndLine>()){
|
||||||
|
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingEndLine::setDialog(){
|
||||||
|
Q_ASSERT(!dialogEndLine.isNull());
|
||||||
|
if(!dialogEndLine.isNull()){
|
||||||
|
VPointF p = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
dialogEndLine->setTypeLine(typeLine);
|
||||||
|
dialogEndLine->setFormula(formula);
|
||||||
|
dialogEndLine->setAngle(angle);
|
||||||
|
dialogEndLine->setBasePointId(basePointId, id);
|
||||||
|
dialogEndLine->setPointName(p.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingEndLine *VModelingEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VDomDocument *doc,
|
||||||
|
VContainer *data){
|
||||||
|
QString pointName = dialog->getPointName();
|
||||||
|
QString typeLine = dialog->getTypeLine();
|
||||||
|
QString formula = dialog->getFormula();
|
||||||
|
qint32 angle = dialog->getAngle();
|
||||||
|
qint64 basePointId = dialog->getBasePointId();
|
||||||
|
return Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, doc, data, Document::FullParse,
|
||||||
|
Tool::FromGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingEndLine *VModelingEndLine::Create(const qint64 _id, const QString &pointName,
|
||||||
|
const QString &typeLine, const QString &formula,
|
||||||
|
const qint32 &angle, const qint64 &basePointId, const qreal &mx,
|
||||||
|
const qreal &my, VDomDocument *doc, VContainer *data,
|
||||||
|
Document::Enum parse, Tool::Enum typeCreation){
|
||||||
|
VModelingEndLine *point = 0;
|
||||||
|
VPointF basePoint = data->GetModelingPoint(basePointId);
|
||||||
|
QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y()));
|
||||||
|
Calculator cal(data);
|
||||||
|
QString errorMsg;
|
||||||
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
|
if(errorMsg.isEmpty()){
|
||||||
|
line.setLength(result*PrintDPI/25.4);
|
||||||
|
line.setAngle(angle);
|
||||||
|
qint64 id = _id;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
id = data->AddModelingPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||||
|
} else {
|
||||||
|
data->UpdateModelingPoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||||
|
if(parse != Document::FullParse){
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
VDataTool *tool = tools->value(id);
|
||||||
|
if(tool != 0){
|
||||||
|
tool->VDataTool::setData(data);
|
||||||
|
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data->AddLine(basePointId, id, Draw::Modeling);
|
||||||
|
data->IncrementReferens(basePointId, Scene::Point, Draw::Modeling);
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
point = new VModelingEndLine(doc, data, id, typeLine, formula, angle, basePointId, typeCreation);
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
tools->insert(id,point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingEndLine::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
typeLine = domElement.attribute("typeLine", "");
|
||||||
|
formula = domElement.attribute("length", "");
|
||||||
|
basePointId = domElement.attribute("basePoint", "").toLongLong();
|
||||||
|
angle = domElement.attribute("angle", "").toInt();
|
||||||
|
}
|
||||||
|
RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogEndLine, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingEndLine::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogEndLine->getPointName());
|
||||||
|
domElement.setAttribute("typeLine", dialogEndLine->getTypeLine());
|
||||||
|
domElement.setAttribute("length", dialogEndLine->getFormula());
|
||||||
|
domElement.setAttribute("angle", QString().setNum(dialogEndLine->getAngle()));
|
||||||
|
domElement.setAttribute("basePoint", QString().setNum(dialogEndLine->getBasePointId()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogEndLine.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingEndLine::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "endLine");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "mx", toMM(point.mx()));
|
||||||
|
AddAttribute(domElement, "my", toMM(point.my()));
|
||||||
|
|
||||||
|
AddAttribute(domElement, "typeLine", typeLine);
|
||||||
|
AddAttribute(domElement, "length", formula);
|
||||||
|
AddAttribute(domElement, "angle", angle);
|
||||||
|
AddAttribute(domElement, "basePoint", basePointId);
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
33
tools/modelingTools/vmodelingendline.h
Normal file
33
tools/modelingTools/vmodelingendline.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef VMODELINGENDLINE_H
|
||||||
|
#define VMODELINGENDLINE_H
|
||||||
|
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include "vmodelinglinepoint.h"
|
||||||
|
#include "dialogs/dialogendline.h"
|
||||||
|
|
||||||
|
class VModelingEndLine : public VModelingLinePoint
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine, const QString &formula, const qint32 &angle,
|
||||||
|
const qint64 &basePointId, Tool::Enum typeCreation,
|
||||||
|
QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static VModelingEndLine* Create(QSharedPointer<DialogEndLine> &dialog, VDomDocument *doc,
|
||||||
|
VContainer *data);
|
||||||
|
static VModelingEndLine* Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||||
|
const QString &formula, const qint32 &angle, const qint64 &basePointId,
|
||||||
|
const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data,
|
||||||
|
Document::Enum parse, Tool::Enum typeCreation);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
private:
|
||||||
|
QSharedPointer<DialogEndLine> dialogEndLine;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGENDLINE_H
|
103
tools/modelingTools/vmodelingline.cpp
Normal file
103
tools/modelingTools/vmodelingline.cpp
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
#include "vmodelingline.h"
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
VModelingLine::VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
|
||||||
|
qint64 secondPoint, Tool::Enum typeCreation, QGraphicsItem *parent):
|
||||||
|
VModelingTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint),
|
||||||
|
secondPoint(secondPoint), dialogLine(QSharedPointer<DialogLine>()){
|
||||||
|
//Лінія
|
||||||
|
VPointF first = data->GetModelingPoint(firstPoint);
|
||||||
|
VPointF second = data->GetModelingPoint(secondPoint);
|
||||||
|
this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
|
||||||
|
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
|
this->setAcceptHoverEvents(true);
|
||||||
|
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLine::setDialog(){
|
||||||
|
dialogLine->setFirstPoint(firstPoint);
|
||||||
|
dialogLine->setSecondPoint(secondPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingLine *VModelingLine::Create(QSharedPointer<DialogLine> &dialog, VDomDocument *doc,
|
||||||
|
VContainer *data){
|
||||||
|
qint64 firstPoint = dialog->getFirstPoint();
|
||||||
|
qint64 secondPoint = dialog->getSecondPoint();
|
||||||
|
return Create(0, firstPoint, secondPoint, doc, data, Document::FullParse, Tool::FromGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingLine *VModelingLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
|
||||||
|
VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
|
Tool::Enum typeCreation){
|
||||||
|
VModelingLine *line = 0;
|
||||||
|
Q_CHECK_PTR(doc);
|
||||||
|
Q_CHECK_PTR(data);
|
||||||
|
data->AddLine(firstPoint, secondPoint, Draw::Modeling);
|
||||||
|
data->IncrementReferens(firstPoint, Scene::Point, Draw::Modeling);
|
||||||
|
data->IncrementReferens(secondPoint, Scene::Point, Draw::Modeling);
|
||||||
|
if(parse != Document::FullParse){
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
Q_CHECK_PTR(tools);
|
||||||
|
VDataTool *tool = tools->value(id);
|
||||||
|
Q_CHECK_PTR(tool);
|
||||||
|
tool->VDataTool::setData(data);
|
||||||
|
}
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
qint64 id = data->getNextId();
|
||||||
|
line = new VModelingLine(doc, data, id, firstPoint, secondPoint, typeCreation);
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
tools->insert(id,line);
|
||||||
|
}
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLine::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
firstPoint = domElement.attribute("firstPoint", "").toLongLong();
|
||||||
|
secondPoint = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
|
}
|
||||||
|
VPointF first = VAbstractTool::data.GetModelingPoint(firstPoint);
|
||||||
|
VPointF second = VAbstractTool::data.GetModelingPoint(secondPoint);
|
||||||
|
this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLine::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("firstPoint", QString().setNum(dialogLine->getFirstPoint()));
|
||||||
|
domElement.setAttribute("secondPoint", QString().setNum(dialogLine->getSecondPoint()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogLine.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogLine, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLine::AddToFile(){
|
||||||
|
QDomElement domElement = doc->createElement("line");
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "firstPoint", firstPoint);
|
||||||
|
AddAttribute(domElement, "secondPoint", secondPoint);
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
|
||||||
|
Q_UNUSED(event);
|
||||||
|
this->setPen(QPen(currentColor, widthMainLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
|
||||||
|
Q_UNUSED(event);
|
||||||
|
this->setPen(QPen(currentColor, widthHairLine));
|
||||||
|
}
|
33
tools/modelingTools/vmodelingline.h
Normal file
33
tools/modelingTools/vmodelingline.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef VMODELINGLINE_H
|
||||||
|
#define VMODELINGLINE_H
|
||||||
|
|
||||||
|
#include "vmodelingtool.h"
|
||||||
|
#include "QGraphicsLineItem"
|
||||||
|
#include "dialogs/dialogline.h"
|
||||||
|
|
||||||
|
class VModelingLine: public VModelingTool, public QGraphicsLineItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
|
||||||
|
qint64 secondPoint, Tool::Enum typeCreation, QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static VModelingLine* Create(QSharedPointer<DialogLine> &dialog, VDomDocument *doc, VContainer *data);
|
||||||
|
static VModelingLine* Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
|
||||||
|
VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
|
Tool::Enum typeCreation);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
private:
|
||||||
|
qint64 firstPoint;
|
||||||
|
qint64 secondPoint;
|
||||||
|
QSharedPointer<DialogLine> dialogLine;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGLINE_H
|
128
tools/modelingTools/vmodelinglineintersect.cpp
Normal file
128
tools/modelingTools/vmodelinglineintersect.cpp
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
#include "vmodelinglineintersect.h"
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
VModelingLineIntersect::VModelingLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2,
|
||||||
|
const qint64 &p2Line2, Tool::Enum typeCreation, QGraphicsItem *parent):
|
||||||
|
VModelingPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
|
||||||
|
p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLineIntersect::setDialog(){
|
||||||
|
Q_ASSERT(!dialogLineIntersect.isNull());
|
||||||
|
if(!dialogLineIntersect.isNull()){
|
||||||
|
VPointF p = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
dialogLineIntersect->setP1Line1(p1Line1);
|
||||||
|
dialogLineIntersect->setP2Line1(p2Line1);
|
||||||
|
dialogLineIntersect->setP1Line2(p1Line2);
|
||||||
|
dialogLineIntersect->setP2Line2(p2Line2);
|
||||||
|
dialogLineIntersect->setPointName(p.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingLineIntersect *VModelingLineIntersect::Create(QSharedPointer<DialogLineIntersect> &dialog,
|
||||||
|
VDomDocument *doc, VContainer *data){
|
||||||
|
qint64 p1Line1Id = dialog->getP1Line1();
|
||||||
|
qint64 p2Line1Id = dialog->getP2Line1();
|
||||||
|
qint64 p1Line2Id = dialog->getP1Line2();
|
||||||
|
qint64 p2Line2Id = dialog->getP2Line2();
|
||||||
|
QString pointName = dialog->getPointName();
|
||||||
|
return Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, doc, data,
|
||||||
|
Document::FullParse, Tool::FromGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingLineIntersect *VModelingLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id,
|
||||||
|
const qint64 &p2Line1Id, const qint64 &p1Line2Id,
|
||||||
|
const qint64 &p2Line2Id, const QString &pointName,
|
||||||
|
const qreal &mx, const qreal &my, VDomDocument *doc,
|
||||||
|
VContainer *data, Document::Enum parse,
|
||||||
|
Tool::Enum typeCreation){
|
||||||
|
VModelingLineIntersect *point = 0;
|
||||||
|
VPointF p1Line1 = data->GetModelingPoint(p1Line1Id);
|
||||||
|
VPointF p2Line1 = data->GetModelingPoint(p2Line1Id);
|
||||||
|
VPointF p1Line2 = data->GetModelingPoint(p1Line2Id);
|
||||||
|
VPointF p2Line2 = data->GetModelingPoint(p2Line2Id);
|
||||||
|
|
||||||
|
QLineF line1(p1Line1.toQPointF(), p2Line1.toQPointF());
|
||||||
|
QLineF line2(p1Line2.toQPointF(), p2Line2.toQPointF());
|
||||||
|
QPointF fPoint;
|
||||||
|
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
|
||||||
|
if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){
|
||||||
|
qint64 id = _id;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
id = data->AddModelingPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||||
|
} else {
|
||||||
|
data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||||
|
if(parse != Document::FullParse){
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
VDataTool *tool = tools->value(id);
|
||||||
|
if(tool != 0){
|
||||||
|
tool->VDataTool::setData(data);
|
||||||
|
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data->AddLine(p1Line1Id, id, Draw::Modeling);
|
||||||
|
data->AddLine(id, p2Line1Id, Draw::Modeling);
|
||||||
|
data->AddLine(p1Line2Id, id, Draw::Modeling);
|
||||||
|
data->AddLine(id, p2Line2Id, Draw::Modeling);
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
point = new VModelingLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id,
|
||||||
|
typeCreation);
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
tools->insert(id,point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLineIntersect::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
p1Line1 = domElement.attribute("p1Line1", "").toLongLong();
|
||||||
|
p2Line1 = domElement.attribute("p2Line1", "").toLongLong();
|
||||||
|
p1Line2 = domElement.attribute("p1Line2", "").toLongLong();
|
||||||
|
p2Line2 = domElement.attribute("p2Line2", "").toLongLong();
|
||||||
|
}
|
||||||
|
RefreshPointGeometry(VAbstractTool::data.GetModelingPoint(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLineIntersect::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogLineIntersect->getPointName());
|
||||||
|
domElement.setAttribute("p1Line1", QString().setNum(dialogLineIntersect->getP1Line1()));
|
||||||
|
domElement.setAttribute("p2Line1", QString().setNum(dialogLineIntersect->getP2Line1()));
|
||||||
|
domElement.setAttribute("p1Line2", QString().setNum(dialogLineIntersect->getP1Line2()));
|
||||||
|
domElement.setAttribute("p2Line2", QString().setNum(dialogLineIntersect->getP2Line2()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogLineIntersect.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogLineIntersect, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLineIntersect::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "lineIntersect");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
|
||||||
|
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
|
||||||
|
|
||||||
|
AddAttribute(domElement, "p1Line1", p1Line1);
|
||||||
|
AddAttribute(domElement, "p2Line1", p2Line1);
|
||||||
|
AddAttribute(domElement, "p1Line2", p1Line2);
|
||||||
|
AddAttribute(domElement, "p2Line2", p2Line2);
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
39
tools/modelingTools/vmodelinglineintersect.h
Normal file
39
tools/modelingTools/vmodelinglineintersect.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#ifndef VMODELINGLINEINTERSECT_H
|
||||||
|
#define VMODELINGLINEINTERSECT_H
|
||||||
|
|
||||||
|
#include "vmodelingpoint.h"
|
||||||
|
#include "dialogs/dialoglineintersect.h"
|
||||||
|
|
||||||
|
class VModelingLineIntersect:public VModelingPoint
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingLineIntersect(VDomDocument *doc, VContainer *data,
|
||||||
|
const qint64 &id,
|
||||||
|
const qint64 &p1Line1,
|
||||||
|
const qint64 &p2Line1, const qint64 &p1Line2,
|
||||||
|
const qint64 &p2Line2, Tool::Enum typeCreation,
|
||||||
|
QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static VModelingLineIntersect* Create(QSharedPointer<DialogLineIntersect> &dialog,
|
||||||
|
VDomDocument *doc,VContainer *data);
|
||||||
|
static VModelingLineIntersect* Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id,
|
||||||
|
const qint64 &p1Line2Id, const qint64 &p2Line2Id,
|
||||||
|
const QString &pointName, const qreal &mx, const qreal &my,
|
||||||
|
VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
|
Tool::Enum typeCreation);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
private:
|
||||||
|
qint64 p1Line1;
|
||||||
|
qint64 p2Line1;
|
||||||
|
qint64 p1Line2;
|
||||||
|
qint64 p2Line2;
|
||||||
|
QSharedPointer<DialogLineIntersect> dialogLineIntersect;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGLINEINTERSECT_H
|
31
tools/modelingTools/vmodelinglinepoint.cpp
Normal file
31
tools/modelingTools/vmodelinglinepoint.cpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#include "vmodelinglinepoint.h"
|
||||||
|
|
||||||
|
VModelingLinePoint::VModelingLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine, const QString &formula, const qint64 &basePointId,
|
||||||
|
const qint32 &angle, QGraphicsItem *parent):
|
||||||
|
VModelingPoint(doc, data, id, parent), typeLine(typeLine), formula(formula), angle(angle),
|
||||||
|
basePointId(basePointId), mainLine(0){
|
||||||
|
//Лінія, що з'єднує дві точки
|
||||||
|
QPointF point1 = data->GetModelingPoint(basePointId).toQPointF();
|
||||||
|
QPointF point2 = data->GetModelingPoint(id).toQPointF();
|
||||||
|
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, point2 - point2), this);
|
||||||
|
mainLine->setPen(QPen(Qt::black, widthHairLine));
|
||||||
|
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
|
if(typeLine == "none"){
|
||||||
|
mainLine->setVisible(false);
|
||||||
|
} else {
|
||||||
|
mainLine->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingLinePoint::RefreshGeometry(){
|
||||||
|
VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetModelingPoint(id));
|
||||||
|
QPointF point = VModelingTool::data.GetModelingPoint(id).toQPointF();
|
||||||
|
QPointF basePoint = VModelingTool::data.GetModelingPoint(basePointId).toQPointF();
|
||||||
|
mainLine->setLine(QLineF(basePoint - point, point - point));
|
||||||
|
if(typeLine == "none"){
|
||||||
|
mainLine->setVisible(false);
|
||||||
|
} else {
|
||||||
|
mainLine->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
25
tools/modelingTools/vmodelinglinepoint.h
Normal file
25
tools/modelingTools/vmodelinglinepoint.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef VMODELINGLINEPOINT_H
|
||||||
|
#define VMODELINGLINEPOINT_H
|
||||||
|
|
||||||
|
#include "vmodelingpoint.h"
|
||||||
|
|
||||||
|
class VModelingLinePoint : public VModelingPoint
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine, const QString &formula,
|
||||||
|
const qint64 &basePointId, const qint32 &angle, QGraphicsItem * parent = 0);
|
||||||
|
protected:
|
||||||
|
QString typeLine;
|
||||||
|
QString formula;
|
||||||
|
qint32 angle;
|
||||||
|
qint64 basePointId;
|
||||||
|
QGraphicsLineItem *mainLine;
|
||||||
|
virtual void RefreshGeometry();
|
||||||
|
private:
|
||||||
|
VModelingLinePoint(const VModelingLinePoint &tool);
|
||||||
|
const VModelingLinePoint &operator=(const VModelingLinePoint &tool);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGLINEPOINT_H
|
142
tools/modelingTools/vmodelingnormal.cpp
Normal file
142
tools/modelingTools/vmodelingnormal.cpp
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
#include "vmodelingnormal.h"
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
VModelingNormal::VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine,
|
||||||
|
const QString &formula, const qreal &angle, const qint64 &firstPointId,
|
||||||
|
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem *parent):
|
||||||
|
VModelingLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent),
|
||||||
|
secondPointId(secondPointId), dialogNormal(QSharedPointer<DialogNormal>()){
|
||||||
|
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingNormal::setDialog(){
|
||||||
|
Q_ASSERT(!dialogNormal.isNull());
|
||||||
|
if(!dialogNormal.isNull()){
|
||||||
|
VPointF p = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
dialogNormal->setTypeLine(typeLine);
|
||||||
|
dialogNormal->setFormula(formula);
|
||||||
|
dialogNormal->setAngle(angle);
|
||||||
|
dialogNormal->setFirstPointId(basePointId, id);
|
||||||
|
dialogNormal->setSecondPointId(secondPointId, id);
|
||||||
|
dialogNormal->setPointName(p.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingNormal* VModelingNormal::Create(QSharedPointer<DialogNormal> &dialog, VDomDocument *doc,
|
||||||
|
VContainer *data){
|
||||||
|
QString formula = dialog->getFormula();
|
||||||
|
qint64 firstPointId = dialog->getFirstPointId();
|
||||||
|
qint64 secondPointId = dialog->getSecondPointId();
|
||||||
|
QString typeLine = dialog->getTypeLine();
|
||||||
|
QString pointName = dialog->getPointName();
|
||||||
|
qint32 angle = dialog->getAngle();
|
||||||
|
return Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, doc, data,
|
||||||
|
Document::FullParse, Tool::FromGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingNormal *VModelingNormal::Create(const qint64 _id, const QString &formula,
|
||||||
|
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
const QString typeLine, const QString pointName,
|
||||||
|
const qreal angle, const qreal &mx, const qreal &my,
|
||||||
|
VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
|
Tool::Enum typeCreation){
|
||||||
|
VModelingNormal *point = 0;
|
||||||
|
VPointF firstPoint = data->GetModelingPoint(firstPointId);
|
||||||
|
VPointF secondPoint = data->GetModelingPoint(secondPointId);
|
||||||
|
Calculator cal(data);
|
||||||
|
QString errorMsg;
|
||||||
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
|
if(errorMsg.isEmpty()){
|
||||||
|
QPointF fPoint = VModelingNormal::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||||
|
result*PrintDPI/25.4, angle);
|
||||||
|
qint64 id = _id;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
id = data->AddModelingPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||||
|
} else {
|
||||||
|
data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||||
|
if(parse != Document::FullParse){
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
VDataTool *tool = tools->value(id);
|
||||||
|
if(tool != 0){
|
||||||
|
tool->VDataTool::setData(data);
|
||||||
|
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data->AddLine(firstPointId, id, Draw::Modeling);
|
||||||
|
data->IncrementReferens(firstPointId, Scene::Point, Draw::Modeling);
|
||||||
|
data->IncrementReferens(secondPointId, Scene::Point, Draw::Modeling);
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
point = new VModelingNormal(doc, data, id, typeLine, formula, angle, firstPointId, secondPointId,
|
||||||
|
typeCreation);
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
tools->insert(id,point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF VModelingNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length,
|
||||||
|
const qreal &angle){
|
||||||
|
QLineF line(firstPoint, secondPoint);
|
||||||
|
QLineF normal = line.normalVector();
|
||||||
|
normal.setAngle(normal.angle()+angle);
|
||||||
|
normal.setLength(length);
|
||||||
|
return normal.p2();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingNormal::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
typeLine = domElement.attribute("typeLine", "");
|
||||||
|
formula = domElement.attribute("length", "");
|
||||||
|
basePointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||||
|
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
|
angle = domElement.attribute("angle", "").toInt();
|
||||||
|
}
|
||||||
|
RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingNormal::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogNormal->getPointName());
|
||||||
|
domElement.setAttribute("typeLine", dialogNormal->getTypeLine());
|
||||||
|
domElement.setAttribute("length", dialogNormal->getFormula());
|
||||||
|
domElement.setAttribute("angle", QString().setNum(dialogNormal->getAngle()));
|
||||||
|
domElement.setAttribute("firstPoint", QString().setNum(dialogNormal->getFirstPointId()));
|
||||||
|
domElement.setAttribute("secondPoint", QString().setNum(dialogNormal->getSecondPointId()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogNormal.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogNormal, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingNormal::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "normal");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
|
||||||
|
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
|
||||||
|
|
||||||
|
AddAttribute(domElement, "typeLine", typeLine);
|
||||||
|
AddAttribute(domElement, "length", formula);
|
||||||
|
AddAttribute(domElement, "angle", angle);
|
||||||
|
AddAttribute(domElement, "firstPoint", basePointId);
|
||||||
|
AddAttribute(domElement, "secondPoint", secondPointId);
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
37
tools/modelingTools/vmodelingnormal.h
Normal file
37
tools/modelingTools/vmodelingnormal.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef VMODELINGNORMAL_H
|
||||||
|
#define VMODELINGNORMAL_H
|
||||||
|
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include "vmodelinglinepoint.h"
|
||||||
|
#include "dialogs/dialognormal.h"
|
||||||
|
|
||||||
|
class VModelingNormal : public VModelingLinePoint
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine, const QString &formula,
|
||||||
|
const qreal &angle, const qint64 &firstPointId,
|
||||||
|
const qint64 &secondPointId, Tool::Enum typeCreation,
|
||||||
|
QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static VModelingNormal* Create(QSharedPointer<DialogNormal> &dialog, VDomDocument *doc, VContainer *data);
|
||||||
|
static VModelingNormal* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||||
|
const qint64 &secondPointId, const QString typeLine,
|
||||||
|
const QString pointName, const qreal angle, const qreal &mx,
|
||||||
|
const qreal &my, VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
|
Tool::Enum typeCreation);
|
||||||
|
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||||
|
const qreal &length, const qreal &angle = 0);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
private:
|
||||||
|
qint64 secondPointId;
|
||||||
|
QSharedPointer<DialogNormal> dialogNormal;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGNORMAL_H
|
86
tools/modelingTools/vmodelingpoint.cpp
Normal file
86
tools/modelingTools/vmodelingpoint.cpp
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
#include "vmodelingpoint.h"
|
||||||
|
#include <QPen>
|
||||||
|
#include <QBrush>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include "container/vpointf.h"
|
||||||
|
|
||||||
|
VModelingPoint::VModelingPoint(VDomDocument *doc, VContainer *data, qint64 id,
|
||||||
|
QGraphicsItem *parent):VModelingTool(doc, data, id),
|
||||||
|
QGraphicsEllipseItem(parent), radius(toPixel(1.5)), namePoint(0), lineName(0){
|
||||||
|
namePoint = new VGraphicsSimpleTextItem(this);
|
||||||
|
lineName = new QGraphicsLineItem(this);
|
||||||
|
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
||||||
|
&VModelingPoint::NameChangePosition);
|
||||||
|
this->setPen(QPen(Qt::black, widthHairLine));
|
||||||
|
this->setBrush(QBrush(Qt::NoBrush));
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
|
this->setAcceptHoverEvents(true);
|
||||||
|
RefreshPointGeometry(VAbstractTool::data.GetModelingPoint(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPoint::NameChangePosition(const QPointF pos){
|
||||||
|
VPointF point = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
QPointF p = pos - this->pos();
|
||||||
|
point.setMx(p.x());
|
||||||
|
point.setMy(p.y());
|
||||||
|
RefreshLine();
|
||||||
|
UpdateNamePosition(point.mx(), point.my());
|
||||||
|
VAbstractTool::data.UpdatePoint(id, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPoint::UpdateNamePosition(qreal mx, qreal my){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("mx", QString().setNum(toMM(mx)));
|
||||||
|
domElement.setAttribute("my", QString().setNum(toMM(my)));
|
||||||
|
emit toolhaveChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
|
||||||
|
if(event->button() == Qt::LeftButton){
|
||||||
|
emit ChoosedTool(id, Scene::Point);
|
||||||
|
}
|
||||||
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
|
||||||
|
Q_UNUSED(event);
|
||||||
|
this->setPen(QPen(currentColor, widthMainLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
|
||||||
|
Q_UNUSED(event);
|
||||||
|
this->setPen(QPen(currentColor, widthHairLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPoint::RefreshPointGeometry(const VPointF &point){
|
||||||
|
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
||||||
|
rec.translate(-rec.center().x(), -rec.center().y());
|
||||||
|
this->setRect(rec);
|
||||||
|
this->setPos(point.toQPointF());
|
||||||
|
disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
||||||
|
&VModelingPoint::NameChangePosition);
|
||||||
|
namePoint->setText(point.name());
|
||||||
|
namePoint->setPos(QPointF(point.mx(), point.my()));
|
||||||
|
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
||||||
|
&VModelingPoint::NameChangePosition);
|
||||||
|
RefreshLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPoint::RefreshLine(){
|
||||||
|
QRectF nameRec = namePoint->sceneBoundingRect();
|
||||||
|
QPointF p1, p2;
|
||||||
|
LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2);
|
||||||
|
QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
|
||||||
|
lineName->setLine(QLineF(p1, pRec - scenePos()));
|
||||||
|
if(QLineF(p1, pRec - scenePos()).length() <= toPixel(4)){
|
||||||
|
lineName->setVisible(false);
|
||||||
|
} else {
|
||||||
|
lineName->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingPoint::~VModelingPoint(){
|
||||||
|
}
|
32
tools/modelingTools/vmodelingpoint.h
Normal file
32
tools/modelingTools/vmodelingpoint.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef VMODELINGPOINT_H
|
||||||
|
#define VMODELINGPOINT_H
|
||||||
|
|
||||||
|
#include "vmodelingtool.h"
|
||||||
|
#include "widgets/vgraphicssimpletextitem.h"
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
|
class VModelingPoint: public VModelingTool, public QGraphicsEllipseItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem * parent = 0);
|
||||||
|
virtual ~VModelingPoint();
|
||||||
|
public slots:
|
||||||
|
void NameChangePosition(const QPointF pos);
|
||||||
|
virtual void FullUpdateFromGui(int result) = 0;
|
||||||
|
protected:
|
||||||
|
qreal radius;
|
||||||
|
VGraphicsSimpleTextItem *namePoint;
|
||||||
|
QGraphicsLineItem *lineName;
|
||||||
|
virtual void UpdateNamePosition(qreal mx, qreal my);
|
||||||
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
virtual void RefreshPointGeometry(const VPointF &point);
|
||||||
|
void RefreshLine();
|
||||||
|
private:
|
||||||
|
VModelingPoint(const VModelingPoint &tool);
|
||||||
|
const VModelingPoint &operator=(const VModelingPoint &tool);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGPOINT_H
|
151
tools/modelingTools/vmodelingpointofcontact.cpp
Normal file
151
tools/modelingTools/vmodelingpointofcontact.cpp
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
#include "vmodelingpointofcontact.h"
|
||||||
|
|
||||||
|
VModelingPointOfContact::VModelingPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &radius, const qint64 ¢er,
|
||||||
|
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
Tool::Enum typeCreation, QGraphicsItem *parent)
|
||||||
|
: VModelingPoint(doc, data, id, parent), radius(radius), center(center), firstPointId(firstPointId),
|
||||||
|
secondPointId(secondPointId), dialogPointOfContact(QSharedPointer<DialogPointOfContact>()){
|
||||||
|
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPointOfContact::setDialog(){
|
||||||
|
Q_ASSERT(!dialogPointOfContact.isNull());
|
||||||
|
if(!dialogPointOfContact.isNull()){
|
||||||
|
VPointF p = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
dialogPointOfContact->setRadius(radius);
|
||||||
|
dialogPointOfContact->setCenter(center, id);
|
||||||
|
dialogPointOfContact->setFirstPoint(firstPointId, id);
|
||||||
|
dialogPointOfContact->setSecondPoint(secondPointId, id);
|
||||||
|
dialogPointOfContact->setPointName(p.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF VModelingPointOfContact::FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint,
|
||||||
|
const QPointF &secondPoint){
|
||||||
|
QPointF pArc;
|
||||||
|
qreal s = 0.0, s_x, s_y, step = 0.01, distans;
|
||||||
|
while( s < 1){
|
||||||
|
s_x = secondPoint.x()-(qAbs(secondPoint.x()-firstPoint.x()))*s;
|
||||||
|
s_y = secondPoint.y()-(qAbs(secondPoint.y()-firstPoint.y()))*s;
|
||||||
|
distans = QLineF(center.x(), center.y(), s_x, s_y).length();
|
||||||
|
if(ceil(distans*10) == ceil(radius*10)){
|
||||||
|
pArc.rx() = s_x;
|
||||||
|
pArc.ry() = s_y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(distans<radius){
|
||||||
|
pArc.rx() = s_x;
|
||||||
|
pArc.ry() = s_y;
|
||||||
|
}
|
||||||
|
s = s + step;
|
||||||
|
}
|
||||||
|
return pArc;
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingPointOfContact *VModelingPointOfContact::Create(QSharedPointer<DialogPointOfContact> &dialog,
|
||||||
|
VDomDocument *doc, VContainer *data){
|
||||||
|
QString radius = dialog->getRadius();
|
||||||
|
qint64 center = dialog->getCenter();
|
||||||
|
qint64 firstPointId = dialog->getFirstPoint();
|
||||||
|
qint64 secondPointId = dialog->getSecondPoint();
|
||||||
|
QString pointName = dialog->getPointName();
|
||||||
|
return Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, doc, data,
|
||||||
|
Document::FullParse, Tool::FromGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingPointOfContact *VModelingPointOfContact::Create(const qint64 _id, const QString &radius,
|
||||||
|
const qint64 ¢er, const qint64 &firstPointId,
|
||||||
|
const qint64 &secondPointId,
|
||||||
|
const QString &pointName, const qreal &mx,
|
||||||
|
const qreal &my, VDomDocument *doc,
|
||||||
|
VContainer *data, Document::Enum parse,
|
||||||
|
Tool::Enum typeCreation){
|
||||||
|
VModelingPointOfContact *point = 0;
|
||||||
|
VPointF centerP = data->GetModelingPoint(center);
|
||||||
|
VPointF firstP = data->GetModelingPoint(firstPointId);
|
||||||
|
VPointF secondP = data->GetModelingPoint(secondPointId);
|
||||||
|
|
||||||
|
Calculator cal(data);
|
||||||
|
QString errorMsg;
|
||||||
|
qreal result = cal.eval(radius, &errorMsg);
|
||||||
|
if(errorMsg.isEmpty()){
|
||||||
|
QPointF fPoint = VModelingPointOfContact::FindPoint(result*PrintDPI/25.4, centerP.toQPointF(),
|
||||||
|
firstP.toQPointF(), secondP.toQPointF());
|
||||||
|
qint64 id = _id;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
id = data->AddModelingPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||||
|
} else {
|
||||||
|
data->UpdateModelingPoint(id, VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||||
|
if(parse != Document::FullParse){
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
VDataTool *tool = tools->value(id);
|
||||||
|
if(tool != 0){
|
||||||
|
tool->VDataTool::setData(data);
|
||||||
|
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data->IncrementReferens(center, Scene::Point, Draw::Modeling);
|
||||||
|
data->IncrementReferens(firstPointId, Scene::Point, Draw::Modeling);
|
||||||
|
data->IncrementReferens(secondPointId, Scene::Point, Draw::Modeling);
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
point = new VModelingPointOfContact(doc, data, id, radius, center, firstPointId, secondPointId,
|
||||||
|
typeCreation);
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
tools->insert(id,point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPointOfContact::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
radius = domElement.attribute("radius", "");
|
||||||
|
center = domElement.attribute("center", "").toLongLong();
|
||||||
|
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||||
|
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
|
}
|
||||||
|
RefreshPointGeometry(VAbstractTool::data.GetModelingPoint(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPointOfContact::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogPointOfContact->getPointName());
|
||||||
|
domElement.setAttribute("radius", dialogPointOfContact->getRadius());
|
||||||
|
domElement.setAttribute("center", QString().setNum(dialogPointOfContact->getCenter()));
|
||||||
|
domElement.setAttribute("firstPoint", QString().setNum(dialogPointOfContact->getFirstPoint()));
|
||||||
|
domElement.setAttribute("secondPoint", QString().setNum(dialogPointOfContact->getSecondPoint()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogPointOfContact.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogPointOfContact, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingPointOfContact::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "pointOfContact");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
|
||||||
|
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
|
||||||
|
|
||||||
|
AddAttribute(domElement, "radius", radius);
|
||||||
|
AddAttribute(domElement, "center", center);
|
||||||
|
AddAttribute(domElement, "firstPoint", firstPointId);
|
||||||
|
AddAttribute(domElement, "secondPoint", secondPointId);
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
38
tools/modelingTools/vmodelingpointofcontact.h
Normal file
38
tools/modelingTools/vmodelingpointofcontact.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef VMODELINGPOINTOFCONTACT_H
|
||||||
|
#define VMODELINGPOINTOFCONTACT_H
|
||||||
|
|
||||||
|
#include "vmodelingpoint.h"
|
||||||
|
#include "dialogs/dialogpointofcontact.h"
|
||||||
|
|
||||||
|
class VModelingPointOfContact : public VModelingPoint
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &radius, const qint64 ¢er, const qint64 &firstPointId,
|
||||||
|
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static QPointF FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint,
|
||||||
|
const QPointF &secondPoint);
|
||||||
|
static VModelingPointOfContact* Create(QSharedPointer<DialogPointOfContact> &dialog,
|
||||||
|
VDomDocument *doc, VContainer *data);
|
||||||
|
static VModelingPointOfContact* Create(const qint64 _id, const QString &radius, const qint64 ¢er,
|
||||||
|
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
const QString &pointName, const qreal &mx, const qreal &my,
|
||||||
|
VDomDocument *doc, VContainer *data, Document::Enum parse,
|
||||||
|
Tool::Enum typeCreation);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
private:
|
||||||
|
QString radius;
|
||||||
|
qint64 center;
|
||||||
|
qint64 firstPointId;
|
||||||
|
qint64 secondPointId;
|
||||||
|
QSharedPointer<DialogPointOfContact> dialogPointOfContact;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGPOINTOFCONTACT_H
|
159
tools/modelingTools/vmodelingshoulderpoint.cpp
Normal file
159
tools/modelingTools/vmodelingshoulderpoint.cpp
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
#include "vmodelingshoulderpoint.h"
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
VModelingShoulderPoint::VModelingShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine, const QString &formula, const qint64 &p1Line,
|
||||||
|
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation,
|
||||||
|
QGraphicsItem * parent):
|
||||||
|
VModelingLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent), p2Line(p2Line),
|
||||||
|
pShoulder(pShoulder), dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>()){
|
||||||
|
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingShoulderPoint::setDialog(){
|
||||||
|
Q_ASSERT(!dialogShoulderPoint.isNull());
|
||||||
|
if(!dialogShoulderPoint.isNull()){
|
||||||
|
VPointF p = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
dialogShoulderPoint->setTypeLine(typeLine);
|
||||||
|
dialogShoulderPoint->setFormula(formula);
|
||||||
|
dialogShoulderPoint->setP1Line(basePointId, id);
|
||||||
|
dialogShoulderPoint->setP2Line(p2Line, id);
|
||||||
|
dialogShoulderPoint->setPShoulder(pShoulder, id);
|
||||||
|
dialogShoulderPoint->setPointName(p.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF VModelingShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
|
||||||
|
const qreal &length){
|
||||||
|
QLineF line = QLineF(p1Line, p2Line);
|
||||||
|
qreal dist = line.length();
|
||||||
|
if(dist>length){
|
||||||
|
qDebug()<<"A3П2="<<length/PrintDPI*25.4<<"А30П ="<<dist/PrintDPI*25.4;
|
||||||
|
throw"Не можу знайти точку плеча. Довжина А3П2 < А3П.";
|
||||||
|
}
|
||||||
|
if(dist==length){
|
||||||
|
return line.p2();
|
||||||
|
}
|
||||||
|
qreal step = 0.01;
|
||||||
|
while(1){
|
||||||
|
line.setLength(line.length()+step);
|
||||||
|
QLineF line2 = QLineF(pShoulder, line.p2());
|
||||||
|
if(line2.length()>=length){
|
||||||
|
return line.p2();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingShoulderPoint *VModelingShoulderPoint::Create(QSharedPointer<DialogShoulderPoint> &dialog,
|
||||||
|
VDomDocument *doc, VContainer *data){
|
||||||
|
QString formula = dialog->getFormula();
|
||||||
|
qint64 p1Line = dialog->getP1Line();
|
||||||
|
qint64 p2Line = dialog->getP2Line();
|
||||||
|
qint64 pShoulder = dialog->getPShoulder();
|
||||||
|
QString typeLine = dialog->getTypeLine();
|
||||||
|
QString pointName = dialog->getPointName();
|
||||||
|
return Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, doc, data,
|
||||||
|
Document::FullParse, Tool::FromGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingShoulderPoint *VModelingShoulderPoint::Create(const qint64 _id, const QString &formula,
|
||||||
|
const qint64 &p1Line, const qint64 &p2Line,
|
||||||
|
const qint64 &pShoulder, const QString &typeLine,
|
||||||
|
const QString &pointName, const qreal &mx,
|
||||||
|
const qreal &my, VDomDocument *doc, VContainer *data,
|
||||||
|
Document::Enum parse, Tool::Enum typeCreation){
|
||||||
|
VModelingShoulderPoint *point = 0;
|
||||||
|
VPointF firstPoint = data->GetModelingPoint(p1Line);
|
||||||
|
VPointF secondPoint = data->GetModelingPoint(p2Line);
|
||||||
|
VPointF shoulderPoint = data->GetModelingPoint(pShoulder);
|
||||||
|
|
||||||
|
Calculator cal(data);
|
||||||
|
QString errorMsg;
|
||||||
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
|
if(errorMsg.isEmpty()){
|
||||||
|
QPointF fPoint = VModelingShoulderPoint::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||||
|
shoulderPoint.toQPointF(), result*PrintDPI/25.4);
|
||||||
|
qint64 id = _id;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
id = data->AddModelingPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||||
|
} else {
|
||||||
|
data->UpdateModelingPoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||||
|
if(parse != Document::FullParse){
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
VDataTool *tool = tools->value(id);
|
||||||
|
if(tool != 0){
|
||||||
|
tool->VDataTool::setData(data);
|
||||||
|
data->IncrementReferens(id, Scene::Point, Draw::Modeling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data->AddLine(p1Line, id, Draw::Modeling);
|
||||||
|
data->AddLine(p2Line, id, Draw::Modeling);
|
||||||
|
data->IncrementReferens(p1Line, Scene::Point, Draw::Modeling);
|
||||||
|
data->IncrementReferens(p2Line, Scene::Point, Draw::Modeling);
|
||||||
|
data->IncrementReferens(pShoulder, Scene::Point, Draw::Modeling);
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
point = new VModelingShoulderPoint(doc, data, id, typeLine, formula, p1Line, p2Line, pShoulder,
|
||||||
|
typeCreation);
|
||||||
|
QMap<qint64, VDataTool*>* tools = doc->getTools();
|
||||||
|
tools->insert(id,point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingShoulderPoint::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
typeLine = domElement.attribute("typeLine", "");
|
||||||
|
formula = domElement.attribute("length", "");
|
||||||
|
basePointId = domElement.attribute("p1Line", "").toLongLong();
|
||||||
|
p2Line = domElement.attribute("p2Line", "").toLongLong();
|
||||||
|
pShoulder = domElement.attribute("pShoulder", "").toLongLong();
|
||||||
|
}
|
||||||
|
RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingShoulderPoint::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogShoulderPoint->getPointName());
|
||||||
|
domElement.setAttribute("typeLine", dialogShoulderPoint->getTypeLine());
|
||||||
|
domElement.setAttribute("length", dialogShoulderPoint->getFormula());
|
||||||
|
domElement.setAttribute("p1Line", QString().setNum(dialogShoulderPoint->getP1Line()));
|
||||||
|
domElement.setAttribute("p2Line", QString().setNum(dialogShoulderPoint->getP2Line()));
|
||||||
|
domElement.setAttribute("pShoulder", QString().setNum(dialogShoulderPoint->getPShoulder()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogShoulderPoint.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogShoulderPoint, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingShoulderPoint::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "shoulder");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
|
||||||
|
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
|
||||||
|
|
||||||
|
AddAttribute(domElement, "typeLine", typeLine);
|
||||||
|
AddAttribute(domElement, "length", formula);
|
||||||
|
AddAttribute(domElement, "p1Line", basePointId);
|
||||||
|
AddAttribute(domElement, "p2Line", p2Line);
|
||||||
|
AddAttribute(domElement, "pShoulder", pShoulder);
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
37
tools/modelingTools/vmodelingshoulderpoint.h
Normal file
37
tools/modelingTools/vmodelingshoulderpoint.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef VMODELINGSHOULDERPOINT_H
|
||||||
|
#define VMODELINGSHOULDERPOINT_H
|
||||||
|
|
||||||
|
#include "vmodelinglinepoint.h"
|
||||||
|
#include "dialogs/dialogshoulderpoint.h"
|
||||||
|
|
||||||
|
class VModelingShoulderPoint : public VModelingLinePoint
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine, const QString &formula, const qint64 &p1Line,
|
||||||
|
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation,
|
||||||
|
QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
|
||||||
|
const qreal &length);
|
||||||
|
static VModelingShoulderPoint* Create(QSharedPointer<DialogShoulderPoint> &dialog,
|
||||||
|
VDomDocument *doc, VContainer *data);
|
||||||
|
static VModelingShoulderPoint* Create(const qint64 _id, const QString &formula, const qint64 &p1Line,
|
||||||
|
const qint64 &p2Line, const qint64 &pShoulder,
|
||||||
|
const QString &typeLine, const QString &pointName,
|
||||||
|
const qreal &mx, const qreal &my, VDomDocument *doc,
|
||||||
|
VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
private:
|
||||||
|
qint64 p2Line;
|
||||||
|
qint64 pShoulder;
|
||||||
|
QSharedPointer<DialogShoulderPoint> dialogShoulderPoint;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGSHOULDERPOINT_H
|
93
tools/modelingTools/vmodelingsinglepoint.cpp
Normal file
93
tools/modelingTools/vmodelingsinglepoint.cpp
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
#include "vmodelingsinglepoint.h"
|
||||||
|
#include <QPen>
|
||||||
|
#include <QBrush>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QGraphicsSceneContextMenuEvent>
|
||||||
|
#include <cmath>
|
||||||
|
#include "options.h"
|
||||||
|
#include "container/vpointf.h"
|
||||||
|
|
||||||
|
VModelingSinglePoint::VModelingSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
|
||||||
|
QGraphicsItem * parent ):VModelingPoint(doc, data, id, parent),
|
||||||
|
dialogSinglePoint(QSharedPointer<DialogSinglePoint>()){
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingSinglePoint::setDialog(){
|
||||||
|
Q_ASSERT(!dialogSinglePoint.isNull());
|
||||||
|
if(!dialogSinglePoint.isNull()){
|
||||||
|
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||||
|
dialogSinglePoint->setData(p.name(), p.toQPointF());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingSinglePoint::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "single");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "x", toMM(point.x()));
|
||||||
|
AddAttribute(domElement, "y", toMM(point.y()));
|
||||||
|
AddAttribute(domElement, "mx", toMM(point.mx()));
|
||||||
|
AddAttribute(domElement, "my", toMM(point.my()));
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant VModelingSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value){
|
||||||
|
if (change == ItemPositionChange && scene()) {
|
||||||
|
// value - это новое положение.
|
||||||
|
QPointF newPos = value.toPointF();
|
||||||
|
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())));
|
||||||
|
return newPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (change == ItemPositionHasChanged && scene()) {
|
||||||
|
// value - это новое положение.
|
||||||
|
QPointF newPos = value.toPointF();
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("x", QString().setNum(toMM(newPos.x())));
|
||||||
|
domElement.setAttribute("y", QString().setNum(toMM(newPos.y())));
|
||||||
|
//I don't now why but signal does not work.
|
||||||
|
doc->FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QGraphicsItem::itemChange(change, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ){
|
||||||
|
ContextMenu(dialogSinglePoint, this, event, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingSinglePoint::FullUpdateFromFile(){
|
||||||
|
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingSinglePoint::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QPointF p = dialogSinglePoint->getPoint();
|
||||||
|
QString name = dialogSinglePoint->getName();
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", name);
|
||||||
|
domElement.setAttribute("x", QString().setNum(toMM(p.x())));
|
||||||
|
domElement.setAttribute("y", QString().setNum(toMM(p.y())));
|
||||||
|
//I don't now why but signal does not work.
|
||||||
|
doc->FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogSinglePoint.clear();
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user