------------------------------------------------------------------------------
| 249 | |
| 250 | //------------------------------------------------------------------------------ |
| 251 | bool vtkWebApplication::HandleInteractionEvent(vtkRenderWindow* view, vtkWebInteractionEvent* event) |
| 252 | { |
| 253 | vtkRenderWindowInteractor* iren = nullptr; |
| 254 | |
| 255 | if (view) |
| 256 | { |
| 257 | iren = view->GetInteractor(); |
| 258 | } |
| 259 | else |
| 260 | { |
| 261 | vtkErrorMacro("Interaction not supported for view : " << view); |
| 262 | return false; |
| 263 | } |
| 264 | |
| 265 | int ctrlKey = (event->GetModifiers() & vtkWebInteractionEvent::CTRL_KEY) != 0 ? 1 : 0; |
| 266 | int shiftKey = (event->GetModifiers() & vtkWebInteractionEvent::SHIFT_KEY) != 0 ? 1 : 0; |
| 267 | |
| 268 | // Handle scroll action if any |
| 269 | if (event->GetScroll()) |
| 270 | { |
| 271 | iren->SetEventInformation(0, 0, ctrlKey, shiftKey, event->GetKeyCode(), 0); |
| 272 | iren->MouseMoveEvent(); |
| 273 | iren->RightButtonPressEvent(); |
| 274 | iren->SetEventInformation( |
| 275 | 0, event->GetScroll() * 10, ctrlKey, shiftKey, event->GetKeyCode(), 0); |
| 276 | iren->MouseMoveEvent(); |
| 277 | iren->RightButtonReleaseEvent(); |
| 278 | this->Internals->ImageCache[view].NeedsRender = true; |
| 279 | return true; |
| 280 | } |
| 281 | |
| 282 | const int* viewSize = view->GetSize(); |
| 283 | int posX = std::floor(viewSize[0] * event->GetX() + 0.5); |
| 284 | int posY = std::floor(viewSize[1] * event->GetY() + 0.5); |
| 285 | |
| 286 | iren->SetEventInformation( |
| 287 | posX, posY, ctrlKey, shiftKey, event->GetKeyCode(), event->GetRepeatCount()); |
| 288 | |
| 289 | unsigned int prev_buttons = this->Internals->ButtonStates[view]; |
| 290 | unsigned int changed_buttons = (event->GetButtons() ^ prev_buttons); |
| 291 | iren->MouseMoveEvent(); |
| 292 | if ((changed_buttons & vtkWebInteractionEvent::LEFT_BUTTON) != 0) |
| 293 | { |
| 294 | if ((event->GetButtons() & vtkWebInteractionEvent::LEFT_BUTTON) != 0) |
| 295 | { |
| 296 | iren->LeftButtonPressEvent(); |
| 297 | if (event->GetRepeatCount() > 0) |
| 298 | { |
| 299 | iren->LeftButtonReleaseEvent(); |
| 300 | } |
| 301 | } |
| 302 | else |
| 303 | { |
| 304 | iren->LeftButtonReleaseEvent(); |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | if ((changed_buttons & vtkWebInteractionEvent::RIGHT_BUTTON) != 0) |
no test coverage detected