Fixed tools Spline and Spline Path. For their work need section by mouse press

event, all other better work with mouse release event.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-03-31 20:10:20 +03:00
parent 351f01e0e3
commit 9f5fd98865
16 changed files with 158 additions and 34 deletions

View file

@ -301,6 +301,7 @@ void MainWindow::InitScenes()
currentScene = sceneDraw;
qApp->setCurrentScene(currentScene);
connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove);
connect(this, &MainWindow::ItemsSelection, sceneDraw, &VMainGraphicsScene::ItemsSelection);
connect(this, &MainWindow::EnableLabelSelection, sceneDraw, &VMainGraphicsScene::ToggleLabelSelection);
connect(this, &MainWindow::EnablePointSelection, sceneDraw, &VMainGraphicsScene::TogglePointSelection);
@ -706,7 +707,7 @@ void MainWindow::ApplyDialog()
*/
void MainWindow::ToolEndLine(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogEndLine>(checked, Tool::EndLine, ":/cursor/endline_cursor.png", tr("Select point"),
&MainWindow::ClosedDialogWithApply<VToolEndLine>,
&MainWindow::ApplyDialog<VToolEndLine>);
@ -719,7 +720,7 @@ void MainWindow::ToolEndLine(bool checked)
*/
void MainWindow::ToolLine(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogLine>(checked, Tool::Line, ":/cursor/line_cursor.png", tr("Select first point"),
&MainWindow::ClosedDialogWithApply<VToolLine>,
&MainWindow::ApplyDialog<VToolLine>);
@ -732,7 +733,7 @@ void MainWindow::ToolLine(bool checked)
*/
void MainWindow::ToolAlongLine(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogAlongLine>(checked, Tool::AlongLine, ":/cursor/alongline_cursor.png",
tr("Select point"), &MainWindow::ClosedDialogWithApply<VToolAlongLine>,
&MainWindow::ApplyDialog<VToolAlongLine>);
@ -745,7 +746,7 @@ void MainWindow::ToolAlongLine(bool checked)
*/
void MainWindow::ToolShoulderPoint(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogShoulderPoint>(checked, Tool::ShoulderPoint, ":/cursor/shoulder_cursor.png",
tr("Select point"),
&MainWindow::ClosedDialogWithApply<VToolShoulderPoint>,
@ -759,7 +760,7 @@ void MainWindow::ToolShoulderPoint(bool checked)
*/
void MainWindow::ToolNormal(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogNormal>(checked, Tool::Normal, ":/cursor/normal_cursor.png",
tr("Select first point of line"),
&MainWindow::ClosedDialogWithApply<VToolNormal>,
@ -773,7 +774,7 @@ void MainWindow::ToolNormal(bool checked)
*/
void MainWindow::ToolBisector(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogBisector>(checked, Tool::Bisector, ":/cursor/bisector_cursor.png",
tr("Select first point of angle"),
&MainWindow::ClosedDialogWithApply<VToolBisector>,
@ -787,7 +788,7 @@ void MainWindow::ToolBisector(bool checked)
*/
void MainWindow::ToolLineIntersect(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogLineIntersect>(checked, Tool::LineIntersect, ":/cursor/intersect_cursor.png",
tr("Select first point of first line"),
&MainWindow::ClosedDialogWithApply<VToolLineIntersect>,
@ -801,7 +802,7 @@ void MainWindow::ToolLineIntersect(bool checked)
*/
void MainWindow::ToolSpline(bool checked)
{
ToolSelectPoint();
ToolSelectPointByPress();
SetToolButtonWithApply<DialogSpline>(checked, Tool::Spline, ":/cursor/spline_cursor.png",
tr("Select first point curve"),
&MainWindow::ClosedDialogWithApply<VToolSpline>,
@ -811,7 +812,7 @@ void MainWindow::ToolSpline(bool checked)
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolCubicBezier(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogCubicBezier>(checked, Tool::CubicBezier, ":/cursor/cubic_bezier_cursor.png",
tr("Select first curve point"),
&MainWindow::ClosedDialogWithApply<VToolCubicBezier>,
@ -839,7 +840,7 @@ void MainWindow::ToolCutSpline(bool checked)
*/
void MainWindow::ToolArc(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogArc>(checked, Tool::Arc, ":/cursor/arc_cursor.png",
tr("Select point of center of arc"), &MainWindow::ClosedDialogWithApply<VToolArc>,
&MainWindow::ApplyDialog<VToolArc>);
@ -852,7 +853,7 @@ void MainWindow::ToolArc(bool checked)
*/
void MainWindow::ToolSplinePath(bool checked)
{
ToolSelectPoint();
ToolSelectPointByPress();
SetToolButtonWithApply<DialogSplinePath>(checked, Tool::SplinePath, ":/cursor/splinepath_cursor.png",
tr("Select point of curve path"),
&MainWindow::ClosedDialogWithApply<VToolSplinePath>,
@ -862,7 +863,7 @@ void MainWindow::ToolSplinePath(bool checked)
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolCubicBezierPath(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogCubicBezierPath>(checked, Tool::CubicBezierPath,
":/cursor/cubic_bezier_path_cursor.png",
tr("Select point of cubic bezier path"),
@ -891,7 +892,7 @@ void MainWindow::ToolCutSplinePath(bool checked)
*/
void MainWindow::ToolPointOfContact(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogPointOfContact>(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png",
tr("Select first point of line"),
&MainWindow::ClosedDialogWithApply<VToolPointOfContact>,
@ -932,7 +933,7 @@ void MainWindow::ClosedDialogDetail(int result)
*/
void MainWindow::ToolHeight(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogHeight>(checked, Tool::Height, ":/cursor/height_cursor.png", tr("Select base point"),
&MainWindow::ClosedDialogWithApply<VToolHeight>,
&MainWindow::ApplyDialog<VToolHeight>);
@ -945,7 +946,7 @@ void MainWindow::ToolHeight(bool checked)
*/
void MainWindow::ToolTriangle(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogTriangle>(checked, Tool::Triangle, ":/cursor/triangle_cursor.png",
tr("Select first point of axis"),
&MainWindow::ClosedDialogWithApply<VToolTriangle>,
@ -959,7 +960,7 @@ void MainWindow::ToolTriangle(bool checked)
*/
void MainWindow::ToolPointOfIntersection(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogPointOfIntersection>(checked, Tool::PointOfIntersection,
":/cursor/pointofintersect_cursor.png",
tr("Select point for X value (vertical)"),
@ -1006,7 +1007,7 @@ void MainWindow::ToolCutArc(bool checked)
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolLineIntersectAxis(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogLineIntersectAxis>(checked, Tool::LineIntersectAxis,
":/cursor/line_intersect_axis_cursor.png",
tr("Select first point of line"),
@ -1051,7 +1052,7 @@ void MainWindow::ToolPointOfIntersectionArcs(bool checked)
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolPointOfIntersectionCircles(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogPointOfIntersectionCircles>(checked, Tool::PointOfIntersectionCircles,
"://cursor/point_of_intersection_circles.png",
tr("Select first circle center "),
@ -1073,7 +1074,7 @@ void MainWindow::ToolPointOfIntersectionCurves(bool checked)
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolPointFromCircleAndTangent(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogPointFromCircleAndTangent>(checked, Tool::PointFromCircleAndTangent,
"://cursor/point_from_circle_and_tangent_cursor.png",
tr("Select point on tangent "),
@ -1095,7 +1096,7 @@ void MainWindow::ToolPointFromArcAndTangent(bool checked)
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolArcWithLength(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogArcWithLength>(checked, Tool::ArcWithLength,
"://cursor/arc_with_length_cursor.png",
tr("Select point of the center of the arc"),
@ -1106,7 +1107,7 @@ void MainWindow::ToolArcWithLength(bool checked)
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolTrueDarts(bool checked)
{
ToolSelectPoint();
ToolSelectPointByRelease();
SetToolButtonWithApply<DialogTrueDarts>(checked, Tool::TrueDarts,
"://cursor/true_darts_cursor.png",
tr("Select the first base line point"),
@ -1889,6 +1890,7 @@ void MainWindow::ArrowTool()
ui->actionStopTool->setEnabled(false);
currentTool = Tool::Arrow;
emit EnableItemMove(true);
emit ItemsSelection(SelectionType::ByMouseRelease);
// Only true for rubber band selection
emit EnableLabelSelection(true);
@ -4500,6 +4502,20 @@ void MainWindow::ToolSelectPoint() const
ui->view->AllowRubberBand(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectPointByRelease() const
{
ToolSelectPoint();
emit ItemsSelection(SelectionType::ByMouseRelease);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectPointByPress() const
{
ToolSelectPoint();
emit ItemsSelection(SelectionType::ByMousePress);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectSpline() const
{
@ -4518,6 +4534,8 @@ void MainWindow::ToolSelectSpline() const
emit EnableSplineHover(true);
emit EnableSplinePathHover(false);
emit ItemsSelection(SelectionType::ByMouseRelease);
ui->view->AllowRubberBand(false);
}
@ -4539,6 +4557,8 @@ void MainWindow::ToolSelectSplinePath() const
emit EnableSplineHover(false);
emit EnableSplinePathHover(true);
emit ItemsSelection(SelectionType::ByMouseRelease);
ui->view->AllowRubberBand(false);
}
@ -4560,6 +4580,8 @@ void MainWindow::ToolSelectArc() const
emit EnableSplineHover(false);
emit EnableSplinePathHover(false);
emit ItemsSelection(SelectionType::ByMouseRelease);
ui->view->AllowRubberBand(false);
}
@ -4581,6 +4603,8 @@ void MainWindow::ToolSelectPointArc() const
emit EnableSplineHover(false);
emit EnableSplinePathHover(false);
emit ItemsSelection(SelectionType::ByMouseRelease);
ui->view->AllowRubberBand(false);
}
@ -4602,6 +4626,8 @@ void MainWindow::ToolSelectCurve() const
emit EnableSplineHover(true);
emit EnableSplinePathHover(true);
emit ItemsSelection(SelectionType::ByMouseRelease);
ui->view->AllowRubberBand(false);
}
@ -4623,6 +4649,8 @@ void MainWindow::ToolSelectAllObjects() const
emit EnableSplineHover(true);
emit EnableSplinePathHover(true);
emit ItemsSelection(SelectionType::ByMouseRelease);
ui->view->AllowRubberBand(false);
}
@ -4639,5 +4667,7 @@ void MainWindow::ToolSelectDetail() const
emit EnableNodePointHover(true);
emit EnableDetailHover(true);
emit ItemsSelection(SelectionType::ByMouseRelease);
ui->view->AllowRubberBand(false);
}

View file

@ -157,6 +157,7 @@ public slots:
signals:
void RefreshHistory();
void EnableItemMove(bool move);
void ItemsSelection(SelectionType type) const;
void EnableLabelSelection(bool enable) const;
void EnablePointSelection(bool enable) const;
@ -352,6 +353,8 @@ private:
bool IgnoreLocking(int error, const QString &path);
void ToolSelectPoint() const;
void ToolSelectPointByPress() const;
void ToolSelectPointByRelease() const;
void ToolSelectSpline() const;
void ToolSelectSplinePath() const;
void ToolSelectArc() const;

View file

@ -55,6 +55,7 @@ enum class MeasurementsType : char { Standard, Individual , Unknown};
enum class Unit : char { Mm = 0, Cm, Inch, Px, LAST_UNIT_DO_NOT_USE};
enum class Source : char { FromGui, FromFile, FromTool };
enum class NodeUsage : bool {NotInUse = false, InUse = true};
enum class SelectionType : bool {ByMousePress, ByMouseRelease};
typedef unsigned char ToolVisHolderType;
enum class Tool : ToolVisHolderType

View file

@ -215,6 +215,14 @@ void VToolDoublePoint::AllowLabelSelecting(bool enabled)
secondPoint->AllowLabelSelecting(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::ToolSelectionType(const SelectionType &type)
{
VAbstractTool::ToolSelectionType(type);
firstPoint->ToolSelectionType(type);
secondPoint->ToolSelectionType(type);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::UpdateNamePosition(quint32 id)
{

View file

@ -73,6 +73,7 @@ public slots:
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:
VSimplePoint *firstPoint;

View file

@ -136,7 +136,17 @@ void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
// Special for not selectable item first need to call standard mousePressEvent then accept event
QGraphicsEllipseItem::mousePressEvent(event);
event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event
if (selectionType == SelectionType::ByMouseRelease)
{
event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event
}
else
{
if (event->button() == Qt::LeftButton)
{
PointChoosed();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -188,9 +198,12 @@ void VToolSinglePoint::FullUpdateFromFile()
*/
void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
if (selectionType == SelectionType::ByMouseRelease)
{
PointChoosed();
if (event->button() == Qt::LeftButton)
{
PointChoosed();
}
}
QGraphicsEllipseItem::mouseReleaseEvent(event);
}
@ -365,3 +378,10 @@ void VToolSinglePoint::AllowLabelSelecting(bool enabled)
{
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::ToolSelectionType(const SelectionType &type)
{
VAbstractTool::ToolSelectionType(type);
namePoint->LabelSelectionType(type);
}

View file

@ -67,6 +67,7 @@ public slots:
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;

View file

@ -242,6 +242,7 @@ void VDrawTool::InitDrawToolConnections(VMainGraphicsScene *scene, T *tool)
QObject::connect(scene, &VMainGraphicsScene::DisableItem, tool, &T::Disable);
QObject::connect(scene, &VMainGraphicsScene::EnableToolMove, tool, &T::EnableToolMove);
QObject::connect(scene, &VMainGraphicsScene::CurveDetailsMode, tool, &T::DetailsMode);
QObject::connect(scene, &VMainGraphicsScene::ItemSelection, tool, &T::ToolSelectionType);
}
#endif // VDRAWTOOL_H

View file

@ -52,7 +52,8 @@ const QString VAbstractTool::AttrInUse = QStringLiteral("inUse");
* @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(nullptr)
:VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), vis(nullptr),
selectionType(SelectionType::ByMouseRelease)
{
SCASSERT(doc != nullptr);
connect(this, &VAbstractTool::toolhaveChange, this->doc, &VAbstractPattern::haveLiteChange);
@ -256,6 +257,12 @@ QMap<QString, quint32> VAbstractTool::PointsList() const
return list;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractTool::ToolSelectionType(const SelectionType &type)
{
selectionType = type;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractTool::ToolCreation(const Source &typeCreation)
{

View file

@ -79,6 +79,7 @@ public slots:
virtual void FullUpdateFromFile()=0;
virtual void AllowHover(bool enabled)=0;
virtual void AllowSelecting(bool enabled)=0;
virtual void ToolSelectionType(const SelectionType &type);
signals:
/**
* @brief toolhaveChange emit if tool create change that need save.
@ -105,6 +106,7 @@ protected:
Qt::GlobalColor baseColor;
Visualization *vis;
SelectionType selectionType;
/**
* @brief AddToFile add tag with informations about tool into file.

View file

@ -45,7 +45,7 @@
* @param parent parent object.
*/
VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent)
:QGraphicsSimpleTextItem(parent), fontSize(0)
:QGraphicsSimpleTextItem(parent), fontSize(0), selectionType(SelectionType::ByMouseRelease)
{
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -64,7 +64,7 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent)
* @param parent parent object.
*/
VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent )
:QGraphicsSimpleTextItem(text, parent), fontSize(0)
:QGraphicsSimpleTextItem(text, parent), fontSize(0), selectionType(SelectionType::ByMouseRelease)
{
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -94,6 +94,12 @@ void VGraphicsSimpleTextItem::setEnabled(bool enabled)
}
}
//---------------------------------------------------------------------------------------------------------------------
void VGraphicsSimpleTextItem::LabelSelectionType(const SelectionType &type)
{
selectionType = type;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange handle item change.
@ -203,7 +209,14 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
SetOverrideCursor(cursorArrowCloseHand, 1, 1);
}
}
event->accept(); // This help for not selectable items still receive mouseReleaseEvent events
if (selectionType == SelectionType::ByMouseRelease)
{
event->accept(); // This help for not selectable items still receive mouseReleaseEvent events
}
else
{
emit PointChoosed();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -218,7 +231,10 @@ void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
}
emit PointChoosed();
if (selectionType == SelectionType::ByMouseRelease)
{
emit PointChoosed();
}
QGraphicsSimpleTextItem::mouseReleaseEvent(event);
}

View file

@ -49,6 +49,7 @@ public:
enum { Type = UserType + static_cast<int>(Vis::GraphicsSimpleTextItem)};
void setEnabled(bool enabled);
void LabelSelectionType(const SelectionType &type);
signals:
/**
* @brief NameChangePosition emit when label change position.
@ -72,7 +73,8 @@ protected:
virtual void keyReleaseEvent ( QKeyEvent * event ) Q_DECL_OVERRIDE;
private:
/** @brief fontSize label font size. */
qint32 fontSize;
qint32 fontSize;
SelectionType selectionType;
};
//---------------------------------------------------------------------------------------------------------------------

View file

@ -281,6 +281,12 @@ void VMainGraphicsScene::EnableDetailsMode(bool mode)
emit CurveDetailsMode(mode);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ItemsSelection(const SelectionType &type)
{
emit ItemSelection(type);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleLabelSelection(bool enabled)
{

View file

@ -58,6 +58,7 @@ public slots:
void SetFactor(qreal factor);
void EnableItemMove(bool move);
void EnableDetailsMode(bool mode);
void ItemsSelection(const SelectionType &type);
void ToggleLabelSelection(bool enabled);
void TogglePointSelection(bool enabled);
@ -105,6 +106,7 @@ signals:
void DisableItem(bool disable, const QString &namePP);
void EnableToolMove(bool move);
void CurveDetailsMode(bool mode);
void ItemSelection(const SelectionType &type);
void EnableLabelItemSelection(bool enable);
void EnablePointItemSelection(bool enable);

View file

@ -39,7 +39,8 @@
//---------------------------------------------------------------------------------------------------------------------
VSimplePoint::VSimplePoint(quint32 id, const QColor &currentColor, Unit patternUnit, qreal *factor, QObject *parent)
:VAbstractSimple(id, currentColor, patternUnit, factor, parent), QGraphicsEllipseItem(),
radius(ToPixel(DefPointRadius/*mm*/, Unit::Mm)), namePoint(nullptr), lineName(nullptr)
radius(ToPixel(DefPointRadius/*mm*/, Unit::Mm)), namePoint(nullptr), lineName(nullptr),
selectionType(SelectionType::ByMouseRelease)
{
namePoint = new VGraphicsSimpleTextItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VSimplePoint::ContextMenu);
@ -158,6 +159,13 @@ void VSimplePoint::AllowLabelSelecting(bool enabled)
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VSimplePoint::ToolSelectionType(const SelectionType &type)
{
selectionType = type;
namePoint->LabelSelectionType(type);
}
//---------------------------------------------------------------------------------------------------------------------
void VSimplePoint::DeleteFromLabel()
{
@ -187,15 +195,28 @@ void VSimplePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
// Special for not selectable item first need to call standard mousePressEvent then accept event
QGraphicsEllipseItem::mousePressEvent(event);
event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event
if (selectionType == SelectionType::ByMouseRelease)
{
event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event
}
else
{
if (event->button() == Qt::LeftButton)
{
emit Choosed(id);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VSimplePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
if (selectionType == SelectionType::ByMouseRelease)
{
emit Choosed(id);
if (event->button() == Qt::LeftButton)
{
emit Choosed(id);
}
}
QGraphicsEllipseItem::mouseReleaseEvent(event);
}

View file

@ -57,6 +57,7 @@ public:
void EnableToolMove(bool move);
void AllowLabelHover(bool enabled);
void AllowLabelSelecting(bool enabled);
void ToolSelectionType(const SelectionType &type);
QColor GetCurrentColor() const;
void SetCurrentColor(const QColor &value);
@ -94,6 +95,8 @@ private:
/** @brief lineName line what we see if label moved too away from point. */
QGraphicsLineItem *lineName;
SelectionType selectionType;
};
#endif // VSIMPLEPOINT_H