CGSGView Class
Represent the scene of the application. It encapsulates the scene graph itself and several methods to track mouse and touch events, ...
Constructor
Item Index
Methods
- _canStartDragSelection
- _clickOnScene
- _dblClickOnScene
- _detectResizeMode
- _dispatchClick
- _doDragSelect
- _getDeltaOnMove
- _moveOnScene
- _upAndClick
- _upAndDblClick
- _updateDblBuffer
- _updateFramerate
- _updateFramerateContainer
- _updateSelection
- _upOnScene
- deleteSelected
- deselectAll
- invalidateTheme
- invalidateTransformation
- onKeyDownHandler
- onKeyUpHandler
- onMouseDblClick
- onMouseDown
- onMouseMove
- onMouseOutHandler
- onMouseUp
- onTouchEnd
- onTouchMove
- onTouchStart
- render
- setCanvasDimension
- setDisplayRatio
- showFPS
- startPlaying
- stopPlaying
Properties
- _frameContainer Handler to the HTML Element displaying the FPS
- _isRunning
- _keyDownedCtrl
- _listCursors List of the names for the cursor when overring a handlebox
- _mousePos
- _selectedNode The current last selected node
- _timerDblTouch
- allowMultiSelect
- cgsgGlobalRenderingTimer
- dblTouchDelay
- dragSelectAlpha
- dragSelectFillColor
- dragSelectStrokeColor
- dragSelectStrokeWidth
- onRenderEnd
- onRenderStart
- onSceneAverageFtpChanged
- onSceneClickEnd
- onSceneClickStart
- onSceneDblClickEnd
- onSceneDblClickStart
Methods
_canStartDragSelection
-
e
This method indicates if, according to the current state of the scene, a drag selection could starts. Called when a touchStart event triggered. Could be overridden to specify different behaviour.
Parameters:
-
e
Eventthe event
Returns:
true if drag selection could starts, false otherwise
_clickOnScene
-
e
-
pickNode
Click on the scene
_dblClickOnScene
-
event
-
mustPickNode
Returns:
the node that was double-clicked
_detectResizeMode
-
mousePosition
Detects if the mouse if over the handle box of a selected node.
Parameters:
-
mousePosition
CGSGPositionthe cursor position
Returns:
true if we resize, false otherwise
_dispatchClick
-
event
Dispatch a 'click' event and for any selected node which is clickable and and only if 'this._isDblClick' == false.
Parameters:
-
event
CGSGEventthe event to dispatch
_doDragSelect
()
protected
Select the nodes under the drag select rectangle
_moveOnScene
-
e
Parameters:
-
e
EventMouseEvent or TouchEvent
_upAndClick
-
event
Creates the custom event by calling _upOnScene and then call _clickOnScene.
Parameters:
-
event
Eventthe event
_upAndDblClick
-
event
Creates the custom event by calling _upOnScene and then call _dblClickOnScene.
Parameters:
-
event
Eventthe event
_updateDblBuffer
()
private
_updateFramerate
()
private
Update the current framerate
_updateFramerateContainer
()
private
Update the innerHTML of the HTMLElement passed as parameter of the "showFPS" function
_updateSelection
-
e
Updates the current selection according to the given event.
Parameters:
-
e
Eventthe event
_upOnScene
-
event
Parameters:
-
event
EventMouseEvent or TouchEvent
Returns:
a structure indicating is the node has been moved or resize
deleteSelected
()
Remove the nodes selected in the scene graph
deselectAll
-
excludedArray
Deselect all nodes
Parameters:
-
excludedArray
ArrayCGSGNodes not to deselect
invalidateTheme
()
Inform the SceneGraph that all nodes must be updated with the current theme
invalidateTransformation
()
public
Inform the SceneGraph that a new render is needed
onMouseDblClick
-
event
mouse double click Event handler function
Parameters:
-
event
MouseEvent
onMouseDown
-
e
click mouse Event handler function
Parameters:
-
e
MouseEventevent
onMouseMove
-
e
mouse move Event handler function
Parameters:
-
e
MouseEventevent
onMouseOutHandler
-
e
Detects when the mouse leaves the canvas.
Parameters:
-
e
MouseEventthe event
onMouseUp
-
event
mouse up Event handler function
Parameters:
-
event
MouseEvent
onTouchEnd
-
event
touch up Event handler function
Parameters:
-
event
Event
onTouchMove
-
event
touch move Event handler function
Parameters:
-
event
Event
onTouchStart
-
e
touch down Event handler function
Parameters:
-
e
Eventevent
render
()
protected
the main rendering loop
setCanvasDimension
-
d
Change the dimension of the canvas. Does not really change the dimension of the rendering canvas container, but is used by the different computations
Parameters:
-
d
CGSGDimensionnewDimension
setDisplayRatio
-
ratio
Set the new value for the display ratio. The display ratio is used to resize all the elements on the graph to be adapted to the screen, depending on the reference screen size. You can compute the ratio like this: x = canvas.width/reference.width ; y = canvas.height/reference.height
Parameters:
-
ratio
CGSGScalea CGSGScale value
showFPS
-
elt
Parameters:
-
elt
HTMLElementan HTML element to receive the FPS. Can be null if you want to remove the framerate
startPlaying
()
public
Call this to start the update of the scene
stopPlaying
()
public
Call this to stop the rendering (and so animation) update
Properties
_selectedNode The current last selected node
Null
private
dblTouchDelay
Number
The delay between 2 touches to be considered as a dbl touch event. To remove the double touch, just set it to 0
Default: CGSG_DEFAULT_DBLTOUCH_DELAY
onRenderEnd
Function
Callback on end rendering event
Default: null
Example:
this.onRenderEnd = function () { //... }
onRenderStart
Function
Callback on start rendering event
Default: null
Example:
this.onSceneClickStart = function () { //... }
onSceneAverageFtpChanged
Function
Callback on frame average changed event.
Default: null
Example:
this.onSceneAverageFtsChanged = function (event) { event.fps; // The average FPS }
onSceneClickEnd
Function
Callback on click up on scene event
Default: null
Example:
this.onSceneClickEnd = function (event) { event.position; //Array of CGSGPosition event.event; //Event }
onSceneClickStart
Function
Callback on click down on scene event.
Default: null
Example:
this.onSceneClickStart = function (event) { event.position; //Array of CGSGPosition event.event; //Event }
onSceneDblClickEnd
Function
Callback on double click up on scene event
Default: null
Example:
this.onSceneDblClickEnd = function (event) { event.position; //Array of CGSGPosition event.event; //Event }
onSceneDblClickStart
Function
Callback on double click start on scene event
Default: null
Example:
this.onSceneDblClickStart = function (event) { event.position; //Array of CGSGPosition event.event; //Event }