clone

a browser-first diagram editor with live svg previews, local drafts and encrypted, accountless sharing

main
diagramzip / renderers / browser-run / frames / diagramsnet / vendor / assets / shapes / pid2 / mxPidValves.js
mxPidValves.js 30.0K
1/**2 * Copyright (c) 2006-2013, JGraph Holdings Ltd3 */45//**********************************************************************************************************************************************************6//Valve7//**********************************************************************************************************************************************************8/**9 * Extends mxShape.10 */11function 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};1920/**21 * Extends mxShape.22 */23mxUtils.extend(mxShapePidValve, mxShape);2425mxShapePidValve.prototype.cst = {26 SHAPE_VALVE : 'mxgraph.pid2valves.valve',27 //states28 DEFAULT_STATE : 'defState',29 CLOSED : 'closed',30 OPEN : 'open',31 //actuators32 ACTUATOR : 'actuator',33 MANUAL : 'man',34 DIAPHRAGM : 'diaph',35 BALANCED_DIAPHRAGM : 'balDiaph',36 MOTOR : 'motor',37 NONE : 'none',38 SPRING : 'spring',39 PILOT : 'pilot',40 POWERED: 'powered',41 SOLENOID : 'solenoid',42 SOLENOID_MANUAL_RESET : 'solenoidManRes',43 SINGLE_ACTING : 'singActing',44 DOUBLE_ACTING : 'dblActing',45 PILOT_CYLINDER : 'pilotCyl',46 DIGITAL : 'digital',47 WEIGHT : 'weight',48 KEY : 'key',49 ELECTRO_HYDRAULIC : 'elHyd',50 //types51 VALVE_TYPE : 'valveType',52 BUTTERFLY : 'butterfly',53 CHECK : 'check',54 GATE : 'gate',55 GLOBE : 'globe',56 NEEDLE : 'needle',57 PLUG : 'plug',58 SELF_DRAINING : 'selfDrain',59 ANGLE : 'angle',60 ANGLE_GLOBE : 'angleGlobe',61 THREE_WAY : 'threeWay',62 ANGLE_BLOWDOWN : 'angBlow',63 BALL : 'ball'64};6566mxShapePidValve.prototype.customProperties = [67 {name: 'defState', dispName: 'Default State', type: 'enum', defVal:'open',68 enumList: [69 {val:'closed', dispName:'Closed'},70 {val:'open', dispName:'Open'}71 ]},72 {name: 'actuator', dispName: 'Actuator', type: 'enum', defVal:'man',73 enumList: [74 {val:'man', dispName:'Manual'},75 {val:'diaph', dispName:'Diphragm'},76 {val:'balDiaph', dispName:'Balanced Diaphragm'},77 {val:'motor', dispName:'Motor'},78 {val:'none', dispName:'None'},79 {val:'spring', dispName:'Spring'},80 {val:'pilot', dispName:'Pilot'},81 {val:'powered', dispName:'Powered'},82 {val:'solenoid', dispName:'Solenoid'},83 {val:'solenoidManRes', dispName:'Solenoid w/ Manual Reset'},84 {val:'singActing', dispName:'Single Acting'},85 {val:'dblActing', dispName:'Double Acting'},86 {val:'pilotCyl', dispName:'Pilot Cylinder'},87 {val:'digital', dispName:'Digital'},88 {val:'weight', dispName:'Weight'},89 {val:'key', dispName:'Key'},90 {val:'elHyd', dispName:'Electro-Hidraulic'}91 ]},92 {name: 'valveType', dispName: 'Type', type: 'enum', defVal:'gate',93 enumList: [94 {val:'butterfly', dispName:'Butterfly'},95 {val:'check', dispName:'check'},96 {val:'gate', dispName:'Gate'},97 {val:'globe', dispName:'Globe'},98 {val:'needle', dispName:'Needle'},99 {val:'plug', dispName:'Plug'},100 {val:'selfDrain', dispName:'Self Draining'},101 {val:'angle', dispName:'Angle'},102 {val:'angleGlobe', dispName:'Angle Globe'},103 {val:'threeWay', dispName:'Three Way'},104// {val:'angBlow', dispName:'Angle Blowdown'},105 {val:'ball', dispName:'Ball'}106 ]},107];108109/**110 * Function: paintVertexShape111 * 112 * Paints the vertex shape.113 */114mxShapePidValve.prototype.paintVertexShape = function(c, x, y, w, h)115{116 var valveType = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.VALVE_TYPE, 'gate');117 var actuator = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.ACTUATOR, mxShapePidValve.prototype.cst.NONE);118 var actH = 0;119120 if (actuator !== 'none')121 {122 if (this.isAngleVariant(valveType))123 {124 actH = h * 0.3333;125 }126 else127 {128 actH = h * 0.4;129 }130 }131132 c.translate(x, y);133 c.setLineJoin('round');134 135 this.background(c, x, y, w, h, valveType, actuator, actH);136 c.setShadow(false);137 this.foreground(c, x, y, w, h, valveType, actuator, actH);138};139140mxShapePidValve.prototype.background = function(c, x, y, w, h, valveType, actuator, actH)141{142 //draw the actuator143 if (actuator !== mxShapePidValve.prototype.cst.NONE)144 {145 if (this.isAngleVariant(valveType))146 {147 this.drawActuatorBg(c, x, y, w, h / 1.2, actuator, actH);148 }149 else150 {151 this.drawActuatorBg(c, x, y, w, h, actuator, actH);152 }153 }154155 //draw the valve body156 if (this.isGateVariant(valveType))157 {158 this.drawGateVariantBg(c, 0, 0, w, h, valveType, actuator, actH);159 }160 else if (this.isAngleVariant(valveType))161 {162 this.drawAngleVariantBg(c, 0, 0, w, h, valveType, actuator, actH);163 }164 else if (valveType === mxShapePidValve.prototype.cst.BUTTERFLY)165 {166 this.drawButterflyValve(c, 0, 0, w, h, actuator, actH);167 }168 else if (valveType === mxShapePidValve.prototype.cst.CHECK)169 {170 this.drawCheckValve(c, 0, 0, w, h, actuator, actH);171 }172};173174mxShapePidValve.prototype.foreground = function(c, x, y, w, h, valveType, actuator, actH)175{176 var valveType = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.VALVE_TYPE, 'gate');177178 //draw the actuator179 if (actuator !== mxShapePidValve.prototype.cst.NONE)180 {181 if (this.isAngleVariant(valveType))182 {183 this.drawActuatorFg(c, x, y, w, h / 1.2, actuator, actH);184 }185 else186 {187 this.drawActuatorFg(c, x, y, w, h, actuator, actH);188 }189 }190191 if (this.isGateVariant(valveType))192 {193 this.drawGateVariantFg(c, 0, 0, w, h, valveType, actuator, actH);194 }195 if (this.isAngleVariant(valveType))196 {197 this.drawAngleVariantFg(c, 0, 0, w, h, valveType, actuator, actH);198 }199};200201mxShapePidValve.prototype.drawActuatorBg = function(c, x, y, w, h, actuator)202{203 if (this.isSquareVariant(actuator))204 {205 c.translate(w * 0.325, 0);206 this.drawSquareAct(c, w * 0.35, h * 0.7, actuator);207 c.translate(- w * 0.325, 0);208 }209 else if (actuator === mxShapePidValve.prototype.cst.MANUAL)210 {211 c.translate(w * 0.25, h * 0.15);212 this.drawManAct(c, w * 0.5, h * 0.55);213 c.translate(- w * 0.25, - h * 0.15);214 }215 else if (actuator === mxShapePidValve.prototype.cst.DIAPHRAGM)216 {217 c.translate(w * 0.25, h * 0.1);218 this.drawDiaphAct(c, w * 0.5, h * 0.6);219 c.translate(- w * 0.25, - h * 0.1);220 }221 else if (actuator === mxShapePidValve.prototype.cst.BALANCED_DIAPHRAGM)222 {223 c.translate(w * 0.25, h * 0.1);224 this.drawBalDiaphActBg(c, w * 0.5, h * 0.6);225 c.translate(- w * 0.25, - h * 0.1);226 }227 else if (actuator === mxShapePidValve.prototype.cst.MOTOR || actuator === mxShapePidValve.prototype.cst.ELECTRO_HYDRAULIC)228 {229 c.translate(w * 0.325, 0);230 this.drawCircleAct(c, w * 0.35, h * 0.7, actuator);231 c.translate(- w * 0.325, 0);232 }233 else if (actuator === mxShapePidValve.prototype.cst.SPRING)234 {235 c.translate(w * 0.36, 0);236 this.drawSpringAct(c, w * 0.28, h * 0.7);237 c.translate(- w * 0.36, 0);238 }239 else if (actuator === mxShapePidValve.prototype.cst.SOLENOID_MANUAL_RESET)240 {241 c.translate(w * 0.325, 0);242 this.drawSolenoidManResetAct(c, w * 0.575, h * 0.7);243 c.translate(- w * 0.325, 0);244 }245 else if (actuator === mxShapePidValve.prototype.cst.SINGLE_ACTING)246 {247 c.translate(w * 0.35, 0);248 this.drawSingActingActBg(c, w * 0.65, h * 0.7);249 c.translate(- w * 0.35, 0);250 }251 else if (actuator === mxShapePidValve.prototype.cst.DOUBLE_ACTING)252 {253 c.translate(w * 0.35, 0);254 this.drawDblActingActBg(c, w * 0.65, h * 0.7);255 c.translate(- w * 0.35, 0);256 }257 else if (actuator === mxShapePidValve.prototype.cst.PILOT_CYLINDER)258 {259 c.translate(w * 0.35, 0);260 this.drawPilotCylinderActBg(c, w * 0.65, h * 0.7);261 c.translate(- w * 0.35, 0);262 }263 else if (actuator === mxShapePidValve.prototype.cst.ANGLE_BLOWDOWN)264 {265 c.translate(w * 0.5, h * 0.2);266 this.drawAngleBlowdownAct(c, w * 0.4, h * 0.5);267 c.translate(- w * 0.5, - h * 0.2);268 }269};270271mxShapePidValve.prototype.drawActuatorFg = function(c, x, y, w, h, actuator)272{273 if (actuator === mxShapePidValve.prototype.cst.BALANCED_DIAPHRAGM)274 {275 c.translate(w * 0.25, h * 0.1);276 this.drawBalDiaphActFg(c, w * 0.5, h * 0.6);277 c.translate(- w * 0.25, - h * 0.1);278 }279 else if (actuator === mxShapePidValve.prototype.cst.SINGLE_ACTING || 280 actuator === mxShapePidValve.prototype.cst.DOUBLE_ACTING || 281 actuator === mxShapePidValve.prototype.cst.PILOT_CYLINDER)282 {283 c.translate(w * 0.35, 0);284 this.drawActingActFg(c, w * 0.65, h * 0.7);285 c.translate(- w * 0.35, 0);286 }287};288289mxShapePidValve.prototype.drawManAct = function(c, w, h)290{291 c.begin();292 c.moveTo(0, 0);293 c.lineTo(w, 0);294 c.moveTo(w * 0.5, 0);295 c.lineTo(w * 0.5, h);296 c.stroke();297};298299mxShapePidValve.prototype.drawDiaphAct = function(c, w, h)300{301 c.begin();302 c.moveTo(w * 0.5, h * 0.2);303 c.lineTo(w * 0.5, h);304 c.stroke();305 306 c.begin();307 c.moveTo(0, h * 0.2);308 c.arcTo(w * 0.6, h * 0.4, 0, 0, 1, w, h * 0.2);309 c.close();310 c.fillAndStroke();311};312313mxShapePidValve.prototype.drawBalDiaphActBg = function(c, w, h)314{315 c.ellipse(0, 0, w, h * 0.3);316 c.fillAndStroke();317318 c.begin();319 c.moveTo(w * 0.5, h * 0.3);320 c.lineTo(w * 0.5, h);321 c.stroke();322};323324mxShapePidValve.prototype.drawBalDiaphActFg = function(c, w, h)325{326 c.begin();327 c.moveTo(0, h * 0.15);328 c.lineTo(w, h * 0.15);329 c.stroke();330};331332mxShapePidValve.prototype.drawCircleAct = function(c, w, h, actuator)333{334 c.ellipse(0, 0, w, h * 0.5);335 c.fillAndStroke();336337 c.begin();338 c.moveTo(w * 0.5, h * 0.5);339 c.lineTo(w * 0.5, h);340 c.stroke();341342 var m = '';343 344 if (actuator === mxShapePidValve.prototype.cst.MOTOR)345 {346 m = 'M';347 }348 else if (actuator === mxShapePidValve.prototype.cst.ELECTRO_HYDRAULIC)349 {350 m = 'E/H';351 }352353 c.setFontStyle(1);354 c.setFontFamily('Helvetica');355 c.setFontSize(Math.min(w, h) * 0.4);356 c.text(w * 0.5, h * 0.25, 0, 0, m, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);357};358359mxShapePidValve.prototype.drawSpringAct = function(c, w, h)360{361 c.begin();362 c.moveTo(w * 0.5, 0);363 c.lineTo(w * 0.5, h);364 c.moveTo(w * 0.32, h * 0.16);365 c.lineTo(w * 0.68, h * 0.08);366 c.moveTo(w * 0.21, h * 0.32);367 c.lineTo(w * 0.79, h * 0.20);368 c.moveTo(w * 0.1, h * 0.52);369 c.lineTo(w * 0.9, h * 0.36);370 c.moveTo(0, h * 0.72);371 c.lineTo(w, h * 0.5);372 c.stroke();373};374375mxShapePidValve.prototype.drawSolenoidManResetAct = function(c, w, h)376{377 c.rect(0, 0, w * 0.61, h * 0.46);378 c.fillAndStroke();379 380 c.begin();381 c.moveTo(w * 0.56, h * 0.6);382 c.lineTo(w * 0.78, h * 0.5);383 c.lineTo(w, h * 0.6);384 c.lineTo(w * 0.78, h * 0.7);385 c.close();386 c.fillAndStroke();387 388 c.begin();389 c.moveTo(w * 0.305, h * 0.46);390 c.lineTo(w * 0.305, h);391 c.moveTo(w * 0.305, h * 0.6);392 c.lineTo(w * 0.56, h * 0.6);393 c.stroke();394395 c.setFontStyle(1);396 c.setFontFamily('Helvetica');397 c.setFontSize(Math.min(w, h) * 0.4);398 c.text(w * 0.305, h * 0.23, 0, 0, 'S', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);399400 c.setFontStyle(0);401 c.setFontSize(Math.min(w, h) * 0.15);402 c.text(w * 0.78, h * 0.6, 0, 0, 'R', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);403};404405mxShapePidValve.prototype.drawSingActingActBg = function(c, w, h)406{407 c.rect(0, 0, w * 0.46, h * 0.46);408 c.fillAndStroke();409410 c.begin();411 c.moveTo(w * 0.23, h * 0.46);412 c.lineTo(w * 0.23, h);413 c.moveTo(w * 0.46, h * 0.23);414 c.lineTo(w, h * 0.23);415 c.moveTo(w * 0.77, h * 0.15);416 c.lineTo(w * 0.69, h * 0.31);417 c.moveTo(w * 0.82, h * 0.15);418 c.lineTo(w * 0.74, h * 0.31);419 c.stroke();420};421422mxShapePidValve.prototype.drawActingActFg = function(c, w, h)423{424 c.begin();425 c.moveTo(w * 0.23, h * 0.23);426 c.lineTo(w * 0.23, h * 0.46);427 c.moveTo(0, h * 0.23);428 c.lineTo(w * 0.46, h * 0.23);429 c.stroke();430};431432mxShapePidValve.prototype.drawDblActingActBg = function(c, w, h)433{434 c.rect(0, 0, w * 0.46, h * 0.46);435 c.fillAndStroke();436437 c.begin();438 c.moveTo(w * 0.23, h * 0.46);439 c.lineTo(w * 0.23, h);440 c.moveTo(w * 0.46, h * 0.115);441 c.lineTo(w, h * 0.115);442 c.moveTo(w * 0.77, h * 0.035);443 c.lineTo(w * 0.69, h * 0.195);444 c.moveTo(w * 0.82, h * 0.035);445 c.lineTo(w * 0.74, h * 0.195);446 c.moveTo(w * 0.46, h * 0.345);447 c.lineTo(w, h * 0.345);448 c.moveTo(w * 0.77, h * 0.265);449 c.lineTo(w * 0.69, h * 0.425);450 c.moveTo(w * 0.82, h * 0.265);451 c.lineTo(w * 0.74, h * 0.425);452 c.stroke();453};454455mxShapePidValve.prototype.drawPilotCylinderActBg = function(c, w, h)456{457 c.rect(0, 0, w * 0.46, h * 0.46);458 c.fillAndStroke();459460 c.begin();461 c.moveTo(w * 0.23, h * 0.46);462 c.lineTo(w * 0.23, h);463 c.moveTo(w * 0.46, h * 0.23);464 c.lineTo(w * 0.77, h * 0.23);465 c.stroke();466 467 c.rect(w * 0.77, h * 0.115, w * 0.23, h * 0.23);468 c.fillAndStroke();469470 c.setFontStyle(0);471 c.setFontFamily('Helvetica');472 c.setFontSize(Math.min(w, h) * 0.15);473 c.text(w * 0.885, h * 0.23, 0, 0, 'P', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);474};475476mxShapePidValve.prototype.drawAngleBlowdownAct = function(c, w, h)477{478 c.begin();479 c.moveTo(w * 0.34, 0);480 c.lineTo(w, h * 0.405);481 c.moveTo(0, h);482 c.lineTo(w * 0.665, h * 0.205);483 c.stroke();484};485486mxShapePidValve.prototype.drawSquareAct = function(c, w, h, actuator)487{488 c.rect(0, 0, w, h * 0.5);489 c.fillAndStroke();490491 c.begin();492 c.moveTo(w * 0.5, h * 0.5);493 c.lineTo(w * 0.5, h);494 c.stroke();495496 var m = '';497 498 if (actuator === mxShapePidValve.prototype.cst.PILOT)499 {500 m = 'P';501 }502 else if (actuator === mxShapePidValve.prototype.cst.SOLENOID)503 {504 m = 'S';505 }506 else if (actuator === mxShapePidValve.prototype.cst.DIGITAL)507 {508 m = 'D';509 }510 else if (actuator === mxShapePidValve.prototype.cst.WEIGHT)511 {512 m = 'W';513 }514 else if (actuator === mxShapePidValve.prototype.cst.KEY)515 {516 m = 'K';517 }518 519 c.setFontStyle(1);520 c.setFontFamily('Helvetica');521 c.setFontSize(Math.min(w, h) * 0.4);522 c.text(w * 0.5, h * 0.25, 0, 0, m, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);523};524525mxShapePidValve.prototype.drawGateVariantFg = function(c, x, y, w, h, valveType, actuator, actH)526{527 var defState = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.DEFAULT_STATE, 'open');528 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');529 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');530 531 if (valveType === mxShapePidValve.prototype.cst.BALL)532 {533 c.ellipse(x + w * 0.3, y + actH + (h - actH) * 0.18, w * 0.4, (h - actH) * 0.64);534 c.fillAndStroke();535 }536 else if (valveType === mxShapePidValve.prototype.cst.GLOBE)537 {538 c.ellipse(x + w * 0.3, y + actH + (h - actH) * 0.18, w * 0.4, (h - actH) * 0.64);539 c.setFillColor(strokeColor);540 c.fillAndStroke();541 c.setFillColor(fillColor);542 }543 else if (valveType === mxShapePidValve.prototype.cst.PLUG)544 {545 this.drawPlug(c, x + w * 0.4, y + actH + (h - actH) * 0.25, w * 0.2, (h - actH) * 0.5);546 }547 else if (valveType === mxShapePidValve.prototype.cst.NEEDLE)548 {549 this.drawNeedle(c, x + w * 0.45, y + actH + (h - actH) * 0.1, w * 0.1, (h - actH) * 0.9);550 }551 else if (valveType === mxShapePidValve.prototype.cst.SELF_DRAINING)552 {553 this.drawDrain(c, x + w * 0.48, y + actH + (h - actH) * 0.5, w * 0.04, (h - actH) * 0.49);554 }555};556557mxShapePidValve.prototype.drawAngleVariantFg = function(c, x, y, w, h, valveType, actuator, actH)558{559 var defState = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.DEFAULT_STATE, 'open');560 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');561 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');562 563 if (valveType === mxShapePidValve.prototype.cst.ANGLE_GLOBE)564 {565 if (actuator === 'none')566 {567 c.ellipse(w * 0.34, h * 0.175, w * 0.32, h * 0.4);568 }569 else570 {571 c.ellipse(w * 0.34, h * 0.45, w * 0.32, h * 0.2667);572 }573 c.setFillColor(strokeColor);574 c.fillAndStroke();575 c.setFillColor(fillColor);576 }577};578579mxShapePidValve.prototype.drawGateVariantBg = function(c, x, y, w, h, valveType, actuator, actH)580{581 if (valveType === mxShapePidValve.prototype.cst.GATE)582 {583 this.drawGateValve(c, x, y + actH, w, h - actH);584 }585 else if (valveType === mxShapePidValve.prototype.cst.BALL || valveType === mxShapePidValve.prototype.cst.GLOBE)586 {587 c.ellipse(x + w * 0.3, y + actH + (h - actH) * 0.18, w * 0.4, (h - actH) * 0.64);588 c.fillAndStroke();589 this.drawGateValve(c, x, y + actH, w, h - actH);590 }591 else if (valveType === mxShapePidValve.prototype.cst.PLUG)592 {593 this.drawPlug(c, x + w * 0.4, y + actH + (h - actH) * 0.25, w * 0.2, (h - actH) * 0.5);594 this.drawGateValve(c, x, y + actH, w, h - actH);595 }596 else if (valveType === mxShapePidValve.prototype.cst.NEEDLE)597 {598 this.drawNeedle(c, x + w * 0.45, y + actH + (h - actH) * 0.1, w * 0.1, (h - actH) * 0.9);599 this.drawGateValve(c, x, y + actH, w, h - actH);600 }601 else if (valveType === mxShapePidValve.prototype.cst.SELF_DRAINING)602 {603 this.drawDrain(c, x + w * 0.48, y + actH + (h - actH) * 0.5, w * 0.04, (h - actH) * 0.49);604 this.drawGateValve(c, x, y + actH, w, h - actH);605 }606};607608mxShapePidValve.prototype.drawAngleVariantBg = function(c, x, y, w, h, valveType, actuator, actH)609{610 if (valveType === mxShapePidValve.prototype.cst.ANGLE)611 {612 this.drawAngleValve(c, w * 0.2, y + actH, w * 0.8, h - actH);613 }614 else if (valveType === mxShapePidValve.prototype.cst.ANGLE_GLOBE)615 {616 this.drawAngleGlobeValveBg(c, w * 0.2, y + actH, w * 0.8, h - actH);617 }618 else if (valveType === mxShapePidValve.prototype.cst.THREE_WAY)619 {620 this.drawThreeWayValve(c, 0, y + actH, w, h - actH);621 }622 else if (valveType === mxShapePidValve.prototype.cst.ANGLE_BLOWDOWN)623 {624 this.drawAngleBlowdownValve(c, x, y + actH, w, h - actH);625 }626};627628mxShapePidValve.prototype.drawPlug = function(c, x, y, w, h)629{630 c.translate(x, y);631 c.begin();632 c.moveTo(0, h * 0.5);633 c.lineTo(w * 0.5, 0);634 c.lineTo(w, h * 0.5);635 c.lineTo(w * 0.5, h);636 c.close();637 c.fillAndStroke();638 c.translate(-x, -y);639};640641mxShapePidValve.prototype.drawNeedle = function(c, x, y, w, h)642{643 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');644 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');645646 c.translate(x, y);647 c.begin();648 c.moveTo(0, 0);649 c.lineTo(w, 0);650 c.lineTo(w * 0.5, h);651 c.close();652 c.setFillColor(strokeColor);653 c.fillAndStroke();654 c.setFillColor(fillColor);655 c.translate(-x, -y);656};657658mxShapePidValve.prototype.drawDrain = function(c, x, y, w, h)659{660 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');661 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');662663 c.translate(x, y);664 c.begin();665 c.moveTo(w * 0.5, 0);666 c.lineTo(w * 0.5, h * 0.96);667 c.stroke();668669 c.begin();670 c.moveTo(0, h * 0.9);671 c.lineTo(w, h * 0.9);672 c.lineTo(w * 0.5, h);673 c.close();674 c.setFillColor(strokeColor);675 c.fillAndStroke();676 c.setFillColor(fillColor);677 c.translate(-x, -y);678};679680mxShapePidValve.prototype.drawGateValve = function(c, x, y, w, h)681{682 var defState = mxUtils.getValue(this.style, mxShapePidValve.prototype.cst.DEFAULT_STATE, 'open');683 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');684 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');685686 c.translate(x, y);687 c.begin();688 c.moveTo(0, 0);689 c.lineTo(w * 0.5, h * 0.5);690 c.lineTo(0, h);691 c.close();692 c.moveTo(w, 0);693 c.lineTo(w * 0.5, h * 0.5);694 c.lineTo(w, h);695 c.close();696697 if (defState === mxShapePidValve.prototype.cst.CLOSED)698 {699 c.setFillColor(strokeColor);700 c.fillAndStroke();701 c.setFillColor(fillColor);702 }703 else704 {705 c.fillAndStroke();706 }707708 c.translate(-x, -y);709};710711mxShapePidValve.prototype.drawAngleValve = function(c, x, y, w, h)712{713 c.translate(x, y);714715 c.begin();716 c.moveTo(w * 0.375, h * 0.375);717 c.lineTo(w, 0);718 c.lineTo(w, h * 0.75);719 c.close();720 c.moveTo(w * 0.375, h * 0.375);721 c.lineTo(w * 0.75, h);722 c.lineTo(0, h);723 c.close();724 c.fillAndStroke();725726 c.translate(-x, -y);727};728729mxShapePidValve.prototype.drawAngleGlobeValveBg = function(c, x, y, w, h)730{731 c.translate(x, y);732733 c.ellipse(w * 0.175, h * 0.175, w * 0.4, h * 0.4);734 c.fillAndStroke();735 c.begin();736 c.moveTo(w * 0.375, h * 0.375);737 c.lineTo(w, 0);738 c.lineTo(w, h * 0.75);739 c.close();740 c.moveTo(w * 0.375, h * 0.375);741 c.lineTo(w * 0.75, h);742 c.lineTo(0, h);743 c.close();744 c.fillAndStroke();745 c.translate(-x, -y);746};747748mxShapePidValve.prototype.drawAngleGlobeValveFg = function(c, x, y, w, h)749{750 c.translate(x, y);751 c.ellipse(w * 0.275, h * 0.275, w * 0.2, h * 0.2);752 c.fillAndStroke();753 c.translate(-x, -y);754};755756mxShapePidValve.prototype.drawThreeWayValve = function(c, x, y, w, h)757{758 c.translate(x, y);759760 c.begin();761 c.moveTo(0, 0);762 c.lineTo(w * 0.5, h * 0.375);763 c.lineTo(0, h * 0.75);764 c.close();765 766 c.moveTo(w, 0);767 c.lineTo(w * 0.5, h * 0.375);768 c.lineTo(w, h * 0.75);769 c.close();770 771 c.moveTo(w * 0.5, h * 0.375);772 c.lineTo(w * 0.8, h);773 c.lineTo(w * 0.2, h);774 c.close();775 c.fillAndStroke();776777 c.translate(-x, -y);778};779780mxShapePidValve.prototype.drawAngleBlowdownValve = function(c, x, y, w, h)781{782 783};784785 786mxShapePidValve.prototype.drawButterflyValve = function(c, x, y, w, h, actuator, actH)787{788 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');789 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');790791 var yv = y + actH;792 var hv = h - actH;793794 c.translate(x, yv);795 c.begin();796 c.moveTo(0, 0);797 c.lineTo(0, hv);798 c.moveTo(w, 0);799 c.lineTo(w, hv);800801 c.moveTo(w * 0.05, hv * 0.05);802 c.lineTo(w * 0.95, hv * 0.95);803 804 c.fillAndStroke();805806 c.ellipse(w * 0.4, hv * 0.33, w * 0.2, hv * 0.33);807 c.fillAndStroke();808 809 c.translate(-x, -y);810};811812mxShapePidValve.prototype.drawCheckValve = function(c, x, y, w, h, actuator, actH)813{814 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');815 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');816817 var yv = y + actH;818 var hv = h - actH;819820 c.translate(x, yv);821 c.begin();822 c.moveTo(0, 0);823 c.lineTo(0, hv);824 c.moveTo(w, 0);825 c.lineTo(w, hv);826 c.moveTo(w * 0.05, hv * 0.05);827 c.lineTo(w * 0.95, hv * 0.95);828 c.fillAndStroke();829830 c.begin();831 c.moveTo(w * 0.8925, hv * 0.815);832 c.lineTo(w * 0.957, hv * 0.955);833 c.lineTo(w * 0.85, hv * 0.928);834 c.close();835 c.setFillColor(strokeColor);836 c.fillAndStroke();837 c.setFillColor(fillColor);838 839 c.translate(-x, -y);840};841842mxShapePidValve.prototype.isGateVariant = function(valveType)843{844 if (valveType === mxShapePidValve.prototype.cst.GATE || 845 valveType === mxShapePidValve.prototype.cst.BALL ||846 valveType === mxShapePidValve.prototype.cst.PLUG ||847 valveType === mxShapePidValve.prototype.cst.NEEDLE ||848 valveType === mxShapePidValve.prototype.cst.SELF_DRAINING ||849 valveType === mxShapePidValve.prototype.cst.GLOBE)850 {851 return true;852 }853 else854 {855 return false;856 }857};858859mxShapePidValve.prototype.isAngleVariant = function(valveType)860{861 if (valveType === mxShapePidValve.prototype.cst.ANGLE || 862 valveType === mxShapePidValve.prototype.cst.ANGLE_GLOBE ||863 valveType === mxShapePidValve.prototype.cst.THREE_WAY ||864 valveType === mxShapePidValve.prototype.cst.ANGLE_BLOWDOWN)865 {866 return true;867 }868 else869 {870 return false;871 }872};873874mxShapePidValve.prototype.isSquareVariant = function(actType)875{876 if (actType === mxShapePidValve.prototype.cst.PILOT || 877 actType === mxShapePidValve.prototype.cst.SOLENOID ||878 actType === mxShapePidValve.prototype.cst.POWERED ||879 actType === mxShapePidValve.prototype.cst.DIGITAL ||880 actType === mxShapePidValve.prototype.cst.WEIGHT ||881 actType === mxShapePidValve.prototype.cst.KEY)882 {883 return true;884 }885 else886 {887 return false;888 }889};890891mxCellRenderer.registerShape(mxShapePidValve.prototype.cst.SHAPE_VALVE, mxShapePidValve);892893//**********************************************************************************************************************************************************894//Integrated Block And Bleed Valve895//**********************************************************************************************************************************************************896/**897* Extends mxShape.898*/899function mxShapePidIntBlockBleedValve(bounds, fill, stroke, strokewidth)900{901 mxShape.call(this);902 this.bounds = bounds;903 this.fill = fill;904 this.stroke = stroke;905 this.strokewidth = (strokewidth != null) ? strokewidth : 1;906};907908/**909* Extends mxShapePidValve.910*/911mxUtils.extend(mxShapePidIntBlockBleedValve, mxShapePidValve);912913/**914* Function: paintVertexShape915* 916* Paints the vertex shape.917*/918mxShapePidIntBlockBleedValve.prototype.paintVertexShape = function(c, x, y, w, h)919{920 var actuator = mxUtils.getValue(this.style, mxShapePidIntBlockBleedValve.prototype.cst.ACTUATOR, mxShapePidIntBlockBleedValve.prototype.cst.NONE);921 var actH = 0;922923 if (actuator !== 'none')924 {925 actH = h * 0.2353;926 }927928 c.translate(x, y);929 c.setLineJoin('round');930 931 this.background(c, x, y, w, h, actuator, actH);932 c.setShadow(false);933 this.foreground(c, x, y, w, h, actuator, actH);934};935936mxShapePidIntBlockBleedValve.prototype.background = function(c, x, y, w, h, actuator, actH)937{938 //draw the actuator939 if (actuator !== mxShapePidIntBlockBleedValve.prototype.cst.NONE)940 {941 this.drawActuatorBg(c, x, y, w, h, actuator);942 }943944 //draw the valve body945 this.drawValveBg(c, 0, actH, w, h - actH);946};947948mxShapePidIntBlockBleedValve.prototype.foreground = function(c, x, y, w, h, actuator, actH)949{950 //draw the actuator951 if (actuator !== mxShapePidIntBlockBleedValve.prototype.cst.NONE)952 {953 this.drawActuatorFg(c, x, y, w, h, actuator);954 }955};956957mxShapePidIntBlockBleedValve.prototype.drawValveBg = function(c, x, y, w, h)958{959 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');960 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');961962 c.translate(x, y);963 c.begin();964 c.moveTo(0, 0);965 c.lineTo(w * 0.5, h * 0.23);966 c.lineTo(0, h * 0.46);967 c.close();968 c.moveTo(w * 0.5, h * 0.23);969 c.lineTo(w, 0);970 c.lineTo(w, h * 0.46);971 c.close();972 c.fillAndStroke();973974 c.begin();975 c.moveTo(w * 0.5, h * 0.23);976 c.lineTo(w * 0.5, h * 0.5);977 c.stroke();978 979 c.setFillColor(strokeColor);980 c.begin();981 c.moveTo(w * 0.3, h * 0.5);982 c.lineTo(w * 0.7, h * 0.5);983 c.lineTo(w * 0.5, h * 0.75);984 c.close();985 c.fillAndStroke();986 987 c.begin();988 c.moveTo(w * 0.3, h);989 c.lineTo(w * 0.5, h * 0.75);990 c.lineTo(w * 0.7, h);991 c.fillAndStroke();992 c.setFillColor(fillColor);993994 c.translate(-x, -y);995};996997mxShapePidIntBlockBleedValve.prototype.drawActuatorBg = function(c, x, y, w, h, actuator)998{999 if (this.isSquareVariant(actuator))1000 {1001 c.translate(w * 0.325, 0);1002 this.drawSquareAct(c, w * 0.35, h * 0.4112, actuator);1003 c.translate(- w * 0.325, 0);1004 }1005 else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.MANUAL)1006 {1007 c.translate(w * 0.25, h * 0.0882);1008 this.drawManAct(c, w * 0.5, h * 0.323);1009 c.translate(- w * 0.25, - h * 0.0882);1010 }1011 else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.DIAPHRAGM)1012 {1013 c.translate(w * 0.25, h * 0.0588);1014 this.drawDiaphAct(c, w * 0.5, h * 0.3524);1015 c.translate(- w * 0.25, - h * 0.0588);1016 }1017 else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.BALANCED_DIAPHRAGM)1018 {1019 c.translate(w * 0.25, h * 0.0588);1020 this.drawBalDiaphActBg(c, w * 0.5, h * 0.3524);1021 c.translate(- w * 0.25, - h * 0.0588);1022 }1023 else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.MOTOR || actuator === mxShapePidIntBlockBleedValve.prototype.cst.ELECTRO_HYDRAULIC)1024 {1025 c.translate(w * 0.325, 0);1026 this.drawCircleAct(c, w * 0.35, h * 0.4112, actuator);1027 c.translate(- w * 0.325, 0);1028 }1029 else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.SPRING)1030 {1031 c.translate(w * 0.36, 0);1032 this.drawSpringAct(c, w * 0.28, h * 0.4112);1033 c.translate(- w * 0.36, 0);1034 }1035 else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.SOLENOID_MANUAL_RESET)1036 {1037 c.translate(w * 0.325, 0);1038 this.drawSolenoidManResetAct(c, w * 0.575, h * 0.4112);1039 c.translate(- w * 0.325, 0);1040 }1041 else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.SINGLE_ACTING)1042 {1043 c.translate(w * 0.35, 0);1044 this.drawSingActingActBg(c, w * 0.65, h * 0.4112);1045 c.translate(- w * 0.35, 0);1046 }1047 else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.DOUBLE_ACTING)1048 {1049 c.translate(w * 0.35, 0);1050 this.drawDblActingActBg(c, w * 0.65, h * 0.4112);1051 c.translate(- w * 0.35, 0);1052 }1053 else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.PILOT_CYLINDER)1054 {1055 c.translate(w * 0.35, 0);1056 this.drawPilotCylinderActBg(c, w * 0.65, h * 0.4112);1057 c.translate(- w * 0.35, 0);1058 }1059};10601061mxShapePidIntBlockBleedValve.prototype.drawActuatorFg = function(c, x, y, w, h, actuator)1062{1063 if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.BALANCED_DIAPHRAGM)1064 {1065 c.translate(w * 0.25, h * 0.0588);1066 this.drawBalDiaphActFg(c, w * 0.5, h * 0.3524);1067 c.translate(- w * 0.25, - h * 0.0588);1068 }1069 else if (actuator === mxShapePidIntBlockBleedValve.prototype.cst.SINGLE_ACTING || 1070 actuator === mxShapePidIntBlockBleedValve.prototype.cst.DOUBLE_ACTING || 1071 actuator === mxShapePidIntBlockBleedValve.prototype.cst.PILOT_CYLINDER)1072 {1073 c.translate(w * 0.35, 0);1074 this.drawActingActFg(c, w * 0.65, h * 0.4112);1075 c.translate(- w * 0.35, 0);1076 }1077};10781079mxCellRenderer.registerShape('mxgraph.pid2valves.blockBleedValve', mxShapePidIntBlockBleedValve);10801081//**********************************************************************************************************************************************************1082//Auto Recirculation Valve1083//**********************************************************************************************************************************************************1084/**1085 * Extends mxShape.1086 */1087function mxShapePidAutoRecircValve(bounds, fill, stroke, strokewidth)1088{1089 mxShape.call(this);1090 this.bounds = bounds;1091 this.fill = fill;1092 this.stroke = stroke;1093 this.strokewidth = (strokewidth != null) ? strokewidth : 1;1094};10951096/**1097 * Extends mxShape.1098 */1099mxUtils.extend(mxShapePidAutoRecircValve, mxShape);110011011102/**1103 * Function: paintVertexShape1104 * 1105 * Paints the vertex shape.1106 */1107mxShapePidAutoRecircValve.prototype.paintVertexShape = function(c, x, y, w, h)1108{1109 c.setLineJoin('round');1110 c.translate(x, y);11111112 //background1113 c.rect(0, 0, w, h);1114 c.fillAndStroke();1115 c.setShadow(false);11161117 //foreground1118 c.begin();1119 c.moveTo(w * 0.08, h * 0.08);1120 c.lineTo(w * 0.08, h * 0.92);1121 c.moveTo(w * 0.92, h * 0.08);1122 c.lineTo(w * 0.92, h * 0.92);1123 c.moveTo(w * 0.12, h * 0.122);1124 c.lineTo(w * 0.8738, h * 0.8837);1125 1126 c.moveTo(w * 0.5, 0);1127 c.lineTo(w * 0.55, h * 0.05);1128 c.lineTo(w * 0.45, h * 0.15);1129 c.lineTo(w * 0.55, h * 0.25);1130 c.lineTo(w * 0.45, h * 0.35);1131 c.lineTo(w * 0.55, h * 0.45);1132 c.lineTo(w * 0.49, h * 0.5);1133 c.stroke();1134 1135 var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');1136 var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');1137 1138 c.begin();1139 c.moveTo(w * 0.8257, h * 0.7695);1140 c.lineTo(w * 0.8797, h * 0.888);1141 c.lineTo(w * 0.79, h * 0.8651);1142 c.close();1143 c.setFillColor(strokeColor);1144 c.fillAndStroke();1145 c.setFillColor(fillColor);1146};11471148mxCellRenderer.registerShape('mxgraph.pid2valves.autoRecircValve', mxShapePidAutoRecircValve);