Welcome to mirror list, hosted at ThFree Co, Russian Federation.

object_gui.py « render_povray - git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2033a0d46794782cd07e67a49035de2755de06c8 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
# SPDX-License-Identifier: GPL-2.0-or-later

# <pep8 compliant>
"""User interface for the POV tools"""

import bpy

import os

from bpy.utils import (
    register_class,
    unregister_class,
    register_tool,
    unregister_tool
)
from bpy.types import (
    # Operator,
    Menu,
    Panel,
    WorkSpaceTool,
)

# Example of wrapping every class 'as is'
from bl_ui import properties_data_modifier

for member in dir(properties_data_modifier):
    subclass = getattr(properties_data_modifier, member)
    if hasattr(subclass, "COMPAT_ENGINES"):
        subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
del properties_data_modifier


from bl_ui import properties_data_mesh

# These panels are kept
properties_data_mesh.DATA_PT_custom_props_mesh.COMPAT_ENGINES.add('POVRAY_RENDER')
properties_data_mesh.DATA_PT_context_mesh.COMPAT_ENGINES.add('POVRAY_RENDER')

# make some native panels contextual to some object variable
# by recreating custom panels inheriting their properties


from .scripting_gui import VIEW_MT_POV_import


class ModifierButtonsPanel:
    """Use this class to define buttons from the modifier tab of
    properties window."""

    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "modifier"
    COMPAT_ENGINES = {'POVRAY_RENDER'}

    @classmethod
    def poll(cls, context):
        mods = context.object.modifiers
        rd = context.scene.render
        return mods and (rd.engine in cls.COMPAT_ENGINES)


class ObjectButtonsPanel:
    """Use this class to define buttons from the object tab of
    properties window."""

    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"
    COMPAT_ENGINES = {'POVRAY_RENDER'}

    @classmethod
    def poll(cls, context):
        obj = context.object
        rd = context.scene.render
        return obj and (rd.engine in cls.COMPAT_ENGINES)


class PovDataButtonsPanel(properties_data_mesh.MeshButtonsPanel):
    """Use this class to define buttons from the edit data tab of
    properties window."""

    COMPAT_ENGINES = {'POVRAY_RENDER'}
    POV_OBJECT_TYPES = {
        'PLANE',
        'BOX',
        'SPHERE',
        'CYLINDER',
        'CONE',
        'TORUS',
        'BLOB',
        'ISOSURFACE_NODE',
        'ISOSURFACE_VIEW',
        'SUPERELLIPSOID',
        'SUPERTORUS',
        'HEIGHT_FIELD',
        'PARAMETRIC',
        'POLYCIRCLE',
    }

    @classmethod
    def poll(cls, context):
        # engine = context.scene.render.engine # XXX Unused
        obj = context.object
        # We use our parent class poll func too, avoids to re-define too much things...
        return (
            super(PovDataButtonsPanel, cls).poll(context)
            and obj
            and obj.pov.object_as not in cls.POV_OBJECT_TYPES
        )


# We cannot inherit from RNA classes (like e.g. properties_data_mesh.DATA_PT_vertex_groups).
# Complex py/bpy/rna interactions (with metaclass and all) simply do not allow it to work.
# So we simply have to explicitly copy here the interesting bits. ;)
class DATA_PT_POV_normals(PovDataButtonsPanel, Panel):
    bl_label = properties_data_mesh.DATA_PT_normals.bl_label

    draw = properties_data_mesh.DATA_PT_normals.draw


class DATA_PT_POV_texture_space(PovDataButtonsPanel, Panel):
    bl_label = properties_data_mesh.DATA_PT_texture_space.bl_label
    bl_options = properties_data_mesh.DATA_PT_texture_space.bl_options

    draw = properties_data_mesh.DATA_PT_texture_space.draw


class DATA_PT_POV_vertex_groups(PovDataButtonsPanel, Panel):
    bl_label = properties_data_mesh.DATA_PT_vertex_groups.bl_label

    draw = properties_data_mesh.DATA_PT_vertex_groups.draw


class DATA_PT_POV_shape_keys(PovDataButtonsPanel, Panel):
    bl_label = properties_data_mesh.DATA_PT_shape_keys.bl_label

    draw = properties_data_mesh.DATA_PT_shape_keys.draw


class DATA_PT_POV_uv_texture(PovDataButtonsPanel, Panel):
    bl_label = properties_data_mesh.DATA_PT_uv_texture.bl_label

    draw = properties_data_mesh.DATA_PT_uv_texture.draw


class DATA_PT_POV_vertex_colors(PovDataButtonsPanel, Panel):
    bl_label = properties_data_mesh.DATA_PT_vertex_colors.bl_label

    draw = properties_data_mesh.DATA_PT_vertex_colors.draw


class DATA_PT_POV_customdata(PovDataButtonsPanel, Panel):
    bl_label = properties_data_mesh.DATA_PT_customdata.bl_label
    bl_options = properties_data_mesh.DATA_PT_customdata.bl_options
    draw = properties_data_mesh.DATA_PT_customdata.draw


del properties_data_mesh


class MODIFIERS_PT_POV_modifiers(ModifierButtonsPanel, Panel):
    """Use this class to define pov modifier buttons. (For booleans)"""

    bl_label = "POV-Ray"

    # def draw_header(self, context):
    # scene = context.scene
    # self.layout.prop(scene.pov, "boolean_mod", text="")

    def draw(self, context):
        # scene = context.scene
        layout = self.layout
        ob = context.object
        col = layout.column()
        # Find Boolean Modifiers for displaying CSG option
        once_csg = 0
        for mod in ob.modifiers:
            if once_csg == 0 and mod:
                if mod.type == 'BOOLEAN':
                    col.prop(ob.pov, "boolean_mod")
                    once_csg = 1

                if ob.pov.boolean_mod == "POV":
                    # split = layout.split() # better ?
                    col = layout.column()
                    # Inside Vector for CSG
                    col.prop(ob.pov, "inside_vector")


class OBJECT_PT_POV_obj_parameters(ObjectButtonsPanel, Panel):
    """Use this class to define pov specific object level options buttons."""

    bl_label = "POV"

    @classmethod
    def poll(cls, context):

        engine = context.scene.render.engine
        return engine in cls.COMPAT_ENGINES

    def draw(self, context):
        layout = self.layout

        obj = context.object

        split = layout.split()

        col = split.column(align=True)

        col.label(text="Radiosity:")
        col.prop(obj.pov, "importance_value", text="Importance")
        col.label(text="Photons:")
        col.prop(obj.pov, "collect_photons", text="Receive Photon Caustics")
        if obj.pov.collect_photons:
            col.prop(obj.pov, "spacing_multiplier", text="Photons Spacing Multiplier")

        split = layout.split()

        col = split.column()
        col.prop(obj.pov, "hollow")
        col.prop(obj.pov, "double_illuminate")

        if obj.type == 'META' or obj.pov.curveshape == 'lathe':
            # if obj.pov.curveshape == 'sor'
            col.prop(obj.pov, "sturm")
        col.prop(obj.pov, "no_shadow")
        col.prop(obj.pov, "no_image")
        col.prop(obj.pov, "no_reflection")
        col.prop(obj.pov, "no_radiosity")
        col.prop(obj.pov, "inverse")
        col.prop(obj.pov, "hierarchy")
        # col.prop(obj.pov,"boundorclip",text="Bound / Clip")
        # if obj.pov.boundorclip != "none":
        # col.prop_search(obj.pov,"boundorclipob",context.blend_data,"objects",text="Object")
        # text = "Clipped by"
        # if obj.pov.boundorclip == "clipped_by":
        # text = "Bounded by"
        # col.prop(obj.pov,"addboundorclip",text=text)


class OBJECT_PT_POV_obj_sphere(PovDataButtonsPanel, Panel):
    """Use this class to define pov sphere primitive parameters buttons."""

    bl_label = "POV Sphere"
    COMPAT_ENGINES = {'POVRAY_RENDER'}
    # bl_options = {'HIDE_HEADER'}

    @classmethod
    def poll(cls, context):
        engine = context.scene.render.engine
        obj = context.object
        return obj and obj.pov.object_as == 'SPHERE' and (engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout

        obj = context.object

        col = layout.column()

        if obj.pov.object_as == 'SPHERE':
            if not obj.pov.unlock_parameters:
                col.prop(
                    obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED'
                )
                col.label(text="Sphere radius: " + str(obj.pov.sphere_radius))

            else:
                col.prop(
                    obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED'
                )
                col.label(text="3D view proxy may get out of synch")
                col.active = obj.pov.unlock_parameters

                layout.operator("pov.sphere_update", text="Update", icon="SHADING_RENDERED")

                # col.label(text="Parameters:")
                col.prop(obj.pov, "sphere_radius", text="Radius of Sphere")


class OBJECT_PT_POV_obj_cylinder(PovDataButtonsPanel, Panel):
    """Use this class to define pov cylinder primitive parameters buttons."""

    bl_label = "POV Cylinder"
    COMPAT_ENGINES = {'POVRAY_RENDER'}
    # bl_options = {'HIDE_HEADER'}

    @classmethod
    def poll(cls, context):
        engine = context.scene.render.engine
        obj = context.object
        return obj and obj.pov.object_as == 'CYLINDER' and (engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout

        obj = context.object

        col = layout.column()

        if obj.pov.object_as == 'CYLINDER':
            if not obj.pov.unlock_parameters:
                col.prop(
                    obj.pov, "unlock_parameters",
                    text="Exported parameters below",
                    icon='LOCKED'
                )
                col.label(text="Cylinder radius: " + str(obj.pov.cylinder_radius))
                col.label(text="Cylinder cap location: " + str(obj.pov.cylinder_location_cap))

            else:
                col.prop(
                    obj.pov, "unlock_parameters",
                    text="Edit exported parameters",
                    icon='UNLOCKED'
                )
                col.label(text="3D view proxy may get out of synch")
                col.active = obj.pov.unlock_parameters

                layout.operator("pov.cylinder_update", text="Update", icon="MESH_CYLINDER")

                # col.label(text="Parameters:")
                col.prop(obj.pov, "cylinder_radius")
                col.prop(obj.pov, "cylinder_location_cap")


class OBJECT_PT_POV_obj_cone(PovDataButtonsPanel, Panel):
    """Use this class to define pov cone primitive parameters buttons."""

    bl_label = "POV Cone"
    COMPAT_ENGINES = {'POVRAY_RENDER'}
    # bl_options = {'HIDE_HEADER'}

    @classmethod
    def poll(cls, context):
        engine = context.scene.render.engine
        obj = context.object
        return obj and obj.pov.object_as == 'CONE' and (engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout

        obj = context.object

        col = layout.column()

        if obj.pov.object_as == 'CONE':
            if not obj.pov.unlock_parameters:
                col.prop(
                    obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED'
                )
                col.label(text="Cone base radius: " + str(obj.pov.cone_base_radius))
                col.label(text="Cone cap radius: " + str(obj.pov.cone_cap_radius))
                col.label(text="Cone proxy segments: " + str(obj.pov.cone_segments))
                col.label(text="Cone height: " + str(obj.pov.cone_height))
            else:
                col.prop(
                    obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED'
                )
                col.label(text="3D view proxy may get out of synch")
                col.active = obj.pov.unlock_parameters

                layout.operator("pov.cone_update", text="Update", icon="MESH_CONE")

                # col.label(text="Parameters:")
                col.prop(obj.pov, "cone_base_radius", text="Radius of Cone Base")
                col.prop(obj.pov, "cone_cap_radius", text="Radius of Cone Cap")
                col.prop(obj.pov, "cone_segments", text="Segmentation of Cone proxy")
                col.prop(obj.pov, "cone_height", text="Height of the cone")


class OBJECT_PT_POV_obj_superellipsoid(PovDataButtonsPanel, Panel):
    """Use this class to define pov superellipsoid primitive parameters buttons."""

    bl_label = "POV Superquadric ellipsoid"
    COMPAT_ENGINES = {'POVRAY_RENDER'}
    # bl_options = {'HIDE_HEADER'}

    @classmethod
    def poll(cls, context):
        engine = context.scene.render.engine
        obj = context.object
        return obj and obj.pov.object_as == 'SUPERELLIPSOID' and (engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout

        obj = context.object

        col = layout.column()

        if obj.pov.object_as == 'SUPERELLIPSOID':
            if not obj.pov.unlock_parameters:
                col.prop(
                    obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED'
                )
                col.label(text="Radial segmentation: " + str(obj.pov.se_u))
                col.label(text="Lateral segmentation: " + str(obj.pov.se_v))
                col.label(text="Ring shape: " + str(obj.pov.se_n1))
                col.label(text="Cross-section shape: " + str(obj.pov.se_n2))
                col.label(text="Fill up and down: " + str(obj.pov.se_edit))
            else:
                col.prop(
                    obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED'
                )
                col.label(text="3D view proxy may get out of synch")
                col.active = obj.pov.unlock_parameters

                layout.operator("pov.superellipsoid_update", text="Update", icon="MOD_SUBSURF")

                # col.label(text="Parameters:")
                col.prop(obj.pov, "se_u")
                col.prop(obj.pov, "se_v")
                col.prop(obj.pov, "se_n1")
                col.prop(obj.pov, "se_n2")
                col.prop(obj.pov, "se_edit")


class OBJECT_PT_POV_obj_torus(PovDataButtonsPanel, Panel):
    """Use this class to define pov torus primitive parameters buttons."""

    bl_label = "POV Torus"
    COMPAT_ENGINES = {'POVRAY_RENDER'}
    # bl_options = {'HIDE_HEADER'}

    @classmethod
    def poll(cls, context):
        engine = context.scene.render.engine
        obj = context.object
        return obj and obj.pov.object_as == 'TORUS' and (engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout

        obj = context.object

        col = layout.column()

        if obj.pov.object_as == 'TORUS':
            if not obj.pov.unlock_parameters:
                col.prop(
                    obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED'
                )
                col.label(text="Torus major radius: " + str(obj.pov.torus_major_radius))
                col.label(text="Torus minor radius: " + str(obj.pov.torus_minor_radius))
                col.label(text="Torus major segments: " + str(obj.pov.torus_major_segments))
                col.label(text="Torus minor segments: " + str(obj.pov.torus_minor_segments))
            else:
                col.prop(
                    obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED'
                )
                col.label(text="3D view proxy may get out of synch")
                col.active = obj.pov.unlock_parameters

                layout.operator("pov.torus_update", text="Update", icon="MESH_TORUS")

                # col.label(text="Parameters:")
                col.prop(obj.pov, "torus_major_radius")
                col.prop(obj.pov, "torus_minor_radius")
                col.prop(obj.pov, "torus_major_segments")
                col.prop(obj.pov, "torus_minor_segments")


class OBJECT_PT_POV_obj_supertorus(PovDataButtonsPanel, Panel):
    """Use this class to define pov supertorus primitive parameters buttons."""

    bl_label = "POV SuperTorus"
    COMPAT_ENGINES = {'POVRAY_RENDER'}
    # bl_options = {'HIDE_HEADER'}

    @classmethod
    def poll(cls, context):
        engine = context.scene.render.engine
        obj = context.object
        return obj and obj.pov.object_as == 'SUPERTORUS' and (engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout

        obj = context.object

        col = layout.column()

        if obj.pov.object_as == 'SUPERTORUS':
            if not obj.pov.unlock_parameters:
                col.prop(
                    obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED'
                )
                col.label(text="SuperTorus major radius: " + str(obj.pov.st_major_radius))
                col.label(text="SuperTorus minor radius: " + str(obj.pov.st_minor_radius))
                col.label(text="SuperTorus major segments: " + str(obj.pov.st_u))
                col.label(text="SuperTorus minor segments: " + str(obj.pov.st_v))

                col.label(text="SuperTorus Ring Manipulator: " + str(obj.pov.st_ring))
                col.label(text="SuperTorus Cross Manipulator: " + str(obj.pov.st_cross))
                col.label(text="SuperTorus Internal And External radii: " + str(obj.pov.st_ie))

                col.label(text="SuperTorus accuracy: " + str(obj.pov.st_accuracy))
                col.label(text="SuperTorus max gradient: " + str(obj.pov.st_max_gradient))

            else:
                col.prop(
                    obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED'
                )
                col.label(text="3D view proxy may get out of synch")
                col.active = obj.pov.unlock_parameters

                layout.operator("pov.supertorus_update", text="Update", icon="MESH_TORUS")

                # col.label(text="Parameters:")
                col.prop(obj.pov, "st_major_radius")
                col.prop(obj.pov, "st_minor_radius")
                col.prop(obj.pov, "st_u")
                col.prop(obj.pov, "st_v")
                col.prop(obj.pov, "st_ring")
                col.prop(obj.pov, "st_cross")
                col.prop(obj.pov, "st_ie")
                # col.prop(obj.pov, "st_edit") #?
                col.prop(obj.pov, "st_accuracy")
                col.prop(obj.pov, "st_max_gradient")


class OBJECT_PT_POV_obj_isosurface(PovDataButtonsPanel, Panel):
    """Use this class to define pov generic isosurface primitive function user field."""

    bl_label = "POV Isosurface"
    COMPAT_ENGINES = {'POVRAY_RENDER'}
    # bl_options = {'HIDE_HEADER'}

    @classmethod
    def poll(cls, context):
        engine = context.scene.render.engine
        obj = context.object
        return obj and obj.pov.object_as == 'ISOSURFACE_VIEW' and (engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout

        obj = context.object

        col = layout.column()

        if obj.pov.object_as == 'ISOSURFACE_VIEW':
                col.prop(obj.pov, "isosurface_eq")

class OBJECT_PT_POV_obj_parametric(PovDataButtonsPanel, Panel):
    """Use this class to define pov parametric surface primitive parameters buttons."""

    bl_label = "POV Parametric surface"
    # bl_options = {'HIDE_HEADER'}

    @classmethod
    def poll(cls, context):
        engine = context.scene.render.engine
        obj = context.object
        return obj and obj.pov.object_as == 'PARAMETRIC' and (engine in cls.COMPAT_ENGINES)

    def draw(self, context):
        layout = self.layout

        obj = context.object

        col = layout.column()

        if obj.pov.object_as == 'PARAMETRIC':
            if not obj.pov.unlock_parameters:
                col.prop(
                    obj.pov, "unlock_parameters", text="Exported parameters below", icon='LOCKED'
                )
                col.label(text="Minimum U: " + str(obj.pov.u_min))
                col.label(text="Minimum V: " + str(obj.pov.v_min))
                col.label(text="Maximum U: " + str(obj.pov.u_max))
                col.label(text="Minimum V: " + str(obj.pov.v_min))
                col.label(text="X Function: " + str(obj.pov.x_eq))
                col.label(text="Y Function: " + str(obj.pov.y_eq))
                col.label(text="Z Function: " + str(obj.pov.x_eq))

            else:
                col.prop(
                    obj.pov, "unlock_parameters", text="Edit exported parameters", icon='UNLOCKED'
                )
                col.label(text="3D view proxy may get out of synch")
                col.active = obj.pov.unlock_parameters

                layout.operator("pov.parametric_update", text="Update", icon="SCRIPTPLUGINS")

                col.prop(obj.pov, "u_min", text="Minimum U")
                col.prop(obj.pov, "v_min", text="Minimum V")
                col.prop(obj.pov, "u_max", text="Maximum U")
                col.prop(obj.pov, "v_max", text="Minimum V")
                col.prop(obj.pov, "x_eq", text="X Function")
                col.prop(obj.pov, "y_eq", text="Y Function")
                col.prop(obj.pov, "z_eq", text="Z Function")


class OBJECT_PT_povray_replacement_text(ObjectButtonsPanel, Panel):
    """Use this class to define pov object replacement field."""

    bl_label = "Custom POV Code"
    COMPAT_ENGINES = {'POVRAY_RENDER'}

    def draw(self, context):
        layout = self.layout

        obj = context.object

        col = layout.column()
        col.label(text="Replace properties with:")
        col.prop(obj.pov, "replacement_text", text="")


# ---------------------------------------------------------------- #
# Add POV objects
# ---------------------------------------------------------------- #
def check_add_mesh_extra_objects():
    """Test if Add mesh extra objects addon is activated

    This addon is currently used to generate the proxy for POV parametric
    surface which is almost the same principle as its Math xyz surface
    """
    return "add_mesh_extra_objects" in bpy.context.preferences.addons.keys()


def menu_func_add(self, context):
    """Append the POV primitives submenu to blender add objects menu"""
    engine = context.scene.render.engine
    if engine == 'POVRAY_RENDER':
        self.layout.menu("VIEW_MT_POV_primitives_add", icon="PLUGIN")


class VIEW_MT_POV_primitives_add(Menu):
    """Define the primitives menu with presets"""

    bl_idname = "VIEW_MT_POV_primitives_add"
    bl_label = "Povray"
    COMPAT_ENGINES = {'POVRAY_RENDER'}

    @classmethod
    def poll(cls, context):
        engine = context.scene.render.engine
        return engine == 'POVRAY_RENDER'

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'
        layout.menu(VIEW_MT_POV_Basic_Shapes.bl_idname, text="Primitives", icon="GROUP")
        layout.menu(VIEW_MT_POV_import.bl_idname, text="Import", icon="IMPORT")


class VIEW_MT_POV_Basic_Shapes(Menu):
    """Use this class to sort simple primitives menu entries."""

    bl_idname = "POVRAY_MT_basic_shape_tools"
    bl_label = "Basic_shapes"

    def draw(self, context):
        layout = self.layout
        layout.operator_context = 'INVOKE_REGION_WIN'
        layout.operator("pov.addplane", text="Infinite Plane", icon='MESH_PLANE')
        layout.operator("pov.addbox", text="Box", icon='MESH_CUBE')
        layout.operator("pov.addsphere", text="Sphere", icon='SHADING_RENDERED')
        layout.operator("pov.addcylinder", text="Cylinder", icon="MESH_CYLINDER")
        layout.operator("pov.addcone", text="Cone", icon="MESH_CONE")
        layout.operator("pov.addtorus", text="Torus", icon='MESH_TORUS')
        layout.separator()
        layout.operator("pov.addrainbow", text="Rainbow", icon="COLOR")
        layout.operator("pov.addlathe", text="Lathe", icon='MOD_SCREW')
        layout.operator("pov.addprism", text="Prism", icon='MOD_SOLIDIFY')
        layout.operator("pov.addsuperellipsoid", text="Superquadric Ellipsoid", icon='MOD_SUBSURF')
        layout.operator("pov.addheightfield", text="Height Field", icon="RNDCURVE")
        layout.operator("pov.addspheresweep", text="Sphere Sweep", icon='FORCE_CURVE')
        layout.separator()
        layout.operator("pov.addblobsphere", text="Blob Sphere", icon='META_DATA')
        layout.separator()
        layout.label(text="Isosurfaces")
        layout.operator("pov.addisosurfacebox", text="Isosurface Box", icon="META_CUBE")
        layout.operator("pov.addisosurfacesphere", text="Isosurface Sphere", icon="META_BALL")
        layout.operator("pov.addsupertorus", text="Supertorus", icon="SURFACE_NTORUS")
        layout.separator()
        layout.label(text="Macro based")
        layout.operator(
            "pov.addpolygontocircle", text="Polygon To Circle Blending", icon="MOD_CAST"
        )
        layout.operator("pov.addloft", text="Loft", icon="SURFACE_NSURFACE")
        layout.separator()
        # Warning if the Add Advanced Objects addon containing
        # Add mesh extra objects is not enabled
        if not check_add_mesh_extra_objects():
            # col = box.column()
            layout.label(text="Please enable Add Mesh: Extra Objects addon", icon="INFO")
            # layout.separator()
            layout.operator(
                "preferences.addon_show",
                text="Go to Add Mesh: Extra Objects addon",
                icon="PREFERENCES",
            ).module = "add_mesh_extra_objects"

            # layout.separator()
            return
        layout.operator("pov.addparametric", text="Parametric", icon='SCRIPTPLUGINS')

# ------------ Tool bar button------------ #
icon_path = (os.path.join(os.path.dirname(__file__), "icons"))
class VIEW_WT_POV_plane_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addplane"
    bl_label = "Add POV plane"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a plane of infinite dimension for POV"
    )
    bl_icon = os.path.join(icon_path, "pov.add.infinite_plane")
    bl_widget = None
    bl_keymap = (
        ("pov.addplane", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_box_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addbox"
    bl_label = "Add POV box"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV box solid primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.box")
    bl_widget = None
    bl_keymap = (
        ("pov.addbox", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_sphere_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addsphere"
    bl_label = "Add POV sphere"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add an untesselated sphere for POV"
    )
    bl_icon = os.path.join(icon_path, "pov.add.sphere")
    bl_widget = None
    bl_keymap = (
        ("pov.addsphere", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_cylinder_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addcylinder"
    bl_label = "Add POV cylinder"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add an untesselated cylinder for POV"
    )
    bl_icon = os.path.join(icon_path, "pov.add.cylinder")
    bl_widget = None
    bl_keymap = (
        ("pov.addcylinder", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_cone_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addcone"
    bl_label = "Add POV cone"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add an untesselated cone for POV"
    )
    bl_icon = os.path.join(icon_path, "pov.add.cone")
    bl_widget = None
    bl_keymap = (
        ("pov.addcone", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_torus_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addtorus"
    bl_label = "Add POV torus"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add an untesselated torus for POV"
    )
    bl_icon = os.path.join(icon_path, "pov.add.torus")
    bl_widget = None
    bl_keymap = (
        ("pov.addtorus", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_rainbow_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addrainbow"
    bl_label = "Add POV rainbow"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV rainbow primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.rainbow")
    bl_widget = None
    bl_keymap = (
        ("pov.addrainbow", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_lathe_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addlathe"
    bl_label = "Add POV lathe"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV lathe primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.lathe")
    bl_widget = None
    bl_keymap = (
        ("pov.addlathe", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_prism_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addprism"
    bl_label = "Add POV prism"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV prism primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.prism")
    bl_widget = None
    bl_keymap = (
        ("pov.addprism", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_heightfield_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addheightfield"
    bl_label = "Add POV heightfield"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV heightfield primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.heightfield")
    bl_widget = None
    bl_keymap = (
        ("pov.addheightfield", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_superellipsoid_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addsuperellipsoid"
    bl_label = "Add POV superquadric ellipsoid"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV superquadric ellipsoid primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.superellipsoid")
    bl_widget = None
    bl_keymap = (
        ("pov.addsuperellipsoid", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_spheresweep_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addspheresweep"
    bl_label = "Add POV spheresweep"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV spheresweep primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.spheresweep")
    bl_widget = None
    bl_keymap = (
        ("pov.addspheresweep", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_loft_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addloft"
    bl_label = "Add POV loft macro"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV loft macro between editable spline cross sections"
    )
    bl_icon = os.path.join(icon_path, "pov.add.loft")
    bl_widget = None
    bl_keymap = (
        ("pov.addloft", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_polytocircle_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addpolytocircle"
    bl_label = "Add POV poly to circle macro"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV regular polygon to circle blending macro"
    )
    bl_icon = os.path.join(icon_path, "pov.add.polytocircle")
    bl_widget = None
    bl_keymap = (
        ("pov.addpolytocircle", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_parametric_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addparametric"
    bl_label = "Add POV parametric surface"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV parametric surface primitive shaped from three equations (for x, y, z directions)"
    )
    bl_icon = os.path.join(icon_path, "pov.add.parametric")
    bl_widget = None
    bl_keymap = (
        ("pov.addparametric", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_isosurface_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addisosurface"
    bl_label = "Add POV generic isosurface"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV generic shaped isosurface primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.isosurface")
    bl_widget = None
    bl_keymap = (
        ("pov.addisosurface", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_isosurfacebox_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addisosurfacebox"
    bl_label = "Add POV isosurface box"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV box shaped isosurface primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.isosurfacebox")
    bl_widget = None
    bl_keymap = (
        ("pov.addisosurfacebox", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_isosurfacesphere_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addisosurfacesphere"
    bl_label = "Add POV isosurface sphere"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV sphere shaped isosurface primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.isosurfacesphere")
    bl_widget = None
    bl_keymap = (
        ("pov.addisosurfacesphere", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_isosurfacesupertorus_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addsupertorus"
    bl_label = "Add POV isosurface supertorus"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV torus shaped isosurface primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.isosurfacesupertorus")
    bl_widget = None
    bl_keymap = (
        ("pov.addsupertorus", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_blobsphere_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addblobsphere"
    bl_label = "Add POV blob sphere"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV sphere shaped blob primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.blobsphere")
    bl_widget = None
    bl_keymap = (
        ("pov.addblobsphere", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_blobcapsule_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addblobcapsule"
    bl_label = "Add POV blob capsule"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV capsule shaped blob primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.blobcapsule")
    bl_widget = None
    bl_keymap = (
        ("pov.addblobcapsule", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_blobplane_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addblobplane"
    bl_label = "Add POV blob plane"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV plane shaped blob primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.blobplane")
    bl_widget = None
    bl_keymap = (
        ("pov.addblobplane", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_blobellipsoid_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addblobellipsoid"
    bl_label = "Add POV blob ellipsoid"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV ellipsoid shaped blob primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.blobellipsoid")
    bl_widget = None
    bl_keymap = (
        ("pov.addblobellipsoid", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


class VIEW_WT_POV_blobcube_add(WorkSpaceTool):
    bl_space_type='VIEW_3D'
    bl_context_mode='OBJECT'

    # The prefix of the idname should be your add-on name.
    bl_idname = "pov.addsblobcube"
    bl_label = "Add POV blob cube"
    bl_options = {'REGISTER', 'UNDO'}
    bl_description = (
        "add a POV cube shaped blob primitive"
    )
    bl_icon = os.path.join(icon_path, "pov.add.blobcube")
    bl_widget = None
    bl_keymap = (
        ("pov.addblobcube", {"type": 'LEFTMOUSE', "value": 'PRESS'},
    {"properties": None}),
        )


classes = (
    # ObjectButtonsPanel,
    # PovDataButtonsPanel,
    DATA_PT_POV_normals,
    DATA_PT_POV_texture_space,
    DATA_PT_POV_vertex_groups,
    DATA_PT_POV_shape_keys,
    DATA_PT_POV_uv_texture,
    DATA_PT_POV_vertex_colors,
    DATA_PT_POV_customdata,
    MODIFIERS_PT_POV_modifiers,
    OBJECT_PT_POV_obj_parameters,
    OBJECT_PT_POV_obj_sphere,
    OBJECT_PT_POV_obj_cylinder,
    OBJECT_PT_POV_obj_cone,
    OBJECT_PT_POV_obj_superellipsoid,
    OBJECT_PT_POV_obj_torus,
    OBJECT_PT_POV_obj_supertorus,
    OBJECT_PT_POV_obj_isosurface,
    OBJECT_PT_POV_obj_parametric,
    OBJECT_PT_povray_replacement_text,
    VIEW_MT_POV_primitives_add,
    VIEW_MT_POV_Basic_Shapes,
)
tool_classes = (
    VIEW_WT_POV_plane_add,
    VIEW_WT_POV_box_add,
    VIEW_WT_POV_sphere_add,
    VIEW_WT_POV_cylinder_add,
    VIEW_WT_POV_cone_add,
    VIEW_WT_POV_torus_add,
    VIEW_WT_POV_prism_add,
    VIEW_WT_POV_lathe_add,
    VIEW_WT_POV_spheresweep_add,
    VIEW_WT_POV_heightfield_add,
    VIEW_WT_POV_superellipsoid_add,
    VIEW_WT_POV_rainbow_add,
    VIEW_WT_POV_loft_add,
    VIEW_WT_POV_polytocircle_add,
    VIEW_WT_POV_parametric_add,
    VIEW_WT_POV_isosurface_add,
    VIEW_WT_POV_isosurfacebox_add,
    VIEW_WT_POV_isosurfacesphere_add,
    VIEW_WT_POV_isosurfacesupertorus_add,
    VIEW_WT_POV_blobsphere_add,
    VIEW_WT_POV_blobcapsule_add,
    VIEW_WT_POV_blobplane_add,
    VIEW_WT_POV_blobellipsoid_add,
    VIEW_WT_POV_blobcube_add,
)

def register():
    for cls in classes:
        register_class(cls)

    # Register tools
    last_tool = {"builtin.measure"}
    for index, wtl in enumerate(tool_classes):
        # Only separate first and 12th tools and hide subtools only in 8th (isosurfaces)
        register_tool(wtl, after=last_tool, separator=index in [0,7,11,12,14,19], group=index == 15)
        last_tool = {wtl.bl_idname}

    bpy.types.VIEW3D_MT_add.prepend(menu_func_add)
    # Below was used for parametric objects but made the other addon unreachable on
    # unregister for other tools to use. Created a user action call instead
    # addon_utils.enable("add_mesh_extra_objects", default_set=False, persistent=True)


def unregister():
    # addon_utils.disable("add_mesh_extra_objects", default_set=False)
    bpy.types.VIEW3D_MT_add.remove(menu_func_add)

    for wtl in reversed(tool_classes):
        unregister_tool(wtl)

    for cls in reversed(classes):
        unregister_class(cls)