-
Notifications
You must be signed in to change notification settings - Fork 40
/
diagnostics.py
55 lines (47 loc) · 2.03 KB
/
diagnostics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from .base_cmd import CmdBase
import wx
from beautifultable import BeautifulTable
from termcolor import colored # also install colorama to make this work on windows
from parsing.dump_pmodel import dump_old_structure, dump_pmodel
class CmdDumpDisplayModel(CmdBase):
def __init__(self, parse_models=False):
self.parse_models = parse_models
def execute(self):
# Also called by Snapshot manager.
# When create Snapshot manager we pass ourselves as a controller and DumpStatus() is expected to exist.
import locale
# http://stackoverflow.com/questions/1823058/how-to-print-number-with-commas-as-thousands-separators-in-python-2-x
locale.setlocale(locale.LC_ALL, "")
if self.parse_models:
self.dump_parse_models()
else:
table = self.context.coordmapper.DumpCalibrationInfo(dump_nodes=False, doprint=False)
self.dump_overlaps(into_existing_table=table)
self.context.displaymodel.Dump()
def dump_parse_models(self):
for pmodel in self.context.displaymodel.pmodels_i_have_seen:
# print(dump_old_structure(pmodel))
print(dump_pmodel(pmodel))
def dump_overlaps(self, into_existing_table=None):
if into_existing_table:
t = into_existing_table
else:
t = BeautifulTable()
t.append_row(
[
"bounds",
self.context.displaymodel.graph.GetBounds()[0],
self.context.displaymodel.graph.GetBounds()[1],
]
)
t.append_row(["node-node overlaps", self.context.overlap_remover.CountOverlaps(), ""])
t.append_row(
[
"line-line intersections, crossings",
len(self.context.displaymodel.graph.CountLineOverLineIntersections()),
self.context.displaymodel.graph.CountLineOverNodeCrossings()["ALL"] / 2,
]
)
t.column_alignments[0] = BeautifulTable.ALIGN_LEFT
t.row_separator_char = ""
print(t)