You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// in examples/src/report/main.ts // Define the report function, which takes any data as input (in this case, the nodes) and outputs the TemplateResult type, as shown below:consttemplate: (nodes: Structure["nodes"])=>TemplateResult=(nodes)=>{returnhtml`<p>Number of nodes: ${nodes.val.length}</p>`;};// Then, when creating the viewer element, add the report along with the data used so the report can render it.document.body.append(viewer({structure: {
nodes,
elements,},report: {template: template,data: nodes,},}));
Extend the viewer object to accept the two inputs defined above
// in awatif-ui/src/viewer/viewer.ts exportfunctionviewer({
structure,
settingsObj,
objects3D,
drawingObj,
reportObj,}: {structure?: Structure;settingsObj?: SettingsObj;objects3D?: State<THREE.Object3D[]>;drawingObj?: Drawing;reportObj: {template: (data: object)=>HTMLDivElement;data: object;};}){// Append the report function to the viewer elementif(reportObj)viewerElm.appendChild(report(reportObj));}
Create the report function to generate the report and canvas
// in awatif-ui/src/viewer/report/report.tsexportfunctionreport({
template,
data,}: {template: (data: object)=>HTMLDivElement;data: object;}): HTMLElement{// Create a container element where you can append two elements: Button and Dialogconstcontainer=document.createElement("div");// Refer to the settings element to see how to style with CSS (awatif-ui/src/viewer/setting/)// Create the Button and Dialog, then append them to the container// Refer to the old implementation to see how these elements were created: https://github.com/madil4/awatif/blob/3cb79f5b01c056ee6b18960bf657a027041a8ba2/awatif-ui/src/report.ts// Create an event handler; on each data change, it will render the elementsvan.derive(()=>{render(template(data),dialogBodyElm.value);});returncontainer;}
Notes
These are the main ideas and structure. You can use them as a starting point to make the implementation fully functional.
Feel free to ask any questions if you need further clarification.
Similar to what we have done for the truss designer:
Requirements
The text was updated successfully, but these errors were encountered: