parent
d211a9deb7
commit
4f17c22de7
|
@ -56,7 +56,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, QWidget *parent)
|
||||||
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||||
connect(bCansel, &QPushButton::clicked, this, &DialogAlongLine::DialogRejected);
|
connect(bCansel, &QPushButton::clicked, this, &DialogAlongLine::DialogRejected);
|
||||||
FillComboBoxTypeLine(ui->comboBoxLineType);
|
FillComboBoxTypeLine(ui->comboBoxLineType);
|
||||||
ui->comboBoxLineType->setCurrentIndex(1);
|
ui->comboBoxLineType->setCurrentIndex(0);
|
||||||
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||||
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include "../container/calculator.h"
|
#include "../container/calculator.h"
|
||||||
#include "../geometry/vgobject.h"
|
#include "../geometry/vgobject.h"
|
||||||
|
#include "../tools/vabstracttool.h"
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
|
@ -36,11 +37,15 @@ DialogTool::DialogTool(const VContainer *data, QWidget *parent)
|
||||||
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0),
|
:QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(0), bOk(0),
|
||||||
spinBoxAngle(0), lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0),
|
spinBoxAngle(0), lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(0),
|
||||||
labelEditNamePoint(0), labelEditFormula(0), radioButtonSizeGrowth(0), radioButtonStandardTable(0),
|
labelEditNamePoint(0), labelEditFormula(0), radioButtonSizeGrowth(0), radioButtonStandardTable(0),
|
||||||
radioButtonIncrements(0), radioButtonLengthLine(0), radioButtonLengthArc(0), radioButtonLengthCurve(0)
|
radioButtonIncrements(0), radioButtonLengthLine(0), radioButtonLengthArc(0), radioButtonLengthCurve(0),
|
||||||
|
lineStyles(QStringList())
|
||||||
{
|
{
|
||||||
Q_ASSERT(data != 0);
|
Q_ASSERT(data != 0);
|
||||||
timerFormula = new QTimer(this);
|
timerFormula = new QTimer(this);
|
||||||
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
|
connect(timerFormula, &QTimer::timeout, this, &DialogTool::EvalFormula);
|
||||||
|
//Keep synchronize with VAbstractTool styles list!!!
|
||||||
|
lineStyles<<tr("No line")<<tr("Line")<<tr("Dash Line")<<tr("Dot Line")<<tr("Dash Dot Line")
|
||||||
|
<<tr("Dash Dot Dot Line");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogTool::closeEvent(QCloseEvent *event)
|
void DialogTool::closeEvent(QCloseEvent *event)
|
||||||
|
@ -199,41 +204,46 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const qint64 &id, Combo
|
||||||
void DialogTool::FillComboBoxTypeLine(QComboBox *box) const
|
void DialogTool::FillComboBoxTypeLine(QComboBox *box) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(box != 0);
|
Q_ASSERT(box != 0);
|
||||||
QStringList list;
|
box->addItems(lineStyles);
|
||||||
list<<tr("Line")<<tr("No line");
|
box->setCurrentIndex(1);
|
||||||
box->addItems(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DialogTool::GetTypeLine(const QComboBox *box) const
|
QString DialogTool::GetTypeLine(const QComboBox *box) const
|
||||||
{
|
{
|
||||||
if (box->currentText()==tr("Line"))
|
switch(lineStyles.indexOf(box->currentText()))
|
||||||
{
|
{
|
||||||
return QString("hair");
|
case 0:
|
||||||
}
|
return VAbstractTool::TypeLineNone;
|
||||||
else
|
break;
|
||||||
{
|
case 1:
|
||||||
return QString("none");
|
return VAbstractTool::TypeLineLine;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return VAbstractTool::TypeLineDashLine;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
return VAbstractTool::TypeLineDotLine;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
return VAbstractTool::TypeLineDashDotLine;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
return VAbstractTool::TypeLineDashDotDotLine;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return VAbstractTool::TypeLineLine;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogTool::SetupTypeLine(QComboBox *box, const QString &value)
|
void DialogTool::SetupTypeLine(QComboBox *box, const QString &value)
|
||||||
{
|
{
|
||||||
if (value == "hair")
|
QStringList styles = VAbstractTool::Styles();
|
||||||
{
|
qint32 index = box->findText(lineStyles.at(styles.indexOf(value)));
|
||||||
qint32 index = box->findText(tr("Line"));
|
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
box->setCurrentIndex(index);
|
box->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (value == "none")
|
|
||||||
{
|
|
||||||
qint32 index = box->findText(tr("No line"));
|
|
||||||
if (index != -1)
|
|
||||||
{
|
|
||||||
box->setCurrentIndex(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value)
|
void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value)
|
||||||
|
|
|
@ -255,6 +255,10 @@ protected:
|
||||||
* @brief radioButtonLengthCurve radio button for lengths of curves variables
|
* @brief radioButtonLengthCurve radio button for lengths of curves variables
|
||||||
*/
|
*/
|
||||||
QRadioButton *radioButtonLengthCurve;
|
QRadioButton *radioButtonLengthCurve;
|
||||||
|
/**
|
||||||
|
* @brief lineStyles list supported line styles.
|
||||||
|
*/
|
||||||
|
QStringList lineStyles;
|
||||||
/**
|
/**
|
||||||
* @brief closeEvent handle when dialog cloded
|
* @brief closeEvent handle when dialog cloded
|
||||||
* @param event event
|
* @param event event
|
||||||
|
|
|
@ -31,23 +31,16 @@
|
||||||
VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
const QString &typeLine, const QString &formula, const qint64 &basePointId,
|
const QString &typeLine, const QString &formula, const qint64 &basePointId,
|
||||||
const qreal &angle, QGraphicsItem *parent)
|
const qreal &angle, QGraphicsItem *parent)
|
||||||
:VToolPoint(doc, data, id, parent), typeLine(typeLine), formula(formula), angle(angle), basePointId(basePointId),
|
:VToolPoint(doc, data, id, parent), formula(formula), angle(angle), basePointId(basePointId),
|
||||||
mainLine(0)
|
mainLine(0)
|
||||||
{
|
{
|
||||||
|
this->typeLine = typeLine;
|
||||||
Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0");
|
Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0");
|
||||||
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, widthHairLine/factor));
|
mainLine->setPen(QPen(Qt::black, widthHairLine/factor, LineStyle()));
|
||||||
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
if (typeLine == TypeLineNone)
|
|
||||||
{
|
|
||||||
mainLine->setVisible(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mainLine->setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
||||||
|
@ -60,25 +53,17 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
||||||
{
|
{
|
||||||
currentColor = Qt::gray;
|
currentColor = Qt::gray;
|
||||||
}
|
}
|
||||||
mainLine->setPen(QPen(currentColor, widthHairLine/factor));
|
mainLine->setPen(QPen(currentColor, widthHairLine/factor, LineStyle()));
|
||||||
VToolPoint::ChangedActivDraw(newName);
|
VToolPoint::ChangedActivDraw(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolLinePoint::RefreshGeometry()
|
void VToolLinePoint::RefreshGeometry()
|
||||||
{
|
{
|
||||||
mainLine->setPen(QPen(currentColor, widthHairLine/factor));
|
mainLine->setPen(QPen(currentColor, widthHairLine/factor, LineStyle()));
|
||||||
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();
|
||||||
mainLine->setLine(QLineF(basePoint - point, QPointF()));
|
mainLine->setLine(QLineF(basePoint - point, QPointF()));
|
||||||
if (typeLine == TypeLineNone)
|
|
||||||
{
|
|
||||||
mainLine->setVisible(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mainLine->setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolLinePoint::SetFactor(qreal factor)
|
void VToolLinePoint::SetFactor(qreal factor)
|
||||||
|
|
|
@ -64,10 +64,6 @@ public slots:
|
||||||
*/
|
*/
|
||||||
virtual void SetFactor(qreal factor);
|
virtual void SetFactor(qreal factor);
|
||||||
protected:
|
protected:
|
||||||
/**
|
|
||||||
* @brief typeLine type line.
|
|
||||||
*/
|
|
||||||
QString typeLine;
|
|
||||||
/**
|
/**
|
||||||
* @brief formula string with length formula.
|
* @brief formula string with length formula.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -64,9 +64,13 @@ const QString VAbstractTool::AttrAxisP1 = QStringLiteral("axisP1");
|
||||||
const QString VAbstractTool::AttrAxisP2 = QStringLiteral("axisP2");
|
const QString VAbstractTool::AttrAxisP2 = QStringLiteral("axisP2");
|
||||||
const QString VAbstractTool::TypeLineNone = QStringLiteral("none");
|
const QString VAbstractTool::TypeLineNone = QStringLiteral("none");
|
||||||
const QString VAbstractTool::TypeLineLine = QStringLiteral("hair");
|
const QString VAbstractTool::TypeLineLine = QStringLiteral("hair");
|
||||||
|
const QString VAbstractTool::TypeLineDashLine = QStringLiteral("dashLine");
|
||||||
|
const QString VAbstractTool::TypeLineDotLine = QStringLiteral("dotLine");
|
||||||
|
const QString VAbstractTool::TypeLineDashDotLine = QStringLiteral("dashDotLine");
|
||||||
|
const QString VAbstractTool::TypeLineDashDotDotLine = QStringLiteral("dashDotDotLine");
|
||||||
|
|
||||||
VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent)
|
VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent)
|
||||||
:VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black)
|
:VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black), typeLine(TypeLineLine)
|
||||||
{
|
{
|
||||||
Q_ASSERT(doc != 0);
|
Q_ASSERT(doc != 0);
|
||||||
connect(this, &VAbstractTool::toolhaveChange, this->doc, &VDomDocument::haveLiteChange);
|
connect(this, &VAbstractTool::toolhaveChange, this->doc, &VDomDocument::haveLiteChange);
|
||||||
|
@ -201,7 +205,6 @@ void VAbstractTool::RemoveAllChild(QDomElement &domElement)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO see method deleteNode. I think no need have QGraphicsItem. QObject can delete yourself.
|
|
||||||
void VAbstractTool::DeleteTool(QGraphicsItem *tool)
|
void VAbstractTool::DeleteTool(QGraphicsItem *tool)
|
||||||
{
|
{
|
||||||
if (_referens <= 1)
|
if (_referens <= 1)
|
||||||
|
@ -242,6 +245,35 @@ void VAbstractTool::DeleteTool(QGraphicsItem *tool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::PenStyle VAbstractTool::LineStyle()
|
||||||
|
{
|
||||||
|
QStringList styles = Styles();
|
||||||
|
switch(styles.indexOf(typeLine))
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return Qt::NoPen;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
return Qt::SolidLine;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return Qt::DashLine;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
return Qt::DotLine;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
return Qt::DashDotLine;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
return Qt::DashDotDotLine;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return Qt::SolidLine;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c)
|
void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c)
|
||||||
{
|
{
|
||||||
//coefficient for equation of segment
|
//coefficient for equation of segment
|
||||||
|
@ -251,6 +283,15 @@ void VAbstractTool::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qre
|
||||||
*c = - *a * p1.x() - *b * p1.y();
|
*c = - *a * p1.x() - *b * p1.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QStringList VAbstractTool::Styles()
|
||||||
|
{
|
||||||
|
//Keep synchronize with DialogTool lineStyles list!!!
|
||||||
|
QStringList styles;
|
||||||
|
styles << TypeLineNone << TypeLineLine << TypeLineDashLine << TypeLineDotLine << TypeLineDashDotLine
|
||||||
|
<< TypeLineDashDotDotLine;
|
||||||
|
return styles;
|
||||||
|
}
|
||||||
|
|
||||||
void VAbstractTool::AddRecord(const qint64 id, const Tool::Tools &toolType, VDomDocument *doc)
|
void VAbstractTool::AddRecord(const qint64 id, const Tool::Tools &toolType, VDomDocument *doc)
|
||||||
{
|
{
|
||||||
qint64 cursor = doc->getCursor();
|
qint64 cursor = doc->getCursor();
|
||||||
|
|
|
@ -137,6 +137,15 @@ public:
|
||||||
static const QString AttrAxisP2;
|
static const QString AttrAxisP2;
|
||||||
static const QString TypeLineNone;
|
static const QString TypeLineNone;
|
||||||
static const QString TypeLineLine;
|
static const QString TypeLineLine;
|
||||||
|
static const QString TypeLineDashLine;
|
||||||
|
static const QString TypeLineDotLine;
|
||||||
|
static const QString TypeLineDashDotLine;
|
||||||
|
static const QString TypeLineDashDotDotLine;
|
||||||
|
/**
|
||||||
|
* @brief Styles return list of all line styles.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static const QStringList Styles();
|
||||||
/**
|
/**
|
||||||
* @brief AddRecord add record about tool in history.
|
* @brief AddRecord add record about tool in history.
|
||||||
* @param id object id in container
|
* @param id object id in container
|
||||||
|
@ -181,6 +190,10 @@ protected:
|
||||||
* @brief currentColor current tool color.
|
* @brief currentColor current tool color.
|
||||||
*/
|
*/
|
||||||
Qt::GlobalColor currentColor;
|
Qt::GlobalColor currentColor;
|
||||||
|
/**
|
||||||
|
* @brief typeLine line type.
|
||||||
|
*/
|
||||||
|
QString typeLine;
|
||||||
/**
|
/**
|
||||||
* @brief AddToFile add tag with informations about tool into file.
|
* @brief AddToFile add tag with informations about tool into file.
|
||||||
*/
|
*/
|
||||||
|
@ -208,6 +221,11 @@ protected:
|
||||||
* @param tool tool
|
* @param tool tool
|
||||||
*/
|
*/
|
||||||
virtual void DeleteTool(QGraphicsItem *tool);
|
virtual void DeleteTool(QGraphicsItem *tool);
|
||||||
|
/**
|
||||||
|
* @brief LineStyle return pen style for current line style.
|
||||||
|
* @return pen style.
|
||||||
|
*/
|
||||||
|
Qt::PenStyle LineStyle();
|
||||||
template <typename T>
|
template <typename T>
|
||||||
/**
|
/**
|
||||||
* @brief SetAttribute set attribute in pattern file. Replace "," by ".".
|
* @brief SetAttribute set attribute in pattern file. Replace "," by ".".
|
||||||
|
|
|
@ -79,8 +79,8 @@ void VMainGraphicsView::scalingTime(qreal x)
|
||||||
|
|
||||||
const QPointF p1mouse = mapFromScene(p0scene);
|
const QPointF p1mouse = mapFromScene(p0scene);
|
||||||
const QPointF move = p1mouse - this->mapFromGlobal(QCursor::pos()); // The move
|
const QPointF move = p1mouse - this->mapFromGlobal(QCursor::pos()); // The move
|
||||||
horizontalScrollBar()->setValue(move.x() + horizontalScrollBar()->value());
|
horizontalScrollBar()->setValue(static_cast<qint32>(move.x()) + horizontalScrollBar()->value());
|
||||||
verticalScrollBar()->setValue(move.y() + verticalScrollBar()->value());
|
verticalScrollBar()->setValue(static_cast<qint32>(move.y()) + verticalScrollBar()->value());
|
||||||
|
|
||||||
VAbstractTool::NewSceneRect(this->scene(), this);
|
VAbstractTool::NewSceneRect(this->scene(), this);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user