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

Method MouseWheelEvent

Rendering/Context2D/vtkContextTransform.cxx:196–237  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

194
195//------------------------------------------------------------------------------
196bool vtkContextTransform::MouseWheelEvent(const vtkContextMouseEvent& mouse, int delta)
197{
198 if (!this->Interactive)
199 {
200 return vtkAbstractContextItem::MouseButtonPressEvent(mouse);
201 }
202 if (this->ZoomOnMouseWheel)
203 {
204 // Determine current position to zoom in on
205 vtkVector2d scenePos(mouse.GetScenePos().Cast<double>().GetData());
206 vtkVector2d pos(0.0, 0.0);
207 vtkTransform2D* transform = this->GetTransform();
208 transform->InverseTransformPoints(scenePos.GetData(), pos.GetData(), 1);
209 vtkVector2f zoomAnchor = vtkVector2f(pos.Cast<float>().GetData());
210
211 // Ten "wheels" to double/halve zoom level
212 float scaling = pow(2.0f, delta / 10.0f);
213
214 // Zoom in on current position
215 this->Translate(zoomAnchor[0], zoomAnchor[1]);
216 this->Scale(scaling, scaling);
217 this->Translate(-zoomAnchor[0], -zoomAnchor[1]);
218
219 // Mark the scene as dirty
220 this->Scene->SetDirty(true);
221
222 this->InvokeEvent(vtkCommand::InteractionEvent);
223 return true;
224 }
225 if (this->PanYOnMouseWheel)
226 {
227 // Ten "wheels" to scroll a screen
228 this->Translate(0.0f, delta / 10.0f * this->Scene->GetSceneHeight());
229
230 // Mark the scene as dirty
231 this->Scene->SetDirty(true);
232
233 this->InvokeEvent(vtkCommand::InteractionEvent);
234 return true;
235 }
236 return false;
237}
238
239//------------------------------------------------------------------------------
240void vtkContextTransform::PrintSelf(ostream& os, vtkIndent indent)

Callers

nothing calls this directly

Calls 11

GetTransformMethod · 0.95
TranslateMethod · 0.95
ScaleMethod · 0.95
MouseButtonPressEventFunction · 0.85
SetDirtyMethod · 0.80
InvokeEventMethod · 0.80
GetSceneHeightMethod · 0.80
vtkVector2fClass · 0.70
powFunction · 0.50
GetDataMethod · 0.45

Tested by

no test coverage detected