Changeset View
Standalone View
tracking_pies.py
| Context not available. | |||||
| import bpy | import bpy | ||||
| from bpy.types import Menu | from bpy.types import Menu | ||||
| from bpy.props import * | from bpy.props import FloatProperty | ||||
campbellbarton: This is bad practice and not allowed in our code, as for why - see:
http://stackoverflow. | |||||
| from mathutils import Vector | from mathutils import Vector | ||||
| ############ FUNCTIONS ################## | ############ FUNCTIONS ################## | ||||
| def log(*args): | def get_marker_coordinates_in_pixels(context, clip, track, frame_number): | ||||
Not Done Inline ActionsThese kinds of ad-hoc logging functions are useful for development, but for now better not add into releases. (python has logging module, currently we dont make use of it though, operators can report warnings, otherwise some print can be OK as long as not flooding the output, in that case better comment them and uncomment for development) campbellbarton: These kinds of ad-hoc logging functions are useful for development, but for now better not add… | |||||
| print(''.join(map(str, args))) | width, height = clip.size | ||||
| def get_marker_coordinates_in_pixels(context, track, frame_number): | |||||
| width, height = context.space_data.clip.size | |||||
| marker = track.markers.find_frame(frame_number) | marker = track.markers.find_frame(frame_number) | ||||
| return Vector((marker.co[0] * width, marker.co[1] * height)) | return Vector((marker.co[0] * width, marker.co[1] * height)) | ||||
Not Done Inline ActionsIf this is called a lot, probably better to get the size once and pass it in. (caller has size anyway) campbellbarton: If this is called a lot, probably better to get the size once and pass it in. (caller has size… | |||||
| def marker_velocity(context, track, frame): | def marker_velocity(context, clip, track, frame): | ||||
| marker_a = get_marker_coordinates_in_pixels(context, track, frame) | marker_a = get_marker_coordinates_in_pixels(context, clip, track, frame) | ||||
| marker_b = get_marker_coordinates_in_pixels(context, track, frame - 1) | marker_b = get_marker_coordinates_in_pixels(context, clip, track, frame - 1) | ||||
| return marker_a - marker_b | return marker_a - marker_b | ||||
| def filter_values(threshold, context): | |||||
| scene = bpy.context.scene | def filter_values(context, threshold): | ||||
| scene = context.scene | |||||
| frame_start = scene.frame_start | frame_start = scene.frame_start | ||||
| frame_end = scene.frame_end | frame_end = scene.frame_end | ||||
Not Done Inline Actionsno need for bpy.context (atm its basically same, but happens to be passed in as an arg) campbellbarton: no need for `bpy.context` (atm its basically same, but happens to be passed in as an arg) | |||||
| clip = context.space_data.clip | clip = context.space_data.clip | ||||
| length = clip.frame_duration | length = clip.frame_duration | ||||
| width, height = clip.size | |||||
| log('Clip size:', Vector((width, height))) | |||||
| log('Clean from frame', frame_start, 'to', frame_end, ';', length, 'frames') | |||||
| bpy.ops.clip.clean_tracks(frames=10, action='DELETE_TRACK') | bpy.ops.clip.clean_tracks(frames=10, action='DELETE_TRACK') | ||||
| tracks_to_clean = [] | tracks_to_clean = [] | ||||
| for frame in range(frame_start, frame_end): | for frame in range(frame_start, frame_end): | ||||
campbellbartonAuthorUnsubmitted Not Done Inline ActionsBlenders start/end frames are inclusive. rendering frames (1-10) will render frame 1 and frame 10. Python's range doesn't include the last value, so you should probably do frame_end + 1 to include the last frame. campbellbarton: Blenders start/end frames are inclusive. rendering frames (1-10) will render frame 1 and frame… | |||||
| log('Frame: ', frame) | |||||
| # TODO(sebastian_k): What about frame_start = 0? | |||||
| # Find tracks with markers in both this frame and the previous one. | # Find tracks with markers in both this frame and the previous one. | ||||
| relevant_tracks = [track for track in clip.tracking.tracks | relevant_tracks = [track for track in clip.tracking.tracks | ||||
| Context not available. | |||||
| track.markers.find_frame(frame - 1)] | track.markers.find_frame(frame - 1)] | ||||
| if not relevant_tracks: | if not relevant_tracks: | ||||
| # log('Skipping frame; no tracks with markers in this and the previous frame') | |||||
| continue | continue | ||||
| # Get average velocity and deselect track. | # Get average velocity and deselect track. | ||||
Not Done Inline Actionsif speed is a concern, you could cache this info, your getting it twice every time. once to check they exist and again later. def track_markers(track):
marker_curr = track.markers.find_frame(frame)
if marker_curr:
marker_prev = track.markers.find_frame(frame - 1)
if marker_prev:
return track, marker_curr, marker_prev
return None
relevant_tracks = filter(None, (track_markers(track) for track in clip.tracking.tracks))... you could convert to a list too if needed list(filter(...)) campbellbarton: if speed is a concern, you could cache this info, your getting it twice every time. once to… | |||||
| average_velocity = Vector().to_2d() | average_velocity = Vector().to_2d() | ||||
campbellbartonAuthorUnsubmitted Not Done Inline ActionsJust Vector((0.0, 0.0)) - no need to convert 3d -> 2d campbellbarton: Just `Vector((0.0, 0.0))` - no need to convert 3d -> 2d | |||||
| for track in relevant_tracks: | for track in relevant_tracks: | ||||
| track.select = False | track.select = False | ||||
| average_velocity += marker_velocity(context, track, frame) | average_velocity += marker_velocity(context, clip, track, frame) | ||||
| average_velocity = average_velocity / float(len(relevant_tracks)) | if len(relevant_tracks)>=1: | ||||
| average_velocity = average_velocity / float(len(relevant_tracks)) | |||||
campbellbartonAuthorUnsubmitted Not Done Inline Actionsno need to convert to float (thats py2), also, should have spaces around operators. campbellbarton: no need to convert to `float` (thats py2), also, should have spaces around operators. | |||||
| # log('Average velocity', average_velocity.magnitude) | |||||
| # Then find all markers that behave differently than the average. | # Then find all markers that behave differently than the average. | ||||
| for track in relevant_tracks: | for track in relevant_tracks: | ||||
| track_velocity = marker_velocity(context, track, frame) | track_velocity = marker_velocity(context, clip, track, frame) | ||||
| distance = (average_velocity - track_velocity).magnitude | distance = (average_velocity - track_velocity).magnitude | ||||
| if distance > threshold and not track in tracks_to_clean: | if distance > threshold and not track in tracks_to_clean: | ||||
| log('To clean:' , track.name, | |||||
| ', average velocity:', average_velocity.magnitude, | |||||
| 'distance:', distance) | |||||
| tracks_to_clean.append(track) | tracks_to_clean.append(track) | ||||
| for track in tracks_to_clean: | for track in tracks_to_clean: | ||||
Not Done Inline ActionsBetter use getattr/setattr here, very similar example: campbellbarton: Better use getattr/setattr here, very similar example:
https://developer.blender. | |||||
| Context not available. | |||||
| bl_idname="clip.filter_tracks" | bl_idname="clip.filter_tracks" | ||||
| bl_options = {'UNDO', 'REGISTER'} | bl_options = {'UNDO', 'REGISTER'} | ||||
| track_threshold = bpy.props.FloatProperty \ | track_threshold = FloatProperty( | ||||
| ( | name="Track Threshold", | ||||
| name = "Track Threshold", | description="Filter Threshold to select problematic track", | ||||
| description = "Filter Threshold", | default=5.0, | ||||
| default = 5.0 | ) | ||||
| ) | |||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
Not Done Inline Actions*super-picky* 8 spaces indent (extra 4, see other scripts). campbellbarton: *super-picky* 8 spaces indent (extra 4, see other scripts). | |||||
| Context not available. | |||||
| return (space.type == 'CLIP_EDITOR') and space.clip | return (space.type == 'CLIP_EDITOR') and space.clip | ||||
| def execute(self, context): | def execute(self, context): | ||||
| num_tracks = filter_values(self.track_threshold, context) | num_tracks = filter_values(context, self.track_threshold) | ||||
Not Done Inline ActionsStyle - convention here is: frame_start = IntProperty(
name="Start Frame",
description="Start frame for baking",
min=0, max=300000,
default=1,
)campbellbarton: Style - convention here is:
frame_start = IntProperty(
name="Start Frame"… | |||||
| self.report({"INFO"}, "Identified %d problematic tracks" % num_tracks) | self.report({'INFO'}, "Identified %d problematic tracks" % num_tracks) | ||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
Not Done Inline Actionsalso pep8, so spaces around keyword = campbellbarton: also pep8, so spaces around keyword `=` | |||||
| Context not available. | |||||
| layout = self.layout | layout = self.layout | ||||
| pie = layout.menu_pie() | pie = layout.menu_pie() | ||||
| pie.operator("clip.bundles_to_mesh", icon="MESH_DATA") | pie.operator("clip.bundles_to_mesh", icon='MESH_DATA') | ||||
| pie.operator("clip.track_to_empty", icon="EMPTY_DATA") | pie.operator("clip.track_to_empty", icon='EMPTY_DATA') | ||||
| Context not available. | |||||
| layout = self.layout | layout = self.layout | ||||
| pie = layout.menu_pie() | pie = layout.menu_pie() | ||||
Not Done Inline Actionsfor enums convention here is to use single quotes. Convention is followed only in some places. campbellbarton: for enums convention here is to use single quotes. Convention is followed only in some places. | |||||
| if space.clip.use_proxy: | pie.prop( | ||||
| pie.prop(space.clip, "use_proxy", text="Use Proxy (On)", icon="CHECKBOX_HLT") | space.clip, | ||||
| else: | "use_brute", | ||||
| pie.prop(space.clip, "use_proxy", text="Use Proxy (Off)", icon="CHECKBOX_DEHLT") | text="Use Proxy", | ||||
| icon=('CHECKBOX_HLT' if space.clip.use_proxy else 'CHECKBOX_DEHLT') | |||||
| ) | |||||
| pie.prop(space.clip_user, "proxy_render_size", expand=True) | pie.prop(space.clip_user, "proxy_render_size", expand=True) | ||||
| class CLIP_PIE_display_pie(Menu): | class CLIP_PIE_display_pie(Menu): | ||||
| # Display Options | # Display Options | ||||
| bl_label = "Marker Display" | bl_label = "Marker Display" | ||||
| Context not available. | |||||
| layout = self.layout | layout = self.layout | ||||
| pie = layout.menu_pie() | pie = layout.menu_pie() | ||||
| pie.prop(space, "show_names", text="Show Track Info", icon="WORDWRAP_ON") | pie.prop(space, "show_names", text="Show Track Info", icon='WORDWRAP_ON') | ||||
| pie.prop(space, "show_disabled", text="Show Disabled Tracks", icon="VISIBLE_IPO_ON") | pie.prop(space, "show_disabled", text="Show Disabled Tracks", icon='VISIBLE_IPO_ON') | ||||
| pie.prop(space, "show_marker_search", text="Display Search Area", icon="VIEWZOOM") | pie.prop(space, "show_marker_search", text="Display Search Area", icon='VIEWZOOM') | ||||
| pie.prop(space, "show_marker_pattern", text="Display Pattern Area", icon="BORDERMOVE") | pie.prop(space, "show_marker_pattern", text="Display Pattern Area", icon='BORDERMOVE') | ||||
| Context not available. | |||||
| def draw(self, context): | def draw(self, context): | ||||
| clip = context.space_data.clip | clip = context.space_data.clip | ||||
| settings = clip.tracking.settings | settings = clip.tracking.settings | ||||
| active = clip.tracking.tracks.active | track_active = clip.tracking.tracks.active | ||||
| layout = self.layout | layout = self.layout | ||||
| pie = layout.menu_pie() | pie = layout.menu_pie() | ||||
| op = pie.operator("wm.context_set_enum", text="Loc", icon="OUTLINER_DATA_EMPTY") | prop = pie.operator("wm.context_set_enum", text="Loc", icon='OUTLINER_DATA_EMPTY') | ||||
| op.data_path="space_data.clip.tracking.tracks.active.motion_model" | prop.data_path="space_data.clip.tracking.tracks.active..motion_model" | ||||
| op.value="Loc" | prop.value="Loc" | ||||
| op = pie.operator("wm.context_set_enum", text="Affine", icon="OUTLINER_DATA_LATTICE") | prop = pie.operator("wm.context_set_enum", text="Affine", icon='OUTLINER_DATA_LATTICE') | ||||
| op.data_path="space_data.clip.tracking.tracks.active.motion_model" | prop.data_path="space_data.clip.tracking.tracks.active..motion_model" | ||||
| op.value="Affine" | prop.value="Affine" | ||||
| pie.operator("clip.track_settings_to_track", icon="COPYDOWN") | pie.operator("clip.track_settings_to_track", icon='COPYDOWN') | ||||
Not Done Inline ActionsThis variable isn't used below (referencing clip.tracking.tracks.active still) Also, could be a bit more verbose track_active, for eg. since blender has lots of different active data. campbellbarton: This variable isn't used below (referencing `clip.tracking.tracks.active` still)
Also, could… | |||||
| pie.operator("clip.track_settings_as_default", icon="SETTINGS") | pie.operator("clip.track_settings_as_default", icon='SETTINGS') | ||||
| if clip.tracking.tracks.active.use_normalization: | pie.prop( | ||||
| pie.prop(active, "use_normalization", text="Normalization (ON)", icon="CHECKBOX_HLT") | track_active, | ||||
| else: | "use_normalization", | ||||
Not Done Inline Actionsop name is misleading, This is in fact operator properties, in Blender's code we use the name props campbellbarton: `op` name is misleading, This is in fact operator properties, in Blender's code we use the name… | |||||
| pie.prop(active, "use_normalization", text="Normalization (OFF", icon="CHECKBOX_DEHLT") | text="Normalization", | ||||
| if clip.tracking.tracks.active.use_brute: | icon=('CHECKBOX_HLT' if track_active.use_normalization else 'CHECKBOX_DEHLT') | ||||
| pie.prop(active, "use_brute", text="Prepass (ON)", icon="CHECKBOX_HLT") | ) | ||||
| else: | pie.prop( | ||||
| pie.prop(active, "use_brute", text="Prepass (OFF)", icon="CHECKBOX_DEHLT") | track_active, | ||||
| "use_brute", | |||||
| if clip.tracking.tracks.active.use_blue_channel: | text="Use Brute Force", | ||||
| pie.prop(active, "use_blue_channel", text="Blue Channel (ON)", icon="CHECKBOX_HLT") | icon=('CHECKBOX_HLT' if track_active.use_brute else 'CHECKBOX_DEHLT') | ||||
| ) | |||||
| pie.prop( | |||||
Not Done Inline ActionsWe dont have strict conventions here, but would be inclined not to have both text & checkbox... eg: pie.prop( active, "use_normalization", text="Normalization", icon='CHECKBOX_HLT' if active.use_normalization else 'CHECKBOX_DEHLT', ) campbellbarton: We dont have strict conventions here, but would be inclined not to have both text & checkbox... | |||||
| track_active, | |||||
| "use_blue_channel", | |||||
| text="Blue Channel", | |||||
Not Done Inline Actionsmissing ) :) campbellbarton: missing `)` :) | |||||
| icon=('CHECKBOX_HLT' if track_active.use_blue_channel else 'CHECKBOX_DEHLT') | |||||
| ) | |||||
| if track_active.pattern_match == "PREV_FRAME": | |||||
| prop = pie.operator("wm.context_set_enum", text="Match Previous", icon='KEYINGSET') | |||||
| prop.data_path="space_data.clip.tracking.tracks.active.pattern_match" | |||||
| prop.value='KEYFRAME' | |||||
| else: | else: | ||||
| pie.prop(active, "use_blue_channel", text="Blue Channel (OFF)", icon="CHECKBOX_DEHLT") | prop = pie.operator("wm.context_set_enum", text="Match Keyframe", icon='KEY_HLT') | ||||
| prop.data_path="space_data.clip.tracking.tracks.active.pattern_match" | |||||
| if active.pattern_match == "PREV_FRAME": | prop.value='PREV_FRAME' | ||||
| op = pie.operator("wm.context_set_enum", text="Match Previous", icon="KEYINGSET") | |||||
| op.data_path="space_data.clip.tracking.tracks.active.pattern_match" | |||||
| op.value="KEYFRAME" | |||||
| else: | |||||
| op = pie.operator("wm.context_set_enum", text="Match Keyframe", icon="KEY_HLT") | |||||
| op.data_path="space_data.clip.tracking.tracks.active.pattern_match" | |||||
| op.value="PREV_FRAME" | |||||
| Context not available. | |||||
| layout = self.layout | layout = self.layout | ||||
| pie = layout.menu_pie() | pie = layout.menu_pie() | ||||
| prop = pie.operator("clip.track_markers", icon="PLAY_REVERSE") | prop = pie.operator("clip.track_markers", icon='PLAY_REVERSE') | ||||
| prop.backwards = True | prop.backwards = True | ||||
| prop.sequence = True | prop.sequence = True | ||||
| prop = pie.operator("clip.track_markers", icon="PLAY") | prop = pie.operator("clip.track_markers", icon='PLAY') | ||||
| prop.backwards = False | prop.backwards = False | ||||
| prop.sequence = True | prop.sequence = True | ||||
| pie.operator("clip.disable_markers", icon="RESTRICT_VIEW_ON") | pie.operator("clip.disable_markers", icon='RESTRICT_VIEW_ON') | ||||
| pie.operator("clip.detect_features", icon="ZOOM_SELECTED") | pie.operator("clip.detect_features", icon='ZOOM_SELECTED') | ||||
| pie.operator("clip.clear_track_path", icon="BACK").action="UPTO" | pie.operator("clip.clear_track_path", icon='BACK').action='UPTO' | ||||
| pie.operator("clip.clear_track_path", icon="FORWARD").action="REMAINED" | pie.operator("clip.clear_track_path", icon='FORWARD').action='REMAINED' | ||||
| pie.operator("clip.refine_markers", icon="LOOP_BACK").backwards=True | pie.operator("clip.refine_markers", icon='LOOP_BACK').backwards=True | ||||
| pie.operator("clip.refine_markers", icon="LOOP_FORWARDS").backwards=False | pie.operator("clip.refine_markers", icon='LOOP_FORWARDS').backwards=False | ||||
Not Done Inline Actionsspace around = campbellbarton: space around `=` | |||||
| Context not available. | |||||
| layout = self.layout | layout = self.layout | ||||
| pie = layout.menu_pie() | pie = layout.menu_pie() | ||||
| pie.operator("clip.reload", text="Reload Footage", icon="FILE_REFRESH") | pie.operator("clip.reload", text="Reload Footage", icon='FILE_REFRESH') | ||||
| pie.operator("clip.prefetch", text="Prefetch Footage", icon="LOOP_FORWARDS") | pie.operator("clip.prefetch", text="Prefetch Footage", icon='LOOP_FORWARDS') | ||||
| pie.prop(space, "use_mute_footage", text="Mute Footage", icon="MUTE_IPO_ON") | pie.prop(space, "use_mute_footage", text="Mute Footage", icon='MUTE_IPO_ON') | ||||
| if space.clip_user.use_render_undistorted: | pie.prop( | ||||
| pie.prop(space.clip_user, "use_render_undistorted", text="Render Undistorted (ON)", icon="CHECKBOX_HLT") | space.clip_user, | ||||
| else: | "use_render_undistorted", | ||||
| pie.prop(space.clip_user, "use_render_undistorted", text="Render Undistorted (OFF)", icon="CHECKBOX_DEHLT") | text="Render Undistorted", | ||||
| icon=('CHECKBOX_HLT' if space.clip_user.use_render_undistorted else 'CHECKBOX_DEHLT') | |||||
| pie.prop(space, "lock_selection", text="Lock", icon="LOCKED") | ) | ||||
| pie.operator("wm.call_menu_pie", text="Marker Display", icon='PLUS').name = "CLIP_PIE_display_pie" | pie.operator("clip.set_scene_frames", text="Set Scene Frames", icon='SCENE_DATA') | ||||
| pie.operator("wm.call_menu_pie", text="Proxy", icon='PLUS').name = "CLIP_PIE_proxy_pie" | pie.operator("wm.call_menu_pie", text="Marker Display", icon='PLUS').name="CLIP_PIE_display_pie" | ||||
| pie.operator("clip.set_active_clip", icon="CLIP") | pie.operator("clip.set_active_clip", icon='CLIP') | ||||
| pie.operator("wm.call_menu_pie", text="Proxy", icon='PLUS').name="CLIP_PIE_proxy_pie" | |||||
Not Done Inline Actionsspace around = (theres more below too) campbellbarton: space around `=` (theres more below too) | |||||
| Context not available. | |||||
| layout = self.layout | layout = self.layout | ||||
| pie = layout.menu_pie() | pie = layout.menu_pie() | ||||
| pie.operator("clip.create_plane_track", icon="MESH_PLANE") | pie.operator("clip.create_plane_track", icon='MESH_PLANE') | ||||
| pie.operator("clip.solve_camera", text="Solve Camera", icon="OUTLINER_OB_CAMERA") | pie.operator("clip.solve_camera", text="Solve Camera", icon='OUTLINER_OB_CAMERA') | ||||
| pie.operator("wm.call_menu_pie", text="Refinement", icon='CAMERA_DATA').name = "CLIP_PIE_refine_pie" | pie.operator("wm.call_menu_pie", text="Refinement", icon='CAMERA_DATA').name="CLIP_PIE_refine_pie" | ||||
| if settings.use_tripod_solver: | pie.prop( | ||||
| pie.prop(settings, "use_tripod_solver", text="Tripod Solver (ON)", icon="RESTRICT_RENDER_OFF") | settings, | ||||
| else: | "use_tripod_solver", | ||||
| pie.prop(settings, "use_tripod_solver", text="Tripod Solver (OFF)", icon="RESTRICT_RENDER_ON") | text="Tripod Solver", | ||||
| icon=('RESTRICT_RENDER_OFF' if settings.use_tripod_solver else 'RESTRICT_RENDER_ON') | |||||
| ) | |||||
| pie.operator("clip.set_solver_keyframe", text="Set Keyframe A", icon="KEY_HLT").keyframe='KEYFRAME_A' | pie.operator("clip.set_solver_keyframe", text="Set Keyframe A", icon='KEY_HLT').keyframe='KEYFRAME_A' | ||||
| pie.operator("clip.set_solver_keyframe", text="Set Keyframe B", icon="KEY_HLT").keyframe='KEYFRAME_B' | pie.operator("clip.set_solver_keyframe", text="Set Keyframe B", icon='KEY_HLT').keyframe='KEYFRAME_B' | ||||
| op= pie.operator("clip.clean_tracks", icon="STICKY_UVS_DISABLE") | prop = pie.operator("clip.clean_tracks", icon='STICKY_UVS_DISABLE') | ||||
| pie.operator("clip.filter_tracks", icon="FILTER") | pie.operator("clip.filter_tracks", icon='FILTER') | ||||
| op.frames=15 | prop.frames = 15 | ||||
| op.error=2 | prop.error = 2 | ||||
| class CLIP_PIE_reconstruction_pie(Menu): | class CLIP_PIE_reconstruction_pie(Menu): | ||||
| Context not available. | |||||
| layout = self.layout | layout = self.layout | ||||
| pie = layout.menu_pie() | pie = layout.menu_pie() | ||||
| pie.operator("clip.set_viewport_background", text="Set Viewport Background", icon="SCENE_DATA") | pie.operator("clip.set_viewport_background", text="Set Viewport Background", icon='SCENE_DATA') | ||||
| pie.operator("clip.setup_tracking_scene", text="Setup Tracking Scene", icon="SCENE_DATA") | pie.operator("clip.setup_tracking_scene", text="Setup Tracking Scene", icon='SCENE_DATA') | ||||
| pie.operator("clip.set_plane", text="Setup Floor", icon="MESH_PLANE") | pie.operator("clip.set_plane", text="Setup Floor", icon='MESH_PLANE') | ||||
| pie.operator("clip.set_origin", text="Set Origin", icon="MANIPUL") | pie.operator("clip.set_origin", text="Set Origin", icon='MANIPUL') | ||||
| pie.operator("clip.set_axis", text="Set X Axis", icon="AXIS_FRONT").axis="X" | pie.operator("clip.set_axis", text="Set X Axis", icon='AXIS_FRONT').axis="X" | ||||
| pie.operator("clip.set_axis", text="Set Y Axis", icon="AXIS_SIDE").axis="Y" | pie.operator("clip.set_axis", text="Set Y Axis", icon='AXIS_SIDE').axis="Y" | ||||
| pie.operator("clip.set_scale", text="Set Scale", icon="ARROW_LEFTRIGHT") | pie.operator("clip.set_scale", text="Set Scale", icon='ARROW_LEFTRIGHT') | ||||
| pie.operator("wm.call_menu_pie", text="Reconstruction", icon='MESH_DATA').name = "CLIP_PIE_geometry_reconstruction" | pie.operator("wm.call_menu_pie", text="Reconstruction", icon='MESH_DATA').name="CLIP_PIE_geometry_reconstruction" | ||||
| class CLIP_PIE_timecontrol_pie(Menu): | class CLIP_PIE_timecontrol_pie(Menu): | ||||
| Context not available. | |||||
| layout = self.layout | layout = self.layout | ||||
| pie = layout.menu_pie() | pie = layout.menu_pie() | ||||
| pie.operator("screen.frame_jump", text="Jump to Startframe", icon="TRIA_LEFT").end=False | pie.operator("screen.frame_jump", text="Jump to Startframe", icon='TRIA_LEFT').end=False | ||||
| pie.operator("screen.frame_jump", text="Jump to Endframe", icon="TRIA_RIGHT").end=True | pie.operator("screen.frame_jump", text="Jump to Endframe", icon='TRIA_RIGHT').end=True | ||||
| pie.operator("clip.frame_jump", text="Start of Track", icon="REW").position="PATHSTART" | pie.operator("clip.frame_jump", text="Start of Track", icon='REW').position="PATHSTART" | ||||
| pie.operator("clip.frame_jump", text="End of Track", icon="FF").position="PATHEND" | pie.operator("clip.frame_jump", text="End of Track", icon='FF').position="PATHEND" | ||||
| pie.operator("screen.animation_play", text="Playback Backwards", icon="PLAY_REVERSE").reverse=True | pie.operator("screen.animation_play", text="Playback Backwards", icon='PLAY_REVERSE').reverse=True | ||||
| pie.operator("screen.animation_play", text="Playback Forwards", icon="PLAY").reverse=False | pie.operator("screen.animation_play", text="Playback Forwards", icon='PLAY').reverse=False | ||||
| pie.operator("screen.frame_offset", text="Previous Frame", icon="TRIA_LEFT").delta=-1 | pie.operator("screen.frame_offset", text="Previous Frame", icon='TRIA_LEFT').delta=-1 | ||||
| pie.operator("screen.frame_offset", text="Next Frame", icon="TRIA_RIGHT").delta=1 | pie.operator("screen.frame_offset", text="Next Frame", icon='TRIA_RIGHT').delta=1 | ||||
| class CLIP_PT_filter_tracks(bpy.types.Panel): | |||||
| bl_label = "Filter Tracks" | |||||
| bl_idname = "clip.filter_track_panel" | |||||
| bl_space_type = "CLIP_EDITOR" | |||||
| bl_region_type = "TOOLS" | |||||
| bl_category = "Track" | |||||
| def draw(self, context): | |||||
| scene = context.scene | |||||
| layout = self.layout | |||||
| layout.operator("clip.filter_tracks") | |||||
| layout.prop(scene, "track_threshold") | |||||
| ########## register ############ | ########## register ############ | ||||
| classes = ( | |||||
| CLIP_OT_set_active_clip, | |||||
| CLIP_OT_filter_tracks, | |||||
| CLIP_OT_track_settings_to_track, | |||||
| CLIP_PIE_geometry_reconstruction, | |||||
| CLIP_PIE_tracking_pie, | |||||
| CLIP_PIE_display_pie, | |||||
| CLIP_PIE_proxy_pie, | |||||
| CLIP_PIE_marker_pie, | |||||
| CLIP_PIE_solver_pie, | |||||
| CLIP_PIE_refine_pie, | |||||
| CLIP_PIE_reconstruction_pie, | |||||
| CLIP_PIE_clipsetup_pie, | |||||
| CLIP_PIE_timecontrol_pie, | |||||
| ) | |||||
| def register(): | def register(): | ||||
| bpy.utils.register_class(CLIP_OT_set_active_clip) | for cls in classes: | ||||
Not Done Inline Actionsin this case prefer to have a class list. campbellbarton: in this case prefer to have a class list.
See: https://developer.blender. | |||||
| bpy.utils.register_class(CLIP_OT_filter_tracks) | bpy.utils.register_class(cls) | ||||
| bpy.utils.register_class(CLIP_OT_track_settings_to_track) | |||||
| bpy.utils.register_class(CLIP_PIE_geometry_reconstruction) | |||||
| bpy.utils.register_class(CLIP_PIE_tracking_pie) | |||||
| bpy.utils.register_class(CLIP_PIE_display_pie) | |||||
| bpy.utils.register_class(CLIP_PIE_proxy_pie) | |||||
| bpy.utils.register_class(CLIP_PIE_marker_pie) | |||||
| bpy.utils.register_class(CLIP_PIE_solver_pie) | |||||
| bpy.utils.register_class(CLIP_PIE_refine_pie) | |||||
| bpy.utils.register_class(CLIP_PIE_reconstruction_pie) | |||||
| bpy.utils.register_class(CLIP_PIE_clipsetup_pie) | |||||
| bpy.utils.register_class(CLIP_PIE_timecontrol_pie) | |||||
| bpy.utils.register_class(CLIP_PT_filter_tracks) | |||||
| track_threshold = bpy.props.FloatProperty \ | |||||
| ( | |||||
| name = "Track Threshold", | |||||
| description = "Filter Threshold", | |||||
| default = 5.0 | |||||
| ) | |||||
| wm = bpy.context.window_manager | wm = bpy.context.window_manager | ||||
| km = wm.keyconfigs.addon.keymaps.new(name='Clip', space_type='CLIP_EDITOR') | km = wm.keyconfigs.addon.keymaps.new(name='Clip', space_type='CLIP_EDITOR') | ||||
| kmi = km.keymap_items.new('wm.call_menu_pie', 'Q', 'PRESS').properties.name = "clip.marker_pie" | kmi = km.keymap_items.new('wm.call_menu_pie', 'Q', 'PRESS').properties.name="clip.marker_pie" | ||||
campbellbartonAuthorUnsubmitted Not Done Inline ActionsSpaces should have been kept around = here, these aren't keyword args. campbellbarton: Spaces should have been kept around `=` here, //these aren't keyword args//. | |||||
| kmi = km.keymap_items.new('wm.call_menu_pie', 'W', 'PRESS').properties.name = "clip.clipsetup_pie" | kmi = km.keymap_items.new('wm.call_menu_pie', 'W', 'PRESS').properties.name="clip.clipsetup_pie" | ||||
| kmi = km.keymap_items.new('wm.call_menu_pie', 'E', 'PRESS').properties.name = "clip.tracking_pie" | kmi = km.keymap_items.new('wm.call_menu_pie', 'E', 'PRESS').properties.name="clip.tracking_pie" | ||||
| kmi = km.keymap_items.new('wm.call_menu_pie', 'S', 'PRESS', shift=True).properties.name = "clip.solver_pie" | kmi = km.keymap_items.new('wm.call_menu_pie', 'S', 'PRESS', shift=True).properties.name="clip.solver_pie" | ||||
| kmi = km.keymap_items.new('wm.call_menu_pie', 'W', 'PRESS', shift=True).properties.name = "clip.reconstruction_pie" | kmi = km.keymap_items.new('wm.call_menu_pie', 'W', 'PRESS', shift=True).properties.name="clip.reconstruction_pie" | ||||
| km = wm.keyconfigs.addon.keymaps.new(name='Frames') | km = wm.keyconfigs.addon.keymaps.new(name='Frames') | ||||
| kmi = km.keymap_items.new('wm.call_menu_pie', 'A', 'PRESS', oskey=True).properties.name = "clip.timecontrol_pie" | kmi = km.keymap_items.new('wm.call_menu_pie', 'A', 'PRESS', oskey=True).properties.name="clip.timecontrol_pie" | ||||
| def unregister(): | def unregister(): | ||||
| bpy.utils.unregister_class(CLIP_OT_set_active_clip) | for cls in classes: | ||||
| bpy.utils.unregister_class(CLIP_OT_filter_tracks) | bpy.utils.unregister_class(cls) | ||||
| bpy.utils.unregister_class(CLIP_OT_track_settings_to_track) | |||||
| bpy.utils.unregister_class(CLIP_PIE_geometry_reconstruction) | |||||
| bpy.utils.unregister_class(CLIP_PIE_tracking_pie) | |||||
| bpy.utils.unregister_class(CLIP_PIE_proxy_pie) | |||||
| bpy.utils.unregister_class(CLIP_PIE_display_pie) | |||||
| bpy.utils.unregister_class(CLIP_PIE_marker_pie) | |||||
| bpy.utils.unregister_class(CLIP_PIE_clipsetup_pie) | |||||
| bpy.utils.unregister_class(CLIP_PIE_solver_pie) | |||||
| bpy.utils.unregister_class(CLIP_PIE_refine_pie) | |||||
| bpy.utils.unregister_class(CLIP_PIE_reconstruction_pie) | |||||
| bpy.utils.unregister_class(CLIP_PIE_timecontrol_pie) | |||||
| bpy.utils.unregister_class(CLIP_PT_filter_tracks) | |||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||
| Context not available. | |||||
This is bad practice and not allowed in our code, as for why - see:
http://stackoverflow.com/a/2386740/432509