------------------------------------------------------------------------------
| 336 | |
| 337 | //------------------------------------------------------------------------------ |
| 338 | void vtkLineWidget2::ProcessKeyEvents(vtkObject*, unsigned long event, void* clientdata, void*) |
| 339 | { |
| 340 | vtkLineWidget2* self = static_cast<vtkLineWidget2*>(clientdata); |
| 341 | vtkLineRepresentation* rep = vtkLineRepresentation::SafeDownCast(self->WidgetRep); |
| 342 | char* cKeySym = self->Interactor->GetKeySym(); |
| 343 | std::string keySym = cKeySym != nullptr ? cKeySym : ""; |
| 344 | std::transform(keySym.begin(), keySym.end(), keySym.begin(), ::toupper); |
| 345 | if (event == vtkCommand::KeyPressEvent) |
| 346 | { |
| 347 | if (keySym == "X") |
| 348 | { |
| 349 | rep->GetPoint1Representation()->SetXTranslationAxisOn(); |
| 350 | rep->GetPoint2Representation()->SetXTranslationAxisOn(); |
| 351 | rep->GetLineHandleRepresentation()->SetXTranslationAxisOn(); |
| 352 | rep->GetPoint1Representation()->SetConstrained(true); |
| 353 | rep->GetPoint2Representation()->SetConstrained(true); |
| 354 | rep->GetLineHandleRepresentation()->SetConstrained(true); |
| 355 | } |
| 356 | else if (keySym == "Y") |
| 357 | { |
| 358 | rep->GetPoint1Representation()->SetYTranslationAxisOn(); |
| 359 | rep->GetPoint2Representation()->SetYTranslationAxisOn(); |
| 360 | rep->GetLineHandleRepresentation()->SetYTranslationAxisOn(); |
| 361 | rep->GetPoint1Representation()->SetConstrained(true); |
| 362 | rep->GetPoint2Representation()->SetConstrained(true); |
| 363 | rep->GetLineHandleRepresentation()->SetConstrained(true); |
| 364 | } |
| 365 | else if (keySym == "Z") |
| 366 | { |
| 367 | rep->GetPoint1Representation()->SetZTranslationAxisOn(); |
| 368 | rep->GetPoint2Representation()->SetZTranslationAxisOn(); |
| 369 | rep->GetLineHandleRepresentation()->SetZTranslationAxisOn(); |
| 370 | rep->GetPoint1Representation()->SetConstrained(true); |
| 371 | rep->GetPoint2Representation()->SetConstrained(true); |
| 372 | rep->GetLineHandleRepresentation()->SetConstrained(true); |
| 373 | } |
| 374 | else if (keySym == "L") |
| 375 | { |
| 376 | double p1[3], p2[3], v[3]; |
| 377 | rep->GetPoint1WorldPosition(p1); |
| 378 | rep->GetPoint2WorldPosition(p2); |
| 379 | vtkMath::Subtract(p2, p1, v); |
| 380 | vtkMath::Normalize(v); |
| 381 | rep->GetPoint1Representation()->SetCustomTranslationAxisOn(); |
| 382 | rep->GetPoint1Representation()->SetCustomTranslationAxis(v); |
| 383 | rep->GetPoint2Representation()->SetCustomTranslationAxisOn(); |
| 384 | rep->GetPoint2Representation()->SetCustomTranslationAxis(v); |
| 385 | rep->GetLineHandleRepresentation()->SetCustomTranslationAxisOn(); |
| 386 | rep->GetLineHandleRepresentation()->SetCustomTranslationAxis(v); |
| 387 | rep->GetPoint1Representation()->SetConstrained(true); |
| 388 | rep->GetPoint2Representation()->SetConstrained(true); |
| 389 | rep->GetLineHandleRepresentation()->SetConstrained(true); |
| 390 | } |
| 391 | } |
| 392 | else if (event == vtkCommand::KeyReleaseEvent) |
| 393 | { |
| 394 | if (keySym == "L" || keySym == "X" || keySym == "Y" || keySym == "Z") |
| 395 | { |
nothing calls this directly
no test coverage detected