Hi,
Apologies for a newbie question. I’d like to use the diagram element alongside the freehand draw tool. I took the example from the website and addedd the freehand drawing tool, but after I draw something the event appears to be captured by the diagram element and creates a new diagram mode instead.
Is this possible?
I’ve got the following so far
var $ = go.GraphObject.make;
var myDiagram =
$(go.Diagram, “myDiagramDiv”,
{
initialContentAlignment: go.Spot.Center, // center Diagram contents
“undoManager.isEnabled”: true, // enable Ctrl-Z to undo and Ctrl-Y to redo
layout: $(go.TreeLayout, // specify a Diagram.layout that arranges trees
{ angle: 90, layerSpacing: 35 })
});
myDiagram.toolManager.mouseDownTools.insertAt(3, new GeometryReshapingTool());
// the template we defined earlier
myDiagram.nodeTemplate =
$(go.Node, “Horizontal”,
{ background: “#44CCFF” },
$(go.Picture,
{ margin: 10, width: 50, height: 50, background: “red” },
new go.Binding(“source”)),
$(go.TextBlock, “Default Text”,
{ margin: 12, stroke: “white”, font: “bold 16px sans-serif” },
new go.Binding(“text”, “name”))
);
var toolX = new FreehandDrawingTool();
// provide the default JavaScript object for a new polygon in the model
toolX.archetypePartData =
{ stroke: “green”, strokeWidth: 3 };
// install as first mouse-down-tool
myDiagram.toolManager.mouseDownTools.insertAt(0, toolX);
// define a Link template that routes orthogonally, with no arrowhead
myDiagram.linkTemplate =
$(go.Link,
{ routing: go.Link.Orthogonal, corner: 5 },
$(go.Shape, { strokeWidth: 3, stroke: “#555” })); // the link shape
var model = $(go.TreeModel);
model.nodeDataArray =
[
{ key: “1”, name: “Animal”, source: “animal.jpg” },
{ key: “2”, parent: “1”, name: “Beaker”, source: “beaker.jpg” },
{ key: “3”, parent: “1”, name: “Miss Piggy”, source: “piggy.jpg” },
{ key: “4”, parent: “3”, name: “Fozzie”, source: “fozzie.jpg” },
{ key: “5”, parent: “3”, name: “Kermit”, source: “kermit.jpg” },
{ key: “6”, parent: “2”, name: “Bunsen”, source: “bunsen.jpg” }
];
myDiagram.model = model;
Thanks