#pragma once

#include "../../../include/dv-processing/visualization/event_visualizer.hpp"

#include <pybind11/pybind11.h>

namespace py = pybind11;

/**
 * @brief Bind visualization::EventVisualizer class to python
 * @param m pybind The module to bind to
 */
void bind_event_visualizer(py::module &m) {
	using pybind11::operator""_a;

	py::class_<dv::visualization::EventVisualizer>(m, "EventVisualizer", "Visualize events.")
		.def(py::init<const cv::Size &, const cv::Scalar &, const cv::Scalar &, const cv::Scalar &>(), "resolution"_a,
			"backgroundColor"_a = dv::visualization::colors::white,
			"positiveColor"_a   = dv::visualization::colors::iniBlue,
			"negativeColor"_a   = dv::visualization::colors::darkGray)
		.def(
			"generateImage",
			[](dv::visualization::EventVisualizer &self, const dv::EventStore &events) {
				return self.generateImage(events);
			},
			"events"_a, "Generate a preview image from an event store.")
		.def(
			"generateImage",
			[](dv::visualization::EventVisualizer &self, const dv::EventStore &events, cv::Mat &background) {
				self.generateImage(events, background);
				return background;
			},
			"events"_a, "background"_a,
			"Generate a preview image of a given event store on the given background. Return the generated image "
			"preview.")
		.def("getBackgroundColor", &dv::visualization::EventVisualizer::getBackgroundColor,
			"Get currently configured background color.")
		.def("setBackgroundColor", &dv::visualization::EventVisualizer::setBackgroundColor, "backgroundColor"_a,
			"Set new background color.")
		.def("getPositiveColor", &dv::visualization::EventVisualizer::getPositiveColor,
			"Get currently configured positive polarity color.")
		.def("setPositiveColor", &dv::visualization::EventVisualizer::setPositiveColor, "positiveColor"_a,
			"Set new positive polarity color.")
		.def("getNegativeColor", &dv::visualization::EventVisualizer::getNegativeColor, "Get negative polarity color.")
		.def("setNegativeColor", &dv::visualization::EventVisualizer::setNegativeColor, "negativeColor"_a,
			"Set new negative polarity color.");
}
