1/**2 * Copyright (c) 2006-2013, JGraph Holdings Ltd3 */45//**********************************************************************************************************************************************************6//Discrete Instrument7//**********************************************************************************************************************************************************8/**9 * Extends mxShape.10 */11function mxShapePidDiscInst(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(mxShapePidDiscInst, mxShape);2425mxShapePidDiscInst.prototype.cst = {26 SHAPE_DISC_INST : 'mxgraph.pid2inst.discInst',27 MOUNTING : 'mounting',28 FIELD : 'field',29 ROOM : 'room',30 INACCESSIBLE : 'inaccessible',31 LOCAL : 'local'32};3334mxShapePidDiscInst.prototype.customProperties = [35 {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',36 enumList: [37 {val:'field', dispName:'Field'},38 {val:'room', dispName:'Room'},39 {val:'inaccessible', dispName:'Inaccessible'},40 {val:'local', dispName:'Local'}41 ]}42];4344/**45 * Function: paintVertexShape46 * 47 * Paints the vertex shape.48 */49mxShapePidDiscInst.prototype.paintVertexShape = function(c, x, y, w, h)50{51 c.translate(x, y);52 this.background(c, x, y, w, h);53 c.setShadow(false);54 this.foreground(c, x, y, w, h);55};5657mxShapePidDiscInst.prototype.background = function(c, x, y, w, h)58{59 c.ellipse(0, 0, w, h);60 c.fillAndStroke();61};6263mxShapePidDiscInst.prototype.foreground = function(c, x, y, w, h)64{65 var mounting = mxUtils.getValue(this.style, mxShapePidDiscInst.prototype.cst.MOUNTING, 'field');6667 if (mounting === mxShapePidDiscInst.prototype.cst.ROOM)68 {69 c.begin();70 c.moveTo(0, h * 0.5);71 c.lineTo(w, h * 0.5);72 c.stroke();73 }74 else if (mounting === mxShapePidDiscInst.prototype.cst.INACCESSIBLE)75 {76 c.setDashed(true);77 c.begin();78 c.moveTo(0, h * 0.5);79 c.lineTo(w, h * 0.5);80 c.stroke();81 }82 else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)83 {84 c.begin();85 c.moveTo(w * 0.005, h * 0.48);86 c.lineTo(w * 0.995, h * 0.48);87 c.moveTo(w * 0.005, h * 0.52);88 c.lineTo(w * 0.995, h * 0.52);89 c.stroke();90 }91};9293mxCellRenderer.registerShape(mxShapePidDiscInst.prototype.cst.SHAPE_DISC_INST, mxShapePidDiscInst);9495mxShapePidDiscInst.prototype.constraints = [96 new mxConnectionConstraint(new mxPoint(0.5, 0), true),97 new mxConnectionConstraint(new mxPoint(0.5, 1), true),98 new mxConnectionConstraint(new mxPoint(0, 0.5), true),99 new mxConnectionConstraint(new mxPoint(1, 0.5), true),100 new mxConnectionConstraint(new mxPoint(0.145, 0.145), false),101 new mxConnectionConstraint(new mxPoint(0.145, 0.855), false),102 new mxConnectionConstraint(new mxPoint(0.855, 0.145), false),103 new mxConnectionConstraint(new mxPoint(0.855, 0.855), false)104 ];105106//**********************************************************************************************************************************************************107//Shared Control/Display108//**********************************************************************************************************************************************************109/**110* Extends mxShape.111*/112function mxShapePidSharedCont(bounds, fill, stroke, strokewidth)113{114 mxShape.call(this);115 this.bounds = bounds;116 this.fill = fill;117 this.stroke = stroke;118 this.strokewidth = (strokewidth != null) ? strokewidth : 1;119};120121/**122* Extends mxShape.123*/124mxUtils.extend(mxShapePidSharedCont, mxShape);125126mxShapePidSharedCont.prototype.cst = {127 SHAPE_SHARED_CONT : 'mxgraph.pid2inst.sharedCont',128 MOUNTING : 'mounting',129 FIELD : 'field',130 ROOM : 'room',131 INACCESSIBLE : 'inaccessible',132 LOCAL : 'local'133};134135mxShapePidSharedCont.prototype.customProperties = [136 {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',137 enumList: [138 {val:'field', dispName:'Field'},139 {val:'room', dispName:'Room'},140 {val:'inaccessible', dispName:'Inaccessible'},141 {val:'local', dispName:'Local'}142 ]}143];144145/**146* Function: paintVertexShape147* 148* Paints the vertex shape.149*/150mxShapePidSharedCont.prototype.paintVertexShape = function(c, x, y, w, h)151{152 c.translate(x, y);153 this.background(c, x, y, w, h);154 c.setShadow(false);155 this.foreground(c, x, y, w, h);156};157158mxShapePidSharedCont.prototype.background = function(c, x, y, w, h)159{160 c.rect(0, 0, w, h);161 c.fillAndStroke();162};163164mxShapePidSharedCont.prototype.foreground = function(c, x, y, w, h)165{166 var mounting = mxUtils.getValue(this.style, mxShapePidSharedCont.prototype.cst.MOUNTING, 'field');167168 c.ellipse(0, 0, w, h);169 c.fillAndStroke();170171 if (mounting === mxShapePidSharedCont.prototype.cst.ROOM)172 {173 c.begin();174 c.moveTo(0, h * 0.5);175 c.lineTo(w, h * 0.5);176 c.stroke();177 }178 else if (mounting === mxShapePidSharedCont.prototype.cst.INACCESSIBLE)179 {180 c.setDashed(true);181 c.begin();182 c.moveTo(0, h * 0.5);183 c.lineTo(w, h * 0.5);184 c.stroke();185 }186 else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)187 {188 c.begin();189 c.moveTo(w * 0.005, h * 0.48);190 c.lineTo(w * 0.995, h * 0.48);191 c.moveTo(w * 0.005, h * 0.52);192 c.lineTo(w * 0.995, h * 0.52);193 c.stroke();194 }195};196197mxCellRenderer.registerShape(mxShapePidSharedCont.prototype.cst.SHAPE_SHARED_CONT, mxShapePidSharedCont);198199mxShapePidSharedCont.prototype.constraints = [200 new mxConnectionConstraint(new mxPoint(0.5, 0), true),201 new mxConnectionConstraint(new mxPoint(0.5, 1), true),202 new mxConnectionConstraint(new mxPoint(0, 0.5), true),203 new mxConnectionConstraint(new mxPoint(1, 0.5), true),204 new mxConnectionConstraint(new mxPoint(0, 0), false),205 new mxConnectionConstraint(new mxPoint(0, 1), false),206 new mxConnectionConstraint(new mxPoint(1, 0), false),207 new mxConnectionConstraint(new mxPoint(1, 1), false)208 ];209210//**********************************************************************************************************************************************************211//Computer Function212//**********************************************************************************************************************************************************213/**214* Extends mxShape.215*/216function mxShapePidCompFunc(bounds, fill, stroke, strokewidth)217{218 mxShape.call(this);219 this.bounds = bounds;220 this.fill = fill;221 this.stroke = stroke;222 this.strokewidth = (strokewidth != null) ? strokewidth : 1;223};224225/**226* Extends mxShape.227*/228mxUtils.extend(mxShapePidCompFunc, mxShape);229230mxShapePidCompFunc.prototype.cst = {231 SHAPE_COMP_FUNC : 'mxgraph.pid2inst.compFunc',232 MOUNTING : 'mounting',233 FIELD : 'field',234 ROOM : 'room',235 INACCESSIBLE : 'inaccessible',236 LOCAL : 'local'237};238239mxShapePidCompFunc.prototype.customProperties = [240 {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',241 enumList: [242 {val:'field', dispName:'Field'},243 {val:'room', dispName:'Room'},244 {val:'inaccessible', dispName:'Inaccessible'},245 {val:'local', dispName:'Local'}246 ]}247];248249/**250* Function: paintVertexShape251* 252* Paints the vertex shape.253*/254mxShapePidCompFunc.prototype.paintVertexShape = function(c, x, y, w, h)255{256 c.translate(x, y);257 this.background(c, x, y, w, h);258 c.setShadow(false);259 this.foreground(c, x, y, w, h);260};261262mxShapePidCompFunc.prototype.background = function(c, x, y, w, h)263{264 c.begin();265 c.moveTo(0, h * 0.5);266 c.lineTo(w * 0.25, 0);267 c.lineTo(w * 0.75, 0);268 c.lineTo(w, h * 0.5);269 c.lineTo(w * 0.75, h);270 c.lineTo(w * 0.25, h);271 c.close();272 c.fillAndStroke();273};274275mxShapePidCompFunc.prototype.foreground = function(c, x, y, w, h)276{277 var mounting = mxUtils.getValue(this.style, mxShapePidCompFunc.prototype.cst.MOUNTING, 'field');278279 if (mounting === mxShapePidCompFunc.prototype.cst.ROOM)280 {281 c.begin();282 c.moveTo(0, h * 0.5);283 c.lineTo(w, h * 0.5);284 c.stroke();285 }286 else if (mounting === mxShapePidCompFunc.prototype.cst.INACCESSIBLE)287 {288 c.setDashed(true);289 c.begin();290 c.moveTo(0, h * 0.5);291 c.lineTo(w, h * 0.5);292 c.stroke();293 }294 else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)295 {296 c.begin();297 c.moveTo(w * 0.01, h * 0.48);298 c.lineTo(w * 0.99, h * 0.48);299 c.moveTo(w * 0.01, h * 0.52);300 c.lineTo(w * 0.99, h * 0.52);301 c.stroke();302 }303};304305mxCellRenderer.registerShape(mxShapePidCompFunc.prototype.cst.SHAPE_COMP_FUNC, mxShapePidCompFunc);306307mxShapePidCompFunc.prototype.constraints = [308 new mxConnectionConstraint(new mxPoint(0.5, 0), true),309 new mxConnectionConstraint(new mxPoint(0.5, 1), true),310 new mxConnectionConstraint(new mxPoint(0, 0.5), true),311 new mxConnectionConstraint(new mxPoint(1, 0.5), true),312 new mxConnectionConstraint(new mxPoint(0.25, 0), false),313 new mxConnectionConstraint(new mxPoint(0.75, 0), false),314 new mxConnectionConstraint(new mxPoint(0.25, 1), false),315 new mxConnectionConstraint(new mxPoint(0.75, 1), false)316 ];317318//**********************************************************************************************************************************************************319//Computer Function320//**********************************************************************************************************************************************************321/**322* Extends mxShape.323*/324function mxShapePidProgLogCont(bounds, fill, stroke, strokewidth)325{326 mxShape.call(this);327 this.bounds = bounds;328 this.fill = fill;329 this.stroke = stroke;330 this.strokewidth = (strokewidth != null) ? strokewidth : 1;331};332333/**334* Extends mxShape.335*/336mxUtils.extend(mxShapePidProgLogCont, mxShape);337338mxShapePidProgLogCont.prototype.cst = {339 SHAPE_PROG_LOG_CONT : 'mxgraph.pid2inst.progLogCont',340 MOUNTING : 'mounting',341 FIELD : 'field',342 ROOM : 'room',343 INACCESSIBLE : 'inaccessible',344 LOCAL : 'local'345};346347mxShapePidProgLogCont.prototype.customProperties = [348 {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',349 enumList: [350 {val:'field', dispName:'Field'},351 {val:'room', dispName:'Room'},352 {val:'inaccessible', dispName:'Inaccessible'},353 {val:'local', dispName:'Local'}354 ]}355];356357/**358* Function: paintVertexShape359* 360* Paints the vertex shape.361*/362mxShapePidProgLogCont.prototype.paintVertexShape = function(c, x, y, w, h)363{364 c.translate(x, y);365 this.background(c, x, y, w, h);366 c.setShadow(false);367 this.foreground(c, x, y, w, h);368};369370mxShapePidProgLogCont.prototype.background = function(c, x, y, w, h)371{372 c.rect(0, 0, w, h);373 c.fillAndStroke();374};375376mxShapePidProgLogCont.prototype.foreground = function(c, x, y, w, h)377{378 var mounting = mxUtils.getValue(this.style, mxShapePidProgLogCont.prototype.cst.MOUNTING, 'field');379380 c.begin();381 c.moveTo(0, h * 0.5);382 c.lineTo(w * 0.5, 0);383 c.lineTo(w, h * 0.5);384 c.lineTo(w * 0.5, h);385 c.close();386 c.stroke();387 388 if (mounting === mxShapePidProgLogCont.prototype.cst.ROOM)389 {390 c.begin();391 c.moveTo(0, h * 0.5);392 c.lineTo(w, h * 0.5);393 c.stroke();394 }395 else if (mounting === mxShapePidProgLogCont.prototype.cst.INACCESSIBLE)396 {397 c.setDashed(true);398 c.begin();399 c.moveTo(0, h * 0.5);400 c.lineTo(w, h * 0.5);401 c.stroke();402 }403 else if (mounting === mxShapePidDiscInst.prototype.cst.LOCAL)404 {405 c.begin();406 c.moveTo(w * 0.02, h * 0.48);407 c.lineTo(w * 0.98, h * 0.48);408 c.moveTo(w * 0.02, h * 0.52);409 c.lineTo(w * 0.98, h * 0.52);410 c.stroke();411 }412};413414mxCellRenderer.registerShape(mxShapePidProgLogCont.prototype.cst.SHAPE_PROG_LOG_CONT, mxShapePidProgLogCont);415416mxShapePidProgLogCont.prototype.constraints = [417 new mxConnectionConstraint(new mxPoint(0.5, 0), true),418 new mxConnectionConstraint(new mxPoint(0.5, 1), true),419 new mxConnectionConstraint(new mxPoint(0, 0.5), true),420 new mxConnectionConstraint(new mxPoint(1, 0.5), true),421 new mxConnectionConstraint(new mxPoint(0, 0), false),422 new mxConnectionConstraint(new mxPoint(0, 1), false),423 new mxConnectionConstraint(new mxPoint(1, 0), false),424 new mxConnectionConstraint(new mxPoint(1, 1), false)425 ];426427//**********************************************************************************************************************************************************428//Indicator429//**********************************************************************************************************************************************************430/**431* Extends mxShape.432*/433function mxShapePidIndicator(bounds, fill, stroke, strokewidth)434{435 mxShape.call(this);436 this.bounds = bounds;437 this.fill = fill;438 this.stroke = stroke;439 this.strokewidth = (strokewidth != null) ? strokewidth : 1;440};441442/**443* Extends mxShape.444*/445mxUtils.extend(mxShapePidIndicator, mxShape);446447mxShapePidIndicator.prototype.cst = {448 SHAPE_INDICATOR : 'mxgraph.pid2inst.indicator',449 MOUNTING : 'mounting',450 FIELD : 'field',451 ROOM : 'room',452 INACCESSIBLE : 'inaccessible',453 LOCAL : 'local',454 IND_TYPE : 'indType',455 INSTRUMENT : 'inst',456 CONTROL : 'ctrl',457 FUNCTION : 'func',458 PLC : 'plc'459};460461mxShapePidIndicator.prototype.customProperties = [462 {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',463 enumList: [464 {val:'field', dispName:'Field'},465 {val:'room', dispName:'Room'},466 {val:'inaccessible', dispName:'Inaccessible'},467 {val:'local', dispName:'Local'}468 ]},469 {name: 'indType', dispName: 'Type', type: 'enum', defVal:'inst',470 enumList: [471 {val:'inst', dispName:'Instrument'},472 {val:'ctrl', dispName:'Control'},473 {val:'func', dispName:'Function'},474 {val:'plc', dispName:'PLC'}475 ]}476];477478/**479* Function: paintVertexShape480* 481* Paints the vertex shape.482*/483mxShapePidIndicator.prototype.paintVertexShape = function(c, x, y, w, h)484{485 c.translate(x, y);486 this.background(c, x, y, w, h);487 c.setShadow(false);488 this.foreground(c, x, y, w, h);489};490491mxShapePidIndicator.prototype.background = function(c, x, y, w, h)492{493 var type = mxUtils.getValue(this.style, mxShapePidIndicator.prototype.cst.IND_TYPE, 'inst');494 495 c.begin();496 c.moveTo(w * 0.5, w);497 c.lineTo(w * 0.5, h);498 c.stroke();499500 if (type === mxShapePidIndicator.prototype.cst.INSTRUMENT)501 {502 c.ellipse(0, 0, w, w);503 c.fillAndStroke();504 }505 else if (type === mxShapePidIndicator.prototype.cst.CONTROL)506 {507 c.rect(0, 0, w, w);508 c.fillAndStroke();509 }510 else if (type === mxShapePidIndicator.prototype.cst.FUNCTION)511 {512 c.begin();513 c.moveTo(0, w * 0.5);514 c.lineTo(w * 0.25, 0);515 c.lineTo(w * 0.75, 0);516 c.lineTo(w, w * 0.5);517 c.lineTo(w * 0.75, w);518 c.lineTo(w * 0.25, w);519 c.close();520 c.fillAndStroke();521 }522 else if (type === mxShapePidIndicator.prototype.cst.PLC)523 {524 c.rect(0, 0, w, w);525 c.fillAndStroke();526 }527};528529mxShapePidIndicator.prototype.foreground = function(c, x, y, w, h)530{531 var mounting = mxUtils.getValue(this.style, mxShapePidIndicator.prototype.cst.MOUNTING, 'field');532 var type = mxUtils.getValue(this.style, mxShapePidIndicator.prototype.cst.IND_TYPE, 'inst');533534 if (type === mxShapePidIndicator.prototype.cst.CONTROL)535 {536 c.ellipse(0, 0, w, w);537 c.stroke();538 }539 else if (type === mxShapePidIndicator.prototype.cst.PLC)540 {541 c.begin();542 c.moveTo(0, w * 0.5);543 c.lineTo(w * 0.5, 0);544 c.lineTo(w, w * 0.5);545 c.lineTo(w * 0.5, w);546 c.close();547 c.stroke();548 }549550 if (mounting === mxShapePidIndicator.prototype.cst.ROOM)551 {552 c.begin();553 c.moveTo(0, w * 0.5);554 c.lineTo(w, w * 0.5);555 c.stroke();556 }557 else if (mounting === mxShapePidIndicator.prototype.cst.INACCESSIBLE)558 {559 c.setDashed(true);560 c.begin();561 c.moveTo(0, w * 0.5);562 c.lineTo(w, w * 0.5);563 c.stroke();564 }565 else if (mounting === mxShapePidIndicator.prototype.cst.LOCAL)566 {567 c.begin();568 c.moveTo(w * 0.005, w * 0.48);569 c.lineTo(w * 0.995, w * 0.48);570 c.moveTo(w * 0.005, w * 0.52);571 c.lineTo(w * 0.995, w * 0.52);572 c.stroke();573 }574};575576mxCellRenderer.registerShape(mxShapePidIndicator.prototype.cst.SHAPE_INDICATOR, mxShapePidIndicator);577578mxShapePidIndicator.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.5, 1), true)];579580//**********************************************************************************************************************************************************581//Logic582//**********************************************************************************************************************************************************583/**584* Extends mxShape.585*/586function mxShapePidLogic(bounds, fill, stroke, strokewidth)587{588 mxShape.call(this);589 this.bounds = bounds;590 this.fill = fill;591 this.stroke = stroke;592 this.strokewidth = (strokewidth != null) ? strokewidth : 1;593};594595/**596* Extends mxShape.597*/598mxUtils.extend(mxShapePidLogic, mxShape);599600mxShapePidLogic.prototype.cst = {601 SHAPE_LOGIC : 'mxgraph.pid2inst.logic',602 MOUNTING : 'mounting',603 FIELD : 'field',604 ROOM : 'room',605 INACCESSIBLE : 'inaccessible',606 LOCAL : 'local'607};608609mxShapePidLogic.prototype.customProperties = [610 {name: 'mounting', dispName: 'Mounting', type: 'enum', defVal:'field',611 enumList: [612 {val:'field', dispName:'Field'},613 {val:'room', dispName:'Room'},614 {val:'inaccessible', dispName:'Inaccessible'},615 {val:'local', dispName:'Local'}616 ]}617];618619/**620* Function: paintVertexShape621* 622* Paints the vertex shape.623*/624mxShapePidLogic.prototype.paintVertexShape = function(c, x, y, w, h)625{626 c.translate(x, y);627 this.background(c, x, y, w, h);628 c.setShadow(false);629 this.foreground(c, x, y, w, h);630};631632mxShapePidLogic.prototype.background = function(c, x, y, w, h)633{634 c.begin();635 c.moveTo(0, h * 0.5);636 c.lineTo(w * 0.5, 0);637 c.lineTo(w, h * 0.5);638 c.lineTo(w * 0.5, h);639 c.close();640 c.fillAndStroke();641};642643mxShapePidLogic.prototype.foreground = function(c, x, y, w, h)644{645 var mounting = mxUtils.getValue(this.style, mxShapePidLogic.prototype.cst.MOUNTING, 'field');646647 if (mounting === mxShapePidLogic.prototype.cst.ROOM)648 {649 c.begin();650 c.moveTo(0, h * 0.5);651 c.lineTo(w, h * 0.5);652 c.stroke();653 }654 else if (mounting === mxShapePidLogic.prototype.cst.INACCESSIBLE)655 {656 c.setDashed(true);657 c.begin();658 c.moveTo(0, h * 0.5);659 c.lineTo(w, h * 0.5);660 c.stroke();661 }662 else if (mounting === mxShapePidLogic.prototype.cst.LOCAL)663 {664 c.begin();665 c.moveTo(w * 0.02, h * 0.48);666 c.lineTo(w * 0.98, h * 0.48);667 c.moveTo(w * 0.02, h * 0.52);668 c.lineTo(w * 0.98, h * 0.52);669 c.stroke();670 }671};672673mxCellRenderer.registerShape(mxShapePidLogic.prototype.cst.SHAPE_LOGIC, mxShapePidLogic);674675mxShapePidLogic.prototype.constraints = [676 new mxConnectionConstraint(new mxPoint(0.5, 0), true),677 new mxConnectionConstraint(new mxPoint(0.5, 1), true),678 new mxConnectionConstraint(new mxPoint(0, 0.5), true),679 new mxConnectionConstraint(new mxPoint(1, 0.5), true),680 new mxConnectionConstraint(new mxPoint(0.25, 0.25), false),681 new mxConnectionConstraint(new mxPoint(0.25, 0.75), false),682 new mxConnectionConstraint(new mxPoint(0.75, 0.25), false),683 new mxConnectionConstraint(new mxPoint(0.75, 0.75), false)684 ];