Cleanup: trailing space
[blender-addons.git] / object_carver / __init__.py
blob2ccda3e78b51caafe2f39b9e5cdd709b1bd0ca13
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
19 bl_info = {
20 "name": "Carver",
21 "author": "Pixivore, Cedric LEPILLER, Ted Milker, Clarkx",
22 "description": "Multiple tools to carve or to create objects",
23 "version": (1, 2, 0),
24 "blender": (2, 80, 0),
25 "location": "3D View > Ctrl/Shift/x",
26 "warning": "",
27 "doc_url": "{BLENDER_MANUAL_URL}/addons/object/carver.html",
28 "support": 'COMMUNITY',
29 "category": "Object"
32 import bpy
33 import imp
34 from bpy.props import (
35 BoolProperty,
36 StringProperty,
37 IntProperty
39 from bpy.types import (AddonPreferences, WorkSpaceTool)
40 from bpy.utils.toolsystem import ToolDef
42 from . import carver_utils
43 imp.reload(carver_utils)
44 from . import carver_profils
45 imp.reload(carver_profils)
46 from . import carver_draw
47 imp.reload(carver_draw)
48 from . import carver_operator
49 imp.reload(carver_operator)
51 # TODO : Create an icon for Carver MT
52 # Add an icon in the toolbar
53 # class CarverTool(WorkSpaceTool):
54 # bl_space_type='VIEW_3D'
55 # bl_context_mode='OBJECT'
56 # bl_idname = "carver.operator"
57 # bl_label = "Carver"
58 # bl_description = (
59 # "Multiple tools to carve \n"
60 # "or to create objects"
61 # )
63 # #Icons : \blender-2.80\2.80\datafiles\icons
64 # #Todo: Create a new icon for Carver
65 # bl_icon = "ops.mesh.knife_tool"
66 # bl_widget = None
67 # bl_keymap = (
68 # ("carver.operator", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
69 # )
71 # def draw_settings(context, layout, tool):
72 # layout.prop(tool.operator_properties, "carver")
75 class CarverPreferences(AddonPreferences):
76 bl_idname = __name__
79 Enable_Tab_01: BoolProperty(
80 name="Info",
81 description="Some general information and settings about the add-on",
82 default=False
84 Enable_Tab_02: BoolProperty(
85 name="Hotkeys",
86 description="List of the shortcuts used during carving",
87 default=False
89 Key_Create: StringProperty(
90 name="Object creation",
91 description="Object creation",
92 maxlen=1,
93 default="C"
95 Key_Update: StringProperty(
96 name="Auto Bevel Update",
97 description="Auto Bevel Update",
98 maxlen=1,
99 default="A",
101 Key_Bool: StringProperty(
102 name="Boolean type",
103 description="Boolean operation type",
104 maxlen=1,
105 default="T",
107 Key_Brush: StringProperty(
108 name="Brush Mode",
109 description="Brush Mode",
110 maxlen=1,
111 default="B",
113 Key_Help: StringProperty(
114 name="Help display",
115 description="Help display",
116 maxlen=1,
117 default="H",
119 Key_Instant: StringProperty(
120 name="Instantiate",
121 description="Instantiate object",
122 maxlen=1,
123 default="I",
125 Key_Close: StringProperty(
126 name="Close polygonal shape",
127 description="Close polygonal shape",
128 maxlen=1,
129 default="X",
131 Key_Apply: StringProperty(
132 name="Apply operation",
133 description="Apply operation",
134 maxlen=1,
135 default="Q",
137 Key_Scale: StringProperty(
138 name="Scale object",
139 description="Scale object",
140 maxlen=1,
141 default="S",
143 Key_Gapy: StringProperty(
144 name="Gap rows",
145 description="Scale gap between columns",
146 maxlen=1,
147 default="J",
149 Key_Gapx: StringProperty(
150 name="Gap columns",
151 description="Scale gap between columns",
152 maxlen=1,
153 default="U",
155 Key_Depth: StringProperty(
156 name="Depth",
157 description="Cursor depth or solidify pattern",
158 maxlen=1,
159 default="D",
161 Key_BrushDepth: StringProperty(
162 name="Brush Depth",
163 description="Brush depth",
164 maxlen=1,
165 default="C",
167 Key_Subadd: StringProperty(
168 name="Add subdivision",
169 description="Add subdivision",
170 maxlen=1,
171 default="X",
173 Key_Subrem: StringProperty(
174 name="Remove subdivision",
175 description="Remove subdivision",
176 maxlen=1,
177 default="W",
179 Key_Randrot: StringProperty(
180 name="Random rotation",
181 description="Random rotation",
182 maxlen=1,
183 default="R",
185 ProfilePrefix: StringProperty(
186 name="Profile prefix",
187 description="Prefix to look for profiles with",
188 default="Carver_Profile-",
190 LineWidth: IntProperty(
191 name="Line Width",
192 description="Thickness of the drawing lines",
193 default=1,
195 Key_Snap: StringProperty(
196 name="Grid Snap",
197 description="Grid Snap",
198 maxlen=1,
199 default="G",
202 def draw(self, context):
203 scene = context.scene
204 layout = self.layout
206 icon_1 = "TRIA_RIGHT" if not self.Enable_Tab_01 else "TRIA_DOWN"
207 box = layout.box()
209 box.prop(self, "Enable_Tab_01", text="Info and Settings", emboss=False, icon=icon_1)
210 if self.Enable_Tab_01:
211 box.label(text="Carver Operator:", icon="LAYER_ACTIVE")
212 box.label(text="Select a Mesh Object and press [CTRL]+[SHIFT]+[X] to carve",
213 icon="LAYER_USED")
214 box.label(text="To finish carving press [ESC] or [RIGHT CLICK]",
215 icon="LAYER_USED")
216 box.prop(self, "ProfilePrefix", text="Profile prefix")
217 row = box.row(align=True)
218 row.label(text="Line width:")
219 row.prop(self, "LineWidth", text="")
221 icon_2 = "TRIA_RIGHT" if not self.Enable_Tab_02 else "TRIA_DOWN"
222 box = layout.box()
223 box.prop(self, "Enable_Tab_02", text="Keys", emboss=False, icon=icon_2)
224 if self.Enable_Tab_02:
225 split = box.split(align=True)
226 box = split.box()
227 col = box.column(align=True)
228 col.label(text="Object Creation:")
229 col.prop(self, "Key_Create", text="")
230 col.label(text="Auto bevel update:")
231 col.prop(self, "Key_Update", text="")
232 col.label(text="Boolean operation type:")
233 col.prop(self, "Key_Bool", text="")
234 col.label(text="Brush Depth:")
235 col.prop(self, "Key_BrushDepth", text="")
237 box = split.box()
238 col = box.column(align=True)
239 col.label(text="Brush Mode:")
240 col.prop(self, "Key_Brush", text="")
241 col.label(text="Help display:")
242 col.prop(self, "Key_Help", text="")
243 col.label(text="Instantiate object:")
244 col.prop(self, "Key_Instant", text="")
245 col.label(text="Random rotation:")
246 col.prop(self, "Key_Randrot", text="")
248 box = split.box()
249 col = box.column(align=True)
250 col.label(text="Close polygonal shape:")
251 col.prop(self, "Key_Close", text="")
252 col.label(text="Apply operation:")
253 col.prop(self, "Key_Apply", text="")
254 col.label(text="Scale object:")
255 col.prop(self, "Key_Scale", text="")
256 col.label(text="Subdiv add:")
257 col.prop(self, "Key_Subadd", text="")
259 box = split.box()
260 col = box.column(align=True)
261 col.label(text="Gap rows:")
262 col.prop(self, "Key_Gapy", text="")
263 col.label(text="Gap columns:")
264 col.prop(self, "Key_Gapx", text="")
265 col.label(text="Depth / Solidify:")
266 col.prop(self, "Key_Depth", text="")
267 col.label(text="Subdiv Remove:")
268 col.prop(self, "Key_Subrem", text="")
270 box = split.box()
271 col = box.column(align=True)
272 col.label(text="Grid Snap:")
273 col.prop(self, "Key_Snap", text="")
275 addon_keymaps = []
277 def register():
278 # print("Registered Carver")
280 bpy.utils.register_class(CarverPreferences)
281 # Todo : Add an icon in the toolbat
282 # bpy.utils.register_tool(CarverTool, separator=True, group=True)
283 carver_operator.register()
285 # add keymap entry
286 kcfg = bpy.context.window_manager.keyconfigs.addon
287 if kcfg:
288 km = kcfg.keymaps.new(name='3D View', space_type='VIEW_3D')
289 kmi = km.keymap_items.new("carver.operator", 'X', 'PRESS', shift=True, ctrl=True)
290 addon_keymaps.append((km, kmi))
292 def unregister():
293 # Todo : Add an icon in the toolbat
294 # bpy.utils.unregister_tool(CarverTool)
295 carver_operator.unregister()
296 bpy.utils.unregister_class(CarverPreferences)
298 # print("Unregistered Carver")
300 # remove keymap entry
301 for km, kmi in addon_keymaps:
302 km.keymap_items.remove(kmi)
303 addon_keymaps.clear()
307 if __name__ == "__main__":
308 register()