Skip to content

GemCAD

This component renders a 3D CAD model and facilitates user interaction through node selection and marker overlays.

Usage Example

/* (c) https://github.com/MontiCore/monticore */
package example_cad;

import mc.fenix.cad.GemCAD;
import mc.fenix.cad.GemCADTypes.Marker;
import common.ExamplePage;

page GemCADExample() {
  @ExamplePage(
    component = cad@GemCAD(
      height = "500px",
      width = "100%",
      filePath = "assets/cad/test.gltf",
      markers = [
        Marker("", "red"),
        Marker("Blue Label", "blue"),
        Marker("Green Label", "green")
      ],
      onNodeClick = handleNodeClick()
    ),
    basePath = "example_cad",
    componentName = "GemCADExample"
  );
}
GemCADExample

TypeScript implementation:

package example_cad;

import umlp.guiutil.HTMLUtils;
import umlp.jsweet.extension.annotation.Component;
import java.util.function.Consumer;

@Component
public class GemCADExample extends GemCADExampleTOP {

  public Consumer<String> handleNodeClick() {
    return (nodeName) -> {
      if ("red".equals(nodeName)) {
        onRedClick();
      } else if ("blue".equals(nodeName)) {
        HTMLUtils.alert("Blue clicked!");
      } else {
        HTMLUtils.alert("Unknown node clicked: " + nodeName);
      }
    };
  }

  private void onRedClick() {
    HTMLUtils.alert("Hello! The Red Node was clicked (handled via Java Event).");
  }
}

GUI Model

component GemCAD(
   String height,

   String width,

   String filePath = "",

   List<Marker> markers,

   Event<String> onNodeClick
)
Name Type Description Default value
height String The vertical dimension of the component (e.g., "100%", "500px").
width String The horizontal dimension of the component.
filePath String The relative or absolute path to the CAD file resource. ""
markers List<Marker> A collection of Marker objects to be rendered as annotations on the CAD model.
onNodeClick Event<String> The event emitted when a user interacts with a specific node in the CAD model.

Types

GemCADTypes

package mc.fenix.cad;

classdiagram GemCADTypes {

  public class Marker {
    String label;

    String nodeName;

    +Marker(String label, String nodeName);
  }
}

Marker

Name Type Description Default value
label String The human-readable text label displayed at the marker position.
nodeName String The unique identifier of the target node within the hierarchical structure of the CAD model. This identifier corresponds to the specific name assigned to a geometric object or group within the source CAD file (e.g., the object name in an .obj or .stl file structure).