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