mxPidValves.js 28 KB

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