CloudViewer: using QWidget::update() call instead of render directly the window

This commit is contained in:
Mathieu Labbe
2015-01-30 17:02:02 -05:00
parent a2dde36093
commit d97ae60e6c
8 changed files with 33 additions and 64 deletions

View File

@@ -2315,7 +2315,7 @@ cv::Mat create2DMap(const std::map<int, Transform> & poses,
UDEBUG("map min=(%f, %f) max=(%f,%f)", xMin, yMin, xMax, yMax);
//UTimer timer;
UTimer timer;
map = cv::Mat::ones((yMax - yMin) / cellSize + 0.5f, (xMax - xMin) / cellSize + 0.5f, CV_8S)*-1;
std::vector<float> maxSquaredLength(localScans.size(), 0.0f);
@@ -2343,7 +2343,7 @@ cv::Mat create2DMap(const std::map<int, Transform> & poses,
}
++j;
}
//UWARN("timer=%fs", timer.ticks());
UDEBUG("Ray trace known space=%fs", timer.ticks());
// now fill unknown spaces
if(unknownSpaceFilled)
@@ -2407,8 +2407,8 @@ cv::Mat create2DMap(const std::map<int, Transform> & poses,
}
}
++j;
//UWARN("timer=%fs", timer.ticks());
}
UDEBUG("Fill empty space=%fs", timer.ticks());
}
}
return map;
@@ -2446,26 +2446,18 @@ void rayTrace(const cv::Point2i & start, const cv::Point2i & end, cv::Mat & grid
//ROS_WARN("lowerbound=%f upperbound=%f", lowerbound, upperbound);
UASSERT_MSG(lowerbound >= 0 && lowerbound < grid.rows, uFormat("lowerbound=%f grid.rows=%d x=%d slope=%f b=%f x=%f", lowerbound, grid.rows, x, slope, b, x).c_str());
UASSERT_MSG(upperbound >= 0 && upperbound < grid.rows, uFormat("upperbound=%f grid.rows=%d x+1=%d slope=%f b=%f x=%f", upperbound, grid.rows, x+1, slope, b, x).c_str());
// verify if there is no obstacle
bool stopped = false;
if(stopOnObstacle)
{
for(int y = lowerbound; y<=(int)upperbound; ++y)
{
if(grid.at<char>(y, x) == 100)
{
stopped = true;
break;
}
}
}
if(stopped)
{
break;
}
for(int y = lowerbound; y<=(int)upperbound; ++y)
{
grid.at<char>(y, x) = 0; // free space
char & v = grid.at<char>(y, x);
if(v == 100 && stopOnObstacle)
{
return;
}
else
{
v = 0; // free space
}
}
}
}

View File

@@ -129,7 +129,7 @@ private slots:
cloudViewer_->updateCameraTargetPosition(data.pose());
}
}
cloudViewer_->render();
cloudViewer_->update();
_lastOdometryProcessed = true;
}
@@ -193,7 +193,7 @@ private slots:
}
}
cloudViewer_->render();
cloudViewer_->update();
_processingStatistics = false;
}

View File

@@ -178,7 +178,6 @@ public:
void setWorkingDirectory(const QString & path) {_workingDirectory = path;}
public slots:
void render();
void setBackgroundColor(const QColor & color);
void setCloudVisibility(const std::string & id, bool isVisible);
void setCloudOpacity(const std::string & id, double opacity = 1.0);

View File

@@ -51,7 +51,7 @@ void CloudViewer::mouseEventOccurred (const pcl::visualization::MouseEvent &even
if (event.getButton () == pcl::visualization::MouseEvent::LeftButton ||
event.getButton () == pcl::visualization::MouseEvent::MiddleButton)
{
this->render(); // this will apply frustum
this->update(); // this will apply frustum
}
}
@@ -517,7 +517,7 @@ void CloudViewer::clearTrajectory()
{
_trajectory->clear();
_visualizer->removeShape("trajectory");
this->render();
this->update();
}
void CloudViewer::removeAllClouds()
@@ -671,9 +671,9 @@ void CloudViewer::updateCameraTargetPosition(const Transform & pose)
cameras.front().focal[1] = Fp.y();
cameras.front().focal[2] = Fp.z();
//FIXME: the view up is not set properly...
cameras.front().view[0] = Fp[8];
cameras.front().view[1] = Fp[9];
cameras.front().view[2] = Fp[10];
cameras.front().view[0] = _aLockViewZ->isChecked()?0:Fp[8];
cameras.front().view[1] = _aLockViewZ->isChecked()?0:Fp[9];
cameras.front().view[2] = _aLockViewZ->isChecked()?1:Fp[10];
}
#if PCL_VERSION_COMPARE(>=, 1, 7, 2)
@@ -693,28 +693,6 @@ void CloudViewer::updateCameraTargetPosition(const Transform & pose)
_lastPose = pose;
}
void CloudViewer::render()
{
// camera view up z locked?
if(_aLockViewZ->isChecked())
{
std::vector<pcl::visualization::Camera> cameras;
_visualizer->getCameras(cameras);
cameras.front().view[0] = 0;
cameras.front().view[1] = 0;
cameras.front().view[2] = 1;
_visualizer->setCameraPosition(
cameras.front().pos[0], cameras.front().pos[1], cameras.front().pos[2],
cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
}
this->GetRenderWindow()->Render();
}
const QColor & CloudViewer::getBackgroundColor() const
{
return _backgroundColor;
@@ -1045,7 +1023,7 @@ void CloudViewer::keyPressEvent(QKeyEvent * event)
cameras.front().focal[0], cameras.front().focal[1], cameras.front().focal[2],
cameras.front().view[0], cameras.front().view[1], cameras.front().view[2]);
render();
update();
emit configChanged();
}
@@ -1141,7 +1119,7 @@ void CloudViewer::handleAction(QAction * a)
0, 0, 0,
0, 0, 1);
}
this->render();
this->update();
}
else if(a == _aShowGrid)
{
@@ -1154,7 +1132,7 @@ void CloudViewer::handleAction(QAction * a)
this->removeGrid();
}
this->render();
this->update();
}
else if(a == _aSetGridCellCount)
{
@@ -1184,7 +1162,7 @@ void CloudViewer::handleAction(QAction * a)
{
if(_aLockViewZ->isChecked())
{
this->render();
this->update();
}
}
}

View File

@@ -1131,7 +1131,7 @@ void DatabaseViewer::update(int value,
ui_->horizontalSlider_loops->setValue(0);
ui_->horizontalSlider_neighbors->setValue(0);
ui_->constraintsViewer->removeAllClouds();
ui_->constraintsViewer->render();
ui_->constraintsViewer->update();
ui_->horizontalSlider_loops->blockSignals(false);
ui_->horizontalSlider_neighbors->blockSignals(false);
}
@@ -1244,7 +1244,7 @@ void DatabaseViewer::updateStereo(const Signature * data)
ui_->stereoViewer->updateCameraTargetPosition(Transform::getIdentity());
ui_->stereoViewer->addOrUpdateCloud("stereo", cloud);
ui_->stereoViewer->render();
ui_->stereoViewer->update();
std::vector<cv::KeyPoint> rightKpts;
cv::KeyPoint::convert(rightCorners, rightKpts);
@@ -1660,7 +1660,7 @@ void DatabaseViewer::updateConstraintView(const rtabmap::Link & linkIn,
ui_->constraintsViewer->updateCameraTargetPosition(t);
ui_->constraintsViewer->clearTrajectory();
ui_->constraintsViewer->render();
ui_->constraintsViewer->update();
}
// update buttons
@@ -2490,7 +2490,7 @@ void DatabaseViewer::updateLoopClosuresSlider(int from, int to)
{
ui_->horizontalSlider_loops->setEnabled(false);
ui_->constraintsViewer->removeAllClouds();
ui_->constraintsViewer->render();
ui_->constraintsViewer->update();
updateConstraintButtons();
}
}

View File

@@ -197,7 +197,7 @@ void LoopClosureViewer::updateView(const Transform & transform)
{
UERROR("loop transform is null !?!?");
ui_->cloudViewerTransform->removeAllClouds();
}
}
ui_->cloudViewerTransform->update();
}
}

View File

@@ -765,7 +765,7 @@ void MainWindow::processOdometry(const rtabmap::SensorData & data, const rtabmap
_ui->widget_cloudViewer->updateCameraTargetPosition(_odometryCorrection*data.pose());
}
}
_ui->widget_cloudViewer->render();
_ui->widget_cloudViewer->update();
}
if(_ui->dockWidget_odometry->isVisible() &&
@@ -1451,7 +1451,7 @@ void MainWindow::updateMapCloud(
_ui->widget_cloudViewer->updateCameraTargetPosition(currentPose);
}
_ui->widget_cloudViewer->render();
_ui->widget_cloudViewer->update();
}
void MainWindow::createAndAddCloudToMap(int nodeId, const Transform & pose, int mapId)
@@ -1648,7 +1648,7 @@ void MainWindow::updateNodeVisibility(int nodeId, bool visible)
}
}
}
_ui->widget_cloudViewer->render();
_ui->widget_cloudViewer->update();
}
void MainWindow::processRtabmapEventInit(int status, const QString & info)

View File

@@ -164,7 +164,7 @@ void OdometryViewer::processData()
this->setBackgroundColor(Qt::darkRed);
}
this->render();
this->update();
}
}