~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to release/scripts/templates/operator_modal_view3d.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
from mathutils import Vector
3
3
from bpy.props import FloatVectorProperty
4
4
 
 
5
 
5
6
class ViewOperator(bpy.types.Operator):
6
7
    '''Translate the view using mouse events.'''
7
8
    bl_idname = "view3d.modal_operator"
8
9
    bl_label = "Simple View Operator"
9
10
 
10
 
    offset = FloatVectorProperty(name="Offset", size=3)
11
 
 
 
11
    offset = FloatVectorProperty(
 
12
            name="Offset",
 
13
            size=3,
 
14
            )
12
15
 
13
16
    def execute(self, context):
14
17
        v3d = context.space_data
15
18
        rv3d = v3d.region_3d
16
19
 
17
 
        rv3d.view_location = self._initial_location + Vector(self.properties.offset)
 
20
        rv3d.view_location = self._initial_location + Vector(self.offset)
18
21
 
19
22
    def modal(self, context, event):
20
23
        v3d = context.space_data
21
24
        rv3d = v3d.region_3d
22
25
 
23
26
        if event.type == 'MOUSEMOVE':
24
 
            self.properties.offset = (self._initial_mouse - Vector((event.mouse_x, event.mouse_y, 0.0))) * 0.02
 
27
            self.offset = (self._initial_mouse - Vector((event.mouse_x, event.mouse_y, 0.0))) * 0.02
25
28
            self.execute(context)
 
29
            context.area.header_text_set("Offset %.4f %.4f %.4f" % tuple(self.offset))
26
30
 
27
31
        elif event.type == 'LEFTMOUSE':
 
32
            context.area.header_text_set()
28
33
            return {'FINISHED'}
29
34
 
30
 
        elif event.type in ('RIGHTMOUSE', 'ESC'):
 
35
        elif event.type in {'RIGHTMOUSE', 'ESC'}:
31
36
            rv3d.view_location = self._initial_location
 
37
            context.area.header_text_set()
32
38
            return {'CANCELLED'}
33
39
 
34
40
        return {'RUNNING_MODAL'}
39
45
            v3d = context.space_data
40
46
            rv3d = v3d.region_3d
41
47
 
42
 
            context.manager.add_modal_handler(self)
 
48
            context.window_manager.modal_handler_add(self)
43
49
 
44
50
            if rv3d.view_perspective == 'CAMERA':
45
51
                rv3d.view_perspective = 'PERSP'
53
59
            return {'CANCELLED'}
54
60
 
55
61
 
56
 
bpy.types.register(ViewOperator)
 
62
def register():
 
63
    bpy.utils.register_class(ViewOperator)
 
64
 
 
65
 
 
66
def unregister():
 
67
    bpy.utils.unregister_class(ViewOperator)
 
68
 
 
69
 
 
70
if __name__ == "__main__":
 
71
    register()