CADViewer Technical Documentation, Installation Guide and Reference Samples Library

functional implementation for Redline/StickyNotes

cvjs_graphicalObjectOnChange() is a callback Method on Creation, Delete and Change. It captures any action on Redline and StickyNote objects:

The cvjs_graphicalObjectOnChange(type, graphicalObject, id) callback contains the parameters:

  • type: The types of interaction are: Create, Delete, Click, Move, Resize, Scale, Edit …
  • graphicalObject: The grapical object itself, there are different types of redlines and space objects
  • id: The ID of the object. Note that the corresponding node of the object will typically be RED_xxx for Redlines , SNOTE_xxx for StickyNotes and NODE_xxx for Space Objects

For setting up Redlines see: Redlines

Redlines and SticyNote shares a common javascript structure in CADViewer v6. For CADViewer v7, the data-structure of Redlines and StickyNotes have been updated to a JSON based structure similar to Space Objects, see the Redline Formats.

CADViewer 6

For CADViewer 6, Application programmers have two main API methods to use to extract and add redlines/stickynotes to the canvas based on interaction.

CADViewer 7

For CADViewer 7, there are 6 new methods extract and add redlines/stickynotes to the canvas based on interaction, all are JSON based and can be freely used with any Front-End Framework.

Below are typical implementations of cvjs_graphicalObjectOnChange() for Redlines and StickyNotes:

Typical Functional implementation of cvjs_graphicalObjectOnChange() for Redlines and StickyNotes



var myredline = "";
var myredlineObjects = {};
var mystickynoteObjects = {};
var myredlinestickynoteObjects = {};

// Callback Method on Creation, Delete and Change
function cvjs_graphicalObjectOnChange(type, graphicalObject, spaceID){
// do something with the graphics object created! 
console.log(" cvjs_graphicalObjectOnChange: "+type+" "+graphicalObject+" "+spaceID);

var thisSpaceObject = spaceID;

// REDLINES
if (type == 'Create' && graphicalObject.toLowerCase().indexOf("redline")>-1 ){
    myredline = cvjs_getStickyNotesRedline();  // cadviewer 6
    console.log(myredline);     // cadviewer 6
    myredlinestickynoteObjects = cvjs_returnAllRedlineStickyNoteObjects(); // cadviewer 7
}

if (type == 'Delete' && graphicalObject.toLowerCase().indexOf("redline")>-1 ){
    myredline = cvjs_getStickyNotesRedline();  // cadviewer 6
    console.log(myredline);     // cadviewer 6
    myredlinestickynoteObjects = cvjs_returnAllRedlineStickyNoteObjects(); // cadviewer 7
}			

if (type == 'Create' && graphicalObject.toLowerCase().indexOf("stickynote")>-1){
    myredline = cvjs_getStickyNotesRedline();  // cadviewer 6
    console.log(myredline);     // cadviewer 6
    myredlinestickynoteObjects = cvjs_returnAllRedlineStickyNoteObjects(); // cadviewer 7
}

if (type == 'Delete' && graphicalObject.toLowerCase().indexOf("stickynote")>-1 ){
    myredline = cvjs_getStickyNotesRedline();  // cadviewer 6
    console.log(myredline);     // cadviewer 6
    myredlinestickynoteObjects = cvjs_returnAllRedlineStickyNoteObjects(); // cadviewer 7
}

if (type == 'Edit' && graphicalObject.toLowerCase().indexOf("stickynote")>-1 ){
    myredline = cvjs_getStickyNotesRedline();  // cadviewer 6
    console.log(myredline);     // cadviewer 6
    myredlinestickynoteObjects = cvjs_returnAllRedlineStickyNoteObjects(); // cadviewer 7
}

if (type == 'Move' && graphicalObject.toLowerCase().indexOf("stickynote")>-1 ){
    myredline = cvjs_getStickyNotesRedline();  // cadviewer 6
    console.log(myredline);     // cadviewer 6
    myredlinestickynoteObjects = cvjs_returnAllRedlineStickyNoteObjects(); // cadviewer 7
}

if (type == 'Click'){
    // remove this entry from my DB
    console.log(graphicalObject+" has been clicked");		
}
}

// Addding the Redline and StickyNote object back into the drawing
cvjs_setStickyNotesRedline(myredline);  // cadviewer 6
cvjs_setAllRedlineStickyNoteObjects(myredlinestickynoteObjects)   // cadviewer 7
Last updated on 30 May 2022
Published on 9 Apr 2020