Refactoring. More independent class VSimpleCurve.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-06-15 12:32:27 +03:00
parent 70441f48ed
commit 4e4deeb2e5
29 changed files with 156 additions and 133 deletions

View File

@ -157,9 +157,8 @@ const QString VApplication::GistFileName = QStringLiteral("gist.json");
*/
VApplication::VApplication(int &argc, char **argv)
: QApplication(argc, argv), _patternUnit(Unit::Cm), _patternType(MeasurementsType::Individual),
_widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0), trVars(nullptr),
undoStack(nullptr), sceneView(nullptr), currentScene(nullptr), autoSaveTimer(nullptr), mainWindow(nullptr),
openingPattern(false), settings(nullptr), doc(nullptr), log(nullptr),
trVars(nullptr), undoStack(nullptr), sceneView(nullptr), currentScene(nullptr), autoSaveTimer(nullptr),
mainWindow(nullptr), openingPattern(false), settings(nullptr), doc(nullptr), log(nullptr),
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
out(nullptr), logLock(nullptr)
#else
@ -167,8 +166,6 @@ VApplication::VApplication(int &argc, char **argv)
#endif
{
undoStack = new QUndoStack(this);
InitLineWidth();
}
//---------------------------------------------------------------------------------------------------------------------
@ -349,27 +346,6 @@ QString VApplication::translationsPath() const
#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
{
@ -493,7 +469,6 @@ void VApplication::ClearOldLogs() const
void VApplication::setPatternUnit(const Unit &patternUnit)
{
_patternUnit = patternUnit;
InitLineWidth();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -77,8 +77,6 @@ public:
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
QString translationsPath() const;
qreal widthMainLine() const;
qreal widthHairLine() const;
template <typename T>
QString LocaleToString(const T &value)
@ -133,8 +131,6 @@ private:
Q_DISABLE_COPY(VApplication)
Unit _patternUnit;
MeasurementsType _patternType;
qreal _widthMainLine;
qreal _widthHairLine;
VTranslateVars *trVars;
QUndoStack *undoStack;
VMainGraphicsView *sceneView;
@ -204,18 +200,6 @@ inline void VApplication::setPatternType(const MeasurementsType &patternType)
_patternType = patternType;
}
//---------------------------------------------------------------------------------------------------------------------
inline qreal VApplication::widthMainLine() const
{
return _widthMainLine;
}
//---------------------------------------------------------------------------------------------------------------------
inline qreal VApplication::widthHairLine() const
{
return _widthHairLine;
}
//---------------------------------------------------------------------------------------------------------------------
inline QUndoStack *VApplication::getUndoStack() const
{

View File

@ -400,8 +400,8 @@ QIcon MainWindowsNoGUI::ScenePreview(int i) const
QPainter painter(&image);
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
scenes.at(i)->render(&painter);
painter.end();
@ -508,8 +508,8 @@ void MainWindowsNoGUI::SvgFile(const QString &name, int i) const
painter.begin(&generator);
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()), Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*pattern->GetPatternUnit())), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
scenes.at(i)->render(&painter, paper->rect(), paper->rect(), Qt::IgnoreAspectRatio);
painter.end();
@ -533,8 +533,8 @@ void MainWindowsNoGUI::PngFile(const QString &name, int i) const
QPainter painter(&image);
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
scenes.at(i)->render(&painter, r, r, Qt::IgnoreAspectRatio);
image.save(name);
@ -577,8 +577,8 @@ void MainWindowsNoGUI::PdfFile(const QString &name, int i) const
}
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
scenes.at(i)->render(&painter, r, r, Qt::IgnoreAspectRatio);
painter.end();
@ -685,15 +685,15 @@ QVector<QImage> MainWindowsNoGUI::AllSheets()
QPainter painter(&image);
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap,
Qt::RoundJoin));
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
scenes.at(i)->render(&painter);
painter.end();
images.append(image);
// 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->setStyle( Qt::SolidPattern );
scenes[i]->setBackgroundBrush( *brush );

View File

@ -75,7 +75,8 @@ void VAbstractSpline::Disable(bool disable, const QString &namePP)
{
enabled = !CorrectDisable(disable, namePP);
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));
emit setEnabledPoint(enabled);
}
@ -119,7 +120,8 @@ void VAbstractSpline::SetFactor(qreal factor)
void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *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));
this->setPath(ToolPath(PathDirection::Show));
isHovered = true;
@ -135,7 +137,8 @@ void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *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)
{
this->setPath(ToolPath(PathDirection::Show));
@ -244,10 +247,12 @@ void VAbstractSpline::setEnabled(bool enabled)
QGraphicsPathItem::setEnabled(enabled);
if (enabled)
{
setPen(QPen(QColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
setPen(QPen(QColor(lineColor),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
}
else
{
setPen(QPen(Qt::gray, qApp->toPixel(qApp->widthHairLine())/factor));
setPen(QPen(Qt::gray,
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
}
}

View File

@ -55,7 +55,7 @@ VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const QString &c
lineColor = color;
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::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
@ -358,7 +358,8 @@ void VToolArc::SetVisualization()
*/
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());
SetVisualization();

View File

@ -47,7 +47,7 @@ VToolArcWithLength::VToolArcWithLength(VPattern *doc, VContainer *data, quint32
lineColor = color;
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::ItemIsFocusable, true);
this->setAcceptHoverEvents(true);
@ -312,7 +312,8 @@ void VToolArcWithLength::SetVisualization()
//---------------------------------------------------------------------------------------------------------------------
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());
SetVisualization();

View File

@ -43,14 +43,16 @@ VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QSt
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);
connect(firstCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
connect(firstCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath);
// TODO: Now we only hide simple curves, but in future need totally delete them all.
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);
connect(secondCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
connect(secondCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath);

View File

@ -62,7 +62,8 @@ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstP
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, 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);
}
@ -218,7 +219,8 @@ void VToolLine::Disable(bool disable, const QString &namePP)
{
enabled = !CorrectDisable(disable, namePP);
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)));
}
@ -270,7 +272,8 @@ void VToolLine::RefreshDataInFile()
void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *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)));
}
@ -284,7 +287,8 @@ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_UNUSED(event);
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)));
}
}

View File

@ -54,7 +54,8 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i
QPointF point1 = data->GeometricObject<VPointF>(basePointId)->toQPointF();
QPointF point2 = data->GeometricObject<VPointF>(id)->toQPointF();
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);
}
@ -70,7 +71,8 @@ VToolLinePoint::~VToolLinePoint()
*/
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)));
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
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)
{
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)));
mainLine->setEnabled(enabled);
}

View File

@ -221,7 +221,8 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *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);
}
@ -233,7 +234,8 @@ void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *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);
}
@ -245,7 +247,8 @@ void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void VToolPoint::RefreshPointGeometry(const VPointF &point)
{
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);
rec.translate(-rec.center().x(), -rec.center().y());
this->setRect(rec);
@ -277,7 +280,8 @@ void VToolPoint::RefreshLine()
VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2);
QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
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))
{
@ -362,10 +366,10 @@ void VToolPoint::setEnabled(bool enabled)
QGraphicsEllipseItem::setEnabled(enabled);
if (enabled)
{
setPen(QPen(QColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor));
setPen(QPen(QColor(baseColor), qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
}
else
{
setPen(QPen(Qt::gray, qApp->toPixel(qApp->widthHairLine())/factor));
setPen(QPen(Qt::gray, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
}
}

View File

@ -53,7 +53,7 @@ VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id,
:VToolPoint(doc, data, id, parent), namePP(namePP), mPath(mPath)
{
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::ItemSendsGeometryChanges, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, false);
@ -258,7 +258,7 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VToolSinglePoint::SetColorLabel(const Qt::GlobalColor &color)
{
namePoint->setBrush(color);
lineName->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor));
lineName->setPen(QPen(color, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -57,7 +57,7 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QStr
sceneType = SceneObject::Spline;
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::ItemIsFocusable, 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);
VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePointPosition::FirstPoint, spl->GetP2(),
spl->GetP1().toQPointF(), this);
spl->GetP1().toQPointF(), *data->GetPatternUnit(),
this);
connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSpline::ControlPointChangePosition);
connect(this, &VToolSpline::RefreshLine, controlPoint1, &VControlPointSpline::RefreshLine);
@ -75,7 +76,8 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QStr
controlPoints.append(controlPoint1);
VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePointPosition::LastPoint, spl->GetP3(),
spl->GetP4().toQPointF(), this);
spl->GetP4().toQPointF(), *data->GetPatternUnit(),
this);
connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSpline::ControlPointChangePosition);
connect(this, &VToolSpline::RefreshLine, controlPoint2, &VControlPointSpline::RefreshLine);
@ -467,7 +469,8 @@ void VToolSpline::SetVisualization()
*/
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)
{
this->setPath(ToolPath(PathDirection::Show));

View File

@ -56,7 +56,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
lineColor = color;
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::ItemIsFocusable, true);
this->setFlag(QGraphicsItem::ItemIsMovable, true);
@ -67,7 +67,8 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
{
VSpline spl = splPath->GetSpline(i);
VControlPointSpline *controlPoint = new VControlPointSpline(i, SplinePointPosition::FirstPoint, spl.GetP2(),
spl.GetP1().toQPointF(), this);
spl.GetP1().toQPointF(), *data->GetPatternUnit(),
this);
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine);
@ -76,7 +77,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
controlPoints.append(controlPoint);
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, spl.GetP3(), spl.GetP4().toQPointF(),
this);
*data->GetPatternUnit(), this);
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine);
@ -548,7 +549,8 @@ void VToolSplinePath::RefreshGeometry()
{
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);
for (qint32 i = 1; i<=splPath->Count(); ++i)
{

View File

@ -53,7 +53,7 @@ VNodeArc::VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, c
:VAbstractNode(doc, data, id, idArc, idTool, qoParent), QGraphicsPathItem(parent)
{
RefreshGeometry();
this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())));
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
ToolCreation(typeCreation);
}
@ -191,7 +191,7 @@ void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *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)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())));
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -60,7 +60,7 @@ VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPo
lineName = new QGraphicsLineItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&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->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true);
@ -208,7 +208,7 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *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)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())));
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -54,7 +54,7 @@ VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 id
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent)
{
RefreshGeometry();
this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())));
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
ToolCreation(typeCreation);
}
@ -193,7 +193,7 @@ void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *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)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())));
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -54,7 +54,7 @@ VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, qu
:VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent)
{
RefreshGeometry();
this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())));
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
ToolCreation(typeCreation);
}
@ -196,7 +196,7 @@ void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *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)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())));
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -44,16 +44,17 @@
* @param parent parent object.
*/
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position,
const QPointF &controlPoint, const QPointF &splinePoint,
const QPointF &controlPoint, const QPointF &splinePoint, Unit patternUnit,
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
radius = (1.5/*mm*/ / 25.4) * PrintDPI;
QRectF rec = QRectF(0, 0, radius*2, radius*2);
rec.translate(-rec.center().x(), -rec.center().y());
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->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemIsMovable, true);
@ -65,7 +66,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
QPointF p1, p2;
VGObject::LineIntersectCircle(QPointF(), radius, QLineF( QPointF(), splinePoint-controlPoint), p1, p2);
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);
}
@ -96,7 +97,7 @@ void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsIte
*/
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);
QGraphicsEllipseItem::hoverEnterEvent(event);
}
@ -104,7 +105,7 @@ void VControlPointSpline::hoverEnterEvent(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
VApplication::restoreOverrideCursor(cursorArrowOpenHand);
QGraphicsEllipseItem::hoverLeaveEvent(event);
@ -183,14 +184,14 @@ void VControlPointSpline::setEnabledPoint(bool enable)
{
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::ItemIsMovable, true);
this->setAcceptHoverEvents(true);
}
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::ItemIsMovable, false);
this->setAcceptHoverEvents(false);

View File

@ -42,7 +42,7 @@ class VControlPointSpline : public QObject, public QGraphicsEllipseItem
Q_OBJECT
public:
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 void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
virtual int type() const {return Type;}
@ -85,6 +85,8 @@ private:
/** @brief position position point in spline. */
SplinePointPosition position;
Unit patternUnit;
};
#endif // VCONTROLPOINTSPLINE_H

View File

@ -120,7 +120,8 @@ QLineF VisLine::Axis(const QPointF &p1, const QPointF &p2) const
//---------------------------------------------------------------------------------------------------------------------
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));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -43,7 +43,8 @@ VisPath::~VisPath()
//---------------------------------------------------------------------------------------------------------------------
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));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -70,6 +70,6 @@ void VisToolLine::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, cons
{
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);
}

View File

@ -135,7 +135,7 @@ void VisToolTriangle::DrawAimedAxis(QGraphicsPathItem *item, const QLineF &line,
{
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;
path.moveTo(line.p1());

View File

@ -109,7 +109,7 @@ QGraphicsEllipseItem *Visualization::InitPoint(const QColor &color, QGraphicsIte
QGraphicsEllipseItem *point = new QGraphicsEllipseItem(parent);
point->setZValue(1);
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->setFlags(QGraphicsItem::ItemStacksBehindParent);
point->setVisible(false);
@ -169,7 +169,7 @@ void Visualization::DrawPoint(QGraphicsEllipseItem *point, const QPointF &pos, c
SCASSERT (point != nullptr);
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);
}
@ -178,7 +178,7 @@ void Visualization::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, co
{
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->setVisible(true);
}
@ -189,7 +189,8 @@ void Visualization::DrawPath(QGraphicsPathItem *pathItem, const QPainterPath &pa
{
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->setVisible(true);
}

View File

@ -35,11 +35,10 @@
#include "../core/vapplication.h"
#include "../widgets/vmaingraphicsscene.h"
#include "../../utils/logging.h"
#include "../../libs/vpatterndb/vcontainer.h"
Q_DECLARE_LOGGING_CATEGORY(vVis)
class VContainer;
class Visualization : public QObject
{
Q_OBJECT
@ -99,7 +98,7 @@ protected:
Item *InitItem(const QColor &color, QGraphicsItem *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->setFlags(QGraphicsItem::ItemStacksBehindParent);
item->setVisible(false);

View File

@ -27,7 +27,6 @@
*************************************************************************/
#include "vsimplecurve.h"
#include "../core/vapplication.h"
#include <QGraphicsSceneMouseEvent>
#include <QPen>
#include <QStyleOptionGraphicsItem>
@ -40,18 +39,18 @@
* @param currentColor current color.
* @param parent parent object.
*/
VSimpleCurve::VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint pointPosition, qreal *factor,
QObject *parent)
VSimpleCurve::VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint pointPosition, Unit patternUnit,
qreal *factor, QObject *parent)
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor),
curvePosition(pointPosition), enabled(true)
curvePosition(pointPosition), enabled(true), patternUnit(patternUnit)
{
if (factor == nullptr)
{
setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())));
setPen(QPen(currentColor, ToPixel(WidthHairLine(patternUnit), patternUnit)));
}
else
{
setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor));
setPen(QPen(currentColor, ToPixel(WidthHairLine(patternUnit), patternUnit)/ *factor));
}
setFlag(QGraphicsItem::ItemIsSelectable, true);
setAcceptHoverEvents(true);
@ -62,7 +61,7 @@ void VSimpleCurve::ChangedActivDraw(const bool &flag)
{
enabled = flag;
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);
if (factor == nullptr)
{
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthMainLine())));
this->setPen(QPen(CorrectColor(currentColor), ToPixel(WidthMainLine(patternUnit), patternUnit)));
}
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);
}
@ -121,11 +120,11 @@ void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_UNUSED(event);
if (factor == nullptr)
{
this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())));
this->setPen(QPen(CorrectColor(currentColor), ToPixel(WidthHairLine(patternUnit), patternUnit)));
}
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);

View File

@ -31,7 +31,7 @@
#include <QGraphicsPathItem>
#include "../libs/vgeometry/vabstractcurve.h"
#include "../options.h"
#include "../../utils/def.h"
enum class SimpleCurvePoint : char { FirstPoint, ForthPoint };
@ -42,7 +42,7 @@ class VSimpleCurve : public QObject, public QGraphicsPathItem
{
Q_OBJECT
public:
VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint curvePosition,
VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint curvePosition, Unit patternUnit,
qreal *factor = nullptr, QObject *parent = 0);
void ChangedActivDraw(const bool &flag);
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
@ -80,6 +80,8 @@ private:
bool enabled;
Unit patternUnit;
QColor CorrectColor(const QColor &color) const;
};

View File

@ -29,3 +29,33 @@
#include "ifcdef.h"
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;
}

View File

@ -61,6 +61,9 @@ static const quint32 null_id = 0;
extern const qreal PrintDPI;
qreal WidthMainLine(Unit patternUnit);
qreal WidthHairLine(Unit patternUnit);
//---------------------------------------------------------------------------------------------------------------------
inline double ToPixel(double val, const Unit &unit)
{