Apply button for dialog line.
--HG-- branch : develop
This commit is contained in:
parent
356209abfa
commit
ad01fe75bd
|
@ -34,6 +34,7 @@
|
||||||
#include "../../visualization/vgraphicslineitem.h"
|
#include "../../visualization/vgraphicslineitem.h"
|
||||||
#include "../../widgets/vapplication.h"
|
#include "../../widgets/vapplication.h"
|
||||||
#include "../../widgets/vmaingraphicsscene.h"
|
#include "../../widgets/vmaingraphicsscene.h"
|
||||||
|
#include "../../tools/vabstracttool.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +47,7 @@ DialogLine::DialogLine(const VContainer *data, QWidget *parent)
|
||||||
line(nullptr)
|
line(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitOkCancel(ui);
|
InitOkCancelApply(ui);
|
||||||
|
|
||||||
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||||
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||||
|
@ -58,6 +59,8 @@ DialogLine::DialogLine(const VContainer *data, QWidget *parent)
|
||||||
this, &DialogLine::PointNameChanged);
|
this, &DialogLine::PointNameChanged);
|
||||||
connect(ui->comboBoxSecondPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
connect(ui->comboBoxSecondPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||||
this, &DialogLine::PointNameChanged);
|
this, &DialogLine::PointNameChanged);
|
||||||
|
|
||||||
|
line = new VGraphicsLineItem(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -75,6 +78,7 @@ DialogLine::~DialogLine()
|
||||||
void DialogLine::setSecondPoint(const quint32 &value)
|
void DialogLine::setSecondPoint(const quint32 &value)
|
||||||
{
|
{
|
||||||
setPointId(ui->comboBoxSecondPoint, secondPoint, value, 0);
|
setPointId(ui->comboBoxSecondPoint, secondPoint, value, 0);
|
||||||
|
line->setPoint2Id(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -86,6 +90,7 @@ void DialogLine::setTypeLine(const QString &value)
|
||||||
{
|
{
|
||||||
typeLine = value;
|
typeLine = value;
|
||||||
SetupTypeLine(ui->comboBoxLineType, value);
|
SetupTypeLine(ui->comboBoxLineType, value);
|
||||||
|
line->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -96,6 +101,7 @@ void DialogLine::setTypeLine(const QString &value)
|
||||||
void DialogLine::setFirstPoint(const quint32 &value)
|
void DialogLine::setFirstPoint(const quint32 &value)
|
||||||
{
|
{
|
||||||
setPointId(ui->comboBoxFirstPoint, firstPoint, value, 0);
|
setPointId(ui->comboBoxFirstPoint, firstPoint, value, 0);
|
||||||
|
line->setPoint1Id(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -104,15 +110,19 @@ void DialogLine::setFirstPoint(const quint32 &value)
|
||||||
*/
|
*/
|
||||||
void DialogLine::DialogAccepted()
|
void DialogLine::DialogAccepted()
|
||||||
{
|
{
|
||||||
//TODO check if points different
|
this->SaveData();
|
||||||
qint32 index = ui->comboBoxFirstPoint->currentIndex();
|
|
||||||
firstPoint = qvariant_cast<quint32>(ui->comboBoxFirstPoint->itemData(index));
|
|
||||||
index = ui->comboBoxSecondPoint->currentIndex();
|
|
||||||
secondPoint = qvariant_cast<quint32>(ui->comboBoxSecondPoint->itemData(index));
|
|
||||||
typeLine = GetTypeLine(ui->comboBoxLineType);
|
|
||||||
DialogClosed(QDialog::Accepted);
|
DialogClosed(QDialog::Accepted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogLine::DialogApply()
|
||||||
|
{
|
||||||
|
this->SaveData();
|
||||||
|
line->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
|
line->RefreshGeometry();
|
||||||
|
emit DialogApplied();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogLine::PointNameChanged()
|
void DialogLine::PointNameChanged()
|
||||||
{
|
{
|
||||||
|
@ -136,7 +146,7 @@ void DialogLine::PointNameChanged()
|
||||||
void DialogLine::UpdateList()
|
void DialogLine::UpdateList()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Does nothing. We redefine this slot because it is only one now way block update list of variable.
|
* Does nothing. We redefine this slot because it is only one now way block update list of variables.
|
||||||
* This dialog doesn't work with formula. Don't delete. Help avoid crash.
|
* This dialog doesn't work with formula. Don't delete. Help avoid crash.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
@ -145,10 +155,19 @@ void DialogLine::UpdateList()
|
||||||
void DialogLine::ShowVisualization()
|
void DialogLine::ShowVisualization()
|
||||||
{
|
{
|
||||||
VMainGraphicsScene *scene = qApp->getCurrentScene();
|
VMainGraphicsScene *scene = qApp->getCurrentScene();
|
||||||
line = new VGraphicsLineItem(data, getCurrentObjectId(ui->comboBoxFirstPoint),
|
|
||||||
getCurrentObjectId(ui->comboBoxSecondPoint));
|
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, line, &VGraphicsLineItem::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, line, &VGraphicsLineItem::SetFactor);
|
||||||
scene->addItem(line);
|
scene->addItem(line);
|
||||||
|
line->RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogLine::SaveData()
|
||||||
|
{
|
||||||
|
qint32 index = ui->comboBoxFirstPoint->currentIndex();
|
||||||
|
firstPoint = qvariant_cast<quint32>(ui->comboBoxFirstPoint->itemData(index));
|
||||||
|
index = ui->comboBoxSecondPoint->currentIndex();
|
||||||
|
secondPoint = qvariant_cast<quint32>(ui->comboBoxSecondPoint->itemData(index));
|
||||||
|
typeLine = GetTypeLine(ui->comboBoxLineType);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -59,10 +59,10 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type);
|
virtual void ChosenObject(quint32 id, const SceneObject &type);
|
||||||
virtual void DialogAccepted();
|
virtual void DialogAccepted();
|
||||||
/** TODO ISSUE 79 : create real function
|
/**
|
||||||
* @brief DialogApply apply data and emit signal about applied dialog.
|
* @brief DialogApply apply data and emit signal about applied dialog.
|
||||||
*/
|
*/
|
||||||
virtual void DialogApply(){}
|
virtual void DialogApply();
|
||||||
virtual void PointNameChanged();
|
virtual void PointNameChanged();
|
||||||
virtual void UpdateList();
|
virtual void UpdateList();
|
||||||
protected:
|
protected:
|
||||||
|
@ -85,6 +85,10 @@ private:
|
||||||
/** @brief typeLine type of line */
|
/** @brief typeLine type of line */
|
||||||
QString typeLine;
|
QString typeLine;
|
||||||
VGraphicsLineItem *line;
|
VGraphicsLineItem *line;
|
||||||
|
/**
|
||||||
|
* @brief SaveData Put dialog data in local variables
|
||||||
|
*/
|
||||||
|
void SaveData();
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -9,20 +9,20 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>267</width>
|
<width>286</width>
|
||||||
<height>154</height>
|
<height>151</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>267</width>
|
<width>286</width>
|
||||||
<height>154</height>
|
<height>151</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>267</width>
|
<width>286</width>
|
||||||
<height>154</height>
|
<height>151</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>9</x>
|
<x>9</x>
|
||||||
<y>9</y>
|
<y>9</y>
|
||||||
<width>255</width>
|
<width>269</width>
|
||||||
<height>134</height>
|
<height>134</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -394,7 +394,7 @@ void MainWindow::ApplyDialog()
|
||||||
void MainWindow::ToolEndLine(bool checked)
|
void MainWindow::ToolEndLine(bool checked)
|
||||||
{
|
{
|
||||||
SetToolButtonWithApply<DialogEndLine>(checked, Tool::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"),
|
SetToolButtonWithApply<DialogEndLine>(checked, Tool::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"),
|
||||||
&MainWindow::ClosedDialogEndLine, &MainWindow::ApplyDialogEndLine);
|
&MainWindow::ClosedDialogEndLine, &MainWindow::ApplyDialogEndLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -423,8 +423,8 @@ void MainWindow::ClosedDialogEndLine(int result)
|
||||||
*/
|
*/
|
||||||
void MainWindow::ToolLine(bool checked)
|
void MainWindow::ToolLine(bool checked)
|
||||||
{
|
{
|
||||||
SetToolButton<DialogLine>(checked, Tool::LineTool, ":/cursor/line_cursor.png", tr("Select first point"),
|
SetToolButtonWithApply<DialogLine>(checked, Tool::LineTool, ":/cursor/line_cursor.png", tr("Select first point"),
|
||||||
&MainWindow::ClosedDialogLine);
|
&MainWindow::ClosedDialogLine, &MainWindow::ApplyDialogLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -434,7 +434,14 @@ void MainWindow::ToolLine(bool checked)
|
||||||
*/
|
*/
|
||||||
void MainWindow::ClosedDialogLine(int result)
|
void MainWindow::ClosedDialogLine(int result)
|
||||||
{
|
{
|
||||||
ClosedDialog<VToolLine>(result);
|
ClosedDialogWithApply<VToolLine>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void MainWindow::ApplyDialogLine()
|
||||||
|
{
|
||||||
|
ApplyDialog<VToolLine>();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -445,7 +452,8 @@ void MainWindow::ClosedDialogLine(int result)
|
||||||
void MainWindow::ToolAlongLine(bool checked)
|
void MainWindow::ToolAlongLine(bool checked)
|
||||||
{
|
{
|
||||||
SetToolButtonWithApply<DialogAlongLine>(checked, Tool::AlongLineTool, ":/cursor/alongline_cursor.png",
|
SetToolButtonWithApply<DialogAlongLine>(checked, Tool::AlongLineTool, ":/cursor/alongline_cursor.png",
|
||||||
tr("Select point"), &MainWindow::ClosedDialogAlongLine, &MainWindow::ApplyDialogAlongLine);
|
tr("Select point"), &MainWindow::ClosedDialogAlongLine,
|
||||||
|
&MainWindow::ApplyDialogAlongLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -108,6 +108,7 @@ public slots:
|
||||||
void ClosedDialogEndLine(int result);
|
void ClosedDialogEndLine(int result);
|
||||||
void ApplyDialogEndLine();
|
void ApplyDialogEndLine();
|
||||||
void ClosedDialogLine(int result);
|
void ClosedDialogLine(int result);
|
||||||
|
void ApplyDialogLine();
|
||||||
void ClosedDialogAlongLine(int result);
|
void ClosedDialogAlongLine(int result);
|
||||||
void ApplyDialogAlongLine();
|
void ApplyDialogAlongLine();
|
||||||
void ClosedDialogShoulderPoint(int result);
|
void ClosedDialogShoulderPoint(int result);
|
||||||
|
|
|
@ -60,7 +60,7 @@ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstP
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle()));
|
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ void VToolLine::setDialog()
|
||||||
* @param doc dom document container.
|
* @param doc dom document container.
|
||||||
* @param data container with variables.
|
* @param data container with variables.
|
||||||
*/
|
*/
|
||||||
void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
|
VToolLine *VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
|
||||||
{
|
{
|
||||||
SCASSERT(dialog != nullptr);
|
SCASSERT(dialog != nullptr);
|
||||||
DialogLine *dialogTool = qobject_cast<DialogLine*>(dialog);
|
DialogLine *dialogTool = qobject_cast<DialogLine*>(dialog);
|
||||||
|
@ -102,7 +102,14 @@ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *
|
||||||
const quint32 firstPoint = dialogTool->getFirstPoint();
|
const quint32 firstPoint = dialogTool->getFirstPoint();
|
||||||
const quint32 secondPoint = dialogTool->getSecondPoint();
|
const quint32 secondPoint = dialogTool->getSecondPoint();
|
||||||
const QString typeLine = dialogTool->getTypeLine();
|
const QString typeLine = dialogTool->getTypeLine();
|
||||||
Create(0, firstPoint, secondPoint, typeLine, scene, doc, data, Document::FullParse, Source::FromGui);
|
|
||||||
|
VToolLine *line = nullptr;
|
||||||
|
line = Create(0, firstPoint, secondPoint, typeLine, scene, doc, data, Document::FullParse, Source::FromGui);
|
||||||
|
if (line != nullptr)
|
||||||
|
{
|
||||||
|
line->dialog=dialogTool;
|
||||||
|
}
|
||||||
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -118,7 +125,7 @@ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *
|
||||||
* @param parse parser file mode.
|
* @param parse parser file mode.
|
||||||
* @param typeCreation way we create this tool.
|
* @param typeCreation way we create this tool.
|
||||||
*/
|
*/
|
||||||
void VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
|
VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
|
||||||
const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
|
const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
|
||||||
const Document &parse, const Source &typeCreation)
|
const Document &parse, const Source &typeCreation)
|
||||||
{
|
{
|
||||||
|
@ -151,7 +158,9 @@ void VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quin
|
||||||
doc->AddTool(id, line);
|
doc->AddTool(id, line);
|
||||||
doc->IncrementReferens(firstPoint);
|
doc->IncrementReferens(firstPoint);
|
||||||
doc->IncrementReferens(secondPoint);
|
doc->IncrementReferens(secondPoint);
|
||||||
|
return line;
|
||||||
}
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -210,7 +219,7 @@ void VToolLine::ChangedActivDraw(const QString &newName)
|
||||||
selectable = false;
|
selectable = false;
|
||||||
currentColor = Qt::gray;
|
currentColor = Qt::gray;
|
||||||
}
|
}
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle()));
|
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
|
||||||
this->setAcceptHoverEvents (selectable);
|
this->setAcceptHoverEvents (selectable);
|
||||||
VDrawTool::ChangedActivDraw(newName);
|
VDrawTool::ChangedActivDraw(newName);
|
||||||
}
|
}
|
||||||
|
@ -263,7 +272,7 @@ void VToolLine::RefreshDataInFile()
|
||||||
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, LineStyle()));
|
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, LineStyle(typeLine)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -274,7 +283,7 @@ void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle()));
|
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -360,5 +369,5 @@ void VToolLine::RefreshGeometry()
|
||||||
const VPointF *first = VAbstractTool::data.GeometricObject<const VPointF *>(firstPoint);
|
const VPointF *first = VAbstractTool::data.GeometricObject<const VPointF *>(firstPoint);
|
||||||
const VPointF *second = VAbstractTool::data.GeometricObject<const VPointF *>(secondPoint);
|
const VPointF *second = VAbstractTool::data.GeometricObject<const VPointF *>(secondPoint);
|
||||||
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
|
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle()));
|
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,9 @@ class VToolLine: public VDrawTool, public QGraphicsLineItem
|
||||||
public:
|
public:
|
||||||
VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint,
|
VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint,
|
||||||
const QString &typeLine, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
const QString &typeLine, const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
|
static VToolLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
|
||||||
static void Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
|
static VToolLine *Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
|
||||||
const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
|
const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
|
||||||
const Document &parse, const Source &typeCreation);
|
const Document &parse, const Source &typeCreation);
|
||||||
static const QString TagName;
|
static const QString TagName;
|
||||||
|
|
|
@ -52,7 +52,7 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i
|
||||||
QPointF point1 = data->GeometricObject<const VPointF *>(basePointId)->toQPointF();
|
QPointF point1 = data->GeometricObject<const VPointF *>(basePointId)->toQPointF();
|
||||||
QPointF point2 = data->GeometricObject<const VPointF *>(id)->toQPointF();
|
QPointF point2 = data->GeometricObject<const VPointF *>(id)->toQPointF();
|
||||||
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this);
|
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this);
|
||||||
mainLine->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle()));
|
mainLine->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
|
||||||
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
||||||
{
|
{
|
||||||
currentColor = Qt::gray;
|
currentColor = Qt::gray;
|
||||||
}
|
}
|
||||||
mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle()));
|
mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
|
||||||
VToolPoint::ChangedActivDraw(newName);
|
VToolPoint::ChangedActivDraw(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
||||||
*/
|
*/
|
||||||
void VToolLinePoint::RefreshGeometry()
|
void VToolLinePoint::RefreshGeometry()
|
||||||
{
|
{
|
||||||
mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle()));
|
mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle(typeLine)));
|
||||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
||||||
QPointF point = VDrawTool::data.GeometricObject<const VPointF *>(id)->toQPointF();
|
QPointF point = VDrawTool::data.GeometricObject<const VPointF *>(id)->toQPointF();
|
||||||
QPointF basePoint = VDrawTool::data.GeometricObject<const VPointF *>(basePointId)->toQPointF();
|
QPointF basePoint = VDrawTool::data.GeometricObject<const VPointF *>(basePointId)->toQPointF();
|
||||||
|
|
|
@ -261,7 +261,7 @@ void VAbstractTool::DeleteTool(bool ask)
|
||||||
* @brief LineStyle return pen style for current line style.
|
* @brief LineStyle return pen style for current line style.
|
||||||
* @return pen style.
|
* @return pen style.
|
||||||
*/
|
*/
|
||||||
Qt::PenStyle VAbstractTool::LineStyle()
|
Qt::PenStyle VAbstractTool::LineStyle(const QString &typeLine)
|
||||||
{
|
{
|
||||||
QStringList styles = Styles();
|
QStringList styles = Styles();
|
||||||
switch (styles.indexOf(typeLine))
|
switch (styles.indexOf(typeLine))
|
||||||
|
|
|
@ -98,6 +98,7 @@ public:
|
||||||
static const QString TypeLineDashDotDotLine;
|
static const QString TypeLineDashDotDotLine;
|
||||||
static const QStringList Styles();
|
static const QStringList Styles();
|
||||||
static void AddRecord(const quint32 id, const Tool &toolType, VPattern *doc);
|
static void AddRecord(const quint32 id, const Tool &toolType, VPattern *doc);
|
||||||
|
static Qt::PenStyle LineStyle(const QString &typeLine);
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* @brief FullUpdateFromFile update tool data form file.
|
* @brief FullUpdateFromFile update tool data form file.
|
||||||
|
@ -147,7 +148,6 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void RemoveReferens(){}
|
virtual void RemoveReferens(){}
|
||||||
virtual void DeleteTool(bool ask = true);
|
virtual void DeleteTool(bool ask = true);
|
||||||
Qt::PenStyle LineStyle();
|
|
||||||
static int ConfirmDeletion();
|
static int ConfirmDeletion();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VAbstractTool)
|
Q_DISABLE_COPY(VAbstractTool)
|
||||||
|
|
|
@ -33,15 +33,12 @@
|
||||||
VUndoCommand::VUndoCommand(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
VUndoCommand::VUndoCommand(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
|
||||||
:QObject(), QUndoCommand(parent), xml(xml), doc(doc), nodeId(0), redoFlag(false)
|
:QObject(), QUndoCommand(parent), xml(xml), doc(doc), nodeId(0), redoFlag(false)
|
||||||
{
|
{
|
||||||
SCASSERT(xml.isNull() == false);
|
|
||||||
SCASSERT(doc != nullptr);
|
SCASSERT(doc != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VUndoCommand::~VUndoCommand()
|
VUndoCommand::~VUndoCommand()
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VUndoCommand::RedoFullParsing()
|
void VUndoCommand::RedoFullParsing()
|
||||||
|
|
|
@ -32,20 +32,17 @@
|
||||||
#include "../widgets/vapplication.h"
|
#include "../widgets/vapplication.h"
|
||||||
#include "../tools/drawTools/vdrawtool.h"
|
#include "../tools/drawTools/vdrawtool.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VGraphicsLineItem::VGraphicsLineItem(const VContainer *data, QGraphicsItem *parent)
|
||||||
|
:QObject(), QGraphicsLineItem(parent), data(data), point1Id(0), point2Id(0), factor(VDrawTool::factor),
|
||||||
|
scenePos(QPointF()), color(Qt::red), lineStyle(Qt::SolidLine)
|
||||||
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VGraphicsLineItem::VGraphicsLineItem(const VContainer *data, const quint32 &pointId, const QPointF &scenePos,
|
VGraphicsLineItem::VGraphicsLineItem(const VContainer *data, const quint32 &pointId, const QPointF &scenePos,
|
||||||
QGraphicsItem *parent)
|
QGraphicsItem *parent)
|
||||||
:QObject(), QGraphicsLineItem(parent), data(data), point1Id(pointId), point2Id(0), factor(VDrawTool::factor),
|
:QObject(), QGraphicsLineItem(parent), data(data), point1Id(pointId), point2Id(0), factor(VDrawTool::factor),
|
||||||
scenePos(scenePos), color(Qt::black)
|
scenePos(scenePos), color(Qt::black), lineStyle(Qt::SolidLine)
|
||||||
{
|
|
||||||
RefreshGeometry();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
VGraphicsLineItem::VGraphicsLineItem(const VContainer *data, const quint32 &p1Id, const quint32 &p2Id,
|
|
||||||
QGraphicsItem *parent)
|
|
||||||
:QObject(), QGraphicsLineItem(parent), data(data), point1Id(p1Id), point2Id(p2Id), factor(VDrawTool::factor),
|
|
||||||
scenePos(QPointF()), color(Qt::red)
|
|
||||||
{
|
{
|
||||||
RefreshGeometry();
|
RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
@ -74,6 +71,24 @@ void VGraphicsLineItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
QGraphicsLineItem::mouseMoveEvent(event);
|
QGraphicsLineItem::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VGraphicsLineItem::setPoint2Id(const quint32 &value)
|
||||||
|
{
|
||||||
|
point2Id = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VGraphicsLineItem::setPoint1Id(const quint32 &value)
|
||||||
|
{
|
||||||
|
point1Id = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VGraphicsLineItem::setLineStyle(const Qt::PenStyle &value)
|
||||||
|
{
|
||||||
|
lineStyle = value;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VGraphicsLineItem::RefreshGeometry()
|
void VGraphicsLineItem::RefreshGeometry()
|
||||||
{
|
{
|
||||||
|
@ -87,5 +102,5 @@ void VGraphicsLineItem::RefreshGeometry()
|
||||||
const VPointF *second = data->GeometricObject<const VPointF *>(point2Id);
|
const VPointF *second = data->GeometricObject<const VPointF *>(point2Id);
|
||||||
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
|
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
|
||||||
}
|
}
|
||||||
this->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor, Qt::SolidLine));
|
this->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor, lineStyle));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,24 +36,29 @@ class VGraphicsLineItem : public QObject, public QGraphicsLineItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
VGraphicsLineItem(const VContainer *data, QGraphicsItem * parent = 0);
|
||||||
VGraphicsLineItem(const VContainer *data, const quint32 &pointId, const QPointF &scenePos,
|
VGraphicsLineItem(const VContainer *data, const quint32 &pointId, const QPointF &scenePos,
|
||||||
QGraphicsItem * parent = 0);
|
QGraphicsItem * parent = 0);
|
||||||
VGraphicsLineItem(const VContainer *data, const quint32 &p1Id, const quint32 &p2Id, QGraphicsItem * parent = 0);
|
|
||||||
virtual ~VGraphicsLineItem();
|
virtual ~VGraphicsLineItem();
|
||||||
|
|
||||||
|
void setLineStyle(const Qt::PenStyle &value);
|
||||||
|
void setPoint1Id(const quint32 &value);
|
||||||
|
void setPoint2Id(const quint32 &value);
|
||||||
|
void RefreshGeometry();
|
||||||
public slots:
|
public slots:
|
||||||
void SetFactor(qreal factor);
|
void SetFactor(qreal factor);
|
||||||
void MousePos(const QPointF &scenePos);
|
void MousePos(const QPointF &scenePos);
|
||||||
protected:
|
protected:
|
||||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VGraphicsLineItem)
|
Q_DISABLE_COPY(VGraphicsLineItem)
|
||||||
const VContainer *data;
|
const VContainer *data;
|
||||||
const quint32 point1Id;
|
quint32 point1Id;
|
||||||
const quint32 point2Id;
|
quint32 point2Id;
|
||||||
qreal factor;
|
qreal factor;
|
||||||
QPointF scenePos;
|
QPointF scenePos;
|
||||||
const QColor color;
|
const QColor color;
|
||||||
void RefreshGeometry();
|
Qt::PenStyle lineStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VGRAPHICSLINEITEM_H
|
#endif // VGRAPHICSLINEITEM_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user