------------------------------------------------------------------------------
| 194 | |
| 195 | //------------------------------------------------------------------------------ |
| 196 | bool 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 | //------------------------------------------------------------------------------ |
| 240 | void vtkContextTransform::PrintSelf(ostream& os, vtkIndent indent) |
nothing calls this directly
no test coverage detected