MatrixDatafieldDisplayWidget.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
26 #include <QWidget>
27 #include <QMutex>
28 #include <Eigen/Dense>
29 #include <valarray>
30 #include <ArmarXCore/interface/observers/ObserverInterface.h>
32 
33 
34 using Eigen::MatrixXf;
35 
36 namespace Ui
37 {
38  class MatrixDatafieldDisplayWidget;
39 }
40 
41 namespace armarx
42 {
43  class MatrixDatafieldDisplayWidget : public QWidget
44  {
45  Q_OBJECT
46 
47  signals:
48  void doUpdate();
49 
50  private slots:
51  void updateRequested();
52 
53  public:
54  explicit MatrixDatafieldDisplayWidget(DatafieldRefBasePtr matrixDatafield, ObserverInterfacePrx observer, QWidget* parent = 0);
56  void paintEvent(QPaintEvent*) override;
57 
58 
59  void setRange(float min, float max)
60  {
61  this->min = min;
62  this->max = max;
63  }
64  void enableOffsetFilter(bool enabled);
65  QColor getColor(float value, float min, float max);
66 
67  void invokeUpdate()
68  {
69  emit doUpdate();
70  }
71  void setInfoOverlay(QString infoOverlay)
72  {
73  mtx.lock();
74  this->infoOverlay = infoOverlay;
75  mtx.unlock();
76  }
77 
78  private:
79  void drawMatrix(const QRect& target, QPainter& painter);
80  void drawPercentiles(const QRect& target, QPainter& painter);
81 
82  private:
83  Ui::MatrixDatafieldDisplayWidget* ui;
84  MatrixXf data;
85  std::vector<float> percentiles;
86  float min, max;
87  std::valarray<QColor> colors;
88  QMutex mtx;
89  QString infoOverlay;
90  DatafieldRefPtr matrixDatafield;
91  DatafieldRefPtr matrixDatafieldOffsetFiltered;
92  DatafieldRefPtr percentilesDatafield;
93  ObserverInterfacePrx observer;
94  };
95 }
96 
armarx::MatrixDatafieldDisplayWidget::setInfoOverlay
void setInfoOverlay(QString infoOverlay)
Definition: MatrixDatafieldDisplayWidget.h:71
armarx::MatrixDatafieldDisplayWidget
Definition: MatrixDatafieldDisplayWidget.h:43
armarx::MatrixDatafieldDisplayWidget::enableOffsetFilter
void enableOffsetFilter(bool enabled)
Definition: MatrixDatafieldDisplayWidget.cpp:87
armarx::MatrixDatafieldDisplayWidget::doUpdate
void doUpdate()
armarx::MatrixDatafieldDisplayWidget::paintEvent
void paintEvent(QPaintEvent *) override
Definition: MatrixDatafieldDisplayWidget.cpp:68
boost::target
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:688
armarx::max
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:267
armarx::MatrixDatafieldDisplayWidget::MatrixDatafieldDisplayWidget
MatrixDatafieldDisplayWidget(DatafieldRefBasePtr matrixDatafield, ObserverInterfacePrx observer, QWidget *parent=0)
Definition: MatrixDatafieldDisplayWidget.cpp:44
armarx::MatrixDatafieldDisplayWidget::~MatrixDatafieldDisplayWidget
~MatrixDatafieldDisplayWidget() override
Definition: MatrixDatafieldDisplayWidget.cpp:63
IceInternal::Handle< DatafieldRef >
DatafieldRef.h
armarx::MatrixDatafieldDisplayWidget::setRange
void setRange(float min, float max)
Definition: MatrixDatafieldDisplayWidget.h:59
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
enabled
std::atomic< bool > * enabled
Definition: RemoteGuiWidgetController.cpp:75
armarx::MatrixDatafieldDisplayWidget::invokeUpdate
void invokeUpdate()
Definition: MatrixDatafieldDisplayWidget.h:67
armarx::MatrixDatafieldDisplayWidget::getColor
QColor getColor(float value, float min, float max)
Definition: MatrixDatafieldDisplayWidget.cpp:101
armarx::min
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:294
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28