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, evt) 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
-
evt: The event used with click operations, null if no mouse event or irrelevant for callback operation.
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.
-
cvjs_getStickyNotesRedline - gets the current redline and stickynote object as string
-
cvjs_setStickyNotesRedline - sets the current redline and stickynote object as string
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.
-
cvjs_returnAllRedlineStickyNoteObjects - gets the current redline and stickynote object as a JSON object
-
cvjs_setAllRedlineStickyNoteObjects - sets a JSON object as redline and stickynotes into the drawing.
-
cvjs_returnAllRedlineObjects - gets the current redline object as a JSON object
-
cvjs_setAllRedlineObjects - sets a JSON object as redlines into the drawing.
-
cvjs_returnAllStickyNoteObjects - gets the current stickynote object as a JSON object
-
cvjs_setAllStickyNoteObjects - sets a JSON object as stickynotes into the drawing.
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, evt){
// 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