Resolved issue #244. New feature: Adjust line and point thickness and label

size.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-06-16 14:53:08 +03:00
parent debcabf1a3
commit b0f867499c
157 changed files with 1994 additions and 1269 deletions

View File

@ -2,6 +2,7 @@
- [#682] New feature. Export increments to Excel .csv.
- [#681] Enhance feature: Dashed line options for curves, arcs, etc.
- [#684] Proposal: Add option to only show outer edges on detail.
- [#244] New feature: Adjust line and point thickness and label size.
# Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -281,7 +281,6 @@ void MainWindow::AddPP(const QString &PPName)
// Show best for new PP
VMainGraphicsView::NewSceneRect(ui->view->scene(), ui->view);
ui->view->fitInView(doc->ActiveDrawBoundingRect(), Qt::KeepAspectRatio);
ui->view->NewFactor(ui->view->transform().m11());
ui->actionNewDraw->setEnabled(true);
helpLabel->setText("");
@ -356,7 +355,6 @@ void MainWindow::InitScenes()
sceneDraw->setTransform(ui->view->transform());
sceneDetails->setTransform(ui->view->transform());
connect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor);
connect(ui->view, &VMainGraphicsView::MouseRelease, this, [this](){EndVisualization(true);});
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
policy.setHorizontalStretch(12);
@ -2261,8 +2259,6 @@ void MainWindow::ActionDraw(bool checked)
currentScene = sceneDraw;
ui->view->setScene(currentScene);
connect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor,
Qt::UniqueConnection);
RestoreCurrentScene();
mode = Draw::Calculation;
@ -2336,7 +2332,6 @@ void MainWindow::ActionDetails(bool checked)
currentScene = sceneDetails;
ui->view->itemClicked(nullptr);
ui->view->setScene(currentScene);
disconnect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor);
RestoreCurrentScene();
if (mode == Draw::Calculation)
@ -2451,7 +2446,6 @@ void MainWindow::ActionLayout(bool checked)
currentScene = tempSceneLayout;
ui->view->itemClicked(nullptr);
ui->view->setScene(currentScene);
disconnect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor);
if (mode == Draw::Calculation)
{
@ -4587,7 +4581,6 @@ void MainWindow::ChangePP(int index, bool zoomBestFit)
if (zoomBestFit)
{
ui->view->fitInView(doc->ActiveDrawBoundingRect(), Qt::KeepAspectRatio);
ui->view->NewFactor(ui->view->transform().m11());
}
}
toolOptions->itemClicked(nullptr);//hide options for tool in previous pattern piece

View File

@ -302,8 +302,7 @@ void MainWindowsNoGUI::PrintPages(QPrinter *printer)
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setPen(QPen(Qt::black, widthMainLine, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
int count = 0;
@ -518,8 +517,7 @@ 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(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setPen(QPen(Qt::black, widthMainLine, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
scenes.at(i)->render(&painter, r, r, Qt::IgnoreAspectRatio);
painter.end();
@ -599,8 +597,7 @@ 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(WidthHairLine(*pattern->GetPatternUnit())), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setPen(QPen(Qt::black, widthHairLine, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
scenes.at(i)->render(&painter, paper->rect(), paper->rect(), Qt::IgnoreAspectRatio);
painter.end();
@ -624,8 +621,7 @@ 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(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setPen(QPen(Qt::black, widthMainLine, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
scenes.at(i)->render(&painter, r, r, Qt::IgnoreAspectRatio);
image.save(name);
@ -671,8 +667,7 @@ 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(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setPen(QPen(Qt::black, widthMainLine, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
scenes.at(i)->render(&painter, r, r, Qt::IgnoreAspectRatio);
painter.end();
@ -827,7 +822,7 @@ void MainWindowsNoGUI::RestorePaper(int index) const
if (paper)
{
// Restore
paper->setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit()))));
paper->setPen(QPen(Qt::black, widthMainLine));
QBrush brush(Qt::gray);
scenes.at(index)->setBackgroundBrush(brush);
shadows.at(index)->setVisible(true);
@ -1063,8 +1058,7 @@ bool MainWindowsNoGUI::IsLayoutGrayscale() const
QImage image(target.size(), QImage::Format_RGB32);
image.fill(Qt::white);
QPainter painter(&image);
painter.setPen(QPen(Qt::black, qApp->toPixel(WidthMainLine(*pattern->GetPatternUnit())), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setPen(QPen(Qt::black, widthMainLine, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
scenes.at(i)->render(&painter, target, paper->rect(), Qt::KeepAspectRatio);
painter.end();

View File

@ -43,33 +43,7 @@
const QString CustomMSign = QStringLiteral("@");
const QString CustomIncrSign = QStringLiteral("#");
#define DefWidth 1.2//mm
//---------------------------------------------------------------------------------------------------------------------
qreal WidthMainLine(Unit patternUnit)
{
qreal _widthMainLine = DefWidth;
switch (patternUnit)
{
case Unit::Cm:
_widthMainLine = DefWidth/10.0;
break;
case Unit::Inch:
_widthMainLine = DefWidth/25.4;
break;
case Unit::Mm:
default:
_widthMainLine = DefWidth;
break;
}
return _widthMainLine;
}
//---------------------------------------------------------------------------------------------------------------------
qreal WidthHairLine(Unit patternUnit)
{
return WidthMainLine(patternUnit)/3.0;
}
const QString AttrType = QStringLiteral("type");
const QString AttrMx = QStringLiteral("mx");

View File

@ -63,9 +63,6 @@ static const quint32 null_id = 0;
# define V_NOEXCEPT_EXPR(x)
# endif
qreal WidthMainLine(Unit patternUnit);
qreal WidthHairLine(Unit patternUnit);
extern const QString AttrType;
extern const QString AttrMx;
extern const QString AttrMy;

View File

@ -322,15 +322,6 @@ qreal UnitConvertor(qreal value, const Unit &from, const Unit &to)
return 0;
}
//---------------------------------------------------------------------------------------------------------------------
void CheckFactor(qreal &oldFactor, const qreal &Newfactor)
{
if (Newfactor <= 2 && Newfactor >= 0.5)
{
oldFactor = Newfactor;
}
}
//---------------------------------------------------------------------------------------------------------------------
QStringList SupportedLocales()
{

View File

@ -53,7 +53,6 @@ class QMarginsF;
class VTranslateMeasurements;
#define SceneSize 50000
#define DefPointRadius 1.5//mm
enum class NodeDetail : char { Contour, Modeling };
enum class SceneObject : char { Point, Line, Spline, Arc, ElArc, SplinePath, Detail, Unknown };
@ -374,8 +373,6 @@ double FromPixel(double pix, const Unit &unit) Q_REQUIRED_RESULT;
qreal UnitConvertor(qreal value, const Unit &from, const Unit &to) Q_REQUIRED_RESULT;
void CheckFactor(qreal &oldFactor, const qreal &Newfactor);
void InitLanguages(QComboBox *combobox);
QStringList SupportedLocales() Q_REQUIRED_RESULT;

View File

@ -206,8 +206,7 @@ void DialogCurveIntersectAxis::ShowDialog(bool click)
QLineF line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes.
qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
if (line.length() <= radius)
if (line.length() <= defPointRadiusPixel*1.5)
{
return;
}

View File

@ -316,8 +316,7 @@ void DialogEndLine::ShowDialog(bool click)
QLineF line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes.
const qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
if (line.length() <= radius)
if (line.length() <= defPointRadiusPixel*1.5)
{
return;
}

View File

@ -236,8 +236,7 @@ void DialogLineIntersectAxis::ShowDialog(bool click)
QLineF line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes.
qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
if (line.length() <= radius)
if (line.length() <= defPointRadiusPixel*1.5)
{
return;
}

View File

@ -216,8 +216,7 @@ void DialogRotation::ShowDialog(bool click)
const QLineF line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes.
const qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
if (line.length() <= radius)
if (line.length() <= defPointRadiusPixel*1.5)
{
return;
}

View File

@ -394,7 +394,6 @@ inline void DialogTool::AddVisualization()
if (not scene->items().contains(toolVis))
{
connect(scene, &VMainGraphicsScene::NewFactor, toolVis, &Visualization::SetFactor);
scene->addItem(toolVis);
}

View File

@ -40,12 +40,6 @@ QString VAbstractOperation::getTagName() const
return VAbstractPattern::TagOperation;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::SetEnabled(bool enabled)
{
this->setEnabled(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractOperation::Suffix() const
{
@ -144,7 +138,7 @@ void VAbstractOperation::FullUpdateFromFile()
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr)
item->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
item->RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
}
else
{
@ -156,29 +150,6 @@ void VAbstractOperation::FullUpdateFromFile()
SetVisualization();
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr)
item->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(i.key()));
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr)
item->RefreshGeometry(VAbstractTool::data.GeometricObject<VAbstractCurve>(i.key()));
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::AllowHover(bool enabled)
{
@ -371,14 +342,25 @@ void VAbstractOperation::ToolSelectionType(const SelectionType &type)
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::Disable(bool disable, const QString &namePP)
{
enabled = !CorrectDisable(disable, namePP);
SetEnabled(enabled);
const bool enabled = !CorrectDisable(disable, namePP);
setEnabled(enabled);
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
{
i.next();
i.value()->SetEnabled(enabled);
if (i.value()->GetType() == GOType::Point)
{
VSimplePoint *item = qobject_cast<VSimplePoint *>(i.value());
SCASSERT(item != nullptr)
item->SetEnabled(enabled);
}
else
{
VSimpleCurve *item = qobject_cast<VSimpleCurve *>(i.value());
SCASSERT(item != nullptr)
item->setEnabled(enabled);
}
}
}
@ -499,7 +481,7 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
VSimpleCurve *VAbstractOperation::InitCurve(quint32 id, VContainer *data, GOType curveType)
{
const QSharedPointer<VAbstractCurve> initCurve = data->GeometricObject<VAbstractCurve>(id);
VSimpleCurve *curve = new VSimpleCurve(id, initCurve, *data->GetPatternUnit(), &factor);
VSimpleCurve *curve = new VSimpleCurve(id, initCurve);
curve->setParentItem(this);
curve->SetType(curveType);
connect(curve, &VSimpleCurve::Selected, this, &VAbstractOperation::ObjectSelected);
@ -526,7 +508,7 @@ void VAbstractOperation::DoChangePosition(quint32 id, qreal mx, qreal my)
VSimplePoint *item = qobject_cast<VSimplePoint *>(operatedObjects.value(id));
SCASSERT(item != nullptr)
item->RefreshGeometry(*point);
item->RefreshPointGeometry(*point);
}
}
@ -593,8 +575,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
{
case GOType::Point:
{
VSimplePoint *point = new VSimplePoint(object.id, QColor(baseColor),
*VAbstractTool::data.GetPatternUnit(), &factor);
VSimplePoint *point = new VSimplePoint(object.id, QColor(Qt::black));
point->setParentItem(this);
point->SetType(GOType::Point);
connect(point, &VSimplePoint::Choosed, this, [this](quint32 id)
@ -609,7 +590,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
});
connect(point, &VSimplePoint::Delete, this, &VAbstractOperation::DeleteFromLabel);
connect(point, &VSimplePoint::NameChangedPosition, this, &VAbstractOperation::LabelChangePosition);
point->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(object.id));
point->RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(object.id));
operatedObjects.insert(object.id, point);
break;
}

View File

@ -67,8 +67,6 @@ public:
virtual QString getTagName() const Q_DECL_OVERRIDE;
void SetEnabled(bool enabled);
QString Suffix() const;
void SetSuffix(const QString &suffix);
@ -79,7 +77,6 @@ public:
QVector<DestinationItem> &destination);
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;

View File

@ -44,7 +44,6 @@
#include "../ifc/exception/vexceptionbadid.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../qmuparser/qmutokenparser.h"
#include "../vgeometry/../ifc/ifcdef.h"
#include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h"
#include "../vgeometry/vspline.h"
@ -56,8 +55,12 @@
//---------------------------------------------------------------------------------------------------------------------
VAbstractSpline::VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector<VControlPointSpline *>()),
sceneType(SceneObject::Unknown), isHovered(false), detailsMode(false)
:VDrawTool(doc, data, id),
QGraphicsPathItem(parent),
controlPoints(),
sceneType(SceneObject::Unknown),
m_isHovered(false),
detailsMode(false)
{
InitDefShape();
setAcceptHoverEvents(true);
@ -76,7 +79,7 @@ QPainterPath VAbstractSpline::shape() const
path.lineTo(points.at(i+1));
}
if (isHovered || detailsMode)
if (m_isHovered || detailsMode)
{
path.addPath(curve->GetDirectionPath());
}
@ -111,7 +114,14 @@ QPainterPath VAbstractSpline::shape() const
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if (isHovered || detailsMode)
const qreal width = ScaleWidth(m_isHovered ? widthMainLine : widthHairLine, SceneScale(scene()));
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
setPen(QPen(CorrectColor(this, curve->GetColor()), width, LineStyleToPenStyle(curve->GetPenStyle()), Qt::RoundCap));
RefreshCtrlPoints();
if (m_isHovered || detailsMode)
{
painter->save();
@ -121,7 +131,6 @@ void VAbstractSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
painter->setPen(arrowPen);
painter->setBrush(brush());
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
painter->drawPath(curve->GetDirectionPath());
painter->restore();
@ -149,12 +158,8 @@ void VAbstractSpline::FullUpdateFromFile()
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::Disable(bool disable, const QString &namePP)
{
enabled = !CorrectDisable(disable, namePP);
const bool enabled = !CorrectDisable(disable, namePP);
this->setEnabled(enabled);
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
this->setPen(QPen(CorrectColor(curve->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(curve->GetPenStyle()), Qt::RoundCap));
emit setEnabledPoint(enabled);
}
@ -189,21 +194,11 @@ void VAbstractSpline::ShowTool(quint32 id, bool enable)
ShowItem(this, id, enable);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VAbstractSpline::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::RefreshGeometry()
{
InitDefShape();
RefreshCtrlPoints();
SetVisualization();
}
@ -215,13 +210,7 @@ void VAbstractSpline::RefreshGeometry()
// cppcheck-suppress unusedFunction
void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
this->setPen(QPen(CorrectColor(curve->GetColor()),
qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(curve->GetPenStyle()), Qt::RoundCap));
this->setPath(curve->GetPath());
isHovered = true;
m_isHovered = true;
QGraphicsPathItem::hoverEnterEvent(event);
}
@ -233,13 +222,7 @@ void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
// cppcheck-suppress unusedFunction
void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
this->setPen(QPen(CorrectColor(curve->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(curve->GetPenStyle()), Qt::RoundCap));
this->setPath(curve->GetPath());
isHovered = false;
m_isHovered = false;
QGraphicsPathItem::hoverLeaveEvent(event);
}
@ -331,6 +314,12 @@ void VAbstractSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &ob
doc->SetAttribute(tag, AttrPenStyle, curve->GetPenStyle());
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::RefreshCtrlPoints()
{
// do nothing
}
//---------------------------------------------------------------------------------------------------------------------
VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePointPosition &position,
const QPointF &pos) const
@ -403,9 +392,6 @@ VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePoin
void VAbstractSpline::InitDefShape()
{
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
this->setPen(QPen(CorrectColor(curve->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(curve->GetPenStyle())));
this->setPath(curve->GetPath());
}
@ -418,26 +404,6 @@ void VAbstractSpline::ShowHandles(bool show)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::setEnabled(bool enabled)
{
QGraphicsPathItem::setEnabled(enabled);
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
if (enabled)
{
setPen(QPen(QColor(curve->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(curve->GetPenStyle())));
}
else
{
setPen(QPen(Qt::gray,
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(curve->GetPenStyle())));
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractSpline::GetLineColor() const
{

View File

@ -68,8 +68,6 @@ public:
virtual QString getTagName() const Q_DECL_OVERRIDE;
void ShowHandles(bool show);
void setEnabled(bool enabled);
QString GetLineColor() const;
void SetLineColor(const QString &value);
@ -85,7 +83,6 @@ public slots:
virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE;
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
signals:
/**
* @brief setEnabledPoint disable control points.
@ -98,7 +95,7 @@ protected:
*/
QVector<VControlPointSpline *> controlPoints;
SceneObject sceneType;
bool isHovered;
bool m_isHovered;
bool detailsMode;
/**
* @brief RefreshGeometry refresh item on scene.
@ -113,11 +110,10 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void RefreshCtrlPoints();
VSpline CorrectedSpline(const VSpline &spline, const SplinePointPosition &position, const QPointF &pos) const;
void InitDefShape();
template <typename T>
void ShowToolVisualization(bool show);
@ -135,6 +131,8 @@ protected:
private:
Q_DISABLE_COPY(VAbstractSpline)
void InitDefShape();
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -259,9 +259,6 @@ void VToolCubicBezier::SetVisualization()
void VToolCubicBezier::RefreshGeometry()
{
const QSharedPointer<VCubicBezier> spl = VAbstractTool::data.GeometricObject<VCubicBezier>(id);
this->setPen(QPen(CorrectColor(spl->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(spl->GetPenStyle())));
this->setPath(spl->GetPath());
SetVisualization();

View File

@ -241,10 +241,6 @@ void VToolCubicBezierPath::RefreshGeometry()
QSharedPointer<VCubicBezierPath> splPath = VAbstractTool::data.GeometricObject<VCubicBezierPath>(id);
setPath(splPath->GetPath());
this->setPen(QPen(CorrectColor(splPath->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(splPath->GetPenStyle())));
SetVisualization();
}

View File

@ -96,7 +96,7 @@ VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, co
auto *controlPoint1 = new VControlPointSpline(1, SplinePointPosition::FirstPoint,
static_cast<QPointF>(spl->GetP2()),
static_cast<QPointF>(spl->GetP1()), *data->GetPatternUnit(),
static_cast<QPointF>(spl->GetP1()),
freeAngle1, freeLength1, this);
connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSpline::ControlPointChangePosition);
@ -109,7 +109,7 @@ VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, co
auto *controlPoint2 = new VControlPointSpline(1, SplinePointPosition::LastPoint,
static_cast<QPointF>(spl->GetP3()),
static_cast<QPointF>(spl->GetP4()), *data->GetPatternUnit(),
static_cast<QPointF>(spl->GetP4()),
freeAngle2, freeLength2, this);
connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSpline::ControlPointChangePosition);
@ -533,10 +533,7 @@ bool VToolSpline::IsMovable() const
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolSpline::RefreshGeometry()
void VToolSpline::RefreshCtrlPoints()
{
// Very important to disable control points. Without it the pogram can't move the curve.
foreach (auto *point, controlPoints)
@ -546,11 +543,6 @@ void VToolSpline::RefreshGeometry()
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
this->setPen(QPen(CorrectColor(spl->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(spl->GetPenStyle())));
this->setPath(spl->GetPath());
controlPoints[0]->blockSignals(true);
controlPoints[1]->blockSignals(true);
@ -577,8 +569,6 @@ void VToolSpline::RefreshGeometry()
controlPoints[0]->blockSignals(false);
controlPoints[1]->blockSignals(false);
SetVisualization();
foreach (auto *point, controlPoints)
{
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

View File

@ -86,7 +86,7 @@ protected:
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void RefreshCtrlPoints() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolSpline)
QPointF oldPosition;

View File

@ -106,7 +106,7 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3
auto *controlPoint = new VControlPointSpline(i, SplinePointPosition::FirstPoint,
static_cast<QPointF>(spl.GetP2()),
static_cast<QPointF>(spl.GetP1()), *data->GetPatternUnit(),
static_cast<QPointF>(spl.GetP1()),
freeAngle1, freeLength1, this);
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
@ -118,8 +118,7 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3
const bool freeLength2 = qmu::QmuTokenParser::IsSingle(spl.GetC2LengthFormula());
controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, static_cast<QPointF>(spl.GetP3()),
static_cast<QPointF>(spl.GetP4()), *data->GetPatternUnit(), freeAngle2,
freeLength2, this);
static_cast<QPointF>(spl.GetP4()), freeAngle2, freeLength2, this);
connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this,
&VToolSplinePath::ControlPointChangePosition);
connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint);
@ -661,10 +660,7 @@ bool VToolSplinePath::IsMovable(int index) const
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolSplinePath::RefreshGeometry()
void VToolSplinePath::RefreshCtrlPoints()
{
// Very important to disable control points. Without it the pogram can't move the curve.
foreach (auto *point, controlPoints)
@ -673,11 +669,6 @@ void VToolSplinePath::RefreshGeometry()
}
const auto splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
this->setPath(splPath->GetPath());
this->setPen(QPen(CorrectColor(splPath->GetColor()),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(splPath->GetPenStyle())));
for (qint32 i = 1; i<=splPath->CountSubSpl(); ++i)
{
@ -710,8 +701,6 @@ void VToolSplinePath::RefreshGeometry()
controlPoints[j-1]->blockSignals(false);
}
SetVisualization();
foreach (auto *point, controlPoints)
{
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

View File

@ -91,16 +91,17 @@ public slots:
const QPointF &pos);
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void RemoveReferens() Q_DECL_OVERRIDE;
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void RemoveReferens() Q_DECL_OVERRIDE;
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual void RefreshCtrlPoints() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolSplinePath)
QPointF oldPosition;
@ -110,7 +111,6 @@ private:
QGraphicsItem *parent = nullptr);
bool IsMovable(int index) const;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
static void AddPathPoint(VAbstractPattern *doc, QDomElement &domElement, const VSplinePoint &splPoint);
void UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const;
void SetSplinePathAttributes(QDomElement &domElement, const VSplinePath &path);

View File

@ -56,26 +56,30 @@
//---------------------------------------------------------------------------------------------------------------------
VToolDoublePoint::VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 p1id, quint32 p2id,
QGraphicsItem *parent)
:VAbstractPoint(doc, data, id), QGraphicsPathItem(parent), firstPoint(nullptr), secondPoint(nullptr), p1id(p1id),
:VAbstractPoint(doc, data, id),
QGraphicsPathItem(parent),
firstPoint(nullptr),
secondPoint(nullptr),
p1id(p1id),
p2id(p2id)
{
firstPoint = new VSimplePoint(p1id, QColor(baseColor), *data->GetPatternUnit(), &factor);
firstPoint = new VSimplePoint(p1id, QColor(Qt::black));
firstPoint->setParentItem(this);
connect(firstPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point1Choosed);
connect(firstPoint, &VSimplePoint::Selected, this, &VToolDoublePoint::Point1Selected);
connect(firstPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent);
connect(firstPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel);
connect(firstPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label1ChangePosition);
firstPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
firstPoint->RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
secondPoint = new VSimplePoint(p2id, QColor(baseColor), *data->GetPatternUnit(), &factor);
secondPoint = new VSimplePoint(p2id, QColor(Qt::black));
secondPoint->setParentItem(this);
connect(secondPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point2Choosed);
connect(secondPoint, &VSimplePoint::Selected, this, &VToolDoublePoint::Point2Selected);
connect(secondPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent);
connect(secondPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel);
connect(secondPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label2ChangePosition);
secondPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
secondPoint->RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
}
//---------------------------------------------------------------------------------------------------------------------
@ -102,12 +106,6 @@ void VToolDoublePoint::setNameP2(const QString &name)
SetPointName(p2id, name);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::SetEnabled(bool enabled)
{
SetToolEnabled(this, baseColor, enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::GroupVisibility(quint32 object, bool visible)
{
@ -133,19 +131,11 @@ void VToolDoublePoint::Label2ChangePosition(const QPointF &pos)
ChangePosition(secondPoint, p2id, pos);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
firstPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
secondPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::Disable(bool disable, const QString &namePP)
{
enabled = !CorrectDisable(disable, namePP);
this->SetEnabled(enabled);
const bool enabled = !CorrectDisable(disable, namePP);
this->setEnabled(enabled);
firstPoint->SetEnabled(enabled);
secondPoint->SetEnabled(enabled);
}
@ -185,8 +175,8 @@ void VToolDoublePoint::Point2Selected(bool selected)
void VToolDoublePoint::FullUpdateFromFile()
{
ReadAttributes();
firstPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
secondPoint->RefreshGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
firstPoint->RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p1id));
secondPoint->RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(p2id));
SetVisualization();
}
@ -199,7 +189,7 @@ void VToolDoublePoint::DoChangePosition(quint32 id, qreal mx, qreal my)
point->setMx(mx);
point->setMy(my);
VAbstractTool::data.UpdateGObject(p1id, point);
firstPoint->RefreshGeometry(*point);
firstPoint->RefreshPointGeometry(*point);
}
else if (id == p2id)
{
@ -207,7 +197,7 @@ void VToolDoublePoint::DoChangePosition(quint32 id, qreal mx, qreal my)
point->setMx(mx);
point->setMy(my);
VAbstractTool::data.UpdateGObject(p2id, point);
secondPoint->RefreshGeometry(*point);
secondPoint->RefreshPointGeometry(*point);
}
}
@ -268,19 +258,6 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::RefreshLine(quint32 id)
{
if (id == p1id)
{
firstPoint->RefreshLine();
}
else if (id == p2id)
{
secondPoint->RefreshLine();
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange hadle item change.

View File

@ -62,13 +62,10 @@ public:
QString nameP2() const;
void setNameP2(const QString &name);
void SetEnabled(bool enabled);
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
public slots:
void Label1ChangePosition(const QPointF &pos);
void Label2ChangePosition(const QPointF &pos);
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
void Point1Choosed();
@ -91,7 +88,6 @@ protected:
quint32 p2id;
virtual void UpdateNamePosition(quint32 id) Q_DECL_OVERRIDE;
virtual void RefreshLine(quint32 id) Q_DECL_OVERRIDE;
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;

View File

@ -80,17 +80,6 @@ VToolAlongLine::VToolAlongLine(VAbstractPattern *doc, VContainer *data, quint32
ToolCreation(typeCreation);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolAlongLine::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events. handle context menu event.

View File

@ -68,8 +68,6 @@ public:
quint32 GetSecondPointId() const;
void SetSecondPointId(const quint32 &value);
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
public slots:
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void RemoveReferens() Q_DECL_OVERRIDE;

View File

@ -241,17 +241,6 @@ QString VToolBisector::ThirdPointName() const
return VAbstractTool::data.GetGObject(thirdPointId)->name();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolBisector::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.

View File

@ -77,8 +77,6 @@ public:
void SetThirdPointId(const quint32 &value);
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
public slots:
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void RemoveReferens() Q_DECL_OVERRIDE;

View File

@ -75,9 +75,6 @@ VToolLinePoint::VToolLinePoint(VAbstractPattern *doc, VContainer *data, const qu
QPointF point1 = static_cast<QPointF>(*data->GeometricObject<VPointF>(basePointId));
QPointF point2 = static_cast<QPointF>(*data->GeometricObject<VPointF>(id));
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this);
mainLine->setPen(QPen(CorrectColor(lineColor),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(typeLine)));
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
}
@ -87,15 +84,30 @@ VToolLinePoint::~VToolLinePoint()
delete mainLine;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal width = ScaleWidth(m_isHovered ? widthMainLine : widthHairLine, SceneScale(scene()));
mainLine->setPen(QPen(CorrectColor(this, lineColor), width, LineStyleToPenStyle(m_lineType)));
VToolSinglePoint::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VToolLinePoint::boundingRect() const
{
QRectF rect = VToolSinglePoint::boundingRect();
rect = rect.united(mainLine->boundingRect());
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshGeometry refresh item on scene.
*/
void VToolLinePoint::RefreshGeometry()
{
mainLine->setPen(QPen(CorrectColor(lineColor),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(m_lineType)));
VToolSinglePoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
QPointF point = static_cast<QPointF>(*VDrawTool::data.GeometricObject<VPointF>(id));
QPointF basePoint = static_cast<QPointF>(*VDrawTool::data.GeometricObject<VPointF>(basePointId));
@ -121,25 +133,11 @@ void VToolLinePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj
doc->SetAttribute(tag, AttrLineColor, lineColor);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolLinePoint::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::Disable(bool disable, const QString &namePP)
{
VToolSinglePoint::Disable(disable, namePP);
mainLine->setPen(QPen(CorrectColor(lineColor),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(m_lineType)));
mainLine->setEnabled(enabled);
mainLine->setEnabled(isEnabled());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -56,6 +56,10 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::LinePoint)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
VFormula GetFormulaLength() const;
void SetFormulaLength(const VFormula &value);
@ -71,7 +75,6 @@ public:
void SetLineColor(const QString &value);
public slots:
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
protected:

View File

@ -217,17 +217,6 @@ QString VToolNormal::SecondPointName() const
return VAbstractTool::data.GetGObject(secondPointId)->name();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolNormal::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.

View File

@ -72,8 +72,6 @@ public:
void SetSecondPointId(const quint32 &value);
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
public slots:
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void RemoveReferens() Q_DECL_OVERRIDE;

View File

@ -259,17 +259,6 @@ QString VToolShoulderPoint::ShoulderPointName() const
return VAbstractTool::data.GetGObject(pShoulder)->name();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolShoulderPoint::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.

View File

@ -77,8 +77,6 @@ public:
void setPShoulder(const quint32 &value);
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
public slots:
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void RemoveReferens() Q_DECL_OVERRIDE;

View File

@ -83,11 +83,10 @@ VToolBasePoint::VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32
const QString &namePP, QGraphicsItem * parent )
:VToolSinglePoint(doc, data, id, parent), namePP(namePP)
{
baseColor = Qt::red;
this->setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
m_baseColor = Qt::red;
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
SetColorLabel(Qt::black);
m_namePoint->setBrush(Qt::black);
ToolCreation(typeCreation);
}
@ -360,17 +359,6 @@ void VToolBasePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
VToolSinglePoint::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetColorLabel change color for label and label line.
* @param color new color.
*/
void VToolBasePoint::SetColorLabel(const Qt::GlobalColor &color)
{
namePoint->setBrush(color);
lineName->setPen(QPen(color, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolBasePoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
@ -435,17 +423,6 @@ void VToolBasePoint::FullUpdateFromFile()
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolBasePoint::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshPointGeometry(*(VAbstractTool::data.GeometricObject<VPointF>(id)));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolBasePoint::EnableToolMove(bool move)
{

View File

@ -68,7 +68,6 @@ public:
void SetBasePointPos(const QPointF &pos);
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
signals:
/**
@ -95,8 +94,6 @@ private:
VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
const QString &namePP, QGraphicsItem * parent = nullptr );
void SetColorLabel(const Qt::GlobalColor & color);
};
#endif // VTOOLBASEPOINT_H

View File

@ -223,17 +223,6 @@ QString VToolLineIntersect::Line2P2Name() const
return VAbstractTool::data.GetGObject(p2Line2)->name();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolLineIntersect::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.

View File

@ -80,8 +80,6 @@ public:
void SetP2Line2(const quint32 &value);
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
public slots:
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void RemoveReferens() Q_DECL_OVERRIDE;

View File

@ -269,17 +269,6 @@ QString VToolPointOfContact::SecondPointName() const
return VAbstractTool::data.GetGObject(secondPointId)->name();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolPointOfContact::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.

View File

@ -84,8 +84,6 @@ public:
void SetSecondPointId(const quint32 &value);
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
public slots:
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void RemoveReferens() Q_DECL_OVERRIDE;

View File

@ -76,19 +76,14 @@ QT_WARNING_POP
* @param parent parent object.
*/
VToolSinglePoint::VToolSinglePoint(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent)
:VAbstractPoint(doc, data, id), QGraphicsEllipseItem(parent), radius(ToPixel(DefPointRadius/*mm*/, Unit::Mm)),
namePoint(nullptr), lineName(nullptr)
: VAbstractPoint(doc, data, id),
VScenePoint(parent)
{
namePoint = new VGraphicsSimpleTextItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolSinglePoint::contextMenuEvent);
connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VToolSinglePoint::DeleteFromLabel);
connect(namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VToolSinglePoint::PointChoosed);
connect(namePoint, &VGraphicsSimpleTextItem::PointSelected, this, &VToolSinglePoint::PointSelected);
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolSinglePoint::NameChangePosition);
lineName = new QGraphicsLineItem(this);
this->setBrush(QBrush(Qt::NoBrush));
this->setAcceptHoverEvents(true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
connect(m_namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolSinglePoint::contextMenuEvent);
connect(m_namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VToolSinglePoint::DeleteFromLabel);
connect(m_namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VToolSinglePoint::PointChoosed);
connect(m_namePoint, &VGraphicsSimpleTextItem::PointSelected, this, &VToolSinglePoint::PointSelected);
connect(m_namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolSinglePoint::NameChangePosition);
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
}
@ -107,8 +102,8 @@ void VToolSinglePoint::setName(const QString &name)
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::SetEnabled(bool enabled)
{
SetToolEnabled(this, baseColor, enabled);
SetToolEnabled(lineName, Qt::black, enabled);
setEnabled(enabled);
m_lineName->setEnabled(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
@ -144,7 +139,7 @@ void VToolSinglePoint::UpdateNamePosition(quint32 id)
void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
// Special for not selectable item first need to call standard mousePressEvent then accept event
QGraphicsEllipseItem::mousePressEvent(event);
VScenePoint::mousePressEvent(event);
// Somehow clicking on notselectable object do not clean previous selections.
if (not (flags() & ItemIsSelectable) && scene())
@ -165,29 +160,18 @@ void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolSinglePoint::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::Disable(bool disable, const QString &namePP)
{
enabled = !CorrectDisable(disable, namePP);
this->SetEnabled(enabled);
namePoint->setEnabled(enabled);
const bool enabled = !CorrectDisable(disable, namePP);
SetEnabled(enabled);
m_namePoint->setEnabled(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::EnableToolMove(bool move)
{
namePoint->setFlag(QGraphicsItem::ItemIsMovable, move);
m_namePoint->setFlag(QGraphicsItem::ItemIsMovable, move);
}
//---------------------------------------------------------------------------------------------------------------------
@ -227,71 +211,7 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
PointChoosed();
}
}
QGraphicsEllipseItem::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverEnterEvent handle hover enter events.
* @param event hover enter event.
*/
void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
this->setPen(QPen(CorrectColor(baseColor),
qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))/factor));
QGraphicsEllipseItem::hoverEnterEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VToolSinglePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
this->setPen(QPen(CorrectColor(baseColor),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
QGraphicsEllipseItem::hoverLeaveEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshPointGeometry refresh point on scene.
* @param point point.
*/
void VToolSinglePoint::RefreshPointGeometry(const VPointF &point)
{
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
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);
this->setPos(static_cast<QPointF>(point));
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
namePoint->blockSignals(true);
QFont font = namePoint->font();
font.setPointSize(static_cast<qint32>(namePoint->FontSize()/factor));
namePoint->setFont(font);
namePoint->setText(point.name());
namePoint->setPos(QPointF(point.mx(), point.my()));
namePoint->blockSignals(false);
RefreshLine(id);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshLine refresh line to label on scene.
*/
void VToolSinglePoint::RefreshLine(quint32 id)
{
Q_UNUSED(id)
VAbstractTool::RefreshLine(this, namePoint, lineName, radius);
lineName->setPen(QPen(CorrectColor(Qt::black),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
VScenePoint::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
@ -305,13 +225,13 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change,
{
if (change == QGraphicsItem::ItemSelectedChange)
{
namePoint->blockSignals(true);
namePoint->setSelected(value.toBool());
namePoint->blockSignals(false);
m_namePoint->blockSignals(true);
m_namePoint->setSelected(value.toBool());
m_namePoint->blockSignals(false);
emit ChangedToolSelection(value.toBool(), id, id);
}
return QGraphicsEllipseItem::itemChange(change, value);
return VScenePoint::itemChange(change, value);
}
//---------------------------------------------------------------------------------------------------------------------
@ -337,7 +257,7 @@ void VToolSinglePoint::keyReleaseEvent(QKeyEvent *event)
default:
break;
}
QGraphicsEllipseItem::keyReleaseEvent ( event );
VScenePoint::keyReleaseEvent ( event );
}
//---------------------------------------------------------------------------------------------------------------------
@ -366,10 +286,10 @@ void VToolSinglePoint::DoChangePosition(quint32 id, qreal mx, qreal my)
point->setMx(mx);
point->setMy(my);
VAbstractTool::data.UpdateGObject(id, point);
namePoint->blockSignals(true);
namePoint->setPos(QPointF(mx, my));
namePoint->blockSignals(false);
RefreshLine(id);
m_namePoint->blockSignals(true);
m_namePoint->setPos(QPointF(mx, my));
m_namePoint->blockSignals(false);
RefreshLine();
}
//---------------------------------------------------------------------------------------------------------------------
@ -387,18 +307,18 @@ void VToolSinglePoint::AllowSelecting(bool enabled)
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::AllowLabelHover(bool enabled)
{
namePoint->setAcceptHoverEvents(enabled);
m_namePoint->setAcceptHoverEvents(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::AllowLabelSelecting(bool enabled)
{
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
m_namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::ToolSelectionType(const SelectionType &type)
{
VAbstractTool::ToolSelectionType(type);
namePoint->LabelSelectionType(type);
m_namePoint->LabelSelectionType(type);
}

View File

@ -30,7 +30,6 @@
#define VTOOLSINGLEPOINT_H
#include <qcompilerdetection.h>
#include <QGraphicsEllipseItem>
#include <QGraphicsItem>
#include <QMetaObject>
#include <QObject>
@ -41,63 +40,50 @@
#include "../vabstractpoint.h"
#include "../vmisc/def.h"
#include "../vwidgets/vscenepoint.h"
template <class T> class QSharedPointer;
/**
* @brief The VToolSinglePoint class parent for all tools what create points.
*/
class VToolSinglePoint: public VAbstractPoint, public QGraphicsEllipseItem
class VToolSinglePoint: public VAbstractPoint, public VScenePoint
{
Q_OBJECT
public:
VToolSinglePoint(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
virtual ~VToolSinglePoint() Q_DECL_EQ_DEFAULT;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::SinglePoint)};
QString name() const;
void setName(const QString &name);
QString name() const;
void setName(const QString &name);
void SetEnabled(bool enabled);
void SetEnabled(bool enabled);
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
public slots:
void NameChangePosition(const QPointF &pos);
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
void PointChoosed();
void PointSelected(bool selected);
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void DoChangePosition(quint32 id, qreal mx, qreal my) Q_DECL_OVERRIDE;
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
void AllowLabelHover(bool enabled);
void AllowLabelSelecting(bool enabled);
virtual void ToolSelectionType(const SelectionType &type) Q_DECL_OVERRIDE;
void NameChangePosition(const QPointF &pos);
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE;
void PointChoosed();
void PointSelected(bool selected);
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void DoChangePosition(quint32 id, qreal mx, qreal my) Q_DECL_OVERRIDE;
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
void AllowLabelHover(bool enabled);
void AllowLabelSelecting(bool enabled);
virtual void ToolSelectionType(const SelectionType &type) Q_DECL_OVERRIDE;
protected:
/** @brief radius radius circle. */
qreal radius;
/** @brief namePoint point label. */
VGraphicsSimpleTextItem *namePoint;
/** @brief lineName line what we see if label moved too away from point. */
QGraphicsLineItem *lineName;
virtual void UpdateNamePosition(quint32 id) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void RefreshPointGeometry(const VPointF &point);
virtual void RefreshLine(quint32 id) Q_DECL_OVERRIDE;
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void UpdateNamePosition(quint32 id) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolSinglePoint)
};

View File

@ -74,10 +74,6 @@ protected:
virtual void UpdateNamePosition(quint32 id)=0;
virtual void RefreshLine(quint32 id)=0;
template <typename T>
void SetToolEnabled(T *item, const QColor &color, bool enabled);
template <typename T>
static void InitToolConnections(VMainGraphicsScene *scene, T *tool);
@ -111,22 +107,6 @@ void VAbstractPoint::ShowToolVisualization(bool show)
}
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VAbstractPoint::SetToolEnabled(T *item, const QColor &color, bool enabled)
{
item->setEnabled(enabled);
if (enabled)
{
item->setPen(QPen(color,
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
}
else
{
item->setPen(QPen(Qt::gray, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
}
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VAbstractPoint::ChangePosition(T *item, quint32 id, const QPointF &pos)

View File

@ -49,8 +49,6 @@
template <class T> class QSharedPointer;
qreal VDrawTool::factor = 1;
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VDrawTool constructor.
@ -61,8 +59,7 @@ qreal VDrawTool::factor = 1;
VDrawTool::VDrawTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent)
: VInteractiveTool(doc, data, id, parent),
nameActivDraw(doc->GetNameActivPP()),
m_lineType(TypeLineLine),
enabled(true)
m_lineType(TypeLineLine)
{
connect(this->doc, &VAbstractPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw);
connect(this->doc, &VAbstractPattern::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw);
@ -184,19 +181,6 @@ void VDrawTool::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, VDomDocument::AttrId, id);
}
//---------------------------------------------------------------------------------------------------------------------
QColor VDrawTool::CorrectColor(const QColor &color) const
{
if (enabled)
{
return color;
}
else
{
return Qt::gray;
}
}
//---------------------------------------------------------------------------------------------------------------------
bool VDrawTool::CorrectDisable(bool disable, const QString &namePP) const
{
@ -224,16 +208,6 @@ void VDrawTool::ReadAttributes()
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VDrawTool::SetFactor(qreal factor)
{
CheckFactor(VDrawTool::factor, factor);
}
//---------------------------------------------------------------------------------------------------------------------
void VDrawTool::EnableToolMove(bool move)
{

View File

@ -63,9 +63,6 @@ public:
VDrawTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr);
virtual ~VDrawTool() Q_DECL_EQ_DEFAULT;
/** @brief factor scene scale factor. */
static qreal factor;
QString getLineType() const;
virtual void SetTypeLine(const QString &value);
@ -76,7 +73,6 @@ public slots:
virtual void ShowTool(quint32 id, bool enable);
virtual void ChangedActivDraw(const QString &newName);
void ChangedNameDraw(const QString &oldName, const QString &newName);
virtual void SetFactor(qreal factor);
virtual void EnableToolMove(bool move);
virtual void Disable(bool disable, const QString &namePP)=0;
virtual void DetailsMode(bool mode);
@ -91,8 +87,6 @@ protected:
/** @brief typeLine line type. */
QString m_lineType;
bool enabled;
void AddToCalculation(const QDomElement &domElement);
/** @brief SaveDialog save options into file after change in dialog. */
@ -103,7 +97,6 @@ protected:
void SaveOption(QSharedPointer<VGObject> &obj);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
QColor CorrectColor(const QColor &color) const;
bool CorrectDisable(bool disable, const QString &namePP) const;
void ReadAttributes();
@ -247,7 +240,6 @@ void VDrawTool::InitDrawToolConnections(VMainGraphicsScene *scene, T *tool)
QObject::connect(tool, &T::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
QObject::connect(tool, &T::ChangedToolSelection, scene, &VMainGraphicsScene::SelectedItem);
QObject::connect(scene, &VMainGraphicsScene::NewFactor, tool, &T::SetFactor);
QObject::connect(scene, &VMainGraphicsScene::DisableItem, tool, &T::Disable);
QObject::connect(scene, &VMainGraphicsScene::EnableToolMove, tool, &T::EnableToolMove);
QObject::connect(scene, &VMainGraphicsScene::CurveDetailsMode, tool, &T::DetailsMode);

View File

@ -69,8 +69,12 @@ template <class T> class QSharedPointer;
VToolLine::VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint,
const QString &typeLine, const QString &lineColor, const Source &typeCreation,
QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint),
lineColor(lineColor)
:VDrawTool(doc, data, id),
QGraphicsLineItem(parent),
firstPoint(firstPoint),
secondPoint(secondPoint),
lineColor(lineColor),
m_isHovered(false)
{
this->m_lineType = typeLine;
//Line
@ -80,9 +84,6 @@ VToolLine::VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint3
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
this->setAcceptHoverEvents(true);
this->setPen(QPen(CorrectColor(lineColor),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(typeLine)));
ToolCreation(typeCreation);
}
@ -193,6 +194,16 @@ QString VToolLine::getTagName() const
return VAbstractPattern::TagLine;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal width = ScaleWidth(m_isHovered ? widthMainLine : widthHairLine, SceneScale(scene()));
setPen(QPen(CorrectColor(this, lineColor), width, LineStyleToPenStyle(m_lineType)));
QGraphicsLineItem::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolLine::FirstPointName() const
{
@ -227,25 +238,11 @@ void VToolLine::ShowTool(quint32 id, bool enable)
ShowItem(this, id, enable);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolLine::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLine::Disable(bool disable, const QString &namePP)
{
enabled = !CorrectDisable(disable, namePP);
const bool enabled = !CorrectDisable(disable, namePP);
this->setEnabled(enabled);
this->setPen(QPen(CorrectColor(lineColor),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(m_lineType)));
}
//---------------------------------------------------------------------------------------------------------------------
@ -315,10 +312,8 @@ void VToolLine::RefreshDataInFile()
*/
void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
this->setPen(QPen(CorrectColor(lineColor),
qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(m_lineType)));
m_isHovered = true;
QGraphicsLineItem::hoverEnterEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
@ -328,12 +323,10 @@ void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
*/
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
if (vis.isNull())
{
this->setPen(QPen(CorrectColor(lineColor),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor,
LineStyleToPenStyle(m_lineType)));
m_isHovered = false;
QGraphicsLineItem::hoverLeaveEvent(event);
}
}
@ -544,5 +537,4 @@ void VToolLine::RefreshGeometry()
const QSharedPointer<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(firstPoint);
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(secondPoint);
this->setLine(QLineF(static_cast<QPointF>(*first), static_cast<QPointF>(*second)));
this->setPen(QPen(CorrectColor(lineColor), pen().widthF(), LineStyleToPenStyle(m_lineType)));
}

View File

@ -64,6 +64,9 @@ public:
enum { Type = UserType + static_cast<int>(Tool::Line)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
QString FirstPointName() const;
QString SecondPointName() const;
@ -83,7 +86,6 @@ public:
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE;
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
@ -112,6 +114,8 @@ private:
/** @brief lineColor color of a line. */
QString lineColor;
bool m_isHovered;
VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint,
const QString &typeLine, const QString &lineColor, const Source &typeCreation,
QGraphicsItem * parent = nullptr);

View File

@ -62,7 +62,6 @@ VAbstractNode::VAbstractNode(VAbstractPattern *doc, VContainer *data, const quin
parentType(ParentType::Item),
idNode(idNode),
idTool(idTool),
currentColor(Qt::black),
m_drawName(drawName),
m_exluded(false)
{

View File

@ -73,9 +73,6 @@ protected:
/** @brief idTool id tool. */
quint32 idTool;
/** @brief currentColor current tool color. */
QColor currentColor;
QString m_drawName;
bool m_exluded;

View File

@ -71,24 +71,16 @@ const QString VNodePoint::ToolType = QStringLiteral("modeling");
*/
VNodePoint::VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Source &typeCreation,
const QString &drawName, const quint32 &idTool, QObject *qoParent, QGraphicsItem *parent)
:VAbstractNode(doc, data, id, idPoint, drawName, idTool, qoParent), QGraphicsEllipseItem(parent), radius(0),
namePoint(nullptr), lineName(nullptr)
: VAbstractNode(doc, data, id, idPoint, drawName, idTool, qoParent),
VScenePoint(parent)
{
radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm);
namePoint = new VGraphicsSimpleTextItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VNodePoint::PointChoosed);
lineName = new QGraphicsLineItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VNodePoint::NameChangePosition);
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu,
connect(m_namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VNodePoint::PointChoosed);
connect(m_namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VNodePoint::NameChangePosition);
connect(m_namePoint, &VGraphicsSimpleTextItem::ShowContextMenu,
this, [this](QGraphicsSceneContextMenuEvent *event)
{
emit ShowContextMenu(event);
});
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
this->setBrush(QBrush(Qt::NoBrush));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true);
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
ToolCreation(typeCreation);
}
@ -234,28 +226,6 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
QGraphicsEllipseItem::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
this->setPen(QPen(currentColor, qApp->toPixel(WidthMainLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
this->setPen(QPen(currentColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief NameChangePosition label change position.
@ -289,35 +259,6 @@ void VNodePoint::UpdateNamePosition(qreal mx, qreal my)
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshPointGeometry refresh point on scene.
* @param point point position.
*/
void VNodePoint::RefreshPointGeometry(const VPointF &point)
{
QRectF rec = QRectF(0, 0, radius*2, radius*2);
rec.translate(-rec.center().x(), -rec.center().y());
this->setRect(rec);
this->setPos(static_cast<QPointF>(point));
namePoint->blockSignals(true);
namePoint->setText(point.name());
namePoint->setPos(QPointF(point.mx(), point.my()));
namePoint->blockSignals(false);
RefreshLine();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshLine refresh label line on scene.
*/
void VNodePoint::RefreshLine()
{
VAbstractTool::RefreshLine(this, namePoint, lineName, radius);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::ShowNode()
{
@ -336,7 +277,7 @@ void VNodePoint::HideNode()
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::EnableToolMove(bool move)
{
namePoint->setFlag(QGraphicsItem::ItemIsMovable, move);
m_namePoint->setFlag(QGraphicsItem::ItemIsMovable, move);
}
//---------------------------------------------------------------------------------------------------------------------
@ -354,11 +295,11 @@ void VNodePoint::AllowSelecting(bool enabled)
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::AllowLabelHover(bool enabled)
{
namePoint->setAcceptHoverEvents(enabled);
m_namePoint->setAcceptHoverEvents(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::AllowLabelSelecting(bool enabled)
{
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
m_namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}

View File

@ -41,11 +41,12 @@
#include "../ifc/xml/vabstractpattern.h"
#include "../vmisc/def.h"
#include "vabstractnode.h"
#include "../vwidgets/vscenepoint.h"
/**
* @brief The VNodePoint class point detail node.
*/
class VNodePoint: public VAbstractNode, public QGraphicsEllipseItem
class VNodePoint: public VAbstractNode, public VScenePoint
{
Q_OBJECT
public:
@ -75,24 +76,11 @@ public slots:
void AllowLabelHover(bool enabled);
void AllowLabelSelecting(bool enabled);
protected:
/** @brief radius radius circle. */
qreal radius;
/** @brief namePoint label name. */
VGraphicsSimpleTextItem *namePoint;
/** @brief lineName pointer to label line. */
QGraphicsLineItem *lineName;
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void UpdateNamePosition(qreal mx, qreal my);
virtual void RefreshPointGeometry(const VPointF &point);
void RefreshLine();
virtual void ShowNode() Q_DECL_OVERRIDE;
virtual void HideNode() Q_DECL_OVERRIDE;
private:

View File

@ -112,6 +112,25 @@ QString VToolPiecePath::getTagName() const
return VAbstractPattern::TagPath;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPiecePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
qreal width = widthHairLine;
const qreal scale = SceneScale(scene());
if (scale > 1)
{
width = qMax(1., width/scale);
}
QPen toolPen = pen();
toolPen.setWidthF(width);
setPen(toolPen);
QGraphicsPathItem::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPiecePath::incrementReferens()
{

View File

@ -50,6 +50,9 @@ public:
enum { Type = UserType + static_cast<int>(Tool::PiecePath)};
virtual QString getTagName() const Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual void incrementReferens() Q_DECL_OVERRIDE;
virtual void decrementReferens() Q_DECL_OVERRIDE;

View File

@ -121,7 +121,10 @@ quint32 CreateNodeSplinePath(VContainer *data, quint32 id)
* @param parent parent object.
*/
VAbstractTool::VAbstractTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent)
:VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), vis(),
:VDataTool(data, parent),
doc(doc),
id(id),
vis(),
selectionType(SelectionType::ByMouseRelease)
{
SCASSERT(doc != nullptr)
@ -470,43 +473,6 @@ void VAbstractTool::AddNodes(VAbstractPattern *doc, QDomElement &domElement, con
AddNodes(doc, domElement, piece.GetPath());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshLine refresh line to label on scene.
*/
void VAbstractTool::RefreshLine(QGraphicsEllipseItem *point, VGraphicsSimpleTextItem *namePoint,
QGraphicsLineItem *lineName, const qreal radius)
{
SCASSERT(point != nullptr)
SCASSERT(namePoint != nullptr)
SCASSERT(lineName != nullptr)
QRectF nRec = namePoint->sceneBoundingRect();
nRec.translate(- point->scenePos());
if (point->rect().intersects(nRec) == false)
{
const QRectF nameRec = namePoint->sceneBoundingRect();
QPointF p1, p2;
VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center() - point->scenePos()), p1,
p2);
const QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(point->scenePos(), nameRec.center()));
lineName->setLine(QLineF(p1, pRec - point->scenePos()));
if (QLineF(p1, pRec - point->scenePos()).length() <= ToPixel(4, Unit::Mm))
{
lineName->setVisible(false);
}
else
{
lineName->setVisible(true);
}
}
else
{
lineName->setVisible(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagName, const VPieceNode &node)
{

View File

@ -111,9 +111,6 @@ protected:
/** @brief id object id. */
const quint32 id;
/** @brief baseColor base color for tool. */
Qt::GlobalColor baseColor;
QPointer<Visualization> vis;
SelectionType selectionType;
@ -138,9 +135,6 @@ protected:
virtual void SetVisualization()=0;
virtual void ToolCreation(const Source &typeCreation);
static void RefreshLine(QGraphicsEllipseItem *point, VGraphicsSimpleTextItem *namePoint,
QGraphicsLineItem *lineName, const qreal radius);
static QDomElement AddSANode(VAbstractPattern *doc, const QString &tagName, const VPieceNode &node);
static void AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node);
@ -179,7 +173,6 @@ inline void VAbstractTool::AddVisualization()
T *visual = new T(getData());
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
connect(visual, &Visualization::ToolTip, this, &VAbstractTool::ToolTip);

View File

@ -788,6 +788,12 @@ void VToolSeamAllowance::SaveRotateGrainline(qreal dRot, const QPointF& ptPos)
*/
void VToolSeamAllowance::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QPen toolPen = pen();
toolPen.setWidthF(ScaleWidth(widthHairLine, SceneScale(scene())));
setPen(toolPen);
m_seamAllowance->setPen(toolPen);
if ((m_dataLabel->IsIdle() == false
|| m_patternInfo->IsIdle() == false
|| m_grainLine->IsIdle() == false) && not isSelected())
@ -979,22 +985,22 @@ void VToolSeamAllowance::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
if (flags() & QGraphicsItem::ItemIsMovable)
{
SetOverrideCursor(cursorArrowOpenHand, 1, 1);
}
QGraphicsPathItem::hoverEnterEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
//Disable cursor-arrow-openhand
if (flags() & QGraphicsItem::ItemIsMovable)
{
RestoreOverrideCursor(cursorArrowOpenHand);
}
QGraphicsPathItem::hoverLeaveEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -94,6 +94,8 @@ public:
virtual QString getTagName() const Q_DECL_OVERRIDE;
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) Q_DECL_OVERRIDE;
public slots:
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
void EnableToolMove(bool move);
@ -117,8 +119,6 @@ protected slots:
void SaveResizeGrainline(qreal dLength);
void SaveRotateGrainline(qreal dRot, const QPointF& ptPos);
protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) Q_DECL_OVERRIDE;
virtual void AddToFile () Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;

View File

@ -77,7 +77,7 @@ void VisOperation::VisualMode(const quint32 &pointId)
//---------------------------------------------------------------------------------------------------------------------
QGraphicsEllipseItem *VisOperation::GetPoint(quint32 i, const QColor &color)
{
return GetPointItem(Visualization::data, factor, points, i, color, this);
return GetPointItem(points, i, color, this);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -38,11 +38,6 @@ VisToolFlippingByAxis::VisToolFlippingByAxis(const VContainer *data, QGraphicsIt
point1 = InitPoint(supportColor2, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolFlippingByAxis::~VisToolFlippingByAxis()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByAxis::RefreshGeometry()
{
@ -85,3 +80,21 @@ void VisToolFlippingByAxis::SetAxisType(AxisType value)
{
m_axisType = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point1, scale);
VisOperation::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolFlippingByAxis::boundingRect() const
{
QRectF rect = VisOperation::boundingRect();
rect = rect.united(point1->boundingRect());
return rect;
}

View File

@ -39,7 +39,7 @@ class VisToolFlippingByAxis : public VisOperation
Q_OBJECT
public:
explicit VisToolFlippingByAxis(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolFlippingByAxis();
virtual ~VisToolFlippingByAxis() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
@ -48,6 +48,10 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolFlippingByAxis)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolFlippingByAxis)

View File

@ -40,11 +40,6 @@ VisToolFlippingByLine::VisToolFlippingByLine(const VContainer *data, QGraphicsIt
point2 = InitPoint(supportColor2, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolFlippingByLine::~VisToolFlippingByLine()
{
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByLine::RefreshGeometry()
{
@ -77,6 +72,26 @@ void VisToolFlippingByLine::RefreshGeometry()
RefreshFlippedObjects(firstPoint, secondPoint);
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point1, scale);
ScalePoint(point2, scale);
VisOperation::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolFlippingByLine::boundingRect() const
{
QRectF rect = VisOperation::boundingRect();
rect = rect.united(point1->boundingRect());
rect = rect.united(point2->boundingRect());
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolFlippingByLine::SetFirstLinePointId(quint32 value)
{

View File

@ -38,9 +38,12 @@ class VisToolFlippingByLine : public VisOperation
Q_OBJECT
public:
explicit VisToolFlippingByLine(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolFlippingByLine();
virtual ~VisToolFlippingByLine() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
void SetFirstLinePointId(quint32 value);
void SetSecondLinePointId(quint32 value);

View File

@ -128,6 +128,26 @@ void VisToolMove::RefreshGeometry()
CreateMovedObjects(iPoint, iCurve, tempLength, tempAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolMove::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(pointOrigin, scale);
ScalePoint(pointFinish, scale);
VisOperation::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolMove::boundingRect() const
{
QRectF rect = VisOperation::boundingRect();
rect = rect.united(pointOrigin->boundingRect());
rect = rect.united(pointFinish->boundingRect());
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
QString VisToolMove::Angle() const
{

View File

@ -50,7 +50,10 @@ public:
explicit VisToolMove(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolMove();
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
QString Angle() const;
void SetAngle(const QString &expression);

View File

@ -116,7 +116,7 @@ void VisToolRotation::RefreshGeometry()
DrawLine(xAxis, QLineF(static_cast<QPointF>(*origin), Ray(static_cast<QPointF>(*origin), 0)), supportColor2,
Qt::DashLine);
VArc arc(*origin, ToPixel(DefPointRadius/*mm*/*2, Unit::Mm), 0, tempAngle);
VArc arc(*origin, defPointRadiusPixel*2, 0, tempAngle);
DrawPath(angleArc, arc.GetPath(PathDirection::Hide), supportColor2, Qt::SolidLine, Qt::RoundCap);
Visualization::toolTip = tr("Rotating angle = %1°, <b>Shift</b> - sticking angle, "
@ -188,9 +188,30 @@ void VisToolRotation::RefreshGeometry()
}
}
}
QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
void VisToolRotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePenWidth(angleArc, scale);
ScalePenWidth(xAxis, scale);
VisOperation::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolRotation::boundingRect() const
{
QRectF rect = VisOperation::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(angleArc->boundingRect());
rect = rect.united(xAxis->boundingRect());
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolRotation::SetOriginPointId(quint32 value)
{

View File

@ -50,7 +50,10 @@ public:
explicit VisToolRotation(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolRotation();
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
void SetOriginPointId(quint32 value);

View File

@ -47,10 +47,6 @@ VisLine::VisLine(const VContainer *data, QGraphicsItem *parent)
InitPen();
}
//---------------------------------------------------------------------------------------------------------------------
VisLine::~VisLine()
{}
//---------------------------------------------------------------------------------------------------------------------
qreal VisLine::CorrectAngle(const qreal &angle)
{
@ -82,6 +78,14 @@ qreal VisLine::CorrectAngle(const qreal &angle)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VisLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
ScalePenWidth(this, SceneScale(scene()));
QGraphicsLineItem::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const
{
@ -138,8 +142,11 @@ QLineF VisLine::Axis(const QPointF &p1, const QPointF &p2) const
//---------------------------------------------------------------------------------------------------------------------
void VisLine::InitPen()
{
this->setPen(QPen(mainColor, qApp->toPixel(WidthHairLine(*Visualization::data->GetPatternUnit()))/factor,
lineStyle));
QPen visPen = pen();
visPen.setColor(mainColor);
visPen.setStyle(lineStyle);
setPen(visPen);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -48,12 +48,15 @@ class VisLine: public Visualization, public QGraphicsLineItem
{
Q_OBJECT
public:
explicit VisLine(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisLine() Q_DECL_OVERRIDE;
explicit VisLine(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisLine() = default;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::Line)};
static qreal CorrectAngle(const qreal &angle);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
protected:
QPointF Ray(const QPointF &firstPoint, const qreal &angle) const;
QPointF Ray(const QPointF &firstPoint) const;

View File

@ -57,10 +57,6 @@ VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent
point = InitPoint(mainColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolAlongLine::~VisToolAlongLine()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolAlongLine::setObject2Id(const quint32 &value)
{
@ -73,6 +69,30 @@ void VisToolAlongLine::setLength(const QString &expression)
length = FindLength(expression, Visualization::data->PlainVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolAlongLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(lineP1, scale);
ScalePoint(lineP2, scale);
ScalePenWidth(line, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolAlongLine::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(lineP1->boundingRect());
rect = rect.united(lineP2->boundingRect());
rect = rect.united(line->boundingRect());
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolAlongLine::RefreshGeometry()
{

View File

@ -43,14 +43,18 @@ class VisToolAlongLine :public VisLine
{
Q_OBJECT
public:
explicit VisToolAlongLine(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolAlongLine() Q_DECL_OVERRIDE;
explicit VisToolAlongLine(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolAlongLine() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
void setObject2Id(const quint32 &value);
void setLength(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolAlongLine)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolAlongLine)
quint32 object2Id;

View File

@ -76,8 +76,32 @@ void VisToolBisector::setLength(const QString &expression)
}
//---------------------------------------------------------------------------------------------------------------------
VisToolBisector::~VisToolBisector()
{}
void VisToolBisector::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(line1P1, scale);
ScalePoint(line1P2, scale);
ScalePenWidth(line1, scale);
ScalePoint(line2P2, scale);
ScalePenWidth(line2, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolBisector::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(line1P1->boundingRect());
rect = rect.united(line1P2->boundingRect());
rect = rect.united(line1->boundingRect());
rect = rect.united(line2P2->boundingRect());
rect = rect.united(line2->boundingRect());
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolBisector::RefreshGeometry()

View File

@ -43,8 +43,8 @@ class VisToolBisector :public VisLine
{
Q_OBJECT
public:
explicit VisToolBisector(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolBisector() Q_DECL_OVERRIDE;
explicit VisToolBisector(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolBisector() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
void setObject2Id(const quint32 &value);
@ -52,6 +52,10 @@ public:
void setLength(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolBisector)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolBisector)
quint32 object2Id;

View File

@ -60,10 +60,6 @@ VisToolCurveIntersectAxis::VisToolCurveIntersectAxis(const VContainer *data, QGr
point = InitPoint(mainColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolCurveIntersectAxis::~VisToolCurveIntersectAxis()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolCurveIntersectAxis::RefreshGeometry()
{
@ -117,3 +113,29 @@ void VisToolCurveIntersectAxis::setAxisPointId(const quint32 &value)
{
axisPointId = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolCurveIntersectAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(basePoint, scale);
ScalePenWidth(baseLine, scale);
ScalePenWidth(axisLine, scale);
ScalePenWidth(visCurve, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolCurveIntersectAxis::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(basePoint->boundingRect());
rect = rect.united(baseLine->boundingRect());
rect = rect.united(axisLine->boundingRect());
rect = rect.united(visCurve->boundingRect());
return rect;
}

View File

@ -43,8 +43,8 @@ class VisToolCurveIntersectAxis : public VisLine
{
Q_OBJECT
public:
explicit VisToolCurveIntersectAxis(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolCurveIntersectAxis() Q_DECL_OVERRIDE;
explicit VisToolCurveIntersectAxis(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolCurveIntersectAxis() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
@ -54,6 +54,10 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersectAxis)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolCurveIntersectAxis)
quint32 axisPointId;

View File

@ -55,10 +55,6 @@ VisToolEndLine::VisToolEndLine(const VContainer *data, QGraphicsItem *parent)
point = InitPoint(mainColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolEndLine::~VisToolEndLine()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolEndLine::RefreshGeometry()
{
@ -114,3 +110,21 @@ void VisToolEndLine::setLength(const QString &expression)
{
length = FindLength(expression, Visualization::data->PlainVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolEndLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolEndLine::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
return rect;
}

View File

@ -43,8 +43,8 @@ class VisToolEndLine : public VisLine
{
Q_OBJECT
public:
explicit VisToolEndLine(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolEndLine() Q_DECL_OVERRIDE;
explicit VisToolEndLine(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolEndLine() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
@ -56,6 +56,10 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolEndLine)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolEndLine)
qreal length;

View File

@ -56,10 +56,6 @@ VisToolHeight::VisToolHeight(const VContainer *data, QGraphicsItem *parent)
point = InitPoint(mainColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolHeight::~VisToolHeight()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolHeight::RefreshGeometry()
{
@ -116,6 +112,34 @@ void VisToolHeight::setLineP2Id(const quint32 &value)
lineP2Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolHeight::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(base_point, scale);
ScalePoint(lineP1, scale);
ScalePoint(lineP2, scale);
ScalePenWidth(line, scale);
ScalePenWidth(line_intersection, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolHeight::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(base_point->boundingRect());
rect = rect.united(lineP1->boundingRect());
rect = rect.united(lineP2->boundingRect());
rect = rect.united(line->boundingRect());
rect = rect.united(line_intersection->boundingRect());
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolHeight::ShowIntersection(const QLineF &height_line, const QLineF &base_line)
{

View File

@ -44,8 +44,8 @@ class VisToolHeight : public VisLine
{
Q_OBJECT
public:
explicit VisToolHeight(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolHeight() Q_DECL_OVERRIDE;
explicit VisToolHeight(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolHeight() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
@ -53,6 +53,10 @@ public:
void setLineP2Id(const quint32 &value);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolHeight)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolHeight)
//base point in parent class

View File

@ -48,10 +48,6 @@ VisToolLine::VisToolLine(const VContainer *data, QGraphicsItem *parent)
this->mainColor = Qt::red;
}
//---------------------------------------------------------------------------------------------------------------------
VisToolLine::~VisToolLine()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLine::RefreshGeometry()
{
@ -80,6 +76,10 @@ void VisToolLine::DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, cons
{
SCASSERT (lineItem != nullptr)
lineItem->setPen(QPen(color, qApp->toPixel(WidthMainLine(*Visualization::data->GetPatternUnit()))/factor, style));
QPen visPen = lineItem->pen();
visPen.setColor(color);
visPen.setStyle(style);
lineItem->setPen(visPen);
lineItem->setLine(line);
}

View File

@ -46,8 +46,8 @@ class VisToolLine : public VisLine
{
Q_OBJECT
public:
explicit VisToolLine(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolLine() Q_DECL_OVERRIDE;
explicit VisToolLine(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolLine() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
void setPoint2Id(const quint32 &value);

View File

@ -56,10 +56,6 @@ VisToolLineIntersect::VisToolLineIntersect(const VContainer *data, QGraphicsItem
point = InitPoint(mainColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolLineIntersect::~VisToolLineIntersect()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersect::RefreshGeometry()
{
@ -139,3 +135,31 @@ void VisToolLineIntersect::setLine2P2Id(const quint32 &value)
{
line2P2Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersect::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(line1P1, scale);
ScalePoint(line1P2, scale);
ScalePenWidth(line1, scale);
ScalePoint(line2P1, scale);
ScalePoint(line2P2, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolLineIntersect::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(line1P1->boundingRect());
rect = rect.united(line1P2->boundingRect());
rect = rect.united(line1->boundingRect());
rect = rect.united(line2P1->boundingRect());
rect = rect.united(line2P2->boundingRect());
return rect;
}

View File

@ -43,8 +43,8 @@ class VisToolLineIntersect :public VisLine
{
Q_OBJECT
public:
explicit VisToolLineIntersect(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolLineIntersect() Q_DECL_OVERRIDE;
explicit VisToolLineIntersect(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolLineIntersect() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
@ -53,6 +53,10 @@ public:
void setLine2P2Id(const quint32 &value);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersect)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolLineIntersect)
quint32 line1P2Id;

View File

@ -59,10 +59,6 @@ VisToolLineIntersectAxis::VisToolLineIntersectAxis(const VContainer *data, QGrap
point = InitPoint(mainColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolLineIntersectAxis::~VisToolLineIntersectAxis()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::RefreshGeometry()
{
@ -137,6 +133,36 @@ void VisToolLineIntersectAxis::setAxisPointId(const quint32 &value)
axisPointId = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(lineP1, scale);
ScalePoint(lineP2, scale);
ScalePoint(basePoint, scale);
ScalePenWidth(baseLine, scale);
ScalePenWidth(axisLine, scale);
ScalePenWidth(line_intersection, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolLineIntersectAxis::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(lineP1->boundingRect());
rect = rect.united(lineP2->boundingRect());
rect = rect.united(basePoint->boundingRect());
rect = rect.united(baseLine->boundingRect());
rect = rect.united(axisLine->boundingRect());
rect = rect.united(line_intersection->boundingRect());
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolLineIntersectAxis::ShowIntersection(const QLineF &axis_line, const QLineF &base_line)
{

View File

@ -44,8 +44,8 @@ class VisToolLineIntersectAxis : public VisLine
{
Q_OBJECT
public:
explicit VisToolLineIntersectAxis(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolLineIntersectAxis() Q_DECL_OVERRIDE;
explicit VisToolLineIntersectAxis(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolLineIntersectAxis() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
@ -56,6 +56,10 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolLineIntersectAxis)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolLineIntersectAxis)
quint32 point2Id;

View File

@ -57,10 +57,6 @@ VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent)
point = InitPoint(mainColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolNormal::~VisToolNormal()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolNormal::RefreshGeometry()
{
@ -128,3 +124,27 @@ void VisToolNormal::SetAngle(const qreal &value)
{
angle = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolNormal::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(lineP1, scale);
ScalePoint(lineP2, scale);
ScalePenWidth(line, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolNormal::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(lineP1->boundingRect());
rect = rect.united(lineP2->boundingRect());
rect = rect.united(line->boundingRect());
return rect;
}

View File

@ -43,8 +43,8 @@ class VisToolNormal : public VisLine
{
Q_OBJECT
public:
explicit VisToolNormal(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolNormal() Q_DECL_OVERRIDE;
explicit VisToolNormal(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolNormal() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
@ -54,6 +54,10 @@ public:
void SetAngle(const qreal &value);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolNormal)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolNormal)
quint32 object2Id;

View File

@ -38,7 +38,7 @@ VisToolPin::VisToolPin(const VContainer *data, QGraphicsItem *parent)
this->mainColor = Qt::red;
this->setZValue(2);// Show on top real tool
m_point = new VSimplePoint(NULL_ID, mainColor, *Visualization::data->GetPatternUnit(), &factor);
m_point = new VSimplePoint(NULL_ID, mainColor);
m_point->SetPointHighlight(true);
m_point->setParentItem(this);
m_point->SetVisualizationMode(true);
@ -62,7 +62,7 @@ void VisToolPin::RefreshGeometry()
const QSharedPointer<VPointF> point = Visualization::data->GeometricObject<VPointF>(object1Id);
m_point->SetOnlyPoint(mode == Mode::Creation);
m_point->RefreshGeometry(*point);
m_point->RefreshPointGeometry(*point);
m_point->setVisible(true);
}
}

View File

@ -38,7 +38,7 @@ class VisToolPin : public VisLine
Q_OBJECT
public:
explicit VisToolPin(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolPin() Q_DECL_OVERRIDE;
virtual ~VisToolPin();
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual int type() const Q_DECL_OVERRIDE {return Type;}

View File

@ -57,10 +57,6 @@ VisToolPointFromArcAndTangent::VisToolPointFromArcAndTangent(const VContainer *d
tangentLine2 = InitItem<QGraphicsLineItem>(supportColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolPointFromArcAndTangent::~VisToolPointFromArcAndTangent()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromArcAndTangent::RefreshGeometry()
{
@ -95,6 +91,30 @@ void VisToolPointFromArcAndTangent::setCrossPoint(const CrossCirclesPoint &value
crossPoint = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromArcAndTangent::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(tangent, scale);
ScalePenWidth(arcPath, scale);
ScalePenWidth(tangentLine2, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolPointFromArcAndTangent::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(tangent->boundingRect());
rect = rect.united(arcPath->boundingRect());
rect = rect.united(tangentLine2->boundingRect());
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromArcAndTangent::FindRays(const QPointF &p, const VArc *arc)
{

View File

@ -45,8 +45,8 @@ class VisToolPointFromArcAndTangent : public VisLine
{
Q_OBJECT
public:
explicit VisToolPointFromArcAndTangent(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolPointFromArcAndTangent() Q_DECL_OVERRIDE;
explicit VisToolPointFromArcAndTangent(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolPointFromArcAndTangent() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
@ -55,6 +55,10 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromArcAndTangent)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointFromArcAndTangent)
quint32 arcId;

View File

@ -54,10 +54,6 @@ VisToolPointFromCircleAndTangent::VisToolPointFromCircleAndTangent(const VContai
tangent2 = InitItem<QGraphicsLineItem>(supportColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolPointFromCircleAndTangent::~VisToolPointFromCircleAndTangent()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromCircleAndTangent::RefreshGeometry()
{
@ -105,6 +101,32 @@ void VisToolPointFromCircleAndTangent::setCrossPoint(const CrossCirclesPoint &va
crossPoint = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromCircleAndTangent::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(tangent, scale);
ScalePoint(cCenter, scale);
ScalePoint(cPath, scale);
ScalePenWidth(tangent2, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolPointFromCircleAndTangent::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(tangent->boundingRect());
rect = rect.united(cCenter->boundingRect());
rect = rect.united(cPath->boundingRect());
rect = rect.united(tangent2->boundingRect());
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointFromCircleAndTangent::FindRays(const QPointF &p, const QPointF &center, qreal radius)
{

View File

@ -45,8 +45,8 @@ class VisToolPointFromCircleAndTangent : public VisLine
{
Q_OBJECT
public:
explicit VisToolPointFromCircleAndTangent(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolPointFromCircleAndTangent() Q_DECL_OVERRIDE;
explicit VisToolPointFromCircleAndTangent(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolPointFromCircleAndTangent() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
@ -56,6 +56,10 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointFromCircleAndTangent)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointFromCircleAndTangent)
quint32 object2Id;

View File

@ -55,10 +55,6 @@ VisToolPointOfContact::VisToolPointOfContact(const VContainer *data, QGraphicsIt
point = InitPoint(mainColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolPointOfContact::~VisToolPointOfContact()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfContact::RefreshGeometry()
{
@ -118,3 +114,29 @@ void VisToolPointOfContact::setRadius(const QString &expression)
{
radius = FindLength(expression, Visualization::data->PlainVariables());
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfContact::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(lineP1, scale);
ScalePoint(lineP2, scale);
ScalePoint(arc_point, scale);
ScalePoint(circle, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolPointOfContact::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(lineP1->boundingRect());
rect = rect.united(lineP2->boundingRect());
rect = rect.united(arc_point->boundingRect());
rect = rect.united(circle->boundingRect());
return rect;
}

View File

@ -43,8 +43,8 @@ class VisToolPointOfContact : public VisLine
{
Q_OBJECT
public:
explicit VisToolPointOfContact(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolPointOfContact() Q_DECL_OVERRIDE;
explicit VisToolPointOfContact(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolPointOfContact() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
void setLineP2Id(const quint32 &value);
@ -52,6 +52,10 @@ public:
void setRadius(const QString &expression);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfContact)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointOfContact)
quint32 lineP2Id;

View File

@ -53,10 +53,6 @@ VisToolPointOfIntersection::VisToolPointOfIntersection(const VContainer *data, Q
point = InitPoint(mainColor, this);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolPointOfIntersection::~VisToolPointOfIntersection()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersection::RefreshGeometry()
{
@ -97,6 +93,30 @@ void VisToolPointOfIntersection::setPoint2Id(const quint32 &value)
point2Id = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersection::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(axisP1, scale);
ScalePoint(axisP2, scale);
ScalePenWidth(axis2, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolPointOfIntersection::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(axisP1->boundingRect());
rect = rect.united(axisP2->boundingRect());
rect = rect.united(axis2->boundingRect());
return rect;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersection::ShowIntersection(const QLineF &axis1, const QLineF &axis2, const QColor &color)
{

View File

@ -45,14 +45,18 @@ class VisToolPointOfIntersection : public VisLine
{
Q_OBJECT
public:
explicit VisToolPointOfIntersection(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolPointOfIntersection() Q_DECL_OVERRIDE;
explicit VisToolPointOfIntersection(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolPointOfIntersection() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
void setPoint2Id(const quint32 &value);
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersection)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointOfIntersection)
quint32 point2Id;

View File

@ -65,10 +65,6 @@ VisToolPointOfIntersectionArcs::VisToolPointOfIntersectionArcs(const VContainer
point->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
}
//---------------------------------------------------------------------------------------------------------------------
VisToolPointOfIntersectionArcs::~VisToolPointOfIntersectionArcs()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionArcs::RefreshGeometry()
{
@ -118,3 +114,25 @@ void VisToolPointOfIntersectionArcs::setCrossPoint(const CrossCirclesPoint &valu
{
crossPoint = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionArcs::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePenWidth(arc1Path, scale);
ScalePenWidth(arc2Path, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolPointOfIntersectionArcs::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(arc1Path->boundingRect());
rect = rect.united(arc2Path->boundingRect());
return rect;
}

View File

@ -44,8 +44,8 @@ class VisToolPointOfIntersectionArcs : public VisLine
{
Q_OBJECT
public:
explicit VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolPointOfIntersectionArcs() Q_DECL_OVERRIDE;
explicit VisToolPointOfIntersectionArcs(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolPointOfIntersectionArcs() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void VisualMode(const quint32 &id) Q_DECL_OVERRIDE;
@ -56,6 +56,10 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionArcs)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointOfIntersectionArcs)
quint32 arc1Id;

View File

@ -59,10 +59,6 @@ VisToolPointOfIntersectionCircles::VisToolPointOfIntersectionCircles(const VCont
c2Center = InitPoint(supportColor, this); //-V656
}
//---------------------------------------------------------------------------------------------------------------------
VisToolPointOfIntersectionCircles::~VisToolPointOfIntersectionCircles()
{}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionCircles::RefreshGeometry()
{
@ -129,3 +125,30 @@ void VisToolPointOfIntersectionCircles::setCrossPoint(const CrossCirclesPoint &v
{
crossPoint = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolPointOfIntersectionCircles::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
const qreal scale = SceneScale(scene());
ScalePoint(point, scale);
ScalePoint(c1Center, scale);
ScalePoint(c2Center, scale);
ScalePoint(c1Path, scale);
ScalePoint(c2Path, scale);
VisLine::paint(painter, option, widget);
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VisToolPointOfIntersectionCircles::boundingRect() const
{
QRectF rect = VisLine::boundingRect();
rect = rect.united(point->boundingRect());
rect = rect.united(c1Center->boundingRect());
rect = rect.united(c2Center->boundingRect());
rect = rect.united(c1Path->boundingRect());
rect = rect.united(c2Path->boundingRect());
return rect;
}

View File

@ -44,8 +44,8 @@ class VisToolPointOfIntersectionCircles : public VisLine
{
Q_OBJECT
public:
explicit VisToolPointOfIntersectionCircles(const VContainer *data, QGraphicsItem *parent = 0);
virtual ~VisToolPointOfIntersectionCircles() Q_DECL_OVERRIDE;
explicit VisToolPointOfIntersectionCircles(const VContainer *data, QGraphicsItem *parent = nullptr);
virtual ~VisToolPointOfIntersectionCircles() = default;
virtual void RefreshGeometry() Q_DECL_OVERRIDE;
virtual void VisualMode(const quint32 &id) Q_DECL_OVERRIDE;
@ -57,6 +57,10 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::ToolPointOfIntersectionCircles)};
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) Q_DECL_OVERRIDE;
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VisToolPointOfIntersectionCircles)
quint32 object2Id;

Some files were not shown because too many files have changed in this diff Show More