oldDraw.js 89 KB

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