• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kalgebra

  • sources
  • kde-4.14
  • kdeedu
  • kalgebra
  • mobile
  • declarative
  • qml
Graph2D.qml
Go to the documentation of this file.
1 import QtQuick 1.1
2 import org.kde.analitza 1.0
3 
4 Graph2DView {
5  id: view
6  anchors.fill: parent
7 
8  showGrid: true
9 
10  PinchArea {
11  anchors.fill: parent
12  property double thePreviousScale: 1
13 // dragAxis: YAxis
14 
15 // onPinchFinished
16 // onPinchStarted:
17 
18  function distance(p1, p2)
19  {
20  var w=p2.x-p1.x
21  var h=p2.y-p1.y
22  return Math.sqrt(w*w+h*h)
23  }
24 
25  onPinchStarted: thePreviousScale=1
26 
27  onPinchUpdated: {
28  var currentDistance = distance(pinch.point1, pinch.point2)
29  if(currentDistance>0) {
30  var startDistance = distance(pinch.startPoint1, pinch.startPoint2)
31 
32  var theCurrentScale = startDistance/currentDistance
33 
34  var doScale = theCurrentScale/thePreviousScale
35  view.scale(doScale, view.width/2, view.height/2)
36 // console.log("scale...", startDistance, theCurrentScale, doScale)
37  thePreviousScale = theCurrentScale
38  }
39  }
40  }
41 
42  MouseArea {
43  anchors.fill: parent
44  property int lastX: 0
45  property int lastY: 0
46  acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
47 
48  onPressed: { lastX=mouse.x; lastY=mouse.y }
49 
50  onPositionChanged: {
51  view.translate(mouse.x-lastX, mouse.y-lastY)
52 
53  lastX=mouse.x
54  lastY=mouse.y
55  }
56  }
57 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:11:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalgebra

Skip menu "kalgebra"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal