Image Component Library (ICL)
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | List of all members
icl::qt::AbstractPlotWidget Class Referenceabstract

The PlotWidget is an abstract base class for 2D plotting components. More...

#include <AbstractPlotWidget.h>

Inheritance diagram for icl::qt::AbstractPlotWidget:
icl::qt::ThreadedUpdatableWidget icl::utils::Configurable icl::qt::LowLevelPlotWidget icl::qt::PlotWidget icl::qt::HistogrammWidget

Classes

struct  Locker
 utility class for scoped locking More...
 
struct  Pen
 Utility structure for styles usend in subclasses. More...
 

Public Types

enum  PenType {
  X_AXIS_PEN, Y_AXIS_PEN, X_TIC_PEN, Y_TIC_PEN,
  X_LABEL_PEN, Y_LABEL_PEN, X_GRID_PEN, Y_GRID_PEN,
  AXIS_NAME_PEN, NUM_PEN_TYPES
}
 different pen types More...
 
typedef utils::SmartPtr< PenPenPtr
 typedef for managed row-style pointers More...
 
typedef utils::Function< float, float, float > bgFunction
 function that is used to render a non-homo More...
 
- Public Types inherited from icl::utils::Configurable
typedef Function< void, const Property & > Callback
 Function type for changed properties. More...
 

Public Member Functions

void install (MouseHandler *h)
 adds a new mouse handler More...
 
void uninstall (MouseHandler *h)
 removes a mouse handler More...
 
 AbstractPlotWidget (QWidget *parent=0)
 Base constructor. More...
 
 ~AbstractPlotWidget ()
 destructor More...
 
virtual void paintEvent (QPaintEvent *evt)
 custom drawing More...
 
virtual void keyPressEvent (QKeyEvent *event)
 listens for F11 which enables the fullscreen mode More...
 
void renderTo (QPainter &p)
 renders the whole content using the given qpainter More...
 
void setBackground (const QBrush &bgBrush)
 sets the background brush More...
 
void setPen (PenType p, const QPen &pen)
 sets the pen for one of the widget compoments More...
 
void render ()
 updates the screen More...
 
virtual utils::Rect32f getDataViewPort () const
 returns the given data vieport More...
 
void setDataViewPort (const utils::Rect32f &viewPort)
 sets the default dataviewport More...
 
void setDataViewPort (const utils::Range32f &xrange, const utils::Range32f &yrange)
 sets the default viewport More...
 
void lock () const
 locks drawing / data updates in subclasses More...
 
void unlock () const
 unlocks drawing / data updates in subclasses More...
 
void addAnnotations (const char type, const float *data, int num=1, const QPen &linePen=QColor(255, 0, 0), const QBrush &brush=Qt::NoBrush, const std::string &text="", const std::string &textDelim=",")
 adds an annotation to the data viewport More...
 
void clearAnnotations ()
 removes all existing annotations More...
 
virtual void clear ()
 clears everything from the widget More...
 
void setBackgroundFunction (bgFunction f)
 sets the background function More...
 
void updateBackgroundFunction ()
 forces a repaint on the background function in the next rendering cycle More...
 
void removeBackgroundFunction ()
 removes the background function More...
 
- Public Member Functions inherited from icl::qt::ThreadedUpdatableWidget
 ThreadedUpdatableWidget (QWidget *parent=0)
 Base constructor. More...
 
void updateFromOtherThread ()
 call this function to update a widget's UI from an external thread More...
 
virtual bool event (QEvent *event)
 automatically called by Qt's event processing mechanism More...
 
- Public Member Functions inherited from icl::utils::Configurable
virtual ~Configurable ()
 virtual destructor More...
 
 Configurable (const Configurable &other)
 Copy constructor. More...
 
Configurableoperator= (const Configurable &other)
 Assignment operator. More...
 
void setConfigurableID (const std::string &ID)
 sets the ID of this configurable More...
 
const std::string & getConfigurableID () const
 returns the configurables static ID More...
 
bool isOrderedFlagSet () const
 returns whether the ordered flag is set More...
 
void deactivateProperty (const std::string &pattern)
 adds an additional deativation pattern More...
 
void deleteDeactivationPattern (const std::string &pattern)
 removed a formerly added deactivation pattern More...
 
std::vector< std::string > getPropertyListWithoutDeactivated () const
 this returns a filtered list of properties (using all filters added by deactivateProperty) More...
 
virtual void adaptProperty (const std::string &name, const std::string &newType, const std::string &newInfo, const std::string &newToolTip)
 this function can be used to adapt a specific property afterwards More...
 
void registerCallback (const Callback &cb)
 add a callback for changed properties More...
 
void removedCallback (const Callback &cb)
 removes a callback that was registered before More...
 
void syncChangesTo (Configurable *others, int num=1)
 this can be used to let this instance also apply property changes to others More...
 
virtual void setPropertyValue (const std::string &propertyName, const Any &value)
 sets a property value More...
 
virtual std::vector< std::string > getPropertyList () const
 returns a list of All properties, that can be set using setProperty More...
 
virtual bool supportsProperty (const std::string &propertyName) const
 base implementation for property check (seaches in the property list) More...
 
virtual void saveProperties (const std::string &filename, const std::vector< std::string > &propertiesToSkip=EMPTY_VEC) const
 writes all available properties into a file More...
 
virtual void loadProperties (const std::string &filename, const std::vector< std::string > &propertiesToSkip=EMPTY_VEC)
 reads a camera config file from disc More...
 
virtual std::string getPropertyType (const std::string &propertyName) const
 get type of property More...
 
virtual std::string getPropertyInfo (const std::string &propertyName) const
 get information of a properties valid values More...
 
virtual Any getPropertyValue (const std::string &propertyName) const
 returns the current value of a property or a parameter More...
 
virtual std::string getPropertyToolTip (const std::string &propertyName) const
 returns the tooltip description for a given property More...
 
virtual int getPropertyVolatileness (const std::string &propertyName) const
 Returns whether this property may be changed internally. More...
 

Protected Member Functions

bool isZoomed () const
 returns whether the zoom is active More...
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 internally used More...
 
virtual void mouseMoveEvent (QMouseEvent *event)
 internally used More...
 
virtual void mousePressEvent (QMouseEvent *event)
 internally used More...
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 internally used More...
 
virtual void enterEvent (QEvent *event)
 internally used More...
 
virtual void leaveEvent (QEvent *event)
 internally used More...
 
virtual bool drawData (QPainter &p)=0
 this must be implemented by the specific drawers More...
 
virtual void drawLegend (QPainter &p, const utils::Rect &where, bool horizontal)
 draws the ledgend More...
 
void drawDefaultLedgend (QPainter &p, const utils::Rect &where, bool horizontal, const std::vector< std::string > &rowNames, const std::vector< PenPtr > &pens)
 draws a default ledgen into the given quad More...
 
float winToDrawX (int winX) const
 converts a window x coordinate to logical drawing coordinate More...
 
float winToDrawY (int winY) const
 converts a window y coordinate to logical drawing coordinate More...
 
utils::Point32f winToDraw (const utils::Point &p) const
 converts a window coordinates to logical drawing coordinates More...
 
int drawToWinX (float drawX) const
 convert logical drawing x coordinate to window coordinate More...
 
int drawToWinY (float drawY) const
 convert logical drawing y coordinate to window coordinate More...
 
utils::Point drawToWin (const utils::Point32f &p) const
 convert logical drawing coordinates to window coordinates More...
 
utils::Rect32f getDynamicDataViewPort () const
 returns the current data viewport w.r.t. the current zoom More...
 
- Protected Member Functions inherited from icl::utils::Configurable
void addProperty (const std::string &name, const std::string &type, const std::string &info, const Any &value=Any(), const int volatileness=0, const std::string &tooltip=std::string())
 This can be used by derived classes to store supported properties in the internal list. More...
 
void addChildConfigurable (Configurable *configurable, const std::string &childPrefix="")
 This adds another configurable as child. More...
 
void removeChildConfigurable (Configurable *configurable)
 removes the given child configurable More...
 
Propertyprop (const std::string &propertyName)
 this CAN be used e.g. to store a property value in internal property-list More...
 
const Propertyprop (const std::string &propertyName) const
 this CAN be used e.g. to store a property value in internal property-list More...
 
 Configurable (const std::string &ID="", bool ordered=true)
 create this configurable with given ID More...
 
void call_callbacks (const std::string &propertyName, const Configurable *caller) const
 calls all registered callbacks More...
 

Static Protected Member Functions

template<char s>
static void draw_symbol (QPainter &p, int size, float x, float y)
 draws one of the Symbols (filled symbols are drawn by setting the QPainters brush manually) More...
 

Private Member Functions

void property_changed (const Property &)
 internally used More...
 

Private Attributes

Data * data
 pimpl More...
 

Additional Inherited Members

- Static Public Member Functions inherited from icl::utils::Configurable
static std::string create_default_ID (const std::string &prefix)
 this function can be used in subclasses to create a default ID More...
 
static Configurableget (const std::string &id)
 returns configurable by given ID More...
 
static void register_configurable_type (const std::string &classname, Function< Configurable * > creator)
 registers a configurable type More...
 
static std::vector< std::string > get_registered_configurables ()
 returns a list of all registered configurable classnames More...
 
static Configurablecreate_configurable (const std::string &classname)
 creates a configurable by given name More...
 
- Static Public Attributes inherited from icl::utils::Configurable
static const std::vector< std::string > EMPTY_VEC
 used as shortcut – just an empty vector of std::strings More...
 
- Protected Attributes inherited from icl::utils::Configurable
std::vector< Callbackcallbacks
 internally managed list of callbacks More...
 

Detailed Description

The PlotWidget is an abstract base class for 2D plotting components.

Member Typedef Documentation

◆ bgFunction

function that is used to render a non-homo

◆ PenPtr

typedef for managed row-style pointers

Member Enumeration Documentation

◆ PenType

different pen types

Enumerator
X_AXIS_PEN 

pen used to draw the x-axis

Y_AXIS_PEN 

pen used to draw the y-axis

X_TIC_PEN 

pen used to draw the x-tics

Y_TIC_PEN 

pen used to draw the y-tics

X_LABEL_PEN 

pen used to draw the x-labels

Y_LABEL_PEN 

pen used to draw the y-labels

X_GRID_PEN 

pen used to draw the x-grid lines

Y_GRID_PEN 

pen used to draw the y-grid lines

AXIS_NAME_PEN 

pen used to draw the axis labels

NUM_PEN_TYPES 

Constructor & Destructor Documentation

◆ AbstractPlotWidget()

icl::qt::AbstractPlotWidget::AbstractPlotWidget ( QWidget *  parent = 0)

Base constructor.

◆ ~AbstractPlotWidget()

icl::qt::AbstractPlotWidget::~AbstractPlotWidget ( )

destructor

Member Function Documentation

◆ addAnnotations()

void icl::qt::AbstractPlotWidget::addAnnotations ( const char  type,
const float *  data,
int  num = 1,
const QPen &  linePen = QColor(255, 0, 0),
const QBrush &  brush = Qt::NoBrush,
const std::string &  text = "",
const std::string &  textDelim = "," 
)

adds an annotation to the data viewport

annotations are used to add some extra information to the data that is already displayed. Please note, that annotation points are not used to estimate the data viewport. If you need the data viewport to be adapted automatically to show all your annotations, you have to compute and set the data viewport manually.

Parameters
typeannotation primitive type
  • rectangles (type: 'r'): data order [x,y,width,height],...
  • circles (type 'c'): data order [x,y,radius]..
  • lines (type 'l') data order: [x1,y1,x2,y2], ...
  • text (type 't'): data order: [x,y],...
  • linestrip (type 'L') data order [x1,y1], ... for linestrips annotations, "text" is not used
  • grid (type 'g') data order [nXCells, nYCells] [x1, x2], ... (point order is row major) for grid annotations, "text" is not used

rectangles and circles can optionally be labelled with text labels The text labels are displayed centered at the annotations, but the text is not scaled. For text primitives, a non-""-text is mandatory.

Parameters
datapacked data that is used to draw 'num' primitives. I.e. for rectangles, data contains num * 4 floats

This is not the way, data shall be visualized, the method is not optimized for speed and rendering and it will always copy the given data deeply.

Parameters
num
linePen
brush
text
textDelim

◆ clear()

virtual void icl::qt::AbstractPlotWidget::clear ( )
inlinevirtual

clears everything from the widget

'Everything' means all data and all annotations

Reimplemented in icl::qt::LowLevelPlotWidget, and icl::qt::PlotWidget.

◆ clearAnnotations()

void icl::qt::AbstractPlotWidget::clearAnnotations ( )

removes all existing annotations

◆ draw_symbol()

template<char s>
static void icl::qt::AbstractPlotWidget::draw_symbol ( QPainter &  p,
int  size,
float  x,
float  y 
)
inlinestaticprotected

draws one of the Symbols (filled symbols are drawn by setting the QPainters brush manually)

Please note that this template is not specialized for filled symbols like filledRect or filledCircle. These shapes must be drawn by setting up the given QPainters brush appropriately before calling the function with the corresponding unfilled shape

◆ drawData()

virtual bool icl::qt::AbstractPlotWidget::drawData ( QPainter &  p)
protectedpure virtual

this must be implemented by the specific drawers

if 0 is returned, no data is available

Implemented in icl::qt::LowLevelPlotWidget.

◆ drawDefaultLedgend()

void icl::qt::AbstractPlotWidget::drawDefaultLedgend ( QPainter &  p,
const utils::Rect where,
bool  horizontal,
const std::vector< std::string > &  rowNames,
const std::vector< PenPtr > &  pens 
)
protected

draws a default ledgen into the given quad

◆ drawLegend()

virtual void icl::qt::AbstractPlotWidget::drawLegend ( QPainter &  p,
const utils::Rect where,
bool  horizontal 
)
protectedvirtual

draws the ledgend

Reimplemented in icl::qt::LowLevelPlotWidget.

◆ drawToWin()

utils::Point icl::qt::AbstractPlotWidget::drawToWin ( const utils::Point32f p) const
protected

convert logical drawing coordinates to window coordinates

◆ drawToWinX()

int icl::qt::AbstractPlotWidget::drawToWinX ( float  drawX) const
protected

convert logical drawing x coordinate to window coordinate

◆ drawToWinY()

int icl::qt::AbstractPlotWidget::drawToWinY ( float  drawY) const
protected

convert logical drawing y coordinate to window coordinate

◆ enterEvent()

virtual void icl::qt::AbstractPlotWidget::enterEvent ( QEvent *  event)
protectedvirtual

internally used

◆ getDataViewPort()

virtual utils::Rect32f icl::qt::AbstractPlotWidget::getDataViewPort ( ) const
virtual

returns the given data vieport

in subclasses, the data viewport can be estimated from the given data dynamically

Reimplemented in icl::qt::LowLevelPlotWidget.

◆ getDynamicDataViewPort()

utils::Rect32f icl::qt::AbstractPlotWidget::getDynamicDataViewPort ( ) const
protected

returns the current data viewport w.r.t. the current zoom

◆ install()

void icl::qt::AbstractPlotWidget::install ( MouseHandler h)

adds a new mouse handler

Please note, the current implementation is not complete: only mouse press, release, move and drag-events are supported custom handlers are only triggered if one of CTRL, ALT or Shift modifiers is active events cannot be removed

◆ isZoomed()

bool icl::qt::AbstractPlotWidget::isZoomed ( ) const
protected

returns whether the zoom is active

◆ keyPressEvent()

virtual void icl::qt::AbstractPlotWidget::keyPressEvent ( QKeyEvent *  event)
virtual

listens for F11 which enables the fullscreen mode

◆ leaveEvent()

virtual void icl::qt::AbstractPlotWidget::leaveEvent ( QEvent *  event)
protectedvirtual

internally used

◆ lock()

void icl::qt::AbstractPlotWidget::lock ( ) const

locks drawing / data updates in subclasses

◆ mouseDoubleClickEvent()

virtual void icl::qt::AbstractPlotWidget::mouseDoubleClickEvent ( QMouseEvent *  event)
protectedvirtual

internally used

◆ mouseMoveEvent()

virtual void icl::qt::AbstractPlotWidget::mouseMoveEvent ( QMouseEvent *  event)
protectedvirtual

internally used

◆ mousePressEvent()

virtual void icl::qt::AbstractPlotWidget::mousePressEvent ( QMouseEvent *  event)
protectedvirtual

internally used

◆ mouseReleaseEvent()

virtual void icl::qt::AbstractPlotWidget::mouseReleaseEvent ( QMouseEvent *  event)
protectedvirtual

internally used

◆ paintEvent()

virtual void icl::qt::AbstractPlotWidget::paintEvent ( QPaintEvent *  evt)
virtual

custom drawing

◆ property_changed()

void icl::qt::AbstractPlotWidget::property_changed ( const Property )
private

internally used

◆ removeBackgroundFunction()

void icl::qt::AbstractPlotWidget::removeBackgroundFunction ( )

removes the background function

◆ render()

void icl::qt::AbstractPlotWidget::render ( )
inline

updates the screen

a shortcut to ThreadedUpdatableWidget::updateFromOtherThread()

◆ renderTo()

void icl::qt::AbstractPlotWidget::renderTo ( QPainter &  p)

renders the whole content using the given qpainter

◆ setBackground()

void icl::qt::AbstractPlotWidget::setBackground ( const QBrush &  bgBrush)

sets the background brush

◆ setBackgroundFunction()

void icl::qt::AbstractPlotWidget::setBackgroundFunction ( bgFunction  f)

sets the background function

The function is then evaluated every time, the viewport or the window size. is adapted. I.e. when the data viewport is set, or adapted automatically, or when the widget is zoomed or when the the widget is resized.

The given background functions is always called with x- and y-parameters in the logical function space rather than in window coordinates. Please note, that constantly changing viewports (i.e. due to dynamic viewport mode) will entail constant recreation of the background image. Which can be quite slow in case of complex background functions.

◆ setDataViewPort() [1/2]

void icl::qt::AbstractPlotWidget::setDataViewPort ( const utils::Rect32f viewPort)

sets the default dataviewport

if width is 0, the xrange is taken from the data if height is 0, the yrange is taken from the data
Important: The viewport needs to be given normalized. I.e.

  • viewport.x is minX
  • viewport.y is minY
  • viewport.right() is maxX
  • viewport.bottom() is maxY

◆ setDataViewPort() [2/2]

void icl::qt::AbstractPlotWidget::setDataViewPort ( const utils::Range32f &  xrange,
const utils::Range32f &  yrange 
)

sets the default viewport

See also
setDAtaViewPort(const utils::Rect32f&) Important: The range length' must be positive (otherwise, they are swapped)

◆ setPen()

void icl::qt::AbstractPlotWidget::setPen ( PenType  p,
const QPen &  pen 
)

sets the pen for one of the widget compoments

◆ uninstall()

void icl::qt::AbstractPlotWidget::uninstall ( MouseHandler h)

removes a mouse handler

not yet supported properly

◆ unlock()

void icl::qt::AbstractPlotWidget::unlock ( ) const

unlocks drawing / data updates in subclasses

◆ updateBackgroundFunction()

void icl::qt::AbstractPlotWidget::updateBackgroundFunction ( )

forces a repaint on the background function in the next rendering cycle

Forces the background function to be updated next time. E.g. if the given background function is changed internally (note, it could be a functor, that has other parameters then the exposed x,y position

◆ winToDraw()

utils::Point32f icl::qt::AbstractPlotWidget::winToDraw ( const utils::Point p) const
protected

converts a window coordinates to logical drawing coordinates

◆ winToDrawX()

float icl::qt::AbstractPlotWidget::winToDrawX ( int  winX) const
protected

converts a window x coordinate to logical drawing coordinate

◆ winToDrawY()

float icl::qt::AbstractPlotWidget::winToDrawY ( int  winY) const
protected

converts a window y coordinate to logical drawing coordinate

Member Data Documentation

◆ data

Data* icl::qt::AbstractPlotWidget::data
private

pimpl

pimpl pointer


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