Tool point of intersection.

--HG--
branch : develop
This commit is contained in:
dismine 2013-10-21 17:09:05 +03:00
parent 933c7d8a75
commit c66439ba7a
29 changed files with 704 additions and 27 deletions

View File

@ -103,7 +103,10 @@ SOURCES += main.cpp\
dialogs/dialogheight.cpp \
tools/drawTools/vtooltriangle.cpp \
tools/modelingTools/vmodelingtriangle.cpp \
dialogs/dialogtriangle.cpp
dialogs/dialogtriangle.cpp \
dialogs/dialogpointofintersection.cpp \
tools/drawTools/vtoolpointofintersection.cpp \
tools/modelingTools/vmodelingpointofintersection.cpp
HEADERS += mainwindow.h \
widgets/vmaingraphicsscene.h \
@ -200,7 +203,10 @@ HEADERS += mainwindow.h \
dialogs/dialogheight.h \
tools/drawTools/vtooltriangle.h \
tools/modelingTools/vmodelingtriangle.h \
dialogs/dialogtriangle.h
dialogs/dialogtriangle.h \
dialogs/dialogpointofintersection.h \
tools/drawTools/vtoolpointofintersection.h \
tools/modelingTools/vmodelingpointofintersection.h
FORMS += mainwindow.ui \
dialogs/dialogsinglepoint.ui \
@ -220,7 +226,8 @@ FORMS += mainwindow.ui \
dialogs/dialogdetail.ui \
tablewindow.ui \
dialogs/dialogheight.ui \
dialogs/dialogtriangle.ui
dialogs/dialogtriangle.ui \
dialogs/dialogpointofintersection.ui
RESOURCES += \
icon.qrc \

View File

@ -14,5 +14,6 @@
<file>cursor/new_detail_cursor.png</file>
<file>cursor/height_cursor.png</file>
<file>cursor/triangle_cursor.png</file>
<file>cursor/pointofintersect_cursor.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,98 @@
#include "dialogpointofintersection.h"
#include "ui_dialogpointofintersection.h"
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(new Ui::DialogPointOfIntersection), number(0), pointName(QString()),
firstPointId(0), secondPointId(0){
ui->setupUi(this);
labelEditNamePoint = ui->labelEditNamePoint;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogPointOfIntersection::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogPointOfIntersection::DialogRejected);
FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged);
}
DialogPointOfIntersection::~DialogPointOfIntersection(){
delete ui;
}
qint64 DialogPointOfIntersection::getSecondPointId() const{
return secondPointId;
}
void DialogPointOfIntersection::setSecondPointId(const qint64 &value, const qint64 &id){
secondPointId = value;
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
}
void DialogPointOfIntersection::ChoosedObject(qint64 id, Scene::Scenes type){
if(idDetail == 0 && mode == Draw::Modeling){
if(type == Scene::Detail){
idDetail = id;
return;
}
}
if(mode == Draw::Modeling){
if(!CheckObject(id)){
return;
}
}
if(type == Scene::Point){
VPointF point;
if(mode == Draw::Calculation){
point = data->GetPoint(id);
} else {
point = data->GetModelingPoint(id);
}
if(number == 0){
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index);
number++;
emit ToolTip(tr("Select point horizontally"));
return;
}
}
if(number == 1){
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
if ( index != -1 ) { // -1 for not found
ui->comboBoxSecondPoint->setCurrentIndex(index);
number = 0;
emit ToolTip("");
}
if(!isInitialized){
this->show();
}
}
}
}
void DialogPointOfIntersection::DialogAccepted(){
pointName = ui->lineEditNamePoint->text();
firstPointId = getCurrentPointId(ui->comboBoxFirstPoint);
secondPointId = getCurrentPointId(ui->comboBoxSecondPoint);
emit DialogClosed(QDialog::Accepted);
}
qint64 DialogPointOfIntersection::getFirstPointId() const{
return firstPointId;
}
void DialogPointOfIntersection::setFirstPointId(const qint64 &value, const qint64 &id){
firstPointId = value;
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
}
QString DialogPointOfIntersection::getPointName() const{
return pointName;
}
void DialogPointOfIntersection::setPointName(const QString &value){
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}

View File

@ -0,0 +1,34 @@
#ifndef DIALOGPOINTOFINTERSECTION_H
#define DIALOGPOINTOFINTERSECTION_H
#include "dialogtool.h"
namespace Ui {
class DialogPointOfIntersection;
}
class DialogPointOfIntersection : public DialogTool{
Q_OBJECT
public:
DialogPointOfIntersection(const VContainer *data, Draw::Draws mode = Draw::Calculation,
QWidget *parent = 0);
~DialogPointOfIntersection();
QString getPointName() const;
void setPointName(const QString &value);
qint64 getFirstPointId() const;
void setFirstPointId(const qint64 &value, const qint64 &id);
qint64 getSecondPointId() const;
void setSecondPointId(const qint64 &value, const qint64 &id);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted();
private:
Q_DISABLE_COPY(DialogPointOfIntersection)
Ui::DialogPointOfIntersection *ui;
qint32 number;
QString pointName;
qint64 firstPointId;
qint64 secondPointId;
};
#endif // DIALOGPOINTOFINTERSECTION_H

View File

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogPointOfIntersection</class>
<widget class="QDialog" name="DialogPointOfIntersection">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>293</width>
<height>180</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="labelEditNamePoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Name new point</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Point vertically</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxFirstPoint">
<property name="toolTip">
<string>First point of angle</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Point horizontally</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxSecondPoint">
<property name="toolTip">
<string>Second point of angle</string>
</property>
</widget>
</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>DialogPointOfIntersection</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>DialogPointOfIntersection</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

@ -36,5 +36,6 @@
<file>icon/16x16/mirror.png</file>
<file>icon/32x32/height.png</file>
<file>icon/32x32/triangle.png</file>
<file>icon/32x32/point_of_intersection.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

View File

@ -49,6 +49,7 @@ MainWindow::MainWindow(QWidget *parent) :
dialogPointOfContact(QSharedPointer<DialogPointOfContact>()),
dialogDetail(QSharedPointer<DialogDetail>()), dialogHeight(QSharedPointer<DialogHeight>()),
dialogTriangle(QSharedPointer<DialogTriangle>()),
dialogPointOfIntersection(QSharedPointer<DialogPointOfIntersection>()),
dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
mode(Draw::Calculation){
ui->setupUi(this);
@ -94,6 +95,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->toolButtonNewDetail, &QToolButton::clicked, this, &MainWindow::ToolDetail);
connect(ui->toolButtonHeight, &QToolButton::clicked, this, &MainWindow::ToolHeight);
connect(ui->toolButtonTriangle, &QToolButton::clicked, this, &MainWindow::ToolTriangle);
connect(ui->toolButtonPointOfIntersection, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersection);
data = new VContainer;
@ -500,6 +502,26 @@ void MainWindow::ClosedDialogTriangle(int result){
ArrowTool();
}
void MainWindow::ToolPointOfIntersection(bool checked){
SetToolButton(checked, Tool::PointOfIntersection, ":/cursor/pointofintersect_cursor.png",
tr("Select point vertically"),
dialogPointOfIntersection, &MainWindow::ClosedDialogPointOfIntersection);
}
void MainWindow::ClosedDialogPointOfIntersection(int result){
if(result == QDialog::Accepted){
if(mode == Draw::Calculation){
VToolPointOfIntersection::Create(dialogPointOfIntersection, currentScene, doc, data);
} else {
VModelingPointOfIntersection *point = VModelingPointOfIntersection::Create(dialogPointOfIntersection,
doc, data);
AddToolToDetail(point, point->getId(), Tool::PointOfIntersection,
dialogPointOfIntersection->getIdDetail());
}
}
ArrowTool();
}
void MainWindow::About(){
QMessageBox::about(this, tr("About Valentina"), tr("Valentina v.0.1.0"));
}
@ -744,6 +766,12 @@ void MainWindow::CanselTool(){
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
case Tool::PointOfIntersection:
dialogPointOfIntersection.clear();
ui->toolButtonPointOfIntersection->setChecked(false);
currentScene->setFocus(Qt::OtherFocusReason);
currentScene->clearSelection();
break;
default:
qWarning()<<"Get wrong tool type. Ignore.";
break;
@ -986,6 +1014,7 @@ void MainWindow::SetEnableTool(bool enable){
ui->toolButtonNewDetail->setEnabled(enable);
ui->toolButtonHeight->setEnabled(enable);
ui->toolButtonTriangle->setEnabled(enable);
ui->toolButtonPointOfIntersection->setEnabled(enable);
}
void MainWindow::MinimumScrollBar(){

View File

@ -81,6 +81,7 @@ public slots:
void ToolDetail(bool checked);
void ToolHeight(bool checked);
void ToolTriangle(bool checked);
void ToolPointOfIntersection(bool checked);
void ClosedDialogEndLine(int result);
void ClosedDialogLine(int result);
void ClosedDialogAlongLine(int result);
@ -95,6 +96,7 @@ public slots:
void ClosedDialogDetail(int result);
void ClosedDialogHeight(int result);
void ClosedDialogTriangle(int result);
void ClosedDialogPointOfIntersection(int result);
void About();
void AboutQt();
void ShowToolTip(const QString &toolTip);
@ -140,6 +142,7 @@ private:
QSharedPointer<DialogDetail> dialogDetail;
QSharedPointer<DialogHeight> dialogHeight;
QSharedPointer<DialogTriangle> dialogTriangle;
QSharedPointer<DialogPointOfIntersection> dialogPointOfIntersection;
DialogHistory *dialogHistory;
VDomDocument *doc;
VContainer *data;

View File

@ -272,6 +272,29 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="toolButtonPointOfIntersection">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="icon.qrc">
<normaloff>:/icon/32x32/point_of_intersection.png</normaloff>:/icon/32x32/point_of_intersection.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 class="QWidget" name="page_2">
@ -279,7 +302,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<width>150</width>
<height>58</height>
</rect>
</property>
@ -355,7 +378,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<width>150</width>
<height>58</height>
</rect>
</property>
@ -431,7 +454,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<width>150</width>
<height>58</height>
</rect>
</property>
@ -481,7 +504,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<width>150</width>
<height>58</height>
</rect>
</property>

View File

@ -57,7 +57,8 @@ enum Tool {ArrowTool,
NodeSpline,
NodeSplinePath,
Height,
Triangle
Triangle,
PointOfIntersection
};
Q_DECLARE_FLAGS(Tools, Tool)

View File

@ -36,5 +36,6 @@
#include "vtoolsplinepath.h"
#include "vtoolheight.h"
#include "vtooltriangle.h"
#include "vtoolpointofintersection.h"
#endif // DRAWTOOLS_H

View File

@ -26,6 +26,7 @@ VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firs
Tool::Sources typeCreation, QGraphicsItem *parent):VDrawTool(doc, data, id),
QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint),
dialogLine(QSharedPointer<DialogLine>()){
ignoreFullUpdate = true;
//Лінія
VPointF first = data->GetPoint(firstPoint);
VPointF second = data->GetPoint(secondPoint);

View File

@ -28,6 +28,7 @@ VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, cons
QGraphicsItem *parent):
VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){
ignoreFullUpdate = true;
if(typeCreation == Tool::FromGui){
AddToFile();
}

View File

@ -0,0 +1,106 @@
#include "vtoolpointofintersection.h"
VToolPointOfIntersection::VToolPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &firstPointId, const qint64 &secondPointId,
Tool::Sources typeCreation, QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId),
dialogPointOfIntersection(QSharedPointer<DialogPointOfIntersection>()) {
ignoreFullUpdate = true;
if(typeCreation == Tool::FromGui){
AddToFile();
}
}
void VToolPointOfIntersection::setDialog(){
Q_ASSERT(!dialogPointOfIntersection.isNull());
VPointF p = VAbstractTool::data.GetPoint(id);
dialogPointOfIntersection->setFirstPointId(firstPointId, id);
dialogPointOfIntersection->setSecondPointId(secondPointId, id);
dialogPointOfIntersection->setPointName(p.name());
}
void VToolPointOfIntersection::Create(QSharedPointer<DialogPointOfIntersection> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data){
qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId();
QString pointName = dialog->getPointName();
Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Tool::FromGui);
}
void VToolPointOfIntersection::Create(const qint64 _id, const QString &pointName, const qint64 &firstPointId,
const qint64 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation){
VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId);
QPointF point(firstPoint.x(), secondPoint.y());
qint64 id = _id;
if(typeCreation == Tool::FromGui){
id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my));
} else {
data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my));
if(parse != Document::FullParse){
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::Triangle, doc);
if(parse == Document::FullParse){
VToolPointOfIntersection *point = new VToolPointOfIntersection(doc, data, id, firstPointId,
secondPointId, typeCreation);
scene->addItem(point);
connect(point, &VToolPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPointOfIntersection::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersection::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
}
}
void VToolPointOfIntersection::FullUpdateFromFile(){
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
}
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
}
void VToolPointOfIntersection::FullUpdateFromGui(int result){
if(result == QDialog::Accepted){
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
domElement.setAttribute("name", dialogPointOfIntersection->getPointName());
domElement.setAttribute("firstPoint", QString().setNum(dialogPointOfIntersection->getFirstPointId()));
domElement.setAttribute("secondPoint", QString().setNum(dialogPointOfIntersection->getSecondPointId()));
emit FullUpdateTree();
}
}
dialogPointOfIntersection.clear();
}
void VToolPointOfIntersection::RemoveReferens(){
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(secondPointId);
}
void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
ContextMenu(dialogPointOfIntersection, this, event);
}
void VToolPointOfIntersection::AddToFile(){
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement("point");
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "pointOfIntersection");
AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "firstPoint", firstPointId);
AddAttribute(domElement, "secondPoint", secondPointId);
AddToCalculation(domElement);
}

View File

@ -0,0 +1,33 @@
#ifndef VTOOLPOINTOFINTERSECTION_H
#define VTOOLPOINTOFINTERSECTION_H
#include "vtoolpoint.h"
#include "dialogs/dialogpointofintersection.h"
class VToolPointOfIntersection : public VToolPoint{
Q_OBJECT
public:
VToolPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &firstPointId,
const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog();
static void Create(QSharedPointer<DialogPointOfIntersection> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data);
static void Create(const qint64 _id, const QString &pointName, const qint64 &firstPointId,
const qint64 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);
protected:
virtual void RemoveReferens();
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
private:
Q_DISABLE_COPY(VToolPointOfIntersection)
qint64 firstPointId;
qint64 secondPointId;
QSharedPointer<DialogPointOfIntersection> dialogPointOfIntersection;
};
#endif // VTOOLPOINTOFINTERSECTION_H

View File

@ -28,6 +28,7 @@ VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id,
Tool::Sources typeCreation,
QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsPathItem(parent),
dialogSpline(QSharedPointer<DialogSpline>()), controlPoints(QVector<VControlPointSpline *>()){
ignoreFullUpdate = true;
VSpline spl = data->GetSpline(id);
QPainterPath path;

View File

@ -27,6 +27,7 @@ VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
QGraphicsItem *parent):VDrawTool(doc, data, id),
QGraphicsPathItem(parent), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
controlPoints(QVector<VControlPointSpline *>()){
ignoreFullUpdate = true;
VSplinePath splPath = data->GetSplinePath(id);
QPainterPath path;
path.addPath(splPath.GetPath());

View File

@ -5,6 +5,7 @@ VToolTriangle::VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 &
const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId),
secondPointId(secondPointId), dialogTriangle(QSharedPointer<DialogTriangle>()) {
ignoreFullUpdate = true;
if(typeCreation == Tool::FromGui){
AddToFile();
}
@ -29,7 +30,6 @@ void VToolTriangle::Create(QSharedPointer<DialogTriangle> &dialog, VMainGraphics
QString pointName = dialog->getPointName();
Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, scene, doc, data,
Document::FullParse, Tool::FromGui);
}
void VToolTriangle::Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id,

View File

@ -36,5 +36,6 @@
#include "vmodelingsplinepath.h"
#include "vmodelingheight.h"
#include "vmodelingtriangle.h"
#include "vmodelingpointofintersection.h"
#endif // MODELINGTOOLS_H

View File

@ -26,6 +26,7 @@ VModelingLine::VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qin
qint64 secondPoint, Tool::Sources typeCreation, QGraphicsItem *parent):
VModelingTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint),
secondPoint(secondPoint), dialogLine(QSharedPointer<DialogLine>()){
ignoreFullUpdate = true;
//Лінія
VPointF first = data->GetModelingPoint(firstPoint);
VPointF second = data->GetModelingPoint(secondPoint);

View File

@ -26,6 +26,7 @@ VModelingLineIntersect::VModelingLineIntersect(VDomDocument *doc, VContainer *da
const qint64 &p2Line2, Tool::Sources typeCreation, QGraphicsItem *parent):
VModelingPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){
ignoreFullUpdate = true;
if(typeCreation == Tool::FromGui){
AddToFile();
}

View File

@ -0,0 +1,105 @@
#include "vmodelingpointofintersection.h"
VModelingPointOfIntersection::VModelingPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &firstPointId, const qint64 &secondPointId,
Tool::Sources typeCreation, QGraphicsItem *parent)
:VModelingPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId),
dialogPointOfIntersection(QSharedPointer<DialogPointOfIntersection>()) {
ignoreFullUpdate = true;
if(typeCreation == Tool::FromGui){
AddToFile();
}
}
void VModelingPointOfIntersection::setDialog(){
Q_ASSERT(!dialogPointOfIntersection.isNull());
VPointF p = VAbstractTool::data.GetPoint(id);
dialogPointOfIntersection->setFirstPointId(firstPointId, id);
dialogPointOfIntersection->setSecondPointId(secondPointId, id);
dialogPointOfIntersection->setPointName(p.name());
}
VModelingPointOfIntersection *VModelingPointOfIntersection::Create(QSharedPointer<DialogPointOfIntersection> &dialog,
VDomDocument *doc, VContainer *data){
qint64 firstPointId = dialog->getFirstPointId();
qint64 secondPointId = dialog->getSecondPointId();
QString pointName = dialog->getPointName();
return Create(0, pointName, firstPointId, secondPointId, 5, 10, doc, data, Document::FullParse, Tool::FromGui);
}
VModelingPointOfIntersection *VModelingPointOfIntersection::Create(const qint64 _id, const QString &pointName,
const qint64 &firstPointId,
const qint64 &secondPointId, const qreal &mx,
const qreal &my, VDomDocument *doc,
VContainer *data,
const Document::Documents &parse,
Tool::Sources typeCreation){
VModelingPointOfIntersection *tool = 0;
VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId);
QPointF point(firstPoint.x(), secondPoint.y());
qint64 id = _id;
if(typeCreation == Tool::FromGui){
id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my));
} else {
data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my));
if(parse != Document::FullParse){
doc->UpdateToolData(id, data);
}
}
if(parse == Document::FullParse){
tool = new VModelingPointOfIntersection(doc, data, id, firstPointId, secondPointId, typeCreation);
doc->AddTool(id, tool);
doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId);
}
return tool;
}
void VModelingPointOfIntersection::FullUpdateFromFile(){
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
}
VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPoint(id));
}
void VModelingPointOfIntersection::FullUpdateFromGui(int result){
if(result == QDialog::Accepted){
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
domElement.setAttribute("name", dialogPointOfIntersection->getPointName());
domElement.setAttribute("firstPoint", QString().setNum(dialogPointOfIntersection->getFirstPointId()));
domElement.setAttribute("secondPoint", QString().setNum(dialogPointOfIntersection->getSecondPointId()));
emit FullUpdateTree();
}
}
dialogPointOfIntersection.clear();
}
void VModelingPointOfIntersection::RemoveReferens(){
doc->DecrementReferens(firstPointId);
doc->DecrementReferens(secondPointId);
}
void VModelingPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
ContextMenu(dialogPointOfIntersection, this, event);
}
void VModelingPointOfIntersection::AddToFile(){
VPointF point = VAbstractTool::data.GetPoint(id);
QDomElement domElement = doc->createElement("point");
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "pointOfIntersection");
AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "firstPoint", firstPointId);
AddAttribute(domElement, "secondPoint", secondPointId);
AddToModeling(domElement);
}

View File

@ -0,0 +1,35 @@
#ifndef VMODELINGPOINTOFINTERSECTION_H
#define VMODELINGPOINTOFINTERSECTION_H
#include "vmodelingpoint.h"
#include "dialogs/dialogpointofintersection.h"
class VModelingPointOfIntersection : public VModelingPoint{
Q_OBJECT
public:
VModelingPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &firstPointId, const qint64 &secondPointId,
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog();
static VModelingPointOfIntersection* Create(QSharedPointer<DialogPointOfIntersection> &dialog, VDomDocument *doc,
VContainer *data);
static VModelingPointOfIntersection* Create(const qint64 _id, const QString &pointName,
const qint64 &firstPointId, const qint64 &secondPointId,
const qreal &mx, const qreal &my, VDomDocument *doc,
VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);
protected:
virtual void RemoveReferens();
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
private:
Q_DISABLE_COPY(VModelingPointOfIntersection)
qint64 firstPointId;
qint64 secondPointId;
QSharedPointer<DialogPointOfIntersection> dialogPointOfIntersection;
};
#endif // VMODELINGPOINTOFINTERSECTION_H

View File

@ -29,7 +29,7 @@ VModelingSpline::VModelingSpline(VDomDocument *doc, VContainer *data, qint64 id,
Tool::Sources typeCreation,
QGraphicsItem *parent):VModelingTool(doc, data, id), QGraphicsPathItem(parent),
dialogSpline(QSharedPointer<DialogSpline>()), controlPoints(QVector<VControlPointSpline *>()){
ignoreFullUpdate = true;
VSpline spl = data->GetModelingSpline(id);
QPainterPath path;
path.addPath(spl.GetPath());

View File

@ -27,6 +27,7 @@ VModelingSplinePath::VModelingSplinePath(VDomDocument *doc, VContainer *data, qi
QGraphicsItem *parent):VModelingTool(doc, data, id),
QGraphicsPathItem(parent), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
controlPoints(QVector<VControlPointSpline *>()){
ignoreFullUpdate = true;
VSplinePath splPath = data->GetModelingSplinePath(id);
QPainterPath path;
path.addPath(splPath.GetPath());

View File

@ -32,7 +32,6 @@ VModelingTriangle *VModelingTriangle::Create(QSharedPointer<DialogTriangle> &dia
QString pointName = dialog->getPointName();
return Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, doc, data,
Document::FullParse, Tool::FromGui);
}
VModelingTriangle *VModelingTriangle::Create(const qint64 _id, const QString &pointName,

View File

@ -857,6 +857,30 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
throw excep;
}
}
if(type == "pointOfIntersection"){
try{
qint64 id = GetParametrId(domElement);
QString name = GetParametrString(domElement, "name");
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
qreal my = toPixel(GetParametrDouble(domElement, "my"));
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
if(mode == Draw::Calculation){
VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, scene, this, data,
parse, Tool::FromFile);
} else {
VModelingPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, this, data,
parse, Tool::FromFile);
}
return;
}
catch(const VExceptionBadId &e){
VExceptionObjectError excep(tr("Error creating or updating point of intersection"), domElement);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
}
}
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,