New tool triangle.
--HG-- branch : develop
This commit is contained in:
parent
25190e16a9
commit
0263b60e3c
|
@ -100,7 +100,10 @@ SOURCES += main.cpp\
|
||||||
exception/vexceptionuniqueid.cpp \
|
exception/vexceptionuniqueid.cpp \
|
||||||
tools/drawTools/vtoolheight.cpp \
|
tools/drawTools/vtoolheight.cpp \
|
||||||
tools/modelingTools/vmodelingheight.cpp \
|
tools/modelingTools/vmodelingheight.cpp \
|
||||||
dialogs/dialogheight.cpp
|
dialogs/dialogheight.cpp \
|
||||||
|
tools/drawTools/vtooltriangle.cpp \
|
||||||
|
tools/modelingTools/vmodelingtriangle.cpp \
|
||||||
|
dialogs/dialogtriangle.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
widgets/vmaingraphicsscene.h \
|
widgets/vmaingraphicsscene.h \
|
||||||
|
@ -194,7 +197,10 @@ HEADERS += mainwindow.h \
|
||||||
exception/vexceptionuniqueid.h \
|
exception/vexceptionuniqueid.h \
|
||||||
tools/drawTools/vtoolheight.h \
|
tools/drawTools/vtoolheight.h \
|
||||||
tools/modelingTools/vmodelingheight.h \
|
tools/modelingTools/vmodelingheight.h \
|
||||||
dialogs/dialogheight.h
|
dialogs/dialogheight.h \
|
||||||
|
tools/drawTools/vtooltriangle.h \
|
||||||
|
tools/modelingTools/vmodelingtriangle.h \
|
||||||
|
dialogs/dialogtriangle.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
dialogs/dialogsinglepoint.ui \
|
dialogs/dialogsinglepoint.ui \
|
||||||
|
@ -213,7 +219,8 @@ FORMS += mainwindow.ui \
|
||||||
dialogs/dialogpointofcontact.ui \
|
dialogs/dialogpointofcontact.ui \
|
||||||
dialogs/dialogdetail.ui \
|
dialogs/dialogdetail.ui \
|
||||||
tablewindow.ui \
|
tablewindow.ui \
|
||||||
dialogs/dialogheight.ui
|
dialogs/dialogheight.ui \
|
||||||
|
dialogs/dialogtriangle.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
icon.qrc \
|
icon.qrc \
|
||||||
|
|
|
@ -13,5 +13,6 @@
|
||||||
<file>cursor/pointcontact_cursor.png</file>
|
<file>cursor/pointcontact_cursor.png</file>
|
||||||
<file>cursor/new_detail_cursor.png</file>
|
<file>cursor/new_detail_cursor.png</file>
|
||||||
<file>cursor/height_cursor.png</file>
|
<file>cursor/height_cursor.png</file>
|
||||||
|
<file>cursor/triangle_cursor.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
BIN
cursor/triangle_cursor.png
Normal file
BIN
cursor/triangle_cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -6,7 +6,6 @@ DialogHeight::DialogHeight(const VContainer *data, Draw::Draws mode, QWidget *pa
|
||||||
typeLine(QString()), basePointId(0), p1LineId(0), p2LineId(0){
|
typeLine(QString()), basePointId(0), p1LineId(0), p2LineId(0){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
labelEditNamePoint = ui->labelEditNamePoint;
|
labelEditNamePoint = ui->labelEditNamePoint;
|
||||||
flagFormula = true;
|
|
||||||
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
connect(bOk, &QPushButton::clicked, this, &DialogHeight::DialogAccepted);
|
connect(bOk, &QPushButton::clicked, this, &DialogHeight::DialogAccepted);
|
||||||
flagName = false;
|
flagName = false;
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="locale">
|
||||||
|
<locale language="English" country="UnitedStates"/>
|
||||||
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
|
|
@ -264,6 +264,21 @@ QString DialogHistory::Record(const VToolRecord &tool){
|
||||||
data->GetPoint(p2LineId).name());
|
data->GetPoint(p2LineId).name());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Tool::Triangle:{
|
||||||
|
qint64 axisP1Id = 0;
|
||||||
|
qint64 axisP2Id = 0;
|
||||||
|
domElement = doc->elementById(QString().setNum(tool.getId()));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
axisP1Id = domElement.attribute("axisP1", "").toLongLong();
|
||||||
|
axisP2Id = domElement.attribute("axisP2", "").toLongLong();
|
||||||
|
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||||
|
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
|
}
|
||||||
|
record = QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg(
|
||||||
|
data->GetPoint(axisP1Id).name(),data->GetPoint(axisP2Id).name(),
|
||||||
|
data->GetPoint(firstPointId).name(), data->GetPoint(secondPointId).name());
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
qWarning()<<tr("Get wrong tool type. Ignore.");
|
qWarning()<<tr("Get wrong tool type. Ignore.");
|
||||||
break;
|
break;
|
||||||
|
|
125
dialogs/dialogtriangle.cpp
Normal file
125
dialogs/dialogtriangle.cpp
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
#include "dialogtriangle.h"
|
||||||
|
#include "ui_dialogtriangle.h"
|
||||||
|
|
||||||
|
DialogTriangle::DialogTriangle(const VContainer *data, Draw::Draws mode, QWidget *parent) :
|
||||||
|
DialogTool(data, mode, parent), ui(new Ui::DialogTriangle), number(0), pointName(QString()), axisP1Id(0),
|
||||||
|
axisP2Id(0), firstPointId(0), secondPointId(0){
|
||||||
|
ui->setupUi(this);
|
||||||
|
labelEditNamePoint = ui->labelEditNamePoint;
|
||||||
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
connect(bOk, &QPushButton::clicked, this, &DialogTriangle::DialogAccepted);
|
||||||
|
flagName = false;
|
||||||
|
CheckState();
|
||||||
|
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||||
|
connect(bCansel, &QPushButton::clicked, this, &DialogTriangle::DialogRejected);
|
||||||
|
FillComboBoxPoints(ui->comboBoxAxisP1);
|
||||||
|
FillComboBoxPoints(ui->comboBoxAxisP2);
|
||||||
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||||
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||||
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogTriangle::NamePointChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogTriangle::~DialogTriangle(){
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTriangle::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);
|
||||||
|
}
|
||||||
|
switch(number){
|
||||||
|
case(0):
|
||||||
|
ChangeCurrentText(ui->comboBoxAxisP1, point.name());
|
||||||
|
number++;
|
||||||
|
emit ToolTip(tr("Select second point of axis"));
|
||||||
|
break;
|
||||||
|
case(1):
|
||||||
|
ChangeCurrentText(ui->comboBoxAxisP2, point.name());
|
||||||
|
number++;
|
||||||
|
emit ToolTip(tr("Select first point"));
|
||||||
|
break;
|
||||||
|
case(2):
|
||||||
|
ChangeCurrentText(ui->comboBoxFirstPoint, point.name());
|
||||||
|
number++;
|
||||||
|
emit ToolTip(tr("Select second point"));
|
||||||
|
break;
|
||||||
|
case(3):
|
||||||
|
ChangeCurrentText(ui->comboBoxSecondPoint, point.name());
|
||||||
|
number = 0;
|
||||||
|
emit ToolTip(tr(""));
|
||||||
|
if(!isInitialized){
|
||||||
|
this->show();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTriangle::DialogAccepted(){
|
||||||
|
pointName = ui->lineEditNamePoint->text();
|
||||||
|
firstPointId = getCurrentPointId(ui->comboBoxFirstPoint);
|
||||||
|
secondPointId = getCurrentPointId(ui->comboBoxSecondPoint);
|
||||||
|
axisP1Id = getCurrentPointId(ui->comboBoxAxisP1);
|
||||||
|
axisP2Id = getCurrentPointId(ui->comboBoxAxisP2);
|
||||||
|
emit DialogClosed(QDialog::Accepted);
|
||||||
|
}
|
||||||
|
QString DialogTriangle::getPointName() const{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTriangle::setPointName(const QString &value){
|
||||||
|
pointName = value;
|
||||||
|
ui->lineEditNamePoint->setText(pointName);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 DialogTriangle::getSecondPointId() const{
|
||||||
|
return secondPointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTriangle::setSecondPointId(const qint64 &value, const qint64 &id){
|
||||||
|
secondPointId = value;
|
||||||
|
setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 DialogTriangle::getFirstPointId() const{
|
||||||
|
return firstPointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTriangle::setFirstPointId(const qint64 &value, const qint64 &id){
|
||||||
|
firstPointId = value;
|
||||||
|
setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 DialogTriangle::getAxisP2Id() const{
|
||||||
|
return axisP2Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTriangle::setAxisP2Id(const qint64 &value, const qint64 &id){
|
||||||
|
axisP2Id = value;
|
||||||
|
setCurrentPointId(ui->comboBoxAxisP2, axisP2Id, value, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 DialogTriangle::getAxisP1Id() const{
|
||||||
|
return axisP1Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogTriangle::setAxisP1Id(const qint64 &value, const qint64 &id){
|
||||||
|
axisP1Id = value;
|
||||||
|
setCurrentPointId(ui->comboBoxAxisP1, axisP1Id, value, id);
|
||||||
|
}
|
||||||
|
|
42
dialogs/dialogtriangle.h
Normal file
42
dialogs/dialogtriangle.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef DIALOGTRIANGLE_H
|
||||||
|
#define DIALOGTRIANGLE_H
|
||||||
|
|
||||||
|
#include "dialogtool.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DialogTriangle;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DialogTriangle : public DialogTool
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DialogTriangle(const VContainer *data, Draw::Draws mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
|
~DialogTriangle();
|
||||||
|
qint64 getAxisP1Id() const;
|
||||||
|
void setAxisP1Id(const qint64 &value, const qint64 &id);
|
||||||
|
qint64 getAxisP2Id() const;
|
||||||
|
void setAxisP2Id(const qint64 &value, const qint64 &id);
|
||||||
|
qint64 getFirstPointId() const;
|
||||||
|
void setFirstPointId(const qint64 &value, const qint64 &id);
|
||||||
|
qint64 getSecondPointId() const;
|
||||||
|
void setSecondPointId(const qint64 &value, const qint64 &id);
|
||||||
|
QString getPointName() const;
|
||||||
|
void setPointName(const QString &value);
|
||||||
|
public slots:
|
||||||
|
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
|
||||||
|
virtual void DialogAccepted();
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(DialogTriangle)
|
||||||
|
Ui::DialogTriangle *ui;
|
||||||
|
qint32 number;
|
||||||
|
QString pointName;
|
||||||
|
qint64 axisP1Id;
|
||||||
|
qint64 axisP2Id;
|
||||||
|
qint64 firstPointId;
|
||||||
|
qint64 secondPointId;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIALOGTRIANGLE_H
|
196
dialogs/dialogtriangle.ui
Normal file
196
dialogs/dialogtriangle.ui
Normal file
|
@ -0,0 +1,196 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DialogTriangle</class>
|
||||||
|
<widget class="QDialog" name="DialogTriangle">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>267</width>
|
||||||
|
<height>220</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<property name="locale">
|
||||||
|
<locale language="English" country="UnitedStates"/>
|
||||||
|
</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_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>First point of axis</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxAxisP1">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>First point of line</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Second point of axis</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxAxisP2">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>First point of line</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>First point</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxFirstPoint">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>First point of line</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>Second point</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxSecondPoint">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>First point of line</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>DialogTriangle</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>DialogTriangle</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>
|
1
icon.qrc
1
icon.qrc
|
@ -35,5 +35,6 @@
|
||||||
<file>icon/32x32/layout.png</file>
|
<file>icon/32x32/layout.png</file>
|
||||||
<file>icon/16x16/mirror.png</file>
|
<file>icon/16x16/mirror.png</file>
|
||||||
<file>icon/32x32/height.png</file>
|
<file>icon/32x32/height.png</file>
|
||||||
|
<file>icon/32x32/triangle.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
BIN
icon/32x32/triangle.png
Normal file
BIN
icon/32x32/triangle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
|
@ -48,6 +48,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
dialogArc(QSharedPointer<DialogArc>()), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
|
dialogArc(QSharedPointer<DialogArc>()), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
|
||||||
dialogPointOfContact(QSharedPointer<DialogPointOfContact>()),
|
dialogPointOfContact(QSharedPointer<DialogPointOfContact>()),
|
||||||
dialogDetail(QSharedPointer<DialogDetail>()), dialogHeight(QSharedPointer<DialogHeight>()),
|
dialogDetail(QSharedPointer<DialogDetail>()), dialogHeight(QSharedPointer<DialogHeight>()),
|
||||||
|
dialogTriangle(QSharedPointer<DialogTriangle>()),
|
||||||
dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
|
dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
|
||||||
mode(Draw::Calculation){
|
mode(Draw::Calculation){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -92,6 +93,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
connect(ui->toolButtonPointOfContact, &QToolButton::clicked, this, &MainWindow::ToolPointOfContact);
|
connect(ui->toolButtonPointOfContact, &QToolButton::clicked, this, &MainWindow::ToolPointOfContact);
|
||||||
connect(ui->toolButtonNewDetail, &QToolButton::clicked, this, &MainWindow::ToolDetail);
|
connect(ui->toolButtonNewDetail, &QToolButton::clicked, this, &MainWindow::ToolDetail);
|
||||||
connect(ui->toolButtonHeight, &QToolButton::clicked, this, &MainWindow::ToolHeight);
|
connect(ui->toolButtonHeight, &QToolButton::clicked, this, &MainWindow::ToolHeight);
|
||||||
|
connect(ui->toolButtonTriangle, &QToolButton::clicked, this, &MainWindow::ToolTriangle);
|
||||||
|
|
||||||
data = new VContainer;
|
data = new VContainer;
|
||||||
|
|
||||||
|
@ -481,6 +483,23 @@ void MainWindow::ClosedDialogHeight(int result){
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::ToolTriangle(bool checked){
|
||||||
|
SetToolButton(checked, Tool::Triangle, ":/cursor/triangle_cursor.png", tr("Select first point of axis"),
|
||||||
|
dialogTriangle, &MainWindow::ClosedDialogTriangle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::ClosedDialogTriangle(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
VToolTriangle::Create(dialogTriangle, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingTriangle *point = VModelingTriangle::Create(dialogTriangle, doc, data);
|
||||||
|
AddToolToDetail(point, point->getId(), Tool::Triangle, dialogTriangle->getIdDetail());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArrowTool();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::About(){
|
void MainWindow::About(){
|
||||||
QMessageBox::about(this, tr("About Valentina"), tr("Valentina v.0.1.0"));
|
QMessageBox::about(this, tr("About Valentina"), tr("Valentina v.0.1.0"));
|
||||||
}
|
}
|
||||||
|
@ -640,6 +659,7 @@ void MainWindow::CanselTool(){
|
||||||
helpLabel->setText("");
|
helpLabel->setText("");
|
||||||
break;
|
break;
|
||||||
case Tool::SinglePointTool:
|
case Tool::SinglePointTool:
|
||||||
|
Q_UNREACHABLE();
|
||||||
//Nothing to do here because we can't create this tool from main window.
|
//Nothing to do here because we can't create this tool from main window.
|
||||||
break;
|
break;
|
||||||
case Tool::EndLineTool:
|
case Tool::EndLineTool:
|
||||||
|
@ -715,6 +735,14 @@ void MainWindow::CanselTool(){
|
||||||
case Tool::Height:
|
case Tool::Height:
|
||||||
dialogHeight.clear();
|
dialogHeight.clear();
|
||||||
ui->toolButtonHeight->setChecked(false);
|
ui->toolButtonHeight->setChecked(false);
|
||||||
|
currentScene->setFocus(Qt::OtherFocusReason);
|
||||||
|
currentScene->clearSelection();
|
||||||
|
break;
|
||||||
|
case Tool::Triangle:
|
||||||
|
dialogTriangle.clear();
|
||||||
|
ui->toolButtonTriangle->setChecked(false);
|
||||||
|
currentScene->setFocus(Qt::OtherFocusReason);
|
||||||
|
currentScene->clearSelection();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning()<<"Get wrong tool type. Ignore.";
|
qWarning()<<"Get wrong tool type. Ignore.";
|
||||||
|
@ -957,6 +985,7 @@ void MainWindow::SetEnableTool(bool enable){
|
||||||
ui->toolButtonPointOfContact->setEnabled(enable);
|
ui->toolButtonPointOfContact->setEnabled(enable);
|
||||||
ui->toolButtonNewDetail->setEnabled(enable);
|
ui->toolButtonNewDetail->setEnabled(enable);
|
||||||
ui->toolButtonHeight->setEnabled(enable);
|
ui->toolButtonHeight->setEnabled(enable);
|
||||||
|
ui->toolButtonTriangle->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MinimumScrollBar(){
|
void MainWindow::MinimumScrollBar(){
|
||||||
|
|
|
@ -41,8 +41,7 @@ namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow{
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = 0);
|
explicit MainWindow(QWidget *parent = 0);
|
||||||
|
@ -81,6 +80,7 @@ public slots:
|
||||||
void ToolPointOfContact(bool checked);
|
void ToolPointOfContact(bool checked);
|
||||||
void ToolDetail(bool checked);
|
void ToolDetail(bool checked);
|
||||||
void ToolHeight(bool checked);
|
void ToolHeight(bool checked);
|
||||||
|
void ToolTriangle(bool checked);
|
||||||
void ClosedDialogEndLine(int result);
|
void ClosedDialogEndLine(int result);
|
||||||
void ClosedDialogLine(int result);
|
void ClosedDialogLine(int result);
|
||||||
void ClosedDialogAlongLine(int result);
|
void ClosedDialogAlongLine(int result);
|
||||||
|
@ -94,6 +94,7 @@ public slots:
|
||||||
void ClosedDialogPointOfContact(int result);
|
void ClosedDialogPointOfContact(int result);
|
||||||
void ClosedDialogDetail(int result);
|
void ClosedDialogDetail(int result);
|
||||||
void ClosedDialogHeight(int result);
|
void ClosedDialogHeight(int result);
|
||||||
|
void ClosedDialogTriangle(int result);
|
||||||
void About();
|
void About();
|
||||||
void AboutQt();
|
void AboutQt();
|
||||||
void ShowToolTip(const QString &toolTip);
|
void ShowToolTip(const QString &toolTip);
|
||||||
|
@ -138,6 +139,7 @@ private:
|
||||||
QSharedPointer<DialogPointOfContact> dialogPointOfContact;
|
QSharedPointer<DialogPointOfContact> dialogPointOfContact;
|
||||||
QSharedPointer<DialogDetail> dialogDetail;
|
QSharedPointer<DialogDetail> dialogDetail;
|
||||||
QSharedPointer<DialogHeight> dialogHeight;
|
QSharedPointer<DialogHeight> dialogHeight;
|
||||||
|
QSharedPointer<DialogTriangle> dialogTriangle;
|
||||||
DialogHistory *dialogHistory;
|
DialogHistory *dialogHistory;
|
||||||
VDomDocument *doc;
|
VDomDocument *doc;
|
||||||
VContainer *data;
|
VContainer *data;
|
||||||
|
|
|
@ -246,6 +246,32 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QToolButton" name="toolButtonTriangle">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Tool triangle.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icon.qrc">
|
||||||
|
<normaloff>:/icon/32x32/triangle.png</normaloff>:/icon/32x32/triangle.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page_2">
|
<widget class="QWidget" name="page_2">
|
||||||
|
@ -253,7 +279,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>150</width>
|
<width>100</width>
|
||||||
<height>58</height>
|
<height>58</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -329,7 +355,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>150</width>
|
<width>100</width>
|
||||||
<height>58</height>
|
<height>58</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -405,7 +431,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>150</width>
|
<width>98</width>
|
||||||
<height>58</height>
|
<height>58</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -455,7 +481,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>150</width>
|
<width>98</width>
|
||||||
<height>58</height>
|
<height>58</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -56,7 +56,8 @@ enum Tool {ArrowTool,
|
||||||
NodeArc,
|
NodeArc,
|
||||||
NodeSpline,
|
NodeSpline,
|
||||||
NodeSplinePath,
|
NodeSplinePath,
|
||||||
Height
|
Height,
|
||||||
|
Triangle
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(Tools, Tool)
|
Q_DECLARE_FLAGS(Tools, Tool)
|
||||||
|
|
||||||
|
|
|
@ -35,5 +35,6 @@
|
||||||
#include "vtoolspline.h"
|
#include "vtoolspline.h"
|
||||||
#include "vtoolsplinepath.h"
|
#include "vtoolsplinepath.h"
|
||||||
#include "vtoolheight.h"
|
#include "vtoolheight.h"
|
||||||
|
#include "vtooltriangle.h"
|
||||||
|
|
||||||
#endif // DRAWTOOLS_H
|
#endif // DRAWTOOLS_H
|
||||||
|
|
|
@ -79,8 +79,8 @@ void VToolAlongLine::AddToFile(){
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
AddAttribute(domElement, "type", "alongLine");
|
AddAttribute(domElement, "type", "alongLine");
|
||||||
AddAttribute(domElement, "name", point.name());
|
AddAttribute(domElement, "name", point.name());
|
||||||
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
|
AddAttribute(domElement, "mx", toMM(point.mx()));
|
||||||
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
|
AddAttribute(domElement, "my", toMM(point.my()));
|
||||||
|
|
||||||
AddAttribute(domElement, "typeLine", typeLine);
|
AddAttribute(domElement, "typeLine", typeLine);
|
||||||
AddAttribute(domElement, "length", formula);
|
AddAttribute(domElement, "length", formula);
|
||||||
|
|
|
@ -51,22 +51,22 @@ void VToolShoulderPoint::setDialog(){
|
||||||
QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
|
QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
|
||||||
const qreal &length){
|
const qreal &length){
|
||||||
QLineF line = QLineF(p1Line, p2Line);
|
QLineF line = QLineF(p1Line, p2Line);
|
||||||
qreal dist = line.length();
|
qreal dist = line.length();
|
||||||
if(dist>length){
|
if(dist>length){
|
||||||
qDebug()<<"A3П2="<<length/PrintDPI*25.4<<"А30П ="<<dist/PrintDPI*25.4;
|
qDebug()<<"A3П2="<<length/PrintDPI*25.4<<"А30П ="<<dist/PrintDPI*25.4;
|
||||||
throw"Не можу знайти точку плеча. Довжина А3П2 < А3П.";
|
throw"Не можу знайти точку плеча. Довжина А3П2 < А3П.";
|
||||||
}
|
}
|
||||||
if(dist==length){
|
if(dist==length){
|
||||||
|
return line.p2();
|
||||||
|
}
|
||||||
|
qreal step = 0.01;
|
||||||
|
while(1){
|
||||||
|
line.setLength(line.length()+step);
|
||||||
|
QLineF line2 = QLineF(pShoulder, line.p2());
|
||||||
|
if(line2.length()>=length){
|
||||||
return line.p2();
|
return line.p2();
|
||||||
}
|
}
|
||||||
qreal step = 0.01;
|
}
|
||||||
while(1){
|
|
||||||
line.setLength(line.length()+step);
|
|
||||||
QLineF line2 = QLineF(pShoulder, line.p2());
|
|
||||||
if(line2.length()>=length){
|
|
||||||
return line.p2();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolShoulderPoint::Create(QSharedPointer<DialogShoulderPoint> &dialog, VMainGraphicsScene *scene,
|
void VToolShoulderPoint::Create(QSharedPointer<DialogShoulderPoint> &dialog, VMainGraphicsScene *scene,
|
||||||
|
|
150
tools/drawTools/vtooltriangle.cpp
Normal file
150
tools/drawTools/vtooltriangle.cpp
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
#include "vtooltriangle.h"
|
||||||
|
|
||||||
|
VToolTriangle::VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const qint64 &axisP1Id, const qint64 &axisP2Id, const qint64 &firstPointId,
|
||||||
|
const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem *parent)
|
||||||
|
:VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId),
|
||||||
|
secondPointId(secondPointId), dialogTriangle(QSharedPointer<DialogTriangle>()) {
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolTriangle::setDialog(){
|
||||||
|
Q_ASSERT(!dialogTriangle.isNull());
|
||||||
|
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||||
|
dialogTriangle->setAxisP1Id(axisP1Id, id);
|
||||||
|
dialogTriangle->setAxisP2Id(axisP2Id, id);
|
||||||
|
dialogTriangle->setFirstPointId(firstPointId, id);
|
||||||
|
dialogTriangle->setSecondPointId(secondPointId, id);
|
||||||
|
dialogTriangle->setPointName(p.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolTriangle::Create(QSharedPointer<DialogTriangle> &dialog, VMainGraphicsScene *scene,
|
||||||
|
VDomDocument *doc, VContainer *data){
|
||||||
|
qint64 axisP1Id = dialog->getAxisP1Id();
|
||||||
|
qint64 axisP2Id = dialog->getAxisP2Id();
|
||||||
|
qint64 firstPointId = dialog->getFirstPointId();
|
||||||
|
qint64 secondPointId = dialog->getSecondPointId();
|
||||||
|
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,
|
||||||
|
const qint64 &axisP2Id, 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 axisP1 = data->GetPoint(axisP1Id);
|
||||||
|
VPointF axisP2 = data->GetPoint(axisP2Id);
|
||||||
|
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||||
|
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||||
|
|
||||||
|
QPointF point = FindPoint(axisP1.toQPointF(), axisP2.toQPointF(), firstPoint.toQPointF(),
|
||||||
|
secondPoint.toQPointF());
|
||||||
|
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){
|
||||||
|
VToolTriangle *point = new VToolTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId,
|
||||||
|
secondPointId, typeCreation);
|
||||||
|
scene->addItem(point);
|
||||||
|
connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
connect(point, &VToolTriangle::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
||||||
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor);
|
||||||
|
doc->AddTool(id, point);
|
||||||
|
doc->IncrementReferens(axisP1Id);
|
||||||
|
doc->IncrementReferens(axisP2Id);
|
||||||
|
doc->IncrementReferens(firstPointId);
|
||||||
|
doc->IncrementReferens(secondPointId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF VToolTriangle::FindPoint(const QPointF axisP1, const QPointF axisP2, const QPointF firstPoint,
|
||||||
|
const QPointF secondPoint){
|
||||||
|
qreal c = QLineF(firstPoint, secondPoint).length();
|
||||||
|
qreal a = QLineF(axisP2, firstPoint).length();
|
||||||
|
qreal b = QLineF(axisP2, secondPoint).length();
|
||||||
|
if(c*c == a*a + b*b){
|
||||||
|
return axisP2;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLineF line = QLineF(axisP1, axisP2);
|
||||||
|
qreal step = 0.01;
|
||||||
|
while(1){
|
||||||
|
line.setLength(line.length()+step);
|
||||||
|
a = QLineF(line.p2(), firstPoint).length();
|
||||||
|
b = QLineF(line.p2(), secondPoint).length();
|
||||||
|
if(static_cast<qint32>(c*c) == static_cast<qint32>(a*a + b*b)){
|
||||||
|
return line.p2();
|
||||||
|
}
|
||||||
|
if(c*c < a*a + b*b){
|
||||||
|
return axisP2;
|
||||||
|
qWarning()<<tr("Can't find point.")<<Q_FUNC_INFO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolTriangle::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
axisP1Id = domElement.attribute("axisP1", "").toLongLong();
|
||||||
|
axisP2Id = domElement.attribute("axisP2", "").toLongLong();
|
||||||
|
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||||
|
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
|
}
|
||||||
|
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolTriangle::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogTriangle->getPointName());
|
||||||
|
domElement.setAttribute("axisP1", QString().setNum(dialogTriangle->getAxisP1Id()));
|
||||||
|
domElement.setAttribute("axisP2", QString().setNum(dialogTriangle->getAxisP2Id()));
|
||||||
|
domElement.setAttribute("firstPoint", QString().setNum(dialogTriangle->getFirstPointId()));
|
||||||
|
domElement.setAttribute("secondPoint", QString().setNum(dialogTriangle->getSecondPointId()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
dialogTriangle.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolTriangle::RemoveReferens(){
|
||||||
|
doc->DecrementReferens(axisP1Id);
|
||||||
|
doc->DecrementReferens(axisP2Id);
|
||||||
|
doc->DecrementReferens(firstPointId);
|
||||||
|
doc->DecrementReferens(secondPointId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogTriangle, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolTriangle::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "triangle");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "mx", toMM(point.mx()));
|
||||||
|
AddAttribute(domElement, "my", toMM(point.my()));
|
||||||
|
|
||||||
|
AddAttribute(domElement, "axisP1", axisP1Id);
|
||||||
|
AddAttribute(domElement, "axisP2", axisP2Id);
|
||||||
|
AddAttribute(domElement, "firstPoint", firstPointId);
|
||||||
|
AddAttribute(domElement, "secondPoint", secondPointId);
|
||||||
|
|
||||||
|
AddToCalculation(domElement);
|
||||||
|
}
|
39
tools/drawTools/vtooltriangle.h
Normal file
39
tools/drawTools/vtooltriangle.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#ifndef VTOOLTRIANGLE_H
|
||||||
|
#define VTOOLTRIANGLE_H
|
||||||
|
|
||||||
|
#include "vtoolpoint.h"
|
||||||
|
#include "dialogs/dialogtriangle.h"
|
||||||
|
|
||||||
|
class VToolTriangle : public VToolPoint{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &axisP1Id,
|
||||||
|
const qint64 &axisP2Id, const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static void Create(QSharedPointer<DialogTriangle> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
|
VContainer *data);
|
||||||
|
static void Create(const qint64 _id, const QString &pointName,
|
||||||
|
const qint64 &axisP1Id, const qint64 &axisP2Id, 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);
|
||||||
|
static QPointF FindPoint(const QPointF axisP1, const QPointF axisP2, const QPointF firstPoint,
|
||||||
|
const QPointF secondPoint);
|
||||||
|
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(VToolTriangle)
|
||||||
|
qint64 axisP1Id;
|
||||||
|
qint64 axisP2Id;
|
||||||
|
qint64 firstPointId;
|
||||||
|
qint64 secondPointId;
|
||||||
|
QSharedPointer<DialogTriangle> dialogTriangle;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VTOOLTRIANGLE_H
|
|
@ -35,5 +35,6 @@
|
||||||
#include "vmodelingspline.h"
|
#include "vmodelingspline.h"
|
||||||
#include "vmodelingsplinepath.h"
|
#include "vmodelingsplinepath.h"
|
||||||
#include "vmodelingheight.h"
|
#include "vmodelingheight.h"
|
||||||
|
#include "vmodelingtriangle.h"
|
||||||
|
|
||||||
#endif // MODELINGTOOLS_H
|
#endif // MODELINGTOOLS_H
|
||||||
|
|
127
tools/modelingTools/vmodelingtriangle.cpp
Normal file
127
tools/modelingTools/vmodelingtriangle.cpp
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
#include "vmodelingtriangle.h"
|
||||||
|
#include "../drawTools/vtooltriangle.h"
|
||||||
|
|
||||||
|
VModelingTriangle::VModelingTriangle(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const qint64 &axisP1Id, const qint64 &axisP2Id,
|
||||||
|
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
Tool::Sources typeCreation, QGraphicsItem *parent)
|
||||||
|
:VModelingPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id),
|
||||||
|
firstPointId(firstPointId), secondPointId(secondPointId),
|
||||||
|
dialogTriangle(QSharedPointer<DialogTriangle>()) {
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingTriangle::setDialog(){
|
||||||
|
Q_ASSERT(!dialogTriangle.isNull());
|
||||||
|
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||||
|
dialogTriangle->setAxisP1Id(axisP1Id, id);
|
||||||
|
dialogTriangle->setAxisP2Id(axisP2Id, id);
|
||||||
|
dialogTriangle->setFirstPointId(firstPointId, id);
|
||||||
|
dialogTriangle->setSecondPointId(secondPointId, id);
|
||||||
|
dialogTriangle->setPointName(p.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingTriangle *VModelingTriangle::Create(QSharedPointer<DialogTriangle> &dialog, VDomDocument *doc,
|
||||||
|
VContainer *data){
|
||||||
|
qint64 axisP1Id = dialog->getAxisP1Id();
|
||||||
|
qint64 axisP2Id = dialog->getAxisP2Id();
|
||||||
|
qint64 firstPointId = dialog->getFirstPointId();
|
||||||
|
qint64 secondPointId = dialog->getSecondPointId();
|
||||||
|
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,
|
||||||
|
const qint64 &axisP1Id, const qint64 &axisP2Id,
|
||||||
|
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
const qreal &mx, const qreal &my, VDomDocument *doc,
|
||||||
|
VContainer *data, const Document::Documents &parse,
|
||||||
|
Tool::Sources typeCreation){
|
||||||
|
VModelingTriangle *tool = 0;
|
||||||
|
VPointF axisP1 = data->GetPoint(axisP1Id);
|
||||||
|
VPointF axisP2 = data->GetPoint(axisP2Id);
|
||||||
|
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||||
|
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||||
|
|
||||||
|
QPointF point = VToolTriangle::FindPoint(axisP1.toQPointF(), axisP2.toQPointF(), firstPoint.toQPointF(),
|
||||||
|
secondPoint.toQPointF());
|
||||||
|
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 VModelingTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId,
|
||||||
|
secondPointId, typeCreation);
|
||||||
|
doc->AddTool(id, tool);
|
||||||
|
doc->IncrementReferens(axisP1Id);
|
||||||
|
doc->IncrementReferens(axisP2Id);
|
||||||
|
doc->IncrementReferens(firstPointId);
|
||||||
|
doc->IncrementReferens(secondPointId);
|
||||||
|
}
|
||||||
|
return tool;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingTriangle::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
axisP1Id = domElement.attribute("axisP1", "").toLongLong();
|
||||||
|
axisP2Id = domElement.attribute("axisP2", "").toLongLong();
|
||||||
|
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||||
|
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
|
}
|
||||||
|
VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPoint(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingTriangle::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogTriangle->getPointName());
|
||||||
|
domElement.setAttribute("axisP1", QString().setNum(dialogTriangle->getAxisP1Id()));
|
||||||
|
domElement.setAttribute("axisP2", QString().setNum(dialogTriangle->getAxisP2Id()));
|
||||||
|
domElement.setAttribute("firstPoint", QString().setNum(dialogTriangle->getFirstPointId()));
|
||||||
|
domElement.setAttribute("secondPoint", QString().setNum(dialogTriangle->getSecondPointId()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
dialogTriangle.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingTriangle::RemoveReferens(){
|
||||||
|
doc->DecrementReferens(axisP1Id);
|
||||||
|
doc->DecrementReferens(axisP2Id);
|
||||||
|
doc->DecrementReferens(firstPointId);
|
||||||
|
doc->DecrementReferens(secondPointId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogTriangle, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingTriangle::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "triangle");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "mx", toMM(point.mx()));
|
||||||
|
AddAttribute(domElement, "my", toMM(point.my()));
|
||||||
|
|
||||||
|
AddAttribute(domElement, "axisP1", axisP1Id);
|
||||||
|
AddAttribute(domElement, "axisP2", axisP2Id);
|
||||||
|
AddAttribute(domElement, "firstPoint", firstPointId);
|
||||||
|
AddAttribute(domElement, "secondPoint", secondPointId);
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
39
tools/modelingTools/vmodelingtriangle.h
Normal file
39
tools/modelingTools/vmodelingtriangle.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#ifndef VMODELINGTRIANGLE_H
|
||||||
|
#define VMODELINGTRIANGLE_H
|
||||||
|
|
||||||
|
#include "vmodelingpoint.h"
|
||||||
|
#include "../drawTools/vtooltriangle.h"
|
||||||
|
#include "dialogs/dialogtriangle.h"
|
||||||
|
|
||||||
|
class VModelingTriangle : public VModelingPoint{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingTriangle(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const qint64 &axisP1Id, const qint64 &axisP2Id,
|
||||||
|
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static VModelingTriangle* Create(QSharedPointer<DialogTriangle> &dialog, VDomDocument *doc,
|
||||||
|
VContainer *data);
|
||||||
|
static VModelingTriangle* Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id,
|
||||||
|
const qint64 &axisP2Id, 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(VModelingTriangle)
|
||||||
|
qint64 axisP1Id;
|
||||||
|
qint64 axisP2Id;
|
||||||
|
qint64 firstPointId;
|
||||||
|
qint64 secondPointId;
|
||||||
|
QSharedPointer<DialogTriangle> dialogTriangle;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGTRIANGLE_H
|
|
@ -150,6 +150,22 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
tool->setParentItem(this);
|
tool->setParentItem(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case(Tool::Height):{
|
||||||
|
VModelingHeight *tool = qobject_cast<VModelingHeight*>(tools->value(detail[i].getId()));
|
||||||
|
Q_ASSERT(tool != 0);
|
||||||
|
connect(tool, &VModelingHeight::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
connect(tool, &VModelingHeight::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
||||||
|
tool->setParentItem(this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case(Tool::Triangle):{
|
||||||
|
VModelingTriangle *tool = qobject_cast<VModelingTriangle*>(tools->value(detail[i].getId()));
|
||||||
|
Q_ASSERT(tool != 0);
|
||||||
|
connect(tool, &VModelingTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
connect(tool, &VModelingTriangle::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
||||||
|
tool->setParentItem(this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
qWarning()<<"Get wrong tool type. Ignore.";
|
qWarning()<<"Get wrong tool type. Ignore.";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -831,6 +831,32 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
|
||||||
throw excep;
|
throw excep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(type == "triangle"){
|
||||||
|
try{
|
||||||
|
qint64 id = GetParametrId(domElement);
|
||||||
|
QString name = GetParametrString(domElement, "name");
|
||||||
|
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
|
||||||
|
qreal my = toPixel(GetParametrDouble(domElement, "my"));
|
||||||
|
qint64 axisP1Id = GetParametrLongLong(domElement, "axisP1");
|
||||||
|
qint64 axisP2Id = GetParametrLongLong(domElement, "axisP2");
|
||||||
|
qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint");
|
||||||
|
qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint");
|
||||||
|
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my,
|
||||||
|
scene, this, data, parse, Tool::FromFile);
|
||||||
|
} else {
|
||||||
|
VModelingTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my,
|
||||||
|
this, data, parse, Tool::FromFile);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch(const VExceptionBadId &e){
|
||||||
|
VExceptionObjectError excep(tr("Error creating or updating triangle"), domElement);
|
||||||
|
excep.AddMoreInformation(e.ErrorMessage());
|
||||||
|
throw excep;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user