diff --git a/dlib/gui_widgets/base_widgets.cpp b/dlib/gui_widgets/base_widgets.cpp index 898692e43..4e4b3c7d1 100644 --- a/dlib/gui_widgets/base_widgets.cpp +++ b/dlib/gui_widgets/base_widgets.cpp @@ -2071,9 +2071,9 @@ namespace dlib parent.invalidate_rectangle(rect+old); const double old_scale = scale; - const vector old_gr_orig(gr_orig); + const vector old_gr_orig(gr_orig); scale = min_scale; - gr_orig = vector(0,0,0); + gr_orig = vector(0,0); lr_point = gui_to_graph_space(point(display_rect_.right(),display_rect_.bottom())); scale = old_scale; @@ -2148,24 +2148,22 @@ namespace dlib point zoomable_region:: graph_to_gui_space ( - const vector& p + const vector& p ) const { const point rect_corner(display_rect_.left(), display_rect_.top()); - const dlib::vector v(p); - return (v - gr_orig)*scale + rect_corner; + return (p - gr_orig)*scale + rect_corner; } // ---------------------------------------------------------------------------------------- - vector zoomable_region:: + vector zoomable_region:: gui_to_graph_space ( const point& p ) const { const point rect_corner(display_rect_.left(), display_rect_.top()); - const dlib::vector v(p - rect_corner); - return v/scale + gr_orig; + return (p - rect_corner)/scale + gr_orig; } // ---------------------------------------------------------------------------------------- @@ -2217,7 +2215,7 @@ namespace dlib void zoomable_region:: center_display_at_graph_point ( - const vector& p + const vector& p ) { // find the point in the center of the graph area @@ -2363,11 +2361,11 @@ namespace dlib void zoomable_region:: adjust_origin ( const point& gui_p, - const vector& graph_p + const vector& graph_p ) { const point rect_corner(display_rect_.left(), display_rect_.top()); - const dlib::vector v(gui_p - rect_corner); + const dlib::vector v(gui_p - rect_corner); gr_orig = graph_p - v/scale; @@ -2380,8 +2378,8 @@ namespace dlib // make sure the lower right corner of the display_rect_ doesn't map to a point beyond lr_point point lr_rect_corner(display_rect_.right(), display_rect_.bottom()); point p = graph_to_gui_space(lr_point); - vector lr_rect_corner_graph_space(gui_to_graph_space(lr_rect_corner)); - vector delta(lr_point - lr_rect_corner_graph_space); + vector lr_rect_corner_graph_space(gui_to_graph_space(lr_rect_corner)); + vector delta(lr_point - lr_rect_corner_graph_space); if (lr_rect_corner.x() > p.x()) { gr_orig.x() += delta.x(); @@ -2393,7 +2391,7 @@ namespace dlib } - const vector ul_rect_corner_graph_space(gui_to_graph_space(rect_corner)); + const vector ul_rect_corner_graph_space(gui_to_graph_space(rect_corner)); lr_rect_corner_graph_space = gui_to_graph_space(lr_rect_corner); // now adjust the scroll bars diff --git a/dlib/gui_widgets/base_widgets.h b/dlib/gui_widgets/base_widgets.h index de9531ce9..1109780cd 100644 --- a/dlib/gui_widgets/base_widgets.h +++ b/dlib/gui_widgets/base_widgets.h @@ -2155,10 +2155,10 @@ namespace dlib protected: point graph_to_gui_space ( - const vector& p + const vector& p ) const; - vector gui_to_graph_space ( + vector gui_to_graph_space ( const point& p ) const; @@ -2176,7 +2176,7 @@ namespace dlib ); void center_display_at_graph_point ( - const vector& p + const vector& p ); // ----------- event handlers --------------- @@ -2227,7 +2227,7 @@ namespace dlib void adjust_origin ( const point& gui_p, - const vector& graph_p + const vector& graph_p ); /*! ensures @@ -2237,8 +2237,8 @@ namespace dlib !*/ - vector gr_orig; // point in graph space such that it's gui space point is the upper left of display_rect_ - vector lr_point; // point in graph space such that it is at the lower right corner of the screen at max zoom + vector gr_orig; // point in graph space such that it's gui space point is the upper left of display_rect_ + vector lr_point; // point in graph space such that it is at the lower right corner of the screen at max zoom mutable std::ostringstream sout; @@ -2249,7 +2249,7 @@ namespace dlib rectangle display_rect_; bool mouse_drag_screen; // true if the user is dragging the white background area - vector drag_screen_point; // the starting point the mouse was at in graph space for the background area drag + vector drag_screen_point; // the starting point the mouse was at in graph space for the background area drag scroll_bar vsb; scroll_bar hsb; diff --git a/dlib/gui_widgets/base_widgets_abstract.h b/dlib/gui_widgets/base_widgets_abstract.h index 0f8dfa292..569f68b2b 100644 --- a/dlib/gui_widgets/base_widgets_abstract.h +++ b/dlib/gui_widgets/base_widgets_abstract.h @@ -1599,9 +1599,6 @@ namespace dlib determined automatically from the size of this object's on screen rectangle and the value of min_zoom_scale() which determines how far out you can zoom. - - Also note that while dlib::vector is used to represent graph points - the z field is always ignored by this object. */ public: @@ -1719,7 +1716,7 @@ namespace dlib !*/ point graph_to_gui_space ( - const vector& graph_point + const vector& graph_point ) const; /*! requires @@ -1729,7 +1726,7 @@ namespace dlib to the given point in Cartesian graph space !*/ - vector gui_to_graph_space ( + vector gui_to_graph_space ( const point& pixel_point ) const; /*! @@ -1740,7 +1737,7 @@ namespace dlib pixel location !*/ - vector max_graph_point ( + vector max_graph_point ( ) const; /*! requires @@ -1782,7 +1779,7 @@ namespace dlib !*/ void center_display_at_graph_point ( - const vector& graph_point + const vector& graph_point ); /*! requires diff --git a/dlib/gui_widgets/widgets.h b/dlib/gui_widgets/widgets.h index a1660b560..2c90e0aee 100644 --- a/dlib/gui_widgets/widgets.h +++ b/dlib/gui_widgets/widgets.h @@ -2091,11 +2091,11 @@ namespace dlib } bool click_hit_node = false; - dlib::vector p(gui_to_graph_space(point(x,y))); + dlib::vector p(gui_to_graph_space(point(x,y))); // check if this click is on an existing node for (unsigned long i = 0; i < graph_.number_of_nodes(); ++i) { - dlib::vector n(graph_.node(i).data.p); + dlib::vector n(graph_.node(i).data.p); if ((p-n).length() < radius) { click_hit_node = true; @@ -2135,10 +2135,10 @@ namespace dlib { for (unsigned long n = 0; n < graph_.number_of_nodes() && edge_selected == false; ++n) { - const dlib::vector parent_center(graph_to_gui_space(graph_.node(n).data.p)); + const dlib::vector parent_center(graph_to_gui_space(graph_.node(n).data.p)); for (unsigned long e = 0; e < graph_.node(n).number_of_children() && edge_selected == false; ++e) { - const dlib::vector child_center(graph_to_gui_space(graph_.node(n).child(e).data.p)); + const dlib::vector child_center(graph_to_gui_space(graph_.node(n).child(e).data.p)); rectangle area; area += parent_center; @@ -2149,7 +2149,7 @@ namespace dlib p = point(x,y); const dlib::vector z(0,0,1); // find the distance from the line between the two nodes - const dlib::vector perpendicular(z.cross(parent_center-child_center).normalize()); + const dlib::vector perpendicular(z.cross(parent_center-child_center).normalize()); double distance = std::abs((child_center-p).dot(perpendicular)); if (distance < 8) { @@ -2197,11 +2197,11 @@ namespace dlib (state & base_window::SHIFT) && selected_node != graph_.number_of_nodes() ) { - dlib::vector p(gui_to_graph_space(point(x,y))); + dlib::vector p(gui_to_graph_space(point(x,y))); // check if this click is on an existing node for (unsigned long i = 0; i < graph_.number_of_nodes(); ++i) { - dlib::vector n(graph_.node(i).data.p); + dlib::vector n(graph_.node(i).data.p); if ((p-n).length() < radius) { // add the edge if it doesn't already exist and isn't an edge back to @@ -2272,7 +2272,7 @@ namespace dlib color.red = 255; // we need to be careful when drawing this line to not draw it over the node dots since it // has a different color from them and would look weird - dlib::vector v(p-center); + dlib::vector v(p-center); v = v.normalize()*rad; draw_line(c,center+v,p-v ,color, area); } @@ -2285,11 +2285,11 @@ namespace dlib // draw the triangle pointing to this node if (area.intersect(circle_area).is_empty() == false) { - dlib::vector v(p-center); + dlib::vector v(p-center); v = v.normalize(); - dlib::vector cross = z.cross(v).normalize(); - dlib::vector r(center + v*rad); + dlib::vector cross = z.cross(v).normalize(); + dlib::vector r(center + v*rad); for (double i = 0; i < 8*zoom_scale(); i += 0.1) draw_line(c,(r+v*i)+cross*i, (r+v*i)-cross*i,color,area); }