New tool Height.
--HG-- branch : develop
This commit is contained in:
parent
2fffdecc86
commit
54bf459e17
|
@ -97,7 +97,10 @@ SOURCES += main.cpp\
|
||||||
exception/vexceptionemptyparameter.cpp \
|
exception/vexceptionemptyparameter.cpp \
|
||||||
exception/vexceptionobjecterror.cpp \
|
exception/vexceptionobjecterror.cpp \
|
||||||
widgets/vapplication.cpp \
|
widgets/vapplication.cpp \
|
||||||
exception/vexceptionuniqueid.cpp
|
exception/vexceptionuniqueid.cpp \
|
||||||
|
tools/drawTools/vtoolheight.cpp \
|
||||||
|
tools/modelingTools/vmodelingheight.cpp \
|
||||||
|
dialogs/dialogheight.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
widgets/vmaingraphicsscene.h \
|
widgets/vmaingraphicsscene.h \
|
||||||
|
@ -188,7 +191,10 @@ HEADERS += mainwindow.h \
|
||||||
exception/vexceptionemptyparameter.h \
|
exception/vexceptionemptyparameter.h \
|
||||||
exception/vexceptionobjecterror.h \
|
exception/vexceptionobjecterror.h \
|
||||||
widgets/vapplication.h \
|
widgets/vapplication.h \
|
||||||
exception/vexceptionuniqueid.h
|
exception/vexceptionuniqueid.h \
|
||||||
|
tools/drawTools/vtoolheight.h \
|
||||||
|
tools/modelingTools/vmodelingheight.h \
|
||||||
|
dialogs/dialogheight.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
dialogs/dialogsinglepoint.ui \
|
dialogs/dialogsinglepoint.ui \
|
||||||
|
@ -206,7 +212,8 @@ FORMS += mainwindow.ui \
|
||||||
dialogs/dialoghistory.ui \
|
dialogs/dialoghistory.ui \
|
||||||
dialogs/dialogpointofcontact.ui \
|
dialogs/dialogpointofcontact.ui \
|
||||||
dialogs/dialogdetail.ui \
|
dialogs/dialogdetail.ui \
|
||||||
tablewindow.ui
|
tablewindow.ui \
|
||||||
|
dialogs/dialogheight.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
icon.qrc \
|
icon.qrc \
|
||||||
|
|
|
@ -12,5 +12,6 @@
|
||||||
<file>cursor/splinepath_cursor.png</file>
|
<file>cursor/splinepath_cursor.png</file>
|
||||||
<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>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
BIN
cursor/height_cursor.png
Normal file
BIN
cursor/height_cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -30,8 +30,7 @@ namespace Ui {
|
||||||
class DialogEndLine;
|
class DialogEndLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DialogEndLine : public DialogTool
|
class DialogEndLine : public DialogTool{
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DialogEndLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,
|
explicit DialogEndLine(const VContainer *data, Draw::Draws mode = Draw::Calculation,
|
||||||
|
|
122
dialogs/dialogheight.cpp
Normal file
122
dialogs/dialogheight.cpp
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
#include "dialogheight.h"
|
||||||
|
#include "ui_dialogheight.h"
|
||||||
|
|
||||||
|
DialogHeight::DialogHeight(const VContainer *data, Draw::Draws mode, QWidget *parent) :
|
||||||
|
DialogTool(data, mode, parent), ui(new Ui::DialogHeight), number(0), pointName(QString()),
|
||||||
|
typeLine(QString()), basePointId(0), p1LineId(0), p2LineId(0){
|
||||||
|
ui->setupUi(this);
|
||||||
|
labelEditNamePoint = ui->labelEditNamePoint;
|
||||||
|
flagFormula = true;
|
||||||
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
connect(bOk, &QPushButton::clicked, this, &DialogHeight::DialogAccepted);
|
||||||
|
flagName = false;
|
||||||
|
CheckState();
|
||||||
|
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||||
|
connect(bCansel, &QPushButton::clicked, this, &DialogHeight::DialogRejected);
|
||||||
|
FillComboBoxPoints(ui->comboBoxBasePoint);
|
||||||
|
FillComboBoxPoints(ui->comboBoxP1Line);
|
||||||
|
FillComboBoxPoints(ui->comboBoxP2Line);
|
||||||
|
FillComboBoxTypeLine(ui->comboBoxLineType);
|
||||||
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogHeight::~DialogHeight(){
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DialogHeight::getPointName() const{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogHeight::setPointName(const QString &value){
|
||||||
|
pointName = value;
|
||||||
|
ui->lineEditNamePoint->setText(pointName);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DialogHeight::getTypeLine() const{
|
||||||
|
return typeLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogHeight::setTypeLine(const QString &value){
|
||||||
|
typeLine = value;
|
||||||
|
SetupTypeLine(ui->comboBoxLineType, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 DialogHeight::getBasePointId() const{
|
||||||
|
return basePointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogHeight::setBasePointId(const qint64 &value, const qint64 &id){
|
||||||
|
basePointId = value;
|
||||||
|
setCurrentPointId(ui->comboBoxBasePoint, basePointId, value, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 DialogHeight::getP1LineId() const{
|
||||||
|
return p1LineId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogHeight::setP1LineId(const qint64 &value, const qint64 &id){
|
||||||
|
p1LineId = value;
|
||||||
|
setCurrentPointId(ui->comboBoxP1Line, p1LineId, value, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 DialogHeight::getP2LineId() const{
|
||||||
|
return p2LineId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogHeight::setP2LineId(const qint64 &value, const qint64 &id){
|
||||||
|
p2LineId = value;
|
||||||
|
setCurrentPointId(ui->comboBoxP2Line, p2LineId, value, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogHeight::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->comboBoxBasePoint, point.name());
|
||||||
|
number++;
|
||||||
|
emit ToolTip(tr("Select first point of line"));
|
||||||
|
break;
|
||||||
|
case(1):
|
||||||
|
ChangeCurrentText(ui->comboBoxP1Line, point.name());
|
||||||
|
number++;
|
||||||
|
emit ToolTip(tr("Select second point of line"));
|
||||||
|
break;
|
||||||
|
case(2):
|
||||||
|
ChangeCurrentText(ui->comboBoxP2Line, point.name());
|
||||||
|
number = 0;
|
||||||
|
emit ToolTip(tr(""));
|
||||||
|
if(!isInitialized){
|
||||||
|
this->show();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogHeight::DialogAccepted(){
|
||||||
|
pointName = ui->lineEditNamePoint->text();
|
||||||
|
typeLine = GetTypeLine(ui->comboBoxLineType);
|
||||||
|
basePointId = getCurrentPointId(ui->comboBoxBasePoint);
|
||||||
|
p1LineId = getCurrentPointId(ui->comboBoxP1Line);
|
||||||
|
p2LineId = getCurrentPointId(ui->comboBoxP2Line);
|
||||||
|
emit DialogClosed(QDialog::Accepted);
|
||||||
|
}
|
||||||
|
|
40
dialogs/dialogheight.h
Normal file
40
dialogs/dialogheight.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#ifndef DIALOGHEIGHT_H
|
||||||
|
#define DIALOGHEIGHT_H
|
||||||
|
|
||||||
|
#include "dialogtool.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DialogHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DialogHeight : public DialogTool{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit DialogHeight(const VContainer *data, Draw::Draws mode = Draw::Calculation,
|
||||||
|
QWidget *parent = 0);
|
||||||
|
~DialogHeight();
|
||||||
|
QString getPointName() const;
|
||||||
|
void setPointName(const QString &value);
|
||||||
|
QString getTypeLine() const;
|
||||||
|
void setTypeLine(const QString &value);
|
||||||
|
qint64 getBasePointId() const;
|
||||||
|
void setBasePointId(const qint64 &value, const qint64 &id);
|
||||||
|
qint64 getP1LineId() const;
|
||||||
|
void setP1LineId(const qint64 &value, const qint64 &id);
|
||||||
|
qint64 getP2LineId() const;
|
||||||
|
void setP2LineId(const qint64 &value, const qint64 &id);
|
||||||
|
public slots:
|
||||||
|
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
|
||||||
|
virtual void DialogAccepted();
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(DialogHeight)
|
||||||
|
Ui::DialogHeight *ui;
|
||||||
|
qint32 number;
|
||||||
|
QString pointName;
|
||||||
|
QString typeLine;
|
||||||
|
qint64 basePointId;
|
||||||
|
qint64 p1LineId;
|
||||||
|
qint64 p2LineId;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIALOGHEIGHT_H
|
211
dialogs/dialogheight.ui
Normal file
211
dialogs/dialogheight.ui
Normal file
|
@ -0,0 +1,211 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DialogHeight</class>
|
||||||
|
<widget class="QDialog" name="DialogHeight">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>247</width>
|
||||||
|
<height>220</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>Base point</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxBasePoint">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>First point of line</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>First point of line</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxP1Line">
|
||||||
|
<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="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Second point of line</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxP2Line">
|
||||||
|
<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_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>Type line</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxLineType">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Show line from first point to our point</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>DialogHeight</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>DialogHeight</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>
|
|
@ -250,6 +250,20 @@ QString DialogHistory::Record(const VToolRecord &tool){
|
||||||
data->GetPoint(secondPointId).name(),
|
data->GetPoint(secondPointId).name(),
|
||||||
data->GetPoint(tool.getId()).name());
|
data->GetPoint(tool.getId()).name());
|
||||||
break;
|
break;
|
||||||
|
case Tool::Height:{
|
||||||
|
qint64 p1LineId = 0;
|
||||||
|
qint64 p2LineId = 0;
|
||||||
|
domElement = doc->elementById(QString().setNum(tool.getId()));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
basePointId = domElement.attribute("basePoint", "").toLongLong();
|
||||||
|
p1LineId = domElement.attribute("p1Line", "").toLongLong();
|
||||||
|
p2LineId = domElement.attribute("p2Line", "").toLongLong();
|
||||||
|
}
|
||||||
|
record = QString(tr("Point of perpendical from point %1 to line %2_%3")).arg(data->GetPoint(basePointId).name(),
|
||||||
|
data->GetPoint(p1LineId).name(),
|
||||||
|
data->GetPoint(p2LineId).name());
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
qWarning()<<tr("Get wrong tool type. Ignore.");
|
qWarning()<<tr("Get wrong tool type. Ignore.");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -37,5 +37,6 @@
|
||||||
#include "dialogsinglepoint.h"
|
#include "dialogsinglepoint.h"
|
||||||
#include "dialogspline.h"
|
#include "dialogspline.h"
|
||||||
#include "dialogsplinepath.h"
|
#include "dialogsplinepath.h"
|
||||||
|
#include "dialogheight.h"
|
||||||
|
|
||||||
#endif // DIALOGS_H
|
#endif // DIALOGS_H
|
||||||
|
|
|
@ -125,6 +125,8 @@ void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value){
|
||||||
qint32 index = box->findText(value);
|
qint32 index = box->findText(value);
|
||||||
if(index != -1){
|
if(index != -1){
|
||||||
box->setCurrentIndex(index);
|
box->setCurrentIndex(index);
|
||||||
|
} else {
|
||||||
|
qWarning()<<tr("Can't find point by name")<<value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
icon.qrc
1
icon.qrc
|
@ -34,5 +34,6 @@
|
||||||
<file>icon/32x32/new_detail.png</file>
|
<file>icon/32x32/new_detail.png</file>
|
||||||
<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>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
BIN
icon/32x32/height.png
Normal file
BIN
icon/32x32/height.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 857 B |
|
@ -44,10 +44,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
dialogAlongLine(QSharedPointer<DialogAlongLine>()),
|
dialogAlongLine(QSharedPointer<DialogAlongLine>()),
|
||||||
dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>()), dialogNormal(QSharedPointer<DialogNormal>()),
|
dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>()), dialogNormal(QSharedPointer<DialogNormal>()),
|
||||||
dialogBisector(QSharedPointer<DialogBisector>()),
|
dialogBisector(QSharedPointer<DialogBisector>()),
|
||||||
dialogLineIntersect(QSharedPointer<DialogLineIntersect>()),
|
dialogLineIntersect(QSharedPointer<DialogLineIntersect>()), dialogSpline(QSharedPointer<DialogSpline>()),
|
||||||
dialogSpline(QSharedPointer<DialogSpline>()),
|
|
||||||
dialogArc(QSharedPointer<DialogArc>()), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
|
dialogArc(QSharedPointer<DialogArc>()), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
|
||||||
dialogPointOfContact(QSharedPointer<DialogPointOfContact>()), dialogDetail(QSharedPointer<DialogDetail>()),
|
dialogPointOfContact(QSharedPointer<DialogPointOfContact>()),
|
||||||
|
dialogDetail(QSharedPointer<DialogDetail>()), dialogHeight(QSharedPointer<DialogHeight>()),
|
||||||
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);
|
||||||
|
@ -91,6 +91,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath);
|
connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath);
|
||||||
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);
|
||||||
|
|
||||||
data = new VContainer;
|
data = new VContainer;
|
||||||
|
|
||||||
|
@ -463,6 +464,23 @@ void MainWindow::ClosedDialogDetail(int result){
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::ToolHeight(bool checked){
|
||||||
|
SetToolButton(checked, Tool::Height, ":/cursor/height_cursor.png", tr("Select base point"),
|
||||||
|
dialogHeight, &MainWindow::ClosedDialogHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::ClosedDialogHeight(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
VToolHeight::Create(dialogHeight, currentScene, doc, data);
|
||||||
|
} else {
|
||||||
|
VModelingHeight *point = VModelingHeight::Create(dialogHeight, doc, data);
|
||||||
|
AddToolToDetail(point, point->getId(), Tool::Height, dialogHeight->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"));
|
||||||
}
|
}
|
||||||
|
@ -616,8 +634,7 @@ void MainWindow::mouseMove(QPointF scenePos){
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::CanselTool(){
|
void MainWindow::CanselTool(){
|
||||||
switch( tool )
|
switch( tool ){
|
||||||
{
|
|
||||||
case Tool::ArrowTool:
|
case Tool::ArrowTool:
|
||||||
ui->actionArrowTool->setChecked(false);
|
ui->actionArrowTool->setChecked(false);
|
||||||
helpLabel->setText("");
|
helpLabel->setText("");
|
||||||
|
@ -695,6 +712,10 @@ void MainWindow::CanselTool(){
|
||||||
dialogDetail.clear();
|
dialogDetail.clear();
|
||||||
ui->toolButtonNewDetail->setChecked(false);
|
ui->toolButtonNewDetail->setChecked(false);
|
||||||
break;
|
break;
|
||||||
|
case Tool::Height:
|
||||||
|
dialogHeight.clear();
|
||||||
|
ui->toolButtonHeight->setChecked(false);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning()<<"Get wrong tool type. Ignore.";
|
qWarning()<<"Get wrong tool type. Ignore.";
|
||||||
break;
|
break;
|
||||||
|
@ -935,6 +956,7 @@ void MainWindow::SetEnableTool(bool enable){
|
||||||
ui->toolButtonSplinePath->setEnabled(enable);
|
ui->toolButtonSplinePath->setEnabled(enable);
|
||||||
ui->toolButtonPointOfContact->setEnabled(enable);
|
ui->toolButtonPointOfContact->setEnabled(enable);
|
||||||
ui->toolButtonNewDetail->setEnabled(enable);
|
ui->toolButtonNewDetail->setEnabled(enable);
|
||||||
|
ui->toolButtonHeight->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MinimumScrollBar(){
|
void MainWindow::MinimumScrollBar(){
|
||||||
|
|
|
@ -80,6 +80,7 @@ public slots:
|
||||||
void ToolSplinePath(bool checked);
|
void ToolSplinePath(bool checked);
|
||||||
void ToolPointOfContact(bool checked);
|
void ToolPointOfContact(bool checked);
|
||||||
void ToolDetail(bool checked);
|
void ToolDetail(bool checked);
|
||||||
|
void ToolHeight(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);
|
||||||
|
@ -92,6 +93,7 @@ public slots:
|
||||||
void ClosedDialogSplinePath(int result);
|
void ClosedDialogSplinePath(int result);
|
||||||
void ClosedDialogPointOfContact(int result);
|
void ClosedDialogPointOfContact(int result);
|
||||||
void ClosedDialogDetail(int result);
|
void ClosedDialogDetail(int result);
|
||||||
|
void ClosedDialogHeight(int result);
|
||||||
void About();
|
void About();
|
||||||
void AboutQt();
|
void AboutQt();
|
||||||
void ShowToolTip(const QString &toolTip);
|
void ShowToolTip(const QString &toolTip);
|
||||||
|
@ -135,6 +137,7 @@ private:
|
||||||
QSharedPointer<DialogSplinePath> dialogSplinePath;
|
QSharedPointer<DialogSplinePath> dialogSplinePath;
|
||||||
QSharedPointer<DialogPointOfContact> dialogPointOfContact;
|
QSharedPointer<DialogPointOfContact> dialogPointOfContact;
|
||||||
QSharedPointer<DialogDetail> dialogDetail;
|
QSharedPointer<DialogDetail> dialogDetail;
|
||||||
|
QSharedPointer<DialogHeight> dialogHeight;
|
||||||
DialogHistory *dialogHistory;
|
DialogHistory *dialogHistory;
|
||||||
VDomDocument *doc;
|
VDomDocument *doc;
|
||||||
VContainer *data;
|
VContainer *data;
|
||||||
|
|
104
mainwindow.ui
104
mainwindow.ui
|
@ -48,7 +48,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>150</width>
|
<width>150</width>
|
||||||
<height>104</height>
|
<height>150</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -64,20 +64,20 @@
|
||||||
<string>Point</string>
|
<string>Point</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QToolButton" name="toolButtonNormal">
|
<widget class="QToolButton" name="toolButtonEndLine">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Tool point of normal.</string>
|
<string>Tool point on the end line.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="icon.qrc">
|
<iconset resource="icon.qrc">
|
||||||
<normaloff>:/icon/32x32/normal.png</normaloff>:/icon/32x32/normal.png</iconset>
|
<normaloff>:/icon/32x32/segment.png</normaloff>:/icon/32x32/segment.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
|
@ -116,46 +116,20 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="1" column="2">
|
||||||
<widget class="QToolButton" name="toolButtonEndLine">
|
<widget class="QToolButton" name="toolButtonPointOfContact">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Tool point on the end line.</string>
|
<string>Tool point of contact.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="icon.qrc">
|
<iconset resource="icon.qrc">
|
||||||
<normaloff>:/icon/32x32/segment.png</normaloff>:/icon/32x32/segment.png</iconset>
|
<normaloff>:/icon/32x32/point_of_contact.png</normaloff>:/icon/32x32/point_of_contact.png</iconset>
|
||||||
</property>
|
|
||||||
<property name="iconSize">
|
|
||||||
<size>
|
|
||||||
<width>32</width>
|
|
||||||
<height>32</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QToolButton" name="toolButtonAlongLine">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Tool point along line.</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="icon.qrc">
|
|
||||||
<normaloff>:/icon/32x32/along_line.png</normaloff>:/icon/32x32/along_line.png</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
|
@ -194,20 +168,72 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="0">
|
||||||
<widget class="QToolButton" name="toolButtonPointOfContact">
|
<widget class="QToolButton" name="toolButtonNormal">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Tool point of contact.</string>
|
<string>Tool point of normal.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="icon.qrc">
|
<iconset resource="icon.qrc">
|
||||||
<normaloff>:/icon/32x32/point_of_contact.png</normaloff>:/icon/32x32/point_of_contact.png</iconset>
|
<normaloff>:/icon/32x32/normal.png</normaloff>:/icon/32x32/normal.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QToolButton" name="toolButtonAlongLine">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Tool point along line.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icon.qrc">
|
||||||
|
<normaloff>:/icon/32x32/along_line.png</normaloff>:/icon/32x32/along_line.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QToolButton" name="toolButtonHeight">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Tool point of height.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icon.qrc">
|
||||||
|
<normaloff>:/icon/32x32/height.png</normaloff>:/icon/32x32/height.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
|
|
|
@ -55,7 +55,8 @@ enum Tool {ArrowTool,
|
||||||
NodePoint,
|
NodePoint,
|
||||||
NodeArc,
|
NodeArc,
|
||||||
NodeSpline,
|
NodeSpline,
|
||||||
NodeSplinePath
|
NodeSplinePath,
|
||||||
|
Height
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(Tools, Tool)
|
Q_DECLARE_FLAGS(Tools, Tool)
|
||||||
|
|
||||||
|
|
|
@ -34,5 +34,6 @@
|
||||||
#include "vtoolsinglepoint.h"
|
#include "vtoolsinglepoint.h"
|
||||||
#include "vtoolspline.h"
|
#include "vtoolspline.h"
|
||||||
#include "vtoolsplinepath.h"
|
#include "vtoolsplinepath.h"
|
||||||
|
#include "vtoolheight.h"
|
||||||
|
|
||||||
#endif // DRAWTOOLS_H
|
#endif // DRAWTOOLS_H
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
qreal VDrawTool::factor = 1;
|
qreal VDrawTool::factor = 1;
|
||||||
|
|
||||||
VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) :
|
VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) :
|
||||||
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false),
|
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false), ignoreFullUpdate(false),
|
||||||
nameActivDraw(doc->GetNameActivDraw()){
|
nameActivDraw(doc->GetNameActivDraw()){
|
||||||
connect(this->doc, &VDomDocument::ChangedActivDraw, this, &VDrawTool::ChangedActivDraw);
|
connect(this->doc, &VDomDocument::ChangedActivDraw, this, &VDrawTool::ChangedActivDraw);
|
||||||
connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw);
|
connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw);
|
||||||
|
|
|
@ -43,6 +43,7 @@ signals:
|
||||||
void RemoveTool(QGraphicsItem *tool);
|
void RemoveTool(QGraphicsItem *tool);
|
||||||
protected:
|
protected:
|
||||||
bool ignoreContextMenuEvent;
|
bool ignoreContextMenuEvent;
|
||||||
|
bool ignoreFullUpdate;
|
||||||
QString nameActivDraw;
|
QString nameActivDraw;
|
||||||
static qreal factor;
|
static qreal factor;
|
||||||
void AddToCalculation(const QDomElement &domElement);
|
void AddToCalculation(const QDomElement &domElement);
|
||||||
|
@ -67,11 +68,12 @@ protected:
|
||||||
if(selectedAction == actionOption){
|
if(selectedAction == actionOption){
|
||||||
dialog = QSharedPointer<Dialog>(new Dialog(getData()));
|
dialog = QSharedPointer<Dialog>(new Dialog(getData()));
|
||||||
|
|
||||||
connect(qobject_cast< VMainGraphicsScene * >(tool->scene()), &VMainGraphicsScene::ChoosedObject,
|
connect(qobject_cast< VMainGraphicsScene * >(tool->scene()),
|
||||||
dialog.data(), &Dialog::ChoosedObject);
|
&VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
|
||||||
connect(dialog.data(), &Dialog::DialogClosed, tool,
|
connect(dialog.data(), &Dialog::DialogClosed, tool, &Tool::FullUpdateFromGui);
|
||||||
&Tool::FullUpdateFromGui);
|
if(!ignoreFullUpdate){
|
||||||
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
|
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
|
||||||
|
}
|
||||||
|
|
||||||
tool->setDialog();
|
tool->setDialog();
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,12 @@ VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id
|
||||||
|
|
||||||
void VToolEndLine::setDialog(){
|
void VToolEndLine::setDialog(){
|
||||||
Q_ASSERT(!dialogEndLine.isNull());
|
Q_ASSERT(!dialogEndLine.isNull());
|
||||||
if(!dialogEndLine.isNull()){
|
|
||||||
VPointF p = VAbstractTool::data.GetPoint(id);
|
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||||
dialogEndLine->setTypeLine(typeLine);
|
dialogEndLine->setTypeLine(typeLine);
|
||||||
dialogEndLine->setFormula(formula);
|
dialogEndLine->setFormula(formula);
|
||||||
dialogEndLine->setAngle(angle);
|
dialogEndLine->setAngle(angle);
|
||||||
dialogEndLine->setBasePointId(basePointId, id);
|
dialogEndLine->setBasePointId(basePointId, id);
|
||||||
dialogEndLine->setPointName(p.name());
|
dialogEndLine->setPointName(p.name());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene,
|
void VToolEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene,
|
||||||
|
|
138
tools/drawTools/vtoolheight.cpp
Normal file
138
tools/drawTools/vtoolheight.cpp
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
#include "vtoolheight.h"
|
||||||
|
|
||||||
|
VToolHeight::VToolHeight(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
|
||||||
|
const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId,
|
||||||
|
Tool::Sources typeCreation, QGraphicsItem * parent)
|
||||||
|
:VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent),
|
||||||
|
dialogHeight(QSharedPointer<DialogHeight>()), p1LineId(p1LineId), p2LineId(p2LineId){
|
||||||
|
ignoreFullUpdate = true;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolHeight::setDialog(){
|
||||||
|
Q_ASSERT(!dialogHeight.isNull());
|
||||||
|
VPointF p = VAbstractTool::data.GetPoint(id);
|
||||||
|
dialogHeight->setTypeLine(typeLine);
|
||||||
|
dialogHeight->setBasePointId(basePointId, id);
|
||||||
|
dialogHeight->setP1LineId(p1LineId, id);
|
||||||
|
dialogHeight->setP2LineId(p2LineId, id);
|
||||||
|
dialogHeight->setPointName(p.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolHeight::Create(QSharedPointer<DialogHeight> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
|
VContainer *data){
|
||||||
|
disconnect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &DialogHeight::UpdateList);
|
||||||
|
QString pointName = dialog->getPointName();
|
||||||
|
QString typeLine = dialog->getTypeLine();
|
||||||
|
qint64 basePointId = dialog->getBasePointId();
|
||||||
|
qint64 p1LineId = dialog->getP1LineId();
|
||||||
|
qint64 p2LineId = dialog->getP2LineId();
|
||||||
|
Create(0, pointName, typeLine, basePointId, p1LineId, p2LineId, 5, 10, scene, doc, data,
|
||||||
|
Document::FullParse, Tool::FromGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolHeight::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||||
|
const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId,
|
||||||
|
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
|
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){
|
||||||
|
VPointF basePoint = data->GetPoint(basePointId);
|
||||||
|
VPointF p1Line = data->GetPoint(p1LineId);
|
||||||
|
VPointF p2Line = data->GetPoint(p2LineId);
|
||||||
|
|
||||||
|
QPointF pHeight = FindPoint(QLineF(p1Line.toQPointF(), p2Line.toQPointF()), basePoint.toQPointF());
|
||||||
|
qint64 id = _id;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
id = data->AddPoint(VPointF(pHeight.x(), pHeight.y(), pointName, mx, my));
|
||||||
|
data->AddLine(basePointId, id);
|
||||||
|
data->AddLine(p1LineId, id);
|
||||||
|
data->AddLine(p2LineId, id);
|
||||||
|
} else {
|
||||||
|
data->UpdatePoint(id, VPointF(pHeight.x(), pHeight.y(), pointName, mx, my));
|
||||||
|
data->AddLine(basePointId, id);
|
||||||
|
data->AddLine(p1LineId, id);
|
||||||
|
data->AddLine(p2LineId, id);
|
||||||
|
if(parse != Document::FullParse){
|
||||||
|
doc->UpdateToolData(id, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VDrawTool::AddRecord(id, Tool::Height, doc);
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
VToolHeight *point = new VToolHeight(doc, data, id, typeLine, basePointId, p1LineId, p2LineId,
|
||||||
|
typeCreation);
|
||||||
|
scene->addItem(point);
|
||||||
|
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
|
||||||
|
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
|
||||||
|
doc->AddTool(id, point);
|
||||||
|
doc->IncrementReferens(basePointId);
|
||||||
|
doc->IncrementReferens(p1LineId);
|
||||||
|
doc->IncrementReferens(p2LineId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF VToolHeight::FindPoint(const QLineF &line, const QPointF &point){
|
||||||
|
qreal a = 0, b = 0, c = 0;
|
||||||
|
LineCoefficients(line, &a, &b, &c);
|
||||||
|
qreal x = point.x() + a;
|
||||||
|
qreal y = b + point.y();
|
||||||
|
QLineF l (point, QPointF(x, y));
|
||||||
|
QPointF p;
|
||||||
|
QLineF::IntersectType intersect = line.intersect(l, &p);
|
||||||
|
if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){
|
||||||
|
return p;
|
||||||
|
} else {
|
||||||
|
return QPointF();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolHeight::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
typeLine = domElement.attribute("typeLine", "");
|
||||||
|
basePointId = domElement.attribute("basePoint", "").toLongLong();
|
||||||
|
p1LineId = domElement.attribute("p1Line", "").toLongLong();
|
||||||
|
p2LineId = domElement.attribute("p2Line", "").toLongLong();
|
||||||
|
}
|
||||||
|
RefreshGeometry();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolHeight::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogHeight->getPointName());
|
||||||
|
domElement.setAttribute("typeLine", dialogHeight->getTypeLine());
|
||||||
|
domElement.setAttribute("basePoint", QString().setNum(dialogHeight->getBasePointId()));
|
||||||
|
domElement.setAttribute("p1Line", QString().setNum(dialogHeight->getP1LineId()));
|
||||||
|
domElement.setAttribute("p2Line", QString().setNum(dialogHeight->getP2LineId()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogHeight.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogHeight, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolHeight::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "height");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "mx", toMM(point.mx()));
|
||||||
|
AddAttribute(domElement, "my", toMM(point.my()));
|
||||||
|
|
||||||
|
AddAttribute(domElement, "typeLine", typeLine);
|
||||||
|
AddAttribute(domElement, "basePoint", basePointId);
|
||||||
|
AddAttribute(domElement, "p1Line", p1LineId);
|
||||||
|
AddAttribute(domElement, "p2Line", p2LineId);
|
||||||
|
|
||||||
|
AddToCalculation(domElement);
|
||||||
|
|
||||||
|
}
|
34
tools/drawTools/vtoolheight.h
Normal file
34
tools/drawTools/vtoolheight.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef VTOOLHEIGHT_H
|
||||||
|
#define VTOOLHEIGHT_H
|
||||||
|
|
||||||
|
#include "vtoollinepoint.h"
|
||||||
|
#include "dialogs/dialogheight.h"
|
||||||
|
#include <QLineF>
|
||||||
|
|
||||||
|
class VToolHeight: public VToolLinePoint{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VToolHeight(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
|
||||||
|
const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId,
|
||||||
|
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static void Create(QSharedPointer<DialogHeight> &dialog, VMainGraphicsScene *scene,
|
||||||
|
VDomDocument *doc, VContainer *data);
|
||||||
|
static void Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||||
|
const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId,
|
||||||
|
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||||
|
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation);
|
||||||
|
static QPointF FindPoint(const QLineF &line, const QPointF &point);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
private:
|
||||||
|
QSharedPointer<DialogHeight> dialogHeight;
|
||||||
|
qint64 p1LineId;
|
||||||
|
qint64 p2LineId;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VTOOLHEIGHT_H
|
|
@ -34,5 +34,6 @@
|
||||||
#include "vmodelingsinglepoint.h"
|
#include "vmodelingsinglepoint.h"
|
||||||
#include "vmodelingspline.h"
|
#include "vmodelingspline.h"
|
||||||
#include "vmodelingsplinepath.h"
|
#include "vmodelingsplinepath.h"
|
||||||
|
#include "vmodelingheight.h"
|
||||||
|
|
||||||
#endif // MODELINGTOOLS_H
|
#endif // MODELINGTOOLS_H
|
||||||
|
|
|
@ -74,8 +74,8 @@ void VModelingAlongLine::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);
|
||||||
|
|
|
@ -24,9 +24,10 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include "widgets/vmaingraphicsscene.h"
|
#include "widgets/vmaingraphicsscene.h"
|
||||||
|
|
||||||
VModelingEndLine::VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
|
VModelingEndLine::VModelingEndLine(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const QString &formula, const qreal &angle, const qint64 &basePointId,
|
const QString &typeLine, const QString &formula, const qreal &angle,
|
||||||
Tool::Sources typeCreation, QGraphicsItem *parent):
|
const qint64 &basePointId, Tool::Sources typeCreation,
|
||||||
|
QGraphicsItem *parent):
|
||||||
VModelingLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent),
|
VModelingLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent),
|
||||||
dialogEndLine(QSharedPointer<DialogEndLine>()){
|
dialogEndLine(QSharedPointer<DialogEndLine>()){
|
||||||
|
|
||||||
|
@ -37,14 +38,12 @@ VModelingEndLine::VModelingEndLine(VDomDocument *doc, VContainer *data, const qi
|
||||||
|
|
||||||
void VModelingEndLine::setDialog(){
|
void VModelingEndLine::setDialog(){
|
||||||
Q_ASSERT(!dialogEndLine.isNull());
|
Q_ASSERT(!dialogEndLine.isNull());
|
||||||
if(!dialogEndLine.isNull()){
|
|
||||||
VPointF p = VAbstractTool::data.GetModelingPoint(id);
|
VPointF p = VAbstractTool::data.GetModelingPoint(id);
|
||||||
dialogEndLine->setTypeLine(typeLine);
|
dialogEndLine->setTypeLine(typeLine);
|
||||||
dialogEndLine->setFormula(formula);
|
dialogEndLine->setFormula(formula);
|
||||||
dialogEndLine->setAngle(angle);
|
dialogEndLine->setAngle(angle);
|
||||||
dialogEndLine->setBasePointId(basePointId, id);
|
dialogEndLine->setBasePointId(basePointId, id);
|
||||||
dialogEndLine->setPointName(p.name());
|
dialogEndLine->setPointName(p.name());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VModelingEndLine *VModelingEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VDomDocument *doc,
|
VModelingEndLine *VModelingEndLine::Create(QSharedPointer<DialogEndLine> &dialog, VDomDocument *doc,
|
||||||
|
@ -70,7 +69,7 @@ VModelingEndLine *VModelingEndLine::Create(const qint64 _id, const QString &poin
|
||||||
QString errorMsg;
|
QString errorMsg;
|
||||||
qreal result = cal.eval(formula, &errorMsg);
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
if(errorMsg.isEmpty()){
|
if(errorMsg.isEmpty()){
|
||||||
line.setLength(result*PrintDPI/25.4);
|
line.setLength(toPixel(result));
|
||||||
line.setAngle(angle);
|
line.setAngle(angle);
|
||||||
qint64 id = _id;
|
qint64 id = _id;
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
|
@ -97,7 +96,7 @@ void VModelingEndLine::FullUpdateFromFile(){
|
||||||
typeLine = domElement.attribute("typeLine", "");
|
typeLine = domElement.attribute("typeLine", "");
|
||||||
formula = domElement.attribute("length", "");
|
formula = domElement.attribute("length", "");
|
||||||
basePointId = domElement.attribute("basePoint", "").toLongLong();
|
basePointId = domElement.attribute("basePoint", "").toLongLong();
|
||||||
angle = domElement.attribute("angle", "").toInt();
|
angle = domElement.attribute("angle", "").toDouble();
|
||||||
}
|
}
|
||||||
RefreshGeometry();
|
RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
|
130
tools/modelingTools/vmodelingheight.cpp
Normal file
130
tools/modelingTools/vmodelingheight.cpp
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
#include "vmodelingheight.h"
|
||||||
|
|
||||||
|
VModelingHeight::VModelingHeight(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine, const qint64 &basePointId, const qint64 &p1LineId,
|
||||||
|
const qint64 &p2LineId, Tool::Sources typeCreation,
|
||||||
|
QGraphicsItem * parent)
|
||||||
|
:VModelingLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent),
|
||||||
|
dialogHeight(QSharedPointer<DialogHeight>()), p1LineId(p1LineId), p2LineId(p2LineId){
|
||||||
|
ignoreFullUpdate = true;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingHeight::setDialog(){
|
||||||
|
Q_ASSERT(!dialogHeight.isNull());
|
||||||
|
VPointF p = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
dialogHeight->setTypeLine(typeLine);
|
||||||
|
dialogHeight->setBasePointId(basePointId, id);
|
||||||
|
dialogHeight->setP1LineId(p1LineId, id);
|
||||||
|
dialogHeight->setP2LineId(p2LineId, id);
|
||||||
|
dialogHeight->setPointName(p.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingHeight *VModelingHeight::Create(QSharedPointer<DialogHeight> &dialog, VDomDocument *doc,
|
||||||
|
VContainer *data){
|
||||||
|
disconnect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &DialogHeight::UpdateList);
|
||||||
|
QString pointName = dialog->getPointName();
|
||||||
|
QString typeLine = dialog->getTypeLine();
|
||||||
|
qint64 basePointId = dialog->getBasePointId();
|
||||||
|
qint64 p1LineId = dialog->getP1LineId();
|
||||||
|
qint64 p2LineId = dialog->getP2LineId();
|
||||||
|
return Create(0, pointName, typeLine, basePointId, p1LineId, p2LineId, 5, 10, doc, data,
|
||||||
|
Document::FullParse, Tool::FromGui);
|
||||||
|
}
|
||||||
|
|
||||||
|
VModelingHeight *VModelingHeight::Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||||
|
const qint64 &basePointId, const qint64 &p1LineId,
|
||||||
|
const qint64 &p2LineId, const qreal &mx, const qreal &my,
|
||||||
|
VDomDocument *doc, VContainer *data,
|
||||||
|
const Document::Documents &parse, Tool::Sources typeCreation){
|
||||||
|
VModelingHeight *point = 0;
|
||||||
|
VPointF basePoint = data->GetModelingPoint(basePointId);
|
||||||
|
VPointF p1Line = data->GetModelingPoint(p1LineId);
|
||||||
|
VPointF p2Line = data->GetModelingPoint(p2LineId);
|
||||||
|
|
||||||
|
QPointF pHeight = FindPoint(QLineF(p1Line.toQPointF(), p2Line.toQPointF()), basePoint.toQPointF());
|
||||||
|
QLineF line = QLineF(basePoint.toQPointF(), pHeight);
|
||||||
|
qint64 id = _id;
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
id = data->AddModelingPoint(VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||||
|
} else {
|
||||||
|
data->UpdateModelingPoint(id, VPointF(line.p2().x(), line.p2().y(), pointName, mx, my));
|
||||||
|
if(parse != Document::FullParse){
|
||||||
|
doc->UpdateToolData(id, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data->AddLine(basePointId, id, Draw::Modeling);
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
point = new VModelingHeight(doc, data, id, typeLine, basePointId, p1LineId, p2LineId, typeCreation);
|
||||||
|
doc->AddTool(id, point);
|
||||||
|
doc->IncrementReferens(basePointId);
|
||||||
|
doc->IncrementReferens(p1LineId);
|
||||||
|
doc->IncrementReferens(p2LineId);
|
||||||
|
}
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingHeight::FullUpdateFromFile(){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
typeLine = domElement.attribute("typeLine", "");
|
||||||
|
basePointId = domElement.attribute("basePoint", "").toLongLong();
|
||||||
|
p1LineId = domElement.attribute("p1Line", "").toLongLong();
|
||||||
|
p2LineId = domElement.attribute("p2Line", "").toLongLong();
|
||||||
|
}
|
||||||
|
RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingHeight::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogHeight->getPointName());
|
||||||
|
domElement.setAttribute("typeLine", dialogHeight->getTypeLine());
|
||||||
|
domElement.setAttribute("basePoint", QString().setNum(dialogHeight->getBasePointId()));
|
||||||
|
domElement.setAttribute("p1Line", QString().setNum(dialogHeight->getP1LineId()));
|
||||||
|
domElement.setAttribute("p2Line", QString().setNum(dialogHeight->getP2LineId()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogHeight.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
ContextMenu(dialogHeight, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VModelingHeight::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data.GetModelingPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "endLine");
|
||||||
|
AddAttribute(domElement, "name", point.name());
|
||||||
|
AddAttribute(domElement, "mx", toMM(point.mx()));
|
||||||
|
AddAttribute(domElement, "my", toMM(point.my()));
|
||||||
|
|
||||||
|
AddAttribute(domElement, "typeLine", typeLine);
|
||||||
|
AddAttribute(domElement, "basePoint", basePointId);
|
||||||
|
AddAttribute(domElement, "p1Line", p1LineId);
|
||||||
|
AddAttribute(domElement, "p2Line", p2LineId);
|
||||||
|
|
||||||
|
AddToModeling(domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF VModelingHeight::FindPoint(const QLineF &line, const QPointF &point){
|
||||||
|
qreal a = 0, b = 0, c = 0;
|
||||||
|
LineCoefficients(line, &a, &b, &c);
|
||||||
|
qreal x = point.x() - b;
|
||||||
|
qreal y = -a + point.y();
|
||||||
|
QLineF l (point, QPointF(x, y));
|
||||||
|
QPointF p;
|
||||||
|
QLineF::IntersectType intersect = line.intersect(l, &p);
|
||||||
|
if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){
|
||||||
|
return p;
|
||||||
|
} else {
|
||||||
|
return QPointF();
|
||||||
|
}
|
||||||
|
}
|
34
tools/modelingTools/vmodelingheight.h
Normal file
34
tools/modelingTools/vmodelingheight.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef VMODELINGHEIGHT_H
|
||||||
|
#define VMODELINGHEIGHT_H
|
||||||
|
|
||||||
|
#include "vmodelinglinepoint.h"
|
||||||
|
#include "dialogs/dialogheight.h"
|
||||||
|
|
||||||
|
class VModelingHeight : public VModelingLinePoint{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VModelingHeight(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine, const qint64 &basePointId,
|
||||||
|
const qint64 &p1LineId, const qint64 &p2LineId,
|
||||||
|
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
|
||||||
|
virtual void setDialog();
|
||||||
|
static VModelingHeight* Create(QSharedPointer<DialogHeight> &dialog, VDomDocument *doc,
|
||||||
|
VContainer *data);
|
||||||
|
static VModelingHeight* Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||||
|
const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId,
|
||||||
|
const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data,
|
||||||
|
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||||
|
static QPointF FindPoint(const QLineF &line, const QPointF &point);
|
||||||
|
public slots:
|
||||||
|
virtual void FullUpdateFromFile();
|
||||||
|
virtual void FullUpdateFromGui(int result);
|
||||||
|
protected:
|
||||||
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
|
virtual void AddToFile();
|
||||||
|
private:
|
||||||
|
QSharedPointer<DialogHeight> dialogHeight;
|
||||||
|
qint64 p1LineId;
|
||||||
|
qint64 p2LineId;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMODELINGHEIGHT_H
|
|
@ -23,7 +23,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
VModelingTool::VModelingTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent):
|
VModelingTool::VModelingTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent):
|
||||||
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false){
|
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false), ignoreFullUpdate(false) {
|
||||||
_referens = 0;
|
_referens = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ signals:
|
||||||
void RemoveTool(QGraphicsItem *tool);
|
void RemoveTool(QGraphicsItem *tool);
|
||||||
protected:
|
protected:
|
||||||
bool ignoreContextMenuEvent;
|
bool ignoreContextMenuEvent;
|
||||||
|
bool ignoreFullUpdate;
|
||||||
void AddToModeling(const QDomElement &domElement);
|
void AddToModeling(const QDomElement &domElement);
|
||||||
virtual void decrementReferens();
|
virtual void decrementReferens();
|
||||||
template <typename Dialog, typename Tool>
|
template <typename Dialog, typename Tool>
|
||||||
|
@ -46,26 +47,30 @@ protected:
|
||||||
bool showRemove = true){
|
bool showRemove = true){
|
||||||
if(!ignoreContextMenuEvent){
|
if(!ignoreContextMenuEvent){
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
QAction *actionOption = menu.addAction("Властивості");
|
QAction *actionOption = menu.addAction(tr("Option"));
|
||||||
QAction *actionRemove;
|
QAction *actionRemove = 0;
|
||||||
if(showRemove){
|
if(showRemove){
|
||||||
actionRemove = menu.addAction("Видалити");
|
actionRemove = menu.addAction(tr("Delete"));
|
||||||
}
|
}
|
||||||
QAction *selectedAction = menu.exec(event->screenPos());
|
QAction *selectedAction = menu.exec(event->screenPos());
|
||||||
if(selectedAction == actionOption){
|
if(selectedAction == actionOption){
|
||||||
dialog = QSharedPointer<Dialog>(new Dialog(getData()));
|
dialog = QSharedPointer<Dialog>(new Dialog(getData()));
|
||||||
|
|
||||||
connect(qobject_cast< VMainGraphicsScene * >(tool->scene()), &VMainGraphicsScene::ChoosedObject,
|
connect(qobject_cast< VMainGraphicsScene * >(tool->scene()),
|
||||||
dialog.data(), &Dialog::ChoosedObject);
|
&VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
|
||||||
connect(dialog.data(), &Dialog::DialogClosed, tool,
|
connect(dialog.data(), &Dialog::DialogClosed, tool, &Tool::FullUpdateFromGui);
|
||||||
&Tool::FullUpdateFromGui);
|
if(!ignoreFullUpdate){
|
||||||
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
|
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
|
||||||
|
}
|
||||||
|
|
||||||
tool->setDialog();
|
tool->setDialog();
|
||||||
|
|
||||||
dialog->show();
|
dialog->show();
|
||||||
}
|
}
|
||||||
|
if(showRemove){
|
||||||
if(selectedAction == actionRemove){
|
if(selectedAction == actionRemove){
|
||||||
|
//deincrement referens
|
||||||
|
RemoveReferens();
|
||||||
//remove form xml file
|
//remove form xml file
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
if(domElement.isElement()){
|
if(domElement.isElement()){
|
||||||
|
@ -82,6 +87,7 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VMODELINGTOOL_H
|
#endif // VMODELINGTOOL_H
|
||||||
|
|
|
@ -85,10 +85,8 @@ qint32 VAbstractTool::LineIntersectCircle(QPointF center, qreal radius, QLineF l
|
||||||
QPointF &p2){
|
QPointF &p2){
|
||||||
const qreal eps = 1e-8;
|
const qreal eps = 1e-8;
|
||||||
//коефіцієнти для рівняння відрізку
|
//коефіцієнти для рівняння відрізку
|
||||||
qreal a = line.p2().y() - line.p1().y();
|
qreal a = 0, b = 0, c = 0;
|
||||||
qreal b = line.p1().x() - line.p2().x();
|
LineCoefficients(line, &a, &b, &c);
|
||||||
// В даному випадку не використовується.
|
|
||||||
//qreal c = - a * line.p1().x() - b * line.p1().y();
|
|
||||||
// проекция центра окружности на прямую
|
// проекция центра окружности на прямую
|
||||||
QPointF p = ClosestPoint (line, center);
|
QPointF p = ClosestPoint (line, center);
|
||||||
// сколько всего решений?
|
// сколько всего решений?
|
||||||
|
@ -138,6 +136,13 @@ const VContainer *VAbstractTool::getData()const{
|
||||||
return &data;
|
return &data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c){
|
||||||
|
//коефіцієнти для рівняння відрізку
|
||||||
|
*a = line.p2().y() - line.p1().y();
|
||||||
|
*b = line.p1().x() - line.p2().x();
|
||||||
|
*c = - *a * line.p1().x() - *b * line.p1().y();
|
||||||
|
}
|
||||||
|
|
||||||
qint64 VAbstractTool::getId() const{
|
qint64 VAbstractTool::getId() const{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
static QPointF ClosestPoint(QLineF line, QPointF p);
|
static QPointF ClosestPoint(QLineF line, QPointF p);
|
||||||
static QPointF addVector (QPointF p, QPointF p1, QPointF p2, qreal k);
|
static QPointF addVector (QPointF p, QPointF p1, QPointF p2, qreal k);
|
||||||
qint64 getId() const;
|
qint64 getId() const;
|
||||||
|
static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c);
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile()=0;
|
virtual void FullUpdateFromFile()=0;
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -806,6 +806,31 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
|
||||||
throw excep;
|
throw excep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(type == "height"){
|
||||||
|
try{
|
||||||
|
qint64 id = GetParametrId(domElement);
|
||||||
|
QString name = GetParametrString(domElement, "name");
|
||||||
|
qreal mx = toPixel(GetParametrDouble(domElement, "mx"));
|
||||||
|
qreal my = toPixel(GetParametrDouble(domElement, "my"));
|
||||||
|
QString typeLine = GetParametrString(domElement, "typeLine");
|
||||||
|
qint64 basePointId = GetParametrLongLong(domElement, "basePoint");
|
||||||
|
qint64 p1LineId = GetParametrLongLong(domElement, "p1Line");
|
||||||
|
qint64 p2LineId = GetParametrLongLong(domElement, "p2Line");
|
||||||
|
if(mode == Draw::Calculation){
|
||||||
|
VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId, mx, my, scene,
|
||||||
|
this, data, parse, Tool::FromFile);
|
||||||
|
} else {
|
||||||
|
VModelingHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId, mx, my, this,
|
||||||
|
data, parse, Tool::FromFile);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch(const VExceptionBadId &e){
|
||||||
|
VExceptionObjectError excep(tr("Error creating or updating height"), 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