mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
CloudViewer: added backface culling option on right-click menu. MainWindow: removed error msg on wrong decimation (util3d already handle this case)
This commit is contained in:
@@ -316,6 +316,7 @@ private:
|
||||
QAction * _aSetRenderingRate;
|
||||
QAction * _aSetLighting;
|
||||
QAction * _aSetEdgeVisibility;
|
||||
QAction * _aBackfaceCulling;
|
||||
QMenu * _menu;
|
||||
std::set<std::string> _graphes;
|
||||
std::set<std::string> _coordinates;
|
||||
@@ -337,7 +338,6 @@ private:
|
||||
QString _workingDirectory;
|
||||
QColor _defaultBgColor;
|
||||
QColor _currentBgColor;
|
||||
bool _backfaceCulling;
|
||||
bool _frontfaceCulling;
|
||||
double _renderingRate;
|
||||
vtkProp * _octomapActor;
|
||||
|
||||
@@ -128,6 +128,7 @@ CloudViewer::CloudViewer(QWidget *parent) :
|
||||
_aSetRenderingRate(0),
|
||||
_aSetLighting(0),
|
||||
_aSetEdgeVisibility(0),
|
||||
_aBackfaceCulling(0),
|
||||
_menu(0),
|
||||
_trajectory(new pcl::PointCloud<pcl::PointXYZ>),
|
||||
_maxTrajectorySize(100),
|
||||
@@ -140,7 +141,6 @@ CloudViewer::CloudViewer(QWidget *parent) :
|
||||
_workingDirectory("."),
|
||||
_defaultBgColor(Qt::black),
|
||||
_currentBgColor(Qt::black),
|
||||
_backfaceCulling(false),
|
||||
_frontfaceCulling(false),
|
||||
_renderingRate(5.0),
|
||||
_octomapActor(0)
|
||||
@@ -241,6 +241,9 @@ void CloudViewer::createMenu()
|
||||
_aSetEdgeVisibility = new QAction("Show edges", this);
|
||||
_aSetEdgeVisibility->setCheckable(true);
|
||||
_aSetEdgeVisibility->setChecked(false);
|
||||
_aBackfaceCulling = new QAction("Backface culling", this);
|
||||
_aBackfaceCulling->setCheckable(true);
|
||||
_aBackfaceCulling->setChecked(true);
|
||||
|
||||
QMenu * cameraMenu = new QMenu("Camera", this);
|
||||
cameraMenu->addAction(_aLockCamera);
|
||||
@@ -279,6 +282,7 @@ void CloudViewer::createMenu()
|
||||
_menu->addAction(_aSetRenderingRate);
|
||||
_menu->addAction(_aSetLighting);
|
||||
_menu->addAction(_aSetEdgeVisibility);
|
||||
_menu->addAction(_aBackfaceCulling);
|
||||
}
|
||||
|
||||
void CloudViewer::saveSettings(QSettings & settings, const QString & group) const
|
||||
@@ -542,14 +546,8 @@ bool CloudViewer::addCloudMesh(
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
|
||||
if(_backfaceCulling)
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->BackfaceCullingOn();
|
||||
}
|
||||
if(_frontfaceCulling)
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->FrontfaceCullingOn();
|
||||
}
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
|
||||
_visualizer->updatePointCloudPose(id, pose.toEigen3f());
|
||||
_addedClouds.insert(id, pose);
|
||||
return true;
|
||||
@@ -573,14 +571,8 @@ bool CloudViewer::addCloudMesh(
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
|
||||
if(_backfaceCulling)
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->BackfaceCullingOn();
|
||||
}
|
||||
if(_frontfaceCulling)
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->FrontfaceCullingOn();
|
||||
}
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
|
||||
_visualizer->updatePointCloudPose(id, pose.toEigen3f());
|
||||
_addedClouds.insert(id, pose);
|
||||
return true;
|
||||
@@ -604,14 +596,8 @@ bool CloudViewer::addCloudMesh(
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
|
||||
if(_backfaceCulling)
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->BackfaceCullingOn();
|
||||
}
|
||||
if(_frontfaceCulling)
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->FrontfaceCullingOn();
|
||||
}
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
|
||||
_visualizer->updatePointCloudPose(id, pose.toEigen3f());
|
||||
_addedClouds.insert(id, pose);
|
||||
return true;
|
||||
@@ -634,14 +620,8 @@ bool CloudViewer::addCloudMesh(
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
|
||||
if(_backfaceCulling)
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->BackfaceCullingOn();
|
||||
}
|
||||
if(_frontfaceCulling)
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->FrontfaceCullingOn();
|
||||
}
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
|
||||
_visualizer->updatePointCloudPose(id, pose.toEigen3f());
|
||||
_addedClouds.insert(id, pose);
|
||||
return true;
|
||||
@@ -665,14 +645,8 @@ bool CloudViewer::addCloudTextureMesh(
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
|
||||
if(_backfaceCulling)
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->BackfaceCullingOn();
|
||||
}
|
||||
if(_frontfaceCulling)
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->FrontfaceCullingOn();
|
||||
}
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
|
||||
if(!textureMesh->cloud.is_dense)
|
||||
{
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetTexture()->SetInterpolate(1);
|
||||
@@ -1152,6 +1126,8 @@ bool CloudViewer::addTextureMesh (
|
||||
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
|
||||
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1733,8 +1709,16 @@ Transform CloudViewer::getTargetPose() const
|
||||
|
||||
void CloudViewer::setBackfaceCulling(bool enabled, bool frontfaceCulling)
|
||||
{
|
||||
_backfaceCulling = enabled;
|
||||
_aBackfaceCulling->setChecked(enabled);
|
||||
_frontfaceCulling = frontfaceCulling;
|
||||
|
||||
pcl::visualization::CloudActorMapPtr cloudActorMap = _visualizer->getCloudActorMap();
|
||||
for(pcl::visualization::CloudActorMap::iterator iter=cloudActorMap->begin(); iter!=cloudActorMap->end(); ++iter)
|
||||
{
|
||||
iter->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
|
||||
iter->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
|
||||
}
|
||||
this->update();
|
||||
}
|
||||
|
||||
void CloudViewer::setRenderingRate(double rate)
|
||||
@@ -2507,6 +2491,10 @@ void CloudViewer::handleAction(QAction * a)
|
||||
{
|
||||
this->setEdgeVisibility(_aSetEdgeVisibility->isChecked());
|
||||
}
|
||||
else if(a == _aBackfaceCulling)
|
||||
{
|
||||
this->setBackfaceCulling(_aBackfaceCulling->isChecked(), _frontfaceCulling);
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace rtabmap */
|
||||
|
||||
@@ -2518,17 +2518,6 @@ std::pair<pcl::PointCloud<pcl::PointXYZRGB>::Ptr, pcl::IndicesPtr> MainWindow::c
|
||||
pcl::IndicesPtr indices(new std::vector<int>);
|
||||
UASSERT(nodeId == data.id());
|
||||
|
||||
if(image.cols % _preferencesDialog->getCloudDecimation(0) != 0 ||
|
||||
image.rows % _preferencesDialog->getCloudDecimation(0) != 0)
|
||||
{
|
||||
UERROR("Decimation (%d) is not modulo of the image resolution (%dx%d)! The cloud cannot be "
|
||||
"created. Go to Preferences->3D Rendering under \"Map\" column to modify this parameter.",
|
||||
_preferencesDialog->getCloudDecimation(0),
|
||||
image.cols,
|
||||
image.rows);
|
||||
return outputPair;
|
||||
}
|
||||
|
||||
// Create organized cloud
|
||||
cloud = util3d::cloudRGBFromSensorData(data,
|
||||
_preferencesDialog->getCloudDecimation(0),
|
||||
|
||||
Reference in New Issue
Block a user