customNode.js 117 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840
  1. import {
  2. Graph
  3. } from '@antv/x6'
  4. // transverse vertical
  5. // 横 纵
  6. const weight = 3;
  7. const fontsize = 12;
  8. const nodeSize = {};
  9. const blueIconWidth = 24;
  10. const blueIconHeight = 18;
  11. const registerRootNode = () => {
  12. const shapeName = "root-node";
  13. Graph.registerNode(shapeName, {
  14. width: 0,
  15. height: weight,
  16. markup: [{
  17. tagName: 'text',
  18. selector: 'label',
  19. },
  20. {
  21. tagName: 'rect',
  22. selector: 'line',
  23. },
  24. ],
  25. attrs: {
  26. label: {
  27. fill: '#D0D0D0',
  28. y: -fontsize,
  29. fontSize: fontsize,
  30. },
  31. line: {
  32. height: weight,
  33. stroke: "transparent",
  34. },
  35. },
  36. }, true);
  37. }
  38. // 断路器纵向断开
  39. const registerCircuitBreakerVerticalBreak = () => {
  40. const width = 100;
  41. const height = 30;
  42. const shapeName = "circuit-breaker-vertical-break";
  43. const commonOption = () => {
  44. return {
  45. width: width,
  46. height: height,
  47. markup: [{
  48. tagName: 'text',
  49. selector: 'label',
  50. },
  51. {
  52. tagName: 'rect',
  53. selector: 'line',
  54. },
  55. ],
  56. attrs: {
  57. label: {
  58. fill: '#D0D0D0',
  59. fontSize: fontsize,
  60. },
  61. line: {
  62. width: weight,
  63. height: height / 3,
  64. x: -(weight / 2),
  65. fill: "#b30461",
  66. stroke: "transparent",
  67. },
  68. },
  69. }
  70. }
  71. const leftOption = () => {
  72. const option = commonOption();
  73. option.attrs.label.refX = -15;
  74. option.attrs.label['text-anchor'] = 'end';
  75. return option;
  76. }
  77. const rightOption = () => {
  78. const option = commonOption();
  79. option.attrs.label.refX = 15;
  80. option.attrs.label['text-anchor'] = 'start';
  81. return option;
  82. }
  83. const topOption = (option) => {
  84. option.attrs.label.refY = weight;
  85. option.attrs.line.y = height / 3 * 2;
  86. }
  87. const bottomOption = (option) => {
  88. option.attrs.label.refY = weight + height / 3;
  89. option.attrs.line.y = 0;
  90. }
  91. const registerTopLeft = () => {
  92. const shape = `${shapeName}-top-left`;
  93. nodeSize[shape] = {
  94. width: width,
  95. height: height
  96. };
  97. const option = leftOption();
  98. topOption(option);
  99. Graph.registerNode(shape, option, true);
  100. }
  101. const registerTopRight = () => {
  102. const shape = `${shapeName}-top-right`;
  103. nodeSize[shape] = {
  104. width: width,
  105. height: height
  106. };
  107. const option = rightOption();
  108. topOption(option);
  109. Graph.registerNode(shape, option, true);
  110. }
  111. const registerBottomLeft = () => {
  112. const shape = `${shapeName}-bottom-left`;
  113. nodeSize[shape] = {
  114. width: width,
  115. height: height
  116. };
  117. const option = leftOption();
  118. bottomOption(option);
  119. Graph.registerNode(shape, option, true);
  120. }
  121. const registerBottomRight = () => {
  122. const shape = `${shapeName}-bottom-right`;
  123. nodeSize[shape] = {
  124. width: width,
  125. height: height
  126. };
  127. const option = rightOption();
  128. bottomOption(option);
  129. Graph.registerNode(shape, option, true);
  130. }
  131. registerTopLeft();
  132. registerTopRight();
  133. registerBottomLeft();
  134. registerBottomRight();
  135. }
  136. // 长断路器纵向断开
  137. const registerLongCircuitBreakerVerticalBreak = () => {
  138. const width = 100;
  139. const height = 50;
  140. const shapeName = "long-circuit-breaker-vertical-break";
  141. const commonOption = () => {
  142. return {
  143. width: width,
  144. height: height,
  145. markup: [{
  146. tagName: 'text',
  147. selector: 'label',
  148. },
  149. {
  150. tagName: 'rect',
  151. selector: 'line',
  152. },
  153. ],
  154. attrs: {
  155. label: {
  156. fill: '#D0D0D0',
  157. fontSize: fontsize,
  158. },
  159. line: {
  160. width: weight,
  161. height: height / 5 * 3,
  162. x: -(weight / 2),
  163. fill: "#cbaa07",
  164. stroke: "transparent",
  165. },
  166. },
  167. }
  168. }
  169. const leftOption = () => {
  170. const option = commonOption();
  171. option.attrs.label.refX = -15;
  172. option.attrs.label['text-anchor'] = 'end';
  173. return option;
  174. }
  175. const rightOption = () => {
  176. const option = commonOption();
  177. option.attrs.label.refX = 15;
  178. option.attrs.label['text-anchor'] = 'start';
  179. return option;
  180. }
  181. const topOption = (option) => {
  182. option.attrs.label.refY = weight;
  183. option.attrs.line.y = height / 3 * 2;
  184. }
  185. const bottomOption = (option) => {
  186. option.attrs.label.refY = weight + height / 5 * 3;
  187. option.attrs.line.y = 0;
  188. }
  189. const registerTopLeft = () => {
  190. const shape = `${shapeName}-top-left`;
  191. nodeSize[shape] = {
  192. width: width,
  193. height: height
  194. };
  195. const option = leftOption();
  196. topOption(option);
  197. Graph.registerNode(shape, option, true);
  198. }
  199. const registerTopRight = () => {
  200. const shape = `${shapeName}-top-right`;
  201. nodeSize[shape] = {
  202. width: width,
  203. height: height
  204. };
  205. const option = rightOption();
  206. topOption(option);
  207. Graph.registerNode(shape, option, true);
  208. }
  209. const registerBottomLeft = () => {
  210. const shape = `${shapeName}-bottom-left`;
  211. nodeSize[shape] = {
  212. width: width,
  213. height: height
  214. };
  215. const option = leftOption();
  216. bottomOption(option);
  217. Graph.registerNode(shape, option, true);
  218. }
  219. const registerBottomRight = () => {
  220. const shape = `${shapeName}-bottom-right`;
  221. nodeSize[shape] = {
  222. width: width,
  223. height: height
  224. };
  225. const option = rightOption();
  226. bottomOption(option);
  227. Graph.registerNode(shape, option, true);
  228. }
  229. registerTopLeft();
  230. registerTopRight();
  231. registerBottomLeft();
  232. registerBottomRight();
  233. }
  234. // 长断路器纵向连接
  235. const registerLongCircuitBreakerVerticalLink = () => {
  236. const width = 100;
  237. const height = 50;
  238. const shapeName = "long-circuit-breaker-vertical-link";
  239. const commonOption = () => {
  240. return {
  241. width: width,
  242. height: height,
  243. markup: [{
  244. tagName: 'text',
  245. selector: 'label',
  246. },
  247. {
  248. tagName: 'rect',
  249. selector: 'line',
  250. },
  251. ],
  252. attrs: {
  253. label: {
  254. fill: '#D0D0D0',
  255. fontSize: fontsize,
  256. },
  257. line: {
  258. width: weight,
  259. height: height,
  260. x: -(weight / 2),
  261. fill: "#cbaa07",
  262. stroke: "transparent",
  263. },
  264. },
  265. }
  266. }
  267. const leftOption = () => {
  268. const option = commonOption();
  269. option.attrs.label.refX = -15;
  270. option.attrs.label['text-anchor'] = 'end';
  271. return option;
  272. }
  273. const rightOption = () => {
  274. const option = commonOption();
  275. option.attrs.label.refX = 15;
  276. option.attrs.label['text-anchor'] = 'start';
  277. return option;
  278. }
  279. const topOption = (option) => {
  280. option.attrs.label.refY = weight;
  281. option.attrs.line.y = height / 3 * 2;
  282. }
  283. const bottomOption = (option) => {
  284. option.attrs.label.refY = weight + height / 5 * 3;
  285. option.attrs.line.y = 0;
  286. }
  287. const registerTopLeft = () => {
  288. const shape = `${shapeName}-top-left`;
  289. nodeSize[shape] = {
  290. width: width,
  291. height: height
  292. };
  293. const option = leftOption();
  294. topOption(option);
  295. Graph.registerNode(shape, option, true);
  296. }
  297. const registerTopRight = () => {
  298. const shape = `${shapeName}-top-right`;
  299. nodeSize[shape] = {
  300. width: width,
  301. height: height
  302. };
  303. const option = rightOption();
  304. topOption(option);
  305. Graph.registerNode(shape, option, true);
  306. }
  307. const registerBottomLeft = () => {
  308. const shape = `${shapeName}-bottom-left`;
  309. nodeSize[shape] = {
  310. width: width,
  311. height: height
  312. };
  313. const option = leftOption();
  314. bottomOption(option);
  315. Graph.registerNode(shape, option, true);
  316. }
  317. const registerBottomRight = () => {
  318. const shape = `${shapeName}-bottom-right`;
  319. nodeSize[shape] = {
  320. width: width,
  321. height: height
  322. };
  323. const option = rightOption();
  324. bottomOption(option);
  325. Graph.registerNode(shape, option, true);
  326. }
  327. registerTopLeft();
  328. registerTopRight();
  329. registerBottomLeft();
  330. registerBottomRight();
  331. }
  332. // 接地隔离开关横向断开
  333. const registerEarthingDisconnectorTransverseBreak = () => {
  334. const width = 300;
  335. const height = 15;
  336. const shapeName = "earthing-disconnector-transverse-break";
  337. const commonOption = () => {
  338. return {
  339. width: width,
  340. height: height,
  341. markup: [{
  342. tagName: 'text',
  343. selector: 'label',
  344. },
  345. {
  346. tagName: 'rect',
  347. selector: 'verticalLine',
  348. },
  349. {
  350. tagName: 'rect',
  351. selector: 'transverseLine',
  352. },
  353. {
  354. tagName: 'rect',
  355. selector: 'iconVerticalLineS',
  356. },
  357. {
  358. tagName: 'rect',
  359. selector: 'iconVerticalLineM',
  360. },
  361. {
  362. tagName: 'rect',
  363. selector: 'iconVerticalLineL',
  364. },
  365. {
  366. tagName: 'rect',
  367. selector: 'iconTransverseLine',
  368. },
  369. ],
  370. attrs: {
  371. label: {
  372. fill: '#D0D0D0',
  373. fontSize: fontsize,
  374. "alignment-baseline": "middle"
  375. },
  376. verticalLine: {
  377. width: weight,
  378. height: height,
  379. x: -(weight / 2),
  380. y: 0,
  381. fill: "#b30461",
  382. stroke: "transparent",
  383. },
  384. transverseLine: {
  385. width: height / 3 * 4,
  386. height: weight,
  387. fill: "#b30461",
  388. stroke: "transparent",
  389. },
  390. iconVerticalLineS: {
  391. width: weight,
  392. height: blueIconHeight / 2,
  393. y: blueIconHeight / 4,
  394. fill: "#2acabe",
  395. stroke: "transparent",
  396. },
  397. iconVerticalLineM: {
  398. width: weight,
  399. height: blueIconHeight / 3 * 2,
  400. y: blueIconHeight / 6,
  401. fill: "#2acabe",
  402. stroke: "transparent",
  403. },
  404. iconVerticalLineL: {
  405. width: weight,
  406. height: blueIconHeight,
  407. y: 0,
  408. fill: "#2acabe",
  409. stroke: "transparent",
  410. },
  411. iconTransverseLine: {
  412. width: blueIconWidth - weight * 4,
  413. height: weight,
  414. y: (blueIconHeight - weight) / 2,
  415. fill: "#2acabe",
  416. stroke: "transparent",
  417. }
  418. },
  419. }
  420. }
  421. const leftOption = () => {
  422. const option = commonOption();
  423. option.attrs.label.x = -(height * 6);
  424. option.attrs.label['text-anchor'] = 'end';
  425. option.attrs.transverseLine.x = -(height / 3 * 4);
  426. option.attrs.iconVerticalLineS.x = 0;
  427. option.attrs.iconVerticalLineM.x = weight / 2 * 3;
  428. option.attrs.iconVerticalLineL.x = weight * 3;
  429. option.attrs.iconTransverseLine.x = weight * 4;
  430. option.attrs.iconVerticalLineS.x -= height * 5;
  431. option.attrs.iconVerticalLineM.x -= height * 5;
  432. option.attrs.iconVerticalLineL.x -= height * 5;
  433. option.attrs.iconTransverseLine.x -= height * 5;
  434. return option;
  435. }
  436. const rightOption = () => {
  437. const option = commonOption();
  438. option.attrs.label.x = height * 6;
  439. option.attrs.label['text-anchor'] = 'start';
  440. option.attrs.transverseLine.x = 0;
  441. option.attrs.iconVerticalLineS.x = 0;
  442. option.attrs.iconVerticalLineM.x = -(weight / 2 * 3);
  443. option.attrs.iconVerticalLineL.x = -(weight * 3);
  444. option.attrs.iconTransverseLine.x = weight - blueIconWidth;
  445. option.attrs.iconVerticalLineS.x += height * 5;
  446. option.attrs.iconVerticalLineM.x += height * 5;
  447. option.attrs.iconVerticalLineL.x += height * 5;
  448. option.attrs.iconTransverseLine.x += height * 5;
  449. return option;
  450. }
  451. const topOption = (option) => {
  452. option.attrs.label.y = fontsize / 2;
  453. option.attrs.transverseLine.y = 0;
  454. option.attrs.iconVerticalLineS.y -= blueIconHeight / 2 - weight / 2;
  455. option.attrs.iconVerticalLineM.y -= blueIconHeight / 2 - weight / 2;
  456. option.attrs.iconVerticalLineL.y -= blueIconHeight / 2 - weight / 2;
  457. option.attrs.iconTransverseLine.y -= blueIconHeight / 2 - weight / 2;
  458. }
  459. const bottomOption = (option) => {
  460. option.attrs.label.y = height - weight + fontsize / 2;
  461. option.attrs.transverseLine.y = height - weight;
  462. option.attrs.iconVerticalLineS.y += height - weight / 2 - blueIconHeight / 2;
  463. option.attrs.iconVerticalLineM.y += height - weight / 2 - blueIconHeight / 2;
  464. option.attrs.iconVerticalLineL.y += height - weight / 2 - blueIconHeight / 2;
  465. option.attrs.iconTransverseLine.y += height - weight / 2 - blueIconHeight / 2;
  466. }
  467. const registerTopLeft = () => {
  468. const shape = `${shapeName}-top-left`;
  469. nodeSize[shape] = {
  470. width: width,
  471. height: height
  472. };
  473. const option = leftOption();
  474. topOption(option);
  475. Graph.registerNode(shape, option, true);
  476. }
  477. const registerTopRight = () => {
  478. const shape = `${shapeName}-top-right`;
  479. nodeSize[shape] = {
  480. width: width,
  481. height: height
  482. };
  483. const option = rightOption();
  484. topOption(option);
  485. Graph.registerNode(shape, option, true);
  486. }
  487. const registerBottomLeft = () => {
  488. const shape = `${shapeName}-bottom-left`;
  489. nodeSize[shape] = {
  490. width: width,
  491. height: height
  492. };
  493. const option = leftOption();
  494. bottomOption(option);
  495. Graph.registerNode(shape, option, true);
  496. }
  497. const registerBottomRight = () => {
  498. const shape = `${shapeName}-bottom-right`;
  499. nodeSize[shape] = {
  500. width: width,
  501. height: height
  502. };
  503. const option = rightOption();
  504. bottomOption(option);
  505. Graph.registerNode(shape, option, true);
  506. }
  507. registerTopLeft();
  508. registerTopRight();
  509. registerBottomLeft();
  510. registerBottomRight();
  511. }
  512. // 接地隔离开关横向断开
  513. const registerEarthingDisconnectorTransverseYBreak = () => {
  514. const width = 300;
  515. const height = 15;
  516. const shapeName = "earthing-disconnector-transverse-y-break";
  517. const commonOption = () => {
  518. return {
  519. width: width,
  520. height: height,
  521. markup: [{
  522. tagName: 'text',
  523. selector: 'label',
  524. },
  525. {
  526. tagName: 'rect',
  527. selector: 'verticalLine',
  528. },
  529. {
  530. tagName: 'rect',
  531. selector: 'transverseLine',
  532. },
  533. {
  534. tagName: 'rect',
  535. selector: 'iconVerticalLineS',
  536. },
  537. {
  538. tagName: 'rect',
  539. selector: 'iconVerticalLineM',
  540. },
  541. {
  542. tagName: 'rect',
  543. selector: 'iconVerticalLineL',
  544. },
  545. {
  546. tagName: 'rect',
  547. selector: 'iconTransverseLine',
  548. },
  549. ],
  550. attrs: {
  551. label: {
  552. fill: '#D0D0D0',
  553. fontSize: fontsize,
  554. "alignment-baseline": "middle"
  555. },
  556. verticalLine: {
  557. width: weight,
  558. height: height,
  559. x: -(weight / 2),
  560. y: 0,
  561. fill: "#cbaa07",
  562. stroke: "transparent",
  563. },
  564. transverseLine: {
  565. width: height / 3 * 4,
  566. height: weight,
  567. fill: "#cbaa07",
  568. stroke: "transparent",
  569. },
  570. iconVerticalLineS: {
  571. width: weight,
  572. height: blueIconHeight / 2,
  573. y: blueIconHeight / 4,
  574. fill: "#2acabe",
  575. stroke: "transparent",
  576. },
  577. iconVerticalLineM: {
  578. width: weight,
  579. height: blueIconHeight / 3 * 2,
  580. y: blueIconHeight / 6,
  581. fill: "#2acabe",
  582. stroke: "transparent",
  583. },
  584. iconVerticalLineL: {
  585. width: weight,
  586. height: blueIconHeight,
  587. y: 0,
  588. fill: "#2acabe",
  589. stroke: "transparent",
  590. },
  591. iconTransverseLine: {
  592. width: blueIconWidth - weight * 4,
  593. height: weight,
  594. y: (blueIconHeight - weight) / 2,
  595. fill: "#2acabe",
  596. stroke: "transparent",
  597. }
  598. },
  599. }
  600. }
  601. const leftOption = () => {
  602. const option = commonOption();
  603. option.attrs.label.x = -(height * 6);
  604. option.attrs.label['text-anchor'] = 'end';
  605. option.attrs.transverseLine.x = -(height / 3 * 4);
  606. option.attrs.iconVerticalLineS.x = 0;
  607. option.attrs.iconVerticalLineM.x = weight / 2 * 3;
  608. option.attrs.iconVerticalLineL.x = weight * 3;
  609. option.attrs.iconTransverseLine.x = weight * 4;
  610. option.attrs.iconVerticalLineS.x -= height * 5;
  611. option.attrs.iconVerticalLineM.x -= height * 5;
  612. option.attrs.iconVerticalLineL.x -= height * 5;
  613. option.attrs.iconTransverseLine.x -= height * 5;
  614. return option;
  615. }
  616. const rightOption = () => {
  617. const option = commonOption();
  618. option.attrs.label.x = height * 6;
  619. option.attrs.label['text-anchor'] = 'start';
  620. option.attrs.transverseLine.x = 0;
  621. option.attrs.iconVerticalLineS.x = 0;
  622. option.attrs.iconVerticalLineM.x = -(weight / 2 * 3);
  623. option.attrs.iconVerticalLineL.x = -(weight * 3);
  624. option.attrs.iconTransverseLine.x = weight - blueIconWidth;
  625. option.attrs.iconVerticalLineS.x += height * 5;
  626. option.attrs.iconVerticalLineM.x += height * 5;
  627. option.attrs.iconVerticalLineL.x += height * 5;
  628. option.attrs.iconTransverseLine.x += height * 5;
  629. return option;
  630. }
  631. const topOption = (option) => {
  632. option.attrs.label.y = fontsize / 2;
  633. option.attrs.transverseLine.y = 0;
  634. option.attrs.iconVerticalLineS.y -= blueIconHeight / 2 - weight / 2;
  635. option.attrs.iconVerticalLineM.y -= blueIconHeight / 2 - weight / 2;
  636. option.attrs.iconVerticalLineL.y -= blueIconHeight / 2 - weight / 2;
  637. option.attrs.iconTransverseLine.y -= blueIconHeight / 2 - weight / 2;
  638. }
  639. const bottomOption = (option) => {
  640. option.attrs.label.y = height - weight + fontsize / 2;
  641. option.attrs.transverseLine.y = height - weight;
  642. option.attrs.iconVerticalLineS.y += height - weight / 2 - blueIconHeight / 2;
  643. option.attrs.iconVerticalLineM.y += height - weight / 2 - blueIconHeight / 2;
  644. option.attrs.iconVerticalLineL.y += height - weight / 2 - blueIconHeight / 2;
  645. option.attrs.iconTransverseLine.y += height - weight / 2 - blueIconHeight / 2;
  646. }
  647. const registerTopLeft = () => {
  648. const shape = `${shapeName}-top-left`;
  649. nodeSize[shape] = {
  650. width: width,
  651. height: height
  652. };
  653. const option = leftOption();
  654. topOption(option);
  655. Graph.registerNode(shape, option, true);
  656. }
  657. const registerTopRight = () => {
  658. const shape = `${shapeName}-top-right`;
  659. nodeSize[shape] = {
  660. width: width,
  661. height: height
  662. };
  663. const option = rightOption();
  664. topOption(option);
  665. Graph.registerNode(shape, option, true);
  666. }
  667. const registerBottomLeft = () => {
  668. const shape = `${shapeName}-bottom-left`;
  669. nodeSize[shape] = {
  670. width: width,
  671. height: height
  672. };
  673. const option = leftOption();
  674. bottomOption(option);
  675. Graph.registerNode(shape, option, true);
  676. }
  677. const registerBottomRight = () => {
  678. const shape = `${shapeName}-bottom-right`;
  679. nodeSize[shape] = {
  680. width: width,
  681. height: height
  682. };
  683. const option = rightOption();
  684. bottomOption(option);
  685. Graph.registerNode(shape, option, true);
  686. }
  687. registerTopLeft();
  688. registerTopRight();
  689. registerBottomLeft();
  690. registerBottomRight();
  691. }
  692. // 接地隔离开关横向断开o
  693. const registerEarthingDisconnectorTransverseYoBreak = () => {
  694. const width = 300;
  695. const height = 15;
  696. const shapeName = "earthing-disconnector-transverse-yo-break";
  697. const commonOption = () => {
  698. return {
  699. width: width,
  700. height: height,
  701. markup: [{
  702. tagName: 'text',
  703. selector: 'label',
  704. },
  705. {
  706. tagName: 'rect',
  707. selector: 'verticalLine',
  708. },
  709. {
  710. tagName: 'rect',
  711. selector: 'transverseLine',
  712. },
  713. {
  714. tagName: 'rect',
  715. selector: 'iconVerticalLineS',
  716. },
  717. {
  718. tagName: 'rect',
  719. selector: 'iconVerticalLineM',
  720. },
  721. {
  722. tagName: 'rect',
  723. selector: 'iconVerticalLineL',
  724. },
  725. {
  726. tagName: 'rect',
  727. selector: 'iconTransverseLine',
  728. },
  729. ],
  730. attrs: {
  731. label: {
  732. fill: '#D0D0D0',
  733. fontSize: fontsize,
  734. "alignment-baseline": "middle",
  735. opacity: 0,
  736. },
  737. verticalLine: {
  738. width: weight,
  739. height: height,
  740. x: -(weight / 2),
  741. y: 0,
  742. fill: "#cbaa07",
  743. stroke: "transparent",
  744. opacity: 0,
  745. },
  746. transverseLine: {
  747. width: height / 3 * 4,
  748. height: weight,
  749. fill: "#cbaa07",
  750. stroke: "transparent",
  751. opacity: 0,
  752. },
  753. iconVerticalLineS: {
  754. width: weight,
  755. height: blueIconHeight / 2,
  756. y: blueIconHeight / 4,
  757. fill: "#2acabe",
  758. stroke: "transparent",
  759. opacity: 0,
  760. },
  761. iconVerticalLineM: {
  762. width: weight,
  763. height: blueIconHeight / 3 * 2,
  764. y: blueIconHeight / 6,
  765. fill: "#2acabe",
  766. stroke: "transparent",
  767. opacity: 0,
  768. },
  769. iconVerticalLineL: {
  770. width: weight,
  771. height: blueIconHeight,
  772. y: 0,
  773. fill: "#2acabe",
  774. stroke: "transparent",
  775. opacity: 0,
  776. },
  777. iconTransverseLine: {
  778. width: blueIconWidth - weight * 4,
  779. height: weight,
  780. y: (blueIconHeight - weight) / 2,
  781. fill: "#2acabe",
  782. stroke: "transparent",
  783. opacity: 0,
  784. }
  785. },
  786. }
  787. }
  788. const leftOption = () => {
  789. const option = commonOption();
  790. option.attrs.label.x = -(height * 6);
  791. option.attrs.label['text-anchor'] = 'end';
  792. option.attrs.transverseLine.x = -(height / 3 * 4);
  793. option.attrs.iconVerticalLineS.x = 0;
  794. option.attrs.iconVerticalLineM.x = weight / 2 * 3;
  795. option.attrs.iconVerticalLineL.x = weight * 3;
  796. option.attrs.iconTransverseLine.x = weight * 4;
  797. option.attrs.iconVerticalLineS.x -= height * 5;
  798. option.attrs.iconVerticalLineM.x -= height * 5;
  799. option.attrs.iconVerticalLineL.x -= height * 5;
  800. option.attrs.iconTransverseLine.x -= height * 5;
  801. return option;
  802. }
  803. const rightOption = () => {
  804. const option = commonOption();
  805. option.attrs.label.x = height * 6;
  806. option.attrs.label['text-anchor'] = 'start';
  807. option.attrs.transverseLine.x = 0;
  808. option.attrs.iconVerticalLineS.x = 0;
  809. option.attrs.iconVerticalLineM.x = -(weight / 2 * 3);
  810. option.attrs.iconVerticalLineL.x = -(weight * 3);
  811. option.attrs.iconTransverseLine.x = weight - blueIconWidth;
  812. option.attrs.iconVerticalLineS.x += height * 5;
  813. option.attrs.iconVerticalLineM.x += height * 5;
  814. option.attrs.iconVerticalLineL.x += height * 5;
  815. option.attrs.iconTransverseLine.x += height * 5;
  816. return option;
  817. }
  818. const topOption = (option) => {
  819. option.attrs.label.y = fontsize / 2;
  820. option.attrs.transverseLine.y = 0;
  821. option.attrs.iconVerticalLineS.y -= blueIconHeight / 2 - weight / 2;
  822. option.attrs.iconVerticalLineM.y -= blueIconHeight / 2 - weight / 2;
  823. option.attrs.iconVerticalLineL.y -= blueIconHeight / 2 - weight / 2;
  824. option.attrs.iconTransverseLine.y -= blueIconHeight / 2 - weight / 2;
  825. }
  826. const bottomOption = (option) => {
  827. option.attrs.label.y = height - weight + fontsize / 2;
  828. option.attrs.transverseLine.y = height - weight;
  829. option.attrs.iconVerticalLineS.y += height - weight / 2 - blueIconHeight / 2;
  830. option.attrs.iconVerticalLineM.y += height - weight / 2 - blueIconHeight / 2;
  831. option.attrs.iconVerticalLineL.y += height - weight / 2 - blueIconHeight / 2;
  832. option.attrs.iconTransverseLine.y += height - weight / 2 - blueIconHeight / 2;
  833. }
  834. const registerTopLeft = () => {
  835. const shape = `${shapeName}-top-left`;
  836. nodeSize[shape] = {
  837. width: width,
  838. height: height
  839. };
  840. const option = leftOption();
  841. topOption(option);
  842. Graph.registerNode(shape, option, true);
  843. }
  844. const registerTopRight = () => {
  845. const shape = `${shapeName}-top-right`;
  846. nodeSize[shape] = {
  847. width: width,
  848. height: height
  849. };
  850. const option = rightOption();
  851. topOption(option);
  852. Graph.registerNode(shape, option, true);
  853. }
  854. const registerBottomLeft = () => {
  855. const shape = `${shapeName}-bottom-left`;
  856. nodeSize[shape] = {
  857. width: width,
  858. height: height
  859. };
  860. const option = leftOption();
  861. bottomOption(option);
  862. Graph.registerNode(shape, option, true);
  863. }
  864. const registerBottomRight = () => {
  865. const shape = `${shapeName}-bottom-right`;
  866. nodeSize[shape] = {
  867. width: width,
  868. height: height
  869. };
  870. const option = rightOption();
  871. bottomOption(option);
  872. Graph.registerNode(shape, option, true);
  873. }
  874. registerTopLeft();
  875. registerTopRight();
  876. registerBottomLeft();
  877. registerBottomRight();
  878. }
  879. // 接地隔离开关横向断开2
  880. const registerEarthingDisconnectorTransverse2Break = () => {
  881. const width = 300;
  882. const height = 0;
  883. const h = 15;
  884. const shapeName = "earthing-disconnector-transverse2-break";
  885. const commonOption = () => {
  886. return {
  887. width: width,
  888. height: height,
  889. markup: [{
  890. tagName: 'text',
  891. selector: 'label',
  892. },
  893. {
  894. tagName: 'rect',
  895. selector: 'transverseLine',
  896. },
  897. {
  898. tagName: 'rect',
  899. selector: 'iconVerticalLineS',
  900. },
  901. {
  902. tagName: 'rect',
  903. selector: 'iconVerticalLineM',
  904. },
  905. {
  906. tagName: 'rect',
  907. selector: 'iconVerticalLineL',
  908. },
  909. {
  910. tagName: 'rect',
  911. selector: 'iconTransverseLine',
  912. },
  913. ],
  914. attrs: {
  915. label: {
  916. fill: '#D0D0D0',
  917. fontSize: fontsize,
  918. "alignment-baseline": "middle"
  919. },
  920. transverseLine: {
  921. width: h / 3 * 4,
  922. height: weight,
  923. y: -weight/2,
  924. fill: "#b30461",
  925. stroke: "transparent",
  926. },
  927. iconVerticalLineS: {
  928. width: weight,
  929. height: blueIconHeight / 2,
  930. y: blueIconHeight / 4 - blueIconHeight / 2,
  931. fill: "#2acabe",
  932. stroke: "transparent",
  933. },
  934. iconVerticalLineM: {
  935. width: weight,
  936. height: blueIconHeight / 3 * 2,
  937. y: blueIconHeight / 6 - blueIconHeight / 2,
  938. fill: "#2acabe",
  939. stroke: "transparent",
  940. },
  941. iconVerticalLineL: {
  942. width: weight,
  943. height: blueIconHeight,
  944. y: 0 - blueIconHeight / 2,
  945. fill: "#2acabe",
  946. stroke: "transparent",
  947. },
  948. iconTransverseLine: {
  949. width: blueIconWidth - weight * 4,
  950. height: weight,
  951. y: (blueIconHeight - weight) / 2 - blueIconHeight / 2,
  952. fill: "#2acabe",
  953. stroke: "transparent",
  954. }
  955. },
  956. }
  957. }
  958. const leftOption = () => {
  959. const option = commonOption();
  960. option.attrs.label.x = -(h * 6);
  961. option.attrs.label['text-anchor'] = 'end';
  962. option.attrs.transverseLine.x = -(h / 3 * 4);
  963. option.attrs.iconVerticalLineS.x = 0;
  964. option.attrs.iconVerticalLineM.x = weight / 2 * 3;
  965. option.attrs.iconVerticalLineL.x = weight * 3;
  966. option.attrs.iconTransverseLine.x = weight * 4;
  967. option.attrs.iconVerticalLineS.x -= h * 5;
  968. option.attrs.iconVerticalLineM.x -= h * 5;
  969. option.attrs.iconVerticalLineL.x -= h * 5;
  970. option.attrs.iconTransverseLine.x -= h * 5;
  971. return option;
  972. }
  973. const rightOption = () => {
  974. const option = commonOption();
  975. option.attrs.label.x = h * 6;
  976. option.attrs.label['text-anchor'] = 'start';
  977. option.attrs.transverseLine.x = 0;
  978. option.attrs.iconVerticalLineS.x = 0;
  979. option.attrs.iconVerticalLineM.x = -(weight / 2 * 3);
  980. option.attrs.iconVerticalLineL.x = -(weight * 3);
  981. option.attrs.iconTransverseLine.x = weight - blueIconWidth;
  982. option.attrs.iconVerticalLineS.x += h * 5;
  983. option.attrs.iconVerticalLineM.x += h * 5;
  984. option.attrs.iconVerticalLineL.x += h * 5;
  985. option.attrs.iconTransverseLine.x += h * 5;
  986. return option;
  987. }
  988. const topOption = (option) => {
  989. option.attrs.label.y = fontsize / 2;
  990. }
  991. const bottomOption = (option) => {
  992. option.attrs.label.y = h - weight + fontsize / 2;
  993. }
  994. const registerTopLeft = () => {
  995. const shape = `${shapeName}-top-left`;
  996. nodeSize[shape] = {
  997. width: width,
  998. height: height
  999. };
  1000. const option = leftOption();
  1001. topOption(option);
  1002. Graph.registerNode(shape, option, true);
  1003. }
  1004. const registerTopRight = () => {
  1005. const shape = `${shapeName}-top-right`;
  1006. nodeSize[shape] = {
  1007. width: width,
  1008. height: height
  1009. };
  1010. const option = rightOption();
  1011. topOption(option);
  1012. Graph.registerNode(shape, option, true);
  1013. }
  1014. const registerBottomLeft = () => {
  1015. const shape = `${shapeName}-bottom-left`;
  1016. nodeSize[shape] = {
  1017. width: width,
  1018. height: height
  1019. };
  1020. const option = leftOption();
  1021. bottomOption(option);
  1022. Graph.registerNode(shape, option, true);
  1023. }
  1024. const registerBottomRight = () => {
  1025. const shape = `${shapeName}-bottom-right`;
  1026. nodeSize[shape] = {
  1027. width: width,
  1028. height: height
  1029. };
  1030. const option = rightOption();
  1031. bottomOption(option);
  1032. Graph.registerNode(shape, option, true);
  1033. }
  1034. registerTopLeft();
  1035. registerTopRight();
  1036. registerBottomLeft();
  1037. registerBottomRight();
  1038. }
  1039. // 接地隔离开关纵向断开
  1040. const registerEarthingDisconnectorVerticalBreak = () => {
  1041. const width = 300;
  1042. const height = 20;
  1043. const shapeName = "earthing-disconnector-vertical-break";
  1044. const commonOption = () => {
  1045. return {
  1046. width: width,
  1047. height: height,
  1048. markup: [{
  1049. tagName: 'text',
  1050. selector: 'label',
  1051. },
  1052. {
  1053. tagName: 'rect',
  1054. selector: 'verticalLine1',
  1055. },
  1056. {
  1057. tagName: 'rect',
  1058. selector: 'verticalLine',
  1059. },
  1060. {
  1061. tagName: 'rect',
  1062. selector: 'transverseLine',
  1063. },
  1064. {
  1065. tagName: 'rect',
  1066. selector: 'iconVerticalLineS',
  1067. },
  1068. {
  1069. tagName: 'rect',
  1070. selector: 'iconVerticalLineM',
  1071. },
  1072. {
  1073. tagName: 'rect',
  1074. selector: 'iconVerticalLineL',
  1075. },
  1076. {
  1077. tagName: 'rect',
  1078. selector: 'iconTransverseLine',
  1079. },
  1080. ],
  1081. attrs: {
  1082. label: {
  1083. fill: '#D0D0D0',
  1084. fontSize: fontsize,
  1085. y: height * 3 + fontsize + blueIconWidth + 9,
  1086. "alignment-baseline": "middle",
  1087. "text-anchor": "middle",
  1088. },
  1089. verticalLine1: {
  1090. width: weight,
  1091. height: height,
  1092. x: -(weight / 2),
  1093. y: 0,
  1094. fill: "#cbaa07",
  1095. stroke: "transparent",
  1096. },
  1097. verticalLine: {
  1098. width: weight,
  1099. height: height,
  1100. y: height,
  1101. fill: "#cbaa07",
  1102. stroke: "transparent",
  1103. },
  1104. transverseLine: {
  1105. width: height,
  1106. height: weight,
  1107. y: height - weight,
  1108. fill: "#cbaa07",
  1109. stroke: "transparent",
  1110. },
  1111. iconVerticalLineS: {
  1112. width: blueIconHeight / 2,
  1113. height: weight,
  1114. x: blueIconHeight / 4,
  1115. y: blueIconHeight + height * 3,
  1116. fill: "#2acabe",
  1117. stroke: "transparent",
  1118. },
  1119. iconVerticalLineM: {
  1120. width: blueIconHeight / 3 * 2,
  1121. height: weight,
  1122. x: blueIconHeight / 6,
  1123. y: blueIconHeight - weight / 2 * 3 + height * 3,
  1124. fill: "#2acabe",
  1125. stroke: "transparent",
  1126. },
  1127. iconVerticalLineL: {
  1128. width: blueIconHeight,
  1129. height: weight,
  1130. x: 0,
  1131. y: blueIconHeight - weight * 3 + height * 3,
  1132. fill: "#2acabe",
  1133. stroke: "transparent",
  1134. },
  1135. iconTransverseLine: {
  1136. width: weight,
  1137. height: blueIconWidth - weight * 4,
  1138. x: (blueIconHeight - weight) / 2,
  1139. y: height * 3,
  1140. fill: "#2acabe",
  1141. stroke: "transparent",
  1142. }
  1143. },
  1144. }
  1145. }
  1146. const leftOption = () => {
  1147. const option = commonOption();
  1148. option.attrs.label.x = -height;
  1149. option.attrs.transverseLine.x = -height;
  1150. option.attrs.verticalLine.x = -height;
  1151. option.attrs.iconVerticalLineS.x -= height / 2 * 3 - weight / 2;
  1152. option.attrs.iconVerticalLineM.x -= height / 2 * 3 - weight / 2;
  1153. option.attrs.iconVerticalLineL.x -= height / 2 * 3 - weight / 2;
  1154. option.attrs.iconTransverseLine.x -= height / 2 * 3 - weight / 2;
  1155. return option;
  1156. }
  1157. const rightOption = () => {
  1158. const option = commonOption();
  1159. option.attrs.label.x = height;
  1160. option.attrs.transverseLine.x = 0;
  1161. option.attrs.verticalLine.x = height - weight;
  1162. option.attrs.iconVerticalLineS.x += height / 2 - weight / 2;
  1163. option.attrs.iconVerticalLineM.x += height / 2 - weight / 2;
  1164. option.attrs.iconVerticalLineL.x += height / 2 - weight / 2;
  1165. option.attrs.iconTransverseLine.x += height / 2 - weight / 2;
  1166. return option;
  1167. }
  1168. const topOption = (option) => { }
  1169. const bottomOption = (option) => { }
  1170. const registerTopLeft = () => {
  1171. const shape = `${shapeName}-top-left`;
  1172. nodeSize[shape] = {
  1173. width: width,
  1174. height: height
  1175. };
  1176. const option = leftOption();
  1177. topOption(option);
  1178. Graph.registerNode(shape, option, true);
  1179. }
  1180. const registerTopRight = () => {
  1181. const shape = `${shapeName}-top-right`;
  1182. nodeSize[shape] = {
  1183. width: width,
  1184. height: height
  1185. };
  1186. const option = rightOption();
  1187. topOption(option);
  1188. Graph.registerNode(shape, option, true);
  1189. }
  1190. const registerBottomLeft = () => {
  1191. const shape = `${shapeName}-bottom-left`;
  1192. nodeSize[shape] = {
  1193. width: width,
  1194. height: height
  1195. };
  1196. const option = leftOption();
  1197. bottomOption(option);
  1198. Graph.registerNode(shape, option, true);
  1199. }
  1200. const registerBottomRight = () => {
  1201. const shape = `${shapeName}-bottom-right`;
  1202. nodeSize[shape] = {
  1203. width: width,
  1204. height: height
  1205. };
  1206. const option = rightOption();
  1207. bottomOption(option);
  1208. Graph.registerNode(shape, option, true);
  1209. }
  1210. registerTopLeft();
  1211. registerTopRight();
  1212. registerBottomLeft();
  1213. registerBottomRight();
  1214. }
  1215. // 注册上下箭头
  1216. const registerArrowVertical = () => {
  1217. const width = weight;
  1218. const height = 0;
  1219. const arrowWidth = 13;
  1220. const arrowHeight = 15;
  1221. const shapeName = "arrow-vertical";
  1222. const commonOption = () => {
  1223. return {
  1224. width: width,
  1225. height: height,
  1226. markup: [
  1227. {
  1228. tagName: 'rect',
  1229. selector: 'line',
  1230. },
  1231. {
  1232. tagName: 'polygon',
  1233. selector: 'arrow',
  1234. },
  1235. ],
  1236. attrs: {
  1237. line: {
  1238. width: weight,
  1239. x: -(weight / 2),
  1240. fill: "#cbaa07",
  1241. stroke: "transparent",
  1242. },
  1243. arrow: {
  1244. x: -(weight / 2),
  1245. fill: "#cbaa07",
  1246. stroke: "transparent",
  1247. }
  1248. },
  1249. }
  1250. }
  1251. const leftOption = () => {
  1252. const option = commonOption();
  1253. return option;
  1254. }
  1255. const rightOption = () => {
  1256. const option = commonOption();
  1257. return option;
  1258. }
  1259. const topOption = (option) => {
  1260. option.attrs.line.y = arrowHeight;
  1261. option.attrs.arrow.refY = 0;
  1262. option.attrs.arrow.points = `0,0 ${-(arrowWidth/2)},${arrowHeight} ${arrowWidth/2},${arrowHeight}`;
  1263. }
  1264. const bottomOption = (option) => {
  1265. option.attrs.line.y = 0;
  1266. option.attrs.arrow.points = `${-(arrowWidth/2)},0 ${arrowWidth/2},0 0,${arrowHeight}`;
  1267. }
  1268. const registerTopLeft = () => {
  1269. const shape = `${shapeName}-top-left`;
  1270. nodeSize[shape] = {
  1271. width: width,
  1272. height: height
  1273. };
  1274. const option = leftOption();
  1275. topOption(option);
  1276. Graph.registerNode(shape, option, true);
  1277. }
  1278. const registerTopRight = () => {
  1279. const shape = `${shapeName}-top-right`;
  1280. nodeSize[shape] = {
  1281. width: width,
  1282. height: height
  1283. };
  1284. const option = rightOption();
  1285. topOption(option);
  1286. Graph.registerNode(shape, option, true);
  1287. }
  1288. const registerBottomLeft = () => {
  1289. const shape = `${shapeName}-bottom-left`;
  1290. nodeSize[shape] = {
  1291. width: width,
  1292. height: height
  1293. };
  1294. const option = leftOption();
  1295. bottomOption(option);
  1296. Graph.registerNode(shape, option, true);
  1297. }
  1298. const registerBottomRight = () => {
  1299. const shape = `${shapeName}-bottom-right`;
  1300. nodeSize[shape] = {
  1301. width: width,
  1302. height: height
  1303. };
  1304. const option = rightOption();
  1305. bottomOption(option);
  1306. Graph.registerNode(shape, option, true);
  1307. }
  1308. registerTopLeft();
  1309. registerTopRight();
  1310. registerBottomLeft();
  1311. registerBottomRight();
  1312. }
  1313. // 注册一条竖线
  1314. const registerLineVertical = () => {
  1315. const width = weight;
  1316. const height = 0;
  1317. const shapeName = "line-vertical";
  1318. const commonOption = () => {
  1319. return {
  1320. width: width,
  1321. height: height,
  1322. markup: [
  1323. {
  1324. tagName: 'rect',
  1325. selector: 'line',
  1326. },
  1327. ],
  1328. attrs: {
  1329. line: {
  1330. width: weight,
  1331. x: -(weight / 2),
  1332. y: 0,
  1333. fill: "#cbaa07",
  1334. stroke: "transparent",
  1335. },
  1336. },
  1337. }
  1338. }
  1339. const leftOption = () => {
  1340. const option = commonOption();
  1341. return option;
  1342. }
  1343. const rightOption = () => {
  1344. const option = commonOption();
  1345. return option;
  1346. }
  1347. const topOption = (option) => { }
  1348. const bottomOption = (option) => { }
  1349. const registerTopLeft = () => {
  1350. const shape = `${shapeName}-top-left`;
  1351. nodeSize[shape] = {
  1352. width: width,
  1353. height: height
  1354. };
  1355. const option = leftOption();
  1356. topOption(option);
  1357. Graph.registerNode(shape, option, true);
  1358. }
  1359. const registerTopRight = () => {
  1360. const shape = `${shapeName}-top-right`;
  1361. nodeSize[shape] = {
  1362. width: width,
  1363. height: height
  1364. };
  1365. const option = rightOption();
  1366. topOption(option);
  1367. Graph.registerNode(shape, option, true);
  1368. }
  1369. const registerBottomLeft = () => {
  1370. const shape = `${shapeName}-bottom-left`;
  1371. nodeSize[shape] = {
  1372. width: width,
  1373. height: height
  1374. };
  1375. const option = leftOption();
  1376. bottomOption(option);
  1377. Graph.registerNode(shape, option, true);
  1378. }
  1379. const registerBottomRight = () => {
  1380. const shape = `${shapeName}-bottom-right`;
  1381. nodeSize[shape] = {
  1382. width: width,
  1383. height: height
  1384. };
  1385. const option = rightOption();
  1386. bottomOption(option);
  1387. Graph.registerNode(shape, option, true);
  1388. }
  1389. registerTopLeft();
  1390. registerTopRight();
  1391. registerBottomLeft();
  1392. registerBottomRight();
  1393. }
  1394. // 竖着的电抗器
  1395. const registerReactorVertical = () => {
  1396. const width = weight;
  1397. const height = 70;
  1398. const r = 10;
  1399. const shapeName = "reactor-vertical";
  1400. const commonOption = () => {
  1401. return {
  1402. width: width,
  1403. height: height,
  1404. markup: [
  1405. {
  1406. tagName: 'path',
  1407. selector: 'reactor',
  1408. },
  1409. ],
  1410. attrs: {
  1411. reactor: {
  1412. d: `M0,0 l0,${height-r*2} a${r} ${r} 0 1 0 ${r} ${r} l-${r},0 l0,${r}`,
  1413. x: -(weight / 2),
  1414. y: 0,
  1415. fill: "transparent",
  1416. stroke: "#cbaa07",
  1417. "stroke-width": weight,
  1418. },
  1419. },
  1420. }
  1421. }
  1422. const leftOption = () => {
  1423. const option = commonOption();
  1424. return option;
  1425. }
  1426. const rightOption = () => {
  1427. const option = commonOption();
  1428. return option;
  1429. }
  1430. const topOption = (option) => { }
  1431. const bottomOption = (option) => { }
  1432. const registerTopLeft = () => {
  1433. const shape = `${shapeName}-top-left`;
  1434. nodeSize[shape] = {
  1435. width: width,
  1436. height: height
  1437. };
  1438. const option = leftOption();
  1439. topOption(option);
  1440. Graph.registerNode(shape, option, true);
  1441. }
  1442. const registerTopRight = () => {
  1443. const shape = `${shapeName}-top-right`;
  1444. nodeSize[shape] = {
  1445. width: width,
  1446. height: height
  1447. };
  1448. const option = rightOption();
  1449. topOption(option);
  1450. Graph.registerNode(shape, option, true);
  1451. }
  1452. const registerBottomLeft = () => {
  1453. const shape = `${shapeName}-bottom-left`;
  1454. nodeSize[shape] = {
  1455. width: width,
  1456. height: height
  1457. };
  1458. const option = leftOption();
  1459. bottomOption(option);
  1460. Graph.registerNode(shape, option, true);
  1461. }
  1462. const registerBottomRight = () => {
  1463. const shape = `${shapeName}-bottom-right`;
  1464. nodeSize[shape] = {
  1465. width: width,
  1466. height: height
  1467. };
  1468. const option = rightOption();
  1469. bottomOption(option);
  1470. Graph.registerNode(shape, option, true);
  1471. }
  1472. registerTopLeft();
  1473. registerTopRight();
  1474. registerBottomLeft();
  1475. registerBottomRight();
  1476. }
  1477. // 竖着的电容
  1478. const registerCapacitanceVertical = () => {
  1479. const width = 16;
  1480. const height = 50;
  1481. const shapeName = "capacitance-vertical";
  1482. const commonOption = () => {
  1483. return {
  1484. width: width,
  1485. height: height,
  1486. markup: [
  1487. {
  1488. tagName: 'path',
  1489. selector: 'reactor',
  1490. },
  1491. ],
  1492. attrs: {
  1493. reactor: {
  1494. d: `M0,0 l0,${height*0.4} m-${width/2},0 l${width},0 m0,${height*0.2-weight} l-${width},0 m${width/2},0 l0,${height*0.4+weight}`,
  1495. x: -(weight / 2),
  1496. y: 0,
  1497. fill: "transparent",
  1498. stroke: "#cbaa07",
  1499. "stroke-width": weight,
  1500. },
  1501. },
  1502. }
  1503. }
  1504. const leftOption = () => {
  1505. const option = commonOption();
  1506. return option;
  1507. }
  1508. const rightOption = () => {
  1509. const option = commonOption();
  1510. return option;
  1511. }
  1512. const topOption = (option) => { }
  1513. const bottomOption = (option) => { }
  1514. const registerTopLeft = () => {
  1515. const shape = `${shapeName}-top-left`;
  1516. nodeSize[shape] = {
  1517. width: width,
  1518. height: height
  1519. };
  1520. const option = leftOption();
  1521. topOption(option);
  1522. Graph.registerNode(shape, option, true);
  1523. }
  1524. const registerTopRight = () => {
  1525. const shape = `${shapeName}-top-right`;
  1526. nodeSize[shape] = {
  1527. width: width,
  1528. height: height
  1529. };
  1530. const option = rightOption();
  1531. topOption(option);
  1532. Graph.registerNode(shape, option, true);
  1533. }
  1534. const registerBottomLeft = () => {
  1535. const shape = `${shapeName}-bottom-left`;
  1536. nodeSize[shape] = {
  1537. width: width,
  1538. height: height
  1539. };
  1540. const option = leftOption();
  1541. bottomOption(option);
  1542. Graph.registerNode(shape, option, true);
  1543. }
  1544. const registerBottomRight = () => {
  1545. const shape = `${shapeName}-bottom-right`;
  1546. nodeSize[shape] = {
  1547. width: width,
  1548. height: height
  1549. };
  1550. const option = rightOption();
  1551. bottomOption(option);
  1552. Graph.registerNode(shape, option, true);
  1553. }
  1554. registerTopLeft();
  1555. registerTopRight();
  1556. registerBottomLeft();
  1557. registerBottomRight();
  1558. }
  1559. // 竖着的电阻
  1560. const registerResistanceVertical = () => {
  1561. const width = 16;
  1562. const height = 100;
  1563. const shapeName = "resistance-vertical";
  1564. const commonOption = () => {
  1565. return {
  1566. width: width,
  1567. height: height,
  1568. markup: [
  1569. {
  1570. tagName: 'path',
  1571. selector: 'reactor',
  1572. },
  1573. ],
  1574. attrs: {
  1575. reactor: {
  1576. d: `M0,0 l0,${height} m-${width/2},-${height*0.3} l${width},0 l0,-${height*0.4} l-${width},0 l0,${height*0.4}`,
  1577. x: -(weight / 2),
  1578. y: 0,
  1579. fill: "transparent",
  1580. stroke: "#cbaa07",
  1581. "stroke-width": weight,
  1582. },
  1583. },
  1584. }
  1585. }
  1586. const leftOption = () => {
  1587. const option = commonOption();
  1588. return option;
  1589. }
  1590. const rightOption = () => {
  1591. const option = commonOption();
  1592. return option;
  1593. }
  1594. const topOption = (option) => { }
  1595. const bottomOption = (option) => { }
  1596. const registerTopLeft = () => {
  1597. const shape = `${shapeName}-top-left`;
  1598. nodeSize[shape] = {
  1599. width: width,
  1600. height: height
  1601. };
  1602. const option = leftOption();
  1603. topOption(option);
  1604. Graph.registerNode(shape, option, true);
  1605. }
  1606. const registerTopRight = () => {
  1607. const shape = `${shapeName}-top-right`;
  1608. nodeSize[shape] = {
  1609. width: width,
  1610. height: height
  1611. };
  1612. const option = rightOption();
  1613. topOption(option);
  1614. Graph.registerNode(shape, option, true);
  1615. }
  1616. const registerBottomLeft = () => {
  1617. const shape = `${shapeName}-bottom-left`;
  1618. nodeSize[shape] = {
  1619. width: width,
  1620. height: height
  1621. };
  1622. const option = leftOption();
  1623. bottomOption(option);
  1624. Graph.registerNode(shape, option, true);
  1625. }
  1626. const registerBottomRight = () => {
  1627. const shape = `${shapeName}-bottom-right`;
  1628. nodeSize[shape] = {
  1629. width: width,
  1630. height: height
  1631. };
  1632. const option = rightOption();
  1633. bottomOption(option);
  1634. Graph.registerNode(shape, option, true);
  1635. }
  1636. registerTopLeft();
  1637. registerTopRight();
  1638. registerBottomLeft();
  1639. registerBottomRight();
  1640. }
  1641. // 电压互感器 3 Voltage transformer
  1642. const registerVoltageTransformer = () => {
  1643. const width = 16;
  1644. const height = 50;
  1645. const r = height / 5;
  1646. const w = weight / 3 * 2;
  1647. const shapeName = "voltage-transformer";
  1648. const commonOption = () => {
  1649. return {
  1650. width: width,
  1651. height: height,
  1652. markup: [
  1653. {
  1654. tagName: 'rect',
  1655. selector: 'line',
  1656. },
  1657. {
  1658. tagName: 'circle',
  1659. selector: 'circle1',
  1660. },
  1661. {
  1662. tagName: 'circle',
  1663. selector: 'circle2',
  1664. },
  1665. {
  1666. tagName: 'circle',
  1667. selector: 'circle3',
  1668. },
  1669. {
  1670. tagName: 'path',
  1671. selector: 'path',
  1672. },
  1673. ],
  1674. attrs: {
  1675. line: {
  1676. x: -(weight / 2),
  1677. y: 0,
  1678. width: weight,
  1679. height: r + weight*2,
  1680. fill: "#cbaa07",
  1681. stroke: "transparent",
  1682. },
  1683. circle1: {
  1684. cx: 0,
  1685. cy: 2*r+weight*2,
  1686. r: r,
  1687. fill: "transparent",
  1688. stroke: "#cbaa07",
  1689. "stroke-width": w,
  1690. },
  1691. circle2: {
  1692. cx: 0,
  1693. cy: 4*r,
  1694. r: r,
  1695. fill: "transparent",
  1696. stroke: "#cbaa07",
  1697. "stroke-width": w,
  1698. },
  1699. circle3: {
  1700. cx: Math.sqrt(weight*(2*r-weight)) + r - 3,
  1701. cy: 3*r+weight,
  1702. r: r,
  1703. fill: "transparent",
  1704. stroke: "#cbaa07",
  1705. "stroke-width": w,
  1706. },
  1707. path: {
  1708. d: `M0,${2*r+weight*2} l-${r/2},-${r/2} m${r/2},${r/2} l${r/2},-${r/2} m-${r/2},${r/2} l0,${r/2}
  1709. M0,${4*r} l-${r/2},-${r/2} m${r/2},${r/2} l${r/2},-${r/2} m-${r/2},${r/2} l0,${r/2}
  1710. M${Math.sqrt(weight*(2*r-weight))+r-3},${3*r+weight} m-1,0 l-${r/3},${r/3} l${r},0 l-${r/3},-${r/3}`,
  1711. x: -(weight / 2),
  1712. y: 0,
  1713. fill: "transparent",
  1714. stroke: "#cbaa07",
  1715. "stroke-width": w,
  1716. },
  1717. },
  1718. }
  1719. }
  1720. const leftOption = () => {
  1721. const option = commonOption();
  1722. return option;
  1723. }
  1724. const rightOption = () => {
  1725. const option = commonOption();
  1726. return option;
  1727. }
  1728. const topOption = (option) => { }
  1729. const bottomOption = (option) => { }
  1730. const registerTopLeft = () => {
  1731. const shape = `${shapeName}-top-left`;
  1732. nodeSize[shape] = {
  1733. width: width,
  1734. height: height
  1735. };
  1736. const option = leftOption();
  1737. topOption(option);
  1738. Graph.registerNode(shape, option, true);
  1739. }
  1740. const registerTopRight = () => {
  1741. const shape = `${shapeName}-top-right`;
  1742. nodeSize[shape] = {
  1743. width: width,
  1744. height: height
  1745. };
  1746. const option = rightOption();
  1747. topOption(option);
  1748. Graph.registerNode(shape, option, true);
  1749. }
  1750. const registerBottomLeft = () => {
  1751. const shape = `${shapeName}-bottom-left`;
  1752. nodeSize[shape] = {
  1753. width: width,
  1754. height: height
  1755. };
  1756. const option = leftOption();
  1757. bottomOption(option);
  1758. Graph.registerNode(shape, option, true);
  1759. }
  1760. const registerBottomRight = () => {
  1761. const shape = `${shapeName}-bottom-right`;
  1762. nodeSize[shape] = {
  1763. width: width,
  1764. height: height
  1765. };
  1766. const option = rightOption();
  1767. bottomOption(option);
  1768. Graph.registerNode(shape, option, true);
  1769. }
  1770. registerTopLeft();
  1771. registerTopRight();
  1772. registerBottomLeft();
  1773. registerBottomRight();
  1774. }
  1775. // 电压互感器3
  1776. const registerVoltage3Transformer = () => {
  1777. const width = 50;
  1778. const height = 0;
  1779. const r = width / 5;
  1780. const w = weight / 3 * 2;
  1781. const shapeName = "voltage3-transformer";
  1782. const commonOption = () => {
  1783. return {
  1784. width: width,
  1785. height: height,
  1786. markup: [
  1787. {
  1788. tagName: 'rect',
  1789. selector: 'line',
  1790. },
  1791. {
  1792. tagName: 'circle',
  1793. selector: 'circle1',
  1794. },
  1795. {
  1796. tagName: 'circle',
  1797. selector: 'circle2',
  1798. },
  1799. {
  1800. tagName: 'circle',
  1801. selector: 'circle3',
  1802. },
  1803. {
  1804. tagName: 'path',
  1805. selector: 'path',
  1806. },
  1807. ],
  1808. attrs: {
  1809. line: {
  1810. x: -width + weight,
  1811. y: -r*2,
  1812. width: weight,
  1813. height: r*2,
  1814. fill: "#b30461",
  1815. stroke: "transparent",
  1816. },
  1817. circle1: {
  1818. cx: -width + weight*3/2,
  1819. cy: -r*3,
  1820. r: r,
  1821. fill: "transparent",
  1822. stroke: "#b30461",
  1823. "stroke-width": w,
  1824. },
  1825. circle2: {
  1826. cx: -width + weight*3/2 - Math.sqrt(weight*(r*2-weight)),
  1827. cy: -r*4 - (r - weight*2),
  1828. r: r,
  1829. fill: "transparent",
  1830. stroke: "#b30461",
  1831. "stroke-width": w,
  1832. },
  1833. circle3: {
  1834. cx: -width + weight*3/2 + Math.sqrt(weight*(r*2-weight)),
  1835. cy: -r*4 - (r - weight*2),
  1836. r: r,
  1837. fill: "transparent",
  1838. stroke: "#b30461",
  1839. "stroke-width": w,
  1840. },
  1841. path: {
  1842. d: `M${-width+weight*3/2},${-r*3} l-${r/2},${r/2} m${r/2},-${r/2} l${r/2},${r/2} m-${r/2},-${r/2} l0,-${r/2}
  1843. M${-width+weight*3/2-Math.sqrt(weight*(r*2-weight))},${-r*4-(r-weight*2)} l-${r/2},${r/2} m${r/2},-${r/2} l${r/2},${r/2} m-${r/2},-${r/2} l0,-${r/2}
  1844. M${-width+weight*3/2+Math.sqrt(weight*(r*2-weight))},${-r*4-(r-weight*2)} l-${r/2},${r/2} m${r/2},-${r/2} l${r/2},${r/2} m-${r/2},-${r/2} l0,-${r/2}`,
  1845. x: -(weight / 2),
  1846. y: 0,
  1847. fill: "transparent",
  1848. stroke: "#b30461",
  1849. "stroke-width": w,
  1850. },
  1851. },
  1852. }
  1853. }
  1854. const leftOption = () => {
  1855. const option = commonOption();
  1856. return option;
  1857. }
  1858. const rightOption = () => {
  1859. const option = commonOption();
  1860. return option;
  1861. }
  1862. const topOption = (option) => { }
  1863. const bottomOption = (option) => { }
  1864. const registerTopLeft = () => {
  1865. const shape = `${shapeName}-top-left`;
  1866. nodeSize[shape] = {
  1867. width: width,
  1868. height: height
  1869. };
  1870. const option = leftOption();
  1871. topOption(option);
  1872. Graph.registerNode(shape, option, true);
  1873. }
  1874. const registerTopRight = () => {
  1875. const shape = `${shapeName}-top-right`;
  1876. nodeSize[shape] = {
  1877. width: width,
  1878. height: height
  1879. };
  1880. const option = rightOption();
  1881. topOption(option);
  1882. Graph.registerNode(shape, option, true);
  1883. }
  1884. const registerBottomLeft = () => {
  1885. const shape = `${shapeName}-bottom-left`;
  1886. nodeSize[shape] = {
  1887. width: width,
  1888. height: height
  1889. };
  1890. const option = leftOption();
  1891. bottomOption(option);
  1892. Graph.registerNode(shape, option, true);
  1893. }
  1894. const registerBottomRight = () => {
  1895. const shape = `${shapeName}-bottom-right`;
  1896. nodeSize[shape] = {
  1897. width: width,
  1898. height: height
  1899. };
  1900. const option = rightOption();
  1901. bottomOption(option);
  1902. Graph.registerNode(shape, option, true);
  1903. }
  1904. registerTopLeft();
  1905. registerTopRight();
  1906. registerBottomLeft();
  1907. registerBottomRight();
  1908. }
  1909. // 电压互感器5
  1910. const registerVoltage5Transformer = () => {
  1911. const width = 50;
  1912. const height = 0;
  1913. const r = width / 5;
  1914. const w = weight / 3 * 2;
  1915. const shapeName = "voltage5-transformer";
  1916. const commonOption = () => {
  1917. return {
  1918. width: width,
  1919. height: height,
  1920. markup: [
  1921. {
  1922. tagName: 'rect',
  1923. selector: 'line',
  1924. },
  1925. {
  1926. tagName: 'circle',
  1927. selector: 'circle1',
  1928. },
  1929. {
  1930. tagName: 'circle',
  1931. selector: 'circle2',
  1932. },
  1933. {
  1934. tagName: 'circle',
  1935. selector: 'circle3',
  1936. },
  1937. {
  1938. tagName: 'circle',
  1939. selector: 'circle4',
  1940. },
  1941. {
  1942. tagName: 'circle',
  1943. selector: 'circle5',
  1944. },
  1945. {
  1946. tagName: 'path',
  1947. selector: 'path',
  1948. },
  1949. ],
  1950. attrs: {
  1951. line: {
  1952. x: -width + weight,
  1953. y: 0,
  1954. width: weight,
  1955. height: r*2,
  1956. fill: "#b30461",
  1957. stroke: "transparent",
  1958. },
  1959. circle1: {
  1960. cx: -width + weight*3/2,
  1961. cy: r*3,
  1962. r: r,
  1963. fill: "transparent",
  1964. stroke: "#b30461",
  1965. "stroke-width": w,
  1966. },
  1967. circle2: {
  1968. cx: -width + weight*3/2 - Math.sqrt(weight*(r*2-weight)),
  1969. cy: r*4 + (r - weight*2),
  1970. r: r,
  1971. fill: "transparent",
  1972. stroke: "#b30461",
  1973. "stroke-width": w,
  1974. },
  1975. circle3: {
  1976. cx: -width + weight*3/2 + Math.sqrt(weight*(r*2-weight)),
  1977. cy: r*4 + (r - weight*2),
  1978. r: r,
  1979. fill: "transparent",
  1980. stroke: "#b30461",
  1981. "stroke-width": w,
  1982. },
  1983. circle4: {
  1984. cx: -width + weight*3/2 - Math.sqrt(weight*(r*2-weight)),
  1985. cy: r*6 + (r - weight*3),
  1986. r: r,
  1987. fill: "transparent",
  1988. stroke: "#b30461",
  1989. "stroke-width": w,
  1990. },
  1991. circle5: {
  1992. cx: -width + weight*3/2 + Math.sqrt(weight*(r*2-weight)),
  1993. cy: r*6 + (r - weight*3),
  1994. r: r,
  1995. fill: "transparent",
  1996. stroke: "#b30461",
  1997. "stroke-width": w,
  1998. },
  1999. path: {
  2000. d: `M${-width+weight*3/2},${r*3} l-${r/2},-${r/2} m${r/2},${r/2} l${r/2},-${r/2} m-${r/2},${r/2} l0,${r/2}
  2001. M${-width+weight*3/2-Math.sqrt(weight*(r*2-weight))},${r*4+(r-weight*2)} m-2,-1 l${r/3},-${r/3} l0,${r-1} l-${r/3},-${r/3}
  2002. M${-width+weight*3/2+Math.sqrt(weight*(r*2-weight))},${r*4+(r-weight*2)} l-${r/2},-${r/2} m${r/2},${r/2} l${r/2},-${r/2} m-${r/2},${r/2} l0,${r/2}
  2003. M${-width+weight*3/2-Math.sqrt(weight*(r*2-weight))},${r*6+(r-weight*3)} l-${r/2},-${r/2} m${r/2},${r/2} l${r/2},-${r/2} m-${r/2},${r/2} l0,${r/2}
  2004. M${-width+weight*3/2+Math.sqrt(weight*(r*2-weight))},${r*6+(r-weight*3)} l-${r/2},-${r/2} m${r/2},${r/2} l${r/2},-${r/2} m-${r/2},${r/2} l0,${r/2}
  2005. M${-width+weight*3/2},${r*3} l-${r*4},0 l0,-${r*3}`,
  2006. x: -(weight / 2),
  2007. y: 0,
  2008. fill: "transparent",
  2009. stroke: "#b30461",
  2010. "stroke-width": w,
  2011. },
  2012. },
  2013. }
  2014. }
  2015. const leftOption = () => {
  2016. const option = commonOption();
  2017. return option;
  2018. }
  2019. const rightOption = () => {
  2020. const option = commonOption();
  2021. return option;
  2022. }
  2023. const topOption = (option) => { }
  2024. const bottomOption = (option) => { }
  2025. const registerTopLeft = () => {
  2026. const shape = `${shapeName}-top-left`;
  2027. nodeSize[shape] = {
  2028. width: width,
  2029. height: height
  2030. };
  2031. const option = leftOption();
  2032. topOption(option);
  2033. Graph.registerNode(shape, option, true);
  2034. }
  2035. const registerTopRight = () => {
  2036. const shape = `${shapeName}-top-right`;
  2037. nodeSize[shape] = {
  2038. width: width,
  2039. height: height
  2040. };
  2041. const option = rightOption();
  2042. topOption(option);
  2043. Graph.registerNode(shape, option, true);
  2044. }
  2045. const registerBottomLeft = () => {
  2046. const shape = `${shapeName}-bottom-left`;
  2047. nodeSize[shape] = {
  2048. width: width,
  2049. height: height
  2050. };
  2051. const option = leftOption();
  2052. bottomOption(option);
  2053. Graph.registerNode(shape, option, true);
  2054. }
  2055. const registerBottomRight = () => {
  2056. const shape = `${shapeName}-bottom-right`;
  2057. nodeSize[shape] = {
  2058. width: width,
  2059. height: height
  2060. };
  2061. const option = rightOption();
  2062. bottomOption(option);
  2063. Graph.registerNode(shape, option, true);
  2064. }
  2065. registerTopLeft();
  2066. registerTopRight();
  2067. registerBottomLeft();
  2068. registerBottomRight();
  2069. }
  2070. // 接地变压器 Grounding transformer
  2071. const registerGroundingTransformer = () => {
  2072. const width = 16;
  2073. const height = 110;
  2074. const r = height / 11;
  2075. const w = weight / 3 * 2;
  2076. const shapeName = "grounding-transformer";
  2077. const commonOption = () => {
  2078. return {
  2079. width: width,
  2080. height: height,
  2081. markup: [
  2082. {
  2083. tagName: 'rect',
  2084. selector: 'line',
  2085. },
  2086. {
  2087. tagName: 'circle',
  2088. selector: 'circle1',
  2089. },
  2090. {
  2091. tagName: 'circle',
  2092. selector: 'circle2',
  2093. },
  2094. {
  2095. tagName: 'path',
  2096. selector: 'path',
  2097. },
  2098. {
  2099. tagName: 'rect',
  2100. selector: 'verticalLine',
  2101. },
  2102. {
  2103. tagName: 'rect',
  2104. selector: 'transverseLine',
  2105. },
  2106. {
  2107. tagName: 'rect',
  2108. selector: 'iconVerticalLineS',
  2109. },
  2110. {
  2111. tagName: 'rect',
  2112. selector: 'iconVerticalLineM',
  2113. },
  2114. {
  2115. tagName: 'rect',
  2116. selector: 'iconVerticalLineL',
  2117. },
  2118. {
  2119. tagName: 'rect',
  2120. selector: 'iconTransverseLine',
  2121. },
  2122. ],
  2123. attrs: {
  2124. line: {
  2125. x: -(weight / 2),
  2126. y: 0,
  2127. width: weight,
  2128. height: 7*r + weight*2,
  2129. fill: "#cbaa07",
  2130. stroke: "transparent",
  2131. },
  2132. circle1: {
  2133. cx: 0,
  2134. cy: 8*r+weight*2,
  2135. r: r,
  2136. fill: "transparent",
  2137. stroke: "#cbaa07",
  2138. "stroke-width": w,
  2139. },
  2140. circle2: {
  2141. cx: 0,
  2142. cy: 10*r,
  2143. r: r,
  2144. fill: "transparent",
  2145. stroke: "#cbaa07",
  2146. "stroke-width": w,
  2147. },
  2148. path: {
  2149. d: `M0,${8*r+weight*2} m-${r/2},1 l${r},0 l-${r/2},-${r-2} l-${r/2},${r-2}
  2150. M0,${10*r} l-${r/2},${r/2} m${r/2},-${r/2} l${r/2},${r/2} m-${r/2},-${r/2} l0,-${r/2}`,
  2151. x: -(weight / 2),
  2152. y: 0,
  2153. fill: "transparent",
  2154. stroke: "#cbaa07",
  2155. "stroke-width": w,
  2156. },
  2157. verticalLine: {
  2158. width: weight,
  2159. height: r*2,
  2160. x: -r*2,
  2161. y: 10*r,
  2162. fill: "#cbaa07",
  2163. stroke: "transparent",
  2164. },
  2165. transverseLine: {
  2166. width: r*2,
  2167. height: w,
  2168. x: -r*2,
  2169. y: 10*r,
  2170. fill: "#cbaa07",
  2171. stroke: "transparent",
  2172. },
  2173. iconVerticalLineS: {
  2174. width: blueIconHeight / 2,
  2175. height: weight,
  2176. x: blueIconHeight / 4 - r*2 - blueIconHeight / 2 + weight / 2,
  2177. y: blueIconHeight + r * 12,
  2178. fill: "#2acabe",
  2179. stroke: "transparent",
  2180. },
  2181. iconVerticalLineM: {
  2182. width: blueIconHeight / 3 * 2,
  2183. height: weight,
  2184. x: blueIconHeight / 6 - r*2 - blueIconHeight / 2 + weight / 2,
  2185. y: blueIconHeight - weight / 2 * 3 + r * 12,
  2186. fill: "#2acabe",
  2187. stroke: "transparent",
  2188. },
  2189. iconVerticalLineL: {
  2190. width: blueIconHeight,
  2191. height: weight,
  2192. x: 0 - r*2 - blueIconHeight / 2 + weight / 2,
  2193. y: blueIconHeight - weight * 3 + r * 12,
  2194. fill: "#2acabe",
  2195. stroke: "transparent",
  2196. },
  2197. iconTransverseLine: {
  2198. width: weight,
  2199. height: blueIconWidth - weight * 4,
  2200. x: (blueIconHeight - weight) / 2 - r*2 - blueIconHeight / 2 + weight / 2,
  2201. y: r * 12,
  2202. fill: "#2acabe",
  2203. stroke: "transparent",
  2204. }
  2205. },
  2206. }
  2207. }
  2208. const leftOption = () => {
  2209. const option = commonOption();
  2210. return option;
  2211. }
  2212. const rightOption = () => {
  2213. const option = commonOption();
  2214. return option;
  2215. }
  2216. const topOption = (option) => { }
  2217. const bottomOption = (option) => { }
  2218. const registerTopLeft = () => {
  2219. const shape = `${shapeName}-top-left`;
  2220. nodeSize[shape] = {
  2221. width: width,
  2222. height: height
  2223. };
  2224. const option = leftOption();
  2225. topOption(option);
  2226. Graph.registerNode(shape, option, true);
  2227. }
  2228. const registerTopRight = () => {
  2229. const shape = `${shapeName}-top-right`;
  2230. nodeSize[shape] = {
  2231. width: width,
  2232. height: height
  2233. };
  2234. const option = rightOption();
  2235. topOption(option);
  2236. Graph.registerNode(shape, option, true);
  2237. }
  2238. const registerBottomLeft = () => {
  2239. const shape = `${shapeName}-bottom-left`;
  2240. nodeSize[shape] = {
  2241. width: width,
  2242. height: height
  2243. };
  2244. const option = leftOption();
  2245. bottomOption(option);
  2246. Graph.registerNode(shape, option, true);
  2247. }
  2248. const registerBottomRight = () => {
  2249. const shape = `${shapeName}-bottom-right`;
  2250. nodeSize[shape] = {
  2251. width: width,
  2252. height: height
  2253. };
  2254. const option = rightOption();
  2255. bottomOption(option);
  2256. Graph.registerNode(shape, option, true);
  2257. }
  2258. registerTopLeft();
  2259. registerTopRight();
  2260. registerBottomLeft();
  2261. registerBottomRight();
  2262. }
  2263. // 横着的接地电容
  2264. const registerGroundingCapacitanceTransverse = () => {
  2265. const width = 100;
  2266. const height = 15;
  2267. const ut = width * 0.20;
  2268. const uv = width * 0.1;
  2269. const shapeName = "grounding-capacitance-transverse";
  2270. const commonOption = () => {
  2271. return {
  2272. width: width,
  2273. height: height,
  2274. markup: [
  2275. {
  2276. tagName: 'path',
  2277. selector: 'reactor',
  2278. },
  2279. {
  2280. tagName: 'path',
  2281. selector: 'icon',
  2282. },
  2283. ],
  2284. attrs: {
  2285. reactor: {
  2286. d: `M0,0 l0,-${height} l-${ut},0 m0,${ut/2} l0,-${ut} m-${uv-weight},0 l0,${ut} m0,-${ut/2} l-${ut*2},0
  2287. m0,${ut/2} l0,-${ut} m-${uv-weight},0 l0,${ut} m0,-${ut/2} l-${ut},0`,
  2288. x: -(weight / 2),
  2289. refY: height,
  2290. fill: "transparent",
  2291. stroke: "#b30461",
  2292. "stroke-width": weight,
  2293. },
  2294. icon: {
  2295. d: `M0,0 l-${blueIconWidth-weight*4},0 m0,${blueIconHeight/2} l0,-${blueIconHeight} m-${weight*1.5},${blueIconHeight/6} l0,${blueIconHeight/3*2}
  2296. m0,${blueIconHeight/6} m-${weight*1.5},-${blueIconHeight/4} l0,-${blueIconHeight/2}`,
  2297. refX: -width + weight*2,
  2298. refY: 0,
  2299. fill: "transparent",
  2300. stroke: "#2acabe",
  2301. "stroke-width": weight,
  2302. },
  2303. },
  2304. }
  2305. }
  2306. const leftOption = () => {
  2307. const option = commonOption();
  2308. return option;
  2309. }
  2310. const rightOption = () => {
  2311. const option = commonOption();
  2312. return option;
  2313. }
  2314. const topOption = (option) => { }
  2315. const bottomOption = (option) => {
  2316. option.attrs.reactor.transform = `scale(1, -1) translate(0, ${height})`;
  2317. option.attrs.icon.refY = height;
  2318. }
  2319. const registerTopLeft = () => {
  2320. const shape = `${shapeName}-top-left`;
  2321. nodeSize[shape] = {
  2322. width: width,
  2323. height: height
  2324. };
  2325. const option = leftOption();
  2326. topOption(option);
  2327. Graph.registerNode(shape, option, true);
  2328. }
  2329. const registerTopRight = () => {
  2330. const shape = `${shapeName}-top-right`;
  2331. nodeSize[shape] = {
  2332. width: width,
  2333. height: height
  2334. };
  2335. const option = rightOption();
  2336. topOption(option);
  2337. Graph.registerNode(shape, option, true);
  2338. }
  2339. const registerBottomLeft = () => {
  2340. const shape = `${shapeName}-bottom-left`;
  2341. nodeSize[shape] = {
  2342. width: width,
  2343. height: height
  2344. };
  2345. const option = leftOption();
  2346. bottomOption(option);
  2347. Graph.registerNode(shape, option, true);
  2348. }
  2349. const registerBottomRight = () => {
  2350. const shape = `${shapeName}-bottom-right`;
  2351. nodeSize[shape] = {
  2352. width: width,
  2353. height: height
  2354. };
  2355. const option = rightOption();
  2356. bottomOption(option);
  2357. Graph.registerNode(shape, option, true);
  2358. }
  2359. registerTopLeft();
  2360. registerTopRight();
  2361. registerBottomLeft();
  2362. registerBottomRight();
  2363. }
  2364. // ???
  2365. const registerGroundingResistanceVertical = () => {
  2366. const width = 15;
  2367. const height = 70;
  2368. const arrowWidth = 13;
  2369. const arrowHeight = 15;
  2370. const shapeName = "grounding-resistance-vertical";
  2371. const commonOption = () => {
  2372. return {
  2373. width: width,
  2374. height: height,
  2375. markup: [
  2376. {
  2377. tagName: 'path',
  2378. selector: 'reactor',
  2379. },
  2380. {
  2381. tagName: 'path',
  2382. selector: 'icon',
  2383. },
  2384. {
  2385. tagName: 'polygon',
  2386. selector: 'arrow',
  2387. },
  2388. ],
  2389. attrs: {
  2390. reactor: {
  2391. d: `M0,0 l0,${width} l0,${width} m0,-${width} l-${width/2},0 l0,40 l${width},0 l0,-40 l-${width/2},0`,
  2392. x: -(weight / 2),
  2393. refY: 0,
  2394. fill: "transparent",
  2395. stroke: "#b30461",
  2396. "stroke-width": weight,
  2397. },
  2398. icon: {
  2399. d: `M0,0 l-${blueIconWidth-weight*4},0 m0,${blueIconHeight/2} l0,-${blueIconHeight} m-${weight*1.5},${blueIconHeight/6} l0,${blueIconHeight/3*2}
  2400. m0,${blueIconHeight/6} m-${weight*1.5},-${blueIconHeight/4} l0,-${blueIconHeight/2}`,
  2401. refX: -width + weight*2,
  2402. refY: 0,
  2403. fill: "transparent",
  2404. stroke: "#2acabe",
  2405. "stroke-width": weight,
  2406. transform: `rotate(-90) translate(-${height-width+weight/2}, ${blueIconHeight/2})`
  2407. },
  2408. arrow: {
  2409. points: `${-(arrowWidth/2)},0 ${arrowWidth/2},0 0,${arrowHeight}`,
  2410. x: -(weight / 2),
  2411. refY: width*2,
  2412. fill: "#b30461",
  2413. stroke: "transparent",
  2414. }
  2415. },
  2416. }
  2417. }
  2418. const leftOption = () => {
  2419. const option = commonOption();
  2420. return option;
  2421. }
  2422. const rightOption = () => {
  2423. const option = commonOption();
  2424. return option;
  2425. }
  2426. const topOption = (option) => { }
  2427. const bottomOption = (option) => { }
  2428. const registerTopLeft = () => {
  2429. const shape = `${shapeName}-top-left`;
  2430. nodeSize[shape] = {
  2431. width: width,
  2432. height: height
  2433. };
  2434. const option = leftOption();
  2435. topOption(option);
  2436. Graph.registerNode(shape, option, true);
  2437. }
  2438. const registerTopRight = () => {
  2439. const shape = `${shapeName}-top-right`;
  2440. nodeSize[shape] = {
  2441. width: width,
  2442. height: height
  2443. };
  2444. const option = rightOption();
  2445. topOption(option);
  2446. Graph.registerNode(shape, option, true);
  2447. }
  2448. const registerBottomLeft = () => {
  2449. const shape = `${shapeName}-bottom-left`;
  2450. nodeSize[shape] = {
  2451. width: width,
  2452. height: height
  2453. };
  2454. const option = leftOption();
  2455. bottomOption(option);
  2456. Graph.registerNode(shape, option, true);
  2457. }
  2458. const registerBottomRight = () => {
  2459. const shape = `${shapeName}-bottom-right`;
  2460. nodeSize[shape] = {
  2461. width: width,
  2462. height: height
  2463. };
  2464. const option = rightOption();
  2465. bottomOption(option);
  2466. Graph.registerNode(shape, option, true);
  2467. }
  2468. registerTopLeft();
  2469. registerTopRight();
  2470. registerBottomLeft();
  2471. registerBottomRight();
  2472. }
  2473. // Three phase transformer
  2474. const registerThreePhaseTransformer = () => {
  2475. const width = 16;
  2476. const height = 50;
  2477. const r = height / 5;
  2478. const w = weight / 3 * 2;
  2479. const shapeName = "three-phase-transformer";
  2480. const commonOption = () => {
  2481. return {
  2482. width: width,
  2483. height: height,
  2484. markup: [
  2485. {
  2486. tagName: 'rect',
  2487. selector: 'line',
  2488. },
  2489. {
  2490. tagName: 'circle',
  2491. selector: 'circle1',
  2492. },
  2493. {
  2494. tagName: 'circle',
  2495. selector: 'circle2',
  2496. },
  2497. {
  2498. tagName: 'circle',
  2499. selector: 'circle3',
  2500. },
  2501. {
  2502. tagName: 'path',
  2503. selector: 'path',
  2504. },
  2505. {
  2506. tagName: 'path',
  2507. selector: 'path1',
  2508. },
  2509. {
  2510. tagName: 'path',
  2511. selector: 'path2',
  2512. },
  2513. ],
  2514. attrs: {
  2515. line: {
  2516. x: -(weight / 2),
  2517. y: 0,
  2518. width: weight,
  2519. height: r + weight*2,
  2520. fill: "#b30461",
  2521. stroke: "transparent",
  2522. },
  2523. circle1: {
  2524. cx: 0,
  2525. cy: 2*r+weight*2,
  2526. r: r,
  2527. fill: "transparent",
  2528. stroke: "#b30461",
  2529. "stroke-width": w,
  2530. },
  2531. circle2: {
  2532. cx: 0,
  2533. cy: 4*r,
  2534. r: r,
  2535. fill: "transparent",
  2536. stroke: "#cbaa07",
  2537. "stroke-width": w,
  2538. },
  2539. circle3: {
  2540. cx: Math.sqrt(weight*(2*r-weight)) + r - 3,
  2541. cy: 3*r+weight,
  2542. r: r,
  2543. fill: "transparent",
  2544. stroke: "#b30461",
  2545. "stroke-width": w,
  2546. },
  2547. path: {
  2548. d: `M0,${2*r+weight*2} l-${r/2},${r/2} m${r/2},-${r/2} l${r/2},${r/2} m-${r/2},-${r/2} l0,-${r/2}
  2549. M${Math.sqrt(weight*(2*r-weight))+r-3},${3*r+weight} m-1,-${r/2} l0,${r} l${r/2},-${r/2} l-${r/2},-${r/2}`,
  2550. x: -(weight / 2),
  2551. y: 0,
  2552. fill: "transparent",
  2553. stroke: "#b30461",
  2554. "stroke-width": w,
  2555. },
  2556. path1: {
  2557. d: `M0,${4*r} l-${r/2},${r/2} m${r/2},-${r/2} l${r/2},${r/2} m-${r/2},-${r/2} l0,-${r/2}`,
  2558. x: -(weight / 2),
  2559. y: 0,
  2560. fill: "transparent",
  2561. stroke: "#cbaa07",
  2562. "stroke-width": w,
  2563. },
  2564. path2: {
  2565. // d: `M-20,${2*r+weight*2+15} l56,-23 l${23/10},${56/10}`,
  2566. d: `M-20,${2*r+weight*2+15} l60,0 l0,5 l15,-5 l-15,-5 l0,5 z`,
  2567. x: -(weight / 2),
  2568. y: 0,
  2569. fill: "#b30461",
  2570. stroke: "#b30461",
  2571. "stroke-width": w,
  2572. transform: `rotate(-30) translate(-20, -10)`
  2573. },
  2574. },
  2575. }
  2576. }
  2577. const leftOption = () => {
  2578. const option = commonOption();
  2579. return option;
  2580. }
  2581. const rightOption = () => {
  2582. const option = commonOption();
  2583. return option;
  2584. }
  2585. const topOption = (option) => { }
  2586. const bottomOption = (option) => { }
  2587. const registerTopLeft = () => {
  2588. const shape = `${shapeName}-top-left`;
  2589. nodeSize[shape] = {
  2590. width: width,
  2591. height: height
  2592. };
  2593. const option = leftOption();
  2594. topOption(option);
  2595. Graph.registerNode(shape, option, true);
  2596. }
  2597. const registerTopRight = () => {
  2598. const shape = `${shapeName}-top-right`;
  2599. nodeSize[shape] = {
  2600. width: width,
  2601. height: height
  2602. };
  2603. const option = rightOption();
  2604. topOption(option);
  2605. Graph.registerNode(shape, option, true);
  2606. }
  2607. const registerBottomLeft = () => {
  2608. const shape = `${shapeName}-bottom-left`;
  2609. nodeSize[shape] = {
  2610. width: width,
  2611. height: height
  2612. };
  2613. const option = leftOption();
  2614. bottomOption(option);
  2615. Graph.registerNode(shape, option, true);
  2616. }
  2617. const registerBottomRight = () => {
  2618. const shape = `${shapeName}-bottom-right`;
  2619. nodeSize[shape] = {
  2620. width: width,
  2621. height: height
  2622. };
  2623. const option = rightOption();
  2624. bottomOption(option);
  2625. Graph.registerNode(shape, option, true);
  2626. }
  2627. registerTopLeft();
  2628. registerTopRight();
  2629. registerBottomLeft();
  2630. registerBottomRight();
  2631. }
  2632. // 主变压器
  2633. const registerMainTransformer = () => {
  2634. const width = 66;
  2635. const height = 0;
  2636. const shapeName = "main-transformer";
  2637. const commonOption = () => {
  2638. return {
  2639. width: width,
  2640. height: height,
  2641. markup: [
  2642. {
  2643. tagName: 'rect',
  2644. selector: 'line',
  2645. },
  2646. ],
  2647. attrs: {
  2648. line: {
  2649. x: -width - 10,
  2650. y: -40,
  2651. width: width,
  2652. height: weight,
  2653. fill: "#b30461",
  2654. stroke: "transparent",
  2655. },
  2656. },
  2657. }
  2658. }
  2659. const leftOption = () => {
  2660. const option = commonOption();
  2661. return option;
  2662. }
  2663. const rightOption = () => {
  2664. const option = commonOption();
  2665. return option;
  2666. }
  2667. const topOption = (option) => { }
  2668. const bottomOption = (option) => { }
  2669. const registerTopLeft = () => {
  2670. const shape = `${shapeName}-top-left`;
  2671. nodeSize[shape] = {
  2672. width: width,
  2673. height: height
  2674. };
  2675. const option = leftOption();
  2676. topOption(option);
  2677. Graph.registerNode(shape, option, true);
  2678. }
  2679. const registerTopRight = () => {
  2680. const shape = `${shapeName}-top-right`;
  2681. nodeSize[shape] = {
  2682. width: width,
  2683. height: height
  2684. };
  2685. const option = rightOption();
  2686. topOption(option);
  2687. Graph.registerNode(shape, option, true);
  2688. }
  2689. const registerBottomLeft = () => {
  2690. const shape = `${shapeName}-bottom-left`;
  2691. nodeSize[shape] = {
  2692. width: width,
  2693. height: height
  2694. };
  2695. const option = leftOption();
  2696. bottomOption(option);
  2697. Graph.registerNode(shape, option, true);
  2698. }
  2699. const registerBottomRight = () => {
  2700. const shape = `${shapeName}-bottom-right`;
  2701. nodeSize[shape] = {
  2702. width: width,
  2703. height: height
  2704. };
  2705. const option = rightOption();
  2706. bottomOption(option);
  2707. Graph.registerNode(shape, option, true);
  2708. }
  2709. registerTopLeft();
  2710. registerTopRight();
  2711. registerBottomLeft();
  2712. registerBottomRight();
  2713. }
  2714. // 主变压器1
  2715. const registerMainTransformer1 = () => {
  2716. const width = 66;
  2717. const height = 0;
  2718. const shapeName = "main-transformer1";
  2719. const commonOption = () => {
  2720. return {
  2721. width: width,
  2722. height: height,
  2723. markup: [
  2724. {
  2725. tagName: 'text',
  2726. selector: 'label',
  2727. },
  2728. {
  2729. tagName: 'path',
  2730. selector: 'path',
  2731. },
  2732. {
  2733. tagName: 'path',
  2734. selector: 'icon',
  2735. },
  2736. ],
  2737. attrs: {
  2738. label: {
  2739. x: -width - 25,
  2740. y: 0,
  2741. fill: '#D0D0D0',
  2742. fontSize: fontsize,
  2743. "text-anchor": "end",
  2744. },
  2745. path: {
  2746. d: `M0,0 l0,15`,
  2747. refX: -width - 10,
  2748. refY: -40,
  2749. fill: "transparent",
  2750. stroke: "#b30461",
  2751. "stroke-width": weight,
  2752. },
  2753. icon: {
  2754. d: `M0,0 l-${blueIconWidth-weight*4},0 m0,${blueIconHeight/2} l0,-${blueIconHeight} m-${weight*1.5},${blueIconHeight/6} l0,${blueIconHeight/3*2}
  2755. m0,${blueIconHeight/6} m-${weight*1.5},-${blueIconHeight/4} l0,-${blueIconHeight/2}`,
  2756. refX: -width + weight*2,
  2757. refY: 0,
  2758. fill: "transparent",
  2759. stroke: "#2acabe",
  2760. "stroke-width": weight,
  2761. transform: `rotate(-90) translate(-16.5,-16)`
  2762. },
  2763. },
  2764. }
  2765. }
  2766. const leftOption = () => {
  2767. const option = commonOption();
  2768. return option;
  2769. }
  2770. const rightOption = () => {
  2771. const option = commonOption();
  2772. return option;
  2773. }
  2774. const topOption = (option) => { }
  2775. const bottomOption = (option) => { }
  2776. const registerTopLeft = () => {
  2777. const shape = `${shapeName}-top-left`;
  2778. nodeSize[shape] = {
  2779. width: width,
  2780. height: height
  2781. };
  2782. const option = leftOption();
  2783. topOption(option);
  2784. Graph.registerNode(shape, option, true);
  2785. }
  2786. const registerTopRight = () => {
  2787. const shape = `${shapeName}-top-right`;
  2788. nodeSize[shape] = {
  2789. width: width,
  2790. height: height
  2791. };
  2792. const option = rightOption();
  2793. topOption(option);
  2794. Graph.registerNode(shape, option, true);
  2795. }
  2796. const registerBottomLeft = () => {
  2797. const shape = `${shapeName}-bottom-left`;
  2798. nodeSize[shape] = {
  2799. width: width,
  2800. height: height
  2801. };
  2802. const option = leftOption();
  2803. bottomOption(option);
  2804. Graph.registerNode(shape, option, true);
  2805. }
  2806. const registerBottomRight = () => {
  2807. const shape = `${shapeName}-bottom-right`;
  2808. nodeSize[shape] = {
  2809. width: width,
  2810. height: height
  2811. };
  2812. const option = rightOption();
  2813. bottomOption(option);
  2814. Graph.registerNode(shape, option, true);
  2815. }
  2816. registerTopLeft();
  2817. registerTopRight();
  2818. registerBottomLeft();
  2819. registerBottomRight();
  2820. }
  2821. // 主变压器2
  2822. const registerMainTransformer2 = () => {
  2823. const width = 15;
  2824. const height = 0;
  2825. const h = 7;
  2826. const arrowWidth = 13;
  2827. const arrowHeight = 15;
  2828. const shapeName = "main-transformer2";
  2829. const commonOption = () => {
  2830. return {
  2831. width: width,
  2832. height: height,
  2833. markup: [
  2834. {
  2835. tagName: 'path',
  2836. selector: 'reactor',
  2837. },
  2838. {
  2839. tagName: 'path',
  2840. selector: 'icon',
  2841. },
  2842. {
  2843. tagName: 'polygon',
  2844. selector: 'arrow',
  2845. },
  2846. ],
  2847. attrs: {
  2848. reactor: {
  2849. d: `M0,0 l0,${width} l0,${width} m0,-${width} l-${width/2},0 l0,40 l${width},0 l0,-40 l-${width/2},0`,
  2850. refX: -50,
  2851. refY: -40,
  2852. fill: "transparent",
  2853. stroke: "#b30461",
  2854. "stroke-width": weight,
  2855. },
  2856. icon: {
  2857. d: `M0,0 l-${blueIconWidth-weight*4},0 m0,${blueIconHeight/2} l0,-${blueIconHeight} m-${weight*1.5},${blueIconHeight/6} l0,${blueIconHeight/3*2}
  2858. m0,${blueIconHeight/6} m-${weight*1.5},-${blueIconHeight/4} l0,-${blueIconHeight/2}`,
  2859. refX: -50,
  2860. refY: 0,
  2861. fill: "transparent",
  2862. stroke: "#2acabe",
  2863. "stroke-width": weight,
  2864. transform: `rotate(-90) translate(-16.5,0)`
  2865. },
  2866. arrow: {
  2867. points: `${-(arrowWidth/2)},0 ${arrowWidth/2},0 0,${arrowHeight}`,
  2868. refX: -50,
  2869. refY: -10,
  2870. fill: "#b30461",
  2871. stroke: "transparent",
  2872. }
  2873. },
  2874. }
  2875. }
  2876. const leftOption = () => {
  2877. const option = commonOption();
  2878. return option;
  2879. }
  2880. const rightOption = () => {
  2881. const option = commonOption();
  2882. return option;
  2883. }
  2884. const topOption = (option) => { }
  2885. const bottomOption = (option) => { }
  2886. const registerTopLeft = () => {
  2887. const shape = `${shapeName}-top-left`;
  2888. nodeSize[shape] = {
  2889. width: width,
  2890. height: height
  2891. };
  2892. const option = leftOption();
  2893. topOption(option);
  2894. Graph.registerNode(shape, option, true);
  2895. }
  2896. const registerTopRight = () => {
  2897. const shape = `${shapeName}-top-right`;
  2898. nodeSize[shape] = {
  2899. width: width,
  2900. height: height
  2901. };
  2902. const option = rightOption();
  2903. topOption(option);
  2904. Graph.registerNode(shape, option, true);
  2905. }
  2906. const registerBottomLeft = () => {
  2907. const shape = `${shapeName}-bottom-left`;
  2908. nodeSize[shape] = {
  2909. width: width,
  2910. height: height
  2911. };
  2912. const option = leftOption();
  2913. bottomOption(option);
  2914. Graph.registerNode(shape, option, true);
  2915. }
  2916. const registerBottomRight = () => {
  2917. const shape = `${shapeName}-bottom-right`;
  2918. nodeSize[shape] = {
  2919. width: width,
  2920. height: height
  2921. };
  2922. const option = rightOption();
  2923. bottomOption(option);
  2924. Graph.registerNode(shape, option, true);
  2925. }
  2926. registerTopLeft();
  2927. registerTopRight();
  2928. registerBottomLeft();
  2929. registerBottomRight();
  2930. }
  2931. // 主变压器3
  2932. const registerMainTransformer3 = () => {
  2933. const width = 15;
  2934. const height = 0;
  2935. const h = 7;
  2936. const arrowWidth = 13;
  2937. const arrowHeight = 15;
  2938. const shapeName = "main-transformer3";
  2939. const commonOption = () => {
  2940. return {
  2941. width: width,
  2942. height: height,
  2943. markup: [
  2944. {
  2945. tagName: 'text',
  2946. selector: 'label',
  2947. },
  2948. {
  2949. tagName: 'path',
  2950. selector: 'reactor',
  2951. },
  2952. {
  2953. tagName: 'path',
  2954. selector: 'icon',
  2955. },
  2956. {
  2957. tagName: 'polygon',
  2958. selector: 'arrow',
  2959. },
  2960. {
  2961. tagName: 'polygon',
  2962. selector: 'arrow1',
  2963. },
  2964. ],
  2965. attrs: {
  2966. label: {
  2967. x: -25,
  2968. y: 55,
  2969. fill: '#D0D0D0',
  2970. fontSize: fontsize,
  2971. "text-anchor": "middle",
  2972. },
  2973. reactor: {
  2974. d: `M0,0 l0,${width}`,
  2975. refX: -25,
  2976. refY: -40,
  2977. fill: "transparent",
  2978. stroke: "#b30461",
  2979. "stroke-width": weight,
  2980. },
  2981. icon: {
  2982. d: `M0,0 l-${blueIconWidth-weight*4},0 m0,${blueIconHeight/2} l0,-${blueIconHeight} m-${weight*1.5},${blueIconHeight/6} l0,${blueIconHeight/3*2}
  2983. m0,${blueIconHeight/6} m-${weight*1.5},-${blueIconHeight/4} l0,-${blueIconHeight/2}`,
  2984. refX: -25,
  2985. refY: 0,
  2986. fill: "transparent",
  2987. stroke: "#2acabe",
  2988. "stroke-width": weight,
  2989. transform: `rotate(-90) translate(-16.5,0)`
  2990. },
  2991. arrow: {
  2992. points: `${-(arrowWidth/2)},0 ${arrowWidth/2},0 0,${arrowHeight}`,
  2993. refX: -25,
  2994. refY: -25,
  2995. fill: "#b30461",
  2996. stroke: "transparent",
  2997. },
  2998. arrow1: {
  2999. points: `0,0 ${-(arrowWidth/2)},${arrowHeight} ${arrowWidth/2},${arrowHeight}`,
  3000. refX: -25,
  3001. refY: 5,
  3002. fill: "#b30461",
  3003. stroke: "transparent",
  3004. },
  3005. },
  3006. }
  3007. }
  3008. const leftOption = () => {
  3009. const option = commonOption();
  3010. return option;
  3011. }
  3012. const rightOption = () => {
  3013. const option = commonOption();
  3014. return option;
  3015. }
  3016. const topOption = (option) => { }
  3017. const bottomOption = (option) => { }
  3018. const registerTopLeft = () => {
  3019. const shape = `${shapeName}-top-left`;
  3020. nodeSize[shape] = {
  3021. width: width,
  3022. height: height
  3023. };
  3024. const option = leftOption();
  3025. topOption(option);
  3026. Graph.registerNode(shape, option, true);
  3027. }
  3028. const registerTopRight = () => {
  3029. const shape = `${shapeName}-top-right`;
  3030. nodeSize[shape] = {
  3031. width: width,
  3032. height: height
  3033. };
  3034. const option = rightOption();
  3035. topOption(option);
  3036. Graph.registerNode(shape, option, true);
  3037. }
  3038. const registerBottomLeft = () => {
  3039. const shape = `${shapeName}-bottom-left`;
  3040. nodeSize[shape] = {
  3041. width: width,
  3042. height: height
  3043. };
  3044. const option = leftOption();
  3045. bottomOption(option);
  3046. Graph.registerNode(shape, option, true);
  3047. }
  3048. const registerBottomRight = () => {
  3049. const shape = `${shapeName}-bottom-right`;
  3050. nodeSize[shape] = {
  3051. width: width,
  3052. height: height
  3053. };
  3054. const option = rightOption();
  3055. bottomOption(option);
  3056. Graph.registerNode(shape, option, true);
  3057. }
  3058. registerTopLeft();
  3059. registerTopRight();
  3060. registerBottomLeft();
  3061. registerBottomRight();
  3062. }
  3063. // 开关断开
  3064. const registerSwitchBreak = () => {
  3065. const width = 0;
  3066. const height = 0;
  3067. const shapeName = "switch-break";
  3068. const commonOption = () => {
  3069. return {
  3070. width: width,
  3071. height: height,
  3072. markup: [
  3073. {
  3074. tagName: 'path',
  3075. selector: 'path',
  3076. },
  3077. ],
  3078. attrs: {
  3079. path: {
  3080. d: `M1,6 a3 3 0 1 0 -2 0 M0,6 l-5,15 m0,5 l10,0`,
  3081. refX: 0,
  3082. refY: 0,
  3083. fill: "transparent",
  3084. stroke: "#04a635",
  3085. "stroke-width": 2,
  3086. },
  3087. },
  3088. }
  3089. }
  3090. const registerTop = () => {
  3091. const shape = `${shapeName}-top`;
  3092. nodeSize[shape] = {
  3093. width: width,
  3094. height: height
  3095. };
  3096. const option = commonOption();
  3097. option.attrs.path.transform = `rotate(180)`; // `rotate(-90) translate(-16.5,0)`;
  3098. Graph.registerNode(shape, option, true);
  3099. }
  3100. const registerBottom = () => {
  3101. const shape = `${shapeName}-bottom`;
  3102. nodeSize[shape] = {
  3103. width: width,
  3104. height: height
  3105. };
  3106. const option = commonOption();
  3107. Graph.registerNode(shape, option, true);
  3108. }
  3109. const registerLeft = () => {
  3110. const shape = `${shapeName}-left`;
  3111. nodeSize[shape] = {
  3112. width: width,
  3113. height: height
  3114. };
  3115. const option = commonOption();
  3116. option.attrs.path.transform = `rotate(90)`; // `rotate(-90) translate(-16.5,0)`;
  3117. Graph.registerNode(shape, option, true);
  3118. }
  3119. const registerRight = () => {
  3120. const shape = `${shapeName}-right`;
  3121. nodeSize[shape] = {
  3122. width: width,
  3123. height: height
  3124. };
  3125. const option = commonOption();
  3126. option.attrs.path.transform = `rotate(-90)`; // `rotate(-90) translate(-16.5,0)`;
  3127. Graph.registerNode(shape, option, true);
  3128. }
  3129. registerTop();
  3130. registerBottom();
  3131. registerLeft();
  3132. registerRight();
  3133. }
  3134. // 开关闭合
  3135. const registerSwitchClose = () => {
  3136. const width = 0;
  3137. const height = 0;
  3138. const shapeName = "switch-close";
  3139. const commonOption = () => {
  3140. return {
  3141. width: width,
  3142. height: height,
  3143. markup: [
  3144. {
  3145. tagName: 'path',
  3146. selector: 'path',
  3147. },
  3148. ],
  3149. attrs: {
  3150. path: {
  3151. d: `M1,6 a3 3 0 1 0 -2 0 M0,6 l0,20 m-5,0 l10,0`,
  3152. refX: 0,
  3153. refY: 0,
  3154. fill: "transparent",
  3155. stroke: "#b30303",
  3156. "stroke-width": 2,
  3157. },
  3158. },
  3159. }
  3160. }
  3161. const registerTop = () => {
  3162. const shape = `${shapeName}-top`;
  3163. nodeSize[shape] = {
  3164. width: width,
  3165. height: height
  3166. };
  3167. const option = commonOption();
  3168. option.attrs.path.transform = `rotate(180)`; // `rotate(-90) translate(-16.5,0)`;
  3169. Graph.registerNode(shape, option, true);
  3170. }
  3171. const registerBottom = () => {
  3172. const shape = `${shapeName}-bottom`;
  3173. nodeSize[shape] = {
  3174. width: width,
  3175. height: height
  3176. };
  3177. const option = commonOption();
  3178. Graph.registerNode(shape, option, true);
  3179. }
  3180. const registerLeft = () => {
  3181. const shape = `${shapeName}-left`;
  3182. nodeSize[shape] = {
  3183. width: width,
  3184. height: height
  3185. };
  3186. const option = commonOption();
  3187. option.attrs.path.transform = `rotate(90)`; // `rotate(-90) translate(-16.5,0)`;
  3188. Graph.registerNode(shape, option, true);
  3189. }
  3190. const registerRight = () => {
  3191. const shape = `${shapeName}-right`;
  3192. nodeSize[shape] = {
  3193. width: width,
  3194. height: height
  3195. };
  3196. const option = commonOption();
  3197. option.attrs.path.transform = `rotate(-90)`; // `rotate(-90) translate(-16.5,0)`;
  3198. Graph.registerNode(shape, option, true);
  3199. }
  3200. registerTop();
  3201. registerBottom();
  3202. registerLeft();
  3203. registerRight();
  3204. }
  3205. // 手车00
  3206. const registerHandcart00 = () => {
  3207. const width = 0;
  3208. const height = 0;
  3209. const shapeName = "handcart00";
  3210. const commonOption = () => {
  3211. return {
  3212. width: width,
  3213. height: height,
  3214. markup: [
  3215. {
  3216. tagName: 'path',
  3217. selector: 'path',
  3218. },
  3219. {
  3220. tagName: 'rect',
  3221. selector: 'rect',
  3222. },
  3223. ],
  3224. attrs: {
  3225. path: {
  3226. d: `M0,0 l-8,8 m8,-8 l8,8 m-8,-2 l-8,8 m8,-8 l8,8
  3227. M0,60 l-8,-8 m8,8 l8,-8 m-8,2 l-8,-8 m8,8 l8,-8`,
  3228. refX: 0,
  3229. refY: 0,
  3230. fill: "transparent",
  3231. stroke: "#04a635",
  3232. "stroke-width": 2,
  3233. },
  3234. rect: {
  3235. x: -8,
  3236. y: 18,
  3237. width: 16,
  3238. height: 24,
  3239. fill: "#04a635",
  3240. stroke: "transparent",
  3241. },
  3242. },
  3243. }
  3244. }
  3245. const registerTop = () => {
  3246. const shape = `${shapeName}-top`;
  3247. nodeSize[shape] = {
  3248. width: width,
  3249. height: height
  3250. };
  3251. const option = commonOption();
  3252. Graph.registerNode(shape, option, true);
  3253. }
  3254. const registerBottom = () => {
  3255. const shape = `${shapeName}-bottom`;
  3256. nodeSize[shape] = {
  3257. width: width,
  3258. height: height
  3259. };
  3260. const option = commonOption();
  3261. Graph.registerNode(shape, option, true);
  3262. }
  3263. const registerLeft = () => {
  3264. const shape = `${shapeName}-left`;
  3265. nodeSize[shape] = {
  3266. width: width,
  3267. height: height
  3268. };
  3269. const option = commonOption();
  3270. Graph.registerNode(shape, option, true);
  3271. }
  3272. const registerRight = () => {
  3273. const shape = `${shapeName}-right`;
  3274. nodeSize[shape] = {
  3275. width: width,
  3276. height: height
  3277. };
  3278. const option = commonOption();
  3279. Graph.registerNode(shape, option, true);
  3280. }
  3281. registerTop();
  3282. registerBottom();
  3283. registerLeft();
  3284. registerRight();
  3285. }
  3286. // 手车01
  3287. const registerHandcart01 = () => {
  3288. const width = 0;
  3289. const height = 0;
  3290. const shapeName = "handcart01";
  3291. const commonOption = () => {
  3292. return {
  3293. width: width,
  3294. height: height,
  3295. markup: [
  3296. {
  3297. tagName: 'path',
  3298. selector: 'path',
  3299. },
  3300. {
  3301. tagName: 'rect',
  3302. selector: 'rect',
  3303. },
  3304. ],
  3305. attrs: {
  3306. path: {
  3307. d: `M0,0 l-8,8 m8,-8 l8,8 m-8,-2 l-8,8 m8,-8 l8,8
  3308. M0,60 l-8,-8 m8,8 l8,-8 m-8,2 l-8,-8 m8,8 l8,-8`,
  3309. refX: 0,
  3310. refY: 0,
  3311. fill: "transparent",
  3312. stroke: "#04a635",
  3313. "stroke-width": 2,
  3314. },
  3315. rect: {
  3316. x: -8,
  3317. y: 18,
  3318. width: 16,
  3319. height: 24,
  3320. fill: "#b30303",
  3321. stroke: "transparent",
  3322. },
  3323. },
  3324. }
  3325. }
  3326. const registerTop = () => {
  3327. const shape = `${shapeName}-top`;
  3328. nodeSize[shape] = {
  3329. width: width,
  3330. height: height
  3331. };
  3332. const option = commonOption();
  3333. Graph.registerNode(shape, option, true);
  3334. }
  3335. const registerBottom = () => {
  3336. const shape = `${shapeName}-bottom`;
  3337. nodeSize[shape] = {
  3338. width: width,
  3339. height: height
  3340. };
  3341. const option = commonOption();
  3342. Graph.registerNode(shape, option, true);
  3343. }
  3344. const registerLeft = () => {
  3345. const shape = `${shapeName}-left`;
  3346. nodeSize[shape] = {
  3347. width: width,
  3348. height: height
  3349. };
  3350. const option = commonOption();
  3351. Graph.registerNode(shape, option, true);
  3352. }
  3353. const registerRight = () => {
  3354. const shape = `${shapeName}-right`;
  3355. nodeSize[shape] = {
  3356. width: width,
  3357. height: height
  3358. };
  3359. const option = commonOption();
  3360. Graph.registerNode(shape, option, true);
  3361. }
  3362. registerTop();
  3363. registerBottom();
  3364. registerLeft();
  3365. registerRight();
  3366. }
  3367. // 手车10
  3368. const registerHandcart10 = () => {
  3369. const width = 0;
  3370. const height = 0;
  3371. const shapeName = "handcart10";
  3372. const commonOption = () => {
  3373. return {
  3374. width: width,
  3375. height: height,
  3376. markup: [
  3377. {
  3378. tagName: 'path',
  3379. selector: 'path',
  3380. },
  3381. {
  3382. tagName: 'rect',
  3383. selector: 'rect',
  3384. },
  3385. ],
  3386. attrs: {
  3387. path: {
  3388. d: `M0,0 l-8,8 m8,-8 l8,8 m-8,-2 l-8,8 m8,-8 l8,8
  3389. M0,60 l-8,-8 m8,8 l8,-8 m-8,2 l-8,-8 m8,8 l8,-8`,
  3390. refX: 0,
  3391. refY: 0,
  3392. fill: "transparent",
  3393. stroke: "#b30303",
  3394. "stroke-width": 2,
  3395. },
  3396. rect: {
  3397. x: -8,
  3398. y: 18,
  3399. width: 16,
  3400. height: 24,
  3401. fill: "#04a635",
  3402. stroke: "transparent",
  3403. },
  3404. },
  3405. }
  3406. }
  3407. const registerTop = () => {
  3408. const shape = `${shapeName}-top`;
  3409. nodeSize[shape] = {
  3410. width: width,
  3411. height: height
  3412. };
  3413. const option = commonOption();
  3414. Graph.registerNode(shape, option, true);
  3415. }
  3416. const registerBottom = () => {
  3417. const shape = `${shapeName}-bottom`;
  3418. nodeSize[shape] = {
  3419. width: width,
  3420. height: height
  3421. };
  3422. const option = commonOption();
  3423. Graph.registerNode(shape, option, true);
  3424. }
  3425. const registerLeft = () => {
  3426. const shape = `${shapeName}-left`;
  3427. nodeSize[shape] = {
  3428. width: width,
  3429. height: height
  3430. };
  3431. const option = commonOption();
  3432. Graph.registerNode(shape, option, true);
  3433. }
  3434. const registerRight = () => {
  3435. const shape = `${shapeName}-right`;
  3436. nodeSize[shape] = {
  3437. width: width,
  3438. height: height
  3439. };
  3440. const option = commonOption();
  3441. Graph.registerNode(shape, option, true);
  3442. }
  3443. registerTop();
  3444. registerBottom();
  3445. registerLeft();
  3446. registerRight();
  3447. }
  3448. // 手车11
  3449. const registerHandcart11 = () => {
  3450. const width = 0;
  3451. const height = 0;
  3452. const shapeName = "handcart11";
  3453. const commonOption = () => {
  3454. return {
  3455. width: width,
  3456. height: height,
  3457. markup: [
  3458. {
  3459. tagName: 'path',
  3460. selector: 'path',
  3461. },
  3462. {
  3463. tagName: 'rect',
  3464. selector: 'rect',
  3465. },
  3466. ],
  3467. attrs: {
  3468. path: {
  3469. d: `M0,0 l-8,8 m8,-8 l8,8 m-8,-2 l-8,8 m8,-8 l8,8
  3470. M0,60 l-8,-8 m8,8 l8,-8 m-8,2 l-8,-8 m8,8 l8,-8`,
  3471. refX: 0,
  3472. refY: 0,
  3473. fill: "transparent",
  3474. stroke: "#b30303",
  3475. "stroke-width": 2,
  3476. },
  3477. rect: {
  3478. x: -8,
  3479. y: 18,
  3480. width: 16,
  3481. height: 24,
  3482. fill: "#b30303",
  3483. stroke: "transparent",
  3484. },
  3485. },
  3486. }
  3487. }
  3488. const registerTop = () => {
  3489. const shape = `${shapeName}-top`;
  3490. nodeSize[shape] = {
  3491. width: width,
  3492. height: height
  3493. };
  3494. const option = commonOption();
  3495. Graph.registerNode(shape, option, true);
  3496. }
  3497. const registerBottom = () => {
  3498. const shape = `${shapeName}-bottom`;
  3499. nodeSize[shape] = {
  3500. width: width,
  3501. height: height
  3502. };
  3503. const option = commonOption();
  3504. Graph.registerNode(shape, option, true);
  3505. }
  3506. const registerLeft = () => {
  3507. const shape = `${shapeName}-left`;
  3508. nodeSize[shape] = {
  3509. width: width,
  3510. height: height
  3511. };
  3512. const option = commonOption();
  3513. Graph.registerNode(shape, option, true);
  3514. }
  3515. const registerRight = () => {
  3516. const shape = `${shapeName}-right`;
  3517. nodeSize[shape] = {
  3518. width: width,
  3519. height: height
  3520. };
  3521. const option = commonOption();
  3522. Graph.registerNode(shape, option, true);
  3523. }
  3524. registerTop();
  3525. registerBottom();
  3526. registerLeft();
  3527. registerRight();
  3528. }
  3529. // 标签文字
  3530. const registerTagText = () => {
  3531. const width = 100;
  3532. const height = 24;
  3533. const shape = "tag-text";
  3534. nodeSize[shape] = {
  3535. width: width,
  3536. height: height
  3537. };
  3538. const option = {
  3539. width: width,
  3540. height: height,
  3541. markup: [
  3542. {
  3543. tagName: 'rect',
  3544. selector: 'rect',
  3545. },
  3546. {
  3547. tagName: 'text',
  3548. selector: 'label',
  3549. },
  3550. ],
  3551. attrs: {
  3552. rect: {
  3553. width: width,
  3554. height: height,
  3555. x: 0,
  3556. y: 0,
  3557. fill: "#5B5792",
  3558. stroke: "transparent",
  3559. },
  3560. label: {
  3561. fill: '#C9D0FE',
  3562. fontSize: 14,
  3563. refX: 50,
  3564. refY: 5,
  3565. "text-anchor": "middle"
  3566. },
  3567. },
  3568. };
  3569. Graph.registerNode(shape, option, true);
  3570. }
  3571. // 小标签文字
  3572. const registerTagTexts = () => {
  3573. const width = 74;
  3574. const height = 24;
  3575. const shape = "tag-text-s";
  3576. nodeSize[shape] = {
  3577. width: width,
  3578. height: height
  3579. };
  3580. const option = {
  3581. width: width,
  3582. height: height,
  3583. markup: [
  3584. {
  3585. tagName: 'rect',
  3586. selector: 'rect',
  3587. },
  3588. {
  3589. tagName: 'text',
  3590. selector: 'label',
  3591. },
  3592. ],
  3593. attrs: {
  3594. rect: {
  3595. width: width,
  3596. height: height,
  3597. x: 0,
  3598. y: 0,
  3599. fill: "#5B5792",
  3600. stroke: "transparent",
  3601. },
  3602. label: {
  3603. fill: '#C9D0FE',
  3604. fontSize: 14,
  3605. refX: 37,
  3606. refY: 5,
  3607. "text-anchor": "middle"
  3608. },
  3609. },
  3610. };
  3611. Graph.registerNode(shape, option, true);
  3612. }
  3613. // 表单文字
  3614. const registerFormText = () => {
  3615. const width = 150;
  3616. const height = 24;
  3617. const shape = "form-text";
  3618. nodeSize[shape] = {
  3619. width: width,
  3620. height: height
  3621. };
  3622. const option = {
  3623. width: width,
  3624. height: height,
  3625. markup: [
  3626. {
  3627. tagName: 'rect',
  3628. selector: 'rect',
  3629. },
  3630. {
  3631. tagName: 'text',
  3632. selector: 'label',
  3633. },
  3634. {
  3635. tagName: 'text',
  3636. selector: 'value',
  3637. },
  3638. ],
  3639. attrs: {
  3640. rect: {
  3641. width: width,
  3642. height: height,
  3643. x: 0,
  3644. y: 0,
  3645. fill: "#536268",
  3646. opacity: 0.2,
  3647. stroke: "transparent",
  3648. },
  3649. label: {
  3650. fill: '#6A7476',
  3651. fontSize: fontsize,
  3652. refX: 6,
  3653. refY: 6,
  3654. "text-anchor": "start"
  3655. },
  3656. value: {
  3657. fill: '#059C40',
  3658. fontSize: fontsize,
  3659. refX: 144,
  3660. refY: 6,
  3661. "text-anchor": "end"
  3662. },
  3663. },
  3664. };
  3665. Graph.registerNode(shape, option, true);
  3666. }
  3667. // label文字
  3668. const registerLabelText = () => {
  3669. const width = 150;
  3670. const height = 24;
  3671. const shape = "label-text";
  3672. nodeSize[shape] = {
  3673. width: width,
  3674. height: height
  3675. };
  3676. const option = {
  3677. width: width,
  3678. height: height,
  3679. markup: [
  3680. {
  3681. tagName: 'text',
  3682. selector: 'label',
  3683. },
  3684. ],
  3685. attrs: {
  3686. label: {
  3687. fill: '#6A7476',
  3688. fontSize: fontsize,
  3689. refX: 0,
  3690. refY: 6,
  3691. "text-anchor": "start"
  3692. },
  3693. },
  3694. };
  3695. Graph.registerNode(shape, option, true);
  3696. }
  3697. // value文字
  3698. const registerValueText = () => {
  3699. const width = 74;
  3700. const height = 24;
  3701. const shape = "value-text";
  3702. nodeSize[shape] = {
  3703. width: width,
  3704. height: height
  3705. };
  3706. const option = {
  3707. width: width,
  3708. height: height,
  3709. markup: [
  3710. {
  3711. tagName: 'rect',
  3712. selector: 'rect',
  3713. },
  3714. {
  3715. tagName: 'text',
  3716. selector: 'label',
  3717. },
  3718. ],
  3719. attrs: {
  3720. rect: {
  3721. width: width,
  3722. height: height,
  3723. x: 0,
  3724. y: 0,
  3725. fill: "#536268",
  3726. opacity: 0.2,
  3727. stroke: "transparent",
  3728. },
  3729. label: {
  3730. fill: '#059C40',
  3731. fontSize: fontsize,
  3732. refX: 37,
  3733. refY: 6,
  3734. "text-anchor": "middle"
  3735. },
  3736. },
  3737. };
  3738. Graph.registerNode(shape, option, true);
  3739. }
  3740. // 注册自定义节点
  3741. const register = () => {
  3742. registerRootNode();
  3743. registerCircuitBreakerVerticalBreak();
  3744. registerLongCircuitBreakerVerticalBreak();
  3745. registerLongCircuitBreakerVerticalLink();
  3746. registerEarthingDisconnectorTransverseBreak();
  3747. registerEarthingDisconnectorTransverse2Break();
  3748. registerEarthingDisconnectorVerticalBreak();
  3749. registerArrowVertical();
  3750. registerLineVertical();
  3751. registerReactorVertical();
  3752. registerCapacitanceVertical();
  3753. registerResistanceVertical();
  3754. registerVoltageTransformer();
  3755. registerGroundingTransformer();
  3756. registerGroundingCapacitanceTransverse();
  3757. registerVoltage3Transformer();
  3758. registerVoltage5Transformer();
  3759. registerGroundingResistanceVertical();
  3760. registerThreePhaseTransformer();
  3761. registerEarthingDisconnectorTransverseYBreak();
  3762. registerMainTransformer();
  3763. registerMainTransformer1();
  3764. registerMainTransformer2();
  3765. registerMainTransformer3();
  3766. registerSwitchBreak();
  3767. registerSwitchClose();
  3768. registerHandcart00();
  3769. registerHandcart01();
  3770. registerHandcart10();
  3771. registerHandcart11();
  3772. registerEarthingDisconnectorTransverseYoBreak();
  3773. registerTagText();
  3774. registerFormText();
  3775. registerLabelText();
  3776. registerValueText();
  3777. registerTagTexts();
  3778. }
  3779. export default {
  3780. register: register,
  3781. nodeSize: nodeSize,
  3782. weight: weight,
  3783. fontsize: fontsize,
  3784. }