SMOOTH RENDERING!

This commit is contained in:
Tim
2024-04-22 21:12:43 -04:00
parent dc8185491b
commit e86b9738d8
6 changed files with 99 additions and 159 deletions

View File

@@ -141,7 +141,6 @@ export function drawShape(shapeType, ...callbacks) {
export function createShape(shapeType, points, options={}, ...callbacks) {
console.log('tvShape creating')
const co = useChartOrderStore()
drawingCallbacks = null
co.drawing = false
@@ -164,45 +163,14 @@ export function createShape(shapeType, points, options={}, ...callbacks) {
if( callbacks.length )
shapeCallbacks[shapeId] = callbacks
const shape = chart.getShapeById(shapeId)
console.log('tvShape created', shape) // todo debug
console.log('tvShape created', shapeId)
shape.bringToFront()
const props = shape.getProperties()
invokeCallbacks(callbacks, 'onCreate', shapeId, shape, points, props)
stub(shape)
return shapeId
}
let stubbed = true
// todo debug
function stub(shape) {
if(stubbed||shape===null) return
function stubFunc(funcName) {
const obj = shape._model
console.log('stubbing', funcName, obj)
const func = obj[funcName]
obj[funcName] = function () {
console.error(shapeId, funcName+'()', [...arguments])
func(...arguments)
}
}
stubFunc('start')
stubFunc('stop')
stubFunc('startChanging')
stubFunc('endChanging')
stubFunc('startMoving')
stubFunc('endMoving')
stubFunc('startMovingPoint')
stubFunc('move')
stubFunc('restart')
stubFunc('restorePoints')
stubbed = true
}
export let allShapeIds = []
export function cancelDrawing() {
@@ -228,14 +196,12 @@ function onSelectedLineToolChanged() {
export let dragging = false
function mouseDown() {
console.log('mouseDown')
dump()
// console.log('mouseDown')
dragging = true
}
function mouseUp() {
console.log('mouseUp')
dump()
// console.log('mouseUp')
dragging = false
draggingShapeIds = []
}
@@ -243,21 +209,6 @@ function mouseUp() {
export let draggingShapeIds = []
function dump() {
return
console.log('all', allShapeIds)
for (const shapeId of allShapeIds) {
const shape = chart.getShapeById(shapeId)
console.log('shape', shape)
console.log('_linePointBeingChanged', shape._model._linePointBeingChanged)
// console.log('_lineBeingEdited', shape._model._lineBeingEdited)
// console.log('_lineBeingCreated', shape._model._lineBeingCreated)
// console.log('_linePointBeingEdited', shape._model._linePointBeingEdited)
// console.log('_lastHoveredHittestData', shape._model._lastHoveredHittestData)
// console.log('_lastSelectedHittestData', shape._model._lastSelectedHittestData)
}
}
function handleCrosshairMovement(point) {
crosshairHandler.invoke(point) // delayed invocation to await selection to register later in the tv loop
@@ -352,8 +303,6 @@ function doHandleDrawingEvent(id, event) {
}
}
if (event === 'create') {
console.log('created tvShape', id, shape) // todo remove debug
stub(shape) // todo debug
allShapeIds.push(id)
const co = useChartOrderStore();