Commit e3818c4e authored by Davis King's avatar Davis King

Added the option to draw crossed out rectangles onto the image_display widget.

parent edeb4f86
...@@ -5978,6 +5978,20 @@ namespace dlib ...@@ -5978,6 +5978,20 @@ namespace dlib
mfont->draw_string(c, r, itr->first, overlay_rects[i].color, 0, mfont->draw_string(c, r, itr->first, overlay_rects[i].color, 0,
std::string::npos, area); std::string::npos, area);
} }
if (overlay_rects[i].crossed_out)
{
if (rect_is_selected && selected_rect == i)
{
draw_line(c, orect.tl_corner(), orect.br_corner(),invert_pixel(overlay_rects[i].color), area);
draw_line(c, orect.bl_corner(), orect.tr_corner(),invert_pixel(overlay_rects[i].color), area);
}
else
{
draw_line(c, orect.tl_corner(), orect.br_corner(),overlay_rects[i].color, area);
draw_line(c, orect.bl_corner(), orect.tr_corner(),overlay_rects[i].color, area);
}
}
} }
// now draw all the overlay lines // now draw all the overlay lines
...@@ -6039,6 +6053,15 @@ namespace dlib ...@@ -6039,6 +6053,15 @@ namespace dlib
if (event_handler.is_set()) if (event_handler.is_set())
event_handler(); event_handler();
} }
if (is_printable && !hidden && enabled && rect_is_selected && (key == 'i'))
{
overlay_rects[selected_rect].crossed_out = !overlay_rects[selected_rect].crossed_out;
parent.invalidate_rectangle(rect);
if (event_handler.is_set())
event_handler();
}
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -3292,24 +3292,25 @@ namespace dlib ...@@ -3292,24 +3292,25 @@ namespace dlib
struct overlay_rect struct overlay_rect
{ {
overlay_rect() { assign_pixel(color, 0);} overlay_rect() :crossed_out(false) { assign_pixel(color, 0);}
template <typename pixel_type> template <typename pixel_type>
overlay_rect(const rectangle& r, pixel_type p) overlay_rect(const rectangle& r, pixel_type p)
: rect(r) { assign_pixel(color, p); } : rect(r),crossed_out(false) { assign_pixel(color, p); }
template <typename pixel_type> template <typename pixel_type>
overlay_rect(const rectangle& r, pixel_type p, const std::string& l) overlay_rect(const rectangle& r, pixel_type p, const std::string& l)
: rect(r),label(l) { assign_pixel(color, p); } : rect(r),label(l),crossed_out(false) { assign_pixel(color, p); }
template <typename pixel_type> template <typename pixel_type>
overlay_rect(const rectangle& r, pixel_type p, const std::string& l, const std::map<std::string,point>& parts_) overlay_rect(const rectangle& r, pixel_type p, const std::string& l, const std::map<std::string,point>& parts_)
: rect(r),label(l),parts(parts_) { assign_pixel(color, p); } : rect(r),label(l),parts(parts_),crossed_out(false) { assign_pixel(color, p); }
rectangle rect; rectangle rect;
rgb_alpha_pixel color; rgb_alpha_pixel color;
std::string label; std::string label;
std::map<std::string,point> parts; std::map<std::string,point> parts;
bool crossed_out;
}; };
struct overlay_line struct overlay_line
......
...@@ -2394,12 +2394,16 @@ namespace dlib ...@@ -2394,12 +2394,16 @@ namespace dlib
Moreover, the rectangle can have sub-parts. Each part is listed Moreover, the rectangle can have sub-parts. Each part is listed
in the parts member variable. This variable maps the name of the in the parts member variable. This variable maps the name of the
part to its position. part to its position.
Rectangles with crossed_out == true will be drawn with an X through
them.
!*/ !*/
rectangle rect; rectangle rect;
rgb_alpha_pixel color; rgb_alpha_pixel color;
std::string label; std::string label;
std::map<std::string,point> parts; std::map<std::string,point> parts;
bool crossed_out;
overlay_rect( overlay_rect(
); );
...@@ -2408,6 +2412,7 @@ namespace dlib ...@@ -2408,6 +2412,7 @@ namespace dlib
- #color == rgb_alpha_pixel(0,0,0,0) - #color == rgb_alpha_pixel(0,0,0,0)
- #rect == rectangle() - #rect == rectangle()
- #label.size() == 0 - #label.size() == 0
- #crossed_out == false
!*/ !*/
template <typename pixel_type> template <typename pixel_type>
...@@ -2420,6 +2425,7 @@ namespace dlib ...@@ -2420,6 +2425,7 @@ namespace dlib
- #rect == r - #rect == r
- performs assign_pixel(color, p) - performs assign_pixel(color, p)
- #label.size() == 0 - #label.size() == 0
- #crossed_out == false
!*/ !*/
template <typename pixel_type> template <typename pixel_type>
...@@ -2433,6 +2439,7 @@ namespace dlib ...@@ -2433,6 +2439,7 @@ namespace dlib
- #rect == r - #rect == r
- performs assign_pixel(color, p) - performs assign_pixel(color, p)
- #label == l - #label == l
- #crossed_out == false
!*/ !*/
template <typename pixel_type> template <typename pixel_type>
...@@ -2448,6 +2455,7 @@ namespace dlib ...@@ -2448,6 +2455,7 @@ namespace dlib
- performs assign_pixel(color, p) - performs assign_pixel(color, p)
- #label == l - #label == l
- #parts == parts_ - #parts == parts_
- #crossed_out == false
!*/ !*/
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment