------------------------------------------------------------------------------
| 522 | |
| 523 | //------------------------------------------------------------------------------ |
| 524 | void vtkBoxWidget2::ProcessKeyEvents(vtkObject*, unsigned long event, void* clientdata, void*) |
| 525 | { |
| 526 | vtkBoxWidget2* self = static_cast<vtkBoxWidget2*>(clientdata); |
| 527 | vtkBoxRepresentation* rep = vtkBoxRepresentation::SafeDownCast(self->WidgetRep); |
| 528 | char* cKeySym = self->Interactor->GetKeySym(); |
| 529 | std::string keySym = cKeySym != nullptr ? cKeySym : ""; |
| 530 | std::transform(keySym.begin(), keySym.end(), keySym.begin(), ::toupper); |
| 531 | if (event == vtkCommand::KeyPressEvent) |
| 532 | { |
| 533 | if (keySym == "X") |
| 534 | { |
| 535 | rep->SetXTranslationAxisOn(); |
| 536 | rep->SetRotationAxisModeToX(); |
| 537 | } |
| 538 | else if (keySym == "Y") |
| 539 | { |
| 540 | rep->SetYTranslationAxisOn(); |
| 541 | rep->SetRotationAxisModeToY(); |
| 542 | } |
| 543 | else if (keySym == "Z") |
| 544 | { |
| 545 | rep->SetZTranslationAxisOn(); |
| 546 | rep->SetRotationAxisModeToZ(); |
| 547 | } |
| 548 | } |
| 549 | else if (event == vtkCommand::KeyReleaseEvent) |
| 550 | { |
| 551 | if (keySym == "X" || keySym == "Y" || keySym == "Z") |
| 552 | { |
| 553 | rep->SetTranslationAxisOff(); |
| 554 | rep->SetRotationAxisModeToFree(); |
| 555 | } |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | //------------------------------------------------------------------------------ |
| 560 | void vtkBoxWidget2::PrintSelf(ostream& os, vtkIndent indent) |