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 <valarray>
27
28#include <QMutex>
29#include <QWidget>
30
31#include <Eigen/Dense>
32
33#include <ArmarXCore/interface/observers/ObserverInterface.h>
35
36
37using Eigen::MatrixXf;
38
39namespace Ui
40{
41 class MatrixDatafieldDisplayWidget;
42}
43
44namespace armarx
45{
46 class MatrixDatafieldDisplayWidget : public QWidget
47 {
48 Q_OBJECT
49
50 signals:
51 void doUpdate();
52
53 private slots:
54 void updateRequested();
55
56 public:
57 explicit MatrixDatafieldDisplayWidget(DatafieldRefBasePtr matrixDatafield,
58 ObserverInterfacePrx observer,
59 QWidget* parent = 0);
61 void paintEvent(QPaintEvent*) override;
62
63 void
64 setRange(float min, float max)
65 {
66 this->min = min;
67 this->max = max;
68 }
69
70 void enableOffsetFilter(bool enabled);
71 QColor getColor(float value, float min, float max);
72
73 void
75 {
76 emit doUpdate();
77 }
78
79 void
80 setInfoOverlay(QString infoOverlay)
81 {
82 mtx.lock();
83 this->infoOverlay = infoOverlay;
84 mtx.unlock();
85 }
86
87 private:
88 void drawMatrix(const QRect& target, QPainter& painter);
89 void drawPercentiles(const QRect& target, QPainter& painter);
90
91 private:
92 Ui::MatrixDatafieldDisplayWidget* ui;
93 MatrixXf data;
94 std::vector<float> percentiles;
95 float min, max;
96 std::valarray<QColor> colors;
97 QMutex mtx;
98 QString infoOverlay;
99 DatafieldRefPtr matrixDatafield;
100 DatafieldRefPtr matrixDatafieldOffsetFiltered;
101 DatafieldRefPtr percentilesDatafield;
102 ObserverInterfacePrx observer;
103 };
104} // namespace armarx
MatrixDatafieldDisplayWidget(DatafieldRefBasePtr matrixDatafield, ObserverInterfacePrx observer, QWidget *parent=0)
QColor getColor(float value, float min, float max)
ArmarX Headers.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< DatafieldRef > DatafieldRefPtr
Definition Observer.h:43
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)