Add tool point of contact.

This commit is contained in:
dismine 2013-08-21 11:03:53 +03:00
parent 8f186148ba
commit 1c751891e2
27 changed files with 887 additions and 89 deletions

View File

@ -58,7 +58,9 @@ SOURCES += main.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 \
dialogs/dialogpointofcontact.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
widgets/vmaingraphicsscene.h \ widgets/vmaingraphicsscene.h \
@ -107,7 +109,9 @@ HEADERS += mainwindow.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 \
dialogs/dialogpointofcontact.h
FORMS += mainwindow.ui \ FORMS += mainwindow.ui \
dialogs/dialogsinglepoint.ui \ dialogs/dialogsinglepoint.ui \
@ -122,7 +126,8 @@ FORMS += mainwindow.ui \
dialogs/dialogspline.ui \ dialogs/dialogspline.ui \
dialogs/dialogarc.ui \ dialogs/dialogarc.ui \
dialogs/dialogsplinepath.ui \ dialogs/dialogsplinepath.ui \
dialogs/dialoghistory.ui dialogs/dialoghistory.ui \
dialogs/dialogpointofcontact.ui
RESOURCES += \ RESOURCES += \
icon.qrc \ icon.qrc \

View File

@ -12,7 +12,7 @@ qint64 VContainer::_id = 0;
VContainer::VContainer():base(QMap<QString, qint32>()), points(QMap<qint64, VPointF>()), VContainer::VContainer():base(QMap<QString, qint32>()), points(QMap<qint64, VPointF>()),
standartTable(QMap<QString, VStandartTableCell>()), incrementTable(QMap<QString, VIncrementTableRow>()), standartTable(QMap<QString, VStandartTableCell>()), incrementTable(QMap<QString, VIncrementTableRow>()),
lengthLines(QMap<QString, qreal>()), lineArcs(QMap<QString, qreal>()), splines(QMap<qint64, VSpline>()), lengthLines(QMap<QString, qreal>()), lineAngles(QMap<QString, qreal>()), splines(QMap<qint64, VSpline>()),
lengthSplines(QMap<QString, qreal>()), arcs(QMap<qint64, VArc>()), lengthArcs(QMap<QString, qreal>()), lengthSplines(QMap<QString, qreal>()), arcs(QMap<qint64, VArc>()), lengthArcs(QMap<QString, qreal>()),
splinePaths(QMap<qint64, VSplinePath>()){ splinePaths(QMap<qint64, VSplinePath>()){
SetSize(500); SetSize(500);
@ -31,7 +31,7 @@ void VContainer::setData(const VContainer &data){
standartTable = *data.DataStandartTable(); standartTable = *data.DataStandartTable();
incrementTable = *data.DataIncrementTable(); incrementTable = *data.DataIncrementTable();
lengthLines = *data.DataLengthLines(); lengthLines = *data.DataLengthLines();
lineArcs = *data.DataLengthArcs(); lineAngles = *data.DataLengthArcs();
splines = *data.DataSplines(); splines = *data.DataSplines();
lengthSplines = *data.DataLengthSplines(); lengthSplines = *data.DataLengthSplines();
arcs = *data.DataArcs(); arcs = *data.DataArcs();
@ -71,7 +71,7 @@ qreal VContainer::GetLine(const QString &name) const{
qreal VContainer::GetLineArc(const QString &name) const{ qreal VContainer::GetLineArc(const QString &name) const{
Q_ASSERT(!name.isEmpty()); Q_ASSERT(!name.isEmpty());
return GetObject(lineArcs, name); return GetObject(lineAngles, name);
} }
VSpline VContainer::GetSpline(qint64 id) const{ VSpline VContainer::GetSpline(qint64 id) const{
@ -157,9 +157,9 @@ void VContainer::AddLengthArc(const QString &name, const qreal &value){
lengthArcs[name] = value; lengthArcs[name] = value;
} }
void VContainer::AddLineArc(const QString &name, const qint32 &value){ void VContainer::AddLineAngle(const QString &name, const qreal &value){
Q_ASSERT(!name.isEmpty()); Q_ASSERT(!name.isEmpty());
lineArcs[name] = value; lineAngles[name] = value;
} }
qreal VContainer::GetValueStandartTableCell(const QString& name) const{ qreal VContainer::GetValueStandartTableCell(const QString& name) const{
@ -184,7 +184,7 @@ void VContainer::Clear(){
incrementTable.clear(); incrementTable.clear();
lengthLines.clear(); lengthLines.clear();
lengthArcs.clear(); lengthArcs.clear();
lineArcs.clear(); lineAngles.clear();
ClearObject(); ClearObject();
CreateManTableIGroup (); CreateManTableIGroup ();
} }
@ -211,8 +211,8 @@ void VContainer::ClearLengthArcs(){
lengthArcs.clear(); lengthArcs.clear();
} }
void VContainer::ClearLineArcs(){ void VContainer::ClearLineAngles(){
lineArcs.clear(); lineAngles.clear();
} }
void VContainer::SetSize(qint32 size){ void VContainer::SetSize(qint32 size){
@ -257,9 +257,9 @@ qreal VContainer::FindVar(const QString &name, bool *ok)const{
*ok = true; *ok = true;
return lengthArcs.value(name); return lengthArcs.value(name);
} }
if(lineArcs.contains(name)){ if(lineAngles.contains(name)){
*ok = true; *ok = true;
return lineArcs.value(name); return lineAngles.value(name);
} }
*ok = false; *ok = false;
return 0; return 0;
@ -301,8 +301,8 @@ const QMap<QString, qreal> *VContainer::DataLengthArcs() const{
return &lengthArcs; return &lengthArcs;
} }
const QMap<QString, qreal> *VContainer::DataLineArcs() const{ const QMap<QString, qreal> *VContainer::DataLineAngles() const{
return &lineArcs; return &lineAngles;
} }
const QMap<qint64, VSplinePath> *VContainer::DataSplinePaths() const{ const QMap<qint64, VSplinePath> *VContainer::DataSplinePaths() const{
@ -314,6 +314,8 @@ void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId
VPointF firstPoint = GetPoint(firstPointId); VPointF firstPoint = GetPoint(firstPointId);
VPointF secondPoint = GetPoint(secondPointId); VPointF secondPoint = GetPoint(secondPointId);
AddLengthLine(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).length()/PrintDPI*25.4); AddLengthLine(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).length()/PrintDPI*25.4);
nameLine = GetNameLineAngle(firstPointId, secondPointId);
AddLineAngle(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).angle());
} }
template <typename key, typename val> template <typename key, typename val>
@ -345,10 +347,10 @@ QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPo
return QString("Line_%1_%2").arg(first.name(), second.name()); return QString("Line_%1_%2").arg(first.name(), second.name());
} }
QString VContainer::GetNameLineArc(const qint64 &firstPoint, const qint64 &secondPoint) const{ QString VContainer::GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint) const{
VPointF first = GetPoint(firstPoint); VPointF first = GetPoint(firstPoint);
VPointF second = GetPoint(secondPoint); VPointF second = GetPoint(secondPoint);
return QString("ArcLine_%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) const{

View File

@ -50,13 +50,13 @@ public:
void AddLengthSpline(const QString &name, const qreal &value); void AddLengthSpline(const QString &name, const qreal &value);
void AddLengthArc(const qint64 &center, const qint64 &id); void AddLengthArc(const qint64 &center, const qint64 &id);
void AddLengthArc(const QString &name, const qreal &value); void AddLengthArc(const QString &name, const qreal &value);
void AddLineArc(const QString &name, const qint32 &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);
qint64 AddSpline(const VSpline& spl); qint64 AddSpline(const VSpline& spl);
qint64 AddSplinePath(const VSplinePath& splPath); qint64 AddSplinePath(const VSplinePath& splPath);
qint64 AddArc(const VArc& arc); qint64 AddArc(const VArc& arc);
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const; QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const;
QString GetNameLineArc(const qint64 &firstPoint, const qint64 &secondPoint) const; QString GetNameLineAngle(const qint64 &firstPoint, const qint64 &secondPoint) const;
QString GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint) const; QString GetNameSpline(const qint64 &firstPoint, const qint64 &secondPoint) const;
QString GetNameSplinePath(const VSplinePath &path) const; QString GetNameSplinePath(const VSplinePath &path) const;
QString GetNameArc(const qint64 &center, const qint64 &id) const; QString GetNameArc(const qint64 &center, const qint64 &id) const;
@ -74,7 +74,7 @@ public:
void ClearLengthLines(); void ClearLengthLines();
void ClearLengthSplines(); void ClearLengthSplines();
void ClearLengthArcs(); void ClearLengthArcs();
void ClearLineArcs(); void ClearLineAngles();
void SetSize(qint32 size); void SetSize(qint32 size);
void SetGrowth(qint32 growth); void SetGrowth(qint32 growth);
qint32 size() const; qint32 size() const;
@ -92,7 +92,7 @@ public:
const QMap<QString, qreal> *DataLengthLines() const; const QMap<QString, qreal> *DataLengthLines() const;
const QMap<QString, qreal> *DataLengthSplines() const; const QMap<QString, qreal> *DataLengthSplines() const;
const QMap<QString, qreal> *DataLengthArcs() const; const QMap<QString, qreal> *DataLengthArcs() const;
const QMap<QString, qreal> *DataLineArcs() const; const QMap<QString, qreal> *DataLineAngles() const;
const QMap<qint64, VSplinePath> *DataSplinePaths() const; const QMap<qint64, VSplinePath> *DataSplinePaths() const;
void UpdateId(qint64 newId); void UpdateId(qint64 newId);
private: private:
@ -102,7 +102,7 @@ private:
QMap<QString, VStandartTableCell> standartTable; QMap<QString, VStandartTableCell> standartTable;
QMap<QString, VIncrementTableRow> incrementTable; QMap<QString, VIncrementTableRow> incrementTable;
QMap<QString, qreal> lengthLines; QMap<QString, qreal> lengthLines;
QMap<QString, qreal> lineArcs; QMap<QString, qreal> lineAngles;
QMap<qint64, VSpline> splines; QMap<qint64, VSpline> splines;
QMap<QString, qreal> lengthSplines; QMap<QString, qreal> lengthSplines;
QMap<qint64, VArc> arcs; QMap<qint64, VArc> arcs;

View File

@ -10,5 +10,6 @@
<file>cursor/spline_cursor.png</file> <file>cursor/spline_cursor.png</file>
<file>cursor/arc_cursor.png</file> <file>cursor/arc_cursor.png</file>
<file>cursor/splinepath_cursor.png</file> <file>cursor/splinepath_cursor.png</file>
<file>cursor/pointcontact_cursor.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -34,7 +34,7 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent) :
connect(ui->toolButtonPutHereRadius, &QPushButton::clicked, this, &DialogArc::PutRadius); connect(ui->toolButtonPutHereRadius, &QPushButton::clicked, this, &DialogArc::PutRadius);
connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1); connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1);
connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1); connect(ui->toolButtonPutHereF2, &QPushButton::clicked, this, &DialogArc::PutF2);
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
ShowVariable(data->DataBase()); ShowVariable(data->DataBase());
@ -42,7 +42,7 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent) :
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogArc::StandartTable); connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogArc::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogArc::Increments); connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogArc::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogArc::LengthLines); connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogArc::LengthLines);
connect(ui->radioButtonLineArcs, &QRadioButton::clicked, this, &DialogArc::LineArcs); connect(ui->radioButtonLineAngles, &QRadioButton::clicked, this, &DialogArc::LineArcs);
connect(ui->toolButtonEqualRadius, &QPushButton::clicked, this, &DialogArc::EvalRadius); connect(ui->toolButtonEqualRadius, &QPushButton::clicked, this, &DialogArc::EvalRadius);
connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF1); connect(ui->toolButtonEqualF1, &QPushButton::clicked, this, &DialogArc::EvalF1);
@ -114,7 +114,7 @@ void DialogArc::ValChenged(int row){
return; return;
} }
QListWidgetItem *item = ui->listWidget->item( row ); QListWidgetItem *item = ui->listWidget->item( row );
if(ui->radioButtonLineArcs->isChecked()){ if(ui->radioButtonLineAngles->isChecked()){
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLineArc(item->text())) QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLineArc(item->text()))
.arg("Значення кута лінії."); .arg("Значення кута лінії.");
ui->labelDescription->setText(desc); ui->labelDescription->setText(desc);
@ -172,7 +172,7 @@ void DialogArc::ShowLineArcs(){
disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); disconnect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
ui->listWidget->clear(); ui->listWidget->clear();
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogArc::ValChenged);
const QMap<QString, qreal> *lineArcsTable = data->DataLineArcs(); const QMap<QString, qreal> *lineArcsTable = data->DataLineAngles();
QMapIterator<QString, qreal> i(*lineArcsTable); QMapIterator<QString, qreal> i(*lineArcsTable);
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();

View File

@ -342,7 +342,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButtonLineArcs"> <widget class="QRadioButton" name="radioButtonLineAngles">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>

View File

@ -1,5 +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 "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, QWidget *parent) :
DialogTool(data, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()), p1Line1(0), DialogTool(data, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()), p1Line1(0),

View File

@ -1,7 +1,13 @@
#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;

View File

@ -1,6 +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 "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, QWidget *parent) :
DialogTool(data, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), typeLine(QString()), DialogTool(data, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), typeLine(QString()),

View File

@ -1,11 +1,16 @@
#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"

View File

@ -0,0 +1,129 @@
#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"
#pragma GCC diagnostic pop
DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *parent) :
DialogTool(data, parent){
ui.setupUi(this);
number = 0;
listWidget = ui.listWidget;
labelResultCalculation = ui.labelResultCalculation;
labelDescription = ui.labelDescription;
radioButtonSizeGrowth = ui.radioButtonSizeGrowth;
radioButtonStandartTable = ui.radioButtonStandartTable;
radioButtonIncrements = ui.radioButtonIncrements;
radioButtonLengthLine = ui.radioButtonLengthLine;
lineEditFormula = ui.lineEditFormula;
flagFormula = false;
bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogPointOfContact::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogPointOfContact::DialogRejected);
FillComboBoxPoints(ui.comboBoxCenter);
FillComboBoxPoints(ui.comboBoxFirstPoint);
FillComboBoxPoints(ui.comboBoxSecondPoint);
connect(ui.toolButtonPutHere, &QPushButton::clicked, this, &DialogPointOfContact::PutHere);
connect(ui.listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal);
connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogPointOfContact::ValChenged);
ShowVariable(data->DataBase());
connect(ui.radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogPointOfContact::SizeGrowth);
connect(ui.radioButtonStandartTable, &QRadioButton::clicked, this, &DialogPointOfContact::StandartTable);
connect(ui.radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments);
connect(ui.radioButtonLengthLine, &QRadioButton::clicked, this, &DialogPointOfContact::LengthLines);
connect(ui.toolButtonEqual, &QPushButton::clicked, this, &DialogPointOfContact::EvalFormula);
connect(ui.lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged);
connect(ui.lineEditFormula, &QLineEdit::textChanged, this, &DialogPointOfContact::FormulaChanged);
}
void DialogPointOfContact::ChoosedObject(qint64 id, Scene::Type type){
if(type == Scene::Point){
VPointF point = data->GetPoint(id);
if(number == 0){
qint32 index = ui.comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found
ui.comboBoxFirstPoint->setCurrentIndex(index);
number++;
return;
}
}
if(number == 1){
qint32 index = ui.comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found
ui.comboBoxSecondPoint->setCurrentIndex(index);
number++;
return;
}
}
if(number == 2){
qint32 index = ui.comboBoxCenter->findText(point.name());
if ( index != -1 ) { // -1 for not found
ui.comboBoxCenter->setCurrentIndex(index);
number = 0;
}
if(!isInitialized){
this->show();
}
}
}
}
void DialogPointOfContact::DialogAccepted(){
pointName = ui.lineEditNamePoint->text();
radius = ui.lineEditFormula->text();
center = getCurrentPointId(ui.comboBoxCenter);
firstPoint = getCurrentPointId(ui.comboBoxFirstPoint);
secondPoint = getCurrentPointId(ui.comboBoxSecondPoint);
emit DialogClosed(QDialog::Accepted);
}
qint64 DialogPointOfContact::getSecondPoint() const{
return secondPoint;
}
void DialogPointOfContact::setSecondPoint(const qint64 &value, const qint64 &id){
setCurrentPointId(ui.comboBoxSecondPoint, secondPoint, value, id);
}
qint64 DialogPointOfContact::getFirstPoint() const{
return firstPoint;
}
void DialogPointOfContact::setFirstPoint(const qint64 &value, const qint64 &id){
setCurrentPointId(ui.comboBoxFirstPoint, firstPoint, value, id);
}
qint64 DialogPointOfContact::getCenter() const{
return center;
}
void DialogPointOfContact::setCenter(const qint64 &value, const qint64 &id){
setCurrentPointId(ui.comboBoxCenter, center, value, id);
center = value;
}
QString DialogPointOfContact::getRadius() const{
return radius;
}
void DialogPointOfContact::setRadius(const QString &value){
radius = value;
ui.lineEditFormula->setText(radius);
}
QString DialogPointOfContact::getPointName() const{
return pointName;
}
void DialogPointOfContact::setPointName(const QString &value){
pointName = value;
ui.lineEditNamePoint->setText(pointName);
}

View File

@ -0,0 +1,52 @@
#ifndef 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 "dialogtool.h"
#pragma GCC diagnostic pop
#include "../options.h"
#include "../container/vcontainer.h"
#include "../container/calculator.h"
class DialogPointOfContact : public DialogTool
{
Q_OBJECT
public:
explicit DialogPointOfContact(const VContainer *data, QWidget *parent = 0);
QString getPointName() const;
void setPointName(const QString &value);
QString getRadius() const;
void setRadius(const QString &value);
qint64 getCenter() const;
void setCenter(const qint64 &value, const qint64 &id);
qint64 getFirstPoint() const;
void setFirstPoint(const qint64 &value, const qint64 &id);
qint64 getSecondPoint() const;
void setSecondPoint(const qint64 &value, const qint64 &id);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type);
virtual void DialogAccepted();
private:
Ui::DialogPointOfContact ui;
qint32 number;
QString pointName;
QString radius;
qint64 center;
qint64 firstPoint;
qint64 secondPoint;
DialogPointOfContact(const DialogPointOfContact &dialog);
const DialogPointOfContact &operator=(const DialogPointOfContact& dialog);
};
#endif // DIALOGPOINTOFCONTACT_H

View File

@ -0,0 +1,348 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogPointOfContact</class>
<widget class="QDialog" name="DialogPointOfContact">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>476</width>
<height>450</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Радіус</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonEqual">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../icon.qrc">
<normaloff>:/icon/24x24/equal.png</normaloff>:/icon/24x24/equal.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResultCalculation">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ім'я нової точки</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
<item>
<widget class="QToolButton" name="toolButtonPutHere">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../icon.qrc">
<normaloff>:/icon/24x24/putHere.png</normaloff>:/icon/24x24/putHere.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Центр дуги</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxCenter">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>145</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Початок лінії</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxFirstPoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>143</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Кінець лінії</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxSecondPoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>145</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Вхідні данні</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="text">
<string>Розмір і зріст</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandartTable">
<property name="text">
<string>Стандартна таблиця</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="text">
<string>Прибавки</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Довжини ліній</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Довжини дуг</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Довжини сплайні</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelDescription">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogPointOfContact</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogPointOfContact</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,5 +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 "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, QWidget *parent) :
DialogTool(data, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()), DialogTool(data, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),

View File

@ -1,7 +1,13 @@
#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"

View File

@ -30,5 +30,6 @@
<file>icon/32x32/splinePath.png</file> <file>icon/32x32/splinePath.png</file>
<file>icon/32x32/history.png</file> <file>icon/32x32/history.png</file>
<file>icon/32x32/put_after.png</file> <file>icon/32x32/put_after.png</file>
<file>icon/32x32/point_of_contact.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 B

View File

@ -23,6 +23,7 @@
#include "tools/vtoolspline.h" #include "tools/vtoolspline.h"
#include "tools/vtoolarc.h" #include "tools/vtoolarc.h"
#include "tools/vtoolsplinepath.h" #include "tools/vtoolsplinepath.h"
#include "tools/vtoolpointofcontact.h"
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#include "geometry/vspline.h" #include "geometry/vspline.h"
@ -36,7 +37,8 @@ MainWindow::MainWindow(QWidget *parent) :
dialogLineIntersect(QSharedPointer<DialogLineIntersect>()), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()),
dialogSpline(QSharedPointer<DialogSpline>()), dialogSpline(QSharedPointer<DialogSpline>()),
dialogArc(QSharedPointer<DialogArc>()), dialogSplinePath(QSharedPointer<DialogSplinePath>()), dialogArc(QSharedPointer<DialogArc>()), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false){ dialogPointOfContact(QSharedPointer<DialogPointOfContact>()), dialogHistory(0),
doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false){
ui->setupUi(this); ui->setupUi(this);
ToolBarOption(); ToolBarOption();
ToolBarDraws(); ToolBarDraws();
@ -74,6 +76,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->toolButtonSpline, &QToolButton::clicked, this, &MainWindow::ToolSpline); connect(ui->toolButtonSpline, &QToolButton::clicked, this, &MainWindow::ToolSpline);
connect(ui->toolButtonArc, &QToolButton::clicked, this, &MainWindow::ToolArc); connect(ui->toolButtonArc, &QToolButton::clicked, this, &MainWindow::ToolArc);
connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath); connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath);
connect(ui->toolButtonPointOfContact, &QToolButton::clicked, this, &MainWindow::ToolPointOfContact);
data = new VContainer; data = new VContainer;
@ -317,6 +320,18 @@ void MainWindow::ClosedDialogSplinePath(int result){
ArrowTool(); ArrowTool();
} }
void MainWindow::ToolPointOfContact(bool checked){
SetToolButton(checked, Tools::PointOfContact, ":/cursor/pointcontact_cursor.png", dialogPointOfContact,
&MainWindow::ClosedDialogPointOfContact);
}
void MainWindow::ClosedDialogPointOfContact(int result){
if(result == QDialog::Accepted){
VToolPointOfContact::Create(dialogPointOfContact, scene, doc, data);
}
ArrowTool();
}
void MainWindow::showEvent( QShowEvent *event ){ void MainWindow::showEvent( QShowEvent *event ){
QMainWindow::showEvent( event ); QMainWindow::showEvent( event );
if( event->spontaneous() ){ if( event->spontaneous() ){
@ -479,6 +494,12 @@ void MainWindow::CanselTool(){
scene->setFocus(Qt::OtherFocusReason); scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection(); scene->clearSelection();
break; break;
case Tools::PointOfContact:
dialogPointOfContact.clear();
ui->toolButtonPointOfContact->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
break;
} }
} }
@ -685,6 +706,7 @@ void MainWindow::SetEnableTool(bool enable){
ui->toolButtonSpline->setEnabled(enable); ui->toolButtonSpline->setEnabled(enable);
ui->toolButtonArc->setEnabled(enable); ui->toolButtonArc->setEnabled(enable);
ui->toolButtonSplinePath->setEnabled(enable); ui->toolButtonSplinePath->setEnabled(enable);
ui->toolButtonPointOfContact->setEnabled(enable);
} }
MainWindow::~MainWindow(){ MainWindow::~MainWindow(){

View File

@ -28,6 +28,7 @@
#include "dialogs/dialogarc.h" #include "dialogs/dialogarc.h"
#include "dialogs/dialogsplinepath.h" #include "dialogs/dialogsplinepath.h"
#include "dialogs/dialoghistory.h" #include "dialogs/dialoghistory.h"
#include "dialogs/dialogpointofcontact.h"
#include "tools/vtoolsinglepoint.h" #include "tools/vtoolsinglepoint.h"
#include "xml/vdomdocument.h" #include "xml/vdomdocument.h"
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
@ -83,6 +84,8 @@ public slots:
void ClosedDialogArc(int result); void ClosedDialogArc(int result);
void ToolSplinePath(bool checked); void ToolSplinePath(bool checked);
void ClosedDialogSplinePath(int result); void ClosedDialogSplinePath(int result);
void ToolPointOfContact(bool checked);
void ClosedDialogPointOfContact(int result);
protected: protected:
virtual void keyPressEvent ( QKeyEvent * event ); virtual void keyPressEvent ( QKeyEvent * event );
virtual void showEvent( QShowEvent *event ); virtual void showEvent( QShowEvent *event );
@ -105,6 +108,7 @@ private:
QSharedPointer<DialogSpline> dialogSpline; QSharedPointer<DialogSpline> dialogSpline;
QSharedPointer<DialogArc> dialogArc; QSharedPointer<DialogArc> dialogArc;
QSharedPointer<DialogSplinePath> dialogSplinePath; QSharedPointer<DialogSplinePath> dialogSplinePath;
QSharedPointer<DialogPointOfContact> dialogPointOfContact;
DialogHistory *dialogHistory; DialogHistory *dialogHistory;
VDomDocument *doc; VDomDocument *doc;
VContainer *data; VContainer *data;

View File

@ -166,6 +166,29 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2">
<widget class="QToolButton" name="toolButtonPointOfContact">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<normaloff>:/icon/32x32/point_of_contact.png</normaloff>:/icon/32x32/point_of_contact.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="page_2"> <widget class="QWidget" name="page_2">
@ -173,7 +196,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>100</width> <width>150</width>
<height>58</height> <height>58</height>
</rect> </rect>
</property> </property>
@ -240,7 +263,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>100</width> <width>150</width>
<height>58</height> <height>58</height>
</rect> </rect>
</property> </property>
@ -307,7 +330,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>87</width> <width>150</width>
<height>58</height> <height>58</height>
</rect> </rect>
</property> </property>

View File

@ -31,7 +31,8 @@ namespace Tools{
LineIntersectTool, LineIntersectTool,
SplineTool, SplineTool,
ArcTool, ArcTool,
SplinePathTool SplinePathTool,
PointOfContact
}; };
} }

View File

@ -0,0 +1,146 @@
#include "vtoolpointofcontact.h"
VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &radius, const qint64 &center,
const qint64 &firstPointId, const qint64 &secondPointId,
Tool::Enum typeCreation, QGraphicsItem *parent)
: VToolPoint(doc, data, id, parent), radius(radius), center(center), firstPointId(firstPointId),
secondPointId(secondPointId), dialogPointOfContact(QSharedPointer<DialogPointOfContact>()){
if(typeCreation == Tool::FromGui){
AddToFile();
}
}
void VToolPointOfContact::setDialog(){
Q_ASSERT(!dialogPointOfContact.isNull());
if(!dialogPointOfContact.isNull()){
VPointF p = VAbstractTool::data.GetPoint(id);
dialogPointOfContact->setRadius(radius);
dialogPointOfContact->setCenter(center, id);
dialogPointOfContact->setFirstPoint(firstPointId, id);
dialogPointOfContact->setSecondPoint(secondPointId, id);
dialogPointOfContact->setPointName(p.name());
}
}
QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF &center, 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;
}
void VToolPointOfContact::Create(QSharedPointer<DialogPointOfContact> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){
QString radius = dialog->getRadius();
qint64 center = dialog->getCenter();
qint64 firstPointId = dialog->getFirstPoint();
qint64 secondPointId = dialog->getSecondPoint();
QString pointName = dialog->getPointName();
Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data,
Document::FullParse, Tool::FromGui);
}
void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const qint64 &center,
const qint64 &firstPointId, const qint64 &secondPointId,
const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
Document::Enum parse, Tool::Enum typeCreation){
VPointF centerP = data->GetPoint(center);
VPointF firstP = data->GetPoint(firstPointId);
VPointF secondP = data->GetPoint(secondPointId);
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(radius, &errorMsg);
if(errorMsg.isEmpty()){
QPointF fPoint = VToolPointOfContact::FindPoint(result*PrintDPI/25.4, centerP.toQPointF(),
firstP.toQPointF(), secondP.toQPointF());
qint64 id = _id;
if(typeCreation == Tool::FromGui){
id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
} else {
data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
tool->VDataTool::setData(data);
tools->insert(id, tool);
}
}
VAbstractTool::AddRecord(id, Tools::PointOfContact, doc);
if(parse == Document::FullParse){
VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center,
firstPointId, secondPointId, typeCreation);
scene->addItem(point);
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id,point);
}
}
}
void VToolPointOfContact::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();
}
RefreshGeometry();
}
void VToolPointOfContact::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 VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
ContextMenu(dialogPointOfContact, this, event);
}
void VToolPointOfContact::AddToFile(){
VPointF point = VAbstractTool::data.GetPoint(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);
AddToCalculation(domElement);
}

View File

@ -0,0 +1,36 @@
#ifndef VTOOLPOINTOFCONTACT_H
#define VTOOLPOINTOFCONTACT_H
#include "vtoolpoint.h"
#include "../dialogs/dialogpointofcontact.h"
class VToolPointOfContact : public VToolPoint
{
public:
VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &radius, const qint64 &center, const qint64 &firstPointId,
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog();
static QPointF FindPoint(const qreal &radius, const QPointF &center, const QPointF &firstPoint,
const QPointF &secondPoint);
static void Create(QSharedPointer<DialogPointOfContact> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data);
static void Create(const qint64 _id, const QString &radius, const qint64 &center, const qint64 &firstPointId,
const qint64 &secondPointId, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, 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 // VTOOLPOINTOFCONTACT_H

View File

@ -102,8 +102,8 @@ void VToolSplinePath::FullUpdateFromGui(int result){
spl = VSpline (VAbstractTool::data.DataPoints(), spl.GetP1(), controlPoints[j-2]->pos(), spl = VSpline (VAbstractTool::data.DataPoints(), spl.GetP1(), controlPoints[j-2]->pos(),
controlPoints[j-1]->pos(), spl.GetP4(), splPath.getKCurve()); controlPoints[j-1]->pos(), spl.GetP4(), splPath.getKCurve());
CorectControlPoints(spl, splPath, i-1, i, SplinePoint::FirstPoint); CorectControlPoints(spl, splPath, i);
CorectControlPoints(spl, splPath, i, i, SplinePoint::LastPoint); CorectControlPoints(spl, splPath, i);
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if(domElement.isElement()){
@ -118,20 +118,16 @@ void VToolSplinePath::FullUpdateFromGui(int result){
} }
void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position, void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position,
const QPointF pos) const QPointF pos){
{
qint32 index = 0;
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id); VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
VSpline spl = splPath.GetSpline(indexSpline); VSpline spl = splPath.GetSpline(indexSpline);
if(position == SplinePoint::FirstPoint){ if(position == SplinePoint::FirstPoint){
spl.ModifiSpl (spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve()); spl.ModifiSpl (spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve());
index = indexSpline - 1;
} else { } else {
spl.ModifiSpl (spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve()); spl.ModifiSpl (spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve());
index = indexSpline;
} }
CorectControlPoints(spl, splPath, index, indexSpline, position); CorectControlPoints(spl, splPath, indexSpline);
QDomElement domElement = doc->elementById(QString().setNum(id)); QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){ if(domElement.isElement()){
domElement.setAttribute("kCurve", QString().setNum(splPath.getKCurve())); domElement.setAttribute("kCurve", QString().setNum(splPath.getKCurve()));
@ -140,8 +136,8 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, Spli
} }
} }
void VToolSplinePath::CorectControlPoints(const VSpline &spl, VSplinePath &splPath, qint32 index, void VToolSplinePath::CorectControlPoints(const VSpline &spl, VSplinePath &splPath,
const qint32 &indexSpline, SplinePoint::Position position){ const qint32 &indexSpline){
VSplinePoint p = splPath.GetSplinePoint(indexSpline, SplinePoint::FirstPoint); VSplinePoint p = splPath.GetSplinePoint(indexSpline, SplinePoint::FirstPoint);
p.SetAngle(spl.GetAngle1()); p.SetAngle(spl.GetAngle1());
p.SetKAsm2(spl.GetKasm1()); p.SetKAsm2(spl.GetKasm1());
@ -151,26 +147,6 @@ void VToolSplinePath::CorectControlPoints(const VSpline &spl, VSplinePath &splPa
p.SetAngle(spl.GetAngle2()-180); p.SetAngle(spl.GetAngle2()-180);
p.SetKAsm1(spl.GetKasm2()); p.SetKAsm1(spl.GetKasm2());
splPath.UpdatePoint(indexSpline, SplinePoint::LastPoint, p); splPath.UpdatePoint(indexSpline, SplinePoint::LastPoint, p);
if(index > 0 && index < splPath.CountPoint()-1){
if(position == SplinePoint::FirstPoint){
VSpline spl = splPath.GetSpline(indexSpline-1);
qint32 i = (indexSpline-1)*2-1;
disconnect(controlPoints[i], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
controlPoints[i]->setPos(spl.GetP3());
connect(controlPoints[i], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
} else {
VSpline spl = splPath.GetSpline(indexSpline+1);
qint32 i = (indexSpline+1)*2-2;
disconnect(controlPoints[i], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
controlPoints[i]->setPos(spl.GetP2());
connect(controlPoints[i], &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
}
}
} }
void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path){ void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path){
@ -271,10 +247,10 @@ void VToolSplinePath::RefreshGeometry(){
this->setPath(path); this->setPath(path);
for(qint32 i = 1; i<=splPath.Count(); ++i){ for(qint32 i = 1; i<=splPath.Count(); ++i){
VSpline spl = splPath.GetSpline(i); VSpline spl = splPath.GetSpline(i);
QPointF splinePoint = VAbstractTool::data.GetPoint(spl.GetP1()).toQPointF(); QPointF splinePoint = spl.GetPointP1().toQPointF();
QPointF controlPoint = spl.GetP2(); QPointF controlPoint = spl.GetP2();
emit RefreshLine(i, SplinePoint::FirstPoint, controlPoint, splinePoint); emit RefreshLine(i, SplinePoint::FirstPoint, controlPoint, splinePoint);
splinePoint = VAbstractTool::data.GetPoint(spl.GetP4()).toQPointF(); splinePoint = spl.GetPointP4().toQPointF();
controlPoint = spl.GetP3(); controlPoint = spl.GetP3();
emit RefreshLine(i, SplinePoint::LastPoint, controlPoint, splinePoint); emit RefreshLine(i, SplinePoint::LastPoint, controlPoint, splinePoint);

View File

@ -49,9 +49,8 @@ private:
void RefreshGeometry(); void RefreshGeometry();
void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint); void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint);
void UpdatePathPoint(QDomNode& node, VSplinePath &path); void UpdatePathPoint(QDomNode& node, VSplinePath &path);
void CorectControlPoints(const VSpline &spl, VSplinePath &splPath, qint32 index, void CorectControlPoints(const VSpline &spl, VSplinePath &splPath,
const qint32 &indexSpline, const qint32 &indexSpline);
SplinePoint::Position position);
}; };
#endif // VTOOLSPLINEPATH_H #endif // VTOOLSPLINEPATH_H

View File

@ -16,6 +16,7 @@
#include "../tools/vtoolspline.h" #include "../tools/vtoolspline.h"
#include "../tools/vtoolarc.h" #include "../tools/vtoolarc.h"
#include "../tools/vtoolsplinepath.h" #include "../tools/vtoolsplinepath.h"
#include "../tools/vtoolpointofcontact.h"
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#include "../options.h" #include "../options.h"
#include "../container/calculator.h" #include "../container/calculator.h"
@ -242,7 +243,7 @@ void VDomDocument::Parse(Document::Enum parse, VMainGraphicsScene *scene){
data->ClearLengthLines(); data->ClearLengthLines();
data->ClearLengthArcs(); data->ClearLengthArcs();
data->ClearLengthSplines(); data->ClearLengthSplines();
data->ClearLineArcs(); data->ClearLineAngles();
history.clear(); history.clear();
QDomElement rootElement = this->documentElement(); QDomElement rootElement = this->documentElement();
QDomNode domNode = rootElement.firstChild(); QDomNode domNode = rootElement.firstChild();
@ -477,6 +478,21 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
} }
return; return;
} }
if(type == "pointOfContact"){
if(!domElement.isNull()){
qint64 id = domElement.attribute("id", "").toLongLong();
QString name = domElement.attribute("name", "");
qreal mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4;
qreal my = domElement.attribute("my","").toDouble()*PrintDPI/25.4;
QString radius = domElement.attribute("radius", "");
qint64 center = domElement.attribute("center", "").toLongLong();
qint64 firstPointId = domElement.attribute("firstPoint", "").toLongLong();
qint64 secondPointId = domElement.attribute("secondPoint", "").toLongLong();
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my,
scene, this, data, parse, Tool::FromFile);
}
return;
}
} }
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement, void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
@ -527,7 +543,7 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
} }
} }
} }
VToolSplinePath::Create(id, path, scene, this, data, Document::FullParse, Tool::FromFile); VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile);
} }
return; return;
} }
@ -576,6 +592,7 @@ void VDomDocument::setCursor(const qint64 &value){
void VDomDocument::setCurrentData(){ void VDomDocument::setCurrentData(){
QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex());
if(nameActivDraw != nameDraw){
nameActivDraw = nameDraw; nameActivDraw = nameDraw;
qint64 id = 0; qint64 id = 0;
if(history.size() == 0){ if(history.size() == 0){
@ -598,4 +615,5 @@ void VDomDocument::setCurrentData(){
VDataTool *vTool = tools.value(id); VDataTool *vTool = tools.value(id);
data->setData(vTool->getData()); data->setData(vTool->getData());
} }
}
} }