35 UIWidget(
const std::string& name =
"##value");
38 bool operator()(T& value)
44 bool operator()(
float& value);
45 bool operator()(
int& value);
46 bool operator()(
bool& value);
47 bool operator()(
double& value);
48 bool operator()(std::string& value);
51 bool operator()(
Texture& value,
int width = 0,
int height = 0);
52 bool operator()(
Color& value);
54 bool operator()(Eigen::Vector2f& value);
55 bool operator()(Eigen::Vector3f& value);
56 bool operator()(Eigen::Vector4f& value);
57 bool operator()(Eigen::Vector2i& value);
58 bool operator()(Eigen::Vector3i& value);
59 bool operator()(Eigen::Vector4i& value);
60 bool operator()(Eigen::Matrix2f& value);
61 bool operator()(Eigen::Matrix3f& value);
62 bool operator()(Eigen::Matrix4f& value);
63 bool operator()(Eigen::Affine3f& value);
66 bool render_matrix(
float* M,
int dimension);
68 const std::string& m_name;
109 template <
typename MatrixType>
111 const MatrixType& matrix,
114 typename MatrixType::Scalar& value_out)
116 const int pages = (int(matrix.rows()) + m_per_page - 1) / m_per_page;
124 m_current_page = std::max(
int(0), std::min(m_current_page, pages - 1));
126 ImGui::Columns(
int(matrix.cols()) + 1);
128 int begin = m_current_page * m_per_page;
129 int end = std::min(
int((m_current_page + 1) * m_per_page),
static_cast<int>(matrix.rows()));
131 bool changed =
false;
133 for (
auto i = begin; i < end; i++) {
134 ImGui::Text(
"[%d]", i);
137 for (
auto k = 0; k < matrix.cols(); k++) {
138 typename MatrixType::Scalar new_value;
139 if (matrix_field(matrix, i, k, new_value)) {
142 value_out = new_value;
153 template <
typename MatrixType,
typename IndexType>
155 const MatrixType& matrix,
156 const std::unordered_set<IndexType>& selection,
159 typename MatrixType::Scalar& value_out)
161 const int pages = (int(selection.size()) + m_per_page - 1) / m_per_page;
169 m_current_page = std::max(
int(0), std::min(m_current_page, pages - 1));
171 ImGui::Columns(
int(matrix.cols()) + 1);
173 int begin = m_current_page * m_per_page;
174 int end = std::min(
int((m_current_page + 1) * m_per_page),
static_cast<int>(matrix.rows()));
176 bool changed =
false;
179 for (
auto elem : selection) {
181 if (cnt < begin)
continue;
182 if (cnt == end)
break;
184 ImGui::Text(
"[%d]",
int(elem));
187 for (
auto k = 0; k < matrix.cols(); k++) {
188 typename MatrixType::Scalar new_value;
189 if (matrix_field(matrix, elem, k, new_value)) {
192 value_out = new_value;
203 int get_per_page()
const {
return m_per_page; }
204 void set_per_page(
int value) { m_per_page = value; }
207 template <
typename MatrixType>
208 bool matrix_field(
const MatrixType& matrix,
int row,
int col,
typename MatrixType::Scalar& out)
210 ImGui::PushID(row *
int(matrix.cols()) + col);
211 auto val = matrix(row, col);
220 int m_current_page = 0;
std::string string_format(fmt::format_string< Args... > format, Args &&... args)
Format args according to the format string fmt, and return the result as a string.
Definition strings.h:103