Class: BaseEditor

Kekule.Editor. BaseEditor

Methods

addHotTrackedObj(obj)

Add a obj to hot tracked objects.
Parameters:
Name Type Description
obj Object
Source:

addObjectsInScreenBoxToSelection(box, allowPartialAreaSelecting) → {Array}

Add objects inside a screen box to selection.
Parameters:
Name Type Description
box Hash
allowPartialAreaSelecting Bool If this value is true, object partial in the box will also be selected.
Source:
Returns:
All inside objects.
Type
Array

addObjToSelection(obj)

Add an object to selection. Descendants can override this method.
Parameters:
Name Type Description
obj Kekule.ChemObject
Source:

addSelectingAnchorCoord(screenCoord)

Add a new anchor coord of selecting region. This method is called when pointer device moving in selecting.
Parameters:
Name Type Description
screenCoord Hash
Source:

addToSelection(param)

Add object or an array of objects to selection.
Parameters:
Name Type Description
param Variant A object or an array of objects.
Source:

beginManipulateObject()

Call this method to indicate a continuous manipulation operation is doing (e.g. moving or rotating objects).
Source:

beginUpdateObject()

Call this method to temporarily suspend object change notification.
Source:

beginUpdateSelection()

Notify that a continuous selection update is underway. UI need not to be changed.
Source:

beginUpdateUiMarkers()

Notify that currently is modifing UI markers and the editor need not to repaint them.
Source:

cancelSelecting()

Cancel current selecting operation.
Source:

canRedo() → {Bool}

Check if an undo action can be taken.
Source:
Returns:
Type
Bool

canUndo() → {Bool}

Check if an undo action can be taken.
Source:
Returns:
Type
Bool

clearHotTrackedObjs()

Set hot tracked objects to empty.
Source:

clearOperHistory()

Pop all operations and empty history list.
Source:

contextCoordToObj(contextCoord) → {Hash}

Turn context coord to obj one.
Parameters:
Name Type Description
contextCoord Hash
Source:
Returns:
Type
Hash

contextCoordToScreen(screenCoord) → {Hash}

Turn context based coord to screen one.
Parameters:
Name Type Description
screenCoord Hash
Source:
Returns:
Type
Hash

createUiEventReceiverElem()

Create a transparent div element above all other elems of editor, this element is used to receive all UI events.
Source:

deleteSelectedObjs()

Delete and free all selected objects.
Source:

deselectAll()

Deselect all objects in selection
Source:

doGetObjSize(obj) → {Hash}

Do actual job of getObjSize. Descendants may override this method.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Hash

doSelectionChanged()

Do actual work of method selectionChanged. Descendants may override this method.
Source:

doSetObjSize(obj, size)

Do actual work of setObjSize.
Parameters:
Name Type Description
obj Object
size Hash
Source:

dragSelectingBoxToCoord(screenCoord)

Drag selecting box to a new coord.
Parameters:
Name Type Description
screenCoord Hash
Source:

dragSelectingCurveToCoord(screenCoord)

Drag selecting curve to a new coord.
Parameters:
Name Type Description
screenCoord Hash
Source:

endManipulateObject()

Call this method to indicate the update process is over and objectChanged will be immediately called.
Source:

endOperatingObjs(noRepaint)

Modification work in editor (e.g., move some atoms) is done. The objs to be modified will be rendered back into objContext.
Parameters:
Name Type Description
noRepaint Bool
Source:

endSelecting(coord, toggleFlag)

Selecting operation end.
Parameters:
Name Type Description
coord Hash
toggleFlag Bool If true, the selecting region will toggle selecting state inside it rather than select them directly.
Source:

endSelectingBoxDrag(coord, toggleFlag)

Selecting box drag end.
Parameters:
Name Type Description
coord Hash
toggleFlag Bool If true, the box will toggle selecting state inside it rather than select them directly.
Source:

endSelectingCurveDrag(coord, toggleFlag)

Selecting curve drag end.
Parameters:
Name Type Description
coord Hash
toggleFlag Bool If true, the box will toggle selecting state inside it rather than select them directly.
Source:

endUpdateObject()

Call this method to indicate the update process is over and objectChanged will be immediately called.
Source:

endUpdateSelection()

Notify that a continuous selection update is done. UI need to be changed.
Source:

endUpdateUiMarkers()

Call this method to indicate the UI marker update process is over and should be immediately updated.
Source:

execOperation(operation)

Execute an operation in editor.
Parameters:
Name Type Description
operation Kekule.Operation
Source:

exportObj(objClass) → {Object}

Returns exportable object for specified class. Descendants can override this method.
Parameters:
Name Type Description
objClass Class Set null to export default object.
Source:
Returns:
Type
Object

exportObjs(objClass) → {Array}

Returns all exportable objects for specified class. Descendants can override this method.
Parameters:
Name Type Description
objClass Class Set null to export default object.
Source:
Returns:
Type
Array

getChemObjBounds(obj, boundInflation) → {Array}

Returns geometry bounds of a obj in editor.
Parameters:
Name Type Description
obj Kekule.ChemObject
boundInflation Number
Source:
Returns:
Type
Array

getChemObjSrcInfo(chemObj) → {Object}

Returns srcInfo of chemObj. If editor is dirty (object been modified), srcInfo will be unavailable.
Parameters:
Name Type Description
chemObj Kekule.ChemObject
Source:
Returns:
Type
Object

getClientDimension()

Returns the dimension of current visible client area of editor.
Source:

getClientScrollPosition() → {Hash}

Returns current scroll position of edit client element.
Source:
Returns:
{x, y}
Type
Hash

getCoord(obj, coordSys) → {Hash}

Get coord of obj.
Parameters:
Name Type Description
obj Object
coordSys Int Value from Kekule.Render.CoordSystem. Only CONTEXT and CHEM are available here.
Source:
Returns:
Type
Hash

getExportableClasses() → {Array}

Returns array of classes that can be exported (saved) from editor. Descendants can override this method.
Source:
Returns:
Type
Array

getInteractionBoundInflation(pointerType)

Returns bound inflation for interaction with a certain pointer device (mouse, touch, etc.)
Parameters:
Name Type Description
pointerType String
Source:

getObjCoord(obj, coordPos) → {Hash}

Returns own coord of obj.
Parameters:
Name Type Description
obj Object
coordPos Int Value from Kekule.Render.CoordPos, relative position of coord in object.
Source:
Returns:
Type
Hash

getObjectContextCoord(obj) → {Hash}

Get object's coord on context.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Hash

getObjectsContainerBox(objects, objBoundInflation) → {Hash}

Returns a minimal box (in screen coord system) containing all objects' bounds in editor.
Parameters:
Name Type Description
objects Array
objBoundInflation Float Inflation of each object's bound.
Source:
Returns:
Type
Hash

getObjectScreenCoord(obj) → {Hash}

Get object's coord on screen.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Hash

getObjectsInPolygon(polygonScreenCoords, allowPartialAreaSelecting) → {Array}

Get all objects inside a polygon defined by a set of screen coords.
Parameters:
Name Type Description
polygonScreenCoords Array
allowPartialAreaSelecting Bool If this value is true, object partial in the box will also be selected.
Source:
Returns:
All inside objects.
Type
Array

getObjectsInScreenBox(screenBox, allowPartialAreaSelecting) → {Array}

Get all objects inside a screen box.
Parameters:
Name Type Description
screenBox Hash
allowPartialAreaSelecting Bool If this value is true, object partial in the box will also be selected.
Source:
Returns:
All inside objects.
Type
Array

getObjectsIntersetExtendedPolyline(polylineScreenCoords, lineWidth) → {Array}

Get all objects interset a polyline defined by a set of screen coords. Here Object partial in the polyline width range will also be put in result.
Parameters:
Name Type Description
polylineScreenCoords Array
lineWidth Number
Source:
Returns:
All interseting objects.
Type
Array

getObjSize(obj) → {Hash}

Returns width and height info of obj.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Hash

getSelectionContainerBox(objBoundInflation) → {Hash}

Returns container box (in screen coord system) that contains all objects in selection.
Parameters:
Name Type Description
objBoundInflation Number
Source:
Returns:
Type
Hash

getSize(obj, coordSys) → {Hash}

Get size of obj.
Parameters:
Name Type Description
obj Object
coordSys Int Value from Kekule.Render.CoordSystem. Only CONTEXT and CHEM are available here.
Source:
Returns:
Type
Hash

getTopmostBoundInfoAtCoord(screenCoord, excludeObjs) → {Object}

returns the topmost bound map item at x/y. Input coord is based on the screen coord system.
Parameters:
Name Type Description
screenCoord Hash
excludeObjs Array Objects in this array will not be returned.
Source:
Returns:
Type
Object

hasSelection() → {Bool}

Check if there is objects selected currently.
Source:
Returns:
Type
Bool

hideHotTrack(doNotClearHotTrackedObjs)

Remove all hot track markers.
Parameters:
Name Type Description
doNotClearHotTrackedObjs Bool If false, the hotTrackedObjs property will also be set to empty.
Source:

hideUiMarker(marker)

Hide a UI marker.
Parameters:
Name Type Description
marker
Source:

hotTrackOnCoord(screenCoord)

Try hot track object on coord.
Parameters:
Name Type Description
screenCoord Hash Coord based on screen system.
Source:

hotTrackOnObj(obj)

Hot try on a basic drawn object.
Parameters:
Name Type Description
obj Object
Source:

isDirty() → {Bool}

Returns whether the chem object inside editor has been modified since load.
Source:
Returns:
Type
Bool

isInSelection(obj) → {Bool}

Check if an object is in selection.
Parameters:
Name Type Description
obj Kekule.ChemObject
Source:
Returns:
Type
Bool

isManipulatingObject()

Check if beginUpdateObject is called and should not send object change notification immediately.
Source:

isSelectionVisible()

Returns whether current selected objects can be seen from screen (not all of them are in hidden scroll area).
Source:

isUpdatingObject()

Check if beginUpdateObject is called and should not send object change notification immediately.
Source:

isUpdatingSelection()

Check if the editor is under continuous selection update.
Source:

isUpdatingUiMarkers()

Check if the editor is under continuous UI marker update.
Source:

modifyObjects(objOrObjs, modifiedPropInfos, putInOperHistory)

Modify properties of objects in editor.
Parameters:
Name Type Description
objOrObjs Variant A object or an array of objects.
modifiedPropInfos Hash A hash of property: value pairs.
putInOperHistory Bool If set to true, the modification will be put into history and can be undone.
Source:

modifyObjectsRenderOptions(objOrObjs, modifiedValues, is3DOption, putInOperHistory)

Modify render options of objects in editor.
Parameters:
Name Type Description
objOrObjs Variant A object or an array of objects.
modifiedValues Hash A hash of name: value pairs.
is3DOption Bool Change renderOptions or render3DOptions.
putInOperHistory Bool If set to true, the modification will be put into history and can be undone.
Source:

newDoc()

Create a new object and load it in editor.
Source:

operationDone(operation)

Called after a operation is executed or reversed. Notify object has changed.
Parameters:
Name Type Description
operation Object
Source:

popOperation(autoReverse) → {Kekule.Operation}

Manually pop an operation from the tail of operation history.
Parameters:
Name Type Description
autoReverse Bool Whether undo the operation after popping it.
Source:
Returns:
Operation popped.
Type
Kekule.Operation

prepareOperatingObjs(objs)

Prepare to do a modification work in editor (e.g., move some atoms). The objs to be modified will be rendered in operContext separately (if enableOperContext is true).
Parameters:
Name Type Description
objs Array
Source:

pulseSelectionAreaMarker(duration, pulseCount)

Pulse selection marker several times to get the attention of user.
Parameters:
Name Type Description
duration Int Duration of the whole process, in ms.
pulseCount Int The times of highlighting marker.
Source:

pushOperation(operation, autoExec)

Manually append an operation to the tail of operation history.
Parameters:
Name Type Description
operation Kekule.Operation
autoExec Bool Whether execute the operation after pushing it.
Source:

reactChemObjChange(e)

React to change event of loaded chemObj.
Parameters:
Name Type Description
e Object
Source:

redo()

Redo last operation.
Source:

removeFromSelection(param)

Remove object or an array of objects from selection.
Parameters:
Name Type Description
param Variant A object or an array of objects.
Source:

removeObjectsInScreenBoxFromSelection(box, allowPartialAreaSelecting) → {Array}

Remove objects inside a screen box from selection.
Parameters:
Name Type Description
box Hash
allowPartialAreaSelecting Bool If this value is true, object partial in the box will also be deselected.
Source:
Returns:
All inside objects.
Type
Array

removeObjFromSelection(obj)

Remove an object (and all its child objects) from selection. Descendants can override this method.
Parameters:
Name Type Description
obj Kekule.ChemObject
Source:

resetZoom()

Reset to normal size.
Source:

screenBoxToContext(screenCoord) → {Hash}

Turn box coords based on screen system to context one.
Parameters:
Name Type Description
screenCoord Hash
Source:
Returns:
Type
Hash

screenCoordToContext(screenCoord) → {Hash}

Turn screen based coord to context one.
Parameters:
Name Type Description
screenCoord Hash
Source:
Returns:
Type
Hash

screenCoordToObj(contextCoord) → {Hash}

Turn screen coord to obj one.
Parameters:
Name Type Description
contextCoord Hash
Source:
Returns:
Type
Hash

scrollClientTo(yPosition,, xPosition,)

Scroll edit client to a position.
Parameters:
Name Type Description
yPosition, Int in px.
xPosition, Int in px.
Source:

scrollClientToTop()

Scroll edit client to top.
Source:

select(objs)

Make a obj or set of objs be selected.
Parameters:
Name Type Description
objs Variant A object or an array of objects.
Source:

selectObjectsInScreenBox(box, allowPartialAreaSelecting) → {Array}

Select all objects inside a screen box.
Parameters:
Name Type Description
box Hash
allowPartialAreaSelecting Bool If this value is true, object partial in the box will also be selected.
Source:
Returns:
All inside objects.
Type
Array

selectOnCoord(coord, toggleFlag)

Try select a object on coord directly.
Parameters:
Name Type Description
coord Hash
toggleFlag Bool If true, the box will toggle selecting state inside it rather than select them directly.
Source:

setCoord(obj, value, coordSys)

Set coord of obj.
Parameters:
Name Type Description
obj Object
value Hash
coordSys Int Value from Kekule.Render.CoordSystem. Only CONTEXT and CHEM are available here.
Source:

setObjCoord(obj, coord, coordPos)

Set own coord of obj.
Parameters:
Name Type Description
obj Object
coord Hash
coordPos Int Value from Kekule.Render.CoordPos, relative position of coord in object.
Source:

setObjectContextCoord(obj, contextCoord)

Change object's coord on context.
Parameters:
Name Type Description
obj Object
contextCoord Hash
Source:

setObjectScreenCoord(obj, contextCoord)

Change object's coord on screen.
Parameters:
Name Type Description
obj Object
contextCoord Hash
Source:

setObjSize(obj, size)

Set dimension of obj.
Parameters:
Name Type Description
obj Object
size Hash
Source:

setSize(obj, value, coordSys)

Set size of obj.
Parameters:
Name Type Description
obj Object
value Hash
coordSys Int Value from Kekule.Render.CoordSystem. Only CONTEXT and CHEM are available here.
Source:

showUiMarker(marker, updateRenderer)

Show an UI marker.
Parameters:
Name Type Description
marker
updateRenderer
Source:

startSelecting(coord, toggleFlag)

Start a selecting operation from coord.
Parameters:
Name Type Description
coord Hash
toggleFlag Bool If true, the selecting region will toggle selecting state inside it rather than select them directly.
Source:

startSelectingBoxDrag(coord, toggleFlag)

Start to drag a selecting box from coord.
Parameters:
Name Type Description
coord Hash
toggleFlag Bool If true, the box will toggle selecting state inside it rather than select them directly.
Source:

startSelectingCurveDrag(coord, toggleFlag)

Start to drag a selecting curve from coord.
Parameters:
Name Type Description
coord Hash
toggleFlag Bool If true, the box will toggle selecting state inside it rather than select them directly.
Source:

toggleSelectingState(param)

Toggle selection state of object or an array of objects.
Parameters:
Name Type Description
param Variant A object or an array of objects.
Source:

toggleSelectingStateOfObjectsInScreenBox(box, allowPartialAreaSelecting) → {Array}

Toggle selection state of objects inside a screen box.
Parameters:
Name Type Description
box Hash
allowPartialAreaSelecting Bool If this value is true, object partial in the box will also be toggled.
Source:
Returns:
All inside objects.
Type
Array

translateCoord(coord, fromSys, toSys)

Translate coord to value of another coord system.
Parameters:
Name Type Description
coord Hash
fromSys Int
toSys Int
Source:

translateDistance(coord, fromSys, toSys)

Translate a distance value to a distance in another coord system.
Parameters:
Name Type Description
coord Hash
fromSys Int
toSys Int
Source:

undo()

Undo last operation.
Source:

undoAll()

Undo all operations.
Source:

zoomIn()

Zoom in.
Source:

zoomOut()

Zoom out.
Source:

Events

editObjChanged

Invoked when the chem object inside editor is changed. event param of it has one fields: {obj: Object, propNames: Array}
Source:

editObjsChanged

Invoked when multiple chem objects inside editor is changed. event param of it has one fields: {objChangeDetails}.
Source:

editObjsUpdated

Invoked when chem objects inside editor is changed and the changes has been updated by editor. event param of it has one fields: {objChangeDetails}. Note: this event is not the same as editObjsChanged. When beginUpdateObj is called, editObjsChanged event still will be invoked but editObjsUpdated event will be suppressed.
Source:

load

Invoked when the an chem object is loaded into editor. event param of it has one fields: {obj: Object}
Source:

operChange

Invoked when the operation history has modifications.
Source:

operHistoryClear

Invoked when the operation history is cleared. event param of it has one field: {currOperIndex: Int}
Source:

operPop

Invoked when the an operation is popped from history. event param of it has one fields: {operation: Kekule.Operation}
Source:

operPush

Invoked when the an operation is pushed into operation history. event param of it has one fields: {operation: Kekule.Operation}
Source:

operRedo

Invoked when one operation is redone. event param of it has two fields: {operation: Kekule.Operation, currOperIndex: Int}
Source:

operUndo

Invoked when one operation is undone. event param of it has two fields: {operation: Kekule.Operation, currOperIndex: Int}
Source:

selectedObjsUpdated

Invoked when the selected objects in editor has been changed. When beginUpdateObj is called, selectedObjsUpdated event will be suppressed. event param of it has one fields: {objs}.
Source:

selectionChange

Invoked when the selection in editor has been changed.
Source: