9 #include "../../ColorPalettes.h"
10 #include "../visitors/AronTreeWidgetCreator.h"
18 QTreeWidgetItem* currentItem) :
23 this->elemType = elemType;
25 outerVerticalLayout =
new QVBoxLayout();
26 innerHorizontalLayout =
new QHBoxLayout();
27 outerVerticalLayout->addItem(innerHorizontalLayout);
30 QGridLayout* innerGrid =
new QGridLayout();
31 const long createRows =
std::min(numRows, MAX_ROWS_DISPLAY);
32 const long createCols =
std::min(numCols, MAX_COLS_DISPLAY);
34 for (
long i = 0; i < createRows * createCols; ++i)
36 auto* edit =
new QLineEdit();
37 dispElements.push_back(edit);
38 int currRow = i / createCols;
39 int currCol = i % createCols;
41 innerGrid->addWidget(edit, currRow, currCol);
43 ss <<
"(" << currRow <<
", " << currCol <<
")";
44 std::string text = ss.str();
46 edit->setText(text.c_str());
48 innerHorizontalLayout->addItem(innerGrid);
51 if (numRows > MAX_ROWS_DISPLAY)
53 QLabel* fullLabel =
new QLabel(
"...");
54 outerVerticalLayout->addWidget(fullLabel);
56 if (numCols > MAX_COLS_DISPLAY)
58 QLabel* fullLabel =
new QLabel(
"...");
59 innerHorizontalLayout->addWidget(fullLabel);
61 setLayout(outerVerticalLayout);
65 const auto hiddenCols = numCols - createCols;
68 hiddenElems.push_back(std::vector<std::string>(hiddenCols * createRows,
""));
71 for (
long i = 0; i < numRows - createRows; ++i)
74 hiddenElems.push_back(std::vector<std::string>(numCols,
""));
78 for (
size_t i = 0; i < dispElements.size(); ++i)
81 dispElements[i], SIGNAL(editingFinished()),
this, SLOT(matrixElementChanged())));
108 auto dispCols = getDisplayedCols();
109 auto dispRows = getDisplayedRows();
110 if (row < dispRows && col < dispCols)
112 dispElements[row * dispCols + col]->setText(
str.c_str());
113 dispElements[row * dispCols + col]->setCursorPosition(0);
115 else if (row < dispRows)
117 long idx = row * (realCols - dispCols) + col - dispCols;
118 hiddenElems.at(0).at(idx) =
str;
122 hiddenElems.at(row - dispRows + 1).at(col) =
str;
131 const auto dispRows = getDisplayedRows();
132 const auto dispCols = getDisplayedCols();
133 if (row < dispRows && col < dispCols)
135 auto txt = dispElements.at(row * dispCols + col)->text();
136 return txt.toStdString();
138 else if (row < getDisplayedRows())
141 long idx = row * (realCols - dispCols) + col - dispCols;
142 return hiddenElems.at(0).at(idx);
147 return hiddenElems.at(row - dispRows + 1).at(col);
154 auto dispRows = getDisplayedRows();
155 auto dispCols = getDisplayedCols();
156 for (
long row = 0; row < dispRows; ++row)
158 for (
long col = 0; col < dispCols; ++col)
163 dispElements.at(row * dispCols + col)
168 dispElements.at(row * dispCols + col)
179 for (
long row = 0; row < realRows; ++row)
181 for (
long col = 0; col < realCols; ++col)
186 if (row >= getDisplayedRows() || col >= getDisplayedCols())
189 <<
"Programming error! Could not parse content in EditMatrixWidget "
190 "that was set programatically from inside the SkillManagerPlugin. "
191 "The error occured in row "
192 << row <<
" and col " << col <<
".";
201 std::vector<unsigned char>
209 case armarx::aron::type::matrix::UINT8:
210 return NDArrayHelper::toByteVector<uint8_t>(
str);
212 case armarx::aron::type::matrix::UINT16:
213 return NDArrayHelper::toByteVector<uint16_t>(
str);
215 case armarx::aron::type::matrix::UINT32:
216 return NDArrayHelper::toByteVector<uint32_t>(
str);
218 case armarx::aron::type::matrix::INT8:
219 return NDArrayHelper::toByteVector<int8_t>(
str);
221 case armarx::aron::type::matrix::INT16:
222 return NDArrayHelper::toByteVector<int16_t>(
str);
224 case armarx::aron::type::matrix::INT32:
225 return NDArrayHelper::toByteVector<int32_t>(
str);
227 case armarx::aron::type::matrix::INT64:
228 return NDArrayHelper::toByteVector<int64_t>(
str);
230 case armarx::aron::type::matrix::FLOAT32:
231 return NDArrayHelper::toByteVector<float>(
str);
233 case armarx::aron::type::matrix::FLOAT64:
234 return NDArrayHelper::toByteVector<double>(
str);
237 catch (
const simox::error::SimoxError& err)
245 EditMatrixWidget::getDisplayedRows()
const
247 return std::min(realRows, MAX_ROWS_DISPLAY);
250 EditMatrixWidget::getDisplayedCols()
const
252 return std::min(realCols, MAX_COLS_DISPLAY);
255 EditMatrixWidget::matrixElementChanged()