lfCamera &lfCamera::operator = (const lfCamera &other) { lf_free (Maker); Maker = lf_mlstr_dup (other.Maker); lf_free (Model); Model = lf_mlstr_dup (other.Model); lf_free (Variant); Variant = lf_mlstr_dup (other.Variant); _lf_setstr (&Mount, other.Mount); CropFactor = other.CropFactor; return *this; }
void lfCamera::SetMount (const char *val) { _lf_setstr (&Mount, val); }
static void _xml_start_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer user_data, GError **error) { int i; lfParserData *pd = (lfParserData *)user_data; if (pd->stack_depth >= sizeof (pd->stack) / sizeof (pd->stack [0])) { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "<%s>: very deeply nested element!\n", element_name); return; } const gchar *ctx = NULL; if (pd->stack_depth) ctx = pd->stack [pd->stack_depth - 1]; pd->stack [pd->stack_depth++] = element_name; if (!strcmp (element_name, "lensdatabase")) { if (ctx) { bad_ctx: g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "Inappropiate context for <%s>!\n", element_name); return; } chk_no_attrs: if (attribute_names [0]) { g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, "The <%s> element cannot have any attributes!\n", element_name); return; } } else if (!strcmp (element_name, "mount")) { if (ctx && !strcmp (ctx, "lensdatabase")) { pd->mount = new lfMount (); goto chk_no_attrs; } else if (ctx && (!strcmp (ctx, "camera") || !strcmp (ctx, "lens"))) goto chk_no_attrs; else goto bad_ctx; } else if (!strcmp (element_name, "camera")) { if (!ctx || strcmp (ctx, "lensdatabase")) goto bad_ctx; pd->camera = new lfCamera (); goto chk_no_attrs; } else if (!strcmp (element_name, "lens")) { if (!ctx || strcmp (ctx, "lensdatabase")) goto bad_ctx; pd->lens = new lfLens (); pd->lens->Type = LF_RECTILINEAR; goto chk_no_attrs; } else if (!strcmp (element_name, "focal")) { if (!ctx || strcmp (ctx, "lens") || !pd->lens) goto bad_ctx; for (i = 0; attribute_names [i]; i++) if (!strcmp (attribute_names [i], "min")) pd->lens->MinFocal = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "max")) pd->lens->MaxFocal = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "value")) pd->lens->MinFocal = pd->lens->MaxFocal = atof (attribute_values [i]); else goto bad_attr; } else if (!strcmp (element_name, "aperture")) { if (!ctx || strcmp (ctx, "lens") || !pd->lens) goto bad_ctx; for (i = 0; attribute_names [i]; i++) if (!strcmp (attribute_names [i], "min")) pd->lens->MinAperture = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "max")) pd->lens->MaxAperture = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "value")) pd->lens->MinAperture = pd->lens->MaxAperture = atof (attribute_values [i]); else goto bad_attr; } else if (!strcmp (element_name, "center")) { if (!ctx || strcmp (ctx, "lens") || !pd->lens) goto bad_ctx; for (i = 0; attribute_names [i]; i++) if (!strcmp (attribute_names [i], "x")) pd->lens->CenterX = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "y")) pd->lens->CenterY = atof (attribute_values [i]); else goto bad_attr; } else if (!strcmp (element_name, "cci")) { if (!ctx || strcmp (ctx, "lens") || !pd->lens) goto bad_ctx; for (i = 0; attribute_names [i]; i++) if (!strcmp (attribute_names [i], "red")) pd->lens->RedCCI = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "green")) pd->lens->GreenCCI = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "blue")) pd->lens->BlueCCI = atof (attribute_values [i]); else goto bad_attr; } else if (!strcmp (element_name, "type")) { if (!ctx || strcmp (ctx, "lens") || !pd->lens) goto bad_ctx; goto chk_no_attrs; } else if (!strcmp (element_name, "calibration")) { if (!ctx || strcmp (ctx, "lens")) goto bad_ctx; goto chk_no_attrs; } else if (!strcmp (element_name, "distortion")) { if (!ctx || strcmp (ctx, "calibration")) goto bad_ctx; lfLensCalibDistortion dc; memset (&dc, 0, sizeof (dc)); for (i = 0; attribute_names [i]; i++) if (!strcmp (attribute_names [i], "model")) { if (!strcmp (attribute_values [i], "none")) dc.Model = LF_DIST_MODEL_NONE; else if (!strcmp (attribute_values [i], "poly3")) dc.Model = LF_DIST_MODEL_POLY3; else if (!strcmp (attribute_values [i], "poly5")) dc.Model = LF_DIST_MODEL_POLY5; else if (!strcmp (attribute_values [i], "fov1")) dc.Model = LF_DIST_MODEL_FOV1; else if (!strcmp (attribute_values [i], "ptlens")) dc.Model = LF_DIST_MODEL_PTLENS; else { bad_attr: g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "Bad attribute value `%s=%s' for element <%s>!\n", attribute_names [i], attribute_values [i], element_name); return; } } else if (!strcmp (attribute_names [i], "focal")) dc.Focal = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "a") || !strcmp (attribute_names [i], "k1") || !strcmp (attribute_names [i], "omega")) dc.Terms [0] = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "b") || !strcmp (attribute_names [i], "k2")) dc.Terms [1] = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "c")) dc.Terms [2] = atof (attribute_values [i]); else { unk_attr: g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "Unknown attribute `%s' for element <%s>!\n", attribute_names [i], element_name); return; } pd->lens->AddCalibDistortion (&dc); } else if (!strcmp (element_name, "tca")) { if (!ctx || strcmp (ctx, "calibration")) goto bad_ctx; lfLensCalibTCA tcac; memset (&tcac, 0, sizeof (tcac)); tcac.Terms [0] = tcac.Terms [1] = 1.0; for (i = 0; attribute_names [i]; i++) if (!strcmp (attribute_names [i], "model")) { if (!strcmp (attribute_values [i], "none")) tcac.Model = LF_TCA_MODEL_NONE; else if (!strcmp (attribute_values [i], "linear")) tcac.Model = LF_TCA_MODEL_LINEAR; else if (!strcmp (attribute_values [i], "poly3")) tcac.Model = LF_TCA_MODEL_POLY3; else goto bad_attr; } else if (!strcmp (attribute_names [i], "focal")) tcac.Focal = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "kr") || !strcmp (attribute_names [i], "vr")) tcac.Terms [0] = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "kb") || !strcmp (attribute_names [i], "vb")) tcac.Terms [1] = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "cr")) tcac.Terms [2] = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "cb")) tcac.Terms [3] = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "br")) tcac.Terms [4] = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "bb")) tcac.Terms [5] = atof (attribute_values [i]); else goto unk_attr; pd->lens->AddCalibTCA (&tcac); } else if (!strcmp (element_name, "vignetting")) { if (!ctx || strcmp (ctx, "calibration")) goto bad_ctx; lfLensCalibVignetting vc; memset (&vc, 0, sizeof (vc)); for (i = 0; attribute_names [i]; i++) if (!strcmp (attribute_names [i], "model")) { if (!strcmp (attribute_values [i], "none")) vc.Model = LF_VIGNETTING_MODEL_NONE; else if (!strcmp (attribute_values [i], "pa")) vc.Model = LF_VIGNETTING_MODEL_PA; else goto bad_attr; } else if (!strcmp (attribute_names [i], "focal")) vc.Focal = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "aperture")) vc.Aperture = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "distance")) vc.Distance = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "k1")) vc.Terms [0] = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "k2")) vc.Terms [1] = atof (attribute_values [i]); else if (!strcmp (attribute_names [i], "k3")) vc.Terms [2] = atof (attribute_values [i]); else goto unk_attr; pd->lens->AddCalibVignetting (&vc); } /* Handle multi-language strings */ else if (!strcmp (element_name, "maker") || !strcmp (element_name, "model") || !strcmp (element_name, "variant") || !strcmp (element_name, "name")) { for (i = 0; attribute_names [i]; i++) if (!strcmp (attribute_names [i], "lang")) _lf_setstr (&pd->lang, attribute_values [i]); else goto unk_attr; } else if (!strcmp (element_name, "compat") || !strcmp (element_name, "cropfactor")) goto chk_no_attrs; else g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, "Unknown element <%s>!\n", element_name); }