15 #include "mouseSubregion.h"
16 #include "dataNodeTransmit.h"
26 MouseSubregion(
const string &name) :
29 _pixel_xy_input = define_input(
"pixel_xy", EventStoreVec2::get_class_type());
30 _pixel_size_input = define_input(
"pixel_size", EventStoreVec2::get_class_type());
31 _xy_input = define_input(
"xy", EventStoreVec2::get_class_type());
32 _button_events_input = define_input(
"button_events", ButtonEventList::get_class_type());
34 _pixel_xy_output = define_output(
"pixel_xy", EventStoreVec2::get_class_type());
35 _pixel_size_output = define_output(
"pixel_size", EventStoreVec2::get_class_type());
36 _xy_output = define_output(
"xy", EventStoreVec2::get_class_type());
37 _button_events_output = define_output(
"button_events", ButtonEventList::get_class_type());
70 bool has_mouse =
false;
78 LVecBase2 n((p[0] - _minx) * _scalex - 1.0f, (p[1] - _miny) * _scaley - 1.0f);
81 if (n[0] >= -1.0f && n[0] <= 1.0f &&
82 n[1] >= -1.0f && n[1] <= 1.0f) {
88 if (input.
has_data(_pixel_size_input)) {
93 PN_stdfloat xf = (1.0f + n[0]) * 0.5f * s[0];
94 PN_stdfloat yf = (1.0f - n[1]) * 0.5f * s[1];
96 _pixel_xy->set_value(
LPoint2(xf, yf));
106 output.
set_data(_button_events_output, input.
get_data(_button_events_input));
109 _button_events->clear();
111 if (input.
has_data(_button_events_input)) {
113 DCAST_INTO_V(button_events, input.
get_data(_button_events_input).
get_ptr());
115 for (
int i = 0; i < num_events; i++) {
117 if (be._type == ButtonEvent::T_up) {
119 _button_events->add_event(be);
124 if (_button_events->get_num_events() != 0) {
131 if (input.
has_data(_pixel_size_input)) {
136 LVecBase2 n(s[0] * (_r - _l), s[1] * (_t - _b));
137 _pixel_size->set_value(n);
An optional parameter associated with an event.
A handy class object for storing simple values (like integers or strings) passed along with an Event ...
void set_data(int index, const EventParameter &data)
Sets the data for the indicated parameter.
const EventParameter & get_data(int index) const
Extracts the data for the indicated index, if it has been stored, or the empty parameter if it has no...
This is the base class for all two-component vectors and points.
This is the base class for some classes that monitor the mouse and keyboard input and perform some ac...
const Type & get_value() const
Retrieves the value stored in the parameter.
TypedWritableReferenceCount * get_ptr() const
Retrieves a pointer to the actual value stored in the parameter.
This is a two-component point in space.
TypeHandle is the identifier used to differentiate C++ class types.
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
Encapsulates the data generated from (or sent into) any particular DataNode.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...