Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Signals | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
omni::ui::proj::ColorCorrectionGraph Class Reference

Widget which draws the graph for color corrections for each channel. More...

#include <ColorCorrectionGraph.h>

Inheritance diagram for omni::ui::proj::ColorCorrectionGraph:
Inheritance graph
[legend]
Collaboration diagram for omni::ui::proj::ColorCorrectionGraph:
Collaboration graph
[legend]

Signals

void dataModelChanged ()
 

Public Member Functions

 ColorCorrectionGraph (QWidget *=nullptr)
 
 ~ColorCorrectionGraph ()
 
Channel channel () const
 Return selected channel. More...
 
void setChannel (Channel _channel)
 Set selected channel. More...
 
- Public Member Functions inherited from omni::ui::mixin::DataModel< DATAMODEL, SHARED >
 DataModel ()
 
void setDataModel (pointer_type _dataModel)
 Set new data model. More...
 
pointer_type dataModel ()
 Return pointer to data model. More...
 
const pointer_type dataModel () const
 Return pointer to data model (const version) More...
 
virtual void updateFrontend ()
 Push data to frontend widgets and all child widgets. More...
 
virtual void updateDataModel ()
 Update the data model interface. More...
 

Protected Member Functions

void paintEvent (QPaintEvent *)
 Paint graph event. More...
 
void resizeEvent (QResizeEvent *)
 Re-paint on resize. More...
 
- Protected Member Functions inherited from omni::ui::mixin::Locked
template<typename F >
void locked (F f)
 Lock widget and execute given functor. More...
 
bool isLocked () const
 Return true if widget is locked. More...
 

Private Member Functions

void dataToFrontend ()
 Update widget from current color correction. More...
 
bool frontendToData ()
 ColorCorrectionGraph cannot change data, hence there is nothing to do here. More...
 
void drawGraphs (QPainter &_p, bool _selected) const
 Draw selected graphs. More...
 
void drawGraphForChannel (QPainter &, omni::proj::ChannelCorrection const &, QColor _color, bool _selected) const
 Draw graph for a channel correction. More...
 
void drawGraphForChannel (QPainter &, Channel _channel) const
 Draw graph for a channel. More...
 
void drawGridLines (QPainter &)
 Draw grid lines in background. More...
 

Private Attributes

Channel channel_ = Channel::ALL
 

Additional Inherited Members

- Public Types inherited from omni::ui::mixin::DataModel< DATAMODEL, SHARED >
typedef DATAMODEL data_model_type
 Data type. More...
 
typedef DataModel
< data_model_type, SHARED > 
type
 This type. More...
 
typedef detail::PointerType
< data_model_type, SHARED > 
pointer_type_handler
 Pointer type handler. More...
 
typedef pointer_type_handler::type pointer_type
 Derived pointer type. More...
 

Detailed Description

Widget which draws the graph for color corrections for each channel.

Constructor & Destructor Documentation

omni::ui::proj::ColorCorrectionGraph::ColorCorrectionGraph ( QWidget *  _parent = nullptr)
31  : QWidget(_parent) {
32 
33  }
omni::ui::proj::ColorCorrectionGraph::~ColorCorrectionGraph ( )
35  {
36 
37  }

Member Function Documentation

Channel omni::ui::proj::ColorCorrectionGraph::channel ( ) const

Return selected channel.

45  {
46  return channel_;
47  }
Channel channel_
Definition: ColorCorrectionGraph.h:88
void omni::ui::proj::ColorCorrectionGraph::dataModelChanged ( )
signal
void omni::ui::proj::ColorCorrectionGraph::dataToFrontend ( )
privatevirtual

Update widget from current color correction.

Implements omni::ui::mixin::DataModel< DATAMODEL, SHARED >.

49  {
50  update();
51  }
void omni::ui::proj::ColorCorrectionGraph::drawGraphForChannel ( QPainter &  _p,
omni::proj::ChannelCorrection const &  _correction,
QColor  _color,
bool  _selected 
) const
private

Draw graph for a channel correction.

92  {
93 
94  QRectF _rect = QRectF(rect()).adjusted(2,2,-2,-2);
95 
96  _p.setBrush(Qt::NoBrush);
97 
98 
99  QPen _pen(_color,_selected ? 1.5 : 1,Qt::SolidLine);
100  _p.setPen(_pen);
101 
102  QPainterPath _path;
103  for (double _posX = _rect.left(); _posX <= _rect.right(); _posX += 2) {
104  double _x = (_posX - _rect.left()) / double(_rect.width());
105  double _y = qBound(0.0,_correction.corrected(_x),1.0);
106  double _posY = float(_rect.height()) - _y*_rect.height() + _rect.top();
107  if (_posX == _rect.left()) {
108  _path.moveTo(_posX,_posY);
109  } else {
110  _path.lineTo(_posX,_posY);
111  }
112  }
113 
114  _p.drawPath(_path);
115  }
void omni::ui::proj::ColorCorrectionGraph::drawGraphForChannel ( QPainter &  _p,
Channel  _channel 
) const
private

Draw graph for a channel.

117  {
118  if (!dataModel()) return;
119 
120  bool _selected = channel() == _channel;
121  drawGraphForChannel(_p,*dataModel()->correction(_channel),
122  omni::proj::ColorCorrection::channelColor(_channel),_selected);
123  }
pointer_type dataModel()
Return pointer to data model.
Definition: DataModel.h:118
static QColor channelColor(Channel)
Definition: ColorCorrection.cpp:117
void drawGraphForChannel(QPainter &, omni::proj::ChannelCorrection const &, QColor _color, bool _selected) const
Draw graph for a channel correction.
Definition: ColorCorrectionGraph.cpp:89
Channel channel() const
Return selected channel.
Definition: ColorCorrectionGraph.cpp:45
void omni::ui::proj::ColorCorrectionGraph::drawGraphs ( QPainter &  _p,
bool  _selected 
) const
private

Draw selected graphs.

78  {
79  auto _drawGraph = [&](Channel _channel) {
80  if ((channel() == _channel) == _selected)
81  drawGraphForChannel(_p,_channel);
82  };
83  _drawGraph(Channel::ALL);
84  _drawGraph(Channel::RED);
85  _drawGraph(Channel::GREEN);
86  _drawGraph(Channel::BLUE);
87  }
Channel
Definition: Channel.h:24
void drawGraphForChannel(QPainter &, omni::proj::ChannelCorrection const &, QColor _color, bool _selected) const
Draw graph for a channel correction.
Definition: ColorCorrectionGraph.cpp:89
Channel channel() const
Return selected channel.
Definition: ColorCorrectionGraph.cpp:45
void omni::ui::proj::ColorCorrectionGraph::drawGridLines ( QPainter &  _p)
private

Draw grid lines in background.

125  {
126  QRectF _rect = QRectF(rect()).adjusted(2,2,-2,-2);
127  QPen _pen("#080808");
128  _p.setPen(_pen);
129  // Draw vertical lines
130  for (double _posX = _rect.left(); _posX <= _rect.right(); _posX += _rect.width()/8) {
131  _p.drawLine(_posX,_rect.top(),_posX,_rect.bottom());
132  }
133 
134  // Draw horizontal lines
135  for (double _posY = _rect.top(); _posY <= _rect.bottom(); _posY += _rect.height()/8) {
136  _p.drawLine(_rect.left(),_posY,_rect.right(),_posY);
137  }
138  }
bool omni::ui::proj::ColorCorrectionGraph::frontendToData ( )
inlineprivatevirtual

ColorCorrectionGraph cannot change data, hence there is nothing to do here.

Implements omni::ui::mixin::DataModel< DATAMODEL, SHARED >.

67  {
68  return false;
69  }
void omni::ui::proj::ColorCorrectionGraph::paintEvent ( QPaintEvent *  _paintEvent)
protected

Paint graph event.

53  {
54  QPainter _painter(this);
55  _painter.setRenderHint(QPainter::HighQualityAntialiasing);
56  _painter.setRenderHint(QPainter::Antialiasing, true);
57 
58  QRect _rect = rect();
59 
60  _painter.setBrush(QBrush("#212121"));
61  _painter.setPen(Qt::NoPen);
62  _painter.drawRect(_rect);
63  drawGridLines(_painter);
64 
65  if (!isEnabled()) return;
66 
67  // Draw not selected graphs first
68  drawGraphs(_painter,false);
69 
70  // Draw selected graphs after
71  drawGraphs(_painter,true);
72  }
void drawGraphs(QPainter &_p, bool _selected) const
Draw selected graphs.
Definition: ColorCorrectionGraph.cpp:78
void drawGridLines(QPainter &)
Draw grid lines in background.
Definition: ColorCorrectionGraph.cpp:125
void omni::ui::proj::ColorCorrectionGraph::resizeEvent ( QResizeEvent *  _resizeEvent)
protected

Re-paint on resize.

74  {
75  update();
76  }
void omni::ui::proj::ColorCorrectionGraph::setChannel ( Channel  _channel)

Set selected channel.

41  {
42  channel_ = _channel;
43  }
Channel channel_
Definition: ColorCorrectionGraph.h:88

Field Documentation

Channel omni::ui::proj::ColorCorrectionGraph::channel_ = Channel::ALL
private

The documentation for this class was generated from the following files: