Refactoring. More independent class VSimpleCurve.
--HG-- branch : feature
This commit is contained in:
parent
70441f48ed
commit
4e4deeb2e5
|
@ -157,9 +157,8 @@ const QString VApplication::GistFileName = QStringLiteral("gist.json");
|
||||||
*/
|
*/
|
||||||
VApplication::VApplication(int &argc, char **argv)
|
VApplication::VApplication(int &argc, char **argv)
|
||||||
: QApplication(argc, argv), _patternUnit(Unit::Cm), _patternType(MeasurementsType::Individual),
|
: QApplication(argc, argv), _patternUnit(Unit::Cm), _patternType(MeasurementsType::Individual),
|
||||||
_widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0), trVars(nullptr),
|
trVars(nullptr), undoStack(nullptr), sceneView(nullptr), currentScene(nullptr), autoSaveTimer(nullptr),
|
||||||
undoStack(nullptr), sceneView(nullptr), currentScene(nullptr), autoSaveTimer(nullptr), mainWindow(nullptr),
|
mainWindow(nullptr), openingPattern(false), settings(nullptr), doc(nullptr), log(nullptr),
|
||||||
openingPattern(false), settings(nullptr), doc(nullptr), log(nullptr),
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||||
out(nullptr), logLock(nullptr)
|
out(nullptr), logLock(nullptr)
|
||||||
#else
|
#else
|
||||||
|
@ -167,8 +166,6 @@ VApplication::VApplication(int &argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
undoStack = new QUndoStack(this);
|
undoStack = new QUndoStack(this);
|
||||||
|
|
||||||
InitLineWidth();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -349,27 +346,6 @@ QString VApplication::translationsPath() const
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VApplication::InitLineWidth()
|
|
||||||
{
|
|
||||||
switch (_patternUnit)
|
|
||||||
{
|
|
||||||
case Unit::Mm:
|
|
||||||
_widthMainLine = DefWidth;
|
|
||||||
break;
|
|
||||||
case Unit::Cm:
|
|
||||||
_widthMainLine = DefWidth/10.0;
|
|
||||||
break;
|
|
||||||
case Unit::Inch:
|
|
||||||
_widthMainLine = DefWidth/25.4;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_widthMainLine = DefWidth;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
_widthHairLine = _widthMainLine/3.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VApplication::LogDirPath() const
|
QString VApplication::LogDirPath() const
|
||||||
{
|
{
|
||||||
|
@ -493,7 +469,6 @@ void VApplication::ClearOldLogs() const
|
||||||
void VApplication::setPatternUnit(const Unit &patternUnit)
|
void VApplication::setPatternUnit(const Unit &patternUnit)
|
||||||
{
|
{
|
||||||
_patternUnit = patternUnit;
|
_patternUnit = patternUnit;
|
||||||
InitLineWidth();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -77,8 +77,6 @@ public:
|
||||||
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||||
|
|
||||||
QString translationsPath() const;
|
QString translationsPath() const;
|
||||||
qreal widthMainLine() const;
|
|
||||||
qreal widthHairLine() const;
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
QString LocaleToString(const T &value)
|
QString LocaleToString(const T &value)
|
||||||
|
@ -133,8 +131,6 @@ private:
|
||||||
Q_DISABLE_COPY(VApplication)
|
Q_DISABLE_COPY(VApplication)
|
||||||
Unit _patternUnit;
|
Unit _patternUnit;
|
||||||
MeasurementsType _patternType;
|
MeasurementsType _patternType;
|
||||||
qreal _widthMainLine;
|
|
||||||
qreal _widthHairLine;
|
|
||||||
VTranslateVars *trVars;
|
VTranslateVars *trVars;
|
||||||
QUndoStack *undoStack;
|
QUndoStack *undoStack;
|
||||||
VMainGraphicsView *sceneView;
|
VMainGraphicsView *sceneView;
|
||||||
|
@ -204,18 +200,6 @@ inline void VApplication::setPatternType(const MeasurementsType &patternType)
|
||||||
_patternType = patternType;
|
_patternType = patternType;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline qreal VApplication::widthMainLine() const
|
|
||||||
{
|
|
||||||
return _widthMainLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline qreal VApplication::widthHairLine() const
|
|
||||||
{
|
|
||||||
return _widthHairLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline QUndoStack *VApplication::getUndoStack() const
|
inline QUndoStack *VApplication::getUndoStack() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -400,8 +400,8 @@ QIcon MainWindowsNoGUI::ScenePreview(int i) const
|
||||||
QPainter painter(&image);
|
QPainter painter(&image);
|
||||||
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap,
|
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
|
||||||
Qt::RoundJoin));
|
Qt::RoundCap, Qt::RoundJoin));
|
||||||
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
||||||
scenes.at(i)->render(&painter);
|
scenes.at(i)->render(&painter);
|
||||||
painter.end();
|
painter.end();
|
||||||
|
@ -508,8 +508,8 @@ void MainWindowsNoGUI::SvgFile(const QString &name, int i) const
|
||||||
painter.begin(&generator);
|
painter.begin(&generator);
|
||||||
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()), Qt::SolidLine, Qt::RoundCap,
|
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*pattern->GetPatternUnit())), Qt::SolidLine,
|
||||||
Qt::RoundJoin));
|
Qt::RoundCap, Qt::RoundJoin));
|
||||||
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
||||||
scenes.at(i)->render(&painter, paper->rect(), paper->rect(), Qt::IgnoreAspectRatio);
|
scenes.at(i)->render(&painter, paper->rect(), paper->rect(), Qt::IgnoreAspectRatio);
|
||||||
painter.end();
|
painter.end();
|
||||||
|
@ -533,8 +533,8 @@ void MainWindowsNoGUI::PngFile(const QString &name, int i) const
|
||||||
QPainter painter(&image);
|
QPainter painter(&image);
|
||||||
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap,
|
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
|
||||||
Qt::RoundJoin));
|
Qt::RoundCap, Qt::RoundJoin));
|
||||||
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
||||||
scenes.at(i)->render(&painter, r, r, Qt::IgnoreAspectRatio);
|
scenes.at(i)->render(&painter, r, r, Qt::IgnoreAspectRatio);
|
||||||
image.save(name);
|
image.save(name);
|
||||||
|
@ -577,8 +577,8 @@ void MainWindowsNoGUI::PdfFile(const QString &name, int i) const
|
||||||
}
|
}
|
||||||
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap,
|
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
|
||||||
Qt::RoundJoin));
|
Qt::RoundCap, Qt::RoundJoin));
|
||||||
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
||||||
scenes.at(i)->render(&painter, r, r, Qt::IgnoreAspectRatio);
|
scenes.at(i)->render(&painter, r, r, Qt::IgnoreAspectRatio);
|
||||||
painter.end();
|
painter.end();
|
||||||
|
@ -685,15 +685,15 @@ QVector<QImage> MainWindowsNoGUI::AllSheets()
|
||||||
QPainter painter(&image);
|
QPainter painter(&image);
|
||||||
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap,
|
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
|
||||||
Qt::RoundJoin));
|
Qt::RoundCap, Qt::RoundJoin));
|
||||||
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
||||||
scenes.at(i)->render(&painter);
|
scenes.at(i)->render(&painter);
|
||||||
painter.end();
|
painter.end();
|
||||||
images.append(image);
|
images.append(image);
|
||||||
|
|
||||||
// Resore
|
// Resore
|
||||||
paper->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine())));
|
paper->setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit()))));
|
||||||
brush->setColor( QColor( Qt::gray ) );
|
brush->setColor( QColor( Qt::gray ) );
|
||||||
brush->setStyle( Qt::SolidPattern );
|
brush->setStyle( Qt::SolidPattern );
|
||||||
scenes[i]->setBackgroundBrush( *brush );
|
scenes[i]->setBackgroundBrush( *brush );
|
||||||
|
|
|
@ -75,7 +75,8 @@ void VAbstractSpline::Disable(bool disable, const QString &namePP)
|
||||||
{
|
{
|
||||||
enabled = !CorrectDisable(disable, namePP);
|
enabled = !CorrectDisable(disable, namePP);
|
||||||
this->setEnabled(enabled);
|
this->setEnabled(enabled);
|
||||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor, Qt::SolidLine,
|
this->setPen(QPen(CorrectColor(lineColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor, Qt::SolidLine,
|
||||||
Qt::RoundCap));
|
Qt::RoundCap));
|
||||||
emit setEnabledPoint(enabled);
|
emit setEnabledPoint(enabled);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +120,8 @@ void VAbstractSpline::SetFactor(qreal factor)
|
||||||
void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine,
|
this->setPen(QPen(CorrectColor(lineColor),
|
||||||
|
qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))/factor, Qt::SolidLine,
|
||||||
Qt::RoundCap));
|
Qt::RoundCap));
|
||||||
this->setPath(ToolPath(PathDirection::Show));
|
this->setPath(ToolPath(PathDirection::Show));
|
||||||
isHovered = true;
|
isHovered = true;
|
||||||
|
@ -135,7 +137,8 @@ void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(CorrectColor(lineColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
if (detailsMode)
|
if (detailsMode)
|
||||||
{
|
{
|
||||||
this->setPath(ToolPath(PathDirection::Show));
|
this->setPath(ToolPath(PathDirection::Show));
|
||||||
|
@ -244,10 +247,12 @@ void VAbstractSpline::setEnabled(bool enabled)
|
||||||
QGraphicsPathItem::setEnabled(enabled);
|
QGraphicsPathItem::setEnabled(enabled);
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
setPen(QPen(QColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
setPen(QPen(QColor(lineColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setPen(QPen(Qt::gray, qApp->toPixel(qApp->widthHairLine())/factor));
|
setPen(QPen(Qt::gray,
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const QString &c
|
||||||
lineColor = color;
|
lineColor = color;
|
||||||
|
|
||||||
this->setPath(ToolPath());
|
this->setPath(ToolPath());
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
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);
|
||||||
|
@ -358,7 +358,8 @@ void VToolArc::SetVisualization()
|
||||||
*/
|
*/
|
||||||
void VToolArc::RefreshGeometry()
|
void VToolArc::RefreshGeometry()
|
||||||
{
|
{
|
||||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(CorrectColor(lineColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
this->setPath(ToolPath());
|
this->setPath(ToolPath());
|
||||||
|
|
||||||
SetVisualization();
|
SetVisualization();
|
||||||
|
|
|
@ -47,7 +47,7 @@ VToolArcWithLength::VToolArcWithLength(VPattern *doc, VContainer *data, quint32
|
||||||
lineColor = color;
|
lineColor = color;
|
||||||
|
|
||||||
this->setPath(ToolPath());
|
this->setPath(ToolPath());
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
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);
|
||||||
|
@ -312,7 +312,8 @@ void VToolArcWithLength::SetVisualization()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolArcWithLength::RefreshGeometry()
|
void VToolArcWithLength::RefreshGeometry()
|
||||||
{
|
{
|
||||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(CorrectColor(lineColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
this->setPath(ToolPath());
|
this->setPath(ToolPath());
|
||||||
|
|
||||||
SetVisualization();
|
SetVisualization();
|
||||||
|
|
|
@ -43,14 +43,16 @@ VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QSt
|
||||||
|
|
||||||
lineColor = color;
|
lineColor = color;
|
||||||
|
|
||||||
firstCurve = new VSimpleCurve(curve1id, QColor(lineColor), SimpleCurvePoint::ForthPoint, &factor);
|
firstCurve = new VSimpleCurve(curve1id, QColor(lineColor), SimpleCurvePoint::ForthPoint, *data->GetPatternUnit(),
|
||||||
|
&factor);
|
||||||
firstCurve->setParentItem(this);
|
firstCurve->setParentItem(this);
|
||||||
connect(firstCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
|
connect(firstCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
|
||||||
connect(firstCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath);
|
connect(firstCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath);
|
||||||
// TODO: Now we only hide simple curves, but in future need totally delete them all.
|
// TODO: Now we only hide simple curves, but in future need totally delete them all.
|
||||||
firstCurve->setVisible(false);
|
firstCurve->setVisible(false);
|
||||||
|
|
||||||
secondCurve = new VSimpleCurve(curve2id, QColor(lineColor), SimpleCurvePoint::FirstPoint, &factor);
|
secondCurve = new VSimpleCurve(curve2id, QColor(lineColor), SimpleCurvePoint::FirstPoint, *data->GetPatternUnit(),
|
||||||
|
&factor);
|
||||||
secondCurve->setParentItem(this);
|
secondCurve->setParentItem(this);
|
||||||
connect(secondCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
|
connect(secondCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
|
||||||
connect(secondCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath);
|
connect(secondCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath);
|
||||||
|
|
|
@ -62,7 +62,8 @@ 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, LineStyleToPenStyle(typeLine)));
|
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
|
||||||
|
LineStyleToPenStyle(typeLine)));
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(typeCreation);
|
||||||
}
|
}
|
||||||
|
@ -218,7 +219,8 @@ void VToolLine::Disable(bool disable, const QString &namePP)
|
||||||
{
|
{
|
||||||
enabled = !CorrectDisable(disable, namePP);
|
enabled = !CorrectDisable(disable, namePP);
|
||||||
this->setEnabled(enabled);
|
this->setEnabled(enabled);
|
||||||
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor,
|
this->setPen(QPen(CorrectColor(baseColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
|
||||||
LineStyleToPenStyle(typeLine)));
|
LineStyleToPenStyle(typeLine)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +272,8 @@ void VToolLine::RefreshDataInFile()
|
||||||
void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthMainLine())/factor,
|
this->setPen(QPen(CorrectColor(lineColor),
|
||||||
|
qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))/factor,
|
||||||
LineStyleToPenStyle(typeLine)));
|
LineStyleToPenStyle(typeLine)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +287,8 @@ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
if (vis == nullptr)
|
if (vis == nullptr)
|
||||||
{
|
{
|
||||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor,
|
this->setPen(QPen(CorrectColor(lineColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
|
||||||
LineStyleToPenStyle(typeLine)));
|
LineStyleToPenStyle(typeLine)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,8 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i
|
||||||
QPointF point1 = data->GeometricObject<VPointF>(basePointId)->toQPointF();
|
QPointF point1 = data->GeometricObject<VPointF>(basePointId)->toQPointF();
|
||||||
QPointF point2 = data->GeometricObject<VPointF>(id)->toQPointF();
|
QPointF point2 = data->GeometricObject<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, LineStyleToPenStyle(typeLine)));
|
mainLine->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
|
||||||
|
LineStyleToPenStyle(typeLine)));
|
||||||
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +71,8 @@ VToolLinePoint::~VToolLinePoint()
|
||||||
*/
|
*/
|
||||||
void VToolLinePoint::RefreshGeometry()
|
void VToolLinePoint::RefreshGeometry()
|
||||||
{
|
{
|
||||||
mainLine->setPen(QPen(CorrectColor(QColor(lineColor)), qApp->toPixel(qApp->widthHairLine())/factor,
|
mainLine->setPen(QPen(CorrectColor(QColor(lineColor)),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
|
||||||
LineStyleToPenStyle(typeLine)));
|
LineStyleToPenStyle(typeLine)));
|
||||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||||
QPointF point = VDrawTool::data.GeometricObject<VPointF>(id)->toQPointF();
|
QPointF point = VDrawTool::data.GeometricObject<VPointF>(id)->toQPointF();
|
||||||
|
@ -111,7 +113,8 @@ void VToolLinePoint::SetFactor(qreal factor)
|
||||||
void VToolLinePoint::Disable(bool disable, const QString &namePP)
|
void VToolLinePoint::Disable(bool disable, const QString &namePP)
|
||||||
{
|
{
|
||||||
VToolPoint::Disable(disable, namePP);
|
VToolPoint::Disable(disable, namePP);
|
||||||
mainLine->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor,
|
mainLine->setPen(QPen(CorrectColor(lineColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
|
||||||
LineStyleToPenStyle(typeLine)));
|
LineStyleToPenStyle(typeLine)));
|
||||||
mainLine->setEnabled(enabled);
|
mainLine->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,8 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthMainLine())/factor));
|
this->setPen(QPen(CorrectColor(baseColor),
|
||||||
|
qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
QGraphicsEllipseItem::hoverEnterEvent(event);
|
QGraphicsEllipseItem::hoverEnterEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +234,8 @@ void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(CorrectColor(baseColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
QGraphicsEllipseItem::hoverLeaveEvent(event);
|
QGraphicsEllipseItem::hoverLeaveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +247,8 @@ void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
void VToolPoint::RefreshPointGeometry(const VPointF &point)
|
void VToolPoint::RefreshPointGeometry(const VPointF &point)
|
||||||
{
|
{
|
||||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||||
this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(CorrectColor(baseColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
||||||
rec.translate(-rec.center().x(), -rec.center().y());
|
rec.translate(-rec.center().x(), -rec.center().y());
|
||||||
this->setRect(rec);
|
this->setRect(rec);
|
||||||
|
@ -277,7 +280,8 @@ void VToolPoint::RefreshLine()
|
||||||
VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2);
|
VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2);
|
||||||
QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
|
QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
|
||||||
lineName->setLine(QLineF(p1, pRec - scenePos()));
|
lineName->setLine(QLineF(p1, pRec - scenePos()));
|
||||||
lineName->setPen(QPen(CorrectColor(Qt::black), qApp->toPixel(qApp->widthHairLine())/factor));
|
lineName->setPen(QPen(CorrectColor(Qt::black),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
|
|
||||||
if (QLineF(p1, pRec - scenePos()).length() <= ToPixel(4, Unit::Mm))
|
if (QLineF(p1, pRec - scenePos()).length() <= ToPixel(4, Unit::Mm))
|
||||||
{
|
{
|
||||||
|
@ -362,10 +366,10 @@ void VToolPoint::setEnabled(bool enabled)
|
||||||
QGraphicsEllipseItem::setEnabled(enabled);
|
QGraphicsEllipseItem::setEnabled(enabled);
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
setPen(QPen(QColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
setPen(QPen(QColor(baseColor), qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setPen(QPen(Qt::gray, qApp->toPixel(qApp->widthHairLine())/factor));
|
setPen(QPen(Qt::gray, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id,
|
||||||
:VToolPoint(doc, data, id, parent), namePP(namePP), mPath(mPath)
|
:VToolPoint(doc, data, id, parent), namePP(namePP), mPath(mPath)
|
||||||
{
|
{
|
||||||
baseColor = Qt::red;
|
baseColor = Qt::red;
|
||||||
this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, false);
|
this->setFlag(QGraphicsItem::ItemIsFocusable, false);
|
||||||
|
@ -258,7 +258,7 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
void VToolSinglePoint::SetColorLabel(const Qt::GlobalColor &color)
|
void VToolSinglePoint::SetColorLabel(const Qt::GlobalColor &color)
|
||||||
{
|
{
|
||||||
namePoint->setBrush(color);
|
namePoint->setBrush(color);
|
||||||
lineName->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor));
|
lineName->setPen(QPen(color, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -57,7 +57,7 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QStr
|
||||||
sceneType = SceneObject::Spline;
|
sceneType = SceneObject::Spline;
|
||||||
lineColor = color;
|
lineColor = color;
|
||||||
|
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
|
@ -66,7 +66,8 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QStr
|
||||||
|
|
||||||
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||||
VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePointPosition::FirstPoint, spl->GetP2(),
|
VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePointPosition::FirstPoint, spl->GetP2(),
|
||||||
spl->GetP1().toQPointF(), this);
|
spl->GetP1().toQPointF(), *data->GetPatternUnit(),
|
||||||
|
this);
|
||||||
connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this,
|
connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this,
|
||||||
&VToolSpline::ControlPointChangePosition);
|
&VToolSpline::ControlPointChangePosition);
|
||||||
connect(this, &VToolSpline::RefreshLine, controlPoint1, &VControlPointSpline::RefreshLine);
|
connect(this, &VToolSpline::RefreshLine, controlPoint1, &VControlPointSpline::RefreshLine);
|
||||||
|
@ -75,7 +76,8 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QStr
|
||||||
controlPoints.append(controlPoint1);
|
controlPoints.append(controlPoint1);
|
||||||
|
|
||||||
VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePointPosition::LastPoint, spl->GetP3(),
|
VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePointPosition::LastPoint, spl->GetP3(),
|
||||||
spl->GetP4().toQPointF(), this);
|
spl->GetP4().toQPointF(), *data->GetPatternUnit(),
|
||||||
|
this);
|
||||||
connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this,
|
connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this,
|
||||||
&VToolSpline::ControlPointChangePosition);
|
&VToolSpline::ControlPointChangePosition);
|
||||||
connect(this, &VToolSpline::RefreshLine, controlPoint2, &VControlPointSpline::RefreshLine);
|
connect(this, &VToolSpline::RefreshLine, controlPoint2, &VControlPointSpline::RefreshLine);
|
||||||
|
@ -467,7 +469,8 @@ void VToolSpline::SetVisualization()
|
||||||
*/
|
*/
|
||||||
void VToolSpline::RefreshGeometry()
|
void VToolSpline::RefreshGeometry()
|
||||||
{
|
{
|
||||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(CorrectColor(lineColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
if (isHovered || detailsMode)
|
if (isHovered || detailsMode)
|
||||||
{
|
{
|
||||||
this->setPath(ToolPath(PathDirection::Show));
|
this->setPath(ToolPath(PathDirection::Show));
|
||||||
|
|
|
@ -56,7 +56,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
|
||||||
lineColor = color;
|
lineColor = color;
|
||||||
|
|
||||||
this->setPath(ToolPath());
|
this->setPath(ToolPath());
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
|
@ -67,7 +67,8 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
|
||||||
{
|
{
|
||||||
VSpline spl = splPath->GetSpline(i);
|
VSpline spl = splPath->GetSpline(i);
|
||||||
VControlPointSpline *controlPoint = new VControlPointSpline(i, SplinePointPosition::FirstPoint, spl.GetP2(),
|
VControlPointSpline *controlPoint = new VControlPointSpline(i, SplinePointPosition::FirstPoint, spl.GetP2(),
|
||||||
spl.GetP1().toQPointF(), this);
|
spl.GetP1().toQPointF(), *data->GetPatternUnit(),
|
||||||
|
this);
|
||||||
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
||||||
&VToolSplinePath::ControlPointChangePosition);
|
&VToolSplinePath::ControlPointChangePosition);
|
||||||
connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine);
|
connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine);
|
||||||
|
@ -76,7 +77,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
|
||||||
controlPoints.append(controlPoint);
|
controlPoints.append(controlPoint);
|
||||||
|
|
||||||
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, spl.GetP3(), spl.GetP4().toQPointF(),
|
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, spl.GetP3(), spl.GetP4().toQPointF(),
|
||||||
this);
|
*data->GetPatternUnit(), this);
|
||||||
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
|
||||||
&VToolSplinePath::ControlPointChangePosition);
|
&VToolSplinePath::ControlPointChangePosition);
|
||||||
connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine);
|
connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine);
|
||||||
|
@ -548,7 +549,8 @@ void VToolSplinePath::RefreshGeometry()
|
||||||
{
|
{
|
||||||
this->setPath(ToolPath());
|
this->setPath(ToolPath());
|
||||||
}
|
}
|
||||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(CorrectColor(lineColor),
|
||||||
|
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
|
||||||
const QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
const QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||||
for (qint32 i = 1; i<=splPath->Count(); ++i)
|
for (qint32 i = 1; i<=splPath->Count(); ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@ VNodeArc::VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, c
|
||||||
:VAbstractNode(doc, data, id, idArc, idTool, qoParent), QGraphicsPathItem(parent)
|
:VAbstractNode(doc, data, id, idArc, idTool, qoParent), QGraphicsPathItem(parent)
|
||||||
{
|
{
|
||||||
RefreshGeometry();
|
RefreshGeometry();
|
||||||
this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(typeCreation);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())));
|
this->setPen(QPen(currentColor, qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -202,7 +202,7 @@ void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -60,7 +60,7 @@ VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPo
|
||||||
lineName = new QGraphicsLineItem(this);
|
lineName = new QGraphicsLineItem(this);
|
||||||
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
||||||
&VNodePoint::NameChangePosition);
|
&VNodePoint::NameChangePosition);
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
this->setBrush(QBrush(Qt::NoBrush));
|
this->setBrush(QBrush(Qt::NoBrush));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
|
@ -208,7 +208,7 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())));
|
this->setPen(QPen(currentColor, qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -219,7 +219,7 @@ void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -54,7 +54,7 @@ VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 id
|
||||||
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent)
|
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent)
|
||||||
{
|
{
|
||||||
RefreshGeometry();
|
RefreshGeometry();
|
||||||
this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(typeCreation);
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())));
|
this->setPen(QPen(currentColor, qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -204,7 +204,7 @@ void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -54,7 +54,7 @@ VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, qu
|
||||||
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent)
|
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent)
|
||||||
{
|
{
|
||||||
RefreshGeometry();
|
RefreshGeometry();
|
||||||
this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
|
|
||||||
ToolCreation(typeCreation);
|
ToolCreation(typeCreation);
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())));
|
this->setPen(QPen(currentColor, qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -207,7 +207,7 @@ void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -44,16 +44,17 @@
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position,
|
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position,
|
||||||
const QPointF &controlPoint, const QPointF &splinePoint,
|
const QPointF &controlPoint, const QPointF &splinePoint, Unit patternUnit,
|
||||||
QGraphicsItem *parent)
|
QGraphicsItem *parent)
|
||||||
:QGraphicsEllipseItem(parent), radius(0), controlLine(nullptr), indexSpline(indexSpline), position(position)
|
:QGraphicsEllipseItem(parent), radius(0), controlLine(nullptr), indexSpline(indexSpline), position(position),
|
||||||
|
patternUnit(patternUnit)
|
||||||
{
|
{
|
||||||
//create circle
|
//create circle
|
||||||
radius = (1.5/*mm*/ / 25.4) * PrintDPI;
|
radius = (1.5/*mm*/ / 25.4) * PrintDPI;
|
||||||
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
||||||
rec.translate(-rec.center().x(), -rec.center().y());
|
rec.translate(-rec.center().x(), -rec.center().y());
|
||||||
this->setRect(rec);
|
this->setRect(rec);
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(patternUnit))));
|
||||||
this->setBrush(QBrush(Qt::NoBrush));
|
this->setBrush(QBrush(Qt::NoBrush));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
|
@ -65,7 +66,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
|
||||||
QPointF p1, p2;
|
QPointF p1, p2;
|
||||||
VGObject::LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2);
|
VGObject::LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2);
|
||||||
controlLine = new QGraphicsLineItem(QLineF(splinePoint-controlPoint, p1), this);
|
controlLine = new QGraphicsLineItem(QLineF(splinePoint-controlPoint, p1), this);
|
||||||
controlLine->setPen(QPen(Qt::red, qApp->toPixel(qApp->widthHairLine())));
|
controlLine->setPen(QPen(Qt::red, qApp->toPixel(WidthHairLine(patternUnit))));
|
||||||
controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
||||||
*/
|
*/
|
||||||
void VControlPointSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void VControlPointSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine())));
|
this->setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(patternUnit))));
|
||||||
VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1);
|
VApplication::setOverrideCursor(cursorArrowOpenHand, 1, 1);
|
||||||
QGraphicsEllipseItem::hoverEnterEvent(event);
|
QGraphicsEllipseItem::hoverEnterEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -104,7 +105,7 @@ void VControlPointSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(patternUnit))));
|
||||||
//Disable cursor-arrow-openhand
|
//Disable cursor-arrow-openhand
|
||||||
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
|
||||||
QGraphicsEllipseItem::hoverLeaveEvent(event);
|
QGraphicsEllipseItem::hoverLeaveEvent(event);
|
||||||
|
@ -183,14 +184,14 @@ void VControlPointSpline::setEnabledPoint(bool enable)
|
||||||
{
|
{
|
||||||
if (enable == true)
|
if (enable == true)
|
||||||
{
|
{
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(patternUnit))));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
this->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setPen(QPen(Qt::gray, qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(Qt::gray, qApp->toPixel(WidthHairLine(patternUnit))));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||||
this->setFlag(QGraphicsItem::ItemIsMovable, false);
|
this->setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||||
this->setAcceptHoverEvents(false);
|
this->setAcceptHoverEvents(false);
|
||||||
|
|
|
@ -42,7 +42,7 @@ class VControlPointSpline : public QObject, public QGraphicsEllipseItem
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, const QPointF &controlPoint,
|
VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, const QPointF &controlPoint,
|
||||||
const QPointF &splinePoint, QGraphicsItem * parent = nullptr);
|
const QPointF &splinePoint, Unit patternUnit, QGraphicsItem * parent = nullptr);
|
||||||
virtual ~VControlPointSpline();
|
virtual ~VControlPointSpline();
|
||||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
||||||
virtual int type() const {return Type;}
|
virtual int type() const {return Type;}
|
||||||
|
@ -85,6 +85,8 @@ private:
|
||||||
|
|
||||||
/** @brief position position point in spline. */
|
/** @brief position position point in spline. */
|
||||||
SplinePointPosition position;
|
SplinePointPosition position;
|
||||||
|
|
||||||
|
Unit patternUnit;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VCONTROLPOINTSPLINE_H
|
#endif // VCONTROLPOINTSPLINE_H
|
||||||
|
|
|
@ -120,7 +120,8 @@ QLineF VisLine::Axis(const QPointF &p1, const QPointF &p2) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisLine::InitPen()
|
void VisLine::InitPen()
|
||||||
{
|
{
|
||||||
this->setPen(QPen(mainColor, qApp->toPixel(qApp->widthHairLine())/factor, lineStyle));
|
this->setPen(QPen(mainColor, qApp->toPixel(WidthHairLine(*Visualization::data->GetPatternUnit()))/factor,
|
||||||
|
lineStyle));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -43,7 +43,8 @@ VisPath::~VisPath()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisPath::InitPen()
|
void VisPath::InitPen()
|
||||||
{
|
{
|
||||||
this->setPen(QPen(mainColor, qApp->toPixel(qApp->widthHairLine())/factor, lineStyle));
|
this->setPen(QPen(mainColor, qApp->toPixel(WidthHairLine(*Visualization::data->GetPatternUnit()))/factor,
|
||||||
|
lineStyle));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -70,6 +70,6 @@ void VisToolLine::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, cons
|
||||||
{
|
{
|
||||||
SCASSERT (lineItem != nullptr);
|
SCASSERT (lineItem != nullptr);
|
||||||
|
|
||||||
lineItem->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor, style));
|
lineItem->setPen(QPen(color, qApp->toPixel(WidthMainLine(*Visualization::data->GetPatternUnit()))/factor, style));
|
||||||
lineItem->setLine(line);
|
lineItem->setLine(line);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ void VisToolTriangle::DrawAimedAxis(QGraphicsPathItem *item, const QLineF &line,
|
||||||
{
|
{
|
||||||
SCASSERT (item != nullptr);
|
SCASSERT (item != nullptr);
|
||||||
|
|
||||||
item->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor, style));
|
item->setPen(QPen(color, qApp->toPixel(WidthHairLine(*Visualization::data->GetPatternUnit()))/factor, style));
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.moveTo(line.p1());
|
path.moveTo(line.p1());
|
||||||
|
|
|
@ -109,7 +109,7 @@ QGraphicsEllipseItem *Visualization::InitPoint(const QColor &color, QGraphicsIte
|
||||||
QGraphicsEllipseItem *point = new QGraphicsEllipseItem(parent);
|
QGraphicsEllipseItem *point = new QGraphicsEllipseItem(parent);
|
||||||
point->setZValue(1);
|
point->setZValue(1);
|
||||||
point->setBrush(QBrush(Qt::NoBrush));
|
point->setBrush(QBrush(Qt::NoBrush));
|
||||||
point->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor));
|
point->setPen(QPen(color, qApp->toPixel(WidthMainLine(*Visualization::data->GetPatternUnit()))/factor));
|
||||||
point->setRect(PointRect(ToPixel(DefPointRadius/*mm*/, Unit::Mm)));
|
point->setRect(PointRect(ToPixel(DefPointRadius/*mm*/, Unit::Mm)));
|
||||||
point->setFlags(QGraphicsItem::ItemStacksBehindParent);
|
point->setFlags(QGraphicsItem::ItemStacksBehindParent);
|
||||||
point->setVisible(false);
|
point->setVisible(false);
|
||||||
|
@ -169,7 +169,7 @@ void Visualization::DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, c
|
||||||
SCASSERT (point != nullptr);
|
SCASSERT (point != nullptr);
|
||||||
|
|
||||||
point->setPos(pos);
|
point->setPos(pos);
|
||||||
point->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor, style));
|
point->setPen(QPen(color, qApp->toPixel(WidthMainLine(*Visualization::data->GetPatternUnit()))/factor, style));
|
||||||
point->setVisible(true);
|
point->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ void Visualization::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, co
|
||||||
{
|
{
|
||||||
SCASSERT (lineItem != nullptr);
|
SCASSERT (lineItem != nullptr);
|
||||||
|
|
||||||
lineItem->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor, style));
|
lineItem->setPen(QPen(color, qApp->toPixel(WidthHairLine(*Visualization::data->GetPatternUnit()))/factor, style));
|
||||||
lineItem->setLine(line);
|
lineItem->setLine(line);
|
||||||
lineItem->setVisible(true);
|
lineItem->setVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,8 @@ void Visualization::DrawPath(QGraphicsPathItem *pathItem, const QPainterPath &pa
|
||||||
{
|
{
|
||||||
SCASSERT (pathItem != nullptr);
|
SCASSERT (pathItem != nullptr);
|
||||||
|
|
||||||
pathItem->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor, style, cap));
|
pathItem->setPen(QPen(color, qApp->toPixel(WidthMainLine(*Visualization::data->GetPatternUnit()))/factor, style,
|
||||||
|
cap));
|
||||||
pathItem->setPath(path);
|
pathItem->setPath(path);
|
||||||
pathItem->setVisible(true);
|
pathItem->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,10 @@
|
||||||
#include "../core/vapplication.h"
|
#include "../core/vapplication.h"
|
||||||
#include "../widgets/vmaingraphicsscene.h"
|
#include "../widgets/vmaingraphicsscene.h"
|
||||||
#include "../../utils/logging.h"
|
#include "../../utils/logging.h"
|
||||||
|
#include "../../libs/vpatterndb/vcontainer.h"
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(vVis)
|
Q_DECLARE_LOGGING_CATEGORY(vVis)
|
||||||
|
|
||||||
class VContainer;
|
|
||||||
|
|
||||||
class Visualization : public QObject
|
class Visualization : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -99,7 +98,7 @@ protected:
|
||||||
Item *InitItem(const QColor &color, QGraphicsItem *parent)
|
Item *InitItem(const QColor &color, QGraphicsItem *parent)
|
||||||
{
|
{
|
||||||
Item *item = new Item(parent);
|
Item *item = new Item(parent);
|
||||||
item->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor));
|
item->setPen(QPen(color, qApp->toPixel(WidthHairLine(*data->GetPatternUnit()))/factor));
|
||||||
item->setZValue(1);
|
item->setZValue(1);
|
||||||
item->setFlags(QGraphicsItem::ItemStacksBehindParent);
|
item->setFlags(QGraphicsItem::ItemStacksBehindParent);
|
||||||
item->setVisible(false);
|
item->setVisible(false);
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vsimplecurve.h"
|
#include "vsimplecurve.h"
|
||||||
#include "../core/vapplication.h"
|
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QStyleOptionGraphicsItem>
|
#include <QStyleOptionGraphicsItem>
|
||||||
|
@ -40,18 +39,18 @@
|
||||||
* @param currentColor current color.
|
* @param currentColor current color.
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VSimpleCurve::VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint pointPosition, qreal *factor,
|
VSimpleCurve::VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint pointPosition, Unit patternUnit,
|
||||||
QObject *parent)
|
qreal *factor, QObject *parent)
|
||||||
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor),
|
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor),
|
||||||
curvePosition(pointPosition), enabled(true)
|
curvePosition(pointPosition), enabled(true), patternUnit(patternUnit)
|
||||||
{
|
{
|
||||||
if (factor == nullptr)
|
if (factor == nullptr)
|
||||||
{
|
{
|
||||||
setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())));
|
setPen(QPen(currentColor, ToPixel(WidthHairLine(patternUnit), patternUnit)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor));
|
setPen(QPen(currentColor, ToPixel(WidthHairLine(patternUnit), patternUnit)/ *factor));
|
||||||
}
|
}
|
||||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
|
@ -62,7 +61,7 @@ void VSimpleCurve::ChangedActivDraw(const bool &flag)
|
||||||
{
|
{
|
||||||
enabled = flag;
|
enabled = flag;
|
||||||
setEnabled(enabled);
|
setEnabled(enabled);
|
||||||
setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())/ *factor));
|
setPen(QPen(CorrectColor(currentColor), ToPixel(WidthHairLine(patternUnit), patternUnit)/ *factor));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -102,11 +101,11 @@ void VSimpleCurve::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
if (factor == nullptr)
|
if (factor == nullptr)
|
||||||
{
|
{
|
||||||
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthMainLine())));
|
this->setPen(QPen(CorrectColor(currentColor), ToPixel(WidthMainLine(patternUnit), patternUnit)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthMainLine())/ *factor));
|
this->setPen(QPen(CorrectColor(currentColor), ToPixel(WidthMainLine(patternUnit), patternUnit)/ *factor));
|
||||||
}
|
}
|
||||||
emit HoverPath(id, curvePosition, PathDirection::Show);
|
emit HoverPath(id, curvePosition, PathDirection::Show);
|
||||||
}
|
}
|
||||||
|
@ -121,11 +120,11 @@ void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
if (factor == nullptr)
|
if (factor == nullptr)
|
||||||
{
|
{
|
||||||
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())));
|
this->setPen(QPen(CorrectColor(currentColor), ToPixel(WidthHairLine(patternUnit), patternUnit)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())/ *factor));
|
this->setPen(QPen(CorrectColor(currentColor), ToPixel(WidthHairLine(patternUnit), patternUnit)/ *factor));
|
||||||
}
|
}
|
||||||
|
|
||||||
emit HoverPath(id, curvePosition, PathDirection::Hide);
|
emit HoverPath(id, curvePosition, PathDirection::Hide);
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#include <QGraphicsPathItem>
|
#include <QGraphicsPathItem>
|
||||||
#include "../libs/vgeometry/vabstractcurve.h"
|
#include "../libs/vgeometry/vabstractcurve.h"
|
||||||
#include "../options.h"
|
#include "../../utils/def.h"
|
||||||
|
|
||||||
enum class SimpleCurvePoint : char { FirstPoint, ForthPoint };
|
enum class SimpleCurvePoint : char { FirstPoint, ForthPoint };
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class VSimpleCurve : public QObject, public QGraphicsPathItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint curvePosition,
|
VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint curvePosition, Unit patternUnit,
|
||||||
qreal *factor = nullptr, QObject *parent = 0);
|
qreal *factor = nullptr, QObject *parent = 0);
|
||||||
void ChangedActivDraw(const bool &flag);
|
void ChangedActivDraw(const bool &flag);
|
||||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
||||||
|
@ -80,6 +80,8 @@ private:
|
||||||
|
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
|
||||||
|
Unit patternUnit;
|
||||||
|
|
||||||
QColor CorrectColor(const QColor &color) const;
|
QColor CorrectColor(const QColor &color) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,3 +29,33 @@
|
||||||
#include "ifcdef.h"
|
#include "ifcdef.h"
|
||||||
|
|
||||||
const qreal PrintDPI = 96.0;
|
const qreal PrintDPI = 96.0;
|
||||||
|
|
||||||
|
#define DefWidth 1.2//mm
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qreal WidthMainLine(Unit patternUnit)
|
||||||
|
{
|
||||||
|
qreal _widthMainLine = DefWidth;
|
||||||
|
switch (patternUnit)
|
||||||
|
{
|
||||||
|
case Unit::Mm:
|
||||||
|
_widthMainLine = DefWidth;
|
||||||
|
break;
|
||||||
|
case Unit::Cm:
|
||||||
|
_widthMainLine = DefWidth/10.0;
|
||||||
|
break;
|
||||||
|
case Unit::Inch:
|
||||||
|
_widthMainLine = DefWidth/25.4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_widthMainLine = DefWidth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return _widthMainLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qreal WidthHairLine(Unit patternUnit)
|
||||||
|
{
|
||||||
|
return WidthMainLine(patternUnit)/3.0;
|
||||||
|
}
|
||||||
|
|
|
@ -61,6 +61,9 @@ static const quint32 null_id = 0;
|
||||||
|
|
||||||
extern const qreal PrintDPI;
|
extern const qreal PrintDPI;
|
||||||
|
|
||||||
|
qreal WidthMainLine(Unit patternUnit);
|
||||||
|
qreal WidthHairLine(Unit patternUnit);
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline double ToPixel(double val, const Unit &unit)
|
inline double ToPixel(double val, const Unit &unit)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user