zyy-engine

图形引擎API


矢量批注

<h1>矢量批注</h1> <h2>类说明</h2> <p><code>Bostil</code> 矢量批注工具类,用于创建和管理各种图形标注。</p> <p><code>BostilConfig</code> 矢量批注工具类的配置类。</p> <h2>1.BCore2DFast.Extension2D.BostilConfig</h2> <h3>构造</h3> <pre><code class="language-javascript">new BCore2DFast.Extension2D.BostilConfig(viewer2D)</code></pre> <h3>成员变量</h3> <table> <thead> <tr> <th>成员变量</th> <th>类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>viewer2D</td> <td>BCore2DFast.Viewer.Viewer2D</td> <td>viewer实例</td> </tr> </tbody> </table> <h2>2.BCore2DFast.Extension2D.BostilTypeEnum</h2> <h3>成员变量</h3> <ul> <li><code>BCore2DFast.Extension2D.BostilTypeEnum.Rect</code> - 批注类型为矩形</li> <li><code>BCore2DFast.Extension2D.BostilTypeEnum.Polyline</code> - 批注类型为自定义多边形</li> </ul> <h2>3.BCore2DFast.Extension2D.Bostil</h2> <h3>构造</h3> <pre><code class="language-javascript">new BCore2DFast.Extension2D.Bostil(config)</code></pre> <h3>方法总览</h3> <ul> <li><strong>beginBostil()</strong>: 开启批注</li> <li><strong>endBostil()</strong>: 关闭批注</li> <li><strong>addRect(startPoint, endPoint, color, lineWidth, uuid)</strong>: 矩形批注</li> <li><strong>addPolyLine(points, color, lineWidth, uuid)</strong>: 多边形批注</li> <li><strong>getBostilScreenShot(startPoint, endPoint)</strong>: 获取标注截图</li> <li><strong>getBostilRecord()</strong>: 获取标注记录</li> <li><strong>setBostilRecord(record)</strong>: 设置标注记录</li> <li><strong>removeAll()</strong>: 清空所有标注</li> <li><strong>removeByUuid(uuid)</strong>: 通过uuid移除标注</li> <li><strong>enableEdit(flag)</strong>: 是否可以编辑</li> <li><strong>editByUuid(uuid)</strong>: 通过uuid编辑标注</li> <li><strong>showUI(flag)</strong>: 是否显示标注功能UI</li> <li><strong>clearWhenClose(flag)</strong>: 关闭标注时 是否清除标注内容</li> <li><strong>queryAll()</strong>: 查询所有标注</li> <li><strong>queryByUuid(uuid)</strong>: 通过uuid查询标注</li> <li><strong>setBostilTypeEnum(type)</strong>: 设置矢量批注类型</li> <li><strong>getBostilTypeEnum()</strong>: 返回矢量批注类型</li> <li><strong>addEventListener(eventType, callBack)</strong>: 批注事件监听</li> <li><strong>hideByUuid(uuid)</strong>: 通过uuid隐藏标注</li> <li><strong>showByUuid(uuid)</strong>: 通过uuid显示标注</li> <li><strong>setBostil(bostil)</strong>: 写入批注</li> </ul> <h2>方法示例</h2> <h3>开启/关闭批注</h3> <ul> <li><strong>接口</strong>: <code>beginBostil()</code> 开启批注 <code>endBostil()</code> 关闭批注 <pre><code class="language-javascript">var bostilConfig = new BCore2DFast.Extension2D.BostilConfig(viewer2D); var bostil new BCore2DFast.Extension2D.Bostil(bostilConfig); bostil.beginBostil(); //开启批注 .. bostil.endBostil(); //关闭批注</code></pre></li> </ul> <h3>矩形标注</h3> <ul> <li><strong>描述</strong>:根据两个3d坐标生成矩形标注</li> <li><strong>接口</strong>: <code>addRect(startPoint:THREE.Vector3, endPoint:THREE.Vector3, color?:number, lineWidth?:number,uuid?:string)</code></li> <li><strong>参数</strong>: <code>startPoint</code>:<code>THREE.Vector3</code> - 矩形左上角的点,一个三维坐标,示例:{x: 1, y: 1, z: 0} <code>endPoint</code>:<code>THREE.Vector3</code> - 矩形右下角的点,一个三维坐标,示例:{x: 1, y: 1, z: 0} <code>color</code> : <code>Array</code> - (选填)标注线条颜色,示例: 0xff0000 <code>lineWidth</code> : <code>number</code> - (选填)标注线条宽度,默认:4 <code>uuid</code> : <code>string</code> - (选填)标注对象的uuid,默认会生成uuid,主动传入uuid优先使用传入uuid</li> </ul> <p><strong>示例</strong></p> <pre><code class="language-javascript">let bostilConfig = new BCore2DFast.Extension2D.BostilConfig(viewer2D); let bostil = new BCore2DFast.Extension2D.Bostil(bostilConfig); bostil.beginBostil(); const startPoint = {x: 21514, y: 52844 z: 0}; const endPoint = {x: 69936, y: 30299, z: 0}; bostil.addRect(startPoint, endPoint);</code></pre> <h3>多边形标注</h3> <ul> <li><strong>描述</strong>:根据多个3d坐标生成多边形标注</li> <li><strong>接口</strong>: <code>addPolyLine(points:Three.Vector3[], color?: number[], lineWidth?: number, uuid?:string)</code></li> <li><strong>参数</strong>: <code>points</code>:<code>THREE.Vector3[]</code> - 多边形顶点坐标,示例:[{x: 1, y: 1, z: 0},{x: 1, y: 0, z: 0},{x: 0, y: 1, z: 0}] <code>color</code> : <code>Array</code> - (选填)标注线条颜色,示例: 0xff0000 <code>lineWidth</code> : <code>number</code> - (选填)标注线条宽度,默认:4 <code>uuid</code> : <code>string</code> - (选填)标注对象的uuid,默认会生成uuid,主动传入uuid优先使用传入uuid</li> </ul> <p><strong>示例</strong></p> <pre><code class="language-javascript">let bostilConfig = new BCore2DFast.Extension2D.BostilConfig(viewer2D); let bostil = new BCore2DFast.Extension2D.Bostil(bostilConfig); bostil.beginBostil(); const points = [{x: 21514, y: 52844, z: 0}, {x: 69936, y: 30299, z: 0}, {x: 69936, y: 50299, z: 0}]; bostil.addPolyLine(points);</code></pre> <h3>获取矩形标注截图</h3> <ul> <li><strong>描述</strong>: 获取矩形标注截图,同时传入startPoint、endPoint,返回矩形区域的截图,否则返回视窗截图 注意:方法返回的是Promise</li> <li><strong>接口</strong>: <code>getBostilScreenShot(startPoint?: number[], endPoint?: number[])</code></li> </ul> <p><strong>示例</strong></p> <pre><code class="language-javascript">let bostilConfig = new BCore2DFast.Extension2D.BostilConfig(viewer2D); let bostil = new BCore2DFast.Extension2D.Bostil(bostilConfig); bostil.beginBostil(); let img = bostil.getBostilScreenShot()</code></pre> <ul> <li><strong>返回值说明</strong>: <strong>ur</strong> : <code>string</code> - 返回一个base64格式图片</li> </ul> <h3>获取/设置标注记录</h3> <ul> <li><strong>描述</strong>: 获取/设置当前所有标注记录,可用于回显标注</li> <li><strong>接口</strong>: <code>getBostilRecord()</code> 获取标注记录 <code>setBostilRecord(record: string)</code> 设置标注记录</li> </ul> <p><strong>示例</strong></p> <pre><code class="language-javascript">let bostilConfig = new BCore2DFast.Extension2D.BostilConfig(viewer2D); let bostil = new BCore2DFast.Extension2D.Bostil(bostilConfig); bostil.beginBostil(); //矩形批注 let startPoint = {x: 10000, y: 10000, z: 0}; let endPoint = {x: 30000, y: 30000, z: 0}; bostil.addRect(startPoint, endPoint); //获取标注记录 let record = bostil.getBostilRecord(); //设置批注记录 bostil.setBostilRecord(record);</code></pre> <h3>清空所有标注</h3> <pre><code class="language-javascript">bostil.removeAll();</code></pre> <h3>通过uuid移除标注</h3> <ul> <li><strong>描述</strong>: 每个标注返回一个uuid,通过uuid移除标注</li> <li><strong>接口</strong>: <code>removeByUuid(uuid: string)</code></li> <li><strong>参数</strong>: <code>uuid</code> : <code>string</code> - 生成标注时返回的uuid</li> </ul> <p><strong>示例</strong></p> <pre><code class="language-javascript">let info = bostil.addRect(startPoint, endPoint); bostil.removeByUuid(info.uuid);</code></pre> <h3>设置标注是否可以编辑</h3> <ul> <li><strong>描述</strong>: 设置标注是否可以编辑,默认为true</li> <li><strong>接口</strong>: <code>enableEdit(flag: boolean)</code></li> <li><strong>参数</strong>: <code>flag</code> : <code>boolean</code> - true为可编辑,false为否</li> </ul> <p><strong>示例</strong></p> <pre><code class="language-javascript">let bostilConfig = new BCore2DFast.Extension2D.BostilConfig(viewer2D); let bostil = new BCore2DFast.Extension2D.Bostil(bostilConfig); bostil.beginBostil(); bostil.enableEdit(false)</code></pre> <h3>查询所有标注</h3> <ul> <li><strong>描述</strong>: 通过传入uuid编辑标注</li> <li><strong>接口</strong>: editByUuid(uuid: string)</li> </ul> <p><strong>示例</strong></p> <pre><code class="language-javascript">var infos = bost.queryAll();</code></pre> <h3>通过uuid查询标注</h3> <ul> <li><strong>描述</strong>: 每个标注返回一个uuid,通过uuid移除标注</li> <li><strong>接口</strong>: <code>queryByUuid(uuid: string)</code></li> <li><strong>参数</strong>: <code>uuid</code> : <code>string</code> - 生成标注时返回的uuid</li> </ul> <p><strong>示例</strong></p> <pre><code class="language-javascript">var info = bostil.queryByUuid(info.uuid);</code></pre> <h3>设置标注类型</h3> <ul> <li><strong>描述</strong>: 设置标注类型,使用BCore2DFast.Extension2D.BostilTypeEnum参数</li> <li><strong>接口</strong>: setBostilTypeEnum(type: BostilTypeEnum)</li> <li><strong>参数</strong>: <code>type</code> : <code>BostilTypeEnum</code> - 批注类型</li> </ul> <p><strong>示例</strong></p> <pre><code class="language-javascript">bostil.setBostilTypeEnumore2DFast.Extension2D.BostilTypeEnum.Rect);</code></pre> <hr />

页面列表

ITEM_HTML