API Docs for: v2.1.0
Show:

CGSGView Class

Extends Object
Defined in: src\class.view.js:64
Module: Scene

Represent the scene of the application. It encapsulates the scene graph itself and several methods to track mouse and touch events, ...

Constructor

CGSGView

(
  • canvas
)

Parameters:

  • canvas HTMLElement

    a handler to the canvas HTML element

Methods

_canStartDragSelection

(
  • e
)
Boolean protected

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 Event

    the event

Returns:

Boolean:

true if drag selection could starts, false otherwise

_clickOnScene

(
  • e
  • pickNode
)
private

Click on the scene

Parameters:

_dblClickOnScene

(
  • event
  • mustPickNode
)
CGSGNode private

Parameters:

Returns:

CGSGNode:

the node that was double-clicked

_detectResizeMode

(
  • mousePosition
)
Boolean private

Detects if the mouse if over the handle box of a selected node.

Parameters:

Returns:

Boolean:

true if we resize, false otherwise

_dispatchClick

(
  • event
)
private

Dispatch a 'click' event and for any selected node which is clickable and and only if 'this._isDblClick' == false.

Parameters:

_doDragSelect

() protected

Select the nodes under the drag select rectangle

_getDeltaOnMove

(
  • delta
  • offX
  • offY
  • w
  • h
  • signeX
  • signeY
)
Object private

Parameters:

Returns:

_moveOnScene

(
  • e
)
private

Parameters:

  • e Event

    MouseEvent or TouchEvent

_upAndClick

(
  • event
)
private

Creates the custom event by calling _upOnScene and then call _clickOnScene.

Parameters:

  • event Event

    the event

_upAndDblClick

(
  • event
)
private

Creates the custom event by calling _upOnScene and then call _dblClickOnScene.

Parameters:

  • event Event

    the 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
)
private

Updates the current selection according to the given event.

Parameters:

  • e Event

    the event

_upOnScene

(
  • event
)
Object private

Parameters:

  • event Event

    MouseEvent or TouchEvent

Returns:

Object:

a structure indicating is the node has been moved or resize

deleteSelected

()

Remove the nodes selected in the scene graph

deselectAll

(
  • excludedArray
)
public

Deselect all nodes

Parameters:

  • excludedArray Array

    CGSGNodes 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

onKeyDownHandler

(
  • event
)
Number protected

Parameters:

  • event KeyboardEvent

Returns:

onKeyUpHandler

(
  • event
)
Number protected

Parameters:

  • event KeyboardEvent

Returns:

onMouseDblClick

(
  • event
)
protected

mouse double click Event handler function

Parameters:

  • event MouseEvent

onMouseDown

(
  • e
)
protected

click mouse Event handler function

Parameters:

  • e MouseEvent

    event

onMouseMove

(
  • e
)
protected

mouse move Event handler function

Parameters:

  • e MouseEvent

    event

onMouseOutHandler

(
  • e
)

Detects when the mouse leaves the canvas.

Parameters:

  • e MouseEvent

    the event

onMouseUp

(
  • event
)
protected

mouse up Event handler function

Parameters:

  • event MouseEvent

onTouchEnd

(
  • event
)
protected

touch up Event handler function

Parameters:

  • event Event

onTouchMove

(
  • event
)
protected

touch move Event handler function

Parameters:

  • event Event

onTouchStart

(
  • e
)
protected

touch down Event handler function

Parameters:

  • e Event

    event

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:

setDisplayRatio

(
  • ratio
)
public

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:

showFPS

(
  • elt
)
public

Parameters:

  • elt HTMLElement

    an 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

_frameContainer Handler to the HTML Element displaying the FPS

HTMLElement private

_isRunning

Boolean private

_keyDownedCtrl

Boolean private

True if the [CTRL} key is being pressed

Default: false

_listCursors List of the names for the cursor when overring a handlebox

Array private

_mousePos

Array private

Current positions of the mouse or touch (Array of CGSGPosition)

_selectedNode The current last selected node

Null private

_timerDblTouch

Number private

Default: null

allowMultiSelect

Boolean

Multiselection boolean.

Default: true

cgsgGlobalRenderingTimer

Number private

Provides requestAnimationFrame in a cross browser way.

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

dragSelectAlpha

Number

Alpha value for the drag selection rectangle

Default: 0.6

dragSelectFillColor

String

Fill color for the drag selection selection rectangle

dragSelectStrokeColor

String

Stroke color for the drag selection selection rectangle

dragSelectStrokeWidth

String

Stroke width for the drag selection selection rectangle

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 }