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


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:28