42
42
struct placement : boost::noncopyable
44
placement(string_info & info_,
45
//path_type & shape_path_,
46
shield_symbolizer const& sym);
44
placement(string_info & info_, shield_symbolizer const& sym, bool has_dimensions_= false);
48
placement(string_info & info_,
49
//path_type & shape_path_,
50
text_symbolizer const& sym);
46
placement(string_info & info_, text_symbolizer const& sym);
55
//std::pair<double, double> get_position_at_distance(double target_distance);
56
//double get_total_distance();
58
50
string_info & info;
59
//path_type & shape_path;
60
//double total_distance_; //cache for distance
62
52
position displacement_;
63
53
label_placement_e label_placement;
78
68
double minimum_distance;
80
70
bool has_dimensions;
81
72
std::pair<double, double> dimensions;
84
77
template <typename DetectorT>
85
78
class placement_finder : boost::noncopyable
88
placement_finder(DetectorT & detector);
90
//Try place a single label at the given point
91
void find_point_placement(placement & p, double, double);
93
//Iterate over the given path, placing point labels with respect to label_spacing
95
void find_point_placements(placement & p, T & path);
97
//Iterate over the given path, placing line-following labels with respect to label_spacing
99
void find_line_placements(placement & p, T & path);
104
///Helpers for find_line_placement
106
///Returns a possible placement on the given line, does not test for collisions
107
//index: index of the node the current line ends on
108
//distance: distance along the given index that the placement should start at, this includes the offset,
109
// as such it may be > or < the length of the current line, so this must be checked for
110
//orientation: if set to != 0 the placement will be attempted with the given orientation
111
// otherwise it will autodetect the orientation.
112
// If >= 50% of the characters end up upside down, it will be retried the other way.
113
// RETURN: 1/-1 depending which way up the string ends up being.
114
std::auto_ptr<placement_element> get_placement_offset(placement & p, const std::vector<vertex2d> & path_positions, const std::vector<double> & path_distances, int & orientation, unsigned index, double distance);
116
///Tests wether the given placement_element be placed without a collision
117
// Returns true if it can
118
// NOTE: This edits p.envelopes so it can be used afterwards (you must clear it otherwise)
119
bool test_placement(placement & p, const std::auto_ptr<placement_element> & current_placement, const int & orientation);
121
///Does a line-circle intersect calculation
122
// NOTE: Follow the strict pre conditions
123
// Pre Conditions: x1,y1 is within radius distance of cx,cy. x2,y2 is outside radius distance of cx,cy
124
// This means there is exactly one intersect point
125
// Result is returned in ix, iy
126
void find_line_circle_intersection(
127
const double &cx, const double &cy, const double &radius,
128
const double &x1, const double &y1, const double &x2, const double &y2,
129
double &ix, double &iy);
133
void update_detector(placement & p);
135
DetectorT & detector_;
136
Envelope<double> const& dimensions_;
81
placement_finder(DetectorT & detector);
83
//Try place a single label at the given point
84
void find_point_placement(placement & p, double pos_x, double pos_y, vertical_alignment_e = MIDDLE);
86
//Iterate over the given path, placing point labels with respect to label_spacing
88
void find_point_placements(placement & p, T & path);
90
//Iterate over the given path, placing line-following labels with respect to label_spacing
92
void find_line_placements(placement & p, T & path);
94
void update_detector(placement & p);
99
///Helpers for find_line_placement
101
///Returns a possible placement on the given line, does not test for collisions
102
//index: index of the node the current line ends on
103
//distance: distance along the given index that the placement should start at, this includes the offset,
104
// as such it may be > or < the length of the current line, so this must be checked for
105
//orientation: if set to != 0 the placement will be attempted with the given orientation
106
// otherwise it will autodetect the orientation.
107
// If >= 50% of the characters end up upside down, it will be retried the other way.
108
// RETURN: 1/-1 depending which way up the string ends up being.
109
std::auto_ptr<placement_element> get_placement_offset(placement & p,
110
const std::vector<vertex2d> & path_positions,
111
const std::vector<double> & path_distances,
112
int & orientation, unsigned index, double distance);
114
///Tests wether the given placement_element be placed without a collision
115
// Returns true if it can
116
// NOTE: This edits p.envelopes so it can be used afterwards (you must clear it otherwise)
117
bool test_placement(placement & p, const std::auto_ptr<placement_element> & current_placement, const int & orientation);
119
///Does a line-circle intersect calculation
120
// NOTE: Follow the strict pre conditions
121
// Pre Conditions: x1,y1 is within radius distance of cx,cy. x2,y2 is outside radius distance of cx,cy
122
// This means there is exactly one intersect point
123
// Result is returned in ix, iy
124
void find_line_circle_intersection(
125
const double &cx, const double &cy, const double &radius,
126
const double &x1, const double &y1, const double &x2, const double &y2,
127
double &ix, double &iy);
133
DetectorT & detector_;
134
Envelope<double> const& dimensions_;