fit function at time machine
This commit is contained in:
1 parent
728cb26017
commit
504afdc89a
4 files changed
+42
-12
No files matched your search
@@ -20,9 +20,9 @@ function newTimeMachine () {
|
||||
container: undefined,
|
||||
timeScale: undefined,
|
||||
rateScale: undefined,
|
||||
fitFunction: undefined,
|
||||
payload: undefined,
|
||||
timelineCharts: [],
|
||||
fitFunction: fitFunction,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
drawBackground: drawBackground,
|
||||
@@ -60,6 +60,7 @@ function newTimeMachine () {
|
||||
function setupContainer () {
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.initialize(MODULE_NAME)
|
||||
thisObject.container.fitFunction = thisObject.fitFunction
|
||||
thisObject.container.isDraggeable = true
|
||||
thisObject.container.insideViewport = true
|
||||
thisObject.container.detectMouseOver = true
|
||||
@@ -281,6 +282,38 @@ function newTimeMachine () {
|
||||
}
|
||||
}
|
||||
|
||||
function fitFunction (point, fullVisible) {
|
||||
/* We prevent a point to be out of the container AND out of the Chart Space in general */
|
||||
|
||||
let returnPoint = {
|
||||
x: point.x,
|
||||
y: point.y
|
||||
}
|
||||
|
||||
let upCorner = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
|
||||
let bottonCorner = {
|
||||
x: thisObject.container.frame.width,
|
||||
y: thisObject.container.frame.height
|
||||
}
|
||||
|
||||
upCorner = transformThisPoint(upCorner, thisObject.container)
|
||||
bottonCorner = transformThisPoint(bottonCorner, thisObject.container)
|
||||
|
||||
/* Checking against the container limits. */
|
||||
if (returnPoint.x < upCorner.x) { returnPoint.x = upCorner.x }
|
||||
if (returnPoint.x > bottonCorner.x) { returnPoint.x = bottonCorner.x }
|
||||
if (returnPoint.y < upCorner.y) { returnPoint.y = upCorner.y }
|
||||
if (returnPoint.y > bottonCorner.y) { returnPoint.y = bottonCorner.y }
|
||||
|
||||
returnPoint = canvas.chartSpace.fitFunction(returnPoint, fullVisible)
|
||||
|
||||
return returnPoint
|
||||
}
|
||||
|
||||
function physics () {
|
||||
thisObjectPhysics()
|
||||
childrenPhysics()
|
||||
@@ -359,6 +392,7 @@ function newTimeMachine () {
|
||||
/* Setting up the new timeline timelineChart. */
|
||||
timelineChart.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true)
|
||||
timelineChart.container.fitFunction = thisObject.container.fitFunction
|
||||
timelineChart.fitFunction = thisObject.fitFunction
|
||||
timelineChart.container.frame.height = thisObject.container.frame.height
|
||||
timelineChart.container.frame.position.x = thisObject.container.frame.width / 2 - timelineChart.container.frame.width / 2
|
||||
timelineChart.container.frame.position.y = 0
|
||||
|
||||
@@ -26,8 +26,6 @@ function newTimelineChart () {
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
thisObject.fitFunction = canvas.chartSpace.fitIntoVisibleArea
|
||||
|
||||
let timeMachineCoordinateSystem
|
||||
let timelineChartCoordinateSystem = newCoordinateSystem()
|
||||
|
||||
@@ -410,8 +408,8 @@ function newTimelineChart () {
|
||||
fromPoint = transformThisPoint(fromPoint, thisObject.container)
|
||||
toPoint = transformThisPoint(toPoint, thisObject.container)
|
||||
|
||||
fromPoint = canvas.chartSpace.fitIntoVisibleArea(fromPoint)
|
||||
toPoint = canvas.chartSpace.fitIntoVisibleArea(toPoint)
|
||||
fromPoint = thisObject.fitFunction(fromPoint)
|
||||
toPoint = thisObject.fitFunction(toPoint)
|
||||
|
||||
browserCanvasContext.beginPath()
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ function newChartSpace () {
|
||||
oneScreenDown: oneScreenDown,
|
||||
oneScreenLeft: oneScreenLeft,
|
||||
oneScreenRight: oneScreenRight,
|
||||
fitIntoVisibleArea: fitIntoVisibleArea,
|
||||
fitFunction: fitFunction,
|
||||
isThisPointVisible: isThisPointVisible,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
@@ -144,7 +144,7 @@ function newChartSpace () {
|
||||
viewPort.displace(displaceVector, true)
|
||||
}
|
||||
|
||||
function fitIntoVisibleArea (point, fullVisible) {
|
||||
function fitFunction (point, fullVisible) {
|
||||
/* Here we check the boundaries of the resulting points, so they dont go out of the visible area. */
|
||||
|
||||
let returnPoint = {
|
||||
@@ -250,8 +250,6 @@ function newChartSpace () {
|
||||
/* Setting up the new time machine. */
|
||||
timeMachine.container.frame.position.x = thisObject.container.frame.width / 2 - timeMachine.container.frame.width / 2
|
||||
timeMachine.container.frame.position.y = thisObject.container.frame.height / 2 - timeMachine.container.frame.height / 2
|
||||
timeMachine.container.fitFunction = fitIntoVisibleArea
|
||||
timeMachine.fitFunction = fitIntoVisibleArea
|
||||
timeMachine.initialize(onTimeMachineInitialized)
|
||||
|
||||
function onTimeMachineInitialized (err) {
|
||||
|
||||
@@ -42,7 +42,7 @@ function newPanelsSpace () {
|
||||
case 'Products Panel':
|
||||
{
|
||||
panel = newProductsPanel()
|
||||
panel.fitFunction = canvas.chartSpace.fitIntoVisibleArea
|
||||
panel.fitFunction = canvas.chartSpace.fitFunction
|
||||
panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible
|
||||
break
|
||||
}
|
||||
@@ -50,13 +50,13 @@ function newPanelsSpace () {
|
||||
{
|
||||
if (pPanelCode !== undefined) {
|
||||
panel = newPlotterPanel()
|
||||
panel.fitFunction = canvas.chartSpace.fitIntoVisibleArea
|
||||
panel.fitFunction = canvas.chartSpace.fitFunction
|
||||
panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible
|
||||
panel.session = pSession
|
||||
panel.initialize(pPanelCode)
|
||||
} else {
|
||||
panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelCodeName)
|
||||
panel.fitFunction = canvas.chartSpace.fitIntoVisibleArea
|
||||
panel.fitFunction = canvas.chartSpace.fitFunction
|
||||
panel.container.isVisibleFunction = canvas.chartSpace.isThisPointVisible
|
||||
panel.session = pSession
|
||||
panel.initialize()
|
||||
|
||||
Reference in new issue
Block a user