|
|
@ -1888,6 +1888,19 @@ Graph3d.prototype._redrawDataGraph = function() { |
|
|
|
// End methods for drawing points per graph style.
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/** |
|
|
|
* Store startX, startY and startOffset for mouse operations |
|
|
|
* |
|
|
|
* @param {Event} event The event that occurred |
|
|
|
*/ |
|
|
|
Graph3d.prototype._storeMousePosition = function(event) { |
|
|
|
// get mouse position (different code for IE and all other browsers)
|
|
|
|
this.startMouseX = getMouseX(event); |
|
|
|
this.startMouseY = getMouseY(event); |
|
|
|
|
|
|
|
this._startCameraOffset = this.camera.getOffset(); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Start a moving operation inside the provided parent element |
|
|
@ -1907,9 +1920,7 @@ Graph3d.prototype._onMouseDown = function(event) { |
|
|
|
this.leftButtonDown = event.which ? (event.which === 1) : (event.button === 1); |
|
|
|
if (!this.leftButtonDown && !this.touchDown) return; |
|
|
|
|
|
|
|
// get mouse position (different code for IE and all other browsers)
|
|
|
|
this.startMouseX = getMouseX(event); |
|
|
|
this.startMouseY = getMouseY(event); |
|
|
|
this._storeMousePosition(event); |
|
|
|
|
|
|
|
this.startStart = new Date(this.start); |
|
|
|
this.startEnd = new Date(this.end); |
|
|
@ -1940,31 +1951,44 @@ Graph3d.prototype._onMouseMove = function (event) { |
|
|
|
// calculate change in mouse position
|
|
|
|
var diffX = parseFloat(getMouseX(event)) - this.startMouseX; |
|
|
|
var diffY = parseFloat(getMouseY(event)) - this.startMouseY; |
|
|
|
|
|
|
|
// move with ctrl or rotate by other
|
|
|
|
if (event && event.ctrlKey === true) { |
|
|
|
// calculate change in mouse position
|
|
|
|
var scaleX = this.frame.clientWidth * 0.5; |
|
|
|
var scaleY = this.frame.clientHeight * 0.5; |
|
|
|
|
|
|
|
var offXNew = (this._startCameraOffset.x || 0) - ((diffX / scaleX) * this.camera.armLength) * 0.8; |
|
|
|
var offYNew = (this._startCameraOffset.y || 0) + ((diffY / scaleY) * this.camera.armLength) * 0.8; |
|
|
|
|
|
|
|
this.camera.setOffset(offXNew, offYNew); |
|
|
|
this._storeMousePosition(event); |
|
|
|
} else { |
|
|
|
var horizontalNew = this.startArmRotation.horizontal + diffX / 200; |
|
|
|
var verticalNew = this.startArmRotation.vertical + diffY / 200; |
|
|
|
|
|
|
|
var snapAngle = 4; // degrees
|
|
|
|
var snapValue = Math.sin(snapAngle / 360 * 2 * Math.PI); |
|
|
|
|
|
|
|
// snap horizontally to nice angles at 0pi, 0.5pi, 1pi, 1.5pi, etc...
|
|
|
|
// the -0.001 is to take care that the vertical axis is always drawn at the left front corner
|
|
|
|
if (Math.abs(Math.sin(horizontalNew)) < snapValue) { |
|
|
|
horizontalNew = Math.round(horizontalNew / Math.PI) * Math.PI - 0.001; |
|
|
|
} |
|
|
|
if (Math.abs(Math.cos(horizontalNew)) < snapValue) { |
|
|
|
horizontalNew = (Math.round(horizontalNew / Math.PI - 0.5) + 0.5) * Math.PI - 0.001; |
|
|
|
} |
|
|
|
|
|
|
|
var horizontalNew = this.startArmRotation.horizontal + diffX / 200; |
|
|
|
var verticalNew = this.startArmRotation.vertical + diffY / 200; |
|
|
|
|
|
|
|
var snapAngle = 4; // degrees
|
|
|
|
var snapValue = Math.sin(snapAngle / 360 * 2 * Math.PI); |
|
|
|
|
|
|
|
// snap horizontally to nice angles at 0pi, 0.5pi, 1pi, 1.5pi, etc...
|
|
|
|
// the -0.001 is to take care that the vertical axis is always drawn at the left front corner
|
|
|
|
if (Math.abs(Math.sin(horizontalNew)) < snapValue) { |
|
|
|
horizontalNew = Math.round((horizontalNew / Math.PI)) * Math.PI - 0.001; |
|
|
|
} |
|
|
|
if (Math.abs(Math.cos(horizontalNew)) < snapValue) { |
|
|
|
horizontalNew = (Math.round((horizontalNew/ Math.PI - 0.5)) + 0.5) * Math.PI - 0.001; |
|
|
|
} |
|
|
|
|
|
|
|
// snap vertically to nice angles
|
|
|
|
if (Math.abs(Math.sin(verticalNew)) < snapValue) { |
|
|
|
verticalNew = Math.round((verticalNew / Math.PI)) * Math.PI; |
|
|
|
} |
|
|
|
if (Math.abs(Math.cos(verticalNew)) < snapValue) { |
|
|
|
verticalNew = (Math.round((verticalNew/ Math.PI - 0.5)) + 0.5) * Math.PI; |
|
|
|
// snap vertically to nice angles
|
|
|
|
if (Math.abs(Math.sin(verticalNew)) < snapValue) { |
|
|
|
verticalNew = Math.round(verticalNew / Math.PI) * Math.PI; |
|
|
|
} |
|
|
|
if (Math.abs(Math.cos(verticalNew)) < snapValue) { |
|
|
|
verticalNew = (Math.round(verticalNew / Math.PI - 0.5) + 0.5) * Math.PI; |
|
|
|
} |
|
|
|
this.camera.setArmRotation(horizontalNew, verticalNew); |
|
|
|
} |
|
|
|
|
|
|
|
this.camera.setArmRotation(horizontalNew, verticalNew); |
|
|
|
this.redraw(); |
|
|
|
|
|
|
|
// fire a cameraPositionChange event
|
|
|
|