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

Method MouseMoveEvent

Charts/Core/vtkChartParallelCoordinates.cxx:556–647  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

554
555//------------------------------------------------------------------------------
556bool vtkChartParallelCoordinates::MouseMoveEvent(const vtkContextMouseEvent& mouse)
557{
558 if (mouse.GetButton() == this->Actions.Select())
559 {
560 // If an axis is selected, then lets try to narrow down a selection...
561 if (this->Storage->CurrentAxis >= 0)
562 {
563 std::array<float, 2>& range = this->Storage->CurrentSelection;
564
565 // Normalize the coordinates
566 float current = mouse.GetScenePos().GetY();
567 current -= this->Storage->Transform->GetMatrix()->GetElement(1, 2);
568 current /= this->Storage->Transform->GetMatrix()->GetElement(1, 1);
569
570 if (current > 1.0f)
571 {
572 range[1] = 1.0f;
573 }
574 else if (current < 0.0f)
575 {
576 range[1] = 0.0f;
577 }
578 else
579 {
580 range[1] = current;
581 }
582 }
583 this->Scene->SetDirty(true);
584 }
585 else if (mouse.GetButton() == this->Actions.Pan())
586 {
587 if (this->Storage->CurrentAxis < 0) // can be -1
588 return false;
589 vtkAxis* axis = this->Storage->Axes[this->Storage->CurrentAxis];
590 if (this->Storage->AxisResize == 0)
591 {
592 // Move the axis in x
593 float deltaX = mouse.GetScenePos().GetX() - mouse.GetLastScenePos().GetX();
594
595 axis->SetPoint1(axis->GetPoint1()[0] + deltaX, axis->GetPoint1()[1]);
596 axis->SetPoint2(axis->GetPoint2()[0] + deltaX, axis->GetPoint2()[1]);
597
598 vtkAxis* leftAxis = this->Storage->CurrentAxis > 0
599 ? this->Storage->Axes[this->Storage->CurrentAxis - 1]
600 : nullptr;
601
602 vtkAxis* rightAxis =
603 this->Storage->CurrentAxis < static_cast<int>(this->Storage->Axes.size()) - 1
604 ? this->Storage->Axes[this->Storage->CurrentAxis + 1]
605 : nullptr;
606
607 if (leftAxis && axis->GetPoint1()[0] < leftAxis->GetPoint1()[0])
608 {
609 this->SwapAxes(this->Storage->CurrentAxis, this->Storage->CurrentAxis - 1);
610 this->Storage->CurrentAxis--;
611 }
612 else if (rightAxis && axis->GetPoint1()[0] > rightAxis->GetPoint1()[0])
613 {

Callers

nothing calls this directly

Calls 15

SwapAxesMethod · 0.95
SetDirtyMethod · 0.80
SelectMethod · 0.45
GetMatrixMethod · 0.45
PanMethod · 0.45
GetXMethod · 0.45
SetPoint1Method · 0.45
GetPoint1Method · 0.45
SetPoint2Method · 0.45
GetPoint2Method · 0.45
sizeMethod · 0.45
SetMinimumMethod · 0.45

Tested by

no test coverage detected