QCAD
Open Source 2D CAD
library.js File Reference

Functions

void activateFont (void fontComboBox, void fontName)
 
void addActionsToWidgets ()
 
void addDirtyFlag (void title)
 
void angleToString (void num, void decimals)
 
void coordinateToString (void coordinate, void decimals, void relative, void polar, void doc)
 Formats the given coordinate (RVector) into a locale aware string. More...
 
void copyDirectory (void sourceDirPath, void destDirPath)
 Copies a directory recursively. More...
 
void deepCopy (void obj)
 Clones the given object (deep copy). More...
 
void deg2rad (void val)
 Converts degrees to radiant. More...
 
void entityTypeToString (void type, void plural)
 Converts the given entity type enum to a human readable, translated string. More...
 
void findFile (void dirPath, void fileName, void ignoreDirs)
 Finds a file recursively. More...
 
void fixSymbolTableName (void name)
 Fixes the given symbol table name (e.g. More...
 
void getAbsolutePathForArg (void file)
 
void getClipboard ()
 
void getClosestSimpleShape (void entity, void pos)
 
void getCurrentDateTime (void format)
 
void getEntityTypeProperties (void type)
 
void getInBlockEasyDragAndDrop (void entity)
 
void getInBlockTextEdit (void entity)
 
void getMainWindow ()
 
void getTypeOf (void v)
 Check the real type of the given object. More...
 
void getUrlsFromMimeData (void mimeData)
 
void getVersionNumber (void major, void minor, void revision, void build)
 
void getWidgetPath (void widget)
 Gets the widget path for the given widget. More...
 
void getWidgets (void widget, void ca)
 Gets all child widgets and stores them in an array. More...
 
void hasPlugin (void name)
 
void initFontComboBox (void comboBox)
 Insert CAD fonts at the top into the given font combo box. More...
 
void isArcEntity (void obj)
 Checks if the given object is an arc entity. More...
 
void isArcShape (void obj)
 Checks if the given object is an arc shape. More...
 
void isArray (void obj)
 Checks the type of the given object. More...
 
void isAttributeDefinitionEntity (void obj)
 Checks if the given object is an attribute definition entity. More...
 
void isAttributeEntity (void obj)
 Checks if the given object is an attribute entity. More...
 
void isBlockReferenceEntity (void obj)
 Checks if the given object is a block reference entity. More...
 
void isBoolean (void obj)
 Checks if the given object is a valid boolean value. More...
 
void isCircleEntity (void obj)
 Checks if the given object is a circle entity. More...
 
void isCircleShape (void obj)
 Checks if the given object is a circle shape. More...
 
void isComboBox (void obj)
 Checks the type of the given object. More...
 
void isDimAlignedEntity (void obj)
 Checks if the given object is an aligned dimension entity. More...
 
void isDimAngularEntity (void obj)
 Checks if the given object is an angular dimension entity. More...
 
void isDimDiametricEntity (void obj)
 Checks if the given object is a diametric dimension entity. More...
 
void isDimensionEntity (void obj)
 Checks if the given object is a dimension entity of any kind. More...
 
void isDimLinearEntity (void obj)
 Checks if the given object is a linear dimension entity. More...
 
void isDimOrdinateEntity (void obj)
 Checks if the given object is an ordinate dimension entity. More...
 
void isDimRadialEntity (void obj)
 Checks if the given object is a radial dimension entity. More...
 
void isDimRotatedEntity (void obj)
 Checks if the given object is a rotated dimension entity. More...
 
void isDirectedShape (void obj)
 Checks if the given object is a directed shape. More...
 
void isEllipseArcShape (void obj)
 Checks if the given object is an ellipse arc shape. More...
 
void isEllipseEntity (void obj)
 Checks if the given object is an ellipse entity. More...
 
void isEllipseShape (void obj)
 Checks if the given object is an ellipse shape. More...
 
void isEntity (void obj)
 Checks if the given object is a graphics entity. More...
 
void isEntityType (void obj, void type)
 Checks if the given object is an entity of the given type. More...
 
void isFullEllipseEntity (void obj)
 Checks if the given object is an ellipse entity and represents a full ellipse. More...
 
void isFullEllipseShape (void obj)
 Checks if the given object is a full ellipse shape. More...
 
void isFunction (void obj)
 Checks if the given object is a valid function. More...
 
void isHatchEntity (void obj)
 Checks if the given object is a hatch entity. More...
 
void isImageEntity (void obj)
 Checks if the given object is an image entity. More...
 
void isLayer (void obj)
 Checks if the given object is a layer. More...
 
void isLeaderEntity (void obj)
 Checks if the given object is a leader entity. More...
 
void isLineBasedEntity (void obj)
 Checks if the given object is a line, xline or ray entity. More...
 
void isLineBasedShape (void obj)
 Checks if the given object is a line based shape. More...
 
void isLineEntity (void obj)
 Checks if the given object is a line entity. More...
 
void isLineShape (void obj)
 Checks if the given object is a line shape. More...
 
void isNull (void obj)
 Checks if the given object is undefined or null. More...
 
void isNumber (void obj)
 Checks if the given object is a valid number. More...
 
void isNumberGreaterEqualZero (void n)
 
void isNumberGreaterZero (void n)
 
void isOfType (void obj, void type)
 Checks if the given object is of the given type. More...
 
void isPointEntity (void obj)
 Checks if the given object is a point entity. More...
 
void isPointShape (void obj)
 Checks if the given object is a point shape. More...
 
void isPolylineEntity (void obj)
 Checks if the given object is a polyline entity. More...
 
void isPolylineShape (void obj)
 Checks if the given object is a polyline shape. More...
 
void isQObject (void obj)
 Checks if the given object is a valid QObject. More...
 
void isQWidget (void obj)
 Checks if the given object is a valid QWidget. More...
 
void isRayEntity (void obj)
 Checks if the given object is a ray entity. More...
 
void isRayShape (void obj)
 Checks if the given object is a ray shape. More...
 
void isSeparator (void obj)
 
void isShape (void obj)
 Checks if the given object is a shape. More...
 
void isSolidEntity (void obj)
 Checks if the given object is a solid entity. More...
 
void isSplineEntity (void obj)
 Checks if the given object is a spline entity. More...
 
void isSplineShape (void obj)
 Checks if the given object is a spline shape. More...
 
void isString (void obj)
 Checks if the given object is a string. More...
 
void isTextBasedEntity (void obj)
 Checks if the given object is a text, attribute or attribute definition entity. More...
 
void isTextEntity (void obj)
 Checks if the given object is a text entity. More...
 
void isTraceEntity (void obj)
 Checks if the given object is a trace entity. More...
 
void isTriangleShape (void obj)
 Checks if the given object is a triangle shape. More...
 
void isUrl (void urlString)
 
void isValidVector (void obj)
 Checks if the given object is a valid vector. More...
 
void isVector (void obj)
 Checks if the given object is of type RVector. More...
 
void isViewportEntity (void obj)
 Checks if the given object is a viewport entity. More...
 
void isXLineEntity (void obj)
 Checks if the given object is an xline entity. More...
 
void isXLineShape (void obj)
 Checks if the given object is an xline shape. More...
 
void mergeProperties (void obj1, void obj2)
 
void modifyEntity (void op, void entity, void shape)
 Modify the given entity to represent the given shape. More...
 
void numberToString (void num, void decimals)
 Formats the given number into a locale aware string. More...
 
void objectFromPath (void path)
 Gets an object from its object path. More...
 
void rad2deg (void val)
 Converts radiant to degrees. More...
 
void rayToLine (void ray)
 
void removeDirectory (void dirPath)
 Removes a directory recursively. More...
 
void requiresFramework (void minVersion, void maxVersion)
 Checks if the QCAD Application Framework is at least of version minVersion and not newer than maxVersion. More...
 
void restoreOverrideCursor ()
 
void roundDouble (void num, void dec)
 
void roundVector (void v, void dec)
 
void setInBlockEasyDragAndDrop (void entity, void v)
 Enable / disable easy drag and drop for the given entity. More...
 
void setInBlockTextEdit (void entity, void v)
 Enable / disable in block text editing for the given entity. More...
 
void setMainWindow (void w)
 
void setOverrideCursor (void cursor)
 
void setOverrideWaitCursor ()
 
void shapeToEntity (void document, void shape)
 Creates and returns a new entity based on the given shape. More...
 
void sleep (void msec)
 Sleeps for the given milliseconds. More...
 
void stringToCoordinate (void relativeZero, void str)
 Parses the given string as coordinate. More...
 
void stringToDirectDistanceEntry (void relativeZero, void cursorPosition, void str)
 Parses the given string as direct distance entry. More...
 
void stripDirtyFlag (void title)
 
void trimEndPoint (void shape, void p)
 
void trimStartPoint (void shape, void p)
 
void xLineToRay (void xline)
 

Function Documentation

void activateFont ( void  fontComboBox,
void  fontName 
)
void addActionsToWidgets ( )
void addDirtyFlag ( void  title)
void angleToString ( void  num,
void  decimals 
)
void coordinateToString ( void  coordinate,
void  decimals,
void  relative,
void  polar,
void  doc 
)

Formats the given coordinate (RVector) into a locale aware string.

void copyDirectory ( void  sourceDirPath,
void  destDirPath 
)

Copies a directory recursively.

Existing files are not overridden.

Parameters
sourceDirPathThe source directory.
destDirPathThe destination directory.
Returns
true, if the directory was deleted successfully
void deepCopy ( void  obj)

Clones the given object (deep copy).

void deg2rad ( void  val)

Converts degrees to radiant.

Parameters
valthe value in degrees
Returns
the value in radiant
void entityTypeToString ( void  type,
void  plural 
)

Converts the given entity type enum to a human readable, translated string.

Returns
A translated string for the given entity type.
Parameters
typeEntity type (RS::EntityType)
pluralTrue to return plural, false (default) to return singular.
void findFile ( void  dirPath,
void  fileName,
void  ignoreDirs 
)

Finds a file recursively.

Parameters
dirPathThe directory to search.
fileNameFile name.
Returns
Path of the file or undefined.
void fixSymbolTableName ( void  name)

Fixes the given symbol table name (e.g.

block or layer name).

Parameters
nameSuggested name, for example coming from a file base name.
Returns
Fixed name or undefined if the name cannot be fixed (i.e. contains invalid characters).
void getAbsolutePathForArg ( void  file)
void getClipboard ( )
void getClosestSimpleShape ( void  entity,
void  pos 
)
void getCurrentDateTime ( void  format)
void getEntityTypeProperties ( void  type)
void getInBlockEasyDragAndDrop ( void  entity)
void getInBlockTextEdit ( void  entity)
void getMainWindow ( )
void getTypeOf ( void  v)

Check the real type of the given object.

Standard ECMAScript typeof returns "string" for a string literal but "object" for a string object constructed with new. Same goes for arrays, etc. This function provides a workaround.

void getUrlsFromMimeData ( void  mimeData)
void getVersionNumber ( void  major,
void  minor,
void  revision,
void  build 
)
void getWidgetPath ( void  widget)

Gets the widget path for the given widget.

The widgets in the path are separated with ::, e.g. MainWindow::LayerListDock::LayerWidget::btAdd

Parameters
widgetthe widget
Returns
the widget path
void getWidgets ( void  widget,
void  ca 
)

Gets all child widgets and stores them in an array.

All child widgets are retrieved (recursively).

Use of this function as shown in the example below (formWidget is the parent widget). var widgets = getWidgets(formWidget); widgets["FindText"].text = text;

Parameters
widgetthe parent widget
cathe initial array which holds some child widgets for recursive calls
Returns
Array of child widgets.
void hasPlugin ( void  name)
void initFontComboBox ( void  comboBox)

Insert CAD fonts at the top into the given font combo box.

void isArcEntity ( void  obj)

Checks if the given object is an arc entity.

Returns
true if the given object is an arc entity (RArcEntity).
void isArcShape ( void  obj)

Checks if the given object is an arc shape.

Returns
true if the given object is an arc shape (RArc).
void isArray ( void  obj)

Checks the type of the given object.

Returns
true if the given object is an array.
void isAttributeDefinitionEntity ( void  obj)

Checks if the given object is an attribute definition entity.

Returns
true if the given object is an attribute definition entity (RAttributeDefinitionEntity).
void isAttributeEntity ( void  obj)

Checks if the given object is an attribute entity.

Returns
true if the given object is an attribute entity (RAttributeEntity).
void isBlockReferenceEntity ( void  obj)

Checks if the given object is a block reference entity.

Returns
true if the given object is a block reference entity (RBlockReferenceEntity).
void isBoolean ( void  obj)

Checks if the given object is a valid boolean value.

Returns
true if the given object is a boolean and not NULL or undefined.
void isCircleEntity ( void  obj)

Checks if the given object is a circle entity.

Returns
true if the given object is a line entity (RCircleEntity).
void isCircleShape ( void  obj)

Checks if the given object is a circle shape.

Returns
true if the given object is a circle shape (RCircle).
void isComboBox ( void  obj)

Checks the type of the given object.

Returns
true if the given object is a combo box.
void isDimAlignedEntity ( void  obj)

Checks if the given object is an aligned dimension entity.

Returns
true if the given object is an aligned dimension entity (RDimAlignedEntity).
void isDimAngularEntity ( void  obj)

Checks if the given object is an angular dimension entity.

Returns
true if the given object is an angular dimension entity (RDimAngularEntity).
void isDimDiametricEntity ( void  obj)

Checks if the given object is a diametric dimension entity.

Returns
true if the given object is a diametric dimension entity (RDimDiametricEntity).
void isDimensionEntity ( void  obj)

Checks if the given object is a dimension entity of any kind.

Returns
true if the given object is a dimension entity (RDimensionEntity).
void isDimLinearEntity ( void  obj)

Checks if the given object is a linear dimension entity.

Returns
true if the given object is a linear dimension entity (RDimLinearEntity).
void isDimOrdinateEntity ( void  obj)

Checks if the given object is an ordinate dimension entity.

Returns
true if the given object is an ordinate dimension entity (RDimOrdinateEntity).
void isDimRadialEntity ( void  obj)

Checks if the given object is a radial dimension entity.

Returns
true if the given object is a radial dimension entity (RDimRadialEntity).
void isDimRotatedEntity ( void  obj)

Checks if the given object is a rotated dimension entity.

Returns
true if the given object is a rotated dimension entity (RDimRotatedEntity).
void isDirectedShape ( void  obj)

Checks if the given object is a directed shape.

Returns
true if the given object is a directed shape (derived from RShape and RDirected).
void isEllipseArcShape ( void  obj)

Checks if the given object is an ellipse arc shape.

Returns
true if the given object is an ellipse arc shape (REllipse).
void isEllipseEntity ( void  obj)

Checks if the given object is an ellipse entity.

Returns
true if the given object is an ellipse entity (REllipseEntity).
void isEllipseShape ( void  obj)

Checks if the given object is an ellipse shape.

Returns
true if the given object is an ellipse shape (REllipse).
void isEntity ( void  obj)

Checks if the given object is a graphics entity.

Returns
true if the given object is an entity (derived from REntity).
void isEntityType ( void  obj,
void  type 
)

Checks if the given object is an entity of the given type.

void isFullEllipseEntity ( void  obj)

Checks if the given object is an ellipse entity and represents a full ellipse.

Returns
true if the given object is an ellipse entity (REllipseEntity).
void isFullEllipseShape ( void  obj)

Checks if the given object is a full ellipse shape.

Returns
true if the given object is a full ellipse shape (REllipse).
void isFunction ( void  obj)

Checks if the given object is a valid function.

Returns
true if the given object is a function.
void isHatchEntity ( void  obj)

Checks if the given object is a hatch entity.

Returns
true if the given object is an arc entity (RHatchEntity).
void isImageEntity ( void  obj)

Checks if the given object is an image entity.

Returns
true if the given object is an image entity (RImageEntity).
void isLayer ( void  obj)

Checks if the given object is a layer.

Returns
true if the given object is a layer.
void isLeaderEntity ( void  obj)

Checks if the given object is a leader entity.

Returns
true if the given object is a leader entity (RLeaderEntity).
void isLineBasedEntity ( void  obj)

Checks if the given object is a line, xline or ray entity.

Returns
true if the given object is a line based entity (RLineEntity, RXLineEntity, RRayEntity).
void isLineBasedShape ( void  obj)

Checks if the given object is a line based shape.

Returns
true if the given object is a line based shape (RLine, RXline, RRay).
void isLineEntity ( void  obj)

Checks if the given object is a line entity.

Returns
true if the given object is a line entity (RLineEntity).
void isLineShape ( void  obj)

Checks if the given object is a line shape.

Returns
true if the given object is a line shape (RLine).
void isNull ( void  obj)

Checks if the given object is undefined or null.

Returns
true if the given object is defined and not null. This method also supports shared pointers, i.e. obj.isNull()==true.
void isNumber ( void  obj)

Checks if the given object is a valid number.

Returns
true if the given object is a number and not NaN or +/-Infinity or NULL or undefined.
void isNumberGreaterEqualZero ( void  n)
void isNumberGreaterZero ( void  n)
void isOfType ( void  obj,
void  type 
)

Checks if the given object is of the given type.

E.g. isOfType(myObject, QLabel) returns true if myObject is a QLabel. Note that isOfType(myObject, QWidget) returns false even though QLabel is derived from QWidget.

void isPointEntity ( void  obj)

Checks if the given object is a point entity.

Returns
true if the given object is a point entity (RPointEntity).
void isPointShape ( void  obj)

Checks if the given object is a point shape.

Returns
true if the given object is a point shape (RPoint).
void isPolylineEntity ( void  obj)

Checks if the given object is a polyline entity.

Returns
true if the given object is a spline entity (RPolylineEntity).
void isPolylineShape ( void  obj)

Checks if the given object is a polyline shape.

Returns
true if the given object is a polyline shape (RPolyline).
void isQObject ( void  obj)

Checks if the given object is a valid QObject.

Returns
true if the given object is a QObject.
void isQWidget ( void  obj)

Checks if the given object is a valid QWidget.

Returns
true if the given object is a QWidget.
void isRayEntity ( void  obj)

Checks if the given object is a ray entity.

Returns
true if the given object is a ray entity (RRayEntity).
void isRayShape ( void  obj)

Checks if the given object is a ray shape.

Returns
true if the given object is a ray shape (RRay).
void isSeparator ( void  obj)
void isShape ( void  obj)

Checks if the given object is a shape.

Returns
true if the given object is a shape (derived from RShape).
void isSolidEntity ( void  obj)

Checks if the given object is a solid entity.

Returns
true if the given object is a solid entity (RSolidEntity).
void isSplineEntity ( void  obj)

Checks if the given object is a spline entity.

Returns
true if the given object is a spline entity (RSplineEntity).
void isSplineShape ( void  obj)

Checks if the given object is a spline shape.

Returns
true if the given object is a spline shape (RSpline).
void isString ( void  obj)

Checks if the given object is a string.

Returns
true if the given object is a string
void isTextBasedEntity ( void  obj)

Checks if the given object is a text, attribute or attribute definition entity.

Returns
true if the given object is a text based entity (RTextBasedEntity).
void isTextEntity ( void  obj)

Checks if the given object is a text entity.

Returns
true if the given object is a text entity (RTextEntity).
void isTraceEntity ( void  obj)

Checks if the given object is a trace entity.

Returns
true if the given object is a trace entity (RTraceEntity).
void isTriangleShape ( void  obj)

Checks if the given object is a triangle shape.

Returns
true if the given object is a triangle shape (RTriangle).
void isUrl ( void  urlString)
void isValidVector ( void  obj)

Checks if the given object is a valid vector.

Returns
true if the given object is a valid RVector object.
void isVector ( void  obj)

Checks if the given object is of type RVector.

Returns
true if the given object is an RVector object.
void isViewportEntity ( void  obj)

Checks if the given object is a viewport entity.

Returns
true if the given object is a viewport entity (RViewportEntity).
void isXLineEntity ( void  obj)

Checks if the given object is an xline entity.

Returns
true if the given object is an xline entity (RXLineEntity).
void isXLineShape ( void  obj)

Checks if the given object is an xline shape.

Returns
true if the given object is an xline shape (RXLine).
void mergeProperties ( void  obj1,
void  obj2 
)
void modifyEntity ( void  op,
void  entity,
void  shape 
)

Modify the given entity to represent the given shape.

void numberToString ( void  num,
void  decimals 
)

Formats the given number into a locale aware string.

void objectFromPath ( void  path)

Gets an object from its object path.

Object paths are separated by ::.

Parameters
paththe object path
widgetthe widget [optional, used for the recursive call], obsolete
Returns
Object or undefined
void rad2deg ( void  val)

Converts radiant to degrees.

Parameters
valthe value in radiant
Returns
the value in degrees
void rayToLine ( void  ray)
void removeDirectory ( void  dirPath)

Removes a directory recursively.

Parameters
dirPathThe directory to remove.
Returns
true, if no errors occurs
void requiresFramework ( void  minVersion,
void  maxVersion 
)

Checks if the QCAD Application Framework is at least of version minVersion and not newer than maxVersion.

Parameters
minVersionarray in the format [major,minor,revision,build]
maxVersionarray in the format [major,minor,revision,build]
void restoreOverrideCursor ( )
void roundDouble ( void  num,
void  dec 
)
void roundVector ( void  v,
void  dec 
)
void setInBlockEasyDragAndDrop ( void  entity,
void  v 
)

Enable / disable easy drag and drop for the given entity.

Entities tagged for easy drag and drop can be moved by dragging them while a block reference is selected.

void setInBlockTextEdit ( void  entity,
void  v 
)

Enable / disable in block text editing for the given entity.

void setMainWindow ( void  w)
void setOverrideCursor ( void  cursor)
void setOverrideWaitCursor ( )
void shapeToEntity ( void  document,
void  shape 
)

Creates and returns a new entity based on the given shape.

void sleep ( void  msec)

Sleeps for the given milliseconds.

Parameters
msecthe time to sleep
void stringToCoordinate ( void  relativeZero,
void  str 
)

Parses the given string as coordinate.

Parameters
relativeZeroRVector position of relative zero point.
strString to parse (e.g. "34,15.6" or "@10,30" or "50<60", ...)
Returns
undefined if the string is not a coordinate, an invalid RVector if str is an invalid coordinate or the RVector result.
void stringToDirectDistanceEntry ( void  relativeZero,
void  cursorPosition,
void  str 
)

Parses the given string as direct distance entry.

Author
Robert S
Parameters
relativeZeroRVector position of relative zero point.
cursorPositionRVector position of cursor.
strString to parse (e.g. "34" or "15.123", ...)
Returns
Invalid RVector if str is an invalid dde or return the dde point.
void stripDirtyFlag ( void  title)
void trimEndPoint ( void  shape,
void  p 
)
void trimStartPoint ( void  shape,
void  p 
)
void xLineToRay ( void  xline)