Abstract
Creates a new base view instance.
Sets up the canvas, initializes internal state, and registers event listeners for mouse interactions and window resize events.
The HTML canvas element to render into
Protected
_canvasThe HTML canvas element for rendering
Readonly
eventsEvents fired by the view for various interactions
Fired when mouse hovers over an entity
Fired when mouse moves over the view
Fired when mouse stops hovering over an entity
Fired when the view is resized
Abstract
backgroundGets the background color of the view.
The color is represented as a 24-bit hexadecimal RGB number, for example
0x000000
for black or 0xffffff
for white.
Sets the background color of the view.
The background color as a 24-bit hexadecimal RGB number
The bounding box to include all entities in this viewer
The canvas HTML element used by this view
Abstract
centerGets the center point of the current view in world coordinates.
The view center point
Sets the center point of the current view in world coordinates.
The new center point
Postion of current mouse in world coordinate system
Postion of current mouse in screen coordinate system
Gets the input manager for handling user interactions.
The editor provides high-level methods for getting user input like point selection, entity selection, and cursor management.
The editor instance
Height of canvas (not height of window) in pixel
Abstract
missedGets information about missing data during rendering.
This includes fonts that couldn't be loaded and images that are missing or inaccessible. Implementations should track and report this information to help users understand rendering issues.
Object containing missing fonts and images
Abstract
modeGets the current view mode.
The view mode determines how the view responds to user interactions:
The current view mode
Gets the size of the selection box used for entity picking.
This determines how close the mouse needs to be to an entity to select it, measured in screen pixels.
Selection box size in pixels
Sets the size of the selection box used for entity picking.
Selection box size in pixels
The selection set in current view.
Width of canvas (not width of window) in pixel
Abstract
addAdd the specified entity or entities in drawing database into the current scene and draw it or them
Input the entity to add into the current scene
Abstract
addAdd the specified layer in drawing database into the current scene
Input the layer to add into the current scene
Abstract
addAdd the specified layout in drawing database into the current scene
Input the layout to add into the current scene
Abstract
clearClear the scene
Abstract
cwcs2Converts a point from client window coordinates to world coordinates.
The client window coordinate system has its origin at the top-left corner of the canvas, with Y increasing downward. World coordinates use the CAD coordinate system with Y typically increasing upward.
Point in client window coordinates
Point in world coordinates
Abstract
highlightSelect the specified entities
Protected
Abstract
onCalled when hovering the specified entity
Protected
Abstract
onCalled when unhovering the specified entity
Protected
onAbstract
pickPick entities intersected with the specified point in the world coordinate system.
Optional
point: AcGeVector2dLikeInput the point to pick objects. If not provided, the position of current cursor is used.
Return ids of entities intersected with the specified point
Abstract
searchSearch entities intersected or contained in the specified bounding box.
Input the query bounding box
Return query results
Abstract
selectSelect entities intersected with the specified point in the world coordinate system, add them to the current selection set, and highlight them.
Optional
point: AcGeVector2dLikeAbstract
selectSelect entities intersected with the specified bounding box in the world coordinate system, add them to the current selection set, and highlight them.
Input one bounding box in the world coordinate system.
Set callback function used to calculate size of canvas when window resized
Input callback function
Abstract
unhighlightUnhighlight the specified entities
Abstract
updateUpdate the specified entity or entities
Input the entity or entities to update
Abstract
updateUpdate the specified layer in the current scene
Input the layer to update
Abstract
wcs2Converts a point from world coordinates to client window coordinates.
This is the inverse of cwcs2Wcs()
, converting from the CAD world
coordinate system to screen pixel coordinates.
Point in world coordinates
Point in client window coordinates
Abstract
zoomZooms the view to fit the specified bounding box with optional margin.
This method adjusts the view's center and zoom level so that the entire specified bounding box is visible within the viewport. The margin parameter adds extra space around the bounding box to provide visual padding.
The bounding box to zoom to, in world coordinates
Additional margin around the bounding box (in world units)
Abstract
zoomZooms the view to fit all visible entities in the current scene.
This method automatically calculates the bounding box of all entities currently displayed in the view and adjusts the view's center and zoom level to show the entire scene. This is useful for getting an overview of the entire drawing or after loading new content.
This function takes effect only if the current view has finished rendering all entities. When opening a file, progressive Rendering is used to render entities incrementally. So this function will wait until all of entities rendered or a timeout occurs.
Optional
timeout: numberMaximum time (ms) to wait before executing zoom to fit action. Default: 0 (no timeout).
Abstract base class for all CAD view implementations.
This class provides the foundation for rendering and interacting with CAD drawings. It manages:
Concrete implementations must provide specific rendering logic and coordinate transformations appropriate for their rendering technology (e.g., Three.js, SVG).
Key Responsibilities
Example