Draw.js 96 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056
  1. import { floorplanService } from '../Service/FloorplanService.js'
  2. import { stateService } from '../Service/StateService.js'
  3. import { coordinate } from '../Coordinate.js'
  4. import Style from '../Style.js'
  5. import VectorType from '../enum/VectorType.js'
  6. import SelectState from '../enum/SelectState.js'
  7. import { mathUtil } from '../MathUtil.js'
  8. import ElementEvents from '../enum/ElementEvents.js'
  9. import Constant from '../Constant.js'
  10. import { signService } from '../Service/SignService.js'
  11. export default class Draw {
  12. constructor() {
  13. this.context = null
  14. }
  15. initContext(canvas) {
  16. if (canvas) {
  17. this.context = canvas.getContext('2d')
  18. } else {
  19. this.context = null
  20. }
  21. }
  22. clear() {
  23. this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height)
  24. }
  25. drawBackGround() {
  26. this.context.save()
  27. this.context.fillStyle = 'white';
  28. this.context.fillRect(0,0,this.context.canvas.width,this.context.canvas.height)
  29. this.context.restore()
  30. }
  31. drawFrame() {
  32. this.context.save()
  33. this.context.strokeStyle = 'black';
  34. const ratio = this.context.canvas.width/297 ;
  35. this.context.strokeRect(ratio * 20, ratio * 20,this.context.canvas.width - 2*ratio * 20,this.context.canvas.height - 2*ratio * 20)
  36. this.context.restore()
  37. }
  38. drawWall(vector) {
  39. let start = floorplanService.getPoint(vector.start)
  40. let end = floorplanService.getPoint(vector.end)
  41. let points = []
  42. points.push(start)
  43. points.push(end)
  44. points = points.sort(sortNumber.bind(this))
  45. function sortNumber(a, b) {
  46. return mathUtil.getDistance(start, a) - mathUtil.getDistance(start, b)
  47. }
  48. this.context.save()
  49. this.context.beginPath()
  50. this.context.lineCap = 'round' //线段端点的样式
  51. this.context.lineWidth = Style.Wall.lineWidth * coordinate.ratio
  52. this.context.strokeStyle = vector.color
  53. const selectItem = stateService.getSelectItem()
  54. const draggingItem = stateService.getDraggingItem()
  55. const focusItem = stateService.getFocusItem()
  56. if (selectItem && selectItem.type == VectorType.Wall) {
  57. if (vector.vectorId == selectItem.vectorId) {
  58. this.context.strokeStyle = Style.Select.Wall.strokeStyle
  59. }
  60. } else if (draggingItem && draggingItem.type == VectorType.Wall) {
  61. if (vector.vectorId == draggingItem.vectorId) {
  62. this.context.strokeStyle = Style.Select.Wall.strokeStyle
  63. }
  64. }
  65. if (focusItem && focusItem.type == VectorType.Wall) {
  66. if (vector.vectorId == focusItem.vectorId) {
  67. this.context.strokeStyle = Style.Focus.Wall.strokeStyle
  68. }
  69. }
  70. for (let i = 0; i < points.length - 1; i += 2) {
  71. let point1 = coordinate.getScreenXY(points[i])
  72. let point2 = coordinate.getScreenXY(points[i + 1])
  73. this.context.moveTo(point1.x, point1.y)
  74. this.context.lineTo(point2.x, point2.y)
  75. }
  76. this.context.stroke()
  77. this.context.restore()
  78. }
  79. drawSpecialPoint() {
  80. const selectItem = stateService.getSelectItem()
  81. const draggingItem = stateService.getDraggingItem()
  82. const focusItem = stateService.getFocusItem()
  83. let point = null
  84. this.context.save()
  85. if (selectItem) {
  86. point = floorplanService.getPoint(selectItem.vectorId)
  87. this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
  88. this.context.strokeStyle = Style.Select.Point.strokeStyle
  89. this.context.fillStyle = Style.Select.Point.fillStyle
  90. }
  91. if (draggingItem) {
  92. point = floorplanService.getPoint(draggingItem.vectorId)
  93. this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
  94. this.context.strokeStyle = Style.Select.Point.strokeStyle
  95. this.context.fillStyle = Style.Select.Point.fillStyle
  96. }
  97. if (focusItem) {
  98. point = floorplanService.getPoint(focusItem.vectorId)
  99. this.context.lineWidth = Style.Focus.Point.lineWidth * coordinate.ratio
  100. this.context.strokeStyle = Style.Focus.Point.strokeStyle
  101. this.context.fillStyle = Style.Focus.Point.fillStyle
  102. }
  103. if (point == null) {
  104. this.context.restore()
  105. return
  106. }
  107. const pt = coordinate.getScreenXY({ x: point.x, y: point.y })
  108. let radius = Style.Point.radius
  109. this.context.beginPath()
  110. this.context.arc(pt.x, pt.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
  111. this.context.stroke()
  112. this.context.fill()
  113. this.context.restore()
  114. }
  115. drawPoint(vector) {
  116. const pt = coordinate.getScreenXY({ x: vector.x, y: vector.y })
  117. const selectItem = stateService.getSelectItem()
  118. const draggingItem = stateService.getDraggingItem()
  119. const focusItem = stateService.getFocusItem()
  120. // this.context.save()
  121. // this.context.lineWidth = Style.Point.lineWidth * coordinate.ratio
  122. // this.context.strokeStyle = Style.Point.strokeStyle
  123. // this.context.fillStyle = Style.Point.fillStyle
  124. let radius = Style.Point.radius
  125. if (
  126. (draggingItem && draggingItem.type == VectorType.WallCorner && vector.vectorId == draggingItem.vectorId) ||
  127. (selectItem && selectItem.type == VectorType.WallCorner && vector.vectorId == selectItem.vectorId)
  128. ) {
  129. this.context.save()
  130. this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
  131. this.context.strokeStyle = Style.Select.Point.strokeStyle
  132. this.context.fillStyle = Style.Select.Point.fillStyle
  133. radius = Style.Select.Point.radius
  134. } else if (focusItem && focusItem.type == VectorType.WallCorner && vector.vectorId == focusItem.vectorId) {
  135. this.context.save()
  136. this.context.lineWidth = Style.Focus.Point.lineWidth * coordinate.ratio
  137. this.context.strokeStyle = Style.Focus.Point.strokeStyle
  138. this.context.fillStyle = Style.Focus.Point.fillStyle
  139. radius = Style.Focus.Point.radius
  140. } else {
  141. return
  142. }
  143. this.context.beginPath()
  144. this.context.arc(pt.x, pt.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
  145. this.context.stroke()
  146. this.context.fill()
  147. this.context.restore()
  148. // this.drawText({ x: vector.x, y: vector.y }, vector.vectorId)
  149. }
  150. // 文字
  151. drawText(position, txt, screenCoord) {
  152. this.context.save()
  153. this.setCanvasStyle(Style.Font)
  154. this.context.font = '12px Microsoft YaHei'
  155. let pt = { x: position.x, y: position.y }
  156. if (!screenCoord) {
  157. pt = coordinate.getScreenXY({ x: position.x, y: position.y })
  158. }
  159. this.context.fillText(txt, pt.x, pt.y)
  160. this.context.restore()
  161. }
  162. drawTag(geometry) {
  163. this.context.save()
  164. this.context.lineWidth = Style.Tag.lineWidth * coordinate.ratio
  165. this.context.strokeStyle = geometry.color
  166. this.context.fillStyle = geometry.color
  167. const selectItem = stateService.getSelectItem()
  168. const draggingItem = stateService.getDraggingItem()
  169. const focusItem = stateService.getFocusItem()
  170. if (selectItem && selectItem.type == VectorType.Tag) {
  171. if (geometry.vectorId == selectItem.vectorId) {
  172. this.context.strokeStyle = Style.Select.Tag.strokeStyle
  173. this.context.fillStyle = Style.Select.Tag.fillStyle
  174. }
  175. } else if (draggingItem && draggingItem.type == VectorType.Tag) {
  176. if (geometry.vectorId == draggingItem.vectorId) {
  177. this.context.strokeStyle = Style.Select.Tag.strokeStyle
  178. this.context.fillStyle = Style.Select.Tag.fillStyle
  179. }
  180. }
  181. if (focusItem && focusItem.type == VectorType.Tag) {
  182. if (geometry.vectorId == focusItem.vectorId) {
  183. this.context.strokeStyle = Style.Focus.Tag.strokeStyle
  184. this.context.fillStyle = Style.Focus.Tag.fillStyle
  185. }
  186. }
  187. this.context.font = `400 ${geometry.fontSize* coordinate.ratio}px Microsoft YaHei`
  188. //根据文字的长度,更新标注范围
  189. //geometry.sideWidth = Math.max(this.context.measureText(geometry.value).width, this.context.measureText(parseFloat(geometry.value).toFixed(2)).width)
  190. let fontInfo = geometry.setFontLenAndHeight()
  191. let sideWidth = 0;
  192. for(let i=0;i<fontInfo.textValues.length;++i){
  193. sideWidth = Math.max(sideWidth,this.context.measureText(fontInfo.textValues[i]).width, this.context.measureText(parseFloat(fontInfo.textValues[i]).toFixed(2)).width)
  194. }
  195. geometry.sideWidth = sideWidth
  196. geometry.sideThickness = fontInfo.height * (geometry.fontSize)
  197. geometry.setPoints2d()
  198. let points2d = geometry.points2d
  199. let points = []
  200. for (let i = 0; i < points2d.length; ++i) {
  201. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  202. }
  203. let pt = coordinate.getScreenXY({ x: geometry.center.x, y: geometry.center.y })
  204. const fontWidth1 = geometry.sideWidth
  205. //let dy = (points[3].y - points[0].y)/fontInfo.textValues.length/2
  206. let dy = geometry.sideThickness/fontInfo.height/2*coordinate.ratio
  207. for(let i=0;i<fontInfo.textValues.length;++i){
  208. // const line1 = mathUtil.createLine1({ x: (points[0].x + points[3].x) / 2, y: (points[0].y + points[3].y) / 2 }, { x: (points[2].x + points[1].x) / 2, y: (points[2].y + points[1].y) / 2 })
  209. // const fontStart1 = mathUtil.getDisPointsLine(line1, pt, fontWidth1 / 2, fontWidth1 / 2)
  210. // if (fontStart1.newpoint1.x < fontStart1.newpoint2.x) {
  211. // this.context.fillText(geometry.value, fontStart1.newpoint1.x, fontStart1.newpoint1.y)
  212. // } else {
  213. // this.context.fillText(geometry.value, fontStart1.newpoint2.x, fontStart1.newpoint2.y)
  214. // }
  215. //let count = (2*(i-(fontInfo.textValues.length-1))+1)
  216. //let count = 1 * (fontInfo.textValues.length-i)
  217. let count = i+1
  218. count = 2* count - fontInfo.textValues.length
  219. this.context.fillText(fontInfo.textValues[i], pt.x - fontWidth1/2, pt.y + dy*count)
  220. }
  221. // this.context.beginPath()
  222. // this.context.arc(pt.x, pt.y, 2 * coordinate.ratio, 0, Math.PI * 2, true)
  223. // this.context.stroke()
  224. // this.context.fill()
  225. // this.context.beginPath()
  226. // this.context.moveTo(points[0].x, points[0].y)
  227. // this.context.lineTo(points[1].x, points[1].y)
  228. // this.context.lineTo(points[2].x, points[2].y)
  229. // this.context.lineTo(points[3].x, points[3].y)
  230. // this.context.closePath();
  231. // this.context.stroke()
  232. this.context.restore()
  233. }
  234. drawTable(geometry){
  235. const leftTop = coordinate.getScreenXY({
  236. x:geometry.center.x - Math.abs(geometry.points[0].x - geometry.points[1].x)/2,
  237. y:geometry.center.y + Math.abs(geometry.points[0].y - geometry.points[3].y)/2,
  238. })
  239. for(let i=0;i<geometry.cells.length;++i){
  240. for(let j=0;j<geometry.cells[i].length;++j)
  241. {
  242. const cell = floorplanService.getCell(geometry.cells[i][j])
  243. const position = geometry.getCellPos(cell.vectorId)
  244. this.drawCell(cell,position.x + leftTop.x,position.y + leftTop.y)
  245. }
  246. }
  247. }
  248. drawCell(geometry,width,height){
  249. this.context.save()
  250. this.context.lineWidth = Style.Table.lineWidth * coordinate.ratio
  251. this.context.strokeStyle = Style.Table.strokeStyle
  252. this.context.fillStyle = Style.Table.fillStyle
  253. const selectItem = stateService.getSelectItem()
  254. const draggingItem = stateService.getDraggingItem()
  255. const focusItem = stateService.getFocusItem()
  256. if (selectItem && selectItem.type == VectorType.Table) {
  257. if (geometry.parent == selectItem.vectorId) {
  258. this.context.strokeStyle = Style.Select.Table.strokeStyle
  259. this.context.fillStyle = Style.Select.Table.fillStyle
  260. }
  261. } else if (draggingItem && draggingItem.type == VectorType.Table) {
  262. if (geometry.parent == draggingItem.vectorId) {
  263. this.context.strokeStyle = Style.Select.Table.strokeStyle
  264. this.context.fillStyle = Style.Select.Table.fillStyle
  265. }
  266. }
  267. if (focusItem && focusItem.type == VectorType.Table) {
  268. if (geometry.parent == focusItem.vectorId) {
  269. this.context.strokeStyle = Style.Focus.Table.strokeStyle
  270. this.context.fillStyle = Style.Focus.Table.fillStyle
  271. }
  272. }
  273. this.context.translate(width, height)
  274. this.context.beginPath()
  275. this.context.moveTo(0,0)
  276. this.context.lineTo(geometry.width* coordinate.ratio,0)
  277. this.context.lineTo(geometry.width* coordinate.ratio,geometry.height* coordinate.ratio)
  278. this.context.lineTo(0,geometry.height* coordinate.ratio)
  279. this.context.closePath();
  280. this.context.stroke()
  281. this.context.font = 12*coordinate.ratio+'px Microsoft YaHei'
  282. let fontWidth = this.context.measureText(geometry.value).width
  283. //如果是数字或者字母
  284. const patt = /[A-z0-9]/g;
  285. const alphanumeric = geometry.value.match(patt);
  286. if(alphanumeric){
  287. const alphanumericLen = geometry.value.match(patt).length;
  288. fontWidth = fontWidth * (geometry.value.length - alphanumericLen)/geometry.value.length + fontWidth * alphanumericLen/geometry.value.length*1.5
  289. }
  290. //let rowCount = Math.ceil(geometry.height/defaultHeight) //分几行写
  291. let rowCount = Math.ceil(fontWidth/(geometry.width* coordinate.ratio)) //分几行写,根据要写的文字的长度来判断
  292. if(rowCount == 1){
  293. this.context.textAlign = "center";
  294. this.context.textBaseline = "middle";
  295. this.context.fillText(geometry.value, geometry.width/2* coordinate.ratio, geometry.height/2* coordinate.ratio)
  296. }
  297. //大于1行
  298. else{
  299. const rowWidth = Math.ceil(fontWidth/rowCount) //每行的长度
  300. const rowFontCount = Math.ceil(geometry.value.length/rowCount) //每行的文字个数
  301. this.context.textAlign = "left";
  302. for(let i=0;i<rowCount;++i){
  303. const value = geometry.value.substr(i*rowFontCount,rowFontCount)
  304. this.context.fillText(value, (geometry.width/2* coordinate.ratio- rowWidth/2), (18+18*i)* coordinate.ratio)
  305. }
  306. }
  307. this.context.restore()
  308. }
  309. drawRectangle(geometry){
  310. let points = []
  311. for(let i=0;i<geometry.points.length;++i){
  312. points.push(coordinate.getScreenXY(geometry.points[i]))
  313. }
  314. this.context.save()
  315. this.context.beginPath()
  316. this.context.lineCap = 'round' //线段端点的样式;
  317. this.context.lineWidth = Style.Rectangle.lineWidth * coordinate.ratio
  318. this.context.strokeStyle = geometry.color
  319. const selectItem = stateService.getSelectItem()
  320. const draggingItem = stateService.getDraggingItem()
  321. const focusItem = stateService.getFocusItem()
  322. let fillFlag = false
  323. if (selectItem && selectItem.type == VectorType.Rectangle) {
  324. if (geometry.vectorId == selectItem.vectorId) {
  325. if(selectItem.selectIndex == SelectState.All){
  326. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  327. this.context.fillStyle = Style.Select.Rectangle.fillStyle
  328. fillFlag = true;
  329. }
  330. else if(selectItem.selectIndex.indexOf(SelectState.Side)>-1){
  331. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  332. }
  333. else if(selectItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  334. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  335. let vertexIndex = selectItem.selectIndex.replace(SelectState.Vertex+'_','');
  336. this.drawCircle({
  337. x:geometry.points[vertexIndex].x,
  338. y:geometry.points[vertexIndex].y,
  339. name: ElementEvents.StartAddWall
  340. })
  341. }
  342. }
  343. } else if (draggingItem && draggingItem.type == VectorType.Rectangle) {
  344. if (geometry.vectorId == draggingItem.vectorId) {
  345. if(draggingItem.selectIndex == SelectState.All){
  346. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  347. this.context.fillStyle = Style.Select.Rectangle.fillStyle
  348. fillFlag = true;
  349. }
  350. else if(draggingItem.selectIndex.indexOf(SelectState.Side)>-1){
  351. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  352. }
  353. else if(draggingItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  354. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  355. let vertexIndex = draggingItem.selectIndex.replace(SelectState.Vertex+'_','');
  356. this.drawCircle({
  357. x:geometry.points[vertexIndex].x,
  358. y:geometry.points[vertexIndex].y,
  359. name: ElementEvents.StartAddWall
  360. })
  361. }
  362. }
  363. }
  364. if (focusItem && focusItem.type == VectorType.Rectangle) {
  365. if (geometry.vectorId == focusItem.vectorId) {
  366. if(focusItem.selectIndex == SelectState.All){
  367. this.context.strokeStyle = Style.Focus.Rectangle.strokeStyle
  368. this.context.fillStyle = Style.Focus.Rectangle.fillStyle
  369. fillFlag = true;
  370. }
  371. else if(focusItem.selectIndex.indexOf(SelectState.Side)>-1){
  372. this.context.strokeStyle = Style.Focus.Rectangle.strokeStyle
  373. }
  374. else if(focusItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  375. this.context.strokeStyle = Style.Focus.Rectangle.strokeStyle
  376. let vertexIndex = focusItem.selectIndex.replace(SelectState.Vertex+'_','');
  377. this.drawCircle({
  378. x:geometry.points[vertexIndex].x,
  379. y:geometry.points[vertexIndex].y,
  380. name: ElementEvents.StartAddWall
  381. })
  382. }
  383. }
  384. }
  385. this.context.moveTo(points[0].x, points[0].y)
  386. for (let i = 1; i < points.length; ++i) {
  387. this.context.lineTo(points[i].x, points[i].y)
  388. }
  389. this.context.closePath();
  390. this.context.stroke()
  391. if(fillFlag){
  392. this.context.fill()
  393. }
  394. this.context.restore()
  395. }
  396. drawCircleGeo(geometry)
  397. {
  398. let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom * coordinate.ratio
  399. const twoPi = Math.PI * 2
  400. const pt = coordinate.getScreenXY(geometry.center)
  401. this.context.save()
  402. this.context.lineWidth = Style.Circle.lineWidth * coordinate.ratio
  403. this.context.strokeStyle = geometry.color
  404. const selectItem = stateService.getSelectItem()
  405. const draggingItem = stateService.getDraggingItem()
  406. const focusItem = stateService.getFocusItem()
  407. let fillFlag = false
  408. if (selectItem && selectItem.type == VectorType.Circle) {
  409. if (geometry.vectorId == selectItem.vectorId) {
  410. if(selectItem.selectIndex == SelectState.All){
  411. this.context.strokeStyle = Style.Select.Circle.strokeStyle
  412. this.context.fillStyle = Style.Select.Circle.fillStyle
  413. fillFlag = true;
  414. this.drawRec(geometry.points)
  415. }
  416. else if(selectItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  417. this.context.strokeStyle = Style.Select.Circle.strokeStyle
  418. let vertexIndex = selectItem.selectIndex.replace(SelectState.Vertex+'_','');
  419. this.drawCircle({
  420. x:geometry.points[vertexIndex].x,
  421. y:geometry.points[vertexIndex].y,
  422. name: ElementEvents.StartAddWall
  423. })
  424. this.drawRec(geometry.points)
  425. }
  426. }
  427. } else if (draggingItem && draggingItem.type == VectorType.Circle) {
  428. if (geometry.vectorId == draggingItem.vectorId) {
  429. if(draggingItem.selectIndex == SelectState.All){
  430. this.context.strokeStyle = Style.Select.Circle.strokeStyle
  431. this.context.fillStyle = Style.Select.Circle.fillStyle
  432. fillFlag = true;
  433. this.drawRec(geometry.points)
  434. }
  435. else if(draggingItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  436. this.context.strokeStyle = Style.Select.Circle.strokeStyle
  437. let vertexIndex = draggingItem.selectIndex.replace(SelectState.Vertex+'_','');
  438. this.drawCircle({
  439. x:geometry.points[vertexIndex].x,
  440. y:geometry.points[vertexIndex].y,
  441. name: ElementEvents.StartAddWall
  442. })
  443. this.drawRec(geometry.points)
  444. }
  445. }
  446. }
  447. if (focusItem && focusItem.type == VectorType.Circle) {
  448. if (geometry.vectorId == focusItem.vectorId) {
  449. if(focusItem.selectIndex == SelectState.All){
  450. this.context.strokeStyle = Style.Focus.Circle.strokeStyle
  451. this.context.fillStyle = Style.Focus.Circle.fillStyle
  452. fillFlag = true;
  453. }
  454. else if(focusItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  455. this.context.strokeStyle = Style.Focus.Circle.strokeStyle
  456. let vertexIndex = focusItem.selectIndex.replace(SelectState.Vertex+'_','');
  457. this.drawCircle({
  458. x:geometry.points[vertexIndex].x,
  459. y:geometry.points[vertexIndex].y,
  460. name: ElementEvents.StartAddWall
  461. })
  462. this.drawRec(geometry.points)
  463. }
  464. }
  465. }
  466. this.context.beginPath()
  467. this.context.arc(pt.x, pt.y, radius, 0, twoPi, true)
  468. this.context.stroke()
  469. if(fillFlag){
  470. this.context.fill()
  471. }
  472. this.context.restore()
  473. }
  474. drawIcon(geometry)
  475. {
  476. let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom * coordinate.ratio
  477. const twoPi = Math.PI * 2
  478. const pt = coordinate.getScreenXY(geometry.center)
  479. this.context.save()
  480. this.context.strokeStyle = Style.Icon.strokeStyle
  481. const selectItem = stateService.getSelectItem()
  482. const draggingItem = stateService.getDraggingItem()
  483. const focusItem = stateService.getFocusItem()
  484. let fillFlag = false
  485. if (selectItem && selectItem.type == VectorType.Icon) {
  486. if (geometry.vectorId == selectItem.vectorId) {
  487. if(selectItem.selectIndex == SelectState.All){
  488. this.context.strokeStyle = Style.Select.Icon.strokeStyle
  489. this.context.fillStyle = Style.Select.Icon.fillStyle
  490. fillFlag = true;
  491. }
  492. else if(selectItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  493. this.context.strokeStyle = Style.Select.Icon.strokeStyle
  494. let vertexIndex = selectItem.selectIndex.replace(SelectState.Vertex+'_','');
  495. this.drawCircle({
  496. x:geometry.points[vertexIndex].x,
  497. y:geometry.points[vertexIndex].y,
  498. name: ElementEvents.StartAddWall
  499. })
  500. this.drawRec(geometry.points)
  501. }
  502. }
  503. } else if (draggingItem && draggingItem.type == VectorType.Icon) {
  504. if (geometry.vectorId == draggingItem.vectorId) {
  505. if(draggingItem.selectIndex == SelectState.All){
  506. this.context.strokeStyle = Style.Select.Icon.strokeStyle
  507. this.context.fillStyle = Style.Select.Icon.fillStyle
  508. fillFlag = true;
  509. }
  510. else if(draggingItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  511. this.context.strokeStyle = Style.Select.Icon.strokeStyle
  512. let vertexIndex = draggingItem.selectIndex.replace(SelectState.Vertex+'_','');
  513. this.drawCircle({
  514. x:geometry.points[vertexIndex].x,
  515. y:geometry.points[vertexIndex].y,
  516. name: ElementEvents.StartAddWall
  517. })
  518. this.drawRec(geometry.points)
  519. }
  520. }
  521. }
  522. if (focusItem && focusItem.type == VectorType.Icon) {
  523. if (geometry.vectorId == focusItem.vectorId) {
  524. if(focusItem.selectIndex == SelectState.All){
  525. this.context.strokeStyle = Style.Focus.Icon.strokeStyle
  526. this.context.fillStyle = Style.Focus.Icon.fillStyle
  527. fillFlag = true;
  528. }
  529. else if(focusItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  530. this.context.strokeStyle = Style.Focus.Icon.strokeStyle
  531. let vertexIndex = focusItem.selectIndex.replace(SelectState.Vertex+'_','');
  532. this.drawCircle({
  533. x:geometry.points[vertexIndex].x,
  534. y:geometry.points[vertexIndex].y,
  535. name: ElementEvents.StartAddWall
  536. })
  537. this.drawRec(geometry.points)
  538. }
  539. }
  540. }
  541. this.context.beginPath()
  542. this.context.arc(pt.x, pt.y, radius, 0, twoPi, true)
  543. this.context.stroke()
  544. if(fillFlag){
  545. this.context.fill()
  546. }
  547. this.context.restore()
  548. this.context.save()
  549. this.setCanvasStyle(Style.Font)
  550. let fontSize = Math.ceil(radius * 14/20);
  551. this.context.font = fontSize + Style.Font.font
  552. let center = coordinate.getScreenXY(geometry.center);
  553. this.context.fillText(geometry.value, center.x , center.y)
  554. this.context.restore()
  555. }
  556. drawArrow(geometry){
  557. this.context.save()
  558. this.context.beginPath()
  559. this.context.lineCap = 'round' //线段端点的样式
  560. this.context.strokeStyle = geometry.color
  561. this.context.lineWidth = Style.Arrow.lineWidth * coordinate.ratio
  562. const selectItem = stateService.getSelectItem()
  563. const draggingItem = stateService.getDraggingItem()
  564. const focusItem = stateService.getFocusItem()
  565. if (selectItem && selectItem.type == VectorType.Arrow) {
  566. if (geometry.vectorId == selectItem.vectorId) {
  567. this.context.strokeStyle = Style.Select.Arrow.strokeStyle
  568. if(selectItem.selectIndex == SelectState.Start){
  569. this.drawCircle({
  570. x:geometry.startPoint.x,
  571. y:geometry.startPoint.y,
  572. name: ElementEvents.StartAddWall
  573. })
  574. }
  575. else if(selectItem.selectIndex == SelectState.End){
  576. this.drawCircle({
  577. x:geometry.endPoint.x,
  578. y:geometry.endPoint.y,
  579. name: ElementEvents.StartAddWall
  580. })
  581. }
  582. }
  583. } else if (draggingItem && draggingItem.type == VectorType.Arrow) {
  584. if (geometry.vectorId == draggingItem.vectorId) {
  585. this.context.strokeStyle = Style.Select.Arrow.strokeStyle
  586. if(draggingItem.selectIndex == SelectState.Start){
  587. this.drawCircle({
  588. x:geometry.startPoint.x,
  589. y:geometry.startPoint.y,
  590. name: ElementEvents.StartAddWall
  591. })
  592. }
  593. else if(draggingItem.selectIndex == SelectState.End){
  594. this.drawCircle({
  595. x:geometry.endPoint.x,
  596. y:geometry.endPoint.y,
  597. name: ElementEvents.StartAddWall
  598. })
  599. }
  600. }
  601. }
  602. if (focusItem && focusItem.type == VectorType.Arrow) {
  603. if (geometry.vectorId == focusItem.vectorId) {
  604. this.context.strokeStyle = Style.Focus.Arrow.strokeStyle
  605. if(focusItem.selectIndex == SelectState.Start){
  606. this.drawCircle({
  607. x:geometry.startPoint.x,
  608. y:geometry.startPoint.y,
  609. name: ElementEvents.StartAddWall
  610. })
  611. }
  612. else if(focusItem.selectIndex == SelectState.End){
  613. this.drawCircle({
  614. x:geometry.endPoint.x,
  615. y:geometry.endPoint.y,
  616. name: ElementEvents.StartAddWall
  617. })
  618. }
  619. }
  620. }
  621. let point1 = coordinate.getScreenXY(geometry.startPoint)
  622. let point2 = coordinate.getScreenXY(geometry.endPoint)
  623. var headlen = 10; //自定义箭头线的长度
  624. var theta = 20; //自定义箭头线与直线的夹角,个人觉得45°刚刚好
  625. //箭头线终点坐标
  626. var arrowX, arrowY;
  627. let fromX = point2.x;
  628. let fromY = point2.y;
  629. let toX = point1.x;
  630. let toY = point1.y;
  631. // 计算各角度和对应的箭头终点坐标
  632. var angle = Math.atan2(fromY - toY, fromX - toX) * 180 / Math.PI;
  633. var angle1 = (angle + theta) * Math.PI / 180;
  634. var angle2 = (angle - theta) * Math.PI / 180;
  635. var topX = headlen * Math.cos(angle1);
  636. var topY = headlen * Math.sin(angle1);
  637. var botX = headlen * Math.cos(angle2);
  638. var botY = headlen * Math.sin(angle2);
  639. this.context.beginPath();
  640. //画直线
  641. this.context.moveTo(fromX, fromY);
  642. this.context.lineTo(toX, toY);
  643. arrowX = toX + topX;
  644. arrowY = toY + topY;
  645. //画上边箭头线
  646. this.context.moveTo(arrowX, arrowY);
  647. this.context.lineTo(toX, toY);
  648. arrowX = toX + botX;
  649. arrowY = toY + botY;
  650. //画下边箭头线
  651. this.context.lineTo(arrowX, arrowY);
  652. this.context.stroke()
  653. this.context.restore()
  654. }
  655. drawCircle(element) {
  656. let radius = null
  657. const twoPi = Math.PI * 2
  658. const pt = coordinate.getScreenXY(element)
  659. this.context.save()
  660. if (element.name == ElementEvents.StartAddWall) {
  661. radius = Style.Element.StartAddWall.radius * coordinate.ratio
  662. this.context.strokeStyle = Style.Element.StartAddWall.strokeStyle
  663. this.context.fillStyle = Style.Element.StartAddWall.fillStyle
  664. }
  665. this.context.beginPath()
  666. this.context.arc(pt.x, pt.y, radius, 0, twoPi, true)
  667. this.context.stroke()
  668. this.context.fill()
  669. this.context.restore()
  670. }
  671. drawRec(points){
  672. let point = coordinate.getScreenXY(points[0])
  673. this.context.moveTo(point.x, point.y)
  674. for (let i = 1; i < points.length; ++i) {
  675. point = coordinate.getScreenXY(points[i])
  676. this.context.lineTo(point.x, point.y)
  677. }
  678. this.context.closePath();
  679. this.context.stroke()
  680. }
  681. drawLine(element) {
  682. let start = coordinate.getScreenXY(element.start)
  683. let end = coordinate.getScreenXY(element.end)
  684. this.context.save()
  685. if (element.name == ElementEvents.VCheckLinesX) {
  686. this.context.lineWidth = Style.Element.VCheckLinesX.lineWidth * coordinate.ratio
  687. this.context.strokeStyle = Style.Element.VCheckLinesX.strokeStyle
  688. this.context.setLineDash([3, 2, 2])
  689. start.y = 0
  690. end.y = this.context.canvas.clientHeight
  691. } else if (element.name == ElementEvents.VCheckLinesY) {
  692. this.context.lineWidth = Style.Element.VCheckLinesY.lineWidth * coordinate.ratio
  693. this.context.strokeStyle = Style.Element.VCheckLinesY.strokeStyle
  694. this.context.setLineDash([3, 2, 2])
  695. start.x = 0
  696. end.x = this.context.canvas.clientWidth
  697. } else if (element.name == ElementEvents.NewWall) {
  698. this.context.lineWidth = Style.Element.NewWall.lineWidth * coordinate.ratio
  699. this.context.strokeStyle = Style.Element.NewWall.strokeStyle
  700. if (element.state == 'error') {
  701. this.context.strokeStyle = Style.Element.NewWall.errorStrokeStyle
  702. }
  703. } else if (element.name == ElementEvents.CheckLinesX) {
  704. this.context.lineWidth = Style.Element.CheckLinesX.lineWidth * coordinate.ratio
  705. this.context.strokeStyle = Style.Element.CheckLinesX.strokeStyle
  706. this.context.setLineDash([3, 2, 2])
  707. } else if (element.name == ElementEvents.CheckLinesY) {
  708. this.context.lineWidth = Style.Element.CheckLinesY.lineWidth * coordinate.ratio
  709. this.context.strokeStyle = Style.Element.CheckLinesY.strokeStyle
  710. this.context.setLineDash([3, 2, 2])
  711. }
  712. this.context.beginPath()
  713. this.context.moveTo(start.x, start.y)
  714. this.context.lineTo(end.x, end.y)
  715. this.context.stroke()
  716. this.context.restore()
  717. this.context.save()
  718. this.context.lineWidth = Style.Point.lineWidth * coordinate.ratio
  719. this.context.strokeStyle = Style.Point.strokeStyle
  720. this.context.fillStyle = Style.Point.fillStyle
  721. let radius = Style.Point.radius
  722. this.context.beginPath()
  723. this.context.arc(start.x, start.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
  724. this.context.stroke()
  725. this.context.fill()
  726. this.context.restore()
  727. }
  728. drawTitle(geometry){
  729. this.context.save()
  730. this.setCanvasStyle(Style.Title)
  731. const selectItem = stateService.getSelectItem()
  732. const draggingItem = stateService.getDraggingItem()
  733. const focusItem = stateService.getFocusItem()
  734. if (selectItem && selectItem.type == VectorType.Title) {
  735. this.context.strokeStyle = Style.Select.Title.strokeStyle
  736. this.context.fillStyle = Style.Select.Title.fillStyle
  737. } else if (draggingItem && draggingItem.type == VectorType.Title) {
  738. this.context.strokeStyle = Style.Select.Title.strokeStyle
  739. this.context.fillStyle = Style.Select.Title.fillStyle
  740. }
  741. if (focusItem && focusItem.type == VectorType.Title) {
  742. this.context.strokeStyle = Style.Focus.Title.strokeStyle
  743. this.context.fillStyle = Style.Focus.Title.fillStyle
  744. }
  745. //this.context.font = `400 ${geometry.fontSize}px Microsoft YaHei`
  746. this.context.font = `${24*coordinate.ratio}px Microsoft YaHei`
  747. this.context.fillText(geometry.value, this.context.canvas.width/2, geometry.height*coordinate.ratio)
  748. this.context.restore()
  749. }
  750. drawBgImage(geometry){
  751. if(geometry.url != null){
  752. const pt = {
  753. x:geometry.center.x*coordinate.ratio,
  754. y:geometry.center.y*coordinate.ratio
  755. }
  756. this.context.save()
  757. this.context.translate(pt.x+geometry.width*coordinate.ratio/2, pt.y+geometry.height*coordinate.ratio/2)
  758. this.context.scale(geometry.scale,geometry.scale)
  759. if(geometry.image == null)
  760. {
  761. var img = new Image()
  762. img.src = geometry.src;
  763. img.crossOrigin=""
  764. img.onload = function () {
  765. this.context.drawImage(img, -img.width*coordinate.ratio/2, -img.height*coordinate.ratio/2, img.width*coordinate.ratio, img.height*coordinate.ratio)
  766. }.bind(this)
  767. geometry.image = img;
  768. }
  769. else{
  770. if(geometry.hasOwnProperty('width')){
  771. this.context.drawImage(geometry.image, -geometry.width*coordinate.ratio/2, -geometry.height*coordinate.ratio/2, geometry.width*coordinate.ratio, geometry.height*coordinate.ratio)
  772. }
  773. else{
  774. this.context.drawImage(geometry.image, -geometry.width*coordinate.ratio/2, -geometry.height*coordinate.ratio/2, geometry.image.width*coordinate.ratio, geometry.image.height*coordinate.ratio)
  775. }
  776. }
  777. const focusItem = stateService.getFocusItem()
  778. const selectItem = stateService.getSelectItem()
  779. if (focusItem && focusItem.type == VectorType.BgImage) {
  780. if (geometry.vectorId == focusItem.vectorId) {
  781. this.context.lineWidth = 2/geometry.scale;
  782. this.context.strokeStyle = Style.Select.Tag.strokeStyle
  783. this.context.fillStyle = Style.Select.Tag.fillStyle
  784. this.context.strokeRect( -geometry.width*coordinate.ratio/2, -geometry.height*coordinate.ratio/2, geometry.width, geometry.height)
  785. }
  786. }
  787. else if (selectItem && selectItem.type == VectorType.BgImage) {
  788. if (geometry.vectorId == selectItem.vectorId) {
  789. this.context.lineWidth = 2/geometry.scale;
  790. this.context.strokeStyle = Style.Select.Tag.strokeStyle
  791. this.context.fillStyle = Style.Select.Tag.fillStyle
  792. this.context.strokeRect( -geometry.width*coordinate.ratio/2, -geometry.height*coordinate.ratio/2, geometry.width, geometry.height)
  793. }
  794. }
  795. // this.context.beginPath()
  796. // this.context.arc(0,0, 2 * coordinate.ratio, 0, Math.PI * 2, true)
  797. // this.context.stroke()
  798. // this.context.fill()
  799. this.context.restore()
  800. }
  801. }
  802. drawCustomImage(geometry){
  803. if(geometry.url != null){
  804. const pt = coordinate.getScreenXY(geometry.center)
  805. this.context.save()
  806. this.context.translate(pt.x, pt.y)
  807. this.context.scale(geometry.scale,geometry.scale)
  808. this.context.translate(-1*geometry.ratio*geometry.width/2*coordinate.ratio, -1*geometry.ratio*geometry.height/2*coordinate.ratio)
  809. this.context.rotate((geometry.angle / 180) * Math.PI)
  810. this.context.translate(geometry.ratio*geometry.width/2*coordinate.ratio, geometry.ratio*geometry.height/2*coordinate.ratio)
  811. if(geometry.image == null)
  812. {
  813. var img = new Image()
  814. img.src = geometry.url;
  815. img.crossOrigin=""
  816. img.onload = function () {
  817. this.context.drawImage(img, -img.width*coordinate.ratio, -img.height*coordinate.ratio)
  818. }.bind(this)
  819. geometry.image = img;
  820. }
  821. else{
  822. if(geometry.hasOwnProperty('width')){
  823. this.context.drawImage(geometry.image, -geometry.ratio * geometry.width*coordinate.ratio, -geometry.ratio * geometry.height*coordinate.ratio,geometry.ratio * geometry.width*coordinate.ratio, geometry.ratio * geometry.height*coordinate.ratio)
  824. }
  825. else{
  826. this.context.drawImage(geometry.image, -geometry.ratio * geometry.width*coordinate.ratio, -geometry.ratio * geometry.height*coordinate.ratio,geometry.ratio * geometry.width*coordinate.ratio, geometry.ratio * geometry.height*coordinate.ratio)
  827. }
  828. }
  829. const focusItem = stateService.getFocusItem()
  830. const selectItem = stateService.getSelectItem()
  831. if (focusItem && focusItem.type == VectorType.CustomImage) {
  832. if (geometry.vectorId == focusItem.vectorId) {
  833. this.context.lineWidth = 2/geometry.scale;
  834. this.context.strokeStyle = Style.Select.Tag.strokeStyle
  835. this.context.fillStyle = Style.Select.Tag.fillStyle
  836. this.context.strokeRect( -geometry.ratio * geometry.width, -geometry.ratio * geometry.height, geometry.ratio * geometry.width, geometry.ratio * geometry.height)
  837. }
  838. }
  839. else if (selectItem && selectItem.type == VectorType.CustomImage) {
  840. if (geometry.vectorId == selectItem.vectorId) {
  841. this.context.lineWidth = 2/geometry.scale;
  842. this.context.strokeStyle = Style.Select.Tag.strokeStyle
  843. this.context.fillStyle = Style.Select.Tag.fillStyle
  844. this.context.strokeRect( -geometry.ratio * geometry.width, -geometry.ratio * geometry.height, geometry.ratio * geometry.width, geometry.ratio * geometry.height)
  845. }
  846. }
  847. this.context.restore()
  848. // this.context.save()
  849. // if(geometry.points.length>1){
  850. // this.context.strokeStyle = 'red'
  851. // this.context.lineWidth = 4
  852. // let p0 = coordinate.getScreenXY(geometry.points[0])
  853. // let p1 = coordinate.getScreenXY(geometry.points[1])
  854. // let p2 = coordinate.getScreenXY(geometry.points[2])
  855. // let p3 = coordinate.getScreenXY(geometry.points[3])
  856. // this.context.beginPath()
  857. // this.context.moveTo(p0.x,p0.y);
  858. // this.context.lineTo(p3.x,p3.y);
  859. // this.context.lineTo(p2.x,p2.y);
  860. // this.context.lineTo(p1.x,p1.y);
  861. // this.context.closePath()
  862. // this.context.stroke();
  863. // }
  864. // this.context.restore()
  865. // this.context.beginPath()
  866. // this.context.arc(pt.x-geometry.ratio * geometry.width/4*geometry.scale, pt.y-geometry.ratio * geometry.height/4*geometry.scale, 2 * coordinate.ratio, 0, Math.PI * 2, true)
  867. // this.context.stroke()
  868. // this.context.fill()
  869. // this.context.restore()
  870. }
  871. }
  872. drawCompass(geometry){
  873. this.context.save()
  874. this.context.strokeStyle = Style.Compass.strokeStyle
  875. this.context.fillStyle = Style.Compass.fillStyle
  876. const selectItem = stateService.getSelectItem()
  877. const draggingItem = stateService.getDraggingItem()
  878. const focusItem = stateService.getFocusItem()
  879. if (selectItem && selectItem.type == VectorType.Compass) {
  880. if (geometry.vectorId == selectItem.vectorId) {
  881. this.context.strokeStyle = Style.Select.Compass.strokeStyle
  882. this.context.fillStyle = Style.Select.Compass.fillStyle
  883. }
  884. } else if (draggingItem && draggingItem.type == VectorType.Compass) {
  885. if (geometry.vectorId == draggingItem.vectorId) {
  886. this.context.strokeStyle = Style.Select.Compass.strokeStyle
  887. this.context.fillStyle = Style.Select.Compass.fillStyle
  888. }
  889. }
  890. if (focusItem && focusItem.type == VectorType.Compass) {
  891. if (geometry.vectorId == focusItem.vectorId) {
  892. this.context.strokeStyle = Style.Focus.Compass.strokeStyle
  893. this.context.fillStyle = Style.Focus.Compass.fillStyle
  894. }
  895. }
  896. this.context.translate(geometry.center.x*coordinate.ratio,geometry.center.y*coordinate.ratio)
  897. this.context.scale(coordinate.ratio,coordinate.ratio)
  898. this.context.translate(16, 36)
  899. this.context.rotate((geometry.angle)/180 * Math.PI)
  900. this.context.translate(-16, -36)
  901. //this.context.translate(18,26)
  902. this.context.lineWidth = 1
  903. this.context.miterLimit=4;
  904. this.context.font="15px ''";
  905. this.context.beginPath();
  906. this.context.moveTo(12.5221,3.262);
  907. this.context.lineTo(8.93807,3.262);
  908. this.context.lineTo(8.93807,4.284);
  909. this.context.lineTo(12.5221,4.284);
  910. this.context.lineTo(12.5221,8.204);
  911. this.context.bezierCurveTo(11.0241,8.778,9.54007,9.352,8.51807,9.688);
  912. this.context.lineTo(8.99407,10.724);
  913. this.context.bezierCurveTo(10.0021,10.304,11.2761,9.786,12.5221,9.24);
  914. this.context.lineTo(12.5221,12.334);
  915. this.context.lineTo(13.5861,12.334);
  916. this.context.lineTo(13.5861,0);
  917. this.context.lineTo(12.5221,0);
  918. this.context.lineTo(12.5221,3.262);
  919. this.context.closePath();
  920. this.context.moveTo(17.6881,11.13);
  921. this.context.bezierCurveTo(17.0721,11.13,16.9601,11.004,16.9601,10.29);
  922. this.context.lineTo(16.9601,5.726);
  923. this.context.bezierCurveTo(18.4581,4.9,20.0821,3.934,21.2581,2.982);
  924. this.context.lineTo(20.4181,2.114);
  925. this.context.bezierCurveTo(19.5781,2.912,18.2621,3.85,16.9601,4.648);
  926. this.context.lineTo(16.9601,0);
  927. this.context.lineTo(15.8961,0);
  928. this.context.lineTo(15.8961,10.276);
  929. this.context.bezierCurveTo(15.8961,11.746,16.2741,12.152,17.5901,12.152);
  930. this.context.lineTo(19.7741,12.152);
  931. this.context.bezierCurveTo(21.1321,12.152,21.4261,11.27,21.5521,8.722);
  932. this.context.bezierCurveTo(21.2581,8.652,20.8241,8.442,20.5441,8.232);
  933. this.context.bezierCurveTo(20.4461,10.556,20.3481,11.13,19.6901,11.13);
  934. this.context.lineTo(17.6881,11.13);
  935. this.context.closePath();
  936. this.context.fill();
  937. this.context.stroke();
  938. this.context.beginPath();
  939. this.context.moveTo(24.8494,49.3321);
  940. this.context.lineTo(28.7452,51);
  941. this.context.lineTo(27.3498,47.2775);
  942. this.context.bezierCurveTo(30.224,44.385,32,40.3999,32,36);
  943. this.context.bezierCurveTo(32,27.5465,25.4442,20.6242,17.1394,20.0399);
  944. this.context.lineTo(15.9998,17);
  945. this.context.lineTo(14.8602,20.04);
  946. this.context.bezierCurveTo(6.55559,20.6245,0,27.5467,0,36);
  947. this.context.bezierCurveTo(0,40.3998,1.77588,44.3847,4.64993,47.2772);
  948. this.context.lineTo(3.25439,51);
  949. this.context.lineTo(7.15046,49.3319);
  950. this.context.bezierCurveTo(9.68503,51.0177,12.7278,52,16,52);
  951. this.context.bezierCurveTo(19.2721,52,22.3148,51.0178,24.8494,49.3321);
  952. this.context.closePath();
  953. this.context.moveTo(26.5656,45.1856);
  954. this.context.lineTo(17.9232,22.131);
  955. this.context.bezierCurveTo(24.7452,23.0683,30,28.9205,30,36);
  956. this.context.bezierCurveTo(30,39.5148,28.7048,42.7271,26.5656,45.1856);
  957. this.context.closePath();
  958. this.context.moveTo(14.0763,22.1311);
  959. this.context.lineTo(5.43414,45.1852);
  960. this.context.bezierCurveTo(3.29512,42.7268,2,39.5146,2,36);
  961. this.context.bezierCurveTo(2,28.9206,7.25457,23.0685,14.0763,22.1311);
  962. this.context.closePath();
  963. this.context.moveTo(7.43459,47.0749);
  964. this.context.bezierCurveTo(7.28407,46.9583,7.13599,46.8387,6.99045,46.7162);
  965. this.context.lineTo(15,25.3497);
  966. this.context.lineTo(15,43.8358);
  967. this.context.lineTo(7.43459,47.0749);
  968. this.context.closePath();
  969. this.context.moveTo(9.4198,48.3604);
  970. this.context.lineTo(15.9998,45.5432);
  971. this.context.lineTo(22.58,48.3605);
  972. this.context.bezierCurveTo(20.6184,49.4069,18.3785,50,16,50);
  973. this.context.bezierCurveTo(13.6214,50,11.3814,49.4068,9.4198,48.3604);
  974. this.context.closePath();
  975. this.context.fill();
  976. this.context.stroke();
  977. this.context.restore();
  978. this.context.save()
  979. this.context.font = 12*coordinate.ratio+`px Microsoft YaHei`
  980. let value = '角度:'+geometry.angle + '°';
  981. let fontWidth = this.context.measureText(value).width
  982. this.context.fillText(value, (geometry.center.x*coordinate.ratio-fontWidth/5), (geometry.center.y+85)*coordinate.ratio)
  983. this.context.restore()
  984. }
  985. setCanvasStyle(style) {
  986. for (const key in style) {
  987. if (key != 'isFill' && key != 'isStroke') {
  988. this.context[key] = style[key]
  989. }
  990. }
  991. }
  992. /*************************************************************************************家具**********************************************************************************************/
  993. drawSign(geometry) {
  994. if (geometry.geoType == VectorType.Cigaret) {
  995. this.drawCigaret(geometry)
  996. this.drawTestCircle(geometry)
  997. } else if (geometry.geoType == VectorType.FirePoint) {
  998. this.drawFirePoint(geometry)
  999. this.drawTestCircle(geometry)
  1000. } else if (geometry.geoType == VectorType.LeftFootPrint) {
  1001. this.drawLeftFootPrint(geometry)
  1002. this.drawTestCircle(geometry)
  1003. } else if (geometry.geoType == VectorType.RightFootPrint) {
  1004. this.drawRightFootPrint(geometry)
  1005. this.drawTestCircle(geometry)
  1006. } else if (geometry.geoType == VectorType.LeftShoePrint) {
  1007. this.drawLeftShoePrint(geometry)
  1008. this.drawTestCircle(geometry)
  1009. } else if (geometry.geoType == VectorType.RightShoePrint) {
  1010. this.drawRightShoePrint(geometry)
  1011. this.drawTestCircle(geometry)
  1012. } else if (geometry.geoType == VectorType.FingerPrint) {
  1013. this.drawFingerPrint(geometry)
  1014. this.drawTestCircle(geometry)
  1015. } else if (geometry.geoType == VectorType.DeadBody) {
  1016. this.drawDeadBody(geometry)
  1017. this.drawTestCircle(geometry)
  1018. } else if (geometry.geoType == VectorType.BloodStain) {
  1019. this.drawBloodStain(geometry)
  1020. this.drawTestCircle(geometry)
  1021. }
  1022. }
  1023. drawTestCircle(geometry) {
  1024. // let radius = 0.1 * coordinate.res
  1025. // const twoPi = Math.PI * 2
  1026. // const center = coordinate.getScreenXY(geometry.center)
  1027. // this.context.save()
  1028. // this.context.strokeStyle = 'blue'
  1029. // this.context.fillStyle = 'red'
  1030. // this.context.beginPath()
  1031. // this.context.arc(center.x, center.y, radius, 0, twoPi, true)
  1032. // this.context.stroke()
  1033. // this.context.fill()
  1034. // this.context.restore()
  1035. }
  1036. drawCigaret(geometry) {
  1037. const selectItem = stateService.getSelectItem()
  1038. const draggingItem = stateService.getDraggingItem()
  1039. const focusItem = stateService.getFocusItem()
  1040. this.context.save()
  1041. this.context.strokeStyle = Style.Sign.strokeStyle
  1042. this.context.fillStyle = "rgba(0,0,0,1)";
  1043. if (selectItem && selectItem.type == VectorType.Cigaret) {
  1044. if (geometry.vectorId == selectItem.vectorId) {
  1045. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1046. this.context.fillStyle = Style.Select.Sign.fillStyle
  1047. }
  1048. } else if (draggingItem && draggingItem.type == VectorType.Cigaret) {
  1049. if (geometry.vectorId == draggingItem.vectorId) {
  1050. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1051. this.context.fillStyle = Style.Select.Sign.fillStyle
  1052. }
  1053. }
  1054. if (focusItem && focusItem.type == VectorType.Cigaret) {
  1055. if (geometry.vectorId == focusItem.vectorId) {
  1056. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1057. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1058. }
  1059. }
  1060. const center = coordinate.getScreenXY({
  1061. x: geometry.center.x,
  1062. y: geometry.center.y,
  1063. })
  1064. const pt = coordinate.getScreenXY({
  1065. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1066. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1067. })
  1068. this.context.translate(center.x, center.y)
  1069. this.context.rotate((geometry.angle / 180) * Math.PI)
  1070. this.context.translate(pt.x - center.x, pt.y - center.y)
  1071. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
  1072. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1073. this.context.miterLimit = 4
  1074. this.context.font = "15px ''"
  1075. this.context.beginPath();
  1076. this.context.moveTo(38.6342,4);
  1077. this.context.bezierCurveTo(38.6342,4,41.1545,9.5,39.1546,12.5);
  1078. this.context.bezierCurveTo(37.1547,15.5,39.1546,19,39.1546,19);
  1079. this.context.bezierCurveTo(36.0776,15.923,34.9395,14,37.1547,10.5);
  1080. this.context.bezierCurveTo(39.3699,7,38.6342,4,38.6342,4);
  1081. this.context.closePath();
  1082. this.context.fill();
  1083. this.context.stroke();
  1084. this.context.beginPath();
  1085. this.context.moveTo(4,29);
  1086. this.context.bezierCurveTo(2.89543,29,2,29.8954,2,31);
  1087. this.context.lineTo(2,39);
  1088. this.context.bezierCurveTo(2,40.1046,2.89543,41,4,41);
  1089. this.context.lineTo(34,41);
  1090. this.context.lineTo(34,29);
  1091. this.context.lineTo(4,29);
  1092. this.context.closePath();
  1093. this.context.fill();
  1094. this.context.stroke();
  1095. this.context.beginPath();
  1096. this.context.moveTo(40.7714,20.5);
  1097. this.context.bezierCurveTo(38.7716,17.5,41.2918,12,41.2918,12);
  1098. this.context.bezierCurveTo(41.2918,12,40.5561,15,42.7713,18.5);
  1099. this.context.bezierCurveTo(44.9866,22,43.8485,23.923,40.7714,27);
  1100. this.context.bezierCurveTo(40.7714,27,42.7713,23.5,40.7714,20.5);
  1101. this.context.closePath();
  1102. this.context.fill();
  1103. this.context.stroke();
  1104. this.context.beginPath();
  1105. this.context.moveTo(37.5,29);
  1106. this.context.bezierCurveTo(36.6716,29,36,29.6716,36,30.5);
  1107. this.context.lineTo(36,39.5);
  1108. this.context.bezierCurveTo(36,40.3284,36.6716,41,37.5,41);
  1109. this.context.bezierCurveTo(38.3284,41,39,40.3284,39,39.5);
  1110. this.context.lineTo(39,30.5);
  1111. this.context.bezierCurveTo(39,29.6716,38.3284,29,37.5,29);
  1112. this.context.closePath();
  1113. this.context.fill();
  1114. this.context.stroke();
  1115. this.context.beginPath();
  1116. this.context.moveTo(42,29);
  1117. this.context.bezierCurveTo(41.1716,29,40.5,29.6716,40.5,30.5);
  1118. this.context.lineTo(40.5,39.5);
  1119. this.context.bezierCurveTo(40.5,40.3284,41.1716,41,42,41);
  1120. this.context.bezierCurveTo(42.8284,41,43.5,40.3284,43.5,39.5);
  1121. this.context.lineTo(43.5,30.5);
  1122. this.context.bezierCurveTo(43.5,29.6716,42.8284,29,42,29);
  1123. this.context.closePath();
  1124. this.context.fill();
  1125. this.context.stroke();
  1126. this.context.restore();
  1127. }
  1128. drawFirePoint(geometry) {
  1129. const selectItem = stateService.getSelectItem()
  1130. const draggingItem = stateService.getDraggingItem()
  1131. const focusItem = stateService.getFocusItem()
  1132. this.context.save()
  1133. this.context.strokeStyle="rgba(0,0,0,0)";
  1134. this.context.miterLimit=4;
  1135. this.context.font="15px ''";
  1136. this.context.fillStyle="rgba(255,77,79,1)";
  1137. if (selectItem && selectItem.type == VectorType.FirePoint) {
  1138. if (geometry.vectorId == selectItem.vectorId) {
  1139. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1140. this.context.fillStyle = Style.Select.Sign.fillStyle
  1141. }
  1142. } else if (draggingItem && draggingItem.type == VectorType.FirePoint) {
  1143. if (geometry.vectorId == draggingItem.vectorId) {
  1144. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1145. this.context.fillStyle = Style.Select.Sign.fillStyle
  1146. }
  1147. }
  1148. if (focusItem && focusItem.type == VectorType.FirePoint) {
  1149. if (geometry.vectorId == focusItem.vectorId) {
  1150. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1151. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1152. }
  1153. }
  1154. const center = coordinate.getScreenXY({
  1155. x: geometry.center.x,
  1156. y: geometry.center.y,
  1157. })
  1158. const pt = coordinate.getScreenXY({
  1159. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1160. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1161. })
  1162. this.context.translate(center.x, center.y)
  1163. this.context.rotate((geometry.angle / 180) * Math.PI)
  1164. this.context.translate(pt.x - center.x, pt.y - center.y)
  1165. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32*coordinate.ratio)
  1166. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1167. this.context.beginPath();
  1168. this.context.moveTo(6.15863,28.8837);
  1169. this.context.bezierCurveTo(4.84988,35.4972,11.9564,43.3721,15.8216,45);
  1170. this.context.bezierCurveTo(15.8216,45,13.2504,38.8,14.8553,34.7442);
  1171. this.context.bezierCurveTo(16.7879,29.8605,19.6868,25.9535,19.6868,25.9535);
  1172. this.context.bezierCurveTo(19.6868,25.9535,20.1699,26.9302,20.6531,28.8837);
  1173. this.context.bezierCurveTo(21.1363,30.8372,21.1363,31.3256,21.1363,31.3256);
  1174. this.context.bezierCurveTo(21.1363,31.3256,22.9249,29.2771,23.5519,27.4186);
  1175. this.context.bezierCurveTo(24.4676,24.7049,24.0351,20.093,24.0351,20.093);
  1176. this.context.bezierCurveTo(24.0351,20.093,29.8166,25.9798,31.2823,30.8372);
  1177. this.context.bezierCurveTo(32.8795,36.1307,30.7991,45,30.7991,45);
  1178. this.context.bezierCurveTo(30.7991,45,40.7338,38.6512,41.9116,29.8605);
  1179. this.context.bezierCurveTo(42.9992,21.7424,33.698,11.3023,33.698,11.3023);
  1180. this.context.bezierCurveTo(33.698,11.3023,34.148,13.8357,33.698,15.6977);
  1181. this.context.bezierCurveTo(33.3976,16.9405,32.2486,18.6279,32.2486,18.6279);
  1182. this.context.bezierCurveTo(32.2486,18.6279,30.7991,13.884,27.9004,9.83721);
  1183. this.context.bezierCurveTo(25.5478,6.55294,20.6531,3,20.6531,3);
  1184. this.context.bezierCurveTo(20.6531,3,20.6531,9.34884,19.2037,13.7442);
  1185. this.context.bezierCurveTo(17.7542,18.1395,12.9227,22.5349,12.9227,22.5349);
  1186. this.context.lineTo(11.4733,15.2093);
  1187. this.context.bezierCurveTo(10.0238,17.9767,7.12508,24,6.15863,28.8837);
  1188. this.context.closePath();
  1189. this.context.fill();
  1190. this.context.stroke();
  1191. this.context.restore();
  1192. }
  1193. drawLeftFootPrint(geometry) {
  1194. const selectItem = stateService.getSelectItem()
  1195. const draggingItem = stateService.getDraggingItem()
  1196. const focusItem = stateService.getFocusItem()
  1197. this.context.save()
  1198. this.context.strokeStyle="rgba(0,0,0,0)";
  1199. this.context.miterLimit=4;
  1200. this.context.font="15px ''";
  1201. this.context.fillStyle="rgba(0,0,0,1)";
  1202. if (selectItem && selectItem.type == VectorType.LeftFootPrint) {
  1203. if (geometry.vectorId == selectItem.vectorId) {
  1204. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1205. this.context.fillStyle = Style.Select.Sign.fillStyle
  1206. }
  1207. } else if (draggingItem && draggingItem.type == VectorType.LeftFootPrint) {
  1208. if (geometry.vectorId == draggingItem.vectorId) {
  1209. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1210. this.context.fillStyle = Style.Select.Sign.fillStyle
  1211. }
  1212. }
  1213. if (focusItem && focusItem.type == VectorType.LeftFootPrint) {
  1214. if (geometry.vectorId == focusItem.vectorId) {
  1215. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1216. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1217. }
  1218. }
  1219. const center = coordinate.getScreenXY({
  1220. x: geometry.center.x,
  1221. y: geometry.center.y,
  1222. })
  1223. const pt = coordinate.getScreenXY({
  1224. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1225. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1226. })
  1227. this.context.translate(center.x, center.y)
  1228. this.context.rotate((geometry.angle / 180) * Math.PI)
  1229. this.context.translate(pt.x - center.x, pt.y - center.y)
  1230. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
  1231. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1232. this.context.beginPath();
  1233. this.context.moveTo(26.5,7);
  1234. this.context.bezierCurveTo(25.1193,7,24,5.88071,24,4.5);
  1235. this.context.bezierCurveTo(24,3.11929,25.1193,2,26.5,2);
  1236. this.context.bezierCurveTo(27.8807,2,29,3.11929,29,4.5);
  1237. this.context.bezierCurveTo(29,5.88071,27.8807,7,26.5,7);
  1238. this.context.closePath();
  1239. this.context.fill();
  1240. this.context.stroke();
  1241. this.context.beginPath();
  1242. this.context.moveTo(32,12);
  1243. this.context.bezierCurveTo(30.3431,12,29,10.6569,29,9);
  1244. this.context.bezierCurveTo(29,7.34315,30.3431,6,32,6);
  1245. this.context.bezierCurveTo(33.6569,6,35,7.34315,35,9);
  1246. this.context.bezierCurveTo(35,10.6569,33.6569,12,32,12);
  1247. this.context.closePath();
  1248. this.context.fill();
  1249. this.context.stroke();
  1250. this.context.beginPath();
  1251. this.context.moveTo(18,5);
  1252. this.context.bezierCurveTo(18,6.10457,18.8954,7,20,7);
  1253. this.context.bezierCurveTo(21.1046,7,22,6.10457,22,5);
  1254. this.context.bezierCurveTo(22,3.89543,21.1046,3,20,3);
  1255. this.context.bezierCurveTo(18.8954,3,18,3.89543,18,5);
  1256. this.context.closePath();
  1257. this.context.fill();
  1258. this.context.stroke();
  1259. this.context.beginPath();
  1260. this.context.moveTo(15,10);
  1261. this.context.bezierCurveTo(13.8954,10,13,9.10457,13,8);
  1262. this.context.bezierCurveTo(13,6.89543,13.8954,6,15,6);
  1263. this.context.bezierCurveTo(16.1046,6,17,6.89543,17,8);
  1264. this.context.bezierCurveTo(17,9.10457,16.1046,10,15,10);
  1265. this.context.closePath();
  1266. this.context.fill();
  1267. this.context.stroke();
  1268. this.context.beginPath();
  1269. this.context.moveTo(10,12.5);
  1270. this.context.bezierCurveTo(10,13.3284,10.6716,14,11.5,14);
  1271. this.context.bezierCurveTo(12.3284,14,13,13.3284,13,12.5);
  1272. this.context.bezierCurveTo(13,11.6716,12.3284,11,11.5,11);
  1273. this.context.bezierCurveTo(10.6716,11,10,11.6716,10,12.5);
  1274. this.context.closePath();
  1275. this.context.fill();
  1276. this.context.stroke();
  1277. this.context.beginPath();
  1278. this.context.moveTo(29.0721,31.5068);
  1279. this.context.bezierCurveTo(29.0721,31.5068,28.037,29.0085,29.0721,27.2243);
  1280. this.context.bezierCurveTo(30.1072,25.4402,30.9125,23.8936,31.6392,20.6224);
  1281. this.context.bezierCurveTo(32.3658,17.3511,30.3143,9.73826,22.1998,10.0059);
  1282. this.context.bezierCurveTo(14.0852,10.2735,13.2572,17.4108,13.0088,21.4254);
  1283. this.context.bezierCurveTo(12.7604,25.44,17.8113,38.0193,21.4544,42.1233);
  1284. this.context.bezierCurveTo(25.0975,46.2273,27.6647,46.5838,29.9831,45.424);
  1285. this.context.bezierCurveTo(32.3016,44.2642,33.3778,42.5692,32.881,40.4282);
  1286. this.context.bezierCurveTo(32.3842,38.2873,29.0721,31.5068,29.0721,31.5068);
  1287. this.context.closePath();
  1288. this.context.fill();
  1289. this.context.stroke();
  1290. this.context.restore();
  1291. }
  1292. drawRightFootPrint(geometry) {
  1293. const selectItem = stateService.getSelectItem()
  1294. const draggingItem = stateService.getDraggingItem()
  1295. const focusItem = stateService.getFocusItem()
  1296. this.context.save()
  1297. this.context.strokeStyle="rgba(0,0,0,0)";
  1298. this.context.miterLimit=4;
  1299. this.context.font="15px ''";
  1300. this.context.fillStyle="rgba(0,0,0,1)";
  1301. if (selectItem && selectItem.type == VectorType.RightFootPrint) {
  1302. if (geometry.vectorId == selectItem.vectorId) {
  1303. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1304. this.context.fillStyle = Style.Select.Sign.fillStyle
  1305. }
  1306. } else if (draggingItem && draggingItem.type == VectorType.RightFootPrint) {
  1307. if (geometry.vectorId == draggingItem.vectorId) {
  1308. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1309. this.context.fillStyle = Style.Select.Sign.fillStyle
  1310. }
  1311. }
  1312. if (focusItem && focusItem.type == VectorType.RightFootPrint) {
  1313. if (geometry.vectorId == focusItem.vectorId) {
  1314. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1315. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1316. }
  1317. }
  1318. const center = coordinate.getScreenXY({
  1319. x: geometry.center.x,
  1320. y: geometry.center.y,
  1321. })
  1322. const pt = coordinate.getScreenXY({
  1323. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1324. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1325. })
  1326. this.context.translate(center.x, center.y)
  1327. this.context.rotate((geometry.angle / 180) * Math.PI)
  1328. this.context.translate(pt.x - center.x, pt.y - center.y)
  1329. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
  1330. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1331. this.context.beginPath();
  1332. this.context.moveTo(18.5,7);
  1333. this.context.bezierCurveTo(19.8807,7,21,5.88071,21,4.5);
  1334. this.context.bezierCurveTo(21,3.11929,19.8807,2,18.5,2);
  1335. this.context.bezierCurveTo(17.1193,2,16,3.11929,16,4.5);
  1336. this.context.bezierCurveTo(16,5.88071,17.1193,7,18.5,7);
  1337. this.context.closePath();
  1338. this.context.fill();
  1339. this.context.stroke();
  1340. this.context.beginPath();
  1341. this.context.moveTo(13,12);
  1342. this.context.bezierCurveTo(14.6569,12,16,10.6569,16,9);
  1343. this.context.bezierCurveTo(16,7.34315,14.6569,6,13,6);
  1344. this.context.bezierCurveTo(11.3431,6,10,7.34315,10,9);
  1345. this.context.bezierCurveTo(10,10.6569,11.3431,12,13,12);
  1346. this.context.closePath();
  1347. this.context.fill();
  1348. this.context.stroke();
  1349. this.context.beginPath();
  1350. this.context.moveTo(27,5);
  1351. this.context.bezierCurveTo(27,6.10457,26.1046,7,25,7);
  1352. this.context.bezierCurveTo(23.8954,7,23,6.10457,23,5);
  1353. this.context.bezierCurveTo(23,3.89543,23.8954,3,25,3);
  1354. this.context.bezierCurveTo(26.1046,3,27,3.89543,27,5);
  1355. this.context.closePath();
  1356. this.context.fill();
  1357. this.context.stroke();
  1358. this.context.beginPath();
  1359. this.context.moveTo(30,10);
  1360. this.context.bezierCurveTo(31.1046,10,32,9.10457,32,8);
  1361. this.context.bezierCurveTo(32,6.89543,31.1046,6,30,6);
  1362. this.context.bezierCurveTo(28.8954,6,28,6.89543,28,8);
  1363. this.context.bezierCurveTo(28,9.10457,28.8954,10,30,10);
  1364. this.context.closePath();
  1365. this.context.fill();
  1366. this.context.stroke();
  1367. this.context.beginPath();
  1368. this.context.moveTo(35,12.5);
  1369. this.context.bezierCurveTo(35,13.3284,34.3284,14,33.5,14);
  1370. this.context.bezierCurveTo(32.6716,14,32,13.3284,32,12.5);
  1371. this.context.bezierCurveTo(32,11.6716,32.6716,11,33.5,11);
  1372. this.context.bezierCurveTo(34.3284,11,35,11.6716,35,12.5);
  1373. this.context.closePath();
  1374. this.context.fill();
  1375. this.context.stroke();
  1376. this.context.beginPath();
  1377. this.context.moveTo(15.9279,31.5068);
  1378. this.context.bezierCurveTo(15.9279,31.5068,16.963,29.0085,15.9279,27.2243);
  1379. this.context.bezierCurveTo(14.8928,25.4402,14.0875,23.8936,13.3608,20.6224);
  1380. this.context.bezierCurveTo(12.6342,17.3511,14.6857,9.73826,22.8002,10.0059);
  1381. this.context.bezierCurveTo(30.9148,10.2735,31.7428,17.4108,31.9912,21.4254);
  1382. this.context.bezierCurveTo(32.2396,25.44,27.1887,38.0193,23.5456,42.1233);
  1383. this.context.bezierCurveTo(19.9025,46.2273,17.3353,46.5838,15.0169,45.424);
  1384. this.context.bezierCurveTo(12.6984,44.2642,11.6222,42.5692,12.119,40.4282);
  1385. this.context.bezierCurveTo(12.6158,38.2873,15.9279,31.5068,15.9279,31.5068);
  1386. this.context.closePath();
  1387. this.context.fill();
  1388. this.context.stroke();
  1389. this.context.restore();
  1390. }
  1391. drawLeftShoePrint(geometry) {
  1392. const selectItem = stateService.getSelectItem()
  1393. const draggingItem = stateService.getDraggingItem()
  1394. const focusItem = stateService.getFocusItem()
  1395. this.context.save()
  1396. this.context.strokeStyle="rgba(0,0,0,0)";
  1397. this.context.miterLimit=4;
  1398. this.context.fillStyle="rgba(0,0,0,1)";
  1399. this.context.font=" 15px ''";
  1400. if (selectItem && selectItem.type == VectorType.LeftShoePrint) {
  1401. if (geometry.vectorId == selectItem.vectorId) {
  1402. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1403. this.context.fillStyle = Style.Select.Sign.fillStyle
  1404. }
  1405. } else if (draggingItem && draggingItem.type == VectorType.LeftShoePrint) {
  1406. if (geometry.vectorId == draggingItem.vectorId) {
  1407. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1408. this.context.fillStyle = Style.Select.Sign.fillStyle
  1409. }
  1410. }
  1411. if (focusItem && focusItem.type == VectorType.LeftShoePrint) {
  1412. if (geometry.vectorId == focusItem.vectorId) {
  1413. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1414. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1415. }
  1416. }
  1417. const center = coordinate.getScreenXY({
  1418. x: geometry.center.x,
  1419. y: geometry.center.y,
  1420. })
  1421. const pt = coordinate.getScreenXY({
  1422. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1423. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1424. })
  1425. this.context.translate(center.x, center.y)
  1426. this.context.rotate((geometry.angle / 180) * Math.PI)
  1427. this.context.translate(pt.x - center.x, pt.y - center.y)
  1428. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
  1429. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1430. this.context.beginPath();
  1431. this.context.moveTo(29.9064,30.2635);
  1432. this.context.lineTo(18.3897,31.999);
  1433. this.context.bezierCurveTo(18.3897,31.999,14,24.0766,14,18.5101);
  1434. this.context.bezierCurveTo(14,9.43774,16.8732,1.75238,22.3803,2.00508);
  1435. this.context.bezierCurveTo(28.3968,2.28117,31,9.00467,31,15.3264);
  1436. this.context.bezierCurveTo(31,18.8919,30.7015,20.0653,29.9867,22.8753);
  1437. this.context.bezierCurveTo(29.7961,23.6244,29.5759,24.4898,29.3239,25.5478);
  1438. this.context.bezierCurveTo(28.9957,26.926,29.9064,30.2635,29.9064,30.2635);
  1439. this.context.closePath();
  1440. this.context.fill();
  1441. this.context.stroke();
  1442. this.context.beginPath();
  1443. this.context.moveTo(30.5,34);
  1444. this.context.lineTo(19,35.4383);
  1445. this.context.bezierCurveTo(19,35.4383,19.316,39.7531,19.8057,42.3198);
  1446. this.context.bezierCurveTo(20.2953,44.8865,22.9828,46.465,26.2418,45.8773);
  1447. this.context.bezierCurveTo(29.5007,45.2895,32.4426,43.1091,31.9447,40.287);
  1448. this.context.bezierCurveTo(31.4469,37.4649,30.5,34,30.5,34);
  1449. this.context.closePath();
  1450. this.context.fill();
  1451. this.context.stroke();
  1452. this.context.restore();
  1453. }
  1454. drawRightShoePrint(geometry) {
  1455. const selectItem = stateService.getSelectItem()
  1456. const draggingItem = stateService.getDraggingItem()
  1457. const focusItem = stateService.getFocusItem()
  1458. this.context.save()
  1459. this.context.strokeStyle="rgba(0,0,0,0)";
  1460. this.context.miterLimit=4;
  1461. this.context.font="15px ''";
  1462. this.context.fillStyle="rgba(0,0,0,1)";
  1463. if (selectItem && selectItem.type == VectorType.RightShoePrint) {
  1464. if (geometry.vectorId == selectItem.vectorId) {
  1465. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1466. this.context.fillStyle = Style.Select.Sign.fillStyle
  1467. }
  1468. } else if (draggingItem && draggingItem.type == VectorType.RightShoePrint) {
  1469. if (geometry.vectorId == draggingItem.vectorId) {
  1470. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1471. this.context.fillStyle = Style.Select.Sign.fillStyle
  1472. }
  1473. }
  1474. if (focusItem && focusItem.type == VectorType.RightShoePrint) {
  1475. if (geometry.vectorId == focusItem.vectorId) {
  1476. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1477. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1478. }
  1479. }
  1480. const center = coordinate.getScreenXY({
  1481. x: geometry.center.x,
  1482. y: geometry.center.y,
  1483. })
  1484. const pt = coordinate.getScreenXY({
  1485. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1486. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1487. })
  1488. this.context.translate(center.x, center.y)
  1489. this.context.rotate((geometry.angle / 180) * Math.PI)
  1490. this.context.translate(pt.x - center.x, pt.y - center.y)
  1491. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
  1492. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1493. this.context.beginPath();
  1494. this.context.moveTo(16.0936,30.2635);
  1495. this.context.lineTo(27.6103,31.999);
  1496. this.context.bezierCurveTo(27.6103,31.999,32,24.0766,32,18.5101);
  1497. this.context.bezierCurveTo(32,9.43774,29.1268,1.75238,23.6197,2.00508);
  1498. this.context.bezierCurveTo(17.6032,2.28117,15,9.00467,15,15.3264);
  1499. this.context.bezierCurveTo(15,18.8919,15.2985,20.0653,16.0133,22.8753);
  1500. this.context.bezierCurveTo(16.2039,23.6244,16.4241,24.4898,16.6761,25.5478);
  1501. this.context.bezierCurveTo(17.0043,26.926,16.0936,30.2635,16.0936,30.2635);
  1502. this.context.closePath();
  1503. this.context.fill();
  1504. this.context.stroke();
  1505. this.context.beginPath();
  1506. this.context.moveTo(15.5,34);
  1507. this.context.lineTo(27,35.4383);
  1508. this.context.bezierCurveTo(27,35.4383,26.684,39.7531,26.1943,42.3198);
  1509. this.context.bezierCurveTo(25.7047,44.8865,23.0172,46.465,19.7582,45.8773);
  1510. this.context.bezierCurveTo(16.4993,45.2895,13.5574,43.1091,14.0553,40.287);
  1511. this.context.bezierCurveTo(14.5531,37.4649,15.5,34,15.5,34);
  1512. this.context.closePath();
  1513. this.context.fill();
  1514. this.context.stroke();
  1515. this.context.restore();
  1516. }
  1517. drawFingerPrint(geometry) {
  1518. const selectItem = stateService.getSelectItem()
  1519. const draggingItem = stateService.getDraggingItem()
  1520. const focusItem = stateService.getFocusItem()
  1521. this.context.save()
  1522. this.context.strokeStyle="rgba(0,0,0,0)";
  1523. this.context.miterLimit=4;
  1524. this.context.font="15px ''";
  1525. this.context.fillStyle="rgba(0,0,0,1)";
  1526. if (selectItem && selectItem.type == VectorType.FingerPrint) {
  1527. if (geometry.vectorId == selectItem.vectorId) {
  1528. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1529. this.context.fillStyle = Style.Select.Sign.fillStyle
  1530. }
  1531. } else if (draggingItem && draggingItem.type == VectorType.FingerPrint) {
  1532. if (geometry.vectorId == draggingItem.vectorId) {
  1533. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1534. this.context.fillStyle = Style.Select.Sign.fillStyle
  1535. }
  1536. }
  1537. if (focusItem && focusItem.type == VectorType.FingerPrint) {
  1538. if (geometry.vectorId == focusItem.vectorId) {
  1539. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1540. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1541. }
  1542. }
  1543. const center = coordinate.getScreenXY({
  1544. x: geometry.center.x,
  1545. y: geometry.center.y,
  1546. })
  1547. const pt = coordinate.getScreenXY({
  1548. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1549. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1550. })
  1551. this.context.translate(center.x, center.y)
  1552. this.context.rotate((geometry.angle / 180) * Math.PI)
  1553. this.context.translate(pt.x - center.x, pt.y - center.y)
  1554. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
  1555. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1556. this.context.beginPath();
  1557. this.context.moveTo(43.4999,21.5);
  1558. this.context.bezierCurveTo(43.4999,16.542,39.7109,10.8816,34.1276,7.63537);
  1559. this.context.bezierCurveTo(28.4657,4.34348,20.8249,3.43868,12.9856,8.14233);
  1560. this.context.bezierCurveTo(6.24753,12.1852,4.43294,18.9936,4.70686,25.2575);
  1561. this.context.bezierCurveTo(4.97928,31.4873,7.31395,37.4063,9.18082,40.0733);
  1562. this.context.bezierCurveTo(9.49752,40.5258,10.121,40.6358,10.5735,40.3191);
  1563. this.context.bezierCurveTo(11.026,40.0024,11.136,39.3789,10.8193,38.9265);
  1564. this.context.bezierCurveTo(9.18619,36.5933,6.96197,31.0477,6.70495,25.1701);
  1565. this.context.bezierCurveTo(6.44942,19.3268,8.13483,13.3852,14.0146,9.85731);
  1566. this.context.bezierCurveTo(21.1752,5.56085,28.0343,6.40615,33.1223,9.36438);
  1567. this.context.bezierCurveTo(38.289,12.3683,41.4999,17.458,41.4999,21.5);
  1568. this.context.bezierCurveTo(41.4999,24.6008,40.785,26.4882,39.8962,27.6385);
  1569. this.context.bezierCurveTo(39.0131,28.7814,37.8743,29.3053,36.8039,29.5194);
  1570. this.context.bezierCurveTo(33.9357,30.0933,31.4302,27.9399,30.9899,24.8585);
  1571. this.context.bezierCurveTo(30.438,20.9948,27.6176,17.4999,23,17.4999);
  1572. this.context.bezierCurveTo(20.6398,17.4999,18.5331,18.6977,17.4181,20.9277);
  1573. this.context.bezierCurveTo(16.3192,23.1255,16.2513,26.1767,17.5583,29.8362);
  1574. this.context.bezierCurveTo(18.5365,32.5753,20.7176,35.1665,22.999,37.2483);
  1575. this.context.bezierCurveTo(25.2933,39.3417,27.7947,41.0153,29.5528,41.8943);
  1576. this.context.bezierCurveTo(30.0468,42.1413,30.6474,41.9411,30.8944,41.4471);
  1577. this.context.bezierCurveTo(31.1414,40.9531,30.9412,40.3525,30.4472,40.1055);
  1578. this.context.bezierCurveTo(28.8719,39.3178,26.5208,37.7543,24.3471,35.7709);
  1579. this.context.bezierCurveTo(22.1606,33.7757,20.2584,31.4503,19.4417,29.1636);
  1580. this.context.bezierCurveTo(18.2488,25.8233,18.4309,23.3744,19.207,21.8222);
  1581. this.context.bezierCurveTo(19.9669,20.3022,21.3602,19.4999,23,19.4999);
  1582. this.context.bezierCurveTo(26.3823,19.4999,28.562,22.0051,29.01,25.1413);
  1583. this.context.bezierCurveTo(29.5699,29.0599,32.9258,32.3349,37.1962,31.4806);
  1584. this.context.bezierCurveTo(38.6259,31.1946,40.237,30.4684,41.4788,28.8614);
  1585. this.context.bezierCurveTo(42.7149,27.2617,43.4999,24.8992,43.4999,21.5);
  1586. this.context.closePath();
  1587. this.context.fill();
  1588. this.context.stroke();
  1589. this.context.beginPath();
  1590. this.context.moveTo(28.3137,13.9002);
  1591. this.context.bezierCurveTo(24.531,12.0661,19.8915,12.2936,16.2281,16.1858);
  1592. this.context.bezierCurveTo(12.5481,20.0959,12.3111,24.8487,13.7047,29.4641);
  1593. this.context.bezierCurveTo(15.1069,34.1077,18.1345,38.4781,20.738,41.3257);
  1594. this.context.bezierCurveTo(21.1106,41.7333,21.0823,42.3658,20.6747,42.7385);
  1595. this.context.bezierCurveTo(20.2671,43.1112,19.6346,43.0828,19.2619,42.6752);
  1596. this.context.bezierCurveTo(16.5321,39.6895,13.3063,35.0635,11.7901,30.0422);
  1597. this.context.bezierCurveTo(10.2654,24.9927,10.445,19.4122,14.7717,14.8151);
  1598. this.context.bezierCurveTo(19.1085,10.2073,24.719,9.93463,29.1863,12.1005);
  1599. this.context.bezierCurveTo(33.601,14.241,36.9999,18.8096,36.9999,24.0005);
  1600. this.context.bezierCurveTo(36.9999,24.5528,36.5522,25.0005,35.9999,25.0005);
  1601. this.context.bezierCurveTo(35.4477,25.0005,34.9999,24.5528,34.9999,24.0005);
  1602. this.context.bezierCurveTo(34.9999,19.6911,32.1489,15.7597,28.3137,13.9002);
  1603. this.context.closePath();
  1604. this.context.fill();
  1605. this.context.stroke();
  1606. this.context.beginPath();
  1607. this.context.moveTo(23.3825,24.507);
  1608. this.context.bezierCurveTo(23.93,24.4422,24.4265,24.8327,24.4928,25.3797);
  1609. this.context.lineTo(24.493,25.381);
  1610. this.context.bezierCurveTo(24.493,25.3814,24.4932,25.3825,23.5001,25.5001);
  1611. this.context.lineTo(22.507,25.6177);
  1612. this.context.bezierCurveTo(22.4421,25.0693,22.834,24.572,23.3825,24.507);
  1613. this.context.closePath();
  1614. this.context.fill();
  1615. this.context.stroke();
  1616. this.context.beginPath();
  1617. this.context.moveTo(23.5001,25.5001);
  1618. this.context.lineTo(24.4932,25.3825);
  1619. this.context.lineTo(24.4934,25.3844);
  1620. this.context.lineTo(24.498,25.4166);
  1621. this.context.bezierCurveTo(24.5026,25.4479,24.5105,25.4984,24.5228,25.5664);
  1622. this.context.bezierCurveTo(24.5472,25.7024,24.5887,25.9078,24.6548,26.1683);
  1623. this.context.bezierCurveTo(24.7871,26.6901,25.0169,27.4283,25.4033,28.2707);
  1624. this.context.bezierCurveTo(26.1756,29.9543,27.5658,32.0393,30.0477,33.6633);
  1625. this.context.bezierCurveTo(32.5055,35.2717,35.0375,35.6213,36.9758,35.563);
  1626. this.context.bezierCurveTo(37.9445,35.534,38.7565,35.403,39.3219,35.2806);
  1627. this.context.bezierCurveTo(39.6041,35.2195,39.8233,35.1608,39.9682,35.1188);
  1628. this.context.bezierCurveTo(40.0407,35.0978,40.0944,35.081,40.1279,35.0701);
  1629. this.context.bezierCurveTo(40.1373,35.0671,40.1451,35.0645,40.1512,35.0625);
  1630. this.context.bezierCurveTo(40.1561,35.0609,40.16,35.0596,40.1629,35.0586);
  1631. this.context.lineTo(40.1665,35.0574);
  1632. this.context.lineTo(40.1686,35.0566);
  1633. this.context.bezierCurveTo(40.6887,34.8739,41.2588,35.1466,41.4428,35.6665);
  1634. this.context.bezierCurveTo(41.6271,36.1871,41.3544,36.7586,40.8337,36.9428);
  1635. this.context.lineTo(40.5001,36.0001);
  1636. this.context.bezierCurveTo(40.8337,36.9428,40.8342,36.9427,40.8337,36.9428);
  1637. this.context.lineTo(40.8319,36.9435);
  1638. this.context.lineTo(40.8295,36.9443);
  1639. this.context.lineTo(40.8233,36.9465);
  1640. this.context.lineTo(40.8046,36.9529);
  1641. this.context.bezierCurveTo(40.7893,36.958,40.7687,36.9649,40.7427,36.9733);
  1642. this.context.bezierCurveTo(40.6909,36.99,40.618,37.0128,40.5254,37.0396);
  1643. this.context.bezierCurveTo(40.3403,37.0933,40.0763,37.1636,39.7451,37.2353);
  1644. this.context.bezierCurveTo(39.0837,37.3785,38.1486,37.5287,37.0358,37.5621);
  1645. this.context.bezierCurveTo(34.8114,37.6289,31.8434,37.2285,28.9525,35.3369);
  1646. this.context.bezierCurveTo(26.0858,33.4609,24.476,31.0459,23.5854,29.1045);
  1647. this.context.bezierCurveTo(23.1404,28.1344,22.8731,27.2789,22.7161,26.66);
  1648. this.context.bezierCurveTo(22.6376,26.3502,22.5864,26.0986,22.5543,25.9202);
  1649. this.context.bezierCurveTo(22.5383,25.8309,22.527,25.7598,22.5195,25.7088);
  1650. this.context.bezierCurveTo(22.5157,25.6833,22.5129,25.6628,22.5108,25.6476);
  1651. this.context.lineTo(22.5084,25.6286);
  1652. this.context.lineTo(22.5076,25.6222);
  1653. this.context.lineTo(22.5073,25.6197);
  1654. this.context.lineTo(22.507,25.6177);
  1655. this.context.bezierCurveTo(22.507,25.6172,22.507,25.6177,23.5001,25.5001);
  1656. this.context.closePath();
  1657. this.context.fill();
  1658. this.context.stroke();
  1659. this.context.restore();
  1660. }
  1661. drawDeadBody(geometry) {
  1662. const selectItem = stateService.getSelectItem()
  1663. const draggingItem = stateService.getDraggingItem()
  1664. const focusItem = stateService.getFocusItem()
  1665. this.context.save()
  1666. this.context.strokeStyle="rgba(0,0,0,0)";
  1667. this.context.miterLimit=4;
  1668. this.context.font="15px ''";
  1669. this.context.fillStyle="#040101";
  1670. if (selectItem && selectItem.type == VectorType.DeadBody) {
  1671. if (geometry.vectorId == selectItem.vectorId) {
  1672. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1673. this.context.fillStyle = Style.Select.Sign.fillStyle
  1674. }
  1675. } else if (draggingItem && draggingItem.type == VectorType.DeadBody) {
  1676. if (geometry.vectorId == draggingItem.vectorId) {
  1677. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1678. this.context.fillStyle = Style.Select.Sign.fillStyle
  1679. }
  1680. }
  1681. if (focusItem && focusItem.type == VectorType.DeadBody) {
  1682. if (geometry.vectorId == focusItem.vectorId) {
  1683. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1684. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1685. }
  1686. }
  1687. const center = coordinate.getScreenXY({
  1688. x: geometry.center.x,
  1689. y: geometry.center.y,
  1690. })
  1691. const pt = coordinate.getScreenXY({
  1692. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1693. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1694. })
  1695. this.context.translate(center.x, center.y)
  1696. this.context.rotate((geometry.angle / 180) * Math.PI)
  1697. this.context.translate(pt.x - center.x, pt.y - center.y)
  1698. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
  1699. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1700. this.context.beginPath();
  1701. this.context.moveTo(5.91335,12.2268);
  1702. this.context.bezierCurveTo(4.35883,11.5123,3.17581,11.4098,2.00721,12.6867);
  1703. this.context.lineTo(2,13.7478);
  1704. this.context.bezierCurveTo(2.29231,15.0665,3.42071,15.5909,4.46298,16.0752);
  1705. this.context.bezierCurveTo(4.51387,16.0989,4.56455,16.1224,4.61492,16.146);
  1706. this.context.bezierCurveTo(11.3957,19.2976,16.3298,24.5608,21.2386,29.8665);
  1707. this.context.bezierCurveTo(21.9491,30.6341,21.8878,31.0197,20.7841,31.1647);
  1708. this.context.bezierCurveTo(19.2801,31.3628,18.7752,32.3001,19.0853,33.6654);
  1709. this.context.bezierCurveTo(19.5326,35.6498,20.0123,37.627,20.6327,39.5689);
  1710. this.context.bezierCurveTo(20.7153,39.9046,20.8859,40.2134,21.1276,40.4646);
  1711. this.context.bezierCurveTo(21.3692,40.7159,21.6735,40.9009,22.0104,41.0015);
  1712. this.context.lineTo(22.7318,41.0015);
  1713. this.context.bezierCurveTo(23.5253,40.5699,23.9725,39.9403,23.785,39.0313);
  1714. this.context.bezierCurveTo(23.7124,38.6795,23.6668,38.3204,23.6213,37.9616);
  1715. this.context.bezierCurveTo(23.5492,37.3932,23.4772,36.8256,23.2981,36.29);
  1716. this.context.bezierCurveTo(22.8184,34.8645,23.3702,34.5816,24.6975,34.7372);
  1717. this.context.bezierCurveTo(26.9098,34.9961,28.9508,33.7344,30.5482,32.747);
  1718. this.context.bezierCurveTo(31.0238,32.453,31.46,32.1833,31.8497,31.9853);
  1719. this.context.bezierCurveTo(32.2324,31.7909,32.6231,31.5841,33.0213,31.3734);
  1720. this.context.bezierCurveTo(34.3907,30.6486,35.848,29.8773,37.3681,29.4032);
  1721. this.context.bezierCurveTo(37.9053,29.2344,38.2276,29.511,38.5499,29.7877);
  1722. this.context.bezierCurveTo(38.6194,29.8473,38.6888,29.9069,38.7603,29.962);
  1723. this.context.bezierCurveTo(40.191,31.0821,41.6277,32.2081,43.0705,33.34);
  1724. this.context.bezierCurveTo(43.9,33.9908,44.7584,34.2986,45.5772,33.3789);
  1725. this.context.bezierCurveTo(46.3959,32.4593,45.9018,31.6634,45.1444,30.956);
  1726. this.context.bezierCurveTo(44.6458,30.494,44.1439,30.0346,43.6418,29.575);
  1727. this.context.bezierCurveTo(42.4948,28.5252,41.3468,27.4745,40.2355,26.3895);
  1728. this.context.bezierCurveTo(39.3158,25.4876,38.4213,25.0313,37.0796,25.5442);
  1729. this.context.bezierCurveTo(34.0823,26.6973,25.2493,20.2632,24.7877,18.7175);
  1730. this.context.bezierCurveTo(24.4268,17.5159,24.8984,16.0559,25.3601,14.6263);
  1731. this.context.bezierCurveTo(25.5168,14.1411,25.6724,13.6594,25.794,13.1925);
  1732. this.context.bezierCurveTo(26.1835,11.6715,25.5343,10.7589,24.1889,10.3628);
  1733. this.context.bezierCurveTo(21.4117,9.55275,18.6056,8.84533,15.796,8.13791);
  1734. this.context.bezierCurveTo(14.768,7.87969,13.7293,7.87262,13.3686,9.16721);
  1735. this.context.bezierCurveTo(13.0404,10.3522,13.6211,11.0136,14.7356,11.4133);
  1736. this.context.bezierCurveTo(16.5065,12.0535,18.263,12.7256,20.0159,13.433);
  1737. this.context.bezierCurveTo(20.0817,13.4588,20.1525,13.4826,20.2245,13.5068);
  1738. this.context.bezierCurveTo(20.6456,13.6484,21.1094,13.8043,20.8815,14.4658);
  1739. this.context.bezierCurveTo(20.4549,15.6984,20.0227,16.9292,19.5629,18.2388);
  1740. this.context.bezierCurveTo(19.3774,18.7669,19.1875,19.3079,18.9916,19.8671);
  1741. this.context.bezierCurveTo(14.9916,16.4537,10.4759,14.3208,5.91335,12.2268);
  1742. this.context.closePath();
  1743. this.context.fill();
  1744. this.context.stroke();
  1745. this.context.beginPath();
  1746. this.context.moveTo(34.7105,32.0067);
  1747. this.context.bezierCurveTo(32.6436,31.8937,31.1351,33.2167,31.0119,35.2432);
  1748. this.context.bezierCurveTo(30.9738,35.7034,31.0276,36.1666,31.17,36.6057);
  1749. this.context.bezierCurveTo(31.3124,37.0448,31.5406,37.4509,31.8411,37.8002);
  1750. this.context.bezierCurveTo(32.1417,38.1495,32.5086,38.435,32.9204,38.6399);
  1751. this.context.bezierCurveTo(33.3322,38.8448,33.7805,38.965,34.2391,38.9935);
  1752. this.context.bezierCurveTo(35.1675,39.0499,36.0808,38.7378,36.7827,38.1244);
  1753. this.context.bezierCurveTo(37.4845,37.511,37.9188,36.6452,37.9922,35.7133);
  1754. this.context.bezierCurveTo(38.0231,35.2524,37.9623,34.79,37.8134,34.353);
  1755. this.context.bezierCurveTo(37.6645,33.916,37.4305,33.5132,37.1249,33.1681);
  1756. this.context.bezierCurveTo(36.8194,32.823,36.4486,32.5426,36.034,32.3432);
  1757. this.context.bezierCurveTo(35.6195,32.1438,35.1695,32.0294,34.7105,32.0067);
  1758. this.context.closePath();
  1759. this.context.fill();
  1760. this.context.stroke();
  1761. this.context.restore();
  1762. }
  1763. drawBloodStain(geometry) {
  1764. const selectItem = stateService.getSelectItem()
  1765. const draggingItem = stateService.getDraggingItem()
  1766. const focusItem = stateService.getFocusItem()
  1767. this.context.save()
  1768. this.context.strokeStyle="rgba(0,0,0,0)";
  1769. this.context.miterLimit=4;
  1770. this.context.font="15px ''";
  1771. this.context.fillStyle="rgba(255,77,79,1)";
  1772. if (selectItem && selectItem.type == VectorType.BloodStain) {
  1773. if (geometry.vectorId == selectItem.vectorId) {
  1774. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1775. this.context.fillStyle = Style.Select.Sign.fillStyle
  1776. }
  1777. } else if (draggingItem && draggingItem.type == VectorType.BloodStain) {
  1778. if (geometry.vectorId == draggingItem.vectorId) {
  1779. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1780. this.context.fillStyle = Style.Select.Sign.fillStyle
  1781. }
  1782. }
  1783. if (focusItem && focusItem.type == VectorType.BloodStain) {
  1784. if (geometry.vectorId == focusItem.vectorId) {
  1785. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1786. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1787. }
  1788. }
  1789. const center = coordinate.getScreenXY({
  1790. x: geometry.center.x,
  1791. y: geometry.center.y,
  1792. })
  1793. const pt = coordinate.getScreenXY({
  1794. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1795. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1796. })
  1797. this.context.translate(center.x, center.y)
  1798. this.context.rotate((geometry.angle / 180) * Math.PI)
  1799. this.context.translate(pt.x - center.x, pt.y - center.y)
  1800. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
  1801. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1802. this.context.beginPath();
  1803. this.context.moveTo(11.7832,43.4124);
  1804. this.context.bezierCurveTo(13.9788,44.5378,19.4679,44.5355,19.468,38.91);
  1805. this.context.bezierCurveTo(19.468,33.2844,21.1146,29.3458,26.0549,28.7831);
  1806. this.context.bezierCurveTo(26.3893,28.745,26.7385,28.7077,27.1002,28.669);
  1807. this.context.bezierCurveTo(32.0834,28.1363,39.425,27.3516,42.5224,20.9046);
  1808. this.context.bezierCurveTo(44.2471,17.3148,41.7011,10.7791,28.2507,7.40168);
  1809. this.context.bezierCurveTo(14.3038,3.89964,6.84294,7.40168,5.19509,13.0273);
  1810. this.context.bezierCurveTo(3.54725,18.6528,12.8799,26.5313,12.8799,26.5313);
  1811. this.context.bezierCurveTo(12.8799,26.5313,16.1646,30.722,15.0766,33.2844);
  1812. this.context.bezierCurveTo(14.9608,34.6355,13.8708,35.0844,12.6391,35.5917);
  1813. this.context.bezierCurveTo(11.5358,36.0461,10.3188,36.5474,9.58641,37.7858);
  1814. this.context.bezierCurveTo(8.03737,40.4055,9.58751,42.2871,11.7832,43.4124);
  1815. this.context.closePath();
  1816. this.context.fill();
  1817. this.context.stroke();
  1818. this.context.beginPath();
  1819. this.context.moveTo(32.8372,34.4465);
  1820. this.context.bezierCurveTo(32.3576,36.4893,31.5484,37,29.9586,37);
  1821. this.context.bezierCurveTo(28.3688,37,26.6003,35.9786,27.08,34.4465);
  1822. this.context.bezierCurveTo(27.5598,32.9144,29.5522,32,31.1421,32);
  1823. this.context.bezierCurveTo(32.7319,32,33.3169,32.4037,32.8372,34.4465);
  1824. this.context.closePath();
  1825. this.context.fill();
  1826. this.context.stroke();
  1827. this.context.beginPath();
  1828. this.context.moveTo(37.4462,43);
  1829. this.context.bezierCurveTo(38.8566,43,40,42.3284,40,41.5);
  1830. this.context.bezierCurveTo(40,40.6716,38.3459,40,36.9355,40);
  1831. this.context.bezierCurveTo(35.525,40,35,40.6716,35,41.5);
  1832. this.context.bezierCurveTo(35,42.3284,36.0358,43,37.4462,43);
  1833. this.context.closePath();
  1834. this.context.fill();
  1835. this.context.stroke();
  1836. this.context.restore();
  1837. }
  1838. /***************************************************************************************************************************************************************************************/
  1839. }
  1840. const draw = new Draw()
  1841. export { draw }