Commit c379ee13 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell
Browse files

ENH: Refactored mouse event API for context

Using the legacy macro to make the data members protected, leave public
for one more release. Ported the code in the charts to use the new API.
Next - modifier keys for mouse events.

Change-Id: I69c8dc25e596f2ad69a0e8463098a3f5a452940f
parent be3d20df
......@@ -160,8 +160,8 @@ vtkAbstractContextItem* vtkAbstractContextItem::GetPickedItem(
const vtkContextMouseEvent &mouse)
{
vtkContextMouseEvent childMouse = mouse;
childMouse.Pos = this->MapFromParent(mouse.Pos);
childMouse.LastPos = this->MapFromParent(mouse.LastPos);
childMouse.SetPos(this->MapFromParent(mouse.GetPos()));
childMouse.SetLastPos(this->MapFromParent(mouse.GetLastPos()));
for(vtkContextScenePrivate::const_reverse_iterator it =
this->Children->rbegin(); it != this->Children->rend(); ++it)
{
......
......@@ -25,6 +25,7 @@
#include "vtkBrush.h"
#include "vtkTextProperty.h"
#include "vtkStdString.h"
#include "vtkVectorOperators.h"
#include "vtkObjectFactory.h"
......@@ -35,7 +36,6 @@ vtkStandardNewMacro(vtkBlockItem);
vtkBlockItem::vtkBlockItem()
{
this->MouseOver = false;
this->MouseButtonPressed = vtkContextMouseEvent::NO_BUTTON;
this->scalarFunction = NULL;
this->Dimensions[0]=0;
this->Dimensions[1]=0;
......@@ -91,10 +91,11 @@ bool vtkBlockItem::Paint(vtkContext2D *painter)
//-----------------------------------------------------------------------------
bool vtkBlockItem::Hit(const vtkContextMouseEvent &mouse)
{
if (mouse.Pos[0] > this->Dimensions[0] &&
mouse.Pos[0] < this->Dimensions[0]+this->Dimensions[2] &&
mouse.Pos[1] > this->Dimensions[1] &&
mouse.Pos[1] < this->Dimensions[1]+this->Dimensions[3])
vtkVector2f pos = mouse.GetPos();
if (pos[0] > this->Dimensions[0] &&
pos[0] < this->Dimensions[0] + this->Dimensions[2] &&
pos[1] > this->Dimensions[1] &&
pos[1] < this->Dimensions[1] + this->Dimensions[3])
{
return true;
}
......@@ -115,34 +116,33 @@ bool vtkBlockItem::MouseEnterEvent(const vtkContextMouseEvent &)
//-----------------------------------------------------------------------------
bool vtkBlockItem::MouseMoveEvent(const vtkContextMouseEvent &mouse)
{
int deltaX = static_cast<int>(mouse.Pos[0] - mouse.LastPos[0]);
int deltaY = static_cast<int>(mouse.Pos[1] - mouse.LastPos[1]);
vtkVector2f delta = mouse.GetPos() - mouse.GetLastPos();
if (mouse.Button == mouse.LEFT_BUTTON)
if (mouse.GetButton() == vtkContextMouseEvent::LEFT_BUTTON)
{
// Move the block by this amount
this->Dimensions[0] += deltaX;
this->Dimensions[1] += deltaY;
this->Dimensions[0] += delta.X();
this->Dimensions[1] += delta.Y();
this->GetScene()->SetDirty(true);
return true;
}
else if (mouse.Button == mouse.MIDDLE_BUTTON)
else if (mouse.GetButton() == mouse.MIDDLE_BUTTON)
{
// Resize the block by this amount
this->Dimensions[0] += deltaX;
this->Dimensions[1] += deltaY;
this->Dimensions[2] -= deltaX;
this->Dimensions[3] -= deltaY;
this->Dimensions[0] += delta.X();
this->Dimensions[1] += delta.Y();
this->Dimensions[2] -= delta.X();
this->Dimensions[3] -= delta.Y();
this->GetScene()->SetDirty(true);
return true;
}
else if (mouse.Button == mouse.RIGHT_BUTTON)
else if (mouse.GetButton() == mouse.RIGHT_BUTTON)
{
// Resize the block by this amount
this->Dimensions[2] += deltaX;
this->Dimensions[3] += deltaY;
this->Dimensions[2] += delta.X();
this->Dimensions[3] += delta.Y();
this->GetScene()->SetDirty(true);
return true;
......@@ -159,18 +159,14 @@ bool vtkBlockItem::MouseLeaveEvent(const vtkContextMouseEvent &)
}
//-----------------------------------------------------------------------------
bool vtkBlockItem::MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
bool vtkBlockItem::MouseButtonPressEvent(const vtkContextMouseEvent &)
{
this->MouseButtonPressed = mouse.Button;
this->LastPosition[0] = mouse.Pos[0];
this->LastPosition[1] = mouse.Pos[1];
return true;
}
//-----------------------------------------------------------------------------
bool vtkBlockItem::MouseButtonReleaseEvent(const vtkContextMouseEvent &)
{
this->MouseButtonPressed = vtkContextMouseEvent::NO_BUTTON;
return true;
}
......
......@@ -98,12 +98,9 @@ protected:
int Dimensions[4];
float LastPosition[2];
vtkStdString Label;
bool MouseOver;
int MouseButtonPressed;
// Some function pointers to optionally do funky things...
double (*scalarFunction)(double, double);
......
......@@ -95,10 +95,11 @@ bool vtkChartHistogram2D::UpdateLayout(vtkContext2D *painter)
//-----------------------------------------------------------------------------
bool vtkChartHistogram2D::Hit(const vtkContextMouseEvent &mouse)
{
if (mouse.ScreenPos[0] > this->Point1[0]-10 &&
mouse.ScreenPos[0] < this->Point2[0]+10 &&
mouse.ScreenPos[1] > this->Point1[1] &&
mouse.ScreenPos[1] < this->Point2[1])
vtkVector2i pos(mouse.GetScreenPos());
if (pos[0] > this->Point1[0] - 10 &&
pos[0] < this->Point2[0] + 10 &&
pos[1] > this->Point1[1] &&
pos[1] < this->Point2[1])
{
return true;
}
......
......@@ -280,10 +280,10 @@ vtkChart* vtkChartLegend::GetChart()
//-----------------------------------------------------------------------------
bool vtkChartLegend::Hit(const vtkContextMouseEvent &mouse)
{
if (this->DragEnabled && mouse.ScreenPos.X() > this->Rect.X() &&
mouse.ScreenPos.X() < this->Rect.X() + this->Rect.Width() &&
mouse.ScreenPos.Y() > this->Rect.Y() &&
mouse.ScreenPos.Y() < this->Rect.Y() + this->Rect.Height())
if (this->DragEnabled && mouse.GetScreenPos().X() > this->Rect.X() &&
mouse.GetScreenPos().X() < this->Rect.X() + this->Rect.Width() &&
mouse.GetScreenPos().Y() > this->Rect.Y() &&
mouse.GetScreenPos().Y() < this->Rect.Y() + this->Rect.Height())
{
return true;
}
......@@ -298,7 +298,7 @@ bool vtkChartLegend::MouseMoveEvent(const vtkContextMouseEvent &mouse)
{
if (this->Button == vtkContextMouseEvent::LEFT_BUTTON)
{
vtkVector2f delta = mouse.ScenePos - mouse.LastScenePos;
vtkVector2f delta = mouse.GetScenePos() - mouse.GetLastScenePos();
this->HorizontalAlignment = vtkChartLegend::CUSTOM;
this->Storage->Point = this->Storage->Point + delta;
this->GetScene()->SetDirty(true);
......@@ -309,7 +309,7 @@ bool vtkChartLegend::MouseMoveEvent(const vtkContextMouseEvent &mouse)
//-----------------------------------------------------------------------------
bool vtkChartLegend::MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
{
if (mouse.Button == vtkContextMouseEvent::LEFT_BUTTON)
if (mouse.GetButton() == vtkContextMouseEvent::LEFT_BUTTON)
{
this->Button = vtkContextMouseEvent::LEFT_BUTTON;
return true;
......
......@@ -412,10 +412,11 @@ void vtkChartParallelCoordinates::RecalculateBounds()
//-----------------------------------------------------------------------------
bool vtkChartParallelCoordinates::Hit(const vtkContextMouseEvent &mouse)
{
if (mouse.ScreenPos[0] > this->Point1[0]-10 &&
mouse.ScreenPos[0] < this->Point2[0]+10 &&
mouse.ScreenPos[1] > this->Point1[1] &&
mouse.ScreenPos[1] < this->Point2[1])
vtkVector2i pos(mouse.GetScreenPos());
if (pos[0] > this->Point1[0] - 10 &&
pos[0] < this->Point2[0] + 10 &&
pos[1] > this->Point1[1] &&
pos[1] < this->Point2[1])
{
return true;
}
......@@ -434,7 +435,7 @@ bool vtkChartParallelCoordinates::MouseEnterEvent(const vtkContextMouseEvent &)
//-----------------------------------------------------------------------------
bool vtkChartParallelCoordinates::MouseMoveEvent(const vtkContextMouseEvent &mouse)
{
if (mouse.Button == this->Actions.Select())
if (mouse.GetButton() == this->Actions.Select())
{
// If an axis is selected, then lets try to narrow down a selection...
if (this->Storage->CurrentAxis >= 0)
......@@ -443,7 +444,7 @@ bool vtkChartParallelCoordinates::MouseMoveEvent(const vtkContextMouseEvent &mou
this->Storage->AxesSelections[this->Storage->CurrentAxis];
// Normalize the coordinates
float current = mouse.ScenePos.Y();
float current = mouse.GetScenePos().Y();
current -= this->Storage->Transform->GetMatrix()->GetElement(1, 2);
current /= this->Storage->Transform->GetMatrix()->GetElement(1, 1);
......@@ -462,13 +463,13 @@ bool vtkChartParallelCoordinates::MouseMoveEvent(const vtkContextMouseEvent &mou
}
this->Scene->SetDirty(true);
}
else if (mouse.Button == this->Actions.Pan())
else if (mouse.GetButton() == this->Actions.Pan())
{
vtkAxis* axis = this->Storage->Axes[this->Storage->CurrentAxis];
if (this->Storage->AxisResize == 0)
{
// Move the axis in x
float deltaX = mouse.ScenePos.X() - mouse.LastScenePos.X();
float deltaX = mouse.GetScenePos().X() - mouse.GetLastScenePos().X();
axis->SetPoint1(axis->GetPoint1()[0]+deltaX, axis->GetPoint1()[1]);
axis->SetPoint2(axis->GetPoint2()[0]+deltaX, axis->GetPoint2()[1]);
......@@ -495,7 +496,7 @@ bool vtkChartParallelCoordinates::MouseMoveEvent(const vtkContextMouseEvent &mou
else if (this->Storage->AxisResize == 1)
{
// Modify the bottom axis range...
float deltaY = mouse.ScenePos.Y() - mouse.LastScenePos.Y();
float deltaY = mouse.GetScenePos().Y() - mouse.GetLastScenePos().Y();
float scale = (axis->GetPoint2()[1]-axis->GetPoint1()[1]) /
(axis->GetMaximum() - axis->GetMinimum());
axis->SetMinimum(axis->GetMinimum() - deltaY/scale);
......@@ -516,7 +517,7 @@ bool vtkChartParallelCoordinates::MouseMoveEvent(const vtkContextMouseEvent &mou
else if (this->Storage->AxisResize == 2)
{
// Modify the bottom axis range...
float deltaY = mouse.ScenePos.Y() - mouse.LastScenePos.Y();
float deltaY = mouse.GetScenePos().Y() - mouse.GetLastScenePos().Y();
float scale = (axis->GetPoint2()[1]-axis->GetPoint1()[1]) /
(axis->GetMaximum() - axis->GetMinimum());
axis->SetMaximum(axis->GetMaximum() - deltaY/scale);
......@@ -549,18 +550,18 @@ bool vtkChartParallelCoordinates::MouseLeaveEvent(const vtkContextMouseEvent &)
bool vtkChartParallelCoordinates::MouseButtonPressEvent(
const vtkContextMouseEvent& mouse)
{
if (mouse.Button == this->Actions.Select())
if (mouse.GetButton() == this->Actions.Select())
{
// Select an axis if we are within range
if (mouse.ScenePos[1] > this->Point1[1] &&
mouse.ScenePos[1] < this->Point2[1])
if (mouse.GetScenePos()[1] > this->Point1[1] &&
mouse.GetScenePos()[1] < this->Point2[1])
{
// Iterate over the axes, see if we are within 10 pixels of an axis
for (size_t i = 0; i < this->Storage->Axes.size(); ++i)
{
vtkAxis* axis = this->Storage->Axes[i];
if (axis->GetPoint1()[0]-10 < mouse.ScenePos[0] &&
axis->GetPoint1()[0]+10 > mouse.ScenePos[0])
if (axis->GetPoint1()[0]-10 < mouse.GetScenePos()[0] &&
axis->GetPoint1()[0]+10 > mouse.GetScenePos()[0])
{
this->Storage->CurrentAxis = static_cast<int>(i);
vtkVector<float, 2>& range = this->Storage->AxesSelections[i];
......@@ -571,7 +572,7 @@ bool vtkChartParallelCoordinates::MouseButtonPressEvent(
}
// Transform into normalized coordinates
float low = mouse.ScenePos[1];
float low = mouse.GetScenePos()[1];
low -= this->Storage->Transform->GetMatrix()->GetElement(1, 2);
low /= this->Storage->Transform->GetMatrix()->GetElement(1, 1);
range[0] = range[1] = low;
......@@ -585,25 +586,25 @@ bool vtkChartParallelCoordinates::MouseButtonPressEvent(
this->Scene->SetDirty(true);
return true;
}
else if (mouse.Button == this->Actions.Pan())
else if (mouse.GetButton() == this->Actions.Pan())
{
// Middle mouse button - move and zoom the axes
// Iterate over the axes, see if we are within 10 pixels of an axis
for (size_t i = 0; i < this->Storage->Axes.size(); ++i)
{
vtkAxis* axis = this->Storage->Axes[i];
if (axis->GetPoint1()[0]-10 < mouse.ScenePos[0] &&
axis->GetPoint1()[0]+10 > mouse.ScenePos[0])
if (axis->GetPoint1()[0]-10 < mouse.GetScenePos()[0] &&
axis->GetPoint1()[0]+10 > mouse.GetScenePos()[0])
{
this->Storage->CurrentAxis = static_cast<int>(i);
if (mouse.ScenePos.Y() > axis->GetPoint1()[1] &&
mouse.ScenePos.Y() < axis->GetPoint1()[1] + 20)
if (mouse.GetScenePos().Y() > axis->GetPoint1()[1] &&
mouse.GetScenePos().Y() < axis->GetPoint1()[1] + 20)
{
// Resize the bottom of the axis
this->Storage->AxisResize = 1;
}
else if (mouse.ScenePos.Y() < axis->GetPoint2()[1] &&
mouse.ScenePos.Y() > axis->GetPoint2()[1] - 20)
else if (mouse.GetScenePos().Y() < axis->GetPoint2()[1] &&
mouse.GetScenePos().Y() > axis->GetPoint2()[1] - 20)
{
// Resize the top of the axis
this->Storage->AxisResize = 2;
......@@ -627,14 +628,14 @@ bool vtkChartParallelCoordinates::MouseButtonPressEvent(
bool vtkChartParallelCoordinates::MouseButtonReleaseEvent(
const vtkContextMouseEvent& mouse)
{
if (mouse.Button == this->Actions.Select())
if (mouse.GetButton() == this->Actions.Select())
{
if (this->Storage->CurrentAxis >= 0)
{
vtkVector<float, 2> &range =
this->Storage->AxesSelections[this->Storage->CurrentAxis];
float final = mouse.ScenePos[1];
float final = mouse.GetScenePos()[1];
final -= this->Storage->Transform->GetMatrix()->GetElement(1, 2);
final /= this->Storage->Transform->GetMatrix()->GetElement(1, 1);
......@@ -689,7 +690,7 @@ bool vtkChartParallelCoordinates::MouseButtonReleaseEvent(
}
return true;
}
else if (mouse.Button == this->Actions.Pan())
else if (mouse.GetButton() == this->Actions.Pan())
{
this->Storage->CurrentAxis = -1;
this->Storage->AxisResize = -1;
......
......@@ -187,10 +187,11 @@ vtkChartLegend * vtkChartPie::GetLegend()
//-----------------------------------------------------------------------------
bool vtkChartPie::Hit(const vtkContextMouseEvent &mouse)
{
if (mouse.ScreenPos[0] > this->Point1[0] &&
mouse.ScreenPos[0] < this->Point2[0] &&
mouse.ScreenPos[1] > this->Point1[1] &&
mouse.ScreenPos[1] < this->Point2[1])
vtkVector2i pos(mouse.GetScreenPos());
if (pos[0] > this->Point1[0] &&
pos[0] < this->Point2[0] &&
pos[1] > this->Point1[1] &&
pos[1] < this->Point2[1])
{
return true;
}
......@@ -209,7 +210,7 @@ bool vtkChartPie::MouseEnterEvent(const vtkContextMouseEvent &)
//-----------------------------------------------------------------------------
bool vtkChartPie::MouseMoveEvent(const vtkContextMouseEvent &mouse)
{
if (mouse.Button == vtkContextMouseEvent::NO_BUTTON)
if (mouse.GetButton() == vtkContextMouseEvent::NO_BUTTON)
{
this->Scene->SetDirty(true);
this->Tooltip->SetVisible(this->LocatePointInPlots(mouse));
......@@ -251,23 +252,27 @@ bool vtkChartPie::LocatePointInPlots(const vtkContextMouseEvent &mouse)
else
{
int dimensions[4];
vtkVector2f position(mouse.ScreenPos[0],mouse.ScreenPos[1]);
vtkVector2f tolerance(5,5);
vtkVector2f position(mouse.GetScreenPos().Cast<float>().GetData());
vtkVector2f tolerance(5, 5);
vtkVector2f plotPos;
this->Private->Plot->GetDimensions(dimensions);
if (mouse.ScreenPos[0] >= dimensions[0] &&
mouse.ScreenPos[0] <= dimensions[0] + dimensions[2] &&
mouse.ScreenPos[1] >= dimensions[1] &&
mouse.ScreenPos[1] <= dimensions[1] + dimensions[3])
vtkVector2i pos(mouse.GetScreenPos());
if (pos[0] >= dimensions[0] &&
pos[0] <= dimensions[0] + dimensions[2] &&
pos[1] >= dimensions[1] &&
pos[1] <= dimensions[1] + dimensions[3])
{
int labelIndex = this->Private->Plot->GetNearestPoint(position,tolerance,&plotPos);
int labelIndex = this->Private->Plot->GetNearestPoint(position, tolerance,
&plotPos);
if (labelIndex >= 0)
{
const char *label = this->Private->Plot->GetLabel(labelIndex);
vtksys_ios::ostringstream ostr;
ostr << label << ": " << plotPos.X();
this->Tooltip->SetText(ostr.str().c_str());
this->Tooltip->SetPosition(mouse.ScreenPos[0]+2,mouse.ScreenPos[1]+2);
this->Tooltip->SetPosition(mouse.GetScreenPos()[0] + 2,
mouse.GetScreenPos()[1] + 2);
return true;
}
}
......
......@@ -28,6 +28,7 @@
#include "vtkContextClip.h"
#include "vtkPoints2D.h"
#include "vtkVector.h"
#include "vtkVectorOperators.h"
#include "vtkPlotBar.h"
#include "vtkPlotStacked.h"
......@@ -1119,10 +1120,11 @@ void vtkChartXY::RecalculateBounds()
//-----------------------------------------------------------------------------
bool vtkChartXY::Hit(const vtkContextMouseEvent &mouse)
{
if (mouse.ScreenPos[0] > this->Point1[0] &&
mouse.ScreenPos[0] < this->Point2[0] &&
mouse.ScreenPos[1] > this->Point1[1] &&
mouse.ScreenPos[1] < this->Point2[1])
vtkVector2i pos(mouse.GetScreenPos());
if (pos[0] > this->Point1[0] &&
pos[0] < this->Point2[0] &&
pos[1] > this->Point1[1] &&
pos[1] < this->Point2[1])
{
return true;
}
......@@ -1152,20 +1154,20 @@ bool vtkChartXY::MouseMoveEvent(const vtkContextMouseEvent &mouse)
}
}
if (mouse.Button == this->Actions.Pan())
if (mouse.GetButton() == this->Actions.Pan())
{
// Figure out how much the mouse has moved by in plot coordinates - pan
double screenPos[2] = { mouse.ScreenPos[0], mouse.ScreenPos[1] };
double lastScreenPos[2] = { mouse.LastScreenPos[0], mouse.LastScreenPos[1] };
double pos[2] = { 0.0, 0.0 };
double last[2] = { 0.0, 0.0 };
vtkVector2d screenPos(mouse.GetScreenPos().Cast<double>().GetData());
vtkVector2d lastScreenPos(mouse.GetLastScreenPos().Cast<double>().GetData());
vtkVector2d pos(0.0);
vtkVector2d last(0.0);
// Go from screen to scene coordinates to work out the delta
vtkTransform2D *transform =
this->ChartPrivate->PlotCorners[0]->GetTransform();
transform->InverseTransformPoints(screenPos, pos, 1);
transform->InverseTransformPoints(lastScreenPos, last, 1);
double delta[] = { last[0] - pos[0], last[1] - pos[1] };
transform->InverseTransformPoints(screenPos.GetData(), pos.GetData(), 1);
transform->InverseTransformPoints(lastScreenPos.GetData(), last.GetData(), 1);
vtkVector2d delta = last - pos;
// Now move the axes and recalculate the transform
vtkAxis* xAxis = this->ChartPrivate->axes[vtkAxis::BOTTOM];
......@@ -1186,10 +1188,9 @@ bool vtkChartXY::MouseMoveEvent(const vtkContextMouseEvent &mouse)
{
// Go from screen to scene coordinates to work out the delta
transform = this->ChartPrivate->PlotCorners[2]->GetTransform();
transform->InverseTransformPoints(screenPos, pos, 1);
transform->InverseTransformPoints(lastScreenPos, last, 1);
delta[0] = last[0] - pos[0];
delta[1] = last[1] - pos[1];
transform->InverseTransformPoints(screenPos.GetData(), pos.GetData(), 1);
transform->InverseTransformPoints(lastScreenPos.GetData(), last.GetData(), 1);
delta = last - pos;
// Now move the axes and recalculate the transform
xAxis = this->ChartPrivate->axes[vtkAxis::TOP];
......@@ -1210,15 +1211,15 @@ bool vtkChartXY::MouseMoveEvent(const vtkContextMouseEvent &mouse)
// Mark the scene as dirty
this->Scene->SetDirty(true);
}
else if (mouse.Button == this->Actions.Zoom() ||
mouse.Button == this->Actions.Select())
else if (mouse.GetButton() == this->Actions.Zoom() ||
mouse.GetButton() == this->Actions.Select())
{
this->MouseBox.SetWidth(mouse.Pos.X() - this->MouseBox.X());
this->MouseBox.SetHeight(mouse.Pos.Y() - this->MouseBox.Y());
this->MouseBox.SetWidth(mouse.GetPos().X() - this->MouseBox.X());
this->MouseBox.SetHeight(mouse.GetPos().Y() - this->MouseBox.Y());
// Mark the scene as dirty
this->Scene->SetDirty(true);
}
else if (mouse.Button == vtkContextMouseEvent::NO_BUTTON)
else if (mouse.GetButton() == vtkContextMouseEvent::NO_BUTTON)
{
this->Scene->SetDirty(true);
this->Tooltip->SetVisible(this->LocatePointInPlots(mouse));
......@@ -1232,10 +1233,11 @@ bool vtkChartXY::LocatePointInPlots(const vtkContextMouseEvent &mouse,
int invokeEvent)
{
size_t n = this->ChartPrivate->plots.size();
if (mouse.ScreenPos[0] > this->Point1[0] &&
mouse.ScreenPos[0] < this->Point2[0] &&
mouse.ScreenPos[1] > this->Point1[1] &&
mouse.ScreenPos[1] < this->Point2[1] && n)
vtkVector2i pos(mouse.GetScreenPos());
if (pos[0] > this->Point1[0] &&
pos[0] < this->Point2[0] &&
pos[1] > this->Point1[1] &&
pos[1] < this->Point2[1] && n)
{
// Iterate through each corner, and check for a nearby point
for (size_t i = 0; i < this->ChartPrivate->PlotCorners.size(); ++i)
......@@ -1247,7 +1249,7 @@ bool vtkChartXY::LocatePointInPlots(const vtkContextMouseEvent &mouse,
vtkVector2f plotPos, position;
vtkTransform2D* transform =
this->ChartPrivate->PlotCorners[i]->GetTransform();
transform->InverseTransformPoints(mouse.Pos.GetData(),
transform->InverseTransformPoints(mouse.GetPos().GetData(),
position.GetData(), 1);
// Use a tolerance of +/- 5 pixels
vtkVector2f tolerance(5*(1.0/transform->GetMatrix()->GetElement(0, 0)),
......@@ -1283,7 +1285,7 @@ bool vtkChartXY::LocatePointInPlots(const vtkContextMouseEvent &mouse,
vtkChartPlotData plotIndex;
plotIndex.SeriesName = plot->GetLabel();
plotIndex.Position = plotPos;
plotIndex.ScreenPosition = mouse.ScreenPos;
plotIndex.ScreenPosition = mouse.GetScreenPos();
plotIndex.Index = seriesIndex;
// Invoke an event, with the client data supplied
this->InvokeEvent(invokeEvent, static_cast<void*>(&plotIndex));
......@@ -1328,8 +1330,8 @@ void vtkChartXY::SetTooltipInfo(const vtkContextMouseEvent& mouse,
// Set the tooltip
this->Tooltip->SetText(tooltipLabel);
this->Tooltip->SetPosition(mouse.ScreenPos[0]+2,
mouse.ScreenPos[1]+2);
this->Tooltip->SetPosition(mouse.GetScreenPos()[0] + 2,
mouse.GetScreenPos()[1] + 2);
}
//-----------------------------------------------------------------------------
......@@ -1352,23 +1354,23 @@ bool vtkChartXY::MouseButtonPressEvent(const vtkContextMouseEvent &mouse)
return true;
}
}
if (mouse.Button == this->Actions.Pan())
if (mouse.GetButton() == this->Actions.Pan())
{
// The mouse panning action.
this->MouseBox.Set(mouse.Pos.X(), mouse.Pos.Y(), 0.0, 0.0);
this->MouseBox.Set(mouse.GetPos().X(), mouse.GetPos().Y(), 0.0, 0.0);
this->DrawBox = false;
return true;
}
else if (mouse.Button == this->Actions.Zoom() ||
mouse.Button == this->Actions.Select())
else if (mouse.GetButton() == this->Actions.Zoom() ||
mouse.GetButton() == this->Actions.Select())
{
// Selection, for now at least...
this->MouseBox.Set(mouse.Pos.X(), mouse.Pos.Y(), 0.0, 0.0);
this->MouseBox.Set(mouse.GetPos().X(), mouse.GetPos().Y(), 0.0, 0.0);
this->DrawBox = true;
return true;
}
else if (mouse.Button == this->ActionsClick.Select() ||
mouse.Button == this->ActionsClick.Notify())
else if (mouse.GetButton() == this->ActionsClick.Select() ||
mouse.GetButton() == this->ActionsClick.Notify())
{
return true;
}
......@@ -1389,25 +1391,25 @@ bool vtkChartXY::MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
return true;
}
}
if (mouse.Button > vtkContextMouseEvent::NO_BUTTON &&
mouse.Button <= vtkContextMouseEvent::RIGHT_BUTTON)
if (mouse.GetButton() > vtkContextMouseEvent::NO_BUTTON &&
mouse.GetButton() <= vtkContextMouseEvent::RIGHT_BUTTON)
{
this->MouseBox.SetWidth(mouse.Pos.X() - this->MouseBox.X());
this->MouseBox.SetHeight(mouse.Pos.Y() - this->MouseBox.Y());
this->MouseBox.SetWidth(mouse.GetPos().X() - this->MouseBox.X());
this->MouseBox.SetHeight(mouse.GetPos().Y() - this->MouseBox.Y());
if ((fabs(this->MouseBox.Width()) < 0.5 && fabs(this->MouseBox.Height()) < 0.5)
&& (mouse.Button == this->Actions.Select() ||
mouse.Button == this->Actions.Pan()))
&& (mouse.GetButton() == this->Actions.Select() ||
mouse.GetButton() == this->Actions.Pan()))
{
// Invalid box size - treat as a single clicke event
this->MouseBox.SetWidth(0.0);
this->MouseBox.SetHeight(0.0);
this->DrawBox = false;
if (mouse.Button == this->ActionsClick.Notify())
if (mouse.GetButton() == this->ActionsClick.Notify())
{