Supplement for seams.

--HG--
branch : develop
This commit is contained in:
dismine 2013-10-25 14:10:45 +03:00
parent aac3dca764
commit 473c90c72c
11 changed files with 500 additions and 98 deletions

View file

@ -177,11 +177,18 @@ void VContainer::UpdateId(qint64 newId){
QPainterPath VContainer::ContourPath(qint64 idDetail) const{
VDetail detail = GetDetail(idDetail);
QVector<QPointF> points;
QVector<QPointF> pointsEkv;
for(qint32 i = 0; i< detail.CountNode(); ++i){
switch(detail[i].getTypeTool()){
case(Tool::NodePoint):{
VPointF point = GetModelingPoint(detail[i].getId());
points.append(point.toQPointF());
if(detail.getSupplement() == true){
QPointF pEkv = point.toQPointF();
pEkv.setX(pEkv.x()+detail[i].getMx());
pEkv.setY(pEkv.y()+detail[i].getMy());
pointsEkv.append(pEkv);
}
}
break;
case(Tool::NodeArc):{
@ -190,8 +197,15 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
qreal lenReverse = GetLengthContour(points, GetReversePoint(arc.GetPoints()));
if(len1 <= lenReverse){
points << arc.GetPoints();
if(detail.getSupplement() == true){
pointsEkv << biasPoints(arc.GetPoints(), detail[i].getMx(), detail[i].getMy());
}
} else {
points << GetReversePoint(arc.GetPoints());
if(detail.getSupplement() == true){
pointsEkv << biasPoints(GetReversePoint(arc.GetPoints()), detail[i].getMx(),
detail[i].getMy());
}
}
}
break;
@ -201,8 +215,15 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
qreal lenReverse = GetLengthContour(points, GetReversePoint(spline.GetPoints()));
if(len1 <= lenReverse){
points << spline.GetPoints();
if(detail.getSupplement() == true){
pointsEkv << biasPoints(spline.GetPoints(), detail[i].getMx(), detail[i].getMy());
}
} else {
points << GetReversePoint(spline.GetPoints());
if(detail.getSupplement() == true){
pointsEkv << biasPoints(GetReversePoint(spline.GetPoints()), detail[i].getMx(),
detail[i].getMy());
}
}
}
break;
@ -212,8 +233,15 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
qreal lenReverse = GetLengthContour(points, GetReversePoint(splinePath.GetPathPoints()));
if(len1 <= lenReverse){
points << splinePath.GetPathPoints();
if(detail.getSupplement() == true){
pointsEkv << biasPoints(splinePath.GetPathPoints(), detail[i].getMx(), detail[i].getMy());
}
} else {
points << GetReversePoint(splinePath.GetPathPoints());
if(detail.getSupplement() == true){
pointsEkv << biasPoints(GetReversePoint(splinePath.GetPathPoints()), detail[i].getMx(),
detail[i].getMy());
}
}
}
break;
@ -224,18 +252,38 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const{
break;
}
}
QPainterPath ekv = Equidistant(points, Detail::CloseEquidistant, toPixel(10));
QPainterPath path;
path.moveTo(points[0]);
for (qint32 i = 1; i < points.count(); ++i){
path.lineTo(points[i]);
}
path.lineTo(points[0]);
path.addPath(ekv);
path.setFillRule(Qt::WindingFill);
if(detail.getSupplement() == true){
QPainterPath ekv;
if(detail.getClosed() == true){
ekv = Equidistant(pointsEkv, Detail::CloseEquidistant, toPixel(detail.getWidth()));
} else {
ekv = Equidistant(pointsEkv, Detail::OpenEquidistant, toPixel(detail.getWidth()));
}
path.addPath(ekv);
path.setFillRule(Qt::WindingFill);
}
return path;
}
QVector<QPointF> VContainer::biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my) const{
QVector<QPointF> p;
for(qint32 i = 0; i < points.size(); ++i){
QPointF point = points.at(i);
point.setX(point.x() + mx);
point.setY(point.x() + my);
p.append(point);
}
return p;
}
QPainterPath VContainer::Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv,
const qreal &width) const{
QPainterPath ekv;

View file

@ -140,6 +140,7 @@ public:
const QHash<qint64, VDetail> *DataDetails() const;
static void UpdateId(qint64 newId);
QPainterPath ContourPath(qint64 idDetail) const;
QVector<QPointF> biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my) const;
QPainterPath Equidistant(QVector<QPointF> points, const Detail::Equidistant &eqv,
const qreal &width)const;
static QLineF ParallelLine(const QLineF &line, qreal width );

View file

@ -23,13 +23,24 @@
#include <QDebug>
DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent) :
DialogTool(data, mode, parent), ui(), details(VDetail()){
DialogTool(data, mode, parent), ui(), details(VDetail()), supplement(true), closed(true){
ui.setupUi(this);
labelEditNamePoint = ui.labelEditNameDetail;
bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogDetail::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogDetail::DialogRejected);
connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogDetail::ObjectChanged);
connect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasXChanged);
connect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
connect(ui.checkBoxSeams, &QCheckBox::clicked, this, &DialogDetail::ClickedSeams);
connect(ui.checkBoxClosed, &QCheckBox::clicked, this, &DialogDetail::ClickedClosed);
connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NamePointChanged);
}
void DialogDetail::ChoosedObject(qint64 id, Scene::Scenes type){
@ -72,12 +83,16 @@ void DialogDetail::DialogAccepted(){
QListWidgetItem *item = ui.listWidget->item(i);
details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
}
details.setWidth(ui.doubleSpinBoxSeams->value());
details.setName(ui.lineEditNameDetail->text());
details.setSupplement(supplement);
details.setClosed(closed);
emit ToolTip("");
emit DialogClosed(QDialog::Accepted);
}
void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode){
void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode, qreal mx,
qreal my){
QString name;
switch(typeTool){
case(Tool::NodePoint):{
@ -127,9 +142,19 @@ void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, No
QListWidgetItem *item = new QListWidgetItem(name);
item->setFont(QFont("Times", 12, QFont::Bold));
VNodeDetail node(id, typeTool, mode, typeNode);
VNodeDetail node(id, typeTool, mode, typeNode, mx, my);
item->setData(Qt::UserRole, QVariant::fromValue(node));
ui.listWidget->addItem(item);
disconnect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasXChanged);
disconnect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
ui.doubleSpinBoxBiasX->setValue(toMM(node.getMx()));
ui.doubleSpinBoxBiasY->setValue(toMM(node.getMy()));
connect(ui.doubleSpinBoxBiasX, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasXChanged);
connect(ui.doubleSpinBoxBiasY, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
}
VDetail DialogDetail::getDetails() const{
@ -140,9 +165,49 @@ void DialogDetail::setDetails(const VDetail &value){
details = value;
ui.listWidget->clear();
for(qint32 i = 0; i < details.CountNode(); ++i){
NewItem(details[i].getId(), details[i].getTypeTool(),details[i].getMode(), details[i].getTypeNode());
NewItem(details[i].getId(), details[i].getTypeTool(), details[i].getMode(), details[i].getTypeNode(), details[i].getMx(),
details[i].getMy());
}
details.setName(ui.lineEditNameDetail->text());
ui.lineEditNameDetail->setText(details.getName());
ui.checkBoxSeams->setChecked(details.getSupplement());
ui.checkBoxClosed->setChecked(details.getClosed());
ui.doubleSpinBoxSeams->setValue(details.getWidth());
ui.listWidget->setCurrentRow(0);
ui.listWidget->setFocus(Qt::OtherFocusReason);
}
void DialogDetail::BiasXChanged(qreal d){
qint32 row = ui.listWidget->currentRow();
QListWidgetItem *item = ui.listWidget->item( row );
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
node.setMx(toPixel(d));
item->setData(Qt::UserRole, QVariant::fromValue(node));
}
void DialogDetail::BiasYChanged(qreal d){
qint32 row = ui.listWidget->currentRow();
QListWidgetItem *item = ui.listWidget->item( row );
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
node.setMy(toPixel(d));
item->setData(Qt::UserRole, QVariant::fromValue(node));
}
void DialogDetail::ClickedSeams(bool checked){
supplement = checked;
ui.checkBoxClosed->setEnabled(checked);
ui.doubleSpinBoxSeams->setEnabled(checked);
}
void DialogDetail::ClickedClosed(bool checked){
closed = checked;
}
void DialogDetail::ObjectChanged(int row){
if(ui.listWidget->count() == 0){
return;
}
QListWidgetItem *item = ui.listWidget->item( row );
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
ui.doubleSpinBoxBiasX->setValue(toMM(node.getMx()));
ui.doubleSpinBoxBiasY->setValue(toMM(node.getMy()));
}

View file

@ -29,17 +29,24 @@
class DialogDetail : public DialogTool{
Q_OBJECT
public:
explicit DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent = 0);
VDetail getDetails() const;
void setDetails(const VDetail &value);
DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent = 0);
VDetail getDetails() const;
void setDetails(const VDetail &value);
public slots:
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted();
virtual void ChoosedObject(qint64 id, Scene::Scenes type);
virtual void DialogAccepted();
void BiasXChanged(qreal d);
void BiasYChanged(qreal d);
void ClickedSeams(bool checked);
void ClickedClosed(bool checked);
void ObjectChanged(int row);
private:
Ui::DialogDetail ui;
VDetail details;
void NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode);
VDetail details;
bool supplement;
bool closed;
void NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode, qreal mx = 0,
qreal my = 0);
};
#endif // DIALOGDETAIL_H

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>298</height>
<width>544</width>
<height>327</height>
</rect>
</property>
<property name="windowTitle">
@ -20,47 +20,196 @@
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelEditNameDetail">
<widget class="QLabel" name="label">
<property name="text">
<string>Bias X</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxBiasX">
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Name detail</string>
<string>Bias Y</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNameDetail"/>
<widget class="QDoubleSpinBox" name="doubleSpinBoxBiasY">
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="checkBoxClosed">
<property name="text">
<string>Closed</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Option</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labelEditNameDetail">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<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="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Name of detail</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNameDetail">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxSeams">
<property name="text">
<string>Supplement for seams</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelEditWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSeams">
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="value">
<double>10.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxClosed">
<property name="text">
<string>Closed</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
@ -83,7 +232,6 @@
</widget>
<tabstops>
<tabstop>lineEditNameDetail</tabstop>
<tabstop>checkBoxClosed</tabstop>
<tabstop>listWidget</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>

View file

@ -21,14 +21,30 @@
#include "vdetail.h"
VDetail::VDetail():nodes(QVector<VNodeDetail>()),name(QString()), mx(0), my(0){
VDetail::VDetail():nodes(QVector<VNodeDetail>()),name(QString()), mx(0), my(0), supplement(true), closed(true),
width(10){
}
VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes):nodes(QVector<VNodeDetail>()),
name(name), mx(0), my(0){
name(name), mx(0), my(0), supplement(true), closed(true), width(10){
this->nodes = nodes;
}
VDetail::VDetail(const VDetail &detail):nodes(detail.getNodes()), name(detail.getName()), mx(detail.getMx()),
my(detail.getMy()), supplement(detail.getSupplement()), closed(detail.getClosed()), width(detail.getWidth()){
}
VDetail &VDetail::operator =(const VDetail &detail){
nodes = detail.getNodes();
name = detail.getName();
mx = detail.getMx();
my = detail.getMy();
supplement = detail.getSupplement();
closed = detail.getClosed();
width = detail.getWidth();
return *this;
}
void VDetail::append(const VNodeDetail &node){
nodes.append(node);
}
@ -38,6 +54,9 @@ void VDetail::Clear(){
name.clear();
mx = 0;
my = 0;
supplement = true;
closed = true;
width = 10;
}
qint32 VDetail::CountNode() const{
@ -81,3 +100,35 @@ QString VDetail::getName() const{
void VDetail::setName(const QString &value){
name = value;
}
qreal VDetail::getWidth() const{
return width;
}
void VDetail::setWidth(const qreal &value){
width = value;
}
bool VDetail::getClosed() const{
return closed;
}
void VDetail::setClosed(bool value){
closed = value;
}
bool VDetail::getSupplement() const{
return supplement;
}
void VDetail::setSupplement(bool value){
supplement = value;
}
QVector<VNodeDetail> VDetail::getNodes() const{
return nodes;
}
void VDetail::setNodes(const QVector<VNodeDetail> &value){
nodes = value;
}

View file

@ -39,24 +39,37 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants)
class VDetail{
public:
VDetail();
VDetail(const QString &name, const QVector<VNodeDetail> &nodes);
void append(const VNodeDetail &node);
void Clear();
qint32 CountNode() const;
bool Containes(const qint64 &id)const;
VDetail();
VDetail(const QString &name, const QVector<VNodeDetail> &nodes);
VDetail(const VDetail &detail);
VDetail &operator=(const VDetail &detail);
void append(const VNodeDetail &node);
void Clear();
qint32 CountNode() const;
bool Containes(const qint64 &id)const;
VNodeDetail & operator[](int indx);
QString getName() const;
void setName(const QString &value);
qreal getMx() const;
void setMx(const qreal &value);
qreal getMy() const;
void setMy(const qreal &value);
void setName(const QString &value);
qreal getMx() const;
void setMx(const qreal &value);
qreal getMy() const;
void setMy(const qreal &value);
bool getSupplement() const;
void setSupplement(bool value);
bool getClosed() const;
void setClosed(bool value);
qreal getWidth() const;
void setWidth(const qreal &value);
QVector<VNodeDetail> getNodes() const;
void setNodes(const QVector<VNodeDetail> &value);
private:
QVector<VNodeDetail> nodes;
QString name;
qreal mx;
qreal my;
qreal mx;
qreal my;
bool supplement;
bool closed;
qreal width;
};
#endif // VDETAIL_H

View file

@ -21,16 +21,27 @@
#include "vnodedetail.h"
VNodeDetail::VNodeDetail():id(0), typeTool(Tool::NodePoint), mode(Draw::Calculation),
typeNode(NodeDetail::Contour){
VNodeDetail::VNodeDetail():id(0), typeTool(Tool::NodePoint), mode(Draw::Modeling),
typeNode(NodeDetail::Contour), mx(0), my(0){
}
VNodeDetail::VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode):id(id),
typeTool(typeTool), mode(mode), typeNode(typeNode){
VNodeDetail::VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
qreal mx, qreal my):id(id), typeTool(typeTool), mode(mode), typeNode(typeNode),
mx(mx), my(my){
}
VNodeDetail::VNodeDetail(const VNodeDetail &node):id(node.getId()), typeTool(node.getTypeTool()),
mode(node.getMode()), typeNode(node.getTypeNode()){
mode(node.getMode()), typeNode(node.getTypeNode()), mx(node.getMx()), my(node.getMy()){
}
VNodeDetail &VNodeDetail::operator =(const VNodeDetail &node){
id = node.getId();
typeTool = node.getTypeTool();
mode = node.getMode();
typeNode = node.getTypeNode();
mx = node.getMx();
my = node.getMy();
return *this;
}
Tool::Tools VNodeDetail::getTypeTool() const{
@ -64,3 +75,19 @@ NodeDetail::NodeDetails VNodeDetail::getTypeNode() const{
void VNodeDetail::setTypeNode(const NodeDetail::NodeDetails &value){
typeNode = value;
}
qreal VNodeDetail::getMy() const{
return my;
}
void VNodeDetail::setMy(const qreal &value){
my = value;
}
qreal VNodeDetail::getMx() const{
return mx;
}
void VNodeDetail::setMx(const qreal &value){
mx = value;
}

View file

@ -31,26 +31,32 @@ namespace NodeDetail {
}
Q_DECLARE_OPERATORS_FOR_FLAGS(NodeDetail::NodeDetails)
class VNodeDetail
{
class VNodeDetail{
public:
VNodeDetail();
VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode);
VNodeDetail(const VNodeDetail &node);
qint64 getId() const;
void setId(const qint64 &value);
VNodeDetail();
VNodeDetail(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode,
qreal mx = 0, qreal my = 0);
VNodeDetail(const VNodeDetail &node);
VNodeDetail &operator=(const VNodeDetail &node);
qint64 getId() const;
void setId(const qint64 &value);
Tool::Tools getTypeTool() const;
void setTypeTool(const Tool::Tools &value);
void setTypeTool(const Tool::Tools &value);
Draw::Draws getMode() const;
void setMode(const Draw::Draws &value);
void setMode(const Draw::Draws &value);
NodeDetail::NodeDetails getTypeNode() const;
void setTypeNode(const NodeDetail::NodeDetails &value);
void setTypeNode(const NodeDetail::NodeDetails &value);
qreal getMx() const;
void setMx(const qreal &value);
qreal getMy() const;
void setMy(const qreal &value);
private:
qint64 id;
qint64 id;
Tool::Tools typeTool;
Draw::Draws mode;
NodeDetail::NodeDetails typeNode;
qreal mx;
qreal my;
};
Q_DECLARE_METATYPE(VNodeDetail)

View file

@ -192,10 +192,8 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id,
void VToolDetail::setDialog(){
Q_ASSERT(!dialogDetail.isNull());
if(!dialogDetail.isNull()){
VDetail detail = VAbstractTool::data.GetDetail(id);
dialogDetail->setDetails(detail);
}
VDetail detail = VAbstractTool::data.GetDetail(id);
dialogDetail->setDetails(detail);
}
void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScene *scene,
@ -257,7 +255,7 @@ void VToolDetail::Create(QSharedPointer<DialogDetail> &dialog, VMainGraphicsScen
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
break;
}
VNodeDetail node(id, detail[i].getTypeTool(), detail[i].getMode(), NodeDetail::Contour);
VNodeDetail node(id, detail[i].getTypeTool(), Draw::Modeling, NodeDetail::Contour);
det.append(node);
}
det.setName(detail.getName());
@ -290,7 +288,26 @@ void VToolDetail::FullUpdateFromFile(){
}
void VToolDetail::FullUpdateFromGui(int result){
Q_UNUSED(result);
if(result == QDialog::Accepted){
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
VDetail det = dialogDetail->getDetails();
domElement.setAttribute("name", det.getName());
domElement.setAttribute("supplement", QString().setNum(det.getSupplement()));
domElement.setAttribute("closed", QString().setNum(det.getClosed()));
domElement.setAttribute("width", QString().setNum(det.getWidth()));
if ( domElement.hasChildNodes() ){
while ( domElement.childNodes().length() >= 1 ){
domElement.removeChild( domElement.firstChild() );
}
}
for(qint32 i = 0; i < det.CountNode(); ++i){
AddNode(domElement, det[i]);
}
emit FullUpdateTree();
}
}
dialogDetail.clear();
}
void VToolDetail::AddToFile(){
@ -299,8 +316,11 @@ void VToolDetail::AddToFile(){
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "name", detail.getName());
AddAttribute(domElement, "mx", detail.getMx());
AddAttribute(domElement, "my", detail.getMy());
AddAttribute(domElement, "mx", toMM(detail.getMx()));
AddAttribute(domElement, "my", toMM(detail.getMy()));
AddAttribute(domElement, "supplement", detail.getSupplement());
AddAttribute(domElement, "closed", detail.getClosed());
AddAttribute(domElement, "width", detail.getWidth());
for(qint32 i = 0; i < detail.CountNode(); ++i){
AddNode(domElement, detail[i]);
@ -338,7 +358,7 @@ void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
QMenu menu;
//QAction *actionOption = menu.addAction(tr("Options"));
QAction *actionOption = menu.addAction(tr("Options"));
QAction *actionRemove = menu.addAction(tr("Delete"));
if(_referens > 1){
actionRemove->setEnabled(false);
@ -346,21 +366,15 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
actionRemove->setEnabled(true);
}
QAction *selectedAction = menu.exec(event->screenPos());
// if(selectedAction == actionOption){
// dialog = QSharedPointer<Dialog>(new Dialog(getData()));
// connect(qobject_cast< VMainGraphicsScene * >(tool->scene()), &VMainGraphicsScene::ChoosedObject,
// dialog.data(), &Dialog::ChoosedObject);
// connect(dialog.data(), &Dialog::DialogClosed, tool,
// &Tool::FullUpdateFromGui);
// connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
// tool->setDialog();
// dialog->show();
// }
if(selectedAction == actionOption){
dialogDetail = QSharedPointer<DialogDetail>(new DialogDetail(getData(), Draw::Modeling));
connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
dialogDetail.data(), &DialogDetail::ChoosedObject);
connect(dialogDetail.data(), &DialogDetail::DialogClosed, this, &VToolDetail::FullUpdateFromGui);
setDialog();
dialogDetail->show();
}
if(selectedAction == actionRemove){
//remove form xml file
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
@ -393,6 +407,8 @@ void VToolDetail::AddNode(QDomElement &domElement, VNodeDetail &node){
QDomElement nod = doc->createElement("node");
AddAttribute(nod, "idObject", node.getId());
AddAttribute(nod, "mx", toMM(node.getMx()));
AddAttribute(nod, "my", toMM(node.getMy()));
if(node.getTypeNode() == NodeDetail::Contour){
AddAttribute(nod, "nodeType", "Contour");
} else {
@ -444,6 +460,15 @@ void VToolDetail::AddNode(QDomElement &domElement, VNodeDetail &node){
case(Tool::SplineTool):
AddAttribute(nod, "type", "SplineTool");
break;
case(Tool::Height):
AddAttribute(nod, "type", "Height");
break;
case(Tool::Triangle):
AddAttribute(nod, "type", "Triangle");
break;
case(Tool::PointOfIntersection):
AddAttribute(nod, "type", "PointOfIntersection");
break;
default:
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
break;

View file

@ -473,6 +473,9 @@ void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDo
detail.setName(GetParametrString(domElement, "name"));
detail.setMx(toPixel(GetParametrDouble(domElement, "mx")));
detail.setMy(toPixel(GetParametrDouble(domElement, "my")));
detail.setSupplement(GetParametrLongLong(domElement, "supplement"));
detail.setWidth(GetParametrDouble(domElement, "width"));
detail.setClosed(GetParametrLongLong(domElement, "closed"));
QDomNodeList nodeList = domElement.childNodes();
qint32 num = nodeList.size();
@ -481,6 +484,8 @@ void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDo
if(!element.isNull()){
if(element.tagName() == "node"){
qint64 id = GetParametrLongLong(element, "idObject");
qreal mx = toPixel(GetParametrDouble(element, "mx"));
qreal my = toPixel(GetParametrDouble(element, "my"));
Tool::Tools tool;
Draw::Draws mode;
NodeDetail::NodeDetails nodeType = NodeDetail::Contour;
@ -527,8 +532,14 @@ void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDo
tool = Tool::SplinePathTool;
} else if(t == "SplineTool"){
tool = Tool::SplineTool;
} else if(t == "Height"){
tool = Tool::Height;
} else if(t == "Triangle"){
tool = Tool::Triangle;
} else if(t == "PointOfIntersection"){
tool = Tool::PointOfIntersection;
}
detail.append(VNodeDetail(id, tool, mode, nodeType));
detail.append(VNodeDetail(id, tool, Draw::Modeling, nodeType, mx, my));
}
}
}