Ports in nodes
Thu Jan 19 19:43:08 WET 2006 Miguel Vilaca <jmvilaca@di.uminho.pt>
* Ports in nodes
This changes the notion of node.
A node now can have ports which are the places where edges can be connected.
Those ports are optional to continue allowing simple graphs.
This implies big changes in the Network, the Palette, the selection mechanism, the read/write to file operations and the display on canvas feature.
{
addfile ./NatExample.INblobs
hunk ./NatExample.INblobs 1
-
+<Network[_^M_][_$_]
+ ><Width[_^M_][_$_]
+ >15.0</Width[_^M_][_$_]
+ ><Height[_^M_][_$_]
+ >9.0</Height[_^M_][_$_]
+ ><Info[_^M_][_$_]
+ ><unit/></Info[_^M_][_$_]
+ ><Palette[_^M_][_$_]
+ ><Palette[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[interface]]></string[_^M_][_$_]
+ ><Circle[_^M_][_$_]
+ ><ShapeStyle[_^M_][_$_]
+ ><int value="2"[_^M_][_$_]
+ /><RGB[_^M_][_$_]
+ ><int value="255"[_^M_][_$_]
+ /><int value="255"[_^M_][_$_]
+ /><int value="255"/></RGB[_^M_][_$_]
+ ><RGB[_^M_][_$_]
+ ><int value="255"[_^M_][_$_]
+ /><int value="255"[_^M_][_$_]
+ /><int value="255"/></RGB></ShapeStyle[_^M_][_$_]
+ ><double value="0.25"/></Circle[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.25</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><maybe-list-int[_^M_][_$_]
+ ><list-int/></maybe-list-int[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[A]]></string[_^M_][_$_]
+ ><Composite[_^M_][_$_]
+ ><list-Shape[_^M_][_$_]
+ ><Circle[_^M_][_$_]
+ ><ShapeStyle[_^M_][_$_]
+ ><int value="2"[_^M_][_$_]
+ /><RGB[_^M_][_$_]
+ ><int value="250"[_^M_][_$_]
+ /><int value="0"[_^M_][_$_]
+ /><int value="0"/></RGB[_^M_][_$_]
+ ><RGB[_^M_][_$_]
+ ><int value="255"[_^M_][_$_]
+ /><int value="255"[_^M_][_$_]
+ /><int value="255"/></RGB></ShapeStyle[_^M_][_$_]
+ ><double value="0.5"/></Circle[_^M_][_$_]
+ ><Lines[_^M_][_$_]
+ ><ShapeStyle[_^M_][_$_]
+ ><int value="2"[_^M_][_$_]
+ /><RGB[_^M_][_$_]
+ ><int value="250"[_^M_][_$_]
+ /><int value="0"[_^M_][_$_]
+ /><int value="0"/></RGB[_^M_][_$_]
+ ><RGB[_^M_][_$_]
+ ><int value="128"[_^M_][_$_]
+ /><int value="128"[_^M_][_$_]
+ /><int value="128"/></RGB></ShapeStyle[_^M_][_$_]
+ ><list-DoublePoint[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.25</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >-0.35</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.25</Y></list-DoublePoint></Lines[_^M_][_$_]
+ ><Lines[_^M_][_$_]
+ ><ShapeStyle[_^M_][_$_]
+ ><int value="2"[_^M_][_$_]
+ /><RGB[_^M_][_$_]
+ ><int value="250"[_^M_][_$_]
+ /><int value="0"[_^M_][_$_]
+ /><int value="0"/></RGB[_^M_][_$_]
+ ><RGB[_^M_][_$_]
+ ><int value="128"[_^M_][_$_]
+ /><int value="128"[_^M_][_$_]
+ /><int value="128"/></RGB></ShapeStyle[_^M_][_$_]
+ ><list-DoublePoint[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.2</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.1</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.2</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.1</Y></list-DoublePoint></Lines></list-Shape></Composite[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[left]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.5</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[right]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.5</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><maybe-list-int[_^M_][_$_]
+ ><list-int/></maybe-list-int[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[Z]]></string[_^M_][_$_]
+ ><Composite[_^M_][_$_]
+ ><list-Shape[_^M_][_$_]
+ ><Circle[_^M_][_$_]
+ ><ShapeStyle[_^M_][_$_]
+ ><int value="2"[_^M_][_$_]
+ /><RGB[_^M_][_$_]
+ ><int value="250"[_^M_][_$_]
+ /><int value="0"[_^M_][_$_]
+ /><int value="0"/></RGB[_^M_][_$_]
+ ><RGB[_^M_][_$_]
+ ><int value="255"[_^M_][_$_]
+ /><int value="255"[_^M_][_$_]
+ /><int value="255"/></RGB></ShapeStyle[_^M_][_$_]
+ ><double value="0.5"/></Circle[_^M_][_$_]
+ ><Lines[_^M_][_$_]
+ ><ShapeStyle[_^M_][_$_]
+ ><int value="2"[_^M_][_$_]
+ /><RGB[_^M_][_$_]
+ ><int value="250"[_^M_][_$_]
+ /><int value="0"[_^M_][_$_]
+ /><int value="0"/></RGB[_^M_][_$_]
+ ><RGB[_^M_][_$_]
+ ><int value="128"[_^M_][_$_]
+ /><int value="128"[_^M_][_$_]
+ /><int value="128"/></RGB></ShapeStyle[_^M_][_$_]
+ ><list-DoublePoint[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >-0.25</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >-0.25</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.25</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.25</Y></list-DoublePoint></Lines[_^M_][_$_]
+ ><Lines[_^M_][_$_]
+ ><ShapeStyle[_^M_][_$_]
+ ><int value="2"[_^M_][_$_]
+ /><RGB[_^M_][_$_]
+ ><int value="250"[_^M_][_$_]
+ /><int value="0"[_^M_][_$_]
+ /><int value="0"/></RGB[_^M_][_$_]
+ ><RGB[_^M_][_$_]
+ ><int value="128"[_^M_][_$_]
+ /><int value="128"[_^M_][_$_]
+ /><int value="128"/></RGB></ShapeStyle[_^M_][_$_]
+ ><list-DoublePoint[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.15</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.15</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y></list-DoublePoint></Lines></list-Shape></Composite[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><maybe-list-int[_^M_][_$_]
+ ><list-int/></maybe-list-int[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[S]]></string[_^M_][_$_]
+ ><Composite[_^M_][_$_]
+ ><list-Shape[_^M_][_$_]
+ ><Circle[_^M_][_$_]
+ ><ShapeStyle[_^M_][_$_]
+ ><int value="2"[_^M_][_$_]
+ /><RGB[_^M_][_$_]
+ ><int value="250"[_^M_][_$_]
+ /><int value="0"[_^M_][_$_]
+ /><int value="0"/></RGB[_^M_][_$_]
+ ><RGB[_^M_][_$_]
+ ><int value="255"[_^M_][_$_]
+ /><int value="255"[_^M_][_$_]
+ /><int value="255"/></RGB></ShapeStyle[_^M_][_$_]
+ ><double value="0.5"/></Circle[_^M_][_$_]
+ ><Lines[_^M_][_$_]
+ ><ShapeStyle[_^M_][_$_]
+ ><int value="2"[_^M_][_$_]
+ /><RGB[_^M_][_$_]
+ ><int value="250"[_^M_][_$_]
+ /><int value="0"[_^M_][_$_]
+ /><int value="0"/></RGB[_^M_][_$_]
+ ><RGB[_^M_][_$_]
+ ><int value="128"[_^M_][_$_]
+ /><int value="128"[_^M_][_$_]
+ /><int value="128"/></RGB></ShapeStyle[_^M_][_$_]
+ ><list-DoublePoint[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >-0.25</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >-0.25</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.25</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.25</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.25</Y></list-DoublePoint></Lines></list-Shape></Composite[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[up]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >-0.5</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><maybe-list-int[_^M_][_$_]
+ ><list-int/></maybe-list-int></Palette></Palette[_^M_][_$_]
+ ><Nodes[_^M_][_$_]
+ ><Node id="N1"[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.635</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >2.3018750000000003</Y[_^M_][_$_]
+ ><Name[_^M_][_$_]
+ ><![CDATA[Node 1]]></Name[_^M_][_$_]
+ ><LabelAbove[_^M_][_$_]
+ >True</LabelAbove[_^M_][_$_]
+ ><Shape[_^M_][_$_]
+ ><Left-string[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[Z]]></string></Left-string></Shape[_^M_][_$_]
+ ><Ports[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint></Ports[_^M_][_$_]
+ ><Info[_^M_][_$_]
+ ><list-int/></Info></Node[_^M_][_$_]
+ ><Node id="N2"[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >6.0325</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >2.3018750000000003</Y[_^M_][_$_]
+ ><Name[_^M_][_$_]
+ ><![CDATA[Node 2]]></Name[_^M_][_$_]
+ ><LabelAbove[_^M_][_$_]
+ >True</LabelAbove[_^M_][_$_]
+ ><Shape[_^M_][_$_]
+ ><Left-string[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[Z]]></string></Left-string></Shape[_^M_][_$_]
+ ><Ports[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint></Ports[_^M_][_$_]
+ ><Info[_^M_][_$_]
+ ><list-int/></Info></Node[_^M_][_$_]
+ ><Node id="N3"[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.635</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >4.709583333333335</Y[_^M_][_$_]
+ ><Name[_^M_][_$_]
+ ><![CDATA[Node 3]]></Name[_^M_][_$_]
+ ><LabelAbove[_^M_][_$_]
+ >True</LabelAbove[_^M_][_$_]
+ ><Shape[_^M_][_$_]
+ ><Left-string[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[S]]></string></Left-string></Shape[_^M_][_$_]
+ ><Ports[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[up]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >-0.5</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint></Ports[_^M_][_$_]
+ ><Info[_^M_][_$_]
+ ><list-int/></Info></Node[_^M_][_$_]
+ ><Node id="N4"[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >6.032500000000001</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >4.736041666666667</Y[_^M_][_$_]
+ ><Name[_^M_][_$_]
+ ><![CDATA[Node 4]]></Name[_^M_][_$_]
+ ><LabelAbove[_^M_][_$_]
+ >True</LabelAbove[_^M_][_$_]
+ ><Shape[_^M_][_$_]
+ ><Left-string[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[S]]></string></Left-string></Shape[_^M_][_$_]
+ ><Ports[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[up]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >-0.5</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint></Ports[_^M_][_$_]
+ ><Info[_^M_][_$_]
+ ><list-int/></Info></Node[_^M_][_$_]
+ ><Node id="N5"[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >2.4341666666666666</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >4.709583333333334</Y[_^M_][_$_]
+ ><Name[_^M_][_$_]
+ ><![CDATA[Node 5]]></Name[_^M_][_$_]
+ ><LabelAbove[_^M_][_$_]
+ >True</LabelAbove[_^M_][_$_]
+ ><Shape[_^M_][_$_]
+ ><Left-string[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[A]]></string></Left-string></Shape[_^M_][_$_]
+ ><Ports[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[left]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.5</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[right]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.5</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint></Ports[_^M_][_$_]
+ ><Info[_^M_][_$_]
+ ><list-int/></Info></Node[_^M_][_$_]
+ ><Node id="N6"[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >7.858125</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >4.736041666666667</Y[_^M_][_$_]
+ ><Name[_^M_][_$_]
+ ><![CDATA[Node 6]]></Name[_^M_][_$_]
+ ><LabelAbove[_^M_][_$_]
+ >True</LabelAbove[_^M_][_$_]
+ ><Shape[_^M_][_$_]
+ ><Left-string[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[A]]></string></Left-string></Shape[_^M_][_$_]
+ ><Ports[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[left]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.5</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[right]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.5</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint></Ports[_^M_][_$_]
+ ><Info[_^M_][_$_]
+ ><list-int/></Info></Node[_^M_][_$_]
+ ><Node id="N7"[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >1.9314583333333335</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >1.2435416666666668</Y[_^M_][_$_]
+ ><Name[_^M_][_$_]
+ ><![CDATA[Node 7]]></Name[_^M_][_$_]
+ ><LabelAbove[_^M_][_$_]
+ >True</LabelAbove[_^M_][_$_]
+ ><Shape[_^M_][_$_]
+ ><Left-string[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[interface]]></string></Left-string></Shape[_^M_][_$_]
+ ><Ports[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.25</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint></Ports[_^M_][_$_]
+ ><Info[_^M_][_$_]
+ ><list-int/></Info></Node[_^M_][_$_]
+ ><Node id="N8"[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >8.334375000000001</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >1.2699999999999998</Y[_^M_][_$_]
+ ><Name[_^M_][_$_]
+ ><![CDATA[Node 8]]></Name[_^M_][_$_]
+ ><LabelAbove[_^M_][_$_]
+ >True</LabelAbove[_^M_][_$_]
+ ><Shape[_^M_][_$_]
+ ><Left-string[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[interface]]></string></Left-string></Shape[_^M_][_$_]
+ ><Ports[_^M_][_$_]
+ ><maybe-list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><list-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.25</Y></list-tuple2-string-DoublePoint></maybe-list-tuple2-string-DoublePoint></Ports[_^M_][_$_]
+ ><Info[_^M_][_$_]
+ ><list-int/></Info></Node></Nodes[_^M_][_$_]
+ ><Edges[_^M_][_$_]
+ ><Edge id="E1"[_^M_][_$_]
+ ><From[_^M_][_$_]
+ >7</From[_^M_][_$_]
+ ><PortFrom[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.25</Y></maybe-tuple2-string-DoublePoint></PortFrom[_^M_][_$_]
+ ><To[_^M_][_$_]
+ >5</To[_^M_][_$_]
+ ><PortTo[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[left]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.5</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y></maybe-tuple2-string-DoublePoint></PortTo[_^M_][_$_]
+ ><Via[_^M_][_$_]
+ /><Info[_^M_][_$_]
+ ><list-int/></Info></Edge[_^M_][_$_]
+ ><Edge id="E2"[_^M_][_$_]
+ ><From[_^M_][_$_]
+ >8</From[_^M_][_$_]
+ ><PortFrom[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.25</Y></maybe-tuple2-string-DoublePoint></PortFrom[_^M_][_$_]
+ ><To[_^M_][_$_]
+ >6</To[_^M_][_$_]
+ ><PortTo[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[right]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.5</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y></maybe-tuple2-string-DoublePoint></PortTo[_^M_][_$_]
+ ><Via[_^M_][_$_]
+ /><Info[_^M_][_$_]
+ ><list-int/></Info></Edge[_^M_][_$_]
+ ><Edge id="E3"[_^M_][_$_]
+ ><From[_^M_][_$_]
+ >5</From[_^M_][_$_]
+ ><PortFrom[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[right]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.5</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y></maybe-tuple2-string-DoublePoint></PortFrom[_^M_][_$_]
+ ><To[_^M_][_$_]
+ >6</To[_^M_][_$_]
+ ><PortTo[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[left]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >-0.5</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.0</Y></maybe-tuple2-string-DoublePoint></PortTo[_^M_][_$_]
+ ><Via[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >2.9104166666666673</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >1.6668749999999999</Y[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >7.355416666666667</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >1.6668749999999999</Y></Via[_^M_][_$_]
+ ><Info[_^M_][_$_]
+ ><list-int/></Info></Edge[_^M_][_$_]
+ ><Edge id="E4"[_^M_][_$_]
+ ><From[_^M_][_$_]
+ >1</From[_^M_][_$_]
+ ><PortFrom[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y></maybe-tuple2-string-DoublePoint></PortFrom[_^M_][_$_]
+ ><To[_^M_][_$_]
+ >3</To[_^M_][_$_]
+ ><PortTo[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[up]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >-0.5</Y></maybe-tuple2-string-DoublePoint></PortTo[_^M_][_$_]
+ ><Via[_^M_][_$_]
+ /><Info[_^M_][_$_]
+ ><list-int/></Info></Edge[_^M_][_$_]
+ ><Edge id="E5"[_^M_][_$_]
+ ><From[_^M_][_$_]
+ >2</From[_^M_][_$_]
+ ><PortFrom[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y></maybe-tuple2-string-DoublePoint></PortFrom[_^M_][_$_]
+ ><To[_^M_][_$_]
+ >4</To[_^M_][_$_]
+ ><PortTo[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[up]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >-0.5</Y></maybe-tuple2-string-DoublePoint></PortTo[_^M_][_$_]
+ ><Via[_^M_][_$_]
+ /><Info[_^M_][_$_]
+ ><list-int/></Info></Edge[_^M_][_$_]
+ ><Edge id="E6"[_^M_][_$_]
+ ><From[_^M_][_$_]
+ >3</From[_^M_][_$_]
+ ><PortFrom[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y></maybe-tuple2-string-DoublePoint></PortFrom[_^M_][_$_]
+ ><To[_^M_][_$_]
+ >5</To[_^M_][_$_]
+ ><PortTo[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y></maybe-tuple2-string-DoublePoint></PortTo[_^M_][_$_]
+ ><Via[_^M_][_$_]
+ /><Info[_^M_][_$_]
+ ><list-int/></Info></Edge[_^M_][_$_]
+ ><Edge id="E7"[_^M_][_$_]
+ ><From[_^M_][_$_]
+ >4</From[_^M_][_$_]
+ ><PortFrom[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y></maybe-tuple2-string-DoublePoint></PortFrom[_^M_][_$_]
+ ><To[_^M_][_$_]
+ >6</To[_^M_][_$_]
+ ><PortTo[_^M_][_$_]
+ ><maybe-tuple2-string-DoublePoint[_^M_][_$_]
+ ><string[_^M_][_$_]
+ ><![CDATA[down]]></string[_^M_][_$_]
+ ><X[_^M_][_$_]
+ >0.0</X[_^M_][_$_]
+ ><Y[_^M_][_$_]
+ >0.5</Y></maybe-tuple2-string-DoublePoint></PortTo[_^M_][_$_]
+ ><Via[_^M_][_$_]
+ /><Info[_^M_][_$_]
+ ><list-int/></Info></Edge></Edges></Network>
addfile ./NatIN.INblobpalette
hunk ./NatIN.INblobpalette 1
+ Palette[_^M_][_$_]
+ [ ("interface"[_^M_][_$_]
+ , ( Circle { shapeStyle = ShapeStyle[_^M_][_$_]
+ { styleStrokeWidth = 2[_^M_][_$_]
+ , styleStrokeColour = RGB 255 255 255[_^M_][_$_]
+ , styleFill = RGB 255 255 255[_^M_][_$_]
+ }[_^M_][_$_]
+ , shapeRadius = 0.25[_^M_][_$_]
+ }[_^M_][_$_]
+ , Just [("down", DoublePoint 0.0 0.25)][_^M_][_$_]
+ , Just [] ))[_^M_][_$_]
+ , ("A"[_^M_][_$_]
+ , ( Composite { shapeSegments =[_^M_][_$_]
+ [ Circle { shapeStyle = ShapeStyle[_^M_][_$_]
+ { styleStrokeWidth = 2[_^M_][_$_]
+ , styleStrokeColour = RGB 250 0 0[_^M_][_$_]
+ , styleFill = RGB 255 255 255[_^M_][_$_]
+ }[_^M_][_$_]
+ , shapeRadius = 0.5[_^M_][_$_]
+ }[_^M_][_$_]
+ , Lines { shapeStyle = ShapeStyle[_^M_][_$_]
+ { styleStrokeWidth = 2[_^M_][_$_]
+ , styleStrokeColour = RGB 250 0 0[_^M_][_$_]
+ , styleFill = RGB 128 128 128[_^M_][_$_]
+ }[_^M_][_$_]
+ , shapePerimeter = [ DoublePoint (-0.25) 0.25[_^M_][_$_]
+ , DoublePoint 0.0 (-0.35)[_^M_][_$_]
+ , DoublePoint 0.25 0.25 ] }[_^M_][_$_]
+ , Lines { shapeStyle = ShapeStyle[_^M_][_$_]
+ { styleStrokeWidth = 2[_^M_][_$_]
+ , styleStrokeColour = RGB 250 0 0[_^M_][_$_]
+ , styleFill = RGB 128 128 128[_^M_][_$_]
+ }[_^M_][_$_]
+ , shapePerimeter = [ DoublePoint (-0.20) 0.10[_^M_][_$_]
+ , DoublePoint 0.20 0.10 ] }[_^M_][_$_]
+ ] }[_^M_][_$_]
+ , Just [("down" , DoublePoint 0.0 0.5)[_^M_][_$_]
+ ,("left" , DoublePoint (-0.5) 0.0)[_^M_][_$_]
+ ,("right", DoublePoint 0.5 0.0)][_^M_][_$_]
+ , Just [] ))[_^M_][_$_]
+ , ("Z"[_^M_][_$_]
+ , ( Composite { shapeSegments =[_^M_][_$_]
+ [ Circle { shapeStyle = ShapeStyle[_^M_][_$_]
+ { styleStrokeWidth = 2[_^M_][_$_]
+ , styleStrokeColour = RGB 250 0 0[_^M_][_$_]
+ , styleFill = RGB 255 255 255[_^M_][_$_]
+ }[_^M_][_$_]
+ , shapeRadius = 0.5[_^M_][_$_]
+ }[_^M_][_$_]
+ , Lines { shapeStyle = ShapeStyle[_^M_][_$_]
+ { styleStrokeWidth = 2[_^M_][_$_]
+ , styleStrokeColour = RGB 250 0 0[_^M_][_$_]
+ , styleFill = RGB 128 128 128[_^M_][_$_]
+ }[_^M_][_$_]
+ , shapePerimeter = [ DoublePoint (-0.25) (-0.25)[_^M_][_$_]
+ , DoublePoint 0.25 (-0.25)[_^M_][_$_]
+ , DoublePoint (-0.25) 0.25[_^M_][_$_]
+ , DoublePoint 0.25 0.25 ] }[_^M_][_$_]
+ , Lines { shapeStyle = ShapeStyle[_^M_][_$_]
+ { styleStrokeWidth = 2[_^M_][_$_]
+ , styleStrokeColour = RGB 250 0 0[_^M_][_$_]
+ , styleFill = RGB 128 128 128[_^M_][_$_]
+ }[_^M_][_$_]
+ , shapePerimeter = [ DoublePoint (-0.15) 0.0[_^M_][_$_]
+ , DoublePoint 0.15 0.0 ] }[_^M_][_$_]
+ ] }[_^M_][_$_]
+ , Just [("down" , DoublePoint 0.0 0.5)][_^M_][_$_]
+ , Just [] ))[_^M_][_$_]
+, ("S"[_^M_][_$_]
+ , ( Composite { shapeSegments =[_^M_][_$_]
+ [ Circle { shapeStyle = ShapeStyle[_^M_][_$_]
+ { styleStrokeWidth = 2[_^M_][_$_]
+ , styleStrokeColour = RGB 250 0 0[_^M_][_$_]
+ , styleFill = RGB 255 255 255[_^M_][_$_]
+ }[_^M_][_$_]
+ , shapeRadius = 0.5[_^M_][_$_]
+ }[_^M_][_$_]
+ , Lines { shapeStyle = ShapeStyle[_^M_][_$_]
+ { styleStrokeWidth = 2[_^M_][_$_]
+ , styleStrokeColour = RGB 250 0 0[_^M_][_$_]
+ , styleFill = RGB 128 128 128[_^M_][_$_]
+ }[_^M_][_$_]
+ , shapePerimeter = [ DoublePoint 0.25 (-0.25)[_^M_][_$_]
+ , DoublePoint (-0.25) (-0.25)[_^M_][_$_]
+ , DoublePoint (-0.25) 0.0[_^M_][_$_]
+ , DoublePoint 0.25 0.0[_^M_][_$_]
+ , DoublePoint 0.25 0.25 [_^M_][_$_]
+ , DoublePoint (-0.25) 0.25[_^M_][_$_]
+ ] }[_^M_][_$_]
+ ] }[_^M_][_$_]
+ , Just [ ("down" , DoublePoint 0.0 0.5)[_^M_][_$_]
+ , ("up" , DoublePoint 0.0 (-0.5) )][_^M_][_$_]
+ , Just [] ))[_^M_][_$_]
+ ][_^M_][_$_]
hunk ./src/ContextMenu.hs 128
- shapeItem curShape contextMenu (name,(shape,info)) =
+ shapeItem curShape contextMenu (name,(shape,ports,info)) =
hunk ./src/Document.hs 21
+import Ports
hunk ./src/Document.hs 34
- | NodeSelection Int
+ | NodeSelection Int (Maybe Port)
hunk ./src/GUIEvents.hs 4
-import NetworkView(clickedNode, clickedEdge, clickedVia)
+import NetworkView(clickedNode, clickedNodePort, clickedEdge, clickedVia)
hunk ./src/GUIEvents.hs 26
- ; case clickedNode doubleMousePoint doc of
+ ; case clickedNodePort doubleMousePoint doc of
hunk ./src/GUIEvents.hs 53
- Just nodeNr ->
+ Just (nodeNr, mPort) ->
hunk ./src/GUIEvents.hs 58
- _ -> pickupNode nodeNr doubleMousePoint state
+ _ -> pickupNode nodeNr mPort doubleMousePoint state
hunk ./src/GUIEvents.hs 73
- ; case clickedNode doubleMousePoint doc of
+ ; case clickedNodePort doubleMousePoint doc of
hunk ./src/GUIEvents.hs 78
- createNode doubleMousePoint state
+ createNode doubleMousePoint state -- change shape of new node
hunk ./src/GUIEvents.hs 81
- Just j -> do -- shift click on node = create edge (if possible)
- case getSelection doc of
- NodeSelection i | i /= j ->
- createEdge i j state
- _ -> selectNode j state
+ Just (j,mP) -> do -- shift click on node = create edge (if possible) [_$_]
+ case (getSelection doc, mP) of
+ (NodeSelection i Nothing, Nothing) | i /= j -> logMessage "Only allow connections between ports." -- createEdge i j state
+ (NodeSelection i Nothing, Just p') -> logMessage "Repeat it selecting a source port."
+ (NodeSelection i (Just p),Nothing) -> logMessage "Select a destination port."
+ (NodeSelection i (Just p), Just p') | i /= j -> createEdgePorts i p j p' state
+ (_, Nothing) -> selectNode j state
+ (_, Just p') -> selectPort j p' state
hunk ./src/GUIEvents.hs 102
- NodeSelection i
+ NodeSelection i _ {-??-}
hunk ./src/GUIEvents.hs 114
- NodeSelection i -> selectMultiple Nothing [i] [(e,v)] state
+ NodeSelection i _ {-??-} -> selectMultiple Nothing [i] [(e,v)] state
hunk ./src/GUIEvents.hs 136
- NodeSelection nodeNr ->
+ NodeSelection nodeNr _ ->
hunk ./src/GUIEvents.hs 157
- NodeSelection nodeNr ->
+ NodeSelection nodeNr _ {-??-} ->
hunk ./src/Network.hs 30
+ , edgeConnectedOnPort
hunk ./src/Network.hs 44
- , getNodeInfo, getNodeName, getNodePosition, getNodeNameAbove, getNodeShape
- , setNodeInfo, setNodeName, setNodePosition, setNodeNameAbove, setNodeShape
- , getInfo, getName, getPosition, getNameAbove, getShape
- , setInfo, setName, setPosition, setNameAbove, setShape
+ , getNodeInfo, getNodeName, getNodePosition, getNodeNameAbove, getNodeShape, getNodePorts
+ , setNodeInfo, setNodeName, setNodePosition, setNodeNameAbove, setNodeShape, setNodePorts
+ , getInfo, getName, getPosition, getNameAbove, getShape, getPorts
+ , setInfo, setName, setPosition, setNameAbove, setShape, setPorts
hunk ./src/Network.hs 50
- , getEdgeFrom, getEdgeTo, getEdgeVia, getEdgeInfo
- , setEdgeFrom, setEdgeTo, setEdgeVia, setEdgeInfo
+ , getEdgeFrom, getPortFrom, getEdgeTo, getPortTo, getEdgeVia, getEdgeInfo
+ , setEdgeFrom, setPortFrom, setEdgeTo, setPortTo, setEdgeVia, setEdgeInfo
hunk ./src/Network.hs 59
+import Ports
hunk ./src/Network.hs 75
+ , portFrom :: Maybe Port -- [_$_]
hunk ./src/Network.hs 77
+ , portTo :: Maybe Port -- [_$_]
hunk ./src/Network.hs 87
+ , nodePorts :: Maybe Ports
hunk ./src/Network.hs 121
-constructEdge :: NodeNr -> NodeNr -> [DoublePoint] -> e -> Edge e
-constructEdge fromNr toNr via info =
+constructEdge :: NodeNr -> Maybe Port -> NodeNr -> Maybe Port -> [DoublePoint] -> e -> Edge e
+constructEdge fromNr fromPort toNr toPort via info =
hunk ./src/Network.hs 125
+ , portFrom = fromPort
hunk ./src/Network.hs 127
+ , portTo = toPort
hunk ./src/Network.hs 134
+
+getPortFrom :: Edge e -> Maybe (NodeNr, Port)
+getPortFrom e = case portFrom e of
+ Nothing -> Nothing
+ Just p -> Just (edgeFrom e, p)
hunk ./src/Network.hs 142
+
+getPortTo :: Edge e -> Maybe (NodeNr, Port)
+getPortTo e = case portTo e of
+ Nothing -> Nothing
+ Just p -> Just (edgeTo e, p)
hunk ./src/Network.hs 156
+
+setPortFrom :: NodeNr -> Port -> Edge e -> Edge e
+setPortFrom fromNr fromPort edge = edge { edgeFrom = fromNr, portFrom = Just fromPort }
hunk ./src/Network.hs 162
+
+setPortTo :: NodeNr -> Port -> Edge e -> Edge e
+setPortTo toNr toPort edge = edge { edgeTo = toNr, portTo = Just toPort }
hunk ./src/Network.hs 171
- constructEdge (getEdgeFrom edge) (getEdgeTo edge)
- (getEdgeVia edge) info
+ constructEdge (getEdgeFrom edge) (maybeSnd $ getPortFrom edge)
+ (getEdgeTo edge) (maybeSnd $ getPortTo edge)
+ (getEdgeVia edge) info
+ where maybeSnd = maybe Nothing (Just . snd) [_$_]
hunk ./src/Network.hs 177
- -> Either String Shape -> n -> Node n
-constructNode name position nameAbove shape info =
- Node
- { nodeName = name
- , nodePosition = position
- , nodeNameAbove = nameAbove
- , nodeShape = shape
- , nodeInfo = info
- }
+ -> Either String Shape -> Maybe Ports -> n -> Node n
+constructNode name position nameAbove shape ports info =
+ Node
+ { nodeName = name
+ , nodePosition = position
+ , nodeNameAbove = nameAbove
+ , nodeShape = shape
+ , nodePorts = ports
+ , nodeInfo = info
+ }
hunk ./src/Network.hs 218
+ (networkNodes network) }
+ where node = networkNodes network ! nodeNr
+
+getNodePorts :: Network g n e -> NodeNr -> Maybe Ports
+getNodePorts network nodeNr = nodePorts (networkNodes network ! nodeNr)
+
+setNodePorts :: NodeNr -> Ports -> Network g n e -> Network g n e
+setNodePorts nodeNr ports network =
+ network { networkNodes = insert nodeNr (node { nodePorts = Just ports })
hunk ./src/Network.hs 246
+
+getPorts :: Node a -> Maybe Ports
+getPorts node = nodePorts node
hunk ./src/Network.hs 265
+
+setPorts :: Ports -> Node a -> Node a
+setPorts p node = node { nodePorts = Just p }
hunk ./src/Network.hs 353
-findEdge :: NodeNr -> NodeNr -> Network g n e -> Maybe EdgeNr
-findEdge fromNodeNr toNodeNr network =
+findEdge :: NodeNr -> Maybe Port -> NodeNr -> Maybe Port -> Network g n e -> Maybe EdgeNr
+findEdge fromNodeNr fromPort toNodeNr toPort network =
hunk ./src/Network.hs 357
- , edgeTo = toNodeNr
- , edgeVia = undefined
+ , portFrom = fromPort
+ , edgeTo = toNodeNr
+ , portTo = toPort
+ , edgeVia = undefined
hunk ./src/Network.hs 420
+ (maybe Nothing snd3 $ Data.List.lookup shape palette)
hunk ./src/Network.hs 426
+ snd3 (_,p,_) = p
hunk ./src/Network.hs 437
- String -> DoublePoint -> Bool -> Either String Shape -> n
+ String -> DoublePoint -> Bool -> Either String Shape -> Maybe Ports -> n
hunk ./src/Network.hs 439
-addNodeEx name position labelAbove shape info network =
+addNodeEx name position labelAbove shape ports info network =
hunk ./src/Network.hs 445
- node = constructNode name position labelAbove shape info
-
+ node = constructNode name position labelAbove shape ports info
hunk ./src/Network.hs 449
-addEdge :: InfoKind e g => NodeNr -> NodeNr -> Network g n e -> Network g n e
-addEdge fromNodeNr toNodeNr network
- | any (sameFromAndTo edge) edgesList || -- prohibit double edges
- any (sameFromAndTo (reverseEdge edge)) edgesList = -- prohibit edges in opposite direction
- network
+addEdge :: InfoKind e g => NodeNr -> Maybe Port -> NodeNr -> Maybe Port -> Network g n e -> Network g n e
+addEdge fromNodeNr fromPort toNodeNr toPort network
+ | any (sameFromAndTo edge) edgesList || -- prohibit double edges [_$_]
+ any (sameFromAndTo (reverseEdge edge)) edgesList || -- prohibit edges in opposite direction
+ anyPortAlreadyUsed edge edgesList -- only one connection per port is allowed
+ = network
hunk ./src/Network.hs 460
- edge = Edge { edgeFrom = fromNodeNr, edgeTo = toNodeNr
+ edge = Edge { edgeFrom = fromNodeNr, portFrom = fromPort
+ , edgeTo = toNodeNr, portTo = toPort
hunk ./src/Network.hs 467
- foldr (\(fromNr, toNr) net -> addEdge fromNr toNr net) network edgeTuples
+ foldr (\(fromNr, toNr) net -> addEdge fromNr Nothing toNr Nothing net) network edgeTuples
hunk ./src/Network.hs 525
+{- | Checks if two edges are equal. Equality in edges is: [_$_]
+ * if the edges have information of ports then the edges are equal when the pairs
+ (node,port) from and to of the two edges are the same
+ * otherwise the edges are equal if the from and to Nodes are the same
+-}
hunk ./src/Network.hs 532
- edgeFrom edge1 == edgeFrom edge2 && edgeTo edge1 == edgeTo edge2
+ edgeFrom edge1 == edgeFrom edge2 && edgeTo edge1 == edgeTo edge2 -- equality on nodes
+ && [_$_]
+ case (portFrom edge1, portFrom edge2, portTo edge1, portTo edge2) of
+ (Just pf1, Just pf2, Just pt1, Just pt2) -> pf1 == pf2 && pt1 == pt2 -- equality on ports
+ _ -> True
hunk ./src/Network.hs 540
- edge { edgeFrom = edgeTo edge, edgeTo = edgeFrom edge }
+ edge { edgeFrom = edgeTo edge [_$_]
+ , portFrom = portTo edge
+ , edgeTo = edgeFrom edge
+ , portTo = portFrom edge}
+
+-- | Avoid the introduction of connections on ports that already are used.
+-- So only one connection per port is allowed.
+anyPortAlreadyUsed :: Edge e -> [Edge e] -> Bool
+anyPortAlreadyUsed edge edgesList = [_$_]
+ (edgeFrom edge, portFrom edge) `elem` portsList
+ || (edgeTo edge, portTo edge) `elem` portsList
+ where portsList = concatMap f edgesList
+ f e = [(edgeFrom e, portFrom e), (edgeTo e, portTo e)]
hunk ./src/Network.hs 573
+
+edgeConnectedOnPort :: IntMap (Edge e) -> NodeNr -> Port -> Maybe EdgeNr [_$_]
+edgeConnectedOnPort edgeMap nodeNr port = [_$_]
+ case IntMap.keys (IntMap.filter f edgeMap) of
+ [edgeNr] -> Just edgeNr
+ _ -> Nothing
+ where f :: Edge e -> Bool
+ f edge = [_$_]
+ getPortFrom edge == Just (nodeNr, port) [_$_]
+ || getPortTo edge == Just (nodeNr, port)
+
hunk ./src/NetworkControl.hs 4
+ , createEdgePorts
hunk ./src/NetworkControl.hs 6
+ , selectPort
hunk ./src/NetworkControl.hs 28
+import Ports
hunk ./src/NetworkControl.hs 42
- NodeSelection nodeNr -> [_$_]
+ NodeSelection nodeNr _ -> [_$_]
hunk ./src/NetworkControl.hs 57
- NodeSelection nodeNr -> [_$_]
+ NodeSelection nodeNr _ -> [_$_]
hunk ./src/NetworkControl.hs 72
- NodeSelection nodeNr -> [_$_]
+ NodeSelection nodeNr _ -> [_$_]
hunk ./src/NetworkControl.hs 103
- doc4 = setSelection (NodeSelection nodeNr) doc3
+ doc4 = setSelection (NodeSelection nodeNr Nothing) doc3
hunk ./src/NetworkControl.hs 126
- ( setSelection (NodeSelection fromNodeNr)
- . updateNetwork (addEdge fromNodeNr toNodeNr)
+ ( setSelection (NodeSelection fromNodeNr Nothing)
+ . updateNetwork (addEdge fromNodeNr Nothing toNodeNr Nothing)
hunk ./src/NetworkControl.hs 132
+createEdgePorts :: (InfoKind e g) => Int -> Port -> Int -> Port -> State g n e -> IO ()
+createEdgePorts fromNodeNr fromPort toNodeNr toPort state = [_$_]
+ do{ pDoc <- getDocument state
+ ; PD.updateDocument "add edge"
+ ( setSelection (NodeSelection fromNodeNr $ Just fromPort)
+ . updateNetwork (addEdge fromNodeNr (Just fromPort) toNodeNr (Just toPort))
+ ) pDoc
+ ; repaintAll state
+ } [_$_]
+
hunk ./src/NetworkControl.hs 182
- ; PD.superficialUpdateDocument (setSelection (NodeSelection nodeNr)) pDoc
+ ; PD.superficialUpdateDocument (setSelection (NodeSelection nodeNr Nothing)) pDoc
hunk ./src/NetworkControl.hs 186
-pickupNode :: Int -> DoublePoint -> State g n e -> IO ()
-pickupNode nodeNr mousePoint state = [_$_]
+selectPort :: Int -> Port -> State g n e -> IO ()
+selectPort nodeNr port state = [_$_]
+ do{ pDoc <- getDocument state
+ ; PD.superficialUpdateDocument (setSelection $ NodeSelection nodeNr $ Just port) pDoc
+ ; repaintAll state
+ }
+
+pickupNode :: Int -> Maybe Port -> DoublePoint -> State g n e -> IO ()
+pickupNode nodeNr mPort mousePoint state = [_$_]
hunk ./src/NetworkControl.hs 200
- ; selectNode nodeNr state
+ ; case mPort of [_$_]
+ Nothing -> selectNode nodeNr state
+ Just p -> selectPort nodeNr p state
hunk ./src/NetworkControl.hs 389
- NodeSelection nodeNr ->
+ NodeSelection nodeNr _ ->
hunk ./src/NetworkControl.hs 410
- NodeSelection nodeNr ->
+ NodeSelection nodeNr _ ->
hunk ./src/NetworkFile.hs 165
+ , makeTag "Ports" (toContents (getPorts node))
hunk ./src/NetworkFile.hs 175
+ ; q <- inElement "Ports" $ parseContents
hunk ./src/NetworkFile.hs 177
- ; return (constructNode n p a s i)
+ ; return (constructNode n p a s q i)
hunk ./src/NetworkFile.hs 200
+ , makeTag "PortFrom" (toContents $ maybeSnd $ getPortFrom edge)
hunk ./src/NetworkFile.hs 202
+ , makeTag "PortTo" (toContents $ maybeSnd $ getPortTo edge)
hunk ./src/NetworkFile.hs 207
+ where maybeSnd = maybe Nothing (Just . snd)
hunk ./src/NetworkFile.hs 211
+ ; q <- inElement "PortFrom" $ parseContents
hunk ./src/NetworkFile.hs 213
+ ; r <- inElement "PortTo" $ parseContents
hunk ./src/NetworkFile.hs 216
- ; return (constructEdge f t v i)
+ ; return (constructEdge f q t r v i) [_$_]
hunk ./src/NetworkFile.hs 305
- where (Palette ((_,(_,Just a)):_)) = p
+ where (Palette ((_,(_,_,Just a)):_)) = p
hunk ./src/NetworkUI.hs 20
+import Ports
hunk ./src/NetworkUI.hs 490
- removeQuotesFromNames = Palette . map (\(a,b) -> (remQuot a, b) ) . shapes [_$_]
+ removeQuotesFromNames = Palette . map (\(a,b) -> (remQuot a, rem1 b) ) . shapes [_$_]
+ rem1 (shape, mPorts, info) = (shape, rem2 mPorts , info)
+ rem2 = maybe Nothing (Just . map rem3)
+ rem3 (str, dpoint) = (remQuot str, dpoint)
+ [_$_]
hunk ./src/NetworkUI.hs 542
-drawNodeButton :: InfoKind n g => Window w -> State g n e -> (String, (Shape, Maybe n)) -> IO Layout
-drawNodeButton w state (name, (shape, _info)) = [_$_]
+drawNodeButton :: InfoKind n g => Window w -> State g n e -> (String, (Shape, Maybe Ports, Maybe n)) -> IO Layout
+drawNodeButton w state (name, (shape, ports, _info)) = [_$_]
hunk ./src/NetworkUI.hs 550
- , on paint := \dc r -> safetyNet frame $ logicalDraw ppi dc (center r) shape []
-
+ , on paint := \dc r -> safetyNet frame $ [_$_]
+ do { logicalDraw ppi dc (center r) shape []
+ ; drawPorts ppi dc (center r) ports []
+ }
hunk ./src/NetworkView.hs 4
+ , clickedNodePort
hunk ./src/NetworkView.hs 17
-
+import Ports
hunk ./src/NetworkView.hs 73
- NodeSelection nodeNr ->
- drawNode nodeNr (kSELECTED_OPTIONS
+ NodeSelection nodeNr mPort ->
+ do drawNode nodeNr (kSELECTED_OPTIONS
hunk ./src/NetworkView.hs 76
+ case mPort of
+ Nothing -> return ()
+ Just (str,dp) -> drawPort ppi dc
+ (getPosition $ getNode nodeNr network)
+ [brushKind := BrushSolid
+ , brushColor := kPortSelectedColor] dp [_$_]
hunk ./src/NetworkView.hs 113
+ ; drawPorts ppi dc center (getPorts node) options
+
hunk ./src/NetworkView.hs 129
- shape = either (\name-> maybe Shape.circle fst
+ fst3 (a,_,_) = a
+ shape = either (\name-> maybe Shape.circle fst3
hunk ./src/NetworkView.hs 183
- fromPoint = getPosition fromNode
- toPoint = getPosition toNode
+ fromPort = getPortFrom edge
+ toPort = getPortTo edge
+ [_$_]
+ hasPort = isJust fromPort && isJust toPort
+ radius = if hasPort then kPortRadius else kNODE_RADIUS [_$_]
+ fromNodePoint = getPosition fromNode
+ toNodePoint = getPosition toNode
+
+ fromPoint = if not hasPort then fromNodePoint [_$_]
+ else translate fromNodePoint $ snd . snd $ fromJust fromPort [_$_]
+ toPoint = if not hasPort then toNodePoint [_$_]
+ else translate toNodePoint $ snd . snd $ fromJust toPort
hunk ./src/NetworkView.hs 212
- pt1 = translatePolar fstAngle kNODE_RADIUS fromPoint
- pt2 = translatePolar endAngle (endTotalLen - kNODE_RADIUS) penultimatePt
+ pt1 = translatePolar fstAngle radius fromPoint
+ pt2 = translatePolar endAngle (endTotalLen - radius) penultimatePt
hunk ./src/NetworkView.hs 232
- NodeSelection nodeNr -> [(nodeNr, getNode nodeNr network)]
+ NodeSelection nodeNr _ {-??-} -> [(nodeNr, getNode nodeNr network)]
hunk ./src/NetworkView.hs 239
+-- | Finds which node and port of the network is clicked by the mouse, if any
+-- mudar esta função para fazer o que deve
+
+clickedNodePort :: DoublePoint -> Document g n e -> Maybe (Int, Maybe Port)
+clickedNodePort clickedPoint doc =
+ let network = getNetwork doc
+ nodeAssocs = case getSelection doc of
+ NodeSelection nodeNr _ {-??-} -> [(nodeNr, getNode nodeNr network)]
+ _ -> []
+ ++ reverse (getNodeAssocs network)
+ in case filter (\(_, node) -> node `nodeContains` clickedPoint) nodeAssocs of
+ [] -> Nothing
+ ((i, n):_) -> case getPorts n of [_$_]
+ Nothing -> Just (i, Nothing) -- nodes don't have ports
+ Just ps -> [_$_]
+ case filter (\p -> portContains n p clickedPoint) ps of
+ [] -> Just (i, Nothing) -- if the mouse is over a node with nodes but not over any of its ports the node is selected
+ (port:_) -> Just (i, Just port)
+
hunk ./src/NetworkView.hs 262
+
+portContains :: Node n -> Port -> DoublePoint -> Bool
+portContains node (_, portP) clickedPoint = [_$_]
+ distancePointPoint portCenter clickedPoint
+ < kPortSelectionRadius
+ where portCenter = translate (getPosition node) portP
hunk ./src/Palette.hs 5
+import Math
hunk ./src/Palette.hs 7
+import Ports
hunk ./src/Palette.hs 9
-data Palette a = Palette [ (String, (Shape, Maybe a)) ]
+
+data Palette a = Palette [ (String, (Shape, Maybe Ports, Maybe a)) ]
hunk ./src/Palette.hs 13
-shapes :: Palette a -> [ (String,(Shape,Maybe a)) ]
+shapes :: Palette a -> [ (String,(Shape,Maybe Ports,Maybe a)) ]
hunk ./src/Palette.hs 24
-empty = Palette [("circle", (Shape.circle, Nothing))]
+empty = Palette [("circle", (Shape.circle, Nothing, Nothing))]
hunk ./src/Palette.hs 27
- fmap _ (Palette p) = Palette (map (\ (n,(s,i))-> (n,(s,Nothing))) p)
+ fmap _ (Palette p) = Palette (map (\ (n,(s,a,_))-> (n,(s,a,Nothing))) p)
addfile ./src/Ports.hs
hunk ./src/Ports.hs 1
+module Ports where[_^M_][_$_]
+[_^M_][_$_]
+import Math[_^M_][_$_]
+import Constants[_^M_][_$_]
+import Shape[_^M_][_$_]
+import CommonIO[_^M_][_$_]
+import Colors[_^M_][_$_]
+import Graphics.UI.WX as WX[_^M_][_$_]
+import Graphics.UI.WXCore[_^M_][_$_]
+[_^M_][_$_]
+{- | 'Ports' represents the extra information for a generalization of nodes in which a node have special points where it can conect with other nodes (more conrrectly the ports of other nodes). [_^M_][_$_]
+[_^M_][_$_]
+We separate the input and output ports of the node, respectively in the first and second pair's components.[_^M_][_$_]
+[_^M_][_$_]
+Each port is represented by its name and a point relative to the center of node shape.[_^M_][_$_]
+-}[_^M_][_$_]
+[_^M_][_$_]
+type Port = (String,DoublePoint) [_^M_][_$_]
+[_^M_][_$_]
+type Ports = [Port][_^M_][_$_]
+[_^M_][_$_]
+{-[_^M_][_$_]
+type Ports = ([Port] -- ^ list of input ports[_^M_][_$_]
+ ,[Port]) -- ^ list of output ports[_^M_][_$_]
+-}[_^M_][_$_]
+[_^M_][_$_]
+drawPorts :: Size -> DC () -> DoublePoint -> Maybe Ports -> [Prop (DC ())] -> IO ()[_^M_][_$_]
+drawPorts ppi dc centre ports options = [_^M_][_$_]
+ case ports of [_^M_][_$_]
+ Nothing -> return ()[_^M_][_$_]
+ Just p -> when (not $ null p)[_^M_][_$_]
+ (if hasPrincipalPorts[_^M_][_$_]
+ then do drawPrincipalPort ppi dc centre optionsPP (snd $ head p)[_^M_][_$_]
+ mapM_ ( drawPort ppi dc centre optionsP . snd ) (tail p)[_^M_][_$_]
+ else mapM_ ( drawPort ppi dc centre optionsP . snd ) p[_^M_][_$_]
+ )[_^M_][_$_]
+[_^M_][_$_]
+ where options' = [ brushKind := BrushSolid ] ++ options[_^M_][_$_]
+ -- penWidth := kPortPenWidth[_^M_][_$_]
+ -- penColor := kPortPenColor[_^M_][_$_]
+ optionsP = [ brushColor := kPortBrushColor[_^M_][_$_]
+ , penColor := kPortBrushColor [_^M_][_$_]
+ ] ++ options'[_^M_][_$_]
+ optionsPP = [ brushColor := kPrincipalPortBrushColor [_^M_][_$_]
+ , penColor := kPrincipalPortBrushColor [_^M_][_$_]
+ ] ++ options'[_^M_][_$_]
+[_^M_][_$_]
+drawPort :: Size -> DC () -> DoublePoint -> [Prop (DC ())] -> DoublePoint -> IO ()[_^M_][_$_]
+drawPort ppi dc centre options point =[_^M_][_$_]
+ WX.circle dc [_^M_][_$_]
+ (logicalToScreenPoint ppi $ translate centre point)[_^M_][_$_]
+ (logicalToScreenX ppi kPortRadius)[_^M_][_$_]
+ options[_^M_][_$_]
+[_^M_][_$_]
+drawPrincipalPort :: Size -> DC () -> DoublePoint -> [Prop (DC ())] -> DoublePoint -> IO ()[_^M_][_$_]
+drawPrincipalPort ppi dc centre options point = [_^M_][_$_]
+ do WX.polygon dc points options[_^M_][_$_]
+ logMessage "" [_^M_][_$_]
+ where centro = logicalToScreenPoint ppi $ translate centre point[_^M_][_$_]
+ param = 2[_^M_][_$_]
+ points = [_^M_][_$_]
+ [ pointMove (vector param param) centro[_^M_][_$_]
+ , pointMove (vector param (- param)) centro[_^M_][_$_]
+ , pointMove (vector (- param) (- param)) centro[_^M_][_$_]
+ , pointMove (vector (- param) param) centro[_^M_][_$_]
+ ][_^M_][_$_]
+[_^M_][_$_]
hunk ./src/State.hs 35
- , stShape :: String -- the name of the shape in the palette
+ , stShape :: String -- ^the name of the shape in the palette
}