Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
omni::input::TestImage Class Referenceabstract

Abstract class for test images that are generated with a shader. More...

#include <TestImage.h>

Inheritance diagram for omni::input::TestImage:
Inheritance graph
[legend]
Collaboration diagram for omni::input::TestImage:
Collaboration graph
[legend]

Public Member Functions

 TestImage (Interface const *_parent=nullptr)
 
virtual ~TestImage ()
 
virtual void update ()
 Update framebuffer image. More...
 
virtual void destroy ()
 
QPointF rulerPos () const
 Return ruler position. More...
 
void setRulerPos (QPointF const &)
 Set ruler position. More...
 
virtual void toPropertyMap (PropertyMap &) const
 Serialize to stream. More...
 
virtual void fromPropertyMap (PropertyMap const &)
 Deserialize from stream. More...
 
virtual categoryset_type categories () const
 Input can have a fixed set of categories. More...
 
- Public Member Functions inherited from omni::input::Framebuffer
 Framebuffer (input::Interface const *=nullptr)
 
virtual ~Framebuffer ()
 
virtual QSize size () const
 An input must return width and height information. More...
 
virtual void setSize (QSize const &)
 
GLuint textureId () const
 An input must return an OpenGL texture ID. More...
 
- Public Member Functions inherited from omni::input::Interface
 Interface (Interface const *_parent=nullptr)
 
virtual ~Interface ()
 Virtual destructor. More...
 
size_t numberOfChildren () const
 
int width () const
 Return width from size. More...
 
int height () const
 Return height from size. More...
 
QString infoText () const
 Optional info text. More...
 
virtual QWidget * widget ()
 Make new parameter widget. More...
 
virtual QWidget * controlWidget ()
 Make new large control widget for live mode. More...
 
virtual bool canAdd ()
 Returns true if this input can be added E.g., an input can be added after an initial settings dialog was approved or it has valid settings. More...
 
virtual bool canHaveChildren () const
 
int setUpdateCallback (callback_type _updatedCallback)
 Insert a new callback when input has updated and returns its unique id. More...
 
callback_type updatedCallback (int _id)
 
void triggerUpdateCallbacks () const
 
void removeUpdateCallback (int _id)
 
InterfaceaddInput (QString const &_id, Id const &_typeId)
 Add new input with given type id. Returns nullptr if input with typeid does not exist. More...
 
InterfaceaddInput (QString const &_id, Interface *_i)
 Input with id and return pointer to input when successfully added. More...
 
QString getId (Interface const *) const
 Get id of child interface. More...
 
virtual void removeInput (QString const &_id)
 Remove input with id. More...
 
InterfacegetInput (QString const &_id)
 Return pointer of input with id, nullptr if input does not exist. More...
 
Interface const * getInput (QString const &_id) const
 Return pointer of input with id, nullptr if input does not exist. More...
 
container_type const & children () const
 Return children. More...
 
Interface const * parent () const
 Return parent interface (const version) More...
 
QString path () const
 Return absolute path of interface. More...
 
void setParent (Interface *)
 Set new parent. More...
 
inputlist_type getAllInputs () const
 Returns a list of input maintained by controller, except this one. More...
 
- Public Member Functions inherited from omni::TypeIdInterface
virtual ~TypeIdInterface ()
 
virtual Id getTypeId () const =0
 Returns type id of object. More...
 
virtual void registerInFactory () const =0
 Register the inherited class in factory. More...
 

Protected Member Functions

virtual void shaderUniformHandler ()
 Virtual method to handle additional shader uniforms in derived classes. More...
 
- Protected Member Functions inherited from omni::input::Framebuffer
QOpenGLFramebufferObject * framebuffer ()
 
QOpenGLFramebufferObject const * framebuffer () const
 
void setupFramebuffer (QSize const &_size)
 
void setupFramebuffer ()
 

Protected Attributes

ContextBoundPtr
< QOpenGLShaderProgram > 
shader_
 

Private Member Functions

virtual QString fragmentShaderSource () const =0
 String representing the fragment shader source. More...
 
virtual QString vertexShaderSource () const =0
 String representing the vertex shader source. More...
 

Private Attributes

QPointF rulerPos_
 

Additional Inherited Members

- Public Types inherited from omni::input::Interface
typedef Interface interface_type
 
typedef std::vector< Interface
const * > 
inputlist_type
 
typedef std::map< QString,
std::unique_ptr< Interface > > 
container_type
 
typedef std::function< void()> callback_type
 
typedef std::set< QString > categoryset_type
 

Detailed Description

Abstract class for test images that are generated with a shader.

Constructor & Destructor Documentation

omni::input::TestImage::TestImage ( Interface const *  _parent = nullptr)
32  :
33  Framebuffer(_parent),
34  rulerPos_(-1.0,-1.0)
35  {
36  }
Framebuffer(input::Interface const *=nullptr)
Definition: Framebuffer.cpp:27
QPointF rulerPos_
Definition: TestImage.h:73
virtual omni::input::TestImage::~TestImage ( )
inlinevirtual
36 {}

Member Function Documentation

virtual categoryset_type omni::input::TestImage::categories ( ) const
inlinevirtual

Input can have a fixed set of categories.

Reimplemented from omni::input::Interface.

55  {
56  return categoryset_type({"Test images"});
57  }
std::set< QString > categoryset_type
Definition: Interface.h:64
void omni::input::TestImage::destroy ( )
virtual

Reimplemented from omni::input::Framebuffer.

39  {
41  shader_.reset();
42  }
ContextBoundPtr< QOpenGLShaderProgram > shader_
Definition: TestImage.h:64
virtual void destroy()
Definition: Framebuffer.cpp:32
virtual QString omni::input::TestImage::fragmentShaderSource ( ) const
privatepure virtual

String representing the fragment shader source.

void omni::input::TestImage::fromPropertyMap ( PropertyMap const &  _map)
virtual

Deserialize from stream.

Reimplemented from omni::input::Framebuffer.

101  {
103  _map.get("rulerPos",rulerPos_);
104  update();
105  }
QPointF rulerPos_
Definition: TestImage.h:73
virtual void fromPropertyMap(PropertyMap const &)
Deserialize from property map.
Definition: Framebuffer.cpp:97
virtual void update()
Update framebuffer image.
Definition: TestImage.cpp:59
QPointF omni::input::TestImage::rulerPos ( ) const

Return ruler position.

50  {
51  return rulerPos_;
52  }
QPointF rulerPos_
Definition: TestImage.h:73
void omni::input::TestImage::setRulerPos ( QPointF const &  _rulerPos)

Set ruler position.

45  {
46  rulerPos_ = _rulerPos;
47  }
QPointF rulerPos_
Definition: TestImage.h:73
void omni::input::TestImage::shaderUniformHandler ( )
protectedvirtual

Virtual method to handle additional shader uniforms in derived classes.

55  {
56  shader_->setUniformValue("ruler_pos",rulerPos_ - QPointF(0.5,0.5));
57  }
QPointF rulerPos_
Definition: TestImage.h:73
ContextBoundPtr< QOpenGLShaderProgram > shader_
Definition: TestImage.h:64
void omni::input::TestImage::toPropertyMap ( PropertyMap &  _map) const
virtual

Serialize to stream.

Reimplemented from omni::input::Framebuffer.

95  {
96  _map("rulerPos",rulerPos_);
98  }
QPointF rulerPos_
Definition: TestImage.h:73
virtual void toPropertyMap(PropertyMap &) const
Serialize to property map.
Definition: Framebuffer.cpp:92
void omni::input::TestImage::update ( )
virtual

Update framebuffer image.

Reimplemented from omni::input::Interface.

60  {
61  if (!shader_)
62  {
63  primaryContextSwitch([&](QOpenGLFunctions& _) {
64  QString _vertSrc = this->vertexShaderSource();
65  QString _fragmentSrc = this->fragmentShaderSource();
66  if (!shader_.reset(new QOpenGLShaderProgram())) return;
67  shader_->addShaderFromSourceCode(QOpenGLShader::Vertex,_vertSrc);
68  shader_->addShaderFromSourceCode(QOpenGLShader::Fragment,_fragmentSrc);
69  shader_->link();
70  });
71  }
72 
74 
76  [&](QOpenGLFunctions& _) // Projection Operation
77  {
78  QMatrix4x4 _m;
79  _m.ortho(-0.5,0.5,-0.5,0.5,-1.0,1.0);
80  glMultMatrixf(_m.constData());
81  },
82  [&](QOpenGLFunctions& _) // Model View Operation
83  {
84  _.glDisable(GL_BLEND);
85  shader_->bind();
86  {
89  }
90  shader_->release();
91  });
92  }
void draw_on_framebuffer(FRAMEBUFFER *_f, PROJECTION _p, MODELVIEW _m)
Draw into QOpenGLFramebufferObject with given projection and model.
Definition: util.h:103
virtual void shaderUniformHandler()
Virtual method to handle additional shader uniforms in derived classes.
Definition: TestImage.cpp:54
static void drawFlipped(float _left=-0.5, float _right=0.5, float _top=0.5, float _bottom=-0.5)
Draw rectangle from border coordinates, flipped on y axis version.
Definition: Rectangle.cpp:68
virtual QSize size() const
An input must return width and height information.
Definition: Framebuffer.cpp:41
ContextBoundPtr< QOpenGLShaderProgram > shader_
Definition: TestImage.h:64
virtual QString vertexShaderSource() const =0
String representing the vertex shader source.
virtual QString fragmentShaderSource() const =0
String representing the fragment shader source.
QOpenGLFramebufferObject * framebuffer()
Definition: Framebuffer.cpp:49
void setupFramebuffer()
Definition: Framebuffer.cpp:88
void primaryContextSwitch(ContextFunctor f)
Switch to primary context to create OpenGL objects like textures etc.
Definition: ContextSwitch.cpp:40
virtual QString omni::input::TestImage::vertexShaderSource ( ) const
privatepure virtual

String representing the vertex shader source.

Field Documentation

QPointF omni::input::TestImage::rulerPos_
private
ContextBoundPtr<QOpenGLShaderProgram> omni::input::TestImage::shader_
protected

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