MCPcopy Create free account
hub / github.com/Kitware/VTK / ProcessEvent

Method ProcessEvent

Web/Core/vtkRemoteInteractionAdapter.cxx:93–282  ·  view source on GitHub ↗

---------------------------------------------------------------------------- based on QVTKInteractorAdapter::ProcessEvent(QEvent* e, vtkRenderWindowInteractor* iren)

Source from the content-addressed store, hash-verified

91//----------------------------------------------------------------------------
92// based on QVTKInteractorAdapter::ProcessEvent(QEvent* e, vtkRenderWindowInteractor* iren)
93bool vtkRemoteInteractionAdapter::ProcessEvent(vtkRenderWindowInteractor* iren,
94 const std::string& event_str, double devicePixelRatio, double devicePixelRatioTolerance)
95{
96
97 if (!iren)
98 {
99 vtkLogF(ERROR, "Null interactor passed");
100 return false;
101 }
102 // the following events only happen if the interactor is enabled
103 if (!iren->GetEnabled())
104 {
105 return false;
106 }
107
108 try
109 {
110 nlohmann::json event = nlohmann::json::parse(event_str);
111 const std::string& type = event.at("type");
112 vtkLogF(TRACE, "event %s", event.dump(1).c_str());
113 const int eventType = EVENT_MAP.at(type);
114 switch (eventType)
115 {
116 case vtkCommand::EnterEvent:
117 case vtkCommand::LeaveEvent:
118 iren->InvokeEvent(eventType, (void*)&event);
119 break;
120 case vtkCommand::MouseMoveEvent:
121 case vtkCommand::LeftButtonPressEvent:
122 case vtkCommand::LeftButtonReleaseEvent:
123 case vtkCommand::RightButtonPressEvent:
124 case vtkCommand::RightButtonReleaseEvent:
125 case vtkCommand::MiddleButtonPressEvent:
126 case vtkCommand::MiddleButtonReleaseEvent:
127 {
128 const int x =
129 (event.at("x").get<double>() / event.at("w").get<double>() * devicePixelRatio +
130 devicePixelRatioTolerance) *
131 iren->GetRenderWindow()->GetSize()[0];
132 const int y =
133 (event.at("y").get<double>() / event.at("h").get<double>() * devicePixelRatio +
134 devicePixelRatioTolerance) *
135 iren->GetRenderWindow()->GetSize()[1];
136
137 const int ctrlKeyPressed = event.at("ctrlKey").get<int>();
138 const int altKeyPressed = event.at("altKey").get<int>();
139 const int shiftKeyPressed = event.at("shiftKey").get<int>();
140 iren->SetEventInformation(x, y, ctrlKeyPressed, shiftKeyPressed);
141 iren->SetAltKey(altKeyPressed);
142 iren->InvokeEvent(eventType, (void*)&event);
143 break;
144 }
145 case vtkCommand::KeyPressEvent:
146 case vtkCommand::KeyReleaseEvent:
147 {
148 const int ctrlKeyPressed = event.at("controlKey").get<int>();
149 const int altKeyPressed = event.at("altKey").get<int>();
150 const int shiftKeyPressed = event.at("shiftKey").get<int>();

Callers 2

test0Method · 0.45
test1Method · 0.45

Calls 12

dumpMethod · 0.80
InvokeEventMethod · 0.80
SetRotationMethod · 0.80
parseFunction · 0.50
atMethod · 0.45
c_strMethod · 0.45
GetSizeMethod · 0.45
GetRenderWindowMethod · 0.45
sizeMethod · 0.45
SetScaleMethod · 0.45
SetTranslationMethod · 0.45
whatMethod · 0.45

Tested by 2

test0Method · 0.36
test1Method · 0.36