Draw.js 157 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577
  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 { compassService } from '../Service/CompassService'
  11. import { furnitureService } from '../Service/FurnitureService.js'
  12. export default class Draw {
  13. constructor() {
  14. this.context = null
  15. }
  16. initContext(canvas) {
  17. if (canvas) {
  18. this.context = canvas.getContext('2d')
  19. } else {
  20. this.context = null
  21. }
  22. }
  23. clear() {
  24. this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height)
  25. }
  26. drawBackGround(color) {
  27. this.context.save()
  28. this.context.fillStyle = color
  29. this.context.fillRect(0, 0, this.context.canvas.width, this.context.canvas.height)
  30. this.context.restore()
  31. }
  32. // setSVGAttr(svgId,width,height){
  33. // }
  34. drawWall(vector, styleType) {
  35. let start = floorplanService.getPoint(vector.start)
  36. let end = floorplanService.getPoint(vector.end)
  37. let points = []
  38. points.push(start)
  39. for (let i = 0; i < vector.children.length; ++i) {
  40. let symbol = floorplanService.getSymbol(vector.children[i])
  41. points.push(symbol.startPoint)
  42. points.push(symbol.endPoint)
  43. }
  44. points.push(end)
  45. points = points.sort(sortNumber.bind(this))
  46. function sortNumber(a, b) {
  47. return mathUtil.getDistance(start, a) - mathUtil.getDistance(start, b)
  48. }
  49. this.context.save()
  50. this.context.beginPath()
  51. this.context.lineCap = 'round' //线段端点的样式
  52. //this.context.lineJoin= 'miter';
  53. this.context.strokeStyle = Style.Wall.strokeStyle
  54. if (vector.out || vector.important) {
  55. this.context.lineWidth = Style.Wall.important.lineWidth * coordinate.ratio
  56. this.context.strokeStyle = Style.Wall.important.strokeStyle
  57. } else {
  58. this.context.lineWidth = Style.Wall.lineWidth * coordinate.ratio
  59. this.context.strokeStyle = Style.Wall.strokeStyle
  60. }
  61. const selectItem = stateService.getSelectItem()
  62. const draggingItem = stateService.getDraggingItem()
  63. const focusItem = stateService.getFocusItem()
  64. //下载的时候,根据样式
  65. if (styleType) {
  66. if (styleType == 'style-1') {
  67. if (vector.out || vector.important) {
  68. this.context.lineWidth = Style.DownLoad.style1.Wall.important.lineWidth * coordinate.ratio
  69. this.context.strokeStyle = Style.DownLoad.style1.Wall.important.strokeStyle
  70. } else {
  71. this.context.lineWidth = Style.DownLoad.style1.Wall.lineWidth * coordinate.ratio
  72. this.context.strokeStyle = Style.DownLoad.style1.Wall.strokeStyle
  73. }
  74. } else if (styleType == 'style-2') {
  75. if (vector.out || vector.important) {
  76. this.context.lineWidth = Style.DownLoad.style2.Wall.important.lineWidth * coordinate.ratio
  77. this.context.strokeStyle = Style.DownLoad.style2.Wall.important.strokeStyle
  78. } else {
  79. this.context.lineWidth = Style.DownLoad.style2.Wall.lineWidth * coordinate.ratio
  80. this.context.strokeStyle = Style.DownLoad.style2.Wall.strokeStyle
  81. }
  82. } else if (styleType == 'style-3') {
  83. if (vector.out || vector.important) {
  84. this.context.lineWidth = Style.DownLoad.style3.Wall.important.lineWidth * coordinate.ratio
  85. this.context.strokeStyle = Style.DownLoad.style3.Wall.important.strokeStyle
  86. } else {
  87. this.context.lineWidth = Style.DownLoad.style3.Wall.lineWidth * coordinate.ratio
  88. this.context.strokeStyle = Style.DownLoad.style3.Wall.strokeStyle
  89. }
  90. } else if (styleType == 'style-4') {
  91. if (vector.out || vector.important) {
  92. this.context.lineWidth = Style.DownLoad.style4.Wall.important.lineWidth * coordinate.ratio
  93. this.context.strokeStyle = Style.DownLoad.style4.Wall.important.strokeStyle
  94. } else {
  95. this.context.lineWidth = Style.DownLoad.style4.Wall.lineWidth * coordinate.ratio
  96. this.context.strokeStyle = Style.DownLoad.style4.Wall.strokeStyle
  97. }
  98. }
  99. } else {
  100. if (selectItem && selectItem.type == VectorType.Wall) {
  101. if (vector.vectorId == selectItem.vectorId) {
  102. if (vector.out || vector.important) {
  103. this.context.strokeStyle = Style.Select.Wall_out.strokeStyle
  104. } else {
  105. this.context.strokeStyle = Style.Select.Wall.strokeStyle
  106. }
  107. }
  108. } else if (draggingItem && draggingItem.type == VectorType.Wall) {
  109. if (vector.vectorId == draggingItem.vectorId) {
  110. if (vector.out || vector.important) {
  111. this.context.strokeStyle = Style.Select.Wall_out.strokeStyle
  112. } else {
  113. this.context.strokeStyle = Style.Select.Wall.strokeStyle
  114. }
  115. }
  116. }
  117. if (focusItem && focusItem.type == VectorType.Wall) {
  118. if (vector.vectorId == focusItem.vectorId) {
  119. this.context.strokeStyle = Style.Focus.Wall.strokeStyle
  120. }
  121. }
  122. }
  123. for (let i = 0; i < points.length - 1; i += 2) {
  124. let point1 = coordinate.getScreenXY(points[i])
  125. let point2 = coordinate.getScreenXY(points[i + 1])
  126. this.context.moveTo(point1.x, point1.y)
  127. this.context.lineTo(point2.x, point2.y)
  128. }
  129. this.context.stroke()
  130. this.context.restore()
  131. // const mid = {
  132. // x: (start.x + end.x) / 2,
  133. // y: (start.y + end.y) / 2,
  134. // }
  135. // this.drawText(mid, vector.vectorId)
  136. if (
  137. (selectItem && selectItem.type == VectorType.Wall && vector.vectorId == selectItem.vectorId) ||
  138. (draggingItem && draggingItem.type == VectorType.Wall && vector.vectorId == draggingItem.vectorId) ||
  139. (focusItem && focusItem.type == VectorType.Wall && vector.vectorId == focusItem.vectorId)
  140. ) {
  141. //添加测量值
  142. this.drawMeasureTxt(start, end)
  143. }
  144. }
  145. drawSpecialPoint() {
  146. const selectItem = stateService.getSelectItem()
  147. const draggingItem = stateService.getDraggingItem()
  148. const focusItem = stateService.getFocusItem()
  149. let point = null
  150. this.context.save()
  151. if (selectItem) {
  152. point = floorplanService.getPoint(selectItem.vectorId)
  153. this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
  154. this.context.strokeStyle = Style.Select.Point.strokeStyle
  155. this.context.fillStyle = Style.Select.Point.fillStyle
  156. }
  157. if (draggingItem) {
  158. point = floorplanService.getPoint(draggingItem.vectorId)
  159. this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
  160. this.context.strokeStyle = Style.Select.Point.strokeStyle
  161. this.context.fillStyle = Style.Select.Point.fillStyle
  162. }
  163. if (focusItem) {
  164. point = floorplanService.getPoint(focusItem.vectorId)
  165. this.context.lineWidth = Style.Focus.Point.lineWidth * coordinate.ratio
  166. this.context.strokeStyle = Style.Focus.Point.strokeStyle
  167. this.context.fillStyle = Style.Focus.Point.fillStyle
  168. }
  169. if (point == null) {
  170. this.context.restore()
  171. return
  172. }
  173. const pt = coordinate.getScreenXY({ x: point.x, y: point.y })
  174. let radius = Style.Point.radius
  175. this.context.beginPath()
  176. this.context.arc(pt.x, pt.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
  177. this.context.stroke()
  178. this.context.fill()
  179. this.context.restore()
  180. }
  181. drawPoint(vector) {
  182. const pt = coordinate.getScreenXY({ x: vector.x, y: vector.y })
  183. const selectItem = stateService.getSelectItem()
  184. const draggingItem = stateService.getDraggingItem()
  185. const focusItem = stateService.getFocusItem()
  186. // this.context.save()
  187. // this.context.lineWidth = Style.Point.lineWidth * coordinate.ratio
  188. // this.context.strokeStyle = Style.Point.strokeStyle
  189. // this.context.fillStyle = Style.Point.fillStyle
  190. let radius = Style.Point.radius
  191. if (
  192. (draggingItem && draggingItem.type == VectorType.WallCorner && vector.vectorId == draggingItem.vectorId) ||
  193. (selectItem && selectItem.type == VectorType.WallCorner && vector.vectorId == selectItem.vectorId)
  194. ) {
  195. this.context.save()
  196. this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
  197. this.context.strokeStyle = Style.Select.Point.strokeStyle
  198. this.context.fillStyle = Style.Select.Point.fillStyle
  199. radius = Style.Select.Point.radius
  200. } else if (focusItem && focusItem.type == VectorType.WallCorner && vector.vectorId == focusItem.vectorId) {
  201. this.context.save()
  202. this.context.lineWidth = Style.Focus.Point.lineWidth * coordinate.ratio
  203. this.context.strokeStyle = Style.Focus.Point.strokeStyle
  204. this.context.fillStyle = Style.Focus.Point.fillStyle
  205. radius = Style.Focus.Point.radius
  206. } else {
  207. return
  208. }
  209. this.context.beginPath()
  210. this.context.arc(pt.x, pt.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
  211. this.context.stroke()
  212. this.context.fill()
  213. this.context.restore()
  214. // this.drawText({ x: vector.x, y: vector.y }, vector.vectorId)
  215. }
  216. // 文字
  217. drawText(position, txt, screenCoord, angle) {
  218. this.context.save()
  219. this.setCanvasStyle(Style.Font)
  220. if (coordinate.ratio == Constant.ratio) {
  221. this.context.font = '36px Microsoft YaHei'
  222. } else {
  223. this.context.font = '12px Microsoft YaHei'
  224. }
  225. let pt = { x: position.x, y: position.y }
  226. if (!screenCoord) {
  227. pt = coordinate.getScreenXY({ x: position.x, y: position.y })
  228. }
  229. if (angle) {
  230. this.context.translate(pt.x, pt.y)
  231. this.context.rotate(angle)
  232. //this.context.strokeText(txt, 0, 0)
  233. this.context.fillText(txt, 0, 0)
  234. } else {
  235. //this.context.strokeText(txt, pt.x, pt.y)
  236. this.context.fillText(txt, pt.x, pt.y)
  237. }
  238. this.context.restore()
  239. }
  240. drawSingleDoor(geometry, styleType, noEnter) {
  241. let points2d = geometry.points2d
  242. let points = []
  243. for (let i = 0; i < points2d.length; ++i) {
  244. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  245. }
  246. const distance = mathUtil.getDistance(points[0], points[1])
  247. this.context.save()
  248. this.context.lineWidth = Style.Symbol.lineWidth * coordinate.ratio
  249. this.context.lineCap = 'square'
  250. this.context.strokeStyle = Style.Symbol.strokeStyle
  251. let isFill = false
  252. if (styleType) {
  253. if (styleType == 'style-1') {
  254. this.context.lineWidth = Style.DownLoad.style1.Symbol.lineWidth * coordinate.ratio
  255. this.context.strokeStyle = Style.DownLoad.style1.Symbol.strokeStyle
  256. } else if (styleType == 'style-2') {
  257. this.context.lineWidth = Style.DownLoad.style2.Symbol.lineWidth * coordinate.ratio
  258. this.context.strokeStyle = Style.DownLoad.style2.Symbol.strokeStyle
  259. } else if (styleType == 'style-3') {
  260. this.context.lineWidth = Style.DownLoad.style3.Symbol.lineWidth * coordinate.ratio
  261. this.context.strokeStyle = Style.DownLoad.style3.Symbol.strokeStyle
  262. } else if (styleType == 'style-4') {
  263. this.context.lineWidth = Style.DownLoad.style4.Symbol.lineWidth * coordinate.ratio
  264. this.context.strokeStyle = Style.DownLoad.style4.Symbol.strokeStyle
  265. }
  266. } else {
  267. const selectItem = stateService.getSelectItem()
  268. const draggingItem = stateService.getDraggingItem()
  269. const focusItem = stateService.getFocusItem()
  270. if (selectItem && selectItem.type == VectorType.SingleDoor && selectItem.selectIndex == SelectState.All) {
  271. if (geometry.vectorId == selectItem.vectorId) {
  272. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  273. this.context.fillStyle = Style.Select.Symbol.fillStyle
  274. isFill = true
  275. }
  276. } else if (draggingItem && draggingItem.type == VectorType.SingleDoor && draggingItem.selectIndex == SelectState.All) {
  277. if (geometry.vectorId == draggingItem.vectorId) {
  278. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  279. this.context.fillStyle = Style.Select.Symbol.fillStyle
  280. isFill = true
  281. }
  282. }
  283. if (focusItem && focusItem.type == VectorType.SingleDoor) {
  284. if (geometry.vectorId == focusItem.vectorId) {
  285. this.context.strokeStyle = Style.Focus.Symbol.strokeStyle
  286. this.context.fillStyle = Style.Focus.Symbol.fillStyle
  287. isFill = true
  288. }
  289. }
  290. }
  291. this.context.beginPath()
  292. this.context.moveTo(points[0].x, points[0].y)
  293. this.context.lineTo(points[1].x, points[1].y)
  294. this.context.arcTo(points[2].x, points[2].y, points[3].x, points[3].y, distance) // 创建弧
  295. this.context.closePath()
  296. this.context.stroke()
  297. if (isFill) {
  298. this.context.fill()
  299. }
  300. this.context.restore()
  301. if (!noEnter && geometry.enter != null) {
  302. this.drawEntranceDoor(geometry)
  303. }
  304. }
  305. drawDoubleDoor(geometry, styleType, noEnter) {
  306. let points2d = geometry.points2d
  307. let points = []
  308. for (let i = 0; i < points2d.length; ++i) {
  309. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  310. }
  311. const distance = mathUtil.getDistance(points[0], points[1])
  312. this.context.save()
  313. this.context.lineWidth = Style.Symbol.lineWidth * coordinate.ratio
  314. this.context.lineCap = 'square'
  315. this.context.strokeStyle = Style.Symbol.strokeStyle
  316. let isFill = false
  317. if (styleType) {
  318. if (styleType == 'style-1') {
  319. this.context.lineWidth = Style.DownLoad.style1.Symbol.lineWidth * coordinate.ratio
  320. this.context.strokeStyle = Style.DownLoad.style1.Symbol.strokeStyle
  321. } else if (styleType == 'style-2') {
  322. this.context.lineWidth = Style.DownLoad.style2.Symbol.lineWidth * coordinate.ratio
  323. this.context.strokeStyle = Style.DownLoad.style2.Symbol.strokeStyle
  324. } else if (styleType == 'style-3') {
  325. this.context.lineWidth = Style.DownLoad.style3.Symbol.lineWidth * coordinate.ratio
  326. this.context.strokeStyle = Style.DownLoad.style3.Symbol.strokeStyle
  327. } else if (styleType == 'style-4') {
  328. this.context.lineWidth = Style.DownLoad.style4.Symbol.lineWidth * coordinate.ratio
  329. this.context.strokeStyle = Style.DownLoad.style4.Symbol.strokeStyle
  330. }
  331. } else {
  332. const selectItem = stateService.getSelectItem()
  333. const draggingItem = stateService.getDraggingItem()
  334. const focusItem = stateService.getFocusItem()
  335. if (selectItem && selectItem.type == VectorType.DoubleDoor && selectItem.selectIndex == SelectState.All) {
  336. if (geometry.vectorId == selectItem.vectorId) {
  337. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  338. this.context.fillStyle = Style.Select.Symbol.fillStyle
  339. isFill = true
  340. }
  341. } else if (draggingItem && draggingItem.type == VectorType.DoubleDoor && draggingItem.selectIndex == SelectState.All) {
  342. if (geometry.vectorId == draggingItem.vectorId) {
  343. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  344. this.context.fillStyle = Style.Select.Symbol.fillStyle
  345. isFill = true
  346. }
  347. }
  348. if (focusItem && focusItem.type == VectorType.DoubleDoor) {
  349. if (geometry.vectorId == focusItem.vectorId) {
  350. this.context.strokeStyle = Style.Focus.Symbol.strokeStyle
  351. this.context.fillStyle = Style.Focus.Symbol.fillStyle
  352. isFill = true
  353. }
  354. }
  355. }
  356. this.context.beginPath()
  357. this.context.moveTo(points[0].x, points[0].y)
  358. this.context.lineTo(points[1].x, points[1].y)
  359. this.context.arcTo(points[4].x, points[4].y, points[5].x, points[5].y, distance) // 创建弧
  360. this.context.closePath()
  361. this.context.stroke()
  362. if (isFill) {
  363. this.context.fill()
  364. }
  365. this.context.beginPath()
  366. this.context.moveTo(points[2].x, points[2].y)
  367. this.context.lineTo(points[1].x, points[1].y)
  368. this.context.arcTo(points[4].x, points[4].y, points[3].x, points[3].y, distance) // 创建弧
  369. this.context.closePath()
  370. this.context.stroke()
  371. if (isFill) {
  372. this.context.fill()
  373. }
  374. this.context.restore()
  375. if (!noEnter && geometry.enter != null) {
  376. this.drawEntranceDoor(geometry)
  377. }
  378. }
  379. drawSlideDoor(geometry, styleType, noEnter) {
  380. let points2d = geometry.points2d
  381. let points = []
  382. for (let i = 0; i < points2d.length; ++i) {
  383. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  384. }
  385. this.context.save()
  386. this.context.lineWidth = Style.Symbol.lineWidth * coordinate.ratio
  387. this.context.strokeStyle = Style.Symbol.strokeStyle
  388. //this.context.fillStyle = Style.Symbol.fillStyle
  389. if (styleType) {
  390. if (styleType == 'style-1') {
  391. this.context.lineWidth = Style.DownLoad.style1.Symbol.lineWidth * coordinate.ratio
  392. this.context.strokeStyle = Style.DownLoad.style1.Symbol.strokeStyle
  393. } else if (styleType == 'style-2') {
  394. this.context.lineWidth = Style.DownLoad.style2.Symbol.lineWidth * coordinate.ratio
  395. this.context.strokeStyle = Style.DownLoad.style2.Symbol.strokeStyle
  396. } else if (styleType == 'style-3') {
  397. this.context.lineWidth = Style.DownLoad.style3.Symbol.lineWidth * coordinate.ratio
  398. this.context.strokeStyle = Style.DownLoad.style3.Symbol.strokeStyle
  399. } else if (styleType == 'style-4') {
  400. this.context.lineWidth = Style.DownLoad.style4.Symbol.lineWidth * coordinate.ratio
  401. this.context.strokeStyle = Style.DownLoad.style4.Symbol.strokeStyle
  402. }
  403. } else {
  404. const selectItem = stateService.getSelectItem()
  405. const draggingItem = stateService.getDraggingItem()
  406. const focusItem = stateService.getFocusItem()
  407. if (selectItem && selectItem.type == VectorType.SlideDoor && selectItem.selectIndex == SelectState.All) {
  408. if (geometry.vectorId == selectItem.vectorId) {
  409. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  410. }
  411. } else if (draggingItem && draggingItem.type == VectorType.SlideDoor && draggingItem.selectIndex == SelectState.All) {
  412. if (geometry.vectorId == draggingItem.vectorId) {
  413. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  414. }
  415. }
  416. if (focusItem && focusItem.type == VectorType.SlideDoor) {
  417. if (geometry.vectorId == focusItem.vectorId) {
  418. this.context.strokeStyle = Style.Focus.Symbol.strokeStyle
  419. }
  420. }
  421. }
  422. this.context.beginPath()
  423. this.context.moveTo(points[0].x, points[0].y)
  424. this.context.lineTo(points[1].x, points[1].y)
  425. this.context.lineTo(points[2].x, points[2].y)
  426. this.context.lineTo(points[3].x, points[3].y)
  427. this.context.closePath()
  428. this.context.stroke()
  429. this.context.beginPath()
  430. this.context.moveTo(points[4].x, points[4].y)
  431. this.context.lineTo(points[5].x, points[5].y)
  432. this.context.lineTo(points[6].x, points[6].y)
  433. this.context.lineTo(points[7].x, points[7].y)
  434. this.context.closePath()
  435. this.context.stroke()
  436. this.context.restore()
  437. if (!noEnter && geometry.enter != null) {
  438. this.drawEntranceDoor(geometry)
  439. }
  440. }
  441. drawSingleWindow(geometry, styleType) {
  442. let points2d = geometry.points2d
  443. let points = []
  444. for (let i = 0; i < points2d.length; ++i) {
  445. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  446. }
  447. this.context.save()
  448. this.context.lineWidth = Style.Symbol.lineWidth * coordinate.ratio
  449. this.context.strokeStyle = Style.Symbol.strokeStyle
  450. if (styleType) {
  451. if (styleType == 'style-1') {
  452. this.context.lineWidth = Style.DownLoad.style1.Symbol.lineWidth * coordinate.ratio
  453. this.context.strokeStyle = Style.DownLoad.style1.Symbol.strokeStyle
  454. } else if (styleType == 'style-2') {
  455. this.context.lineWidth = Style.DownLoad.style2.Symbol.lineWidth * coordinate.ratio
  456. this.context.strokeStyle = Style.DownLoad.style2.Symbol.strokeStyle
  457. } else if (styleType == 'style-3') {
  458. this.context.lineWidth = Style.DownLoad.style3.Symbol.lineWidth * coordinate.ratio
  459. this.context.strokeStyle = Style.DownLoad.style3.Symbol.strokeStyle
  460. } else if (styleType == 'style-4') {
  461. this.context.lineWidth = Style.DownLoad.style4.Symbol.lineWidth * coordinate.ratio
  462. this.context.strokeStyle = Style.DownLoad.style4.Symbol.strokeStyle
  463. }
  464. } else {
  465. const selectItem = stateService.getSelectItem()
  466. const draggingItem = stateService.getDraggingItem()
  467. const focusItem = stateService.getFocusItem()
  468. if (selectItem && selectItem.type == VectorType.SingleWindow && selectItem.selectIndex == SelectState.All) {
  469. if (geometry.vectorId == selectItem.vectorId) {
  470. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  471. }
  472. } else if (draggingItem && draggingItem.type == VectorType.SingleWindow && draggingItem.selectIndex == SelectState.All) {
  473. if (geometry.vectorId == draggingItem.vectorId) {
  474. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  475. }
  476. }
  477. if (focusItem && focusItem.type == VectorType.SingleWindow) {
  478. if (geometry.vectorId == focusItem.vectorId) {
  479. this.context.strokeStyle = Style.Focus.Symbol.strokeStyle
  480. }
  481. }
  482. }
  483. this.context.beginPath()
  484. this.context.moveTo(points[0].x, points[0].y)
  485. this.context.lineTo(points[1].x, points[1].y)
  486. this.context.stroke()
  487. this.context.beginPath()
  488. this.context.moveTo(points[2].x, points[2].y)
  489. this.context.lineTo(points[3].x, points[3].y)
  490. this.context.lineTo(points[4].x, points[4].y)
  491. this.context.lineTo(points[5].x, points[5].y)
  492. this.context.closePath()
  493. this.context.stroke()
  494. this.context.restore()
  495. }
  496. drawBayWindow(geometry, styleType) {
  497. let points2d = geometry.points2d
  498. let points = []
  499. for (let i = 0; i < points2d.length; ++i) {
  500. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  501. }
  502. this.context.save()
  503. this.context.lineWidth = Style.Symbol.lineWidth * coordinate.ratio
  504. this.context.strokeStyle = Style.Symbol.strokeStyle
  505. //this.context.fillStyle = Style.Symbol.fillStyle
  506. let isFill = false
  507. if (styleType) {
  508. if (styleType == 'style-1') {
  509. this.context.lineWidth = Style.DownLoad.style1.Symbol.lineWidth * coordinate.ratio
  510. this.context.strokeStyle = Style.DownLoad.style1.Symbol.strokeStyle
  511. } else if (styleType == 'style-2') {
  512. this.context.lineWidth = Style.DownLoad.style2.Symbol.lineWidth * coordinate.ratio
  513. this.context.strokeStyle = Style.DownLoad.style2.Symbol.strokeStyle
  514. } else if (styleType == 'style-3') {
  515. this.context.lineWidth = Style.DownLoad.style3.Symbol.lineWidth * coordinate.ratio
  516. this.context.strokeStyle = Style.DownLoad.style3.Symbol.strokeStyle
  517. } else if (styleType == 'style-4') {
  518. this.context.lineWidth = Style.DownLoad.style4.Symbol.lineWidth * coordinate.ratio
  519. this.context.strokeStyle = Style.DownLoad.style4.Symbol.strokeStyle
  520. }
  521. } else {
  522. const selectItem = stateService.getSelectItem()
  523. const draggingItem = stateService.getDraggingItem()
  524. const focusItem = stateService.getFocusItem()
  525. if (selectItem && selectItem.type == VectorType.BayWindow && selectItem.selectIndex == SelectState.All) {
  526. if (geometry.vectorId == selectItem.vectorId) {
  527. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  528. this.context.fillStyle = Style.Select.Symbol.fillStyle
  529. isFill = true
  530. }
  531. } else if (draggingItem && draggingItem.type == VectorType.BayWindow && draggingItem.selectIndex == SelectState.All) {
  532. if (geometry.vectorId == draggingItem.vectorId) {
  533. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  534. this.context.fillStyle = Style.Select.Symbol.fillStyle
  535. isFill = true
  536. }
  537. }
  538. if (focusItem && focusItem.type == VectorType.BayWindow) {
  539. if (geometry.vectorId == focusItem.vectorId) {
  540. this.context.strokeStyle = Style.Focus.Symbol.strokeStyle
  541. this.context.fillStyle = Style.Focus.Symbol.fillStyle
  542. isFill = true
  543. }
  544. }
  545. }
  546. this.context.beginPath()
  547. this.context.moveTo(points[0].x, points[0].y)
  548. this.context.lineTo(points[1].x, points[1].y)
  549. this.context.lineTo(points[2].x, points[2].y)
  550. this.context.lineTo(points[3].x, points[3].y)
  551. this.context.closePath()
  552. this.context.stroke()
  553. if (isFill) {
  554. this.context.fill()
  555. }
  556. this.context.beginPath()
  557. this.context.moveTo(points[5].x, points[5].y)
  558. this.context.lineTo(points[6].x, points[6].y)
  559. this.context.lineTo(points[7].x, points[7].y)
  560. this.context.lineTo(points[4].x, points[4].y)
  561. //this.context.closePath()
  562. this.context.stroke()
  563. this.context.restore()
  564. }
  565. drawFrenchWindow(geometry, styleType) {
  566. let points2d = geometry.points2d
  567. let points = []
  568. for (let i = 0; i < points2d.length; ++i) {
  569. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  570. }
  571. this.context.save()
  572. this.context.lineWidth = Style.Symbol.lineWidth * coordinate.ratio
  573. this.context.strokeStyle = Style.Symbol.strokeStyle
  574. if (styleType) {
  575. if (styleType == 'style-1') {
  576. this.context.lineWidth = Style.DownLoad.style1.Symbol.lineWidth * coordinate.ratio
  577. this.context.strokeStyle = Style.DownLoad.style1.Symbol.strokeStyle
  578. } else if (styleType == 'style-2') {
  579. this.context.lineWidth = Style.DownLoad.style2.Symbol.lineWidth * coordinate.ratio
  580. this.context.strokeStyle = Style.DownLoad.style2.Symbol.strokeStyle
  581. } else if (styleType == 'style-3') {
  582. this.context.lineWidth = Style.DownLoad.style3.Symbol.lineWidth * coordinate.ratio
  583. this.context.strokeStyle = Style.DownLoad.style3.Symbol.strokeStyle
  584. } else if (styleType == 'style-4') {
  585. this.context.lineWidth = Style.DownLoad.style4.Symbol.lineWidth * coordinate.ratio
  586. this.context.strokeStyle = Style.DownLoad.style4.Symbol.strokeStyle
  587. }
  588. } else {
  589. const selectItem = stateService.getSelectItem()
  590. const draggingItem = stateService.getDraggingItem()
  591. const focusItem = stateService.getFocusItem()
  592. if (selectItem && selectItem.type == VectorType.FrenchWindow && selectItem.selectIndex == SelectState.All) {
  593. if (geometry.vectorId == selectItem.vectorId) {
  594. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  595. }
  596. } else if (draggingItem && draggingItem.type == VectorType.FrenchWindow && draggingItem.selectIndex == SelectState.All) {
  597. if (geometry.vectorId == draggingItem.vectorId) {
  598. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  599. }
  600. }
  601. if (focusItem && focusItem.type == VectorType.FrenchWindow) {
  602. if (geometry.vectorId == focusItem.vectorId) {
  603. this.context.strokeStyle = Style.Focus.Symbol.strokeStyle
  604. }
  605. }
  606. }
  607. this.context.beginPath()
  608. this.context.moveTo(points[0].x, points[0].y)
  609. this.context.lineTo(points[1].x, points[1].y)
  610. this.context.moveTo(points[2].x, points[2].y)
  611. this.context.lineTo(points[3].x, points[3].y)
  612. this.context.moveTo(points[4].x, points[4].y)
  613. this.context.lineTo(points[5].x, points[5].y)
  614. this.context.moveTo(points[2].x, points[2].y)
  615. this.context.lineTo(points[4].x, points[4].y)
  616. this.context.moveTo(points[3].x, points[3].y)
  617. this.context.lineTo(points[5].x, points[5].y)
  618. this.context.moveTo(points[6].x, points[6].y)
  619. this.context.lineTo(points[7].x, points[7].y)
  620. this.context.stroke()
  621. this.context.restore()
  622. }
  623. drawPass(geometry, styleType) {
  624. let points2d = geometry.points2d
  625. let points = []
  626. for (let i = 0; i < points2d.length; ++i) {
  627. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  628. }
  629. this.context.save()
  630. this.context.lineWidth = Style.Symbol.lineWidth * coordinate.ratio
  631. this.context.strokeStyle = Style.Symbol.strokeStyle
  632. if (styleType) {
  633. if (styleType == 'style-1') {
  634. this.context.lineWidth = Style.DownLoad.style1.Symbol.lineWidth * coordinate.ratio
  635. this.context.strokeStyle = Style.DownLoad.style1.Symbol.strokeStyle
  636. } else if (styleType == 'style-2') {
  637. this.context.lineWidth = Style.DownLoad.style2.Symbol.lineWidth * coordinate.ratio
  638. this.context.strokeStyle = Style.DownLoad.style2.Symbol.strokeStyle
  639. } else if (styleType == 'style-3') {
  640. this.context.lineWidth = Style.DownLoad.style3.Symbol.lineWidth * coordinate.ratio
  641. this.context.strokeStyle = Style.DownLoad.style3.Symbol.strokeStyle
  642. } else if (styleType == 'style-4') {
  643. this.context.lineWidth = Style.DownLoad.style4.Symbol.lineWidth * coordinate.ratio
  644. this.context.strokeStyle = Style.DownLoad.style4.Symbol.strokeStyle
  645. }
  646. } else {
  647. const selectItem = stateService.getSelectItem()
  648. const draggingItem = stateService.getDraggingItem()
  649. const focusItem = stateService.getFocusItem()
  650. if (selectItem && selectItem.type == VectorType.Pass && selectItem.selectIndex == SelectState.All) {
  651. if (geometry.vectorId == selectItem.vectorId) {
  652. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  653. }
  654. } else if (draggingItem && draggingItem.type == VectorType.Pass && draggingItem.selectIndex == SelectState.All) {
  655. if (geometry.vectorId == draggingItem.vectorId) {
  656. this.context.strokeStyle = Style.Select.Symbol.strokeStyle
  657. }
  658. }
  659. if (focusItem && focusItem.type == VectorType.Pass) {
  660. if (geometry.vectorId == focusItem.vectorId) {
  661. this.context.strokeStyle = Style.Focus.Symbol.strokeStyle
  662. }
  663. }
  664. }
  665. this.context.beginPath()
  666. this.context.moveTo(points[0].x, points[0].y)
  667. this.context.lineTo(points[1].x, points[1].y)
  668. this.context.lineTo(points[2].x, points[2].y)
  669. this.context.lineTo(points[3].x, points[3].y)
  670. this.context.closePath()
  671. this.context.stroke()
  672. this.context.beginPath()
  673. this.context.moveTo(points[4].x, points[4].y)
  674. this.context.lineTo(points[5].x, points[5].y)
  675. this.context.setLineDash([3, 2, 2])
  676. //this.context.dashedLine(points[4].x, points[4].y, points[5].x, points[5].y, dashGapArray);
  677. this.context.stroke()
  678. this.context.beginPath()
  679. this.context.moveTo(points[6].x, points[6].y)
  680. this.context.lineTo(points[7].x, points[7].y)
  681. this.context.setLineDash([3, 2, 2])
  682. //this.context.dashedLine(points[6].x, points[6].y, points[7].x, points[7].y, dashGapArray);
  683. this.context.stroke()
  684. this.context.restore()
  685. }
  686. drawBeam(geometry, styleType) {
  687. let points2d = geometry.points2d
  688. let points = []
  689. for (let i = 0; i < points2d.length; ++i) {
  690. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  691. }
  692. this.context.save()
  693. this.context.lineWidth = Style.Component.lineWidth * coordinate.ratio
  694. this.context.strokeStyle = Style.Component.strokeStyle
  695. let isFill = false
  696. if (styleType) {
  697. if (styleType == 'style-1') {
  698. this.context.lineWidth = Style.DownLoad.style1.Component.lineWidth * coordinate.ratio
  699. this.context.strokeStyle = Style.DownLoad.style1.Component.strokeStyle
  700. } else if (styleType == 'style-2') {
  701. this.context.lineWidth = Style.DownLoad.style2.Component.lineWidth * coordinate.ratio
  702. this.context.strokeStyle = Style.DownLoad.style2.Component.strokeStyle
  703. } else if (styleType == 'style-3') {
  704. this.context.lineWidth = Style.DownLoad.style3.Component.lineWidth * coordinate.ratio
  705. this.context.strokeStyle = Style.DownLoad.style3.Component.strokeStyle
  706. } else if (styleType == 'style-4') {
  707. this.context.lineWidth = Style.DownLoad.style4.Component.lineWidth * coordinate.ratio
  708. this.context.strokeStyle = Style.DownLoad.style4.Component.strokeStyle
  709. }
  710. } else {
  711. const selectItem = stateService.getSelectItem()
  712. const draggingItem = stateService.getDraggingItem()
  713. const focusItem = stateService.getFocusItem()
  714. if (selectItem && selectItem.type == VectorType.Beam) {
  715. if (geometry.vectorId == selectItem.vectorId) {
  716. this.context.strokeStyle = Style.Select.Component.strokeStyle
  717. this.context.fillStyle = Style.Select.Component.fillStyle
  718. isFill = true
  719. }
  720. } else if (draggingItem && draggingItem.type == VectorType.Beam) {
  721. if (geometry.vectorId == draggingItem.vectorId) {
  722. this.context.strokeStyle = Style.Select.Component.strokeStyle
  723. this.context.fillStyle = Style.Select.Component.fillStyle
  724. isFill = true
  725. }
  726. }
  727. if (focusItem && focusItem.type == VectorType.Beam) {
  728. if (geometry.vectorId == focusItem.vectorId) {
  729. this.context.strokeStyle = Style.Focus.Component.strokeStyle
  730. this.context.fillStyle = Style.Focus.Component.fillStyle
  731. isFill = true
  732. }
  733. }
  734. }
  735. this.context.beginPath()
  736. this.context.moveTo(points[0].x, points[0].y)
  737. this.context.lineTo(points[1].x, points[1].y)
  738. this.context.lineTo(points[2].x, points[2].y)
  739. this.context.lineTo(points[3].x, points[3].y)
  740. this.context.closePath()
  741. this.context.stroke()
  742. if (isFill) {
  743. this.context.fill()
  744. }
  745. //this.context.beginPath()
  746. this.context.moveTo(points[0].x, points[0].y)
  747. this.context.lineTo(points[2].x, points[2].y)
  748. //this.context.stroke()
  749. //this.context.beginPath()
  750. this.context.moveTo(points[1].x, points[1].y)
  751. this.context.lineTo(points[3].x, points[3].y)
  752. this.context.stroke()
  753. this.context.restore()
  754. }
  755. drawFlue(geometry, styleType) {
  756. let points2d = geometry.points2d
  757. let points = []
  758. for (let i = 0; i < points2d.length; ++i) {
  759. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  760. }
  761. this.context.save()
  762. this.context.lineWidth = Style.Component.lineWidth * coordinate.ratio
  763. this.context.strokeStyle = Style.Component.strokeStyle
  764. let isFill = false
  765. if (styleType) {
  766. if (styleType == 'style-1') {
  767. this.context.lineWidth = Style.DownLoad.style1.Component.lineWidth * coordinate.ratio
  768. this.context.strokeStyle = Style.DownLoad.style1.Component.strokeStyle
  769. } else if (styleType == 'style-2') {
  770. this.context.lineWidth = Style.DownLoad.style2.Component.lineWidth * coordinate.ratio
  771. this.context.strokeStyle = Style.DownLoad.style2.Component.strokeStyle
  772. } else if (styleType == 'style-3') {
  773. this.context.lineWidth = Style.DownLoad.style3.Component.lineWidth * coordinate.ratio
  774. this.context.strokeStyle = Style.DownLoad.style3.Component.strokeStyle
  775. } else if (styleType == 'style-4') {
  776. this.context.lineWidth = Style.DownLoad.style4.Component.lineWidth * coordinate.ratio
  777. this.context.strokeStyle = Style.DownLoad.style4.Component.strokeStyle
  778. }
  779. } else {
  780. const selectItem = stateService.getSelectItem()
  781. const draggingItem = stateService.getDraggingItem()
  782. const focusItem = stateService.getFocusItem()
  783. if (selectItem && selectItem.type == VectorType.Flue) {
  784. if (geometry.vectorId == selectItem.vectorId) {
  785. this.context.strokeStyle = Style.Select.Component.strokeStyle
  786. this.context.fillStyle = Style.Select.Component.fillStyle
  787. isFill = true
  788. }
  789. } else if (draggingItem && draggingItem.type == VectorType.Flue) {
  790. if (geometry.vectorId == draggingItem.vectorId) {
  791. this.context.strokeStyle = Style.Select.Component.strokeStyle
  792. this.context.fillStyle = Style.Select.Component.fillStyle
  793. isFill = true
  794. }
  795. }
  796. if (focusItem && focusItem.type == VectorType.Flue) {
  797. if (geometry.vectorId == focusItem.vectorId) {
  798. this.context.strokeStyle = Style.Focus.Component.strokeStyle
  799. this.context.fillStyle = Style.Focus.Component.fillStyle
  800. isFill = true
  801. }
  802. }
  803. }
  804. this.context.beginPath()
  805. this.context.moveTo(points[0].x, points[0].y)
  806. this.context.lineTo(points[1].x, points[1].y)
  807. this.context.lineTo(points[2].x, points[2].y)
  808. this.context.lineTo(points[3].x, points[3].y)
  809. this.context.closePath()
  810. this.context.stroke()
  811. if (isFill) {
  812. this.context.fill()
  813. }
  814. this.context.beginPath()
  815. this.context.moveTo(points[4].x, points[4].y)
  816. this.context.lineTo(points[5].x, points[5].y)
  817. this.context.lineTo(points[6].x, points[6].y)
  818. this.context.lineTo(points[7].x, points[7].y)
  819. this.context.closePath()
  820. this.context.stroke()
  821. this.context.moveTo(points[4].x, points[4].y)
  822. this.context.lineTo(points[8].x, points[8].y)
  823. this.context.lineTo(points[6].x, points[6].y)
  824. this.context.stroke()
  825. this.context.restore()
  826. }
  827. drawCorridor(geometry, styleType) {
  828. let points2d = geometry.points2d
  829. let points = []
  830. for (let i = 0; i < points2d.length; ++i) {
  831. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  832. }
  833. this.context.save()
  834. this.context.lineWidth = Style.Component.lineWidth * coordinate.ratio
  835. this.context.strokeStyle = Style.Component.strokeStyle
  836. if (styleType) {
  837. if (styleType == 'style-1') {
  838. this.context.lineWidth = Style.DownLoad.style1.Component.lineWidth * coordinate.ratio
  839. this.context.strokeStyle = Style.DownLoad.style1.Component.strokeStyle
  840. } else if (styleType == 'style-2') {
  841. this.context.lineWidth = Style.DownLoad.style2.Component.lineWidth * coordinate.ratio
  842. this.context.strokeStyle = Style.DownLoad.style2.Component.strokeStyle
  843. } else if (styleType == 'style-3') {
  844. this.context.lineWidth = Style.DownLoad.style3.Component.lineWidth * coordinate.ratio
  845. this.context.strokeStyle = Style.DownLoad.style3.Component.strokeStyle
  846. } else if (styleType == 'style-4') {
  847. this.context.lineWidth = Style.DownLoad.style4.Component.lineWidth * coordinate.ratio
  848. this.context.strokeStyle = Style.DownLoad.style4.Component.strokeStyle
  849. }
  850. } else {
  851. const selectItem = stateService.getSelectItem()
  852. const draggingItem = stateService.getDraggingItem()
  853. const focusItem = stateService.getFocusItem()
  854. if (selectItem && selectItem.type == VectorType.Corridor) {
  855. if (geometry.vectorId == selectItem.vectorId) {
  856. this.context.strokeStyle = Style.Select.Component.strokeStyle
  857. }
  858. } else if (draggingItem && draggingItem.type == VectorType.Corridor) {
  859. if (geometry.vectorId == draggingItem.vectorId) {
  860. this.context.strokeStyle = Style.Select.Component.strokeStyle
  861. }
  862. }
  863. if (focusItem && focusItem.type == VectorType.Corridor) {
  864. if (geometry.vectorId == focusItem.vectorId) {
  865. this.context.strokeStyle = Style.Focus.Component.strokeStyle
  866. }
  867. }
  868. }
  869. this.context.beginPath()
  870. this.context.moveTo(points[0].x, points[0].y)
  871. this.context.lineTo(points[1].x, points[1].y)
  872. this.context.lineTo(points[2].x, points[2].y)
  873. this.context.lineTo(points[3].x, points[3].y)
  874. this.context.closePath()
  875. this.context.stroke()
  876. for (let i = 4; i < points.length - 1; i += 2) {
  877. this.context.moveTo(points[i].x, points[i].y)
  878. this.context.lineTo(points[i + 1].x, points[i + 1].y)
  879. }
  880. this.context.stroke()
  881. this.context.restore()
  882. }
  883. drawTag(geometry, styleType, hide) {
  884. this.context.save()
  885. this.context.lineWidth = Style.Tag.lineWidth * coordinate.ratio
  886. this.context.strokeStyle = Style.Tag.strokeStyle
  887. this.context.fillStyle = Style.Tag.fillStyle
  888. if (styleType) {
  889. if (styleType == 'style-1') {
  890. this.context.lineWidth = Style.DownLoad.style1.Tag.lineWidth * coordinate.ratio
  891. this.context.strokeStyle = Style.DownLoad.style1.Tag.strokeStyle
  892. this.context.fillStyle = Style.DownLoad.style1.Tag.fillStyle
  893. } else if (styleType == 'style-2') {
  894. this.context.lineWidth = Style.DownLoad.style2.Tag.lineWidth * coordinate.ratio
  895. this.context.strokeStyle = Style.DownLoad.style2.Tag.strokeStyle
  896. this.context.fillStyle = Style.DownLoad.style2.Tag.fillStyle
  897. } else if (styleType == 'style-3') {
  898. this.context.lineWidth = Style.DownLoad.style3.Tag.lineWidth * coordinate.ratio
  899. this.context.strokeStyle = Style.DownLoad.style3.Tag.strokeStyle
  900. this.context.fillStyle = Style.DownLoad.style3.Tag.fillStyle
  901. } else if (styleType == 'style-4') {
  902. this.context.lineWidth = Style.DownLoad.style4.Tag.lineWidth * coordinate.ratio
  903. this.context.strokeStyle = Style.DownLoad.style4.Tag.strokeStyle
  904. this.context.fillStyle = Style.DownLoad.style4.Tag.fillStyle
  905. }
  906. } else {
  907. const selectItem = stateService.getSelectItem()
  908. const draggingItem = stateService.getDraggingItem()
  909. const focusItem = stateService.getFocusItem()
  910. if (selectItem && selectItem.type == VectorType.Tag) {
  911. if (geometry.vectorId == selectItem.vectorId) {
  912. this.context.strokeStyle = Style.Select.Tag.strokeStyle
  913. this.context.fillStyle = Style.Select.Tag.fillStyle
  914. }
  915. } else if (draggingItem && draggingItem.type == VectorType.Tag) {
  916. if (geometry.vectorId == draggingItem.vectorId) {
  917. this.context.strokeStyle = Style.Select.Tag.strokeStyle
  918. this.context.fillStyle = Style.Select.Tag.fillStyle
  919. }
  920. }
  921. if (focusItem && focusItem.type == VectorType.Tag) {
  922. if (geometry.vectorId == focusItem.vectorId) {
  923. this.context.strokeStyle = Style.Focus.Tag.strokeStyle
  924. this.context.fillStyle = Style.Focus.Tag.fillStyle
  925. }
  926. }
  927. }
  928. //正在添加
  929. if (geometry.adding) {
  930. let points2d = geometry.points2d
  931. let points = []
  932. for (let i = 0; i < points2d.length; ++i) {
  933. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  934. }
  935. this.context.strokeStyle = Style.Tag.strokeStyle_adding
  936. this.context.fillStyle = Style.Tag.fillStyle_adding
  937. this.context.beginPath()
  938. this.context.moveTo(points[0].x, points[0].y)
  939. this.context.lineTo(points[1].x, points[1].y)
  940. this.context.lineTo(points[2].x, points[2].y)
  941. this.context.lineTo(points[3].x, points[3].y)
  942. this.context.closePath()
  943. this.context.stroke()
  944. for (let i = 4; i < points.length - 1; i += 2) {
  945. this.context.moveTo(points[i].x, points[i].y)
  946. this.context.lineTo(points[i + 1].x, points[i + 1].y)
  947. }
  948. this.context.stroke()
  949. } else {
  950. const fontSize = coordinate.ratio == Constant.ratio ? 36 : 12
  951. this.context.font = `400 ${fontSize}px Microsoft YaHei`
  952. //根据文字的长度,更新标注范围
  953. let title = geometry.title
  954. if (!hide && (title == null || title.trim() == '')) {
  955. console.log(floorplanService.$app.config)
  956. // title = '请输入名称'
  957. title = floorplanService.$app.config.i18n('cad.input')
  958. }
  959. geometry.des += ''
  960. if (geometry.des != '') {
  961. geometry.sideWidth = Math.max(this.context.measureText(title).width, this.context.measureText(parseFloat(geometry.des.replace(',', '')).toFixed(2)).width)
  962. geometry.setPoints2d()
  963. }
  964. let points2d = geometry.points2d
  965. let points = []
  966. for (let i = 0; i < points2d.length; ++i) {
  967. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  968. }
  969. let pt = { x: geometry.center.x, y: geometry.center.y }
  970. pt = coordinate.getScreenXY({ x: geometry.center.x, y: geometry.center.y })
  971. const fontWidth1 = this.context.measureText(title).width
  972. 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 })
  973. let fontWidth2 = this.context.measureText(geometry.des + 'm²').width
  974. if (geometry.des != '' && geometry.unit == 'ft') {
  975. fontWidth2 = this.context.measureText(parseFloat(geometry.des.replace(',', '')).toFixed(2) + 'ft²').width
  976. }
  977. const line2 = mathUtil.createLine1(points[2], points[3])
  978. const fontStart1 = mathUtil.getDisPointsLine(line1, pt, fontWidth1 / 2, fontWidth1 / 2)
  979. const fontStart2 = mathUtil.getDisPointsLine(line2, { x: (points[2].x + points[3].x) / 2, y: (points[2].y + points[3].y) / 2 }, fontWidth2 / 2, fontWidth2 / 2)
  980. if (fontStart1.newpoint1.x < fontStart1.newpoint2.x) {
  981. this.context.fillText(title, fontStart1.newpoint1.x, fontStart1.newpoint1.y)
  982. } else {
  983. this.context.fillText(title, fontStart1.newpoint2.x, fontStart1.newpoint2.y)
  984. }
  985. }
  986. this.context.restore()
  987. }
  988. // drawFurniture2(geometry) {
  989. // // //this.app.store.getAppImage(`images/cad/furnitures/${this.uiControl.selectUI}.svg`).then(img => {})
  990. // // var img = new Image()
  991. // // // img.src = 'chart.svg';
  992. // // // if(geometry.geoType == ''){
  993. // // // img.src = '';
  994. // // // }
  995. // // document.body.appendChild(img)
  996. // // img.onload = function () {
  997. // // var width = img.clientWidth * 1.5
  998. // // var height = img.clientHeight * 1.5
  999. // // var x = 2
  1000. // // var y = 2
  1001. // // this.context.drawImage(img, x, y, width, height)
  1002. // // }
  1003. // this.context.save()
  1004. // let imgWidth = geometry.sideLength * coordinate.res*50
  1005. // let imgHeight = geometry.sideLength * coordinate.res*50
  1006. // const pt = coordinate.getScreenXY({
  1007. // x: geometry.center.x - geometry.sideLength *50/ 2,
  1008. // y: geometry.center.y + geometry.sideLength *50/ 2,
  1009. // })
  1010. // // furnitureService.getFurniture(geometry.geoType).then(img => {
  1011. // // this.context.drawImage(img, pt.x, pt.y, imgWidth, imgHeight)
  1012. // // })
  1013. // let img = furnitureService.getFurniture(geometry.geoType)
  1014. // this.context.drawImage(img, pt.x, pt.y, imgWidth, imgHeight)
  1015. // this.context.restore()
  1016. // }
  1017. drawCircle(element) {
  1018. let radius = null
  1019. const twoPi = Math.PI * 2
  1020. const pt = coordinate.getScreenXY(element)
  1021. this.context.save()
  1022. if (element.name == ElementEvents.StartAddWall) {
  1023. radius = Style.Element.StartAddWall.radius * coordinate.ratio
  1024. this.context.strokeStyle = Style.Element.StartAddWall.strokeStyle
  1025. this.context.fillStyle = Style.Element.StartAddWall.fillStyle
  1026. } else if (element.name == ElementEvents.StartSymbolPoints) {
  1027. radius = Style.Element.StartSymbolPoints.radius * coordinate.ratio
  1028. this.context.strokeStyle = Style.Element.StartSymbolPoints.strokeStyle
  1029. this.context.fillStyle = Style.Element.StartSymbolPoints.fillStyle
  1030. } else if (element.name == ElementEvents.EndSymbolPoints) {
  1031. radius = Style.Element.EndSymbolPoints.radius * coordinate.ratio
  1032. this.context.strokeStyle = Style.Element.EndSymbolPoints.strokeStyle
  1033. this.context.fillStyle = Style.Element.EndSymbolPoints.fillStyle
  1034. } else if (element.name == 'pano') {
  1035. radius = Style.Pano.radius * coordinate.ratio
  1036. this.context.strokeStyle = Style.Pano.strokeStyle
  1037. this.context.fillStyle = Style.Pano.fillStyle
  1038. this.context.lineWidth = Style.Pano.lineWidth
  1039. }
  1040. this.context.beginPath()
  1041. this.context.arc(pt.x, pt.y, radius, 0, twoPi, true)
  1042. this.context.stroke()
  1043. this.context.fill()
  1044. this.context.restore()
  1045. }
  1046. drawLine(element) {
  1047. let start = coordinate.getScreenXY(element.start)
  1048. let end = coordinate.getScreenXY(element.end)
  1049. this.context.save()
  1050. if (element.name == ElementEvents.VCheckLinesX) {
  1051. this.context.lineWidth = Style.Element.VCheckLinesX.lineWidth * coordinate.ratio
  1052. this.context.strokeStyle = Style.Element.VCheckLinesX.strokeStyle
  1053. this.context.setLineDash([3, 2, 2])
  1054. start.y = 0
  1055. end.y = this.context.canvas.clientHeight
  1056. } else if (element.name == ElementEvents.VCheckLinesY) {
  1057. this.context.lineWidth = Style.Element.VCheckLinesY.lineWidth * coordinate.ratio
  1058. this.context.strokeStyle = Style.Element.VCheckLinesY.strokeStyle
  1059. this.context.setLineDash([3, 2, 2])
  1060. start.x = 0
  1061. end.x = this.context.canvas.clientWidth
  1062. } else if (element.name == ElementEvents.NewWall) {
  1063. this.context.lineWidth = Style.Element.NewWall.lineWidth * coordinate.ratio
  1064. this.context.strokeStyle = Style.Element.NewWall.strokeStyle
  1065. if (element.state == 'error') {
  1066. this.context.strokeStyle = Style.Element.NewWall.errorStrokeStyle
  1067. } else if (element.state == 'normal-out') {
  1068. this.context.strokeStyle = Style.Element.NewWall.strokeStyle_out
  1069. this.context.lineWidth = Style.Element.NewWall.lineWidth_out * coordinate.ratio
  1070. }
  1071. } else if (element.name == ElementEvents.CheckLinesX) {
  1072. this.context.lineWidth = Style.Element.CheckLinesX.lineWidth * coordinate.ratio
  1073. this.context.strokeStyle = Style.Element.CheckLinesX.strokeStyle
  1074. this.context.setLineDash([3, 2, 2])
  1075. } else if (element.name == ElementEvents.CheckLinesY) {
  1076. this.context.lineWidth = Style.Element.CheckLinesY.lineWidth * coordinate.ratio
  1077. this.context.strokeStyle = Style.Element.CheckLinesY.strokeStyle
  1078. this.context.setLineDash([3, 2, 2])
  1079. }
  1080. this.context.beginPath()
  1081. this.context.moveTo(start.x, start.y)
  1082. this.context.lineTo(end.x, end.y)
  1083. this.context.stroke()
  1084. this.context.restore()
  1085. if (element.name == ElementEvents.NewWall) {
  1086. //添加测量值
  1087. this.drawMeasureTxt(element.start, element.end)
  1088. }
  1089. this.context.save()
  1090. this.context.lineWidth = Style.Point.lineWidth * coordinate.ratio
  1091. this.context.strokeStyle = Style.Point.strokeStyle
  1092. this.context.fillStyle = Style.Point.fillStyle
  1093. let radius = Style.Point.radius
  1094. this.context.beginPath()
  1095. this.context.arc(start.x, start.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
  1096. this.context.stroke()
  1097. this.context.fill()
  1098. this.context.restore()
  1099. }
  1100. drawCompass(styleType) {
  1101. const padTop = 160
  1102. const padRight = 310
  1103. let img = null
  1104. if (styleType == 'style-1' || styleType == 'style-3') {
  1105. img = compassService.getWhiteImg()
  1106. } else {
  1107. img = compassService.getBlackImg()
  1108. }
  1109. let angle = floorplanService.getCompass()
  1110. this.context.save()
  1111. this.context.translate((coordinate.width - padRight) * coordinate.ratio, padTop * coordinate.ratio)
  1112. this.context.rotate((angle / 180) * Math.PI)
  1113. this.context.scale(coordinate.ratio / 2, coordinate.ratio / 2)
  1114. this.context.drawImage(img, -img.width / 2, -img.height / 2)
  1115. this.context.restore()
  1116. }
  1117. setCanvasStyle(style) {
  1118. for (const key in style) {
  1119. if (key != 'isFill' && key != 'isStroke') {
  1120. this.context[key] = style[key]
  1121. }
  1122. }
  1123. }
  1124. /*************************************************************************************家具**********************************************************************************************/
  1125. drawFurniture(geometry) {
  1126. if (geometry.geoType == VectorType.TV) {
  1127. this.drawTV(geometry)
  1128. } else if (geometry.geoType == VectorType.CombinationSofa) {
  1129. this.drawCombinationSofa(geometry)
  1130. } else if (geometry.geoType == VectorType.SingleSofa) {
  1131. this.drawSingleSofa(geometry)
  1132. } else if (geometry.geoType == VectorType.TeaTable) {
  1133. this.drawTeaTable(geometry)
  1134. } else if (geometry.geoType == VectorType.Carpet) {
  1135. this.drawCarpet(geometry)
  1136. } else if (geometry.geoType == VectorType.Plant) {
  1137. this.drawPlant(geometry)
  1138. } else if (geometry.geoType == VectorType.DiningTable) {
  1139. this.drawDiningTable(geometry)
  1140. } else if (geometry.geoType == VectorType.DoubleBed) {
  1141. this.drawDoubleBed(geometry)
  1142. } else if (geometry.geoType == VectorType.SingleBed) {
  1143. this.drawSingleBed(geometry)
  1144. } else if (geometry.geoType == VectorType.Wardrobe) {
  1145. this.drawWardrobe(geometry)
  1146. } else if (geometry.geoType == VectorType.Dresser) {
  1147. this.drawDresser(geometry)
  1148. } else if (geometry.geoType == VectorType.BedsideCupboard) {
  1149. this.drawBedsideCupboard(geometry)
  1150. } else if (geometry.geoType == VectorType.Pillow) {
  1151. this.drawPillow(geometry)
  1152. } else if (geometry.geoType == VectorType.GasStove) {
  1153. this.drawGasStove(geometry)
  1154. } else if (geometry.geoType == VectorType.Cupboard) {
  1155. this.drawCupboard(geometry)
  1156. } else if (geometry.geoType == VectorType.Bathtub) {
  1157. this.drawBathtub(geometry)
  1158. } else if (geometry.geoType == VectorType.Closestool) {
  1159. this.drawClosestool(geometry)
  1160. } else if (geometry.geoType == VectorType.Washstand) {
  1161. this.drawWashstand(geometry)
  1162. } else if (geometry.geoType == VectorType.Desk) {
  1163. this.drawDesk(geometry)
  1164. } else if (geometry.geoType == VectorType.BalconyChair) {
  1165. this.drawBalconyChair(geometry)
  1166. } else if (geometry.geoType == VectorType.Elevator) {
  1167. this.drawElevator(geometry)
  1168. }
  1169. }
  1170. drawTV(geometry) {
  1171. const selectItem = stateService.getSelectItem()
  1172. const draggingItem = stateService.getDraggingItem()
  1173. const focusItem = stateService.getFocusItem()
  1174. this.context.save()
  1175. this.context.strokeStyle = Style.Furniture.strokeStyle
  1176. this.context.fillStyle = Style.Furniture.fillStyle
  1177. if (selectItem && selectItem.type == VectorType.TV) {
  1178. if (geometry.vectorId == selectItem.vectorId) {
  1179. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1180. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1181. }
  1182. } else if (draggingItem && draggingItem.type == VectorType.TV) {
  1183. if (geometry.vectorId == draggingItem.vectorId) {
  1184. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1185. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1186. }
  1187. }
  1188. if (focusItem && focusItem.type == VectorType.TV) {
  1189. if (geometry.vectorId == focusItem.vectorId) {
  1190. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  1191. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  1192. }
  1193. }
  1194. const center = coordinate.getScreenXY({
  1195. x: geometry.center.x,
  1196. y: geometry.center.y,
  1197. })
  1198. const pt = coordinate.getScreenXY({
  1199. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1200. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1201. })
  1202. this.context.translate(center.x, center.y)
  1203. this.context.rotate((geometry.angle / 180) * Math.PI)
  1204. this.context.translate(pt.x - center.x, pt.y - center.y)
  1205. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1206. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1207. this.context.miterLimit = 4
  1208. this.context.font = "15px ''"
  1209. this.context.beginPath()
  1210. this.context.moveTo(0.5, 12.5)
  1211. this.context.lineTo(31.5, 12.5)
  1212. this.context.lineTo(31.5, 20.5)
  1213. this.context.lineTo(0.5, 20.5)
  1214. this.context.lineTo(0.5, 12.5)
  1215. this.context.closePath()
  1216. this.context.fill()
  1217. this.context.stroke()
  1218. this.context.beginPath()
  1219. this.context.moveTo(7.5, 16.5)
  1220. this.context.lineTo(24.5, 16.5)
  1221. this.context.lineTo(24.5, 18.5)
  1222. this.context.lineTo(7.5, 18.5)
  1223. this.context.lineTo(7.5, 16.5)
  1224. this.context.closePath()
  1225. this.context.fill()
  1226. this.context.stroke()
  1227. this.context.beginPath()
  1228. this.context.moveTo(22, 16.5)
  1229. this.context.lineTo(21, 14.5)
  1230. this.context.lineTo(11, 14.5)
  1231. this.context.lineTo(10, 16.5)
  1232. this.context.fill()
  1233. this.context.stroke()
  1234. this.context.restore()
  1235. }
  1236. drawCombinationSofa(geometry) {
  1237. const selectItem = stateService.getSelectItem()
  1238. const draggingItem = stateService.getDraggingItem()
  1239. const focusItem = stateService.getFocusItem()
  1240. this.context.save()
  1241. this.context.strokeStyle = Style.Furniture.strokeStyle
  1242. this.context.fillStyle = Style.Furniture.fillStyle
  1243. if (selectItem && selectItem.type == VectorType.CombinationSofa) {
  1244. if (geometry.vectorId == selectItem.vectorId) {
  1245. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1246. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1247. }
  1248. } else if (draggingItem && draggingItem.type == VectorType.CombinationSofa) {
  1249. if (geometry.vectorId == draggingItem.vectorId) {
  1250. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1251. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1252. }
  1253. }
  1254. if (focusItem && focusItem.type == VectorType.CombinationSofa) {
  1255. if (geometry.vectorId == focusItem.vectorId) {
  1256. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  1257. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  1258. }
  1259. }
  1260. const center = coordinate.getScreenXY({
  1261. x: geometry.center.x,
  1262. y: geometry.center.y,
  1263. })
  1264. const pt = coordinate.getScreenXY({
  1265. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1266. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1267. })
  1268. this.context.translate(center.x, center.y)
  1269. this.context.rotate((geometry.angle / 180) * Math.PI)
  1270. this.context.translate(pt.x - center.x, pt.y - center.y)
  1271. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1272. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1273. this.context.miterLimit = 4
  1274. this.context.font = "15px ''"
  1275. this.context.beginPath()
  1276. this.context.moveTo(4, 16)
  1277. this.context.lineTo(19, 16)
  1278. this.context.lineTo(19, 25)
  1279. this.context.lineTo(4, 25)
  1280. this.context.lineTo(4, 16)
  1281. this.context.closePath()
  1282. this.context.fill()
  1283. this.context.stroke()
  1284. this.context.beginPath()
  1285. this.context.moveTo(6, 18)
  1286. this.context.lineTo(17, 18)
  1287. this.context.lineTo(17, 23)
  1288. this.context.lineTo(6, 23)
  1289. this.context.lineTo(6, 18)
  1290. this.context.closePath()
  1291. this.context.fill()
  1292. this.context.stroke()
  1293. this.context.beginPath()
  1294. this.context.moveTo(21.5, 19.5)
  1295. this.context.bezierCurveTo(21.5, 18.9477, 21.9477, 18.5, 22.5, 18.5)
  1296. this.context.lineTo(30.5, 18.5)
  1297. this.context.bezierCurveTo(31.0523, 18.5, 31.5, 18.9477, 31.5, 19.5)
  1298. this.context.lineTo(31.5, 24.5)
  1299. this.context.bezierCurveTo(31.5, 25.0523, 31.0523, 25.5, 30.5, 25.5)
  1300. this.context.lineTo(22.5, 25.5)
  1301. this.context.bezierCurveTo(21.9477, 25.5, 21.5, 25.0523, 21.5, 24.5)
  1302. this.context.lineTo(21.5, 19.5)
  1303. this.context.closePath()
  1304. this.context.fill()
  1305. this.context.stroke()
  1306. this.context.beginPath()
  1307. this.context.moveTo(3.5, 4.5)
  1308. this.context.bezierCurveTo(3.5, 3.94772, 3.94772, 3.5, 4.5, 3.5)
  1309. this.context.lineTo(17.5, 3.5)
  1310. this.context.bezierCurveTo(18.0523, 3.5, 18.5, 3.94772, 18.5, 4.5)
  1311. this.context.lineTo(18.5, 11.5)
  1312. this.context.bezierCurveTo(18.5, 12.0523, 18.0523, 12.5, 17.5, 12.5)
  1313. this.context.lineTo(4.5, 12.5)
  1314. this.context.bezierCurveTo(3.94772, 12.5, 3.5, 12.0523, 3.5, 11.5)
  1315. this.context.lineTo(3.5, 4.5)
  1316. this.context.closePath()
  1317. this.context.fill()
  1318. this.context.stroke()
  1319. this.context.beginPath()
  1320. this.context.moveTo(3.5, 5.5)
  1321. this.context.lineTo(1.5, 5.5)
  1322. this.context.bezierCurveTo(0.947715, 5.5, 0.5, 5.94772, 0.5, 6.5)
  1323. this.context.lineTo(0.5, 10.5)
  1324. this.context.bezierCurveTo(0.5, 11.0523, 0.947715, 11.5, 1.5, 11.5)
  1325. this.context.lineTo(3.5, 11.5)
  1326. this.context.fill()
  1327. this.context.stroke()
  1328. this.context.beginPath()
  1329. this.context.moveTo(18.5, 5.5)
  1330. this.context.lineTo(20.5, 5.5)
  1331. this.context.bezierCurveTo(21.0523, 5.5, 21.5, 5.94772, 21.5, 6.5)
  1332. this.context.lineTo(21.5, 10.5)
  1333. this.context.bezierCurveTo(21.5, 11.0523, 21.0523, 11.5, 20.5, 11.5)
  1334. this.context.lineTo(18.5, 11.5)
  1335. this.context.fill()
  1336. this.context.stroke()
  1337. this.context.beginPath()
  1338. this.context.moveTo(4, 6.5)
  1339. this.context.lineTo(18, 6.5)
  1340. this.context.fill()
  1341. this.context.stroke()
  1342. this.context.beginPath()
  1343. this.context.moveTo(22.5, 25.5)
  1344. this.context.lineTo(22.5, 27.5)
  1345. this.context.bezierCurveTo(22.5, 28.0523, 22.9477, 28.5, 23.5, 28.5)
  1346. this.context.lineTo(29.5, 28.5)
  1347. this.context.bezierCurveTo(30.0523, 28.5, 30.5, 28.0523, 30.5, 27.5)
  1348. this.context.lineTo(30.5, 25.5)
  1349. this.context.fill()
  1350. this.context.stroke()
  1351. this.context.beginPath()
  1352. this.context.moveTo(22.5, 18.5)
  1353. this.context.lineTo(22.5, 16.5)
  1354. this.context.bezierCurveTo(22.5, 15.9477, 22.9477, 15.5, 23.5, 15.5)
  1355. this.context.lineTo(29.5, 15.5)
  1356. this.context.bezierCurveTo(30.0523, 15.5, 30.5, 15.9477, 30.5, 16.5)
  1357. this.context.lineTo(30.5, 18.5)
  1358. this.context.fill()
  1359. this.context.stroke()
  1360. this.context.beginPath()
  1361. this.context.moveTo(28.5, 19)
  1362. this.context.lineTo(28.5, 25)
  1363. this.context.fill()
  1364. this.context.stroke()
  1365. this.context.beginPath()
  1366. this.context.moveTo(8.5, 4)
  1367. this.context.lineTo(8.5, 12)
  1368. this.context.fill()
  1369. this.context.stroke()
  1370. this.context.beginPath()
  1371. this.context.moveTo(13.5, 4)
  1372. this.context.lineTo(13.5, 12)
  1373. this.context.fill()
  1374. this.context.stroke()
  1375. this.context.restore()
  1376. }
  1377. drawSingleSofa(geometry) {
  1378. const selectItem = stateService.getSelectItem()
  1379. const draggingItem = stateService.getDraggingItem()
  1380. const focusItem = stateService.getFocusItem()
  1381. this.context.save()
  1382. this.context.strokeStyle = Style.Furniture.strokeStyle
  1383. this.context.fillStyle = Style.Furniture.fillStyle
  1384. if (selectItem && selectItem.type == VectorType.SingleSofa) {
  1385. if (geometry.vectorId == selectItem.vectorId) {
  1386. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1387. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1388. }
  1389. } else if (draggingItem && draggingItem.type == VectorType.SingleSofa) {
  1390. if (geometry.vectorId == draggingItem.vectorId) {
  1391. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1392. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1393. }
  1394. }
  1395. if (focusItem && focusItem.type == VectorType.SingleSofa) {
  1396. if (geometry.vectorId == focusItem.vectorId) {
  1397. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  1398. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  1399. }
  1400. }
  1401. const center = coordinate.getScreenXY({
  1402. x: geometry.center.x,
  1403. y: geometry.center.y,
  1404. })
  1405. const pt = coordinate.getScreenXY({
  1406. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1407. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1408. })
  1409. this.context.translate(center.x, center.y)
  1410. this.context.rotate((geometry.angle / 180) * Math.PI)
  1411. this.context.translate(pt.x - center.x, pt.y - center.y)
  1412. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1413. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1414. this.context.miterLimit = 4
  1415. this.context.font = "15px ''"
  1416. this.context.beginPath()
  1417. this.context.moveTo(23, 8.5)
  1418. this.context.lineTo(27.5, 8.5)
  1419. this.context.bezierCurveTo(28.0523, 8.5, 28.5, 8.94772, 28.5, 9.5)
  1420. this.context.lineTo(28.5, 22.5)
  1421. this.context.bezierCurveTo(28.5, 23.0523, 28.0523, 23.5, 27.5, 23.5)
  1422. this.context.lineTo(23, 23.5)
  1423. this.context.fill()
  1424. this.context.stroke()
  1425. this.context.beginPath()
  1426. this.context.moveTo(9, 8.5)
  1427. this.context.lineTo(4.5, 8.5)
  1428. this.context.bezierCurveTo(3.94772, 8.5, 3.5, 8.94772, 3.5, 9.5)
  1429. this.context.lineTo(3.5, 22.5)
  1430. this.context.bezierCurveTo(3.5, 23.0523, 3.94772, 23.5, 4.5, 23.5)
  1431. this.context.lineTo(9, 23.5)
  1432. this.context.fill()
  1433. this.context.stroke()
  1434. this.context.beginPath()
  1435. this.context.moveTo(9.5, 7.5)
  1436. this.context.bezierCurveTo(9.5, 6.94771, 9.94772, 6.5, 10.5, 6.5)
  1437. this.context.lineTo(21.5, 6.5)
  1438. this.context.bezierCurveTo(22.0523, 6.5, 22.5, 6.94772, 22.5, 7.5)
  1439. this.context.lineTo(22.5, 24.5)
  1440. this.context.bezierCurveTo(22.5, 25.0523, 22.0523, 25.5, 21.5, 25.5)
  1441. this.context.lineTo(10.5, 25.5)
  1442. this.context.bezierCurveTo(9.94772, 25.5, 9.5, 25.0523, 9.5, 24.5)
  1443. this.context.closePath()
  1444. this.context.fill()
  1445. this.context.stroke()
  1446. this.context.beginPath()
  1447. this.context.moveTo(10, 12.5)
  1448. this.context.lineTo(22, 12.5)
  1449. this.context.fill()
  1450. this.context.stroke()
  1451. this.context.restore()
  1452. }
  1453. drawTeaTable(geometry) {
  1454. const selectItem = stateService.getSelectItem()
  1455. const draggingItem = stateService.getDraggingItem()
  1456. const focusItem = stateService.getFocusItem()
  1457. this.context.save()
  1458. this.context.strokeStyle = Style.Furniture.strokeStyle
  1459. this.context.fillStyle = Style.Furniture.fillStyle
  1460. if (selectItem && selectItem.type == VectorType.TeaTable) {
  1461. if (geometry.vectorId == selectItem.vectorId) {
  1462. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1463. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1464. }
  1465. } else if (draggingItem && draggingItem.type == VectorType.TeaTable) {
  1466. if (geometry.vectorId == draggingItem.vectorId) {
  1467. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1468. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1469. }
  1470. }
  1471. if (focusItem && focusItem.type == VectorType.TeaTable) {
  1472. if (geometry.vectorId == focusItem.vectorId) {
  1473. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  1474. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  1475. }
  1476. }
  1477. const center = coordinate.getScreenXY({
  1478. x: geometry.center.x,
  1479. y: geometry.center.y,
  1480. })
  1481. const pt = coordinate.getScreenXY({
  1482. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1483. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1484. })
  1485. this.context.translate(center.x, center.y)
  1486. this.context.rotate((geometry.angle / 180) * Math.PI)
  1487. this.context.translate(pt.x - center.x, pt.y - center.y)
  1488. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1489. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1490. this.context.miterLimit = 4
  1491. this.context.font = "15px ''"
  1492. this.context.beginPath()
  1493. this.context.moveTo(1.5, 8.5)
  1494. this.context.lineTo(30.5, 8.5)
  1495. this.context.lineTo(30.5, 23.5)
  1496. this.context.lineTo(1.5, 23.5)
  1497. this.context.lineTo(1.5, 8.5)
  1498. this.context.closePath()
  1499. this.context.fill()
  1500. this.context.stroke()
  1501. this.context.beginPath()
  1502. this.context.moveTo(3.5, 10.5)
  1503. this.context.lineTo(28.5, 10.5)
  1504. this.context.lineTo(28.5, 21.5)
  1505. this.context.lineTo(3.5, 21.5)
  1506. this.context.lineTo(3.5, 10.5)
  1507. this.context.closePath()
  1508. this.context.fill()
  1509. this.context.stroke()
  1510. this.context.beginPath()
  1511. this.context.moveTo(3.5, 21.5)
  1512. this.context.lineTo(14.5, 10.5)
  1513. this.context.fill()
  1514. this.context.stroke()
  1515. this.context.beginPath()
  1516. this.context.moveTo(28.5, 13.5)
  1517. this.context.lineTo(22.5, 19.5)
  1518. this.context.fill()
  1519. this.context.stroke()
  1520. this.context.beginPath()
  1521. this.context.moveTo(16.5, 21.5)
  1522. this.context.lineTo(23, 15)
  1523. this.context.fill()
  1524. this.context.stroke()
  1525. this.context.beginPath()
  1526. this.context.moveTo(28.5, 17)
  1527. this.context.lineTo(24, 21.5)
  1528. this.context.fill()
  1529. this.context.stroke()
  1530. this.context.beginPath()
  1531. this.context.moveTo(16.5, 21.5)
  1532. this.context.lineTo(23, 15)
  1533. this.context.fill()
  1534. this.context.stroke()
  1535. this.context.beginPath()
  1536. this.context.moveTo(7.5, 21.5)
  1537. this.context.lineTo(18.5, 10.5)
  1538. this.context.fill()
  1539. this.context.stroke()
  1540. this.context.beginPath()
  1541. this.context.moveTo(3.5, 15.5)
  1542. this.context.lineTo(8.5, 10.5)
  1543. this.context.fill()
  1544. this.context.stroke()
  1545. this.context.restore()
  1546. }
  1547. drawCarpet(geometry) {
  1548. const selectItem = stateService.getSelectItem()
  1549. const draggingItem = stateService.getDraggingItem()
  1550. const focusItem = stateService.getFocusItem()
  1551. this.context.save()
  1552. this.context.strokeStyle = Style.Furniture.strokeStyle
  1553. this.context.fillStyle = Style.Furniture.fillStyle
  1554. if (selectItem && selectItem.type == VectorType.Carpet) {
  1555. if (geometry.vectorId == selectItem.vectorId) {
  1556. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1557. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1558. }
  1559. } else if (draggingItem && draggingItem.type == VectorType.Carpet) {
  1560. if (geometry.vectorId == draggingItem.vectorId) {
  1561. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1562. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1563. }
  1564. }
  1565. if (focusItem && focusItem.type == VectorType.Carpet) {
  1566. if (geometry.vectorId == focusItem.vectorId) {
  1567. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  1568. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  1569. }
  1570. }
  1571. const center = coordinate.getScreenXY({
  1572. x: geometry.center.x,
  1573. y: geometry.center.y,
  1574. })
  1575. const pt = coordinate.getScreenXY({
  1576. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1577. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1578. })
  1579. this.context.translate(center.x, center.y)
  1580. this.context.rotate((geometry.angle / 180) * Math.PI)
  1581. this.context.translate(pt.x - center.x, pt.y - center.y)
  1582. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1583. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1584. this.context.miterLimit = 4
  1585. this.context.font = "15px ''"
  1586. this.context.beginPath()
  1587. this.context.moveTo(31.5, 16)
  1588. this.context.bezierCurveTo(31.5, 21.5228, 24.8366, 25.5, 16, 25.5)
  1589. this.context.bezierCurveTo(7.16344, 25.5, 0.5, 21.5228, 0.5, 16)
  1590. this.context.bezierCurveTo(0.5, 10.4772, 7.16344, 6.5, 16, 6.5)
  1591. this.context.bezierCurveTo(24.8366, 6.5, 31.5, 10.4772, 31.5, 16)
  1592. this.context.closePath()
  1593. this.context.fill()
  1594. this.context.stroke()
  1595. this.context.beginPath()
  1596. this.context.moveTo(0.5, 16)
  1597. this.context.lineTo(4.5, 16.5)
  1598. this.context.fill()
  1599. this.context.stroke()
  1600. this.context.beginPath()
  1601. this.context.moveTo(5, 9.5)
  1602. this.context.lineTo(6.5, 12.5)
  1603. this.context.fill()
  1604. this.context.stroke()
  1605. this.context.beginPath()
  1606. this.context.moveTo(9, 7.5)
  1607. this.context.lineTo(10, 10.5)
  1608. this.context.fill()
  1609. this.context.stroke()
  1610. this.context.beginPath()
  1611. this.context.moveTo(16, 9.5)
  1612. this.context.lineTo(18.5, 6.5)
  1613. this.context.fill()
  1614. this.context.stroke()
  1615. this.context.beginPath()
  1616. this.context.moveTo(27.5, 16)
  1617. this.context.bezierCurveTo(27.5, 20.0695, 22.2711, 22.5, 16, 22.5)
  1618. this.context.bezierCurveTo(9.7289, 22.5, 4.5, 20.0695, 4.5, 16)
  1619. this.context.bezierCurveTo(4.5, 11.9305, 9.7289, 9.5, 16, 9.5)
  1620. this.context.bezierCurveTo(22.2711, 9.5, 27.5, 11.9305, 27.5, 16)
  1621. this.context.closePath()
  1622. this.context.fill()
  1623. this.context.stroke()
  1624. this.context.beginPath()
  1625. this.context.moveTo(27, 17.5)
  1626. this.context.lineTo(30.5, 19.5)
  1627. this.context.fill()
  1628. this.context.stroke()
  1629. this.context.beginPath()
  1630. this.context.moveTo(10, 21.5)
  1631. this.context.lineTo(8.5, 24.5)
  1632. this.context.fill()
  1633. this.context.stroke()
  1634. this.context.beginPath()
  1635. this.context.moveTo(21.5, 7)
  1636. this.context.bezierCurveTo(21.5, 7, 20.5, 7.5, 20.5, 8.5)
  1637. this.context.bezierCurveTo(20.5, 9.5, 21, 10, 21, 10)
  1638. this.context.fill()
  1639. this.context.stroke()
  1640. this.context.beginPath()
  1641. this.context.moveTo(12.5, 22.5)
  1642. this.context.lineTo(11.5, 25)
  1643. this.context.fill()
  1644. this.context.stroke()
  1645. this.context.beginPath()
  1646. this.context.moveTo(20.5001, 22)
  1647. this.context.bezierCurveTo(20.5001, 22, 19.3705, 22.759, 19, 23.5)
  1648. this.context.bezierCurveTo(18.5, 24.5, 19.0001, 25.5, 19.0001, 25.5)
  1649. this.context.fill()
  1650. this.context.stroke()
  1651. this.context.beginPath()
  1652. this.context.moveTo(24.5, 20.5)
  1653. this.context.lineTo(25.5, 23.5)
  1654. this.context.fill()
  1655. this.context.stroke()
  1656. this.context.beginPath()
  1657. this.context.moveTo(27.5, 15)
  1658. this.context.lineTo(31, 14)
  1659. this.context.fill()
  1660. this.context.stroke()
  1661. this.context.restore()
  1662. }
  1663. drawPlant(geometry) {
  1664. const selectItem = stateService.getSelectItem()
  1665. const draggingItem = stateService.getDraggingItem()
  1666. const focusItem = stateService.getFocusItem()
  1667. this.context.save()
  1668. this.context.strokeStyle = Style.Furniture.strokeStyle
  1669. this.context.fillStyle = Style.Furniture.fillStyle
  1670. if (selectItem && selectItem.type == VectorType.Plant) {
  1671. if (geometry.vectorId == selectItem.vectorId) {
  1672. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1673. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1674. }
  1675. } else if (draggingItem && draggingItem.type == VectorType.Plant) {
  1676. if (geometry.vectorId == draggingItem.vectorId) {
  1677. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1678. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1679. }
  1680. }
  1681. if (focusItem && focusItem.type == VectorType.Plant) {
  1682. if (geometry.vectorId == focusItem.vectorId) {
  1683. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  1684. this.context.fillStyle = Style.Focus.Furniture.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, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1699. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1700. this.context.miterLimit = 4
  1701. this.context.font = "15px ''"
  1702. this.context.beginPath()
  1703. this.context.moveTo(16.0702, 14.54)
  1704. this.context.bezierCurveTo(15.9302, 14.31, 15.7701, 14.05, 15.6201, 13.76)
  1705. this.context.bezierCurveTo(14.8408, 12.4391, 14.4298, 10.9336, 14.4298, 9.39999)
  1706. this.context.bezierCurveTo(14.4298, 7.8664, 14.8408, 6.36081, 15.6201, 5.03998)
  1707. this.context.bezierCurveTo(15.8611, 4.58601, 16.1317, 4.1484, 16.4302, 3.72998)
  1708. this.context.bezierCurveTo(16.7286, 4.1484, 16.9992, 4.58601, 17.2401, 5.03998)
  1709. this.context.bezierCurveTo(17.9803, 6.37702, 18.3885, 7.87232, 18.4302, 9.39999)
  1710. this.context.bezierCurveTo(18.4354, 9.47657, 18.4354, 9.5534, 18.4302, 9.62997)
  1711. this.context.fill()
  1712. this.context.stroke()
  1713. this.context.beginPath()
  1714. this.context.moveTo(7.9801, 15.98)
  1715. this.context.bezierCurveTo(6.6152, 15.993, 5.25947, 15.7557, 3.9801, 15.28)
  1716. this.context.bezierCurveTo(3.60847, 15.1397, 3.24756, 14.9726, 2.90015, 14.78)
  1717. this.context.bezierCurveTo(3.21211, 14.5116, 3.54669, 14.2707, 3.90015, 14.06)
  1718. this.context.bezierCurveTo(5.22554, 13.2482, 6.73712, 12.7903, 8.29016, 12.73)
  1719. this.context.bezierCurveTo(9.15355, 12.6749, 10.0202, 12.7525, 10.8601, 12.96)
  1720. this.context.fill()
  1721. this.context.stroke()
  1722. this.context.beginPath()
  1723. this.context.moveTo(23.4602, 22.59)
  1724. this.context.bezierCurveTo(23.9779, 23.4363, 24.3718, 24.3522, 24.6302, 25.31)
  1725. this.context.bezierCurveTo(24.7381, 25.6898, 24.815, 26.0777, 24.8602, 26.47)
  1726. this.context.bezierCurveTo(24.464, 26.3786, 24.0761, 26.2548, 23.7002, 26.1)
  1727. this.context.bezierCurveTo(22.2631, 25.4958, 21.0035, 24.5356, 20.0402, 23.31)
  1728. this.context.bezierCurveTo(19.0654, 22.1493, 18.4441, 20.7332, 18.2502, 19.23)
  1729. this.context.bezierCurveTo(18.2452, 19.1935, 18.2452, 19.1565, 18.2502, 19.12)
  1730. this.context.fill()
  1731. this.context.stroke()
  1732. this.context.beginPath()
  1733. this.context.moveTo(18.0201, 18.79)
  1734. this.context.bezierCurveTo(18.289, 19.8049, 18.4268, 20.8501, 18.4302, 21.9)
  1735. this.context.bezierCurveTo(18.3982, 23.7828, 17.9865, 25.6399, 17.2201, 27.36)
  1736. this.context.bezierCurveTo(16.9871, 27.9045, 16.7234, 28.4354, 16.4302, 28.95)
  1737. this.context.bezierCurveTo(16.1369, 28.4354, 15.8731, 27.9045, 15.6401, 27.36)
  1738. this.context.bezierCurveTo(14.8737, 25.6399, 14.4622, 23.7828, 14.4302, 21.9)
  1739. this.context.lineTo(14.4302, 21.9)
  1740. this.context.fill()
  1741. this.context.stroke()
  1742. this.context.beginPath()
  1743. this.context.moveTo(15.7802, 14.98)
  1744. this.context.bezierCurveTo(15.7769, 14.9568, 15.7769, 14.9332, 15.7802, 14.91)
  1745. this.context.lineTo(16.0302, 14.53)
  1746. this.context.bezierCurveTo(16.1729, 14.3156, 16.3264, 14.1087, 16.4901, 13.91)
  1747. this.context.fill()
  1748. this.context.stroke()
  1749. this.context.beginPath()
  1750. this.context.moveTo(17.2201, 17.35)
  1751. this.context.bezierCurveTo(16.8106, 17.2814, 16.4063, 17.1845, 16.0101, 17.06)
  1752. this.context.fill()
  1753. this.context.stroke()
  1754. this.context.beginPath()
  1755. this.context.moveTo(23.9001, 9.38)
  1756. this.context.bezierCurveTo(24.8831, 9.14548, 25.8897, 9.02471, 26.9001, 9.02002)
  1757. this.context.bezierCurveTo(27.5704, 9.02021, 28.2395, 9.07706, 28.9001, 9.19)
  1758. this.context.lineTo(29.1702, 9.24002)
  1759. this.context.bezierCurveTo(29.1702, 9.34002, 29.1701, 9.44, 29.0901, 9.56)
  1760. this.context.bezierCurveTo(28.6759, 10.9776, 27.9845, 12.2989, 27.0558, 13.4473)
  1761. this.context.bezierCurveTo(26.1271, 14.5957, 24.9797, 15.5483, 23.6802, 16.25)
  1762. this.context.lineTo(23.5502, 16.31)
  1763. this.context.fill()
  1764. this.context.stroke()
  1765. this.context.beginPath()
  1766. this.context.moveTo(16.2902, 15.19)
  1767. this.context.bezierCurveTo(16.2902, 15.19, 16.2902, 15.12, 16.2902, 15.08)
  1768. this.context.lineTo(16.2902, 14.94)
  1769. this.context.bezierCurveTo(16.3291, 14.6435, 16.3859, 14.3496, 16.4602, 14.06)
  1770. this.context.lineTo(16.4602, 13.93)
  1771. this.context.bezierCurveTo(16.8635, 12.4153, 17.4975, 10.9717, 18.3401, 9.64999)
  1772. this.context.bezierCurveTo(18.6001, 9.23999, 18.8802, 8.81, 19.2002, 8.37)
  1773. this.context.bezierCurveTo(20.5088, 6.52287, 22.1501, 4.93576, 24.0402, 3.68997)
  1774. this.context.bezierCurveTo(24.573, 3.35365, 25.1276, 3.053, 25.7002, 2.78998)
  1775. this.context.bezierCurveTo(25.7076, 3.42365, 25.654, 4.05658, 25.5402, 4.67999)
  1776. this.context.bezierCurveTo(25.2507, 6.33791, 24.6647, 7.93003, 23.8102, 9.37997)
  1777. this.context.bezierCurveTo(23.5307, 9.86497, 23.227, 10.3356, 22.9001, 10.79)
  1778. this.context.bezierCurveTo(21.6488, 12.5924, 19.9543, 14.0423, 17.9801, 15)
  1779. this.context.bezierCurveTo(17.5625, 15.1915, 17.1314, 15.3519, 16.6902, 15.48)
  1780. this.context.lineTo(16.3102, 15.59)
  1781. this.context.fill()
  1782. this.context.stroke()
  1783. this.context.beginPath()
  1784. this.context.moveTo(12.9901, 14.58)
  1785. this.context.bezierCurveTo(12.2143, 14.1057, 11.4845, 13.56, 10.8102, 12.95)
  1786. this.context.bezierCurveTo(10.5402, 12.72, 10.2701, 12.47, 10.0001, 12.19)
  1787. this.context.bezierCurveTo(8.5657, 10.7859, 7.41477, 9.11892, 6.61011, 7.28)
  1788. this.context.bezierCurveTo(6.39455, 6.78774, 6.21745, 6.27957, 6.0802, 5.76001)
  1789. this.context.bezierCurveTo(6.61731, 5.84803, 7.14586, 5.98184, 7.66016, 6.16)
  1790. this.context.bezierCurveTo(9.55116, 6.80258, 11.2641, 7.88174, 12.6602, 9.31)
  1791. this.context.bezierCurveTo(14.0736, 10.6511, 15.1084, 12.3413, 15.6602, 14.21)
  1792. this.context.bezierCurveTo(15.7402, 14.49, 15.7901, 14.76, 15.8401, 14.99)
  1793. this.context.fill()
  1794. this.context.stroke()
  1795. this.context.beginPath()
  1796. this.context.moveTo(11.1301, 22.84)
  1797. this.context.bezierCurveTo(9.47432, 23.8584, 7.59868, 24.4653, 5.66016, 24.61)
  1798. this.context.bezierCurveTo(4.9583, 24.6744, 4.25203, 24.6744, 3.55017, 24.61)
  1799. this.context.lineTo(3.16016, 24.61)
  1800. this.context.bezierCurveTo(3.16016, 24.49, 3.16016, 24.33, 3.16016, 24.15)
  1801. this.context.bezierCurveTo(3.22801, 23.4121, 3.36532, 22.6821, 3.57019, 21.97)
  1802. this.context.bezierCurveTo(4.18103, 19.7501, 5.52348, 17.8015, 7.38013, 16.44)
  1803. this.context.bezierCurveTo(7.56306, 16.303, 7.75341, 16.1761, 7.9502, 16.06)
  1804. this.context.bezierCurveTo(9.44614, 15.1201, 11.1838, 14.637, 12.9502, 14.67)
  1805. this.context.lineTo(13.2701, 14.67)
  1806. this.context.lineTo(13.7201, 14.67)
  1807. this.context.bezierCurveTo(14.3987, 14.7284, 15.0692, 14.8591, 15.7201, 15.06)
  1808. this.context.lineTo(15.7201, 15.06)
  1809. this.context.lineTo(15.8701, 15.06)
  1810. this.context.lineTo(16.1902, 15.16)
  1811. this.context.lineTo(16.3302, 15.21)
  1812. this.context.bezierCurveTo(16.3302, 15.3, 16.3302, 15.41, 16.3302, 15.54)
  1813. this.context.bezierCurveTo(16.2457, 16.0399, 16.1186, 16.5317, 15.9502, 17.01)
  1814. this.context.bezierCurveTo(15.9502, 17.08, 15.9501, 17.16, 15.8701, 17.24)
  1815. this.context.fill()
  1816. this.context.stroke()
  1817. this.context.beginPath()
  1818. this.context.moveTo(23.5802, 16.31)
  1819. this.context.bezierCurveTo(23.6966, 16.364, 23.8101, 16.4241, 23.9202, 16.49)
  1820. this.context.bezierCurveTo(25.4558, 17.4575, 26.6812, 18.8459, 27.4502, 20.49)
  1821. this.context.bezierCurveTo(27.7426, 21.0659, 27.9965, 21.6605, 28.2102, 22.27)
  1822. this.context.lineTo(28.2902, 22.51)
  1823. this.context.lineTo(28.0402, 22.56)
  1824. this.context.bezierCurveTo(27.4061, 22.6801, 26.7646, 22.757, 26.1201, 22.79)
  1825. this.context.bezierCurveTo(25.2303, 22.8383, 24.3379, 22.7846, 23.4602, 22.63)
  1826. this.context.bezierCurveTo(22.5677, 22.4742, 21.7086, 22.1664, 20.9202, 21.72)
  1827. this.context.bezierCurveTo(19.8482, 21.0758, 18.9327, 20.2014, 18.2401, 19.16)
  1828. this.context.lineTo(18.0201, 18.83)
  1829. this.context.bezierCurveTo(17.7901, 18.47, 17.5801, 18.11, 17.4001, 17.76)
  1830. this.context.lineTo(17.2201, 17.39)
  1831. this.context.bezierCurveTo(16.9992, 16.9318, 16.8056, 16.461, 16.6401, 15.98)
  1832. this.context.lineTo(16.5602, 15.74)
  1833. this.context.lineTo(16.8102, 15.69)
  1834. this.context.bezierCurveTo(17.4312, 15.5743, 18.0593, 15.5008, 18.6902, 15.47)
  1835. this.context.bezierCurveTo(20.3653, 15.3236, 22.0499, 15.613, 23.5802, 16.31)
  1836. this.context.lineTo(23.5802, 16.31)
  1837. this.context.closePath()
  1838. this.context.fill()
  1839. this.context.stroke()
  1840. this.context.beginPath()
  1841. this.context.moveTo(11.1301, 22.84)
  1842. this.context.bezierCurveTo(11.2192, 21.7269, 11.5001, 20.6375, 11.9602, 19.62)
  1843. this.context.bezierCurveTo(12.5529, 18.2225, 13.5309, 17.0224, 14.7802, 16.16)
  1844. this.context.bezierCurveTo(14.9538, 16.04, 15.1341, 15.9298, 15.3202, 15.83)
  1845. this.context.lineTo(15.5302, 15.73)
  1846. this.context.bezierCurveTo(15.636, 15.6714, 15.7463, 15.6213, 15.8601, 15.58)
  1847. this.context.bezierCurveTo(15.8601, 15.66, 15.8601, 15.74, 15.8601, 15.84)
  1848. this.context.bezierCurveTo(15.8723, 16.0832, 15.8723, 16.3268, 15.8601, 16.57)
  1849. this.context.bezierCurveTo(15.8601, 16.72, 15.8601, 16.88, 15.8601, 17.05)
  1850. this.context.bezierCurveTo(15.8601, 17.22, 15.8601, 17.21, 15.8601, 17.3)
  1851. this.context.bezierCurveTo(15.7267, 18.5244, 15.3887, 19.7176, 14.8601, 20.83)
  1852. this.context.bezierCurveTo(14.7044, 21.192, 14.5241, 21.5428, 14.3202, 21.88)
  1853. this.context.bezierCurveTo(13.759, 22.908, 13.0288, 23.8343, 12.1602, 24.62)
  1854. this.context.bezierCurveTo(11.8633, 24.887, 11.5493, 25.1341, 11.2201, 25.36)
  1855. this.context.bezierCurveTo(11.1265, 24.962, 11.063, 24.5576, 11.0302, 24.15)
  1856. this.context.bezierCurveTo(11.0324, 23.7115, 11.0658, 23.2737, 11.1301, 22.84)
  1857. this.context.lineTo(11.1301, 22.84)
  1858. this.context.closePath()
  1859. this.context.fill()
  1860. this.context.stroke()
  1861. this.context.restore()
  1862. }
  1863. drawDiningTable(geometry) {
  1864. const selectItem = stateService.getSelectItem()
  1865. const draggingItem = stateService.getDraggingItem()
  1866. const focusItem = stateService.getFocusItem()
  1867. this.context.save()
  1868. this.context.strokeStyle = Style.Furniture.strokeStyle
  1869. this.context.fillStyle = Style.Furniture.fillStyle
  1870. if (selectItem && selectItem.type == VectorType.DiningTable) {
  1871. if (geometry.vectorId == selectItem.vectorId) {
  1872. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1873. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1874. }
  1875. } else if (draggingItem && draggingItem.type == VectorType.DiningTable) {
  1876. if (geometry.vectorId == draggingItem.vectorId) {
  1877. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1878. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1879. }
  1880. }
  1881. if (focusItem && focusItem.type == VectorType.DiningTable) {
  1882. if (geometry.vectorId == focusItem.vectorId) {
  1883. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  1884. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  1885. }
  1886. }
  1887. const center = coordinate.getScreenXY({
  1888. x: geometry.center.x,
  1889. y: geometry.center.y,
  1890. })
  1891. const pt = coordinate.getScreenXY({
  1892. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1893. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1894. })
  1895. this.context.translate(center.x, center.y)
  1896. this.context.rotate((geometry.angle / 180) * Math.PI)
  1897. this.context.translate(pt.x - center.x, pt.y - center.y)
  1898. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1899. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1900. this.context.miterLimit = 4
  1901. this.context.font = "15px ''"
  1902. this.context.beginPath()
  1903. this.context.moveTo(2.5, 10.5)
  1904. this.context.lineTo(29.5, 10.5)
  1905. this.context.lineTo(29.5, 21.5)
  1906. this.context.lineTo(2.5, 21.5)
  1907. this.context.closePath()
  1908. this.context.fill()
  1909. this.context.stroke()
  1910. this.context.beginPath()
  1911. this.context.moveTo(14.5, 10)
  1912. this.context.lineTo(14.5, 3.5)
  1913. this.context.lineTo(5.5, 3.5)
  1914. this.context.lineTo(5.5, 10)
  1915. this.context.fill()
  1916. this.context.stroke()
  1917. this.context.beginPath()
  1918. this.context.moveTo(14.5, 22)
  1919. this.context.lineTo(14.5, 28.5)
  1920. this.context.lineTo(5.5, 28.5)
  1921. this.context.lineTo(5.5, 22)
  1922. this.context.fill()
  1923. this.context.stroke()
  1924. this.context.beginPath()
  1925. this.context.moveTo(26.5, 10)
  1926. this.context.lineTo(26.5, 3.5)
  1927. this.context.lineTo(17.5, 3.5)
  1928. this.context.lineTo(17.5, 10)
  1929. this.context.fill()
  1930. this.context.stroke()
  1931. this.context.beginPath()
  1932. this.context.moveTo(26.5, 22)
  1933. this.context.lineTo(26.5, 28.5)
  1934. this.context.lineTo(17.5, 28.5)
  1935. this.context.lineTo(17.5, 22)
  1936. this.context.fill()
  1937. this.context.stroke()
  1938. this.context.beginPath()
  1939. this.context.moveTo(6, 5.5)
  1940. this.context.lineTo(14, 5.5)
  1941. this.context.fill()
  1942. this.context.stroke()
  1943. this.context.beginPath()
  1944. this.context.moveTo(6, 26.5)
  1945. this.context.lineTo(14, 26.5)
  1946. this.context.fill()
  1947. this.context.stroke()
  1948. this.context.beginPath()
  1949. this.context.moveTo(18, 5.5)
  1950. this.context.lineTo(26, 5.5)
  1951. this.context.fill()
  1952. this.context.stroke()
  1953. this.context.beginPath()
  1954. this.context.moveTo(18, 26.5)
  1955. this.context.lineTo(26, 26.5)
  1956. this.context.fill()
  1957. this.context.stroke()
  1958. this.context.restore()
  1959. }
  1960. drawDoubleBed(geometry) {
  1961. const selectItem = stateService.getSelectItem()
  1962. const draggingItem = stateService.getDraggingItem()
  1963. const focusItem = stateService.getFocusItem()
  1964. this.context.save()
  1965. this.context.strokeStyle = Style.Furniture.strokeStyle
  1966. this.context.fillStyle = Style.Furniture.fillStyle
  1967. if (selectItem && selectItem.type == VectorType.DoubleBed) {
  1968. if (geometry.vectorId == selectItem.vectorId) {
  1969. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1970. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1971. }
  1972. } else if (draggingItem && draggingItem.type == VectorType.DoubleBed) {
  1973. if (geometry.vectorId == draggingItem.vectorId) {
  1974. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  1975. this.context.fillStyle = Style.Select.Furniture.fillStyle
  1976. }
  1977. }
  1978. if (focusItem && focusItem.type == VectorType.DoubleBed) {
  1979. if (geometry.vectorId == focusItem.vectorId) {
  1980. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  1981. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  1982. }
  1983. }
  1984. const center = coordinate.getScreenXY({
  1985. x: geometry.center.x,
  1986. y: geometry.center.y,
  1987. })
  1988. const pt = coordinate.getScreenXY({
  1989. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1990. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1991. })
  1992. this.context.translate(center.x, center.y)
  1993. this.context.rotate((geometry.angle / 180) * Math.PI)
  1994. this.context.translate(pt.x - center.x, pt.y - center.y)
  1995. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1996. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1997. this.context.miterLimit = 4
  1998. this.context.beginPath()
  1999. this.context.moveTo(0.5, 3.5)
  2000. this.context.lineTo(31.5, 3.5)
  2001. this.context.lineTo(31.5, 28.5)
  2002. this.context.lineTo(0.5, 28.5)
  2003. this.context.lineTo(0.5, 3.5)
  2004. this.context.closePath()
  2005. this.context.fill()
  2006. this.context.stroke()
  2007. this.context.beginPath()
  2008. this.context.moveTo(1, 9.5)
  2009. this.context.lineTo(31, 9.5)
  2010. this.context.fill()
  2011. this.context.stroke()
  2012. this.context.beginPath()
  2013. this.context.moveTo(14.5, 9)
  2014. this.context.lineTo(14.5, 7.5)
  2015. this.context.bezierCurveTo(14.5, 6.39543, 13.6046, 5.5, 12.5, 5.5)
  2016. this.context.lineTo(5.5, 5.5)
  2017. this.context.bezierCurveTo(4.39543, 5.5, 3.5, 6.39543, 3.5, 7.5)
  2018. this.context.lineTo(3.5, 9)
  2019. this.context.fill()
  2020. this.context.stroke()
  2021. this.context.beginPath()
  2022. this.context.moveTo(28.5, 9)
  2023. this.context.lineTo(28.5, 7.5)
  2024. this.context.bezierCurveTo(28.5, 6.39543, 27.6046, 5.5, 26.5, 5.5)
  2025. this.context.lineTo(19.5, 5.5)
  2026. this.context.bezierCurveTo(18.3954, 5.5, 17.5, 6.39543, 17.5, 7.5)
  2027. this.context.lineTo(17.5, 9)
  2028. this.context.fill()
  2029. this.context.stroke()
  2030. this.context.beginPath()
  2031. this.context.moveTo(1, 12.5)
  2032. this.context.lineTo(31, 12.5)
  2033. this.context.fill()
  2034. this.context.stroke()
  2035. this.context.restore()
  2036. }
  2037. drawSingleBed(geometry) {
  2038. const selectItem = stateService.getSelectItem()
  2039. const draggingItem = stateService.getDraggingItem()
  2040. const focusItem = stateService.getFocusItem()
  2041. this.context.save()
  2042. this.context.strokeStyle = Style.Furniture.strokeStyle
  2043. this.context.fillStyle = Style.Furniture.fillStyle
  2044. if (selectItem && selectItem.type == VectorType.SingleBed) {
  2045. if (geometry.vectorId == selectItem.vectorId) {
  2046. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2047. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2048. }
  2049. } else if (draggingItem && draggingItem.type == VectorType.SingleBed) {
  2050. if (geometry.vectorId == draggingItem.vectorId) {
  2051. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2052. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2053. }
  2054. }
  2055. if (focusItem && focusItem.type == VectorType.SingleBed) {
  2056. if (geometry.vectorId == focusItem.vectorId) {
  2057. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  2058. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  2059. }
  2060. }
  2061. const center = coordinate.getScreenXY({
  2062. x: geometry.center.x,
  2063. y: geometry.center.y,
  2064. })
  2065. const pt = coordinate.getScreenXY({
  2066. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  2067. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  2068. })
  2069. this.context.translate(center.x, center.y)
  2070. this.context.rotate((geometry.angle / 180) * Math.PI)
  2071. this.context.translate(pt.x - center.x, pt.y - center.y)
  2072. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2073. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2074. this.context.miterLimit = 4
  2075. this.context.beginPath()
  2076. this.context.moveTo(6.5, 3.5)
  2077. this.context.lineTo(25.5, 3.5)
  2078. this.context.lineTo(25.5, 28.5)
  2079. this.context.lineTo(6.5, 28.5)
  2080. this.context.lineTo(6.5, 3.5)
  2081. this.context.closePath()
  2082. this.context.fill()
  2083. this.context.stroke()
  2084. this.context.beginPath()
  2085. this.context.moveTo(7, 9.5)
  2086. this.context.lineTo(25, 9.5)
  2087. this.context.fill()
  2088. this.context.stroke()
  2089. this.context.beginPath()
  2090. this.context.moveTo(7, 12.5)
  2091. this.context.lineTo(25, 12.5)
  2092. this.context.fill()
  2093. this.context.stroke()
  2094. this.context.beginPath()
  2095. this.context.moveTo(22.5, 9)
  2096. this.context.lineTo(22.5, 7.5)
  2097. this.context.bezierCurveTo(22.5, 6.39543, 21.6046, 5.5, 20.5, 5.5)
  2098. this.context.lineTo(11.5, 5.5)
  2099. this.context.bezierCurveTo(10.3954, 5.5, 9.5, 6.39543, 9.5, 7.5)
  2100. this.context.lineTo(9.5, 9)
  2101. this.context.fill()
  2102. this.context.stroke()
  2103. this.context.restore()
  2104. }
  2105. drawWardrobe(geometry) {
  2106. const selectItem = stateService.getSelectItem()
  2107. const draggingItem = stateService.getDraggingItem()
  2108. const focusItem = stateService.getFocusItem()
  2109. this.context.save()
  2110. this.context.strokeStyle = Style.Furniture.strokeStyle
  2111. this.context.fillStyle = Style.Furniture.fillStyle
  2112. if (selectItem && selectItem.type == VectorType.WallCorner) {
  2113. if (geometry.vectorId == selectItem.vectorId) {
  2114. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2115. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2116. }
  2117. } else if (draggingItem && draggingItem.type == VectorType.WallCorner) {
  2118. if (geometry.vectorId == draggingItem.vectorId) {
  2119. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2120. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2121. }
  2122. }
  2123. if (focusItem && focusItem.type == VectorType.WallCorner) {
  2124. if (geometry.vectorId == focusItem.vectorId) {
  2125. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  2126. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  2127. }
  2128. }
  2129. const center = coordinate.getScreenXY({
  2130. x: geometry.center.x,
  2131. y: geometry.center.y,
  2132. })
  2133. const pt = coordinate.getScreenXY({
  2134. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  2135. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  2136. })
  2137. this.context.translate(center.x, center.y)
  2138. this.context.rotate((geometry.angle / 180) * Math.PI)
  2139. this.context.translate(pt.x - center.x, pt.y - center.y)
  2140. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2141. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2142. this.context.miterLimit = 4
  2143. this.context.font = "15px ''"
  2144. this.context.beginPath()
  2145. this.context.moveTo(1.5, 7.5)
  2146. this.context.lineTo(30.5, 7.5)
  2147. this.context.lineTo(30.5, 23.5)
  2148. this.context.lineTo(1.5, 23.5)
  2149. this.context.lineTo(1.5, 7.5)
  2150. this.context.closePath()
  2151. this.context.fill()
  2152. this.context.stroke()
  2153. this.context.beginPath()
  2154. this.context.moveTo(3.5, 9.5)
  2155. this.context.lineTo(28.5, 9.5)
  2156. this.context.lineTo(28.5, 21.5)
  2157. this.context.lineTo(3.5, 21.5)
  2158. this.context.lineTo(3.5, 9.5)
  2159. this.context.closePath()
  2160. this.context.fill()
  2161. this.context.stroke()
  2162. this.context.beginPath()
  2163. this.context.moveTo(4, 15.5)
  2164. this.context.lineTo(28, 15.5)
  2165. this.context.fill()
  2166. this.context.stroke()
  2167. this.context.beginPath()
  2168. this.context.moveTo(6.5, 12)
  2169. this.context.lineTo(7.5, 19)
  2170. this.context.fill()
  2171. this.context.stroke()
  2172. this.context.beginPath()
  2173. this.context.moveTo(10.5, 12)
  2174. this.context.lineTo(10.5, 19)
  2175. this.context.fill()
  2176. this.context.stroke()
  2177. this.context.beginPath()
  2178. this.context.moveTo(15.5, 12)
  2179. this.context.lineTo(15.5, 19)
  2180. this.context.fill()
  2181. this.context.stroke()
  2182. this.context.beginPath()
  2183. this.context.moveTo(19.5, 12)
  2184. this.context.lineTo(21.5, 19)
  2185. this.context.fill()
  2186. this.context.stroke()
  2187. this.context.beginPath()
  2188. this.context.moveTo(25.5, 12)
  2189. this.context.lineTo(25.5, 19)
  2190. this.context.fill()
  2191. this.context.stroke()
  2192. this.context.restore()
  2193. }
  2194. drawDresser(geometry) {
  2195. const selectItem = stateService.getSelectItem()
  2196. const draggingItem = stateService.getDraggingItem()
  2197. const focusItem = stateService.getFocusItem()
  2198. this.context.save()
  2199. this.context.strokeStyle = Style.Furniture.strokeStyle
  2200. this.context.fillStyle = Style.Furniture.fillStyle
  2201. if (selectItem && selectItem.type == VectorType.Dresser) {
  2202. if (geometry.vectorId == selectItem.vectorId) {
  2203. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2204. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2205. }
  2206. } else if (draggingItem && draggingItem.type == VectorType.Dresser) {
  2207. if (geometry.vectorId == draggingItem.vectorId) {
  2208. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2209. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2210. }
  2211. }
  2212. if (focusItem && focusItem.type == VectorType.Dresser) {
  2213. if (geometry.vectorId == focusItem.vectorId) {
  2214. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  2215. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  2216. }
  2217. }
  2218. const center = coordinate.getScreenXY({
  2219. x: geometry.center.x,
  2220. y: geometry.center.y,
  2221. })
  2222. const pt = coordinate.getScreenXY({
  2223. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  2224. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  2225. })
  2226. this.context.translate(center.x, center.y)
  2227. this.context.rotate((geometry.angle / 180) * Math.PI)
  2228. this.context.translate(pt.x - center.x, pt.y - center.y)
  2229. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2230. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2231. this.context.miterLimit = 4
  2232. this.context.font = "15px ''"
  2233. this.context.beginPath()
  2234. this.context.moveTo(2.5, 4.5)
  2235. this.context.lineTo(29.5, 4.5)
  2236. this.context.lineTo(29.5, 16.5)
  2237. this.context.bezierCurveTo(29.5, 17.6046, 28.6046, 18.5, 27.5, 18.5)
  2238. this.context.lineTo(4.5, 18.5)
  2239. this.context.bezierCurveTo(3.39543, 18.5, 2.5, 17.6046, 2.5, 16.5)
  2240. this.context.lineTo(2.5, 4.5)
  2241. this.context.closePath()
  2242. this.context.fill()
  2243. this.context.stroke()
  2244. this.context.beginPath()
  2245. this.context.moveTo(7.5, 6.5)
  2246. this.context.lineTo(24.5, 6.5)
  2247. this.context.lineTo(24.5, 8.5)
  2248. this.context.lineTo(7.5, 8.5)
  2249. this.context.lineTo(7.5, 6.5)
  2250. this.context.closePath()
  2251. this.context.fill()
  2252. this.context.stroke()
  2253. this.context.beginPath()
  2254. this.context.moveTo(9.5, 25)
  2255. this.context.bezierCurveTo(9.5, 23.067, 11.067, 21.5, 13, 21.5)
  2256. this.context.lineTo(19, 21.5)
  2257. this.context.bezierCurveTo(20.933, 21.5, 22.5, 23.067, 22.5, 25)
  2258. this.context.lineTo(22.5, 25)
  2259. this.context.bezierCurveTo(22.5, 26.933, 20.933, 28.5, 19, 28.5)
  2260. this.context.lineTo(13, 28.5)
  2261. this.context.bezierCurveTo(11.067, 28.5, 9.5, 26.933, 9.5, 25)
  2262. this.context.lineTo(9.5, 25)
  2263. this.context.closePath()
  2264. this.context.fill()
  2265. this.context.stroke()
  2266. this.context.restore()
  2267. }
  2268. drawBedsideCupboard(geometry) {
  2269. const selectItem = stateService.getSelectItem()
  2270. const draggingItem = stateService.getDraggingItem()
  2271. const focusItem = stateService.getFocusItem()
  2272. this.context.save()
  2273. this.context.strokeStyle = Style.Furniture.strokeStyle
  2274. this.context.fillStyle = Style.Furniture.fillStyle
  2275. if (selectItem && selectItem.type == VectorType.BedsideCupboard) {
  2276. if (geometry.vectorId == selectItem.vectorId) {
  2277. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2278. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2279. }
  2280. } else if (draggingItem && draggingItem.type == VectorType.BedsideCupboard) {
  2281. if (geometry.vectorId == draggingItem.vectorId) {
  2282. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2283. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2284. }
  2285. }
  2286. if (focusItem && focusItem.type == VectorType.BedsideCupboard) {
  2287. if (geometry.vectorId == focusItem.vectorId) {
  2288. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  2289. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  2290. }
  2291. }
  2292. const center = coordinate.getScreenXY({
  2293. x: geometry.center.x,
  2294. y: geometry.center.y,
  2295. })
  2296. const pt = coordinate.getScreenXY({
  2297. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  2298. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  2299. })
  2300. this.context.translate(center.x, center.y)
  2301. this.context.rotate((geometry.angle / 180) * Math.PI)
  2302. this.context.translate(pt.x - center.x, pt.y - center.y)
  2303. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2304. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2305. this.context.miterLimit = 4
  2306. this.context.font = "15px ''"
  2307. this.context.beginPath()
  2308. this.context.moveTo(2.5, 3.5)
  2309. this.context.lineTo(28.5, 3.5)
  2310. this.context.lineTo(28.5, 29.5)
  2311. this.context.lineTo(2.5, 29.5)
  2312. this.context.lineTo(2.5, 3.5)
  2313. this.context.closePath()
  2314. this.context.fill()
  2315. this.context.stroke()
  2316. this.context.beginPath()
  2317. this.context.moveTo(4.5, 5.5)
  2318. this.context.lineTo(26.5, 5.5)
  2319. this.context.lineTo(26.5, 27.5)
  2320. this.context.lineTo(4.5, 27.5)
  2321. this.context.lineTo(4.5, 5.5)
  2322. this.context.closePath()
  2323. this.context.fill()
  2324. this.context.stroke()
  2325. this.context.beginPath()
  2326. this.context.moveTo(23.5, 16.5)
  2327. this.context.bezierCurveTo(23.5, 20.9183, 19.9183, 24.5, 15.5, 24.5)
  2328. this.context.bezierCurveTo(11.0817, 24.5, 7.5, 20.9183, 7.5, 16.5)
  2329. this.context.bezierCurveTo(7.5, 12.0817, 11.0817, 8.5, 15.5, 8.5)
  2330. this.context.bezierCurveTo(19.9183, 8.5, 23.5, 12.0817, 23.5, 16.5)
  2331. this.context.closePath()
  2332. this.context.fill()
  2333. this.context.stroke()
  2334. this.context.beginPath()
  2335. this.context.moveTo(20.5, 16.5)
  2336. this.context.bezierCurveTo(20.5, 19.2614, 18.2614, 21.5, 15.5, 21.5)
  2337. this.context.bezierCurveTo(12.7386, 21.5, 10.5, 19.2614, 10.5, 16.5)
  2338. this.context.bezierCurveTo(10.5, 13.7386, 12.7386, 11.5, 15.5, 11.5)
  2339. this.context.bezierCurveTo(18.2614, 11.5, 20.5, 13.7386, 20.5, 16.5)
  2340. this.context.closePath()
  2341. this.context.fill()
  2342. this.context.stroke()
  2343. this.context.beginPath()
  2344. this.context.moveTo(20.5, 16.5)
  2345. this.context.bezierCurveTo(20.5, 19.2614, 18.2614, 21.5, 15.5, 21.5)
  2346. this.context.bezierCurveTo(12.7386, 21.5, 10.5, 19.2614, 10.5, 16.5)
  2347. this.context.bezierCurveTo(10.5, 13.7386, 12.7386, 11.5, 15.5, 11.5)
  2348. this.context.bezierCurveTo(18.2614, 11.5, 20.5, 13.7386, 20.5, 16.5)
  2349. this.context.closePath()
  2350. this.context.fill()
  2351. this.context.stroke()
  2352. this.context.beginPath()
  2353. this.context.moveTo(16.5, 16.5)
  2354. this.context.bezierCurveTo(16.5, 17.0523, 16.0523, 17.5, 15.5, 17.5)
  2355. this.context.bezierCurveTo(14.9477, 17.5, 14.5, 17.0523, 14.5, 16.5)
  2356. this.context.bezierCurveTo(14.5, 15.9477, 14.9477, 15.5, 15.5, 15.5)
  2357. this.context.bezierCurveTo(16.0523, 15.5, 16.5, 15.9477, 16.5, 16.5)
  2358. this.context.closePath()
  2359. this.context.fill()
  2360. this.context.stroke()
  2361. this.context.beginPath()
  2362. this.context.moveTo(11, 18.5)
  2363. this.context.lineTo(14.5, 17)
  2364. this.context.fill()
  2365. this.context.stroke()
  2366. this.context.beginPath()
  2367. this.context.moveTo(16.5, 17)
  2368. this.context.lineTo(20, 18.5)
  2369. this.context.moveTo(15.5, 11.5)
  2370. this.context.lineTo(15.5, 15.5)
  2371. this.context.fill()
  2372. this.context.stroke()
  2373. this.context.restore()
  2374. }
  2375. drawPillow(geometry) {
  2376. const selectItem = stateService.getSelectItem()
  2377. const draggingItem = stateService.getDraggingItem()
  2378. const focusItem = stateService.getFocusItem()
  2379. this.context.save()
  2380. this.context.strokeStyle = Style.Furniture.strokeStyle
  2381. this.context.fillStyle = Style.Furniture.fillStyle
  2382. if (selectItem && selectItem.type == VectorType.Pillow) {
  2383. if (geometry.vectorId == selectItem.vectorId) {
  2384. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2385. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2386. }
  2387. } else if (draggingItem && draggingItem.type == VectorType.Pillow) {
  2388. if (geometry.vectorId == draggingItem.vectorId) {
  2389. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2390. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2391. }
  2392. }
  2393. if (focusItem && focusItem.type == VectorType.Pillow) {
  2394. if (geometry.vectorId == focusItem.vectorId) {
  2395. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  2396. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  2397. }
  2398. }
  2399. const center = coordinate.getScreenXY({
  2400. x: geometry.center.x,
  2401. y: geometry.center.y,
  2402. })
  2403. const pt = coordinate.getScreenXY({
  2404. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  2405. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  2406. })
  2407. this.context.translate(center.x, center.y)
  2408. this.context.rotate((geometry.angle / 180) * Math.PI)
  2409. this.context.translate(pt.x - center.x, pt.y - center.y)
  2410. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2411. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2412. this.context.miterLimit = 4
  2413. this.context.beginPath()
  2414. this.context.moveTo(18.0747, 9)
  2415. this.context.bezierCurveTo(16.2223, 9.05191, 14.3762, 9.23862, 12.5513, 9.55861)
  2416. this.context.bezierCurveTo(11.8131, 9.80487, 11.014, 9.80487, 10.2758, 9.55861)
  2417. this.context.bezierCurveTo(8.86176, 9.28479, 8.69606, 10.8291, 9.17107, 11.7492)
  2418. this.context.bezierCurveTo(9.01642, 12.3187, 8.78433, 13.2716, 8.65177, 13.8631)
  2419. this.context.bezierCurveTo(7.54709, 17.9485, 8.14367, 21.3439, 8.98323, 25.3198)
  2420. this.context.bezierCurveTo(9.16793, 25.9353, 9.14078, 26.5943, 8.90596, 27.1928)
  2421. this.context.bezierCurveTo(8.62979, 28.6276, 10.2315, 28.7262, 11.1815, 28.2881)
  2422. this.context.bezierCurveTo(15.52, 29.157, 19.9815, 29.2386, 24.3494, 28.529)
  2423. this.context.bezierCurveTo(24.7471, 28.529, 25.454, 28.3538, 25.7964, 28.3428)
  2424. this.context.bezierCurveTo(26.7354, 28.6057, 28.3593, 28.6824, 28.1826, 27.2475)
  2425. this.context.bezierCurveTo(27.8733, 26.4132, 27.8733, 25.497, 28.1826, 24.6626)
  2426. this.context.bezierCurveTo(28.4367, 23.414, 28.6686, 22.0449, 28.8343, 20.7744)
  2427. this.context.bezierCurveTo(29.6297, 17.4885, 27.8512, 14.2026, 28.0611, 10.9168)
  2428. this.context.bezierCurveTo(28.1106, 10.7308, 28.1099, 10.5352, 28.0589, 10.3496)
  2429. this.context.bezierCurveTo(28.008, 10.164, 27.9086, 9.99502, 27.7709, 9.85957)
  2430. this.context.bezierCurveTo(27.6332, 9.72413, 27.462, 9.62701, 27.2744, 9.57803)
  2431. this.context.bezierCurveTo(27.0868, 9.52904, 26.8895, 9.5299, 26.7024, 9.5805)
  2432. this.context.bezierCurveTo(26.3084, 9.74462, 25.8765, 9.7977, 25.4541, 9.73386)
  2433. this.context.bezierCurveTo(23.013, 9.33025, 20.548, 9.0851, 18.0747, 9)
  2434. this.context.lineTo(18.0747, 9)
  2435. this.context.closePath()
  2436. this.context.fill()
  2437. this.context.stroke()
  2438. this.context.beginPath()
  2439. this.context.moveTo(23.4453, 9.5)
  2440. this.context.bezierCurveTo(23.2025, 8.27344, 22.9884, 7.04688, 23.067, 5.82031)
  2441. this.context.bezierCurveTo(23.1141, 5.64371, 23.1134, 5.45793, 23.0649, 5.28169)
  2442. this.context.bezierCurveTo(23.0164, 5.10544, 22.9217, 4.94495, 22.7905, 4.81632)
  2443. this.context.bezierCurveTo(22.6593, 4.68769, 22.4961, 4.59547, 22.3174, 4.54894)
  2444. this.context.bezierCurveTo(22.1387, 4.50242, 21.9507, 4.50323, 21.7724, 4.55129)
  2445. this.context.bezierCurveTo(21.3971, 4.70716, 20.9855, 4.75756, 20.5831, 4.69693)
  2446. this.context.bezierCurveTo(18.2573, 4.31363, 15.9087, 4.08082, 13.5522, 4)
  2447. this.context.bezierCurveTo(11.7872, 4.0493, 10.0283, 4.22661, 8.28964, 4.5305)
  2448. this.context.bezierCurveTo(7.58628, 4.76437, 6.82488, 4.76437, 6.12153, 4.5305)
  2449. this.context.bezierCurveTo(4.77431, 4.27046, 4.61643, 5.73711, 5.06901, 6.61086)
  2450. this.context.bezierCurveTo(4.92166, 7.15175, 4.70054, 8.0567, 4.57423, 8.6184)
  2451. this.context.bezierCurveTo(3.52172, 12.4983, 4.09013, 15.7228, 4.89004, 19.4987)
  2452. this.context.bezierCurveTo(5.06602, 20.0832, 5.04015, 20.709, 4.81642, 21.2774)
  2453. this.context.bezierCurveTo(4.55329, 22.64, 6.07937, 22.7337, 6.98453, 22.3176)
  2454. this.context.bezierCurveTo(7.41836, 22.4042, 7.85347, 22.4826, 8.28964, 22.5527)
  2455. this.context.fill()
  2456. this.context.stroke()
  2457. this.context.restore()
  2458. }
  2459. drawGasStove(geometry) {
  2460. const selectItem = stateService.getSelectItem()
  2461. const draggingItem = stateService.getDraggingItem()
  2462. const focusItem = stateService.getFocusItem()
  2463. this.context.save()
  2464. this.context.strokeStyle = Style.Furniture.strokeStyle
  2465. this.context.fillStyle = Style.Furniture.fillStyle
  2466. if (selectItem && selectItem.type == VectorType.GasStove) {
  2467. if (geometry.vectorId == selectItem.vectorId) {
  2468. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2469. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2470. }
  2471. } else if (draggingItem && draggingItem.type == VectorType.GasStove) {
  2472. if (geometry.vectorId == draggingItem.vectorId) {
  2473. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2474. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2475. }
  2476. }
  2477. if (focusItem && focusItem.type == VectorType.GasStove) {
  2478. if (geometry.vectorId == focusItem.vectorId) {
  2479. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  2480. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  2481. }
  2482. }
  2483. const center = coordinate.getScreenXY({
  2484. x: geometry.center.x,
  2485. y: geometry.center.y,
  2486. })
  2487. const pt = coordinate.getScreenXY({
  2488. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  2489. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  2490. })
  2491. this.context.translate(center.x, center.y)
  2492. this.context.rotate((geometry.angle / 180) * Math.PI)
  2493. this.context.translate(pt.x - center.x, pt.y - center.y)
  2494. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2495. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2496. this.context.miterLimit = 4
  2497. this.context.beginPath()
  2498. this.context.moveTo(0.5, 8.5)
  2499. this.context.bezierCurveTo(0.5, 7.94772, 0.947715, 7.5, 1.5, 7.5)
  2500. this.context.lineTo(30.5, 7.5)
  2501. this.context.bezierCurveTo(31.0523, 7.5, 31.5, 7.94772, 31.5, 8.5)
  2502. this.context.lineTo(31.5, 24.5)
  2503. this.context.bezierCurveTo(31.5, 25.0523, 31.0523, 25.5, 30.5, 25.5)
  2504. this.context.lineTo(1.5, 25.5)
  2505. this.context.bezierCurveTo(0.947716, 25.5, 0.5, 25.0523, 0.5, 24.5)
  2506. this.context.lineTo(0.5, 8.5)
  2507. this.context.closePath()
  2508. this.context.fill()
  2509. this.context.stroke()
  2510. this.context.beginPath()
  2511. this.context.moveTo(1, 20.5)
  2512. this.context.lineTo(31, 20.5)
  2513. this.context.fill()
  2514. this.context.stroke()
  2515. this.context.beginPath()
  2516. this.context.moveTo(13.5, 14)
  2517. this.context.bezierCurveTo(13.5, 16.4853, 11.4853, 18.5, 9, 18.5)
  2518. this.context.bezierCurveTo(6.51472, 18.5, 4.5, 16.4853, 4.5, 14)
  2519. this.context.bezierCurveTo(4.5, 11.5147, 6.51472, 9.5, 9, 9.5)
  2520. this.context.bezierCurveTo(11.4853, 9.5, 13.5, 11.5147, 13.5, 14)
  2521. this.context.closePath()
  2522. this.context.fill()
  2523. this.context.stroke()
  2524. this.context.beginPath()
  2525. this.context.moveTo(13.5, 23)
  2526. this.context.bezierCurveTo(13.5, 23.2761, 13.2761, 23.5, 13, 23.5)
  2527. this.context.bezierCurveTo(12.7239, 23.5, 12.5, 23.2761, 12.5, 23)
  2528. this.context.bezierCurveTo(12.5, 22.7239, 12.7239, 22.5, 13, 22.5)
  2529. this.context.bezierCurveTo(13.2761, 22.5, 13.5, 22.7239, 13.5, 23)
  2530. this.context.closePath()
  2531. this.context.fill()
  2532. this.context.stroke()
  2533. this.context.beginPath()
  2534. this.context.moveTo(19.5, 23)
  2535. this.context.bezierCurveTo(19.5, 23.2761, 19.2761, 23.5, 19, 23.5)
  2536. this.context.bezierCurveTo(18.7239, 23.5, 18.5, 23.2761, 18.5, 23)
  2537. this.context.bezierCurveTo(18.5, 22.7239, 18.7239, 22.5, 19, 22.5)
  2538. this.context.bezierCurveTo(19.2761, 22.5, 19.5, 22.7239, 19.5, 23)
  2539. this.context.closePath()
  2540. this.context.fill()
  2541. this.context.stroke()
  2542. this.context.beginPath()
  2543. this.context.moveTo(10.5, 14)
  2544. this.context.bezierCurveTo(10.5, 14.8284, 9.82843, 15.5, 9, 15.5)
  2545. this.context.bezierCurveTo(8.17157, 15.5, 7.5, 14.8284, 7.5, 14)
  2546. this.context.bezierCurveTo(7.5, 13.1716, 8.17157, 12.5, 9, 12.5)
  2547. this.context.bezierCurveTo(9.82843, 12.5, 10.5, 13.1716, 10.5, 14)
  2548. this.context.closePath()
  2549. this.context.fill()
  2550. this.context.stroke()
  2551. this.context.beginPath()
  2552. this.context.moveTo(4.5, 9.5)
  2553. this.context.lineTo(6.5, 11.5)
  2554. this.context.fill()
  2555. this.context.stroke()
  2556. this.context.beginPath()
  2557. this.context.moveTo(11.5, 16.5)
  2558. this.context.lineTo(13.5, 18.5)
  2559. this.context.fill()
  2560. this.context.stroke()
  2561. this.context.beginPath()
  2562. this.context.moveTo(6.5, 16.5)
  2563. this.context.lineTo(4.5, 18.5)
  2564. this.context.fill()
  2565. this.context.stroke()
  2566. this.context.beginPath()
  2567. this.context.moveTo(27.5, 14)
  2568. this.context.bezierCurveTo(27.5, 16.4853, 25.4853, 18.5, 23, 18.5)
  2569. this.context.bezierCurveTo(20.5147, 18.5, 18.5, 16.4853, 18.5, 14)
  2570. this.context.bezierCurveTo(18.5, 11.5147, 20.5147, 9.5, 23, 9.5)
  2571. this.context.bezierCurveTo(25.4853, 9.5, 27.5, 11.5147, 27.5, 14)
  2572. this.context.closePath()
  2573. this.context.fill()
  2574. this.context.stroke()
  2575. this.context.beginPath()
  2576. this.context.moveTo(24.5, 14)
  2577. this.context.bezierCurveTo(24.5, 14.8284, 23.8284, 15.5, 23, 15.5)
  2578. this.context.bezierCurveTo(22.1716, 15.5, 21.5, 14.8284, 21.5, 14)
  2579. this.context.bezierCurveTo(21.5, 13.1716, 22.1716, 12.5, 23, 12.5)
  2580. this.context.bezierCurveTo(23.8284, 12.5, 24.5, 13.1716, 24.5, 14)
  2581. this.context.closePath()
  2582. this.context.fill()
  2583. this.context.stroke()
  2584. this.context.beginPath()
  2585. this.context.moveTo(18.5, 9.5)
  2586. this.context.lineTo(20.5, 11.5)
  2587. this.context.fill()
  2588. this.context.stroke()
  2589. this.context.beginPath()
  2590. this.context.moveTo(25.5, 16.5)
  2591. this.context.lineTo(27.5, 18.5)
  2592. this.context.fill()
  2593. this.context.stroke()
  2594. this.context.beginPath()
  2595. this.context.moveTo(20.5, 16.5)
  2596. this.context.lineTo(18.5, 18.5)
  2597. this.context.fill()
  2598. this.context.stroke()
  2599. this.context.beginPath()
  2600. this.context.moveTo(13.5, 9.5)
  2601. this.context.lineTo(11.5, 11.5)
  2602. this.context.fill()
  2603. this.context.stroke()
  2604. this.context.beginPath()
  2605. this.context.moveTo(27.5, 9.5)
  2606. this.context.lineTo(25.5, 11.5)
  2607. this.context.fill()
  2608. this.context.stroke()
  2609. this.context.restore()
  2610. }
  2611. drawCupboard(geometry) {
  2612. const selectItem = stateService.getSelectItem()
  2613. const draggingItem = stateService.getDraggingItem()
  2614. const focusItem = stateService.getFocusItem()
  2615. this.context.save()
  2616. this.context.strokeStyle = Style.Furniture.strokeStyle
  2617. this.context.fillStyle = Style.Furniture.fillStyle
  2618. if (selectItem && selectItem.type == VectorType.Cupboard) {
  2619. if (geometry.vectorId == selectItem.vectorId) {
  2620. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2621. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2622. }
  2623. } else if (draggingItem && draggingItem.type == VectorType.Cupboard) {
  2624. if (geometry.vectorId == draggingItem.vectorId) {
  2625. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2626. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2627. }
  2628. }
  2629. if (focusItem && focusItem.type == VectorType.Cupboard) {
  2630. if (geometry.vectorId == focusItem.vectorId) {
  2631. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  2632. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  2633. }
  2634. }
  2635. const center = coordinate.getScreenXY({
  2636. x: geometry.center.x,
  2637. y: geometry.center.y,
  2638. })
  2639. const pt = coordinate.getScreenXY({
  2640. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  2641. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  2642. })
  2643. this.context.translate(center.x, center.y)
  2644. this.context.rotate((geometry.angle / 180) * Math.PI)
  2645. this.context.translate(pt.x - center.x, pt.y - center.y)
  2646. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2647. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2648. this.context.miterLimit = 4
  2649. this.context.beginPath()
  2650. this.context.moveTo(21, 7.5)
  2651. this.context.bezierCurveTo(21.8284, 7.5, 22.5, 6.82843, 22.5, 6)
  2652. this.context.bezierCurveTo(22.5, 5.17157, 21.8284, 4.5, 21, 4.5)
  2653. this.context.fill()
  2654. this.context.stroke()
  2655. this.context.beginPath()
  2656. this.context.moveTo(21, 17.5)
  2657. this.context.bezierCurveTo(21.8284, 17.5, 22.5, 16.8284, 22.5, 16)
  2658. this.context.bezierCurveTo(22.5, 15.1716, 21.8284, 14.5, 21, 14.5)
  2659. this.context.fill()
  2660. this.context.stroke()
  2661. this.context.beginPath()
  2662. this.context.moveTo(21, 27.5)
  2663. this.context.bezierCurveTo(21.8284, 27.5, 22.5, 26.8284, 22.5, 26)
  2664. this.context.bezierCurveTo(22.5, 25.1716, 21.8284, 24.5, 21, 24.5)
  2665. this.context.fill()
  2666. this.context.stroke()
  2667. this.context.beginPath()
  2668. this.context.moveTo(12.5, 0.5)
  2669. this.context.lineTo(20.5, 0.5)
  2670. this.context.lineTo(20.5, 31.5)
  2671. this.context.lineTo(12.5, 31.5)
  2672. this.context.lineTo(12.5, 0.5)
  2673. this.context.closePath()
  2674. this.context.fill()
  2675. this.context.stroke()
  2676. this.context.beginPath()
  2677. this.context.moveTo(18.5, 1)
  2678. this.context.lineTo(18.5, 31)
  2679. this.context.fill()
  2680. this.context.stroke()
  2681. this.context.beginPath()
  2682. this.context.moveTo(13, 21.5)
  2683. this.context.lineTo(20, 21.5)
  2684. this.context.fill()
  2685. this.context.stroke()
  2686. this.context.beginPath()
  2687. this.context.moveTo(13, 10.5)
  2688. this.context.lineTo(20, 10.5)
  2689. this.context.fill()
  2690. this.context.stroke()
  2691. this.context.restore()
  2692. }
  2693. drawBathtub(geometry) {
  2694. const selectItem = stateService.getSelectItem()
  2695. const draggingItem = stateService.getDraggingItem()
  2696. const focusItem = stateService.getFocusItem()
  2697. this.context.save()
  2698. this.context.strokeStyle = Style.Furniture.strokeStyle
  2699. this.context.fillStyle = Style.Furniture.fillStyle
  2700. if (selectItem && selectItem.type == VectorType.Bathtub) {
  2701. if (geometry.vectorId == selectItem.vectorId) {
  2702. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2703. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2704. }
  2705. } else if (draggingItem && draggingItem.type == VectorType.Bathtub) {
  2706. if (geometry.vectorId == draggingItem.vectorId) {
  2707. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2708. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2709. }
  2710. }
  2711. if (focusItem && focusItem.type == VectorType.Bathtub) {
  2712. if (geometry.vectorId == focusItem.vectorId) {
  2713. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  2714. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  2715. }
  2716. }
  2717. const center = coordinate.getScreenXY({
  2718. x: geometry.center.x,
  2719. y: geometry.center.y,
  2720. })
  2721. const pt = coordinate.getScreenXY({
  2722. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  2723. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  2724. })
  2725. this.context.translate(center.x, center.y)
  2726. this.context.rotate((geometry.angle / 180) * Math.PI)
  2727. this.context.translate(pt.x - center.x, pt.y - center.y)
  2728. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2729. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2730. this.context.miterLimit = 4
  2731. this.context.beginPath()
  2732. this.context.moveTo(0.5, 7.5)
  2733. this.context.lineTo(31.5, 7.5)
  2734. this.context.lineTo(31.5, 24.5)
  2735. this.context.lineTo(0.5, 24.5)
  2736. this.context.lineTo(0.5, 7.5)
  2737. this.context.closePath()
  2738. this.context.fill()
  2739. this.context.stroke()
  2740. this.context.beginPath()
  2741. this.context.moveTo(2.5, 16)
  2742. this.context.bezierCurveTo(2.5, 12.4101, 5.41015, 9.5, 9, 9.5)
  2743. this.context.lineTo(23, 9.5)
  2744. this.context.bezierCurveTo(26.5899, 9.5, 29.5, 12.4101, 29.5, 16)
  2745. this.context.lineTo(29.5, 16)
  2746. this.context.bezierCurveTo(29.5, 19.5899, 26.5899, 22.5, 23, 22.5)
  2747. this.context.lineTo(9, 22.5)
  2748. this.context.bezierCurveTo(5.41015, 22.5, 2.5, 19.5899, 2.5, 16)
  2749. this.context.lineTo(2.5, 16)
  2750. this.context.closePath()
  2751. this.context.fill()
  2752. this.context.stroke()
  2753. this.context.beginPath()
  2754. this.context.moveTo(1, 15.5)
  2755. this.context.lineTo(5.5, 15.5)
  2756. this.context.lineTo(5.5, 16.5)
  2757. this.context.lineTo(1, 16.5)
  2758. this.context.lineTo(1, 15.5)
  2759. this.context.closePath()
  2760. this.context.fill()
  2761. this.context.stroke()
  2762. this.context.beginPath()
  2763. this.context.moveTo(26.5, 16)
  2764. this.context.bezierCurveTo(26.5, 16.2761, 26.2761, 16.5, 26, 16.5)
  2765. this.context.bezierCurveTo(25.7239, 16.5, 25.5, 16.2761, 25.5, 16)
  2766. this.context.bezierCurveTo(25.5, 15.7239, 25.7239, 15.5, 26, 15.5)
  2767. this.context.bezierCurveTo(26.2761, 15.5, 26.5, 15.7239, 26.5, 16)
  2768. this.context.closePath()
  2769. this.context.fill()
  2770. this.context.stroke()
  2771. this.context.beginPath()
  2772. this.context.moveTo(11.5, 20.5)
  2773. this.context.lineTo(20.5, 20.5)
  2774. this.context.fill()
  2775. this.context.stroke()
  2776. this.context.beginPath()
  2777. this.context.moveTo(13.5, 20.5)
  2778. this.context.lineTo(13.5, 22.5)
  2779. this.context.fill()
  2780. this.context.stroke()
  2781. this.context.beginPath()
  2782. this.context.moveTo(18.5, 20.5)
  2783. this.context.lineTo(18.5, 22.5)
  2784. this.context.fill()
  2785. this.context.stroke()
  2786. this.context.restore()
  2787. }
  2788. drawClosestool(geometry) {
  2789. const selectItem = stateService.getSelectItem()
  2790. const draggingItem = stateService.getDraggingItem()
  2791. const focusItem = stateService.getFocusItem()
  2792. this.context.save()
  2793. this.context.strokeStyle = Style.Furniture.strokeStyle
  2794. this.context.fillStyle = Style.Furniture.fillStyle
  2795. if (selectItem && selectItem.type == VectorType.Closestool) {
  2796. if (geometry.vectorId == selectItem.vectorId) {
  2797. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2798. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2799. }
  2800. } else if (draggingItem && draggingItem.type == VectorType.Closestool) {
  2801. if (geometry.vectorId == draggingItem.vectorId) {
  2802. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2803. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2804. }
  2805. }
  2806. if (focusItem && focusItem.type == VectorType.Closestool) {
  2807. if (geometry.vectorId == focusItem.vectorId) {
  2808. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  2809. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  2810. }
  2811. }
  2812. const center = coordinate.getScreenXY({
  2813. x: geometry.center.x,
  2814. y: geometry.center.y,
  2815. })
  2816. const pt = coordinate.getScreenXY({
  2817. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  2818. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  2819. })
  2820. this.context.translate(center.x, center.y)
  2821. this.context.rotate((geometry.angle / 180) * Math.PI)
  2822. this.context.translate(pt.x - center.x, pt.y - center.y)
  2823. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2824. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2825. this.context.miterLimit = 4
  2826. this.context.beginPath()
  2827. this.context.moveTo(5.5, 3.5)
  2828. this.context.bezierCurveTo(5.5, 2.94772, 5.94772, 2.5, 6.5, 2.5)
  2829. this.context.lineTo(25.5, 2.5)
  2830. this.context.bezierCurveTo(26.0523, 2.5, 26.5, 2.94772, 26.5, 3.5)
  2831. this.context.lineTo(26.5, 9.5)
  2832. this.context.bezierCurveTo(26.5, 10.0523, 26.0523, 10.5, 25.5, 10.5)
  2833. this.context.lineTo(6.5, 10.5)
  2834. this.context.bezierCurveTo(5.94772, 10.5, 5.5, 10.0523, 5.5, 9.5)
  2835. this.context.lineTo(5.5, 3.5)
  2836. this.context.closePath()
  2837. this.context.fill()
  2838. this.context.stroke()
  2839. this.context.beginPath()
  2840. this.context.moveTo(9.5, 12.6485)
  2841. this.context.bezierCurveTo(9.5, 12.5665, 9.56649, 12.5, 9.64851, 12.5)
  2842. this.context.lineTo(22.3515, 12.5)
  2843. this.context.bezierCurveTo(22.4335, 12.5, 22.5, 12.5665, 22.5, 12.6485)
  2844. this.context.lineTo(22.5, 21)
  2845. this.context.bezierCurveTo(22.5, 24.5899, 19.5899, 27.5, 16, 27.5)
  2846. this.context.lineTo(16, 27.5)
  2847. this.context.bezierCurveTo(12.4101, 27.5, 9.5, 24.5899, 9.5, 21)
  2848. this.context.lineTo(9.5, 12.6485)
  2849. this.context.closePath()
  2850. this.context.fill()
  2851. this.context.stroke()
  2852. this.context.beginPath()
  2853. this.context.moveTo(7.5, 10.5)
  2854. this.context.lineTo(7.5, 21)
  2855. this.context.bezierCurveTo(7.5, 25.6944, 11.3056, 29.5, 16, 29.5)
  2856. this.context.lineTo(16, 29.5)
  2857. this.context.bezierCurveTo(20.6944, 29.5, 24.5, 25.6944, 24.5, 21)
  2858. this.context.lineTo(24.5, 10.5)
  2859. this.context.fill()
  2860. this.context.stroke()
  2861. this.context.beginPath()
  2862. this.context.moveTo(17.5, 6)
  2863. this.context.bezierCurveTo(17.5, 6.82843, 16.8284, 7.5, 16, 7.5)
  2864. this.context.bezierCurveTo(15.1716, 7.5, 14.5, 6.82843, 14.5, 6)
  2865. this.context.bezierCurveTo(14.5, 5.17157, 15.1716, 4.5, 16, 4.5)
  2866. this.context.bezierCurveTo(16.8284, 4.5, 17.5, 5.17157, 17.5, 6)
  2867. this.context.closePath()
  2868. this.context.fill()
  2869. this.context.stroke()
  2870. this.context.restore()
  2871. }
  2872. drawWashstand(geometry) {
  2873. const selectItem = stateService.getSelectItem()
  2874. const draggingItem = stateService.getDraggingItem()
  2875. const focusItem = stateService.getFocusItem()
  2876. this.context.save()
  2877. this.context.strokeStyle = Style.Furniture.strokeStyle
  2878. this.context.fillStyle = Style.Furniture.fillStyle
  2879. if (selectItem && selectItem.type == VectorType.Washstand) {
  2880. if (geometry.vectorId == selectItem.vectorId) {
  2881. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2882. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2883. }
  2884. } else if (draggingItem && draggingItem.type == VectorType.Washstand) {
  2885. if (geometry.vectorId == draggingItem.vectorId) {
  2886. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2887. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2888. }
  2889. }
  2890. if (focusItem && focusItem.type == VectorType.Washstand) {
  2891. if (geometry.vectorId == focusItem.vectorId) {
  2892. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  2893. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  2894. }
  2895. }
  2896. const center = coordinate.getScreenXY({
  2897. x: geometry.center.x,
  2898. y: geometry.center.y,
  2899. })
  2900. const pt = coordinate.getScreenXY({
  2901. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  2902. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  2903. })
  2904. this.context.translate(center.x, center.y)
  2905. this.context.rotate((geometry.angle / 180) * Math.PI)
  2906. this.context.translate(pt.x - center.x, pt.y - center.y)
  2907. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2908. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  2909. this.context.miterLimit = 4
  2910. this.context.font = "15px ''"
  2911. this.context.beginPath()
  2912. this.context.moveTo(13.5, 9)
  2913. this.context.bezierCurveTo(13.5, 9.27614, 13.2761, 9.5, 13, 9.5)
  2914. this.context.bezierCurveTo(12.7239, 9.5, 12.5, 9.27614, 12.5, 9)
  2915. this.context.bezierCurveTo(12.5, 8.72386, 12.7239, 8.5, 13, 8.5)
  2916. this.context.bezierCurveTo(13.2761, 8.5, 13.5, 8.72386, 13.5, 9)
  2917. this.context.closePath()
  2918. this.context.fill()
  2919. this.context.stroke()
  2920. this.context.beginPath()
  2921. this.context.moveTo(19.5, 9)
  2922. this.context.bezierCurveTo(19.5, 9.27614, 19.2761, 9.5, 19, 9.5)
  2923. this.context.bezierCurveTo(18.7239, 9.5, 18.5, 9.27614, 18.5, 9)
  2924. this.context.bezierCurveTo(18.5, 8.72386, 18.7239, 8.5, 19, 8.5)
  2925. this.context.bezierCurveTo(19.2761, 8.5, 19.5, 8.72386, 19.5, 9)
  2926. this.context.closePath()
  2927. this.context.fill()
  2928. this.context.stroke()
  2929. this.context.beginPath()
  2930. this.context.moveTo(16.5, 17)
  2931. this.context.bezierCurveTo(16.5, 17.2761, 16.2761, 17.5, 16, 17.5)
  2932. this.context.bezierCurveTo(15.7239, 17.5, 15.5, 17.2761, 15.5, 17)
  2933. this.context.bezierCurveTo(15.5, 16.7239, 15.7239, 16.5, 16, 16.5)
  2934. this.context.bezierCurveTo(16.2761, 16.5, 16.5, 16.7239, 16.5, 17)
  2935. this.context.closePath()
  2936. this.context.fill()
  2937. this.context.stroke()
  2938. this.context.beginPath()
  2939. this.context.moveTo(26.5, 17)
  2940. this.context.bezierCurveTo(26.5, 20.0376, 21.799, 22.5, 16, 22.5)
  2941. this.context.bezierCurveTo(10.201, 22.5, 5.5, 20.0376, 5.5, 17)
  2942. this.context.bezierCurveTo(5.5, 13.9624, 10.201, 11.5, 16, 11.5)
  2943. this.context.bezierCurveTo(21.799, 11.5, 26.5, 13.9624, 26.5, 17)
  2944. this.context.closePath()
  2945. this.context.fill()
  2946. this.context.stroke()
  2947. this.context.beginPath()
  2948. this.context.moveTo(2.5, 6.5)
  2949. this.context.lineTo(29.5, 6.5)
  2950. this.context.lineTo(29.5, 25.5)
  2951. this.context.lineTo(2.5, 25.5)
  2952. this.context.lineTo(2.5, 6.5)
  2953. this.context.closePath()
  2954. this.context.fill()
  2955. this.context.stroke()
  2956. this.context.beginPath()
  2957. this.context.moveTo(15.5, 9)
  2958. this.context.bezierCurveTo(15.5, 8.72386, 15.7239, 8.5, 16, 8.5)
  2959. this.context.lineTo(16, 8.5)
  2960. this.context.bezierCurveTo(16.2761, 8.5, 16.5, 8.72386, 16.5, 9)
  2961. this.context.lineTo(16.5, 14)
  2962. this.context.bezierCurveTo(16.5, 14.2761, 16.2761, 14.5, 16, 14.5)
  2963. this.context.lineTo(16, 14.5)
  2964. this.context.bezierCurveTo(15.7239, 14.5, 15.5, 14.2761, 15.5, 14)
  2965. this.context.lineTo(15.5, 9)
  2966. this.context.closePath()
  2967. this.context.fill()
  2968. this.context.stroke()
  2969. this.context.restore()
  2970. }
  2971. drawDesk(geometry) {
  2972. const selectItem = stateService.getSelectItem()
  2973. const draggingItem = stateService.getDraggingItem()
  2974. const focusItem = stateService.getFocusItem()
  2975. this.context.save()
  2976. this.context.strokeStyle = Style.Furniture.strokeStyle
  2977. this.context.fillStyle = Style.Furniture.fillStyle
  2978. if (selectItem && selectItem.type == VectorType.Desk) {
  2979. if (geometry.vectorId == selectItem.vectorId) {
  2980. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2981. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2982. }
  2983. } else if (draggingItem && draggingItem.type == VectorType.Desk) {
  2984. if (geometry.vectorId == draggingItem.vectorId) {
  2985. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  2986. this.context.fillStyle = Style.Select.Furniture.fillStyle
  2987. }
  2988. }
  2989. if (focusItem && focusItem.type == VectorType.Desk) {
  2990. if (geometry.vectorId == focusItem.vectorId) {
  2991. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  2992. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  2993. }
  2994. }
  2995. const center = coordinate.getScreenXY({
  2996. x: geometry.center.x,
  2997. y: geometry.center.y,
  2998. })
  2999. const pt = coordinate.getScreenXY({
  3000. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  3001. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  3002. })
  3003. this.context.translate(center.x, center.y)
  3004. this.context.rotate((geometry.angle / 180) * Math.PI)
  3005. this.context.translate(pt.x - center.x, pt.y - center.y)
  3006. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  3007. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  3008. this.context.miterLimit = 4
  3009. this.context.beginPath()
  3010. this.context.moveTo(3.5, 7.5)
  3011. this.context.lineTo(28.5, 7.5)
  3012. this.context.lineTo(28.5, 19.5)
  3013. this.context.lineTo(3.5, 19.5)
  3014. this.context.lineTo(3.5, 7.5)
  3015. this.context.closePath()
  3016. this.context.fill()
  3017. this.context.stroke()
  3018. this.context.beginPath()
  3019. this.context.moveTo(11.5, 20)
  3020. this.context.lineTo(11.5, 22)
  3021. this.context.bezierCurveTo(11.5, 24.4853, 13.5147, 26.5, 16, 26.5)
  3022. this.context.lineTo(16, 26.5)
  3023. this.context.bezierCurveTo(18.4853, 26.5, 20.5, 24.4853, 20.5, 22)
  3024. this.context.lineTo(20.5, 20)
  3025. this.context.fill()
  3026. this.context.stroke()
  3027. this.context.beginPath()
  3028. this.context.moveTo(15.5, 10.5)
  3029. this.context.lineTo(25.5, 10.5)
  3030. this.context.lineTo(25.5, 16.5)
  3031. this.context.lineTo(15.5, 16.5)
  3032. this.context.lineTo(15.5, 10.5)
  3033. this.context.closePath()
  3034. this.context.fill()
  3035. this.context.stroke()
  3036. this.context.beginPath()
  3037. this.context.moveTo(20.5, 11)
  3038. this.context.lineTo(20.5, 16)
  3039. this.context.fill()
  3040. this.context.stroke()
  3041. this.context.beginPath()
  3042. this.context.moveTo(17.5, 12.5)
  3043. this.context.lineTo(18.5, 12.5)
  3044. this.context.fill()
  3045. this.context.stroke()
  3046. this.context.beginPath()
  3047. this.context.moveTo(22.5, 12.5)
  3048. this.context.lineTo(23.5, 12.5)
  3049. this.context.fill()
  3050. this.context.stroke()
  3051. this.context.beginPath()
  3052. this.context.moveTo(17.5, 14.5)
  3053. this.context.lineTo(18.5, 14.5)
  3054. this.context.fill()
  3055. this.context.stroke()
  3056. this.context.beginPath()
  3057. this.context.moveTo(22.5, 14.5)
  3058. this.context.lineTo(23.5, 14.5)
  3059. this.context.fill()
  3060. this.context.stroke()
  3061. this.context.restore()
  3062. }
  3063. drawBalconyChair(geometry) {
  3064. const selectItem = stateService.getSelectItem()
  3065. const draggingItem = stateService.getDraggingItem()
  3066. const focusItem = stateService.getFocusItem()
  3067. this.context.save()
  3068. this.context.strokeStyle = Style.Furniture.strokeStyle
  3069. this.context.fillStyle = Style.Furniture.fillStyle
  3070. if (selectItem && selectItem.type == VectorType.BalconyChair) {
  3071. if (geometry.vectorId == selectItem.vectorId) {
  3072. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  3073. this.context.fillStyle = Style.Select.Furniture.fillStyle
  3074. }
  3075. } else if (draggingItem && draggingItem.type == VectorType.BalconyChair) {
  3076. if (geometry.vectorId == draggingItem.vectorId) {
  3077. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  3078. this.context.fillStyle = Style.Select.Furniture.fillStyle
  3079. }
  3080. }
  3081. if (focusItem && focusItem.type == VectorType.BalconyChair) {
  3082. if (geometry.vectorId == focusItem.vectorId) {
  3083. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  3084. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  3085. }
  3086. }
  3087. const center = coordinate.getScreenXY({
  3088. x: geometry.center.x,
  3089. y: geometry.center.y,
  3090. })
  3091. const pt = coordinate.getScreenXY({
  3092. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  3093. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  3094. })
  3095. this.context.translate(center.x, center.y)
  3096. this.context.rotate((geometry.angle / 180) * Math.PI)
  3097. this.context.translate(pt.x - center.x, pt.y - center.y)
  3098. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  3099. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  3100. this.context.miterLimit = 4
  3101. this.context.beginPath()
  3102. this.context.arc(16, 16, 4.5, 0, 6.283185307179586, false)
  3103. this.context.closePath()
  3104. this.context.fill()
  3105. this.context.stroke()
  3106. this.context.beginPath()
  3107. this.context.moveTo(0.5, 12.3182)
  3108. this.context.bezierCurveTo(0.5, 11.8663, 0.866313, 11.5, 1.31818, 11.5)
  3109. this.context.lineTo(8.68182, 11.5)
  3110. this.context.bezierCurveTo(9.13369, 11.5, 9.5, 11.8663, 9.5, 12.3182)
  3111. this.context.lineTo(9.5, 16)
  3112. this.context.bezierCurveTo(9.5, 18.4853, 7.48528, 20.5, 5, 20.5)
  3113. this.context.lineTo(5, 20.5)
  3114. this.context.bezierCurveTo(2.51472, 20.5, 0.5, 18.4853, 0.5, 16)
  3115. this.context.lineTo(0.5, 12.3182)
  3116. this.context.closePath()
  3117. this.context.fill()
  3118. this.context.stroke()
  3119. this.context.beginPath()
  3120. this.context.moveTo(22.5, 12.3182)
  3121. this.context.bezierCurveTo(22.5, 11.8663, 22.8663, 11.5, 23.3182, 11.5)
  3122. this.context.lineTo(30.6818, 11.5)
  3123. this.context.bezierCurveTo(31.1337, 11.5, 31.5, 11.8663, 31.5, 12.3182)
  3124. this.context.lineTo(31.5, 16)
  3125. this.context.bezierCurveTo(31.5, 18.4853, 29.4853, 20.5, 27, 20.5)
  3126. this.context.lineTo(27, 20.5)
  3127. this.context.bezierCurveTo(24.5147, 20.5, 22.5, 18.4853, 22.5, 16)
  3128. this.context.lineTo(22.5, 12.3182)
  3129. this.context.closePath()
  3130. this.context.fill()
  3131. this.context.stroke()
  3132. this.context.beginPath()
  3133. this.context.moveTo(0.5, 13.5)
  3134. this.context.lineTo(0.5, 13.5)
  3135. this.context.bezierCurveTo(0.5, 15.9853, 2.51472, 18, 5, 18)
  3136. this.context.lineTo(5, 18)
  3137. this.context.bezierCurveTo(7.48528, 18, 9.5, 15.9853, 9.5, 13.5)
  3138. this.context.lineTo(9.5, 13.5)
  3139. this.context.fill()
  3140. this.context.stroke()
  3141. this.context.beginPath()
  3142. this.context.moveTo(22.5, 13.5)
  3143. this.context.lineTo(22.5, 13.5)
  3144. this.context.bezierCurveTo(22.5, 15.9853, 24.5147, 18, 27, 18)
  3145. this.context.lineTo(27, 18)
  3146. this.context.bezierCurveTo(29.4853, 18, 31.5, 15.9853, 31.5, 13.5)
  3147. this.context.lineTo(31.5, 13.5)
  3148. this.context.fill()
  3149. this.context.stroke()
  3150. this.context.restore()
  3151. }
  3152. drawElevator(geometry) {
  3153. const selectItem = stateService.getSelectItem()
  3154. const draggingItem = stateService.getDraggingItem()
  3155. const focusItem = stateService.getFocusItem()
  3156. this.context.save()
  3157. this.context.strokeStyle = Style.Furniture.strokeStyle
  3158. this.context.fillStyle = Style.Furniture.fillStyle
  3159. if (selectItem && selectItem.type == VectorType.Elevator) {
  3160. if (geometry.vectorId == selectItem.vectorId) {
  3161. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  3162. this.context.fillStyle = Style.Select.Furniture.fillStyle
  3163. }
  3164. } else if (draggingItem && draggingItem.type == VectorType.Elevator) {
  3165. if (geometry.vectorId == draggingItem.vectorId) {
  3166. this.context.strokeStyle = Style.Select.Furniture.strokeStyle
  3167. this.context.fillStyle = Style.Select.Furniture.fillStyle
  3168. }
  3169. }
  3170. if (focusItem && focusItem.type == VectorType.Elevator) {
  3171. if (geometry.vectorId == focusItem.vectorId) {
  3172. this.context.strokeStyle = Style.Focus.Furniture.strokeStyle
  3173. this.context.fillStyle = Style.Focus.Furniture.fillStyle
  3174. }
  3175. }
  3176. const center = coordinate.getScreenXY({
  3177. x: geometry.center.x,
  3178. y: geometry.center.y,
  3179. })
  3180. const pt = coordinate.getScreenXY({
  3181. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  3182. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  3183. })
  3184. this.context.translate(center.x, center.y)
  3185. this.context.rotate((geometry.angle / 180) * Math.PI)
  3186. this.context.translate(pt.x - center.x, pt.y - center.y)
  3187. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  3188. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  3189. this.context.miterLimit = 4
  3190. this.context.font = "15px ''"
  3191. this.context.beginPath()
  3192. this.context.moveTo(2.5, 29.5)
  3193. this.context.lineTo(10.5, 29.5)
  3194. this.context.lineTo(10.5, 27.5)
  3195. this.context.lineTo(4.5, 27.5)
  3196. this.context.lineTo(4.5, 4.5)
  3197. this.context.lineTo(27.5, 4.5)
  3198. this.context.lineTo(27.5, 27.5)
  3199. this.context.lineTo(20.5, 27.5)
  3200. this.context.lineTo(20.5, 29.5)
  3201. this.context.lineTo(29.5, 29.5)
  3202. this.context.lineTo(29.5, 2.5)
  3203. this.context.lineTo(2.5, 2.5)
  3204. this.context.lineTo(2.5, 29.5)
  3205. this.context.closePath()
  3206. this.context.fill()
  3207. this.context.stroke()
  3208. this.context.beginPath()
  3209. this.context.moveTo(11, 28.5)
  3210. this.context.lineTo(20, 28.5)
  3211. this.context.fill()
  3212. this.context.stroke()
  3213. this.context.beginPath()
  3214. this.context.moveTo(8.5, 9.5)
  3215. this.context.lineTo(8.5, 7.5)
  3216. this.context.lineTo(23.5, 7.5)
  3217. this.context.lineTo(23.5, 9.5)
  3218. this.context.lineTo(8.5, 9.5)
  3219. this.context.closePath()
  3220. this.context.fill()
  3221. this.context.stroke()
  3222. this.context.beginPath()
  3223. this.context.moveTo(24.5, 12.5)
  3224. this.context.lineTo(7.5, 12.5)
  3225. this.context.lineTo(7.5, 24.5)
  3226. this.context.lineTo(24.5, 24.5)
  3227. this.context.lineTo(24.5, 12.5)
  3228. this.context.closePath()
  3229. this.context.fill()
  3230. this.context.stroke()
  3231. this.context.beginPath()
  3232. this.context.moveTo(8, 13)
  3233. this.context.lineTo(24, 24)
  3234. this.context.fill()
  3235. this.context.stroke()
  3236. this.context.beginPath()
  3237. this.context.moveTo(24, 13)
  3238. this.context.lineTo(8, 24)
  3239. this.context.fill()
  3240. this.context.stroke()
  3241. this.context.restore()
  3242. }
  3243. // drawDoubleBed(geometry){
  3244. // //开始画矢量
  3245. // this.context.save()
  3246. // /*
  3247. // let imgWidth = geometry.sideLength * coordinate.res*50
  3248. // let imgHeight = geometry.sideLength * coordinate.res*50
  3249. // const pt = coordinate.getScreenXY({
  3250. // x: geometry.center.x - geometry.sideLength *50/ 2,
  3251. // y: geometry.center.y + geometry.sideLength *50/ 2,
  3252. // })
  3253. // // furnitureService.getFurniture(geometry.geoType).then(img => {
  3254. // // this.context.drawImage(img, pt.x, pt.y, imgWidth, imgHeight)
  3255. // // })
  3256. // let img = furnitureService.getFurniture(geometry.geoType)
  3257. // this.context.drawImage(img, pt.x, pt.y, imgWidth, imgHeight)
  3258. // this.context.restore()
  3259. // */
  3260. // const pt = coordinate.getScreenXY({
  3261. // x: geometry.center.x - geometry.sideLength / 2,
  3262. // y: geometry.center.y + geometry.sideLength / 2,
  3263. // })
  3264. // this.context.translate(pt.x, pt.y)
  3265. // this.context.rotate((geometry.angle / 180) * Math.PI)
  3266. // this.context.scale(geometry.sideLength, geometry.sideLength)
  3267. // this.context.restore()
  3268. // }
  3269. /***************************************************************************************************************************************************************************************/
  3270. }
  3271. const draw = new Draw()
  3272. export { draw }