rock_widget_collection  0.1
ImageView.cc
Go to the documentation of this file.
1 
5 #include "ImageView.h"
7 
8 #include <base-logging/Logging.hpp>
9 #include <iostream>
10 
11 #include <QtOpenGL/QGLWidget>
12 #include "GraphicsPointsItem.h"
13 
14 #ifdef USE_GST
15  #include <QGst/Init>
16  #include <QGst/Parse>
17  #include <QGst/Pipeline>
18  #include <QGst/ElementFactory>
19  #include <QGst/Ui/VideoWidget>
20  #include <QGst/Ui/GraphicsVideoSurface>
21  #include <QGst/Ui/GraphicsVideoWidget>
22 #endif
23 
24 ImageView::ImageView(QWidget *parent)
25  : QWidget(parent),
26  bgColor(QColor(Qt::black)),
27  use_progress_indicator(true),
28  use_smooth_transformation(true),
29  progress_indicator_timeout(2500),
30  rgb_swapped(false),
31  invert_color(false),
32  progress_indicator_timer(this),
33  context_menu(this),
34  rotate_image_clockwise_act(this),
35  save_image_act(this),
36  save_image_overlay_act(this),
37  activate_progress_indicator_act(this),
38  rgb_swapped_act(this),
39  invert_color_act(this)
40 #ifdef USE_GST
41  ,
42  pipelineDescription("videotestsrc ! ximagesink"), //qtglvideosink
43  use_gl(false)
44 #endif
45 {
46  setWindowTitle("ImageView");
47  setMinimumSize(220,170);
48  setContentsMargins(0,0,0,0);
49 
50  imageItem = NULL;
51 
52  /* Configure progress indicator */
53  progress_indicator.setAnimationDelay(40);
54  progress_indicator.setDisplayedWhenStopped(false);
55  progress_indicator.resize(30,30);
56  progress_indicator.hide();
57 
58  /* Set up timer for progress indicator */
59  progress_indicator_timer.setInterval(getProgressIndicatorTimeout());
60  connect(&progress_indicator_timer, SIGNAL(timeout()), this, SLOT(startProgressIndicator()));
61 
62  setupContextMenu();
63 
64 #ifdef USE_GST
65  QGst::PipelinePtr pipeline;
66  QGst::ElementPtr videoSrc;
67  /* GStreamer setup */
68  QGst::init();
69 
70 // pipeline = QGst::Parse::launch(pipelineDescription).dynamicCast<QGst::Pipeline>();
71  pipeline = QGst::Pipeline::create("pipeline"); // Create hard coded pipeline for debugging
72  videoSrc = QGst::ElementFactory::make("videotestsrc");
73 #endif
74 
75  /* Setup inner graphicsscene and view. This scene contains the image and image related overlays. */
76  imageScene = new QGraphicsScene(this);
77  imageScene->setBackgroundBrush(getBackgroundColor());
78  imageScene->installEventFilter(this); // to get mouse press events to emit clicked image coordinate
79 
80  imageView = new QGraphicsView(imageScene);
81  imageView->setAlignment(Qt::AlignCenter);
82  imageView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
83  imageView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
84  imageView->setFocusPolicy(Qt::NoFocus);
85  imageView->setFrameStyle(QFrame::NoFrame);
86  imageView->setContentsMargins(0,0,0,0);
87 
88 #ifdef USE_GST
89  if(use_gl) {
90  // Indicator to use qtglvideosink (hardware rendering!) instead of qtvideosink
91  imageView->setViewport(new QGLWidget);
92  }
93 
94  QGst::Ui::GraphicsVideoSurface *surface = NULL;
95  QGst::Ui::GraphicsVideoWidget *widget = NULL;
96 
97  surface = new QGst::Ui::GraphicsVideoSurface(view);
98  widget = new QGst::Ui::GraphicsVideoWidget;
99  widget->setSurface(surface);
100 
101  scene->addItem(widget);
102 
103  // Connect hard coded pipeline
104  pipeline->add(videoSrc, surface->videoSink());
105  videoSrc->link(surface->videoSink());
106 
107  LOG_INFO_S << "Video source name: " << surface->videoSink()->property("name").toString().toStdString();
108 
109  /* Try to start playing */
110  if(!pipeline->setState(QGst::StatePlaying)) {
111  // TODO proper fallback handling
112  LOG_WARN("Could not play pipeline.");
113  }
114 #else
115  imageItem = new QGraphicsPixmapItem;
116 
118 
119  imageScene->addItem(imageItem);
120 #endif
121 
122  /* Setup outer graphicsscene and view. This scene contains fixed overlays like the
123  * image timestamp which are immune to rotation etc. i.e. they stay at the same place
124  * nevertheless the inner scene gets rotated or scaled.
125  */
126  fixedOverlayScene = new QGraphicsScene(this);
127  fixedOverlayScene->setBackgroundBrush(Qt::transparent);
128 
129  fixedOverlayView = new QGraphicsView(fixedOverlayScene, this);
130  fixedOverlayView->setAlignment(Qt::AlignCenter);
131  fixedOverlayView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
132  fixedOverlayView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
133  fixedOverlayView->setFocusPolicy(Qt::NoFocus);
134  fixedOverlayView->setFrameStyle(QFrame::NoFrame);
135  fixedOverlayView->setContentsMargins(0,0,0,0);
136 
137  /* Layout for outer scene to help positioning text overlay */
138  overlay_grid = new QGraphicsGridLayout;
139 
140  /* XXX Transparent middle item with variable size (default). This snaps the border items to the border.
141  * TODO That seems to eliminate the possibility of a middle widget with fixed size.
142  */
143  QGraphicsWidget *label_mi = fixedOverlayScene->addWidget(new QLabel);
144  QPalette label_mi_pal;
145  label_mi_pal.setColor(QPalette::Window, QColor(Qt::transparent));
146  //label_mi_pal.setColor(QPalette::Window, QColor(Qt::white));
147  label_mi->setPalette(label_mi_pal);
148  label_mi->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
149  overlay_grid->addItem(label_mi, 1, 1, Qt::AlignVCenter|Qt::AlignCenter);
150 
151  overlayWidget = new ContextMenuGraphicsWidget;//new QGraphicsWidget;
152  connect(overlayWidget, SIGNAL(contextMenuRequest(QPoint)), this, SLOT(displayContextMenu(QPoint)));
153 
154  overlayWidget->setLayout(overlay_grid);
155  overlayWidget->setZValue(12);
156  fixedOverlayScene->addItem(overlayWidget);
157 
158  // Nest inner view in outer scene
159  imageViewProxy = fixedOverlayScene->addWidget(imageView);
160 
161  progress_indicator.setParent(fixedOverlayView);
162 
163  setItemPositions();
164  update();
165 }
166 
168 {
169 }
170 
171 QSize ImageView::sizeHint() const
172 {
173  return QSize(500,500);
174 }
175 
176 const QColor& ImageView::getBackgroundColor() const
177 {
178  return bgColor;
179 }
180 
181 void ImageView::setBackgroundColor(const QColor & color)
182 {
183  bgColor = color;
184  imageScene->setBackgroundBrush(bgColor);
185 }
186 
188 {
189  return use_progress_indicator;
190 }
191 
192 
194 {
196  progress_indicator.hide();
197 
198  if(use) {
199  progress_indicator_timer.start();
200  // TODO Maybe unwanted behavior since the timer starts even if there is not a single frame yet.
201  // But it is nice if you trigger the use of the progress indicator while the replay is stopped.
202  }
203  else {
204  // Disable possibly already running widget
205  progress_indicator_timer.stop();
206  progress_indicator.stopAnimation();
207  }
208 }
209 
211 {
213 }
214 
216 {
217  use_smooth_transformation = smooth;
218  if(smooth)
219  imageItem->setTransformationMode(Qt::SmoothTransformation);
220  else
221  imageItem->setTransformationMode(Qt::FastTransformation);
222 }
223 
225 {
227 }
228 
230 {
231  progress_indicator_timeout = timeout;
232  progress_indicator_timer.setInterval(timeout);
233 }
234 
235 #ifdef USE_GST
236  const QString ImageView::getPipelineDescription() const
237  {
238  return pipelineDescription;
239  }
240 
241  void ImageView::setPipelineDescription(QString descr)
242  {
243  this->pipelineDescription = descr;
244  }
245 
246  bool ImageView::getUseGl()
247  {
248  return this->use_gl;
249  }
250 
251  void ImageView::setUseGl(bool use_gl)
252  {
253  this->use_gl = use_gl;
254  }
255 #endif /* USE_GST */
256 
257 void ImageView::addCircle(QPointF &center, double radius, QColor &color, int width, bool persistent)
258 {
259  QGraphicsEllipseItem *circlePtr =
260  new QGraphicsEllipseItem(QRectF(center.x() - radius/2.0, center.y() - radius/2.0, radius, radius));
261  QPen pen;
262  pen.setColor(color);
263  pen.setWidth(width);
264  circlePtr->setPen(pen);
265 
266  addDrawItem(imageScene, circlePtr, persistent);
267 }
268 
269 void ImageView::addLine(QLineF &line, QColor &color, int width, bool persistent)
270 {
271  QGraphicsLineItem *linePtr = new QGraphicsLineItem(line);
272  QPen pen;
273  pen.setColor(color);
274  pen.setWidth(width);
275  linePtr->setPen(pen);
276 
277  addDrawItem(imageScene, linePtr, persistent);
278 }
279 
280 void ImageView::addPoints(const QList<int> points_x,QList<int> points_y, QColor &color, int width, bool persistent)
281 {
282  QList<QPoint> points;
283  QList<int>::const_iterator iter1 = points_x.begin();
284  QList<int>::const_iterator iter2 = points_y.begin();
285  for(;iter1 != points_x.end() && iter2 != points_y.end();++iter1,++iter2)
286  {
287  points.push_back(QPoint(*iter1,*iter2));
288  }
289 
290  GraphicsPointsItem *pointsPtr = new GraphicsPointsItem(points);
291  QPen pen;
292  pen.setColor(color);
293  pen.setWidth(width);
294  pointsPtr->setPen(pen);
295 
296  addDrawItem(imageScene, pointsPtr, persistent);
297 }
298 
299 void ImageView::addPolygon(QPolygonF &polygon, QColor &color, int width, bool persistent)
300 {
301  LOG_DEBUG_S << "Received polygon. Polygon closed: " << polygon.isClosed();
302  LOG_DEBUG_S << "The polygon has a size of " << polygon.size() << ".";
303  QGraphicsPolygonItem *polygonPtr = new QGraphicsPolygonItem(polygon);
304  QPen pen;
305  pen.setColor(color);
306  pen.setWidth(width);
307  polygonPtr->setPen(pen);
308 
309  addDrawItem(imageScene, polygonPtr, persistent);
310 }
311 
312 void ImageView::addText(QString text, /*TextLocation*/ int location, QColor color, bool persistent)
313 {
314  /* Positioning */
315  int row = 0;
316  int col = 0;
317  Qt::Alignment alignment = Qt::AlignLeft;
318 
319  switch(location) {
320  case TOPLEFT :
321  row = 0;
322  col = 0;
323  alignment = Qt::AlignTop|Qt::AlignLeft;
324  break;
325  case TOPRIGHT :
326  row = 0;
327  col = 2;
328  alignment = Qt::AlignTop|Qt::AlignRight;
329  break;
330  case BOTTOMLEFT :
331  row = 2;
332  col = 0;
333  alignment = Qt::AlignBottom|Qt::AlignLeft;
334  break;
335  case BOTTOMRIGHT :
336  row = 2;
337  col = 2;
338  alignment = Qt::AlignBottom|Qt::AlignRight;
339  break;
340  default:
341  LOG_WARN("Unsupported text location. Switching to TOPLEFT.");
342  addText(text, TOPLEFT, persistent);
343  return;
344  }
345 
346  QLabel *label = NULL;
347  QGraphicsWidget *textLabel = NULL;
348  int margin = 1;
349 
350  // Avoid displaying empty labels, i.e. labels with margin only and no text
351  if(text.isEmpty()) {
352  margin = 0;
353  }
354 
355  // Label for text location already exists?
356  if(overlayMap.contains(location)) {
357  // Alter existing label
358  label = overlayMap[location];
359  label->setText(text);
360  label->adjustSize();
361  } else {
362  // Add new label to map
363  label = new QLabel(text);
364  label->setVisible(false);
365  label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
366 
367  overlayMap[location] = label;
368 
369  textLabel = fixedOverlayScene->addWidget(label);
370  overlay_grid->addItem(textLabel, row, col, alignment);
371  textLabel->setVisible(true); // TODO use label instead?
372  }
373 
374  QPalette palette;
375  QColor labelBgColor(Qt::white);
376  labelBgColor.setAlphaF(0.7);
377  palette.setColor(QPalette::Window, labelBgColor);
378  palette.setColor(QPalette::WindowText, color);
379  palette.setColor(QPalette::Text, color); // <-- this one seems to be working but WindowText should be correct according to docu
380 
381  label->setPalette(palette);
382  label->setMargin(margin);
383 
384  QFont font("Monospace");
385  font.setPointSize(12);
386  font.setStyleHint(QFont::TypeWriter);
387  label->setFont(font);
388 
389  label->setMaximumSize(label->sizeHint());
390 
391 // std::cout << "label size hint: " << label->sizeHint().width() << "," << label->sizeHint().height() << " ('" << text.toStdString().data() << "')" << std::endl;
392 // std::cout << "label size: " << label->width() << "," << label->height() << " ('" << text.toStdString().data() << "')" << std::endl;
393 // std::cout << "label maximum size: " << label->maximumSize().width() << "," << label->maximumSize().height() << " ('" << text.toStdString().data() << "')" << std::endl;
394 // std::cout << "---" << std::endl;
395 
396  overlay_grid->invalidate();
397  //addDrawItem(NULL, textLabel, persistent); // TODO check correctness of deletion etc.
398  update();
399 }
400 
401 void ImageView::clearOverlays(bool clear_persistent_items)
402 {
403  if(clear_persistent_items) {
404  Q_FOREACH(QGraphicsItem *item, persistentDrawItems) {
405  item->scene()->removeItem(item);
406  }
407  persistentDrawItems.clear();
408  }
409 
410  Q_FOREACH(QGraphicsItem *item, volatileDrawItems) {
411  item->scene()->removeItem(item);
412  }
413  volatileDrawItems.clear();
414 }
415 
416 void ImageView::rotate(int deg)
417 {
418  imageView->rotate(deg);
419  imageView->fitInView(imageItem, Qt::KeepAspectRatio);
420  //view->fitInView(view->sceneRect(), Qt::KeepAspectRatio);
421 }
422 
423 void ImageView::saveImage(QString path, bool overlay)
424 {
425  QImage saveImage(imageScene->sceneRect().size().toSize(), image.format());
426  saveImage.fill(0); // Painter cannnot handle null image
427 
428  /* Get destination path if not submitted */
429  if(path.isEmpty()) {
430  path = QFileDialog::getSaveFileName(this, "Save Image",
431  last_path,
432  "Images (*.png)");
433  last_path = path;
434  }
435 
436  /* Save original image or also the overlay? */
437  if(overlay) {
438  QPainter painter(&saveImage);
439 
440  // Render image and image overlays first
441  imageScene->render(&painter);
442 
443  QSize oldSize = size();
444  QSize newSize = imageScene->sceneRect().size().toSize();
445 
446  // Hide image view from outer scene. It is already painted.
447  imageViewProxy->hide();
448 
449  fixedOverlayScene->setSceneRect(imageScene->sceneRect());
450  overlayWidget->resize(newSize);
451 
452  // Render outer scene (text overlays) on top
453  fixedOverlayScene->render(&painter);
454 
455  imageViewProxy->show();
456 
457  // restore old sizes
458  resize(oldSize.width(),oldSize.height()+1);
459  resize(oldSize.width(),oldSize.height()-1);
460  } else {
461  saveImage = image;
462  }
463 
464  saveImage.save(path, "PNG", 80);
465 }
466 
467 void ImageView::setFrame(const base::samples::DistanceImage &frame)
468 {
469 
470  base::samples::frame::Frame bframe(frame.width,frame.height,16);
471  std::vector<uint16_t> v(frame.data.size());
472  for(unsigned int i=0;i<v.size();i++){
473  v[i] = frame.data[i];
474  }
475 
476  bframe.setImage((uint8_t*)&v[0],frame.data.size()*2);
477  if(1 == frame_converter.copyFrameToQImageRGB888(image,bframe)) {
478  LOG_WARN("Frame size changed while converting frame to QImage (says converter)");
479  }
480  processImage();
481  refresh();
482 }
483 
484 void ImageView::setFrame(const base::samples::frame::Frame &frame)
485 {
486  if(1 == frame_converter.copyFrameToQImageRGB888(image,frame)) {
487  LOG_WARN("Frame size changed while converting frame to QImage (says converter)");
488  }
489  processImage();
490  refresh();
491 }
492 
493 void ImageView::setRawImage(const QString &mode, int pixel_size, int width, int height,const char* pbuffer, const int size)
494 {
495  frame_converter.copyFrameToQImageRGB888(image,mode, pixel_size, width, height,pbuffer,size);
496  processImage();
497  refresh();
498 }
499 
500 void ImageView::setImage(const QImage &image)
501 {
502  this->image = image.copy();
503  processImage();
504  refresh();
505 }
506 
508 {
509  if(getInvertColor())
510  image.invertPixels();
511  if(getRgbSwapped())
512  image = image.rgbSwapped();
513 }
514 
516 {
518  progress_indicator.hide();
519  progress_indicator_timer.start();
520  progress_indicator.stopAnimation();
521  }
522 
523 #ifdef USE_GST
524  // TODO
525 #else
526  clearOverlays();
527 
528  // Backup image size for detecting size change
529  QSize oldSize = imageSize;
530  imageSize = image.size();
531  //std::cout << "Image size: x=" << image.width() <<", y=" << image.height() << std::endl;
532  QPixmap pixmap = QPixmap::fromImage(image);
533  pixmap.scaled(size(), Qt::KeepAspectRatio);
534 
535  //std::cout << "Pixmap size: x=" << pixmap.width() <<", y=" << pixmap.height() << std::endl;
536  if(imageItem) {
537  imageItem->setPixmap(pixmap);
538  } else {
539  LOG_WARN("imageItem undefined!");
540  }
541 
542  //std::cout << "ImageItem BoundingRect: x=" << imageItem->boundingRect().width() <<", y=" << imageItem->boundingRect().height() << std::endl;
543 
544  /* Resize and repositioning if frame size changes (and on start) */
545  if(imageSize != oldSize) {
546  LOG_INFO("image size changed. resize.");
547 
548  // Avoid dynamic scene growth
549  imageScene->setSceneRect(0, 0, imageSize.width(), imageSize.height());
550 
551  setItemPositions();
552 
553  /* For some reason the first frame is not scaled to fit the full space.
554  * Calling update or even repaint did not help but a simple resize or
555  * setVisible does. On Debian, you have to call both ???
556  */
557  setVisible(false); setVisible(true);
558  resize(width(),height()-1);
559  resize(width(),height()+1);
560  }
561  update();
562 #endif
563 }
564 
565 /* PROTECTED METHODS ---------------------------------------------------------- */
566 
567 void ImageView::resizeEvent(QResizeEvent *event)
568 {
569  QWidget::resizeEvent(event);
570 
571  //fixedOverlayScene->setSceneRect(fixedOverlayScene->itemsBoundingRect());
572  QSize eventSize = event->size();
573  fixedOverlayScene->setSceneRect(0, 0, eventSize.width(), eventSize.height());
574  imageView->resize(eventSize);
575 
576 
577 // std::cout << "resize event.\nview.width: " << view->width() << "\n"
578 // << "view.height: " << view->height() << std::endl;
579 
580  imageView->fitInView(imageItem, Qt::KeepAspectRatio);
581 
582 
583  fixedOverlayView->resize(eventSize);
584  overlayWidget->resize(eventSize);
585  setItemPositions();
586  LOG_DEBUG_S << "scene dimensions:\n"
587  << "fixedOverlayScene (w/h): (" << fixedOverlayScene->width() << "," << fixedOverlayScene->height() << ")\n"
588  << "imageScene (w/h): (" << imageScene->width() << "," << imageScene->height() << ")\n";
589 }
590 
591 void ImageView::contextMenuEvent ( QContextMenuEvent * event )
592 {
593  context_menu.exec(event->globalPos());
594 }
595 
596 bool ImageView::eventFilter(QObject* obj, QEvent* event)
597 {
598  //std::cout << "Got an event: " << event->type() << std::endl;
599 
600  if (event->type() == QEvent::GraphicsSceneMousePress) {
601  QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
602 
603  QPoint scenePos = mouseEvent->scenePos().toPoint();
604 
605  // Clicked on image scene?
606  if(imageScene->sceneRect().contains(scenePos)) {
607  LOG_INFO_S << "Clicked at image coordinate (w,h) (" << scenePos.x() << "," << scenePos.y() << ")";
608  emit clickedImage(scenePos);
609  }
610 
611  return true;
612  } else {
613  // standard event processing
614  return QObject::eventFilter(obj, event);
615  }
616 }
617 
618 
619 /* PRIVATE SLOTS ------------------------------------------------------------ */
620 
621 void ImageView::displayContextMenu(QPoint screenPos)
622 {
623  LOG_DEBUG("Got context menu request signal");
624  context_menu.exec(screenPos);
625 }
626 
627 void ImageView::rotate_clockwise()
628 {
629  rotate(90);
630 }
631 
632 void ImageView::save_image()
633 {
634  saveImage(QString(), false);
635 }
636 
637 void ImageView::save_image_overlay()
638 {
639  saveImage(QString(), true);
640 }
641 
642 void ImageView::startProgressIndicator()
643 {
644  progress_indicator.show();
645  progress_indicator.startAnimation();
646 }
647 
648 
649 /* PRIVATE METHODS ---------------------------------------------------------- */
650 
651 void ImageView::addDrawItem(QGraphicsScene* scene, QGraphicsItem *item, bool persistent)
652 {
653  //std::cout << "addDrawItem: adding item: " << item << std::endl;
654 
655  if(persistent) {
656  persistentDrawItems.push_back(item);
657  } else {
658  volatileDrawItems.push_back(item);
659  }
660  if(scene) {// Text overlays are already in the scene and have therefore scene==null
661  LOG_DEBUG("Adding item to scene");
662  scene->addItem(item);
663  }
664  update();
665 }
666 
668 {
669  QWidget::update();
670 }
671 
672 void ImageView::setItemPositions()
673 {
674  // Align to center of view (scene gets always fit in view)
675  progress_indicator.move(imageView->width()/2 - progress_indicator.width()/2,
676  imageView->height()/2 - progress_indicator.height()/2);
677 }
678 
680 {
681  return imageSize.height();
682 }
683 
685 {
686  return imageSize.width();
687 }
688 
689 void ImageView::setInvertColor(bool invert)
690 {
691  if(invert_color == invert)
692  return;
693  invert_color=invert;
694  image.invertPixels();
695  refresh();
696 }
697 void ImageView::setRgbSwapped(bool swapped)
698 {
699  if(rgb_swapped == swapped)
700  return;
701  rgb_swapped=swapped;
702  image = image.rgbSwapped();
703  refresh();
704 }
705 
706 void ImageView::setupContextMenu()
707 {
708  rgb_swapped_act.setText("RGB Swapped");
709  rgb_swapped_act.setCheckable(true);
710  rgb_swapped_act.setChecked(getRgbSwapped());
711  connect(&rgb_swapped_act,SIGNAL(triggered(bool)),this,SLOT(setRgbSwapped(bool)));
712  context_menu.addAction(&rgb_swapped_act);
713 
714  invert_color_act.setText("Invert Color");
715  invert_color_act.setCheckable(true);
716  invert_color_act.setChecked(getInvertColor());
717  connect(&invert_color_act,SIGNAL(triggered(bool)),this,SLOT(setInvertColor(bool)));
718  context_menu.addAction(&invert_color_act);
719 
720  rotate_image_clockwise_act.setText("Rotate 90 deg");
721  connect(&rotate_image_clockwise_act,SIGNAL(triggered()),this,SLOT(rotate_clockwise()));
722  context_menu.addAction(&rotate_image_clockwise_act);
723 
724  save_image_act.setText("Save");
725  connect(&save_image_act,SIGNAL(triggered()),this,SLOT(save_image()));
726  context_menu.addAction(&save_image_act);
727 
728  save_image_overlay_act.setText("Save with Overlay");
729  connect(&save_image_overlay_act,SIGNAL(triggered()),this,SLOT(save_image_overlay()));
730  context_menu.addAction(&save_image_overlay_act);
731 
732  activate_progress_indicator_act.setText("Show Progress-Indicator");
733  activate_progress_indicator_act.setCheckable(true);
734  activate_progress_indicator_act.setChecked(use_progress_indicator);
735  connect(&activate_progress_indicator_act,SIGNAL(triggered(bool)),this,SLOT(setUseProgressIndicator(bool)));
736  context_menu.addAction(&activate_progress_indicator_act);
737 }
738 
void setRawImage(const QString &mode, int pixel_size, int width, int height, const char *pbuffer, const int size)
Definition: ImageView.cc:493
void addText(QString text, int location, QColor color=QColor(Qt::black), bool persistent=0)
Draws text overlay.
Definition: ImageView.cc:312
void saveImage(QString path=QString(), bool overlay=0)
Saves current image to file.
Definition: ImageView.cc:423
void setRgbSwapped(bool swapped)
Definition: ImageView.cc:697
void addPoints(const QList< int > points_x, QList< int > points_y, QColor &color, int width, bool persistent=0)
Draws points overlay (2D point cloud).
Definition: ImageView.cc:280
const int getProgressIndicatorTimeout() const
Definition: ImageView.cc:224
bool getRgbSwapped()
Definition: ImageView.h:134
void setUseProgressIndicator(bool use)
Definition: ImageView.cc:193
void setImage(const QImage &image)
Definition: ImageView.cc:500
void addCircle(QPointF &center, double radius, QColor &color, int width, bool persistent=0)
Draws circle overlay.
Definition: ImageView.cc:257
bool useProgressIndicator()
Definition: ImageView.cc:187
void setPen(const QPen &pen)
virtual ~ImageView()
Definition: ImageView.cc:167
ImageView(QWidget *parent=0)
Definition: ImageView.cc:24
void setBackgroundColor(const QColor &color)
Definition: ImageView.cc:181
void addPolygon(QPolygonF &polygon, QColor &color, int width, bool persistent=0)
Draws polygon overlay.
Definition: ImageView.cc:299
const QColor & getBackgroundColor() const
Definition: ImageView.cc:176
bool useSmoothTransformation()
Definition: ImageView.cc:210
void clickedImage(const QPoint &point)
Mouse click coordinates in image.
bool eventFilter(QObject *obj, QEvent *event)
Definition: ImageView.cc:596
bool invert_color
Definition: ImageView.h:80
void setAnimationDelay(int delay)
void refresh()
Definition: ImageView.cc:515
bool use_progress_indicator
Display progress indicator widget if no frames have being received for a defined time.
Definition: ImageView.h:65
void setInvertColor(bool invert)
Definition: ImageView.cc:689
void setFrame(const base::samples::DistanceImage &frame)
Frame input.
Definition: ImageView.cc:467
void setSmoothTransformation(bool smooth)
Definition: ImageView.cc:215
int getWidth() const
returns the real width of the underlaying widget
Definition: ImageView.cc:684
void update2()
Wrapper for QWidget::update(). This is due to some QtRuby limitations.
Definition: ImageView.cc:667
bool getInvertColor()
Definition: ImageView.h:132
bool use_smooth_transformation
Usage of antialiasing techniques during image transformation.
Definition: ImageView.h:77
void setProgressIndicatorTimeout(int timeout)
Definition: ImageView.cc:229
void setDisplayedWhenStopped(bool state)
QSize sizeHint() const
Definition: ImageView.cc:171
void contextMenuEvent(QContextMenuEvent *event)
Definition: ImageView.cc:591
void rotate(int deg)
Rotates image display.
Definition: ImageView.cc:416
void clearOverlays(bool clear_persistent_items=0)
Removes overlays.
Definition: ImageView.cc:401
void resizeEvent(QResizeEvent *event)
Definition: ImageView.cc:567
void addLine(QLineF &line, QColor &color, int width, bool persistent=0)
Draws line overlay.
Definition: ImageView.cc:269
void processImage()
Definition: ImageView.cc:507
int progress_indicator_timeout
The time without frame update in ms after which the progress indicator gets started.
Definition: ImageView.h:68
int getHeight() const
returns the real height of the underlaying widget
Definition: ImageView.cc:679
Definition: DrawItem.h:19
bool rgb_swapped
Definition: ImageView.h:79