Disable hover and selection when work with a tool.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-03-31 17:01:41 +03:00
parent 254ccf8f52
commit 351f01e0e3
63 changed files with 845 additions and 168 deletions

View File

@ -242,18 +242,11 @@ void MainWindow::AddPP(const QString &PPName)
ui->view->itemClicked(nullptr);//hide options previous tool ui->view->itemClicked(nullptr);//hide options previous tool
const QString label = doc->GenerateLabel(LabelType::NewPatternPiece); const QString label = doc->GenerateLabel(LabelType::NewPatternPiece);
const QPointF startPosition = StartPositionNewPP(); const QPointF startPosition = StartPositionNewPP();
const quint32 id = pattern->AddGObject(new VPointF(startPosition.x(), startPosition.y(), label, 5, 10)); VPointF *point = new VPointF(startPosition.x(), startPosition.y(), label, 5, 10);
VToolBasePoint *spoint = new VToolBasePoint(doc, pattern, id, Source::FromGui, PPName); auto spoint = VToolBasePoint::Create(0, PPName, point, sceneDraw, doc, pattern, Document::FullParse,
sceneDraw->addItem(spoint); Source::FromGui);
ui->view->itemClicked(spoint); ui->view->itemClicked(spoint);
connect(spoint, &VToolSinglePoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
connect(sceneDraw, &VMainGraphicsScene::DisableItem, spoint, &VToolBasePoint::Disable);
connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolBasePoint::SetFactor);
connect(sceneDraw, &VMainGraphicsScene::EnableToolMove, spoint, &VToolBasePoint::EnableToolMove);
doc->AddTool(id, spoint);
VDrawTool::AddRecord(id, Tool::BasePoint, doc);
SetEnableTool(true); SetEnableTool(true);
SetEnableWidgets(true); SetEnableWidgets(true);
@ -308,9 +301,33 @@ void MainWindow::InitScenes()
currentScene = sceneDraw; currentScene = sceneDraw;
qApp->setCurrentScene(currentScene); qApp->setCurrentScene(currentScene);
connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove); connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove);
connect(this, &MainWindow::EnableLabelSelection, sceneDraw, &VMainGraphicsScene::ToggleLabelSelection);
connect(this, &MainWindow::EnablePointSelection, sceneDraw, &VMainGraphicsScene::TogglePointSelection);
connect(this, &MainWindow::EnableArcSelection, sceneDraw, &VMainGraphicsScene::ToggleArcSelection);
connect(this, &MainWindow::EnableSplineSelection, sceneDraw, &VMainGraphicsScene::ToggleSplineSelection);
connect(this, &MainWindow::EnableSplinePathSelection, sceneDraw, &VMainGraphicsScene::ToggleSplinePathSelection);
connect(this, &MainWindow::EnableLabelHover, sceneDraw, &VMainGraphicsScene::ToggleLabelHover);
connect(this, &MainWindow::EnablePointHover, sceneDraw, &VMainGraphicsScene::TogglePointHover);
connect(this, &MainWindow::EnableLineHover, sceneDraw, &VMainGraphicsScene::ToggleLineHover);
connect(this, &MainWindow::EnableArcHover, sceneDraw, &VMainGraphicsScene::ToggleArcHover);
connect(this, &MainWindow::EnableSplineHover, sceneDraw, &VMainGraphicsScene::ToggleSplineHover);
connect(this, &MainWindow::EnableSplinePathHover, sceneDraw, &VMainGraphicsScene::ToggleSplinePathHover);
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
sceneDetails = new VMainGraphicsScene(); sceneDetails = new VMainGraphicsScene();
connect(this, &MainWindow::EnableItemMove, sceneDetails, &VMainGraphicsScene::EnableItemMove); connect(this, &MainWindow::EnableItemMove, sceneDetails, &VMainGraphicsScene::EnableItemMove);
connect(this, &MainWindow::EnableNodeLabelSelection, sceneDetails, &VMainGraphicsScene::ToggleNodeLabelSelection);
connect(this, &MainWindow::EnableNodePointSelection, sceneDetails, &VMainGraphicsScene::ToggleNodePointSelection);
connect(this, &MainWindow::EnableDetailSelection, sceneDetails, &VMainGraphicsScene::ToggleDetailSelection);
connect(this, &MainWindow::EnableNodeLabelHover, sceneDetails, &VMainGraphicsScene::ToggleNodeLabelHover);
connect(this, &MainWindow::EnableNodePointHover, sceneDetails, &VMainGraphicsScene::ToggleNodePointHover);
connect(this, &MainWindow::EnableDetailHover, sceneDetails, &VMainGraphicsScene::ToggleDetailHover);
connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
ui->view->setScene(currentScene); ui->view->setScene(currentScene);
@ -689,6 +706,7 @@ void MainWindow::ApplyDialog()
*/ */
void MainWindow::ToolEndLine(bool checked) void MainWindow::ToolEndLine(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogEndLine>(checked, Tool::EndLine, ":/cursor/endline_cursor.png", tr("Select point"), SetToolButtonWithApply<DialogEndLine>(checked, Tool::EndLine, ":/cursor/endline_cursor.png", tr("Select point"),
&MainWindow::ClosedDialogWithApply<VToolEndLine>, &MainWindow::ClosedDialogWithApply<VToolEndLine>,
&MainWindow::ApplyDialog<VToolEndLine>); &MainWindow::ApplyDialog<VToolEndLine>);
@ -701,6 +719,7 @@ void MainWindow::ToolEndLine(bool checked)
*/ */
void MainWindow::ToolLine(bool checked) void MainWindow::ToolLine(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogLine>(checked, Tool::Line, ":/cursor/line_cursor.png", tr("Select first point"), SetToolButtonWithApply<DialogLine>(checked, Tool::Line, ":/cursor/line_cursor.png", tr("Select first point"),
&MainWindow::ClosedDialogWithApply<VToolLine>, &MainWindow::ClosedDialogWithApply<VToolLine>,
&MainWindow::ApplyDialog<VToolLine>); &MainWindow::ApplyDialog<VToolLine>);
@ -713,6 +732,7 @@ void MainWindow::ToolLine(bool checked)
*/ */
void MainWindow::ToolAlongLine(bool checked) void MainWindow::ToolAlongLine(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogAlongLine>(checked, Tool::AlongLine, ":/cursor/alongline_cursor.png", SetToolButtonWithApply<DialogAlongLine>(checked, Tool::AlongLine, ":/cursor/alongline_cursor.png",
tr("Select point"), &MainWindow::ClosedDialogWithApply<VToolAlongLine>, tr("Select point"), &MainWindow::ClosedDialogWithApply<VToolAlongLine>,
&MainWindow::ApplyDialog<VToolAlongLine>); &MainWindow::ApplyDialog<VToolAlongLine>);
@ -725,6 +745,7 @@ void MainWindow::ToolAlongLine(bool checked)
*/ */
void MainWindow::ToolShoulderPoint(bool checked) void MainWindow::ToolShoulderPoint(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogShoulderPoint>(checked, Tool::ShoulderPoint, ":/cursor/shoulder_cursor.png", SetToolButtonWithApply<DialogShoulderPoint>(checked, Tool::ShoulderPoint, ":/cursor/shoulder_cursor.png",
tr("Select point"), tr("Select point"),
&MainWindow::ClosedDialogWithApply<VToolShoulderPoint>, &MainWindow::ClosedDialogWithApply<VToolShoulderPoint>,
@ -738,6 +759,7 @@ void MainWindow::ToolShoulderPoint(bool checked)
*/ */
void MainWindow::ToolNormal(bool checked) void MainWindow::ToolNormal(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogNormal>(checked, Tool::Normal, ":/cursor/normal_cursor.png", SetToolButtonWithApply<DialogNormal>(checked, Tool::Normal, ":/cursor/normal_cursor.png",
tr("Select first point of line"), tr("Select first point of line"),
&MainWindow::ClosedDialogWithApply<VToolNormal>, &MainWindow::ClosedDialogWithApply<VToolNormal>,
@ -751,6 +773,7 @@ void MainWindow::ToolNormal(bool checked)
*/ */
void MainWindow::ToolBisector(bool checked) void MainWindow::ToolBisector(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogBisector>(checked, Tool::Bisector, ":/cursor/bisector_cursor.png", SetToolButtonWithApply<DialogBisector>(checked, Tool::Bisector, ":/cursor/bisector_cursor.png",
tr("Select first point of angle"), tr("Select first point of angle"),
&MainWindow::ClosedDialogWithApply<VToolBisector>, &MainWindow::ClosedDialogWithApply<VToolBisector>,
@ -764,6 +787,7 @@ void MainWindow::ToolBisector(bool checked)
*/ */
void MainWindow::ToolLineIntersect(bool checked) void MainWindow::ToolLineIntersect(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogLineIntersect>(checked, Tool::LineIntersect, ":/cursor/intersect_cursor.png", SetToolButtonWithApply<DialogLineIntersect>(checked, Tool::LineIntersect, ":/cursor/intersect_cursor.png",
tr("Select first point of first line"), tr("Select first point of first line"),
&MainWindow::ClosedDialogWithApply<VToolLineIntersect>, &MainWindow::ClosedDialogWithApply<VToolLineIntersect>,
@ -777,6 +801,7 @@ void MainWindow::ToolLineIntersect(bool checked)
*/ */
void MainWindow::ToolSpline(bool checked) void MainWindow::ToolSpline(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogSpline>(checked, Tool::Spline, ":/cursor/spline_cursor.png", SetToolButtonWithApply<DialogSpline>(checked, Tool::Spline, ":/cursor/spline_cursor.png",
tr("Select first point curve"), tr("Select first point curve"),
&MainWindow::ClosedDialogWithApply<VToolSpline>, &MainWindow::ClosedDialogWithApply<VToolSpline>,
@ -786,6 +811,7 @@ void MainWindow::ToolSpline(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolCubicBezier(bool checked) void MainWindow::ToolCubicBezier(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogCubicBezier>(checked, Tool::CubicBezier, ":/cursor/cubic_bezier_cursor.png", SetToolButtonWithApply<DialogCubicBezier>(checked, Tool::CubicBezier, ":/cursor/cubic_bezier_cursor.png",
tr("Select first curve point"), tr("Select first curve point"),
&MainWindow::ClosedDialogWithApply<VToolCubicBezier>, &MainWindow::ClosedDialogWithApply<VToolCubicBezier>,
@ -799,6 +825,7 @@ void MainWindow::ToolCubicBezier(bool checked)
*/ */
void MainWindow::ToolCutSpline(bool checked) void MainWindow::ToolCutSpline(bool checked)
{ {
ToolSelectSpline();
SetToolButtonWithApply<DialogCutSpline>(checked, Tool::CutSpline, ":/cursor/spline_cut_point_cursor.png", SetToolButtonWithApply<DialogCutSpline>(checked, Tool::CutSpline, ":/cursor/spline_cut_point_cursor.png",
tr("Select simple curve"), tr("Select simple curve"),
&MainWindow::ClosedDialogWithApply<VToolCutSpline>, &MainWindow::ClosedDialogWithApply<VToolCutSpline>,
@ -812,6 +839,7 @@ void MainWindow::ToolCutSpline(bool checked)
*/ */
void MainWindow::ToolArc(bool checked) void MainWindow::ToolArc(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogArc>(checked, Tool::Arc, ":/cursor/arc_cursor.png", SetToolButtonWithApply<DialogArc>(checked, Tool::Arc, ":/cursor/arc_cursor.png",
tr("Select point of center of arc"), &MainWindow::ClosedDialogWithApply<VToolArc>, tr("Select point of center of arc"), &MainWindow::ClosedDialogWithApply<VToolArc>,
&MainWindow::ApplyDialog<VToolArc>); &MainWindow::ApplyDialog<VToolArc>);
@ -824,6 +852,7 @@ void MainWindow::ToolArc(bool checked)
*/ */
void MainWindow::ToolSplinePath(bool checked) void MainWindow::ToolSplinePath(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogSplinePath>(checked, Tool::SplinePath, ":/cursor/splinepath_cursor.png", SetToolButtonWithApply<DialogSplinePath>(checked, Tool::SplinePath, ":/cursor/splinepath_cursor.png",
tr("Select point of curve path"), tr("Select point of curve path"),
&MainWindow::ClosedDialogWithApply<VToolSplinePath>, &MainWindow::ClosedDialogWithApply<VToolSplinePath>,
@ -833,6 +862,7 @@ void MainWindow::ToolSplinePath(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolCubicBezierPath(bool checked) void MainWindow::ToolCubicBezierPath(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogCubicBezierPath>(checked, Tool::CubicBezierPath, SetToolButtonWithApply<DialogCubicBezierPath>(checked, Tool::CubicBezierPath,
":/cursor/cubic_bezier_path_cursor.png", ":/cursor/cubic_bezier_path_cursor.png",
tr("Select point of cubic bezier path"), tr("Select point of cubic bezier path"),
@ -847,6 +877,7 @@ void MainWindow::ToolCubicBezierPath(bool checked)
*/ */
void MainWindow::ToolCutSplinePath(bool checked) void MainWindow::ToolCutSplinePath(bool checked)
{ {
ToolSelectSplinePath();
SetToolButtonWithApply<DialogCutSplinePath>(checked, Tool::CutSplinePath, SetToolButtonWithApply<DialogCutSplinePath>(checked, Tool::CutSplinePath,
":/cursor/splinepath_cut_point_cursor.png", tr("Select curve path"), ":/cursor/splinepath_cut_point_cursor.png", tr("Select curve path"),
&MainWindow::ClosedDialogWithApply<VToolCutSplinePath>, &MainWindow::ClosedDialogWithApply<VToolCutSplinePath>,
@ -860,6 +891,7 @@ void MainWindow::ToolCutSplinePath(bool checked)
*/ */
void MainWindow::ToolPointOfContact(bool checked) void MainWindow::ToolPointOfContact(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogPointOfContact>(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png", SetToolButtonWithApply<DialogPointOfContact>(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png",
tr("Select first point of line"), tr("Select first point of line"),
&MainWindow::ClosedDialogWithApply<VToolPointOfContact>, &MainWindow::ClosedDialogWithApply<VToolPointOfContact>,
@ -873,6 +905,7 @@ void MainWindow::ToolPointOfContact(bool checked)
*/ */
void MainWindow::ToolDetail(bool checked) void MainWindow::ToolDetail(bool checked)
{ {
ToolSelectAllObjects();
SetToolButton<DialogDetail>(checked, Tool::Detail, "://cursor/new_detail_cursor.png", SetToolButton<DialogDetail>(checked, Tool::Detail, "://cursor/new_detail_cursor.png",
tr("Select points, arcs, curves clockwise."), &MainWindow::ClosedDialogDetail); tr("Select points, arcs, curves clockwise."), &MainWindow::ClosedDialogDetail);
} }
@ -899,6 +932,7 @@ void MainWindow::ClosedDialogDetail(int result)
*/ */
void MainWindow::ToolHeight(bool checked) void MainWindow::ToolHeight(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogHeight>(checked, Tool::Height, ":/cursor/height_cursor.png", tr("Select base point"), SetToolButtonWithApply<DialogHeight>(checked, Tool::Height, ":/cursor/height_cursor.png", tr("Select base point"),
&MainWindow::ClosedDialogWithApply<VToolHeight>, &MainWindow::ClosedDialogWithApply<VToolHeight>,
&MainWindow::ApplyDialog<VToolHeight>); &MainWindow::ApplyDialog<VToolHeight>);
@ -911,6 +945,7 @@ void MainWindow::ToolHeight(bool checked)
*/ */
void MainWindow::ToolTriangle(bool checked) void MainWindow::ToolTriangle(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogTriangle>(checked, Tool::Triangle, ":/cursor/triangle_cursor.png", SetToolButtonWithApply<DialogTriangle>(checked, Tool::Triangle, ":/cursor/triangle_cursor.png",
tr("Select first point of axis"), tr("Select first point of axis"),
&MainWindow::ClosedDialogWithApply<VToolTriangle>, &MainWindow::ClosedDialogWithApply<VToolTriangle>,
@ -924,6 +959,7 @@ void MainWindow::ToolTriangle(bool checked)
*/ */
void MainWindow::ToolPointOfIntersection(bool checked) void MainWindow::ToolPointOfIntersection(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogPointOfIntersection>(checked, Tool::PointOfIntersection, SetToolButtonWithApply<DialogPointOfIntersection>(checked, Tool::PointOfIntersection,
":/cursor/pointofintersect_cursor.png", ":/cursor/pointofintersect_cursor.png",
tr("Select point for X value (vertical)"), tr("Select point for X value (vertical)"),
@ -938,6 +974,7 @@ void MainWindow::ToolPointOfIntersection(bool checked)
*/ */
void MainWindow::ToolUnionDetails(bool checked) void MainWindow::ToolUnionDetails(bool checked)
{ {
ToolSelectDetail();
SetToolButton<DialogUnionDetails>(checked, Tool::UnionDetails, ":/cursor/union_cursor.png", SetToolButton<DialogUnionDetails>(checked, Tool::UnionDetails, ":/cursor/union_cursor.png",
tr("Select detail"), &MainWindow::ClosedDialogUnionDetails); tr("Select detail"), &MainWindow::ClosedDialogUnionDetails);
} }
@ -960,6 +997,7 @@ void MainWindow::ClosedDialogUnionDetails(int result)
*/ */
void MainWindow::ToolCutArc(bool checked) void MainWindow::ToolCutArc(bool checked)
{ {
ToolSelectArc();
SetToolButtonWithApply<DialogCutArc>(checked, Tool::CutArc, ":/cursor/arc_cut_cursor.png", SetToolButtonWithApply<DialogCutArc>(checked, Tool::CutArc, ":/cursor/arc_cut_cursor.png",
tr("Select arc"), &MainWindow::ClosedDialogWithApply<VToolCutArc>, tr("Select arc"), &MainWindow::ClosedDialogWithApply<VToolCutArc>,
&MainWindow::ApplyDialog<VToolCutArc>); &MainWindow::ApplyDialog<VToolCutArc>);
@ -968,6 +1006,7 @@ void MainWindow::ToolCutArc(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolLineIntersectAxis(bool checked) void MainWindow::ToolLineIntersectAxis(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogLineIntersectAxis>(checked, Tool::LineIntersectAxis, SetToolButtonWithApply<DialogLineIntersectAxis>(checked, Tool::LineIntersectAxis,
":/cursor/line_intersect_axis_cursor.png", ":/cursor/line_intersect_axis_cursor.png",
tr("Select first point of line"), tr("Select first point of line"),
@ -978,6 +1017,7 @@ void MainWindow::ToolLineIntersectAxis(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolCurveIntersectAxis(bool checked) void MainWindow::ToolCurveIntersectAxis(bool checked)
{ {
ToolSelectAllObjects();
SetToolButtonWithApply<DialogCurveIntersectAxis>(checked, Tool::CurveIntersectAxis, SetToolButtonWithApply<DialogCurveIntersectAxis>(checked, Tool::CurveIntersectAxis,
":/cursor/curve_intersect_axis_cursor.png", ":/cursor/curve_intersect_axis_cursor.png",
tr("Select curve"), tr("Select curve"),
@ -988,6 +1028,7 @@ void MainWindow::ToolCurveIntersectAxis(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolArcIntersectAxis(bool checked) void MainWindow::ToolArcIntersectAxis(bool checked)
{ {
ToolSelectAllObjects();
// Reuse ToolCurveIntersectAxis but with different cursor and tool tip // Reuse ToolCurveIntersectAxis but with different cursor and tool tip
SetToolButtonWithApply<DialogCurveIntersectAxis>(checked, Tool::CurveIntersectAxis, SetToolButtonWithApply<DialogCurveIntersectAxis>(checked, Tool::CurveIntersectAxis,
":/cursor/arc_intersect_axis_cursor.png", ":/cursor/arc_intersect_axis_cursor.png",
@ -999,6 +1040,7 @@ void MainWindow::ToolArcIntersectAxis(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolPointOfIntersectionArcs(bool checked) void MainWindow::ToolPointOfIntersectionArcs(bool checked)
{ {
ToolSelectArc();
SetToolButtonWithApply<DialogPointOfIntersectionArcs>(checked, Tool::PointOfIntersectionArcs, SetToolButtonWithApply<DialogPointOfIntersectionArcs>(checked, Tool::PointOfIntersectionArcs,
"://cursor/point_of_intersection_arcs.png", "://cursor/point_of_intersection_arcs.png",
tr("Select first an arc"), tr("Select first an arc"),
@ -1009,6 +1051,7 @@ void MainWindow::ToolPointOfIntersectionArcs(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolPointOfIntersectionCircles(bool checked) void MainWindow::ToolPointOfIntersectionCircles(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogPointOfIntersectionCircles>(checked, Tool::PointOfIntersectionCircles, SetToolButtonWithApply<DialogPointOfIntersectionCircles>(checked, Tool::PointOfIntersectionCircles,
"://cursor/point_of_intersection_circles.png", "://cursor/point_of_intersection_circles.png",
tr("Select first circle center "), tr("Select first circle center "),
@ -1019,6 +1062,7 @@ void MainWindow::ToolPointOfIntersectionCircles(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolPointOfIntersectionCurves(bool checked) void MainWindow::ToolPointOfIntersectionCurves(bool checked)
{ {
ToolSelectCurve();
SetToolButtonWithApply<DialogPointOfIntersectionCurves>(checked, Tool::PointOfIntersectionCurves, SetToolButtonWithApply<DialogPointOfIntersectionCurves>(checked, Tool::PointOfIntersectionCurves,
"://cursor/intersection_curves_cursor.png", "://cursor/intersection_curves_cursor.png",
tr("Select first curve"), tr("Select first curve"),
@ -1029,6 +1073,7 @@ void MainWindow::ToolPointOfIntersectionCurves(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolPointFromCircleAndTangent(bool checked) void MainWindow::ToolPointFromCircleAndTangent(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogPointFromCircleAndTangent>(checked, Tool::PointFromCircleAndTangent, SetToolButtonWithApply<DialogPointFromCircleAndTangent>(checked, Tool::PointFromCircleAndTangent,
"://cursor/point_from_circle_and_tangent_cursor.png", "://cursor/point_from_circle_and_tangent_cursor.png",
tr("Select point on tangent "), tr("Select point on tangent "),
@ -1039,6 +1084,7 @@ void MainWindow::ToolPointFromCircleAndTangent(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolPointFromArcAndTangent(bool checked) void MainWindow::ToolPointFromArcAndTangent(bool checked)
{ {
ToolSelectPointArc();
SetToolButtonWithApply<DialogPointFromArcAndTangent>(checked, Tool::PointFromArcAndTangent, SetToolButtonWithApply<DialogPointFromArcAndTangent>(checked, Tool::PointFromArcAndTangent,
"://cursor/point_from_arc_and_tangent_cursor.png", "://cursor/point_from_arc_and_tangent_cursor.png",
tr("Select point on tangent "), tr("Select point on tangent "),
@ -1049,6 +1095,7 @@ void MainWindow::ToolPointFromArcAndTangent(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolArcWithLength(bool checked) void MainWindow::ToolArcWithLength(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogArcWithLength>(checked, Tool::ArcWithLength, SetToolButtonWithApply<DialogArcWithLength>(checked, Tool::ArcWithLength,
"://cursor/arc_with_length_cursor.png", "://cursor/arc_with_length_cursor.png",
tr("Select point of the center of the arc"), tr("Select point of the center of the arc"),
@ -1059,6 +1106,7 @@ void MainWindow::ToolArcWithLength(bool checked)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolTrueDarts(bool checked) void MainWindow::ToolTrueDarts(bool checked)
{ {
ToolSelectPoint();
SetToolButtonWithApply<DialogTrueDarts>(checked, Tool::TrueDarts, SetToolButtonWithApply<DialogTrueDarts>(checked, Tool::TrueDarts,
"://cursor/true_darts_cursor.png", "://cursor/true_darts_cursor.png",
tr("Select the first base line point"), tr("Select the first base line point"),
@ -1841,6 +1889,30 @@ void MainWindow::ArrowTool()
ui->actionStopTool->setEnabled(false); ui->actionStopTool->setEnabled(false);
currentTool = Tool::Arrow; currentTool = Tool::Arrow;
emit EnableItemMove(true); emit EnableItemMove(true);
// Only true for rubber band selection
emit EnableLabelSelection(true);
emit EnablePointSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
emit EnableNodeLabelSelection(true);
emit EnableNodePointSelection(true);
emit EnableDetailSelection(true);// Disable when done visualization details
// Hovering
emit EnableLabelHover(true);
emit EnablePointHover(true);
emit EnableLineHover(true);
emit EnableArcHover(true);
emit EnableSplineHover(true);
emit EnableSplinePathHover(true);
emit EnableNodeLabelHover(true);
emit EnableNodePointHover(true);
emit EnableDetailHover(true);
ui->view->AllowRubberBand(true);
QCursor cur(Qt::ArrowCursor); QCursor cur(Qt::ArrowCursor);
ui->view->setCursor(cur); ui->view->setCursor(cur);
helpLabel->setText(""); helpLabel->setText("");
@ -4406,3 +4478,166 @@ bool MainWindow::IgnoreLocking(int error, const QString &path)
} }
return true; return true;
} }
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectPoint() const
{
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
// Hovering
emit EnableLabelHover(true);
emit EnablePointHover(true);
emit EnableLineHover(false);
emit EnableArcHover(false);
emit EnableSplineHover(false);
emit EnableSplinePathHover(false);
ui->view->AllowRubberBand(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectSpline() const
{
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
// Hovering
emit EnableLabelHover(false);
emit EnablePointHover(false);
emit EnableLineHover(false);
emit EnableArcHover(false);
emit EnableSplineHover(true);
emit EnableSplinePathHover(false);
ui->view->AllowRubberBand(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectSplinePath() const
{
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
// Hovering
emit EnableLabelHover(false);
emit EnablePointHover(false);
emit EnableLineHover(false);
emit EnableArcHover(false);
emit EnableSplineHover(false);
emit EnableSplinePathHover(true);
ui->view->AllowRubberBand(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectArc() const
{
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
// Hovering
emit EnableLabelHover(false);
emit EnablePointHover(false);
emit EnableLineHover(false);
emit EnableArcHover(true);
emit EnableSplineHover(false);
emit EnableSplinePathHover(false);
ui->view->AllowRubberBand(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectPointArc() const
{
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
// Hovering
emit EnableLabelHover(true);
emit EnablePointHover(true);
emit EnableLineHover(false);
emit EnableArcHover(true);
emit EnableSplineHover(false);
emit EnableSplinePathHover(false);
ui->view->AllowRubberBand(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectCurve() const
{
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
// Hovering
emit EnableLabelHover(false);
emit EnablePointHover(false);
emit EnableLineHover(false);
emit EnableArcHover(true);
emit EnableSplineHover(true);
emit EnableSplinePathHover(true);
ui->view->AllowRubberBand(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectAllObjects() const
{
// Only true for rubber band selection
emit EnableLabelSelection(false);
emit EnablePointSelection(false);
emit EnableArcSelection(false);
emit EnableSplineSelection(false);
emit EnableSplinePathSelection(false);
// Hovering
emit EnableLabelHover(true);
emit EnablePointHover(true);
emit EnableLineHover(false);
emit EnableArcHover(true);
emit EnableSplineHover(true);
emit EnableSplinePathHover(true);
ui->view->AllowRubberBand(false);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolSelectDetail() const
{
// Only true for rubber band selection
emit EnableNodeLabelSelection(false);
emit EnableNodePointSelection(false);
emit EnableDetailSelection(true);// Disable when done visualization details
// Hovering
emit EnableNodeLabelHover(true);
emit EnableNodePointHover(true);
emit EnableDetailHover(true);
ui->view->AllowRubberBand(false);
}

View File

@ -157,6 +157,25 @@ public slots:
signals: signals:
void RefreshHistory(); void RefreshHistory();
void EnableItemMove(bool move); void EnableItemMove(bool move);
void EnableLabelSelection(bool enable) const;
void EnablePointSelection(bool enable) const;
void EnableArcSelection(bool enable) const;
void EnableSplineSelection(bool enable) const;
void EnableSplinePathSelection(bool enable) const;
void EnableNodeLabelSelection(bool enable) const;
void EnableNodePointSelection(bool enable) const;
void EnableDetailSelection(bool enable) const;
void EnableLabelHover(bool enable) const;
void EnablePointHover(bool enable) const;
void EnableLineHover(bool enable) const;
void EnableArcHover(bool enable) const;
void EnableSplineHover(bool enable) const;
void EnableSplinePathHover(bool enable) const;
void EnableNodeLabelHover(bool enable) const;
void EnableNodePointHover(bool enable) const;
void EnableDetailHover(bool enable) const;
protected: protected:
virtual void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; virtual void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
@ -331,6 +350,15 @@ private:
void UpdateWindowTitle(); void UpdateWindowTitle();
bool IgnoreLocking(int error, const QString &path); bool IgnoreLocking(int error, const QString &path);
void ToolSelectPoint() const;
void ToolSelectSpline() const;
void ToolSelectSplinePath() const;
void ToolSelectArc() const;
void ToolSelectPointArc() const;
void ToolSelectCurve() const;
void ToolSelectAllObjects() const;
void ToolSelectDetail() const;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -940,22 +940,8 @@ void VPattern::ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement &
const qreal x = qApp->toPixel(GetParametrDouble(domElement, AttrX, "10.0")); const qreal x = qApp->toPixel(GetParametrDouble(domElement, AttrX, "10.0"));
const qreal y = qApp->toPixel(GetParametrDouble(domElement, AttrY, "10.0")); const qreal y = qApp->toPixel(GetParametrDouble(domElement, AttrY, "10.0"));
data->UpdateGObject(id, new VPointF(x, y, name, mx, my)); VPointF *point = new VPointF(x, y, name, mx, my);
VDrawTool::AddRecord(id, Tool::BasePoint, this); VToolBasePoint::Create(id, nameActivPP, point, scene, this, data, parse, Source::FromFile);
if (parse != Document::FullParse)
{
UpdateToolData(id, data);
}
if (parse == Document::FullParse)
{
spoint = new VToolBasePoint(this, data, id, Source::FromFile, nameActivPP);
scene->addItem(spoint);
connect(spoint, &VToolBasePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolBasePoint::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, spoint, &VToolBasePoint::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, spoint, &VToolBasePoint::EnableToolMove);
tools[id] = spoint;
}
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)
{ {

View File

@ -38,7 +38,9 @@ const QString VAbstractSpline::TagName = QStringLiteral("spline");
VAbstractSpline::VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent) VAbstractSpline::VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector<VControlPointSpline *>()), :VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector<VControlPointSpline *>()),
sceneType(SceneObject::Unknown), isHovered(false), detailsMode(false) sceneType(SceneObject::Unknown), isHovered(false), detailsMode(false)
{} {
setAcceptHoverEvents(true);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstractSpline::~VAbstractSpline() VAbstractSpline::~VAbstractSpline()
@ -92,6 +94,18 @@ void VAbstractSpline::DetailsMode(bool mode)
ShowHandles(detailsMode); ShowHandles(detailsMode);
} }
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::AllowHover(bool enabled)
{
setAcceptHoverEvents(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::AllowSelecting(bool enabled)
{
setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief ShowTool highlight tool. * @brief ShowTool highlight tool.
@ -205,18 +219,26 @@ void VAbstractSpline::keyReleaseEvent(QKeyEvent *event)
QGraphicsItem::keyReleaseEvent ( event ); QGraphicsItem::keyReleaseEvent ( event );
} }
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
// Special for not selectable item first need to call standard mousePressEvent then accept event
QGraphicsPathItem::mousePressEvent(event);
event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief mousePressEvent handle mouse press events. * @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event. * @param event mouse release event.
*/ */
void VAbstractSpline::mousePressEvent(QGraphicsSceneMouseEvent *event) void VAbstractSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
{ {
emit ChoosedTool(id, sceneType); emit ChoosedTool(id, sceneType);
} }
QGraphicsPathItem::mousePressEvent(event); QGraphicsPathItem::mouseReleaseEvent(event);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -58,7 +58,10 @@ public:
public slots: public slots:
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
void DetailsMode(bool mode); 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: signals:
/** /**
* @brief setEnabledPoint disable control points. * @brief setEnabledPoint disable control points.
@ -78,12 +81,12 @@ protected:
*/ */
virtual void RefreshGeometry ()=0; virtual void RefreshGeometry ()=0;
virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE; virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE;
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE; virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE; virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const; QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const;
virtual void ReadToolAttributes(const QDomElement &domElement) 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 SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
@ -93,6 +96,15 @@ protected:
template <typename T> template <typename T>
void ShowToolVisualization(bool show); void ShowToolVisualization(bool show);
template <typename T>
static void InitSplineToolConnections(VMainGraphicsScene *scene, T *tool);
template <typename T>
static void InitSplinePathToolConnections(VMainGraphicsScene *scene, T *tool);
template <typename T>
static void InitArcToolConnections(VMainGraphicsScene *scene, T *tool);
private: private:
Q_DISABLE_COPY(VAbstractSpline) Q_DISABLE_COPY(VAbstractSpline)
}; };
@ -137,4 +149,40 @@ inline void VAbstractSpline::ShowToolVisualization(bool show)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VAbstractSpline::InitSplineToolConnections(VMainGraphicsScene *scene, T *tool)
{
SCASSERT(scene != nullptr);
SCASSERT(tool != nullptr);
InitDrawToolConnections(scene, tool);
QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemHover, tool, &T::AllowHover);
QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemSelection, tool, &T::AllowSelecting);
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VAbstractSpline::InitSplinePathToolConnections(VMainGraphicsScene *scene, T *tool)
{
SCASSERT(scene != nullptr);
SCASSERT(tool != nullptr);
InitDrawToolConnections(scene, tool);
QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemHover, tool, &T::AllowHover);
QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemSelection, tool, &T::AllowSelecting);
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VAbstractSpline::InitArcToolConnections(VMainGraphicsScene *scene, T *tool)
{
SCASSERT(scene != nullptr);
SCASSERT(tool != nullptr);
InitDrawToolConnections(scene, tool);
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemHover, tool, &T::AllowHover);
QObject::connect(scene, &VMainGraphicsScene::EnableArcItemSelection, tool, &T::AllowSelecting);
}
#endif // VABSTRACTSPLINE_H #endif // VABSTRACTSPLINE_H

View File

@ -58,7 +58,6 @@ VToolArc::VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const QS
this->setPath(ToolPath()); this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
this->setAcceptHoverEvents(true);
ToolCreation(typeCreation); ToolCreation(typeCreation);
} }
@ -154,9 +153,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
{ {
VToolArc *toolArc = new VToolArc(doc, data, id, color, typeCreation); VToolArc *toolArc = new VToolArc(doc, data, id, color, typeCreation);
scene->addItem(toolArc); scene->addItem(toolArc);
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitArcToolConnections(scene, toolArc);
connect(scene, &VMainGraphicsScene::NewFactor, toolArc, &VToolArc::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, toolArc, &VToolArc::Disable);
doc->AddTool(id, toolArc); doc->AddTool(id, toolArc);
doc->IncrementReferens(c.getIdTool()); doc->IncrementReferens(c.getIdTool());
return toolArc; return toolArc;

View File

@ -49,7 +49,6 @@ VToolArcWithLength::VToolArcWithLength(VAbstractPattern *doc, VContainer *data,
this->setPath(ToolPath()); this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
this->setAcceptHoverEvents(true);
ToolCreation(typeCreation); ToolCreation(typeCreation);
} }
@ -123,9 +122,7 @@ VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32
{ {
VToolArcWithLength *toolArc = new VToolArcWithLength(doc, data, id, color, typeCreation); VToolArcWithLength *toolArc = new VToolArcWithLength(doc, data, id, color, typeCreation);
scene->addItem(toolArc); scene->addItem(toolArc);
connect(toolArc, &VToolArcWithLength::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitArcToolConnections(scene, toolArc);
connect(scene, &VMainGraphicsScene::NewFactor, toolArc, &VToolArcWithLength::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, toolArc, &VToolArcWithLength::Disable);
doc->AddTool(id, toolArc); doc->AddTool(id, toolArc);
doc->IncrementReferens(c.getIdTool()); doc->IncrementReferens(c.getIdTool());
return toolArc; return toolArc;

View File

@ -43,7 +43,6 @@ VToolCubicBezier::VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quin
lineColor = color; lineColor = color;
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
this->setAcceptHoverEvents(true);
this->setPath(ToolPath()); this->setPath(ToolPath());
ToolCreation(typeCreation); ToolCreation(typeCreation);
@ -108,9 +107,7 @@ VToolCubicBezier *VToolCubicBezier::Create(const quint32 _id, VCubicBezier *spli
{ {
auto _spl = new VToolCubicBezier(doc, data, id, color, typeCreation); auto _spl = new VToolCubicBezier(doc, data, id, color, typeCreation);
scene->addItem(_spl); scene->addItem(_spl);
connect(_spl, &VToolCubicBezier::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitSplineToolConnections(scene, _spl);
connect(scene, &VMainGraphicsScene::NewFactor, _spl, &VToolCubicBezier::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, _spl, &VToolCubicBezier::Disable);
doc->AddTool(id, _spl); doc->AddTool(id, _spl);
doc->IncrementReferens(spline->GetP1().getIdTool()); doc->IncrementReferens(spline->GetP1().getIdTool());
doc->IncrementReferens(spline->GetP1().getIdTool()); doc->IncrementReferens(spline->GetP1().getIdTool());

View File

@ -42,7 +42,6 @@ VToolCubicBezierPath::VToolCubicBezierPath(VAbstractPattern *doc, VContainer *da
this->setPath(ToolPath()); this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
this->setAcceptHoverEvents(true);
ToolCreation(typeCreation); ToolCreation(typeCreation);
} }
@ -109,9 +108,7 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(const quint32 _id, VCubicBezi
{ {
VToolCubicBezierPath *spl = new VToolCubicBezierPath(doc, data, id, color, typeCreation); VToolCubicBezierPath *spl = new VToolCubicBezierPath(doc, data, id, color, typeCreation);
scene->addItem(spl); scene->addItem(spl);
connect(spl, &VToolCubicBezierPath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitSplinePathToolConnections(scene, spl);
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolCubicBezierPath::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolCubicBezierPath::Disable);
doc->AddTool(id, spl); doc->AddTool(id, spl);
return spl; return spl;
} }

View File

@ -62,7 +62,6 @@ VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, co
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setAcceptHoverEvents(true);
this->setPath(ToolPath()); this->setPath(ToolPath());
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id); const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
@ -179,11 +178,7 @@ VToolSpline* VToolSpline::Create(const quint32 _id, VSpline *spline, const QStri
{ {
auto _spl = new VToolSpline(doc, data, id, color, typeCreation); auto _spl = new VToolSpline(doc, data, id, color, typeCreation);
scene->addItem(_spl); scene->addItem(_spl);
connect(_spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitSplineToolConnections(scene, _spl);
connect(scene, &VMainGraphicsScene::NewFactor, _spl, &VToolSpline::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, _spl, &VToolSpline::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, _spl, &VToolSpline::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, _spl, &VToolSpline::DetailsMode);
doc->AddTool(id, _spl); doc->AddTool(id, _spl);
doc->IncrementReferens(spline->GetP1().getIdTool()); doc->IncrementReferens(spline->GetP1().getIdTool());
doc->IncrementReferens(spline->GetP4().getIdTool()); doc->IncrementReferens(spline->GetP4().getIdTool());

View File

@ -63,7 +63,6 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3
this->setPath(ToolPath()); this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setAcceptHoverEvents(true);
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(id); const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(id);
for (qint32 i = 1; i<=splPath->CountSubSpl(); ++i) for (qint32 i = 1; i<=splPath->CountSubSpl(); ++i)
@ -183,11 +182,7 @@ VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, c
{ {
VToolSplinePath *spl = new VToolSplinePath(doc, data, id, color, typeCreation); VToolSplinePath *spl = new VToolSplinePath(doc, data, id, color, typeCreation);
scene->addItem(spl); scene->addItem(spl);
connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitSplinePathToolConnections(scene, spl);
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSplinePath::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, spl, &VToolSplinePath::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, spl, &VToolSplinePath::DetailsMode);
doc->AddTool(id, spl); doc->AddTool(id, spl);
return spl; return spl;
} }

View File

@ -187,6 +187,34 @@ void VToolDoublePoint::DoChangePosition(quint32 id, qreal mx, qreal my)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::AllowHover(bool enabled)
{
firstPoint->setAcceptHoverEvents(enabled);
secondPoint->setAcceptHoverEvents(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::AllowSelecting(bool enabled)
{
firstPoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
secondPoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::AllowLabelHover(bool enabled)
{
firstPoint->AllowLabelHover(enabled);
secondPoint->AllowLabelHover(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::AllowLabelSelecting(bool enabled)
{
firstPoint->AllowLabelSelecting(enabled);
secondPoint->AllowLabelSelecting(enabled);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::UpdateNamePosition(quint32 id) void VToolDoublePoint::UpdateNamePosition(quint32 id)
{ {

View File

@ -69,6 +69,10 @@ public slots:
void Point2Choosed(); void Point2Choosed();
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void DoChangePosition(quint32 id, qreal mx, qreal my) 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);
protected: protected:
VSimplePoint *firstPoint; VSimplePoint *firstPoint;

View File

@ -172,10 +172,7 @@ VToolTrueDarts *VToolTrueDarts::Create(quint32 _id,
VToolTrueDarts *points = new VToolTrueDarts(doc, data, id, p1id, p2id, baseLineP1Id, baseLineP2Id, VToolTrueDarts *points = new VToolTrueDarts(doc, data, id, p1id, p2id, baseLineP1Id, baseLineP2Id,
dartP1Id, dartP2Id, dartP3Id, typeCreation); dartP1Id, dartP2Id, dartP3Id, typeCreation);
scene->addItem(points); scene->addItem(points);
connect(points, &VToolDoublePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, points);
connect(scene, &VMainGraphicsScene::NewFactor, points, &VToolTrueDarts::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, points, &VToolTrueDarts::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, points, &VToolTrueDarts::EnableToolMove);
doc->AddTool(id, points); doc->AddTool(id, points);
doc->IncrementReferens(baseLineP1->getIdTool()); doc->IncrementReferens(baseLineP1->getIdTool());
doc->IncrementReferens(baseLineP2->getIdTool()); doc->IncrementReferens(baseLineP2->getIdTool());

View File

@ -52,7 +52,7 @@ public:
public slots: public slots:
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
void DetailsMode(bool mode); virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE;
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
protected: protected:
/** @brief formula keep formula of length */ /** @brief formula keep formula of length */

View File

@ -163,10 +163,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
{ {
VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, arc1id, arc2id, color, typeCreation); VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, arc1id, arc2id, color, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutArc::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutArc::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutArc::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->AddTool(arc1id, point); doc->AddTool(arc1id, point);
doc->AddTool(arc2id, point); doc->AddTool(arc2id, point);

View File

@ -170,11 +170,7 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa
VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, color, VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, color,
typeCreation); typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSpline::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSpline::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSpline::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, point, &VToolCutSpline::DetailsMode);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->AddTool(spl1id, point); doc->AddTool(spl1id, point);
doc->AddTool(spl2id, point); doc->AddTool(spl2id, point);

View File

@ -180,11 +180,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id, VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id,
splPath2id, color, typeCreation); splPath2id, color, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSplinePath::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSplinePath::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSplinePath::EnableToolMove);
connect(scene, &VMainGraphicsScene::CurveDetailsMode, point, &VToolCutSplinePath::DetailsMode);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->AddTool(splPath1id, point); doc->AddTool(splPath1id, point);
doc->AddTool(splPath2id, point); doc->AddTool(splPath2id, point);

View File

@ -275,10 +275,7 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa
VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine, VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine,
lineColor, typeCreation); lineColor, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolAlongLine::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolAlongLine::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(firstPoint->getIdTool()); doc->IncrementReferens(firstPoint->getIdTool());
doc->IncrementReferens(secondPoint->getIdTool()); doc->IncrementReferens(secondPoint->getIdTool());

View File

@ -200,10 +200,7 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, lineColor, formula, firstPointId, VToolBisector *point = new VToolBisector(doc, data, id, typeLine, lineColor, formula, firstPointId,
secondPointId, thirdPointId, typeCreation); secondPointId, thirdPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolBisector::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolBisector::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(firstPoint->getIdTool()); doc->IncrementReferens(firstPoint->getIdTool());
doc->IncrementReferens(secondPoint->getIdTool()); doc->IncrementReferens(secondPoint->getIdTool());

View File

@ -129,10 +129,7 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, cons
VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle, VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle,
basePointId, curveId, typeCreation); basePointId, curveId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCurveIntersectAxis::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCurveIntersectAxis::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCurveIntersectAxis::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(basePoint->getIdTool()); doc->IncrementReferens(basePoint->getIdTool());
doc->IncrementReferens(curve->getIdTool()); doc->IncrementReferens(curve->getIdTool());

View File

@ -165,10 +165,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, lineColor, formulaLength, formulaAngle, VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, lineColor, formulaLength, formulaAngle,
basePointId, typeCreation); basePointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolEndLine::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolEndLine::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolEndLine::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(basePoint->getIdTool()); doc->IncrementReferens(basePoint->getIdTool());
return point; return point;

View File

@ -157,10 +157,7 @@ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, co
VToolHeight *point = new VToolHeight(doc, data, id, typeLine, lineColor, basePointId, p1LineId, p2LineId, VToolHeight *point = new VToolHeight(doc, data, id, typeLine, lineColor, basePointId, p1LineId, p2LineId,
typeCreation); typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolHeight::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolHeight::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolHeight::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(basePoint->getIdTool()); doc->IncrementReferens(basePoint->getIdTool());
doc->IncrementReferens(p1Line->getIdTool()); doc->IncrementReferens(p1Line->getIdTool());

View File

@ -140,10 +140,7 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const
basePointId, firstPointId, secondPointId, basePointId, firstPointId, secondPointId,
typeCreation); typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersectAxis::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersectAxis::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolLineIntersectAxis::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(basePoint->getIdTool()); doc->IncrementReferens(basePoint->getIdTool());
doc->IncrementReferens(firstPoint->getIdTool()); doc->IncrementReferens(firstPoint->getIdTool());

View File

@ -160,10 +160,7 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin
VToolNormal *point = new VToolNormal(doc, data, id, typeLine, lineColor, formula, angle, firstPointId, VToolNormal *point = new VToolNormal(doc, data, id, typeLine, lineColor, formula, angle, firstPointId,
secondPointId, typeCreation); secondPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolNormal::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolNormal::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolNormal::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(firstPoint->getIdTool()); doc->IncrementReferens(firstPoint->getIdTool());
doc->IncrementReferens(secondPoint->getIdTool()); doc->IncrementReferens(secondPoint->getIdTool());

View File

@ -204,10 +204,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu
p1Line, p2Line, pShoulder, p1Line, p2Line, pShoulder,
typeCreation); typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolShoulderPoint::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolShoulderPoint::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolShoulderPoint::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(firstPoint->getIdTool()); doc->IncrementReferens(firstPoint->getIdTool());
doc->IncrementReferens(secondPoint->getIdTool()); doc->IncrementReferens(secondPoint->getIdTool());

View File

@ -79,6 +79,38 @@ void VToolBasePoint::setDialog()
dialogTool->SetData(p->name(), p->toQPointF()); dialogTool->SetData(p->name(), p->toQPointF());
} }
//---------------------------------------------------------------------------------------------------------------------
VToolBasePoint *VToolBasePoint::Create(quint32 _id, const QString &nameActivPP, VPointF *point,
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
{
SCASSERT(point != nullptr);
quint32 id = _id;
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(point);
}
else
{
data->UpdateGObject(id, point);
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);
}
}
VDrawTool::AddRecord(id, Tool::BasePoint, doc);
if (parse == Document::FullParse)
{
VToolBasePoint *spoint = new VToolBasePoint(doc, data, id, typeCreation, nameActivPP);
scene->addItem(spoint);
InitToolConnections(scene, spoint);
doc->AddTool(id, spoint);
return spoint;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolBasePoint::ShowVisualization(bool show) void VToolBasePoint::ShowVisualization(bool show)
{ {

View File

@ -43,6 +43,9 @@ public:
const QString &namePP, QGraphicsItem * parent = nullptr ); const QString &namePP, QGraphicsItem * parent = nullptr );
virtual ~VToolBasePoint() Q_DECL_OVERRIDE; virtual ~VToolBasePoint() Q_DECL_OVERRIDE;
virtual void setDialog() Q_DECL_OVERRIDE; virtual void setDialog() Q_DECL_OVERRIDE;
static VToolBasePoint *Create(quint32 _id, const QString &nameActivPP, VPointF *point,
VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString ToolType; static const QString ToolType;
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::BasePoint)}; enum { Type = UserType + static_cast<int>(Tool::BasePoint)};

View File

@ -164,10 +164,7 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32
VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id,
p2Line2Id, typeCreation); p2Line2Id, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersect::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersect::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolLineIntersect::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(p1Line1->getIdTool()); doc->IncrementReferens(p1Line1->getIdTool());
doc->IncrementReferens(p2Line1->getIdTool()); doc->IncrementReferens(p2Line1->getIdTool());

View File

@ -108,10 +108,7 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(const quint32 _
VToolPointFromArcAndTangent *point = new VToolPointFromArcAndTangent(doc, data, id, arcId, tangentPointId, VToolPointFromArcAndTangent *point = new VToolPointFromArcAndTangent(doc, data, id, arcId, tangentPointId,
crossPoint, typeCreation); crossPoint, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPointFromArcAndTangent::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointFromArcAndTangent::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointFromArcAndTangent::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointFromArcAndTangent::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(arc.getIdTool()); doc->IncrementReferens(arc.getIdTool());
doc->IncrementReferens(tPoint.getIdTool()); doc->IncrementReferens(tPoint.getIdTool());

View File

@ -118,10 +118,7 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(const qui
circleRadius, tangentPointId, circleRadius, tangentPointId,
crossPoint, typeCreation); crossPoint, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPointFromCircleAndTangent::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointFromCircleAndTangent::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointFromCircleAndTangent::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointFromCircleAndTangent::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(cPoint.getIdTool()); doc->IncrementReferens(cPoint.getIdTool());
doc->IncrementReferens(tPoint.getIdTool()); doc->IncrementReferens(tPoint.getIdTool());

View File

@ -220,10 +220,7 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad
VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center, VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center,
firstPointId, secondPointId, typeCreation); firstPointId, secondPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfContact::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfContact::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfContact::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(centerP->getIdTool()); doc->IncrementReferens(centerP->getIdTool());
doc->IncrementReferens(firstP->getIdTool()); doc->IncrementReferens(firstP->getIdTool());

View File

@ -141,10 +141,7 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, co
VToolPointOfIntersection *point = new VToolPointOfIntersection(doc, data, id, firstPointId, VToolPointOfIntersection *point = new VToolPointOfIntersection(doc, data, id, firstPointId,
secondPointId, typeCreation); secondPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersection::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersection::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersection::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(firstPoint->getIdTool()); doc->IncrementReferens(firstPoint->getIdTool());
doc->IncrementReferens(secondPoint->getIdTool()); doc->IncrementReferens(secondPoint->getIdTool());

View File

@ -109,10 +109,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32
VToolPointOfIntersectionArcs *point = new VToolPointOfIntersectionArcs(doc, data, id, firstArcId, VToolPointOfIntersectionArcs *point = new VToolPointOfIntersectionArcs(doc, data, id, firstArcId,
secondArcId, pType, typeCreation); secondArcId, pType, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPointOfIntersectionArcs::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersectionArcs::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionArcs::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionArcs::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(firstArc->getIdTool()); doc->IncrementReferens(firstArc->getIdTool());
doc->IncrementReferens(secondArc->getIdTool()); doc->IncrementReferens(secondArc->getIdTool());

View File

@ -130,10 +130,7 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(const q
secondCircleRadius, crossPoint, secondCircleRadius, crossPoint,
typeCreation); typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPointOfIntersectionCircles::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersectionCircles::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionCircles::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionCircles::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(c1Point.getIdTool()); doc->IncrementReferens(c1Point.getIdTool());
doc->IncrementReferens(c2Point.getIdTool()); doc->IncrementReferens(c2Point.getIdTool());

View File

@ -116,10 +116,7 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(const qui
auto point = new VToolPointOfIntersectionCurves(doc, data, id, firstCurveId, secondCurveId, vCrossPoint, auto point = new VToolPointOfIntersectionCurves(doc, data, id, firstCurveId, secondCurveId, vCrossPoint,
hCrossPoint, typeCreation); hCrossPoint, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPointOfIntersectionCurves::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersectionCurves::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionCurves::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionCurves::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(curve1->getIdTool()); doc->IncrementReferens(curve1->getIdTool());
doc->IncrementReferens(curve2->getIdTool()); doc->IncrementReferens(curve2->getIdTool());

View File

@ -131,6 +131,14 @@ void VToolSinglePoint::UpdateNamePosition(quint32 id)
qApp->getUndoStack()->push(moveLabel); qApp->getUndoStack()->push(moveLabel);
} }
//---------------------------------------------------------------------------------------------------------------------
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
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief SetFactor set current scale factor of scene. * @brief SetFactor set current scale factor of scene.
@ -175,16 +183,16 @@ void VToolSinglePoint::FullUpdateFromFile()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief mousePressEvent handle mouse press events. * @brief mouseReleaseEvent handle mouse release events.
* @param event mouse release event. * @param event mouse release event.
*/ */
void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event) void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
{ {
PointChoosed(); PointChoosed();
} }
QGraphicsEllipseItem::mousePressEvent(event); QGraphicsEllipseItem::mouseReleaseEvent(event);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -333,3 +341,27 @@ void VToolSinglePoint::DoChangePosition(quint32 id, qreal mx, qreal my)
namePoint->blockSignals(false); namePoint->blockSignals(false);
RefreshLine(id); RefreshLine(id);
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::AllowHover(bool enabled)
{
setAcceptHoverEvents(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::AllowSelecting(bool enabled)
{
setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::AllowLabelHover(bool enabled)
{
namePoint->setAcceptHoverEvents(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::AllowLabelSelecting(bool enabled)
{
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}

View File

@ -63,6 +63,10 @@ public slots:
void PointChoosed(); void PointChoosed();
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual void DoChangePosition(quint32 id, qreal mx, qreal my) 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);
protected: protected:
/** @brief radius radius circle. */ /** @brief radius radius circle. */
qreal radius; qreal radius;
@ -75,6 +79,7 @@ protected:
virtual void UpdateNamePosition(quint32 id) Q_DECL_OVERRIDE; virtual void UpdateNamePosition(quint32 id) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) 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 hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void RefreshPointGeometry(const VPointF &point); virtual void RefreshPointGeometry(const VPointF &point);

View File

@ -151,10 +151,7 @@ VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName
VToolTriangle *point = new VToolTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId, VToolTriangle *point = new VToolTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId,
secondPointId, typeCreation); secondPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); InitToolConnections(scene, point);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolTriangle::Disable);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolTriangle::EnableToolMove);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(axisP1->getIdTool()); doc->IncrementReferens(axisP1->getIdTool());
doc->IncrementReferens(axisP2->getIdTool()); doc->IncrementReferens(axisP2->getIdTool());

View File

@ -63,6 +63,9 @@ protected:
template <typename T> template <typename T>
void SetToolEnabled(T *item, bool enabled); void SetToolEnabled(T *item, bool enabled);
template <typename T>
static void InitToolConnections(VMainGraphicsScene *scene, T *tool);
private: private:
Q_DISABLE_COPY(VAbstractPoint) Q_DISABLE_COPY(VAbstractPoint)
}; };
@ -118,4 +121,18 @@ void VAbstractPoint::ChangePosition(T *item, quint32 id, const QPointF &pos)
UpdateNamePosition(id); UpdateNamePosition(id);
} }
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VAbstractPoint::InitToolConnections(VMainGraphicsScene *scene, T *tool)
{
SCASSERT(scene != nullptr);
SCASSERT(tool != nullptr);
InitDrawToolConnections(scene, tool);
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemHover, tool, &T::AllowHover);
QObject::connect(scene, &VMainGraphicsScene::EnablePointItemSelection, tool, &T::AllowSelecting);
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemHover, tool, &T::AllowLabelHover);
QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemSelection, tool, &T::AllowLabelSelecting);
}
#endif // VABSTRACTPOINT_H #endif // VABSTRACTPOINT_H

View File

@ -265,6 +265,13 @@ void VDrawTool::EnableToolMove(bool move)
// Do nothing. // Do nothing.
} }
//---------------------------------------------------------------------------------------------------------------------
void VDrawTool::DetailsMode(bool mode)
{
Q_UNUSED(mode)
// Do nothing.
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief CheckFormula check formula. * @brief CheckFormula check formula.

View File

@ -70,6 +70,7 @@ public slots:
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void EnableToolMove(bool move); virtual void EnableToolMove(bool move);
virtual void Disable(bool disable, const QString &namePP)=0; virtual void Disable(bool disable, const QString &namePP)=0;
virtual void DetailsMode(bool mode);
protected: protected:
enum class RemoveOption : bool {Disable = false, Enable = true}; enum class RemoveOption : bool {Disable = false, Enable = true};
@ -115,6 +116,9 @@ protected:
template <typename T> template <typename T>
QString ObjectName(quint32 id) const; QString ObjectName(quint32 id) const;
template <typename T>
static void InitDrawToolConnections(VMainGraphicsScene *scene, T *tool);
private: private:
Q_DISABLE_COPY(VDrawTool) Q_DISABLE_COPY(VDrawTool)
}; };
@ -226,4 +230,18 @@ QString VDrawTool::ObjectName(quint32 id) const
} }
} }
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VDrawTool::InitDrawToolConnections(VMainGraphicsScene *scene, T *tool)
{
SCASSERT(scene != nullptr);
SCASSERT(tool != nullptr);
QObject::connect(tool, &T::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
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);
}
#endif // VDRAWTOOL_H #endif // VDRAWTOOL_H

View File

@ -152,6 +152,7 @@ VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, con
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor); connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, line, &VToolLine::Disable); connect(scene, &VMainGraphicsScene::DisableItem, line, &VToolLine::Disable);
connect(scene, &VMainGraphicsScene::EnableLineItemHover, line, &VToolLine::AllowHover);
doc->AddTool(id, line); doc->AddTool(id, line);
const QSharedPointer<VPointF> first = data->GeometricObject<VPointF>(firstPoint); const QSharedPointer<VPointF> first = data->GeometricObject<VPointF>(firstPoint);
@ -226,6 +227,18 @@ void VToolLine::Disable(bool disable, const QString &namePP)
LineStyleToPenStyle(typeLine))); LineStyleToPenStyle(typeLine)));
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolLine::AllowHover(bool enabled)
{
setAcceptHoverEvents(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolLine::AllowSelecting(bool enabled)
{
setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief contextMenuEvent handle context menu events. * @brief contextMenuEvent handle context menu events.

View File

@ -69,6 +69,8 @@ public slots:
virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE; virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE;
virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE; virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE;
virtual void Disable(bool disable, const QString &namePP) 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;
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void AddToFile() Q_DECL_OVERRIDE; virtual void AddToFile() Q_DECL_OVERRIDE;

View File

@ -99,6 +99,20 @@ QString VNodeArc::getTagName() const
return VNodeArc::TagName; return VNodeArc::TagName;
} }
//---------------------------------------------------------------------------------------------------------------------
void VNodeArc::AllowHover(bool enabled)
{
Q_UNUSED(enabled)
// do nothing
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeArc::AllowSelecting(bool enabled)
{
Q_UNUSED(enabled)
// do nothing
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief AddToFile add tag with informations about tool into file. * @brief AddToFile add tag with informations about tool into file.

View File

@ -49,6 +49,8 @@ public:
virtual QString getTagName() const Q_DECL_OVERRIDE; virtual QString getTagName() const Q_DECL_OVERRIDE;
public slots: public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE {} virtual void FullUpdateFromFile() Q_DECL_OVERRIDE {}
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
protected: protected:
virtual void AddToFile() Q_DECL_OVERRIDE; virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE;

View File

@ -91,6 +91,10 @@ void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsSc
VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, idTool, doc); VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, idTool, doc);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VNodePoint::EnableToolMove); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VNodePoint::EnableToolMove);
connect(scene, &VMainGraphicsScene::EnablePointItemHover, point, &VNodePoint::AllowHover);
connect(scene, &VMainGraphicsScene::EnablePointItemSelection, point, &VNodePoint::AllowSelecting);
connect(scene, &VMainGraphicsScene::EnableLabelItemHover, point, &VNodePoint::AllowLabelHover);
connect(scene, &VMainGraphicsScene::EnableLabelItemSelection, point, &VNodePoint::AllowLabelSelecting);
doc->AddTool(id, point); doc->AddTool(id, point);
if (idTool != NULL_ID) if (idTool != NULL_ID)
{ {
@ -227,6 +231,14 @@ void VNodePoint::RefreshDataInFile()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::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
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief mouseReleaseEvent handle mouse release events. * @brief mouseReleaseEvent handle mouse release events.
@ -238,7 +250,7 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
emit ChoosedTool(id, SceneObject::Point); emit ChoosedTool(id, SceneObject::Point);
} }
QGraphicsItem::mouseReleaseEvent(event); QGraphicsEllipseItem::mouseReleaseEvent(event);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -345,3 +357,27 @@ void VNodePoint::EnableToolMove(bool move)
{ {
namePoint->setFlag(QGraphicsItem::ItemIsMovable, move); namePoint->setFlag(QGraphicsItem::ItemIsMovable, move);
} }
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::AllowHover(bool enabled)
{
setAcceptHoverEvents(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::AllowSelecting(bool enabled)
{
setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::AllowLabelHover(bool enabled)
{
namePoint->setAcceptHoverEvents(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::AllowLabelSelecting(bool enabled)
{
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}

View File

@ -64,6 +64,10 @@ public slots:
void NameChangePosition(const QPointF &pos); void NameChangePosition(const QPointF &pos);
void PointChoosed(); void PointChoosed();
void EnableToolMove(bool move); void EnableToolMove(bool move);
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
void AllowLabelHover(bool enabled);
void AllowLabelSelecting(bool enabled);
protected: protected:
/** @brief radius radius circle. */ /** @brief radius radius circle. */
qreal radius; qreal radius;
@ -76,6 +80,7 @@ protected:
virtual void AddToFile() Q_DECL_OVERRIDE; virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() 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 mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;

View File

@ -102,6 +102,20 @@ QString VNodeSpline::getTagName() const
return VNodeSpline::TagName; return VNodeSpline::TagName;
} }
//---------------------------------------------------------------------------------------------------------------------
void VNodeSpline::AllowHover(bool enabled)
{
Q_UNUSED(enabled)
// do nothing
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSpline::AllowSelecting(bool enabled)
{
Q_UNUSED(enabled)
// do nothing
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief AddToFile add tag with informations about tool into file. * @brief AddToFile add tag with informations about tool into file.

View File

@ -50,6 +50,8 @@ public:
virtual QString getTagName() const Q_DECL_OVERRIDE; virtual QString getTagName() const Q_DECL_OVERRIDE;
public slots: public slots:
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE {} virtual void FullUpdateFromFile () Q_DECL_OVERRIDE {}
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
protected: protected:
virtual void AddToFile () Q_DECL_OVERRIDE; virtual void AddToFile () Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE;

View File

@ -100,6 +100,20 @@ QString VNodeSplinePath::getTagName() const
return VNodeSplinePath::TagName; return VNodeSplinePath::TagName;
} }
//---------------------------------------------------------------------------------------------------------------------
void VNodeSplinePath::AllowHover(bool enabled)
{
Q_UNUSED(enabled)
// do nothing
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeSplinePath::AllowSelecting(bool enabled)
{
Q_UNUSED(enabled)
// do nothing
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief AddToFile add tag with informations about tool into file. * @brief AddToFile add tag with informations about tool into file.

View File

@ -49,6 +49,8 @@ public:
virtual QString getTagName() const Q_DECL_OVERRIDE; virtual QString getTagName() const Q_DECL_OVERRIDE;
public slots: public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE {} virtual void FullUpdateFromFile() Q_DECL_OVERRIDE {}
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
protected: protected:
virtual void AddToFile() Q_DECL_OVERRIDE; virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE;

View File

@ -77,6 +77,8 @@ public slots:
* @brief FullUpdateFromFile update tool data form file. * @brief FullUpdateFromFile update tool data form file.
*/ */
virtual void FullUpdateFromFile()=0; virtual void FullUpdateFromFile()=0;
virtual void AllowHover(bool enabled)=0;
virtual void AllowSelecting(bool enabled)=0;
signals: signals:
/** /**
* @brief toolhaveChange emit if tool create change that need save. * @brief toolhaveChange emit if tool create change that need save.

View File

@ -253,6 +253,8 @@ void VToolDetail::Create(const quint32 &_id, const VDetail &newDetail, VMainGrap
VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene, drawName); VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene, drawName);
scene->addItem(detail); scene->addItem(detail);
connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::EnableDetailItemHover, detail, &VToolDetail::AllowHover);
connect(scene, &VMainGraphicsScene::EnableDetailItemSelection, detail, &VToolDetail::AllowSelecting);
doc->AddTool(id, detail); doc->AddTool(id, detail);
} }
} }
@ -458,6 +460,8 @@ void VToolDetail::keyReleaseEvent(QKeyEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolDetail::mousePressEvent(QGraphicsSceneMouseEvent *event) void VToolDetail::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
// Special for not selectable item first need to call standard mousePressEvent then accept event
VNoBrushScalePathItem::mousePressEvent(event);
if (flags() & QGraphicsItem::ItemIsMovable) if (flags() & QGraphicsItem::ItemIsMovable)
{ {
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
@ -471,7 +475,7 @@ void VToolDetail::mousePressEvent(QGraphicsSceneMouseEvent *event)
emit ChoosedTool(id, SceneObject::Detail); emit ChoosedTool(id, SceneObject::Detail);
} }
VNoBrushScalePathItem::mousePressEvent(event); event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -689,5 +693,17 @@ void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolDetail::EnableToolMove(bool move) void VToolDetail::EnableToolMove(bool move)
{ {
this->setFlag(QGraphicsItem::ItemIsMovable, move); setFlag(QGraphicsItem::ItemIsMovable, move);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDetail::AllowHover(bool enabled)
{
setAcceptHoverEvents(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDetail::AllowSelecting(bool enabled)
{
setFlag(QGraphicsItem::ItemIsSelectable, enabled);
} }

View File

@ -90,6 +90,8 @@ public slots:
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
virtual void FullUpdateFromGuiOk(int result); virtual void FullUpdateFromGuiOk(int result);
void EnableToolMove(bool move); void EnableToolMove(bool move);
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
protected: protected:
virtual void AddToFile () Q_DECL_OVERRIDE; virtual void AddToFile () Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE;

View File

@ -89,6 +89,8 @@ public slots:
* @brief FullUpdateFromFile update tool data form file. * @brief FullUpdateFromFile update tool data form file.
*/ */
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE {} virtual void FullUpdateFromFile () Q_DECL_OVERRIDE {}
virtual void AllowHover(bool) Q_DECL_OVERRIDE {}
virtual void AllowSelecting(bool) Q_DECL_OVERRIDE {}
protected: protected:
virtual void AddToFile() Q_DECL_OVERRIDE; virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE;

View File

@ -158,10 +158,9 @@ void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
if (flags() & QGraphicsItem::ItemIsMovable) if (flags() & QGraphicsItem::ItemIsMovable)
{ {
this->setBrush(Qt::green);
SetOverrideCursor(cursorArrowOpenHand, 1, 1); SetOverrideCursor(cursorArrowOpenHand, 1, 1);
} }
this->setBrush(Qt::green);
QGraphicsSimpleTextItem::hoverEnterEvent(event); QGraphicsSimpleTextItem::hoverEnterEvent(event);
} }
@ -175,11 +174,10 @@ void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_UNUSED(event); Q_UNUSED(event);
if (flags() & QGraphicsItem::ItemIsMovable) if (flags() & QGraphicsItem::ItemIsMovable)
{ {
this->setBrush(Qt::black);
//Disable cursor-arrow-openhand //Disable cursor-arrow-openhand
RestoreOverrideCursor(cursorArrowOpenHand); RestoreOverrideCursor(cursorArrowOpenHand);
} }
this->setBrush(Qt::black);
QGraphicsSimpleTextItem::hoverLeaveEvent(event); QGraphicsSimpleTextItem::hoverLeaveEvent(event);
} }
@ -196,6 +194,8 @@ void VGraphicsSimpleTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *e
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
// Special for not selectable item first need to call standard mousePressEvent then accept event
QGraphicsSimpleTextItem::mousePressEvent(event);
if (flags() & QGraphicsItem::ItemIsMovable) if (flags() & QGraphicsItem::ItemIsMovable)
{ {
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
@ -203,10 +203,7 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
SetOverrideCursor(cursorArrowCloseHand, 1, 1); SetOverrideCursor(cursorArrowCloseHand, 1, 1);
} }
} }
event->accept(); // This help for not selectable items still receive mouseReleaseEvent events
emit PointChoosed();
QGraphicsSimpleTextItem::mousePressEvent(event);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -221,6 +218,8 @@ void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
} }
} }
emit PointChoosed();
QGraphicsSimpleTextItem::mouseReleaseEvent(event); QGraphicsSimpleTextItem::mouseReleaseEvent(event);
} }

View File

@ -280,3 +280,105 @@ void VMainGraphicsScene::EnableDetailsMode(bool mode)
{ {
emit CurveDetailsMode(mode); emit CurveDetailsMode(mode);
} }
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleLabelSelection(bool enabled)
{
emit EnableLabelItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::TogglePointSelection(bool enabled)
{
emit EnablePointItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleArcSelection(bool enabled)
{
emit EnableArcItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleSplineSelection(bool enabled)
{
emit EnableSplineItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleSplinePathSelection(bool enabled)
{
emit EnableSplinePathItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleNodeLabelSelection(bool enabled)
{
emit EnableNodeLabelItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleNodePointSelection(bool enabled)
{
emit EnableNodePointItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleDetailSelection(bool enabled)
{
emit EnableDetailItemSelection(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleLabelHover(bool enabled)
{
emit EnableLabelItemHover(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::TogglePointHover(bool enabled)
{
emit EnablePointItemHover(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleLineHover(bool enabled)
{
emit EnableLineItemHover(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleArcHover(bool enabled)
{
emit EnableArcItemHover(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleSplineHover(bool enabled)
{
emit EnableSplineItemHover(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleSplinePathHover(bool enabled)
{
emit EnableSplinePathItemHover(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleNodeLabelHover(bool enabled)
{
emit EnableNodeLabelItemHover(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleNodePointHover(bool enabled)
{
emit EnableNodePointItemHover(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleDetailHover(bool enabled)
{
emit EnableDetailItemHover(enabled);
}

View File

@ -58,6 +58,25 @@ public slots:
void SetFactor(qreal factor); void SetFactor(qreal factor);
void EnableItemMove(bool move); void EnableItemMove(bool move);
void EnableDetailsMode(bool mode); void EnableDetailsMode(bool mode);
void ToggleLabelSelection(bool enabled);
void TogglePointSelection(bool enabled);
void ToggleArcSelection(bool enabled);
void ToggleSplineSelection(bool enabled);
void ToggleSplinePathSelection(bool enabled);
void ToggleNodeLabelSelection(bool enabled);
void ToggleNodePointSelection(bool enabled);
void ToggleDetailSelection(bool enabled);
void ToggleLabelHover(bool enabled);
void TogglePointHover(bool enabled);
void ToggleLineHover(bool enabled);
void ToggleArcHover(bool enabled);
void ToggleSplineHover(bool enabled);
void ToggleSplinePathHover(bool enabled);
void ToggleNodeLabelHover(bool enabled);
void ToggleNodePointHover(bool enabled);
void ToggleDetailHover(bool enabled);
protected: protected:
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
@ -86,6 +105,25 @@ signals:
void DisableItem(bool disable, const QString &namePP); void DisableItem(bool disable, const QString &namePP);
void EnableToolMove(bool move); void EnableToolMove(bool move);
void CurveDetailsMode(bool mode); void CurveDetailsMode(bool mode);
void EnableLabelItemSelection(bool enable);
void EnablePointItemSelection(bool enable);
void EnableArcItemSelection(bool enable);
void EnableSplineItemSelection(bool enable);
void EnableSplinePathItemSelection(bool enable);
void EnableNodeLabelItemSelection(bool enabled);
void EnableNodePointItemSelection(bool enabled);
void EnableDetailItemSelection(bool enabled);
void EnableLabelItemHover(bool enable);
void EnablePointItemHover(bool enable);
void EnableArcItemHover(bool enable);
void EnableSplineItemHover(bool enable);
void EnableSplinePathItemHover(bool enable);
void EnableNodeLabelItemHover(bool enabled);
void EnableNodePointItemHover(bool enabled);
void EnableDetailItemHover(bool enabled);
void EnableLineItemHover(bool enabled);
private: private:
/** @brief horScrollBar value horizontal scroll bar. */ /** @brief horScrollBar value horizontal scroll bar. */
qint32 horScrollBar; qint32 horScrollBar;

View File

@ -321,7 +321,7 @@ bool GraphicsViewZoom::StartHorizontalScrollings(QWheelEvent *wheel_event)
* @param parent parent object. * @param parent parent object.
*/ */
VMainGraphicsView::VMainGraphicsView(QWidget *parent) VMainGraphicsView::VMainGraphicsView(QWidget *parent)
:QGraphicsView(parent), zoom(nullptr), showToolOptions(true) :QGraphicsView(parent), zoom(nullptr), showToolOptions(true), isAllowRubberBand(true)
{ {
zoom = new GraphicsViewZoom(this); zoom = new GraphicsViewZoom(this);
this->setResizeAnchor(QGraphicsView::AnchorUnderMouse); this->setResizeAnchor(QGraphicsView::AnchorUnderMouse);
@ -385,8 +385,11 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
switch (mousePress->button()) switch (mousePress->button())
{ {
case Qt::LeftButton: case Qt::LeftButton:
{
if (isAllowRubberBand)
{ {
QGraphicsView::setDragMode(QGraphicsView::RubberBandDrag); QGraphicsView::setDragMode(QGraphicsView::RubberBandDrag);
}
if (showToolOptions) if (showToolOptions)
{ {
QList<QGraphicsItem *> list = items(mousePress->pos()); QList<QGraphicsItem *> list = items(mousePress->pos());
@ -436,7 +439,7 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
*/ */
void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event) void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event)
{ {
QGraphicsView::mouseReleaseEvent ( event ); QGraphicsView::mouseReleaseEvent ( event ); // First because need to hide a rubber band
QGraphicsView::setDragMode( QGraphicsView::NoDrag ); QGraphicsView::setDragMode( QGraphicsView::NoDrag );
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
{ {
@ -450,6 +453,12 @@ void VMainGraphicsView::setShowToolOptions(bool value)
showToolOptions = value; showToolOptions = value;
} }
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsView::AllowRubberBand(bool value)
{
isAllowRubberBand = value;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view. * @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view.

View File

@ -109,6 +109,7 @@ public:
explicit VMainGraphicsView(QWidget *parent = nullptr); explicit VMainGraphicsView(QWidget *parent = nullptr);
void setShowToolOptions(bool value); void setShowToolOptions(bool value);
void AllowRubberBand(bool value);
static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view); static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view);
static QRectF SceneVisibleArea(QGraphicsView *view); static QRectF SceneVisibleArea(QGraphicsView *view);
@ -138,6 +139,7 @@ private:
Q_DISABLE_COPY(VMainGraphicsView) Q_DISABLE_COPY(VMainGraphicsView)
GraphicsViewZoom* zoom; GraphicsViewZoom* zoom;
bool showToolOptions; bool showToolOptions;
bool isAllowRubberBand;
}; };
#endif // VMAINGRAPHICSVIEW_H #endif // VMAINGRAPHICSVIEW_H

View File

@ -146,6 +146,18 @@ void VSimplePoint::EnableToolMove(bool move)
namePoint->setFlag(QGraphicsItem::ItemIsMovable, move); namePoint->setFlag(QGraphicsItem::ItemIsMovable, move);
} }
//---------------------------------------------------------------------------------------------------------------------
void VSimplePoint::AllowLabelHover(bool enabled)
{
namePoint->setAcceptHoverEvents(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VSimplePoint::AllowLabelSelecting(bool enabled)
{
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSimplePoint::DeleteFromLabel() void VSimplePoint::DeleteFromLabel()
{ {
@ -172,12 +184,20 @@ void VSimplePoint::ContextMenu(QGraphicsSceneContextMenuEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSimplePoint::mousePressEvent(QGraphicsSceneMouseEvent *event) 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
}
//---------------------------------------------------------------------------------------------------------------------
void VSimplePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
{ {
emit Choosed(id); emit Choosed(id);
} }
QGraphicsEllipseItem::mousePressEvent(event); QGraphicsEllipseItem::mouseReleaseEvent(event);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -55,6 +55,8 @@ public:
void RefreshGeometry(const VPointF &point); void RefreshGeometry(const VPointF &point);
void SetEnabled(bool enabled); void SetEnabled(bool enabled);
void EnableToolMove(bool move); void EnableToolMove(bool move);
void AllowLabelHover(bool enabled);
void AllowLabelSelecting(bool enabled);
QColor GetCurrentColor() const; QColor GetCurrentColor() const;
void SetCurrentColor(const QColor &value); void SetCurrentColor(const QColor &value);
@ -76,6 +78,7 @@ public slots:
protected: protected:
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) 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 hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;