[Bf-extensions-cvs] [d22e3338] master: archipack: T52120 fix panels context, fix draw a wall in perspective view, add draw a wall mouse click/release cycle option
Stephen Leger
noreply at git.blender.org
Sat Jul 22 13:11:24 CEST 2017
Commit: d22e333867b04297a7164432d54ddca719eeea3e
Author: Stephen Leger
Date: Wed Jul 19 14:53:32 2017 +0200
Branches: master
https://developer.blender.org/rBACd22e333867b04297a7164432d54ddca719eeea3e
archipack: T52120 fix panels context, fix draw a wall in perspective view, add draw a wall mouse click/release cycle option
===================================================================
M archipack/__init__.py
M archipack/archipack_snap.py
M archipack/archipack_wall2.py
===================================================================
diff --git a/archipack/__init__.py b/archipack/__init__.py
index 7e783bcf..79ac9879 100644
--- a/archipack/__init__.py
+++ b/archipack/__init__.py
@@ -154,6 +154,11 @@ class Archipack_Pref(AddonPreferences):
description="Put Achipack's object into a sub menu (shift+a)",
default=True
)
+ max_style_draw_tool = BoolProperty(
+ name="Draw a wall use 3dsmax style",
+ description="Reverse clic / release cycle for Draw a wall",
+ default=True
+ )
# Arrow sizes (world units)
arrow_size = FloatProperty(
name="Arrow",
@@ -236,6 +241,7 @@ class Archipack_Pref(AddonPreferences):
col.prop(self, "tools_category")
col.prop(self, "create_category")
col.prop(self, "create_submenu")
+ col.prop(self, "max_style_draw_tool")
box = layout.box()
row = box.row()
split = row.split(percentage=0.5)
@@ -272,7 +278,8 @@ class TOOLS_PT_Archipack_PolyLib(Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_category = "Tools"
-
+ bl_context = "objectmode"
+
@classmethod
def poll(self, context):
@@ -377,7 +384,8 @@ class TOOLS_PT_Archipack_Tools(Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_category = "Tools"
-
+ bl_context = "objectmode"
+
@classmethod
def poll(self, context):
return True
@@ -405,7 +413,8 @@ class TOOLS_PT_Archipack_Create(Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_category = "Create"
-
+ bl_context = "objectmode"
+
@classmethod
def poll(self, context):
return True
@@ -522,7 +531,8 @@ def draw_menu(self, context):
class ARCHIPACK_create_menu(Menu):
bl_label = 'Archipack'
bl_idname = 'ARCHIPACK_create_menu'
-
+ bl_context = "objectmode"
+
def draw(self, context):
draw_menu(self, context)
@@ -604,7 +614,7 @@ def unregister():
bpy.utils.unregister_class(TOOLS_PT_Archipack_Tools)
bpy.utils.unregister_class(TOOLS_PT_Archipack_Create)
bpy.utils.unregister_class(Archipack_Pref)
-
+
# unregister subs
archipack_snap.unregister()
archipack_manipulator.unregister()
diff --git a/archipack/archipack_snap.py b/archipack/archipack_snap.py
index eb3898d3..936a07d8 100644
--- a/archipack/archipack_snap.py
+++ b/archipack/archipack_snap.py
@@ -273,10 +273,10 @@ 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'):
+ if event.type in {'ESC', 'RIGHTMOUSE'}:
SnapStore.callback(context, event, 'CANCEL', self)
else:
SnapStore.placeloc = SnapStore.helper.location
@@ -290,6 +290,7 @@ class ARCHIPACK_OT_snap(ArchipackSnapBase, Operator):
# print("Snap.invoke event %s %s" % (event.type, event.value))
self.init(context, event)
context.window_manager.modal_handler_add(self)
+ # print("SnapStore.transform_orientation%s" % (SnapStore.transform_orientation))
bpy.ops.transform.translate('INVOKE_DEFAULT',
constraint_axis=SnapStore.constraint_axis,
constraint_orientation=SnapStore.transform_orientation,
diff --git a/archipack/archipack_wall2.py b/archipack/archipack_wall2.py
index 523ff3f3..4944f59f 100644
--- a/archipack/archipack_wall2.py
+++ b/archipack/archipack_wall2.py
@@ -1786,6 +1786,8 @@ class ARCHIPACK_OT_wall2_draw(ArchpackDrawTool, Operator):
parent = None
takemat = None
+ max_style_draw_tool = False
+
@classmethod
def poll(cls, context):
return True
@@ -1923,25 +1925,36 @@ class ARCHIPACK_OT_wall2_draw(ArchpackDrawTool, Operator):
if self.state == 'STARTING':
takeloc = self.mouse_to_plane(context, event)
- # print("STARTING")
- snap_point(takeloc=takeloc,
- callback=self.sp_init,
- constraint_axis=(True, True, False),
- release_confirm=True)
+ # wait for takeloc being visible when button is over horizon
+ rv3d = context.region_data
+ viewinv = rv3d.view_matrix.inverted()
+ if (takeloc * viewinv).z < 0:
+ # print("STARTING")
+ # when user press draw button
+ snap_point(takeloc=takeloc,
+ callback=self.sp_init,
+ # transform_orientation=context.space_data.transform_orientation,
+ constraint_axis=(True, True, False),
+ release_confirm=True)
return {'RUNNING_MODAL'}
elif self.state == 'RUNNING':
# print("RUNNING")
+ # when user start drawing
+
+ # release confirm = False on blender mode
+ # release confirm = True on max mode
self.state = 'CREATE'
snap_point(takeloc=self.takeloc,
draw=self.sp_draw,
takemat=self.takemat,
+ transform_orientation=context.space_data.transform_orientation,
callback=self.sp_callback,
constraint_axis=(True, True, False),
- release_confirm=True)
+ release_confirm=self.max_style_draw_tool)
return {'RUNNING_MODAL'}
- elif event.type in {'LEFTMOUSE', 'RET', 'NUMPAD_ENTER', 'SPACE'}:
+ elif self.state != 'CANCEL' and event.type in {'LEFTMOUSE', 'RET', 'NUMPAD_ENTER', 'SPACE'}:
# print('LEFTMOUSE %s' % (event.value))
self.feedback.instructions(context, "Draw a wall", "Click & Drag to add a segment", [
@@ -1952,8 +1965,13 @@ class ARCHIPACK_OT_wall2_draw(ArchpackDrawTool, Operator):
('RIGHTCLICK or ESC', 'exit')
])
- if event.value == 'PRESS':
+ # press with max mode release with blender mode
+ if self.max_style_draw_tool:
+ evt_value = 'PRESS'
+ else:
+ evt_value = 'RELEASE'
+ if event.value == evt_value:
if self.flag_next:
self.flag_next = False
o = self.o
@@ -1981,7 +1999,7 @@ class ARCHIPACK_OT_wall2_draw(ArchpackDrawTool, Operator):
draw=self.sp_draw,
callback=self.sp_callback,
constraint_axis=(True, True, False),
- release_confirm=True)
+ release_confirm=self.max_style_draw_tool)
return {'RUNNING_MODAL'}
@@ -2010,12 +2028,17 @@ class ARCHIPACK_OT_wall2_draw(ArchpackDrawTool, Operator):
else:
self.o.select = True
context.scene.objects.active = self.o
- # self.ensure_ccw()
+ d = archipack_wall2.datablock(self.o)
+
+ # remove last segment with blender mode
+ if not self.max_style_draw_tool:
+ if not d.closed and d.n_parts > 1:
+ d.n_parts -= 1
+
self.o.select = True
context.scene.objects.active = self.o
# make T child
if self.parent is not None:
- d = archipack_wall2.datablock(self.o)
d.t_part = self.parent
if bpy.ops.archipack.wall2_manipulate.poll():
@@ -2028,6 +2051,8 @@ class ARCHIPACK_OT_wall2_draw(ArchpackDrawTool, Operator):
def invoke(self, context, event):
if context.mode == "OBJECT":
+ prefs = context.user_preferences.addons[__name__.split('.')[0]].preferences
+ self.max_style_draw_tool = prefs.max_style_draw_tool
self.keymap = Keymaps(context)
self.wall_part1 = GlPolygon((0.5, 0, 0, 0.2))
self.wall_line1 = GlPolyline((0.5, 0, 0, 0.8))
More information about the Bf-extensions-cvs
mailing list