main = Graph(name = 'main') main.add_node(x=0.0, y=0.0, name = 'A', ll = 'bottom') main.add_node(x=1.0, y=0.0, name = 'B', ll = 'right') main.add_node(x=1.0, y=1.0, name = 'C', ll = 'top') main.add_node(x=0.0, y=1.0, name = 'D', ll = 'left') main.connect('A', 'B', name = '1', ll = 'top', la = 0.0) main.connect('B', 'C', name = '2', ll = 'top', la = 0.0) main.connect('C', 'D', name = '3', ll = 'top', la = 0.0) main.connect('D', 'A', name = '4', ll = 'top', la = 0.0) main.anchor_graph() print 'Nodes are anchored:', main.anchored print main.general_info(), '\n' print main graphs = [] displacement = 3.0 for i in range(2): graphs.append( main.copy(i * displacement, 0.0) ) graphs[-1].rotate(i * 45.0) CAN = Canvas(border_thickness = 0.05, grid = True) for graph in graphs: CAN.add_graph(graph) CAN.draw(save_file = 'test.pdf', display = True, print_information = False)
from schematics import ExampleDebugger command_line_parser = ExampleDebugger('Detailed node label.') command_line_parser.parse() from schematics import Graph from schematics import Canvas import matplotlib.pyplot as plt main = Graph(name = 'main') main.add_node(x=0.0, y=0.0, name = 'test0', ll = 'bottom', lp = 0.0) main.add_node(x=0.0, y=0.0, name = 'test1', ll = 'top', lp = 0.0) main.add_node(x=0.0, y=0.0, name = 'test2', ll = 'left', lp = 0.0) main.add_node(x=0.0, y=0.0, name = 'test3', ll = 'right', lp = 0.0) bounding = Graph(name = 'bounding') disp = 0.1 bounding.add_node(x=disp, y=0.0, name = 'top', dl = False) bounding.add_node(x=-disp, y=0.0, name = 'bottom', dl = False) bounding.add_node(x=0.0, y=-disp, name = 'left', dl = False) bounding.add_node(x=0.0, y=disp, name = 'right', dl = False) GRAPH = Graph(name = 'graph', graphs = [main, bounding]) CAN = Canvas(border_thickness = 0.0, grid = True) CAN.add_graph(GRAPH) CAN.draw(save_file = 'test.pdf', display = True, print_information = False)
main.add_node(x=0.0, y=0.0, name='A', ll='bottom') main.add_node(x=1.0, y=0.0, name='B', ll='right') main.add_node(x=1.0, y=1.0, name='C', ll='top') main.add_node(x=0.0, y=1.0, name='D', ll='left') main.connect('A', 'B', name='1', ll='top', la=45.0, lp=1.0) main.connect('B', 'C', name='2', ll='top', la=45.0, lp=1.0) main.connect('C', 'D', name='3', ll='top', la=45.0, lp=1.0) main.connect('D', 'A', name='4', ll='top', la=45.0, lp=1.0) main.anchor_graph() print('Nodes are anchored:', main.anchored) print(main.general_info(), '\n') print(main) graphs = [] graphs.append(main) graphs.append(main.copy(-1.0, 0.0)) graphs[-1].reflect('y') graphs.append(main.copy(0.0, -1.0)) graphs[-1].reflect('x') CAN = Canvas(border_thickness=0.05, grid=True) for graph in graphs: CAN.add_graph(graph) CAN.draw(save_file='test.pdf', display=True, print_information=False)
GRAPH.add_node(x=0.75, y=-1.5, name='B', ll='bottom') GRAPH.add_node(x=-1.5, y=-0.75, name='C', ll='left') GRAPH.add_node(x=1.5, y=-0.75, name='D', ll='right') GRAPH.add_node(x=-0.75, y=-1.5, name='E', ll='bottom') # Add Connections GRAPH.connect('A', 'B', name="I", directional=False, ll='top') GRAPH.connect('C', 'A', name="II", ll='top') GRAPH.connect('A', 'D', name="III", ll='top') GRAPH.connect('A', 'E', name="IV", directional=False, ll='top') GRAPH.connect('B', 'C', name="V", directional=False, ll='top') GRAPH.connect('D', 'B', name="VI", ll='bottom') GRAPH.connect('B', 'E', name="VII", ll='bottom') GRAPH.connect('C', 'D', name="VIII", directional=False, ll='top') GRAPH.connect('E', 'C', name="IX", ll='bottom') GRAPH.connect('D', 'E', name="X", directional=False, ll='top') GRAPH.anchor_graph() print('Nodes are anchored:', GRAPH.anchored) print(GRAPH.general_info(), '\n') print(GRAPH) # plot CAN = Canvas(border_thickness=0.05, grid=True) CAN.add_graph(GRAPH) CAN.draw(save_file='test.pdf', display=True, print_information=False)
n = deepcopy(self.name, memo), ll = deepcopy(self.label_location, memo), ls = deepcopy(self.label_string, memo), la = deepcopy(self.label_angle, memo), lp = deepcopy(self.label_pad, memo), fs = deepcopy(self.font_size, memo), a = deepcopy(self.angle, memo), ref = deepcopy(self.reflect, memo), fc = deepcopy(self.face_color, memo), ec = deepcopy(self.edge_color, memo), lw = deepcopy(self.line_width, memo) ) # debugging routine if __name__ == '__main__': from schematics import component_debug_switch debugging = component_debug_switch('The component Pipe') from schematics import Canvas component = Pipe( 1.0, 0.5, Point(0.0, 0.0), name = 'Pipe', a = 0.0, ll = 'top', lp = 1.0, ls = 'Component', la = 0.0, fs = 12 ) CAN = Canvas(border_thickness = 0.05, grid = False) CAN.add_component(component) CAN.add_graph(component.graph) CAN.draw(display = True)
system2 = system1.copy(2.0, 0.0, name = 'system2') system2.rotate(45.0) # ----- component1 = Graph(name = 'component1') component1.add_node(x=0.0, y=2.0, name = 'outlet', ll = 'bottom') component2 = Graph(name = 'component2') component2.add_node(x=1.5, y=3.0, name = 'inlet', ll = 'right') junction = Graph(name = 'junction') junction.add_node(x=1.0, y=2.0, name = 'node', ll = 'bottom', draw = False) system3 = Graph(name = 'system3', graphs = [component1, component2, junction]) system3.connect('component1:outlet', 'junction:node', dir = False, ll = 'top') system3.connect('junction:node', 'component2:inlet', dir = True, ll = 'top') system4 = system3.copy(2.0, 2.0, name = 'system4') system4.rotate(45.0) # ----- plot = Graph(name = 'plot', graphs = [system1, system2, system3, system4]) CAN = Canvas(border_thickness = 0.05, grid = True) CAN.add_graph(plot) CAN.draw(save_file = 'test.pdf', display = True, print_information = False)
junction.add_node(x=1.0, y=0.0, name='node1', ll='bottom', draw=False) junction.add_node(x=1.0, y=1.0, name='node2', ll='top', draw=False) system1 = Graph(name='system1', graphs=[component1, component2, junction]) system1.connect('component1:outlet', 'junction:node1', dir=False, ll='top', ew=0.05) system1.connect('junction:node1', 'junction:node2', dir=False, ll='top', ew=0.05) system1.connect('junction:node2', 'component2:inlet', dir=True, ll='top', ew=0.05, hw_to_ew=2.5, hl_to_hw=2.5) # system2 = system1.copy(4.0, 0.0, name = 'system2') # system2.rotate(45.0) plot = Graph(name='plot', graphs=[system1]) #, system2]) CAN = Canvas(border_thickness=0.05, grid=True) CAN.add_graph(plot) CAN.draw(save_file='test.pdf', display=True, print_information=False)
ref=deepcopy(self.reflect, memo), fc=deepcopy(self.face_color, memo), ec=deepcopy(self.edge_color, memo), lw=deepcopy(self.line_width, memo)) # debugging routine if __name__ == '__main__': from schematics import component_debug_switch debugging = component_debug_switch('The component Pipe') from schematics import Canvas component = Pipe(1.0, 0.5, Point(0.0, 0.0), name='Pipe', a=0.0, ll='top', lp=1.0, ls='Component', la=0.0, fs=12) CAN = Canvas(border_thickness=0.05, grid=False) CAN.add_component(component) CAN.add_graph(component.graph) CAN.draw(display=True)
# ------------- circuit1 circuit1 = Graph(name = 'circuit1', graphs = [long_pipe1, long_pipe2]) circuit1.connect('long_pipe1:pipe2:outlet', 'long_pipe2:pipe1:inlet', name = "junction1") circuit1.connect('long_pipe2:pipe2:outlet', 'long_pipe1:pipe1:inlet', name = "junction2") # ------------- circuit2 circuit2 = circuit1.copy(name = 'circuit2') circuit2.move(x=3.0, y=3.0) circuit2.rotate(angle = 45.0) # ------------- super graph super_graph = Graph(name = 'super', graphs = [circuit1, circuit2]) # print super_graph, '\n' * 2 # print super_graph.general_info() # ------------- PLOTTING CAN = Canvas(border_thickness = 0.05, grid = True) CAN.add_graph(super_graph) CAN.draw(save_file = 'test.pdf', display = True, print_information = False)