39 #include <QMessageBox> 41 #include <QFileDialog> 51 m_treeWidget(treeWidget)
54 m_ui =
new Ui_CorrespondenceDialog;
64 m_ui->comboBoxModel->setAutoFillBackground(
true );
65 m_ui->comboBoxModel->setStyleSheet(
"QComboBox { background-color: blue; } QComboBox QAbstractItemView {border: 2px solid darkgray; selection-background-color: lightgray;}");
69 m_ui->comboBoxData->setAutoFillBackground(
true );
70 m_ui->comboBoxData->setStyleSheet(
"QComboBox { background-color: yellow; }");
74 QObject::connect(
m_ui->buttonNew, SIGNAL(pressed()),
this, SLOT(
insertNewItem()));
75 QObject::connect(
m_ui->buttonDelete, SIGNAL(pressed()),
this, SLOT(
deleteItem()));
79 QObject::connect(
m_ui->buttonDelete, SIGNAL(pressed()),
this, SLOT(
deleteItem()));
80 QObject::connect(
m_ui->treeWidget, SIGNAL(currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)),
this, SLOT(
treeItemSelected(QTreeWidgetItem*, QTreeWidgetItem*)));
87 while(
m_ui->treeWidget->topLevelItemCount ())
89 m_ui->treeWidget->selectAll();
118 QList<QTreeWidgetItem*> items =
m_ui->treeWidget->selectedItems();
121 QList<QTreeWidgetItem*>::iterator it;
122 for(it = items.begin(); it != items.end(); it++)
124 m_ui->treeWidget->setItemSelected(*it,
false);
127 m_ui->treeWidget->addTopLevelItem(item);
128 m_ui->treeWidget->setItemSelected(item,
true);
129 m_ui->treeWidget->setCurrentItem(item);
136 QList<QTreeWidgetItem*> items =
m_ui->treeWidget->selectedItems();
139 QTreeWidgetItem* it = items.first();
142 int index =
m_ui->treeWidget->indexOfTopLevelItem(it);
156 m_ui->comboBoxModel->clear();
157 m_ui->comboBoxData->clear();
167 QString text = (*it)->parent()->text(0);
168 m_ui->comboBoxData->addItem(text);
169 m_ui->comboBoxModel->addItem(text);
173 m_ui->comboBoxModel->setCurrentText(text);
177 m_ui->comboBoxData->setCurrentText(text);
188 QString str =
m_ui->comboBoxModel->currentText();
196 if(item->parent()->text(0) == str)
212 QString str =
m_ui->comboBoxData->currentText();
220 if(item->parent()->text(0) == str)
236 return m_ui->checkBoxICP->isChecked();
241 return m_ui->spinBoxEpsilon->value();
246 return m_ui->spinBoxDistance->value();
251 return m_ui->spinBoxIterations->value();
263 QList<QTreeWidgetItem*> items =
m_ui->treeWidget->selectedItems();
266 QTreeWidgetItem* it = items.first();
301 QList<QTreeWidgetItem*> items =
m_ui->treeWidget->selectedItems();
304 QTreeWidgetItem* it = items.first();
338 QList<QTreeWidgetItem*> items =
m_ui->treeWidget->selectedItems();
341 QTreeWidgetItem* it = items.first();
345 double* end = item->
getEnd();
355 QString fileName = QFileDialog::getSaveFileName(
m_treeWidget,
356 tr(
"Save Correspondences"),
"./",
tr(
"Correspondence Files (*.cor)"));
360 ofstream outfile(fileName.toStdString().c_str());
361 QTreeWidgetItemIterator it(
m_ui->treeWidget);
368 double* end = item->
getEnd();
369 outfile << start[0] <<
" " << start[1] <<
" " << start[2] <<
" ";
370 outfile << end[0] <<
" " << end[1] <<
" " << end[2] << endl;
371 cout << start <<
" " << end << endl;
381 QString fileName = QFileDialog::getOpenFileName(
m_treeWidget,
382 tr(
"Load Correspondences"),
"./",
tr(
"Correspondence Files (*.cor)"));
386 ifstream infile(fileName.toStdString().c_str());
389 double* start =
new double[3];
390 double* end =
new double[3];
391 infile >> start[0] >> start[1] >> start[2];
392 infile >> end[0] >> end[1] >> end[2];
406 m_ui->treeWidget->addTopLevelItem(item);
407 m_ui->treeWidget->setItemSelected(item,
false);
408 m_ui->treeWidget->setCurrentItem(item);
452 std::vector<std::pair<Eigen::Vector3f, Eigen::Vector3f>> pairs;
456 QTreeWidgetItemIterator it(
m_ui->treeWidget);
465 double* e = item->
getEnd();
470 centroid_m += start.cast<
float>();
471 centroid_d += end.cast<
float>();
473 pairs.push_back(make_pair(start, end));
482 centroid_m /= pairs.size();
483 centroid_d /= pairs.size();
487 align.
alignPoints(pairs, centroid_m, centroid_d, matrix);
489 return boost::make_optional(matrix);
493 cout <<
"Need at least 4 corresponding points" << endl;
500 return m_ui->comboBoxModel->currentText();
505 return m_ui->comboBoxData->currentText();
virtual ~LVRCorrespondanceDialog()
void treeItemSelected(QTreeWidgetItem *, QTreeWidgetItem *)
void addArrow(LVRVtkArrow *)
QColor m_modelSelectionColor
void setStart(double *start)
void loadCorrespondences()
void setTmpColor(double r, double g, double b)
Ui_CorrespondenceDialog * m_ui
Eigen::Vector3f Vector3f
Eigen 3D vector, single precision.
LVRCorrespondanceDialog(QTreeWidget *parent)
__kf_device__ Vec3f tr(const float4 &v)
void saveCorrespondences()
Transform< float > Transformf
4x4 single precision transformation matrix
QTreeWidget * m_treeWidget
void setSelectionColor(QColor &c)
QColor m_dataSelectionColor
void firstPointPicked(double *)
A wrapper class to generate arrow actors for vtk based on VTK's oriented arrow example.
void updateDataSelection(int)
void disableCorrespondenceSearch()
void secondPointPicked(double *)
void updateModelSelection(int)
void enableCorrespondenceSearch()
void removeArrow(LVRVtkArrow *)
T alignPoints(SLAMScanPtr scan, Point3 **neighbors, const Vec3 ¢roid_m, const Vec3 ¢roid_d, Mat4 &align) const
Calculates the estimated Transformation to match a Data Pointcloud to a Model Pointcloud.
boost::optional< Transformf > getTransformation()