Class: ChemSpaceEditor

Kekule.Editor. ChemSpaceEditor

new ChemSpaceEditor(parentOrElementOrDocument, chemObj, renderType, editorConfigs)

A chem editor to edit chemspace object and other chem objects. When load a chem object other than instance of Kekule.ChemSpace, an empty ChemSpace instance will be created and loaded object should be insert into it.
Parameters:
Name Type Description
parentOrElementOrDocument Variant
chemObj Kekule.ChemObject initially loaded chemObj.
renderType Int Display in 2D or 3D. Value from Kekule.Render.RendererType.
editorConfigs Kekule.Editor.BaseEditorConfigs Configuration of this editor.
Properties:
Name Type Description
chemSpace Kekule.ChemSpace ChemSpace loaded in this editor.
defBondLength Float
allowCreateNewChild Bool Whether new direct child of space can be created. Note: if the space is empty, one new child will always be allowed to create.
autoCreateNewStructFragment Bool Whether new molecule object can be created in space. Note: if property Kekule.Editor.ChemSpaceEditor.allowCreateNewChild is false, this property will always be false.
Source:

Extends

Methods

addHotTrackedObj(obj)

Add a obj to hot tracked objects.
Parameters:
Name Type Description
obj Object
Inherited From:
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.
Inherited From:
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
Inherited From:
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
Inherited From:
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.
Inherited From:
Source:

beginManipulateObject()

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

beginUpdateObject()

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

beginUpdateSelection()

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

beginUpdateUiMarkers()

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

canAddNewStandaloneObject() → {Bool}

Returns whether a new standalone object (e.g. molecule) can be added to editor.
Source:
Returns:
Type
Bool

canAddUnconnectedStructFragment() → {Bool}

Returns whether a new structure fragment that doest not connected to any existing ones can be added to space. This function returns true if property autoCreateNewStructFragment is true or there is an empty molecule in space.
Source:
Returns:
Type
Bool

cancelSelecting()

Cancel current selecting operation.
Inherited From:
Source:

canCloneObjects() → {Bool}

Returns whether current editor allows clone objects.
Source:
Returns:
Type
Bool

canCreateNewChild() → {Bool}

Returns whether new direct child can be created in current space. This method will returns true of property Kekule.Editor.ChemSpaceEditor.allowCreateNewChild is true or the space is empty.
Source:
Returns:
Type
Bool

canRedo() → {Bool}

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

canUndo() → {Bool}

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

clearHotTrackedObjs()

Set hot tracked objects to empty.
Inherited From:
Source:

clearOperHistory()

Pop all operations and empty history list.
Inherited From:
Source:

cloneObjects(objects, screenCoordOffset, addToSpace) → {Array}

Clone objects in space. Note that this method only works when property allowCreateNewChild is true.
Parameters:
Name Type Description
objects Array
screenCoordOffset Hash If this value is set, new cloned objects will be moved based on this coord.
addToSpace Bool If true, the cloned objects will add to current space immediately.
Source:
Returns:
Actually cloned objects.
Type
Array

cloneSelection(coordOffset, addToSpace) → {Array}

Clone objects in editor's selection.
Parameters:
Name Type Description
coordOffset Hash New cloned objects will be moved based on this coord. If this value is not set, a default one will be used.
addToSpace Bool If true, the objects cloned will be added to space immediately.
Source:
Returns:
Actually cloned objects.
Type
Array

contextCoordToObj(contextCoord) → {Hash}

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

contextCoordToScreen(screenCoord) → {Hash}

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

createNewStructFragmentAnchor(id) → {Kekule.StructureFragment}

Create new molecule or structure fragment in chem space.
Parameters:
Name Type Description
id String
Source:
Returns:
Type
Kekule.StructureFragment

createNewStructFragmentAndStartingAtom(id, absCoord, isotopeId) → {Kekule.ChemStructureNode}

Create new molecule or structure fragment in chem space, the fragment containing a starting node (atom) to growing bond.
Parameters:
Name Type Description
id String
absCoord Hash
isotopeId String Set null to create a default one
Source:
Returns:
Type
Kekule.ChemStructureNode

createStructStartingAtom(parentMol, id, absCoord, isotopeId) → {Kekule.ChemStructureNode}

Create a new atom in a blank parentMol to growing bonds.
Parameters:
Name Type Description
parentMol Kekule.StructFragment
id String
absCoord Hash
isotopeId String Set null to create a default one
Source:
Returns:
Type
Kekule.ChemStructureNode

createUiEventReceiverElem()

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

deleteSelectedObjs()

Delete and free all selected objects.
Inherited From:
Source:

deselectAll()

Deselect all objects in selection
Inherited From:
Source:

doGetObjSize(obj) → {Hash}

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

doSelectionChanged()

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

doSetObjSize(obj, size)

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

dragSelectingBoxToCoord(screenCoord)

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

dragSelectingCurveToCoord(screenCoord)

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

endManipulateObject()

Call this method to indicate the update process is over and objectChanged will be immediately called.
Inherited From:
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
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
Source:

endUpdateObject()

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

endUpdateSelection()

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

endUpdateUiMarkers()

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

execOperation(operation)

Execute an operation in editor.
Parameters:
Name Type Description
operation Kekule.Operation
Inherited From:
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.
Inherited From:
Source:
Returns:
Type
Object

getChemObjBounds(obj, boundInflation) → {Array}

Returns geometry bounds of a obj in editor.
Parameters:
Name Type Description
obj Kekule.ChemObject
boundInflation Number
Inherited From:
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
Inherited From:
Source:
Returns:
Type
Object

getClientDimension()

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

getClientScrollPosition() → {Hash}

Returns current scroll position of edit client element.
Inherited From:
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.
Inherited From:
Source:
Returns:
Type
Hash

getDefaultCloneScreenCoordOffset() → {Hash}

Returns default coord offset when doing clone selection job in editor.
Source:
Returns:
Type
Hash

getEnabledBondFormData() → {Array}

A helper function returning the available bond form data used by bond setter widget.
Source:
Returns:
Type
Array

getEnabledNonAtomInputData() → {Array}

A helper function returning the available non-atom settings used by atom setter widget.
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
Inherited From:
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.
Inherited From:
Source:
Returns:
Type
Hash

getObjectContextCoord(obj) → {Hash}

Get object's coord on context.
Parameters:
Name Type Description
obj Object
Inherited From:
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.
Inherited From:
Source:
Returns:
Type
Hash

getObjectScreenCoord(obj) → {Hash}

Get object's coord on screen.
Parameters:
Name Type Description
obj Object
Inherited From:
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.
Inherited From:
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.
Inherited From:
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
Inherited From:
Source:
Returns:
All interseting objects.
Type
Array

getObjSize(obj) → {Hash}

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

getOnlyOneBlankStructFragment() → {Kekule.StructureFragment}

If there is only one blank structure fragment (with no node and connector or formula) in editor, returns it.
Source:
Returns:
Type
Kekule.StructureFragment

getSelectionContainerBox(objBoundInflation) → {Hash}

Returns container box (in screen coord system) that contains all objects in selection.
Parameters:
Name Type Description
objBoundInflation Number
Inherited From:
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.
Inherited From:
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.
Inherited From:
Source:
Returns:
Type
Object

hasOnlyOneBlankStructFragment() → {Bool}

Check if there is only one blank structure fragment (with no node and connector or formula) in editor.
Source:
Returns:
Type
Bool

hasSelection() → {Bool}

Check if there is objects selected currently.
Inherited From:
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.
Inherited From:
Source:

hideUiMarker(marker)

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

hotTrackOnCoord(screenCoord)

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

hotTrackOnObj(obj)

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

isDirty() → {Bool}

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

isInSelection(obj) → {Bool}

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

isManipulatingObject()

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

isSelectionVisible()

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

isUpdatingObject()

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

isUpdatingSelection()

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

isUpdatingUiMarkers()

Check if the editor is under continuous UI marker update.
Inherited From:
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.
Inherited From:
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.
Inherited From:
Source:

newDoc()

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

operationDone(operation)

Called after a operation is executed or reversed. Notify object has changed.
Parameters:
Name Type Description
operation Object
Inherited From:
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.
Inherited From:
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
Inherited From:
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.
Inherited From:
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.
Inherited From:
Source:

reactChemObjChange(e)

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

redo()

Redo last operation.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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
Inherited From:
Source:

resetZoom()

Reset to normal size.
Inherited From:
Source:

screenBoxToContext(screenCoord) → {Hash}

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

screenCoordToContext(screenCoord) → {Hash}

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

screenCoordToObj(contextCoord) → {Hash}

Turn screen coord to obj one.
Parameters:
Name Type Description
contextCoord Hash
Inherited From:
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.
Inherited From:
Source:

scrollClientToTop()

Scroll edit client to top.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
Source:

setObjectContextCoord(obj, contextCoord)

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

setObjectScreenCoord(obj, contextCoord)

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

setObjSize(obj, size)

Set dimension of obj.
Parameters:
Name Type Description
obj Object
size Hash
Inherited From:
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.
Inherited From:
Source:

showUiMarker(marker, updateRenderer)

Show an UI marker.
Parameters:
Name Type Description
marker
updateRenderer
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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
Inherited From:
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
Inherited From:
Source:

undo()

Undo last operation.
Inherited From:
Source:

undoAll()

Undo all operations.
Inherited From:
Source:

zoomIn()

Zoom in.
Inherited From:
Source:

zoomOut()

Zoom out.
Inherited From:
Source:

Events

editObjChanged

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

editObjsChanged

Invoked when multiple chem objects inside editor is changed. event param of it has one fields: {objChangeDetails}.
Inherited From:
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.
Inherited From:
Source:

load

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

operChange

Invoked when the operation history has modifications.
Inherited From:
Source:

operHistoryClear

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

operPop

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

operPush

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

operRedo

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

operUndo

Invoked when one operation is undone. event param of it has two fields: {operation: Kekule.Operation, currOperIndex: Int}
Inherited From:
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}.
Inherited From:
Source:

selectionChange

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

Kekule.Editor. ChemSpaceEditor

Methods

addHotTrackedObj(obj)

Add a obj to hot tracked objects.
Parameters:
Name Type Description
obj Object
Inherited From:
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.
Inherited From:
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
Inherited From:
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
Inherited From:
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.
Inherited From:
Source:

beginManipulateObject()

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

beginUpdateObject()

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

beginUpdateSelection()

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

beginUpdateUiMarkers()

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

canAddNewStandaloneObject() → {Bool}

Returns whether a new standalone object (e.g. molecule) can be added to editor.
Source:
Returns:
Type
Bool

canAddUnconnectedStructFragment() → {Bool}

Returns whether a new structure fragment that doest not connected to any existing ones can be added to space. This function returns true if property autoCreateNewStructFragment is true or there is an empty molecule in space.
Source:
Returns:
Type
Bool

cancelSelecting()

Cancel current selecting operation.
Inherited From:
Source:

canCloneObjects() → {Bool}

Returns whether current editor allows clone objects.
Source:
Returns:
Type
Bool

canCreateNewChild() → {Bool}

Returns whether new direct child can be created in current space. This method will returns true of property Kekule.Editor.ChemSpaceEditor.allowCreateNewChild is true or the space is empty.
Source:
Returns:
Type
Bool

canRedo() → {Bool}

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

canUndo() → {Bool}

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

clearHotTrackedObjs()

Set hot tracked objects to empty.
Inherited From:
Source:

clearOperHistory()

Pop all operations and empty history list.
Inherited From:
Source:

cloneObjects(objects, screenCoordOffset, addToSpace) → {Array}

Clone objects in space. Note that this method only works when property allowCreateNewChild is true.
Parameters:
Name Type Description
objects Array
screenCoordOffset Hash If this value is set, new cloned objects will be moved based on this coord.
addToSpace Bool If true, the cloned objects will add to current space immediately.
Source:
Returns:
Actually cloned objects.
Type
Array

cloneSelection(coordOffset, addToSpace) → {Array}

Clone objects in editor's selection.
Parameters:
Name Type Description
coordOffset Hash New cloned objects will be moved based on this coord. If this value is not set, a default one will be used.
addToSpace Bool If true, the objects cloned will be added to space immediately.
Source:
Returns:
Actually cloned objects.
Type
Array

contextCoordToObj(contextCoord) → {Hash}

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

contextCoordToScreen(screenCoord) → {Hash}

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

createNewStructFragmentAnchor(id) → {Kekule.StructureFragment}

Create new molecule or structure fragment in chem space.
Parameters:
Name Type Description
id String
Source:
Returns:
Type
Kekule.StructureFragment

createNewStructFragmentAndStartingAtom(id, absCoord, isotopeId) → {Kekule.ChemStructureNode}

Create new molecule or structure fragment in chem space, the fragment containing a starting node (atom) to growing bond.
Parameters:
Name Type Description
id String
absCoord Hash
isotopeId String Set null to create a default one
Source:
Returns:
Type
Kekule.ChemStructureNode

createStructStartingAtom(parentMol, id, absCoord, isotopeId) → {Kekule.ChemStructureNode}

Create a new atom in a blank parentMol to growing bonds.
Parameters:
Name Type Description
parentMol Kekule.StructFragment
id String
absCoord Hash
isotopeId String Set null to create a default one
Source:
Returns:
Type
Kekule.ChemStructureNode

createUiEventReceiverElem()

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

deleteSelectedObjs()

Delete and free all selected objects.
Inherited From:
Source:

deselectAll()

Deselect all objects in selection
Inherited From:
Source:

doGetObjSize(obj) → {Hash}

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

doSelectionChanged()

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

doSetObjSize(obj, size)

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

dragSelectingBoxToCoord(screenCoord)

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

dragSelectingCurveToCoord(screenCoord)

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

endManipulateObject()

Call this method to indicate the update process is over and objectChanged will be immediately called.
Inherited From:
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
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
Source:

endUpdateObject()

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

endUpdateSelection()

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

endUpdateUiMarkers()

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

execOperation(operation)

Execute an operation in editor.
Parameters:
Name Type Description
operation Kekule.Operation
Inherited From:
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.
Inherited From:
Source:
Returns:
Type
Object

getChemObjBounds(obj, boundInflation) → {Array}

Returns geometry bounds of a obj in editor.
Parameters:
Name Type Description
obj Kekule.ChemObject
boundInflation Number
Inherited From:
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
Inherited From:
Source:
Returns:
Type
Object

getClientDimension()

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

getClientScrollPosition() → {Hash}

Returns current scroll position of edit client element.
Inherited From:
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.
Inherited From:
Source:
Returns:
Type
Hash

getDefaultCloneScreenCoordOffset() → {Hash}

Returns default coord offset when doing clone selection job in editor.
Source:
Returns:
Type
Hash

getEnabledBondFormData() → {Array}

A helper function returning the available bond form data used by bond setter widget.
Source:
Returns:
Type
Array

getEnabledNonAtomInputData() → {Array}

A helper function returning the available non-atom settings used by atom setter widget.
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
Inherited From:
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.
Inherited From:
Source:
Returns:
Type
Hash

getObjectContextCoord(obj) → {Hash}

Get object's coord on context.
Parameters:
Name Type Description
obj Object
Inherited From:
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.
Inherited From:
Source:
Returns:
Type
Hash

getObjectScreenCoord(obj) → {Hash}

Get object's coord on screen.
Parameters:
Name Type Description
obj Object
Inherited From:
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.
Inherited From:
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.
Inherited From:
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
Inherited From:
Source:
Returns:
All interseting objects.
Type
Array

getObjSize(obj) → {Hash}

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

getOnlyOneBlankStructFragment() → {Kekule.StructureFragment}

If there is only one blank structure fragment (with no node and connector or formula) in editor, returns it.
Source:
Returns:
Type
Kekule.StructureFragment

getSelectionContainerBox(objBoundInflation) → {Hash}

Returns container box (in screen coord system) that contains all objects in selection.
Parameters:
Name Type Description
objBoundInflation Number
Inherited From:
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.
Inherited From:
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.
Inherited From:
Source:
Returns:
Type
Object

hasOnlyOneBlankStructFragment() → {Bool}

Check if there is only one blank structure fragment (with no node and connector or formula) in editor.
Source:
Returns:
Type
Bool

hasSelection() → {Bool}

Check if there is objects selected currently.
Inherited From:
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.
Inherited From:
Source:

hideUiMarker(marker)

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

hotTrackOnCoord(screenCoord)

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

hotTrackOnObj(obj)

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

isDirty() → {Bool}

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

isInSelection(obj) → {Bool}

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

isManipulatingObject()

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

isSelectionVisible()

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

isUpdatingObject()

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

isUpdatingSelection()

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

isUpdatingUiMarkers()

Check if the editor is under continuous UI marker update.
Inherited From:
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.
Inherited From:
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.
Inherited From:
Source:

newDoc()

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

operationDone(operation)

Called after a operation is executed or reversed. Notify object has changed.
Parameters:
Name Type Description
operation Object
Inherited From:
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.
Inherited From:
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
Inherited From:
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.
Inherited From:
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.
Inherited From:
Source:

reactChemObjChange(e)

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

redo()

Redo last operation.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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
Inherited From:
Source:

resetZoom()

Reset to normal size.
Inherited From:
Source:

screenBoxToContext(screenCoord) → {Hash}

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

screenCoordToContext(screenCoord) → {Hash}

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

screenCoordToObj(contextCoord) → {Hash}

Turn screen coord to obj one.
Parameters:
Name Type Description
contextCoord Hash
Inherited From:
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.
Inherited From:
Source:

scrollClientToTop()

Scroll edit client to top.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
Source:

setObjectContextCoord(obj, contextCoord)

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

setObjectScreenCoord(obj, contextCoord)

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

setObjSize(obj, size)

Set dimension of obj.
Parameters:
Name Type Description
obj Object
size Hash
Inherited From:
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.
Inherited From:
Source:

showUiMarker(marker, updateRenderer)

Show an UI marker.
Parameters:
Name Type Description
marker
updateRenderer
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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.
Inherited From:
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
Inherited From:
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
Inherited From:
Source:

undo()

Undo last operation.
Inherited From:
Source:

undoAll()

Undo all operations.
Inherited From:
Source:

zoomIn()

Zoom in.
Inherited From:
Source:

zoomOut()

Zoom out.
Inherited From:
Source:

Events

editObjChanged

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

editObjsChanged

Invoked when multiple chem objects inside editor is changed. event param of it has one fields: {objChangeDetails}.
Inherited From:
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.
Inherited From:
Source:

load

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

operChange

Invoked when the operation history has modifications.
Inherited From:
Source:

operHistoryClear

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

operPop

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

operPush

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

operRedo

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

operUndo

Invoked when one operation is undone. event param of it has two fields: {operation: Kekule.Operation, currOperIndex: Int}
Inherited From:
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}.
Inherited From:
Source:

selectionChange

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