ImageView.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #include "rtabmap/gui/ImageView.h"
29 
30 #include <QtGui/QWheelEvent>
31 #include <QtCore/qmath.h>
32 #include <QMenu>
33 #include <QFileDialog>
34 #include <QtCore/QDir>
35 #include <QAction>
36 #include <QGraphicsEffect>
37 #include <QInputDialog>
38 #include <QVBoxLayout>
39 #include <QColorDialog>
40 #include <QPrinter>
41 #include <QGraphicsRectItem>
44 #include "rtabmap/core/util2d.h"
45 
46 #include <QtGlobal>
47 #if QT_VERSION >= 0x050000
48  #include <QStandardPaths>
49 #endif
50 
51 namespace rtabmap {
52 
53 //LineItem
54 class LineItem : public QGraphicsLineItem
55 {
56 public:
57  LineItem(float x1, float y1, float x2, float y2, const QString & text = QString(), QGraphicsItem * parent = 0) :
58  QGraphicsLineItem(x1, y1, x2, y2, parent),
59  _text(text),
60  _placeHolder(0)
61  {
62  this->setAcceptHoverEvents(true);
63  this->setFlag(QGraphicsItem::ItemIsFocusable, true);
64  _width = pen().width();
65  }
66  virtual ~LineItem()
67  {
68  delete _placeHolder;
69  }
70 
71  void setColor(const QColor & color);
72 
73 protected:
74  virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
75  {
76  QGraphicsScene * scene = this->scene();
77  if(scene && scene->focusItem() == 0)
78  {
79  this->showDescription();
80  }
81  else
82  {
83  this->setPen(QPen(pen().color(), _width+2));
84  }
85  QGraphicsLineItem::hoverEnterEvent(event);
86  }
87 
88  virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
89  {
90  if(!this->hasFocus())
91  {
92  this->hideDescription();
93  }
94  QGraphicsLineItem::hoverEnterEvent(event);
95  }
96 
97  virtual void focusInEvent ( QFocusEvent * event )
98  {
99  this->showDescription();
100  QGraphicsLineItem::focusInEvent(event);
101  }
102 
103  virtual void focusOutEvent ( QFocusEvent * event )
104  {
105  this->hideDescription();
106  QGraphicsLineItem::focusOutEvent(event);
107  }
108 
109 private:
111  {
112  if(!_text.isEmpty())
113  {
114  if(!_placeHolder)
115  {
116  _placeHolder = new QGraphicsRectItem (this);
117  _placeHolder->setVisible(false);
118  if(qGray(pen().color().rgb() > 255/2))
119  {
120  _placeHolder->setBrush(QBrush(QColor ( 0,0,0, 170 )));
121  }
122  else
123  {
124  _placeHolder->setBrush(QBrush(QColor ( 255, 255, 255, 170 )));
125  }
126  QGraphicsTextItem * text = new QGraphicsTextItem(_placeHolder);
127  text->setDefaultTextColor(this->pen().color().rgb());
128  text->setPlainText(_text);
129  _placeHolder->setRect(text->boundingRect());
130  }
131 
132  if(_placeHolder->parentItem())
133  {
134  _placeHolder->setParentItem(0); // Make it a to level item
135  }
136  _placeHolder->setZValue(this->zValue()+1);
137  _placeHolder->setPos(this->mapFromScene(0,0));
138  _placeHolder->setVisible(true);
139  }
140  QPen pen = this->pen();
141  this->setPen(QPen(pen.color(), _width+2));
142  }
144  {
145  if(_placeHolder)
146  {
147  _placeHolder->setVisible(false);
148  }
149  this->setPen(QPen(pen().color(), _width));
150  }
151 
152 private:
153  QString _text;
154  QGraphicsRectItem * _placeHolder;
155  int _width;
156 };
157 
158 QIcon ImageView::createIcon(const QColor & color)
159 {
160  QPixmap pixmap(50, 50);
161  pixmap.fill(color);
162  return QIcon(pixmap);
163 }
164 
165 ImageView::ImageView(QWidget * parent) :
166  QWidget(parent),
167  _alpha(100),
168  _featuresSize(0.0f),
169  _defaultBgColor(Qt::black),
170  _defaultFeatureColor(Qt::yellow),
171  _defaultMatchingFeatureColor(Qt::magenta),
172  _defaultMatchingLineColor(Qt::cyan),
173  _imageItem(0),
174  _imageDepthItem(0)
175 {
176 #if QT_VERSION >= 0x050000
177  _savedFileName = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
178 #endif
179  QDir dir;
180  if(!dir.exists(_savedFileName))
181  {
182  _savedFileName = QDir::homePath()+ "/picture.png";
183  }
184  else
185  {
186  _savedFileName += "/picture.png";
187  }
188 
189  _graphicsView = new QGraphicsView(this);
190  _graphicsView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
191  _graphicsView->setScene(new QGraphicsScene(this));
192  _graphicsView->setVisible(false);
193 
194  this->setLayout(new QVBoxLayout(this));
195  this->layout()->addWidget(_graphicsView);
196  this->layout()->setContentsMargins(0,0,0,0);
197 
198  _menu = new QMenu(tr(""), this);
199  _showImage = _menu->addAction(tr("Show image"));
200  _showImage->setCheckable(true);
201  _showImage->setChecked(true);
202  _showImageDepth = _menu->addAction(tr("Show image depth"));
203  _showImageDepth->setCheckable(true);
204  _showImageDepth->setChecked(false);
205  _featureMenu = _menu->addMenu("Features");
206  _showFeatures = _featureMenu->addAction(tr("Show features"));
207  _showFeatures->setCheckable(true);
208  _showFeatures->setChecked(true);
209  _setFeaturesSize = _featureMenu->addAction(tr("Set features size..."));
210  _showLines = _featureMenu->addAction(tr("Show lines"));
211  _showLines->setCheckable(true);
212  _showLines->setChecked(true);
213  _setFeatureColor = _featureMenu->addAction(tr("Set default feature color"));
215  _setFeatureColor->setIconVisibleInMenu(true);
216  _setMatchingFeatureColor = _featureMenu->addAction(tr("Set default correspondence color"));
218  _setMatchingFeatureColor->setIconVisibleInMenu(true);
219  _setMatchingLineColor = _featureMenu->addAction(tr("Set default line color"));
221  _setMatchingLineColor->setIconVisibleInMenu(true);
222  _setAlpha = _featureMenu->addAction(tr("Set transparency..."));
223  _graphicsViewMode = _menu->addAction(tr("Graphics view"));
224  _graphicsViewMode->setCheckable(true);
225  _graphicsViewMode->setChecked(false);
226  _scaleMenu = _menu->addMenu("Scale image");
227  _scaleMenu->setEnabled(false);
228  _graphicsViewScaled = _scaleMenu->addAction(tr("Fit in view"));
229  _graphicsViewScaled->setCheckable(true);
230  _graphicsViewScaled->setChecked(true);
231  _graphicsViewScaledToHeight = _scaleMenu->addAction(tr("Fit height"));
232  _graphicsViewScaledToHeight->setCheckable(true);
233  _graphicsViewScaledToHeight->setChecked(false);
234  _graphicsViewNoScaling = _scaleMenu->addAction(tr("No scale"));
235  _graphicsViewNoScaling->setCheckable(true);
236  _graphicsViewNoScaling->setChecked(false);
237  QActionGroup * group = new QActionGroup(this);
238  group->addAction(_graphicsViewScaled);
239  group->addAction(_graphicsViewScaledToHeight);
240  group->addAction(_graphicsViewNoScaling);
241  QMenu * colorMap = _menu->addMenu("Depth color map");
242  _colorMapWhiteToBlack = colorMap->addAction(tr("White to black"));
243  _colorMapWhiteToBlack->setCheckable(true);
244  _colorMapWhiteToBlack->setChecked(false);
245  _colorMapBlackToWhite = colorMap->addAction(tr("Black to white"));
246  _colorMapBlackToWhite->setCheckable(true);
247  _colorMapBlackToWhite->setChecked(false);
248  _colorMapRedToBlue = colorMap->addAction(tr("Red to blue"));
249  _colorMapRedToBlue->setCheckable(true);
250  _colorMapRedToBlue->setChecked(true);
251  _colorMapBlueToRed = colorMap->addAction(tr("Blue to red"));
252  _colorMapBlueToRed->setCheckable(true);
253  _colorMapBlueToRed->setChecked(false);
254  group = new QActionGroup(this);
255  group->addAction(_colorMapWhiteToBlack);
256  group->addAction(_colorMapBlackToWhite);
257  group->addAction(_colorMapRedToBlue);
258  group->addAction(_colorMapBlueToRed);
259  _saveImage = _menu->addAction(tr("Save picture..."));
260  _saveImage->setEnabled(false);
261 
262  connect(_graphicsView->scene(), SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(sceneRectChanged(const QRectF &)));
263 }
264 
266  clear();
267 }
268 
269 void ImageView::saveSettings(QSettings & settings, const QString & group) const
270 {
271  if(!group.isEmpty())
272  {
273  settings.beginGroup(group);
274  }
275  settings.setValue("image_shown", this->isImageShown());
276  settings.setValue("depth_shown", this->isImageDepthShown());
277  settings.setValue("features_shown", this->isFeaturesShown());
278  settings.setValue("features_size", this->getFeaturesSize());
279  settings.setValue("lines_shown", this->isLinesShown());
280  settings.setValue("alpha", this->getAlpha());
281  settings.setValue("bg_color", this->getDefaultBackgroundColor());
282  settings.setValue("feature_color", this->getDefaultFeatureColor());
283  settings.setValue("matching_feature_color", this->getDefaultMatchingFeatureColor());
284  settings.setValue("matching_line_color", this->getDefaultMatchingLineColor());
285  settings.setValue("graphics_view", this->isGraphicsViewMode());
286  settings.setValue("graphics_view_scale", this->isGraphicsViewScaled());
287  settings.setValue("graphics_view_scale_to_height", this->isGraphicsViewScaledToHeight());
288  settings.setValue("colormap", _colorMapWhiteToBlack->isChecked()?0:_colorMapBlackToWhite->isChecked()?1:_colorMapRedToBlue->isChecked()?2:3);
289  if(!group.isEmpty())
290  {
291  settings.endGroup();
292  }
293 }
294 
295 void ImageView::loadSettings(QSettings & settings, const QString & group)
296 {
297  if(!group.isEmpty())
298  {
299  settings.beginGroup(group);
300  }
301  this->setImageShown(settings.value("image_shown", this->isImageShown()).toBool());
302  this->setImageDepthShown(settings.value("depth_shown", this->isImageDepthShown()).toBool());
303  this->setFeaturesShown(settings.value("features_shown", this->isFeaturesShown()).toBool());
304  this->setFeaturesSize(settings.value("features_size", this->getFeaturesSize()).toInt());
305  this->setLinesShown(settings.value("lines_shown", this->isLinesShown()).toBool());
306  this->setAlpha(settings.value("alpha", this->getAlpha()).toInt());
307  this->setDefaultBackgroundColor(settings.value("bg_color", this->getDefaultBackgroundColor()).value<QColor>());
308  this->setDefaultFeatureColor(settings.value("feature_color", this->getDefaultFeatureColor()).value<QColor>());
309  this->setDefaultMatchingFeatureColor(settings.value("matching_feature_color", this->getDefaultMatchingFeatureColor()).value<QColor>());
310  this->setDefaultMatchingLineColor(settings.value("matching_line_color", this->getDefaultMatchingLineColor()).value<QColor>());
311  this->setGraphicsViewMode(settings.value("graphics_view", this->isGraphicsViewMode()).toBool());
312  this->setGraphicsViewScaled(settings.value("graphics_view_scale", this->isGraphicsViewScaled()).toBool());
313  this->setGraphicsViewScaledToHeight(settings.value("graphics_view_scale_to_height", this->isGraphicsViewScaledToHeight()).toBool());
314  int colorMap = settings.value("colormap", 2).toInt();
315  _colorMapWhiteToBlack->setChecked(colorMap==0);
316  _colorMapBlackToWhite->setChecked(colorMap==1);
317  _colorMapRedToBlue->setChecked(colorMap==2);
318  _colorMapBlueToRed->setChecked(colorMap==3);
319  if(!group.isEmpty())
320  {
321  settings.endGroup();
322  }
323 }
324 
325 QRectF ImageView::sceneRect() const
326 {
327  return _graphicsView->scene()->sceneRect();
328 }
329 
331 {
332  return _showImage->isChecked();
333 }
334 
336 {
337  return _showImageDepth->isChecked();
338 }
339 
341 {
342  return _showFeatures->isChecked();
343 }
344 
346 {
347  return _graphicsViewMode->isChecked();
348 }
349 
351 {
352  return _graphicsViewScaled->isChecked();
353 }
354 
356 {
357  return _graphicsViewScaledToHeight->isChecked();
358 }
359 
361 {
362  return _defaultBgColor;
363 }
364 const QColor & ImageView::getDefaultFeatureColor() const
365 {
366  return _defaultFeatureColor;
367 }
369 {
371 }
373 {
375 }
376 
377 const QColor & ImageView::getBackgroundColor() const
378 {
379  return _graphicsView->backgroundBrush().color();
380 }
381 
383 {
385  if(_colorMapBlackToWhite->isChecked())
386  {
387  colorMap = uCvQtDepthBlackToWhite;
388  }
389  else if(_colorMapRedToBlue->isChecked())
390  {
391  colorMap = uCvQtDepthRedToBlue;
392  }
393  else if(_colorMapBlueToRed->isChecked())
394  {
395  colorMap = uCvQtDepthBlueToRed;
396  }
397  return colorMap;
398 }
399 
400 
402 {
403  _showFeatures->setChecked(shown);
404  for(QMultiMap<int, KeypointItem*>::iterator iter=_features.begin(); iter!=_features.end(); ++iter)
405  {
406  iter.value()->setVisible(_showFeatures->isChecked());
407  }
408 
409  if(!_graphicsView->isVisible())
410  {
411  this->update();
412  }
413 }
414 
415 void ImageView::setImageShown(bool shown)
416 {
417  _showImage->setChecked(shown);
418  if(_imageItem)
419  {
420  _imageItem->setVisible(_showImage->isChecked());
421  this->updateOpacity();
422  }
423 
424  if(!_graphicsView->isVisible())
425  {
426  this->update();
427  }
428 }
429 
431 {
432  _showImageDepth->setChecked(shown);
433  if(_imageDepthItem)
434  {
435  _imageDepthItem->setVisible(_showImageDepth->isChecked());
436  this->updateOpacity();
437  }
438 
439  if(!_graphicsView->isVisible())
440  {
441  this->update();
442  }
443 }
444 
446 {
447  return _showLines->isChecked();
448 }
449 
450 void ImageView::setLinesShown(bool shown)
451 {
452  _showLines->setChecked(shown);
453  for(int i=0; i<_lines.size(); ++i)
454  {
455  _lines.at(i)->setVisible(_showLines->isChecked());
456  }
457 
458  if(!_graphicsView->isVisible())
459  {
460  this->update();
461  }
462 }
463 
464 float ImageView::viewScale() const
465 {
466  if(_graphicsView->isVisible())
467  {
468  return _graphicsView->transform().m11();
469  }
470  else
471  {
472  float scale, offsetX, offsetY;
473  computeScaleOffsets(this->rect(), scale, offsetX, offsetY);
474  return scale;
475  }
476 }
477 
479 {
480  _graphicsViewMode->setChecked(on);
481  _graphicsView->setVisible(on);
482  _scaleMenu->setEnabled(on);
483 
484  if(on)
485  {
486  for(QMultiMap<int, KeypointItem*>::iterator iter=_features.begin(); iter!=_features.end(); ++iter)
487  {
488  if(iter.value()->scene() != _graphicsView->scene())
489  {
490  _graphicsView->scene()->addItem(iter.value());
491  }
492  }
493 
494  for(QList<QGraphicsLineItem*>::iterator iter=_lines.begin(); iter!=_lines.end(); ++iter)
495  {
496  if((*iter)->scene() != _graphicsView->scene())
497  {
498  _graphicsView->scene()->addItem(*iter);
499  }
500  }
501 
502  //update images
503  if(_imageItem)
504  {
505  _imageItem->setPixmap(_image);
506  }
507  else
508  {
509  _imageItem = _graphicsView->scene()->addPixmap(_image);
510  _imageItem->setVisible(_showImage->isChecked());
511  }
512 
513  if(_imageDepthItem)
514  {
515  _imageDepthItem->setPixmap(_imageDepth);
516  }
517  else
518  {
519  _imageDepthItem = _graphicsView->scene()->addPixmap(_imageDepth);
520  _imageDepthItem->setVisible(_showImageDepth->isChecked());
521  }
522  this->updateOpacity();
523 
524  if(_graphicsViewScaled->isChecked())
525  {
526  _graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio);
527  }
528  else if(_graphicsViewScaledToHeight->isChecked())
529  {
530  QRectF rect = _graphicsView->sceneRect();
531  rect.setWidth(1);
532  _graphicsView->fitInView(rect, Qt::KeepAspectRatio);
533  }
534  else
535  {
536  _graphicsView->resetTransform();
537  }
538  }
539  else
540  {
541  this->update();
542  }
543 }
544 
546 {
547  _graphicsViewScaled->setChecked(scaled);
548 
549  if(scaled)
550  {
551  _graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio);
552  }
553  else
554  {
555  _graphicsView->resetTransform();
556  }
557 
558  if(!_graphicsView->isVisible())
559  {
560  this->update();
561  }
562 }
563 
565 {
566  _graphicsViewScaledToHeight->setChecked(scaled);
567 
568  if(scaled)
569  {
570  QRectF rect = _graphicsView->sceneRect();
571  rect.setWidth(1);
572  _graphicsView->fitInView(rect, Qt::KeepAspectRatio);
573  }
574  else
575  {
576  _graphicsView->resetTransform();
577  }
578 
579  if(!_graphicsView->isVisible())
580  {
581  this->update();
582  }
583 }
584 
585 void ImageView::setDefaultBackgroundColor(const QColor & color)
586 {
587  _defaultBgColor = color;
588  setBackgroundColor(color);
589 }
590 
591 void ImageView::setDefaultFeatureColor(const QColor & color)
592 {
593  QColor previousColor = _defaultFeatureColor;
594  _defaultFeatureColor = color;
595  for(QMultiMap<int, KeypointItem*>::iterator iter=_features.begin(); iter!=_features.end(); ++iter)
596  {
597  if(QColor(iter.value()->pen().color().rgb()) == previousColor)
598  {
599  QColor c = _defaultFeatureColor;
600  c.setAlpha(_alpha);
601  iter.value()->setPen(QPen(c));
602  iter.value()->setBrush(QBrush(c));
603  }
604  }
605  if(!_graphicsView->isVisible())
606  {
607  this->update();
608  }
609 }
611 {
612  QColor previousColor = _defaultMatchingFeatureColor;
614  for(QMultiMap<int, KeypointItem*>::iterator iter=_features.begin(); iter!=_features.end(); ++iter)
615  {
616  if(QColor(iter.value()->pen().color().rgb()) == previousColor)
617  {
618  QColor c = _defaultMatchingFeatureColor;
619  c.setAlpha(_alpha);
620  iter.value()->setPen(QPen(c));
621  iter.value()->setBrush(QBrush(c));
622  }
623  }
624 
625  for(QList<QGraphicsLineItem*>::iterator iter=_lines.begin(); iter!=_lines.end(); ++iter)
626  {
627  if(QColor((*iter)->pen().color().rgb()) == previousColor)
628  {
629  QColor c = _defaultMatchingFeatureColor;
630  c.setAlpha(_alpha);
631  (*iter)->setPen(QPen(c));
632  }
633  }
634  if(!_graphicsView->isVisible())
635  {
636  this->update();
637  }
638 }
639 void ImageView::setDefaultMatchingLineColor(const QColor & color)
640 {
641  QColor previousColor = _defaultMatchingLineColor;
643  for(QMultiMap<int, KeypointItem*>::iterator iter=_features.begin(); iter!=_features.end(); ++iter)
644  {
645  if(QColor(iter.value()->pen().color().rgb()) == previousColor)
646  {
647  QColor c = _defaultMatchingLineColor;
648  c.setAlpha(_alpha);
649  iter.value()->setPen(QPen(c));
650  iter.value()->setBrush(QBrush(c));
651  }
652  }
653 
654  for(QList<QGraphicsLineItem*>::iterator iter=_lines.begin(); iter!=_lines.end(); ++iter)
655  {
656  if(QColor((*iter)->pen().color().rgb()) == previousColor)
657  {
658  QColor c = _defaultMatchingLineColor;
659  c.setAlpha(_alpha);
660  (*iter)->setPen(QPen(c));
661  }
662  }
663  if(!_graphicsView->isVisible())
664  {
665  this->update();
666  }
667 }
668 
669 void ImageView::setBackgroundColor(const QColor & color)
670 {
671  _graphicsView->setBackgroundBrush(QBrush(color));
672 
673  if(!_graphicsView->isVisible())
674  {
675  this->update();
676  }
677 }
678 
679 void ImageView::computeScaleOffsets(const QRect & targetRect, float & scale, float & offsetX, float & offsetY) const
680 {
681  scale = 1.0f;
682  offsetX = 0.0f;
683  offsetY = 0.0f;
684 
685  if(!_graphicsView->scene()->sceneRect().isNull())
686  {
687  float w = _graphicsView->scene()->width();
688  float h = _graphicsView->scene()->height();
689  float widthRatio = float(targetRect.width()) / w;
690  float heightRatio = float(targetRect.height()) / h;
691 
692  //printf("w=%f, h=%f, wR=%f, hR=%f, sW=%d, sH=%d\n", w, h, widthRatio, heightRatio, this->rect().width(), this->rect().height());
693  if(widthRatio < heightRatio)
694  {
695  scale = widthRatio;
696  }
697  else
698  {
699  scale = heightRatio;
700  }
701 
702  //printf("ratio=%f\n",ratio);
703 
704  w *= scale;
705  h *= scale;
706 
707  if(w < targetRect.width())
708  {
709  offsetX = (targetRect.width() - w)/2.0f;
710  }
711  if(h < targetRect.height())
712  {
713  offsetY = (targetRect.height() - h)/2.0f;
714  }
715  //printf("offsetX=%f, offsetY=%f\n",offsetX, offsetY);
716  }
717 }
718 
719 void ImageView::sceneRectChanged(const QRectF & rect)
720 {
721  _saveImage->setEnabled(rect.isValid());
722 }
723 
724 void ImageView::paintEvent(QPaintEvent *event)
725 {
726  if(_graphicsViewMode->isChecked())
727  {
728  QWidget::paintEvent(event);
729  }
730  else
731  {
732  if(!_graphicsView->scene()->sceneRect().isNull())
733  {
734  //Scale
735  float ratio, offsetX, offsetY;
736  this->computeScaleOffsets(event->rect(), ratio, offsetX, offsetY);
737  QPainter painter(this);
738 
739  //Background
740  painter.save();
741  painter.setBrush(_graphicsView->backgroundBrush());
742  painter.drawRect(event->rect());
743  painter.restore();
744 
745  painter.translate(offsetX, offsetY);
746  painter.scale(ratio, ratio);
747 
748  painter.save();
749  if(_showImage->isChecked() && !_image.isNull() &&
750  _showImageDepth->isChecked() && !_imageDepth.isNull())
751  {
752  painter.setOpacity(0.5);
753  }
754 
755  if(_showImage->isChecked() && !_image.isNull())
756  {
757  painter.drawPixmap(QPoint(0,0), _image);
758  }
759 
760  if(_showImageDepth->isChecked() && !_imageDepth.isNull())
761  {
762  painter.drawPixmap(QPoint(0,0), _imageDepth);
763  }
764  painter.restore();
765 
766  if(_showFeatures->isChecked())
767  {
768  for(QMultiMap<int, rtabmap::KeypointItem *>::iterator iter = _features.begin(); iter != _features.end(); ++iter)
769  {
770  QColor color = iter.value()->pen().color();
771  painter.save();
772  painter.setPen(color);
773  painter.setBrush(color);
774  painter.drawEllipse(iter.value()->rect());
775  painter.restore();
776  }
777  }
778 
779  if(_showLines->isChecked())
780  {
781  for(QList<QGraphicsLineItem*>::iterator iter = _lines.begin(); iter != _lines.end(); ++iter)
782  {
783  QColor color = (*iter)->pen().color();
784  painter.save();
785  painter.setPen(color);
786  painter.drawLine((*iter)->line());
787  painter.restore();
788  }
789  }
790  }
791  }
792 }
793 
794 void ImageView::resizeEvent(QResizeEvent* event)
795 {
796  QWidget::resizeEvent(event);
797  if(_graphicsView->isVisible())
798  {
799  if(_graphicsViewScaled->isChecked())
800  {
801  _graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio);
802  }
803  else if(_graphicsViewScaledToHeight->isChecked())
804  {
805  QRectF rect = _graphicsView->sceneRect();
806  rect.setWidth(1);
807  _graphicsView->fitInView(rect, Qt::KeepAspectRatio);
808  }
809  }
810 }
811 
812 void ImageView::contextMenuEvent(QContextMenuEvent * e)
813 {
817  _setFeatureColor->setIconVisibleInMenu(true);
818  _setMatchingFeatureColor->setIconVisibleInMenu(true);
819  _setMatchingLineColor->setIconVisibleInMenu(true);
820 
821  QAction * action = _menu->exec(e->globalPos());
822  if(action == _saveImage)
823  {
824  if(!_graphicsView->scene()->sceneRect().isNull())
825  {
826  QString text;
827  QString extensions = "*.png *.xpm *.jpg";
828  if(_graphicsView->isVisible())
829  {
830  extensions += " *.pdf";
831  }
832 #ifdef QT_SVG_LIB
833  extensions += " *.svg";
834 #endif
835  text = QFileDialog::getSaveFileName(this, tr("Save figure to ..."), _savedFileName, extensions);
836 
837  if(!text.isEmpty())
838  {
839  if(QFileInfo(text).suffix() == "")
840  {
841  //use png by default
842  text += ".png";
843  }
844 
845  _savedFileName = text;
846  if(QFileInfo(text).suffix().compare("pdf") == 0)
847  {
848  QPrinter printer(QPrinter::HighResolution);
849  printer.setOrientation(QPrinter::Portrait);
850  printer.setOutputFileName( text );
851  QPainter p(&printer);
852  p.begin(&printer);
853  double xscale = printer.pageRect().width()/double(_graphicsView->sceneRect().width());
854  double yscale = printer.pageRect().height()/double(_graphicsView->sceneRect().height());
855  double scale = qMin(xscale, yscale);
856  p.scale(scale, scale);
857  _graphicsView->scene()->render(&p, _graphicsView->sceneRect(), _graphicsView->sceneRect());
858  p.end();
859  }
860  else
861  {
862  QImage img(_graphicsView->sceneRect().width(), _graphicsView->sceneRect().height(), QImage::Format_ARGB32_Premultiplied);
863  QPainter p(&img);
864  if(_graphicsView->isVisible())
865  {
866  _graphicsView->scene()->render(&p, _graphicsView->sceneRect(), _graphicsView->sceneRect());
867  }
868  else
869  {
870  this->render(&p, QPoint(), _graphicsView->sceneRect().toRect());
871  }
872  img.save(text);
873  }
874  }
875  }
876  }
877  else if(action == _showFeatures)
878  {
879  this->setFeaturesShown(_showFeatures->isChecked());
880  Q_EMIT configChanged();
881  }
882  else if(action == _setFeatureColor ||
883  action == _setMatchingFeatureColor ||
884  action == _setMatchingLineColor)
885  {
886  QColor color;
887  if(action == _setMatchingFeatureColor)
888  {
890  }
891  else if(action == _setMatchingLineColor)
892  {
894  }
895  else //if(action == _setFeatureColor)
896  {
897  color = _defaultFeatureColor;
898  }
899  color = QColorDialog::getColor(color, this);
900  if(color.isValid())
901  {
902 
903  if(action == _setMatchingFeatureColor)
904  {
905  this->setDefaultMatchingFeatureColor(color);
906  }
907  else if(action == _setMatchingLineColor)
908  {
909  this->setDefaultMatchingLineColor(color);
910  }
911  else //if(action == _setFeatureColor)
912  {
913  this->setDefaultFeatureColor(color);
914  }
915  }
916  }
917  else if(action == _showImage)
918  {
919  this->setImageShown(_showImage->isChecked());
920  Q_EMIT configChanged();
921  }
922  else if(action == _showImageDepth)
923  {
924  this->setImageDepthShown(_showImageDepth->isChecked());
925  Q_EMIT configChanged();
926  }
927  else if(action == _showLines)
928  {
929  this->setLinesShown(_showLines->isChecked());
930  Q_EMIT configChanged();
931  }
932  else if(action == _graphicsViewMode)
933  {
934  this->setGraphicsViewMode(_graphicsViewMode->isChecked());
935  Q_EMIT configChanged();
936  }
937  else if(action == _graphicsViewScaled)
938  {
939  this->setGraphicsViewScaled(_graphicsViewScaled->isChecked());
940  Q_EMIT configChanged();
941  }
942  else if(action == _graphicsViewScaledToHeight || action == _graphicsViewNoScaling)
943  {
945  Q_EMIT configChanged();
946  }
947  else if(action == _colorMapBlackToWhite || action == _colorMapWhiteToBlack || action == _colorMapRedToBlue || action == _colorMapBlueToRed)
948  {
949  if(!_imageDepthCv.empty())
951  Q_EMIT configChanged();
952  }
953  else if(action == _setAlpha)
954  {
955  bool ok = false;
956  int value = QInputDialog::getInt(this, tr("Set features and lines transparency"), tr("alpha (0-255)"), _alpha, 0, 255, 10, &ok);
957  if(ok)
958  {
959  this->setAlpha(value);
960  Q_EMIT configChanged();
961  }
962  }
963  else if(action == _setFeaturesSize)
964  {
965  bool ok = false;
966  int value = QInputDialog::getInt(this, tr("Set features size"), tr("Size (0 means actual keypoint size)"), _featuresSize, 0, 999, 1, &ok);
967  if(ok)
968  {
969  this->setFeaturesSize(value);
970  Q_EMIT configChanged();
971  }
972  }
973 
974  if(action == _showImage || action ==_showImageDepth)
975  {
976  this->updateOpacity();
977  Q_EMIT configChanged();
978  }
979 }
980 
982 {
984  {
985  if(_imageItem->isVisible() && _imageDepthItem->isVisible())
986  {
987  QGraphicsOpacityEffect * effect = new QGraphicsOpacityEffect();
988  effect->setOpacity(0.5);
989  _imageDepthItem->setGraphicsEffect(effect);
990  }
991  else
992  {
993  _imageDepthItem->setGraphicsEffect(0);
994  }
995  }
996  else if(_imageDepthItem)
997  {
998  _imageDepthItem->setGraphicsEffect(0);
999  }
1000 }
1001 
1002 void ImageView::setFeatures(const std::multimap<int, cv::KeyPoint> & refWords, const cv::Mat & depth, const QColor & color)
1003 {
1004  clearFeatures();
1005 
1006  float xRatio = 0;
1007  float yRatio = 0;
1008  if (this->sceneRect().isValid() && !depth.empty() && int(this->sceneRect().height()) % depth.rows == 0 && int(this->sceneRect().width()) % depth.cols == 0)
1009  {
1010  UDEBUG("depth=%dx%d sceneRect=%fx%f", depth.cols, depth.rows, this->sceneRect().width(), this->sceneRect().height());
1011  xRatio = float(depth.cols)/float(this->sceneRect().width());
1012  yRatio = float(depth.rows)/float(this->sceneRect().height());
1013  UDEBUG("xRatio=%f yRatio=%f", xRatio, yRatio);
1014  }
1015 
1016  for(std::multimap<int, cv::KeyPoint>::const_iterator iter = refWords.begin(); iter != refWords.end(); ++iter )
1017  {
1018  if (xRatio > 0 && yRatio > 0)
1019  {
1020  addFeature(iter->first, iter->second, util2d::getDepth(depth, iter->second.pt.x*xRatio, iter->second.pt.y*yRatio, false), color);
1021  }
1022  else
1023  {
1024  addFeature(iter->first, iter->second, 0, color);
1025  }
1026  }
1027 
1028  if(!_graphicsView->isVisible())
1029  {
1030  this->update();
1031  }
1032 }
1033 
1034 void ImageView::setFeatures(const std::vector<cv::KeyPoint> & features, const cv::Mat & depth, const QColor & color)
1035 {
1036  clearFeatures();
1037 
1038  float xRatio = 0;
1039  float yRatio = 0;
1040  if (this->sceneRect().isValid() && !depth.empty() && int(this->sceneRect().height()) % depth.rows == 0 && int(this->sceneRect().width()) % depth.cols == 0)
1041  {
1042  UDEBUG("depth=%dx%d sceneRect=%fx%f", depth.cols, depth.rows, this->sceneRect().width(), this->sceneRect().height());
1043  xRatio = float(depth.cols) / float(this->sceneRect().width());
1044  yRatio = float(depth.rows) / float(this->sceneRect().height());
1045  UDEBUG("xRatio=%f yRatio=%f", xRatio, yRatio);
1046  }
1047 
1048  for(unsigned int i = 0; i< features.size(); ++i )
1049  {
1050  if(xRatio > 0 && yRatio > 0)
1051  {
1052  addFeature(i, features[i], util2d::getDepth(depth, features[i].pt.x*xRatio, features[i].pt.y*yRatio, false), color);
1053  }
1054  else
1055  {
1056  addFeature(i, features[i], 0, color);
1057  }
1058  }
1059 
1060  if(!_graphicsView->isVisible())
1061  {
1062  this->update();
1063  }
1064 }
1065 
1066 void ImageView::addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor color)
1067 {
1068  color.setAlpha(this->getAlpha());
1069  rtabmap::KeypointItem * item = new rtabmap::KeypointItem(id, kpt, depth, color);
1070  if(_featuresSize>0.0f)
1071  {
1072  item->setRect(kpt.pt.x-_featuresSize/2.0f, kpt.pt.y-_featuresSize/2.0f, _featuresSize, _featuresSize);
1073  }
1074  _features.insert(id, item);
1075  item->setVisible(isFeaturesShown());
1076  item->setZValue(1);
1077 
1078  if(_graphicsView->isVisible())
1079  {
1080  _graphicsView->scene()->addItem(item);
1081  }
1082 }
1083 
1084 void ImageView::addLine(float x1, float y1, float x2, float y2, QColor color, const QString & text)
1085 {
1086  color.setAlpha(this->getAlpha());
1087  LineItem * item = new LineItem(x1, y1, x2, y2, text);
1088  item->setPen(QPen(color));
1089  _lines.push_back(item);
1090  item->setVisible(isLinesShown());
1091  item->setZValue(1);
1092 
1093  if(_graphicsView->isVisible())
1094  {
1095  _graphicsView->scene()->addItem(item);
1096  }
1097 }
1098 
1099 void ImageView::setImage(const QImage & image)
1100 {
1101  _image = QPixmap::fromImage(image);
1102  if(_graphicsView->isVisible())
1103  {
1104  if(_imageItem)
1105  {
1106  _imageItem->setPixmap(_image);
1107  }
1108  else
1109  {
1110  _imageItem = _graphicsView->scene()->addPixmap(_image);
1111  _imageItem->setVisible(_showImage->isChecked());
1112  this->updateOpacity();
1113  }
1114  }
1115 
1116  if(image.rect().isValid())
1117  {
1118  this->setSceneRect(image.rect());
1119  }
1120  else if(!_graphicsView->isVisible())
1121  {
1122  this->update();
1123  }
1124 }
1125 
1126 void ImageView::setImageDepth(const cv::Mat & imageDepth)
1127 {
1128  _imageDepthCv = imageDepth;
1130 }
1131 
1132 void ImageView::setImageDepth(const QImage & imageDepth)
1133 {
1134  _imageDepth = QPixmap::fromImage(imageDepth);
1135 
1136  UASSERT(_imageDepth.width() && _imageDepth.height());
1137 
1138  if( _image.width() > 0 &&
1139  _image.width() > _imageDepth.width() &&
1140  _image.height() > _imageDepth.height())
1141  {
1142  // scale depth to rgb
1143  _imageDepth = _imageDepth.scaled(_image.size());
1144  }
1145 
1146  if(_graphicsView->isVisible())
1147  {
1148  if(_imageDepthItem)
1149  {
1150  _imageDepthItem->setPixmap(_imageDepth);
1151  }
1152  else
1153  {
1154  _imageDepthItem = _graphicsView->scene()->addPixmap(_imageDepth);
1155  _imageDepthItem->setVisible(_showImageDepth->isChecked());
1156  this->updateOpacity();
1157  }
1158  }
1159  else
1160  {
1161  if(_image.isNull())
1162  {
1163  this->setSceneRect(imageDepth.rect());
1164  }
1165  this->update();
1166  }
1167 }
1168 
1169 void ImageView::setFeatureColor(int id, QColor color)
1170 {
1171  color.setAlpha(getAlpha());
1172  QList<KeypointItem*> items = _features.values(id);
1173  if(items.size())
1174  {
1175  for(int i=0; i<items.size(); ++i)
1176  {
1177  items[i]->setColor(color);
1178  }
1179  }
1180  else
1181  {
1182  UWARN("Not found feature %d", id);
1183  }
1184 
1185  if(!_graphicsView->isVisible())
1186  {
1187  this->update();
1188  }
1189 }
1190 
1192 {
1193  color.setAlpha(getAlpha());
1194  for(QMultiMap<int, KeypointItem*>::iterator iter=_features.begin(); iter!=_features.end(); ++iter)
1195  {
1196  iter.value()->setColor(color);
1197  }
1198 
1199  if(!_graphicsView->isVisible())
1200  {
1201  this->update();
1202  }
1203 }
1204 
1205 void ImageView::setAlpha(int alpha)
1206 {
1207  UASSERT(alpha >=0 && alpha <= 255);
1208  _alpha = alpha;
1209  for(QMultiMap<int, KeypointItem*>::iterator iter=_features.begin(); iter!=_features.end(); ++iter)
1210  {
1211  QColor c = iter.value()->pen().color();
1212  c.setAlpha(_alpha);
1213  iter.value()->setPen(QPen(c));
1214  iter.value()->setBrush(QBrush(c));
1215  }
1216 
1217  for(QList<QGraphicsLineItem*>::iterator iter=_lines.begin(); iter!=_lines.end(); ++iter)
1218  {
1219  QColor c = (*iter)->pen().color();
1220  c.setAlpha(_alpha);
1221  (*iter)->setPen(QPen(c));
1222  }
1223 
1224  if(!_graphicsView->isVisible())
1225  {
1226  this->update();
1227  }
1228 }
1229 
1231 {
1232  _featuresSize = size;
1233  for(QMultiMap<int, KeypointItem*>::iterator iter=_features.begin(); iter!=_features.end(); ++iter)
1234  {
1235  const cv::KeyPoint & kpt = iter.value()->keypoint();
1236  if(size <= 0.0f)
1237  {
1238  size = kpt.size==0?3:kpt.size;
1239  }
1240  float sizef = size;
1241  iter.value()->setRect(kpt.pt.x-sizef/2.0f, kpt.pt.y-sizef/2.0f, sizef, sizef);
1242  }
1243 
1244  if(!_graphicsView->isVisible())
1245  {
1246  this->update();
1247  }
1248 }
1249 
1250 void ImageView::setSceneRect(const QRectF & rect)
1251 {
1252  _graphicsView->scene()->setSceneRect(rect);
1253 
1254  if(_graphicsViewScaled->isChecked())
1255  {
1256  _graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio);
1257  }
1258  else if(_graphicsViewScaledToHeight->isChecked())
1259  {
1260  QRectF rect = _graphicsView->sceneRect();
1261  rect.setWidth(1);
1262  _graphicsView->fitInView(rect, Qt::KeepAspectRatio);
1263  }
1264  else
1265  {
1266  _graphicsView->resetTransform();
1267  }
1268 
1269  if(!_graphicsView->isVisible())
1270  {
1271  this->update();
1272  }
1273 }
1274 
1276 {
1277  qDeleteAll(_lines);
1278  _lines.clear();
1279 
1280  if(!_graphicsView->isVisible())
1281  {
1282  this->update();
1283  }
1284 }
1285 
1287 {
1288  qDeleteAll(_features);
1289  _features.clear();
1290 
1291  if(!_graphicsView->isVisible())
1292  {
1293  this->update();
1294  }
1295 }
1296 
1298 {
1299  clearFeatures();
1300 
1301  qDeleteAll(_lines);
1302  _lines.clear();
1303 
1304  if(_imageItem)
1305  {
1306  _graphicsView->scene()->removeItem(_imageItem);
1307  delete _imageItem;
1308  _imageItem = 0;
1309  }
1310  _image = QPixmap();
1311 
1312  if(_imageDepthItem)
1313  {
1314  _graphicsView->scene()->removeItem(_imageDepthItem);
1315  delete _imageDepthItem;
1316  _imageDepthItem = 0;
1317  }
1318  _imageDepth = QPixmap();
1319 
1320  _graphicsView->scene()->setSceneRect(QRectF());
1321  _graphicsView->setScene(_graphicsView->scene());
1322 
1323  if(!_graphicsView->isVisible())
1324  {
1325  this->update();
1326  }
1327 }
1328 
1329 QSize ImageView::sizeHint() const
1330 {
1331  return _graphicsView->sizeHint();
1332 }
1333 
1334 }
void setDefaultFeatureColor(const QColor &color)
Definition: ImageView.cpp:591
void addLine(float x1, float y1, float x2, float y2, QColor color, const QString &text=QString())
Definition: ImageView.cpp:1084
QMultiMap< int, rtabmap::KeypointItem * > _features
Definition: ImageView.h:160
bool isImageDepthShown() const
Definition: ImageView.cpp:335
QAction * _showImageDepth
Definition: ImageView.h:139
void setAlpha(int alpha)
Definition: ImageView.cpp:1205
const QColor & getDefaultMatchingFeatureColor() const
Definition: ImageView.cpp:368
void showDescription()
Definition: ImageView.cpp:110
bool isLinesShown() const
Definition: ImageView.cpp:445
void setDefaultMatchingLineColor(const QColor &color)
Definition: ImageView.cpp:639
QAction * _showLines
Definition: ImageView.h:141
void setFeaturesColor(QColor color)
Definition: ImageView.cpp:1191
f
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
Definition: ImageView.cpp:74
bool isImageShown() const
Definition: ImageView.cpp:330
bool isGraphicsViewScaledToHeight() const
Definition: ImageView.cpp:355
void setFeatureColor(int id, QColor color)
Definition: ImageView.cpp:1169
QAction * _setFeaturesSize
Definition: ImageView.h:147
void setLinesShown(bool shown)
Definition: ImageView.cpp:450
void computeScaleOffsets(const QRect &targetRect, float &scale, float &offsetX, float &offsetY) const
Definition: ImageView.cpp:679
QList< QGraphicsLineItem * > _lines
Definition: ImageView.h:161
bool isGraphicsViewScaled() const
Definition: ImageView.cpp:350
GLM_FUNC_DECL genType e()
GLM_FUNC_DECL detail::tmat4x4< T, P > scale(detail::tmat4x4< T, P > const &m, detail::tvec3< T, P > const &v)
QColor _defaultBgColor
Definition: ImageView.h:132
void setFeaturesSize(int size)
Definition: ImageView.cpp:1230
QAction * _showImage
Definition: ImageView.h:138
QAction * _graphicsViewScaledToHeight
Definition: ImageView.h:150
void setImage(const QImage &image)
Definition: ImageView.cpp:1099
LineItem(float x1, float y1, float x2, float y2, const QString &text=QString(), QGraphicsItem *parent=0)
Definition: ImageView.cpp:57
QAction * _colorMapRedToBlue
Definition: ImageView.h:154
const QColor & getDefaultBackgroundColor() const
Definition: ImageView.cpp:360
QAction * _setMatchingFeatureColor
Definition: ImageView.h:143
virtual ~ImageView()
Definition: ImageView.cpp:265
#define UASSERT(condition)
QGraphicsView * _graphicsView
Definition: ImageView.h:159
QAction * _graphicsViewMode
Definition: ImageView.h:148
void loadSettings(QSettings &settings, const QString &group="")
Definition: ImageView.cpp:295
void setSceneRect(const QRectF &rect)
Definition: ImageView.cpp:1250
void setImageShown(bool shown)
Definition: ImageView.cpp:415
void setBackgroundColor(const QColor &color)
Definition: ImageView.cpp:669
QGraphicsRectItem * _placeHolder
Definition: ImageView.cpp:154
QGraphicsPixmapItem * _imageItem
Definition: ImageView.h:162
QAction * _saveImage
Definition: ImageView.h:145
QImage uCvMat2QImage(const cv::Mat &image, bool isBgr=true, uCvQtDepthColorMap colorMap=uCvQtDepthWhiteToBlack)
Definition: UCv2Qt.h:44
void setGraphicsViewScaledToHeight(bool scaled)
Definition: ImageView.cpp:564
void setDefaultMatchingFeatureColor(const QColor &color)
Definition: ImageView.cpp:610
virtual ~LineItem()
Definition: ImageView.cpp:66
QAction * _colorMapWhiteToBlack
Definition: ImageView.h:152
QColor _defaultMatchingFeatureColor
Definition: ImageView.h:134
void setImageDepth(const cv::Mat &imageDepth)
Definition: ImageView.cpp:1126
void setFeaturesShown(bool shown)
Definition: ImageView.cpp:401
QColor _defaultFeatureColor
Definition: ImageView.h:133
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Definition: ImageView.cpp:88
QMenu * _scaleMenu
Definition: ImageView.h:157
virtual void focusOutEvent(QFocusEvent *event)
Definition: ImageView.cpp:103
virtual QSize sizeHint() const
Definition: ImageView.cpp:1329
ImageView(QWidget *parent=0)
Definition: ImageView.cpp:165
QRectF sceneRect() const
Definition: ImageView.cpp:325
void addFeature(int id, const cv::KeyPoint &kpt, float depth, QColor color)
Definition: ImageView.cpp:1066
QPixmap _imageDepth
Definition: ImageView.h:165
QAction * _setMatchingLineColor
Definition: ImageView.h:144
bool isGraphicsViewMode() const
Definition: ImageView.cpp:345
void setGraphicsViewMode(bool on)
Definition: ImageView.cpp:478
QAction * _setAlpha
Definition: ImageView.h:146
void hideDescription()
Definition: ImageView.cpp:143
void setColor(const QColor &color)
const QColor & getBackgroundColor() const
Definition: ImageView.cpp:377
virtual void focusInEvent(QFocusEvent *event)
Definition: ImageView.cpp:97
const QColor & getDefaultFeatureColor() const
Definition: ImageView.cpp:364
void setGraphicsViewScaled(bool scaled)
Definition: ImageView.cpp:545
QAction * _colorMapBlueToRed
Definition: ImageView.h:155
virtual void resizeEvent(QResizeEvent *event)
Definition: ImageView.cpp:794
const QColor & getDefaultMatchingLineColor() const
Definition: ImageView.cpp:372
#define UDEBUG(...)
QAction * _showFeatures
Definition: ImageView.h:140
QMenu * _featureMenu
Definition: ImageView.h:156
int getAlpha() const
Definition: ImageView.h:64
QAction * _setFeatureColor
Definition: ImageView.h:142
QColor _defaultMatchingLineColor
Definition: ImageView.h:135
virtual void paintEvent(QPaintEvent *event)
Definition: ImageView.cpp:724
void sceneRectChanged(const QRectF &rect)
Definition: ImageView.cpp:719
QIcon createIcon(const QColor &color)
Definition: ImageView.cpp:158
ULogger class and convenient macros.
#define UWARN(...)
float viewScale() const
Definition: ImageView.cpp:464
QAction * _colorMapBlackToWhite
Definition: ImageView.h:153
bool isFeaturesShown() const
Definition: ImageView.cpp:340
uCvQtDepthColorMap
Definition: UCv2Qt.h:30
QString _savedFileName
Definition: ImageView.h:129
float RTABMAP_EXP getDepth(const cv::Mat &depthImage, float x, float y, bool smoothing, float depthErrorRatio=0.02f, bool estWithNeighborsIfNull=false)
Definition: util2d.cpp:947
virtual void contextMenuEvent(QContextMenuEvent *e)
Definition: ImageView.cpp:812
QAction * _graphicsViewNoScaling
Definition: ImageView.h:151
void setFeatures(const std::multimap< int, cv::KeyPoint > &refWords, const cv::Mat &depth=cv::Mat(), const QColor &color=Qt::yellow)
Definition: ImageView.cpp:1002
uCvQtDepthColorMap getDepthColorMap() const
Definition: ImageView.cpp:382
int getFeaturesSize() const
Definition: ImageView.h:65
cv::Mat _imageDepthCv
Definition: ImageView.h:166
void setDefaultBackgroundColor(const QColor &color)
Definition: ImageView.cpp:585
void saveSettings(QSettings &settings, const QString &group="") const
Definition: ImageView.cpp:269
QAction * _graphicsViewScaled
Definition: ImageView.h:149
void setImageDepthShown(bool shown)
Definition: ImageView.cpp:430
QGraphicsPixmapItem * _imageDepthItem
Definition: ImageView.h:163


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:59