Skip to content

Commit

Permalink
Consider dash symbols in combined symbols
Browse files Browse the repository at this point in the history
When drawing line objects for symbols with dash symbols, no dash
points were set automatically if the symbol was a combined symbol.
When editing line objects for symbols with dash symbols, additional
points were not added as dash points if the symbol was a combined
symbol.
These deviations were known and marked as TODO.
This commit treats line symbols with dash symbols and combined symbols
containing line symbols with dash symbols equally.
  • Loading branch information
dl3sdo committed Jun 26, 2023
1 parent e76528b commit 044165a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
19 changes: 7 additions & 12 deletions src/tools/draw_path_tool.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2012-2014 Thomas Schöps
* Copyright 2013-2020 Kai Pastor
* Copyright 2013-2023 Kai Pastor
*
* This file is part of OpenOrienteering.
*
Expand Down Expand Up @@ -30,8 +30,8 @@
#include <QColor>
#include <QCursor>
#include <QFlags>
#include <QLatin1String>
#include <QKeyEvent>
#include <QLatin1String>
#include <QLineF>
#include <QLocale>
#include <QMouseEvent>
Expand Down Expand Up @@ -1119,19 +1119,14 @@ void DrawPathTool::updateDashPointDrawing()
if (is_helper_tool)
return;

Symbol* symbol = editor->activeSymbol();
if (symbol && symbol->getType() == Symbol::Line)
const Symbol* symbol = editor->activeSymbol();
// Auto-activate dash points depending on if the selected symbol has a dash symbol.
if (symbolContainsDashSymbol(symbol))
{
// Auto-activate dash points depending on if the selected symbol has a dash symbol.
// TODO: instead of just looking if it is a line symbol with dash points,
// could also check for combined symbols containing lines with dash points
draw_dash_points = (symbol->asLine()->getDashSymbol());

draw_dash_points = true;
updateStatusText();
}
else if (symbol &&
(symbol->getType() == Symbol::Area ||
symbol->getType() == Symbol::Combined))
else
{
draw_dash_points = false;
}
Expand Down
10 changes: 3 additions & 7 deletions src/tools/edit_point_tool.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2012-2014 Thomas Schöps
* Copyright 2013-2017 Kai Pastor
* Copyright 2013-2023 Kai Pastor
*
* This file is part of OpenOrienteering.
*
Expand Down Expand Up @@ -98,11 +98,7 @@ EditPointTool::~EditPointTool()
bool EditPointTool::addDashPointDefault() const
{
// Toggle dash points depending on if the selected symbol has a dash symbol.
// TODO: instead of just looking if it is a line symbol with dash points,
// could also check for combined symbols containing lines with dash points
return ( hover_object &&
hover_object->getSymbol()->getType() == Symbol::Line &&
hover_object->getSymbol()->asLine()->getDashSymbol() != nullptr );
return (hover_object && symbolContainsDashSymbol(hover_object->getSymbol()));
}

bool EditPointTool::mousePressEvent(QMouseEvent* event, const MapCoordF& map_coord, MapWidget* widget)
Expand Down Expand Up @@ -185,7 +181,7 @@ void EditPointTool::clickPress()
startDragging();
hover_state = OverObjectNode;
hover_point = path->subdivide(closest.path_coord);
if (addDashPointDefault() ^ switch_dash_points)
if (addDashPointDefault() != switch_dash_points)
{
auto point = path->getCoordinate(hover_point);
point.setDashPoint(true);
Expand Down

0 comments on commit 044165a

Please sign in to comment.