fixed temp issue for dealing with xml and node positions as floats, updated shape metadata to save bold/italic/underline options and read them back from xml

This commit is contained in:
Blake Harnden 2019-12-06 22:33:21 -08:00
parent 71df2a3b7f
commit 0308a4c8d7
5 changed files with 228 additions and 207 deletions

View file

@ -335,6 +335,9 @@ class CoreClient:
shape_config["color"], shape_config["color"],
shape_config["border"], shape_config["border"],
shape_config["width"], shape_config["width"],
shape_config["bold"],
shape_config["italic"],
shape_config["underline"],
) )
shape = Shape( shape = Shape(
self.app, self.app.canvas, shape_type, *coords, data=data self.app, self.app.canvas, shape_type, *coords, data=data

View file

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<scenario name="/tmp/tmp620b48d8"> <scenario name="/tmp/tmpsn2dcw73">
<networks> <networks>
<network id="4" name="n4" icon="" type="SWITCH"> <network id="4" name="n4" icon="" type="SWITCH">
<position x="192" y="252" lat="47.57577240005682" lon="-122.12855068636081" alt="2.0"/> <position x="192" y="252" lat="47.57577240005682" lon="-122.12855068636081" alt="2.0"/>
@ -37,7 +37,7 @@
</services> </services>
</device> </device>
<device id="6" name="n6" icon="" type="mdr"> <device id="6" name="n6" icon="" type="mdr">
<position x="780" y="228" z="0.0" lat="47.57600659186813" lon="-122.11681868175411" alt="2.0"/> <position x="780" y="228" z="0" lat="47.57600659186813" lon="-122.11681868175411" alt="2.0"/>
<services> <services>
<service name="zebra"/> <service name="zebra"/>
<service name="OSPFv3MDR"/> <service name="OSPFv3MDR"/>
@ -53,24 +53,30 @@
<service name="IPForward"/> <service name="IPForward"/>
</services> </services>
</device> </device>
<device id="7" name="n7" icon="" type="mdr"> <device id="8" name="n8" icon="" type="mdr">
<position x="816" y="348" z="0.0" lat="47.574381616411884" lon="-122.11612798101025" alt="2.0"/> <position x="672" y="420" z="0" lat="47.573432043030344" lon="-122.11901601255748" alt="2.0"/>
<services> <services>
<service name="zebra"/> <service name="zebra"/>
<service name="OSPFv3MDR"/> <service name="OSPFv3MDR"/>
<service name="IPForward"/> <service name="IPForward"/>
</services> </services>
</device> </device>
<device id="8" name="n8" icon="" type="mdr"> <device id="7" name="n7" icon="" type="mdr">
<position x="672" y="420" z="0.0" lat="47.573432043030344" lon="-122.11901601255748" alt="2.0"/> <position x="816" y="348" z="0" lat="47.574381616411884" lon="-122.11612798101025" alt="2.0"/>
<services> <services>
<service name="zebra"/> <service name="zebra"/>
<service name="OSPFv3MDR"/> <service name="OSPFv3MDR"/>
<service name="IPForward"/> <service name="IPForward"/>
</services> </services>
</device> </device>
<device id="11" name="n11" icon="" type="PC">
<position x="192" y="156" lat="47.57706795991869" lon="-122.1285291884349" alt="2.0"/>
<services>
<service name="DefaultRoute"/>
</services>
</device>
<device id="9" name="n9" icon="" type="mdr"> <device id="9" name="n9" icon="" type="mdr">
<position x="672" y="96" z="0.0" lat="47.57780454700428" lon="-122.11894266318714" alt="2.0"/> <position x="672" y="96" z="0" lat="47.57780454700428" lon="-122.11894266318714" alt="2.0"/>
<services> <services>
<service name="zebra"/> <service name="zebra"/>
<service name="OSPFv3MDR"/> <service name="OSPFv3MDR"/>
@ -83,12 +89,6 @@
<service name="DefaultRoute"/> <service name="DefaultRoute"/>
</services> </services>
</device> </device>
<device id="11" name="n11" icon="" type="PC">
<position x="192" y="156" lat="47.57706795991869" lon="-122.1285291884349" alt="2.0"/>
<services>
<service name="DefaultRoute"/>
</services>
</device>
<device id="13" name="n13" icon="" type="PC"> <device id="13" name="n13" icon="" type="PC">
<position x="336" y="156" lat="47.57704610311368" lon="-122.1256573022515" alt="2.0"/> <position x="336" y="156" lat="47.57704610311368" lon="-122.1256573022515" alt="2.0"/>
<services> <services>
@ -113,26 +113,30 @@
</device> </device>
</devices> </devices>
<links> <links>
<link node_one="4" node_two="12">
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:11" ip4="10.0.1.21" ip4_mask="24" ip6="a:1::21" ip6_mask="64"/>
<options delay="0" bandwidth="100000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
</link>
<link node_one="4" node_two="13"> <link node_one="4" node_two="13">
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:12" ip4="10.0.1.22" ip4_mask="24" ip6="a:1::22" ip6_mask="64"/> <interface_two id="0" name="eth0" mac="00:00:00:aa:00:12" ip4="10.0.1.22" ip4_mask="24" ip6="a:1::22" ip6_mask="64"/>
<options delay="0" bandwidth="100000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/> <options delay="0" bandwidth="100000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
</link> </link>
<link node_one="4" node_two="11">
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:10" ip4="10.0.1.20" ip4_mask="24" ip6="a:1::20" ip6_mask="64"/>
<options delay="0" bandwidth="100000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
</link>
<link node_one="4" node_two="3">
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:05" ip4="10.0.1.1" ip4_mask="24" ip6="a:1::1" ip6_mask="64"/>
<options delay="0" bandwidth="100000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
</link>
<link node_one="4" node_two="14"> <link node_one="4" node_two="14">
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:13" ip4="10.0.1.10" ip4_mask="24" ip6="a:1::10" ip6_mask="64"/> <interface_two id="0" name="eth0" mac="00:00:00:aa:00:13" ip4="10.0.1.10" ip4_mask="24" ip6="a:1::10" ip6_mask="64"/>
<options delay="0" bandwidth="100000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/> <options delay="0" bandwidth="100000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
</link> </link>
<link node_one="4" node_two="12"> <link node_one="4" node_two="3">
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:11" ip4="10.0.1.21" ip4_mask="24" ip6="a:1::21" ip6_mask="64"/> <interface_two id="0" name="eth0" mac="00:00:00:aa:00:05" ip4="10.0.1.1" ip4_mask="24" ip6="a:1::1" ip6_mask="64"/>
<options delay="0" bandwidth="100000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/> <options delay="0" bandwidth="100000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
</link> </link>
<link node_one="4" node_two="11">
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:10" ip4="10.0.1.20" ip4_mask="24" ip6="a:1::20" ip6_mask="64"/>
<options delay="0" bandwidth="100000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
</link>
<link node_one="10" node_two="6">
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:03" ip4="10.0.0.6" ip4_mask="32" ip6="a::6" ip6_mask="128"/>
<options delay="50000" bandwidth="54000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
</link>
<link node_one="10" node_two="8"> <link node_one="10" node_two="8">
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:00" ip4="10.0.0.8" ip4_mask="32" ip6="a::8" ip6_mask="128"/> <interface_two id="0" name="eth0" mac="00:00:00:aa:00:00" ip4="10.0.0.8" ip4_mask="32" ip6="a::8" ip6_mask="128"/>
<options delay="50000" bandwidth="54000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/> <options delay="50000" bandwidth="54000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
@ -145,10 +149,6 @@
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:01" ip4="10.0.0.7" ip4_mask="32" ip6="a::7" ip6_mask="128"/> <interface_two id="0" name="eth0" mac="00:00:00:aa:00:01" ip4="10.0.0.7" ip4_mask="32" ip6="a::7" ip6_mask="128"/>
<options delay="50000" bandwidth="54000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/> <options delay="50000" bandwidth="54000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
</link> </link>
<link node_one="10" node_two="6">
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:03" ip4="10.0.0.6" ip4_mask="32" ip6="a::6" ip6_mask="128"/>
<options delay="50000" bandwidth="54000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
</link>
<link node_one="10" node_two="9"> <link node_one="10" node_two="9">
<interface_two id="0" name="eth0" mac="00:00:00:aa:00:04" ip4="10.0.0.9" ip4_mask="32" ip6="a::9" ip6_mask="128"/> <interface_two id="0" name="eth0" mac="00:00:00:aa:00:04" ip4="10.0.0.9" ip4_mask="32" ip6="a::9" ip6_mask="128"/>
<options delay="50000" bandwidth="54000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/> <options delay="50000" bandwidth="54000000" per="0.0" dup="0" jitter="0" type="1" unidirectional="0"/>
@ -1063,6 +1063,164 @@ bootquagga
/sbin/sysctl -w net.ipv4.conf.eth1.forwarding=1 /sbin/sysctl -w net.ipv4.conf.eth1.forwarding=1
/sbin/sysctl -w net.ipv4.conf.eth1.send_redirects=0 /sbin/sysctl -w net.ipv4.conf.eth1.send_redirects=0
/sbin/sysctl -w net.ipv4.conf.eth1.rp_filter=0 /sbin/sysctl -w net.ipv4.conf.eth1.rp_filter=0
</file>
</files>
</service>
<service name="zebra" node="8">
<directories>
<directory>/usr/local/etc/quagga</directory>
<directory>/var/run/quagga</directory>
</directories>
<startups>
<startup>sh quaggaboot.sh zebra</startup>
</startups>
<validates>
<validate>pidof zebra</validate>
</validates>
<shutdowns>
<shutdown>killall zebra</shutdown>
</shutdowns>
<files>
<file name="/usr/local/etc/quagga/Quagga.conf">interface eth0
ip address 10.0.0.8/32
ipv6 address a::8/128
ipv6 ospf6 instance-id 65
ipv6 ospf6 hello-interval 2
ipv6 ospf6 dead-interval 6
ipv6 ospf6 retransmit-interval 5
ipv6 ospf6 network manet-designated-router
ipv6 ospf6 diffhellos
ipv6 ospf6 adjacencyconnectivity uniconnected
ipv6 ospf6 lsafullness mincostlsa
!
router ospf6
router-id 10.0.0.8
interface eth0 area 0.0.0.0
!
</file>
<file name="quaggaboot.sh">#!/bin/sh
# auto-generated by zebra service (quagga.py)
QUAGGA_CONF=/usr/local/etc/quagga/Quagga.conf
QUAGGA_SBIN_SEARCH="/usr/local/sbin /usr/sbin /usr/lib/quagga"
QUAGGA_BIN_SEARCH="/usr/local/bin /usr/bin /usr/lib/quagga"
QUAGGA_STATE_DIR=/var/run/quagga
searchforprog()
{
prog=$1
searchpath=$@
ret=
for p in $searchpath; do
if [ -x $p/$prog ]; then
ret=$p
break
fi
done
echo $ret
}
confcheck()
{
CONF_DIR=`dirname $QUAGGA_CONF`
# if /etc/quagga exists, point /etc/quagga/Quagga.conf -&gt; CONF_DIR
if [ "$CONF_DIR" != "/etc/quagga" ] &amp;&amp; [ -d /etc/quagga ] &amp;&amp; [ ! -e /etc/quagga/Quagga.conf ]; then
ln -s $CONF_DIR/Quagga.conf /etc/quagga/Quagga.conf
fi
# if /etc/quagga exists, point /etc/quagga/vtysh.conf -&gt; CONF_DIR
if [ "$CONF_DIR" != "/etc/quagga" ] &amp;&amp; [ -d /etc/quagga ] &amp;&amp; [ ! -e /etc/quagga/vtysh.conf ]; then
ln -s $CONF_DIR/vtysh.conf /etc/quagga/vtysh.conf
fi
}
bootdaemon()
{
QUAGGA_SBIN_DIR=$(searchforprog $1 $QUAGGA_SBIN_SEARCH)
if [ "z$QUAGGA_SBIN_DIR" = "z" ]; then
echo "ERROR: Quagga's '$1' daemon not found in search path:"
echo " $QUAGGA_SBIN_SEARCH"
return 1
fi
flags=""
if [ "$1" = "xpimd" ] &amp;&amp; \
grep -E -q '^[[:space:]]*router[[:space:]]+pim6[[:space:]]*$' $QUAGGA_CONF; then
flags="$flags -6"
fi
$QUAGGA_SBIN_DIR/$1 $flags -d
if [ "$?" != "0" ]; then
echo "ERROR: Quagga's '$1' daemon failed to start!:"
return 1
fi
}
bootquagga()
{
QUAGGA_BIN_DIR=$(searchforprog 'vtysh' $QUAGGA_BIN_SEARCH)
if [ "z$QUAGGA_BIN_DIR" = "z" ]; then
echo "ERROR: Quagga's 'vtysh' program not found in search path:"
echo " $QUAGGA_BIN_SEARCH"
return 1
fi
# fix /var/run/quagga permissions
id -u quagga 2&gt;/dev/null &gt;/dev/null
if [ "$?" = "0" ]; then
chown quagga $QUAGGA_STATE_DIR
fi
bootdaemon "zebra"
for r in rip ripng ospf6 ospf bgp babel; do
if grep -q "^router \&lt;${r}\&gt;" $QUAGGA_CONF; then
bootdaemon "${r}d"
fi
done
if grep -E -q '^[[:space:]]*router[[:space:]]+pim6?[[:space:]]*$' $QUAGGA_CONF; then
bootdaemon "xpimd"
fi
$QUAGGA_BIN_DIR/vtysh -b
}
if [ "$1" != "zebra" ]; then
echo "WARNING: '$1': all Quagga daemons are launched by the 'zebra' service!"
exit 1
fi
confcheck
bootquagga
</file>
<file name="/usr/local/etc/quagga/vtysh.conf">service integrated-vtysh-config
</file>
</files>
</service>
<service name="OSPFv3MDR" node="8">
<validates>
<validate>pidof ospf6d</validate>
</validates>
<shutdowns>
<shutdown>killall ospf6d</shutdown>
</shutdowns>
</service>
<service name="IPForward" node="8">
<startups>
<startup>sh ipforward.sh</startup>
</startups>
<files>
<file name="ipforward.sh">#!/bin/sh
# auto-generated by IPForward service (utility.py)
/sbin/sysctl -w net.ipv4.conf.all.forwarding=1
/sbin/sysctl -w net.ipv4.conf.default.forwarding=1
/sbin/sysctl -w net.ipv6.conf.all.forwarding=1
/sbin/sysctl -w net.ipv6.conf.default.forwarding=1
/sbin/sysctl -w net.ipv4.conf.all.send_redirects=0
/sbin/sysctl -w net.ipv4.conf.default.send_redirects=0
/sbin/sysctl -w net.ipv4.conf.all.rp_filter=0
/sbin/sysctl -w net.ipv4.conf.default.rp_filter=0
/sbin/sysctl -w net.ipv4.conf.eth0.forwarding=1
/sbin/sysctl -w net.ipv4.conf.eth0.send_redirects=0
/sbin/sysctl -w net.ipv4.conf.eth0.rp_filter=0
</file> </file>
</files> </files>
</service> </service>
@ -1224,161 +1382,15 @@ bootquagga
</file> </file>
</files> </files>
</service> </service>
<service name="zebra" node="8"> <service name="DefaultRoute" node="11">
<directories>
<directory>/usr/local/etc/quagga</directory>
<directory>/var/run/quagga</directory>
</directories>
<startups> <startups>
<startup>sh quaggaboot.sh zebra</startup> <startup>sh defaultroute.sh</startup>
</startups>
<validates>
<validate>pidof zebra</validate>
</validates>
<shutdowns>
<shutdown>killall zebra</shutdown>
</shutdowns>
<files>
<file name="/usr/local/etc/quagga/Quagga.conf">interface eth0
ip address 10.0.0.8/32
ipv6 address a::8/128
ipv6 ospf6 instance-id 65
ipv6 ospf6 hello-interval 2
ipv6 ospf6 dead-interval 6
ipv6 ospf6 retransmit-interval 5
ipv6 ospf6 network manet-designated-router
ipv6 ospf6 diffhellos
ipv6 ospf6 adjacencyconnectivity uniconnected
ipv6 ospf6 lsafullness mincostlsa
!
router ospf6
router-id 10.0.0.8
interface eth0 area 0.0.0.0
!
</file>
<file name="quaggaboot.sh">#!/bin/sh
# auto-generated by zebra service (quagga.py)
QUAGGA_CONF=/usr/local/etc/quagga/Quagga.conf
QUAGGA_SBIN_SEARCH="/usr/local/sbin /usr/sbin /usr/lib/quagga"
QUAGGA_BIN_SEARCH="/usr/local/bin /usr/bin /usr/lib/quagga"
QUAGGA_STATE_DIR=/var/run/quagga
searchforprog()
{
prog=$1
searchpath=$@
ret=
for p in $searchpath; do
if [ -x $p/$prog ]; then
ret=$p
break
fi
done
echo $ret
}
confcheck()
{
CONF_DIR=`dirname $QUAGGA_CONF`
# if /etc/quagga exists, point /etc/quagga/Quagga.conf -&gt; CONF_DIR
if [ "$CONF_DIR" != "/etc/quagga" ] &amp;&amp; [ -d /etc/quagga ] &amp;&amp; [ ! -e /etc/quagga/Quagga.conf ]; then
ln -s $CONF_DIR/Quagga.conf /etc/quagga/Quagga.conf
fi
# if /etc/quagga exists, point /etc/quagga/vtysh.conf -&gt; CONF_DIR
if [ "$CONF_DIR" != "/etc/quagga" ] &amp;&amp; [ -d /etc/quagga ] &amp;&amp; [ ! -e /etc/quagga/vtysh.conf ]; then
ln -s $CONF_DIR/vtysh.conf /etc/quagga/vtysh.conf
fi
}
bootdaemon()
{
QUAGGA_SBIN_DIR=$(searchforprog $1 $QUAGGA_SBIN_SEARCH)
if [ "z$QUAGGA_SBIN_DIR" = "z" ]; then
echo "ERROR: Quagga's '$1' daemon not found in search path:"
echo " $QUAGGA_SBIN_SEARCH"
return 1
fi
flags=""
if [ "$1" = "xpimd" ] &amp;&amp; \
grep -E -q '^[[:space:]]*router[[:space:]]+pim6[[:space:]]*$' $QUAGGA_CONF; then
flags="$flags -6"
fi
$QUAGGA_SBIN_DIR/$1 $flags -d
if [ "$?" != "0" ]; then
echo "ERROR: Quagga's '$1' daemon failed to start!:"
return 1
fi
}
bootquagga()
{
QUAGGA_BIN_DIR=$(searchforprog 'vtysh' $QUAGGA_BIN_SEARCH)
if [ "z$QUAGGA_BIN_DIR" = "z" ]; then
echo "ERROR: Quagga's 'vtysh' program not found in search path:"
echo " $QUAGGA_BIN_SEARCH"
return 1
fi
# fix /var/run/quagga permissions
id -u quagga 2&gt;/dev/null &gt;/dev/null
if [ "$?" = "0" ]; then
chown quagga $QUAGGA_STATE_DIR
fi
bootdaemon "zebra"
for r in rip ripng ospf6 ospf bgp babel; do
if grep -q "^router \&lt;${r}\&gt;" $QUAGGA_CONF; then
bootdaemon "${r}d"
fi
done
if grep -E -q '^[[:space:]]*router[[:space:]]+pim6?[[:space:]]*$' $QUAGGA_CONF; then
bootdaemon "xpimd"
fi
$QUAGGA_BIN_DIR/vtysh -b
}
if [ "$1" != "zebra" ]; then
echo "WARNING: '$1': all Quagga daemons are launched by the 'zebra' service!"
exit 1
fi
confcheck
bootquagga
</file>
<file name="/usr/local/etc/quagga/vtysh.conf">service integrated-vtysh-config
</file>
</files>
</service>
<service name="OSPFv3MDR" node="8">
<validates>
<validate>pidof ospf6d</validate>
</validates>
<shutdowns>
<shutdown>killall ospf6d</shutdown>
</shutdowns>
</service>
<service name="IPForward" node="8">
<startups>
<startup>sh ipforward.sh</startup>
</startups> </startups>
<files> <files>
<file name="ipforward.sh">#!/bin/sh <file name="defaultroute.sh">#!/bin/sh
# auto-generated by IPForward service (utility.py) # auto-generated by DefaultRoute service (utility.py)
/sbin/sysctl -w net.ipv4.conf.all.forwarding=1 ip route add default via 10.0.1.1
/sbin/sysctl -w net.ipv4.conf.default.forwarding=1 ip route add default via a:1::1
/sbin/sysctl -w net.ipv6.conf.all.forwarding=1
/sbin/sysctl -w net.ipv6.conf.default.forwarding=1
/sbin/sysctl -w net.ipv4.conf.all.send_redirects=0
/sbin/sysctl -w net.ipv4.conf.default.send_redirects=0
/sbin/sysctl -w net.ipv4.conf.all.rp_filter=0
/sbin/sysctl -w net.ipv4.conf.default.rp_filter=0
/sbin/sysctl -w net.ipv4.conf.eth0.forwarding=1
/sbin/sysctl -w net.ipv4.conf.eth0.send_redirects=0
/sbin/sysctl -w net.ipv4.conf.eth0.rp_filter=0
</file> </file>
</files> </files>
</service> </service>
@ -1549,18 +1561,6 @@ bootquagga
# auto-generated by DefaultRoute service (utility.py) # auto-generated by DefaultRoute service (utility.py)
ip route add default via 10.0.1.1 ip route add default via 10.0.1.1
ip route add default via a:1::1 ip route add default via a:1::1
</file>
</files>
</service>
<service name="DefaultRoute" node="11">
<startups>
<startup>sh defaultroute.sh</startup>
</startups>
<files>
<file name="defaultroute.sh">#!/bin/sh
# auto-generated by DefaultRoute service (utility.py)
ip route add default via 10.0.1.1
ip route add default via a:1::1
</file> </file>
</files> </files>
</service> </service>
@ -1842,8 +1842,8 @@ bootquagga
<configuration name="sdturl" value="tcp://127.0.0.1:50000/"/> <configuration name="sdturl" value="tcp://127.0.0.1:50000/"/>
</session_options> </session_options>
<session_metadata> <session_metadata>
<configuration name="shapes" value="[{&quot;type&quot;: &quot;rectangle&quot;, &quot;iconcoords&quot;: [125.0, 108.0, 402.0, 293.0], &quot;label&quot;: &quot;&quot;, &quot;fontfamily&quot;: &quot;Arial&quot;, &quot;fontsize&quot;: 12, &quot;labelcolor&quot;: &quot;#000000&quot;, &quot;color&quot;: &quot;#ebebde&quot;, &quot;border&quot;: &quot;#000000&quot;, &quot;width&quot;: 0}]"/>
<configuration name="canvas" value="{&quot;wallpaper&quot;: &quot;sample1-bg.gif&quot;, &quot;wallpaper-style&quot;: 1}"/> <configuration name="canvas" value="{&quot;wallpaper&quot;: &quot;sample1-bg.gif&quot;, &quot;wallpaper-style&quot;: 1}"/>
<configuration name="shapes" value="[{&quot;type&quot;: &quot;rectangle&quot;, &quot;iconcoords&quot;: [125.0, 108.0, 402.0, 293.0], &quot;label&quot;: &quot;&quot;, &quot;fontfamily&quot;: &quot;Arial&quot;, &quot;fontsize&quot;: 12, &quot;labelcolor&quot;: &quot;#000000&quot;, &quot;color&quot;: &quot;#ebebde&quot;, &quot;border&quot;: &quot;#000000&quot;, &quot;width&quot;: 0, &quot;bold&quot;: false, &quot;italic&quot;: false, &quot;underline&quot;: false}, {&quot;type&quot;: &quot;text&quot;, &quot;iconcoords&quot;: [502.0, 405.0], &quot;label&quot;: &quot;gateway&quot;, &quot;fontfamily&quot;: &quot;Arial&quot;, &quot;fontsize&quot;: 12, &quot;labelcolor&quot;: &quot;#000000&quot;, &quot;color&quot;: &quot;&quot;, &quot;border&quot;: &quot;#000000&quot;, &quot;width&quot;: 1, &quot;bold&quot;: true, &quot;italic&quot;: false, &quot;underline&quot;: false}, {&quot;type&quot;: &quot;text&quot;, &quot;iconcoords&quot;: [638.0, 501.0], &quot;label&quot;: &quot;wireless network&quot;, &quot;fontfamily&quot;: &quot;Arial&quot;, &quot;fontsize&quot;: 12, &quot;labelcolor&quot;: &quot;#000000&quot;, &quot;color&quot;: &quot;&quot;, &quot;border&quot;: &quot;#000000&quot;, &quot;width&quot;: 1, &quot;bold&quot;: true, &quot;italic&quot;: false, &quot;underline&quot;: false}]"/>
</session_metadata> </session_metadata>
<default_services> <default_services>
<node type="mdr"> <node type="mdr">

View file

@ -33,9 +33,9 @@ class ShapeDialog(Dialog):
self.fill_color = fill_color self.fill_color = fill_color
self.border_color = data.border_color self.border_color = data.border_color
self.border_width = tk.IntVar(value=0) self.border_width = tk.IntVar(value=0)
self.bold = tk.IntVar(value=data.bold) self.bold = tk.BooleanVar(value=data.bold)
self.italic = tk.IntVar(value=data.italic) self.italic = tk.BooleanVar(value=data.italic)
self.underline = tk.IntVar(value=data.underline) self.underline = tk.BooleanVar(value=data.underline)
self.top.columnconfigure(0, weight=1) self.top.columnconfigure(0, weight=1)
self.draw() self.draw()
@ -162,11 +162,11 @@ class ShapeDialog(Dialog):
""" """
size = int(self.font_size.get()) size = int(self.font_size.get())
text_font = [self.font.get(), size] text_font = [self.font.get(), size]
if self.bold.get() == 1: if self.bold.get():
text_font.append("bold") text_font.append("bold")
if self.italic.get() == 1: if self.italic.get():
text_font.append("italic") text_font.append("italic")
if self.underline.get() == 1: if self.underline.get():
text_font.append("underline") text_font.append("underline")
return text_font return text_font

View file

@ -1,5 +1,4 @@
import logging import logging
from tkinter.font import Font
from coretk.dialogs.shapemod import ShapeDialog from coretk.dialogs.shapemod import ShapeDialog
from coretk.graph.shapeutils import ShapeType from coretk.graph.shapeutils import ShapeType
@ -17,9 +16,9 @@ class AnnotationData:
fill_color="", fill_color="",
border_color="#000000", border_color="#000000",
border_width=1, border_width=1,
bold=0, bold=False,
italic=0, italic=False,
underline=0, underline=False,
): ):
self.text = text self.text = text
self.font = font self.font = font
@ -92,7 +91,7 @@ class Shape:
) )
self.draw_shape_text() self.draw_shape_text()
elif self.shape_type == ShapeType.TEXT: elif self.shape_type == ShapeType.TEXT:
font = Font(family=self.shape_data.font, size=self.shape_data.font_size) font = self.get_font()
self.id = self.canvas.create_text( self.id = self.canvas.create_text(
self.x1, self.x1,
self.y1, self.y1,
@ -105,11 +104,21 @@ class Shape:
logging.error("unknown shape type: %s", self.shape_type) logging.error("unknown shape type: %s", self.shape_type)
self.created = True self.created = True
def get_font(self):
font = [self.shape_data.font, self.shape_data.font_size]
if self.shape_data.bold:
font.append("bold")
if self.shape_data.italic:
font.append("italic")
if self.shape_data.underline:
font.append("underline")
return font
def draw_shape_text(self): def draw_shape_text(self):
if self.shape_data.text: if self.shape_data.text:
x = (self.x1 + self.x2) / 2 x = (self.x1 + self.x2) / 2
y = self.y1 + 1.5 * self.shape_data.font_size y = self.y1 + 1.5 * self.shape_data.font_size
font = Font(family=self.shape_data.font, size=self.shape_data.font_size) font = self.get_font()
self.text_id = self.canvas.create_text( self.text_id = self.canvas.create_text(
x, x,
y, y,
@ -155,4 +164,7 @@ class Shape:
"color": self.shape_data.fill_color, "color": self.shape_data.fill_color,
"border": self.shape_data.border_color, "border": self.shape_data.border_color,
"width": self.shape_data.border_width, "width": self.shape_data.border_width,
"bold": self.shape_data.bold,
"italic": self.shape_data.italic,
"underline": self.shape_data.underline,
} }

View file

@ -117,15 +117,21 @@ class NodeElement:
def add_position(self): def add_position(self):
x = self.node.position.x x = self.node.position.x
if x is not None:
x = int(x)
y = self.node.position.y y = self.node.position.y
if y is not None:
y = int(y)
z = self.node.position.z z = self.node.position.z
if z is not None:
z = int(z)
lat, lon, alt = None, None, None lat, lon, alt = None, None, None
if x is not None and y is not None: if x is not None and y is not None:
lat, lon, alt = self.session.location.getgeo(x, y, z) lat, lon, alt = self.session.location.getgeo(x, y, z)
position = etree.SubElement(self.element, "position") position = etree.SubElement(self.element, "position")
add_attribute(position, "x", int(x)) add_attribute(position, "x", x)
add_attribute(position, "y", int(y)) add_attribute(position, "y", y)
add_attribute(position, "z", int(z)) add_attribute(position, "z", z)
add_attribute(position, "lat", lat) add_attribute(position, "lat", lat)
add_attribute(position, "lon", lon) add_attribute(position, "lon", lon)
add_attribute(position, "alt", alt) add_attribute(position, "alt", alt)