24 #include "pybind11/pybind11.h"
27 #include "pybind11/stl.h"
34 using namespace py::literals;
38 namespace cameraGeom {
40 using PyCamera = py::class_<Camera, DetectorCollection, std::shared_ptr<Camera>>;
41 using PyCameraBuilder = py::class_<Camera::Builder, DetectorCollectionBase<Detector::InCameraBuilder>,
52 cls.def(
"rebuild", &Camera::rebuild);
53 cls.def(
"getName", &Camera::getName);
54 cls.def(
"getPupilFactoryName", &Camera::getPupilFactoryName);
55 cls.def(
"findDetectors", &Camera::findDetectors,
"point"_a,
"cameraSys"_a);
56 cls.def(
"findDetectorsList", &Camera::findDetectorsList,
"pointList"_a,
"cameraSys"_a);
60 [](Camera const &self, CameraSys const &fromSys, CameraSys const &toSys) {
62 return self.getTransform(fromSys, toSys);
63 } catch (pex::exceptions::NotFoundError &err) {
64 PyErr_SetString(PyExc_KeyError, err.what());
65 throw py::error_already_set();
68 "fromSys"_a,
"toSys"_a);
69 cls.def(
"getTransformMap", &Camera::getTransformMap);
75 return self.transform(point, fromSys, toSys);
77 PyErr_SetString(PyExc_KeyError, err.
what());
78 throw py::error_already_set();
81 "point"_a,
"fromSys"_a,
"toSys"_a);
87 return self.transform(points, fromSys, toSys);
89 PyErr_SetString(PyExc_KeyError, err.
what());
90 throw py::error_already_set();
93 "points"_a,
"fromSys"_a,
"toSys"_a);
96 wrappers.wrapType(
PyCameraBuilder(camera,
"Builder"), [](
auto &mod,
auto &cls) {
97 cls.def(py::init<std::string const &>(),
"name"_a);
98 cls.def(py::init<Camera const &>(),
"camera"_a);
99 cls.def(
"finish", &Camera::Builder::finish);
101 cls.def(
"setName", &Camera::Builder::setName);
102 cls.def(
"getPupilFactoryName", &Camera::Builder::getPupilFactoryName);
103 cls.def(
"setPupilFactoryName", &Camera::Builder::setPupilFactoryName);
104 cls.def(
"setPupilFactoryClass", [](Camera::Builder &
self, py::object pupilFactoryClass) {
106 if (!pupilFactoryClass.is(py::none())) {
107 pupilFactoryName = py::str(
"{}.{}").format(pupilFactoryClass.attr(
"__module__"),
108 pupilFactoryClass.attr(
"__name__"));
112 cls.def(
"setTransformFromFocalPlaneTo", &Camera::Builder::setTransformFromFocalPlaneTo,
"toSys"_a,
114 cls.def(
"discardTransformFromFocalPlaneTo", &Camera::Builder::discardTransformFromFocalPlaneTo);
115 cls.def(
"add", &Camera::Builder::add);
116 cls.def(
"__delitem__", py::overload_cast<int>(&Camera::Builder::remove));
117 cls.def(
"__delitem__", py::overload_cast<std::string const &>(&Camera::Builder::remove));
table::Key< std::string > pupilFactoryName
An immutable representation of a camera.
Camera coordinate system; used as a key in in TransformMap.
virtual char const * what(void) const noexcept
Return a character string summarizing this exception.
Reports attempts to access elements using an invalid key.
A helper class for subdividing pybind11 module across multiple translation units (i....
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
void addInheritanceDependency(std::string const &name)
Indicate an external module that provides a base class for a subsequent addType call.
void addSignatureDependency(std::string const &name)
Indicate an external module that provides a type used in function/method signatures.
py::class_< Camera, DetectorCollection, std::shared_ptr< Camera > > PyCamera
void wrapCamera(lsst::utils::python::WrapperCollection &wrappers)
py::class_< Camera::Builder, DetectorCollectionBase< Detector::InCameraBuilder >, std::shared_ptr< Camera::Builder > > PyCameraBuilder
std::string const & getName() const noexcept
Return a filter's name.
void addPersistableMethods(pybind11::class_< Class, Args... > &cls)
Add table::io::Persistable and PersistableFacade methods to the pybind11 wrapper for a class.
A base class for image defects.