11 #include <json/json.h>
18 namespace visualization {
25 if (
type == Type::MOVE) {
27 }
else if (
type == Type::BUTTON_DOWN) {
29 }
else if (
type == Type::DRAG) {
31 }
else if (
type == Type::BUTTON_UP) {
33 }
else if (
type == Type::WHEEL) {
41 if (
type == Type::MOVE ||
type == Type::DRAG) {
42 ss <<
", move.buttons : " <<
move.buttons;
43 }
else if (
type == Type::BUTTON_DOWN ||
type == Type::BUTTON_UP) {
44 ss <<
", button.button: ";
60 ss <<
", button.count: " <<
button.count;
61 }
else if (
type == Type::WHEEL) {
62 ss <<
", wheel.dx: " <<
wheel.dx;
63 ss <<
", wheel.dy: " <<
wheel.dy;
64 ss <<
", wheel.isTrackpad: " <<
wheel.isTrackpad;
71 if (!value.isObject()) {
76 std::string class_name = value.get(
"class_name",
"").asString();
77 if (class_name !=
"MouseEvent") {
79 "MouseEvent::FromJson failed: Incorrect class name {}.",
84 std::string type_name = value.get(
"type",
"").asString();
85 if (type_name ==
"MOVE") {
86 this->
type = MouseEvent::Type::MOVE;
87 }
else if (type_name ==
"BUTTON_DOWN") {
88 this->
type = MouseEvent::Type::BUTTON_DOWN;
89 }
else if (type_name ==
"BUTTON_UP") {
90 this->
type = MouseEvent::Type::BUTTON_UP;
91 }
else if (type_name ==
"DRAG") {
92 this->
type = MouseEvent::Type::DRAG;
93 }
else if (type_name ==
"WHEEL") {
94 this->
type = MouseEvent::Type::WHEEL;
97 "MouseEvent::FromJson failed: Incorrect type name {}.",
101 this->
x = value.get(
"x", 0).asInt();
102 this->
y = value.get(
"y", 0).asInt();
103 this->
modifiers = value.get(
"modifiers", 0).asInt();
105 if (this->
type == Type::MOVE || this->
type == Type::DRAG) {
106 this->
move.buttons = value[
"move"].get(
"buttons", 0).asInt();
107 }
else if (this->
type == Type::BUTTON_DOWN ||
108 this->
type == Type::BUTTON_UP) {
109 std::string button_name = value[
"button"].get(
"button",
"").asString();
110 if (button_name ==
"NONE") {
112 }
else if (button_name ==
"LEFT") {
114 }
else if (button_name ==
"MIDDLE") {
116 }
else if (button_name ==
"RIGHT") {
118 }
else if (button_name ==
"BUTTON4") {
120 }
else if (button_name ==
"BUTTON5") {
124 "MouseEvent::FromJson failed: Incorrect button name {}.",
128 this->
button.count = value[
"button"].get(
"count", 1).asInt();
129 }
else if (this->
type == Type::WHEEL) {
130 this->
wheel.dx = value[
"wheel"].get(
"dx", 0.f).asFloat();
131 this->
wheel.dy = value[
"wheel"].get(
"dy", 0.f).asFloat();
132 this->
wheel.isTrackpad =
133 value[
"wheel"].get(
"isTrackpad",
false).asBool();
175 const bool isTrackpad) {
Generic file read and write utility for python interface.
struct cloudViewer::visualization::gui::MouseEvent::@17::@21 wheel
bool FromJson(const Json::Value &value)
struct cloudViewer::visualization::gui::MouseEvent::@17::@19 move
static MouseEvent MakeWheelEvent(const Type type, const int x, const int y, const int modifiers, const float dx, const float dy, const bool isTrackpad)
static MouseEvent MakeButtonEvent(const Type type, const int x, const int y, const int modifiers, const MouseButton button, const int count)
static MouseEvent MakeMoveEvent(const Type type, const int x, const int y, const int modifiers, const int buttons)
std::string ToString() const