zyy-engine

图形引擎API


图元操作

<h1>图元操作</h1> <h2>构造函数</h2> <pre><code class="language-javascript">new BCore2DFast.Viewer.Viewer2D(config)</code></pre> <ul> <li><strong>参数</strong>: <ul> <li><code>config</code>:<code>BCore2DFast.Viewer.Viewer2DConfig</code> - 二维图纸视图对象的配置</li> </ul></li> </ul> <hr /> <h2>方法总览</h2> <p><code>hideBlocksByHandles(handles)</code> 通过图元handle隐藏图元 <code>showBlocksByHandles(handles)</code> 通过图元handle显示图元 <code>showAllBlocksByHandles()</code> 显示所有图元 <code>isoHideBlocksByHandles(handles)</code> 通过图元handle隔离图元 <code>getHideBlocksHandles()</code> 返回所有的隐藏图元 <code>getHighLightBlockHandle()</code> 返回高亮图元</p> <h2>方法示例</h2> <h3>1.显示/隐藏图元</h3> <ul> <li><strong>接口</strong>: <code>showBlocksByHandles(handles)</code> 显示图元 <code>hideBlocksByHandles(handles)</code> 隐藏图元</li> <li><strong>参数</strong>: <ul> <li><code>handles</code>:<code>string[]</code> - 图元对象 handle</li> </ul></li> <li><strong>示例</strong>: <pre><code class="language-javascript">let handles = ['xxx','yyy']; mViewer2D.hideBlocksByHandles(handles); //隐藏图元 mViewer2D.showBlocksByHandles(handles); //显示图元</code></pre></li> </ul> <h3>2. 显示所有图元</h3> <ul> <li><strong>接口描述</strong>: <code>showAllBlocksByHandles()</code> 显示所有图元,包含通过图层隐藏的图元</li> <li><strong>示例</strong>: <pre><code class="language-javascript">mViewer2D.showAllBlocksByHandles();</code></pre></li> </ul> <h3>3. 通过 handle 隔离图元,隐藏其他图元</h3> <ul> <li><strong>接口</strong>:<code>isoHideBlocksByHandles(handles)</code></li> <li><strong>参数</strong>: <code>handles</code>:<code>string[]</code> - 图元对象 handle</li> <li><strong>示例</strong>: <pre><code class="language-javascript">let handles = ['xxx','yyy']; mViewer2D.isoHideBlocksByHandles(handles);</code></pre></li> </ul> <hr /> <h3>4. 返回当前隐藏图元/图块</h3> <ul> <li><strong>接口</strong>:<code>getHideBlocksHandles()</code></li> <li><strong>返回值</strong>: <code>string[]</code> - 图块/图元 handle 数组</li> <li><strong>示例</strong>: <pre><code class="language-javascript">let hiddenBlocks = mViewer2D.getHideBlocksHandles(); console.log(hiddenBlocks);</code></pre></li> </ul> <h3>5. 返回当前高亮图元/图块</h3> <ul> <li><strong>接口</strong>:<code>getHighLightBlockHandle()</code></li> <li><strong>返回值</strong>: <code>string[]</code> - 图块/图元 handle 数组</li> <li><strong>示例</strong>: <pre><code class="language-javascript">let highlightedBlocks = mViewer2D.getHighLightBlockHandle(); console.log(highlightedBlocks);</code></pre></li> </ul> <h3>6. 使用图元/图块返回图层名称</h3> <ul> <li><strong>接口</strong>:<code>getLayerNameByHandles(handles)</code></li> <li><strong>参数</strong>: <code>handles</code>:<code>string[]</code> - 图元对象 handle</li> <li><strong>返回值</strong>: <code>string[]</code> - 图层名称数组</li> <li><strong>示例</strong>: <pre><code class="language-javascript">let handles = ['xxx','yyy']; let layers = mViewer2D.getLayerNameByHandles(handles); console.log(layers);</code></pre></li> </ul> <h3>7. 设置图元颜色</h3> <ul> <li><strong>接口</strong>: <code>setBlockColorByHandles(handles, color)</code> 设置图元颜色 <code>resetBlockColorByHandles(handles)</code> 重置图元颜色</li> <li><strong>参数</strong>: <code>handles</code>:<code>string[]</code> - 图元集合 <code>color</code>:<code>string</code> - 颜色值</li> <li><strong>示例</strong>: <pre><code class="language-javascript">var viewer2dConfig = new BCore.Viewer.Viewer2DConfig(); viewer2dConfig.customColor.colorDatas = ['rgb(155,155,155)']; mViewer2D.setBlockColorByHandles(handles, 'rgb(155,155,155)'); //设置图元颜色 mViewer2D.resetBlockColorByHandles(handles); // 重置图元颜色</code></pre></li> </ul> <h3>8. 设置所有图元颜色</h3> <ul> <li><strong>接口</strong>:<code>setAllBlocksColor(color)</code></li> <li><strong>参数</strong>: <code>color</code>:<code>string</code> - 颜色值</li> <li><strong>示例</strong>: <pre><code class="language-javascript">var viewer2dConfig = new BCore.Viewer.Viewer2DConfig(); viewer2dConfig.customColor.colorDatas = [color]; mViewer2D.setAllBlocksColor(color);</code></pre></li> </ul> <h3>9. 重置所有图元颜色</h3> <ul> <li><strong>接口</strong>: <code>resetAllBlocksColor()</code></li> <li><strong>示例</strong>: <pre><code class="language-javascript">mViewer2D.resetAllBlocksColor();</code></pre></li> </ul> <h3>10. 获取图元的包围盒</h3> <ul> <li><strong>简要描述</strong>:getBoundingBoxByHandle(handle)</li> <li><strong>参数</strong>: <code>handle</code>:<code>string</code> - 图元 handle</li> <li><strong>返回值</strong>: <code>THREE.Box2</code> - 图元的 boundingBox</li> <li><strong>示例</strong>: <pre><code class="language-javascript">let boundingBox = mViewer2D.getBoundingBoxByHandle(handle);</code></pre></li> </ul> <hr /> <h3>11.添加云线</h3> <ul> <li><strong>接口</strong>:<code>addCloudLine(name, box, dis, color, width)</code></li> <li><strong>参数</strong>: <code>name</code>:<code>string</code> - 云线 name (唯一) <code>box</code>:<code>{min:{x,y}, max:{x,y}}</code> - 云线范围(图元box) <code>dis</code>:<code>number</code> - 云线半径(波浪的宽度) <code>color</code>:<code>string</code> - 云线颜色 <code>width</code>:<code>number</code> - 云线宽度(可选,默认3)</li> <li><strong>示例</strong>: <pre><code class="language-javascript">const params = { name: 'xxx', box: {min: {x: 0, y: 0}, max: {x: 100, y: 100}}, dis: 10, color: 'red', width: 3 }; mViewer2D.addCloudLine(...params);</code></pre></li> </ul> <h3>14. 删除云线</h3> <ul> <li><strong>简要描述</strong>:<code>deleteCloudLine(name)</code></li> <li><strong>参数</strong>: <code>name</code>:<code>string</code> - 云线 name (唯一)</li> <li><strong>示例</strong>: <pre><code class="language-javascript">mViewer2D.deleteCloudLine('xxx');</code></pre></li> </ul> <hr /> <p>以上是 <code>BCore2DFast.Viewer.Viewer2D</code> 的详细文档,包括构造函数、参数说明和各个方法的示例</p>

页面列表

ITEM_HTML