/
advanced_tools.py
1517 lines (1371 loc) · 58.6 KB
/
advanced_tools.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
"""Legacy tools system (A unified list-style GUI with geometry/transforms)."""
import bpy
import mesh_mesh_align_plus.utils.exceptions as maplus_except
import mesh_mesh_align_plus.utils.geom as maplus_geom
import mesh_mesh_align_plus.utils.gui_tools as maplus_guitools
# Custom list, for displaying combined list of all primitives (Used at top
# of main panel and for item pointers in transformation primitives
class MAPLUS_UL_MAPlusList(bpy.types.UIList):
bl_idname = "maplus.advancedtoolslist"
def draw_item(self,
context,
layout,
data,
item,
icon,
active_data,
active_propname
):
addon_data = bpy.context.scene.maplus_data
prims = addon_data.prim_list
# Check which type of primitive, separate draw code for each
if item.kind == 'POINT':
layout.label(text=item.name, icon="LAYER_ACTIVE")
elif item.kind == 'LINE':
layout.label(text=item.name, icon="LIGHT_SUN")
elif item.kind == 'PLANE':
layout.label(text=item.name, icon="OUTLINER_OB_MESH")
elif item.kind == 'CALCULATION':
layout.label(text=item.name, icon="NODETREE")
elif item.kind == 'TRANSFORMATION':
layout.label(text=item.name, icon="GRAPH")
class MAPLUS_OT_AddListItemBase(bpy.types.Operator):
bl_idname = "maplus.addlistitembase"
bl_label = "Add a new item"
bl_options = {'REGISTER', 'UNDO'}
def add_new_named(self):
addon_data = bpy.context.scene.maplus_data
prims = addon_data.prim_list
# Add Name.001 or Name.002 (numbers at the end if the name is
# already in use)
name_list = {n.name for n in prims}
name_counter = 0
num_postfix_group = 1
base_name = 'Item'
cur_item_name = base_name
num_format = '.{0:0>3}'
keep_naming = True
while keep_naming:
name_counter += 1
cur_item_name = base_name + num_format.format(str(name_counter))
if num_postfix_group > 16:
raise maplus_except.UniqueNameError('Cannot add, unique name error.')
if name_counter == 999:
name_counter = 0
base_name += num_format.format('1')
num_postfix_group += 1
if not (base_name in name_list):
cur_item_name = base_name
keep_naming = False
continue
elif cur_item_name in name_list:
continue
else:
keep_naming = False
continue
new_item = addon_data.prim_list.add()
new_item.name = cur_item_name
new_item.kind = self.new_kind
addon_data.active_list_item = len(prims) - 1
return new_item
def execute(self, context):
try:
self.add_new_named()
except maplus_except.UniqueNameError:
self.report({'ERROR'}, 'Cannot add item, unique name error.')
return {'CANCELLED'}
return {'FINISHED'}
class MAPLUS_OT_RemoveListItem(bpy.types.Operator):
bl_idname = "maplus.removelistitem"
bl_label = "Remove an item"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
addon_data = bpy.context.scene.maplus_data
prims = addon_data.prim_list
if len(prims) == 0:
self.report({'WARNING'}, "Nothing to remove")
return {'CANCELLED'}
else:
prims.remove(addon_data.active_list_item)
if len(prims) == 0 or addon_data.active_list_item == 0:
# ^ The extra or prevents act=0 from going to the else below
addon_data.active_list_item = 0
elif addon_data.active_list_item > (len(prims) - 1):
addon_data.active_list_item = len(prims) - 1
else:
addon_data.active_list_item -= 1
return {'FINISHED'}
class MAPLUS_OT_AddNewPoint(MAPLUS_OT_AddListItemBase):
bl_idname = "maplus.addnewpoint"
bl_label = "Add a new item"
bl_options = {'REGISTER', 'UNDO'}
new_kind = "POINT"
class MAPLUS_OT_AddNewLine(MAPLUS_OT_AddListItemBase):
bl_idname = "maplus.addnewline"
bl_label = "Add a new item"
bl_options = {'REGISTER', 'UNDO'}
new_kind = "LINE"
class MAPLUS_OT_AddNewPlane(MAPLUS_OT_AddListItemBase):
bl_idname = "maplus.addnewplane"
bl_label = "Add a new item"
bl_options = {'REGISTER', 'UNDO'}
new_kind = "PLANE"
class MAPLUS_OT_AddNewCalculation(MAPLUS_OT_AddListItemBase):
bl_idname = "maplus.addnewcalculation"
bl_label = "Add a new item"
bl_options = {'REGISTER', 'UNDO'}
new_kind = "CALCULATION"
class MAPLUS_OT_AddNewTransformation(MAPLUS_OT_AddListItemBase):
bl_idname = "maplus.addnewtransformation"
bl_label = "Add a new item"
bl_options = {'REGISTER', 'UNDO'}
new_kind = "TRANSFORMATION"
class MAPLUS_OT_DuplicateItemBase(bpy.types.Operator):
bl_idname = "maplus.duplicateitembase"
bl_label = "Duplicate Item"
bl_description = "Duplicates this item"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
addon_data = bpy.context.scene.maplus_data
prims = addon_data.prim_list
active_item = prims[addon_data.active_list_item]
self.new_kind = active_item.kind
if active_item.kind not in {'POINT', 'LINE', 'PLANE'}:
self.report(
{'ERROR'},
('Wrong operand: "Duplicate Item" can only operate on'
' geometry items')
)
return {'CANCELLED'}
try:
new_item = MAPLUS_OT_AddListItemBase.add_new_named(self)
except maplus_except.UniqueNameError:
self.report({'ERROR'}, 'Cannot add item, unique name error.')
return {'CANCELLED'}
new_item.kind = self.new_kind
attrib_copy = {
"POINT": (
"point",
"pt_make_unit_vec",
"pt_flip_direction",
"pt_multiplier"
),
"LINE": (
"line_start",
"line_end",
"ln_make_unit_vec",
"ln_flip_direction",
"ln_multiplier"
),
"PLANE": (
"plane_pt_a",
"plane_pt_b",
"plane_pt_c"
),
}
if active_item.kind in attrib_copy:
for att in attrib_copy[active_item.kind]:
setattr(new_item, att, getattr(active_item, att))
return {'FINISHED'}
# Basic type selector functionality, derived classes provide
# the "kind" to switch to (target_type attrib)
class MAPLUS_OT_ChangeTypeBaseClass(bpy.types.Operator):
bl_idname = "maplus.changetypebaseclass"
bl_label = "Change type base class"
bl_description = "The base class for changing types"
bl_options = {'REGISTER', 'UNDO'}
target_type = None
def execute(self, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
active_item.kind = self.target_type
return {'FINISHED'}
class MAPLUS_OT_ChangeTypeToPointPrim(MAPLUS_OT_ChangeTypeBaseClass):
bl_idname = "maplus.changetypetopointprim"
bl_label = "Change this to a point primitive"
bl_description = "Makes this item a point primitive"
bl_options = {'REGISTER', 'UNDO'}
target_type = 'POINT'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.kind == cls.target_type:
return False
return True
class MAPLUS_OT_ChangeTypeToLinePrim(MAPLUS_OT_ChangeTypeBaseClass):
bl_idname = "maplus.changetypetolineprim"
bl_label = "Change this to a line primitive"
bl_description = "Makes this item a line primitive"
bl_options = {'REGISTER', 'UNDO'}
target_type = 'LINE'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.kind == cls.target_type:
return False
return True
class MAPLUS_OT_ChangeTypeToPlanePrim(MAPLUS_OT_ChangeTypeBaseClass):
bl_idname = "maplus.changetypetoplaneprim"
bl_label = "Change this to a plane primitive"
bl_description = "Makes this item a plane primitive"
bl_options = {'REGISTER', 'UNDO'}
target_type = 'PLANE'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.kind == cls.target_type:
return False
return True
class MAPLUS_OT_ChangeTypeToCalcPrim(MAPLUS_OT_ChangeTypeBaseClass):
bl_idname = "maplus.changetypetocalcprim"
bl_label = "Change this to a calculation primitive"
bl_description = "Makes this item a calculation primitive"
bl_options = {'REGISTER', 'UNDO'}
target_type = 'CALCULATION'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.kind == cls.target_type:
return False
return True
class MAPLUS_OT_ChangeTypeToTransfPrim(MAPLUS_OT_ChangeTypeBaseClass):
bl_idname = "maplus.changetypetotransfprim"
bl_label = "Change this to a transformation primitive"
bl_description = "Makes this item a transformation primitive"
bl_options = {'REGISTER', 'UNDO'}
target_type = 'TRANSFORMATION'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.kind == cls.target_type:
return False
return True
class MAPLUS_OT_ChangeCalcBaseClass(bpy.types.Operator):
bl_idname = "maplus.changecalcbaseclass"
bl_label = "Change calculation base class"
bl_description = "The base class for changing calc types"
bl_options = {'REGISTER', 'UNDO'}
target_calc = None
def execute(self, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
active_item.calc_type = self.target_calc
return {'FINISHED'}
class MAPLUS_OT_ChangeCalcToSingle(MAPLUS_OT_ChangeCalcBaseClass):
bl_idname = "maplus.changecalctosingle"
bl_label = "Change to single item calculation"
bl_description = "Change the calculation type to single item"
bl_options = {'REGISTER', 'UNDO'}
target_calc = 'SINGLEITEM'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.calc_type == cls.target_calc:
return False
return True
class MAPLUS_OT_ChangeCalcToMulti(MAPLUS_OT_ChangeCalcBaseClass):
bl_idname = "maplus.changecalctomulti"
bl_label = "Change to multi-item calculation"
bl_description = "Change the calculation type to multi item"
bl_options = {'REGISTER', 'UNDO'}
target_calc = 'MULTIITEM'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.calc_type == cls.target_calc:
return False
return True
# Basic transformation type selector functionality (a primitive sub-type),
# derived classes provide the transf. to switch to (target_transf attrib)
class MAPLUS_OT_ChangeTransfBaseClass(bpy.types.Operator):
bl_idname = "maplus.changetransfbaseclass"
bl_label = "Change transformation base class"
bl_description = "The base class for changing tranf types"
bl_options = {'REGISTER', 'UNDO'}
target_transf = None
def execute(self, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
active_item.transf_type = self.target_transf
return {'FINISHED'}
class MAPLUS_OT_ChangeTransfToAlignPoints(MAPLUS_OT_ChangeTransfBaseClass):
bl_idname = "maplus.changetransftoalignpoints"
bl_label = "Change transformation to align points"
bl_description = "Change the transformation type to align points"
bl_options = {'REGISTER', 'UNDO'}
target_transf = 'ALIGNPOINTS'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.transf_type == cls.target_transf:
return False
return True
class MAPLUS_OT_ChangeTransfToDirectionalSlide(MAPLUS_OT_ChangeTransfBaseClass):
bl_idname = "maplus.changetransftodirectionalslide"
bl_label = "Change transformation to directional slide"
bl_description = "Change the transformation type to directional slide"
bl_options = {'REGISTER', 'UNDO'}
target_transf = 'DIRECTIONALSLIDE'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.transf_type == cls.target_transf:
return False
return True
class MAPLUS_OT_ChangeTransfToScaleMatchEdge(MAPLUS_OT_ChangeTransfBaseClass):
bl_idname = "maplus.changetransftoscalematchedge"
bl_label = "Change transformation to scale match edge"
bl_description = "Change the transformation type to scale match edge"
bl_options = {'REGISTER', 'UNDO'}
target_transf = 'SCALEMATCHEDGE'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.transf_type == cls.target_transf:
return False
return True
class MAPLUS_OT_ChangeTransfToAxisRotate(MAPLUS_OT_ChangeTransfBaseClass):
bl_idname = "maplus.changetransftoaxisrotate"
bl_label = "Change transformation to axis rotate"
bl_description = "Change the transformation type to axis rotate"
bl_options = {'REGISTER', 'UNDO'}
target_transf = 'AXISROTATE'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.transf_type == cls.target_transf:
return False
return True
class MAPLUS_OT_ChangeTransfToAlignLines(MAPLUS_OT_ChangeTransfBaseClass):
bl_idname = "maplus.changetransftoalignlines"
bl_label = "Change transformation to align lines"
bl_description = "Change the transformation type to align lines"
bl_options = {'REGISTER', 'UNDO'}
target_transf = 'ALIGNLINES'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.transf_type == cls.target_transf:
return False
return True
class MAPLUS_OT_ChangeTransfToAlignPlanes(MAPLUS_OT_ChangeTransfBaseClass):
bl_idname = "maplus.changetransftoalignplanes"
bl_label = "Change transformation to align planes"
bl_description = "Change the transformation type to align planes"
bl_options = {'REGISTER', 'UNDO'}
target_transf = 'ALIGNPLANES'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
prims = bpy.context.scene.maplus_data.prim_list
active_item = prims[addon_data.active_list_item]
if active_item.transf_type == cls.target_transf:
return False
return True
class MAPLUS_OT_SpecialsAddFromActiveBase(bpy.types.Operator):
bl_idname = "maplus.specialsaddfromactivebase"
bl_label = "Specials Menu Item Base Class, Add Geometry Item From Active"
bl_options = {'REGISTER', 'UNDO'}
new_kind = None
vert_attribs_to_set = None
multiply_by_world_matrix = None
message_geom_type = None
def execute(self, context):
addon_data = bpy.context.scene.maplus_data
prims = addon_data.prim_list
try:
vert_data = maplus_geom.return_selected_verts(
maplus_geom.get_active_object(),
len(self.vert_attribs_to_set),
maplus_geom.get_active_object().matrix_world
)
except maplus_except.InsufficientSelectionError:
self.report({'ERROR'}, 'Not enough vertices selected.')
return {'CANCELLED'}
except maplus_except.NonMeshGrabError:
self.report(
{'ERROR'},
'Cannot grab coords: non-mesh or no active object.'
)
return {'CANCELLED'}
target_data = dict(zip(self.vert_attribs_to_set, vert_data))
try:
new_item = AddListItemBase.add_new_named(self)
except maplus_except.UniqueNameError:
self.report({'ERROR'}, 'Cannot add item, unique name error.')
return {'CANCELLED'}
new_item.kind = self.new_kind
for key, val in target_data.items():
setattr(new_item, key, val)
self.report(
{'INFO'},
'{0} \'{1}\' was added'.format(
self.message_geom_type,
new_item.name
)
)
return {'FINISHED'}
class MAPLUS_OT_SpecialsAddPointFromActiveGlobal(MAPLUS_OT_SpecialsAddFromActiveBase):
bl_idname = "maplus.specialsaddpointfromactiveglobal"
bl_label = "Point From Active Global"
bl_options = {'REGISTER', 'UNDO'}
new_kind = 'POINT'
message_geom_type = 'Point'
vert_attribs_to_set = ('point',)
multiply_by_world_matrix = True
class MAPLUS_OT_SpecialsAddLineFromActiveGlobal(MAPLUS_OT_SpecialsAddFromActiveBase):
bl_idname = "maplus.specialsaddlinefromactiveglobal"
bl_label = "Line From Active Global"
bl_options = {'REGISTER', 'UNDO'}
new_kind = 'LINE'
message_geom_type = 'Line'
vert_attribs_to_set = ('line_start', 'line_end')
multiply_by_world_matrix = True
class MAPLUS_OT_SpecialsAddPlaneFromActiveGlobal(MAPLUS_OT_SpecialsAddFromActiveBase):
bl_idname = "maplus.specialsaddplanefromactiveglobal"
bl_label = "Plane From Active Global"
bl_options = {'REGISTER', 'UNDO'}
new_kind = 'PLANE'
message_geom_type = 'Plane'
vert_attribs_to_set = ('plane_pt_a', 'plane_pt_b', 'plane_pt_c')
multiply_by_world_matrix = True
# Advanced Tools panel
class MAPLUS_PT_MAPlusGui(bpy.types.Panel):
bl_idname = "MAPLUS_PT_MAPlusGui"
bl_label = "Mesh Align Plus Advanced Tools"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
def draw(self, context):
layout = self.layout
maplus_data_ptr = bpy.types.AnyType(bpy.context.scene.maplus_data)
addon_data = bpy.context.scene.maplus_data
prims = addon_data.prim_list
if len(prims) > 0:
active_item = prims[addon_data.active_list_item]
# We start with a row that holds the prim list and buttons
# for adding/subtracting prims (the data management section
# of the interface)
maplus_data_mgmt_row = layout.row()
maplus_items_list = maplus_data_mgmt_row.column()
maplus_items_list.template_list(
"MAPLUS_UL_MAPlusList",
"",
maplus_data_ptr,
"prim_list",
maplus_data_ptr,
"active_list_item",
type='DEFAULT'
)
add_remove_data_col = maplus_data_mgmt_row.column()
add_new_items = add_remove_data_col.column(align=True)
add_new_items.operator(
"maplus.addnewpoint",
icon='LAYER_ACTIVE',
text=""
)
add_new_items.operator(
"maplus.addnewline",
icon='LIGHT_SUN',
text=""
)
add_new_items.operator(
"maplus.addnewplane",
icon='OUTLINER_OB_MESH',
text=""
)
add_new_items.operator(
"maplus.addnewcalculation",
icon='NODETREE',
text=""
)
add_new_items.operator(
"maplus.addnewtransformation",
icon='GRAPH',
text=""
)
add_remove_data_col.operator(
"maplus.removelistitem",
icon='X',
text=""
)
# Items below data management section, this consists of either the
# empty list message or the Primitive type selector (for when the
# list is not empty, it allow users to choose the type of the
# current primitive)
if len(prims) == 0:
layout.label(text="Add items above")
else:
basic_item_attribs_col = layout.column()
basic_item_attribs_col.label(text="Item Name and Type:")
item_name_and_types = basic_item_attribs_col.split(
align=True,
factor=.8
)
item_name_and_types.prop(
bpy.types.AnyType(active_item),
'name',
text=""
)
item_name_and_types.prop(
bpy.types.AnyType(active_item),
'kind',
text=""
)
basic_item_attribs_col.separator()
# Item-specific UI elements (primitive-specific data like coords
# for plane points, transformation type etc.)
item_info_col = layout.column()
if active_item.kind == 'POINT':
modifier_header = item_info_col.row()
modifier_header.label(text="Point Modifiers:")
apply_mods = modifier_header.row()
apply_mods.alignment = 'RIGHT'
apply_mods.operator(
"maplus.applygeommodifiers",
text="Apply Modifiers"
)
item_mods_box = item_info_col.box()
mods_row_1 = item_mods_box.row()
mods_row_1.prop(
bpy.types.AnyType(active_item),
'pt_make_unit_vec',
text="Set Length Equal to One"
)
mods_row_1.prop(
bpy.types.AnyType(active_item),
'pt_flip_direction',
text="Flip Direction"
)
mods_row_2 = item_mods_box.row()
mods_row_2.prop(
bpy.types.AnyType(active_item),
'pt_multiplier',
text="Multiplier"
)
item_info_col.separator()
item_info_col.label(text="Point Coordinates:")
pt_grab_all = item_info_col.row(align=True)
pt_grab_all.operator(
"maplus.grabpointfromcursor",
icon='PIVOT_CURSOR',
text="Grab Cursor"
)
pt_grab_all.operator(
"maplus.grabpointfromactivelocal",
icon='VERTEXSEL',
text="Grab All Local"
)
pt_grab_all.operator(
"maplus.grabpointfromactiveglobal",
icon='WORLD',
text="Grab All Global"
)
item_info_col.separator()
special_grabs = item_info_col.row(align=True)
special_grabs.operator(
"maplus.copyfromadvtoolsactive",
icon='COPYDOWN',
text="Copy (To Clipboard)"
)
special_grabs.operator(
"maplus.pasteintoadvtoolsactive",
icon='PASTEDOWN',
text="Paste (From Clipboard)"
)
item_info_col.separator()
maplus_guitools.layout_coordvec(
parent_layout=item_info_col,
coordvec_label="Point Coordinates:",
op_id_cursor_grab=(
"maplus.grabpointfromcursor"
),
op_id_avg_grab=(
"maplus.pointgrabavg"
),
op_id_local_grab=(
"maplus.grabpointfromactivelocal"
),
op_id_global_grab=(
"maplus.grabpointfromactiveglobal"
),
coord_container=active_item,
coord_attribute="point",
op_id_cursor_send=(
"maplus.sendpointtocursor"
)
)
item_info_col.separator()
item_info_col.operator(
"maplus.duplicateitembase",
text="Duplicate Item"
)
elif active_item.kind == 'LINE':
modifier_header = item_info_col.row()
modifier_header.label(text="Line Modifiers:")
apply_mods = modifier_header.row()
apply_mods.alignment = 'RIGHT'
apply_mods.operator(
"maplus.applygeommodifiers",
text="Apply Modifiers"
)
item_mods_box = item_info_col.box()
mods_row_1 = item_mods_box.row()
mods_row_1.prop(
bpy.types.AnyType(active_item),
'ln_make_unit_vec',
text="Set Length Equal to One"
)
mods_row_1.prop(
bpy.types.AnyType(active_item),
'ln_flip_direction',
text="Flip Direction"
)
mods_row_2 = item_mods_box.row()
mods_row_2.prop(
bpy.types.AnyType(active_item),
'ln_multiplier',
text="Multiplier"
)
item_info_col.separator()
item_info_col.label(text="Line Coordinates:")
ln_grab_all = item_info_col.row(align=True)
ln_grab_all.operator(
"maplus.graballvertslinelocal",
icon='VERTEXSEL',
text="Grab All Local"
)
ln_grab_all.operator(
"maplus.graballvertslineglobal",
icon='WORLD',
text="Grab All Global"
)
item_info_col.separator()
special_grabs = item_info_col.row(align=True)
special_grabs.operator(
"maplus.grabnormal",
icon='LIGHT_HEMI',
text="Grab Normal"
)
item_info_col.separator()
special_grabs_extra = item_info_col.row(align=True)
special_grabs_extra.operator(
"maplus.copyfromadvtoolsactive",
icon='COPYDOWN',
text="Copy (To Clipboard)"
)
special_grabs_extra.operator(
"maplus.pasteintoadvtoolsactive",
icon='PASTEDOWN',
text="Paste (From Clipboard)"
)
item_info_col.separator()
maplus_guitools.layout_coordvec(
parent_layout=item_info_col,
coordvec_label="Start:",
op_id_cursor_grab=(
"maplus.grablinestartfromcursor"
),
op_id_avg_grab=(
"maplus.linestartgrabavg"
),
op_id_local_grab=(
"maplus.grablinestartfromactivelocal"
),
op_id_global_grab=(
"maplus.grablinestartfromactiveglobal"
),
coord_container=active_item,
coord_attribute="line_start",
op_id_cursor_send=(
"maplus.sendlinestarttocursor"
),
op_id_text_tuple_swap_first=(
"maplus.swaplinepoints",
"End"
)
)
item_info_col.separator()
maplus_guitools.layout_coordvec(
parent_layout=item_info_col,
coordvec_label="End:",
op_id_cursor_grab=(
"maplus.grablineendfromcursor"
),
op_id_avg_grab=(
"maplus.lineendgrabavg"
),
op_id_local_grab=(
"maplus.grablineendfromactivelocal"
),
op_id_global_grab=(
"maplus.grablineendfromactiveglobal"
),
coord_container=active_item,
coord_attribute="line_end",
op_id_cursor_send=(
"maplus.sendlineendtocursor"
),
op_id_text_tuple_swap_first=(
"maplus.swaplinepoints",
"Start"
)
)
item_info_col.separator()
item_info_col.operator(
"maplus.duplicateitembase",
text="Duplicate Item"
)
elif active_item.kind == 'PLANE':
item_info_col.label(text="Plane Coordinates:")
plane_grab_all = item_info_col.row(align=True)
plane_grab_all.operator(
"maplus.graballvertsplanelocal",
icon='VERTEXSEL',
text="Grab All Local"
)
plane_grab_all.operator(
"maplus.graballvertsplaneglobal",
icon='WORLD',
text="Grab All Global"
)
item_info_col.separator()
special_grabs = item_info_col.row(align=True)
special_grabs.operator(
"maplus.copyfromadvtoolsactive",
icon='COPYDOWN',
text="Copy (To Clipboard)"
)
special_grabs.operator(
"maplus.pasteintoadvtoolsactive",
icon='PASTEDOWN',
text="Paste (From Clipboard)"
)
item_info_col.separator()
maplus_guitools.layout_coordvec(
parent_layout=item_info_col,
coordvec_label="Pt. A:",
op_id_cursor_grab=(
"maplus.grabplaneafromcursor"
),
op_id_avg_grab=(
"maplus.planeagrabavg"
),
op_id_local_grab=(
"maplus.grabplaneafromactivelocal"
),
op_id_global_grab=(
"maplus.grabplaneafromactiveglobal"
),
coord_container=active_item,
coord_attribute="plane_pt_a",
op_id_cursor_send=(
"maplus.sendplaneatocursor"
),
op_id_text_tuple_swap_first=(
"maplus.swapplaneaplaneb",
"B"
),
op_id_text_tuple_swap_second=(
"maplus.swapplaneaplanec",
"C"
)
)
item_info_col.separator()
maplus_guitools.layout_coordvec(
parent_layout=item_info_col,
coordvec_label="Pt. B:",
op_id_cursor_grab=(
"maplus.grabplanebfromcursor"
),
op_id_avg_grab=(
"maplus.planebgrabavg"
),
op_id_local_grab=(
"maplus.grabplanebfromactivelocal"
),
op_id_global_grab=(
"maplus.grabplanebfromactiveglobal"
),
coord_container=active_item,
coord_attribute="plane_pt_b",
op_id_cursor_send=(
"maplus.sendplanebtocursor"
),
op_id_text_tuple_swap_first=(
"maplus.swapplaneaplaneb",
"A"
),
op_id_text_tuple_swap_second=(
"maplus.swapplanebplanec",
"C"
)
)
item_info_col.separator()
maplus_guitools.layout_coordvec(
parent_layout=item_info_col,
coordvec_label="Pt. C:",
op_id_cursor_grab=(
"maplus.grabplanecfromcursor"
),
op_id_avg_grab=(
"maplus.planecgrabavg"
),
op_id_local_grab=(
"maplus.grabplanecfromactivelocal"
),
op_id_global_grab=(
"maplus.grabplanecfromactiveglobal"
),
coord_container=active_item,
coord_attribute="plane_pt_c",
op_id_cursor_send=(
"maplus.sendplanectocursor"
),
op_id_text_tuple_swap_first=(
"maplus.swapplaneaplanec",
"A"
),
op_id_text_tuple_swap_second=(
"maplus.swapplanebplanec",
"B"
)
)
item_info_col.separator()