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

Method ProcessKeyEvents

Interaction/Widgets/vtkLineWidget2.cxx:338–404  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

336
337//------------------------------------------------------------------------------
338void 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 {

Callers

nothing calls this directly

Calls 8

GetKeySymMethod · 0.80
transformFunction · 0.50
SubtractFunction · 0.50
NormalizeFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected