parent
d211a9deb7
commit
4f17c22de7
|
@ -56,7 +56,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, QWidget *parent)
|
|||
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||
connect(bCansel, &QPushButton::clicked, this, &DialogAlongLine::DialogRejected);
|
||||
FillComboBoxTypeLine(ui->comboBoxLineType);
|
||||
ui->comboBoxLineType->setCurrentIndex(1);
|
||||
ui->comboBoxLineType->setCurrentIndex(0);
|
||||
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "dialogtool.h"
|
||||
#include "../container/calculator.h"
|
||||
#include "../geometry/vgobject.h"
|
||||
#include "../tools/vabstracttool.h"
|
||||
|
||||
#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),
|
||||
spinBoxAngle(0), lineEditFormula(0), listWidget(0), labelResultCalculation(0), labelDescription(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);
|
||||
timerFormula = new QTimer(this);
|
||||
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)
|
||||
|
@ -199,41 +204,46 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const qint64 &id, Combo
|
|||
void DialogTool::FillComboBoxTypeLine(QComboBox *box) const
|
||||
{
|
||||
Q_ASSERT(box != 0);
|
||||
QStringList list;
|
||||
list<<tr("Line")<<tr("No line");
|
||||
box->addItems(list);
|
||||
box->addItems(lineStyles);
|
||||
box->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
QString DialogTool::GetTypeLine(const QComboBox *box) const
|
||||
{
|
||||
if (box->currentText()==tr("Line"))
|
||||
switch(lineStyles.indexOf(box->currentText()))
|
||||
{
|
||||
return QString("hair");
|
||||
}
|
||||
else
|
||||
{
|
||||
return QString("none");
|
||||
case 0:
|
||||
return VAbstractTool::TypeLineNone;
|
||||
break;
|
||||
case 1:
|
||||
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)
|
||||
{
|
||||
if (value == "hair")
|
||||
{
|
||||
qint32 index = box->findText(tr("Line"));
|
||||
QStringList styles = VAbstractTool::Styles();
|
||||
qint32 index = box->findText(lineStyles.at(styles.indexOf(value)));
|
||||
if (index != -1)
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -255,6 +255,10 @@ protected:
|
|||
* @brief radioButtonLengthCurve radio button for lengths of curves variables
|
||||
*/
|
||||
QRadioButton *radioButtonLengthCurve;
|
||||
/**
|
||||
* @brief lineStyles list supported line styles.
|
||||
*/
|
||||
QStringList lineStyles;
|
||||
/**
|
||||
* @brief closeEvent handle when dialog cloded
|
||||
* @param event event
|
||||
|
|
|
@ -31,23 +31,16 @@
|
|||
VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const QString &formula, const qint64 &basePointId,
|
||||
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)
|
||||
{
|
||||
this->typeLine = typeLine;
|
||||
Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0");
|
||||
QPointF point1 = data->GeometricObject<const VPointF *>(basePointId)->toQPointF();
|
||||
QPointF point2 = data->GeometricObject<const VPointF *>(id)->toQPointF();
|
||||
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);
|
||||
if (typeLine == TypeLineNone)
|
||||
{
|
||||
mainLine->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
mainLine->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
||||
|
@ -60,25 +53,17 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
|
|||
{
|
||||
currentColor = Qt::gray;
|
||||
}
|
||||
mainLine->setPen(QPen(currentColor, widthHairLine/factor));
|
||||
mainLine->setPen(QPen(currentColor, widthHairLine/factor, LineStyle()));
|
||||
VToolPoint::ChangedActivDraw(newName);
|
||||
}
|
||||
|
||||
void VToolLinePoint::RefreshGeometry()
|
||||
{
|
||||
mainLine->setPen(QPen(currentColor, widthHairLine/factor));
|
||||
mainLine->setPen(QPen(currentColor, widthHairLine/factor, LineStyle()));
|
||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
||||
QPointF point = VDrawTool::data.GeometricObject<const VPointF *>(id)->toQPointF();
|
||||
QPointF basePoint = VDrawTool::data.GeometricObject<const VPointF *>(basePointId)->toQPointF();
|
||||
mainLine->setLine(QLineF(basePoint - point, QPointF()));
|
||||
if (typeLine == TypeLineNone)
|
||||
{
|
||||
mainLine->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
mainLine->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void VToolLinePoint::SetFactor(qreal factor)
|
||||
|
|
|
@ -64,10 +64,6 @@ public slots:
|
|||
*/
|
||||
virtual void SetFactor(qreal factor);
|
||||
protected:
|
||||
/**
|
||||
* @brief typeLine type line.
|
||||
*/
|
||||
QString typeLine;
|
||||
/**
|
||||
* @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::TypeLineNone = QStringLiteral("none");
|
||||
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)
|
||||
: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);
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
//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();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
qint64 cursor = doc->getCursor();
|
||||
|
|
|
@ -137,6 +137,15 @@ public:
|
|||
static const QString AttrAxisP2;
|
||||
static const QString TypeLineNone;
|
||||
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.
|
||||
* @param id object id in container
|
||||
|
@ -181,6 +190,10 @@ protected:
|
|||
* @brief currentColor current tool color.
|
||||
*/
|
||||
Qt::GlobalColor currentColor;
|
||||
/**
|
||||
* @brief typeLine line type.
|
||||
*/
|
||||
QString typeLine;
|
||||
/**
|
||||
* @brief AddToFile add tag with informations about tool into file.
|
||||
*/
|
||||
|
@ -208,6 +221,11 @@ protected:
|
|||
* @param tool tool
|
||||
*/
|
||||
virtual void DeleteTool(QGraphicsItem *tool);
|
||||
/**
|
||||
* @brief LineStyle return pen style for current line style.
|
||||
* @return pen style.
|
||||
*/
|
||||
Qt::PenStyle LineStyle();
|
||||
template <typename T>
|
||||
/**
|
||||
* @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 move = p1mouse - this->mapFromGlobal(QCursor::pos()); // The move
|
||||
horizontalScrollBar()->setValue(move.x() + horizontalScrollBar()->value());
|
||||
verticalScrollBar()->setValue(move.y() + verticalScrollBar()->value());
|
||||
horizontalScrollBar()->setValue(static_cast<qint32>(move.x()) + horizontalScrollBar()->value());
|
||||
verticalScrollBar()->setValue(static_cast<qint32>(move.y()) + verticalScrollBar()->value());
|
||||
|
||||
VAbstractTool::NewSceneRect(this->scene(), this);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user