27 #ifndef SCRIBO_PRIMITIVE_LINK_INTERNAL_COMPUTE_ANCHOR_HH
28 # define SCRIBO_PRIMITIVE_LINK_INTERNAL_COMPUTE_ANCHOR_HH
34 # include <mln/math/min.hh>
36 # include <scribo/core/tag/anchor.hh>
37 # include <scribo/core/component_set.hh>
78 compute_anchor(const component_set<L>&
components,
79 unsigned current_object, anchor::Type anchor);
82 # ifndef MLN_INCLUDE_ONLY
86 compute_anchor(const component_set<L>& components,
87 unsigned current_object, anchor::Type anchor)
89 typedef mln_site(L) P;
91 unsigned h = components(current_object).
bbox().
height();
92 unsigned w = components(current_object).
bbox().width();
94 mln_site(L) sp = components(current_object).
bbox().pcenter();
99 case anchor::MassCenter:
100 return components(current_object).mass_center();
106 sp.row() =
components(current_object).bbox().pmin().row()
109 sp.row() =
components(current_object).bbox().pmin().row()
115 case anchor::StrictTopCenter:
116 sp.row() =
components(current_object).bbox().pmin().row();
121 case anchor::TopStrictLeft:
122 sp.col() =
components(current_object).bbox().pmin().col();
123 sp.row() =
components(current_object).bbox().pmin().row()
129 case anchor::BottomStrictRight:
130 sp.col() =
components(current_object).bbox().pmax().col();
131 sp.row() =
components(current_object).bbox().pmax().row()
139 sp.row() =
components(current_object).bbox().pmax().row()
142 sp.row() =
components(current_object).bbox().pmax().row()
148 case anchor::StrictBottomCenter:
149 sp.row() =
components(current_object).bbox().pmax().row();
155 return components(current_object).bbox().pcenter();
159 case anchor::StrictLeft:
167 sp.col() =
components(current_object).bbox().pmin().col()
170 sp.col() =
components(current_object).bbox().pmin().col()
176 case anchor::StrictRight:
184 sp.col() =
components(current_object).bbox().pmax().col()
187 sp.col() =
components(current_object).bbox().pmax().col()
193 case anchor::TopLeft:
195 sp.row() =
components(current_object).bbox().pmin().row()
198 sp.row() =
components(current_object).bbox().pmin().row()
201 sp.col() =
components(current_object).bbox().pmin().col()
204 sp.col() =
components(current_object).bbox().pmin().col()
210 case anchor::TopRight:
212 sp.row() =
components(current_object).bbox().pmin().row()
215 sp.row() =
components(current_object).bbox().pmin().row()
218 sp.col() =
components(current_object).bbox().pmax().col()
221 sp.col() =
components(current_object).bbox().pmax().col()
227 case anchor::BottomLeft:
229 sp.row() =
components(current_object).bbox().pmax().row()
232 sp.row() =
components(current_object).bbox().pmax().row()
235 sp.col() =
components(current_object).bbox().pmin().col()
238 sp.col() =
components(current_object).bbox().pmin().col()
243 case anchor::BottomRight:
245 sp.row() =
components(current_object).bbox().pmax().row()
248 sp.row() =
components(current_object).bbox().pmax().row()
251 sp.col() =
components(current_object).bbox().pmax().col()
254 sp.col() =
components(current_object).bbox().pmax().col()
261 mln_trace_warning(
"Non handled anchor");
262 mln_assertion(anchor < anchor::Invalid);
268 # endif // ! MLN_INCLUDE_ONLY
278 #endif // ! SCRIBO_PRIMITIVE_LINK_INTERNAL_COMPUTE_ANCHOR_HH