Skip to content

Commit 9033e67

Browse files
authored
Ver 2.4.3
1 parent 0cd4f5f commit 9033e67

File tree

4 files changed

+182
-19
lines changed

4 files changed

+182
-19
lines changed

network_sketcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ def click_action_main1_1(self,click_value):
182182
self.main1_1_label_4.grid(row=4, column=1, columnspan=7, sticky='W', padx=5, pady=2)
183183

184184
if click_value == 'self.help_1_button_1':
185-
webbrowser.open('https://github.com/cisco-open/network-sketcher/blob/main/User_Guide/Japanese/User_Guide%5BJP%5D.md')
185+
webbrowser.open('https://github.com/cisco-open/network-sketcher/wiki/User_Guide%5BEN%5D')
186186

187187
if click_value == 'self.help_1_button_2':
188-
webbrowser.open('https://github.com/cisco-open/network-sketcher/blob/main/User_Guide/English/User_Guide%5BEN%5D.md')
188+
webbrowser.open('https://github.com/cisco-open/network-sketcher/wiki/User_Guide%5BJP%5D')
189189

190190
'''
191191
Sketch Panel

ns_ddx_figure.py

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,7 +2766,7 @@ def add_shape(self,shape_type,shape_left, shape_top, shape_width, shape_hight,sh
27662766
#line paramter
27672767
shape_line.color.rgb = RGBColor(112, 48, 160)
27682768
shape_line.width = Pt(0.5)
2769-
self.shape.adjustments[0] = float(0.15) # curve of ROUNDED_RECTANGLE 0.0~1.0
2769+
self.shape.adjustments[0] = float(0.150051) # curve of ROUNDED_RECTANGLE 0.0~1.0
27702770
# text parameter
27712771
self.shape.text_frame.paragraphs[0].font.color.rgb = RGBColor(112, 48, 160)
27722772

@@ -2798,7 +2798,7 @@ def add_shape(self,shape_type,shape_left, shape_top, shape_width, shape_hight,sh
27982798
# line paramter
27992799
shape_line.fill.background()
28002800
shape_line.width = Pt(0.75)
2801-
self.shape.adjustments[0] = float(0.0) # curve of ROUNDED_RECTANGLE 0.0~1.0
2801+
self.shape.adjustments[0] = float(0.00046) # curve of ROUNDED_RECTANGLE 0.0~1.0
28022802
# text parameter
28032803
#self.shape.text_frame.paragraphs[0].font.size = Pt(self.tag_font_large_size)
28042804
self.shape.text_frame.paragraphs[0].alignment = PP_ALIGN.LEFT
@@ -2811,7 +2811,7 @@ def add_shape(self,shape_type,shape_left, shape_top, shape_width, shape_hight,sh
28112811
# line paramter
28122812
shape_line.color.rgb = RGBColor(127, 127, 127)
28132813
shape_line.width = Pt(0.5)
2814-
self.shape.adjustments[0] = float(0.15) # curve of ROUNDED_RECTANGLE 0.0~1.0
2814+
self.shape.adjustments[0] = float(0.150051) # curve of ROUNDED_RECTANGLE 0.0~1.0
28152815
# text parameter
28162816
self.shape.text_frame.paragraphs[0].font.color.rgb = RGBColor(127, 127, 127)
28172817

@@ -2821,7 +2821,7 @@ def add_shape(self,shape_type,shape_left, shape_top, shape_width, shape_hight,sh
28212821
# line paramter
28222822
shape_line.color.rgb = RGBColor(0, 0, 0)
28232823
shape_line.width = Pt(0.75)
2824-
self.shape.adjustments[0] = float(0.3) # curve of ROUNDED_RECTANGLE 0.0~1.0
2824+
self.shape.adjustments[0] = float(0.30045) # curve of ROUNDED_RECTANGLE 0.0~1.0
28252825
# text parameter
28262826
self.shape.text_frame.paragraphs[0].font.color.rgb = RGBColor(0, 0, 0)
28272827

@@ -2831,7 +2831,7 @@ def add_shape(self,shape_type,shape_left, shape_top, shape_width, shape_hight,sh
28312831
# line paramter
28322832
shape_line.color.rgb = RGBColor(192, 0, 0)
28332833
shape_line.width = Pt(0.75)
2834-
self.shape.adjustments[0] = float(0.3) # curve of ROUNDED_RECTANGLE 0.0~1.0
2834+
self.shape.adjustments[0] = float(0.30045) # curve of ROUNDED_RECTANGLE 0.0~1.0
28352835
# text parameter
28362836
self.shape.text_frame.paragraphs[0].font.color.rgb = RGBColor(0, 0, 0)
28372837

@@ -2861,13 +2861,11 @@ def add_shape(self,shape_type,shape_left, shape_top, shape_width, shape_hight,sh
28612861
#line paramter
28622862
shape_line.color.rgb = RGBColor(0, 0, 0)
28632863
shape_line.width = Pt(1.0)
2864-
self.shape.adjustments[0] = float(0.0) # curve of ROUNDED_RECTANGLE 0.0~1.0
2864+
self.shape.adjustments[0] = float(0.0001) # curve of ROUNDED_RECTANGLE 0.0~1.0
28652865
# text parameter
28662866
self.shape.text_frame.paragraphs[0].font.color.rgb = RGBColor(0, 0, 0)
28672867
self.shape.text_frame.paragraphs[0].font.size = Pt(self.shae_font_large_size)
28682868

2869-
2870-
28712869
elif shape_type == 'DEVICE_L3_INSTANCE':
28722870
#fill paramter
28732871
shape_fill.fore_color.rgb = RGBColor(250, 251, 247)
@@ -2894,7 +2892,7 @@ def add_shape(self,shape_type,shape_left, shape_top, shape_width, shape_hight,sh
28942892
#line paramter
28952893
shape_line.color.rgb = RGBColor(0, 0, 0)
28962894
shape_line.width = Pt(0.5)
2897-
self.shape.adjustments[0] = float(0.0) # curve of ROUNDED_RECTANGLE 0.0~1.0
2895+
self.shape.adjustments[0] = float(0.0008) # curve of ROUNDED_RECTANGLE 0.0~1.0
28982896
# text parameter
28992897
self.shape.text_frame.paragraphs[0].font.color.rgb = RGBColor(0, 0, 0)
29002898
self.shape.text_frame.paragraphs[0].alignment = PP_ALIGN.LEFT
@@ -2907,7 +2905,7 @@ def add_shape(self,shape_type,shape_left, shape_top, shape_width, shape_hight,sh
29072905
#line paramter
29082906
shape_line.color.rgb = RGBColor(0, 0, 0)
29092907
shape_line.width = Pt(1.0)
2910-
self.shape.adjustments[0] = float(0.2) # curve of ROUNDED_RECTANGLE 0.0~1.0
2908+
self.shape.adjustments[0] = float(0.2007) # curve of ROUNDED_RECTANGLE 0.0~1.0
29112909
# text parameter
29122910
self.shape.text_frame.paragraphs[0].font.color.rgb = RGBColor(0, 0, 0)
29132911
#self.shape.text_frame.paragraphs[0].font.size = Pt(16.0)
@@ -2956,6 +2954,7 @@ def add_shape(self,shape_type,shape_left, shape_top, shape_width, shape_hight,sh
29562954
elif shape_type == 'L2SEG_TEXT':
29572955
shape_fill.background()
29582956
shape_line.fill.background()
2957+
self.shape.adjustments[0] = float(0.00057)
29592958
self.shape.text_frame.paragraphs[0].alignment = PP_ALIGN.LEFT
29602959
self.shape.text_frame.paragraphs[0].font.color.rgb = RGBColor(163, 101, 209)
29612960

@@ -2975,7 +2974,7 @@ def add_shape(self,shape_type,shape_left, shape_top, shape_width, shape_hight,sh
29752974
tmp_rgp_color = self.attribute_tuple1_1[self.shape.text]
29762975
shape_fill.fore_color.rgb = RGBColor(tmp_rgp_color[0], tmp_rgp_color[1], tmp_rgp_color[2])
29772976

2978-
self.shape.adjustments[0] = 0.2
2977+
self.shape.adjustments[0] = 0.2002
29792978
self.shape.text_frame.paragraphs[0].font.size = Pt(self.shae_font_large_size)
29802979

29812980
else:
@@ -3056,6 +3055,58 @@ def add_line(self,line_type,inche_from_connect_x,inche_from_connect_y,inche_to_c
30563055
<a:headEnd type="diamond" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
30573056
"""))
30583057

3058+
if line_type == 'FLOW0':
3059+
self.shape.shadow.inherit = True
3060+
shape_line.color.brightness = 0.3
3061+
shape_line.color.rgb = RGBColor(0, 112, 192)
3062+
shape_line.width = Pt(4.0)
3063+
line_elem = self.shape.line._get_or_add_ln()
3064+
line_elem.append(parse_xml("""
3065+
<a:headEnd type="oval" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
3066+
"""))
3067+
line_elem.append(parse_xml("""
3068+
<a:tailEnd type="arrow" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
3069+
"""))
3070+
3071+
if line_type == 'FLOW1':
3072+
self.shape.shadow.inherit = True
3073+
shape_line.color.brightness = 0.3
3074+
shape_line.color.rgb = RGBColor(0, 112, 192)
3075+
shape_line.width = Pt(4.0)
3076+
line_elem = self.shape.line._get_or_add_ln()
3077+
line_elem.append(parse_xml("""
3078+
<a:headEnd type="oval" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
3079+
"""))
3080+
'''line_elem.append(parse_xml("""
3081+
<a:tailEnd type="arrow" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
3082+
"""))'''
3083+
3084+
if line_type == 'FLOW2':
3085+
self.shape.shadow.inherit = True
3086+
shape_line.color.brightness = 0.3
3087+
shape_line.color.rgb = RGBColor(0, 112, 192)
3088+
shape_line.width = Pt(4.0)
3089+
line_elem = self.shape.line._get_or_add_ln()
3090+
'''line_elem.append(parse_xml("""
3091+
<a:headEnd type="oval" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
3092+
"""))'''
3093+
line_elem.append(parse_xml("""
3094+
<a:tailEnd type="arrow" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
3095+
"""))
3096+
3097+
if line_type == 'FLOW3':
3098+
self.shape.shadow.inherit = True
3099+
shape_line.color.brightness = 0.3
3100+
shape_line.color.rgb = RGBColor(0, 112, 192)
3101+
shape_line.width = Pt(4.0)
3102+
line_elem = self.shape.line._get_or_add_ln()
3103+
'''line_elem.append(parse_xml("""
3104+
<a:headEnd type="oval" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
3105+
"""))
3106+
line_elem.append(parse_xml("""
3107+
<a:tailEnd type="arrow" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"/>
3108+
"""))'''
3109+
30593110

30603111
def l2_device_materials(self,action_type,input_device_name,write_left_top_array,wp_list_array):
30613112
import ns_def

ns_extensions.py

Lines changed: 117 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
'''
1818
from idlelib.debugobj_r import remote_object_tree_item
1919

20-
import ns_def, ns_egt_maker
20+
import ns_def, ns_egt_maker, ns_ddx_figure
2121
from collections import Counter
2222
import tkinter as tk ,tkinter.ttk , openpyxl
2323
import ipaddress, sys, os, re, shutil
@@ -36,7 +36,7 @@ def append_flows_to_diagram(self,variable3_7_y_1,variable3_7_y_2,variable3_7_y_3
3636

3737
# Exclude the last element (['<<END_MARK>>'])
3838
filtered_master_flow = master_flow_array[:-1]
39-
print(filtered_master_flow)
39+
#print(filtered_master_flow)
4040

4141
# Exclude invalid lines
4242
filterd2_master_flow = []
@@ -45,7 +45,7 @@ def append_flows_to_diagram(self,variable3_7_y_1,variable3_7_y_2,variable3_7_y_3
4545
# Check if the second or third elements are not empty
4646
if sublist[1] and sublist[2]:
4747
filterd2_master_flow.append(sublist) # Append the sublist without the first number
48-
print(filterd2_master_flow)
48+
#print(filterd2_master_flow)
4949

5050
# Filter lines by the target
5151
filtered_target_flow = []
@@ -58,8 +58,120 @@ def append_flows_to_diagram(self,variable3_7_y_1,variable3_7_y_2,variable3_7_y_3
5858

5959
print(filtered_target_flow)
6060

61-
###ここから開始 PPTを読み込んでフロー追加
62-
61+
'''read the pptx file and shapes data'''
62+
self.shape_name_grid_array = []
63+
64+
from pptx import Presentation
65+
from pptx.util import Inches
66+
prs = Presentation(self.pptx_full_filepath)
67+
for shape in prs.slides[0].shapes:
68+
if shape.has_text_frame:
69+
if hasattr(shape, "adjustments"):
70+
try:
71+
if shape.adjustments[0] not in [0.99445, 0.50444, 0.30045, 0.00046, 0.15005, 0.00057, 0.2007] and shape.text.strip() != '': #exclude not (device or wp) shape. 0.0001 device, 0.0008 L3 instance device , 0.2002 way point, 0.2007 l3 instance in device
72+
#print(shape.text.strip(), shape.adjustments[0] , shape.left, shape.top, shape.width, shape.height)
73+
self.shape_name_grid_array.append([shape.text.strip(), shape.left, shape.top, shape.width, shape.height])
74+
75+
except IndexError:
76+
pass
77+
78+
print(self.shape_name_grid_array)
79+
80+
''' deside routes and write flows '''
81+
if os.path.isfile(self.pptx_full_filepath) == True:
82+
self.active_ppt = Presentation(self.pptx_full_filepath)
83+
self.slide = self.active_ppt.slides[0]
84+
85+
for tmp_filtered_target_flow in filtered_target_flow:
86+
87+
# select routing path is auto or static
88+
selected_route_path = []
89+
if tmp_filtered_target_flow[6] == '' and tmp_filtered_target_flow[7] == ' ':
90+
selected_route_path = [tmp_filtered_target_flow[1], tmp_filtered_target_flow[2]]
91+
92+
elif tmp_filtered_target_flow[6] == '' and tmp_filtered_target_flow[7] != ' ':
93+
selected_route_path = [element.strip().strip("'") for element in tmp_filtered_target_flow[7].split(',')]
94+
selected_route_path.insert(0, tmp_filtered_target_flow[1])
95+
selected_route_path.append(tmp_filtered_target_flow[2])
96+
97+
elif tmp_filtered_target_flow[6] != '':
98+
selected_route_path = [element.strip().strip("'") for element in tmp_filtered_target_flow[6].split(',')]
99+
selected_route_path.insert(0, tmp_filtered_target_flow[1])
100+
selected_route_path.append(tmp_filtered_target_flow[2])
101+
102+
#print(tmp_filtered_target_flow,selected_route_path)
103+
104+
''' write line'''
105+
if len(selected_route_path) == 2:
106+
# get source grid value
107+
source_grid = next(
108+
(item for item in self.shape_name_grid_array if item[0] == tmp_filtered_target_flow[1]),
109+
None # Returns None if no match is found.
110+
)
111+
112+
destination_grid = next(
113+
(item for item in self.shape_name_grid_array if item[0] == tmp_filtered_target_flow[2]),
114+
None # Returns None if no match is found.
115+
)
116+
117+
if source_grid == None or destination_grid == None:
118+
continue
119+
120+
print(source_grid, destination_grid)
121+
122+
line_type = 'FLOW0'
123+
inche_from_connect_x = (source_grid[1] + source_grid[3] * 0.25) / 914400
124+
inche_from_connect_y = (source_grid[2] + source_grid[4] * 0.5) / 914400
125+
inche_to_connect_x = (destination_grid[1] + destination_grid[3] * 0.75) / 914400
126+
inche_to_connect_y = (destination_grid[2] + destination_grid[4] * 0.5) / 914400
127+
ns_ddx_figure.extended.add_line(self,line_type,inche_from_connect_x,inche_from_connect_y,inche_to_connect_x,inche_to_connect_y)
128+
129+
elif len(selected_route_path) >= 3:
130+
print(selected_route_path)
131+
for i in range(len(selected_route_path) - 1):
132+
pair = [selected_route_path[i], selected_route_path[i + 1]]
133+
print(pair,i,len(selected_route_path) - 2 )
134+
135+
# get source grid value
136+
source_grid = next(
137+
(item for item in self.shape_name_grid_array if item[0] == pair[0]),
138+
None # Returns None if no match is found.
139+
)
140+
141+
destination_grid = next(
142+
(item for item in self.shape_name_grid_array if item[0] == pair[1]),
143+
None # Returns None if no match is found.
144+
)
145+
146+
if source_grid == None or destination_grid == None:
147+
continue
148+
149+
if i == 0:
150+
line_type = 'FLOW1'
151+
inche_from_connect_x = (source_grid[1] + source_grid[3] * 0.25) / 914400
152+
inche_from_connect_y = (source_grid[2] + source_grid[4] * 0.5) / 914400
153+
inche_to_connect_x = (destination_grid[1] + destination_grid[3] * 0.5) / 914400
154+
inche_to_connect_y = (destination_grid[2] + destination_grid[4] * 0.5) / 914400
155+
ns_ddx_figure.extended.add_line(self, line_type, inche_from_connect_x, inche_from_connect_y,inche_to_connect_x, inche_to_connect_y)
156+
elif i == len(selected_route_path) - 2:
157+
line_type = 'FLOW2'
158+
inche_from_connect_x = (source_grid[1] + source_grid[3] * 0.5) / 914400
159+
inche_from_connect_y = (source_grid[2] + source_grid[4] * 0.5) / 914400
160+
inche_to_connect_x = (destination_grid[1] + destination_grid[3] * 0.75) / 914400
161+
inche_to_connect_y = (destination_grid[2] + destination_grid[4] * 0.5) / 914400
162+
ns_ddx_figure.extended.add_line(self, line_type, inche_from_connect_x, inche_from_connect_y,inche_to_connect_x, inche_to_connect_y)
163+
else:
164+
line_type = 'FLOW3'
165+
inche_from_connect_x = (source_grid[1] + source_grid[3] * 0.5) / 914400
166+
inche_from_connect_y = (source_grid[2] + source_grid[4] * 0.5) / 914400
167+
inche_to_connect_x = (destination_grid[1] + destination_grid[3] * 0.5) / 914400
168+
inche_to_connect_y = (destination_grid[2] + destination_grid[4] * 0.5) / 914400
169+
ns_ddx_figure.extended.add_line(self, line_type, inche_from_connect_x, inche_from_connect_y,inche_to_connect_x, inche_to_connect_y)
170+
171+
folder = os.path.dirname(self.pptx_full_filepath)
172+
filename = os.path.basename(self.pptx_full_filepath)
173+
modified_filepath = os.path.join(folder, f"Added_flows_{filename}")
174+
self.active_ppt.save(modified_filepath)
63175

64176
def get_flow_item_list(self): # add at ver 2.4.3
65177
#print('--- get_flow_item_list ---')

ns_l3_diagram_create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def __init__(self):
203203
shape.fill.fore_color.rgb = RGBColor(tmp_rgp_color[0], tmp_rgp_color[1],tmp_rgp_color[2])
204204

205205
if shape.adjustments:
206-
shape.adjustments[0] = 0.2
206+
shape.adjustments[0] = 0.2002
207207

208208
#print(self.output_ppt_file)
209209
prs.save(self.output_ppt_file)

0 commit comments

Comments
 (0)