Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | Static Private Attributes
omni::visual::Projector Class Reference

Visualizer for drawing a projector with halo. More...

#include <Projector.h>

Inheritance diagram for omni::visual::Projector:
Inheritance graph
[legend]
Collaboration diagram for omni::visual::Projector:
Collaboration graph
[legend]

Public Member Functions

 Projector (const proj::Projector &)
 
 ~Projector ()
 
void update ()
 Update geometry. More...
 
qreal size () const
 Return size of drawn projector. More...
 
void setSize (qreal)
 Set size. More...
 
bool isSelected () const
 Halo is bright if projector is selected. More...
 
void setSelected (bool)
 Set boolean if projector is selected. More...
 
QColor color () const
 Return drawn color. More...
 
void setColor (QColor)
 Set color if drawn projector. More...
 
void draw () const
 Draw projector line. More...
 
void drawHalo () const
 Draw projector value. More...
 
void drawPositioning (QVector3D const &_center) const
 Draw positioning of projector with center point. More...
 
- Public Member Functions inherited from omni::visual::Interface
virtual ~Interface ()
 

Private Attributes

proj::Projector const & proj_
 
bool selected_ = false
 
float size_ = 2.0
 
QColor color_
 
QVector3D eye_
 
QVector3D topLeft_
 
QVector3D topRight_
 
QVector3D bottomLeft_
 
QVector3D bottomRight_
 

Static Private Attributes

static ContextBoundPtr
< QOpenGLShaderProgram > 
haloShader_
 

Additional Inherited Members

- Static Protected Member Functions inherited from omni::visual::Interface
static void vertex3 (QVector3D const &)
 glVertex3f from QVector3D More...
 
static void visualLine (QVector3D const &_from, QVector3D const &_to)
 Draws a line. More...
 
static void color (QColor _color, float _alpha=1.0)
 glColor4f from QColor More...
 

Detailed Description

Visualizer for drawing a projector with halo.

Constructor & Destructor Documentation

omni::visual::Projector::Projector ( const proj::Projector _proj)
30  :
31  proj_(_proj)
32  {
33  update();
34  }
proj::Projector const & proj_
Definition: Projector.h:71
void update()
Update geometry.
Definition: Projector.cpp:67
omni::visual::Projector::~Projector ( )
inline
40 {}

Member Function Documentation

QColor omni::visual::Projector::color ( ) const

Return drawn color.

58  {
59  return color_;
60  }
QColor color_
Definition: Projector.h:76
void omni::visual::Projector::draw ( ) const
virtual

Draw projector line.

Implements omni::visual::Interface.

82  {
84 
85  withCurrentContext([this](QOpenGLFunctions& _)
86  {
87  _.glLineWidth(selected_ ? 2.0 : 1.0);
88 
89  glPushMatrix();
90  {
91  glLoadIdentity();
92  _.glDisable(GL_COLOR_MATERIAL);
93  _.glDisable(GL_LIGHTING);
94 
95  // Apply matrix to OpenGL
96  glMultMatrixf(proj_.matrix().constData());
97  this->visualLine(eye_, topLeft_);
98  this->visualLine(eye_, topRight_);
99  this->visualLine(eye_, bottomLeft_);
100  this->visualLine(eye_, bottomRight_);
101  this->visualLine(topLeft_, topRight_);
105  }
106  glPopMatrix();
107  });
108  }
QColor color_
Definition: Projector.h:76
proj::Projector const & proj_
Definition: Projector.h:71
QVector3D topRight_
Definition: Projector.h:77
bool selected_
Definition: Projector.h:73
QVector3D bottomRight_
Definition: Projector.h:77
QMatrix4x4 const & matrix() const
Return transformation matrix.
Definition: Projector.cpp:101
static void visualLine(QVector3D const &_from, QVector3D const &_to)
Draws a line.
Definition: Interface.cpp:32
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
QVector3D bottomLeft_
Definition: Projector.h:77
QVector3D eye_
Definition: Projector.h:77
static void color(QColor _color, float _alpha=1.0)
glColor4f from QColor
Definition: Interface.cpp:40
QVector3D topLeft_
Definition: Projector.h:77
void omni::visual::Projector::drawHalo ( ) const

Draw projector value.

144  {
145  if (!haloShader_) return;
146  glPushMatrix();
147  {
148  glLoadIdentity();
149 
150  // Apply matrix to OpenGL
151  glMultMatrixf(proj_.matrix().data());
152  haloShader_->bind();
153  haloShader_->setUniformValue("color",
154  color_.redF(),
155  color_.greenF(),
156  color_.blueF(),
157  selected_ ? 0.25 : 0.05);
158 
159  glDisable(GL_DEPTH_TEST);
160  glBegin(GL_TRIANGLE_FAN);
161  Interface::color(color_, selected_ ? 0.45 : 0.15);
162 
163  glTexCoord2f(0.0, 0.0);
164 
165  this->vertex3(eye_);
166  Interface::color(color_, 0.0);
167  float _scale = size_ * 2.0;
168 
169  if (selected_) _scale *= 2.0;
170 
171  glTexCoord2f(0.0, 1.0);
172  this->vertex3(topLeft_ * _scale);
173  this->vertex3(topRight_ * _scale);
174  this->vertex3(bottomRight_ * _scale);
175  this->vertex3(bottomLeft_ * _scale);
176  this->vertex3(topLeft_ * _scale);
177  glEnd();
178  glEnable(GL_DEPTH_TEST);
179 
180  haloShader_->release();
181  }
182  glPopMatrix();
183  }
QColor color_
Definition: Projector.h:76
proj::Projector const & proj_
Definition: Projector.h:71
static void vertex3(QVector3D const &)
glVertex3f from QVector3D
Definition: Interface.cpp:27
QVector3D topRight_
Definition: Projector.h:77
bool selected_
Definition: Projector.h:73
QVector3D bottomRight_
Definition: Projector.h:77
QMatrix4x4 const & matrix() const
Return transformation matrix.
Definition: Projector.cpp:101
static ContextBoundPtr< QOpenGLShaderProgram > haloShader_
Definition: Projector.h:79
float size_
Definition: Projector.h:74
QVector3D bottomLeft_
Definition: Projector.h:77
QVector3D eye_
Definition: Projector.h:77
static void color(QColor _color, float _alpha=1.0)
glColor4f from QColor
Definition: Interface.cpp:40
QVector3D topLeft_
Definition: Projector.h:77
void omni::visual::Projector::drawPositioning ( QVector3D const &  _center) const

Draw positioning of projector with center point.

111  {
113 
114  withCurrentContext([this](QOpenGLFunctions& _)
115  {
116  _.glLineWidth(selected_ ? 4.0 : 1.5);
117  });
118 
119  auto _p = proj_.pos();
120  auto _setupId =
121  proj_.setup() ? proj_.setup()->getTypeId().str() :
122  "PeripheralSetup";
123 
124  if (_setupId == "PeripheralSetup")
125  {
126  // Draw line from center to projector ground position
127  this->visualLine(_center, QVector3D(_p.x(), _p.y(), _center.z()));
128  this->visualLine(
129  QVector3D(_p.x(), _p.y(), _center.z()), _p);
130  } else
131  {
132  // Draw manhattan line from center to projector ground position
133  this->visualLine(_center,
134  QVector3D(_p.x(), _center.y(), _center.z()));
135  this->visualLine(
136  QVector3D(_p.x(), _center.y(), _center.z()),
137  QVector3D(_p.x(), _p.y(), _center.z()));
138  this->visualLine(
139  QVector3D(_p.x(), _p.y(), _center.z()), _p);
140  }
141  }
QColor color_
Definition: Projector.h:76
proj::Projector const & proj_
Definition: Projector.h:71
virtual Id getTypeId() const =0
Returns type id of object.
bool selected_
Definition: Projector.h:73
QString const & str() const
Returns string representation (const)
Definition: Id.cpp:42
static void visualLine(QVector3D const &_from, QVector3D const &_to)
Draws a line.
Definition: Interface.cpp:32
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
Setup * setup(Id const &_setupId, float _sceneScale=1.0)
Make a new projector setup with a certain id and delete old one.
Definition: Projector.cpp:40
static void color(QColor _color, float _alpha=1.0)
glColor4f from QColor
Definition: Interface.cpp:40
QVector3D pos() const
Return projector position (3rd column of projector matrix)
Definition: Projector.cpp:126
bool omni::visual::Projector::isSelected ( ) const

Halo is bright if projector is selected.

48  {
49  return selected_;
50  }
bool selected_
Definition: Projector.h:73
void omni::visual::Projector::setColor ( QColor  _color)

Set color if drawn projector.

63  {
64  color_ = _color;
65  }
QColor color_
Definition: Projector.h:76
void omni::visual::Projector::setSelected ( bool  _selected)

Set boolean if projector is selected.

53  {
54  selected_ = _selected;
55  }
bool selected_
Definition: Projector.h:73
void omni::visual::Projector::setSize ( qreal  _size)

Set size.

42  {
43  size_ = _size;
44  update();
45  }
float size_
Definition: Projector.h:74
void update()
Update geometry.
Definition: Projector.cpp:67
qreal omni::visual::Projector::size ( ) const

Return size of drawn projector.

37  {
38  return size_;
39  }
float size_
Definition: Projector.h:74
void omni::visual::Projector::update ( )
virtual

Update geometry.

Reimplemented from omni::visual::Interface.

68  {
69  withCurrentContext([&](QOpenGLFunctions& _) {
70  initShader(haloShader_,"halo");
71  });
72 
73  proj::Frustum _frustum(proj_);
74  eye_ = QVector3D(0, 0, 0);
75  topLeft_ = _frustum.topLeft() *size_;
76  topRight_ = _frustum.topRight() *size_;
77  bottomLeft_ = _frustum.bottomLeft() *size_;
78  bottomRight_ = _frustum.bottomRight() * size_;
79  }
proj::Projector const & proj_
Definition: Projector.h:71
QVector3D topRight_
Definition: Projector.h:77
QVector3D bottomRight_
Definition: Projector.h:77
void initShader(QOpenGLShaderProgram &_s, const char *_filename)
Initialize shader: load from file and compile.
Definition: Shader.cpp:27
static ContextBoundPtr< QOpenGLShaderProgram > haloShader_
Definition: Projector.h:79
float size_
Definition: Projector.h:74
void withCurrentContext(ContextFunctor f)
Do OpenGL operations with current context, if it exists.
Definition: ContextSwitch.cpp:45
QVector3D bottomLeft_
Definition: Projector.h:77
QVector3D eye_
Definition: Projector.h:77
QVector3D topLeft_
Definition: Projector.h:77

Field Documentation

QVector3D omni::visual::Projector::bottomLeft_
private
QVector3D omni::visual::Projector::bottomRight_
private
QColor omni::visual::Projector::color_
private
QVector3D omni::visual::Projector::eye_
private
ContextBoundPtr< QOpenGLShaderProgram > omni::visual::Projector::haloShader_
staticprivate
proj::Projector const& omni::visual::Projector::proj_
private
bool omni::visual::Projector::selected_ = false
private
float omni::visual::Projector::size_ = 2.0
private
QVector3D omni::visual::Projector::topLeft_
private
QVector3D omni::visual::Projector::topRight_
private

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