MorphoGraphX  2.0-1-227
QTransferFunctionViewer.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef QTRANSFERFUNCTIONVIEWER_HPP
12 #define QTRANSFERFUNCTIONVIEWER_HPP
13 
14 #include <Config.hpp>
15 
16 #include <TransferFunction.hpp>
17 
18 #include <QColor>
19 #include <QLinearGradient>
20 #include <QPainterPath>
21 #include <QWidget>
22 #include <vector>
23 
24 class QMouseEvent;
25 class QPixmap;
26 class QAction;
27 class QPaintEvent;
28 
29 namespace mgx {
30  class mgx_EXPORT QTransferFunctionViewer : public QWidget {
31  Q_OBJECT
32  public:
34  enum BackgroundType { BG_CHECKS, BG_WHITE, BG_BLACK };
35 
36  QTransferFunctionViewer(QWidget* parent = 0, Qt::WindowFlags f = 0);
38  }
39 
40  size_t nbValues() const;
41 
43  return transfer_fct;
44  }
45 
46  public slots:
47  void changeNbValues(int n);
48  void reverseFunction();
49  void changeTransferFunction(const TransferFunction& fct);
50  void setupGradient();
51  void setHistogram(const std::vector<double>& h);
52  void setBounds(double min, double max);
53  void setStickers(const std::vector<double>& s);
54  void setMarkerSize(int s);
55  void setCheckSize(int s);
56  void setBackgroundType(BackgroundType type);
57  void setInterpolation(TransferFunction::Interpolation i);
58  void setSelectionColor(QColor col);
59  void editMarkers();
60  void autoAdjust();
61 
62  signals:
63  void changedTransferFunction(const TransferFunction& fct);
64 
65  protected:
66  void paintEvent(QPaintEvent* event);
67  void mouseDoubleClickEvent(QMouseEvent* e);
68  void mousePressEvent(QMouseEvent* e);
69  void mouseReleaseEvent(QMouseEvent* e);
70  void mouseMoveEvent(QMouseEvent* e);
71  void resetMouseInteraction();
72 
73  void prepareHistogram();
74 
75  void createBackground();
76  QPixmap createChecks();
77 
79  std::vector<double> histogram, hist_values;
80  double minValue, maxValue;
81  QPainterPath hist_shape;
83  std::vector<double> stickers;
84  bool sticking;
86  bool select_pos;
87  double current_pos;
88  int bg_size;
89  double bg_bright;
90  double bg_dark;
93  double saved_pos;
94  QAction* reverse_act, *edit_markers;
95  QLinearGradient gradient;
97  size_t _nb_values;
98  };
99 }
100 #endif
mgx::QTransferFunctionViewer::bg_bright
double bg_bright
Definition: QTransferFunctionViewer.hpp:89
mgx::QTransferFunctionViewer::minValue
double minValue
Definition: QTransferFunctionViewer.hpp:80
mgx::QTransferFunctionViewer::BackgroundType
BackgroundType
Definition: QTransferFunctionViewer.hpp:34
mgx::QTransferFunctionViewer::stickers
std::vector< double > stickers
Definition: QTransferFunctionViewer.hpp:83
TransferFunction.hpp
mgx::QTransferFunctionViewer::transferFunction
const TransferFunction & transferFunction() const
Definition: QTransferFunctionViewer.hpp:42
mgx::QTransferFunctionViewer::bg_type
BackgroundType bg_type
Definition: QTransferFunctionViewer.hpp:96
mgx::QTransferFunctionViewer::gradient
QLinearGradient gradient
Definition: QTransferFunctionViewer.hpp:95
n
#define n
Definition: Eigenvalues.hpp:36
mgx::TransferFunction
Definition: TransferFunction.hpp:34
mgx::QTransferFunctionViewer::saved_color
Colorf saved_color
Definition: QTransferFunctionViewer.hpp:92
mgx::QTransferFunctionViewer::current_pos
double current_pos
Definition: QTransferFunctionViewer.hpp:87
mgx
Distributed matrix library.
Definition: Assert.hpp:26
mgx::QTransferFunctionViewer::saved_pos
double saved_pos
Definition: QTransferFunctionViewer.hpp:93
mgx::TransferFunction::Interpolation
Interpolation
Type of interpolation.
Definition: TransferFunction.hpp:40
mgx::QTransferFunctionViewer::Colorf
TransferFunction::Colorf Colorf
Definition: QTransferFunctionViewer.hpp:33
mgx::max
T CU_HOST_DEVICE max(const T a, const T b)
Definition: Util.hpp:34
mgx::QTransferFunctionViewer::marker_size
int marker_size
Definition: QTransferFunctionViewer.hpp:85
mgx::QTransferFunctionViewer::select_pos
bool select_pos
Definition: QTransferFunctionViewer.hpp:86
mgx::QTransferFunctionViewer::hist_shape
QPainterPath hist_shape
Definition: QTransferFunctionViewer.hpp:81
mgx::QTransferFunctionViewer::reverse_act
QAction * reverse_act
Definition: QTransferFunctionViewer.hpp:94
mgx::QTransferFunctionViewer::BG_WHITE
@ BG_WHITE
Definition: QTransferFunctionViewer.hpp:34
mgx::QTransferFunctionViewer::bg_size
int bg_size
Definition: QTransferFunctionViewer.hpp:88
mgx::QTransferFunctionViewer::use_histogram
bool use_histogram
Definition: QTransferFunctionViewer.hpp:82
mgx::min
CU_HOST_DEVICE T min(const T a, const T b)
Definition: Util.hpp:26
mgx::QTransferFunctionViewer::sticking
bool sticking
Definition: QTransferFunctionViewer.hpp:84
mgx::QTransferFunctionViewer::activ_pos_color
QColor activ_pos_color
Definition: QTransferFunctionViewer.hpp:91
mgx::Color< float >
mgx::QTransferFunctionViewer::transfer_fct
TransferFunction transfer_fct
Definition: QTransferFunctionViewer.hpp:78
mgx::QTransferFunctionViewer::_nb_values
size_t _nb_values
Definition: QTransferFunctionViewer.hpp:97
mgx::QTransferFunctionViewer::histogram
std::vector< double > histogram
Definition: QTransferFunctionViewer.hpp:79
mgx::QTransferFunctionViewer
Definition: QTransferFunctionViewer.hpp:30
mgx::QTransferFunctionViewer::~QTransferFunctionViewer
virtual ~QTransferFunctionViewer()
Definition: QTransferFunctionViewer.hpp:37
mgx::QTransferFunctionViewer::bg_dark
double bg_dark
Definition: QTransferFunctionViewer.hpp:90