mxdraw 0.1.123 → 0.1.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/MxModule/Mx3PointArc/draw.d.ts +1 -0
- package/dist/lib/MxModule/Mx3PointArc/draw.js +1 -0
- package/dist/lib/MxModule/Mx3PointArc/index.d.ts +5 -1
- package/dist/lib/MxModule/Mx3PointArc/index.js +1 -1
- package/dist/lib/MxModule/MxDb2LineAngularDimension/draw.d.ts +2 -0
- package/dist/lib/MxModule/MxDb2LineAngularDimension/draw.js +1 -0
- package/dist/lib/MxModule/MxDb2LineAngularDimension/index.d.ts +5 -1
- package/dist/lib/MxModule/MxDb2LineAngularDimension/index.js +1 -1
- package/dist/lib/MxModule/MxDbAlignedDimension/draw.d.ts +2 -0
- package/dist/lib/MxModule/MxDbAlignedDimension/draw.js +1 -0
- package/dist/lib/MxModule/MxDbAlignedDimension/index.d.ts +5 -1
- package/dist/lib/MxModule/MxDbAlignedDimension/index.js +1 -1
- package/dist/lib/MxModule/MxDbAnyLine/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbAnyLine/draw.js +1 -0
- package/dist/lib/MxModule/MxDbAnyLine/index.d.ts +5 -1
- package/dist/lib/MxModule/MxDbAnyLine/index.js +1 -1
- package/dist/lib/MxModule/MxDbArcShape/index.d.ts +2 -1
- package/dist/lib/MxModule/MxDbArcShape/index.js +1 -1
- package/dist/lib/MxModule/MxDbArcShapeDraw/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbArcShapeDraw/draw.js +1 -0
- package/dist/lib/MxModule/MxDbArcShapeDraw/index.d.ts +6 -1
- package/dist/lib/MxModule/MxDbArcShapeDraw/index.js +1 -1
- package/dist/lib/MxModule/MxDbArea/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbArea/draw.js +1 -0
- package/dist/lib/MxModule/MxDbArea/index.d.ts +5 -1
- package/dist/lib/MxModule/MxDbArea/index.js +1 -1
- package/dist/lib/MxModule/MxDbArrow/draw.d.ts +2 -0
- package/dist/lib/MxModule/MxDbArrow/draw.js +1 -0
- package/dist/lib/MxModule/MxDbArrow/index.d.ts +5 -1
- package/dist/lib/MxModule/MxDbArrow/index.js +1 -1
- package/dist/lib/MxModule/MxDbCircleArc/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbCircleArc/draw.js +1 -0
- package/dist/lib/MxModule/MxDbCircleArc/index.d.ts +5 -1
- package/dist/lib/MxModule/MxDbCircleArc/index.js +1 -1
- package/dist/lib/MxModule/MxDbCloudLine/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbCloudLine/draw.js +1 -0
- package/dist/lib/MxModule/MxDbCloudLine/index.d.ts +6 -1
- package/dist/lib/MxModule/MxDbCloudLine/index.js +1 -1
- package/dist/lib/MxModule/MxDbCoord/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbCoord/draw.js +1 -0
- package/dist/lib/MxModule/MxDbCoord/index.d.ts +5 -2
- package/dist/lib/MxModule/MxDbCoord/index.js +1 -1
- package/dist/lib/MxModule/MxDbEllipse/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbEllipse/draw.js +1 -0
- package/dist/lib/MxModule/MxDbEllipse/index.d.ts +5 -1
- package/dist/lib/MxModule/MxDbEllipse/index.js +1 -1
- package/dist/lib/MxModule/MxDbEllipseArc/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbEllipseArc/draw.js +1 -0
- package/dist/lib/MxModule/MxDbEllipseArc/index.d.ts +7 -3
- package/dist/lib/MxModule/MxDbEllipseArc/index.js +1 -1
- package/dist/lib/MxModule/MxDbEntity/index.d.ts +11 -0
- package/dist/lib/MxModule/MxDbEntity/index.js +1 -1
- package/dist/lib/MxModule/MxDbGradientLine/index.d.ts +2 -1
- package/dist/lib/MxModule/MxDbGradientLine/index.js +1 -1
- package/dist/lib/MxModule/MxDbHatch/index.d.ts +2 -1
- package/dist/lib/MxModule/MxDbHatch/index.js +1 -1
- package/dist/lib/MxModule/MxDbImage/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbImage/draw.js +1 -0
- package/dist/lib/MxModule/MxDbImage/index.d.ts +5 -2
- package/dist/lib/MxModule/MxDbImage/index.js +1 -1
- package/dist/lib/MxModule/MxDbLeadComment/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbLeadComment/draw.js +1 -0
- package/dist/lib/MxModule/MxDbLeadComment/index.d.ts +5 -2
- package/dist/lib/MxModule/MxDbLeadComment/index.js +1 -1
- package/dist/lib/MxModule/MxDbLeadTag/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbLeadTag/draw.js +1 -0
- package/dist/lib/MxModule/MxDbLeadTag/index.d.ts +5 -2
- package/dist/lib/MxModule/MxDbLeadTag/index.js +1 -1
- package/dist/lib/MxModule/MxDbLine/draw.d.ts +2 -0
- package/dist/lib/MxModule/MxDbLine/draw.js +1 -0
- package/dist/lib/MxModule/MxDbLine/index.d.ts +5 -2
- package/dist/lib/MxModule/MxDbLine/index.js +1 -1
- package/dist/lib/MxModule/MxDbLineShape/index.d.ts +2 -1
- package/dist/lib/MxModule/MxDbLineShape/index.js +1 -1
- package/dist/lib/MxModule/MxDbPolyline/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbPolyline/draw.js +1 -0
- package/dist/lib/MxModule/MxDbPolyline/index.d.ts +5 -2
- package/dist/lib/MxModule/MxDbPolyline/index.js +1 -1
- package/dist/lib/MxModule/MxDbRect/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbRect/draw.js +1 -0
- package/dist/lib/MxModule/MxDbRect/index.d.ts +5 -1
- package/dist/lib/MxModule/MxDbRect/index.js +1 -1
- package/dist/lib/MxModule/MxDbRectBoxLeadComment/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbRectBoxLeadComment/draw.js +1 -0
- package/dist/lib/MxModule/MxDbRectBoxLeadComment/index.d.ts +5 -1
- package/dist/lib/MxModule/MxDbRectBoxLeadComment/index.js +1 -1
- package/dist/lib/MxModule/MxDbRegularPolygon/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbRegularPolygon/draw.js +1 -0
- package/dist/lib/MxModule/MxDbRegularPolygon/index.d.ts +5 -1
- package/dist/lib/MxModule/MxDbRegularPolygon/index.js +1 -1
- package/dist/lib/MxModule/MxDbRegularPolygonShape/index.d.ts +2 -1
- package/dist/lib/MxModule/MxDbRegularPolygonShape/index.js +1 -1
- package/dist/lib/MxModule/MxDbRingShape/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbRingShape/draw.js +1 -0
- package/dist/lib/MxModule/MxDbRingShape/index.d.ts +14 -1
- package/dist/lib/MxModule/MxDbRingShape/index.js +1 -1
- package/dist/lib/MxModule/MxDbSVG/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbSVG/draw.js +1 -0
- package/dist/lib/MxModule/MxDbSVG/index.d.ts +5 -2
- package/dist/lib/MxModule/MxDbSVG/index.js +1 -1
- package/dist/lib/MxModule/MxDbShape/index.js +1 -1
- package/dist/lib/MxModule/MxDbStarShape/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbStarShape/draw.js +1 -0
- package/dist/lib/MxModule/MxDbStarShape/index.d.ts +13 -1
- package/dist/lib/MxModule/MxDbStarShape/index.js +1 -1
- package/dist/lib/MxModule/MxDbText/MxDbText.d.ts +3 -0
- package/dist/lib/MxModule/MxDbText/MxDbText.js +1 -1
- package/dist/lib/MxModule/MxDbText/draw.d.ts +1 -0
- package/dist/lib/MxModule/MxDbText/draw.js +1 -0
- package/dist/lib/MxModule/MxDbText/index.js +1 -1
- package/dist/lib/MxModule/MxPaintBrush/index.d.ts +44 -0
- package/dist/lib/MxModule/MxPaintBrush/index.js +1 -0
- package/dist/lib/MxModule/loadCoreCode/index.js +1 -1
- package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +1 -1
- package/dist/lib/MxModule/store/Pubsub.d.ts +6 -0
- package/dist/lib/MxModule/store/Pubsub.js +1 -1
- package/dist/{index.d.ts → lib/MxModule.d.ts} +164 -15
- package/dist/lib/mxdraw.d.ts +1 -0
- package/dist/lib/mxdraw.js +1 -1
- package/dist/lib/tools/dynamicImport/index.js +1 -1
- package/dist/lib/tools/registerMxDbEntity/index.d.ts +5 -0
- package/dist/lib/tools/registerMxDbEntity/index.js +1 -0
- package/dist/mxdraw.es.js +1 -1
- package/dist/mxdraw.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import McGiWorldDrawType from"../McGiWorldDrawType";import MxDbEntity from"../MxDbEntity";function createCurvePath(e=!1){const t=new THREE.CurvePath;return t.autoClose=e,t}function createQuadraticBezierCurve3(e){let t=0,r=[];for(let i=0;i<e.length;i++){const i=e[t],n=e[++t]||i,s=e[++t]||n;if(!i||!n||!s)break;r.push(new THREE.QuadraticBezierCurve3(i,n,s))}return r}function createCubicBezierCurve3(e){let t=0,r=[];for(let i=0;i<e.length;i++){const i=e[t],n=e[++t]||i,s=e[++t]||n,o=e[++t]||s;if(!(i&&n&&s&&o))break;r.push(new THREE.CubicBezierCurve3(i,n,s,o))}return r}function getCurveColorGradientData(e,t){let r=0,i=[],n=[];const s=Number((1/t.length).toFixed(2));let o=new THREE.Color(t[r]),c=new THREE.Color(t[r+1]);for(let u=0,l=e.length;u<l;u++){const l=e[u],a=u/e.length;a/r>=s&&(r++,c.set(new THREE.Color(t[r]||t[--r]))),i.push(l.x,l.y,l.z||0),o.lerpHSL(c,a),n.push(o.r,o.g,o.b)}return[i,n]}function getColorGradientData(e,t){let r=[],i=[];for(let n=0,s=e.length;n<s;n++){const s=e[n];r.push(s.x,s.y,s.z||0);const o=new THREE.Color(t[n]);i.push(o.r,o.g,o.b)}return[r,i]}const propertyDbKeys=["points","colors","linecap","linejoin","closed","curveType","tension","bezierType"];
|
|
1
|
+
import McGiWorldDrawType from"../McGiWorldDrawType";import MxDbEntity from"../MxDbEntity";import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";function createCurvePath(e=!1){const t=new THREE.CurvePath;return t.autoClose=e,t}function createQuadraticBezierCurve3(e){let t=0,r=[];for(let i=0;i<e.length;i++){const i=e[t],n=e[++t]||i,s=e[++t]||n;if(!i||!n||!s)break;r.push(new THREE.QuadraticBezierCurve3(i,n,s))}return r}function createCubicBezierCurve3(e){let t=0,r=[];for(let i=0;i<e.length;i++){const i=e[t],n=e[++t]||i,s=e[++t]||n,o=e[++t]||s;if(!(i&&n&&s&&o))break;r.push(new THREE.CubicBezierCurve3(i,n,s,o))}return r}function getCurveColorGradientData(e,t){let r=0,i=[],n=[];const s=Number((1/t.length).toFixed(2));let o=new THREE.Color(t[r]),c=new THREE.Color(t[r+1]);for(let u=0,l=e.length;u<l;u++){const l=e[u],a=u/e.length;a/r>=s&&(r++,c.set(new THREE.Color(t[r]||t[--r]))),i.push(l.x,l.y,l.z||0),o.lerpHSL(c,a),n.push(o.r,o.g,o.b)}return[i,n]}function getColorGradientData(e,t){let r=[],i=[];for(let n=0,s=e.length;n<s;n++){const s=e[n];r.push(s.x,s.y,s.z||0);const o=new THREE.Color(t[n]);i.push(o.r,o.g,o.b)}return[r,i]}const propertyDbKeys=["points","colors","linecap","linejoin","closed","curveType","tension","bezierType"];class MxDbGradientLine extends MxDbEntity{constructor(){super(...arguments),this.linecap="round",this.linejoin="round",this.closed=!1,this.curveType="centripetal",this.tension=0,this.bezierType="quadratic"}create(){return new MxDbGradientLine}getTypeName(){return"MxDbGradientLine"}setPoints(e){return this.points=e,this}setColors(e){return this.colors=e,this}addColor(e){return this.colors.push(e),this}setLinecap(e){this.linecap=e}setClosed(e){this.closed=e}setCurveType(e){this.curveType=e}setTension(e){this.tension=e}setBezierType(e){this.bezierType=e}worldDraw(e){const t=e.getType();let r=this.getPoints();const{closed:i,curveType:n,tension:s,bezierType:o}=this,c=new THREE.BufferGeometry;let u=[],l=[];const a="cubic"===o,h="quadratic"===o;0!==s?this.curve=new THREE.CatmullRomCurve3(r,i,n,s):o?(this.curve=createCurvePath(i),a?this.curve.curves=createCubicBezierCurve3(r):h?this.curve.curves=createQuadraticBezierCurve3(r):this.curve=void 0):this.curve=void 0,this.curve&&(r=this.curve.getPoints(50));const{linecap:p,linejoin:d}=this;let v;if(this.colors&&this.colors.length>1){const e=i?[...this.colors,this.colors[0]]:this.colors;[u,l]=this.curve?getCurveColorGradientData(r,e):getColorGradientData(r,e),c.setAttribute("position",new THREE.Float32BufferAttribute(u,3)),c.setAttribute("color",new THREE.Float32BufferAttribute(l,3)),v=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,linecap:p,linejoin:d})}else c.setFromPoints(r),v=new THREE.LineBasicMaterial({color:this.color,linecap:p,linejoin:d});const E=i?new THREE.LineLoop(c,v):new THREE.Line(c,v);if(e.drawEntity(E),(t===McGiWorldDrawType.kSelectDraw||t===McGiWorldDrawType.kDynDragDraw)&&this.curve){let t=this.getPoints();const r=e.getLineWidth();e.setLineWidth(1),e.drawLines(t),e.setLineWidth(r)}}getGripPoints(){return this.getPoints()}getPoints(){return this.closed?[...this.points,this.points[0]]:this.points}moveGripPointsAt(e,t){return this.move(e,t),!0}move(e,t){return this.points[e].add(t),this}dwgIn(e){return this.dwgInHelp(e,propertyDbKeys),this.curve=e.curve,!0}dwgOut(e){return this.dwgOutHelp(e,propertyDbKeys),e.curve=this.curve,e}}addRegisterMxDbEntity(MxDbGradientLine);export default MxDbGradientLine;
|
|
@@ -3,7 +3,7 @@ import MxDbEntity from '../MxDbEntity';
|
|
|
3
3
|
/**
|
|
4
4
|
* MxDbHatch 填充对象
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
declare class MxDbHatch extends MxDbEntity {
|
|
7
7
|
points: THREE.Vector3[];
|
|
8
8
|
worldDraw(pWorldDraw: McGiWorldDraw): void;
|
|
9
9
|
getTypeName(): string;
|
|
@@ -14,3 +14,4 @@ export default class MxDbHatch extends MxDbEntity {
|
|
|
14
14
|
dwgIn(obj: any): boolean;
|
|
15
15
|
dwgOut(obj: any): any;
|
|
16
16
|
}
|
|
17
|
+
export default MxDbHatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{computeBounding}from"../../tools/three/index";import McGiWorldDrawType from"../McGiWorldDrawType";import MxDbEntity from"../MxDbEntity";
|
|
1
|
+
import{computeBounding}from"../../tools/three/index";import McGiWorldDrawType from"../McGiWorldDrawType";import MxDbEntity from"../MxDbEntity";import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";class MxDbHatch extends MxDbEntity{constructor(){super(...arguments),this.points=[]}worldDraw(t){t.getType()===McGiWorldDrawType.kWorldDraw?t.drawSolid(this.points):t.drawLines([...this.points,this.points[0]])}getTypeName(){return"MxDbHatch"}moveGripPointsAt(t,i){return 0===t?this.points.forEach(t=>{t.add(i)}):this.points[t-1]&&this.points[t-1].add(i),!0}setPoints(t){this.points=t.map(t=>t.clone())}getGripPoints(){if(this.points.length>0){const{centerPoint:t}=computeBounding(this.points);return[t,...this.points]}return[]}dwgIn(t){this.onDwgIn(t);const i=t.points;return this.points=i.map(({x:t,y:i,z:o})=>new THREE.Vector3(t,i,o)),!0}dwgOut(t){return this.onDwgOut(t),t.points=this.points,t}}addRegisterMxDbEntity(MxDbHatch);export default MxDbHatch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function drawMxDbImage(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import MxDbImage from".";import MrxDbgUiPrPoint from"../MrxDbgUiPrPoint";import MxFun from"../MxFun";import MxType from"../MxType";export default function drawMxDbImage(){const e=new MrxDbgUiPrPoint;e.setMessage("\n指定插入点:");let r=MxFun.getCurrentDraw();e.go(t=>{if(0!=t)return;let n=MxFun.screenCoordLong2Doc(300),o=MxFun.screenCoordLong2Doc(200);const d=e.value();let i=MxFun.screenCoord2Doc(10,10);d.z=i.z;let a=new MxDbImage;a.setRenderOrder(MxType.MxDefaultRenderOrder.kCADMeshRenderOrder-1),a.setPoint1(d);let x=new THREE.Vector3(d.x+n,d.y+o,d.z);a.setPoint2(x);let M=prompt("请填写图片网络地址","https://cdn.pixabay.com/photo/2022/11/15/12/23/winter-7593872_960_720.jpg");M&&(a.setImagePath(M),r.addMxEntity(a),a.addEvent("onStartGripEidt",()=>(a.visible=!1,a.setNeedUpdateDisplay(),{renderOrder:MxType.MxDefaultRenderOrder.kCADMeshRenderOrder-1})),a.addEvent("onEndGripEidt",()=>{a.visible=!0,a.setNeedUpdateDisplay()}))})};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
/** @module MxDbImage*/
|
|
2
1
|
import McGiWorldDraw from '../McGiWorldDraw';
|
|
3
2
|
import MxDbEntity from '../MxDbEntity';
|
|
3
|
+
import drawMxDbImage from './draw';
|
|
4
4
|
/**
|
|
5
5
|
* MxDbImage 图片对象.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare class MxDbImage extends MxDbEntity {
|
|
8
|
+
static cmd: string;
|
|
9
|
+
static draw: typeof drawMxDbImage;
|
|
8
10
|
private pt1;
|
|
9
11
|
private pt2;
|
|
10
12
|
private imagePath;
|
|
@@ -52,3 +54,4 @@ export default class MxDbImage extends MxDbEntity {
|
|
|
52
54
|
dwgOut(obj: any): object;
|
|
53
55
|
create(): MxDbEntity;
|
|
54
56
|
}
|
|
57
|
+
export default MxDbImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import MxDbEntity from"../MxDbEntity";import MxFun from"../MxFun";import MxType from"../MxType";
|
|
1
|
+
import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import MxDbEntity from"../MxDbEntity";import MxFun from"../MxFun";import MxType from"../MxType";import drawMxDbImage from"./draw";class MxDbImage extends MxDbEntity{constructor(){super(...arguments),this.pt1=new THREE.Vector3,this.pt2=new THREE.Vector3,this.imagePath="",this.isLoadMaterialFromPath=!0,this.material=null,this.angle=0}getTypeName(){return"MxDbImage"}getAngle(){return this.angle}setAngle(t){this.angle=t}worldDraw(t){let e=new THREE.Vector3(this.pt1.x,this.pt2.y),i=new THREE.Vector3(this.pt2.x,this.pt1.y);if(Math.abs(this.angle)>1e-5){let e=new THREE.Vector3(.5*(this.pt1.x-this.pt2.x)+this.pt2.x,.5*(this.pt1.y-this.pt2.y)+this.pt2.y),i=new THREE.Matrix4;i.makeRotationZ(this.angle);let a=(new THREE.Matrix4).makeTranslation(e.x,e.y,e.z).multiply(i).multiply((new THREE.Matrix4).makeTranslation(-e.x,-e.y,-e.z));t.setMatrix(a)}if(1==t.getType()){if(t.drawSelectLine(this.pt1,e),t.drawSelectLine(e,this.pt2),t.drawSelectLine(this.pt2,i),t.drawSelectLine(i,this.pt1),this.material){let e=Math.abs(this.pt1.x-this.pt2.x),i=Math.abs(this.pt1.y-this.pt2.y),a=new THREE.PlaneGeometry(e,i),s=Math.min(this.pt1.x,this.pt2.x),h=Math.min(this.pt1.y,this.pt2.y);for(let t=0;t<a.vertices.length;t++)a.vertices[t].x+=s+.5*e,a.vertices[t].y+=h+.5*i,a.vertices[t].z=0;let r=new THREE.Mesh(a,this.material);r.material.depthTest=!1,t.drawEntity(r)}else if(this.imagePath.length>0&&this.isLoadMaterialFromPath){let e=this,i=t.getMxObject();MxFun.loadImageMaterial(this.imagePath,t=>{this.isLoadMaterialFromPath=!1,t&&(e.setMaterial(t),e.setNeedUpdateDisplay(),i.updateDisplay())})}}else if(this.material){let e=Math.abs(this.pt1.x-this.pt2.x),i=Math.abs(this.pt1.y-this.pt2.y),a=new THREE.PlaneGeometry(e,i),s=Math.min(this.pt1.x,this.pt2.x),h=Math.min(this.pt1.y,this.pt2.y);for(let t=0;t<a.vertices.length;t++)a.vertices[t].x+=s+.5*e,a.vertices[t].y+=h+.5*i,a.vertices[t].z=0;let r=new THREE.Mesh(a,this.material);r.material.depthTest=!1,t.drawEntity(r)}else t.drawLine(this.pt1,e),t.drawLine(e,this.pt2),t.drawLine(this.pt2,i),t.drawLine(i,this.pt1);t.setMatrix(null)}setImagePath(t){this.imagePath=t,this.isLoadMaterialFromPath=!0,this.material=null}getImagePath(){return this.imagePath}setMaterial(t){this.material=t}loadMaterial(t){t&&(this.imagePath=t),this.isLoadMaterialFromPath=!1,this.material=null;let e=this;MxFun.loadImageMaterial(this.imagePath,t=>{this.isLoadMaterialFromPath=!1,e.setMaterial(t)})}setPoint1(t){this.pt1=t}getPoint1(){return this.pt1}setPoint2(t){this.pt2=t}getPoint2(){return this.pt2}getGripPoints(){let t=[];t.push(this.pt1),t.push(this.pt2);let e=new THREE.Vector3(this.pt1.x+.5*(this.pt2.x-this.pt1.x),this.pt1.y+.5*(this.pt2.y-this.pt1.y));return t.push(e),t}moveGripPointsAt(t,e){return 0==t?this.pt1.add(e):1==t?this.pt2.add(e):2==t&&(this.pt1.add(e),this.pt2.add(e)),!0}dwgIn(t){return this.onDwgIn(t),this.pt1.copy(t.pt1),this.pt2.copy(t.pt2),this.imagePath=t.imagePath.substr(0),this.isLoadMaterialFromPath=!0,t.angle&&(this.angle=t.angle),t.material&&(this.material=t.material),!0}dwgOut(t){return this.onDwgOut(t),t.pt1=this.pt1,t.pt2=this.pt2,t.imagePath=this.imagePath,t.angle=this.angle,t.type==MxType.MxCloneType.kDragClone&&(t.material=this.material),t}create(){return new MxDbImage}}MxDbImage.cmd="Mx_DrawImage",MxDbImage.draw=drawMxDbImage,addRegisterMxDbEntity(MxDbImage);export default MxDbImage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function drawMxDbLeadComment(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import MxDbLeadComment from".";import McEdGetPointWorldDrawObject from"../McEdGetPointWorldDrawObject";import MrxDbgUiPrPoint from"../MrxDbgUiPrPoint";import MxFun from"../MxFun";export default function drawMxDbLeadComment(){const t=new MrxDbgUiPrPoint;t.setMessage("\n指定第一点:"),t.go(e=>{if(0!=e)return;const o=t.value();let n=new MxDbLeadComment;n.point1=o.clone(),n.textHeight=MxFun.screenCoordLong2Doc(50);let r=prompt("请输入文字批注","批注");if(!r)return;n.text=r,n.textWidth=MxFun.screenCoordLong2Doc(10*r.length),n.fixedSize=!0,n.fixedSize&&(n.textHeight=50,n.textWidth=50*r.length);const i=new McEdGetPointWorldDrawObject;i.setDraw((t,e)=>{n.point2=t,e.drawCustomEntity(n)}),t.setBasePt(o),t.setUseBasePt(!0),t.setUserDraw(i),t.setMessage("\n指定第二点:"),t.go(e=>{if(0!=e)return void console.log(e);const o=t.value();n.point2=o,MxFun.addToCurrentSpace(n)})})};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
/** @module MxDbLeadComment*/
|
|
2
1
|
import McGiWorldDraw from '../McGiWorldDraw';
|
|
3
2
|
import MxDbEntity from '../MxDbEntity';
|
|
3
|
+
import drawMxDbLeadComment from './draw';
|
|
4
4
|
/**
|
|
5
5
|
* MxDbLeadComment 引线文字标注
|
|
6
6
|
* */
|
|
7
|
-
|
|
7
|
+
declare class MxDbLeadComment extends MxDbEntity {
|
|
8
|
+
static cmd: string;
|
|
9
|
+
static draw: typeof drawMxDbLeadComment;
|
|
8
10
|
/** 标注点 */
|
|
9
11
|
point1: THREE.Vector3;
|
|
10
12
|
/** 文字显示位置 */
|
|
@@ -25,3 +27,4 @@ export default class MxDbLeadComment extends MxDbEntity {
|
|
|
25
27
|
dwgOut(obj: any): object;
|
|
26
28
|
protected onViewChange(): boolean;
|
|
27
29
|
}
|
|
30
|
+
export default MxDbLeadComment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import MxDbEntity from"../MxDbEntity";import MxThreeJS from"../MxThreeJS";
|
|
1
|
+
import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import MxDbEntity from"../MxDbEntity";import MxThreeJS from"../MxThreeJS";import drawMxDbLeadComment from"./draw";class MxDbLeadComment extends MxDbEntity{constructor(){super(...arguments),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.text="",this.textHeight=20,this.textWidth=0,this.fixedSize=!1}getTypeName(){return"MxDbLeadComment"}create(){return new MxDbLeadComment}worldDraw(t){if(t.drawLine(this.point1,this.point2),this.text.length>0){const e=new THREE.Vector3;let i=this.textHeight,n=this.textWidth,o=t.getMxObject();this.fixedSize&&(i=o.screenCoordLong2Doc(i),n=o.screenCoordLong2Doc(n));let h=MxThreeJS.clacTextSpriteSize(this.text,i,n);e.x=this.point2.x+.5*h.textwidth,e.y=this.point2.y+.5*h.allTextHeight,t.drawText(this.text,i,0,e,n);const s=new THREE.Vector3;s.x=this.point2.x+h.textwidth,s.y=this.point2.y,t.drawLine(s,this.point2)}}getGripPoints(){let t=[];return t.push(this.point1),t.push(this.point2),t}moveGripPointsAt(t,e){return 0==t?this.point1.add(e):1==t&&this.point2.add(e),!0}dwgIn(t){return this.onDwgIn(t),this.point1.copy(t.point1),this.point2.copy(t.point2),this.text=t.text.substr(0),this.textHeight=t.textHeight,t.textWidth&&(this.textWidth=t.textWidth),this.fixedSize=t.fixedSize,!0}dwgOut(t){return this.onDwgOut(t),t.point1=this.point1,t.point2=this.point2,t.textHeight=this.textHeight,t.text=this.text,t.textWidth=this.textWidth,t.fixedSize=this.fixedSize,t}onViewChange(){return!!this.fixedSize&&(this.setNeedUpdateDisplay(!1),!0)}}MxDbLeadComment.cmd="Mx_Comment",MxDbLeadComment.draw=drawMxDbLeadComment,addRegisterMxDbEntity(MxDbLeadComment);export default MxDbLeadComment;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function drawMxDbLeadTag(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,n,r,i){return new(r||(r=Promise))(function(e,o){function a(t){try{c(i.next(t))}catch(t){o(t)}}function u(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(t){t(n)})).then(a,u)}c((i=i.apply(t,n||[])).next())})};import MxDbLeadTag from".";import MrxDbgUiPrPoint from"../MrxDbgUiPrPoint";import MxFun from"../MxFun";export default function drawMxDbLeadTag(){return __awaiter(this,void 0,void 0,function*(){let t=yield(new MrxDbgUiPrPoint).go();if(!t)return;let n=prompt("请输入文字批注","批注");if(!n)return;const r=new MxDbLeadTag;r.point=t,r.text=n,MxFun.addToCurrentSpace(r)})};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
/** @module MxDbLeadTag*/
|
|
2
1
|
import McGiWorldDraw from '../McGiWorldDraw';
|
|
3
2
|
import MxDbEntity from '../MxDbEntity';
|
|
3
|
+
import drawMxDbLeadTag from './draw';
|
|
4
4
|
/**
|
|
5
5
|
* MxDbLeadTag 引出标注
|
|
6
6
|
* */
|
|
7
|
-
|
|
7
|
+
declare class MxDbLeadTag extends MxDbEntity {
|
|
8
|
+
static cmd: string;
|
|
9
|
+
static draw: typeof drawMxDbLeadTag;
|
|
8
10
|
point: import("three").Vector3;
|
|
9
11
|
leadLen: number;
|
|
10
12
|
text: string;
|
|
@@ -18,3 +20,4 @@ export default class MxDbLeadTag extends MxDbEntity {
|
|
|
18
20
|
dwgIn(obj: any): boolean;
|
|
19
21
|
dwgOut(obj: any): any;
|
|
20
22
|
}
|
|
23
|
+
export default MxDbLeadTag;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import MxDbEntity from"../MxDbEntity";import MxThreeJS from"../MxThreeJS";
|
|
1
|
+
import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import MxDbEntity from"../MxDbEntity";import MxThreeJS from"../MxThreeJS";import drawMxDbLeadTag from"./draw";class MxDbLeadTag extends MxDbEntity{constructor(){super(...arguments),this.point=new THREE.Vector3,this.leadLen=88,this.text="",this.textHeight=24}getTypeName(){return"MxDbLeadTag"}createDots(e,t){const{x:n,y:o,z:r}=e,i=new THREE.Shape;i.arc(n,o,t.screenCoordLong2Doc(6),0,2*Math.PI,!0);const s=new THREE.Path;s.arc(n,o,t.screenCoordLong2Doc(3),0,2*Math.PI,!0),i.holes.push(s);const a=new THREE.ShapeGeometry(i),d=new THREE.MeshPhongMaterial({color:"#ff0000",transparent:!0}),x=new THREE.Shape;x.arc(n,o,t.screenCoordLong2Doc(3),0,2*Math.PI,!0);const c=new THREE.ShapeGeometry(x),E=new THREE.MeshPhongMaterial({color:"#e2da8f",transparent:!0}),h=new THREE.Mesh(a,d),g=new THREE.Mesh(c,E);return h.add(g),h}worldDraw(e){let t=e.getMxObject();const n=this.createDots(this.point,t);if(e.drawEntity(n),n.geometry.computeBoundingBox(),e.drawSelectLine(n.geometry.boundingBox.max,n.geometry.boundingBox.min),2===e.getType())return;let o=e.getMxObject().screenCoordLong2Doc(this.leadLen),r=new THREE.Vector3(this.point.x+2*o,this.point.y+o,0);const i=r.x-o,s=new THREE.Vector3(i,r.y,r.z);e.setLineWidth(4),e.setColor("#ffe605"),e.drawLines([this.point,s,r]);const a=e.getMxObject().screenCoordLong2Doc(this.textHeight),d=r.clone().setX(r.x);e.setColor(16744448);const x=MxThreeJS.creatTextSprite(this.text,d,a,0,e.getColor());if(x){const t=new THREE.Box3,n=new THREE.Vector3;t.expandByObject(x),t.getSize(n),x.position.setX(x.position.x+n.x/2);const o=e.getMxObject().screenCoordLong2Doc(5),r=t.min.clone().setX(t.min.x+n.x/2).setY(t.min.y-o),i=t.max.clone().setX(t.max.x+n.x/2).setY(t.min.y+o);i.setY(t.max.y+o);const s=new THREE.Vector3(r.x,i.y),a=new THREE.Vector3(i.x,r.y);e.setColor("#ffffff"),e.setLineWidth(0),e.drawLine(r,s),e.drawLine(i,a),e.drawLine(r,a),e.drawLine(s,i);const d=o/2,c=[],E=[];c.push(new THREE.Vector3(s.x+d,s.y-o,s.z),new THREE.Vector3(s.x+d,s.y-d,s.z),new THREE.Vector3(s.x+o,s.y-d,s.z)),E.push(new THREE.Vector3(a.x-d,a.y+o,a.z),new THREE.Vector3(a.x-d,a.y+d,a.z),new THREE.Vector3(a.x-o,a.y+d,a.z)),e.drawLines(c),e.drawLines(E),e.setOpacity(.5),e.setColor("#663244"),e.setRenderOrder(-100),e.drawSolid([r,s,i,a]),e.setRenderOrder(100),e.drawEntity(x)}}getGripPoints(){return[this.point]}onViewChange(){return this.setNeedUpdateDisplay(),!0}moveGripPointsAt(e,t){return 0===e&&this.point.add(t),!0}dwgIn(e){return this.onDwgIn(e),this.dwgInHelp(e,["point","text","textHeight","leadLen"]),!0}dwgOut(e){return this.onDwgOut(e),this.dwgOutHelp(e,["point","text","textHeight","leadLen"]),e}}MxDbLeadTag.cmd="Mx_LeadTag",MxDbLeadTag.draw=drawMxDbLeadTag,addRegisterMxDbEntity(MxDbLeadTag);export default MxDbLeadTag;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,n,e,i){return new(e||(e=Promise))(function(r,o){function a(t){try{s(i.next(t))}catch(t){o(t)}}function u(t){try{s(i.throw(t))}catch(t){o(t)}}function s(t){var n;t.done?r(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(a,u)}s((i=i.apply(t,n||[])).next())})};import MxDbLine from"./index";import MrxDbgUiPrPoint from"../MrxDbgUiPrPoint";import MxFun from"../MxFun";export default function drawMxDbLine(){return __awaiter(this,void 0,void 0,function*(){const t=new MrxDbgUiPrPoint;t.setMessage("\n指定第一点:");let n=yield t.go();if(null==n)return;t.setBasePt(n.clone()),t.setUseBasePt(!0),t.setMessage("\n指定第二点:");let e=yield t.go();if(null==e)return;let i=new MxDbLine;i.pt1=n,i.pt2=e,MxFun.addToCurrentSpace(i)})};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
/** @module MxDbLine*/
|
|
2
1
|
import McGiWorldDraw from '../McGiWorldDraw';
|
|
3
2
|
import MxDbEntity from '../MxDbEntity';
|
|
3
|
+
import draw from './draw';
|
|
4
4
|
/**
|
|
5
5
|
* MxDbLine 直线对象.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare class MxDbLine extends MxDbEntity {
|
|
8
|
+
static cmd: string;
|
|
9
|
+
static draw: typeof draw;
|
|
8
10
|
/** 直线的开始点 */
|
|
9
11
|
pt1: THREE.Vector3;
|
|
10
12
|
/** 直线的结束点 */
|
|
@@ -29,3 +31,4 @@ export default class MxDbLine extends MxDbEntity {
|
|
|
29
31
|
*/
|
|
30
32
|
getGetLength(): number;
|
|
31
33
|
}
|
|
34
|
+
export default MxDbLine;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import MxDbEntity from"../MxDbEntity";
|
|
1
|
+
import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import MxDbEntity from"../MxDbEntity";import draw from"./draw";class MxDbLine extends MxDbEntity{constructor(){super(...arguments),this.pt1=new THREE.Vector3,this.pt2=new THREE.Vector3}getTypeName(){return"MxDbLine"}worldDraw(t){t.drawLine(this.pt1,this.pt2)}setPoint1(t){this.pt1=t}getPoint1(){return this.pt1}setPoint2(t){this.pt2=t}getPoint2(){return this.pt2}getGripPoints(){let t=[];t.push(this.pt1),t.push(this.pt2);let i=new THREE.Vector3(this.pt1.x+.5*(this.pt2.x-this.pt1.x),this.pt1.y+.5*(this.pt2.y-this.pt1.y),0);return t.push(i),t}moveGripPointsAt(t,i){return 0==t?this.pt1.add(i):1==t?this.pt2.add(i):2==t&&(this.pt1.add(i),this.pt2.add(i)),!0}dwgIn(t){return this.onDwgIn(t),this.pt1.copy(t.pt1),this.pt2.copy(t.pt2),!0}dwgOut(t){return this.onDwgOut(t),t.pt1=this.pt1,t.pt2=this.pt2,t}create(){return new MxDbLine}getGeomExtents(){return new THREE.Box3(this.pt1,this.pt2)}getGetLength(){return this.pt1.distanceTo(this.pt2)}}MxDbLine.cmd="Mx_Line",MxDbLine.draw=draw,addRegisterMxDbEntity(MxDbLine);export default MxDbLine;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import McGiWorldDraw from "../McGiWorldDraw";
|
|
2
2
|
import MxDbShape from "../MxDbShape";
|
|
3
3
|
/** 线形状 */
|
|
4
|
-
|
|
4
|
+
declare class MxDbLineShape extends MxDbShape {
|
|
5
5
|
points: THREE.Vector3[];
|
|
6
6
|
setPoints(points: THREE.Vector3[]): this;
|
|
7
7
|
addPoint(point: THREE.Vector3): this;
|
|
@@ -19,3 +19,4 @@ export default class MxDbLineShape extends MxDbShape {
|
|
|
19
19
|
*/
|
|
20
20
|
getGetLength(): number;
|
|
21
21
|
}
|
|
22
|
+
export default MxDbLineShape;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import MxDbShape from"../MxDbShape";
|
|
1
|
+
import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import MxDbShape from"../MxDbShape";class MxDbLineShape extends MxDbShape{constructor(){super(),this.points=[],this._propertyDbKeys=[...this._propertyDbKeys,"points"]}setPoints(t){return this.points=t,this}addPoint(t){return this.points.push(t),this}removePoint(t){return this.points.splice(t,1),this}getTypeName(){return"MxDbLineShape"}worldDraw(t){this._draw(t,this.points),this._drawStoreLine(t,this.points)}getGripPoints(){return this.points}moveGripPointsAt(t,e){return this.points[t].add(e),!0}getGeomExtents(){return(new THREE.Box3).setFromPoints(this.points)}getGetLength(){let t=0;for(let e=0;e++;e<this.points.length)this.points[e+1]&&(t+=this.points[e].distanceTo(this.points[e+1]));return t}}addRegisterMxDbEntity(MxDbLineShape);export default MxDbLineShape;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function drawMxDbPolyline(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import MxDbPolyline from".";import McEdGetPointWorldDrawObject from"../McEdGetPointWorldDrawObject";import MrxDbgUiPrPoint from"../MrxDbgUiPrPoint";import MxFun from"../MxFun";export default function drawMxDbPolyline(){const e=new MrxDbgUiPrPoint;e.setMessage("\n指定第一点:");let t,r=new MxDbPolyline;e.go(o=>{if(0!=o)return;let n=e.value();t||(t=n.clone());let s=n;const i=new McEdGetPointWorldDrawObject;i.setDraw((e,t)=>{t.setColor(16711680),t.drawLine(s,e),t.drawCustomEntity(r)}),e.setUserDraw(i),e.setMessage("\n指定下一点:");let d=0;r.addVertexAt(n),e.goWhile(t=>{if(0==t)s=e.value(),r.addVertexAt(s),++d>=2?(e.setMessage("\n指定下一点:"),e.setKeyWords("[闭合(C)/放弃(U)]")):d>0?(e.setMessage("\n指定下一点:"),e.setKeyWords("[放弃(U)]")):(e.setMessage("\n指定第一点:"),e.setKeyWords(""));else if(1==t){if(e.isKeyWordPicked("C"))return{exit:!0};e.isKeyWordPicked("U")&&console.log("Mx_Line undo....")}},()=>{MxFun.getCurrentDraw().addMxEntity(r)})})};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
/** @module MxDbPolyline*/
|
|
2
1
|
import McGiWorldDraw from '../McGiWorldDraw';
|
|
3
2
|
import MxDbEntity from '../MxDbEntity';
|
|
3
|
+
import drawMxDbPolyline from './draw';
|
|
4
4
|
/**
|
|
5
5
|
* MxDbPolyline 多义线对象(多个点构成的线段)
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare class MxDbPolyline extends MxDbEntity {
|
|
8
|
+
static cmd: string;
|
|
9
|
+
static draw: typeof drawMxDbPolyline;
|
|
8
10
|
/** 顶点位置集合 */
|
|
9
11
|
points: THREE.Vector3[];
|
|
10
12
|
getTypeName(): string;
|
|
@@ -25,3 +27,4 @@ export default class MxDbPolyline extends MxDbEntity {
|
|
|
25
27
|
* */
|
|
26
28
|
setPointAt(index: number, pt: THREE.Vector3): boolean;
|
|
27
29
|
}
|
|
30
|
+
export default MxDbPolyline;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import MxDbEntity from"../MxDbEntity";
|
|
1
|
+
import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import MxDbEntity from"../MxDbEntity";import drawMxDbPolyline from"./draw";class MxDbPolyline extends MxDbEntity{constructor(){super(...arguments),this.points=[]}getTypeName(){return"MxDbPolyline"}worldDraw(t){this.points.length<2||t.drawLines(this.points)}getGripPoints(){return this.points}moveGripPointsAt(t,i){return!(t>=this.points.length)&&(this.points[t].add(i),!0)}create(){return new MxDbPolyline}dwgIn(t){this.onDwgIn(t);let i=t.points;return this.points=[],i.forEach(t=>{this.points.push(new THREE.Vector3(t.x,t.y,t.z))}),!0}dwgOut(t){return this.onDwgOut(t),t.points=this.points,t}addVertexAt(t){this.points.push(t)}numVerts(){return this.points.length}getPointAt(t){return t<this.points.length?this.points[t]:null}setPointAt(t,i){return t<this.points.length&&(this.points[t]=i,!0)}}MxDbPolyline.cmd="Mx_Lines",MxDbPolyline.draw=drawMxDbPolyline,addRegisterMxDbEntity(MxDbPolyline);export default MxDbPolyline;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function drawMxDbRect(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,c)}s((r=r.apply(t,e||[])).next())})};import MxDbRect from".";import McEdGetPointWorldDrawObject from"../McEdGetPointWorldDrawObject";import MrxDbgUiPrPoint from"../MrxDbgUiPrPoint";import MxFun from"../MxFun";export default function drawMxDbRect(){return __awaiter(this,void 0,void 0,function*(){const t=new MrxDbgUiPrPoint;t.setMessage("\n指定第一点:");let e=yield t.go();if(!e)return;let n=new MxDbRect;n.pt1=e;const r=new McEdGetPointWorldDrawObject;r.setDraw(t=>{n.pt2=t,r.drawCustomEntity(n)}),t.setBasePt(e),t.setUseBasePt(!0),t.setUserDraw(r),t.setMessage("\n指定第二点:"),(yield t.go())&&(n.pt2=t.value(),MxFun.getCurrentDraw().addMxEntity(n))})};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import MxDbEntity from '../MxDbEntity';
|
|
2
2
|
import MxFilters from '../MxFilters';
|
|
3
3
|
import McGiWorldDraw from '../McGiWorldDraw';
|
|
4
|
+
import drawMxDbRect from './draw';
|
|
4
5
|
/**
|
|
5
6
|
* MxRectEntity 矩形对象.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
declare class MxDbRect extends MxDbEntity {
|
|
9
|
+
static cmd: string;
|
|
10
|
+
static draw: typeof drawMxDbRect;
|
|
8
11
|
private cornerRadius;
|
|
9
12
|
/**
|
|
10
13
|
* pt1: 构成矩形的第一个点
|
|
@@ -56,3 +59,4 @@ export default class MxDbRect extends MxDbEntity {
|
|
|
56
59
|
/** 获取填充的背景图片路径 */
|
|
57
60
|
getFillImagePath(): string | undefined;
|
|
58
61
|
}
|
|
62
|
+
export default MxDbRect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import MxDbEntity from"../MxDbEntity";import{computeRectPoints,getToGenerateRoundedCorners,repairGeometryFaceVertexUvs}from"../../tools/three/index";import MxFun from"../MxFun";import McGiWorldDrawType from"../McGiWorldDrawType";
|
|
1
|
+
import MxDbEntity from"../MxDbEntity";import{computeRectPoints,getToGenerateRoundedCorners,repairGeometryFaceVertexUvs}from"../../tools/three/index";import MxFun from"../MxFun";import McGiWorldDrawType from"../McGiWorldDrawType";import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import drawMxDbRect from"./draw";class MxDbRect extends MxDbEntity{constructor(){super(...arguments),this.cornerRadius=[],this.pt1=new THREE.Vector3,this.pt2=new THREE.Vector3,this.isSolidColorFill=!1,this.isLoadMaterialFromPath=!0,this.material=null}worldDraw(t){let e=computeRectPoints(this.pt1,this.pt2);if(this.cornerRadius.length>0&&(e=getToGenerateRoundedCorners(e,this.cornerRadius)),t.getType()!=McGiWorldDrawType.kWorldDraw)return e.push(e[0]),void t.drawLines(e);const i={transparent:!0,depthTest:!1,opacity:this.opacity,visible:this.visible};if(this.isSolidColorFill){let r;e=e.map(({x:t,y:e})=>new THREE.Vector2(t,e)),r=new THREE.ShapeGeometry(new THREE.Shape(e));let a=new THREE.MeshBasicMaterial(Object.assign({color:this.filter?this.filter._getFilterColor(this.color,this.opacity):new THREE.Color(this.color)},i)),s=new THREE.Mesh(r,a);t.drawEntity(s)}else if(this.fillImageSrc){if(this.material){e=e.map(({x:t,y:e})=>new THREE.Vector2(t,e));let r=this.material,a=new THREE.ShapeGeometry(new THREE.Shape(e));if(a=repairGeometryFaceVertexUvs(a),this.filter){const t=r.map;this.fillImageParam&&(this.fillImageParam.center&&(t.center=this.fillImageParam.center),this.fillImageParam.offset&&(t.offset=this.fillImageParam.offset),this.fillImageParam.repeat&&(t.repeat=this.fillImageParam.repeat),this.fillImageParam.rotation&&(t.rotation=this.fillImageParam.rotation));const e=this.filter._getFilterShaderData(t);r=new THREE.ShaderMaterial(Object.assign(Object.assign({},e),i))}r.depthTest=!1,r.transparent=!0,r.opacity=this.opacity,r.visible=this.visible;let s=new THREE.Mesh(a,r);t.drawEntity(s)}else if(this.fillImageSrc.length>0&&this.isLoadMaterialFromPath){let t=this;MxFun.loadImageMaterial(this.fillImageSrc,e=>{this.isLoadMaterialFromPath=!1,e&&(t.material=e,t.setNeedUpdateDisplay(),MxFun.updateDisplay())})}}else{let r=(new THREE.BufferGeometry).setFromPoints(e),a=new THREE.LineBasicMaterial(Object.assign({color:this.getColor()},i)),s=new THREE.LineLoop(r,a);t.drawEntity(s)}}getGripPoints(){let t=[];t.push(this.pt1);const e=new THREE.Line3(this.pt1,this.pt2);let i=new THREE.Vector3;return e.getCenter(i),t.push(i),t.push(this.pt2),t}moveGripPointsAt(t,e){return 0==t?this.pt1.add(e):1==t?(this.pt1.add(e),this.pt2.add(e)):2==t&&this.pt2.add(e),!0}dwgIn(t){return this.onDwgIn(t),this.pt1.copy(t.pt1),this.pt2.copy(t.pt2),this.isSolidColorFill=t.isSolidColorFill,this.fillImageSrc=t.fillImageSrc,this.fillImageParam=t.fillImageParam,this.cornerRadius=t.cornerRadius,this.filter=t.filter,this.isLoadMaterialFromPath=!0,this.material=null,!0}dwgOut(t){return this.onDwgOut(t),t.pt1=this.pt1,t.pt2=this.pt2,t.isSolidColorFill=this.isSolidColorFill,t.fillImageSrc=this.fillImageSrc,t.fillImageParam=this.fillImageParam,t.cornerRadius=this.cornerRadius,t.filter=this.filter,t}create(){return new MxDbRect}transformBy(t){this.pt1.applyMatrix4(t),this.pt2.applyMatrix4(t)}setRadius(t,e=!0){t instanceof Array?this.cornerRadius=t.map(t=>e?MxFun.screenCoordLong2Doc(t):t):this.cornerRadius=t>0?e?[MxFun.screenCoordLong2Doc(t),MxFun.screenCoordLong2Doc(t),MxFun.screenCoordLong2Doc(t),MxFun.screenCoordLong2Doc(t)]:[t,t,t,t]:[]}getTypeName(){return"MxDbRect"}getFilter(){return this.filter}setFilter(t){this.filter=t,this.isLoadMaterialFromPath=!0,this.material=null}setFillImagePath(t){this.fillImageSrc=t,this.isLoadMaterialFromPath=!0,this.material=null,this.fillImageSrc&&(this.isSolidColorFill=!1)}getFillImagePath(){return this.fillImageSrc}}MxDbRect.cmd="Mx_DrawRect",MxDbRect.draw=drawMxDbRect,addRegisterMxDbEntity(MxDbRect);export default MxDbRect;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function drawMxDbRectBoxLeadComment(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import MxDbRectBoxLeadComment from".";import McEdGetPointWorldDrawObject from"../McEdGetPointWorldDrawObject";import MrxDbgUiPrBaseReturn from"../MrxDbgUiPrBaseReturn";import MrxDbgUiPrPoint from"../MrxDbgUiPrPoint";import MxFun from"../MxFun";export default function drawMxDbRectBoxLeadComment(){const t=new MrxDbgUiPrPoint,e=MxFun.getCurrentDraw(),r=new McEdGetPointWorldDrawObject,o=new MxDbRectBoxLeadComment;o.setLineWidth(3),o.setLineWidthByPixels(!0),t.setMessage("\n云线框起始点:"),t.go(n=>{o.radius=MxFun.screenCoordLong2Doc(8),n==MrxDbgUiPrBaseReturn.kOk&&(o.point1=t.value(),r.setDraw(t=>{o.point2=t,r.drawCustomEntity(o)}),t.setUserDraw(r),t.setMessage("\n云线框结束点:"),t.go(n=>{if(n!=MrxDbgUiPrBaseReturn.kOk)return;o.point2=t.value(),r.setDraw(t=>{o.point3=t,r.drawCustomEntity(o)});let i=prompt("请输入文字批注","批注");i||(i="默认批注文字"),o.text=i,o.textWidth=MxFun.screenCoordLong2Doc(10*i.length),o.textHeight=MxFun.screenCoordLong2Doc(5*i.length),o.fixedSize=!0,o.fixedSize&&(o.textHeight=20,o.textWidth=20*i.length),t.setMessage("\n审图标注点:"),t.go(r=>{r==MrxDbgUiPrBaseReturn.kOk&&(o.point3=t.value(),e.addMxEntity(o))})}))})};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import McGiWorldDraw from '../McGiWorldDraw';
|
|
2
2
|
import MxDbEntity from '../MxDbEntity';
|
|
3
|
+
import drawMxDbRectBoxLeadComment from './draw';
|
|
3
4
|
/**
|
|
4
5
|
* MxDbRectBoxLeadComment 引线审图标注
|
|
5
6
|
* */
|
|
6
|
-
|
|
7
|
+
declare class MxDbRectBoxLeadComment extends MxDbEntity {
|
|
8
|
+
static cmd: string;
|
|
9
|
+
static draw: typeof drawMxDbRectBoxLeadComment;
|
|
7
10
|
/** 云线矩形的对角点1 */
|
|
8
11
|
point1: THREE.Vector3;
|
|
9
12
|
/** 云线矩形的对角点2 */
|
|
@@ -29,3 +32,4 @@ export default class MxDbRectBoxLeadComment extends MxDbEntity {
|
|
|
29
32
|
dwgOut(obj: any): object;
|
|
30
33
|
protected onViewChange(): boolean;
|
|
31
34
|
}
|
|
35
|
+
export default MxDbRectBoxLeadComment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import MxDbLeadComment from"../MxDbLeadComment";import MxDbCloudLine from"../MxDbCloudLine";import MxDbEntity from"../MxDbEntity";import MxType from"../MxType";
|
|
1
|
+
import MxDbLeadComment from"../MxDbLeadComment";import MxDbCloudLine from"../MxDbCloudLine";import MxDbEntity from"../MxDbEntity";import MxType from"../MxType";import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import drawMxDbRectBoxLeadComment from"./draw";class MxDbRectBoxLeadComment extends MxDbEntity{constructor(){super(...arguments),this.point1=new THREE.Vector3,this.point2=new THREE.Vector3,this.point3=new THREE.Vector3,this.text="",this.textHeight=20,this.radius=16,this.textWidth=0,this.fixedSize=!1}getTypeName(){return"MxDbRectBoxLeadComment"}create(){return new MxDbRectBoxLeadComment}getCloudLine(){let t=new MxDbCloudLine;t.setRadius(this.radius);let e=this.point1.clone(),i=this.point2.clone();if(e.x>i.x){let t=e.x;e.x=i.x,i.x=t}if(e.y>i.y){let t=e.y;e.y=i.y,i.y=t}let o=new THREE.Vector3(e.x,i.y,e.z);o=t.addLine(e,o),i=new THREE.Vector3(i.x,o.y,i.z),i=t.addLine(o,i);let n=new THREE.Vector3(i.x,e.y,e.z);n=t.addLine(i,n);let d=e=t.addLine(n,e),s=e.distanceTo(this.point3);return s>o.distanceTo(this.point3)&&(d=o,s=o.distanceTo(this.point3)),s>i.distanceTo(this.point3)&&(d=i,s=i.distanceTo(this.point3)),s>n.distanceTo(this.point3)&&(d=n,s=n.distanceTo(this.point3)),{cloudLine:t,pt1:e,pt2:o,pt3:i,pt4:n,leadPt:d}}worldDraw(t){let e=this.getCloudLine();if(e.cloudLine.worldDraw(t),this.text.length>0){let i=e.leadPt,o=new MxDbLeadComment;o.point1=i,o.point2=this.point3,o.text=this.text,o.textHeight=this.textHeight,o.textWidth=this.textWidth,o.fixedSize=this.fixedSize,o.worldDraw(t)}}getGripPoints(){let t=[];return t.push(this.point1),t.push(this.point2),t.push(this.point3),t}moveGripPointsAt(t,e){return 0==t?this.point1.add(e):1==t?this.point2.add(e):2==t&&this.point3.add(e),!0}dwgIn(t){return this.onDwgIn(t),this.point1.copy(t.point1),this.point2.copy(t.point2),this.point3.copy(t.point3),this.text=t.text.substr(0),this.textHeight=t.textHeight,this.radius=t.radius,t.textWidth&&(this.textWidth=t.textWidth),this.fixedSize=t.fixedSize,!0}dwgOut(t){if(this.onDwgOut(t),t.point1=this.point1,t.point2=this.point2,t.point3=this.point3,t.textHeight=this.textHeight,t.text=this.text,t.radius=this.radius,t.textWidth=this.textWidth,t.fixedSize=this.fixedSize,t.type===MxType.MxCloneType.kSaveDwgClone){let e=this.getCloudLine(),i=e.cloudLine.reCalculateDrawGeometryPoint();t.cachePoint=i||[],t.leadPt=e.leadPt}return t}onViewChange(){return!!this.fixedSize&&(this.setNeedUpdateDisplay(!1),!0)}}MxDbRectBoxLeadComment.cmd="Mx_CheckDraw",MxDbRectBoxLeadComment.draw=drawMxDbRectBoxLeadComment,addRegisterMxDbEntity(MxDbRectBoxLeadComment);export default MxDbRectBoxLeadComment;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function drawMxDbRegularPolygon(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import MxDbRegularPolygon from".";import McEdGetPointWorldDrawObject from"../McEdGetPointWorldDrawObject";import MrxDbgUiPrPoint from"../MrxDbgUiPrPoint";import MxFun from"../MxFun";export default function drawMxDbRegularPolygon(){const r=new MrxDbgUiPrPoint,t=MxFun.getCurrentDraw(),e=new McEdGetPointWorldDrawObject,o=new MxDbRegularPolygon;r.setMessage("\n点击开始绘制多边形:"),r.go(()=>{let n=prompt("请输入多边形的边数","8");n&&(o.sidesNumber=Number(n),o.centerPoint=r.value(),r.setUserDraw(e),e.setDraw(r=>{o.otherPoint=r,e.drawCustomEntity(o)}),r.setMessage("\n再次点击结束绘制多边形:"),r.go(()=>{t.addMxEntity(o)}))})};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import McGiWorldDraw from '../McGiWorldDraw';
|
|
2
2
|
import MxDbShape from '../MxDbShape';
|
|
3
|
-
|
|
3
|
+
import drawMxDbRegularPolygon from './draw';
|
|
4
|
+
declare class MxDbRegularPolygon extends MxDbShape {
|
|
5
|
+
static cmd: string;
|
|
6
|
+
static draw: typeof drawMxDbRegularPolygon;
|
|
4
7
|
/** 正多边形的中心点位置 */
|
|
5
8
|
centerPoint: import("three").Vector3;
|
|
6
9
|
/** 正多边形两条边之间的交点位置 */
|
|
@@ -16,3 +19,4 @@ export default class MxDbRegularPolygon extends MxDbShape {
|
|
|
16
19
|
getGripPoints(): THREE.Vector3[];
|
|
17
20
|
moveGripPointsAt(index: number, offset: THREE.Vector3): boolean;
|
|
18
21
|
}
|
|
22
|
+
export default MxDbRegularPolygon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{computeRegularPolygonVertices}from"../../tools/three/index";import MxDbShape from"../MxDbShape";
|
|
1
|
+
import{computeRegularPolygonVertices}from"../../tools/three/index";import MxDbShape from"../MxDbShape";import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import drawMxDbRegularPolygon from"./draw";class MxDbRegularPolygon extends MxDbShape{constructor(){super(),this.centerPoint=new THREE.Vector3,this.otherPoint=new THREE.Vector3,this.sidesNumber=5,this._propertyDbKeys=[...this._propertyDbKeys,"centerPoint","otherPoint","sidesNumber"]}getTypeName(){return"MxDbRegularPolygon"}worldDraw(t){const e=computeRegularPolygonVertices(this.centerPoint,this.otherPoint,this.sidesNumber);this.closed=!1,e.push(e[0]),this._draw(t,e),this._drawStoreLine(t,e)}getGripPoints(){return[this.centerPoint,this.otherPoint]}moveGripPointsAt(t,e){return 0===t?(this.centerPoint.add(e),this.otherPoint.add(e)):1===t&&this.otherPoint.add(e),!0}}MxDbRegularPolygon.cmd="Mx_RegularPolygon",MxDbRegularPolygon.draw=drawMxDbRegularPolygon,addRegisterMxDbEntity(MxDbRegularPolygon);export default MxDbRegularPolygon;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import McGiWorldDraw from "../McGiWorldDraw";
|
|
2
2
|
import MxDbShape from "../MxDbShape";
|
|
3
3
|
/** 等边多边形 */
|
|
4
|
-
|
|
4
|
+
declare class MxDbRegularPolygonShape extends MxDbShape {
|
|
5
5
|
center: import("three").Vector3;
|
|
6
6
|
sidesNumber: number;
|
|
7
7
|
radius: number;
|
|
@@ -16,3 +16,4 @@ export default class MxDbRegularPolygonShape extends MxDbShape {
|
|
|
16
16
|
getGripPoints(): THREE.Vector3[];
|
|
17
17
|
moveGripPointsAt(index: number, offset: THREE.Vector3): boolean;
|
|
18
18
|
}
|
|
19
|
+
export default MxDbRegularPolygonShape;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import MxDbShape from"../MxDbShape";
|
|
1
|
+
import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import MxDbShape from"../MxDbShape";class MxDbRegularPolygonShape extends MxDbShape{constructor(){super(),this.center=new THREE.Vector3,this.sidesNumber=6,this.radius=70,this._propertyDbKeys=[...this._propertyDbKeys,"center","sidesNumber","radius"]}getTypeName(){return"MxDbRegularPolygonShape"}worldDraw(e){this._drawPolygonShape(e)}_drawPolygonShape(e){const t=this._getPoints(),r=new THREE.Path;r.moveTo(t[0].x,t[0].y);for(let e=0;e<t.length;e++)r.lineTo(t[e].x,t[e].y);r.closePath();const s=this.createPaths(r),o=this.getShapePoints(s);this._draw(e,o),this._drawStoreLine(e,o)}_getPoints(){const{sidesNumber:e,radius:t}=this,{x:r,y:s}=this.center,o=[];for(let i=0;i<e;i++)o.push({x:t*Math.sin(2*i*Math.PI/e)+r,y:-1*t*Math.cos(2*i*Math.PI/e)+s});return o}getGripPoints(){return[this.center]}moveGripPointsAt(e,t){return 0===e&&this.center.add(t),!0}}addRegisterMxDbEntity(MxDbRegularPolygonShape);export default MxDbRegularPolygonShape;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function drawMxDbRingShape(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{w(r.next(t))}catch(t){i(t)}}function c(t){try{w(r.throw(t))}catch(t){i(t)}}function w(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,c)}w((r=r.apply(t,e||[])).next())})};import{MxDbRingShapeDraw}from".";import McEdGetPointWorldDrawObject from"../McEdGetPointWorldDrawObject";import MrxDbgUiPrPoint from"../MrxDbgUiPrPoint";import MxFun from"../MxFun";export default function drawMxDbRingShape(){const t=new MrxDbgUiPrPoint,e=MxFun.getCurrentDraw(),n=new McEdGetPointWorldDrawObject;t.setUserDraw(n);const r=new McEdGetPointWorldDrawObject,o=new MxDbRingShapeDraw;t.setUserDraw(r),t.setMessage("\n确定圆弧开始点:"),t.go(n=>__awaiter(this,void 0,void 0,function*(){console.log(123),o.center=t.value(),r.setDraw(t=>{r.drawCircle(o.center,o.center.distanceTo(t))}),o.innerPoint=(yield t.go())||new THREE.Vector3,r.setDraw(t=>{o.outerPoint=t,r.drawCustomEntity(o)}),o.outerPoint=(yield t.go())||new THREE.Vector3,e.addMxEntity(o)}))};
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import McGiWorldDraw from "../McGiWorldDraw";
|
|
2
2
|
import MxDbArcShape from "../MxDbArcShape";
|
|
3
|
+
import drawMxDbRingShape from "./draw";
|
|
3
4
|
/** 环形 */
|
|
4
|
-
|
|
5
|
+
declare class MxDbRingShape extends MxDbArcShape {
|
|
6
|
+
static isRegister: boolean;
|
|
7
|
+
static cmd: string;
|
|
8
|
+
static draw: typeof drawMxDbRingShape;
|
|
5
9
|
getTypeName(): string;
|
|
6
10
|
worldDraw(pWorldDraw: McGiWorldDraw): void;
|
|
7
11
|
}
|
|
12
|
+
export declare class MxDbRingShapeDraw extends MxDbRingShape {
|
|
13
|
+
innerPoint: import("three").Vector3;
|
|
14
|
+
outerPoint: import("three").Vector3;
|
|
15
|
+
constructor();
|
|
16
|
+
getGripPoints(): THREE.Vector3[];
|
|
17
|
+
moveGripPointsAt(index: number, offset: THREE.Vector3): boolean;
|
|
18
|
+
worldDraw(pWorldDraw: McGiWorldDraw): void;
|
|
19
|
+
}
|
|
20
|
+
export default MxDbRingShape;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import MxDbArcShape from"../MxDbArcShape";
|
|
1
|
+
import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import MxDbArcShape from"../MxDbArcShape";import drawMxDbRingShape from"./draw";class MxDbRingShape extends MxDbArcShape{getTypeName(){return"MxDbRingShape"}worldDraw(t){const{center:e,startAngle:i,endAngle:r,clockwise:s}=this,{x:n,y:h}=e;this.isClosedToCenter=!1;const o=this.createEllipseCurve(n,h,this.innerRadius,this.innerRadius,i,r,s),a=this.createEllipseCurve(n,h,this.outerRadius,this.outerRadius,i,r,!s),d=this.createPaths([o,a]);let p=this.getShapePoints(d);const c=this.createPaths(o);let u=this.getShapePoints(c);const x=this.createPaths(a);let D=this.getShapePoints(x);this.isFill?(this._draw(t,p),this._drawStoreLine(t,u),this._drawStoreLine(t,D)):(this._draw(t,u),this._drawStoreLine(t,u),this._draw(t,D),this._drawStoreLine(t,D))}}MxDbRingShape.isRegister=!1,MxDbRingShape.cmd="Mx_MxDbRingShape",MxDbRingShape.draw=drawMxDbRingShape;export class MxDbRingShapeDraw extends MxDbRingShape{constructor(){super(),this.innerPoint=new THREE.Vector3,this.outerPoint=new THREE.Vector3,this._propertyDbKeys=[...this._propertyDbKeys,"innerPoint","outerPoint"]}getGripPoints(){return[this.center,this.innerPoint,this.outerPoint]}moveGripPointsAt(t,e){return 0===t&&(this.center.add(e),this.innerPoint.add(e),this.outerPoint.add(e)),1===t&&this.innerPoint.add(e),2===t&&this.outerPoint.add(e),!0}worldDraw(t){this.innerPoint&&(this.innerRadius=this.center.distanceTo(this.innerPoint)),this.outerPoint&&(this.outerRadius=this.center.distanceTo(this.outerPoint)),super.worldDraw(t)}};addRegisterMxDbEntity(MxDbRingShape);export default MxDbRingShape;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function drawMxDbSVG(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{s(r.next(t))}catch(t){o(t)}}function x(t){try{s(r.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,x)}s((r=r.apply(t,e||[])).next())})};import MxDbSVG from".";import MrxDbgUiPrPoint from"../MrxDbgUiPrPoint";import MxDbSVGText from"../MxDbSVGText";import MxFun from"../MxFun";export default function drawMxDbSVG(){return __awaiter(this,void 0,void 0,function*(){const t=new MrxDbgUiPrPoint;t.setMessage("\n指定一点:");let e=yield t.go();if(!e)return;let n=new MxDbSVG,r=prompt("请输入svg图片网络或本地地址","https://img.alicdn.com/imgextra/i2/O1CN01FF1t1g1Q3PDWpSm4b_!!6000000001920-55-tps-508-135.svg");if(!r)return;n.setSvgPath(r),n.setSvgPostion(e),n.svgReverse=!0,n.svgMargin.x=.2,n.setSvgAlignmentRatio(new THREE.Vector2(.5,-1)),n.setRenderOrder(100);n.setSvgSize(new THREE.Vector2(50,0));let i=new MxDbSVGText;i.txt="A1";i.txtPos=new THREE.Vector3(0,-30,0),i.txtHeight=30,n.addText(i),n.fixedSize=!0,n.color=65297,MxFun.addToCurrentSpace(n)})};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
/** @module MxDbSVG*/
|
|
2
1
|
import McGiWorldDraw from '../McGiWorldDraw';
|
|
3
2
|
import MxDbEntity from '../MxDbEntity';
|
|
4
3
|
import MxDbSVGText from '../MxDbSVGText';
|
|
4
|
+
import drawMxDbSVG from './draw';
|
|
5
5
|
/**
|
|
6
6
|
* MxDbSVG 绘制SVG图形.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
declare class MxDbSVG extends MxDbEntity {
|
|
9
|
+
static cmd: string;
|
|
10
|
+
static draw: typeof drawMxDbSVG;
|
|
9
11
|
private svgPos;
|
|
10
12
|
private svg;
|
|
11
13
|
private svgPath;
|
|
@@ -91,3 +93,4 @@ export default class MxDbSVG extends MxDbEntity {
|
|
|
91
93
|
reComputeSVG(): void;
|
|
92
94
|
protected onViewChange(): boolean;
|
|
93
95
|
}
|
|
96
|
+
export default MxDbSVG;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))(function(o,r){function n(t){try{l(s.next(t))}catch(t){r(t)}}function g(t){try{l(s.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,g)}l((s=s.apply(t,e||[])).next())})};import McGiWorldDrawType from"../McGiWorldDrawType";import MxDbEntity from"../MxDbEntity";import MxDbSVGText from"../MxDbSVGText";import MxFun from"../MxFun";import MxThreeJS from"../MxThreeJS";import MxType from"../MxType";export default class MxDbSVG extends MxDbEntity{constructor(){super(...arguments),this.svgPos=new THREE.Vector3,this.svg=null,this.svgPath="",this.svgSize=new THREE.Vector2(50,50),this.svgAlignmentRatio=new THREE.Vector2(0,0),this.svgRotate=0,this.svgReverse=!1,this.svgMirror=!1,this.svgChildColor=[],this.svgMargin=new THREE.Vector2(0,0),this.isSvgDirtyLocation=!1,this.isLoadFromPath=!0,this.aryText=[],this.svgBoxSize=null,this.fixedSize=!1,this.useSvgColor=!1}setSvgChildColor(t){if(this.svgChildColor=t,!this.useSvgColor&&this.svg){let t=new THREE.Color(this.getColor()),e=0,i=this;this.svg.traverse(function(s){s.material&&(e<i.svgChildColor.length?s.material.color=new THREE.Color(i.svgChildColor[e]):s.material.color=t,e++)}),this.setNeedUpdateDisplay(!0)}}getSvgChildColor(){return this.svgChildColor}calcVewSize(t){let e=this.svgSize.x,i=this.svgSize.y;return i<=0&&(i=this.svgBoxSize?this.svgBoxSize.y/this.svgBoxSize.x*e:e),this.fixedSize&&(e=t.screenCoordLong2Doc(e),i=t.screenCoordLong2Doc(i)),[e,i]}calcSvgDrawRect(t){if(!t)return;this.calcSvgPosition(t);let[e,i]=this.calcVewSize(t),s=new THREE.Matrix4;s.makeScale(this.svgMirror?-1:1,this.svgReverse?-1:1,1);let o=new THREE.Matrix4;o.makeRotationZ(this.svgRotate);let r=new THREE.Matrix4,n=new THREE.Vector3(this.svgPos.x-e*this.svgAlignmentRatio.x,this.svgPos.y-i*this.svgAlignmentRatio.y,0);r.makeTranslation(n.x,n.y,n.z),o.multiply(s),o.premultiply(r);let g=new THREE.Vector3(0,0,0),l=new THREE.Vector3(e,0,0),a=new THREE.Vector3(e,i,0),h=new THREE.Vector3(0,i,0);return g.applyMatrix4(o),l.applyMatrix4(o),a.applyMatrix4(o),h.applyMatrix4(o),{pt1:g,pt2:a,pt3:l,pt4:h,cenpt:a.clone().add(g.clone().sub(a).multiplyScalar(.5)),sizew:e,sizeh:i}}worldDraw(t){let e=t.getMxObject(),i=this.calcSvgDrawRect(e),s=i.pt1,o=i.pt2,r=i.pt3,n=i.pt4,g=i.cenpt,l=i.sizew,a=this;if(t.getType()!=McGiWorldDrawType.kSelectDraw&&this.aryText.forEach((i,s)=>{if(i.txt.length>0){let n=new THREE.Vector3(i.txtPos.x,i.txtPos.y,0);this.fixedSize&&(i.txtPos.x>0?n.x=this.svgPos.x+e.screenCoordLong2Doc(i.txtPos.x):n.x=this.svgPos.x-e.screenCoordLong2Doc(i.txtPos.x),i.txtPos.y>0?n.y=this.svgPos.y+e.screenCoordLong2Doc(i.txtPos.y):n.y=this.svgPos.y-e.screenCoordLong2Doc(i.txtPos.y));let h=void 0;i.color&&(h=t.getColor(),t.setColor(i.color));let c=i.txtHeight;a.fixedSize&&(c=e.screenCoordLong2Doc(i.txtHeight)),t.setXData({type:"text",txt:i.txt,index:s});let x=t.drawText(i.txt,c,0,n,void 0,t=>{let e="";return e=i.fontStyle.length>0?`${i.fontStyle} ${t}px Arial`:`normal ${t}px Arial`});if(t.getType()==McGiWorldDrawType.kWorldDraw&&(i._txtObject=x),i.underline&&i._txtObject){const e=new THREE.Box3;e.expandByObject(i._txtObject);let s=new THREE.Vector3(e.min.x,e.min.y+.1*c,0),n=new THREE.Vector3(e.max.x,e.min.y+.1*c,0);var o=new THREE.Geometry;let g=new THREE.LineBasicMaterial({color:t.getColor(),transparent:!0,depthTest:!1});o.vertices.push(s,n);var r=new THREE.Line(o,g);t.drawEntity(r),t.getType()==McGiWorldDrawType.kWorldDraw&&(i._underLine=r)}if(i._txtAspectRatio=-1,h&&t.setColor(h),i.drawConnectingLine){let e=g.clone().sub(n);if(e.length()>c+l){e.normalize();let s=g.clone().sub(e.clone().multiplyScalar(l)),a=n.clone().add(e.clone().multiplyScalar(c));o=new THREE.Geometry;let h=new THREE.LineBasicMaterial({color:t.getColor(),transparent:!0,depthTest:!1});o.vertices.push(s,a);r=new THREE.Line(o,h);t.setXData({type:"line"}),t.drawEntity(r),t.getType()==McGiWorldDrawType.kWorldDraw&&(i._connectingLine=r)}}}}),1==t.getType()){if(this.svg)t.setXData({type:"svg"}),t.drawEntity(this.svg);else if(this.svgPath.length>0&&this.isLoadFromPath){let i=this,s=t.getMxObject();MxThreeJS.loadSVG(this.svgPath,void 0,o=>{if(o){let r=o;if(r.boxSize)i.svgBoxSize=r.boxSize.clone();else{let t=(new THREE.Box3).setFromObject(o);i.svgBoxSize||(i.svgBoxSize=new THREE.Vector3),i.svgBoxSize.x=t.max.x-t.min.x,i.svgBoxSize.y=t.max.y-t.min.y}let[n,g]=i.calcVewSize(e);i.svgBoxSize&&(o.scale.x=n/i.svgBoxSize.x,o.scale.y=g/i.svgBoxSize.y),o.scale.z=o.scale.x,i.svgReverse&&(o.scale.y*=-1),i.svgMirror&&(o.scale.x*=-1),o.rotateZ(i.svgRotate),i.isSvgDirtyLocation=!0;let l=new THREE.Color(t.getColor()),a=0;o.traverse(function(t){t.material&&(t.material=t.material.clone(),t.material.transparent=!0,t.material.depthTest=!1,i.useSvgColor||(a<i.svgChildColor.length?t.material.color=new THREE.Color(i.svgChildColor[a]):t.material.color=l),a++)}),i.svg=o,i.setNeedUpdateDisplay(),s.updateDisplay()}else console.log("mx LoadSVG:"+i.svgPath+" failed");i.isLoadFromPath=!1})}this.fixedSize||(t.drawSelectLine(s,o),t.drawSelectLine(r,n),t.drawSelectLine(s,r),t.drawSelectLine(r,o),t.drawSelectLine(o,n),t.drawSelectLine(n,s))}else t.drawLine(s,r),t.drawLine(r,o),t.drawLine(o,n),t.drawLine(n,s)}setSvgPath(t,e=!1){return __awaiter(this,void 0,void 0,function*(){this.svgPath=t,this.svg=null,this.isLoadFromPath=!0,this.svgBoxSize=null,e&&(yield MxThreeJS.loadSVG(t))})}getSvgPath(){return this.svgPath}setSvgPostion(t){this.svgPos=t.clone(),this.isSvgDirtyLocation=!0}getSvgPostion(){return this.svgPos}setSvgSize(t){this.svgSize=t,this.isSvgDirtyLocation=!0}getSvgSize(){return this.svgSize}setSvgAlignmentRatio(t){this.svgAlignmentRatio=t,this.isSvgDirtyLocation=!0}getSvgAlignmentRatio(){return this.svgAlignmentRatio}getText(t){return t<this.aryText.length?this.aryText[t]:null}addText(t){this.aryText.push(t)}getGripPoints(){let t=[];t.push(this.svgPos);let e=0;for(;e<this.aryText.length;e++){let i=this.aryText[e];if(i.move){let e=new THREE.Vector3(i.txtPos.x,i.txtPos.y,0);if(this.fixedSize){let t=MxFun.getCurrentDraw();i.txtPos.x>0?e.x=this.svgPos.x+t.screenCoordLong2Doc(i.txtPos.x):e.x=this.svgPos.x-t.screenCoordLong2Doc(i.txtPos.x),i.txtPos.y>0?e.y=this.svgPos.y+t.screenCoordLong2Doc(i.txtPos.y):e.y=this.svgPos.y-t.screenCoordLong2Doc(i.txtPos.y)}t.push(e)}}return t}moveGripPointsAt(t,e){if(0==t)this.svgPos.add(e),this.fixedSize||this.aryText.forEach(t=>{t.txtPos.add(e)});else if(t-1>=0&&t-1<this.aryText.length){let i=this.aryText[t-1];if(i.move)if(this.fixedSize){let t=MxFun.getCurrentDraw();i.txtPos.x+=t.docCoordLong2Screen(e.x),i.txtPos.y+=t.docCoordLong2Screen(e.y)}else i.txtPos.add(e)}return this.isSvgDirtyLocation=!0,!0}calcSvgPosition(t){if(!this.svg||!this.isSvgDirtyLocation)return;this.isSvgDirtyLocation=!1;let[e,i]=this.calcVewSize(t);this.svg.position.x=this.svgPos.x-e*this.svgAlignmentRatio.x-this.svgMargin.x*e,this.svg.position.y=this.svgPos.y-i*this.svgAlignmentRatio.y-this.svgMargin.y*i}dwgIn(t){this.onDwgIn(t),this.fixedSize=t.fixedSize,this.fixedSize?this.svg=null:t.type==MxType.MxCloneType.kClone&&t.svg&&(this.svg=t.svg.clone()),this.svgPos.copy(t.svgPos),this.svgPath=t.svgPath.substr(0),this.svgSize.copy(t.svgSize),this.svgAlignmentRatio.copy(t.svgAlignmentRatio),this.isSvgDirtyLocation=!0,this.svg||(this.isLoadFromPath=!0),this.svgBoxSize=null;let e=t.txts;return this.aryText=[],e.forEach(t=>{let e=new MxDbSVGText;e.txt=t.txt,e.txtHeight=t.txtHeight,e.txtPos.copy(t.txtPos),e.move=t.move,e.drawConnectingLine=t.drawConnectingLine,this.aryText.push(e)}),this.svgRotate=t.svgRotate,this.useSvgColor=t.useSvgColor,this.svgReverse=t.svgReverse,this.svgMirror=t.svgMirror,this.svgMargin=t.svgMargin,t.svgChildColor?this.svgChildColor=t.svgChildColor:this.svgChildColor=[],!0}dwgOut(t){this.onDwgOut(t);let e,i=this.getMxObject();return t.type==MxType.MxCloneType.kClone&&(t.svg=this.svg),t.svgPath=this.svgPath,t.svgPos=this.svgPos,t.svgSize=this.svgSize,t.svgAlignmentRatio=this.svgAlignmentRatio,t.txts=[],t.type==MxType.MxCloneType.kSaveDwgClone&&i&&(e=this.calcSvgDrawRect(i)),this.aryText.forEach(e=>{let i={txtPos:e.txtPos,txt:e.txt,txtHeight:e.txtHeight,color:e.color,_txtAspectRatio:e._txtAspectRatio,move:e.move,drawConnectingLine:e.drawConnectingLine};t.type==MxType.MxCloneType.kSaveDwgClone&&(e._connectingLine&&(i.connectingLine=e._connectingLine.geometry.vertice),e._underLine&&(i._underLine=e._underLine.geometry.vertice)),t.txts.push(i)}),t.fixedSize=this.fixedSize,t.svgRotate=this.svgRotate,t.useSvgColor=this.useSvgColor,t.svgReverse=this.svgReverse,t.svgMirror=this.svgMirror,t.svgMargin=this.svgMargin,t.svgChildColor=this.svgChildColor,t.type==MxType.MxCloneType.kSaveDwgClone&&(t.svgRect=e),t}create(){return new MxDbSVG}transformBy(t){this.svgPos.applyMatrix4(t),this.isSvgDirtyLocation=!0,this.fixedSize||this.aryText.forEach(e=>{e.txtPos.applyMatrix4(t)})}getTypeName(){return"MxDbSVG"}setColor(t){if(super.setColor(t),this.svg){let t=new THREE.Color(this.color);this.svg.traverse(function(e){e.material&&(e.material.color=t)})}return this}setSvg(t){this.svg=t,this.isLoadFromPath=!1,this.svgBoxSize=null}calcSvgBoxSize(t){if(!this.svgBoxSize)if(t.boxSize)this.svgBoxSize=t.boxSize.clone();else{let e=(new THREE.Box3).setFromObject(t);this.svgBoxSize||(this.svgBoxSize=new THREE.Vector3),this.svgBoxSize.x=e.max.x-e.min.x,this.svgBoxSize.y=e.max.y-e.min.y}}reComputeSVG(){if(!this.svg)return;let t=this.getMxObject();if(!t)return;this.calcSvgBoxSize(this.svg);let[e,i]=this.calcVewSize(t);this.svgBoxSize&&(this.svg.scale.x=e/this.svgBoxSize.x,this.svg.scale.y=i/this.svgBoxSize.y),this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.svgMirror&&(this.svg.scale.x*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}onViewChange(){if(!this.fixedSize)return!1;let t=this.getMxObject();if(null==t)return!1;if(this.svg){this.calcSvgBoxSize(this.svg);let[e,i]=this.calcVewSize(t);this.svgBoxSize&&(this.svg.scale.x=e/this.svgBoxSize.x,this.svg.scale.y=i/this.svgBoxSize.y),this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.svgMirror&&(this.svg.scale.x*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}let e=this.calcSvgDrawRect(t),i=e.cenpt,s=e.sizew,o=this;return this.aryText.forEach(e=>{if(e._txtObject&&t){let n=t.screenCoordLong2Doc(e.txtHeight);if(n>1e-5){e._txtAspectRatio<=0&&(e._txtAspectRatio=e._txtObject.scale.x/e._txtObject.scale.y),e._txtObject.scale.set(e._txtAspectRatio*n*1.5,1.5*n,1),e.txtPos.x>0?e._txtObject.position.x=o.svgPos.x+t.screenCoordLong2Doc(e.txtPos.x):e._txtObject.position.x=o.svgPos.x-t.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?e._txtObject.position.y=o.svgPos.y+t.screenCoordLong2Doc(e.txtPos.y):e._txtObject.position.y=o.svgPos.y-t.screenCoordLong2Doc(e.txtPos.y);let g=e._txtObject.position;if(e._txtObject.updateMatrix(),e._underLine){const t=new THREE.Box3;let i=e._txtObject.parent;e._txtObject.parent=null,t.expandByObject(e._txtObject),e._txtObject.parent=i;let s=new THREE.Vector3(t.min.x,t.min.y+.1*n,0),o=new THREE.Vector3(t.max.x,t.min.y+.1*n,0);(r=new THREE.Geometry).vertices.push(s,o),e._underLine.geometry=r}if(e._connectingLine){let t=i.clone().sub(g);t.normalize();let o=i.clone().sub(t.clone().multiplyScalar(s)),l=g.clone().add(t.clone().multiplyScalar(n));var r;(r=new THREE.Geometry).vertices.push(o,l),e._connectingLine.geometry=r}}}}),!0}};
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,e,i,s){return new(i||(i=Promise))(function(o,r){function n(t){try{a(s.next(t))}catch(t){r(t)}}function g(t){try{a(s.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,g)}a((s=s.apply(t,e||[])).next())})};import{addRegisterMxDbEntity}from"../../tools/registerMxDbEntity";import McGiWorldDrawType from"../McGiWorldDrawType";import MxDbEntity from"../MxDbEntity";import MxDbSVGText from"../MxDbSVGText";import MxFun from"../MxFun";import MxThreeJS from"../MxThreeJS";import MxType from"../MxType";import drawMxDbSVG from"./draw";class MxDbSVG extends MxDbEntity{constructor(){super(...arguments),this.svgPos=new THREE.Vector3,this.svg=null,this.svgPath="",this.svgSize=new THREE.Vector2(50,50),this.svgAlignmentRatio=new THREE.Vector2(0,0),this.svgRotate=0,this.svgReverse=!1,this.svgMirror=!1,this.svgChildColor=[],this.svgMargin=new THREE.Vector2(0,0),this.isSvgDirtyLocation=!1,this.isLoadFromPath=!0,this.aryText=[],this.svgBoxSize=null,this.fixedSize=!1,this.useSvgColor=!1}setSvgChildColor(t){if(this.svgChildColor=t,!this.useSvgColor&&this.svg){let t=new THREE.Color(this.getColor()),e=0,i=this;this.svg.traverse(function(s){s.material&&(e<i.svgChildColor.length?s.material.color=new THREE.Color(i.svgChildColor[e]):s.material.color=t,e++)}),this.setNeedUpdateDisplay(!0)}}getSvgChildColor(){return this.svgChildColor}calcVewSize(t){let e=this.svgSize.x,i=this.svgSize.y;return i<=0&&(i=this.svgBoxSize?this.svgBoxSize.y/this.svgBoxSize.x*e:e),this.fixedSize&&(e=t.screenCoordLong2Doc(e),i=t.screenCoordLong2Doc(i)),[e,i]}calcSvgDrawRect(t){if(!t)return;this.calcSvgPosition(t);let[e,i]=this.calcVewSize(t),s=new THREE.Matrix4;s.makeScale(this.svgMirror?-1:1,this.svgReverse?-1:1,1);let o=new THREE.Matrix4;o.makeRotationZ(this.svgRotate);let r=new THREE.Matrix4,n=new THREE.Vector3(this.svgPos.x-e*this.svgAlignmentRatio.x,this.svgPos.y-i*this.svgAlignmentRatio.y,0);r.makeTranslation(n.x,n.y,n.z),o.multiply(s),o.premultiply(r);let g=new THREE.Vector3(0,0,0),a=new THREE.Vector3(e,0,0),l=new THREE.Vector3(e,i,0),x=new THREE.Vector3(0,i,0);return g.applyMatrix4(o),a.applyMatrix4(o),l.applyMatrix4(o),x.applyMatrix4(o),{pt1:g,pt2:l,pt3:a,pt4:x,cenpt:l.clone().add(g.clone().sub(l).multiplyScalar(.5)),sizew:e,sizeh:i}}worldDraw(t){let e=t.getMxObject(),i=this.calcSvgDrawRect(e),s=i.pt1,o=i.pt2,r=i.pt3,n=i.pt4,g=i.cenpt,a=i.sizew,l=this;if(t.getType()!=McGiWorldDrawType.kSelectDraw&&this.aryText.forEach((i,s)=>{if(i.txt.length>0){let n=new THREE.Vector3(i.txtPos.x,i.txtPos.y,0);this.fixedSize&&(i.txtPos.x>0?n.x=this.svgPos.x+e.screenCoordLong2Doc(i.txtPos.x):n.x=this.svgPos.x-e.screenCoordLong2Doc(i.txtPos.x),i.txtPos.y>0?n.y=this.svgPos.y+e.screenCoordLong2Doc(i.txtPos.y):n.y=this.svgPos.y-e.screenCoordLong2Doc(i.txtPos.y));let x=void 0;i.color&&(x=t.getColor(),t.setColor(i.color));let h=i.txtHeight;l.fixedSize&&(h=e.screenCoordLong2Doc(i.txtHeight)),t.setXData({type:"text",txt:i.txt,index:s});let c=t.drawText(i.txt,h,0,n,void 0,t=>{let e="";return e=i.fontStyle.length>0?`${i.fontStyle} ${t}px Arial`:`normal ${t}px Arial`});if(t.getType()==McGiWorldDrawType.kWorldDraw&&(i._txtObject=c),i.underline&&i._txtObject){const e=new THREE.Box3;e.expandByObject(i._txtObject);let s=new THREE.Vector3(e.min.x,e.min.y+.1*h,0),n=new THREE.Vector3(e.max.x,e.min.y+.1*h,0);var o=new THREE.Geometry;let g=new THREE.LineBasicMaterial({color:t.getColor(),transparent:!0,depthTest:!1});o.vertices.push(s,n);var r=new THREE.Line(o,g);t.drawEntity(r),t.getType()==McGiWorldDrawType.kWorldDraw&&(i._underLine=r)}if(i._txtAspectRatio=-1,x&&t.setColor(x),i.drawConnectingLine){let e=g.clone().sub(n);if(e.length()>h+a){e.normalize();let s=g.clone().sub(e.clone().multiplyScalar(a)),l=n.clone().add(e.clone().multiplyScalar(h));o=new THREE.Geometry;let x=new THREE.LineBasicMaterial({color:t.getColor(),transparent:!0,depthTest:!1});o.vertices.push(s,l);r=new THREE.Line(o,x);t.setXData({type:"line"}),t.drawEntity(r),t.getType()==McGiWorldDrawType.kWorldDraw&&(i._connectingLine=r)}}}}),1==t.getType()){if(this.svg)t.setXData({type:"svg"}),t.drawEntity(this.svg);else if(this.svgPath.length>0&&this.isLoadFromPath){let i=this,s=t.getMxObject();MxThreeJS.loadSVG(this.svgPath,void 0,o=>{if(o){let r=o;if(r.boxSize)i.svgBoxSize=r.boxSize.clone();else{let t=(new THREE.Box3).setFromObject(o);i.svgBoxSize||(i.svgBoxSize=new THREE.Vector3),i.svgBoxSize.x=t.max.x-t.min.x,i.svgBoxSize.y=t.max.y-t.min.y}let[n,g]=i.calcVewSize(e);i.svgBoxSize&&(o.scale.x=n/i.svgBoxSize.x,o.scale.y=g/i.svgBoxSize.y),o.scale.z=o.scale.x,i.svgReverse&&(o.scale.y*=-1),i.svgMirror&&(o.scale.x*=-1),o.rotateZ(i.svgRotate),i.isSvgDirtyLocation=!0;let a=new THREE.Color(t.getColor()),l=0;o.traverse(function(t){t.material&&(t.material=t.material.clone(),t.material.transparent=!0,t.material.depthTest=!1,i.useSvgColor||(l<i.svgChildColor.length?t.material.color=new THREE.Color(i.svgChildColor[l]):t.material.color=a),l++)}),i.svg=o,i.setNeedUpdateDisplay(),s.updateDisplay()}else console.log("mx LoadSVG:"+i.svgPath+" failed");i.isLoadFromPath=!1})}this.fixedSize||(t.drawSelectLine(s,o),t.drawSelectLine(r,n),t.drawSelectLine(s,r),t.drawSelectLine(r,o),t.drawSelectLine(o,n),t.drawSelectLine(n,s))}else t.drawLine(s,r),t.drawLine(r,o),t.drawLine(o,n),t.drawLine(n,s)}setSvgPath(t,e=!1){return __awaiter(this,void 0,void 0,function*(){this.svgPath=t,this.svg=null,this.isLoadFromPath=!0,this.svgBoxSize=null,e&&(yield MxThreeJS.loadSVG(t))})}getSvgPath(){return this.svgPath}setSvgPostion(t){this.svgPos=t.clone(),this.isSvgDirtyLocation=!0}getSvgPostion(){return this.svgPos}setSvgSize(t){this.svgSize=t,this.isSvgDirtyLocation=!0}getSvgSize(){return this.svgSize}setSvgAlignmentRatio(t){this.svgAlignmentRatio=t,this.isSvgDirtyLocation=!0}getSvgAlignmentRatio(){return this.svgAlignmentRatio}getText(t){return t<this.aryText.length?this.aryText[t]:null}addText(t){this.aryText.push(t)}getGripPoints(){let t=[];t.push(this.svgPos);let e=0;for(;e<this.aryText.length;e++){let i=this.aryText[e];if(i.move){let e=new THREE.Vector3(i.txtPos.x,i.txtPos.y,0);if(this.fixedSize){let t=MxFun.getCurrentDraw();i.txtPos.x>0?e.x=this.svgPos.x+t.screenCoordLong2Doc(i.txtPos.x):e.x=this.svgPos.x-t.screenCoordLong2Doc(i.txtPos.x),i.txtPos.y>0?e.y=this.svgPos.y+t.screenCoordLong2Doc(i.txtPos.y):e.y=this.svgPos.y-t.screenCoordLong2Doc(i.txtPos.y)}t.push(e)}}return t}moveGripPointsAt(t,e){if(0==t)this.svgPos.add(e),this.fixedSize||this.aryText.forEach(t=>{t.txtPos.add(e)});else if(t-1>=0&&t-1<this.aryText.length){let i=this.aryText[t-1];if(i.move)if(this.fixedSize){let t=MxFun.getCurrentDraw();i.txtPos.x+=t.docCoordLong2Screen(e.x),i.txtPos.y+=t.docCoordLong2Screen(e.y)}else i.txtPos.add(e)}return this.isSvgDirtyLocation=!0,!0}calcSvgPosition(t){if(!this.svg||!this.isSvgDirtyLocation)return;this.isSvgDirtyLocation=!1;let[e,i]=this.calcVewSize(t);this.svg.position.x=this.svgPos.x-e*this.svgAlignmentRatio.x-this.svgMargin.x*e,this.svg.position.y=this.svgPos.y-i*this.svgAlignmentRatio.y-this.svgMargin.y*i}dwgIn(t){this.onDwgIn(t),this.fixedSize=t.fixedSize,this.fixedSize?this.svg=null:t.type==MxType.MxCloneType.kClone&&t.svg&&(this.svg=t.svg.clone()),this.svgPos.copy(t.svgPos),this.svgPath=t.svgPath.substr(0),this.svgSize.copy(t.svgSize),this.svgAlignmentRatio.copy(t.svgAlignmentRatio),this.isSvgDirtyLocation=!0,this.svg||(this.isLoadFromPath=!0),this.svgBoxSize=null;let e=t.txts;return this.aryText=[],e.forEach(t=>{let e=new MxDbSVGText;e.txt=t.txt,e.txtHeight=t.txtHeight,e.txtPos.copy(t.txtPos),e.move=t.move,e.drawConnectingLine=t.drawConnectingLine,this.aryText.push(e)}),this.svgRotate=t.svgRotate,this.useSvgColor=t.useSvgColor,this.svgReverse=t.svgReverse,this.svgMirror=t.svgMirror,this.svgMargin=t.svgMargin,t.svgChildColor?this.svgChildColor=t.svgChildColor:this.svgChildColor=[],!0}dwgOut(t){this.onDwgOut(t);let e,i=this.getMxObject();return t.type==MxType.MxCloneType.kClone&&(t.svg=this.svg),t.svgPath=this.svgPath,t.svgPos=this.svgPos,t.svgSize=this.svgSize,t.svgAlignmentRatio=this.svgAlignmentRatio,t.txts=[],t.type==MxType.MxCloneType.kSaveDwgClone&&i&&(e=this.calcSvgDrawRect(i)),this.aryText.forEach(e=>{let i={txtPos:e.txtPos,txt:e.txt,txtHeight:e.txtHeight,color:e.color,_txtAspectRatio:e._txtAspectRatio,move:e.move,drawConnectingLine:e.drawConnectingLine};t.type==MxType.MxCloneType.kSaveDwgClone&&(e._connectingLine&&(i.connectingLine=e._connectingLine.geometry.vertice),e._underLine&&(i._underLine=e._underLine.geometry.vertice)),t.txts.push(i)}),t.fixedSize=this.fixedSize,t.svgRotate=this.svgRotate,t.useSvgColor=this.useSvgColor,t.svgReverse=this.svgReverse,t.svgMirror=this.svgMirror,t.svgMargin=this.svgMargin,t.svgChildColor=this.svgChildColor,t.type==MxType.MxCloneType.kSaveDwgClone&&(t.svgRect=e),t}create(){return new MxDbSVG}transformBy(t){this.svgPos.applyMatrix4(t),this.isSvgDirtyLocation=!0,this.fixedSize||this.aryText.forEach(e=>{e.txtPos.applyMatrix4(t)})}getTypeName(){return"MxDbSVG"}setColor(t){if(super.setColor(t),this.svg){let t=new THREE.Color(this.color);this.svg.traverse(function(e){e.material&&(e.material.color=t)})}return this}setSvg(t){this.svg=t,this.isLoadFromPath=!1,this.svgBoxSize=null}calcSvgBoxSize(t){if(!this.svgBoxSize)if(t.boxSize)this.svgBoxSize=t.boxSize.clone();else{let e=(new THREE.Box3).setFromObject(t);this.svgBoxSize||(this.svgBoxSize=new THREE.Vector3),this.svgBoxSize.x=e.max.x-e.min.x,this.svgBoxSize.y=e.max.y-e.min.y}}reComputeSVG(){if(!this.svg)return;let t=this.getMxObject();if(!t)return;this.calcSvgBoxSize(this.svg);let[e,i]=this.calcVewSize(t);this.svgBoxSize&&(this.svg.scale.x=e/this.svgBoxSize.x,this.svg.scale.y=i/this.svgBoxSize.y),this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.svgMirror&&(this.svg.scale.x*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}onViewChange(){if(!this.fixedSize)return!1;let t=this.getMxObject();if(null==t)return!1;if(this.svg){this.calcSvgBoxSize(this.svg);let[e,i]=this.calcVewSize(t);this.svgBoxSize&&(this.svg.scale.x=e/this.svgBoxSize.x,this.svg.scale.y=i/this.svgBoxSize.y),this.svg.scale.z=this.svg.scale.x,this.svgReverse&&(this.svg.scale.y*=-1),this.svgMirror&&(this.svg.scale.x*=-1),this.isSvgDirtyLocation=!0,this.calcSvgPosition(t)}let e=this.calcSvgDrawRect(t),i=e.cenpt,s=e.sizew,o=this;return this.aryText.forEach(e=>{if(e._txtObject&&t){let n=t.screenCoordLong2Doc(e.txtHeight);if(n>1e-5){e._txtAspectRatio<=0&&(e._txtAspectRatio=e._txtObject.scale.x/e._txtObject.scale.y),e._txtObject.scale.set(e._txtAspectRatio*n*1.5,1.5*n,1),e.txtPos.x>0?e._txtObject.position.x=o.svgPos.x+t.screenCoordLong2Doc(e.txtPos.x):e._txtObject.position.x=o.svgPos.x-t.screenCoordLong2Doc(e.txtPos.x),e.txtPos.y>0?e._txtObject.position.y=o.svgPos.y+t.screenCoordLong2Doc(e.txtPos.y):e._txtObject.position.y=o.svgPos.y-t.screenCoordLong2Doc(e.txtPos.y);let g=e._txtObject.position;if(e._txtObject.updateMatrix(),e._underLine){const t=new THREE.Box3;let i=e._txtObject.parent;e._txtObject.parent=null,t.expandByObject(e._txtObject),e._txtObject.parent=i;let s=new THREE.Vector3(t.min.x,t.min.y+.1*n,0),o=new THREE.Vector3(t.max.x,t.min.y+.1*n,0);(r=new THREE.Geometry).vertices.push(s,o),e._underLine.geometry=r}if(e._connectingLine){let t=i.clone().sub(g);t.normalize();let o=i.clone().sub(t.clone().multiplyScalar(s)),a=g.clone().add(t.clone().multiplyScalar(n));var r;(r=new THREE.Geometry).vertices.push(o,a),e._connectingLine.geometry=r}}}}),!0}}MxDbSVG.cmd="Mx_ModelFixedSvg",MxDbSVG.draw=drawMxDbSVG,addRegisterMxDbEntity(MxDbSVG);export default MxDbSVG;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getToGenerateRoundedCorners,repairGeometryFaceVertexUvs}from"../../tools/three";import McGeTool from"../McGeTool";import MxDbEntity from"../MxDbEntity";import MxFilters from"../MxFilters";import MxFun from"../MxFun";import MxType from"../MxType";export default class MxDbShape extends MxDbEntity{constructor(){super(...arguments),this.isLoadMaterialFromPath=!0,this.strokeLineWidth=2,this.isStrokeDashLine=!1,this.isFill=!1,this.curveSegments=50,this.closed=!0,this.cornerRadius=[],this._propertyDbKeys=["isFill","stroke","strokeLineWidth","isStrokeDashLine","closed","cornerRadius","fillImageSrc","fillImageParam"]}setStroke(t){return this.stroke=t,this}setStrokeLineWidth(t){return this.strokeLineWidth=t,this}setIsStrokeDashLine(t){return this.isStrokeDashLine=t,this}setIsFill(t){return this.isFill=t,this}get fillImageSrc(){return this._fillImageSrc}set fillImageSrc(t){this._fillImageSrc=t,this.isLoadMaterialFromPath=!0,this.material=null}setFillImageSrc(t){return this.fillImageSrc=t,this}setCurveSegments(t){return this.curveSegments=t,this}setClosed(t){return this.closed=t,this}setCornerRadius(t,e=!0){t instanceof Array?this.cornerRadius=t.map(t=>e?MxFun.screenCoordLong2Doc(t):t):this.cornerRadius=e?MxFun.screenCoordLong2Doc(t):t}getTypeName(){return"MxDbShape"}getShapePoints(t){const{curveSegments:e}=this;return this.points=t.getPoints(e).map(t=>t instanceof THREE.Vector2?new THREE.Vector3(t.x,t.y,0):t),this.points}createPaths(t){return this._paths=new THREE.CurvePath,Array.isArray(t)?t.forEach(t=>this._paths.add(t)):this._paths.add(t),this._paths}_draw(t,e){let{isFill:i,closed:s}=this;const r=t.getColor();t.setColor(this.filter?this.filter._getFilterColor(this.color,this.opacity):this.color);const o=this.getCornerRadiusPoints(s||i?this.getClosedPoints(e):e);i?!this.fillImageSrc&&t.drawSolid(o):t.drawLines(o),this._fillImg(t,o),t.setColor(r)}getCornerRadiusPoints(t){const{cornerRadius:e}=this;if(!e)return t;const i="number"==typeof e?t.map(()=>e):e;return i.length>0?getToGenerateRoundedCorners(t,i):t}_drawStoreLine(t,e,i){const{isFill:s,stroke:r,strokeLineWidth:o}=this,a=t.getLineWidth(),n=t.getColor(),l=t.isDashLineDisplay();r&&s&&(t.setDashLineDisplay(this.isStrokeDashLine),t.setColor(r),t.setLineWidth(o),i?i(t):t.drawLines(this.getCornerRadiusPoints(this.getClosedPoints(e))),t.setColor(n),t.setLineWidth(a),t.setDashLineDisplay(l))}getClosedPoints(t){return[...t,t[0]]}getTotalLength(){return this._paths?this._paths.getLength()+(this.closedLine?this.closedLine.getLength():0):0}getArea(){return this.points?McGeTool.calcArea(this.closed?this.getClosedPoints(this.points):this.points):0}worldDraw(t){const e=this.createPaths(new THREE.Curve),i=this.getShapePoints(e);this._draw(t,i),this._drawStoreLine(t,i)}_fillImg(t,e){const i={transparent:!0,depthTest:!1,opacity:this.opacity,visible:this.visible};if(!this.isFill||!this.fillImageSrc)return;if(!this.material){let t=this;return void MxFun.loadImageMaterial(this.fillImageSrc,e=>{t.isLoadMaterialFromPath=!1,e&&(t.material=e,t.setNeedUpdateDisplay(),MxFun.updateDisplay())})}const s=e.map(({x:t,y:e})=>new THREE.Vector2(t,e));let r=this.material,o=new THREE.ShapeGeometry(new THREE.Shape(s));if(o=repairGeometryFaceVertexUvs(o),this.filter){const t=r.map,e=this.filter._getFilterShaderData(t);r=new THREE.ShaderMaterial(Object.assign(Object.assign({},e),i))}if(r.depthTest=!1,r.transparent=!0,r.opacity=this.opacity,r.visible=this.visible,this.fillImageParam){const t=this.fillImageParam;for(let e in this.fillImageParam){this.material.map[e]=t[e]}}let a=new THREE.Mesh(o,r);t.drawEntity(a)}getGripPoints(){return[]}moveGripPointsAt(t,e){return!0}dwgIn(t){return this.dwgInHelp(t,this._propertyDbKeys),this.isLoadMaterialFromPath=!0,this.material=null,t.type===MxType.MxCloneType.kMxFileClone?this.filter=MxFilters.fromJSON(t.filter):t.filter&&(this.filter=t.filter),!0}dwgOut(t){var e;return this.dwgOutHelp(t,this._propertyDbKeys),t.type===MxType.MxCloneType.kMxFileClone?this.filter&&(t.filter=null===(e=this.filter)||void 0===e?void 0:e.toJSON()):t.filter=this.filter,t}};
|
|
1
|
+
import{getToGenerateRoundedCorners,repairGeometryFaceVertexUvs}from"../../tools/three";import McGeTool from"../McGeTool";import MxDbEntity from"../MxDbEntity";import MxFilters from"../MxFilters";import MxFun from"../MxFun";import MxType from"../MxType";export default class MxDbShape extends MxDbEntity{constructor(){super(...arguments),this.isLoadMaterialFromPath=!0,this.strokeLineWidth=2,this.isStrokeDashLine=!1,this.isFill=!1,this.curveSegments=50,this.closed=!0,this.cornerRadius=[],this._propertyDbKeys=["isFill","stroke","strokeLineWidth","isStrokeDashLine","closed","cornerRadius","fillImageSrc","fillImageParam"]}setStroke(t){return this.stroke=t,this}setStrokeLineWidth(t){return this.strokeLineWidth=t,this}setIsStrokeDashLine(t){return this.isStrokeDashLine=t,this}setIsFill(t){return this.isFill=t,this}get fillImageSrc(){return this._fillImageSrc}set fillImageSrc(t){this._fillImageSrc=t,this.isLoadMaterialFromPath=!0,this.material=null}setFillImageSrc(t){return this.fillImageSrc=t,this}setCurveSegments(t){return this.curveSegments=t,this}setClosed(t){return this.closed=t,this}setCornerRadius(t,e=!0){t instanceof Array?this.cornerRadius=t.map(t=>e?MxFun.screenCoordLong2Doc(t):t):this.cornerRadius=e?MxFun.screenCoordLong2Doc(t):t}getTypeName(){return"MxDbShape"}getShapePoints(t){const{curveSegments:e}=this;return this.points=t.getPoints(e).map(t=>t instanceof THREE.Vector2?new THREE.Vector3(t.x,t.y,0):t),this.points}createPaths(t){return this._paths=new THREE.CurvePath,Array.isArray(t)?t.forEach(t=>this._paths.add(t)):this._paths.add(t),this._paths}_draw(t,e){let{isFill:i,closed:s}=this;const r=t.getColor();t.setColor(this.filter?this.filter._getFilterColor(this.color,this.opacity):this.color);const o=this.getCornerRadiusPoints(s||i?this.getClosedPoints(e):e);i?!this.fillImageSrc&&t.drawSolid(o):t.drawLines(o),this._fillImg(t,o),t.setColor(r)}getCornerRadiusPoints(t){const{cornerRadius:e}=this;if(!e)return t;const i="number"==typeof e?t.map(()=>e):e;return i.length>0?getToGenerateRoundedCorners(t,i):t}_drawStoreLine(t,e,i){const{isFill:s,stroke:r,strokeLineWidth:o}=this,a=t.getLineWidth(),n=t.getColor(),l=t.isDashLineDisplay();r&&s&&(t.setDashLineDisplay(this.isStrokeDashLine),t.setColor(r),t.setLineWidth(o),i?i(t):t.drawLines(this.getCornerRadiusPoints(this.getClosedPoints(e))),t.setColor(n),t.setLineWidth(a),t.setDashLineDisplay(l))}getClosedPoints(t){return[...t,t[0]]}getTotalLength(){return this._paths?this._paths.getLength()+(this.closedLine?this.closedLine.getLength():0):0}getArea(){return this.points?McGeTool.calcArea(this.closed?this.getClosedPoints(this.points):this.points):0}worldDraw(t){const e=this.createPaths(new THREE.Curve),i=this.getShapePoints(e);this._draw(t,i),this._drawStoreLine(t,i)}_fillImg(t,e){const i={transparent:!0,depthTest:!1,opacity:this.opacity,visible:this.visible};if(!this.isFill||!this.fillImageSrc)return;if(!this.material){let t=this;return void MxFun.loadImageMaterial(this.fillImageSrc,e=>{t.isLoadMaterialFromPath=!1,e&&(t.material=e,t.setNeedUpdateDisplay(),MxFun.updateDisplay())})}const s=e.map(({x:t,y:e})=>new THREE.Vector2(t,e));let r=this.material,o=new THREE.ShapeGeometry(new THREE.Shape(s));if(o=repairGeometryFaceVertexUvs(o),this.filter){const t=r.map,e=this.filter._getFilterShaderData(t);r=new THREE.ShaderMaterial(Object.assign(Object.assign({},e),i))}if(r.depthTest=!1,r.transparent=!0,r.opacity=this.opacity,r.visible=this.visible,this.fillImageParam){const t=this.fillImageParam;for(let e in this.fillImageParam){this.material.map[e]=t[e]}}let a=new THREE.Mesh(o,r);t.drawEntity(a)}getGripPoints(){return[]}moveGripPointsAt(t,e){return!0}dwgIn(t){return this.onDwgIn(t),this.dwgInHelp(t,this._propertyDbKeys),this.isLoadMaterialFromPath=!0,this.material=null,t.type===MxType.MxCloneType.kMxFileClone?t.filter&&(this.filter=MxFilters.fromJSON(t.filter)):t.filter&&(this.filter=t.filter),!0}dwgOut(t){var e;return this.onDwgOut(t),this.dwgOutHelp(t,this._propertyDbKeys),t.type===MxType.MxCloneType.kMxFileClone?this.filter&&(t.filter=null===(e=this.filter)||void 0===e?void 0:e.toJSON()):t.filter=this.filter,t}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function drawMxDbStarShape(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,i){function a(t){try{w(n.next(t))}catch(t){i(t)}}function c(t){try{w(n.throw(t))}catch(t){i(t)}}function w(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,c)}w((n=n.apply(t,e||[])).next())})};import{MxDbStarShapeDraw}from".";import McEdGetPointWorldDrawObject from"../McEdGetPointWorldDrawObject";import MrxDbgUiPrPoint from"../MrxDbgUiPrPoint";import MxFun from"../MxFun";export default function drawMxDbStarShape(){const t=new MrxDbgUiPrPoint,e=MxFun.getCurrentDraw(),r=new McEdGetPointWorldDrawObject;t.setUserDraw(r);const n=new McEdGetPointWorldDrawObject,o=new MxDbStarShapeDraw;t.setUserDraw(n),t.setMessage("\n确定圆弧开始点:"),t.go(r=>__awaiter(this,void 0,void 0,function*(){o.center=t.value(),n.setDraw(t=>{o.innerPoint=t,n.drawCircle(o.center,o.center.distanceTo(t))}),o.innerPoint=(yield t.go())||new THREE.Vector3,n.setDraw(t=>{o.outerPoint=t,n.drawCustomEntity(o)}),o.outerPoint=(yield t.go())||new THREE.Vector3,e.addMxEntity(o)}))};
|