[Bf-extensions-cvs] [2eb94b9] master: version 1.4.2: FastOrigin readded

Gert De Roost noreply at git.blender.org
Wed Dec 9 07:15:32 CET 2015


Commit: 2eb94b9caf2c0c04dc7fc7d20185c39495fd37af
Author: Gert De Roost
Date:   Wed Dec 9 07:14:58 2015 +0100
Branches: master
https://developer.blender.org/rBAC2eb94b9caf2c0c04dc7fc7d20185c39495fd37af

version 1.4.2: FastOrigin readded

===================================================================

M	ewoc_projects_tools/__init__.py
M	ewoc_projects_tools/object_fastorigin.py

===================================================================

diff --git a/ewoc_projects_tools/__init__.py b/ewoc_projects_tools/__init__.py
index 4c61aab..5ca7c00 100644
--- a/ewoc_projects_tools/__init__.py
+++ b/ewoc_projects_tools/__init__.py
@@ -21,12 +21,12 @@
 bl_info = {
 	"name": "EWOCprojects tools",
 	"author": "Gert De Roost - paleajed",
-	"version": (1, 4, 1),
+	"version": (1, 4, 2),
 	"blender": (2, 65, 0),
 	"location": "View3D > Toolbar and View3D > Specials (W-key)",
 	"description": "Edit mode tools - contrib version",
 	"warning": "",
-	"wiki_url": "http://www.ewocprojects.be/scripts.html",
+	"wiki_url": "",
 	"tracker_url": "",
 	"category": "Mesh"}
 
@@ -38,6 +38,7 @@ if "bpy" in locals():
 	imp.reload(mesh_paredge)
 	imp.reload(mesh_edgegrow)
 	imp.reload(mesh_fanconnect)
+	imp.reload(object_fastorigin)
 	imp.reload(mesh_laprelax)
 	imp.reload(mesh_polyredux)
 	imp.reload(mesh_filletplus)
@@ -56,6 +57,7 @@ else:
 	from . import mesh_paredge
 	from . import mesh_edgegrow
 	from . import mesh_fanconnect
+	from . import object_fastorigin
 	from . import mesh_laprelax
 	from . import mesh_polyredux
 	from . import mesh_filletplus
@@ -91,6 +93,8 @@ class VIEW3D_MT_edit_mesh_paleajed(bpy.types.Menu):
 			text="EdgeGrow")
 		layout.operator("mesh.fanconnect",
 			text="FanConnect")
+		layout.operator("object.fastorigin",
+			text="FastOrigin")
 		layout.operator("mesh.laprelax",
 			text="LapRelax")
 		layout.operator("mesh.polyredux",
@@ -130,6 +134,7 @@ class PaleajedPanel(bpy.types.Panel):
 
 		layout.operator("mesh.edgegrow")
 		layout.operator("mesh.fanconnect")
+		layout.operator("object.fastorigin")
 		layout.operator("mesh.laprelax")
 		layout.operator("mesh.polyredux")
 		layout.operator("mesh.filletplus")
diff --git a/ewoc_projects_tools/object_fastorigin.py b/ewoc_projects_tools/object_fastorigin.py
index 84a1b31..3998a75 100644
--- a/ewoc_projects_tools/object_fastorigin.py
+++ b/ewoc_projects_tools/object_fastorigin.py
@@ -16,7 +16,7 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
-"""
+__bpydoc__ = """\
 The FastOrigin addon enables one to interactively set the active objects origin, either by 3D
 manipulator or Gkey with full support for snapping and realtime preview of this.
 
@@ -25,8 +25,8 @@ Documentation
 
 First go to User Preferences->Addons and enable the FastOrigin addon in the Object category.
 Select an object.  Invoke addon (button in Tools panel).  When in Object mode, addon will switch into
-EditMode and create a sinbgl.gle selected vertex which can be translated by standard means with snapping
-on for vertices (this can be changed in the standard way to other targets or no snap , the snap target
+EditMode and create a single selected vertex which can be translated by standard means with snapping
+on for vertices (this can be changed in the standard way to other targets or no snap , the snap target 
 mode will be retained when using the addon a second time).  The 3D cursor will move along with the vert
 to make the chosen position a bit clearer.  The old origin will remain visible during moving, this is
 perfectly normal.
@@ -47,8 +47,8 @@ Save as Default (Optional).
 bl_info = {
 	"name": "FastOrigin",
 	"author": "Gert De Roost",
-	"version": (0, 4, 0),
-	"blender": (2, 68, 0),
+	"version": (0, 4, 1),
+	"blender": (2, 6, 8),
 	"location": "View3D > Tools",
 	"description": "Set object origin with snapping.",
 	"warning": "",
@@ -61,36 +61,46 @@ bl_info = {
 import bpy
 from bpy_extras.view3d_utils import location_3d_to_region_2d
 import bmesh
-import bgl
-import blf
-from mathutils import *
+from bgl import glColor3f, glBegin, GL_POLYGON, glVertex2f, glEnd
+from mathutils import * 
 import time
 
 
+class FastScalePanel(bpy.types.Panel):
+	bl_label = "FastScale"
+	bl_space_type = 'VIEW_3D'
+	bl_region_type = 'TOOLS'
+	bl_category = 'Tools'
+
+	def draw(self, context):
+		self.layout.operator("mesh.fastscale")
+		self.layout.operator("object.fastorigin", text="Choose Origin")
+		
+		
 class FastOrigin(bpy.types.Operator):
 	bl_idname = "object.fastorigin"
 	bl_label = "Fast Origin"
 	bl_description = "Set object origin with snapping"
 	bl_options = {'REGISTER', 'UNDO'}
-
+	
 	@classmethod
 	def poll(cls, context):
 		obj = context.active_object
 		return (obj and obj.type == 'MESH')
 
 	def invoke(self, context, event):
-
+		
 		bpy.types.Scene.PreSelOff = bpy.props.BoolProperty(
-				name = "PreSelOff",
+				name = "PreSelOff", 
 				description = "Switch off PreSel during Straighten operation",
 				default = True)
-
+		
 		self.init_fastorigin(context)
-
+		
 		context.window_manager.modal_handler_add(self)
 
 		self._handle = bpy.types.SpaceView3D.draw_handler_add(self.redraw, (), 'WINDOW', 'POST_PIXEL')
-
+		
 		return {'RUNNING_MODAL'}
 
 
@@ -98,7 +108,7 @@ class FastOrigin(bpy.types.Operator):
 
 		if event.type in {'LEFTMOUSE', 'MIDDLEMOUSE', 'RIGHTMOUSE', 'WHEELDOWNMOUSE', 'WHEELUPMOUSE', 'G', 'X', 'Y', 'Z', 'MOUSEMOVE'}:
 			return {'PASS_THROUGH'}
-
+			
 		elif event.type in {'RET', 'NUMPAD_ENTER'}:
 			del bpy.types.Scene.PreSelOff
 			# Consolidate changes.
@@ -112,49 +122,30 @@ class FastOrigin(bpy.types.Operator):
 			bmesh.update_edit_mesh(self.mesh, destructive=True)
 			self.mesh.update()
 			self.bm.free()
+			self.snapelem = context.tool_settings.snap_element
+			self.snapstate = context.tool_settings.use_snap
 			context.tool_settings.snap_element = self.snapelsave
 			context.tool_settings.use_snap = self.snapstsave
 			bpy.ops.object.editmode_toggle()
 			bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
-			self.space3d.cursor_location = self.cursorsave
+			self.space3d.cursor_location = self.cursorsave			
 			if self.mode == 'EDIT':
 				bpy.ops.object.editmode_toggle()
 			bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
 			return {'FINISHED'}
-
-		elif event.type == 'ESC':
-			del bpy.types.Scene.PreSelOff
-			# Cancel
-			for v in self.vsellist:
-				v.select = True
-			for e in self.esellist:
-				e.select = True
-			for f in self.fsellist:
-				f.select = True
-			self.bm.verts.remove(self.originvert)
-			bmesh.update_edit_mesh(self.mesh, destructive=True)
-			self.mesh.update()
-			self.bm.free()
-			context.tool_settings.snap_element = self.snapelsave
-			context.tool_settings.use_snap = self.snapstsave
-			self.space3d.cursor_location = self.cursorsave
-			if self.mode == 'EDIT':
-				bpy.ops.object.editmode_toggle()
-			bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
-			return {'CANCELLED'}
-
+		
 		return {'RUNNING_MODAL'}
 
 
 	def init_fastorigin(self, context):
-
+	
 		for space in context.area.spaces:
 			if space.type == 'VIEW_3D':
 				self.space3d = space
 		self.selobj = context.active_object
 		self.mesh = self.selobj.data
-		self.region = context.region
-
+		self.area = context.area
+		
 		self.rv3ds = {}
 		for a in bpy.context.screen.areas:
 			if not(a.type == "VIEW_3D"):
@@ -165,12 +156,12 @@ class FastOrigin(bpy.types.Operator):
 						if not(r.type == "WINDOW"):
 							continue
 						self.rv3ds[r] = sp.region_3d
-
+		
 		self.mode = self.selobj.mode
 		if self.mode == 'OBJECT':
 			bpy.ops.object.editmode_toggle()
 		self.bm = bmesh.from_edit_mesh(self.mesh)
-
+		
 		self.vsellist = []
 		self.esellist = []
 		self.fsellist = []
@@ -183,10 +174,10 @@ class FastOrigin(bpy.types.Operator):
 		for f in self.bm.faces:
 			if f.select:
 				self.fsellist.append(f)
-
+			
 		self.snapelem = 'VERTEX'
 		self.snapstate = True
-
+		
 		self.snapelsave = context.tool_settings.snap_element
 		self.snapstsave = context.tool_settings.use_snap
 		context.tool_settings.snap_element = self.snapelem
@@ -200,10 +191,10 @@ class FastOrigin(bpy.types.Operator):
 		bmesh.update_edit_mesh(self.mesh, destructive=True)
 		self.mesh.update()
 		self.space3d.cursor_location = self.originvert.co[:]
-
-
+		
+				
 	def getscreencoords(self, vec, reg, rv3d):
-
+	
 		# calculate screencoords of given Vector
 		vec.rotate(self.selobj.matrix_world)
 		vec.rotate(self.selobj.matrix_world)
@@ -211,55 +202,38 @@ class FastOrigin(bpy.types.Operator):
 		return location_3d_to_region_2d(reg, rv3d, vec)
 
 
-
+	
 	def redraw(self):
-
+	
 		drawregion = bpy.context.region
-
+		
 		rv3d = self.rv3ds[drawregion]
 		vec = self.originvert.co.copy()
 		vec.rotate(self.selobj.matrix_world)
 		vec.rotate(self.selobj.matrix_world)
 		self.space3d.cursor_location =  vec * self.selobj.matrix_world + self.selobj.matrix_world.to_translation()
 
-		bgl.glColor3f(1.0, 1.0, 0)
-		bgl.glBegin(bgl.GL_POLYGON)
+		glColor3f(1.0, 1.0, 0)
+		glBegin(GL_POLYGON)
 		x, y = self.getscreencoords(Vector(self.originvert.co), drawregion, rv3d)
-		bgl.glVertex2f(x-2, y-2)
-		bgl.glVertex2f(x-2, y+2)
-		bgl.glVertex2f(x+2, y+2)
-		bgl.glVertex2f(x+2, y-2)
-		bgl.glEnd()
-
-		bgl.glColor3f(1, 1, 0.7)
-		bgl.glMatrixMode(bgl.GL_PROJECTION)
-		bgl.glLoadIdentity()
-		bgl.gluOrtho2D(0, self.region.width, 0, self.region.height)
-		bgl.glMatrixMode(bgl.GL_MODELVIEW)
-		bgl.glLoadIdentity()
-		blf.position(0, self.region.width/2 - 80, self.region.height - 20, 0)
-		blf.size(0, 12, 72)
-		blf.draw(0, "FastOrigin :  Enter confirms - ESC cancels")
-
+		glVertex2f(x-2, y-2)
+		glVertex2f(x-2, y+2)
+		glVertex2f(x+2, y+2)
+		glVertex2f(x+2, y-2)
+		glEnd()
 
-def panel_func(self, context):
-	self.layout.label(text="FastOrigin:")
-	self.layout.operator("object.fastorigin", text="Choose Origin")
 
 
 def register():
 	bpy.utils.register_module(__name__)
-	bpy.types.VIEW3D_PT_tools_meshedit.append(panel_func)
-	bpy.types.VIEW3D_PT_tools_objectmode.append(panel_func)
 
 
 def unregister():
 	bpy.utils.unregister_module(__name__)
-	bpy.types.VIEW3D_PT_tools_meshedit.remove(panel_func)
-	bpy.types.VIEW3D_PT_tools_objectmode.remove(panel_func)
+
 
 if __name__ == "__main__":
 	register()
 
 
-
+



More information about the Bf-extensions-cvs mailing list