535 "show image" + (
"" if argparse
else " <image> [<nx> [<ny>]]"))
536 parser.add_option(
"-a",
"--all", action=
"store_true",
537 help=
"Display the whole image/mask")
538 parser.add_option(
"-c",
"--center", type=
"str", nargs=2, default=(
None,
None,),
539 help=
"Center the output at (x, y)")
540 parser.add_option(
"-o",
"--origin", type=
"str", nargs=2, default=(
None,
None,),
541 help=
"Print the region starting at (x, y)")
542 parser.add_option(
"-x",
"--xy0", action=
"store_true",
543 help=
"Obey the image's (x0, y0)")
544 parser.add_option(
"-f",
"--formatWidth", type=
"int",
545 default=8, help=
"Field width for values")
546 parser.add_option(
"-d",
"--dataFmt", default=
"%.2f",
547 help=
"Format for values")
551 "image", help=
"Expression giving image to show")
553 "width", help=
"Width of patch to print", default=1, nargs=
"?")
555 "height", help=
"Height of patch to print", default=1, nargs=
"?")
557 opts = parser.parse_args(args)
561 opts, args = parser.parse_args(args)
566 raise gdb.GdbError(
"Please specify an image")
568 opts.image = args.pop(0)
570 opts.width, opts.height = 1, 1
572 opts.width = int(args.pop(0))
574 opts.height = int(args.pop(0))
578 "Unrecognised trailing arguments: %s" %
" ".join(args))
582 if opts.origin[i]
is None:
583 if opts.center[i]
is not None:
587 if opts.center[i]
is not None:
589 "You may not specify both --center and --origin")
591 val = gdb.parse_and_eval(val)
600 nx, ny = opts.width, opts.height
602 var = gdb.parse_and_eval(opts.image)
604 if re.search(
r"shared_ptr<", str(var.type)):
605 var = var[
"px"].dereference()
607 if not re.search(
r"(lsst::afw::image::)?(Image|Mask|MaskedImage)", str(var.type.unqualified())):
609 "Please specify an image, not %s" % var.type)
611 if re.search(
r"MaskedImage", str(var.type))
and \
612 not re.search(
r"::Image(\s*&)?$", str(var.type)):
613 print(
"N.b. %s is a MaskedImage; showing image" % (opts.image))
616 if re.search(
r"shared_ptr<", str(var.type)):
617 var = var[
"px"].dereference()
619 if var.type.code == gdb.TYPE_CODE_PTR:
620 var = var.dereference()
622 pixelTypeName = str(var.type.template_argument(0))
624 dataFmt = opts.dataFmt
625 elif pixelTypeName
in [
"short",
"unsigned short"]:
627 elif pixelTypeName
in [
"int",
"unsigned int"]:
633 nx = var[
"_gilView"][
"_dimensions"][
"x"]
635 ny = var[
"_gilView"][
"_dimensions"][
"y"]
641 if opts.xy0
and not opts.all:
642 arr = var[
"_origin"][
"_vector"][
"m_storage"][
"m_data"][
"array"]
649 print(
"%-4s" %
"", end=
' ')
650 for x
in range(x0, x0 + nx):
651 print(
"%*d" % (opts.formatWidth, x), end=
' ')
654 for y
in reversed(
list(range(y0, y0 + ny))):
655 print(
"%-4d" % y, end=
' ')
656 for x
in range(x0, x0 + nx):
657 print(
"%*s" % (opts.formatWidth, dataFmt %
658 self.
get(var, x, y)), end=
' ')