mxPidValves.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  1. /**
  2. * $Id: mxPidValves.js,v 1.5 2013/10/22 12:55:55 mate Exp $
  3. * Copyright (c) 2006-2013, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. //Valve
  7. //**********************************************************************************************************************************************************
  8. /**
  9. * Extends mxShape.
  10. */
  11. function mxShapePidValve(bounds, fill, stroke, strokewidth)
  12. {
  13. mxShape.call(this);
  14. this.bounds = bounds;
  15. this.fill = fill;
  16. this.stroke = stroke;
  17. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  18. };
  19. /**
  20. * Extends mxShape.
  21. */
  22. mxUtils.extend(mxShapePidValve, mxShape);
  23. mxShapePidValve.prototype.cst = {
  24. SHAPE_VALVE : 'mxgraph.pid2valves.valve',
  25. //states
  26. DEFAULT_STATE : 'defState',
  27. CLOSED : 'closed',
  28. OPEN : 'open',
  29. //actuators
  30. ACTUATOR : 'actuator',
  31. MANUAL : 'man',
  32. DIAPHRAGM : 'diaph',
  33. BALANCED_DIAPHRAGM : 'balDiaph',
  34. MOTOR : 'motor',
  35. NONE : 'none',
  36. SPRING : 'spring',
  37. PILOT : 'pilot',
  38. SOLENOID : 'solenoid',
  39. SOLENOID_MANUAL_RESET : 'solenoidManRes',
  40. SINGLE_ACTING : 'singActing',
  41. DOUBLE_ACTING : 'dblActing',
  42. PILOT_CYLINDER : 'pilotCyl',
  43. DIGITAL : 'digital',
  44. WEIGHT : 'weight',
  45. KEY : 'key',
  46. ELECTRO_HYDRAULIC : 'elHyd',
  47. //types
  48. VALVE_TYPE : 'valveType',
  49. BUTTERFLY : 'butterfly',
  50. CHECK : 'check',
  51. GATE : 'gate',
  52. GLOBE : 'globe',
  53. NEEDLE : 'needle',
  54. PLUG : 'plug',
  55. SELF_DRAINING : 'selfDrain',
  56. ANGLE : 'angle',
  57. ANGLE_GLOBE : 'angleGlobe',
  58. THREE_WAY : 'threeWay',
  59. ANGLE_BLOWDOWN : 'angBlow',
  60. BALL : 'ball'
  61. };
  62. /**
  63. * Function: paintVertexShape
  64. *
  65. * Paints the vertex shape.
  66. */
  67. mxShapePidValve.prototype.paintVertexShape = function(c, x, y, w, h)
  68. {
  69. var valveType = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.VALVE_TYPE, 'gate');
  70. var actuator = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.ACTUATOR, mxShapePidValve.prototype.cst.NONE);
  71. var actH = 0;
  72. if (actuator !== 'none')
  73. {
  74. if (this.isAngleVariant(valveType))
  75. {
  76. actH = h * 0.3333;
  77. }
  78. else
  79. {
  80. actH = h * 0.4;
  81. }
  82. }
  83. c.translate(x, y);
  84. c.setLineJoin('round');
  85. this.background(c, x, y, w, h, valveType, actuator, actH);
  86. c.setShadow(false);
  87. this.foreground(c, x, y, w, h, valveType, actuator, actH);
  88. };
  89. mxShapePidValve.prototype.background = function(c, x, y, w, h, valveType, actuator, actH)
  90. {
  91. //draw the actuator
  92. if (actuator !== mxShapePidValve.prototype.cst.NONE)
  93. {
  94. if (this.isAngleVariant(valveType))
  95. {
  96. this.drawActuatorBg(c, x, y, w, h / 1.2, actuator, actH);
  97. }
  98. else
  99. {
  100. this.drawActuatorBg(c, x, y, w, h, actuator, actH);
  101. }
  102. }
  103. //draw the valve body
  104. if (this.isGateVariant(valveType))
  105. {
  106. this.drawGateVariantBg(c, 0, 0, w, h, valveType, actuator, actH);
  107. }
  108. else if (this.isAngleVariant(valveType))
  109. {
  110. this.drawAngleVariantBg(c, 0, 0, w, h, valveType, actuator, actH);
  111. }
  112. else if (valveType === mxShapePidValve.prototype.cst.BUTTERFLY)
  113. {
  114. this.drawButterflyValve(c, 0, 0, w, h, actuator, actH);
  115. }
  116. else if (valveType === mxShapePidValve.prototype.cst.CHECK)
  117. {
  118. this.drawCheckValve(c, 0, 0, w, h, actuator, actH);
  119. }
  120. };
  121. mxShapePidValve.prototype.foreground = function(c, x, y, w, h, valveType, actuator, actH)
  122. {
  123. var valveType = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.VALVE_TYPE, 'gate');
  124. //draw the actuator
  125. if (actuator !== mxShapePidValve.prototype.cst.NONE)
  126. {
  127. if (this.isAngleVariant(valveType))
  128. {
  129. this.drawActuatorFg(c, x, y, w, h / 1.2, actuator, actH);
  130. }
  131. else
  132. {
  133. this.drawActuatorFg(c, x, y, w, h, actuator, actH);
  134. }
  135. }
  136. if (this.isGateVariant(valveType))
  137. {
  138. this.drawGateVariantFg(c, 0, 0, w, h, valveType, actuator, actH);
  139. }
  140. if (this.isAngleVariant(valveType))
  141. {
  142. this.drawAngleVariantFg(c, 0, 0, w, h, valveType, actuator, actH);
  143. }
  144. };
  145. mxShapePidValve.prototype.drawActuatorBg = function(c, x, y, w, h, actuator)
  146. {
  147. if (this.isSquareVariant(actuator))
  148. {
  149. c.translate(w * 0.325, 0);
  150. this.drawSquareAct(c, w * 0.35, h * 0.7, actuator);
  151. c.translate(- w * 0.325, 0);
  152. }
  153. else if (actuator === mxShapePidValve.prototype.cst.MANUAL)
  154. {
  155. c.translate(w * 0.25, h * 0.15);
  156. this.drawManAct(c, w * 0.5, h * 0.55);
  157. c.translate(- w * 0.25, - h * 0.15);
  158. }
  159. else if (actuator === mxShapePidValve.prototype.cst.DIAPHRAGM)
  160. {
  161. c.translate(w * 0.25, h * 0.1);
  162. this.drawDiaphAct(c, w * 0.5, h * 0.6);
  163. c.translate(- w * 0.25, - h * 0.1);
  164. }
  165. else if (actuator === mxShapePidValve.prototype.cst.BALANCED_DIAPHRAGM)
  166. {
  167. c.translate(w * 0.25, h * 0.1);
  168. this.drawBalDiaphActBg(c, w * 0.5, h * 0.6);
  169. c.translate(- w * 0.25, - h * 0.1);
  170. }
  171. else if (actuator === mxShapePidValve.prototype.cst.MOTOR || actuator === mxShapePidValve.prototype.cst.ELECTRO_HYDRAULIC)
  172. {
  173. c.translate(w * 0.325, 0);
  174. this.drawCircleAct(c, w * 0.35, h * 0.7, actuator);
  175. c.translate(- w * 0.325, 0);
  176. }
  177. else if (actuator === mxShapePidValve.prototype.cst.SPRING)
  178. {
  179. c.translate(w * 0.36, 0);
  180. this.drawSpringAct(c, w * 0.28, h * 0.7);
  181. c.translate(- w * 0.36, 0);
  182. }
  183. else if (actuator === mxShapePidValve.prototype.cst.SOLENOID_MANUAL_RESET)
  184. {
  185. c.translate(w * 0.325, 0);
  186. this.drawSolenoidManResetAct(c, w * 0.575, h * 0.7);
  187. c.translate(- w * 0.325, 0);
  188. }
  189. else if (actuator === mxShapePidValve.prototype.cst.SINGLE_ACTING)
  190. {
  191. c.translate(w * 0.35, 0);
  192. this.drawSingActingActBg(c, w * 0.65, h * 0.7);
  193. c.translate(- w * 0.35, 0);
  194. }
  195. else if (actuator === mxShapePidValve.prototype.cst.DOUBLE_ACTING)
  196. {
  197. c.translate(w * 0.35, 0);
  198. this.drawDblActingActBg(c, w * 0.65, h * 0.7);
  199. c.translate(- w * 0.35, 0);
  200. }
  201. else if (actuator === mxShapePidValve.prototype.cst.PILOT_CYLINDER)
  202. {
  203. c.translate(w * 0.35, 0);
  204. this.drawPilotCylinderActBg(c, w * 0.65, h * 0.7);
  205. c.translate(- w * 0.35, 0);
  206. }
  207. else if (actuator === mxShapePidValve.prototype.cst.ANGLE_BLOWDOWN)
  208. {
  209. c.translate(w * 0.5, h * 0.2);
  210. this.drawAngleBlowdownAct(c, w * 0.4, h * 0.5);
  211. c.translate(- w * 0.5, - h * 0.2);
  212. }
  213. };
  214. mxShapePidValve.prototype.drawActuatorFg = function(c, x, y, w, h, actuator)
  215. {
  216. if (actuator === mxShapePidValve.prototype.cst.BALANCED_DIAPHRAGM)
  217. {
  218. c.translate(w * 0.25, h * 0.1);
  219. this.drawBalDiaphActFg(c, w * 0.5, h * 0.6);
  220. c.translate(- w * 0.25, - h * 0.1);
  221. }
  222. else if (actuator === mxShapePidValve.prototype.cst.SINGLE_ACTING ||
  223. actuator === mxShapePidValve.prototype.cst.DOUBLE_ACTING ||
  224. actuator === mxShapePidValve.prototype.cst.PILOT_CYLINDER)
  225. {
  226. c.translate(w * 0.35, 0);
  227. this.drawActingActFg(c, w * 0.65, h * 0.7);
  228. c.translate(- w * 0.35, 0);
  229. }
  230. };
  231. mxShapePidValve.prototype.drawManAct = function(c, w, h)
  232. {
  233. c.begin();
  234. c.moveTo(0, 0);
  235. c.lineTo(w, 0);
  236. c.moveTo(w * 0.5, 0);
  237. c.lineTo(w * 0.5, h);
  238. c.stroke();
  239. };
  240. mxShapePidValve.prototype.drawDiaphAct = function(c, w, h)
  241. {
  242. c.begin();
  243. c.moveTo(w * 0.5, h * 0.2);
  244. c.lineTo(w * 0.5, h);
  245. c.stroke();
  246. c.moveTo(0, h * 0.2);
  247. c.arcTo(w * 0.6, h * 0.4, 0, 0, 1, w, h * 0.2);
  248. c.close();
  249. c.fillAndStroke();
  250. };
  251. mxShapePidValve.prototype.drawBalDiaphActBg = function(c, w, h)
  252. {
  253. c.ellipse(0, 0, w, h * 0.3);
  254. c.fillAndStroke();
  255. c.begin();
  256. c.moveTo(w * 0.5, h * 0.3);
  257. c.lineTo(w * 0.5, h);
  258. c.stroke();
  259. };
  260. mxShapePidValve.prototype.drawBalDiaphActFg = function(c, w, h)
  261. {
  262. c.begin();
  263. c.moveTo(0, h * 0.15);
  264. c.lineTo(w, h * 0.15);
  265. c.stroke();
  266. };
  267. mxShapePidValve.prototype.drawCircleAct = function(c, w, h, actuator)
  268. {
  269. c.ellipse(0, 0, w, h * 0.5);
  270. c.fillAndStroke();
  271. c.begin();
  272. c.moveTo(w * 0.5, h * 0.5);
  273. c.lineTo(w * 0.5, h);
  274. c.stroke();
  275. var m = '';
  276. if (actuator === mxShapePidValve.prototype.cst.MOTOR)
  277. {
  278. m = 'M';
  279. }
  280. else if (actuator === mxShapePidValve.prototype.cst.ELECTRO_HYDRAULIC)
  281. {
  282. m = 'E/H';
  283. }
  284. c.setFontStyle(1);
  285. c.setFontFamily('Helvetica');
  286. c.setFontSize(Math.min(w, h) * 0.4);
  287. c.text(w * 0.5, h * 0.25, 0, 0, m, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  288. };
  289. mxShapePidValve.prototype.drawSpringAct = function(c, w, h)
  290. {
  291. c.begin();
  292. c.moveTo(w * 0.5, 0);
  293. c.lineTo(w * 0.5, h);
  294. c.moveTo(w * 0.32, h * 0.16);
  295. c.lineTo(w * 0.68, h * 0.08);
  296. c.moveTo(w * 0.21, h * 0.32);
  297. c.lineTo(w * 0.79, h * 0.20);
  298. c.moveTo(w * 0.1, h * 0.52);
  299. c.lineTo(w * 0.9, h * 0.36);
  300. c.moveTo(0, h * 0.72);
  301. c.lineTo(w, h * 0.5);
  302. c.stroke();
  303. };
  304. mxShapePidValve.prototype.drawSolenoidManResetAct = function(c, w, h)
  305. {
  306. c.rect(0, 0, w * 0.61, h * 0.46);
  307. c.fillAndStroke();
  308. c.begin();
  309. c.moveTo(w * 0.56, h * 0.6);
  310. c.lineTo(w * 0.78, h * 0.5);
  311. c.lineTo(w, h * 0.6);
  312. c.lineTo(w * 0.78, h * 0.7);
  313. c.close();
  314. c.fillAndStroke();
  315. c.begin();
  316. c.moveTo(w * 0.305, h * 0.46);
  317. c.lineTo(w * 0.305, h);
  318. c.moveTo(w * 0.305, h * 0.6);
  319. c.lineTo(w * 0.56, h * 0.6);
  320. c.stroke();
  321. c.setFontStyle(1);
  322. c.setFontFamily('Helvetica');
  323. c.setFontSize(Math.min(w, h) * 0.4);
  324. c.text(w * 0.305, h * 0.23, 0, 0, 'S', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  325. c.setFontStyle(0);
  326. c.setFontSize(Math.min(w, h) * 0.15);
  327. c.text(w * 0.78, h * 0.6, 0, 0, 'R', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  328. };
  329. mxShapePidValve.prototype.drawSingActingActBg = function(c, w, h)
  330. {
  331. c.rect(0, 0, w * 0.46, h * 0.46);
  332. c.fillAndStroke();
  333. c.begin();
  334. c.moveTo(w * 0.23, h * 0.46);
  335. c.lineTo(w * 0.23, h);
  336. c.moveTo(w * 0.46, h * 0.23);
  337. c.lineTo(w, h * 0.23);
  338. c.moveTo(w * 0.77, h * 0.15);
  339. c.lineTo(w * 0.69, h * 0.31);
  340. c.moveTo(w * 0.82, h * 0.15);
  341. c.lineTo(w * 0.74, h * 0.31);
  342. c.stroke();
  343. };
  344. mxShapePidValve.prototype.drawActingActFg = function(c, w, h)
  345. {
  346. c.begin();
  347. c.moveTo(w * 0.23, h * 0.23);
  348. c.lineTo(w * 0.23, h * 0.46);
  349. c.moveTo(0, h * 0.23);
  350. c.lineTo(w * 0.46, h * 0.23);
  351. c.stroke();
  352. };
  353. mxShapePidValve.prototype.drawDblActingActBg = function(c, w, h)
  354. {
  355. c.rect(0, 0, w * 0.46, h * 0.46);
  356. c.fillAndStroke();
  357. c.begin();
  358. c.moveTo(w * 0.23, h * 0.46);
  359. c.lineTo(w * 0.23, h);
  360. c.moveTo(w * 0.46, h * 0.115);
  361. c.lineTo(w, h * 0.115);
  362. c.moveTo(w * 0.77, h * 0.035);
  363. c.lineTo(w * 0.69, h * 0.195);
  364. c.moveTo(w * 0.82, h * 0.035);
  365. c.lineTo(w * 0.74, h * 0.195);
  366. c.moveTo(w * 0.46, h * 0.345);
  367. c.lineTo(w, h * 0.345);
  368. c.moveTo(w * 0.77, h * 0.265);
  369. c.lineTo(w * 0.69, h * 0.425);
  370. c.moveTo(w * 0.82, h * 0.265);
  371. c.lineTo(w * 0.74, h * 0.425);
  372. c.stroke();
  373. };
  374. mxShapePidValve.prototype.drawPilotCylinderActBg = function(c, w, h)
  375. {
  376. c.rect(0, 0, w * 0.46, h * 0.46);
  377. c.fillAndStroke();
  378. c.begin();
  379. c.moveTo(w * 0.23, h * 0.46);
  380. c.lineTo(w * 0.23, h);
  381. c.moveTo(w * 0.46, h * 0.23);
  382. c.lineTo(w * 0.77, h * 0.23);
  383. c.stroke();
  384. c.rect(w * 0.77, h * 0.115, w * 0.23, h * 0.23);
  385. c.fillAndStroke();
  386. c.setFontStyle(0);
  387. c.setFontFamily('Helvetica');
  388. c.setFontSize(Math.min(w, h) * 0.15);
  389. c.text(w * 0.885, h * 0.23, 0, 0, 'P', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  390. };
  391. mxShapePidValve.prototype.drawAngleBlowdownAct = function(c, w, h)
  392. {
  393. c.begin();
  394. c.moveTo(w * 0.34, 0);
  395. c.lineTo(w, h * 0.405);
  396. c.moveTo(0, h);
  397. c.lineTo(w * 0.665, h * 0.205);
  398. c.stroke();
  399. };
  400. mxShapePidValve.prototype.drawSquareAct = function(c, w, h, actuator)
  401. {
  402. c.rect(0, 0, w, h * 0.5);
  403. c.fillAndStroke();
  404. c.begin();
  405. c.moveTo(w * 0.5, h * 0.5);
  406. c.lineTo(w * 0.5, h);
  407. c.stroke();
  408. var m = '';
  409. if (actuator === mxShapePidValve.prototype.cst.PILOT)
  410. {
  411. m = 'P';
  412. }
  413. else if (actuator === mxShapePidValve.prototype.cst.SOLENOID)
  414. {
  415. m = 'S';
  416. }
  417. else if (actuator === mxShapePidValve.prototype.cst.DIGITAL)
  418. {
  419. m = 'D';
  420. }
  421. else if (actuator === mxShapePidValve.prototype.cst.WEIGHT)
  422. {
  423. m = 'W';
  424. }
  425. else if (actuator === mxShapePidValve.prototype.cst.KEY)
  426. {
  427. m = 'K';
  428. }
  429. c.setFontStyle(1);
  430. c.setFontFamily('Helvetica');
  431. c.setFontSize(Math.min(w, h) * 0.4);
  432. c.text(w * 0.5, h * 0.25, 0, 0, m, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  433. };
  434. mxShapePidValve.prototype.drawGateVariantFg = function(c, x, y, w, h, valveType, actuator, actH)
  435. {
  436. var defState = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.DEFAULT_STATE, 'open');
  437. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  438. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  439. if (valveType === mxShapePidValve.prototype.cst.BALL)
  440. {
  441. c.ellipse(x + w * 0.3, y + actH + (h - actH) * 0.18, w * 0.4, (h - actH) * 0.64);
  442. c.fillAndStroke();
  443. }
  444. else if (valveType === mxShapePidValve.prototype.cst.GLOBE)
  445. {
  446. c.ellipse(x + w * 0.3, y + actH + (h - actH) * 0.18, w * 0.4, (h - actH) * 0.64);
  447. c.setFillColor(strokeColor);
  448. c.fillAndStroke();
  449. c.setFillColor(fillColor);
  450. }
  451. else if (valveType === mxShapePidValve.prototype.cst.PLUG)
  452. {
  453. this.drawPlug(c, x + w * 0.4, y + actH + (h - actH) * 0.25, w * 0.2, (h - actH) * 0.5);
  454. }
  455. else if (valveType === mxShapePidValve.prototype.cst.NEEDLE)
  456. {
  457. this.drawNeedle(c, x + w * 0.45, y + actH + (h - actH) * 0.1, w * 0.1, (h - actH) * 0.9);
  458. }
  459. else if (valveType === mxShapePidValve.prototype.cst.SELF_DRAINING)
  460. {
  461. this.drawDrain(c, x + w * 0.48, y + actH + (h - actH) * 0.5, w * 0.04, (h - actH) * 0.49);
  462. }
  463. };
  464. mxShapePidValve.prototype.drawAngleVariantFg = function(c, x, y, w, h, valveType, actuator, actH)
  465. {
  466. var defState = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.DEFAULT_STATE, 'open');
  467. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  468. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  469. if (valveType === mxShapePidValve.prototype.cst.ANGLE_GLOBE)
  470. {
  471. if (actuator === 'none')
  472. {
  473. c.ellipse(w * 0.34, h * 0.175, w * 0.32, h * 0.4);
  474. }
  475. else
  476. {
  477. c.ellipse(w * 0.34, h * 0.45, w * 0.32, h * 0.2667);
  478. }
  479. c.setFillColor(strokeColor);
  480. c.fillAndStroke();
  481. c.setFillColor(fillColor);
  482. }
  483. };
  484. mxShapePidValve.prototype.drawGateVariantBg = function(c, x, y, w, h, valveType, actuator, actH)
  485. {
  486. if (valveType === mxShapePidValve.prototype.cst.GATE)
  487. {
  488. this.drawGateValve(c, x, y + actH, w, h - actH);
  489. }
  490. else if (valveType === mxShapePidValve.prototype.cst.BALL || valveType === mxShapePidValve.prototype.cst.GLOBE)
  491. {
  492. c.ellipse(x + w * 0.3, y + actH + (h - actH) * 0.18, w * 0.4, (h - actH) * 0.64);
  493. c.fillAndStroke();
  494. this.drawGateValve(c, x, y + actH, w, h - actH);
  495. }
  496. else if (valveType === mxShapePidValve.prototype.cst.PLUG)
  497. {
  498. this.drawPlug(c, x + w * 0.4, y + actH + (h - actH) * 0.25, w * 0.2, (h - actH) * 0.5);
  499. this.drawGateValve(c, x, y + actH, w, h - actH);
  500. }
  501. else if (valveType === mxShapePidValve.prototype.cst.NEEDLE)
  502. {
  503. this.drawNeedle(c, x + w * 0.45, y + actH + (h - actH) * 0.1, w * 0.1, (h - actH) * 0.9);
  504. this.drawGateValve(c, x, y + actH, w, h - actH);
  505. }
  506. else if (valveType === mxShapePidValve.prototype.cst.SELF_DRAINING)
  507. {
  508. this.drawDrain(c, x + w * 0.48, y + actH + (h - actH) * 0.5, w * 0.04, (h - actH) * 0.49);
  509. this.drawGateValve(c, x, y + actH, w, h - actH);
  510. }
  511. };
  512. mxShapePidValve.prototype.drawAngleVariantBg = function(c, x, y, w, h, valveType, actuator, actH)
  513. {
  514. if (valveType === mxShapePidValve.prototype.cst.ANGLE)
  515. {
  516. this.drawAngleValve(c, w * 0.2, y + actH, w * 0.8, h - actH);
  517. }
  518. else if (valveType === mxShapePidValve.prototype.cst.ANGLE_GLOBE)
  519. {
  520. this.drawAngleGlobeValveBg(c, w * 0.2, y + actH, w * 0.8, h - actH);
  521. }
  522. else if (valveType === mxShapePidValve.prototype.cst.THREE_WAY)
  523. {
  524. this.drawThreeWayValve(c, 0, y + actH, w, h - actH);
  525. }
  526. else if (valveType === mxShapePidValve.prototype.cst.ANGLE_BLOWDOWN)
  527. {
  528. this.drawAngleBlowdownValve(c, x, y + actH, w, h - actH);
  529. }
  530. };
  531. mxShapePidValve.prototype.drawPlug = function(c, x, y, w, h)
  532. {
  533. c.translate(x, y);
  534. c.begin();
  535. c.moveTo(0, h * 0.5);
  536. c.lineTo(w * 0.5, 0);
  537. c.lineTo(w, h * 0.5);
  538. c.lineTo(w * 0.5, h);
  539. c.close();
  540. c.fillAndStroke();
  541. c.translate(-x, -y);
  542. };
  543. mxShapePidValve.prototype.drawNeedle = function(c, x, y, w, h)
  544. {
  545. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  546. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  547. c.translate(x, y);
  548. c.begin();
  549. c.moveTo(0, 0);
  550. c.lineTo(w, 0);
  551. c.lineTo(w * 0.5, h);
  552. c.close();
  553. c.setFillColor(strokeColor);
  554. c.fillAndStroke();
  555. c.setFillColor(fillColor);
  556. c.translate(-x, -y);
  557. };
  558. mxShapePidValve.prototype.drawDrain = function(c, x, y, w, h)
  559. {
  560. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  561. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  562. c.translate(x, y);
  563. c.begin();
  564. c.moveTo(w * 0.5, 0);
  565. c.lineTo(w * 0.5, h * 0.96);
  566. c.stroke();
  567. c.begin();
  568. c.moveTo(0, h * 0.9);
  569. c.lineTo(w, h * 0.9);
  570. c.lineTo(w * 0.5, h);
  571. c.close();
  572. c.setFillColor(strokeColor);
  573. c.fillAndStroke();
  574. c.setFillColor(fillColor);
  575. c.translate(-x, -y);
  576. };
  577. mxShapePidValve.prototype.drawGateValve = function(c, x, y, w, h)
  578. {
  579. var defState = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.DEFAULT_STATE, 'open');
  580. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  581. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  582. c.translate(x, y);
  583. c.begin();
  584. c.moveTo(0, 0);
  585. c.lineTo(w * 0.5, h * 0.5);
  586. c.lineTo(0, h);
  587. c.close();
  588. c.moveTo(w, 0);
  589. c.lineTo(w * 0.5, h * 0.5);
  590. c.lineTo(w, h);
  591. c.close();
  592. if (defState === mxShapePidValve.prototype.cst.CLOSED)
  593. {
  594. c.setFillColor(strokeColor);
  595. c.fillAndStroke();
  596. c.setFillColor(fillColor);
  597. }
  598. else
  599. {
  600. c.fillAndStroke();
  601. }
  602. c.translate(-x, -y);
  603. };
  604. mxShapePidValve.prototype.drawAngleValve = function(c, x, y, w, h)
  605. {
  606. c.translate(x, y);
  607. c.begin();
  608. c.moveTo(w * 0.375, h * 0.375);
  609. c.lineTo(w, 0);
  610. c.lineTo(w, h * 0.75);
  611. c.close();
  612. c.moveTo(w * 0.375, h * 0.375);
  613. c.lineTo(w * 0.75, h);
  614. c.lineTo(0, h);
  615. c.close();
  616. c.fillAndStroke();
  617. c.translate(-x, -y);
  618. };
  619. mxShapePidValve.prototype.drawAngleGlobeValveBg = function(c, x, y, w, h)
  620. {
  621. c.translate(x, y);
  622. c.ellipse(w * 0.175, h * 0.175, w * 0.4, h * 0.4);
  623. c.fillAndStroke();
  624. c.begin();
  625. c.moveTo(w * 0.375, h * 0.375);
  626. c.lineTo(w, 0);
  627. c.lineTo(w, h * 0.75);
  628. c.close();
  629. c.moveTo(w * 0.375, h * 0.375);
  630. c.lineTo(w * 0.75, h);
  631. c.lineTo(0, h);
  632. c.close();
  633. c.fillAndStroke();
  634. c.translate(-x, -y);
  635. };
  636. mxShapePidValve.prototype.drawAngleGlobeValveFg = function(c, x, y, w, h)
  637. {
  638. c.translate(x, y);
  639. c.ellipse(w * 0.275, h * 0.275, w * 0.2, h * 0.2);
  640. c.fillAndStroke();
  641. c.translate(-x, -y);
  642. };
  643. mxShapePidValve.prototype.drawThreeWayValve = function(c, x, y, w, h)
  644. {
  645. c.translate(x, y);
  646. c.begin();
  647. c.moveTo(0, 0);
  648. c.lineTo(w * 0.5, h * 0.375);
  649. c.lineTo(0, h * 0.75);
  650. c.close();
  651. c.moveTo(w, 0);
  652. c.lineTo(w * 0.5, h * 0.375);
  653. c.lineTo(w, h * 0.75);
  654. c.close();
  655. c.moveTo(w * 0.5, h * 0.375);
  656. c.lineTo(w * 0.8, h);
  657. c.lineTo(w * 0.2, h);
  658. c.close();
  659. c.fillAndStroke();
  660. c.translate(-x, -y);
  661. };
  662. mxShapePidValve.prototype.drawAngleBlowdownValve = function(c, x, y, w, h)
  663. {
  664. };
  665. mxShapePidValve.prototype.drawButterflyValve = function(c, x, y, w, h, actuator, actH)
  666. {
  667. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  668. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  669. var yv = y + actH;
  670. var hv = h - actH;
  671. c.translate(x, yv);
  672. c.begin();
  673. c.moveTo(0, 0);
  674. c.lineTo(0, hv);
  675. c.moveTo(w, 0);
  676. c.lineTo(w, hv);
  677. c.moveTo(w * 0.05, hv * 0.05);
  678. c.lineTo(w * 0.95, hv * 0.95);
  679. c.fillAndStroke();
  680. c.ellipse(w * 0.4, hv * 0.33, w * 0.2, hv * 0.33);
  681. c.fillAndStroke();
  682. c.translate(-x, -y);
  683. };
  684. mxShapePidValve.prototype.drawCheckValve = function(c, x, y, w, h, actuator, actH)
  685. {
  686. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  687. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  688. var yv = y + actH;
  689. var hv = h - actH;
  690. c.translate(x, yv);
  691. c.begin();
  692. c.moveTo(0, 0);
  693. c.lineTo(0, hv);
  694. c.moveTo(w, 0);
  695. c.lineTo(w, hv);
  696. c.moveTo(w * 0.05, hv * 0.05);
  697. c.lineTo(w * 0.95, hv * 0.95);
  698. c.fillAndStroke();
  699. c.begin();
  700. c.moveTo(w * 0.8925, hv * 0.815);
  701. c.lineTo(w * 0.957, hv * 0.955);
  702. c.lineTo(w * 0.85, hv * 0.928);
  703. c.close();
  704. c.setFillColor(strokeColor);
  705. c.fillAndStroke();
  706. c.setFillColor(fillColor);
  707. c.translate(-x, -y);
  708. };
  709. mxShapePidValve.prototype.isGateVariant = function(valveType)
  710. {
  711. if (valveType === mxShapePidValve.prototype.cst.GATE ||
  712. valveType === mxShapePidValve.prototype.cst.BALL ||
  713. valveType === mxShapePidValve.prototype.cst.PLUG ||
  714. valveType === mxShapePidValve.prototype.cst.NEEDLE ||
  715. valveType === mxShapePidValve.prototype.cst.SELF_DRAINING ||
  716. valveType === mxShapePidValve.prototype.cst.GLOBE)
  717. {
  718. return true;
  719. }
  720. else
  721. {
  722. return false;
  723. }
  724. };
  725. mxShapePidValve.prototype.isAngleVariant = function(valveType)
  726. {
  727. if (valveType === mxShapePidValve.prototype.cst.ANGLE ||
  728. valveType === mxShapePidValve.prototype.cst.ANGLE_GLOBE ||
  729. valveType === mxShapePidValve.prototype.cst.THREE_WAY ||
  730. valveType === mxShapePidValve.prototype.cst.ANGLE_BLOWDOWN)
  731. {
  732. return true;
  733. }
  734. else
  735. {
  736. return false;
  737. }
  738. };
  739. mxShapePidValve.prototype.isSquareVariant = function(actType)
  740. {
  741. if (actType === mxShapePidValve.prototype.cst.PILOT ||
  742. actType === mxShapePidValve.prototype.cst.SOLENOID ||
  743. actType === mxShapePidValve.prototype.cst.DIGITAL ||
  744. actType === mxShapePidValve.prototype.cst.WEIGHT ||
  745. actType === mxShapePidValve.prototype.cst.KEY)
  746. {
  747. return true;
  748. }
  749. else
  750. {
  751. return false;
  752. }
  753. };
  754. mxCellRenderer.prototype.defaultShapes[mxShapePidValve.prototype.cst.SHAPE_VALVE] = mxShapePidValve;
  755. //**********************************************************************************************************************************************************
  756. //Integrated Block And Bleed Valve
  757. //**********************************************************************************************************************************************************
  758. /**
  759. * Extends mxShape.
  760. */
  761. function mxShapePidIntBlockBleedValve(bounds, fill, stroke, strokewidth)
  762. {
  763. mxShape.call(this);
  764. this.bounds = bounds;
  765. this.fill = fill;
  766. this.stroke = stroke;
  767. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  768. };
  769. /**
  770. * Extends mxShapePidValve.
  771. */
  772. mxUtils.extend(mxShapePidIntBlockBleedValve, mxShapePidValve);
  773. /**
  774. * Function: paintVertexShape
  775. *
  776. * Paints the vertex shape.
  777. */
  778. mxShapePidIntBlockBleedValve.prototype.paintVertexShape = function(c, x, y, w, h)
  779. {
  780. var actuator = mxUtils.getValue(this.style, mxShapePidIntBlockBleedValve.prototype.cst.ACTUATOR, mxShapePidIntBlockBleedValve.prototype.cst.NONE);
  781. var actH = 0;
  782. if (actuator !== 'none')
  783. {
  784. actH = h * 0.2353;
  785. }
  786. c.translate(x, y);
  787. c.setLineJoin('round');
  788. this.background(c, x, y, w, h, actuator, actH);
  789. c.setShadow(false);
  790. this.foreground(c, x, y, w, h, actuator, actH);
  791. };
  792. mxShapePidIntBlockBleedValve.prototype.background = function(c, x, y, w, h, actuator, actH)
  793. {
  794. //draw the actuator
  795. if (actuator !== mxShapePidIntBlockBleedValve.prototype.cst.NONE)
  796. {
  797. this.drawActuatorBg(c, x, y, w, h, actuator);
  798. }
  799. //draw the valve body
  800. this.drawValveBg(c, 0, actH, w, h - actH);
  801. };
  802. mxShapePidIntBlockBleedValve.prototype.foreground = function(c, x, y, w, h, actuator, actH)
  803. {
  804. //draw the actuator
  805. if (actuator !== mxShapePidIntBlockBleedValve.prototype.cst.NONE)
  806. {
  807. this.drawActuatorFg(c, x, y, w, h, actuator);
  808. }
  809. };
  810. mxShapePidIntBlockBleedValve.prototype.drawValveBg = function(c, x, y, w, h)
  811. {
  812. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  813. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  814. c.translate(x, y);
  815. c.begin();
  816. c.moveTo(0, 0);
  817. c.lineTo(w * 0.5, h * 0.23);
  818. c.lineTo(0, h * 0.46);
  819. c.close();
  820. c.moveTo(w * 0.5, h * 0.23);
  821. c.lineTo(w, 0);
  822. c.lineTo(w, h * 0.46);
  823. c.close();
  824. c.fillAndStroke();
  825. c.begin();
  826. c.moveTo(w * 0.5, h * 0.23);
  827. c.lineTo(w * 0.5, h * 0.5);
  828. c.stroke();
  829. c.setFillColor(strokeColor);
  830. c.begin();
  831. c.moveTo(w * 0.3, h * 0.5);
  832. c.lineTo(w * 0.7, h * 0.5);
  833. c.lineTo(w * 0.5, h * 0.75);
  834. c.close();
  835. c.fillAndStroke();
  836. c.begin();
  837. c.moveTo(w * 0.3, h);
  838. c.lineTo(w * 0.5, h * 0.75);
  839. c.lineTo(w * 0.7, h);
  840. c.fillAndStroke();
  841. c.setFillColor(fillColor);
  842. c.translate(-x, -y);
  843. };
  844. mxShapePidIntBlockBleedValve.prototype.drawActuatorBg = function(c, x, y, w, h, actuator)
  845. {
  846. if (this.isSquareVariant(actuator))
  847. {
  848. c.translate(w * 0.325, 0);
  849. this.drawSquareAct(c, w * 0.35, h * 0.4112, actuator);
  850. c.translate(- w * 0.325, 0);
  851. }
  852. else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.MANUAL)
  853. {
  854. c.translate(w * 0.25, h * 0.0882);
  855. this.drawManAct(c, w * 0.5, h * 0.323);
  856. c.translate(- w * 0.25, - h * 0.0882);
  857. }
  858. else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.DIAPHRAGM)
  859. {
  860. c.translate(w * 0.25, h * 0.0588);
  861. this.drawDiaphAct(c, w * 0.5, h * 0.3524);
  862. c.translate(- w * 0.25, - h * 0.0588);
  863. }
  864. else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.BALANCED_DIAPHRAGM)
  865. {
  866. c.translate(w * 0.25, h * 0.0588);
  867. this.drawBalDiaphActBg(c, w * 0.5, h * 0.3524);
  868. c.translate(- w * 0.25, - h * 0.0588);
  869. }
  870. else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.MOTOR || actuator === mxShapePidIntBlockBleedValve.prototype.cst.ELECTRO_HYDRAULIC)
  871. {
  872. c.translate(w * 0.325, 0);
  873. this.drawCircleAct(c, w * 0.35, h * 0.4112, actuator);
  874. c.translate(- w * 0.325, 0);
  875. }
  876. else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.SPRING)
  877. {
  878. c.translate(w * 0.36, 0);
  879. this.drawSpringAct(c, w * 0.28, h * 0.4112);
  880. c.translate(- w * 0.36, 0);
  881. }
  882. else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.SOLENOID_MANUAL_RESET)
  883. {
  884. c.translate(w * 0.325, 0);
  885. this.drawSolenoidManResetAct(c, w * 0.575, h * 0.4112);
  886. c.translate(- w * 0.325, 0);
  887. }
  888. else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.SINGLE_ACTING)
  889. {
  890. c.translate(w * 0.35, 0);
  891. this.drawSingActingActBg(c, w * 0.65, h * 0.4112);
  892. c.translate(- w * 0.35, 0);
  893. }
  894. else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.DOUBLE_ACTING)
  895. {
  896. c.translate(w * 0.35, 0);
  897. this.drawDblActingActBg(c, w * 0.65, h * 0.4112);
  898. c.translate(- w * 0.35, 0);
  899. }
  900. else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.PILOT_CYLINDER)
  901. {
  902. c.translate(w * 0.35, 0);
  903. this.drawPilotCylinderActBg(c, w * 0.65, h * 0.4112);
  904. c.translate(- w * 0.35, 0);
  905. }
  906. };
  907. mxShapePidIntBlockBleedValve.prototype.drawActuatorFg = function(c, x, y, w, h, actuator)
  908. {
  909. if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.BALANCED_DIAPHRAGM)
  910. {
  911. c.translate(w * 0.25, h * 0.0588);
  912. this.drawBalDiaphActFg(c, w * 0.5, h * 0.3524);
  913. c.translate(- w * 0.25, - h * 0.0588);
  914. }
  915. else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.SINGLE_ACTING ||
  916. actuator === mxShapePidIntBlockBleedValve.prototype.cst.DOUBLE_ACTING ||
  917. actuator === mxShapePidIntBlockBleedValve.prototype.cst.PILOT_CYLINDER)
  918. {
  919. c.translate(w * 0.35, 0);
  920. this.drawActingActFg(c, w * 0.65, h * 0.4112);
  921. c.translate(- w * 0.35, 0);
  922. }
  923. };
  924. mxCellRenderer.prototype.defaultShapes['mxgraph.pid2valves.blockBleedValve'] = mxShapePidIntBlockBleedValve;
  925. //**********************************************************************************************************************************************************
  926. //Auto Recirculation Valve
  927. //**********************************************************************************************************************************************************
  928. /**
  929. * Extends mxShape.
  930. */
  931. function mxShapePidAutoRecircValve(bounds, fill, stroke, strokewidth)
  932. {
  933. mxShape.call(this);
  934. this.bounds = bounds;
  935. this.fill = fill;
  936. this.stroke = stroke;
  937. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  938. };
  939. /**
  940. * Extends mxShape.
  941. */
  942. mxUtils.extend(mxShapePidAutoRecircValve, mxShape);
  943. /**
  944. * Function: paintVertexShape
  945. *
  946. * Paints the vertex shape.
  947. */
  948. mxShapePidAutoRecircValve.prototype.paintVertexShape = function(c, x, y, w, h)
  949. {
  950. c.setLineJoin('round');
  951. c.translate(x, y);
  952. //background
  953. c.rect(0, 0, w, h);
  954. c.fillAndStroke();
  955. c.setShadow(false);
  956. //foreground
  957. c.begin();
  958. c.moveTo(w * 0.08, h * 0.08);
  959. c.lineTo(w * 0.08, h * 0.92);
  960. c.moveTo(w * 0.92, h * 0.08);
  961. c.lineTo(w * 0.92, h * 0.92);
  962. c.moveTo(w * 0.12, h * 0.122);
  963. c.lineTo(w * 0.8738, h * 0.8837);
  964. c.moveTo(w * 0.5, 0);
  965. c.lineTo(w * 0.55, h * 0.05);
  966. c.lineTo(w * 0.45, h * 0.15);
  967. c.lineTo(w * 0.55, h * 0.25);
  968. c.lineTo(w * 0.45, h * 0.35);
  969. c.lineTo(w * 0.55, h * 0.45);
  970. c.lineTo(w * 0.49, h * 0.5);
  971. c.stroke();
  972. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  973. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  974. c.begin();
  975. c.moveTo(w * 0.8257, h * 0.7695);
  976. c.lineTo(w * 0.8797, h * 0.888);
  977. c.lineTo(w * 0.79, h * 0.8651);
  978. c.close();
  979. c.setFillColor(strokeColor);
  980. c.fillAndStroke();
  981. c.setFillColor(fillColor);
  982. };
  983. mxCellRenderer.prototype.defaultShapes['mxgraph.pid2valves.autoRecircValve'] = mxShapePidAutoRecircValve;