forked from hlorus/CAD_Sketcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect.py
117 lines (85 loc) · 2.96 KB
/
select.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
from bpy.types import Operator, Context
from bpy.props import IntProperty, BoolProperty
from bpy.utils import register_classes_factory
from .utilities import select_extend, select_invert
from ..utilities.select import select_all, deselect_all
from .. import global_data
from ..declarations import Operators
from ..utilities.highlighting import HighlightElement
from ..utilities.select import mode_property
class View3D_OT_slvs_select(Operator, HighlightElement):
"""
Select an entity
Either the entity specified by the index property or the hovered index
if the index property is not set
"""
bl_idname = Operators.Select
bl_label = "Select Sketch Entities"
index: IntProperty(name="Index", default=-1)
mode: mode_property
def execute(self, context: Context):
index = (
self.index
if self.properties.is_property_set("index")
else global_data.hover
)
hit = index != -1
mode = self.mode
if mode == "SET" or not hit:
deselect_all(context)
if hit:
entity = context.scene.sketcher.entities.get(index)
value = True
if mode == "SUBTRACT":
value = False
if mode == "TOGGLE":
value = not entity.selected
entity.selected = value
context.area.tag_redraw()
return {"FINISHED"}
class View3D_OT_slvs_select_all(Operator):
"""Select / Deselect all entities"""
bl_idname = Operators.SelectAll
bl_label = "Select / Deselect Entities"
deselect: BoolProperty(name="Deselect")
def execute(self, context: Context):
if self.deselect:
deselect_all(context)
else:
select_all(context)
context.area.tag_redraw()
return {"FINISHED"}
class View3D_OT_slvs_select_invert(Operator):
"""Invert entities selection"""
bl_idname = Operators.SelectInvert
bl_label = "Invert entities selection"
def execute(self, context: Context):
select_invert(context)
context.area.tag_redraw()
return {"FINISHED"}
class View3D_OT_slvs_select_extend(Operator):
"""Select neighbour entities"""
bl_idname = Operators.SelectExtend
bl_label = "Select neighbour entities"
def execute(self, context: Context):
select_extend(context)
context.area.tag_redraw()
return {"FINISHED"}
class View3D_OT_slvs_select_extend_all(Operator):
"""Select neighbour entities"""
bl_idname = Operators.SelectExtendAll
bl_label = "Select neighbour entities"
def execute(self, context: Context):
while select_extend(context):
pass
context.area.tag_redraw()
return {"FINISHED"}
register, unregister = register_classes_factory(
(
View3D_OT_slvs_select,
View3D_OT_slvs_select_all,
View3D_OT_slvs_select_invert,
View3D_OT_slvs_select_extend,
View3D_OT_slvs_select_extend_all,
)
)