-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathns_l3_diagram_create.py
2253 lines (1804 loc) · 129 KB
/
ns_l3_diagram_create.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'''
SPDX-License-Identifier: Apache-2.0
Copyright 2023 Cisco Systems, Inc. and its affiliates
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'''
import copy
from pptx import *
import sys, os, re, shutil
import numpy as np
import math
import ns_def , ns_ddx_figure
import openpyxl
from pptx import Presentation
from pptx.enum.dml import MSO_LINE
from pptx.enum.text import MSO_ANCHOR, PP_ALIGN, MSO_AUTO_SIZE
from pptx.enum.shapes import MSO_SHAPE, MSO_CONNECTOR
from pptx.dml.color import RGBColor, MSO_THEME_COLOR
from pptx.dml.line import LineFormat
from pptx.shapes.connector import Connector
from pptx.util import Inches, Cm, Pt
from collections import defaultdict
class ns_l3_diagram_create():
def __init__(self):
#print('--- ns_l3_diagram_create ---')
'''
STEP0 get values of Master Data
'''
#parameter
ws_name = 'Master_Data'
ws_l2_name = 'Master_Data_L2'
ws_l3_name = 'Master_Data_L3'
excel_maseter_file = self.inFileTxt_L3_3_1.get()
if self.click_value_l3 == 'L3-4-1':
excel_maseter_file = self.outFileTxt_L3_3_5_1.get()
self.result_get_l2_broadcast_domains = ns_def.get_l2_broadcast_domains.run(self,excel_maseter_file) ## 'self.update_l2_table_array, device_l2_boradcast_domain_array, device_l2_directly_l3vport_array, device_l2_other_array, marged_l2_broadcast_group_array'
#print('--- self.update_l2_table_array ---')
#print(self.result_get_l2_broadcast_domains[0])
#print('--- self.device_l2_boradcast_domain_array ---')
#print(self.result_get_l2_broadcast_domains[1])
self.device_l2_boradcast_domain_array = self.result_get_l2_broadcast_domains[1]
#print('--- device_l2_directly_l3vport_array ---')
#print(self.result_get_l2_broadcast_domains[2])
self.device_l2_directly_l3vport_array = self.result_get_l2_broadcast_domains[2]
#print('--- device_l2_other_array ---')
#print(self.result_get_l2_broadcast_domains[3])
self.device_l2_other_array = self.result_get_l2_broadcast_domains[3]
#print('--- marged_l2_broadcast_group_array ---')
#print(self.result_get_l2_broadcast_domains[4])
self.marged_l2_broadcast_group_array = self.result_get_l2_broadcast_domains[4]
#print('--- self.target_l2_broadcast_group_array ---')
#print(self.target_l2_broadcast_group_array)
self.l3_table_array = ns_def.convert_master_to_array(ws_l3_name, excel_maseter_file, '<<L3_TABLE>>')
#print('--- self.l3_table_array ---')
#print(self.l3_table_array )
self.update_l3_table_array =[]
for tmp_l3_table_array in self.l3_table_array :
if tmp_l3_table_array[0] != 1 and tmp_l3_table_array[0] != 2:
tmp_l3_table_array[1].extend(['','','',''])
del tmp_l3_table_array[1][6:]
#get per ip address
work_new_l3_table_array = tmp_l3_table_array[1][4].split(',')
add_ip_address_set_array = []
for tmp_tmp_new_l3_table_array in work_new_l3_table_array:
# check IP Addresses
if ns_def.check_ip_format(tmp_tmp_new_l3_table_array) == 'IPv4':
change_tmp_ip_address = str(tmp_tmp_new_l3_table_array).replace('[', '').replace(']', '').replace('\'', '').replace(' ', '')
#extend [[ip_address,network_address,mask,host_address][etc..]]
ip_address_set_array = ns_def.get_ip_address_set(change_tmp_ip_address)
add_ip_address_set_array.append(ip_address_set_array)
tmp_l3_table_array[1].append(str(add_ip_address_set_array))
self.update_l3_table_array.append(tmp_l3_table_array[1])
#print('--- self.update_l3_table_array ---')
#print(self.update_l3_table_array )
# GET way point with folder tuple
self.wp_with_folder_tuple = {}
for tmp_wp_folder_name in self.folder_wp_name_array[1]:
current_row = 1
flag_start_row = False
flag_end_row = False
while flag_end_row == False:
if str(self.position_shape_tuple[current_row, 1]) == tmp_wp_folder_name:
start_row = current_row
flag_start_row = True
if flag_start_row == True and str(self.position_shape_tuple[current_row, 1]) == '<END>':
flag_end_row = True
end_row = current_row - 1
current_row += 1
# print(tmp_wp_folder_name,start_row,end_row)
for i in range(start_row, end_row + 1):
flag_start_column = False
current_column = 2
while flag_start_column == False:
if str(self.position_shape_tuple[i, current_column]) != '<END>':
self.wp_with_folder_tuple[self.position_shape_tuple[i, current_column]] = tmp_wp_folder_name
else:
flag_start_column = True
current_column += 1
#print('---- wp_with_folder_tuple ----')
#print(self.wp_with_folder_tuple)
'''
Create per area l3 ppt
'''
if self.click_value == 'L3-3-2':
'''GET SIZE'''
self.page_size_array = []
self.slide_width = 0.0
self.slide_hight = 0.0
for tmp_new_position_folder_array in self.folder_wp_name_array[0]:
action_type = 'GET_SIZE'
offset_x = 0.0 #inches
offset_y = 0.0 #inches
self.page_size_array.append( ns_l3_diagram_create.l3_area_create(self, tmp_new_position_folder_array , action_type ,offset_x ,offset_y))
for tmp_page_size_array in self.page_size_array:
if self.slide_width < tmp_page_size_array[3]:
self.slide_width = tmp_page_size_array[3]
if self.slide_hight < tmp_page_size_array[4]:
self.slide_hight = tmp_page_size_array[4]
#add page margin
self.slide_width += 1.0 * 2 #page margin
self.slide_hight += 1.0 * 2 #page margin
#print('--- self.page_size_array ,self.slide_width ,self.slide_hight --- [outline_shape_type, outline_shape_left, outline_shape_top, outline_shape_width, outline_shape_hight, folder_shape_text] ,self.slide_width ,self.slide_hight')
#print(self.page_size_array,self.slide_width ,self.slide_hight)
# Calculate area offset for one area at ver 2.3.3
if self.click_value_l3 == 'L3-4-1':
create_master_file_one_area.calculate_area_offset(self)
'''CREATE L3 DIAGRAM'''
self.result_get_l2_broadcast_domains = ns_def.get_l2_broadcast_domains.run(self, excel_maseter_file) ## 'self.update_l2_table_array, device_l2_boradcast_domain_array, device_l2_directly_l3vport_array, device_l2_other_array, marged_l2_broadcast_group_array'
#self.active_ppt = Presentation() # define target ppt object
if os.path.exists(self.output_ppt_file) and self.flag_second_page == True:
self.active_ppt = Presentation(self.output_ppt_file)
slide_layout = self.active_ppt.slide_layouts[5] # Blank layout
#self.active_ppt.slides.add_slide(slide_layout)
else:
self.active_ppt = Presentation()
for tmp_new_position_folder_array in self.folder_wp_name_array[0]:
action_type = 'CREATE'
offset_x = 0.0 #inches
offset_y = 0.0 #inches
for tmp_page_size_array in self.page_size_array:
if tmp_page_size_array[5] == tmp_new_position_folder_array:
offset_x = tmp_page_size_array[1]
offset_y = tmp_page_size_array[2]
break
ns_l3_diagram_create.l3_area_create(self, tmp_new_position_folder_array , action_type,offset_x ,offset_y)
### save pptx file
self.active_ppt.save(self.output_ppt_file)
'''
Modify style of device for All Areas at ver 2.3.0
'''
if self.click_value_l3 == 'L3-4-1':
from pptx.dml.color import RGBColor
prs = Presentation(self.output_ppt_file)
for slide in prs.slides:
shapes_to_process = list(slide.shapes)
while shapes_to_process:
shape = shapes_to_process.pop()
if shape.has_text_frame:
for text in shape.text.splitlines():
if text in self.global_wp_array:
shape.fill.solid()
shape.fill.fore_color.rgb = RGBColor(220, 230, 242)
### apply attribute color to shape at ver 2.4.0
tmp_rgp_color = self.attribute_tuple1_1[text]
shape.fill.fore_color.rgb = RGBColor(tmp_rgp_color[0], tmp_rgp_color[1],tmp_rgp_color[2])
if shape.adjustments:
shape.adjustments[0] = 0.2
#print(self.output_ppt_file)
prs.save(self.output_ppt_file)
def l3_area_create(self, target_folder_name, action_type,offset_x ,offset_y):
print('--- l3_area_create -',action_type,' - ',target_folder_name,'---')
self.used_l3segment_array = []
### get l3segment in the target folder
target_all_device_array = []
for tmp_update_l2_table_array in self.update_l2_table_array:
if tmp_update_l2_table_array[0] == target_folder_name and 'L3' in tmp_update_l2_table_array[2]:
#print([tmp_update_l2_table_array[1],tmp_update_l2_table_array[3]])
target_all_device_array.append([tmp_update_l2_table_array[1],tmp_update_l2_table_array[3]])
if tmp_update_l2_table_array[0] == target_folder_name and 'L3' in tmp_update_l2_table_array[4]:
#print([tmp_update_l2_table_array[1], tmp_update_l2_table_array[5]])
target_all_device_array.append([tmp_update_l2_table_array[1], tmp_update_l2_table_array[5]])
target_all_device_array = ns_def.get_l2_broadcast_domains.get_unique_list(target_all_device_array)
#print(target_all_device_array)
update_l2_broadcast_group_array = []
for tmp_target_l2_broadcast_group_array in self.target_l2_broadcast_group_array:
for tmp_tmp_target_l2_broadcast_group_array in tmp_target_l2_broadcast_group_array[1]:
if tmp_tmp_target_l2_broadcast_group_array in target_all_device_array:
#print(tmp_tmp_target_l2_broadcast_group_array)
update_l2_broadcast_group_array.append(tmp_target_l2_broadcast_group_array)
break
#print('--- update_l2_broadcast_group_array ---')
#print(update_l2_broadcast_group_array)
### get <<POSITION_SHAPE>> in MASTER EXCEL
target_position_shape_array = []
#print('--- self.position_shape_array ---')
#print(self.position_shape_array )
flag_match_folder = False
for tmp_position_shape_array in self.position_shape_array:
if tmp_position_shape_array[1][0] == target_folder_name:
del tmp_position_shape_array[1][0]
del tmp_position_shape_array[1][-1]
target_position_shape_array.append(tmp_position_shape_array[1])
flag_match_folder = True
elif flag_match_folder == True and tmp_position_shape_array[1][0] == '':
del tmp_position_shape_array[1][0]
del tmp_position_shape_array[1][-1]
target_position_shape_array.append(tmp_position_shape_array[1])
elif flag_match_folder == True and tmp_position_shape_array[1][0] != '':
break
#print('--- target_position_shape_array ---')
#print(target_position_shape_array,len(target_position_shape_array))
### Kyuusai if len(target_position_shape_array) == 1
if len(target_position_shape_array) == 1:
target_position_shape_array.append(['_AIR_9999']) # add dummy shape to second row
### get WP of <<POSITION_FOLDER>>in MASTER EXCEL
wp_exist_array = [[], [], [], []] # up/down/left/right
target_folder_row = 1
# check left/right wp
for tmp_position_folder_array in self.position_folder_array:
if tmp_position_folder_array[1][0] != '<<POSITION_FOLDER>>' and tmp_position_folder_array[1][0] != '<SET_WIDTH>':
#print(tmp_position_folder_array)
for index, tmp_folder_name in enumerate(tmp_position_folder_array[1]):
if tmp_folder_name == target_folder_name:
target_folder_row = tmp_position_folder_array[0]
if len(tmp_position_folder_array[1]) >= (index + 2):
if '_wp_' in str(tmp_position_folder_array[1][index+1]):
#print('right ', tmp_position_folder_array[1][index+1])
wp_exist_array[3].extend([tmp_position_folder_array[1][index+1]])
if index >= 1:
if '_wp_' in str(tmp_position_folder_array[1][index - 1]):
#print('left ', tmp_position_folder_array[1][index - 1])
wp_exist_array[2].extend([tmp_position_folder_array[1][index - 1]])
#check up/down wp
for tmp_position_folder_array in self.position_folder_array:
if tmp_position_folder_array[0] == target_folder_row -2:
for tmp_tmp_position_folder_array in tmp_position_folder_array[1]:
if '_wp_' in str(tmp_tmp_position_folder_array):
wp_exist_array[0].extend([tmp_tmp_position_folder_array])
if tmp_position_folder_array[0] == target_folder_row +2:
for tmp_tmp_position_folder_array in tmp_position_folder_array[1]:
if '_wp_' in str(tmp_tmp_position_folder_array):
wp_exist_array[1].extend([tmp_tmp_position_folder_array])
#print('--- wp_exist_array ---')
#print(wp_exist_array,' #up/down/left/right')
#convert _wp_ folder name to shape name
new_wp_exist_array = [[], [], [], []]
for index,tmp_wp_exist_array in enumerate(wp_exist_array):
for tmp_tmp_wp_exist_array in tmp_wp_exist_array:
for tmp_wp_with_folder_tuple in self.wp_with_folder_tuple:
if tmp_tmp_wp_exist_array == str(self.wp_with_folder_tuple[tmp_wp_with_folder_tuple]):
#check if wp is connected to own folder
#check wp name
for tmp_update_l2_broadcast_group_array in update_l2_broadcast_group_array:
for tmp_tmp_update_l2_broadcast_group_array in tmp_update_l2_broadcast_group_array[1]:
#print(tmp_tmp_target_l2_broadcast_group_array )
if tmp_tmp_update_l2_broadcast_group_array[0] == str(tmp_wp_with_folder_tuple):
# print(index,tmp_wp_with_folder_tuple)
new_wp_exist_array[index].extend([tmp_wp_with_folder_tuple])
#check broadcast domain number
for tmp_device_l2_boradcast_domain_array in self.device_l2_boradcast_domain_array:
for tmp_tmp_device_l2_boradcast_domain_array in tmp_device_l2_boradcast_domain_array:
#print(tmp_tmp_device_l2_boradcast_domain_array)
if tmp_tmp_device_l2_boradcast_domain_array[1] == str(tmp_wp_with_folder_tuple):
for tmp_update_l2_broadcast_group_array in update_l2_broadcast_group_array:
for tmp_tmp_update_l2_broadcast_group_array in tmp_update_l2_broadcast_group_array:
if tmp_tmp_device_l2_boradcast_domain_array[0] in tmp_tmp_update_l2_broadcast_group_array :
#print(tmp_tmp_device_l2_boradcast_domain_array[0],tmp_tmp_device_l2_boradcast_domain_array[1])
new_wp_exist_array[index].extend([tmp_wp_with_folder_tuple])
new_wp_exist_array = [list(set(new_wp_exist_array [0])),list(set(new_wp_exist_array [1])),list(set(new_wp_exist_array [2])),list(set(new_wp_exist_array[3]))]
#print('--- new_wp_exist_array ---')
#print(new_wp_exist_array ,' #up/down/left/right')
self.new_wp_exist_array = new_wp_exist_array
marge_target_position_shape_array = target_position_shape_array
if new_wp_exist_array[0] != []:
marge_target_position_shape_array.insert(0,new_wp_exist_array[0])
if new_wp_exist_array[1] != []:
marge_target_position_shape_array.append(new_wp_exist_array[1])
#print('--- marge_target_position_shape_array ---')
#print(marge_target_position_shape_array)
wp_marge_target_position_shape_array = marge_target_position_shape_array
#left_right_wp_row_num = math.floor(len(marge_target_position_shape_array) * 0.5 - 1)
left_right_wp_row_num = math.floor((len(marge_target_position_shape_array) - 1) * 0.5) # updated
# write wp left
if new_wp_exist_array[2] != []:
for tmp_i in new_wp_exist_array[2]:
shape_text = tmp_i
# insert wp to edge of left side
wp_marge_target_position_shape_array[left_right_wp_row_num].insert(0, shape_text)
# write wp right
if new_wp_exist_array[3] != []:
for tmp_i in new_wp_exist_array[3]:
shape_text = tmp_i
# insert wp to edge of right side
wp_marge_target_position_shape_array[left_right_wp_row_num].extend([shape_text])
#print('--- wp_marge_target_position_shape_array---')
#print(wp_marge_target_position_shape_array)
#get up down l3if array
self.up_down_l3if_array = get_up_down_l3if_count(self,wp_marge_target_position_shape_array)
#print('--- self.up_down_l3if_array --- # up/down')
#print(self.up_down_l3if_array[0])
#print(self.up_down_l3if_array[1])
### get index for target_position_shape_array
#get index_1 -> target_position_shape_array
self.index_1_array = []
for self.index_1,tmp_target_position_shape_array in enumerate(target_position_shape_array):
#print(self.index_1,tmp_target_position_shape_array )
self.index_1_array.append(self.index_1)
#get index_11 -> marge_target_position_shape_array
self.index_11_array = []
for self.index_11,tmp_target_position_shape_array in enumerate(marge_target_position_shape_array):
#print(self.index_11,tmp_target_position_shape_array )
self.index_11_array.append(self.index_1)
### GET identify L3IF that is connected to l3 segment
self.l3_if_has_l3_segment_array = []
return_get_l3_segment_array = []
self.used_l3segment_array = []
for self.index_2, tmp_target_position_shape_array in enumerate(target_position_shape_array):
for return_get_l3_segment_num in get_l3_segment_num(self,tmp_target_position_shape_array,target_position_shape_array)[1]:
return_get_l3_segment_array.append(return_get_l3_segment_num)
for tmp_target_l2_broadcast_group_array in self.target_l2_broadcast_group_array:
if return_get_l3_segment_num in tmp_target_l2_broadcast_group_array[1]:
self.l3_if_has_l3_segment_array.extend(tmp_target_l2_broadcast_group_array[1])
#print('--- self.l3_if_has_l3_segment_array ---')
#print(self.l3_if_has_l3_segment_array)
### GET L3 instance
self.defalut_l3_instance_name = 'Defalut'
self.l3_instance_array = []
self.update_l3_instance_array = []
for tmp_update_l3_table_array in self.update_l3_table_array:
if tmp_update_l3_table_array[3].replace(' ','') != '':
self.l3_instance_array.append([tmp_update_l3_table_array[1],tmp_update_l3_table_array[3]])
self.l3_instance_array = ns_def.get_l2_broadcast_domains.get_unique_list(self.l3_instance_array)
#print('--- self.l3_instance_array ---')
#print(self.l3_instance_array)
for tmp_update_l3_table_array in self.update_l3_table_array:
for tmp_l3_instance_array in self.l3_instance_array:
if tmp_l3_instance_array[0] == tmp_update_l3_table_array[1]:
if tmp_update_l3_table_array[3].replace(' ','') != '':
self.update_l3_instance_array.append([tmp_update_l3_table_array,tmp_update_l3_table_array[3]])
#print([tmp_update_l3_table_array,tmp_update_l3_table_array[3]])
else:
self.update_l3_instance_array.append([tmp_update_l3_table_array, self.defalut_l3_instance_name])
#print([tmp_update_l3_table_array, self.defalut_l3_instance_name])
#print('--- self.update_l3_instance_array ---')
#print(self.update_l3_instance_array)
'''
make ppt diagram
'''
### create slide
if action_type == 'CREATE':
self.active_ppt.slide_width = Inches(10.0)
self.active_ppt.slide_height = Inches(5.0)
### adjust to large size , ver 2.1
if self.slide_width > 56.0:
self.slide_width = 56.0
if self.slide_hight > 56.0:
self.slide_hight = 56.0
#input from get_size
if self.active_ppt.slide_width < Inches(self.slide_width):
self.active_ppt.slide_width = Inches(self.slide_width)
if self.active_ppt.slide_height < Inches(self.slide_hight):
self.active_ppt.slide_height = Inches(self.slide_hight)
self.title_only_slide_layout = self.active_ppt.slide_layouts[5]
self.slide = self.active_ppt.slides.add_slide(self.title_only_slide_layout)
self.slide.shapes.title.left = Inches(0.0)
self.slide.shapes.title.top = Inches(0.0)
self.slide.shapes.title.width = Inches(10.0)
self.slide.shapes.title.height = Inches(1.0)
self.shape = self.slide.shapes
self.shape.title.text = '[L3] ' + target_folder_name
if self.flag_second_page == True and self.click_value_l3 == 'L3-4-1':
self.shape.title.text = '[L3] ' + target_folder_name +' <Focus on Connectivity>'
elif self.flag_second_page == False and self.click_value_l3 == 'L3-4-1':
self.shape.title.text = '[L3] ' + target_folder_name + ' <Focus on Area>'
if self.click_value_VPN == 'VPN-1-3': # add ver 2.3.2
if self.flag_second_page == True and self.click_value_l3 == 'L3-4-1':
self.shape.title.text = '[VPNs on L3] <Focus on Connectivity>'
elif self.flag_second_page == False and self.click_value_l3 == 'L3-4-1':
self.shape.title.text = '[VPNs on L3] <Focus on Area>'
### parameter
self.left_margin = 1.0 # Inches
self.top_margin = 1.0 # Inches
# input from get_size
if action_type == 'CREATE':
self.left_margin = self.left_margin - offset_x + self.left_margin # Inches
self.top_margin = self.top_margin - offset_y + self.top_margin # Inches
top_offset = 0.0 #Inches
left_offset = 0.0 #Inches
self.folder_font_type = 'Calibri'
self.folder_font_size = 10 # Pt
self.shape_font_type = 'Calibri'
self.shae_font_size = 6.0 # Pt
self.shae_font_large_size = 8.0 # Pt
self.tag_font_large_size = 4.0 # Pt
self.between_shape_column = 0.5 #inches
between_shape_row = 0.25 # inches
self.between_l3if = 0.25 #inches
l3_segment_up_down_offset = 0.15
if self.click_value_l3 == 'L3-4-1': # inches #changed at ver 2.3.3
l3_segment_up_down_offset = 0.35
min_between_line = 0.075 # inches
min_shape_width = 1.0 #inches
l3_segment_hight_ratio = 1.75 # ratio
'''
main loop
'''
shape_left = self.left_margin
shape_top = self.top_margin
'''
loop write device
'''
l3segment_line_array = []
self.connected_l3if_key_array = []
self.all_l3if_tag_array = []
self.mark_multi_ip_array = []
self.size_l3_instance_array = []
self.used_l3segment_array = []
self.area_position_array = [9999.0,0.0,0.0,0.0,target_folder_name] # shape_left, shape_top, shape_width, shape_hight, shape_text
self.outline_position_array = [9999.0, 0.0, 0.0, 0.0] # shape_left, shape_top, shape_width, shape_hight
max_offset_x = 0.0
end_l3_seg_inche_x = 0.0
self.mark_wp_top = self.top_margin + top_offset
flag_first_colmun = True
### ver 2.3.3 make self.target_offset_shape_array ###
# get shape name in the folder and sort
ws_name = 'Master_Data'
ppt_meta_file = str(self.inFileTxt_11_1.get())
self.ori_position_shape_array = ns_def.convert_master_to_array(ws_name, ppt_meta_file, '<<POSITION_SHAPE>>')
ori_position_shape_tuple = ns_def.convert_array_to_tuple(self.ori_position_shape_array)
self.shape_folder_tuple = ns_def.get_shape_folder_tuple(ori_position_shape_tuple)
# print(self.shape_folder_tuple)
self.target_offset_shape_array = []
def process_elements(array):
target_array = []
for element in array:
if element[0] >= 2:
items = element[1]
for item in items[1:]:
if '_AIR_' not in item and '<END>' not in item:
target_array.append(item)
break # Stop after appending the first valid item
return target_array
# Process the array and print the result
self.target_offset_shape_array = process_elements(self.ori_position_shape_array)
#print('--- self.target_offset_shape_array ---')
#print(self.target_offset_shape_array)
################################################
for self.index_2,tmp_target_position_shape_array in enumerate(target_position_shape_array):
start_l3_seg_inche_x = self.left_margin + left_offset
''' write device and wp(up/down)'''
self.flag_area_equel_left = True
self.second_area_offset = 0.0
for tmp_tmp_target_position_shape_array in tmp_target_position_shape_array:
''' OFFSET Ver 2.3.3 '''
if self.click_value_l3 == 'L3-4-1':
if action_type == 'CREATE' and tmp_tmp_target_position_shape_array not in '_AIR_' and self.flag_second_page == False:
shape_name = tmp_tmp_target_position_shape_array
left_offset += create_master_file_one_area.get_l3_shape_offset(self,shape_name ,left_offset)
tmp_left_array = []
tmp_right_array = []
for i in new_wp_exist_array[2]:
tmp_left_array.append(i)
for k in new_wp_exist_array[3]:
tmp_left_array.append(k)
if tmp_tmp_target_position_shape_array not in tmp_left_array and tmp_tmp_target_position_shape_array not in tmp_right_array and '_AIR_' not in tmp_tmp_target_position_shape_array: # except left/right wp in writing pre device. If you need _AIR_ empty space, delete '_AIR_ not in tmp_tmp_target_position_shape_array'
shape_text = tmp_tmp_target_position_shape_array
shape_type = 'DEVICE_NORMAL'
shape_left = self.left_margin + left_offset
shape_top = self.top_margin + top_offset
shape_width_hight_array = ns_def.get_description_width_hight(self.shae_font_large_size,tmp_tmp_target_position_shape_array)
shape_width = shape_width_hight_array[0]
shape_hight = shape_width_hight_array[1] * 5
### Add wp change at ver 2.3.0 ####
if self.click_value_l3 == 'L3-4-1' and len(self.wp_list_array) != 0:
self.global_wp_array = copy.deepcopy(self.wp_list_array)
self.wp_list_array = []
###################################
if shape_text in self.wp_list_array:
shape_type = 'WAY_POINT_NORMAL'
self.shape_width_if_array = get_shape_width_if_array(self,tmp_tmp_target_position_shape_array) ### return_shape_width,tmp_up_array,tmp_down_array,full_ip_address_width_array
tmp_shpae_width = self.shape_width_if_array[0]
if shape_width < tmp_shpae_width:
shape_width = tmp_shpae_width
if min_shape_width > shape_width:
shape_width = min_shape_width
#check l3 instance exist
for tmp_l3_instance_array in self.l3_instance_array:
if tmp_l3_instance_array[0] == shape_text:
shape_type = 'DEVICE_L3_INSTANCE'
#write l3 instance
self.between_l3instance = min_between_line * 2
tmp_l3_add_shape_array = []
if shape_type == 'DEVICE_L3_INSTANCE':
tmp_l3_instance_array = []
for tmp_update_l3_instance_array in self.update_l3_instance_array:
if tmp_update_l3_instance_array[0][1] == shape_text:
tmp_l3_instance_array.append(tmp_update_l3_instance_array[1])
tmp_l3_instance_array = ns_def.get_l2_broadcast_domains.get_unique_list(tmp_l3_instance_array)
offset_l3_instance = ns_def.get_description_width_hight(self.shae_font_size,shape_text)[0] + self.between_l3instance
calc_need_device_width = ns_def.get_description_width_hight(self.shae_font_size,shape_text)[0] + offset_l3_instance
for tmp_tmp_l3_instance_array in tmp_l3_instance_array:
l3_shape_text = tmp_tmp_l3_instance_array
l3_shape_width = ns_def.get_description_width_hight(self.shae_font_size,tmp_tmp_l3_instance_array)[0]
l3_shape_hight = ns_def.get_description_width_hight(self.shae_font_size,tmp_tmp_l3_instance_array)[1]
if (min_shape_width * 0.3) > l3_shape_width:
l3_shape_width = (min_shape_width * 0.3)
l3_shape_top = shape_top + (shape_hight * 0.5) - l3_shape_hight * 0.5
l3_shape_left = shape_left + offset_l3_instance
l3_shape_type = 'L3_INSTANCE'
calc_need_device_width += l3_shape_width + self.between_l3instance
if action_type == 'CREATE':
#self.shape = self.slide.shapes
#ns_ddx_figure.extended.add_shape(self, l3_shape_type, l3_shape_left, l3_shape_top, l3_shape_width, l3_shape_hight, l3_shape_text)
tmp_l3_add_shape_array.append([l3_shape_type, l3_shape_left, l3_shape_top, l3_shape_width, l3_shape_hight, l3_shape_text])
offset_l3_instance += l3_shape_width + self.between_l3instance
#self.size_l3_instance_array.append([shape_text, l3_shape_text, l3_shape_type, l3_shape_left, l3_shape_top, l3_shape_width, l3_shape_hight])
if calc_need_device_width > shape_width:
### extend distance of shape
shape_width = calc_need_device_width
for tmp_tmp_l3_add_shape_array in tmp_l3_add_shape_array:
l3_shape_type = tmp_tmp_l3_add_shape_array[0]
l3_shape_left = tmp_tmp_l3_add_shape_array[1]
l3_shape_top = tmp_tmp_l3_add_shape_array[2]
l3_shape_width = tmp_tmp_l3_add_shape_array[3]
l3_shape_hight = tmp_tmp_l3_add_shape_array[4]
l3_shape_text = tmp_tmp_l3_add_shape_array[5]
self.shape = self.slide.shapes
ns_ddx_figure.extended.add_shape(self, l3_shape_type, l3_shape_left, l3_shape_top, l3_shape_width, l3_shape_hight, l3_shape_text)
self.size_l3_instance_array.append([shape_text, l3_shape_text, l3_shape_type, l3_shape_left, l3_shape_top, l3_shape_width, l3_shape_hight])
else:
### not extend distance of shape
tmp_l3_instance_array = []
for tmp_update_l3_instance_array in self.update_l3_instance_array:
if tmp_update_l3_instance_array[0][1] == shape_text:
tmp_l3_instance_array.append(tmp_update_l3_instance_array[1])
tmp_l3_instance_array = ns_def.get_l2_broadcast_domains.get_unique_list(tmp_l3_instance_array)
tmp_plus_width = shape_width / (len(tmp_l3_instance_array) + 1)
offset_l3_instance = 0.0
for tmp_tmp_l3_instance_array in tmp_l3_instance_array:
l3_shape_text = tmp_tmp_l3_instance_array
l3_shape_width = ns_def.get_description_width_hight(self.shae_font_size, tmp_tmp_l3_instance_array)[0]
l3_shape_hight = ns_def.get_description_width_hight(self.shae_font_size, tmp_tmp_l3_instance_array)[1]
if (min_shape_width * 0.3) > l3_shape_width:
l3_shape_width = (min_shape_width * 0.3)
l3_shape_top = shape_top + (shape_hight * 0.5) - l3_shape_hight * 0.5
l3_shape_left = shape_left + tmp_plus_width - l3_shape_width * 0.5 + offset_l3_instance
l3_shape_type = 'L3_INSTANCE'
if action_type == 'CREATE':
self.shape = self.slide.shapes
ns_ddx_figure.extended.add_shape(self, l3_shape_type, l3_shape_left, l3_shape_top, l3_shape_width, l3_shape_hight, l3_shape_text)
if self.click_value_l3 == 'L3-4-1':
self.add_shape_array.append([shape_type, shape_left, shape_top, shape_width, shape_hight,shape_text]) # add ver 2.3.3
offset_l3_instance += tmp_plus_width
self.size_l3_instance_array.append([shape_text, l3_shape_text, l3_shape_type, l3_shape_left, l3_shape_top, l3_shape_width, l3_shape_hight])
if '_AIR_' not in shape_text:
if action_type == 'CREATE':
self.shape = self.slide.shapes
ns_ddx_figure.extended.add_shape(self, shape_type, shape_left, shape_top, shape_width, shape_hight, shape_text)
self.slide.shapes._spTree.remove(self.shape._element) # move shape to back layer
self.slide.shapes._spTree.insert(2, self.shape._element) # move shape to back layer
if self.click_value_l3 == 'L3-4-1':
self.add_shape_array.append([shape_type, shape_left, shape_top, shape_width, shape_hight, shape_text]) # add ver 2.3.3
'''GET Folder and Outline position'''
# get folder left
if (shape_type == 'DEVICE_L3_INSTANCE' or shape_type == 'DEVICE_NORMAL' or shape_type == 'WAY_POINT_NORMAL') and self.area_position_array[0] + self.between_shape_column > shape_left:
self.area_position_array[0] = shape_left - self.between_shape_column
self.outline_position_array[0] = shape_left - self.between_shape_column * 2
# get folder top
if (shape_type == 'DEVICE_L3_INSTANCE' or shape_type == 'DEVICE_NORMAL') and flag_first_colmun == True:
self.area_position_array[1] = shape_top - between_shape_row
if new_wp_exist_array[0] == []:
self.outline_position_array[1] = shape_top - between_shape_row * 2
flag_first_colmun = False
# get folder width
if (shape_type == 'DEVICE_L3_INSTANCE' or shape_type == 'DEVICE_NORMAL' or shape_type == 'WAY_POINT_NORMAL') and (self.outline_position_array[0] + self.outline_position_array[2]) < shape_left + shape_width:
self.outline_position_array[2] = shape_left + shape_width + self.between_shape_column * 2 - self.outline_position_array[0]
if (shape_type == 'DEVICE_L3_INSTANCE' or shape_type == 'DEVICE_NORMAL' ) and (self.area_position_array[0] + self.area_position_array[2]) < shape_left + shape_width:
self.area_position_array[2] = shape_left + shape_width + self.between_shape_column - self.area_position_array[0]
# get folder hight
if shape_type == 'DEVICE_L3_INSTANCE' or shape_type == 'DEVICE_NORMAL':
self.area_position_array[3] = shape_top + shape_hight + between_shape_row - self.area_position_array[1]
self.outline_position_array[3] = shape_top + shape_hight + between_shape_row * 3 - self.outline_position_array[1]
# adjust shape_hight if downside wp exist
if new_wp_exist_array[1] != []: #up/down/left/right
self.area_position_array[3] = (shape_top - between_shape_row) - self.area_position_array[1]
#adjust shape top of outline, if wp
if shape_type == 'WAY_POINT_NORMAL':
if shape_text in new_wp_exist_array[0]:
self.outline_position_array[1] = shape_top - between_shape_row
if shape_text in new_wp_exist_array[1]:
self.outline_position_array[3] = (shape_top + shape_hight + between_shape_row) - self.outline_position_array[1]
left_offset += shape_width + self.between_shape_column
#print('--- self.size_l3_instance_array --- shape_text, l3_shape_text, l3_shape_type, l3_shape_left, l3_shape_top, l3_shape_width, l3_shape_hight')
#print(self.size_l3_instance_array)
'''write l3 if '''
#print('### self.shape_width_if_array[1], self.shape_width_if_array[2] ',self.shape_width_if_array[1], self.shape_width_if_array[2])
tag_up_offset_x = self.between_l3if
tag_down_offset_x = self.between_l3if
for tmp_update_l3_table_array in self.update_l3_table_array:
if tmp_update_l3_table_array[1] == shape_text:
'''write upside l3 if'''
for up_shape_width_if_array in self.shape_width_if_array[1]:
if up_shape_width_if_array[0] == tmp_update_l3_table_array[2]:
#print('##UP ',shape_text,up_shape_width_if_array[1])
shape_width_hight_array = ns_def.get_description_width_hight(self.tag_font_large_size, up_shape_width_if_array[1]) # width, hight
tag_shape_type = 'TAG_NORMAL'
tag_shape_left = shape_left + tag_up_offset_x
tag_shape_top = shape_top - shape_width_hight_array[1] * 0.5
tag_shape_width = shape_width_hight_array[0]
tag_shape_hight = shape_width_hight_array[1]
tag_shape_text = up_shape_width_if_array[1]
if action_type == 'CREATE':
self.shape = self.slide.shapes
ns_ddx_figure.extended.add_shape(self, tag_shape_type, tag_shape_left, tag_shape_top, tag_shape_width, tag_shape_hight, tag_shape_text)
self.all_l3if_tag_array.append([tag_shape_type, tag_shape_left, tag_shape_top, tag_shape_width, tag_shape_hight, tag_shape_text,up_shape_width_if_array[0],shape_text])
#reflect description ip address name distance-1
flag_match_shape_width_if_array = False
for tmp_shape_width_if_array in self.shape_width_if_array[3]:
if [shape_text ,up_shape_width_if_array[0]] == tmp_shape_width_if_array[0]:
tag_up_offset_x += tmp_shape_width_if_array[1]
flag_match_shape_width_if_array = True
tmp_add_width = tmp_shape_width_if_array[1]
if flag_match_shape_width_if_array == False:
tag_up_offset_x += tag_shape_width + self.between_l3if
tmp_add_width = tag_shape_width + self.between_l3if
'''mark ip address(up side)'''
offset_ipaddress = 0.0 #inches
remake_array = []
remake_array = eval(tmp_update_l3_table_array[6])
if remake_array != []:
#print('##mark ip address', len(remake_array),remake_array)
for tmp_remake_array in remake_array:
tag_shape_type = 'IP_ADDRESS_TAG'
tag_ip_width = ns_def.get_description_width_hight(self.shae_font_size,tmp_remake_array[2])[0]
self.mark_multi_ip_array.append([tag_shape_type, tag_shape_left + tag_shape_width * 0.6, tag_shape_top - tag_shape_hight - offset_ipaddress, tag_ip_width, tag_shape_hight, tmp_remake_array[2],tmp_remake_array,shape_text,len(remake_array),[shape_text,up_shape_width_if_array[0]],tag_shape_left ])
offset_ipaddress += tag_shape_hight
# reflect description ip address name distance-2
#if tag_ip_width + tag_shape_width * 0.5 > tmp_add_width:
# tag_up_offset_x += (tag_ip_width + tag_shape_width * 0.5) - tmp_add_width
#write downside l3 if
for down_shape_width_if_array in self.shape_width_if_array[2]:
if down_shape_width_if_array[0] == tmp_update_l3_table_array[2]:
#print('##DOWN ',shape_text,down_shape_width_if_array[1])
shape_width_hight_array = ns_def.get_description_width_hight(self.tag_font_large_size, down_shape_width_if_array[1]) # width, hight
tag_shape_type = 'TAG_NORMAL'
tag_shape_left = shape_left + tag_down_offset_x
tag_shape_top = shape_top + shape_hight - shape_width_hight_array[1] * 0.5
tag_shape_width = shape_width_hight_array[0]
tag_shape_hight = shape_width_hight_array[1]
tag_shape_text = down_shape_width_if_array[1]
if action_type == 'CREATE':
self.shape = self.slide.shapes
ns_ddx_figure.extended.add_shape(self, tag_shape_type, tag_shape_left, tag_shape_top, tag_shape_width, tag_shape_hight, tag_shape_text)
self.all_l3if_tag_array.append([tag_shape_type, tag_shape_left, tag_shape_top, tag_shape_width, tag_shape_hight, tag_shape_text,down_shape_width_if_array[0],shape_text])
# reflect description ip address name distance-1
flag_match_shape_width_if_array = False
for tmp_shape_width_if_array in self.shape_width_if_array[3]:
if [shape_text, down_shape_width_if_array[0]] == tmp_shape_width_if_array[0]:
tag_down_offset_x += tmp_shape_width_if_array[1]
flag_match_shape_width_if_array = True
tmp_add_width = tmp_shape_width_if_array[1]
if flag_match_shape_width_if_array == False:
tag_down_offset_x += tag_shape_width + self.between_l3if
tmp_add_width = tag_shape_width + self.between_l3if
'''mark ip address(down side)'''
offset_ipaddress = 0.0 #inches
remake_array = []
remake_array = eval(tmp_update_l3_table_array[6])
if remake_array != []:
#print('##mark ip address', len(remake_array),remake_array)
for tmp_remake_array in remake_array:
tag_shape_type = 'IP_ADDRESS_TAG'
tag_ip_width = ns_def.get_description_width_hight(self.shae_font_size,tmp_remake_array[2])[0]
self.mark_multi_ip_array.append([tag_shape_type, tag_shape_left + tag_shape_width * 0.6, tag_shape_top + tag_shape_hight + offset_ipaddress, tag_ip_width, tag_shape_hight, tmp_remake_array[2],tmp_remake_array,shape_text,len(remake_array),[shape_text,down_shape_width_if_array[0]],tag_shape_left])
offset_ipaddress += tag_shape_hight
# reflect description ip address name distance-2
#if tag_ip_width + tag_shape_width * 0.5 > tmp_add_width:
# tag_up_offset_x += (tag_ip_width + tag_shape_width * 0.5) - tmp_add_width
''' pre mark wp(left/right)'''
if (new_wp_exist_array[2] != [] or new_wp_exist_array[3] != []) and left_right_wp_row_num == self.index_2:
self.mark_wp_top = self.top_margin + top_offset
'''add top_offset for folder outline'''
#upside
if shape_text in self.wp_list_array:
top_offset += between_shape_row * 2
#downside
if len(target_position_shape_array) > self.index_2 + 1:
for down_target_position_shape_array in target_position_shape_array[self.index_2 + 1]:
if down_target_position_shape_array in self.wp_list_array and len(target_position_shape_array) == self.index_2 +2:
top_offset += between_shape_row * 2
break
### check end l3 segment point
if end_l3_seg_inche_x < shape_left + shape_width:
end_l3_seg_inche_x = shape_left + shape_width
### write broadcast domain line
top_device_name_array = tmp_target_position_shape_array
#get count l3_segment
return_get_l3_segment_num = get_l3_segment_num(self,top_device_name_array ,target_position_shape_array)
count_l3segment = return_get_l3_segment_num[0]
self.connected_l3if_key_array.append(return_get_l3_segment_num[1])
#print('## return_get_l3_segment_num ',return_get_l3_segment_num ,top_device_name_array )
tmp_l3segment_y_array = []
if count_l3segment != 0:
tmp_line_offset = l3_segment_up_down_offset
for tmp_count_l3segment in range(count_l3segment):
#add distance upside or downside of device shape
if tmp_count_l3segment == 0:
top_offset += between_shape_row + l3_segment_up_down_offset
else:
top_offset += between_shape_row
if tmp_count_l3segment +1 == count_l3segment:
top_offset += l3_segment_up_down_offset
tmp_l3segment_y_array.append(shape_top + tmp_line_offset + shape_hight + between_shape_row)
tmp_line_offset += between_shape_row
l3segment_line_array.append([[start_l3_seg_inche_x,end_l3_seg_inche_x],tmp_l3segment_y_array,return_get_l3_segment_num[1]])
'''change offset check_move_to_right '''
top_offset += shape_hight + between_shape_row
now_offset_x = end_l3_seg_inche_x - self.left_margin
if max_offset_x < now_offset_x :
max_offset_x = now_offset_x
if check_move_to_right(self,top_device_name_array,target_position_shape_array) == True:
left_offset = max_offset_x + self.left_margin # add 1.0 at ver 2.3.4
else:
left_offset = start_l3_seg_inche_x - self.left_margin
#print('## end_l3_seg_inche_x ', end_l3_seg_inche_x)
#print('--- l3segment_line_array ---')
#print(l3segment_line_array)
'''
write wp(left/right)
'''
shape_top = self.mark_wp_top
shape_width_hight_array = ns_def.get_description_width_hight(self.shae_font_large_size, str(new_wp_exist_array[2]))
shape_width = shape_width_hight_array[0]
shape_hight = shape_width_hight_array[1] * 5
''' write wp left'''
offset_shape_left = 0.0
if new_wp_exist_array[2] != []:
for tmp_i in new_wp_exist_array[2]:
shape_text = tmp_i
shape_type = 'WAY_POINT_NORMAL'
self.shape_width_if_array = get_shape_width_if_array(self, shape_text) # return_shape_width, tmp_up_array, tmp_down_array
tmp_shpae_width = self.shape_width_if_array[0]
if shape_width < tmp_shpae_width:
shape_width = tmp_shpae_width
if min_shape_width > shape_width:
shape_width = min_shape_width
#print('### WRITE LEFT WP ', shape_text, shape_width,new_wp_exist_array[2])
shape_left = self.left_margin - shape_width - self.between_shape_column * 3 + offset_shape_left
if action_type == 'CREATE':
self.shape = self.slide.shapes
ns_ddx_figure.extended.add_shape(self, shape_type, shape_left, shape_top, shape_width, shape_hight, shape_text)
if self.click_value_l3 == 'L3-4-1':
self.add_shape_array.append([shape_type, shape_left, shape_top, shape_width, shape_hight, shape_text]) # add ver 2.3.3
#get left side folder and outline point
self.area_position_array[0] = shape_left + shape_width + self.between_shape_column * 2 - offset_shape_left
self.outline_position_array[0] = shape_left - self.between_shape_column * 2
self.outline_position_array[2] += shape_width + self.between_shape_column * 3
'''write wp_left l3 if '''
# print('### self.shape_width_if_array[1], self.shape_width_if_array[2] ',self.shape_width_if_array[1], self.shape_width_if_array[2])
tag_up_offset_x = self.between_l3if
tag_down_offset_x = self.between_l3if
for tmp_update_l3_table_array in self.update_l3_table_array:
if tmp_update_l3_table_array[1] == shape_text:
for up_shape_width_if_array in self.shape_width_if_array[1]:
#write up side l3 if
if up_shape_width_if_array[0] == tmp_update_l3_table_array[2]:
# print('##UP ',shape_text,up_shape_width_if_array[1])
shape_width_hight_array = ns_def.get_description_width_hight(self.tag_font_large_size, up_shape_width_if_array[1]) # width, hight
tag_shape_type = 'TAG_NORMAL'
tag_shape_left = shape_left + tag_up_offset_x
tag_shape_top = shape_top - shape_width_hight_array[1] * 0.5
tag_shape_width = shape_width_hight_array[0]
tag_shape_hight = shape_width_hight_array[1]
tag_shape_text = up_shape_width_if_array[1]
if action_type == 'CREATE':
self.shape = self.slide.shapes
ns_ddx_figure.extended.add_shape(self, tag_shape_type, tag_shape_left, tag_shape_top, tag_shape_width, tag_shape_hight, tag_shape_text)
self.all_l3if_tag_array.append([tag_shape_type, tag_shape_left, tag_shape_top, tag_shape_width, tag_shape_hight, tag_shape_text,up_shape_width_if_array[0],shape_text])
# reflect description ip address name distance-1
flag_match_shape_width_if_array = False
for tmp_shape_width_if_array in self.shape_width_if_array[3]:
if [shape_text, up_shape_width_if_array[0]] == tmp_shape_width_if_array[0]:
tag_up_offset_x += tmp_shape_width_if_array[1]
flag_match_shape_width_if_array = True
tmp_add_width = tmp_shape_width_if_array[1]
if flag_match_shape_width_if_array == False:
tag_up_offset_x += tag_shape_width + self.between_l3if
tmp_add_width = tag_shape_width + self.between_l3if
'''wp_left write ip address(up side)'''
offset_ipaddress = 0.0 # inches
remake_array = []
remake_array = eval(tmp_update_l3_table_array[6])
if remake_array != []:
for tmp_remake_array in remake_array:
#print('##wp_left write ip address', tmp_remake_array)
tag_shape_type = 'IP_ADDRESS_TAG'
tag_ip_width = ns_def.get_description_width_hight(self.shae_font_size, tmp_remake_array[2])[0]
#self.shape = self.slide.shapes
self.mark_multi_ip_array.append([tag_shape_type, tag_shape_left + tag_shape_width * 0.6, tag_shape_top - tag_shape_hight - offset_ipaddress, tag_ip_width, tag_shape_hight, tmp_remake_array[2], tmp_remake_array, shape_text, len(remake_array), [shape_text, up_shape_width_if_array[0]], tag_shape_left])