MatrixDisplayWidget.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 <valarray>
27 
28 #include <QMutex>
29 #include <QWidget>
30 
31 #include <Eigen/Dense>
32 
33 using Eigen::MatrixXf;
34 
35 namespace Ui
36 {
37  class MatrixDisplayWidget;
38 }
39 
40 namespace armarx
41 {
42  class MatrixDisplayWidget : public QWidget
43  {
44  Q_OBJECT
45 
46  signals:
47  void doUpdate();
48 
49  public slots:
50 
51  void
52  setData(MatrixXf data)
53  {
54  mtx.lock();
55  this->data = data;
56  mtx.unlock();
57  //this->update();
58  }
59 
60  public:
61  explicit MatrixDisplayWidget(QWidget* parent = 0);
62  ~MatrixDisplayWidget() override;
63  void paintEvent(QPaintEvent*) override;
64 
65  void
66  setRange(float min, float max)
67  {
68  this->min = min;
69  this->max = max;
70  }
71 
72  QColor getColor(float value, float min, float max);
73 
74  void
76  {
77  emit doUpdate();
78  }
79 
80  void
81  setInfoOverlay(QString infoOverlay)
82  {
83  mtx.lock();
84  this->infoOverlay = infoOverlay;
85  mtx.unlock();
86  }
87 
88  private:
89  Ui::MatrixDisplayWidget* ui;
90  MatrixXf data;
91  float min, max;
92  std::valarray<QColor> colors;
93  QMutex mtx;
94  QString infoOverlay;
95  };
96 } // namespace armarx
armarx::MatrixDisplayWidget::setInfoOverlay
void setInfoOverlay(QString infoOverlay)
Definition: MatrixDisplayWidget.h:81
armarx::MatrixDisplayWidget::invokeUpdate
void invokeUpdate()
Definition: MatrixDisplayWidget.h:75
armarx::max
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:297
armarx::MatrixDisplayWidget::setRange
void setRange(float min, float max)
Definition: MatrixDisplayWidget.h:66
armarx::MatrixDisplayWidget::MatrixDisplayWidget
MatrixDisplayWidget(QWidget *parent=0)
Definition: MatrixDisplayWidget.cpp:36
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
armarx::MatrixDisplayWidget::getColor
QColor getColor(float value, float min, float max)
Definition: MatrixDisplayWidget.cpp:94
armarx::MatrixDisplayWidget::setData
void setData(MatrixXf data)
Definition: MatrixDisplayWidget.h:52
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::MatrixDisplayWidget::~MatrixDisplayWidget
~MatrixDisplayWidget() override
Definition: MatrixDisplayWidget.cpp:57
armarx::MatrixDisplayWidget::doUpdate
void doUpdate()
armarx::MatrixDisplayWidget
Definition: MatrixDisplayWidget.h:42
armarx::min
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:327
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::MatrixDisplayWidget::paintEvent
void paintEvent(QPaintEvent *) override
Definition: MatrixDisplayWidget.cpp:63