archipack: fix left select issue in draw window/door and allow selecting preset while drawing

This commit is contained in:
stephen leger 2017-08-03 15:59:40 +02:00
parent 948149cefc
commit 92301276de
3 changed files with 39 additions and 5 deletions

View File

@ -1598,7 +1598,7 @@ class ARCHIPACK_OT_door(ArchipackCreateTool, Operator):
def unique(self, context):
act = context.active_object
sel = [o for o in context.selected_objects]
sel = context.selected_objects[:]
bpy.ops.object.select_all(action="DESELECT")
for o in sel:
if archipack_door.filter(o):
@ -1650,6 +1650,7 @@ class ARCHIPACK_OT_door_draw(ArchpackDrawTool, Operator):
filepath = StringProperty(default="")
feedback = None
stack = []
object_name = ""
@classmethod
def poll(cls, context):
@ -1690,6 +1691,8 @@ class ARCHIPACK_OT_door_draw(ArchpackDrawTool, Operator):
bpy.ops.archipack.door(auto_manipulate=False, filepath=self.filepath)
o = context.active_object
self.object_name = o.name
bpy.ops.archipack.generate_hole('INVOKE_DEFAULT')
o.select = True
context.scene.objects.active = o
@ -1697,7 +1700,10 @@ class ARCHIPACK_OT_door_draw(ArchpackDrawTool, Operator):
def modal(self, context, event):
context.area.tag_redraw()
o = context.active_object
o = context.scene.objects.get(self.object_name)
if o is None:
return {'FINISHED'}
d = archipack_door.datablock(o)
hole = None
@ -1721,6 +1727,16 @@ class ARCHIPACK_OT_door_draw(ArchpackDrawTool, Operator):
d.y = wall.data.archipack_wall2[0].width
if event.value == 'PRESS':
if event.type in {'C'}:
bpy.ops.archipack.door(mode='DELETE')
self.feedback.disable()
bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
bpy.ops.archipack.door_preset_menu(
'INVOKE_DEFAULT',
preset_operator="archipack.door_draw")
return {'FINISHED'}
if event.type in {'LEFTMOUSE', 'RET', 'NUMPAD_ENTER', 'SPACE'}:
if wall is not None:
context.scene.objects.active = wall
@ -1781,6 +1797,7 @@ class ARCHIPACK_OT_door_draw(ArchpackDrawTool, Operator):
self.feedback.instructions(context, "Draw a door", "Click & Drag over a wall", [
('LEFTCLICK, RET, SPACE, ENTER', 'Create a door'),
('BACKSPACE, CTRL+Z', 'undo last'),
('C', 'Choose another door'),
('SHIFT', 'Make independant copy'),
('RIGHTCLICK or ESC', 'exit')
])

View File

@ -142,10 +142,11 @@ def snap_point(takeloc=None,
# for ArchipackSnapBase to be able to handle both modes
# must implements corresponding helper create and delete actions
SnapStore.mode = mode
res = bpy.ops.archipack.snap('INVOKE_DEFAULT')
bpy.ops.archipack.snap('INVOKE_DEFAULT')
# return helper so we are able to move it "live"
return SnapStore.helper
class ArchipackSnapBase():
"""
Helper class for snap Operators
@ -273,7 +274,7 @@ class ARCHIPACK_OT_snap(ArchipackSnapBase, Operator):
# NOTE: this part only run after transform LEFTMOUSE RELEASE
# or with ESC and RIGHTMOUSE
if event.type not in {'ESC', 'RIGHTMOUSE', 'LEFTMOUSE', 'MOUSEMOVE'}:
print("Snap.modal skip unknown event %s %s" % (event.type, event.value))
# print("Snap.modal skip unknown event %s %s" % (event.type, event.value))
# self.report({'WARNING'}, "ARCHIPACK_OT_snap unknown event")
return{'PASS_THROUGH'}
if event.type in ('ESC', 'RIGHTMOUSE'):

View File

@ -1841,6 +1841,7 @@ class ARCHIPACK_OT_window_draw(ArchpackDrawTool, Operator):
filepath = StringProperty(default="")
feedback = None
stack = []
object_name = ""
@classmethod
def poll(cls, context):
@ -1881,6 +1882,8 @@ class ARCHIPACK_OT_window_draw(ArchpackDrawTool, Operator):
bpy.ops.archipack.window(auto_manipulate=False, filepath=self.filepath)
o = context.active_object
self.object_name = o.name
bpy.ops.archipack.generate_hole('INVOKE_DEFAULT')
o.select = True
context.scene.objects.active = o
@ -1888,7 +1891,11 @@ class ARCHIPACK_OT_window_draw(ArchpackDrawTool, Operator):
def modal(self, context, event):
context.area.tag_redraw()
o = context.active_object
o = context.scene.objects.get(self.object_name)
if o is None:
return {'FINISHED'}
d = archipack_window.datablock(o)
hole = None
if d is not None:
@ -1911,6 +1918,14 @@ class ARCHIPACK_OT_window_draw(ArchpackDrawTool, Operator):
d.y = wall.data.archipack_wall2[0].width
if event.value == 'PRESS':
if event.type in {'C'}:
bpy.ops.archipack.window(mode='DELETE')
self.feedback.disable()
bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
bpy.ops.archipack.window_preset_menu('INVOKE_DEFAULT', preset_operator="archipack.window_draw")
return {'FINISHED'}
if event.type in {'LEFTMOUSE', 'RET', 'NUMPAD_ENTER', 'SPACE'}:
if wall is not None:
context.scene.objects.active = wall
@ -1970,6 +1985,7 @@ class ARCHIPACK_OT_window_draw(ArchpackDrawTool, Operator):
self.feedback.instructions(context, "Draw a window", "Click & Drag over a wall", [
('LEFTCLICK, RET, SPACE, ENTER', 'Create a window'),
('BACKSPACE, CTRL+Z', 'undo last'),
('C', 'Choose another window'),
('SHIFT', 'Make independant copy'),
('RIGHTCLICK or ESC', 'exit')
])