GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ogdf-python/src/ogdf_python/pythonize/graph_attributes.py at master · ogdf/ogdf-python

Expand file tree

/

graph_attributes.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
101 lines (86 loc) · 3.92 KB
/

graph_attributes.py

Copy path

File metadata and controls

101 lines (86 loc) · 3.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import cppyy
class GraphAttributesProxy(object):
def __init__(self, GA, getter, setter):
self.GA = GA
self.getter = getter
self.setter = setter
def __setitem__(self, key, item):
return self.setter(self.GA, key, item)
def __getitem__(self, key):
return self.getter(self.GA, key)
def __call__(self, *args, **kwargs):
return self.getter(self.GA, *args, **kwargs)
class GraphAttributesDescriptor(object):
def __init__(self, getter, setter):
self.getter = getter
self.setter = setter
def __get__(self, obj, type=None):
return GraphAttributesProxy(obj, self.getter, self.setter)
GA_FIELDS = [
("x", "ogdf::node", "double"),
("y", "ogdf::node", "double"),
("z", "ogdf::node", "double"),
("xLabel", "ogdf::node", "double"),
("yLabel", "ogdf::node", "double"),
("zLabel", "ogdf::node", "double"),
("width", "ogdf::node", "double"),
("height", "ogdf::node", "double"),
("shape", "ogdf::node", "ogdf::Shape"),
("strokeType", "ogdf::node", "ogdf::StrokeType"),
("strokeColor", "ogdf::node", "const ogdf::Color &"),
("strokeWidth", "ogdf::node", "float"),
("fillPattern", "ogdf::node", "ogdf::FillPattern"),
("fillColor", "ogdf::node", "const ogdf::Color &"),
("fillBgColor", "ogdf::node", "const ogdf::Color &"),
("label", "ogdf::node", "const std::string &"),
("templateNode", "ogdf::node", "const std::string &"),
("weight", "ogdf::node", "int"),
("type", "ogdf::node", "ogdf::Graph::NodeType"),
("idNode", "ogdf::node", "int"),
("bends", "ogdf::edge", "const ogdf::DPolyline &"),
("arrowType", "ogdf::edge", "ogdf::EdgeArrow"),
("strokeType", "ogdf::edge", "ogdf::StrokeType"),
("strokeColor", "ogdf::edge", "const ogdf::Color &"),
("strokeWidth", "ogdf::edge", "float"),
("label", "ogdf::edge", "const std::string &"),
("intWeight", "ogdf::edge", "int"),
("doubleWeight", "ogdf::edge", "double"),
("type", "ogdf::edge", "ogdf::Graph::EdgeType"),
("subGraphBits", "ogdf::edge", "uint32_t"),
]
CGA_FIELDS = [
("x", "ogdf::cluster", "double"),
("y", "ogdf::cluster", "double"),
("width", "ogdf::cluster", "double"),
("height", "ogdf::cluster", "double"),
("label", "ogdf::cluster", "const std::string &"),
("strokeType", "ogdf::cluster", "ogdf::StrokeType"),
("strokeColor", "ogdf::cluster", "const ogdf::Color &"),
("strokeWidth", "ogdf::cluster", "float"),
("fillPattern", "ogdf::cluster", "ogdf::FillPattern"),
("fillColor", "ogdf::cluster", "const ogdf::Color &"),
("fillBgColor", "ogdf::cluster", "const ogdf::Color &"),
("templateCluster", "ogdf::cluster", "const std::string &"),
]
GA_FIELD_NAMES = set(t[0] for t in GA_FIELDS)
CGA_FIELD_NAMES = set(t[0] for t in CGA_FIELDS)
def generate_GA_setters():
DEFS = """
#include <ogdf/basic/GraphAttributes.h>
#include <ogdf/cluster/ClusterGraphAttributes.h>
namespace ogdf_pythonization {
void GraphAttributes_set_directed(ogdf::GraphAttributes &GA, bool v) { GA.directed() = v; }"""
for name, obj, val in GA_FIELDS:
DEFS += ("\n\tvoid GraphAttributes_set_{name}(ogdf::GraphAttributes &GA, {obj} o, {val} v) "
"{{ GA.{name}(o) = v; }}\n".format(name=name, obj=obj, val=val))
for name, obj, val in CGA_FIELDS:
DEFS += ("\n\tvoid GraphAttributes_set_{name}(ogdf::ClusterGraphAttributes &GA, {obj} o, {val} v) "
"{{ GA.{name}(o) = v; }}\n".format(name=name, obj=obj, val=val))
cppyy.cppdef(DEFS + "};")
def replace_GraphAttributes(klass, name):
klass.directed = property(klass.directed, cppyy.gbl.ogdf_pythonization.GraphAttributes_set_directed)
for field in (CGA_FIELD_NAMES if name.startswith("Cluster") else GA_FIELD_NAMES):
setattr(klass, field, GraphAttributesDescriptor(
getattr(klass, field),
getattr(cppyy.gbl.ogdf_pythonization, "GraphAttributes_set_%s" % field)
))
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.