Tableau to rubberband circles, lines etc. More...
#include <vgui_rubberband_tableau.h>
Public Member Functions | |
void | init (vgui_rubberband_client *client) |
Initialise vgui_rubberband_tableau. | |
vgui_rubberband_tableau (vgui_rubberband_client *client) | |
Constructor - don't use this, use vgui_rubberband_tableau_new. | |
vcl_string | type_name () const |
Return the type of this tableau ('vgui_rubberband_tableau'). | |
void | rubberband_point () |
void | rubberband_line () |
void | rubberband_infinite_line () |
void | rubberband_circle () |
void | rubberband_polygon () |
void | rubberband_linestrip () |
void | rubberband_box () |
void | rubberband_none () |
vgui_rubberband_client * | get_client () |
void | set_client (vgui_rubberband_client *client) |
void | draw_point (float x0, float y0) |
Render the given point. | |
void | draw_line (float x0, float y0, float x1, float y1) |
Render the finite line between the given points. | |
void | draw_infinite_line (float a, float b, float c) |
Render the infinite line ax + by + c = 0. | |
void | draw_circle (float x0, float y0, float r) |
Render the rubber circle. | |
void | draw_linestrip (float x, float y) |
Render the rubber line strip. | |
void | draw_polygon (float x, float y) |
Render the rubber polygon. | |
void | draw_box (float x0, float y0, float x1, float y1) |
Render rubber box. | |
virtual vcl_string | name () const |
Return the name of the tableau. | |
virtual vcl_string | file_name () const |
Return the name of a file associated with some tableau below (if meaningful). | |
virtual vcl_string | pretty_name () const |
Used to provide an informative name for printouts, debugging etc. | |
void | get_parents (vcl_vector< vgui_tableau_sptr > *out) const |
Get the parent tableaux for this tableau. | |
void | get_children (vcl_vector< vgui_tableau_sptr > *out) const |
Get the child tableaux for this tableau. | |
vgui_tableau_sptr | get_child (unsigned i) const |
Get the ith child or return 0. | |
virtual bool | add_child (vgui_tableau_sptr const &) |
Add the given tableau to the list of child tableaux. | |
virtual bool | remove_child (vgui_tableau_sptr const &) |
Remove the given child from the list of child tableaux. | |
virtual bool | notify_replaced_child (vgui_tableau_sptr const &old_child, vgui_tableau_sptr const &new_child) |
Called whenever a child of this tableau is about to be forcibly replaced. | |
virtual void | add_popup (vgui_menu &) |
Add the given menu to the popup menu for the tableau. | |
virtual void | get_popup (vgui_popup_params const &, vgui_menu &) |
Get the default popup menu for the tableau. | |
virtual void | post_message (char const *, void const *) |
Post a message event. | |
virtual void | post_redraw () |
Post a draw event. | |
virtual void | post_overlay_redraw () |
Post an overlay-redraw event. | |
virtual void | post_idle_request () |
Post an idle request event. | |
virtual bool | get_bounding_box (float low[3], float high[3]) const |
Get the bounding box of this tableau. | |
virtual bool | draw () |
Called by default handle when it receives a draw event. | |
virtual bool | mouse_down (int x, int y, vgui_button, vgui_modifier) |
Called by default handle when it receives a mouse down event. | |
virtual bool | mouse_up (int x, int y, vgui_button, vgui_modifier) |
Called by default handle when it receives a mouse up event. | |
virtual bool | motion (int x, int y) |
Called by handle when it receives a mouse motion event. | |
virtual bool | key_press (int x, int y, vgui_key, vgui_modifier) |
Called by default handle when it receives a key-press event. | |
virtual bool | help () |
Called by default handle when it receives a '?' pressed event. | |
virtual bool | idle () |
Called when the application is otherwise idle. | |
void | ref () const |
Increase the reference count by one (for smart pointers). | |
void | unref () const |
Decrease the reference count by one (for smart pointers). | |
Static Public Member Functions | |
static void | get_all (vcl_vector< vgui_tableau_sptr > *out) |
Push all tableaux onto the given vector. | |
static bool | exists (vgui_tableau_sptr const &) |
Returns true if the given address points to a valid tableau. | |
Public Attributes | |
bool | use_overlays |
Whether to use overlays or not. | |
vgui_event_condition | gesture0 |
vgui_event_condition | gesture1 |
vgui_event_condition | gesture2 |
Protected Member Functions | |
~vgui_rubberband_tableau () | |
bool | handle_point (vgui_event const &, float, float) |
bool | handle_line (vgui_event const &, float, float) |
bool | handle_linestrip (vgui_event const &, float, float) |
bool | handle_infinite_line (vgui_event const &, float, float) |
bool | handle_circle (vgui_event const &, float, float) |
bool | handle_polygon (vgui_event const &, float, float) |
bool | handle_box (vgui_event const &, float, float) |
bool | handle (vgui_event const &) |
Handle all events sent to this tableau. | |
Private Types | |
enum | object_type { none_enum, point_enum, line_enum, infinite_line_enum, circle_enum, polygon_enum, linestrip_enum, box_enum } |
Private Attributes | |
vgui_rubberband_client * | client_ |
bool | active |
float | lastx |
float | lasty |
vcl_vector< float > | x_coords |
vcl_vector< float > | y_coords |
Static Private Attributes | |
static object_type | obj_type = none_enum |
Tableau to rubberband circles, lines etc.
The values captured (eg. two points defining a line) are passed to the appropriate function (eg. add_line) in the client passed in to the constructor. This client is derived from vgui_rubberband_client.
In more detail:
The user draws the object in the rendering area using the defined 'gestures'. For example, to draw a line, the first gesture is a mouse down event defining the start point. A line is shown on the display between the start point and the mouse pointer until the second gesture is performed (releasing the mouse button) and this defines the end point.
These values are passed to add_line in the client. These values could be used to draw the line (like vgui_rubberband_easy2D_client) or you can create your own client derived from vgui_rubberband_client to do something different.
See xcv to see a rubberbander in action (used to add geometric objects).
If you want to get values from a user and you want your code to wait until the values have been collected then rubberbander won't do this. You need to write something like ./oxl/xcv/xcv_picker_tableau that grabs the event loop.
Definition at line 141 of file vgui_rubberband_tableau.h.
enum vgui_rubberband_tableau::object_type [private] |
none_enum | |
point_enum | |
line_enum | |
infinite_line_enum | |
circle_enum | |
polygon_enum | |
linestrip_enum | |
box_enum |
Definition at line 197 of file vgui_rubberband_tableau.h.
vgui_rubberband_tableau::vgui_rubberband_tableau | ( | vgui_rubberband_client * | client | ) | [inline] |
Constructor - don't use this, use vgui_rubberband_tableau_new.
Takes the vgui_rubberband_client as a parameter.
Definition at line 152 of file vgui_rubberband_tableau.h.
vgui_rubberband_tableau::~vgui_rubberband_tableau | ( | ) | [inline, protected] |
Definition at line 185 of file vgui_rubberband_tableau.h.
bool vgui_tableau::add_child | ( | vgui_tableau_sptr const & | ) | [virtual, inherited] |
Add the given tableau to the list of child tableaux.
Virtual overridden by consenting parents.
Reimplemented in vgui_composite_tableau, vgui_selector_tableau, vgui_deck_tableau, and vgui_wrapper_tableau.
Definition at line 284 of file vgui_tableau.cxx.
void vgui_tableau::add_popup | ( | vgui_menu & | ) | [virtual, inherited] |
Add the given menu to the popup menu for the tableau.
Add given menu to the tableau popup menu.
This method is for tableaux to implement if they want to _add_ some items to the popup menu. They can assign to or clear 'menu', but that is not recommended as it would remove what other tableaux put there. The recommended usage is to .add() items or to .include() another menu.
** This is an interface method. it abstracts a behaviour. **
Reimplemented in vgui_satellite_tableau_t< object, data >, vgui_active_tableau, and vgui_clear_tableau.
Definition at line 316 of file vgui_tableau.cxx.
bool vgui_tableau::draw | ( | ) | [virtual, inherited] |
Called by default handle when it receives a draw event.
Reimplemented in vgui_function_tableau.
Definition at line 176 of file vgui_tableau.cxx.
void vgui_rubberband_tableau::draw_box | ( | float | x0, |
float | y0, | ||
float | x1, | ||
float | y1 | ||
) |
Render rubber box.
Definition at line 268 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::draw_circle | ( | float | x0, |
float | y0, | ||
float | r | ||
) |
Render the rubber circle.
Definition at line 231 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::draw_infinite_line | ( | float | a, |
float | b, | ||
float | c | ||
) |
Render the infinite line ax + by + c = 0.
Definition at line 210 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::draw_line | ( | float | x0, |
float | y0, | ||
float | x1, | ||
float | y1 | ||
) |
Render the finite line between the given points.
Definition at line 198 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::draw_linestrip | ( | float | x, |
float | y | ||
) |
Render the rubber line strip.
Definition at line 288 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::draw_point | ( | float | x0, |
float | y0 | ||
) |
Render the given point.
Definition at line 186 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::draw_polygon | ( | float | x, |
float | y | ||
) |
Render the rubber polygon.
Definition at line 246 of file vgui_rubberband_tableau.cxx.
bool vgui_tableau::exists | ( | vgui_tableau_sptr const & | ptr | ) | [static, inherited] |
Returns true if the given address points to a valid tableau.
Definition at line 385 of file vgui_tableau.cxx.
virtual vcl_string vgui_tableau::file_name | ( | ) | const [inline, virtual, inherited] |
Return the name of a file associated with some tableau below (if meaningful).
Reimplemented in vgui_easy2D_tableau, vgui_deck_tableau, vgui_composite_tableau, vgui_blender_tableau, vgui_roi_tableau, vgui_enhance_tableau, vgui_selector_tableau, vgui_image_tableau, vgui_wrapper_tableau, and vgui_vrml_tableau.
Definition at line 93 of file vgui_tableau.h.
void vgui_tableau::get_all | ( | vcl_vector< vgui_tableau_sptr > * | out | ) | [static, inherited] |
Push all tableaux onto the given vector.
Definition at line 376 of file vgui_tableau.cxx.
bool vgui_tableau::get_bounding_box | ( | float | low[3], |
float | high[3] | ||
) | const [virtual, inherited] |
Get the bounding box of this tableau.
Return the bounding box of this tableau.
If infinite in extent, or nothing is drawn, or you can't be bothered to implement it, return false. const. if you need to cache, cast away const.
If infinite in extent, or nothing is drawn, or you can't be bothered to implement it, return false.
Reimplemented in vgui_composite_tableau, vgui_selector_tableau, vgui_image_tableau, vgui_roi_tableau, and vgui_wrapper_tableau.
Definition at line 198 of file vgui_tableau.cxx.
vgui_tableau_sptr vgui_tableau::get_child | ( | unsigned | i | ) | const [inherited] |
Get the ith child or return 0.
Get the ith child, or return 0.
Definition at line 274 of file vgui_tableau.cxx.
void vgui_tableau::get_children | ( | vcl_vector< vgui_tableau_sptr > * | out | ) | const [inherited] |
Get the child tableaux for this tableau.
Push children onto the given vcl_vector.
Definition at line 267 of file vgui_tableau.cxx.
vgui_rubberband_client* vgui_rubberband_tableau::get_client | ( | ) | [inline] |
Definition at line 173 of file vgui_rubberband_tableau.h.
void vgui_tableau::get_parents | ( | vcl_vector< vgui_tableau_sptr > * | out | ) | const [inherited] |
Get the parent tableaux for this tableau.
Push parents onto the given vcl_vector.
Definition at line 260 of file vgui_tableau.cxx.
void vgui_tableau::get_popup | ( | vgui_popup_params const & | params, |
vgui_menu & | menu | ||
) | [virtual, inherited] |
Get the default popup menu for the tableau.
Gets popup menu for this tableau.
If recurse is, true, recursively add the popup menus for children and children's children etc.
** this is a mixin method. it does some work for you. **
Reimplemented in vgui_image_tableau, vgui_shell_tableau, vgui_deck_tableau, vgui_poly_tableau, vgui_selector_tableau, vgui_tview_launcher_tableau, and vgui_tview_tableau.
Definition at line 327 of file vgui_tableau.cxx.
bool vgui_rubberband_tableau::handle | ( | vgui_event const & | event | ) | [protected, virtual] |
Handle all events sent to this tableau.
Override in subclass to give the tableau some appearance and behaviour.
Override in subclasses to give the tableau some appearance and behaviour.
Reimplemented from vgui_tableau.
Definition at line 481 of file vgui_rubberband_tableau.cxx.
bool vgui_rubberband_tableau::handle_box | ( | vgui_event const & | e, |
float | ix, | ||
float | iy | ||
) | [protected] |
Definition at line 432 of file vgui_rubberband_tableau.cxx.
bool vgui_rubberband_tableau::handle_circle | ( | vgui_event const & | e, |
float | ix, | ||
float | iy | ||
) | [protected] |
Definition at line 365 of file vgui_rubberband_tableau.cxx.
bool vgui_rubberband_tableau::handle_infinite_line | ( | vgui_event const & | e, |
float | ix, | ||
float | iy | ||
) | [protected] |
Definition at line 344 of file vgui_rubberband_tableau.cxx.
bool vgui_rubberband_tableau::handle_line | ( | vgui_event const & | e, |
float | ix, | ||
float | iy | ||
) | [protected] |
Definition at line 325 of file vgui_rubberband_tableau.cxx.
bool vgui_rubberband_tableau::handle_linestrip | ( | vgui_event const & | e, |
float | ix, | ||
float | iy | ||
) | [protected] |
Definition at line 450 of file vgui_rubberband_tableau.cxx.
bool vgui_rubberband_tableau::handle_point | ( | vgui_event const & | e, |
float | ix, | ||
float | iy | ||
) | [protected] |
Definition at line 306 of file vgui_rubberband_tableau.cxx.
bool vgui_rubberband_tableau::handle_polygon | ( | vgui_event const & | e, |
float | ix, | ||
float | iy | ||
) | [protected] |
Definition at line 391 of file vgui_rubberband_tableau.cxx.
bool vgui_tableau::help | ( | ) | [virtual, inherited] |
Called by default handle when it receives a '?' pressed event.
Reimplemented in vgui_deck_tableau, vgui_listmanager2D_tableau, vgui_composite_tableau, vgui_viewer2D_tableau, vgui_function_tableau, and vgui_viewer3D_tableau.
Definition at line 166 of file vgui_tableau.cxx.
bool vgui_tableau::idle | ( | ) | [virtual, inherited] |
Called when the application is otherwise idle.
Override if you want to do idle processing. Return false once your idle processing is complete, or if you have no need for more idle processing. Return true if you need more idle processing time.
Definition at line 185 of file vgui_tableau.cxx.
void vgui_rubberband_tableau::init | ( | vgui_rubberband_client * | client | ) |
Initialise vgui_rubberband_tableau.
Definition at line 107 of file vgui_rubberband_tableau.cxx.
bool vgui_tableau::key_press | ( | int | x, |
int | y, | ||
vgui_key | , | ||
vgui_modifier | |||
) | [virtual, inherited] |
Called by default handle when it receives a key-press event.
Caled by default handle when it receives a key press event.
Reimplemented in vgui_deck_tableau, vgui_listmanager2D_tableau, vgui_viewer2D_tableau, vgui_function_tableau, and vgui_viewer3D_tableau.
Definition at line 156 of file vgui_tableau.cxx.
bool vgui_tableau::motion | ( | int | x, |
int | y | ||
) | [virtual, inherited] |
Called by handle when it receives a mouse motion event.
Called by default handle when it receives a mouse motion event.
Reimplemented in vgui_listmanager2D_tableau, vgui_function_tableau, and vgui_displaylist2D_tableau.
Definition at line 146 of file vgui_tableau.cxx.
bool vgui_tableau::mouse_down | ( | int | x, |
int | y, | ||
vgui_button | , | ||
vgui_modifier | |||
) | [virtual, inherited] |
Called by default handle when it receives a mouse down event.
Reimplemented in vgui_listmanager2D_tableau, vgui_viewer2D_tableau, vgui_function_tableau, vgui_viewer3D_tableau, vgui_displaylist3D_tableau, and vgui_displaylist2D_tableau.
Definition at line 126 of file vgui_tableau.cxx.
bool vgui_tableau::mouse_up | ( | int | x, |
int | y, | ||
vgui_button | , | ||
vgui_modifier | |||
) | [virtual, inherited] |
Called by default handle when it receives a mouse up event.
Reimplemented in vgui_viewer2D_tableau, vgui_function_tableau, and vgui_viewer3D_tableau.
Definition at line 136 of file vgui_tableau.cxx.
virtual vcl_string vgui_tableau::name | ( | void | ) | const [inline, virtual, inherited] |
Return the name of the tableau.
Reimplemented in vgui_easy2D_tableau.
Definition at line 90 of file vgui_tableau.h.
bool vgui_tableau::notify_replaced_child | ( | vgui_tableau_sptr const & | old_child, |
vgui_tableau_sptr const & | new_child | ||
) | [virtual, inherited] |
Called whenever a child of this tableau is about to be forcibly replaced.
Called when a child of this tableau is forcibly replaced.
This method is called when some part of the program (typically the parent_child_link mechanism) is about to forcibly replace a child of this tableau. The canonical reason to override this is in order to invalidate caches.
Definition at line 302 of file vgui_tableau.cxx.
void vgui_tableau::post_idle_request | ( | void | ) | [virtual, inherited] |
Post an idle request event.
The fact that this is virtual does not imply that you should go and override it.
Posting an idle event request means that your tableau has some idle processing that it'd like to do. This means that your tableau will continue to receive vgui_IDLE events until the event handler returns false (i.e. all idle processing is complete). The idle event handler should return false when it has no idle processing, or has completed its idle processing. It may return true if has only partially completed its idle processing; in this case, it will receive more idle event to allow it to complete processing.
Reimplemented in vgui_adaptor_tableau.
Definition at line 235 of file vgui_tableau.cxx.
void vgui_tableau::post_message | ( | char const * | msg, |
void const * | data | ||
) | [virtual, inherited] |
Post a message event.
The fact that this is virtual does not imply that you should go and override it.
Reimplemented in vgui_adaptor_tableau.
Definition at line 205 of file vgui_tableau.cxx.
void vgui_tableau::post_overlay_redraw | ( | void | ) | [virtual, inherited] |
Post an overlay-redraw event.
Post an overlay redraw event.
The fact that this is virtual does not imply that you should go and override it.
Reimplemented in vgui_adaptor_tableau.
Definition at line 225 of file vgui_tableau.cxx.
void vgui_tableau::post_redraw | ( | void | ) | [virtual, inherited] |
Post a draw event.
The fact that this is virtual does not imply that you should go and override it.
Reimplemented in vgui_adaptor_tableau.
Definition at line 215 of file vgui_tableau.cxx.
virtual vcl_string vgui_tableau::pretty_name | ( | ) | const [inline, virtual, inherited] |
Used to provide an informative name for printouts, debugging etc.
Often it's type_name() + some representation of the essential state.
Reimplemented in vgui_easy2D_tableau, vgui_deck_tableau, vgui_composite_tableau, vgui_roi_tableau, vgui_image_tableau, vgui_selector_tableau, vgui_wrapper_tableau, and vgui_vrml_tableau.
Definition at line 97 of file vgui_tableau.h.
void vgui_tableau::ref | ( | ) | const [inherited] |
Increase the reference count by one (for smart pointers).
Increase the reference count by one (for smart-pointers).
"const" is for convenience, it is cast away internally.
Definition at line 79 of file vgui_tableau.cxx.
bool vgui_tableau::remove_child | ( | vgui_tableau_sptr const & | ) | [virtual, inherited] |
Remove the given child from the list of child tableaux.
Remove the given tableau from the list of child tableaux.
Reimplemented in vgui_composite_tableau, vgui_selector_tableau, vgui_deck_tableau, and vgui_wrapper_tableau.
Definition at line 291 of file vgui_tableau.cxx.
void vgui_rubberband_tableau::rubberband_box | ( | ) |
Definition at line 172 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::rubberband_circle | ( | ) |
Definition at line 146 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::rubberband_infinite_line | ( | ) |
Definition at line 139 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::rubberband_line | ( | ) |
Definition at line 132 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::rubberband_linestrip | ( | ) |
Definition at line 163 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::rubberband_none | ( | ) |
Definition at line 179 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::rubberband_point | ( | ) |
Definition at line 125 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::rubberband_polygon | ( | ) |
Definition at line 153 of file vgui_rubberband_tableau.cxx.
void vgui_rubberband_tableau::set_client | ( | vgui_rubberband_client * | client | ) | [inline] |
Definition at line 174 of file vgui_rubberband_tableau.h.
vcl_string vgui_rubberband_tableau::type_name | ( | ) | const [inline, virtual] |
Return the type of this tableau ('vgui_rubberband_tableau').
Reimplemented from vgui_tableau.
Definition at line 157 of file vgui_rubberband_tableau.h.
void vgui_tableau::unref | ( | ) | const [inherited] |
Decrease the reference count by one (for smart pointers).
Decrease the reference count by one (for smart-pointers).
"const" is for convenience, it is cast away internally. If the reference count reaches zero then delete the object.
If the reference count reaches zero then delete the object.
Definition at line 87 of file vgui_tableau.cxx.
bool vgui_rubberband_tableau::active [private] |
Definition at line 199 of file vgui_rubberband_tableau.h.
Definition at line 196 of file vgui_rubberband_tableau.h.
Definition at line 160 of file vgui_rubberband_tableau.h.
Definition at line 161 of file vgui_rubberband_tableau.h.
Definition at line 162 of file vgui_rubberband_tableau.h.
float vgui_rubberband_tableau::lastx [private] |
Definition at line 201 of file vgui_rubberband_tableau.h.
float vgui_rubberband_tableau::lasty [private] |
Definition at line 201 of file vgui_rubberband_tableau.h.
vgui_rubberband_tableau::object_type vgui_rubberband_tableau::obj_type = none_enum [static, private] |
Definition at line 200 of file vgui_rubberband_tableau.h.
Whether to use overlays or not.
Definition at line 145 of file vgui_rubberband_tableau.h.
vcl_vector<float> vgui_rubberband_tableau::x_coords [private] |
Definition at line 202 of file vgui_rubberband_tableau.h.
vcl_vector<float> vgui_rubberband_tableau::y_coords [private] |
Definition at line 202 of file vgui_rubberband_tableau.h.