Add class VDetail.

This commit is contained in:
dismine 2013-08-28 11:55:11 +03:00
parent 1c751891e2
commit 51a17f453d
71 changed files with 2468 additions and 360 deletions

View File

@ -60,7 +60,15 @@ SOURCES += main.cpp\
xml/vtoolrecord.cpp \
dialogs/dialoghistory.cpp \
tools/vtoolpointofcontact.cpp \
dialogs/dialogpointofcontact.cpp
dialogs/dialogpointofcontact.cpp \
geometry/vnodedetail.cpp \
geometry/vdetail.cpp \
dialogs/dialogdetail.cpp \
tools/vtooldetail.cpp \
tools/vmodelingpoint.cpp \
tools/vmodelingspline.cpp \
tools/vmodelingarc.cpp \
tools/vmodelingsplinepath.cpp
HEADERS += mainwindow.h \
widgets/vmaingraphicsscene.h \
@ -111,7 +119,15 @@ HEADERS += mainwindow.h \
xml/vtoolrecord.h \
dialogs/dialoghistory.h \
tools/vtoolpointofcontact.h \
dialogs/dialogpointofcontact.h
dialogs/dialogpointofcontact.h \
geometry/vnodedetail.h \
geometry/vdetail.h \
dialogs/dialogdetail.h \
tools/vtooldetail.h \
tools/vmodelingpoint.h \
tools/vmodelingspline.h \
tools/vmodelingarc.h \
tools/vmodelingsplinepath.h
FORMS += mainwindow.ui \
dialogs/dialogsinglepoint.ui \
@ -127,7 +143,8 @@ FORMS += mainwindow.ui \
dialogs/dialogarc.ui \
dialogs/dialogsplinepath.ui \
dialogs/dialoghistory.ui \
dialogs/dialogpointofcontact.ui
dialogs/dialogpointofcontact.ui \
dialogs/dialogdetail.ui
RESOURCES += \
icon.qrc \

View File

@ -11,10 +11,14 @@
qint64 VContainer::_id = 0;
VContainer::VContainer():base(QMap<QString, qint32>()), points(QMap<qint64, VPointF>()),
modelingPoints(QMap<qint64, VPointF>()),
standartTable(QMap<QString, VStandartTableCell>()), incrementTable(QMap<QString, VIncrementTableRow>()),
lengthLines(QMap<QString, qreal>()), lineAngles(QMap<QString, qreal>()), splines(QMap<qint64, VSpline>()),
lengthSplines(QMap<QString, qreal>()), arcs(QMap<qint64, VArc>()), lengthArcs(QMap<QString, qreal>()),
splinePaths(QMap<qint64, VSplinePath>()){
modelingSplines(QMap<qint64, VSpline>()),
lengthSplines(QMap<QString, qreal>()), arcs(QMap<qint64, VArc>()), modelingArcs(QMap<qint64, VArc>()),
lengthArcs(QMap<QString, qreal>()),
splinePaths(QMap<qint64, VSplinePath>()), modelingSplinePaths(QMap<qint64, VSplinePath>()),
details(QMap<qint64, VDetail>()){
SetSize(500);
SetGrowth(1760);
CreateManTableIGroup ();
@ -28,15 +32,20 @@ const VContainer &VContainer::operator =(const VContainer &data){
void VContainer::setData(const VContainer &data){
base = *data.DataBase();
points = *data.DataPoints();
modelingPoints = *data.DataModelingPoints();
standartTable = *data.DataStandartTable();
incrementTable = *data.DataIncrementTable();
lengthLines = *data.DataLengthLines();
lineAngles = *data.DataLengthArcs();
splines = *data.DataSplines();
modelingSplines = *data.DataModelingSplines();
lengthSplines = *data.DataLengthSplines();
arcs = *data.DataArcs();
modelingArcs = *data.DataModelingArcs();
lengthArcs = *data.DataLengthArcs();
splinePaths = *data.DataSplinePaths();
modelingSplinePaths = *data.DataModelingSplinePaths();
details = *data.DataDetails();
}
template <typename key, typename val>
@ -54,6 +63,10 @@ VPointF VContainer::GetPoint(qint64 id) const{
return GetObject(points, id);
}
VPointF VContainer::GetModelingPoint(qint64 id) const{
return GetObject(modelingPoints, id);
}
VStandartTableCell VContainer::GetStandartTableCell(const QString &name) const{
Q_ASSERT(!name.isEmpty());
return GetObject(standartTable, name);
@ -78,14 +91,30 @@ VSpline VContainer::GetSpline(qint64 id) const{
return GetObject(splines, id);
}
VSpline VContainer::GetModelingSpline(qint64 id) const{
return GetObject(modelingSplines, id);
}
VArc VContainer::GetArc(qint64 id) const{
return GetObject(arcs, id);
}
VArc VContainer::GetModelingArc(qint64 id) const{
return GetObject(modelingArcs, id);
}
VSplinePath VContainer::GetSplinePath(qint64 id) const{
return GetObject(splinePaths, id);
}
VSplinePath VContainer::GetModelingSplinePath(qint64 id) const{
return GetObject(modelingSplinePaths, id);
}
VDetail VContainer::GetDetail(qint64 id) const{
return GetObject(details, id);
}
void VContainer::AddStandartTableCell(const QString& name, const VStandartTableCell& cell){
standartTable[name] = cell;
}
@ -109,6 +138,37 @@ void VContainer::UpdateId(qint64 newId){
}
}
void VContainer::IncrementReferens(qint64 id, Scene::Type obj){
switch( obj ){
case(Scene::Line):
break;
case(Scene::Point):{
VPointF point = GetPoint(id);
point.incrementReferens();
UpdatePoint(id, point);
}
break;
case(Scene::Arc):{
VArc arc = GetArc(id);
arc.incrementReferens();
UpdateArc(id, arc);
}
break;
case(Scene::Spline):{
VSpline spl = GetSpline(id);
spl.incrementReferens();
UpdateSpline(id, spl);
}
break;
case(Scene::SplinePath):{
VSplinePath splPath = GetSplinePath(id);
splPath.incrementReferens();
UpdateSplinePath(id, splPath);
}
break;
}
}
void VContainer::RemoveIncrementTableRow(const QString& name){
incrementTable.remove(name);
}
@ -123,18 +183,38 @@ void VContainer::UpdatePoint(qint64 id, const VPointF& point){
UpdateObject(points, id, point);
}
void VContainer::UpdateModelingPoint(qint64 id, const VPointF &point){
UpdateObject(modelingPoints, id, point);
}
void VContainer::UpdateDetail(qint64 id, const VDetail &detail){
UpdateObject(details, id, detail);
}
void VContainer::UpdateSpline(qint64 id, const VSpline &spl){
UpdateObject(splines, id, spl);
}
void VContainer::UpdateModelingSpline(qint64 id, const VSpline &spl){
UpdateObject(modelingSplines, id, spl);
}
void VContainer::UpdateSplinePath(qint64 id, const VSplinePath &splPath){
UpdateObject(splinePaths, id, splPath);
}
void VContainer::UpdateModelingSplinePath(qint64 id, const VSplinePath &splPath){
UpdateObject(modelingSplinePaths, id, splPath);
}
void VContainer::UpdateArc(qint64 id, const VArc &arc){
UpdateObject(arcs, id, arc);
}
void VContainer::UpdateModelingArc(qint64 id, const VArc &arc){
UpdateObject(modelingArcs, id, arc);
}
void VContainer::UpdateStandartTableCell(const QString& name, const VStandartTableCell& cell){
standartTable[name] = cell;
}
@ -185,6 +265,11 @@ void VContainer::Clear(){
lengthLines.clear();
lengthArcs.clear();
lineAngles.clear();
details.clear();
modelingArcs.clear();
modelingPoints.clear();
modelingSplinePaths.clear();
modelingSplines.clear();
ClearObject();
CreateManTableIGroup ();
}
@ -193,6 +278,7 @@ void VContainer::ClearObject(){
points.clear();
splines.clear();
arcs.clear();
splinePaths.clear();
}
void VContainer::ClearIncrementTable(){
@ -269,14 +355,26 @@ const QMap<qint64, VPointF> *VContainer::DataPoints() const{
return &points;
}
const QMap<qint64, VPointF> *VContainer::DataModelingPoints() const{
return &modelingPoints;
}
const QMap<qint64, VSpline> *VContainer::DataSplines() const{
return &splines;
}
const QMap<qint64, VSpline> *VContainer::DataModelingSplines() const{
return &modelingSplines;
}
const QMap<qint64, VArc> *VContainer::DataArcs() const{
return &arcs;
}
const QMap<qint64, VArc> *VContainer::DataModelingArcs() const{
return &modelingArcs;
}
const QMap<QString, qint32> *VContainer::DataBase() const{
return &base;
}
@ -309,6 +407,14 @@ const QMap<qint64, VSplinePath> *VContainer::DataSplinePaths() const{
return &splinePaths;
}
const QMap<qint64, VSplinePath> *VContainer::DataModelingSplinePaths() const{
return &modelingSplinePaths;
}
const QMap<qint64, VDetail> *VContainer::DataDetails() const{
return &details;
}
void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId){
QString nameLine = GetNameLine(firstPointId, secondPointId);
VPointF firstPoint = GetPoint(firstPointId);
@ -329,18 +435,38 @@ qint64 VContainer::AddPoint(const VPointF& point){
return AddObject(points, point);
}
qint64 VContainer::AddModelingPoint(const VPointF &point){
return AddObject(modelingPoints, point);
}
qint64 VContainer::AddDetail(const VDetail &detail){
return AddObject(details, detail);
}
qint64 VContainer::AddSpline(const VSpline &spl){
return AddObject(splines, spl);
}
qint64 VContainer::AddModelingSpline(const VSpline &spl){
return AddObject(modelingSplines, spl);
}
qint64 VContainer::AddSplinePath(const VSplinePath &splPath){
return AddObject(splinePaths, splPath);
}
qint64 VContainer::AddModelingSplinePath(const VSplinePath &splPath){
return AddObject(modelingSplinePaths, splPath);
}
qint64 VContainer::AddArc(const VArc &arc){
return AddObject(arcs, arc);
}
qint64 VContainer::AddModelingArc(const VArc &arc){
return AddObject(modelingArcs, arc);
}
QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const{
VPointF first = GetPoint(firstPoint);
VPointF second = GetPoint(secondPoint);

View File

@ -9,12 +9,14 @@
#include <QMap>
#include <QTableWidget>
#pragma GCC diagnostic pop
#include "../options.h"
#include "vpointf.h"
#include "vstandarttablecell.h"
#include "vincrementtablerow.h"
#include "../geometry/vspline.h"
#include "../geometry/varc.h"
#include "../geometry/vsplinepath.h"
#include "../geometry/vdetail.h"
/**
* @brief The VContainer class
@ -34,15 +36,22 @@ public:
* @return
*/
VPointF GetPoint(qint64 id) const;
VPointF GetModelingPoint(qint64 id) const;
VStandartTableCell GetStandartTableCell(const QString& name) const;
VIncrementTableRow GetIncrementTableRow(const QString& name) const;
qreal GetLine(const QString &name) const;
qreal GetLineArc(const QString &name) const;
VSpline GetSpline(qint64 id) const;
VSpline GetModelingSpline(qint64 id) const;
VArc GetArc(qint64 id) const;
VArc GetModelingArc(qint64 id) const;
VSplinePath GetSplinePath(qint64 id) const;
VSplinePath GetModelingSplinePath(qint64 id) const;
VDetail GetDetail(qint64 id) const;
qint64 getId();
qint64 AddPoint(const VPointF& point);
qint64 AddModelingPoint(const VPointF& point);
qint64 AddDetail(const VDetail& detail);
void AddStandartTableCell(const QString& name, const VStandartTableCell& cell);
void AddIncrementTableRow(const QString& name, const VIncrementTableRow &cell);
void AddLengthLine(const QString &name, const qreal &value);
@ -53,17 +62,25 @@ public:
void AddLineAngle(const QString &name, const qreal &value);
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId);
qint64 AddSpline(const VSpline& spl);
qint64 AddModelingSpline(const VSpline& spl);
qint64 AddSplinePath(const VSplinePath& splPath);
qint64 AddModelingSplinePath(const VSplinePath& splPath);
qint64 AddArc(const VArc& arc);
qint64 AddModelingArc(const VArc& arc);
QString GetNameLine(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 GetNameSplinePath(const VSplinePath &path) const;
QString GetNameArc(const qint64 &center, const qint64 &id) const;
void UpdatePoint(qint64 id, const VPointF& point);
void UpdateModelingPoint(qint64 id, const VPointF& point);
void UpdateDetail(qint64 id, const VDetail& detail);
void UpdateSpline(qint64 id, const VSpline& spl);
void UpdateModelingSpline(qint64 id, const VSpline& spl);
void UpdateSplinePath(qint64 id, const VSplinePath& splPath);
void UpdateModelingSplinePath(qint64 id, const VSplinePath& splPath);
void UpdateArc(qint64 id, const VArc& arc);
void UpdateModelingArc(qint64 id, const VArc& arc);
void UpdateStandartTableCell(const QString& name, const VStandartTableCell& cell);
void UpdateIncrementTableRow(const QString& name, const VIncrementTableRow& cell);
qreal GetValueStandartTableCell(const QString& name) const;
@ -84,8 +101,11 @@ public:
qint64 getNextId();
void RemoveIncrementTableRow(const QString& name);
const QMap<qint64, VPointF> *DataPoints() const;
const QMap<qint64, VPointF> *DataModelingPoints() const;
const QMap<qint64, VSpline> *DataSplines() const;
const QMap<qint64, VSpline> *DataModelingSplines() const;
const QMap<qint64, VArc> *DataArcs() const;
const QMap<qint64, VArc> *DataModelingArcs() const;
const QMap<QString, qint32> *DataBase() const;
const QMap<QString, VStandartTableCell> *DataStandartTable() const;
const QMap<QString, VIncrementTableRow> *DataIncrementTable() const;
@ -94,20 +114,28 @@ public:
const QMap<QString, qreal> *DataLengthArcs() const;
const QMap<QString, qreal> *DataLineAngles() const;
const QMap<qint64, VSplinePath> *DataSplinePaths() const;
const QMap<qint64, VSplinePath> *DataModelingSplinePaths() const;
const QMap<qint64, VDetail> *DataDetails() const;
void UpdateId(qint64 newId);
void IncrementReferens(qint64 id, Scene::Type obj);
private:
static qint64 _id;
QMap<QString, qint32> base;
QMap<qint64, VPointF> points;
QMap<qint64, VPointF> modelingPoints;
QMap<QString, VStandartTableCell> standartTable;
QMap<QString, VIncrementTableRow> incrementTable;
QMap<QString, qreal> lengthLines;
QMap<QString, qreal> lineAngles;
QMap<qint64, VSpline> splines;
QMap<qint64, VSpline> modelingSplines;
QMap<QString, qreal> lengthSplines;
QMap<qint64, VArc> arcs;
QMap<qint64, VArc> modelingArcs;
QMap<QString, qreal> lengthArcs;
QMap<qint64, VSplinePath> splinePaths;
QMap<qint64, VSplinePath> modelingSplinePaths;
QMap<qint64, VDetail> details;
template <typename key, typename val> val GetObject(const QMap<key,val> &obj, key id) const;
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);

View File

@ -1,14 +1,15 @@
#include "vpointf.h"
VPointF::VPointF():_name(QString()), _mx(0), _my(0), _x(0), _y(0){
VPointF::VPointF():_name(QString()), _mx(0), _my(0), _x(0), _y(0), _referens(0), mode(Draw::Calculation),
idObject(0){
}
VPointF::VPointF ( const VPointF & point ):_name(point.name()), _mx(point.mx()), _my(point.my()),
_x(point.x()), _y(point.y()){
_x(point.x()), _y(point.y()), _referens(0), mode(point.getMode()), idObject(point.getIdObject()){
}
VPointF::VPointF (qreal x, qreal y , QString name, qreal mx, qreal my):_name(name), _mx(mx), _my(my), _x(x),
_y(y){
VPointF::VPointF (qreal x, qreal y , QString name, qreal mx, qreal my, Draw::Mode mode, qint64 idObject):_name(name), _mx(mx),
_my(my), _x(x), _y(y), _referens(0), mode(mode), idObject(idObject){
}
VPointF::~VPointF(){
@ -57,3 +58,35 @@ qreal VPointF::x() const{
void VPointF::setX(const qreal &value){
_x = value;
}
qint32 VPointF::referens() const{
return _referens;
}
void VPointF::incrementReferens(){
++_referens;
}
void VPointF::decrementReferens(){
if(_referens > 0){
--_referens;
}
}
Draw::Mode VPointF::getMode() const
{
return mode;
}
void VPointF::setMode(const Draw::Mode &value)
{
mode = value;
}
qint64 VPointF::getIdObject() const{
return idObject;
}
void VPointF::setIdObject(const qint64 &value){
idObject = value;
}

View File

@ -1,20 +1,17 @@
#ifndef VPOINTF_H
#define VPOINTF_H
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#include <QPointF>
#include <QString>
#pragma GCC diagnostic pop
#include "options.h"
class VPointF
{
public:
VPointF();
VPointF (const VPointF &point );
VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my );
VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my, Draw::Mode mode = Draw::Calculation,
qint64 idObject = 0);
~VPointF();
QString name() const;
qreal mx() const;
@ -27,6 +24,14 @@ public:
void setX(const qreal &value);
qreal y() const;
void setY(const qreal &value);
qint32 referens() const;
void incrementReferens();
void decrementReferens();
Draw::Mode getMode() const;
void setMode(const Draw::Mode &value);
qint64 getIdObject() const;
void setIdObject(const qint64 &value);
private:
QString _name;
@ -34,6 +39,9 @@ private:
qreal _my;
qreal _x;
qreal _y;
qint32 _referens;
Draw::Mode mode;
qint64 idObject;
};
#endif // VPOINTF_H

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

77
dialogs/dialogdetail.cpp Normal file
View File

@ -0,0 +1,77 @@
#include "dialogdetail.h"
DialogDetail::DialogDetail(const VContainer *data, Draw::Mode mode, QWidget *parent) :
DialogTool(data, parent), ui(), details(VDetail()), mode(mode){
ui.setupUi(this);
bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogDetail::DialogAccepted);
QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogDetail::DialogRejected);
}
void DialogDetail::ChoosedObject(qint64 id, Scene::Type type){
if(type != Scene::Line){
NewItem(id, type, mode);
this->show();
}
}
void DialogDetail::DialogAccepted(){
details.Clear();
for(qint32 i = 0; i < ui.listWidget->count(); ++i){
QListWidgetItem *item = ui.listWidget->item(i);
details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
}
details.setName(ui.lineEditNameDetail->text());
emit DialogClosed(QDialog::Accepted);
}
void DialogDetail::NewItem(qint64 id, Scene::Type typeTool, Draw::Mode mode){
QString name;
switch(typeTool){
case(Scene::Line):
break;
case(Scene::Point):{
VPointF point = data->GetPoint(id);
name = point.name();
}
break;
case(Scene::Arc):{
VArc arc = data->GetArc(id);
name = data->GetNameArc(arc.GetCenter(), id);
}
break;
case(Scene::Spline):{
VSpline spl = data->GetSpline(id);
name = spl.GetName();
}
break;
case(Scene::SplinePath):{
VSplinePath splPath = data->GetSplinePath(id);
name = data->GetNameSplinePath(splPath);
}
break;
}
QListWidgetItem *item = new QListWidgetItem(name);
item->setFont(QFont("Times", 12, QFont::Bold));
VNodeDetail node(id, typeTool, mode);
item->setData(Qt::UserRole, QVariant::fromValue(node));
ui.listWidget->addItem(item);
}
VDetail DialogDetail::getDetails() const{
return details;
}
void DialogDetail::setDetails(const VDetail &value){
details = value;
ui.listWidget->clear();
for(qint32 i = 0; i < details.CountNode(); ++i){
NewItem(details[i].getId(), details[i].getTypeTool(),details[i].getMode());
}
details.setName(ui.lineEditNameDetail->text());
ui.listWidget->setFocus(Qt::OtherFocusReason);
}

27
dialogs/dialogdetail.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef DIALOGDETAIL_H
#define DIALOGDETAIL_H
#include "ui_dialogdetail.h"
#include "dialogtool.h"
#include "../container/vcontainer.h"
#include "../geometry/vdetail.h"
class DialogDetail : public DialogTool
{
Q_OBJECT
public:
explicit DialogDetail(const VContainer *data, Draw::Mode mode, QWidget *parent = 0);
VDetail getDetails() const;
void setDetails(const VDetail &value);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Type type);
virtual void DialogAccepted();
private:
Ui::DialogDetail ui;
VDetail details;
Draw::Mode mode;
void NewItem(qint64 id, Scene::Type typeTool, Draw::Mode mode);
};
#endif // DIALOGDETAIL_H

109
dialogs/dialogdetail.ui Normal file
View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogDetail</class>
<widget class="QDialog" name="DialogDetail">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>298</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ім'я деталі</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNameDetail"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="checkBoxClosed">
<property name="text">
<string>Замкнена</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</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/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogDetail</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>DialogDetail</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

@ -121,6 +121,7 @@ QString DialogHistory::Record(const VToolRecord &tool){
qint64 p2Line1 = 0;
qint64 p1Line2 = 0;
qint64 p2Line2 = 0;
qint64 center = 0;
QDomElement domElement;
switch( tool.getTypeTool() ){
case Tools::ArrowTool:
@ -217,6 +218,18 @@ QString DialogHistory::Record(const VToolRecord &tool){
}
}
break;
case Tools::PointOfContact:
domElement = doc->elementById(QString().setNum(tool.getId()));
if(domElement.isElement()){
center = domElement.attribute("center", "").toLongLong();
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
}
record = QString("%4 - Точка дотику дуги з центром в точці %1 і відрізку %2_%3").arg(data->GetPoint(center).name(),
data->GetPoint(firstPointId).name(),
data->GetPoint(secondPointId).name(),
data->GetPoint(tool.getId()).name());
break;
}
return record;
}

View File

@ -7,9 +7,9 @@
#pragma GCC diagnostic pop
DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *parent) :
DialogTool(data, parent){
DialogTool(data, parent), ui(), number(0), pointName(QString()), radius(QString()), center(0),
firstPoint(0), secondPoint(0){
ui.setupUi(this);
number = 0;
listWidget = ui.listWidget;
labelResultCalculation = ui.labelResultCalculation;
labelDescription = ui.labelDescription;

View File

@ -4,25 +4,19 @@
#include <QDebug>
VArc::VArc () : f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()),
center(0), points(0){
center(0), points(0), _referens(0), mode(Draw::Calculation), idObject(0){
}
VArc::VArc (const QMap<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2, QString formulaF2 )
qreal f1, QString formulaF1, qreal f2, QString formulaF2, Draw::Mode mode, qint64 idObject)
: f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius),
center(center), points(points){
center(center), points(points), _referens(0), mode(mode), idObject(idObject){
}
VArc::VArc(const VArc &arc): f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0),
formulaRadius(QString()), center(0), points(0){
this->points = arc.GetDataPoints();
this->f1 = arc.GetF1();
this->formulaF1 = arc.GetFormulaF1();
this->f2 = arc.GetF2();
this->formulaF2 = arc.GetFormulaF2();
this->radius = arc.GetRadius();
this->formulaRadius = arc.GetFormulaRadius();
this->center = arc.GetCenter();
VArc::VArc(const VArc &arc): f1(arc.GetF1()), formulaF1(arc.GetFormulaF1()), f2(arc.GetF2()),
formulaF2(arc.GetFormulaF2()), radius(arc.GetRadius()), formulaRadius(arc.GetFormulaRadius()),
center(arc.GetCenter()), points(arc.GetDataPoints()), _referens(0), mode(arc.getMode()),
idObject(arc.getIdObject()){
}
const VArc &VArc::operator =(const VArc &arc){
@ -34,6 +28,7 @@ const VArc &VArc::operator =(const VArc &arc){
this->radius = arc.GetRadius();
this->formulaRadius = arc.GetFormulaRadius();
this->center = arc.GetCenter();
this->mode = arc.getMode();
return *this;
}
@ -107,3 +102,110 @@ QPainterPath VArc::GetPath() const{
return Path;
}
qreal VArc::AngleArc() const{
QLineF l1(0,0, 100, 100);
l1.setAngle(f1);
QLineF l2(0,0, 100, 100);
l2.setAngle(f2);
return l1.angleTo(l2);
}
qint32 VArc::NumberSplOfArc() const{
qint32 angArc = static_cast<qint32> (AngleArc ());
switch( angArc ){
case 0:
throw "Кут дуги не може бути 0 градусів.";
break;
case 90:
return 1;
case 180:
return 2;
case 270:
return 3;
case 360:
return 4;
default :
return static_cast<qint32> (AngleArc ( ) / 90 + 1);
}
}
QVector<QPointF> VArc::GetPoints() const{
QVector<QPointF> points;
qint32 numberSpl = NumberSplOfArc();
for(qint32 i = 1; i <= numberSpl; ++i){
points<<SplOfArc ( i );
}
return points;
}
QVector<QPointF> VArc::SplOfArc(qint32 number) const{
qint32 n = NumberSplOfArc ();
if( number > n ){
throw "Дуга не складається з такої кількості сплайнів.";
}
qreal f1 = GetF1 ();
qreal f2 = GetF2 ();
qint32 i;
for ( i = 0; i < n; ++i ){
if ( i == n - 1 ){
f2 = GetF2 ();
} else {
if ( f1 + 90 > 360 ){
f2 = f1 + 90 - 360;
} else {
f2 = f1 + 90;
}
}
qreal anglF1, anglF2;
if ( f1 + 90 > 360 ){
anglF1 = f1 + 90 - 360 ;
} else {
anglF1 = f1 + 90 ;
}
if ( f2 - 90 < 0 ){
anglF2 = 360 + f2 - 90 ;
} else {
anglF2 = f2 - 90 ;
}
if ( i + 1 == number ){
return VSpline::SplinePoints(GetP1 (), GetP2 (), anglF1, anglF2, 1., 1., 1.);
f1 = f2;
}
}
return QVector<QPointF>();
}
qint32 VArc::referens() const{
return _referens;
}
void VArc::incrementReferens(){
++_referens;
}
void VArc::decrementReferens(){
if(_referens > 0){
--_referens;
}
}
Draw::Mode VArc::getMode() const
{
return mode;
}
void VArc::setMode(const Draw::Mode &value)
{
mode = value;
}
qint64 VArc::getIdObject() const
{
return idObject;
}
void VArc::setIdObject(const qint64 &value)
{
idObject = value;
}

View File

@ -5,6 +5,7 @@
#include <QVector>
#include <QMap>
#include "container/vpointf.h"
#include "vspline.h"
/**
* @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою.
@ -23,7 +24,8 @@ public:
* @param f2 кінцевий кут в градусах.
*/
VArc (const QMap<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2 , QString formulaF2);
qreal f1, QString formulaF1, qreal f2 , QString formulaF2,
Draw::Mode mode = Draw::Calculation, qint64 idObject = 0);
VArc(const VArc &arc);
const VArc& operator= (const VArc &arc);
/**
@ -71,6 +73,19 @@ public:
* @return повертає шлях.
*/
QPainterPath GetPath() const;
qreal AngleArc()const;
qint32 NumberSplOfArc () const;
QVector<QPointF> GetPoints () const;
QVector<QPointF> SplOfArc( qint32 number ) const;
qint32 referens() const;
void incrementReferens();
void decrementReferens();
Draw::Mode getMode() const;
void setMode(const Draw::Mode &value);
qint64 getIdObject() const;
void setIdObject(const qint64 &value);
private:
/**
* @brief f1 початковий кут в градусах
@ -92,6 +107,9 @@ private:
*/
qint64 center;
const QMap<qint64, VPointF> *points;
qint32 _referens;
Draw::Mode mode;
qint64 idObject;
};
#endif // VARC_H

58
geometry/vdetail.cpp Normal file
View File

@ -0,0 +1,58 @@
#include "vdetail.h"
VDetail::VDetail():nodes(QVector<VNodeDetail>()),name(QString()), mx(0), my(0){
}
VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes):nodes(QVector<VNodeDetail>()),
name(name), mx(0), my(0){
this->nodes = nodes;
}
void VDetail::append(const VNodeDetail &node){
nodes.append(node);
}
void VDetail::Clear(){
nodes.clear();
name.clear();
mx = 0;
my = 0;
}
qint32 VDetail::CountNode() const{
return nodes.size();
}
VNodeDetail &VDetail::operator [](int indx){
return nodes[indx];
}
qreal VDetail::getMy() const
{
return my;
}
void VDetail::setMy(const qreal &value)
{
my = value;
}
qreal VDetail::getMx() const
{
return mx;
}
void VDetail::setMx(const qreal &value)
{
mx = value;
}
QString VDetail::getName() const
{
return name;
}
void VDetail::setName(const QString &value)
{
name = value;
}

33
geometry/vdetail.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef VDETAIL_H
#define VDETAIL_H
#include "vnodedetail.h"
#include <QVector>
#include <QString>
class VDetail
{
public:
VDetail();
VDetail(const QString &name, const QVector<VNodeDetail> &nodes);
void append(const VNodeDetail &node);
void Clear();
qint32 CountNode() const;
VNodeDetail & operator[](int indx);
QString getName() const;
void setName(const QString &value);
qreal getMx() const;
void setMx(const qreal &value);
qreal getMy() const;
void setMy(const qreal &value);
private:
QVector<VNodeDetail> nodes;
QString name;
qreal mx;
qreal my;
};
#endif // VDETAIL_H

36
geometry/vnodedetail.cpp Normal file
View File

@ -0,0 +1,36 @@
#include "vnodedetail.h"
VNodeDetail::VNodeDetail():id(0), typeTool(Scene::Point), mode(Draw::Calculation){
}
VNodeDetail::VNodeDetail(qint64 id, Scene::Type typeTool, Draw::Mode mode):id(id), typeTool(typeTool),
mode(mode){
}
VNodeDetail::VNodeDetail(const VNodeDetail &node):id(node.getId()), typeTool(node.getTypeTool()),
mode(node.getMode()){
}
Scene::Type VNodeDetail::getTypeTool() const{
return typeTool;
}
void VNodeDetail::setTypeTool(const Scene::Type &value){
typeTool = value;
}
qint64 VNodeDetail::getId() const{
return id;
}
void VNodeDetail::setId(const qint64 &value){
id = value;
}
Draw::Mode VNodeDetail::getMode() const{
return mode;
}
void VNodeDetail::setMode(const Draw::Mode &value){
mode = value;
}

28
geometry/vnodedetail.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef VNODEDETAIL_H
#define VNODEDETAIL_H
#include <QtGlobal>
#include <QMetaType>
#include "../options.h"
class VNodeDetail
{
public:
VNodeDetail();
VNodeDetail(qint64 id, Scene::Type typeTool, Draw::Mode mode);
VNodeDetail(const VNodeDetail &node);
qint64 getId() const;
void setId(const qint64 &value);
Scene::Type getTypeTool() const;
void setTypeTool(const Scene::Type &value);
Draw::Mode getMode() const;
void setMode(const Draw::Mode &value);
private:
qint64 id;
Scene::Type typeTool;
Draw::Mode mode;
};
Q_DECLARE_METATYPE(VNodeDetail)
#endif // VNODEDETAIL_H

View File

@ -4,23 +4,25 @@
#include <QDebug>
VSpline::VSpline():p1(0), p2(QPointF()), p3(QPointF()), p4(0), angle1(0), angle2(0), kAsm1(1), kAsm2(1),
kCurve(1), points(0){
kCurve(1), points(0), _referens(0), mode(Draw::Calculation), idObject(0){
}
VSpline::VSpline ( const VSpline & spline ):p1(spline.GetP1 ()), p2(spline.GetP2 ()), p3(spline.GetP3 ()),
p4(spline.GetP4 ()), angle1(spline.GetAngle1 ()), angle2(spline.GetAngle2 ()), kAsm1(spline.GetKasm1()),
kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()), points(spline.GetDataPoints()){
kAsm2(spline.GetKasm2()), kCurve(spline.GetKcurve()), points(spline.GetDataPoints()), _referens(0),
mode(spline.getMode()), idObject(spline.getIdObject()){
}
VSpline::VSpline (const QMap<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1, qreal angle2,
qreal kAsm1, qreal kAsm2 , qreal kCurve):p1(p1), p2(QPointF()), p3(QPointF()),
p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve), points(points){
qreal kAsm1, qreal kAsm2 , qreal kCurve, Draw::Mode mode, qint64 idObject):p1(p1), p2(QPointF()), p3(QPointF()),
p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve), points(points),
_referens(0), mode(mode), idObject(idObject){
ModifiSpl ( p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve );
}
VSpline::VSpline (const QMap<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3, qint64 p4,
qreal kCurve):p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1),
kCurve(1), points(points){
qreal kCurve, Draw::Mode mode, qint64 idObject):p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1),
kCurve(1), points(points), _referens(0), mode(mode), idObject(idObject){
ModifiSpl ( p1, p2, p3, p4, kCurve);
}
@ -36,14 +38,14 @@ void VSpline::ModifiSpl ( qint64 p1, qint64 p4, qreal angle1, qreal angle2,
QLineF p1pX(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + 100, GetPointP1().y());
p1pX.setAngle( angle1 );
qreal L = 0, radius = 0, angle = 90;
// angle = QLineF(GetPointP1(), p1pX.p2()).angleTo(QLineF(GetPointP1(), GetPointP4()));
// if ( angle > 180 ){
// angle = 360 - angle;
// }
// angle = QLineF(GetPointP1(), p1pX.p2()).angleTo(QLineF(GetPointP1(), GetPointP4()));
// if ( angle > 180 ){
// angle = 360 - angle;
// }
QPointF point1 = GetPointP1().toQPointF();
QPointF point4 = GetPointP4().toQPointF();
radius = QLineF(QPointF(point1.x(), point4.y()),point4).length();
// radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 );
// radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 );
L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 );
QLineF p1p2(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + L * kAsm1, GetPointP1().y());
p1p2.setAngle(angle1);
@ -64,14 +66,14 @@ void VSpline::ModifiSpl (qint64 p1, QPointF p2, QPointF p3, qint64 p4, qreal kCu
QLineF p1pX(GetPointP1().x(), GetPointP1().y(), GetPointP1().x() + 100, GetPointP1().y());
p1pX.setAngle( angle1 );
qreal L = 0, radius = 0, angle = 90;
// angle = QLineF(GetPointP1(), p1pX.p2()).angleTo(QLineF(GetPointP1(), GetPointP4()));
// if ( angle >= 180 ){
// angle = 360 - angle;
// }
// angle = QLineF(GetPointP1(), p1pX.p2()).angleTo(QLineF(GetPointP1(), GetPointP4()));
// if ( angle >= 180 ){
// angle = 360 - angle;
// }
QPointF point1 = GetPointP1().toQPointF();
QPointF point4 = GetPointP4().toQPointF();
radius = QLineF(QPointF(point1.x(), point4.y()),point4).length();
// radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 );
// radius = QLineF(GetPointP1(), GetPointP4()).length() / 2 / sin( angle * M_PI / 180.0 );
L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 );
this->kCurve = kCurve;
@ -260,7 +262,7 @@ QVector<QPointF> VSpline::GetPoints () const{
return GetPoints(GetPointP1().toQPointF(), p2, p3, GetPointP4().toQPointF());
}
QVector<QPointF> VSpline::GetPoints (QPointF p1, QPointF p2, QPointF p3, QPointF p4) const{
QVector<QPointF> VSpline::GetPoints (QPointF p1, QPointF p2, QPointF p3, QPointF p4){
QVector<QPointF> pvector;
QVector<qreal> x;
QVector<qreal> y;
@ -309,7 +311,7 @@ qreal VSpline::LengthBezier ( QPointF p1, QPointF p2, QPointF p3, QPointF p4 ) c
void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
qreal x3, qreal y3, qreal x4, qreal y4,
qint16 level, QVector<qreal> &px, QVector<qreal> &py) const{
qint16 level, QVector<qreal> &px, QVector<qreal> &py){
const double curve_collinearity_epsilon = 1e-30;
const double curve_angle_tolerance_epsilon = 0.01;
const double m_angle_tolerance = 0.0;
@ -379,16 +381,16 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
return;
}
if(d2 <= 0)
d2 = this->CalcSqDistance(x2, y2, x1, y1);
d2 = CalcSqDistance(x2, y2, x1, y1);
else if(d2 >= 1)
d2 = CalcSqDistance(x2, y2, x4, y4);
else
d2 = CalcSqDistance(x2, y2, x1 + d2*dx, y1 + d2*dy);
if(d3 <= 0)
d3 = this->CalcSqDistance(x3, y3, x1, y1);
d3 = CalcSqDistance(x3, y3, x1, y1);
else if(d3 >= 1)
d3 = this->CalcSqDistance(x3, y3, x4, y4);
d3 = CalcSqDistance(x3, y3, x4, y4);
else
d3 = CalcSqDistance(x3, y3, x1 + d3*dx, y1 + d3*dy);
}
@ -570,7 +572,7 @@ void VSpline::PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
PointBezier_r(x1234, y1234, x234, y234, x34, y34, x4, y4, static_cast<qint16>(level + 1), px, py);
}
qreal VSpline::CalcSqDistance (qreal x1, qreal y1, qreal x2, qreal y2) const{
qreal VSpline::CalcSqDistance (qreal x1, qreal y1, qreal x2, qreal y2){
qreal dx = x2 - x1;
qreal dy = y2 - y1;
return dx * dx + dy * dy;
@ -586,6 +588,20 @@ QPainterPath VSpline::GetPath() const{
return splinePath;
}
qint32 VSpline::referens() const{
return _referens;
}
void VSpline::incrementReferens(){
++_referens;
}
void VSpline::decrementReferens(){
if(_referens > 0){
--_referens;
}
}
/* Cubic equation solution. Real coefficients case.
int Cubic(double *x,double a,double b,double c);
@ -710,3 +726,37 @@ qreal VSpline::param_t (QPointF pBt)const{
// P4 = QPointF(P4.x() + Pmirror.x(), P4.y() + Pmirror.y());
// this->ModifiSpl(P1, P2, P3, P4);
//}
Draw::Mode VSpline::getMode() const{
return mode;
}
void VSpline::setMode(const Draw::Mode &value){
mode = value;
}
QVector<QPointF> VSpline::SplinePoints(QPointF p1, QPointF p4, qreal angle1, qreal angle2, qreal kAsm1,
qreal kAsm2, qreal kCurve){
QLineF p1pX(p1.x(), p1.y(), p1.x() + 100, p1.y());
p1pX.setAngle( angle1 );
qreal L = 0, radius = 0, angle = 90;
radius = QLineF(QPointF(p1.x(), p4.y()),p4).length();
L = kCurve * radius * 4 / 3 * tan( angle * M_PI / 180.0 / 4 );
QLineF p1p2(p1.x(), p1.y(), p1.x() + L * kAsm1, p1.y());
p1p2.setAngle(angle1);
QLineF p4p3(p4.x(), p4.y(), p4.x() + L * kAsm2, p4.y());
p4p3.setAngle(angle2);
QPointF p2 = p1p2.p2();
QPointF p3 = p4p3.p2();
return GetPoints(p1, p2, p3, p4);
}
qint64 VSpline::getIdObject() const
{
return idObject;
}
void VSpline::setIdObject(const qint64 &value)
{
idObject = value;
}

View File

@ -7,6 +7,7 @@
#include <QVector>
#include <QMap>
#include "container/vpointf.h"
#include "options.h"
/**
* @brief VSpline клас, що реалізує сплайн.
@ -30,7 +31,8 @@ public:
* @param kAsm2 коефіцієнт довжини другої напрямної.
*/
VSpline (const QMap<qint64, VPointF> *points, qint64 p1, qint64 p4, qreal angle1,
qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve);
qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve,
Draw::Mode mode = Draw::Calculation, qint64 idObject = 0);
/**
* @brief VSpline конструктор.
* @param p1 початкова точка сплайну.
@ -39,7 +41,8 @@ public:
* @param p4 кінцева точка сплайну.
*/
VSpline (const QMap<qint64, VPointF> *points, qint64 p1, QPointF p2, QPointF p3,
qint64 p4, qreal kCurve);
qint64 p4, qreal kCurve, Draw::Mode mode = Draw::Calculation,
qint64 idObject = 0);
/**
* @brief ModifiSpl модифікує сплайн.
* @param p1 початкова точка сплайну.
@ -156,6 +159,16 @@ public:
* @param Pmirror точка відносно якої відбувається вертикальне дзеркалення сплайну.
*/
// void Mirror(const QPointF Pmirror);
qint32 referens() const;
void incrementReferens();
void decrementReferens();
Draw::Mode getMode() const;
void setMode(const Draw::Mode &value);
static QVector<QPointF> SplinePoints(QPointF p1, QPointF p4, qreal angle1,
qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve);
qint64 getIdObject() const;
void setIdObject(const qint64 &value);
protected:
/**
* @brief GetPoints повертає точки з яких складається сплайн.
@ -165,7 +178,7 @@ protected:
* @param p4 кінцева точка сплайну.
* @return список точок.
*/
QVector<QPointF> GetPoints ( QPointF p1, QPointF p2, QPointF p3, QPointF p4 ) const;
static QVector<QPointF> GetPoints ( QPointF p1, QPointF p2, QPointF p3, QPointF p4 );
private:
/**
* @brief p1 початкова точка сплайну
@ -195,6 +208,9 @@ private:
qreal kAsm2;
qreal kCurve;
const QMap<qint64, VPointF> *points;
qint32 _referens;
Draw::Mode mode;
qint64 idObject;
/**
* @brief LengthBezier повертає дожину сплайну за його чотирьма точками.
* @param p1 початкова точка сплайну.
@ -218,9 +234,9 @@ private:
* @param px список х координат точок сплайну.
* @param py список у коодринат сплайну.
*/
void PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
static void PointBezier_r ( qreal x1, qreal y1, qreal x2, qreal y2,
qreal x3, qreal y3, qreal x4, qreal y4,
qint16 level, QVector<qreal> &px, QVector<qreal> &py) const;
qint16 level, QVector<qreal> &px, QVector<qreal> &py);
/**
* @brief CalcSqDistance розраховує довжину між точками.
* @param x1 х координата першої точки.
@ -229,7 +245,7 @@ private:
* @param y2 у координата другої точки.
* @return довжину.
*/
qreal CalcSqDistance ( qreal x1, qreal y1, qreal x2, qreal y2) const;
static qreal CalcSqDistance ( qreal x1, qreal y1, qreal x2, qreal y2);
/**
* @brief Cubic знаходить розв'язок кубічного рівняння.
* @param x коефіцієнт.

View File

@ -1,14 +1,24 @@
#include "vsplinepath.h"
VSplinePath::VSplinePath(): path(QVector<VSplinePoint>()), kCurve(1), points(0){
VSplinePath::VSplinePath(): path(QVector<VSplinePoint>()), kCurve(1), mode(Draw::Calculation), points(0),
_referens(0), idObject(0){
}
VSplinePath::VSplinePath(const QMap<qint64, VPointF> *points, qreal kCurve): path(QVector<VSplinePoint>()),
kCurve(kCurve), points(points){
VSplinePath::VSplinePath(const QMap<qint64, VPointF> *points, qreal kCurve, Draw::Mode mode, qint64 idObject): path(QVector<VSplinePoint>()),
kCurve(kCurve), mode(mode), points(points), _referens(0), idObject(idObject){
}
VSplinePath::VSplinePath(const VSplinePath &splPath): path(*splPath.GetPoint()),
kCurve(splPath.getKCurve()), points( splPath.GetDataPoints()){
kCurve(splPath.getKCurve()), mode(splPath.getMode()), points( splPath.GetDataPoints()), _referens(0),
idObject(splPath.getIdObject()){
}
Draw::Mode VSplinePath::getMode() const{
return mode;
}
void VSplinePath::setMode(const Draw::Mode &value){
mode = value;
}
void VSplinePath::append(VSplinePoint point){
@ -35,7 +45,7 @@ VSpline VSplinePath::GetSpline(qint32 index) const{
throw "Такого сплайну немає.";
}
VSpline spl(points, path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(),
path[index-1].KAsm2(), path[index].KAsm1(), this->kCurve);
path[index-1].KAsm2(), path[index].KAsm1(), this->kCurve);
return spl;
}
@ -43,12 +53,25 @@ QPainterPath VSplinePath::GetPath() const{
QPainterPath painterPath;
for(qint32 i = 1; i <= Count(); ++i){
VSpline spl(points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(),
path[i].KAsm1(), this->kCurve);
path[i].KAsm1(), this->kCurve);
painterPath.addPath(spl.GetPath());
}
return painterPath;
}
QVector<QPointF> VSplinePath::GetPathPoints() const{
QVector<QPointF> pathPoints;
for(qint32 i = 1; i <= Count(); ++i){
VSpline spl(points, path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(),
path[i].KAsm1(), this->kCurve);
QVector<QPointF> splP = spl.GetPoints();
for(qint32 j = 0; i < splP.size(); ++j){
pathPoints.append(splP[j]);
}
}
return pathPoints;
}
QVector<VSplinePoint> VSplinePath::GetSplinePath() const{
return path;
}
@ -108,6 +131,7 @@ const QVector<VSplinePoint> *VSplinePath::GetPoint() const{
VSplinePath &VSplinePath::operator =(const VSplinePath &path){
this->path = path.GetSplinePath();
this->kCurve = path.getKCurve();
this->mode = path.getMode();
this->points = path.GetDataPoints();
return *this;
}
@ -115,3 +139,27 @@ VSplinePath &VSplinePath::operator =(const VSplinePath &path){
VSplinePoint & VSplinePath::operator[](int indx){
return path[indx];
}
qint32 VSplinePath::referens() const{
return _referens;
}
void VSplinePath::incrementReferens(){
++_referens;
}
void VSplinePath::decrementReferens(){
if(_referens > 0){
--_referens;
}
}
qint64 VSplinePath::getIdObject() const
{
return idObject;
}
void VSplinePath::setIdObject(const qint64 &value)
{
idObject = value;
}

View File

@ -2,10 +2,9 @@
#define VSPLINEPATH_H
#include "vsplinepoint.h"
#pragma GCC diagnostic ignored "-Weffc++"
#include <QVector>
#pragma GCC diagnostic warning "-Weffc++"
#include "vspline.h"
#include "options.h"
namespace SplinePoint{
enum Position
@ -27,7 +26,8 @@ public:
/**
* @brief VSplinePath конструктор по замовчуванню.
*/
VSplinePath(const QMap<qint64, VPointF> *points, qreal kCurve = 1);
VSplinePath(const QMap<qint64, VPointF> *points, qreal kCurve = 1,
Draw::Mode mode = Draw::Calculation, qint64 idObject = 0);
VSplinePath(const VSplinePath& splPath);
/**
* @brief append додає точку сплайну до шляху.
@ -38,6 +38,7 @@ public:
qint32 CountPoint() const;
VSpline GetSpline(qint32 index) const;
QPainterPath GetPath() const;
QVector<QPointF> GetPathPoints() const;
QVector<VSplinePoint> GetSplinePath() const;
qreal GetLength() const;
const QMap<qint64, VPointF> *GetDataPoints() const;
@ -52,13 +53,25 @@ public:
const QVector<VSplinePoint> *GetPoint() const;
VSplinePath& operator=(const VSplinePath &path);
VSplinePoint & operator[](int indx);
qint32 referens() const;
void incrementReferens();
void decrementReferens();
Draw::Mode getMode() const;
void setMode(const Draw::Mode &value);
qint64 getIdObject() const;
void setIdObject(const qint64 &value);
protected:
/**
* @brief path вектор з точок сплайна.
*/
QVector<VSplinePoint> path;
qreal kCurve;
Draw::Mode mode;
const QMap<qint64, VPointF> *points;
qint32 _referens;
qint64 idObject;
};
#endif // VSPLINEPATH_H

View File

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

BIN
icon/32x32/new_detail.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -24,12 +24,13 @@
#include "tools/vtoolarc.h"
#include "tools/vtoolsplinepath.h"
#include "tools/vtoolpointofcontact.h"
#include "tools/vtooldetail.h"
#pragma GCC diagnostic pop
#include "geometry/vspline.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow), tool(Tools::ArrowTool), scene(0), mouseCoordinate(0),
helpLabel(0), view(0), isInitialized(false), dialogTable(0),
QMainWindow(parent), ui(new Ui::MainWindow), tool(Tools::ArrowTool), currentScene(0), sceneDraw(0),
sceneDetails(0), mouseCoordinate(0), helpLabel(0), view(0), isInitialized(false), dialogTable(0),
dialogEndLine(QSharedPointer<DialogEndLine>()), dialogLine(QSharedPointer<DialogLine>()),
dialogAlongLine(QSharedPointer<DialogAlongLine>()),
dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>()), dialogNormal(QSharedPointer<DialogNormal>()),
@ -37,21 +38,24 @@ MainWindow::MainWindow(QWidget *parent) :
dialogLineIntersect(QSharedPointer<DialogLineIntersect>()),
dialogSpline(QSharedPointer<DialogSpline>()),
dialogArc(QSharedPointer<DialogArc>()), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
dialogPointOfContact(QSharedPointer<DialogPointOfContact>()), dialogHistory(0),
doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false){
dialogPointOfContact(QSharedPointer<DialogPointOfContact>()), dialogDetail(QSharedPointer<DialogDetail>()),
dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
mode(Draw::Calculation){
ui->setupUi(this);
ToolBarOption();
ToolBarDraws();
QRectF sceneRect = QRectF(0, 0, PaperSize, PaperSize);
scene = new VMainGraphicsScene(sceneRect);
sceneDraw = new VMainGraphicsScene(sceneRect);
currentScene = sceneDraw;
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
sceneDetails = new VMainGraphicsScene(sceneRect);
connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
view = new VMainGraphicsView();
ui->LayoutView->addWidget(view);
view->setScene(scene);
view->setScene(currentScene);
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
policy.setHorizontalStretch(12);
view->setSizePolicy(policy);
connect(scene, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
helpLabel = new QLabel("Створіть новий файл для початку роботи.");
ui->statusBar->addWidget(helpLabel);
@ -77,6 +81,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->toolButtonArc, &QToolButton::clicked, this, &MainWindow::ToolArc);
connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath);
connect(ui->toolButtonPointOfContact, &QToolButton::clicked, this, &MainWindow::ToolPointOfContact);
connect(ui->toolButtonNewDetail, &QToolButton::clicked, this, &MainWindow::ToolDetail);
data = new VContainer;
@ -137,8 +142,8 @@ void MainWindow::ActionNewDraw(){
qint64 id = data->AddPoint(VPointF((10+comboBoxDraws->count()*5)*PrintDPI/25.4, 10*PrintDPI/25.4, "А", 5,
10));
VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui);
scene->addItem(spoint);
connect(spoint, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
sceneDraw->addItem(spoint);
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, spoint);
VAbstractTool::AddRecord(id, Tools::SinglePointTool, doc);
@ -190,7 +195,7 @@ void MainWindow::SetToolButton(bool checked, Tools::Enum t, const QString &curso
view->setCursor(cur);
helpLabel->setText("Виберіть точки.");
dialog = QSharedPointer<Dialog>(new Dialog(data));
connect(scene, &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
connect(dialog.data(), &Dialog::DialogClosed, this, closeDialogSlot);
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
} else {
@ -207,7 +212,7 @@ void MainWindow::ToolEndLine(bool checked){
void MainWindow::ClosedDialogEndLine(int result){
if(result == QDialog::Accepted){
VToolEndLine::Create(dialogEndLine, scene, doc, data);
VToolEndLine::Create(dialogEndLine, currentScene, doc, data, mode);
}
ArrowTool();
}
@ -219,7 +224,7 @@ void MainWindow::ToolLine(bool checked){
void MainWindow::ClosedDialogLine(int result){
if(result == QDialog::Accepted){
VToolLine::Create(dialogLine, scene, doc, data);
VToolLine::Create(dialogLine, currentScene, doc, data, mode);
}
ArrowTool();
}
@ -231,7 +236,7 @@ void MainWindow::ToolAlongLine(bool checked){
void MainWindow::ClosedDialogAlongLine(int result){
if(result == QDialog::Accepted){
VToolAlongLine::Create(dialogAlongLine, scene, doc, data);
VToolAlongLine::Create(dialogAlongLine, currentScene, doc, data, mode);
}
ArrowTool();
}
@ -243,7 +248,7 @@ void MainWindow::ToolShoulderPoint(bool checked){
void MainWindow::ClosedDialogShoulderPoint(int result){
if(result == QDialog::Accepted){
VToolShoulderPoint::Create(dialogShoulderPoint, scene, doc, data);
VToolShoulderPoint::Create(dialogShoulderPoint, currentScene, doc, data, mode);
}
ArrowTool();
}
@ -255,7 +260,7 @@ void MainWindow::ToolNormal(bool checked){
void MainWindow::ClosedDialogNormal(int result){
if(result == QDialog::Accepted){
VToolNormal::Create(dialogNormal, scene, doc, data);
VToolNormal::Create(dialogNormal, currentScene, doc, data, mode);
}
ArrowTool();
}
@ -267,7 +272,7 @@ void MainWindow::ToolBisector(bool checked){
void MainWindow::ClosedDialogBisector(int result){
if(result == QDialog::Accepted){
VToolBisector::Create(dialogBisector, scene, doc, data);
VToolBisector::Create(dialogBisector, currentScene, doc, data, mode);
}
ArrowTool();
}
@ -279,7 +284,7 @@ void MainWindow::ToolLineIntersect(bool checked){
void MainWindow::ClosedDialogLineIntersect(int result){
if(result == QDialog::Accepted){
VToolLineIntersect::Create(dialogLineIntersect, scene, doc, data);
VToolLineIntersect::Create(dialogLineIntersect, currentScene, doc, data, mode);
}
ArrowTool();
}
@ -291,7 +296,7 @@ void MainWindow::ToolSpline(bool checked){
void MainWindow::ClosedDialogSpline(int result){
if(result == QDialog::Accepted){
VToolSpline::Create(dialogSpline, scene, doc, data);
VToolSpline::Create(dialogSpline, currentScene, doc, data, mode);
}
ArrowTool();
}
@ -303,7 +308,7 @@ void MainWindow::ToolArc(bool checked){
void MainWindow::ClosedDialogArc(int result){
if(result == QDialog::Accepted){
VToolArc::Create(dialogArc, scene, doc, data);
VToolArc::Create(dialogArc, currentScene, doc, data, mode);
}
ArrowTool();
}
@ -315,7 +320,7 @@ void MainWindow::ToolSplinePath(bool checked){
void MainWindow::ClosedDialogSplinePath(int result){
if(result == QDialog::Accepted){
VToolSplinePath::Create(dialogSplinePath, scene, doc, data);
VToolSplinePath::Create(dialogSplinePath, currentScene, doc, data, mode);
}
ArrowTool();
}
@ -327,7 +332,34 @@ void MainWindow::ToolPointOfContact(bool checked){
void MainWindow::ClosedDialogPointOfContact(int result){
if(result == QDialog::Accepted){
VToolPointOfContact::Create(dialogPointOfContact, scene, doc, data);
VToolPointOfContact::Create(dialogPointOfContact, currentScene, doc, data, mode);
}
ArrowTool();
}
void MainWindow::ToolDetail(bool checked){
if(checked){
CanselTool();
tool = Tools::Detail;
QPixmap pixmap("://cursor/new_detail_cursor.png");
QCursor cur(pixmap, 2, 3);
view->setCursor(cur);
helpLabel->setText("Виберіть точки.");
dialogDetail = QSharedPointer<DialogDetail>(new DialogDetail(data, mode));
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogDetail.data(),
&DialogDetail::ChoosedObject);
connect(dialogDetail.data(), &DialogDetail::DialogClosed, this, &MainWindow::ClosedDialogDetail);
connect(doc, &VDomDocument::FullUpdateFromFile, dialogDetail.data(), &DialogDetail::UpdateList);
} else {
if(QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())){
tButton->setChecked(true);
}
}
}
void MainWindow::ClosedDialogDetail(int result){
if(result == QDialog::Accepted){
VToolDetail::Create(dialogDetail, sceneDetails, doc, data);
}
ArrowTool();
}
@ -437,68 +469,72 @@ void MainWindow::CanselTool(){
case Tools::EndLineTool:
dialogEndLine.clear();
ui->toolButtonEndLine->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tools::LineTool:
dialogLine.clear();
ui->toolButtonLine->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearFocus();
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearFocus();
break;
case Tools::AlongLineTool:
dialogAlongLine.clear();
ui->toolButtonAlongLine->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tools::ShoulderPointTool:
dialogShoulderPoint.clear();
ui->toolButtonShoulderPoint->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tools::NormalTool:
dialogNormal.clear();
ui->toolButtonNormal->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tools::BisectorTool:
dialogBisector.clear();
ui->toolButtonBisector->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tools::LineIntersectTool:
dialogLineIntersect.clear();
ui->toolButtonLineIntersect->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tools::SplineTool:
dialogSpline.clear();
ui->toolButtonSpline->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tools::ArcTool:
dialogArc.clear();
ui->toolButtonArc->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tools::SplinePathTool:
dialogSplinePath.clear();
ui->toolButtonSplinePath->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tools::PointOfContact:
dialogPointOfContact.clear();
ui->toolButtonPointOfContact->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tools::Detail:
dialogDetail.clear();
ui->toolButtonNewDetail->setChecked(false);
break;
}
}
@ -528,6 +564,9 @@ void MainWindow::keyPressEvent ( QKeyEvent * event ){
void MainWindow::ActionDraw(bool checked){
if(checked){
ui->actionDetails->setChecked(false);
currentScene = sceneDraw;
view->setScene(currentScene);
mode = Draw::Calculation;
} else {
ui->actionDraw->setChecked(true);
}
@ -536,6 +575,9 @@ void MainWindow::ActionDraw(bool checked){
void MainWindow::ActionDetails(bool checked){
if(checked){
ui->actionDraw->setChecked(false);
currentScene = sceneDetails;
view->setScene(sceneDetails);
mode = Draw::Modeling;
} else {
ui->actionDetails->setChecked(true);
}
@ -559,6 +601,7 @@ void MainWindow::ActionSaveAs(){
QFile file(fileName);
if(file.open(QIODevice::WriteOnly| QIODevice::Truncate)){
doc->GarbageCollector();
const int Indent = 4;
QTextStream out(&file);
doc->save(out, Indent);
@ -572,6 +615,7 @@ void MainWindow::ActionSave(){
if(!fileName.isEmpty()){
QFile file(fileName);
if(file.open(QIODevice::WriteOnly| QIODevice::Truncate)){
doc->GarbageCollector();
const int Indent = 4;
QTextStream out(&file);
doc->save(out, Indent);
@ -597,7 +641,7 @@ void MainWindow::ActionOpen(){
if(doc->setContent(&file)){
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MainWindow::currentDrawChanged);
doc->Parse(Document::FullParse, scene);
doc->Parse(Document::FullParse, sceneDraw, sceneDetails);
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MainWindow::currentDrawChanged);
QString nameDraw = doc->GetNameActivDraw();
@ -621,7 +665,8 @@ void MainWindow::ActionNew(){
fileName.clear();
data->Clear();
doc->clear();
scene->clear();
sceneDraw->clear();
sceneDetails->clear();
CanselTool();
comboBoxDraws->clear();
fileName.clear();
@ -707,6 +752,7 @@ void MainWindow::SetEnableTool(bool enable){
ui->toolButtonArc->setEnabled(enable);
ui->toolButtonSplinePath->setEnabled(enable);
ui->toolButtonPointOfContact->setEnabled(enable);
ui->toolButtonNewDetail->setEnabled(enable);
}
MainWindow::~MainWindow(){

View File

@ -29,6 +29,7 @@
#include "dialogs/dialogsplinepath.h"
#include "dialogs/dialoghistory.h"
#include "dialogs/dialogpointofcontact.h"
#include "dialogs/dialogdetail.h"
#include "tools/vtoolsinglepoint.h"
#include "xml/vdomdocument.h"
#pragma GCC diagnostic pop
@ -86,13 +87,17 @@ public slots:
void ClosedDialogSplinePath(int result);
void ToolPointOfContact(bool checked);
void ClosedDialogPointOfContact(int result);
void ToolDetail(bool checked);
void ClosedDialogDetail(int result);
protected:
virtual void keyPressEvent ( QKeyEvent * event );
virtual void showEvent( QShowEvent *event );
private:
Ui::MainWindow *ui;
Tools::Enum tool;
VMainGraphicsScene *scene;
VMainGraphicsScene *currentScene;
VMainGraphicsScene *sceneDraw;
VMainGraphicsScene *sceneDetails;
QLabel *mouseCoordinate;
QLabel *helpLabel;
VMainGraphicsView *view;
@ -109,12 +114,14 @@ private:
QSharedPointer<DialogArc> dialogArc;
QSharedPointer<DialogSplinePath> dialogSplinePath;
QSharedPointer<DialogPointOfContact> dialogPointOfContact;
QSharedPointer<DialogDetail> dialogDetail;
DialogHistory *dialogHistory;
VDomDocument *doc;
VContainer *data;
QComboBox *comboBoxDraws;
QString fileName;
bool changeInFile;
Draw::Mode mode;
MainWindow(const MainWindow &window);
const MainWindow &operator=(const MainWindow &window);
void ToolBarOption();

View File

@ -30,7 +30,7 @@
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>4</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
@ -196,7 +196,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>150</width>
<width>100</width>
<height>58</height>
</rect>
</property>
@ -263,7 +263,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>150</width>
<width>100</width>
<height>58</height>
</rect>
</property>
@ -330,7 +330,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>150</width>
<width>98</width>
<height>58</height>
</rect>
</property>
@ -369,6 +369,41 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="page_5">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>150</width>
<height>427</height>
</rect>
</property>
<attribute name="label">
<string>Деталі</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QToolButton" name="toolButtonNewDetail">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<normaloff>:/icon/32x32/new_detail.png</normaloff>:/icon/32x32/new_detail.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>
</widget>
</widget>
</item>
<item>

View File

@ -1,11 +1,16 @@
#ifndef OPTIONS_H
#define OPTIONS_H
#include <QtGlobal>
#define PrintDPI 96
#define PaperSize 50000
#define widthMainLine 0.8*PrintDPI/25.4
#define toPixel(mm) ((mm / 25.4) * PrintDPI)
#define toMM(pix) ((pix / PrintDPI) * 25.4)
#define widthMainLine toPixel(0.8)
#define widthHairLine widthMainLine/3
namespace Scene{
enum Type
{
@ -32,7 +37,16 @@ namespace Tools{
SplineTool,
ArcTool,
SplinePathTool,
PointOfContact
PointOfContact,
Detail
};
}
namespace Draw{
enum Mode
{
Calculation,
Modeling
};
}

View File

@ -7,9 +7,9 @@
#include <QDebug>
#pragma GCC diagnostic pop
VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent):
VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, QObject *parent):
VDataTool(data, parent), doc(doc), id(id), ignoreContextMenuEvent(false), nameActivDraw(QString()),
baseColor(Qt::black), currentColor(Qt::black){
baseColor(Qt::black), currentColor(Qt::black), mode(mode){
this->doc = doc;
this->id = id;
nameActivDraw = doc->GetNameActivDraw();
@ -70,24 +70,31 @@ void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, c
VAbstractTool::~VAbstractTool(){
}
void VAbstractTool::AddToCalculation(const QDomElement &domElement){
void VAbstractTool::AddToDraw(const QDomElement &domElement){
QDomElement calcElement;
bool ok = doc->GetActivCalculationElement(calcElement);
if(ok){
qint64 id = doc->getCursor();
if(id <= 0){
if(mode == Draw::Modeling){
bool ok = doc->GetActivModelingElement(calcElement);
if(ok){
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()<<"Не можу знайти тег калькуляції."<< Q_FUNC_INFO;
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()<<"Не можу знайти тег калькуляції."<< Q_FUNC_INFO;
}
}
emit toolhaveChange();
}
@ -100,9 +107,6 @@ void VAbstractTool::setData(const VContainer &value){
data = value;
}
void VAbstractTool::RemoveDataTool(){
}
void VAbstractTool::setDialog(){
}
@ -123,3 +127,7 @@ void VAbstractTool::AddRecord(const qint64 id, Tools::Enum toolType, VDomDocumen
history->insert(index+1, VToolRecord(id, toolType, doc->GetNameActivDraw()));
}
}
void VAbstractTool::ignoreContextMenu(bool enable){
ignoreContextMenuEvent = enable;
}

View File

@ -24,10 +24,12 @@ class VAbstractTool:public VDataTool
{
Q_OBJECT
public:
VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent = 0);
VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode,
QObject *parent = 0);
virtual ~VAbstractTool();
virtual void setDialog();
static void AddRecord(const qint64 id, Tools::Enum toolType, VDomDocument *doc);
void ignoreContextMenu(bool enable);
public slots:
virtual void FullUpdateFromFile()=0;
void ChangedNameDraw(const QString oldName, const QString newName);
@ -46,15 +48,15 @@ protected:
QString nameActivDraw;
const Qt::GlobalColor baseColor;
Qt::GlobalColor currentColor;
Draw::Mode mode;
virtual void AddToFile()=0;
void AddAttribute(QDomElement &domElement, const QString &name, const qint64 &value);
void AddAttribute(QDomElement &domElement, const QString &name, const qint32 &value);
void AddAttribute(QDomElement &domElement, const QString &name, const qreal &value);
void AddAttribute(QDomElement &domElement, const QString &name, const QString &value);
void AddToCalculation(const QDomElement &domElement);
void AddToDraw(const QDomElement &domElement);
const VContainer *getData() const;
void setData(const VContainer &value);
virtual void RemoveDataTool();
template <typename Dialog, typename Tool>
void ContextMenu(QSharedPointer<Dialog> &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event,
bool showRemove = true){
@ -80,14 +82,13 @@ protected:
dialog->show();
}
if(selectedAction == actionRemove){
RemoveDataTool();//remove form data
//remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
QDomElement calcElement;
bool ok = doc->GetActivCalculationElement(calcElement);
QDomElement element;
bool ok = doc->GetActivCalculationElement(element);
if(ok){
calcElement.removeChild(domElement);
element.removeChild(domElement);
//update xml file
emit FullUpdateTree();
//remove form scene

96
tools/vmodelingarc.cpp Normal file
View File

@ -0,0 +1,96 @@
#include "vmodelingarc.h"
VModelingArc::VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, Draw::Mode typeobject,
Tool::Enum typeCreation, QGraphicsItem * parent):VAbstractTool(doc, data, id, Draw::Modeling),
QGraphicsPathItem(parent), idArc(idArc), typeobject(typeobject){
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();
}
}
VModelingArc *VModelingArc::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc,
Draw::Mode typeobject, Document::Enum parse, Tool::Enum typeCreation){
VModelingArc *arc;
if(parse == Document::FullParse){
arc = new VModelingArc(doc, data, id, idArc, typeobject, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, arc);
} else {
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
}
}
return arc;
}
void VModelingArc::FullUpdateFromFile(){
RefreshGeometry();
}
void VModelingArc::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 VModelingArc::FullUpdateFromGui(int result)
{
}
void VModelingArc::AddToFile(){
QDomElement domElement = doc->createElement("arc");
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "modeling");
AddAttribute(domElement, "idObject", idArc);
if(typeobject == Draw::Calculation){
AddAttribute(domElement, "typeObject", "Calculation");
} else {
AddAttribute(domElement, "typeObject", "Modeling");
}
AddToDraw(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);
}

30
tools/vmodelingarc.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef VMODELINGARC_H
#define VMODELINGARC_H
#include "vabstracttool.h"
#include <QGraphicsPathItem>
class VModelingArc :public VAbstractTool, public QGraphicsPathItem
{
Q_OBJECT
public:
VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc, Draw::Mode typeobject,
Tool::Enum typeCreation, QGraphicsItem * parent = 0);
static VModelingArc *Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idArc,
Draw::Mode typeobject, Document::Enum parse, Tool::Enum typeCreation);
public slots:
virtual void FullUpdateFromFile();
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
virtual void FullUpdateFromGui(int result);
protected:
virtual void AddToFile();
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
qint64 idArc;
Draw::Mode typeobject;
void RefreshGeometry();
};
#endif // VMODELINGARC_H

55
tools/vmodelingpoint.cpp Normal file
View File

@ -0,0 +1,55 @@
#include "vmodelingpoint.h"
VModelingPoint::VModelingPoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint,
Draw::Mode typeobject, Tool::Enum typeCreation, QGraphicsItem *parent)
:VToolPoint(doc, data, id, Draw::Modeling, parent), idPoint(idPoint), typeobject(typeobject){
disconnect(this->doc, &VDomDocument::ChangedActivDraw, this, &VModelingPoint::ChangedActivDraw);
disconnect(this->doc, &VDomDocument::ChangedNameDraw, this, &VModelingPoint::ChangedNameDraw);
if(typeCreation == Tool::FromGui){
AddToFile();
}
}
VModelingPoint *VModelingPoint::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint,
Draw::Mode typeobject, Document::Enum parse, Tool::Enum typeCreation){
VModelingPoint *point;
if(parse == Document::FullParse){
point = new VModelingPoint(doc, data, id, idPoint, typeobject, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, point);
} else {
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
}
}
return point;
}
void VModelingPoint::FullUpdateFromFile(){
RefreshGeometry();
}
void VModelingPoint::FullUpdateFromGui(int result)
{
}
void VModelingPoint::AddToFile(){
VPointF point = VAbstractTool::data.GetModelingPoint(id);
QDomElement domElement = doc->createElement("point");
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "modeling");
AddAttribute(domElement, "idObject", idPoint);
if(typeobject == Draw::Calculation){
AddAttribute(domElement, "typeObject", "Calculation");
} else {
AddAttribute(domElement, "typeObject", "Modeling");
}
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
AddToDraw(domElement);
}

24
tools/vmodelingpoint.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef VMODELINGPOINT_H
#define VMODELINGPOINT_H
#include "vtoolpoint.h"
class VModelingPoint: public VToolPoint
{
Q_OBJECT
public:
VModelingPoint(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint, Draw::Mode typeobject,
Tool::Enum typeCreation, QGraphicsItem * parent = 0 );
static VModelingPoint *Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idPoint,
Draw::Mode typeobject, Document::Enum parse, Tool::Enum typeCreation);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);
protected:
virtual void AddToFile();
private:
qint64 idPoint;
Draw::Mode typeobject;
};
#endif // VMODELINGPOINT_H

97
tools/vmodelingspline.cpp Normal file
View File

@ -0,0 +1,97 @@
#include "vmodelingspline.h"
VModelingSpline::VModelingSpline(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
Draw::Mode typeobject, Tool::Enum typeCreation, QGraphicsItem * parent)
:VAbstractTool(doc, data, id, Draw::Modeling), QGraphicsPathItem(parent), idSpline(idSpline),
typeobject(typeobject){
VSpline spl = data->GetModelingSpline(id);
QPainterPath path;
path.addPath(spl.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();
}
}
VModelingSpline *VModelingSpline::Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
Draw::Mode typeobject, Document::Enum parse, Tool::Enum typeCreation){
VModelingSpline *spl;
if(parse == Document::FullParse){
spl = new VModelingSpline(doc, data, id, idSpline, typeobject, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, spl);
} else {
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
}
}
return spl;
}
void VModelingSpline::FullUpdateFromFile(){
RefreshGeometry();
}
void VModelingSpline::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 VModelingSpline::FullUpdateFromGui(int result)
{
}
void VModelingSpline::AddToFile(){
QDomElement domElement = doc->createElement("spline");
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "modelingSpline");
AddAttribute(domElement, "idObject", idSpline);
if(typeobject == Draw::Calculation){
AddAttribute(domElement, "typeObject", "Calculation");
} else {
AddAttribute(domElement, "typeObject", "Modeling");
}
AddToDraw(domElement);
}
void VModelingSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
if(event->button() == Qt::LeftButton){
emit ChoosedTool(id, Scene::Spline);
}
QGraphicsItem::mouseReleaseEvent(event);
}
void VModelingSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine));
}
void VModelingSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine));
}
void VModelingSpline::RefreshGeometry(){
VSpline spl = VAbstractTool::data.GetModelingSpline(id);
QPainterPath path;
path.addPath(spl.GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
}

30
tools/vmodelingspline.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef VMODELINGSPLINE_H
#define VMODELINGSPLINE_H
#include "vabstracttool.h"
#include <QGraphicsPathItem>
class VModelingSpline:public VAbstractTool, public QGraphicsPathItem
{
Q_OBJECT
public:
VModelingSpline(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline, Draw::Mode typeobject,
Tool::Enum typeCreation, QGraphicsItem * parent = 0);
static VModelingSpline *Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
Draw::Mode typeobject, Document::Enum parse, Tool::Enum typeCreation);
public slots:
virtual void FullUpdateFromFile ();
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
virtual void FullUpdateFromGui(int result);
protected:
virtual void AddToFile ();
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
qint64 idSpline;
Draw::Mode typeobject;
void RefreshGeometry ();
};
#endif // VMODELINGSPLINE_H

View File

@ -0,0 +1,98 @@
#include "vmodelingsplinepath.h"
VModelingSplinePath::VModelingSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
Draw::Mode typeobject, Tool::Enum typeCreation,
QGraphicsItem * parent):VAbstractTool(doc, data, id, Draw::Modeling),
QGraphicsPathItem(parent), idSpline(idSpline), typeobject(typeobject){
VSplinePath splPath = data->GetModelingSplinePath(id);
QPainterPath path;
path.addPath(splPath.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();
}
}
VModelingSplinePath *VModelingSplinePath::Create(VDomDocument *doc, VContainer *data, qint64 id,
qint64 idSpline, Draw::Mode typeobject, Document::Enum parse,
Tool::Enum typeCreation){
VModelingSplinePath *splPath;
if(parse == Document::FullParse){
splPath = new VModelingSplinePath(doc, data, id, idSpline, typeobject, typeCreation);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, splPath);
} else {
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
}
}
return splPath;
}
void VModelingSplinePath::FullUpdateFromFile(){
RefreshGeometry();
}
void VModelingSplinePath::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 VModelingSplinePath::FullUpdateFromGui(int result)
{
}
void VModelingSplinePath::AddToFile(){
QDomElement domElement = doc->createElement("spline");
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "modelingPath");
AddAttribute(domElement, "idObject", idSpline);
if(typeobject == Draw::Calculation){
AddAttribute(domElement, "typeObject", "Calculation");
} else {
AddAttribute(domElement, "typeObject", "Modeling");
}
AddToDraw(domElement);
}
void VModelingSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
if(event->button() == Qt::LeftButton){
emit ChoosedTool(id, Scene::SplinePath);
}
QGraphicsItem::mouseReleaseEvent(event);
}
void VModelingSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine));
}
void VModelingSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine));
}
void VModelingSplinePath::RefreshGeometry(){
VSplinePath splPath = VAbstractTool::data.GetModelingSplinePath(id);
QPainterPath path;
path.addPath(splPath.GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
}

View File

@ -0,0 +1,30 @@
#ifndef VMODELINGSPLINEPATH_H
#define VMODELINGSPLINEPATH_H
#include "vabstracttool.h"
#include <QGraphicsPathItem>
class VModelingSplinePath:public VAbstractTool, public QGraphicsPathItem
{
Q_OBJECT
public:
VModelingSplinePath(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
Draw::Mode typeobject, Tool::Enum typeCreation, QGraphicsItem * parent = 0);
static VModelingSplinePath *Create(VDomDocument *doc, VContainer *data, qint64 id, qint64 idSpline,
Draw::Mode typeobject, Document::Enum parse, Tool::Enum typeCreation);
public slots:
virtual void FullUpdateFromFile();
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
virtual void FullUpdateFromGui(int result);
protected:
virtual void AddToFile();
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
qint64 idSpline;
Draw::Mode typeobject;
void RefreshGeometry();
};
#endif // VMODELINGSPLINEPATH_H

View File

@ -7,11 +7,11 @@
#pragma GCC diagnostic pop
#include "../container/calculator.h"
VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, const QString &formula,
const qint64 &firstPointId, const qint64 &secondPointId,
const QString &typeLine, Tool::Enum typeCreation,
QGraphicsItem *parent):
VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId),
VToolLinePoint(doc, data, id, mode, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId),
dialogAlongLine(QSharedPointer<DialogAlongLine>()){
if(typeCreation == Tool::FromGui){
@ -51,7 +51,12 @@ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
}
void VToolAlongLine::AddToFile(){
VPointF point = VAbstractTool::data.GetPoint(id);
VPointF point;
if(mode == Draw::Calculation){
point = VAbstractTool::data.GetPoint(id);
} else {
point = VAbstractTool::data.GetModelingPoint(id);
}
QDomElement domElement = doc->createElement("point");
AddAttribute(domElement, "id", id);
@ -65,7 +70,7 @@ void VToolAlongLine::AddToFile(){
AddAttribute(domElement, "firstPoint", basePointId);
AddAttribute(domElement, "secondPoint", secondPointId);
AddToCalculation(domElement);
AddToDraw(domElement);
}
void VToolAlongLine::setDialog(){
@ -81,20 +86,20 @@ void VToolAlongLine::setDialog(){
}
void VToolAlongLine::Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){
VDomDocument *doc, VContainer *data, Draw::Mode mode){
QString formula = dialog->getFormula();
qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId();
QString typeLine = dialog->getTypeLine();
QString pointName = dialog->getPointName();
Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, scene, doc, data,
Document::FullParse, Tool::FromGui);
Document::FullParse, Tool::FromGui, mode);
}
void VToolAlongLine::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, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId);
QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF());
@ -111,15 +116,22 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
tool->VDataTool::setData(data);
tools->insert(id, tool);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
data->IncrementReferens(id, Scene::Point);
}
}
}
VAbstractTool::AddRecord(id, Tools::AlongLineTool, doc);
data->AddLine(firstPointId, id);
data->AddLine(id, secondPointId);
if(mode == Draw::Modeling){
data->IncrementReferens(firstPointId, Scene::Point);
data->IncrementReferens(secondPointId, Scene::Point);
}
if(parse == Document::FullParse){
VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId,
VToolAlongLine *point = new VToolAlongLine(doc, data, id, mode, formula, firstPointId,
secondPointId, typeLine, typeCreation);
scene->addItem(point);
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);

View File

@ -11,16 +11,16 @@ class VToolAlongLine : public VToolLinePoint
{
Q_OBJECT
public:
VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, const QString &formula,
const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine,
Tool::Enum typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
VContainer *data, Draw::Mode mode);
static void 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, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);

View File

@ -8,8 +8,8 @@
#pragma GCC diagnostic pop
#include "../container/calculator.h"
VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
QGraphicsItem *parent):VAbstractTool(doc, data, id), QGraphicsPathItem(parent),
VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, Tool::Enum typeCreation,
QGraphicsItem *parent):VAbstractTool(doc, data, id, mode), QGraphicsPathItem(parent),
dialogArc(QSharedPointer<DialogArc>()){
VArc arc = data->GetArc(id);
QPainterPath path;
@ -37,17 +37,17 @@ void VToolArc::setDialog(){
}
void VToolArc::Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data){
VContainer *data, Draw::Mode mode){
qint64 center = dialog->GetCenter();
QString radius = dialog->GetRadius();
QString f1 = dialog->GetF1();
QString f2 = dialog->GetF2();
Create(0, center, radius, f1, f2, scene, doc, data, Document::FullParse, Tool::FromGui);
Create(0, center, radius, f1, f2, scene, doc, data, Document::FullParse, Tool::FromGui, mode);
}
void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &radius, const QString &f1,
const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
Calculator cal(data);
@ -78,14 +78,20 @@ void VToolArc::Create(const qint64 _id, const qint64 &center, const QString &rad
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
tool->VDataTool::setData(data);
tools->insert(id, tool);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
data->IncrementReferens(id, Scene::Arc);
}
}
}
data->AddLengthArc(data->GetNameArc(center,id), arc.GetLength());
VAbstractTool::AddRecord(id, Tools::ArcTool, doc);
if(mode == Draw::Modeling){
data->IncrementReferens(center, Scene::Point);
}
if(parse == Document::FullParse){
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation);
VToolArc *toolArc = new VToolArc(doc, data, id, mode, typeCreation);
scene->addItem(toolArc);
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(toolArc, &VToolArc::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
@ -143,7 +149,12 @@ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
}
void VToolArc::AddToFile(){
VArc arc = VAbstractTool::data.GetArc(id);
VArc arc;
if(mode == Draw::Calculation){
arc = VAbstractTool::data.GetArc(id);
} else {
arc = VAbstractTool::data.GetModelingArc(id);
}
QDomElement domElement = doc->createElement("arc");
AddAttribute(domElement, "id", id);
@ -153,7 +164,7 @@ void VToolArc::AddToFile(){
AddAttribute(domElement, "angle1", arc.GetFormulaF1());
AddAttribute(domElement, "angle2", arc.GetFormulaF2());
AddToCalculation(domElement);
AddToDraw(domElement);
}
void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){

View File

@ -18,14 +18,14 @@ class VToolArc :public VAbstractTool, public QGraphicsPathItem
{
Q_OBJECT
public:
VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, Tool::Enum typeCreation,
QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
VContainer *data, Draw::Mode mode);
static void Create(const qint64 _id, const qint64 &center, const QString &radius,
const QString &f1, const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);

View File

@ -3,10 +3,11 @@
#include <QMenu>
#pragma GCC diagnostic warning "-Weffc++"
VToolBisector::VToolBisector(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):
VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(0),
VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
const QString &typeLine, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Enum typeCreation,
QGraphicsItem *parent):
VToolLinePoint(doc, data, id, mode, typeLine, formula, secondPointId, 0, parent), firstPointId(0),
thirdPointId(0), dialogBisector(QSharedPointer<DialogBisector>()){
this->firstPointId = firstPointId;
this->thirdPointId = thirdPointId;
@ -43,7 +44,7 @@ void VToolBisector::setDialog(){
}
void VToolBisector::Create(QSharedPointer<DialogBisector> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){
VDomDocument *doc, VContainer *data, Draw::Mode mode){
QString formula = dialog->getFormula();
qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId();
@ -51,14 +52,14 @@ void VToolBisector::Create(QSharedPointer<DialogBisector> &dialog, VMainGraphics
QString typeLine = dialog->getTypeLine();
QString pointName = dialog->getPointName();
Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data,
Document::FullParse, Tool::FromGui);
Document::FullParse, Tool::FromGui, mode);
}
void VToolBisector::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,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
Document::Enum parse, Tool::Enum typeCreation){
Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId);
VPointF thirdPoint = data->GetPoint(thirdPointId);
@ -77,14 +78,22 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
tool->VDataTool::setData(data);
tools->insert(id, tool);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
data->IncrementReferens(id, Scene::Point);
}
}
}
data->AddLine(firstPointId, id);
VAbstractTool::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){
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula,
VToolBisector *point = new VToolBisector(doc, data, id, mode, typeLine, formula,
firstPointId, secondPointId, thirdPointId,
typeCreation);
scene->addItem(point);
@ -129,7 +138,12 @@ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
}
void VToolBisector::AddToFile(){
VPointF point = VAbstractTool::data.GetPoint(id);
VPointF point;
if(mode == Draw::Calculation){
point = VAbstractTool::data.GetPoint(id);
} else {
point = VAbstractTool::data.GetModelingPoint(id);
}
QDomElement domElement = doc->createElement("point");
AddAttribute(domElement, "id", id);
@ -144,5 +158,5 @@ void VToolBisector::AddToFile(){
AddAttribute(domElement, "secondPoint", basePointId);
AddAttribute(domElement, "thirdPoint", thirdPointId);
AddToCalculation(domElement);
AddToDraw(domElement);
}

View File

@ -10,18 +10,20 @@
class VToolBisector : public VToolLinePoint
{
public:
VToolBisector(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);
VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
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 void Create(QSharedPointer<DialogBisector> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
VContainer *data, Draw::Mode mode);
static void 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, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, Document::Enum parse, Tool::Enum typeCreation,
Draw::Mode mode);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);

268
tools/vtooldetail.cpp Normal file
View File

@ -0,0 +1,268 @@
#include "vtooldetail.h"
#include "vmodelingpoint.h"
#include "vmodelingarc.h"
#include "vmodelingspline.h"
#include "vmodelingsplinepath.h"
#include <QDebug>
VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, VDetail &oldDetail,
Tool::Enum typeCreation, Document::Enum parse,
VMainGraphicsScene *scene, QGraphicsItem *parent)
:VAbstractTool(doc, data, id, Draw::Modeling), QGraphicsPathItem(parent),
dialogDetail(QSharedPointer<DialogDetail>()){
VDetail detail = data->GetDetail(id);
for(qint32 i = 0; i< detail.CountNode(); ++i){
switch(detail[i].getTypeTool()){
case(Scene::Point):{
VModelingPoint *point = VModelingPoint::Create(doc, data, detail[i].getId(), oldDetail[i].getId(),
detail[i].getMode(), parse, typeCreation);
connect(point, &VModelingPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(),point);
point->setParentItem(this);
}
break;
case(Scene::Arc):{
VModelingArc *arc = VModelingArc::Create(doc, data, detail[i].getId(), oldDetail[i].getId(),
detail[i].getMode(), parse, typeCreation);
connect(arc, &VModelingArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(), arc);
arc->setParentItem(this);
}
break;
case(Scene::Spline):{
VModelingSpline *spl = VModelingSpline::Create(doc, data, detail[i].getId(), oldDetail[i].getId(),
detail[i].getMode(), parse, typeCreation);
connect(spl, &VModelingSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(), spl);
spl->setParentItem(this);
}
break;
case(Scene::SplinePath):{
VModelingSplinePath *splPath = VModelingSplinePath::Create(doc, data, detail[i].getId(),
oldDetail[i].getId(),
detail[i].getMode(), parse,
typeCreation);
connect(splPath, &VModelingSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(detail[i].getId(), splPath);
splPath->setParentItem(this);
}
break;
}
}
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
RefreshGeometry();
this->setPos(detail.getMx(), detail.getMy());
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
if(typeCreation == Tool::FromGui){
AddToFile();
}
}
void VToolDetail::setDialog(){
Q_ASSERT(!dialogDetail.isNull());
if(!dialogDetail.isNull()){
VDetail detail = VAbstractTool::data.GetDetail(id);
dialogDetail->setDetails(detail);
}
}
void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data){
VDetail detail = dialog->getDetails();
VDetail det;
for(qint32 i = 0; i< detail.CountNode(); ++i){
qint64 id = 0;
switch(detail[i].getTypeTool()){
case(Scene::Point):{
VPointF point;
if(detail[i].getMode() == Draw::Calculation){
point = data->GetPoint(detail[i].getId());
} else {
point = data->GetModelingPoint(detail[i].getId());
}
id = data->AddModelingPoint(point);
}
break;
case(Scene::Arc):{
VArc arc;
if(detail[i].getMode() == Draw::Calculation){
arc = data->GetArc(detail[i].getId());
} else {
arc = data->GetModelingArc(detail[i].getId());
}
id = data->AddModelingArc(arc);
}
break;
case(Scene::Spline):{
VSpline spline;
if(detail[i].getMode() == Draw::Calculation){
spline = data->GetSpline(detail[i].getId());
} else {
spline = data->GetModelingSpline(detail[i].getId());
}
id = data->AddModelingSpline(spline);
}
break;
case(Scene::SplinePath):{
VSplinePath splinePath;
if(detail[i].getMode() == Draw::Calculation){
splinePath = data->GetSplinePath(detail[i].getId());
} else {
splinePath = data->GetModelingSplinePath(detail[i].getId());
}
id = data->AddModelingSplinePath(splinePath);
}
break;
case(Scene::Line):
break;
}
VNodeDetail node(id, detail[i].getTypeTool(), detail[i].getMode());
det.append(node);
}
det.setName(detail.getName());
Create(0, det, detail, scene, doc, data, Document::FullParse, Tool::FromGui);
}
void VToolDetail::Create(const qint64 _id, VDetail &newDetail, VDetail &oldDetail,
VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){
qint64 id = _id;
if(typeCreation == Tool::FromGui){
id = data->AddDetail(newDetail);
} else {
data->UpdateDetail(id, newDetail);
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
}
for(qint32 i = 0; i< newDetail.CountNode(); ++i){
VDataTool *tool = tools->value(newDetail[i].getId());
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
}
}
}
}
if(parse == Document::FullParse){
VToolDetail *detail = new VToolDetail(doc, data, id, oldDetail, typeCreation, parse, scene);
scene->addItem(detail);
//connect(detail, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
//connect(detail, &VToolBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
QMap<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, detail);
}
}
void VToolDetail::FullUpdateFromFile(){
RefreshGeometry();
}
void VToolDetail::FullUpdateFromGui(int result)
{
}
void VToolDetail::AddToFile(){
VDetail detail = VAbstractTool::data.GetDetail(id);
QDomElement domElement = doc->createElement("detail");
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "name", detail.getName());
AddAttribute(domElement, "mx", detail.getMx());
AddAttribute(domElement, "my", detail.getMy());
for(qint32 i = 0; i < detail.CountNode(); ++i){
AddNode(domElement, detail[i]);
}
QDomElement element;
bool ok = doc->GetActivDetailsElement(element);
if(ok){
element.appendChild(domElement);
}
}
QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value){
if (change == ItemPositionHasChanged && scene()) {
// value - это новое положение.
QPointF newPos = value.toPointF();
qDebug()<<newPos;
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
domElement.setAttribute("mx", QString().setNum(toMM(newPos.x())));
domElement.setAttribute("my", QString().setNum(toMM(newPos.y())));
//I don't now why but signal does not work.
doc->FullUpdateTree();
}
}
return QGraphicsItem::itemChange(change, value);
}
void VToolDetail::AddNode(QDomElement &domElement, VNodeDetail &node){
QDomElement nod = doc->createElement("node");
AddAttribute(nod, "id", node.getId());
switch(node.getTypeTool()){
case(Scene::Point):
AddAttribute(nod, "type", "Point");
break;
case(Scene::Arc):
AddAttribute(nod, "type", "Arc");
break;
case(Scene::Spline):
AddAttribute(nod, "type", "Spline");
break;
case(Scene::SplinePath):
AddAttribute(nod, "type", "SplinePath");
break;
}
domElement.appendChild(nod);
}
void VToolDetail::RefreshGeometry(){
QVector<QPointF> points;
VDetail detail = VAbstractTool::data.GetDetail(id);
for(qint32 i = 0; i< detail.CountNode(); ++i){
switch(detail[i].getTypeTool()){
case(Scene::Point):{
VPointF point = VAbstractTool::data.GetModelingPoint(detail[i].getId());
points.append(point.toQPointF());
}
break;
case(Scene::Arc):{
VArc arc = VAbstractTool::data.GetModelingArc(detail[i].getId());
points << arc.GetPoints();
}
break;
case(Scene::Spline):{
VSpline spline = VAbstractTool::data.GetModelingSpline(detail[i].getId());
points << spline.GetPoints();
}
break;
case(Scene::SplinePath):{
VSplinePath splinePath = VAbstractTool::data.GetModelingSplinePath(detail[i].getId());
points << splinePath.GetPathPoints();
}
break;
}
}
QPainterPath path;
path.moveTo(points[0]);
for (qint32 i = 1; i < points.count(); ++i){
path.lineTo(points[i]);
}
path.lineTo(points[0]);
this->setPath(path);
//this->setPos(detail.getMx(), detail.getMy());
}

33
tools/vtooldetail.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef VTOOLDETAIL_H
#define VTOOLDETAIL_H
#include "vabstracttool.h"
#include <QGraphicsPathItem>
#include "../dialogs/dialogdetail.h"
class VToolDetail: public VAbstractTool, public QGraphicsPathItem
{
Q_OBJECT
public:
VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, VDetail &oldDetail,
Tool::Enum typeCreation, Document::Enum parse, VMainGraphicsScene *scene,
QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
static void Create(const qint64 _id, VDetail &newDetail, VDetail &oldDetail,
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 AddToFile ();
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
private:
QSharedPointer<DialogDetail> dialogDetail;
void RefreshGeometry ();
void AddNode(QDomElement &domElement, VNodeDetail &node);
};
#endif // VTOOLDETAIL_H

View File

@ -6,10 +6,10 @@
#include "../widgets/vmaingraphicsscene.h"
#pragma GCC diagnostic pop
VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode, const QString &typeLine,
const QString &formula, const qint32 &angle, const qint64 &basePointId,
Tool::Enum typeCreation, QGraphicsItem *parent):
VToolLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent),
VToolLinePoint(doc, data, id, mode, typeLine, formula, basePointId, angle, parent),
dialogEndLine(QSharedPointer<DialogEndLine>()){
if(typeCreation == Tool::FromGui){
@ -30,20 +30,20 @@ void VToolEndLine::setDialog(){
}
void VToolEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data){
VContainer *data, Draw::Mode mode){
QString pointName = dialog->getPointName();
QString typeLine = dialog->getTypeLine();
QString formula = dialog->getFormula();
qint32 angle = dialog->getAngle();
qint64 basePointId = dialog->getBasePointId();
Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse,
Tool::FromGui);
Tool::FromGui, mode);
}
void VToolEndLine::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, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
VPointF basePoint = data->GetPoint(basePointId);
QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y()));
@ -61,14 +61,20 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
tool->VDataTool::setData(data);
tools->insert(id, tool);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
data->IncrementReferens(id, Scene::Point);
}
}
}
data->AddLine(basePointId, id);
VAbstractTool::AddRecord(id, Tools::EndLineTool, doc);
if(mode == Draw::Modeling){
data->IncrementReferens(basePointId, Scene::Point);
}
if(parse == Document::FullParse){
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formula, angle,
VToolEndLine *point = new VToolEndLine(doc, data, id, mode, typeLine, formula, angle,
basePointId, typeCreation);
scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
@ -110,7 +116,12 @@ void VToolEndLine::FullUpdateFromGui(int result){
}
void VToolEndLine::AddToFile(){
VPointF point = VAbstractTool::data.GetPoint(id);
VPointF point;
if(mode == Draw::Calculation){
point = VAbstractTool::data.GetPoint(id);
} else {
point = VAbstractTool::data.GetModelingPoint(id);
}
QDomElement domElement = doc->createElement("point");
AddAttribute(domElement, "id", id);
@ -124,6 +135,6 @@ void VToolEndLine::AddToFile(){
AddAttribute(domElement, "angle", angle);
AddAttribute(domElement, "basePoint", basePointId);
AddToCalculation(domElement);
AddToDraw(domElement);
}

View File

@ -12,17 +12,17 @@ class VToolEndLine : public VToolLinePoint
{
Q_OBJECT
public:
VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id,
VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
const QString &typeLine, const QString &formula, const qint32 &angle,
const qint64 &basePointId, Tool::Enum typeCreation,
QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
VContainer *data, Draw::Mode mode);
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,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
Tool::Enum typeCreation);
Tool::Enum typeCreation, Draw::Mode mode);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);

View File

@ -8,8 +8,8 @@
#include <QDebug>
#pragma GCC diagnostic pop
VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint,
Tool::Enum typeCreation, QGraphicsItem *parent):VAbstractTool(doc, data, id),
VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, qint64 firstPoint, qint64 secondPoint,
Tool::Enum typeCreation, QGraphicsItem *parent):VAbstractTool(doc, data, id, mode),
QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint),
dialogLine(QSharedPointer<DialogLine>()){
//Лінія
@ -31,26 +31,36 @@ void VToolLine::setDialog(){
}
void VToolLine::Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data){
VContainer *data, Draw::Mode mode){
qint64 firstPoint = dialog->getFirstPoint();
qint64 secondPoint = dialog->getSecondPoint();
Create(0, firstPoint, secondPoint, scene, doc, data, Document::FullParse, Tool::FromGui);
Create(0, firstPoint, secondPoint, scene, doc, data, Document::FullParse, Tool::FromGui, mode);
}
void VToolLine::Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
Tool::Enum typeCreation){
Tool::Enum typeCreation, Draw::Mode mode){
Q_CHECK_PTR(scene);
Q_CHECK_PTR(doc);
Q_CHECK_PTR(data);
data->AddLine(firstPoint, secondPoint);
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);
tools->insert(id, tool);
}
VAbstractTool::AddRecord(id, Tools::LineTool, doc);
if(mode == Draw::Modeling){
data->IncrementReferens(firstPoint, Scene::Point);
data->IncrementReferens(secondPoint, Scene::Point);
}
if(parse == Document::FullParse){
qint64 id = data->getNextId();
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeCreation);
VToolLine *line = new VToolLine(doc, data, id, mode, firstPoint, secondPoint, typeCreation);
Q_CHECK_PTR(line);
scene->addItem(line);
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(line, &VToolLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
@ -117,7 +127,7 @@ void VToolLine::AddToFile(){
AddAttribute(domElement, "firstPoint", firstPoint);
AddAttribute(domElement, "secondPoint", secondPoint);
AddToCalculation(domElement);
AddToDraw(domElement);
}
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event){

View File

@ -15,14 +15,14 @@ class VToolLine: public VAbstractTool, public QGraphicsLineItem
{
Q_OBJECT
public:
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint,
Tool::Enum typeCreation, QGraphicsItem * parent = 0);
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, qint64 firstPoint,
qint64 secondPoint, Tool::Enum typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
VContainer *data, Draw::Mode mode);
static void Create(const qint64 &id, const qint64 &firstPoint, const qint64 &secondPoint,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
Tool::Enum typeCreation);
Tool::Enum typeCreation, Draw::Mode mode);
public slots:
virtual void FullUpdateFromFile();
virtual void ChangedActivDraw(const QString newName);

View File

@ -7,11 +7,11 @@
#include <QMenu>
#pragma GCC diagnostic pop
VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id,
VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2, Tool::Enum typeCreation, QGraphicsItem *parent):
VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2), p2Line2(p2Line2),
dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){
VToolPoint(doc, data, id, mode, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){
if(typeCreation == Tool::FromGui){
AddToFile();
}
@ -30,20 +30,20 @@ void VToolLineIntersect::setDialog(){
}
void VToolLineIntersect::Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){
VDomDocument *doc, VContainer *data, Draw::Mode mode){
qint64 p1Line1Id = dialog->getP1Line1();
qint64 p2Line1Id = dialog->getP2Line1();
qint64 p1Line2Id = dialog->getP1Line2();
qint64 p2Line2Id = dialog->getP2Line2();
QString pointName = dialog->getPointName();
Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data,
Document::FullParse, Tool::FromGui);
Document::FullParse, Tool::FromGui, mode);
}
void VToolLineIntersect::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, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation){
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
VPointF p1Line1 = data->GetPoint(p1Line1Id);
VPointF p2Line1 = data->GetPoint(p2Line1Id);
VPointF p1Line2 = data->GetPoint(p1Line2Id);
@ -62,17 +62,26 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
tool->VDataTool::setData(data);
tools->insert(id, tool);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
data->IncrementReferens(id, Scene::Point);
}
}
}
data->AddLine(p1Line1Id, id);
data->AddLine(id, p2Line1Id);
data->AddLine(p1Line2Id, id);
data->AddLine(id, p2Line2Id);
if(mode == Draw::Modeling){
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){
VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id,
VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, mode, p1Line1Id,
p2Line1Id, p1Line2Id,
p2Line2Id, typeCreation);
scene->addItem(point);
@ -115,7 +124,12 @@ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
}
void VToolLineIntersect::AddToFile(){
VPointF point = VAbstractTool::data.GetPoint(id);
VPointF point;
if(mode == Draw::Calculation){
point = VAbstractTool::data.GetPoint(id);
} else {
point = VAbstractTool::data.GetModelingPoint(id);
}
QDomElement domElement = doc->createElement("point");
AddAttribute(domElement, "id", id);
@ -129,5 +143,5 @@ void VToolLineIntersect::AddToFile(){
AddAttribute(domElement, "p1Line2", p1Line2);
AddAttribute(domElement, "p2Line2", p2Line2);
AddToCalculation(domElement);
AddToDraw(domElement);
}

View File

@ -14,17 +14,18 @@ class VToolLineIntersect:public VToolPoint
{
public:
VToolLineIntersect(VDomDocument *doc, VContainer *data,
const qint64 &id, const qint64 &p1Line1,
const qint64 &id, Draw::Mode mode,
const qint64 &p1Line1,
const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2, Tool::Enum typeCreation,
QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc,VContainer *data);
VDomDocument *doc,VContainer *data, Draw::Mode mode);
static void 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, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);

View File

@ -6,9 +6,9 @@
#include "vtoollinepoint.h"
#pragma GCC diagnostic pop
VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode, const QString &typeLine,
const QString &formula, const qint64 &basePointId, const qint32 &angle,
QGraphicsItem *parent): VToolPoint(doc, data, id, parent), typeLine(typeLine), formula(formula),
QGraphicsItem *parent): VToolPoint(doc, data, id, mode, parent), typeLine(typeLine), formula(formula),
angle(angle), basePointId(basePointId), mainLine(0){
//Лінія, що з'єднує дві точки
QPointF point1 = data->GetPoint(basePointId).toQPointF();

View File

@ -9,7 +9,7 @@
class VToolLinePoint : public VToolPoint
{
public:
VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
const QString &typeLine, const QString &formula,
const qint64 &basePointId, const qint32 &angle, QGraphicsItem * parent = 0);
public slots:

View File

@ -7,10 +7,11 @@
#include <QMenu>
#pragma GCC diagnostic pop
VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &firstPointId,
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem *parent):
VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent),
VToolLinePoint(doc, data, id, mode, typeLine, formula, firstPointId, angle, parent),
secondPointId(secondPointId), dialogNormal(QSharedPointer<DialogNormal>()){
if(typeCreation == Tool::FromGui){
@ -33,7 +34,7 @@ void VToolNormal::setDialog(){
}
void VToolNormal::Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data){
VContainer *data, Draw::Mode mode){
QString formula = dialog->getFormula();
qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId();
@ -41,13 +42,14 @@ void VToolNormal::Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScen
QString pointName = dialog->getPointName();
qint32 angle = dialog->getAngle();
Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data,
Document::FullParse, Tool::FromGui);
Document::FullParse, Tool::FromGui, mode);
}
void VToolNormal::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, 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 secondPoint = data->GetPoint(secondPointId);
Calculator cal(data);
@ -64,14 +66,21 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
tool->VDataTool::setData(data);
tools->insert(id, tool);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
data->IncrementReferens(id, Scene::Point);
}
}
}
data->AddLine(firstPointId, id);
VAbstractTool::AddRecord(id, Tools::NormalTool, doc);
if(mode == Draw::Modeling){
data->IncrementReferens(firstPointId, Scene::Point);
data->IncrementReferens(secondPointId, Scene::Point);
}
if(parse == Document::FullParse){
VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle,
VToolNormal *point = new VToolNormal(doc, data, id, mode, typeLine, formula, angle,
firstPointId, secondPointId, typeCreation);
scene->addItem(point);
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
@ -124,7 +133,12 @@ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
}
void VToolNormal::AddToFile(){
VPointF point = VAbstractTool::data.GetPoint(id);
VPointF point;
if(mode == Draw::Calculation){
point = VAbstractTool::data.GetPoint(id);
} else {
point = VAbstractTool::data.GetModelingPoint(id);
}
QDomElement domElement = doc->createElement("point");
AddAttribute(domElement, "id", id);
@ -139,5 +153,5 @@ void VToolNormal::AddToFile(){
AddAttribute(domElement, "firstPoint", basePointId);
AddAttribute(domElement, "secondPoint", secondPointId);
AddToCalculation(domElement);
AddToDraw(domElement);
}

View File

@ -15,17 +15,19 @@ class VToolNormal : public VToolLinePoint
{
public:
VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
Draw::Mode mode,
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 void Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
VContainer *data, Draw::Mode mode);
static void 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, 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,
const qreal &length, const qreal &angle = 0);
public slots:

View File

@ -14,11 +14,16 @@
#include "../container/vpointf.h"
VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id,
QGraphicsItem *parent):VAbstractTool(doc, data, id), QGraphicsEllipseItem(parent),
VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode,
QGraphicsItem *parent):VAbstractTool(doc, data, id, mode), QGraphicsEllipseItem(parent),
radius(1.5*PrintDPI/25.4), namePoint(0), lineName(0){
//create circle
VPointF point = data->GetPoint(id);
VPointF point;
if(mode == Draw::Calculation){
point = data->GetPoint(id);
} else {
point = data->GetModelingPoint(id);
}
QRectF rec = QRectF(0, 0, radius*2, radius*2);
rec.translate(-rec.center().x(), -rec.center().y());
this->setRect(rec);
@ -41,7 +46,12 @@ VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id,
}
void VToolPoint::NameChangePosition(const QPointF pos){
VPointF point = VAbstractTool::data.GetPoint(id);
VPointF point;
if(mode == Draw::Calculation){
point = VAbstractTool::data.GetPoint(id);
} else {
point = VAbstractTool::data.GetModelingPoint(id);
}
QPointF p = pos - this->pos();
point.setMx(p.x());
point.setMy(p.y());
@ -77,10 +87,10 @@ QPointF VToolPoint::LineIntersectRect(QRectF rec, QLineF line) const{
void VToolPoint::RefreshLine(){
QRectF nameRec = namePoint->sceneBoundingRect();
QPointF p1, p2;
LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center()- pos()), p1, p2);
QPointF pRec = LineIntersectRect(nameRec, QLineF(pos(), nameRec.center()));
lineName->setLine(QLineF(p1, pRec - pos()));
if(QLineF(p1, pRec - pos()).length() <= 4*PrintDPI/25.4){
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);
@ -188,7 +198,12 @@ void VToolPoint::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){
}
void VToolPoint::RefreshGeometry(){
VPointF point = VAbstractTool::data.GetPoint(id);
VPointF point;
if(mode == Draw::Calculation){
point = VAbstractTool::data.GetPoint(id);
} else {
point = VAbstractTool::data.GetModelingPoint(id);
}
QRectF rec = QRectF(0, 0, radius*2, radius*2);
rec.translate(-rec.center().x(), -rec.center().y());
this->setRect(rec);

View File

@ -17,7 +17,7 @@ class VToolPoint: public VAbstractTool, public QGraphicsEllipseItem
{
Q_OBJECT
public:
VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem * parent = 0);
VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode, QGraphicsItem * parent = 0);
virtual ~VToolPoint();
public slots:
void NameChangePosition(const QPointF pos);

View File

@ -1,10 +1,11 @@
#include "vtoolpointofcontact.h"
VToolPointOfContact::VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
Draw::Mode mode,
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),
: VToolPoint(doc, data, id, mode, parent), radius(radius), center(center), firstPointId(firstPointId),
secondPointId(secondPointId), dialogPointOfContact(QSharedPointer<DialogPointOfContact>()){
if(typeCreation == Tool::FromGui){
@ -47,21 +48,21 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF &cente
}
void VToolPointOfContact::Create(QSharedPointer<DialogPointOfContact> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){
VDomDocument *doc, VContainer *data, Draw::Mode mode){
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);
Document::FullParse, Tool::FromGui, mode);
}
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){
Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
VPointF centerP = data->GetPoint(center);
VPointF firstP = data->GetPoint(firstPointId);
VPointF secondP = data->GetPoint(secondPointId);
@ -80,13 +81,21 @@ void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
tool->VDataTool::setData(data);
tools->insert(id, tool);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
data->IncrementReferens(id, Scene::Point);
}
}
}
VAbstractTool::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){
VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center,
VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, mode, radius, center,
firstPointId, secondPointId, typeCreation);
scene->addItem(point);
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
@ -128,7 +137,12 @@ void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event
}
void VToolPointOfContact::AddToFile(){
VPointF point = VAbstractTool::data.GetPoint(id);
VPointF point;
if(mode == Draw::Calculation){
point = VAbstractTool::data.GetPoint(id);
} else {
point = VAbstractTool::data.GetModelingPoint(id);
}
QDomElement domElement = doc->createElement("point");
AddAttribute(domElement, "id", id);
@ -142,5 +156,5 @@ void VToolPointOfContact::AddToFile(){
AddAttribute(domElement, "firstPoint", firstPointId);
AddAttribute(domElement, "secondPoint", secondPointId);
AddToCalculation(domElement);
AddToDraw(domElement);
}

View File

@ -7,18 +7,18 @@
class VToolPointOfContact : public VToolPoint
{
public:
VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
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);
VDomDocument *doc, VContainer *data, Draw::Mode mode);
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);
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);

View File

@ -8,11 +8,11 @@
#include <QMenu>
#pragma GCC diagnostic pop
VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
const QString &typeLine, const QString &formula, const qint64 &p1Line,
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation,
QGraphicsItem * parent):
VToolLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent), p2Line(p2Line), pShoulder(pShoulder),
VToolLinePoint(doc, data, id, mode, typeLine, formula, p1Line, 0, parent), p2Line(p2Line), pShoulder(pShoulder),
dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>()){
if(typeCreation == Tool::FromGui){
@ -56,7 +56,7 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li
}
void VToolShoulderPoint::Create(QSharedPointer<DialogShoulderPoint> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){
VDomDocument *doc, VContainer *data, Draw::Mode mode){
QString formula = dialog->getFormula();
qint64 p1Line = dialog->getP1Line();
qint64 p2Line = dialog->getP2Line();
@ -64,14 +64,14 @@ void VToolShoulderPoint::Create(QSharedPointer<DialogShoulderPoint> &dialog, VMa
QString typeLine = dialog->getTypeLine();
QString pointName = dialog->getPointName();
Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data,
Document::FullParse, Tool::FromGui);
Document::FullParse, Tool::FromGui, mode);
}
void VToolShoulderPoint::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,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
Document::Enum parse, Tool::Enum typeCreation){
Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode){
VPointF firstPoint = data->GetPoint(p1Line);
VPointF secondPoint = data->GetPoint(p2Line);
VPointF shoulderPoint = data->GetPoint(pShoulder);
@ -90,15 +90,23 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
tool->VDataTool::setData(data);
tools->insert(id, tool);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
data->IncrementReferens(id, Scene::Point);
}
}
}
data->AddLine(p1Line, id);
data->AddLine(p2Line, id);
VAbstractTool::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){
VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, formula,
VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, mode, typeLine, formula,
p1Line, p2Line, pShoulder,
typeCreation);
scene->addItem(point);
@ -143,7 +151,12 @@ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
}
void VToolShoulderPoint::AddToFile(){
VPointF point = VAbstractTool::data.GetPoint(id);
VPointF point;
if(mode == Draw::Calculation){
point = VAbstractTool::data.GetPoint(id);
} else {
point = VAbstractTool::data.GetModelingPoint(id);
}
QDomElement domElement = doc->createElement("point");
AddAttribute(domElement, "id", id);
@ -158,5 +171,5 @@ void VToolShoulderPoint::AddToFile(){
AddAttribute(domElement, "p2Line", p2Line);
AddAttribute(domElement, "pShoulder", pShoulder);
AddToCalculation(domElement);
AddToDraw(domElement);
}

View File

@ -13,7 +13,7 @@
class VToolShoulderPoint : public VToolLinePoint
{
public:
VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, Draw::Mode mode,
const QString &typeLine, const QString &formula, const qint64 &p1Line,
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation,
QGraphicsItem * parent = 0);
@ -21,11 +21,11 @@ public:
static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
const qreal &length);
static void Create(QSharedPointer<DialogShoulderPoint> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data);
VDomDocument *doc, VContainer *data, Draw::Mode mode);
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 qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, Document::Enum parse, Tool::Enum typeCreation);
VContainer *data, Document::Enum parse, Tool::Enum typeCreation, Draw::Mode mode);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);

View File

@ -16,7 +16,8 @@
#include "../container/vpointf.h"
VToolSinglePoint::VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
QGraphicsItem * parent ):VToolPoint(doc, data, id, parent),
QGraphicsItem * parent ):VToolPoint(doc, data, id, Draw::Calculation,
parent),
dialogSinglePoint(QSharedPointer<DialogSinglePoint>()){
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@ -45,7 +46,7 @@ void VToolSinglePoint::AddToFile(){
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
AddToCalculation(domElement);
AddToDraw(domElement);
}
QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value){

View File

@ -17,7 +17,8 @@ class VToolSinglePoint : public VToolPoint
Q_OBJECT
public:
VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id,
Tool::Enum typeCreation, QGraphicsItem * parent = 0 );
Tool::Enum typeCreation,
QGraphicsItem * parent = 0 );
virtual void setDialog();
public slots:
virtual void FullUpdateFromFile();

View File

@ -10,8 +10,9 @@
#include "../geometry/vspline.h"
VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
QGraphicsItem *parent):VAbstractTool(doc, data, id), QGraphicsPathItem(parent),
VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode,
Tool::Enum typeCreation,
QGraphicsItem *parent):VAbstractTool(doc, data, id, mode), QGraphicsPathItem(parent),
dialogSpline(QSharedPointer<DialogSpline>()), controlPoints(QVector<VControlPointSpline *>()){
VSpline spl = data->GetSpline(id);
@ -59,7 +60,7 @@ void VToolSpline::setDialog(){
}
void VToolSpline::Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data){
VContainer *data, Draw::Mode mode){
qint64 p1 = dialog->getP1();
qint64 p4 = dialog->getP4();
qreal kAsm1 = dialog->getKAsm1();
@ -68,13 +69,13 @@ void VToolSpline::Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScen
qreal angle2 = dialog->getAngle2();
qreal kCurve = dialog->getKCurve();
Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse,
Tool::FromGui);
Tool::FromGui, mode);
}
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,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
Tool::Enum typeCreation){
Tool::Enum typeCreation, Draw::Mode mode){
VSpline spline = VSpline(data->DataPoints(), p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve);
qint64 id = _id;
if(typeCreation == Tool::FromGui){
@ -84,14 +85,21 @@ void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, c
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
tool->VDataTool::setData(data);
tools->insert(id, tool);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
data->IncrementReferens(id, Scene::Spline);
}
}
}
data->AddLengthSpline(data->GetNameSpline(p1, p4), spline.GetLength());
VAbstractTool::AddRecord(id, Tools::SplineTool, doc);
if(mode == Draw::Modeling){
data->IncrementReferens(p1, Scene::Point);
data->IncrementReferens(p4, Scene::Point);
}
if(parse == Document::FullParse){
VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation);
VToolSpline *spl = new VToolSpline(doc, data, id, mode, typeCreation);
scene->addItem(spl);
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(spl, &VToolSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
@ -163,7 +171,12 @@ void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
}
void VToolSpline::AddToFile(){
VSpline spl = VAbstractTool::data.GetSpline(id);
VSpline spl;
if(mode == Draw::Calculation){
spl = VAbstractTool::data.GetSpline(id);
} else {
spl = VAbstractTool::data.GetModelingSpline(id);
}
QDomElement domElement = doc->createElement("spline");
AddAttribute(domElement, "id", id);
@ -176,7 +189,7 @@ void VToolSpline::AddToFile(){
AddAttribute(domElement, "kAsm2", spl.GetKasm2());
AddAttribute(domElement, "kCurve", spl.GetKcurve());
AddToCalculation(domElement);
AddToDraw(domElement);
}
void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){

View File

@ -19,15 +19,15 @@ class VToolSpline:public VAbstractTool, public QGraphicsPathItem
{
Q_OBJECT
public:
VToolSpline ( VDomDocument *doc, VContainer *data, qint64 id,
VToolSpline (VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode,
Tool::Enum typeCreation, QGraphicsItem * parent = 0 );
virtual void setDialog();
static void Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
VContainer *data, Draw::Mode mode);
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,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, Document::Enum parse,
Tool::Enum typeCreation);
Tool::Enum typeCreation, Draw::Mode mode);
signals:
void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &controlPoint, const QPointF &splinePoint );

View File

@ -1,8 +1,9 @@
#include "vtoolsplinepath.h"
#include <QMenu>
VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
QGraphicsItem *parent):VAbstractTool(doc, data, id),
VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, Draw::Mode mode,
Tool::Enum typeCreation,
QGraphicsItem *parent):VAbstractTool(doc, data, id, mode),
QGraphicsPathItem(parent), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
controlPoints(QVector<VControlPointSpline *>()){
VSplinePath splPath = data->GetSplinePath(id);
@ -32,7 +33,6 @@ VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint);
controlPoints.append(controlPoint);
}
if(typeCreation == Tool::FromGui){
AddToFile();
}
@ -47,14 +47,14 @@ void VToolSplinePath::setDialog(){
}
void VToolSplinePath::Create(QSharedPointer<DialogSplinePath> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){
VDomDocument *doc, VContainer *data, Draw::Mode mode){
VSplinePath path = dialog->GetPath();
Create(0, path, scene, doc, data, Document::FullParse, Tool::FromGui);
Create(0, path, scene, doc, data, Document::FullParse, Tool::FromGui, mode);
}
void VToolSplinePath::Create(const qint64 _id, const VSplinePath &path, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, Document::Enum parse,
Tool::Enum typeCreation){
Tool::Enum typeCreation, Draw::Mode mode){
qint64 id = _id;
if(typeCreation == Tool::FromGui){
id = data->AddSplinePath(path);
@ -63,14 +63,23 @@ void VToolSplinePath::Create(const qint64 _id, const VSplinePath &path, VMainGra
if(parse != Document::FullParse){
QMap<qint64, VDataTool*>* tools = doc->getTools();
VDataTool *tool = tools->value(id);
tool->VDataTool::setData(data);
tools->insert(id, tool);
if(tool != 0){
tool->VDataTool::setData(data);
tools->insert(id, tool);
data->IncrementReferens(id, Scene::SplinePath);
}
}
}
data->AddLengthSpline(data->GetNameSplinePath(path), path.GetLength());
VAbstractTool::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){
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation);
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, mode, typeCreation);
scene->addItem(spl);
connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(spl, &VToolSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
@ -208,7 +217,7 @@ void VToolSplinePath::AddToFile(){
AddPathPoint(domElement, splPath[i]);
}
AddToCalculation(domElement);
AddToDraw(domElement);
}
void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint){

View File

@ -19,12 +19,15 @@ class VToolSplinePath:public VAbstractTool, public QGraphicsPathItem
Q_OBJECT
public:
VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
Tool::Enum typeCreation, QGraphicsItem * parent = 0);
Draw::Mode mode,
Tool::Enum typeCreation,
QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogSplinePath> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data);
VContainer *data, Draw::Mode mode);
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:
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos,
const QPointF &controlPoint, const QPointF &splinePoint);

View File

@ -5,6 +5,7 @@
#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
#include "vgraphicssimpletextitem.h"
#include <QGraphicsScene>
#include <QEvent>
#pragma GCC diagnostic pop
VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent):QGraphicsSimpleTextItem(parent){

View File

@ -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 "vdomdocument.h"
#include <QDebug>
#include "../tools/vtoolsinglepoint.h"
@ -17,7 +12,8 @@
#include "../tools/vtoolarc.h"
#include "../tools/vtoolsplinepath.h"
#include "../tools/vtoolpointofcontact.h"
#pragma GCC diagnostic pop
#include "../tools/vmodelingpoint.h"
#include "../tools/vtooldetail.h"
#include "../options.h"
#include "../container/calculator.h"
#include "../geometry/vsplinepoint.h"
@ -124,7 +120,7 @@ bool VDomDocument::appendDraw(const QString& name){
QDomElement calculationElement = this->createElement("calculation");
QDomElement modelingElement = this->createElement("modeling");
QDomElement pathsElement = this->createElement("paths");
QDomElement pathsElement = this->createElement("details");
drawElement.appendChild(calculationElement);
drawElement.appendChild(modelingElement);
drawElement.appendChild(pathsElement);
@ -203,8 +199,8 @@ bool VDomDocument::GetActivModelingElement(QDomElement &element){
}
}
bool VDomDocument::GetActivPathsElement(QDomElement &element){
bool ok = GetActivNodeElement("paths", element);
bool VDomDocument::GetActivDetailsElement(QDomElement &element){
bool ok = GetActivNodeElement("details", element);
if(ok){
return true;
} else {
@ -231,11 +227,12 @@ bool VDomDocument::GetActivNodeElement(const QString& name, QDomElement &element
}
}
void VDomDocument::Parse(Document::Enum parse, VMainGraphicsScene *scene){
void VDomDocument::Parse(Document::Enum parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail){
if(parse == Document::FullParse){
data->Clear();
nameActivDraw.clear();
scene->clear();
sceneDraw->clear();
sceneDetail->clear();
comboBoxDraws->clear();
tools.clear();
cursor = 0;
@ -262,7 +259,7 @@ void VDomDocument::Parse(Document::Enum parse, VMainGraphicsScene *scene){
} else {
ChangeActivDraw(domElement.attribute("name"), Document::LiteParse);
}
ParseDrawElement(scene, domElement, parse);
ParseDrawElement(sceneDraw, sceneDetail, domElement, parse);
}
if(domElement.tagName()=="increments"){
ParseIncrementsElement(domElement);
@ -308,8 +305,8 @@ void VDomDocument::ParseIncrementsElement(const QDomNode &node){
}
}
void VDomDocument::ParseDrawElement(VMainGraphicsScene *scene, const QDomNode& node,
Document::Enum parse){
void VDomDocument::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, Document::Enum parse){
QDomNode domNode = node.firstChild();
while(!domNode.isNull()){
if(domNode.isElement()){
@ -317,13 +314,13 @@ void VDomDocument::ParseDrawElement(VMainGraphicsScene *scene, const QDomNode& n
if(!domElement.isNull()){
if(domElement.tagName() == "calculation"){
data->ClearObject();
ParseCalculationElement(scene, domElement, parse);
ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Calculation);
}
if(domElement.tagName() == "modeling"){
ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Modeling);
}
if(domElement.tagName() == "paths"){
if(domElement.tagName() == "details"){
ParseDetails(sceneDetail, domElement, parse);
}
}
}
@ -331,31 +328,102 @@ void VDomDocument::ParseDrawElement(VMainGraphicsScene *scene, const QDomNode& n
}
}
void VDomDocument::ParseCalculationElement(VMainGraphicsScene *scene, const QDomNode& node,
Document::Enum parse){
void VDomDocument::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, Document::Enum parse, Draw::Mode mode){
VMainGraphicsScene *scene = 0;
if(mode == Draw::Calculation){
scene = sceneDraw;
} else {
scene = sceneDetail;
}
QDomNodeList nodeList = node.childNodes();
qint32 num = nodeList.size();
for(qint32 i = 0; i < num; ++i){
QDomElement domElement = nodeList.at(i).toElement();
if(!domElement.isNull()){
if(domElement.tagName() == "point"){
ParsePointElement(scene, domElement, parse, domElement.attribute("type", ""));
ParsePointElement(scene, domElement, parse, domElement.attribute("type", ""), mode);
}
if(domElement.tagName() == "line"){
ParseLineElement(scene, domElement, parse);
ParseLineElement(scene, domElement, parse, mode);
}
if(domElement.tagName() == "spline"){
ParseSplineElement(scene, domElement, parse, domElement.attribute("type", ""));
ParseSplineElement(scene, domElement, parse, domElement.attribute("type", ""), mode);
}
if(domElement.tagName() == "arc"){
ParseArcElement(scene, domElement, parse, domElement.attribute("type", ""));
ParseArcElement(scene, domElement, parse, domElement.attribute("type", ""), mode);
}
}
}
}
void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
Document::Enum parse){
if(!domElement.isNull()){
VDetail detail;
VDetail oldDetail;
qint64 id = domElement.attribute("id", "").toLongLong();
detail.setName(domElement.attribute("name", ""));
detail.setMx(toPixel(domElement.attribute("mx","").toDouble()));
detail.setMy(toPixel(domElement.attribute("my","").toDouble()));
QDomNodeList nodeList = domElement.childNodes();
qint32 num = nodeList.size();
for(qint32 i = 0; i < num; ++i){
QDomElement element = nodeList.at(i).toElement();
if(!element.isNull()){
if(element.tagName() == "node"){
qint64 id = element.attribute("id","").toLongLong();
Scene::Type tool;
Draw::Mode mode;
QString t = element.attribute("type","");
if(t == "Point"){
tool = Scene::Point;
VPointF point = data->GetModelingPoint(id);
mode = point.getMode();
oldDetail.append(VNodeDetail(point.getIdObject(), tool, mode));
} else if(t == "Arc"){
tool = Scene::Arc;
VArc arc = data->GetModelingArc(id);
mode = arc.getMode();
oldDetail.append(VNodeDetail(arc.getIdObject(), tool, mode));
} else if(t == "Spline"){
tool = Scene::Spline;
VSpline spl = data->GetModelingSpline(id);
mode = spl.getMode();
oldDetail.append(VNodeDetail(spl.getIdObject(), tool, mode));
} else if(t == "SplinePath"){
tool = Scene::SplinePath;
VSplinePath splPath = data->GetModelingSplinePath(id);
mode = splPath.getMode();
oldDetail.append(VNodeDetail(splPath.getIdObject(), tool, mode));
}
detail.append(VNodeDetail(id, tool, mode));
}
}
}
VToolDetail::Create(id, detail, oldDetail, sceneDetail, this, data, parse, Tool::FromFile);
}
}
void VDomDocument::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
Document::Enum parse){
QDomNode domNode = domElement.firstChild();
while(!domNode.isNull()){
if(domNode.isElement()){
QDomElement domElement = domNode.toElement();
if(!domElement.isNull()){
if(domElement.tagName() == "detail"){
ParseDetailElement(sceneDetail, domElement, parse);
}
}
}
domNode = domNode.nextSibling();
}
}
void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
Document::Enum parse, const QString& type){
Document::Enum parse, const QString& type, Draw::Mode mode){
if(type == "single"){
if(!domElement.isNull()){
QString name;
@ -396,7 +464,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 basePointId = domElement.attribute("basePoint", "").toLongLong();
qint32 angle = domElement.attribute("angle", "").toInt();
VToolEndLine::Create(id, name, typeLine, formula, angle, basePointId, mx, my, scene, this, data,
parse, Tool::FromFile);
parse, Tool::FromFile, mode);
}
return;
}
@ -411,7 +479,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 firstPointId = domElement.attribute("firstPoint", "").toLongLong();
qint64 secondPointId = domElement.attribute("secondPoint", "").toLongLong();
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my,
scene, this, data, parse, Tool::FromFile);
scene, this, data, parse, Tool::FromFile, mode);
}
return;
}
@ -427,7 +495,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 p2Line = domElement.attribute("p2Line", "").toLongLong();
qint64 pShoulder = domElement.attribute("pShoulder", "").toLongLong();
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my,
scene, this, data, parse, Tool::FromFile);
scene, this, data, parse, Tool::FromFile, mode);
}
return;
}
@ -443,7 +511,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 secondPointId = domElement.attribute("secondPoint", "").toLongLong();
qreal angle = domElement.attribute("angle", "").toDouble();
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle,
mx, my, scene, this, data, parse, Tool::FromFile);
mx, my, scene, this, data, parse, Tool::FromFile, mode);
}
return;
}
@ -459,7 +527,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 secondPointId = domElement.attribute("secondPoint", "").toLongLong();
qint64 thirdPointId = domElement.attribute("thirdPoint", "").toLongLong();
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId, typeLine,
name, mx, my, scene, this, data, parse, Tool::FromFile);
name, mx, my, scene, this, data, parse, Tool::FromFile, mode);
}
return;
}
@ -474,7 +542,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
qint64 p1Line2Id = domElement.attribute("p1Line2", "").toLongLong();
qint64 p2Line2Id = domElement.attribute("p2Line2", "").toLongLong();
VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, mx, my, scene,
this, data, parse, Tool::FromFile);
this, data, parse, Tool::FromFile, mode);
}
return;
}
@ -489,24 +557,46 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
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);
scene, this, data, parse, Tool::FromFile, mode);
}
return;
}
if(type == "modeling"){
if(!domElement.isNull()){
qint64 id = domElement.attribute("id", "").toLongLong();
qint64 idObject = domElement.attribute("idObject", "").toLongLong();
QString tObject = domElement.attribute("typeObject", "");
VPointF point;
Draw::Mode typeObject;
if(tObject == "Calculation"){
typeObject = Draw::Calculation;
point = data->GetPoint(idObject );
} else {
typeObject = Draw::Modeling;
point = data->GetModelingPoint(idObject);
}
qreal mx = toPixel(domElement.attribute("mx","").toDouble());
qreal my = toPixel(domElement.attribute("my","").toDouble());
data->UpdateModelingPoint(id, VPointF(point.x(), point.y(), point.name(), mx, my, typeObject,
idObject ));
data->IncrementReferens(idObject, Scene::Point);
}
return;
}
}
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
Document::Enum parse){
Document::Enum parse, Draw::Mode mode){
if(!domElement.isNull()){
qint64 id = domElement.attribute("id", "").toLongLong();
qint64 firstPoint = domElement.attribute("firstPoint", "").toLongLong();
qint64 secondPoint = domElement.attribute("secondPoint", "").toLongLong();
VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile);
VToolLine::Create(id, firstPoint, secondPoint, scene, this, data, parse, Tool::FromFile, mode);
}
}
void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
Document::Enum parse, const QString &type){
Document::Enum parse, const QString &type, Draw::Mode mode){
if(type == "simple"){
if(!domElement.isNull()){
qint64 id = domElement.attribute("id", "").toLongLong();
@ -518,7 +608,7 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
qreal kAsm2 = domElement.attribute("kAsm2","").toDouble();
qreal kCurve = domElement.attribute("kCurve","").toDouble();
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, data,
parse, Tool::FromFile);
parse, Tool::FromFile, mode);
}
return;
}
@ -543,14 +633,60 @@ void VDomDocument::ParseSplineElement(VMainGraphicsScene *scene, const QDomEleme
}
}
}
VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile);
VToolSplinePath::Create(id, path, scene, this, data, parse, Tool::FromFile, mode);
}
return;
}
if(type == "modelingSpline"){
if(!domElement.isNull()){
qint64 id = domElement.attribute("id", "").toLongLong();
qint64 idObject = domElement.attribute("idObject", "").toLongLong();
QString tObject = domElement.attribute("typeObject", "");
VSpline spl;
Draw::Mode typeObject;
if(tObject == "Calculation"){
typeObject = Draw::Calculation;
spl = data->GetSpline(idObject);
} else {
typeObject = Draw::Modeling;
spl = data->GetModelingSpline(idObject);
}
spl.setMode(typeObject);
spl.setIdObject(idObject);
data->UpdateModelingSpline(id, spl);
data->IncrementReferens(spl.GetP1(), Scene::Point);
data->IncrementReferens(spl.GetP4(), Scene::Point);
}
return;
}
if(type == "modelingPath"){
if(!domElement.isNull()){
qint64 id = domElement.attribute("id", "").toLongLong();
qint64 idObject = domElement.attribute("idObject", "").toLongLong();
QString tObject = domElement.attribute("typeObject", "");
VSplinePath path;
Draw::Mode typeObject;
if(tObject == "Calculation"){
typeObject = Draw::Calculation;
path = data->GetSplinePath(idObject);
} else {
typeObject = Draw::Modeling;
path = data->GetModelingSplinePath(idObject);
}
path.setMode(typeObject);
path.setIdObject(idObject);
data->UpdateModelingSplinePath(id, path);
const QVector<VSplinePoint> *points = path.GetPoint();
for(qint32 i = 0; i<points->size(); ++i){
data->IncrementReferens(points->at(i).P(), Scene::Point);
}
}
return;
}
}
void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement,
Document::Enum parse, const QString &type){
Document::Enum parse, const QString &type, Draw::Mode mode){
if(type == "simple"){
if(!domElement.isNull()){
qint64 id = domElement.attribute("id", "").toLongLong();
@ -558,7 +694,27 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
QString radius = domElement.attribute("radius", "");
QString f1 = domElement.attribute("angle1", "");
QString f2 = domElement.attribute("angle2","");
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile);
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Tool::FromFile, mode);
}
return;
}
if(type == "modeling"){
if(!domElement.isNull()){
qint64 id = domElement.attribute("id", "").toLongLong();
qint64 idObject = domElement.attribute("idObject", "").toLongLong();
QString tObject = domElement.attribute("typeObject", "");
VArc arc;
Draw::Mode typeObject;
if(tObject == "Calculation"){
typeObject = Draw::Calculation;
arc = data->GetArc(idObject);
} else {
typeObject = Draw::Modeling;
arc = data->GetModelingArc(idObject);
}
arc.setMode(typeObject);
arc.setIdObject(idObject);
data->UpdateModelingArc(id, arc);
}
return;
}
@ -566,7 +722,8 @@ void VDomDocument::ParseArcElement(VMainGraphicsScene *scene, const QDomElement
void VDomDocument::FullUpdateTree(){
VMainGraphicsScene *scene = new VMainGraphicsScene();
Parse(Document::LiteParse, scene);
data->ClearObject();
Parse(Document::LiteParse, scene, scene);
delete scene;
setCurrentData();
emit FullUpdateFromFile();
@ -617,3 +774,74 @@ void VDomDocument::setCurrentData(){
}
}
}
void VDomDocument::GarbageCollector(){
const QMap<qint64, VPointF> *points = data->DataPoints();
QMapIterator<qint64, VPointF> p(*points);
while (p.hasNext()) {
p.next();
VPointF point = p.value();
if(point.referens() <= 0){
QDomElement domElement = elementById(QString().setNum(p.key()));
if(domElement.isElement()){
QDomElement element;
bool ok = GetActivModelingElement(element);
if(ok){
element.removeChild(domElement);
}
}
}
}
const QMap<qint64, VArc> *arc = data->DataArcs();
QMapIterator<qint64, VArc> a(*arc);
while (a.hasNext()) {
a.next();
VArc arc = a.value();
if(arc.referens() <= 0){
QDomElement domElement = elementById(QString().setNum(a.key()));
if(domElement.isElement()){
QDomElement element;
bool ok = GetActivModelingElement(element);
if(ok){
element.removeChild(domElement);
}
}
}
}
const QMap<qint64, VSpline> *spl = data->DataSplines();
QMapIterator<qint64, VSpline> s(*spl);
while (s.hasNext()) {
s.next();
VSpline spl = s.value();
if(spl.referens() <= 0){
QDomElement domElement = elementById(QString().setNum(s.key()));
if(domElement.isElement()){
QDomElement element;
bool ok = GetActivModelingElement(element);
if(ok){
element.removeChild(domElement);
}
}
}
}
const QMap<qint64, VSplinePath> *splPath = data->DataSplinePaths();
QMapIterator<qint64, VSplinePath> q(*splPath);
while (q.hasNext()) {
q.next();
VSplinePath splPath = q.value();
if(splPath.referens() <= 0){
QDomElement domElement = elementById(QString().setNum(q.key()));
if(domElement.isElement()){
QDomElement element;
bool ok = GetActivModelingElement(element);
if(ok){
element.removeChild(domElement);
}
}
}
}
}

View File

@ -41,15 +41,16 @@ public:
bool GetActivDrawElement(QDomElement &element);
bool GetActivCalculationElement(QDomElement &element);
bool GetActivModelingElement(QDomElement &element);
bool GetActivPathsElement(QDomElement &element);
bool GetActivDetailsElement(QDomElement &element);
bool appendDraw(const QString& name);
void SetNameDraw(const QString& name);
void Parse(Document::Enum parse, VMainGraphicsScene *scene);
void Parse(Document::Enum parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail);
QMap<qint64, VDataTool*>* getTools();
QVector<VToolRecord> *getHistory();
qint64 getCursor() const;
void setCursor(const qint64 &value);
void setCurrentData();
qint64 getCursor() const;
void setCursor(const qint64 &value);
void setCurrentData();
void GarbageCollector();
signals:
void ChangedActivDraw(const QString newName);
void ChangedNameDraw(const QString oldName, const QString newName);
@ -75,18 +76,22 @@ private:
bool CheckNameDraw(const QString& name) const;
void SetActivDraw(const QString& name);
bool GetActivNodeElement(const QString& name, QDomElement& element);
void ParseDrawElement(VMainGraphicsScene *scene,
void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, Document::Enum parse);
void ParseCalculationElement(VMainGraphicsScene *scene, const QDomNode& node,
Document::Enum parse);
void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, Document::Enum parse, Draw::Mode mode);
void ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
Document::Enum parse);
void ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
Document::Enum parse);
void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
Document::Enum parse, const QString &type);
Document::Enum parse, const QString &type, Draw::Mode mode);
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
Document::Enum parse);
Document::Enum parse, Draw::Mode mode);
void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
Document::Enum parse, const QString& type);
Document::Enum parse, const QString& type, Draw::Mode mode);
void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
Document::Enum parse, const QString& type);
Document::Enum parse, const QString& type, Draw::Mode mode);
void ParseIncrementsElement(const QDomNode& node);
};