-
Notifications
You must be signed in to change notification settings - Fork 105
/
distribute_points_tool.h
137 lines (114 loc) · 3.52 KB
/
distribute_points_tool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* Copyright 2013 Thomas Schöps
* Copyright 2015 Kai Pastor
*
* This file is part of OpenOrienteering.
*
* OpenOrienteering is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenOrienteering is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenOrienteering. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPENORIENTEERING_TOOL_DISTRIBUTE_POINTS_H
#define OPENORIENTEERING_TOOL_DISTRIBUTE_POINTS_H
#include <vector>
#include <QDialog>
#include <QObject>
#include <QString>
class QDoubleSpinBox;
class QCheckBox;
class QSpinBox;
class QWidget;
namespace OpenOrienteering {
class PathObject;
class PointObject;
class PointSymbol;
/**
* Provides methods to create evenly spaced point objects along a line.
*
* \todo Integrate implementation of MapEditorController::distributePointsClicked().
*/
class DistributePointsTool
{
public:
/** Required user input for applying the action. */
struct Settings
{
/** Number of points to create */
int num_points_per_line;
/** If true, points will also be placed at open paths ends,
* otherwise only inside for open paths*/
bool points_at_ends;
/** If true, points will be aligned with the path direction if rotatable */
bool rotate_symbols;
/** Additional rotation for rotatable point symbols,
* in radians counter-clockwise */
double additional_rotation;
/** Constructor, sets default values. */
constexpr Settings()
: num_points_per_line{ 3 }
, points_at_ends{ true }
, rotate_symbols{ true }
, additional_rotation{ 0.0 }
{
// Nothing else
}
};
/**
* Shows a settings dialog for the tool.
*
* If the user presses Ok, returns true and saves the chosen values to
* settings, otherwise returns false.
*
* The settings parameter is also used as initial values for the dialog.
* The point symbol is used to determine the enabled state of some options.
*/
static bool showSettingsDialog(
QWidget* parent,
const PointSymbol* point,
DistributePointsTool::Settings& settings
);
/**
* Executes the tool on the path, creating points according to settings.
*
* Appends the created objects to the out_objects vector, but does not add
* them to the map.
*/
static void execute(
const PathObject* path,
PointSymbol* point,
const DistributePointsTool::Settings& settings,
std::vector<PointObject*>& out_objects
);
};
/**
* Settings dialog for DistributePointsTool
*/
class DistributePointsSettingsDialog : public QDialog
{
Q_OBJECT
public:
/** Creates a new DistributePointsSettingsDialog. */
DistributePointsSettingsDialog(
QWidget* parent,
const PointSymbol* point,
const DistributePointsTool::Settings& settings
);
/** After the dialog finished successfully, returns the entered values. */
void getValues(DistributePointsTool::Settings& settings);
private:
QSpinBox* num_points_edit;
QCheckBox* points_at_ends_check;
QCheckBox* rotate_symbols_check;
QDoubleSpinBox* additional_rotation_edit;
};
} // namespace OpenOrienteering
#endif