Class: Viewer3D

Kekule.ChemWidget. Viewer3D

new Viewer3D(parentOrElementOrDocument, chemObj)

An 3D viewer widget for chem objects, actually a specialization of Kekule.ChemWidget.Viewer.
Parameters:
Name Type Description
parentOrElementOrDocument Variant
chemObj Kekule.ChemObject
Source:

Extends

Methods

allowAutoSize() → {Bool}

Whether current painter can meet the requirement of auto size.
Inherited From:
Source:
Returns:
Type
Bool

backgroundColorChanged()

Called after background color is changed, should repaint the context.
Inherited From:
Source:

beginContinuousRepainting()

Notify the displayer that in following process, continuous repainting will start and auto size should be disabled. After this phase, endContinuousRepainting() must be called.
Inherited From:
Source:

canModifyPartialGraphic() → {Bool}

Whether context and draw bridge can modify existing graphic content.
Inherited From:
Source:
Returns:
Type
Bool

captionIsShown()

Returns whether the caption is actually displayed.
Inherited From:
Source:

changeContextDimension(newDimension) → {Bool}

Change the dimension of context.
Parameters:
Name Type Description
newDimension Hash
Inherited From:
Source:
Returns:
Return true if dimension change successfully.
Type
Bool

endContinuousRepainting()

Notify the displayer that continuous phase has ended, turn into normal mode.
Inherited From:
Source:

exportToDataUri(dataType, options) → {String}

Export drawing content in viewer to a data URL for tag to use.
Parameters:
Name Type Description
dataType String Type of image data, e.g. 'image/png'.
options Hash Export options, usually this is a number between 0 and 1 indicating image quality if the requested type is image/jpeg or image/webp.
Inherited From:
Source:
Returns:
Type
String

getAllowEditing()

Returns whether editor can be lauched in current viewer.
Inherited From:
Source:

getBackgroundColorOfType(renderType) → {String}

Returns background color used for a special renderType.
Parameters:
Name Type Description
renderType Int
Inherited From:
Source:
Returns:
Type
String

getContextDimension() → {Hash}

Returns dimension of context.
Inherited From:
Source:
Returns:
Type
Hash

getCoordMode() → {Int}

Returns coord mode according to current renderType.
Inherited From:
Source:
Returns:
Type
Int

getCurr2DRotationAngle() → {Float}

Returns current 2D rotation angle (in arc).
Inherited From:
Source:
Returns:
Type
Float

getCurr3DRotationInfo() → {Hash}

Returns current 3D rotation info.
Inherited From:
Source:
Returns:
{rotateMatrix, rotateX, rotateY, rotateZ, rotateAngle, rotateAxisVector}
Type
Hash

getCurrMoleculeDisplayType() → {Int}

Returns current molecule display type.
Inherited From:
Source:
Returns:
Type
Int

getCurrZoom() → {Float}

Returns zoom property in drawOptions.
Inherited From:
Source:
Returns:
Type
Float

getDrawContextParentElem()

Returns parent element to create draw context inside. Descendants can override this method.
Inherited From:
Source:

initialize()

Source:

isPainting() → {Bool}

Returns whether in the painting process.
Inherited From:
Source:
Returns:
Type
Bool

isToolbarEmbedded() → {Bool}

Return whether toolbarParentElem is not set the the toolbar is directly embedded in viewer itself.
Inherited From:
Source:
Returns:
Type
Bool

load(chemObj)

Load and display chemObj in viewer
Parameters:
Name Type Description
chemObj Kekule.ChemObject
Inherited From:
Source:

loadFromData(data, mimeType, fromUrlOrFileName)

Load chem object from data of special MIME type or file format.
Parameters:
Name Type Description
data Variant Usually text content.
mimeType String
fromUrlOrFileName String From which file or url is this data loaded.
Inherited From:
Source:

loadFromFile(file)

Load chem object from file object. NOTE: browser must support File Reader API to use this method.
Parameters:
Name Type Description
file File
Inherited From:
Source:

openEditor(callerWidget)

Open a popup editor to modify displayed object.
Parameters:
Name Type Description
callerWidget Kekule.Widget.BaseWidget Who invokes edit action, default is the viewer itself.
Inherited From:
Source:

prepareSaveData()

Called before obj is saved. Descendants can overrride this method.
Inherited From:
Source:

repaint(overrideOptions)

Repaint the context with current chem object.
Parameters:
Name Type Description
overrideOptions Hash Transform options to do repainting. If this param is set to null, all transform options will be recalculated. If overrideOptions.preserveTransformOptions is true, transform options remains same as last painting process (rather than recalculated).
Inherited From:
Source:

resetDisplay()

Reset displayer to initial state (no zoom, rotation and so on).
Inherited From:
Source:

resetView()

Reset viewer to initial state (no zoom, rotation and so on).
Inherited From:
Source:

resetZoom()

Reset to normal size.
Inherited From:
Source:

rotate2DBy(delta, suspendRendering)

Do a 2D rotation base on delta.
Parameters:
Name Type Description
delta Float In arc.
suspendRendering Bool Set this to true if a immediate repaint is not needed.
Inherited From:
Source:

rotate2DTo(angle, suspendRendering)

Do a 2D rotation to angle.
Parameters:
Name Type Description
angle Float In arc.
suspendRendering Bool Set this to true if a immediate repaint is not needed.
Inherited From:
Source:

rotate3DBy(deltaX, deltaY, deltaZ, suspendRendering)

Do a 3D rotation base on delta.
Parameters:
Name Type Description
deltaX Float In arc.
deltaY Float In arc.
deltaZ Float In arc.
suspendRendering Bool Set this to true if a immediate repaint is not needed.
Inherited From:
Source:

rotate3DByAxis(angle, axisVector, suspendRendering)

Do a 3D rotation around axis.
Parameters:
Name Type Description
angle Float In arc.
axisVector Hash Axis vector coord.
suspendRendering Bool Set this to true if a immediate repaint is not needed.
Inherited From:
Source:

saveData(formatId, dataType, obj) → {Variant}

Save loaded chem object to data.
Parameters:
Name Type Description
formatId String
dataType Int Text or binary. Set null to use default type.
obj Kekule.ChemObject Object to save, default is current chemObj loaded in displayer.
Inherited From:
Source:
Returns:
Saved data.
Type
Variant

setBackgroundColorOfType(color, renderType)

Set background color used for a special renderType.
Parameters:
Name Type Description
color String
renderType Int
Inherited From:
Source:

setCoordMode(coordMode)

Set renderType according to coord mode.
Parameters:
Name Type Description
coordMode Int
Inherited From:
Source:

setHideHydrogens(newType)

Hide or show all hydrogen atoms in 3D model.
Parameters:
Name Type Description
newType Int Value from Kekule.Render.Molecule2DDisplayType or {@link Kekule.Render.Molecule3DDisplayType}.
Inherited From:
Source:

setRotate3DMatrix(matrix, suspendRendering)

Set 3D rotation matrix.
Parameters:
Name Type Description
matrix Array A 4X4 rotation matrix.
suspendRendering Bool Set this to true if a immediate repaint is not needed.
Inherited From:
Source:

updateMenu()

Update menu in viewer.
Inherited From:
Source:

updateToolbar()

Update toolbar in viewer.
Inherited From:
Source:

updateUiComps()

Update toolbar and menu in viewer.
Inherited From:
Source:

zoomIn()

Zoom in.
Inherited From:
Source:

zoomOut()

Zoom out.
Inherited From:
Source:

zoomTo(value, suspendRendering)

Zoom to a specified ratio
Parameters:
Name Type Description
value Float
suspendRendering Bool Set this to true if a immediate repaint is not needed.
Inherited From:
Source:

Events

load

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