MarkGraph class

Drawing marks in 3d scene

Signature:

export default class MarkGraph extends Tool 

Extends: Tool

Remarks

在拾取模式中(DrawMode为0) ,按住Ctrl键,支持多选 在绘制线和矩形时(DrawMode为2 或者4) ,按住Ctrl键,线或者矩形的长边会和xyz中最近的轴平行 可以配合TransformGizmo工具一起使用,支持mark标记的位置编辑

Example

// viewer基础的交互事件
viewer.addInput(new Modelo.View.Input.Mouse(viewer));
viewer.addInput(new Modelo.View.Input.Keyboard(viewer));

// 标记的工具
var markGraph = new Modelo.View.Tool.MarkGraph(viewer);
// 位置编辑控件
var gizmo = new Modelo.View.Tool.TransformGizmo(viewer);

// 添加tool到viewer
viewer.addTool(markGraph);
viewer.addTool(gizmo);
// 开启标绘功能
markGraph.setEnabled(true);

viewer.loadModel(modelId, ()=>{}.then(() => {
    // 监听标绘的创建
    viewer.getEventEmitter().on("MarkGraph-Created", function(id){
    console.log('create mark success: ' + id);
  });

   // 监听标绘的删除
  viewer.getEventEmitter().on("MarkGraph-Removed", function(id){
    console.log('delete mark: ' + id);
  });
})

// 如果想给标绘添加gizemo
document.getElementById("Gizmo").onclick = function(){
  // 获得当前选中的标记(也可以用其它方式)
  let marks = markGraph.getSelectMarks();
  // 这里目前只支持单个mark的gizmo操作
  if(marks[0]){
    useGizmo = !useGizmo;
    gizmo.setDrawable(marks[0].drawable);
  }else{
    useGizmo = false;
  }
  gizmo.setEnabled(useGizmo);
}

Constructors

ConstructorDescription
(constructor)(viewer, selector)Constructs a new instance of the MarkGraph class

Properties

PropertyModifiersDescription
enableGizmo
enableOnlyDrawingRevoke
marksMap<string | Map for store marks, composed by key-value pairs
orthoDrawing
revokeEnabled

Methods

MethodDescription
clearAllSelect(shouldNotify)取消高亮选中
clearOperation()
completeDrawing()结束当前绘制
copyArrows()复制粘贴选中得箭头(目前只支持箭头)
destroy()Delete all resources in the measure tool
drawMark(keyPoints, type, id, parameter)参数化绘制模型
editMark(mark)进入标绘编辑状态
enabledOrthoDrawing(enabled)允许正交绘制
exitTransformMark()退出mark位置编辑功能
getArrowDrawingParameters()获得下一次绘制的参数
getArrowParameters(markId)
getGizmo()获得gizmo对象
getLines()获得线
getMark(id)get mark by id
getPoints()获得点
getRects()获得矩形/箭头
getSelectArrows()get all the arrows as an array
getSelectMarks()get all the marks as an array
remove(mark)remove mark
reset()reset all marks
revoke()
setArrowDrawingParameters(parameter)
setArrowParameters(markId, parameters)
setAuxiliaryVisibility(visibility)
setContourColor(color)set contour color
setDefaultColor(color, isOverride)set default color for all the marks
setDefaultOpacity(opacity, isOverride)set default opacity for all the marks
setHoverEnabled(enabled)允许鼠标浮动高亮轮廓线
setMarkDiffuse(mark, color)set color for a mark
setMarkOpacity(mark, opacity)set opacity for a mark
setMarkType(mode)set mark type
setOrthoPlane(orthoPlane)
setRectDefaultWidth(width, influenceAll)set rectangle width
setSceneSize(bbox)
setSelectMarks(marks, shouldNotify)
setSelectType(selectType)set select style for marks
startGizmo()设置gizmo
transformMark(marks, gizmo, group)
unRevoke()