Jetson Inference
DNN Vision Library
glWidget Class Reference

OpenGL graphics widget for rendering moveable/resizable shapes. More...

#include <glWidget.h>

Classes

struct  eventHandler
 

Public Types

enum  Shape { Rect, Line, Ellipse }
 Shape enum. More...
 
typedef bool(* glWidgetEventHandler) (glWidget *widget, uint16_t event, int a, int b, void *user)
 Event message handler callback for recieving UI messages from widgets. More...
 

Public Member Functions

 glWidget (Shape shape=Rect)
 Constructor. More...
 
 glWidget (float x, float y, float width, float height, Shape shape=Rect)
 Constructor. More...
 
virtual ~glWidget ()
 Destructor. More...
 
bool Contains (float x, float y) const
 Test if the point is inside the widget. More...
 
void Move (float x, float y)
 Move the widget's position by the specified offset. More...
 
float X () const
 Get the widget's X coordinate. More...
 
float Y () const
 Get the widget's Y coordinate. More...
 
void SetX (float x)
 Set the widget's X coordinate. More...
 
void SetY (float y)
 Set the widget's Y coordinate. More...
 
float Width () const
 Get the widget's width. More...
 
float Height () const
 Get the widget's height. More...
 
void SetWidth (float width)
 Set the widget's width. More...
 
void SetHeight (float height)
 Set the widget's height. More...
 
void GetPosition (float *x, float *y) const
 Get position of widget in global window coordinates. More...
 
void SetPosition (float x, float y)
 Set position of widget in global window coordinates. More...
 
void GetCoords (float *x1, float *y1, float *x2, float *y2) const
 Get the bounding coordinates of the widget. More...
 
void SetCoords (float x1, float y1, float x2, float y2)
 Set the bounding coordinates of the widget. More...
 
void GetSize (float *width, float *height) const
 Get the widget's size. More...
 
void SetSize (float width, float height)
 Set the widget's size. More...
 
Shape GetShape () const
 Get the shape. More...
 
void SetShape (Shape shape)
 Set the shape. More...
 
void SetFillAlpha (float a)
 Set fill alpha. More...
 
void SetLineAlpha (float a)
 Set outline alpha. More...
 
void SetLineWidth (float width)
 Set outline width. More...
 
void SetFillColor (float r, float g, float b, float a=1.0f)
 Set fill color. More...
 
void SetLineColor (float r, float g, float b, float a=1.0f)
 Set outline color. More...
 
void SetSelectedFillColor (float r, float g, float b, float a=1.0f)
 Set selected fill color. More...
 
void SetSelectedLineColor (float r, float g, float b, float a=1.0f)
 Set selected outline color. More...
 
bool IsMoveable () const
 Is the widget moveable/draggable by the user? More...
 
void SetMoveable (bool moveable)
 Toggle if the user can move/drag the widget. More...
 
bool IsResizeable () const
 Is the widget resizeable by the user? More...
 
void SetResizeable (bool resizeable)
 Toggle if the user can resize the widget. More...
 
bool IsSelected () const
 Is the widget selected? More...
 
void SetSelected (bool selected)
 Select/de-select the widget. More...
 
bool IsVisible () const
 Is the widget visible. More...
 
void SetVisible (bool visible)
 Show/hide the widget. More...
 
void * GetUserData () const
 Retrieve user data. More...
 
void SetUserData (void *user)
 Set user-defined data. More...
 
glDisplayGetDisplay () const
 Get the root window of the widget. More...
 
int GetIndex () const
 Get the index of the widget in the window (or -1 if none) More...
 
void Render ()
 Render (automatically called by parent) More...
 
void GlobalToLocal (float x, float y, float *x_out, float *y_out) const
 Convert from global window coordinates to local widget offset. More...
 
void LocalToGlobal (float x, float y, float *x_out, float *y_out) const
 Convert from local widget offset to global window coordinates. More...
 
void AddEventHandler (glWidgetEventHandler callback, void *user=NULL)
 Register an event message handler the widget will send events to. More...
 
void RemoveEventHandler (glWidgetEventHandler callback, void *user=NULL)
 Remove an event message handler from being called by the widget. More...
 
bool OnEvent (uint16_t event, int a, int b, void *user)
 

Protected Types

enum  DragState {
  DragNone, DragMove, DragResizeN, DragResizeNW,
  DragResizeNE, DragResizeS, DragResizeSW, DragResizeSE,
  DragResizeW, DragResizeE
}
 

Protected Member Functions

void initDefaults ()
 
void setCursor (DragState cursor)
 
void setDisplay (glDisplay *display)
 
void dispatchEvent (uint16_t msg, int a, int b)
 
DragState coordToBorder (float x, float y, float max_distance=10.0f)
 

Protected Attributes

float mX
 
float mY
 
float mWidth
 
float mHeight
 
float mSelectedFillColor [4]
 
float mSelectedLineColor [4]
 
float mFillColor [4]
 
float mLineColor [4]
 
float mLineWidth
 
bool mMoveable
 
bool mResizeable
 
bool mSelected
 
bool mVisible
 
Shape mShape
 
void * mUserData
 
glDisplaymDisplay
 
DragState mDragState
 
std::vector< eventHandlermEventHandlers
 

Friends

class glDisplay
 

Detailed Description

OpenGL graphics widget for rendering moveable/resizable shapes.

Member Typedef Documentation

◆ glWidgetEventHandler

typedef bool(* glWidget::glWidgetEventHandler) (glWidget *widget, uint16_t event, int a, int b, void *user)

Event message handler callback for recieving UI messages from widgets.

Recieves 4 parameters - the widget that sent the event, the event type, a & b message values (

See also
glEventType from glEvents.h), and a user-specified pointer from registration.

Event message handlers should return true if the message was handled, or false if the message was skipped or not handled.

See also
AddEventHandler
RemoveEventHandler

Member Enumeration Documentation

◆ DragState

enum glWidget::DragState
protected
Enumerator
DragNone 
DragMove 
DragResizeN 
DragResizeNW 
DragResizeNE 
DragResizeS 
DragResizeSW 
DragResizeSE 
DragResizeW 
DragResizeE 

◆ Shape

Shape enum.

Enumerator
Rect 
Line 
Ellipse 

Constructor & Destructor Documentation

◆ glWidget() [1/2]

glWidget::glWidget ( Shape  shape = Rect)

Constructor.

◆ glWidget() [2/2]

glWidget::glWidget ( float  x,
float  y,
float  width,
float  height,
Shape  shape = Rect 
)

Constructor.

◆ ~glWidget()

virtual glWidget::~glWidget ( )
virtual

Destructor.

Member Function Documentation

◆ AddEventHandler()

void glWidget::AddEventHandler ( glWidgetEventHandler  callback,
void *  user = NULL 
)

Register an event message handler the widget will send events to.

Parameters
callbackfunction pointer to the event message handler callback
useroptional user-specified pointer that will be passed to all invocations of this event handler (typically an object)

◆ Contains()

bool glWidget::Contains ( float  x,
float  y 
) const

Test if the point is inside the widget.

◆ coordToBorder()

DragState glWidget::coordToBorder ( float  x,
float  y,
float  max_distance = 10.0f 
)
protected

◆ dispatchEvent()

void glWidget::dispatchEvent ( uint16_t  msg,
int  a,
int  b 
)
protected

◆ GetCoords()

void glWidget::GetCoords ( float *  x1,
float *  y1,
float *  x2,
float *  y2 
) const
inline

Get the bounding coordinates of the widget.

◆ GetDisplay()

glDisplay* glWidget::GetDisplay ( ) const
inline

Get the root window of the widget.

◆ GetIndex()

int glWidget::GetIndex ( ) const

Get the index of the widget in the window (or -1 if none)

◆ GetPosition()

void glWidget::GetPosition ( float *  x,
float *  y 
) const
inline

Get position of widget in global window coordinates.

◆ GetShape()

Shape glWidget::GetShape ( ) const
inline

Get the shape.

◆ GetSize()

void glWidget::GetSize ( float *  width,
float *  height 
) const
inline

Get the widget's size.

◆ GetUserData()

void* glWidget::GetUserData ( ) const
inline

Retrieve user data.

◆ GlobalToLocal()

void glWidget::GlobalToLocal ( float  x,
float  y,
float *  x_out,
float *  y_out 
) const

Convert from global window coordinates to local widget offset.

◆ Height()

float glWidget::Height ( ) const
inline

Get the widget's height.

◆ initDefaults()

void glWidget::initDefaults ( )
protected

◆ IsMoveable()

bool glWidget::IsMoveable ( ) const
inline

Is the widget moveable/draggable by the user?

◆ IsResizeable()

bool glWidget::IsResizeable ( ) const
inline

Is the widget resizeable by the user?

◆ IsSelected()

bool glWidget::IsSelected ( ) const
inline

Is the widget selected?

◆ IsVisible()

bool glWidget::IsVisible ( ) const
inline

Is the widget visible.

◆ LocalToGlobal()

void glWidget::LocalToGlobal ( float  x,
float  y,
float *  x_out,
float *  y_out 
) const

Convert from local widget offset to global window coordinates.

◆ Move()

void glWidget::Move ( float  x,
float  y 
)
inline

Move the widget's position by the specified offset.

◆ OnEvent()

bool glWidget::OnEvent ( uint16_t  event,
int  a,
int  b,
void *  user 
)

◆ RemoveEventHandler()

void glWidget::RemoveEventHandler ( glWidgetEventHandler  callback,
void *  user = NULL 
)

Remove an event message handler from being called by the widget.

RemoveEventHandler() will search for previously registered event handlers that have the same function pointer and/or user pointer, and remove them for being called again in the future.

◆ Render()

void glWidget::Render ( )

Render (automatically called by parent)

◆ SetCoords()

void glWidget::SetCoords ( float  x1,
float  y1,
float  x2,
float  y2 
)
inline

Set the bounding coordinates of the widget.

◆ setCursor()

void glWidget::setCursor ( DragState  cursor)
protected

◆ setDisplay()

void glWidget::setDisplay ( glDisplay display)
protected

◆ SetFillAlpha()

void glWidget::SetFillAlpha ( float  a)
inline

Set fill alpha.

◆ SetFillColor()

void glWidget::SetFillColor ( float  r,
float  g,
float  b,
float  a = 1.0f 
)
inline

Set fill color.

◆ SetHeight()

void glWidget::SetHeight ( float  height)
inline

Set the widget's height.

◆ SetLineAlpha()

void glWidget::SetLineAlpha ( float  a)
inline

Set outline alpha.

◆ SetLineColor()

void glWidget::SetLineColor ( float  r,
float  g,
float  b,
float  a = 1.0f 
)
inline

Set outline color.

◆ SetLineWidth()

void glWidget::SetLineWidth ( float  width)
inline

Set outline width.

◆ SetMoveable()

void glWidget::SetMoveable ( bool  moveable)
inline

Toggle if the user can move/drag the widget.

◆ SetPosition()

void glWidget::SetPosition ( float  x,
float  y 
)
inline

Set position of widget in global window coordinates.

◆ SetResizeable()

void glWidget::SetResizeable ( bool  resizeable)
inline

Toggle if the user can resize the widget.

◆ SetSelected()

void glWidget::SetSelected ( bool  selected)
inline

Select/de-select the widget.

◆ SetSelectedFillColor()

void glWidget::SetSelectedFillColor ( float  r,
float  g,
float  b,
float  a = 1.0f 
)
inline

Set selected fill color.

◆ SetSelectedLineColor()

void glWidget::SetSelectedLineColor ( float  r,
float  g,
float  b,
float  a = 1.0f 
)
inline

Set selected outline color.

◆ SetShape()

void glWidget::SetShape ( Shape  shape)
inline

Set the shape.

◆ SetSize()

void glWidget::SetSize ( float  width,
float  height 
)
inline

Set the widget's size.

◆ SetUserData()

void glWidget::SetUserData ( void *  user)
inline

Set user-defined data.

◆ SetVisible()

void glWidget::SetVisible ( bool  visible)
inline

Show/hide the widget.

◆ SetWidth()

void glWidget::SetWidth ( float  width)
inline

Set the widget's width.

◆ SetX()

void glWidget::SetX ( float  x)
inline

Set the widget's X coordinate.

◆ SetY()

void glWidget::SetY ( float  y)
inline

Set the widget's Y coordinate.

◆ Width()

float glWidget::Width ( ) const
inline

Get the widget's width.

◆ X()

float glWidget::X ( ) const
inline

Get the widget's X coordinate.

◆ Y()

float glWidget::Y ( ) const
inline

Get the widget's Y coordinate.

Friends And Related Function Documentation

◆ glDisplay

friend class glDisplay
friend

Member Data Documentation

◆ mDisplay

glDisplay* glWidget::mDisplay
protected

◆ mDragState

DragState glWidget::mDragState
protected

◆ mEventHandlers

std::vector<eventHandler> glWidget::mEventHandlers
protected

◆ mFillColor

float glWidget::mFillColor[4]
protected

◆ mHeight

float glWidget::mHeight
protected

◆ mLineColor

float glWidget::mLineColor[4]
protected

◆ mLineWidth

float glWidget::mLineWidth
protected

◆ mMoveable

bool glWidget::mMoveable
protected

◆ mResizeable

bool glWidget::mResizeable
protected

◆ mSelected

bool glWidget::mSelected
protected

◆ mSelectedFillColor

float glWidget::mSelectedFillColor[4]
protected

◆ mSelectedLineColor

float glWidget::mSelectedLineColor[4]
protected

◆ mShape

Shape glWidget::mShape
protected

◆ mUserData

void* glWidget::mUserData
protected

◆ mVisible

bool glWidget::mVisible
protected

◆ mWidth

float glWidget::mWidth
protected

◆ mX

float glWidget::mX
protected

◆ mY

float glWidget::mY
protected

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