Type Definitions
Area
Area object.
{left: number, top: number, right: number, bottom: number}
| Name | Type | Description |
|---|---|---|
left | number | Left coordinate |
top | number | Top coordinate |
right | number | Right coordinate |
bottom | number | Bottom coordinate |
BBox
Bounding box object.
{x: number, y: number, width: number, height: number}
| Name | Type | Description |
|---|---|---|
x | number | X coordinate |
y | number | Y coordinate |
width | number | Width of bounding box |
height | number | Height of bounding box |
Intersect
Intersect object.
{pts: Point[], ts1: number[], ts2: number[]}
| Name | Type | Description |
|---|---|---|
pts | Point[] | An array of intersected points, or an empty array if no intersections. |
ts | Array.<number[]> | Two arrays (0 === first segment, 1 === second segment) of T values for the intersected points. |
PathList
Path segment list. Contains an array of objects in the following format:
{type: string, x: number, y: number, x1: number, y1: number, x2: number, y2: number}
| Name | Type | Attributes | Description |
|---|---|---|---|
type | string | Valid svg path command limited to M, L, C, Q, Z | |
x | number | X coordinate | |
y | number | Y coordinate | |
x1 | number | optional | X control point for quadratic and bezier curve |
y1 | number | optional | Y control point for quadratic and bezier curve |
x2 | number | optional | Second X control point for bezier curve |
y2 | number | optional | Second Y control point for bezier curve |
length | number | The number of items in the path segment list |
Point
Point object.
{x: number, y: number}
| Name | Type | Description |
|---|---|---|
x | number | X coordinate |
y | number | Y coordinate |
Methods
.addToGroup(src, tgt) Returns: Vecta.Shape
Add src shape to first level of the tgt shape
| Name | Type | Description |
|---|---|---|
src | Vecta.Shape | Source shape to be added into the tgt shape |
tgt | Vecta.Shape | Target shape to keep the src shape |
Returns:
tgt Target shape that contained the src shape
.batchUpdate(path, json) Returns: *
Batch update to remedy the "Write too large" error on Firebase
| Name | Type | Description |
|---|---|---|
path | Path to data | |
json | Update json object |
.getRefComp(infos, ref_shapes, [type], [edit], [include_empty]) Returns: Object
Get components of all symbol references and also reset group value to start from 1
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
infos | Object | All symbols information like location and group | ||
ref_shapes | Object | All refs that separated by page ({ pg_id: [shp_ids] }) | ||
type | Object | optional | 11 | Symbol type, default to electrical symbol |
edit | Boolean | optional | false | To denote whether want to update infos while update group |
include_empty | Boolean | optional | false | To denote whether want to include wires that have no component |
Returns:
comps Object that contains the ref and corresponding comp info. Example: { reference: { id:shp_id, page_id:page id, ref:reference, group:Number, shps:[shp1, shp2], pages: [pg1, pg2], type:symbol type } }
.getRefShapes([options]) Returns: Object
Get list of shape ids with the same reference
| Name | Type | Attributes | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | optional | Object that contains options such as reference, name, etc
|
Returns:
ret List of shape ids by page ids. Structure is { pg_id: [shp_ids] }
.getTags(tag_ids) Returns: Object
Get lists of component tags and cable tags from the given ids
| Name | Type | Description |
|---|---|---|
tag_ids | string | IDs of the component tags and cable tags in the format of 'id1|id2|id3' |
Returns:
tags Contains list of cable tags and component tags, their key is the symbol type number Example: { 29: []. 30: [] }
.getTBlockComps(term_blocks) Returns: Object
Get terminal blocks with their information such as group number
| Name | Type | Description |
|---|---|---|
term_blocks | Object | All terminal block's information like location and group |
Returns:
obj Object that contains the ref and corresponding comp info. Example: { reference: { id:shp_id, page_id:page id, ref:reference, group:Number, shps:[shp1, shp2], pages: [pg1, pg2], type:symbol type } }
.loadOriginalView(cur_view, cur_pg_id, [shape])
Load a page with a given zoom and view coordinate
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cur_view | object | Object that hold information such as zoom and coordinate of view
| |||||||||||||
cur_pg_id | string | ID of the page | |||||||||||||
shape | Vecta.Shape | optional | The shape to be selected after view the page |
.preparePages() Returns: *
returns a Promise with an array of Vecta.Page as return value. also prepares Vecta.activeDoc and Vecta.activePage and v.pages to be used by export functions later
.searchNetwork(wire, scanned) Returns: Promise.<T>
Given a wire, we scan through all the wires and symbols that connected to it
| Name | Type | Description |
|---|---|---|
wire | Vecta.Shape | The wire that we want to scan |
scanned | object | The list of wires that already scanned before, its structure is { wire_id: 1 } |
Returns:
It resolved an object: 1. if the wire is already scanned previously, it resolve { scanned: true } 2. otherwise, it resolve { nets: { id: {object} }, shapes: [ {object} ] }
.spinText(str, [decrement], [begin]) Returns: string
increment or decrement page prefix or refs/net names
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
str | string | the string to do inc/dec | ||
decrement | boolean | optional | false | increment by default |
begin | boolean | optional | false | dec/inc the begin number |
Returns:
incremented/decremented text
.typeNo(shape, [val]) Returns: number
Get or set the symbol type
| Name | Type | Attributes | Description |
|---|---|---|---|
shape | Vecta.Shape|v.Group | The symbol shape in Vecta.Shape or v.Group | |
val | number | optional | The value of symbol type to set or get if undefined |
Returns:
type Type of the symbol
.updateVType(connector)
Update v:type according to the path
| Name | Type | Description |
|---|---|---|
connector | Vecta.Shape |
.userJSON(shape, [key], [val]) Returns: string|number|null
Get or set the shape's json.user
| Name | Type | Attributes | Description |
|---|---|---|---|
shape | Vecta.Shape|v.Group | The symbol shape in Vecta.Shape or v.Group | |
key | string|object | optional | The key of the property in json.user, set multiple properties if this is an object, returns whole object if this is undefined |
val | string|number|null | optional | The value to be set on the property if given, null to remove, read value this is not provided |
Returns:
type Returns the value if val is not provided
.waitLangLoaded()
Utility method to check & wait for lang loaded if it's not already loaded. If it's already loaded, then it will just resolve