Added an option to camera preset to include/exclude focal length from the preset
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 19 Feb 2014 12:18:02 +0000 (18:18 +0600)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 19 Feb 2014 12:18:02 +0000 (18:18 +0600)
Useful for cameras which have fixed focal length.

release/scripts/startup/bl_operators/presets.py

index ae6ec3946f15f0ebf39e4ab85618794e70d122a7..f1da0ff615d1267977387c154f32c3104aa4105a 100644 (file)
@@ -256,14 +256,26 @@ class AddPresetCamera(AddPresetBase, Operator):
         "cam = bpy.context.object.data"
     ]
 
-    preset_values = [
-        "cam.sensor_width",
-        "cam.sensor_height",
-        "cam.sensor_fit"
-    ]
-
     preset_subdir = "camera"
 
+    use_focal_length = BoolProperty(
+            name="Include Focal Length",
+            description="Include focal length into the preset",
+            options={'SKIP_SAVE'},
+            )
+
+    @property
+    def preset_values(self):
+        preset_values = [
+            "cam.sensor_width",
+            "cam.sensor_height",
+            "cam.sensor_fit"
+        ]
+        if self.use_focal_length:
+            preset_values.append("cam.lens")
+            preset_values.append("cam.lens_unit")
+        return preset_values
+
 
 class AddPresetSSS(AddPresetBase, Operator):
     """Add or remove a Subsurface Scattering Preset"""
@@ -398,18 +410,29 @@ class AddPresetTrackingCamera(AddPresetBase, Operator):
         "camera = bpy.context.edit_movieclip.tracking.camera"
     ]
 
-    preset_values = [
-        "camera.sensor_width",
-        "camera.units",
-        "camera.focal_length",
-        "camera.pixel_aspect",
-        "camera.k1",
-        "camera.k2",
-        "camera.k3"
-    ]
-
     preset_subdir = "tracking_camera"
 
+    use_focal_length = BoolProperty(
+            name="Include Focal Length",
+            description="Include focal length into the preset",
+            options={'SKIP_SAVE'},
+            default=True
+            )
+
+    @property
+    def preset_values(self):
+        preset_values = [
+            "camera.sensor_width",
+            "camera.pixel_aspect",
+            "camera.k1",
+            "camera.k2",
+            "camera.k3"
+        ]
+        if self.use_focal_length:
+            preset_values.append("camera.units")
+            preset_values.append("camera.focal_length")
+        return preset_values
+
 
 class AddPresetTrackingTrackColor(AddPresetBase, Operator):
     """Add or remove a Clip Track Color Preset"""