Camstream: CamStream API documentation

Main Page Class Hierarchy Compound List File List Compound Members File Members

# CCamPanel Class Reference

Abstract class for panels, visual representations of various stages in the image processing. More...

`#include <CamPanel.h>`

Inheritance diagram for CCamPanel::

List of all members.

## Public Types

- enum PanelTypes { None, YUV420, Graph }

## Public Methods

- virtual ~CCamPanel ()
- QString GetName () const
- QString GetDescription () const
- int GetPanelType () const
- QSize GetImageSize () const
- QSize GetVisibleSize () const
- bool IsDrawable ()
- int IsUsed ()
- virtual const QImage& GetImage (int n=0)
- const QPixmap& GetPixmap () const
- virtual QDialog* GetPropertiesDialog () const
- const CCamPanel& copy (const CCamPanel &src)
- const CCamPanel& operator+= (const CCamPanel &add)
- CCamPanel& operator-= (const CCamPanel &minus)
- virtual QSize sizeHint () const
- virtual QSizePolicy sizePolicy () const
- virtual void paintEvent (QPaintEvent *)

## Public Slots

- virtual void SetSize (const QSize &new_size)
- void IncrementUse ()
- void DecrementUse ()
- virtual void RightClick (const QPoint &pos)

## Signals

- void ChangedImageSize (const QSize &new_size)
- void ChangedVisibleSize (const QSize &new_size)
- void ChangedVisibility (bool new_visibility)
- void ChangedToVisible ()
- void ChangedToHidden ()
- void ChangedUsage (int new_usage)
- void ChangedToUsed ()
- void ChangedToUnused ()
- void Updated ()

## Protected Methods

- CCamPanel (const QString &new_name, const QString &new_description, int panel_type, bool draw=TRUE, QWidget *parent=0, const char *name=0)
- void SetImageSize (const QSize &new_size)
- void SetVisibleSize (const QSize &new_size)
- void CreateImages ()
- void ConnectUsage (CCamPanel *parent)
- void ConnectResizes (CCamPanel *parent)

## Protected Attributes

- int image_w
- int image_h
- int half_w
- int half_h
- QImage ImgRGB
- QImage ImgY
- QImage ImgU
- QImage ImgV
- QPixmap PixGraph
- QPopupMenu* pMenu
- bool MenuVisible

## Detailed Description

Abstract class for panels, visual representations of various stages in the image processing.

The process from image to (compressed) datastream is a long one, involving a number of steps. A CamPanel is used to hold data for a step, and if possible draw a graphical representation on the screen (this is great for debugging, but also produces some pretty pictures :)).

A CamPanel can show something as simple as the RGB image retrieved from the video device, or the DCT-ized version of the differential motion-compensated YUV image. Whatever is shown, it needs to be represented in a uniform manner through a decent base class.

CamPanels are handled by CamWidget: a CamPanel registers itself with CamWidget; this class determines which panels should be shown (depending on flags and user settings), arranges them on the screen and gives the command to draw them.

CamPanels have a unique name; this name is used to register the panel and retrieve others. Note: the name is unique per class of CamPanel, not per instance.

For example, the differentiator works on a YUV image, so when the diff-panel needs to be drawn/calculated, it will request the image(s) from the YUV panel (which may or not be visible). The YUV panel may in turn require the RGB panel, etcetera. A panel may be needed by several other panels, or require more than one panel. Circular references are not allowed.

The signal/slot mechanism of Qt is used to keep things going; the 'lower' panels with basic images are updated by CamWidget; these panels emited Updated() signal which 'higher', more sophisticated Panels may connect to. They in turn will emit Updated() signals when they are done with their work.

Panels can, and will be, created by various classes. For example, a video compressor based on the DCT and H.3* protocols may register a set of panels, while another compressor based upon subband image coding will use another set of panels. Both sets however, may be dependant upon the same 'base' panels. CamWidget itself registers 3 panels, nl. the full colour image, the YUV image and differentional YUV image (which are pretty basic :))

Panels come in three basic forms: a single RGB image that forms the begin (or end)point YUV panels in 4:2:0 format, used for steps. The UV panels are a quarter in size and displayed below the large Y image Non-image panels, for example graphs

TODO: A full list of available panels

## Member Enumeration Documentation

enum CCamPanel::PanelTypes

  | The following enumeration helps in determining how a panel should be handled, and how many images it houses. Enumeration values:
  None | Undrawable.
  YUV420 | YUV images in 4:2:0 format, 1 large and 2 smaller.
  Graph | Not an image.

## Constructor & Destructor Documentation

CCamPanel::CCamPanel ( | const QString & new_name,
| const QString & new_description,
| int panel_type,
| bool draw = TRUE,
| QWidget * parent = 0,
| const char * name = 0 )`[protected]`

  | Constructor. Parameters:
  new_name | Unique name for this kind of panel.
  new_description | Short description for this panel.
  panel_type | One of PanelTypes, sets type of this panel
  draw | Whether or not this panel can be drawn at all.
Initializes panel to 0-size and not visible. By making this constructor protected this class cannot be instantiated directly, but only through a subclass. This class is derived from QWidget, with one notable difference: the WRepaintNoErase flag is set, so that we don't get annoying flicker when we update our panel (normally, a widget is erase before updated).

CCamPanel::~CCamPanel ( | )`[virtual]`

| Destructor. Destroys all internal structures, images, etc. Is virtual to allow proper destruction of subclasses.

## Member Function Documentation

void CCamPanel::ChangedImageSize ( | const QSize & new_size )`[signal]`

| Emitted when the principle image-size has been changed.

void CCamPanel::ChangedToHidden ( | )`[signal]`

| Only emitted when the panel is turned off.

void CCamPanel::ChangedToUnused ( | )`[signal]`

| Emitted when the usage counter drops to 0 (not used any more).

void CCamPanel::ChangedToUsed ( | )`[signal]`

| Emitted when the usage counter increases to 1 (first use).

void CCamPanel::ChangedToVisible ( | )`[signal]`

| Only emitted when the panel is turned on.

void CCamPanel::ChangedUsage ( | int new_usage )`[signal]`

| Emitted whenever the usage counter changes.

void CCamPanel::ChangedVisibility ( | bool new_visibility )`[signal]`

| The visibility has changed.

void CCamPanel::ChangedVisibleSize ( | const QSize & new_size )`[signal]`

| Emitted when the visible size has been changed.

void CCamPanel::ConnectResizes ( | CCamPanel * parent )`[protected]`

| Make SIGNAL/SLOT connections to propagate updates. This function is similar to CCamPanel::ConnectUsage but this will make the necessary connections to make sure changes in size are propagated through the panels. It is probably a bad idea to connect to more than one parent for updates.

void CCamPanel::ConnectUsage ( | CCamPanel * parent )`[protected]`

| Make SIGNAL/SLOT connections for usage counting. This function connect()s the SIGNALs of this class to the apropriate SLOTSs in the parent, so that the parent class knows if it is being used by any of its children. Classes that depend on multiple parents should call ConnectUsage for each of its parent classes.

void CCamPanel::CreateImages ( | )`[protected]`

| Create image buffers in ImgRGB, ImgY/U/V or Graph resp. This function will call create() in the QImage objects ImgRGB or ImgY/U/V with the apropriate sizes; it will also fill the YUV buffers with a grayscale palet and set it to all-equal gray. In case of a Graph panel, it does the same for the QPixmap object.

void CCamPanel::DecrementUse ( | )`[slot]`

| Decrement usage counter. Wheneven a panel nog longer needs this panel it should call DecrementUse() so this panel can release resources or stop calculations that are no longer required. The usage counter may not drop below zero, and this is considered an error condition. Triggers UsageChanged().

QString CCamPanel::GetDescription ( | ) const

| Returns a short description of the panel.

const QImage & CCamPanel::GetImage ( | int n = 0 )`[virtual]`

  | Return image representing step. Returns: QImage representing the current step. Parameters:
  n | Selector for sub-image.
This function returns an image for this panel. For RGB panels, it will return ImgRGB, and for YUV panels ImgU, ImgU or ImgV, depending on n. Graph panels never return an image (but they should draw something when Draw() is called). This function can be overloaded for panels that have special needs. When there is nothing useful to return, this function will return a null image.

QSize CCamPanel::GetImageSize ( | ) const

| Return size of principle image. May be (0, 0). Returns: An object of type QSize. See also CCamPanel::SetImageSize

QString CCamPanel::GetName ( | ) const

| Returns unique name of panel.

int CCamPanel::GetPanelType ( | ) const

| Returns the panel type. Returns: One of the PanelTypes enums

const QPixmap & CCamPanel::GetPixmap ( | ) const

| Return pixmap object. Similar to GetImage, this function returns the Pixmap object for Graph panel.

QDialog * CCamPanel::GetPropertiesDialog ( | ) const`[virtual]`

| Returns: Returns a Dialog object Panels that have properties that can be manipulated by the user should return a QDialog object that is used to perform these manipulations. This dialog may not be a modal dialog box, and the handling is left up to the panel & dialog code. Default implementation returns a NULL pointer, i.e. this panel does not have such a dialog.

QSize CCamPanel::GetVisibleSize ( | ) const

| Return size of drawable portion; may be (0, 0) when there's nothing to draw. Returns: An object of type QSize.

void CCamPanel::IncrementUse ( | )`[slot]`

| Increment usage counter. Wheneven a panel has need of this panel it should call IncrementUse() to indicate its needed and should emit Updated() signals. Triggers UsageChanged().

bool CCamPanel::IsDrawable ( | )

| Returns: TRUE when this panel can be drawn. This function tells if this panel has something to draw at all. Some panels may only be used as place holders of data, and cannot draw anything useful. In that case IsDrawable() returns false. The Panel will be included in the list, but not show up in the PanelSelector, for example.

int CCamPanel::IsUsed ( | )

| Returns usage counter. This function returns the number of panels that claimed this panel for use; it returns an integer of 0 or higher. A value of 0 means this panel can be removed without problems.

virtual void CCamPanel::RightClick ( | const QPoint & pos )`[virtual, slot]`

void CCamPanel::SetImageSize ( | const QSize & new_size )`[protected]`

  | Sets principle image size. Parameters:
  new_size | New size of image
This function will set size of the underlying image. It could be an image is enhanced, scaled down or has multiple panels; in that case VisibleSize != ImageSize. This size is mainly for functions who operate on the image and need to know the dimensions. For convenience, it also sets the variables image_w, image_h, half_w and half_h. This function will emit ChangedImageSize() when the size is different. See also SetSize

void CCamPanel::SetSize ( | const QSize & new_size )`[virtual, slot]`

| Slot to signal changes in image size. Whenever the image size is changed, this function should be called with the new image size. It should determine the panel size (which may be smaller or larger than the image size). The default implemenation sets the visible and image size equal for RGB and Graph panels, while the height of YUV420 panels is 1.5 the image height to allow space for the UV boxes. Note that the Image and Visible size can always be overruled by calling SetImageSize and SetVisibleSize Reimplemented in CBasicPanel, CDCTPanel, and CDiffPanel.

void CCamPanel::SetVisibleSize ( | const QSize & new_size )`[protected]`

  | Sets visible image size. Parameters:
  new_size | New size of image
This function will set the new, visible size (which may be different from the image size set by SetImageSize) and emits a ChangedVisibleSize() signal if necessary. See also SetSize

void CCamPanel::Updated ( | )`[signal]`

| Emitted after the panel's data has been updated.

const CCamPanel & CCamPanel::copy ( | const CCamPanel & src )

| Make deep copies of images, by overwriting buffers. Blegh; the = operator is the ONLY operator that can't be inherited. Too bad.

const CCamPanel & CCamPanel::operator+= ( | const CCamPanel & plus )

| Operator overload that will add the values of the buffers of plus to this panel. The CCamPanel equivalent of 'a += b', where the YUV values are regarded as signed quantities with a virtual null point at 128. This is the integration step.

CCamPanel& CCamPanel::operator-= ( | const CCamPanel & minus )

void CCamPanel::paintEvent ( | QPaintEvent * e )`[virtual]`

  | Paint visible representation of step. Parameters:
  p | A QPainter object that has already been moved to the correct location
This function will draw the Panel contents on screen. The default implementation will draw ImgRGB or ImgYUV, depending on its PanelType. A Graph panel should overload this function.

QSize CCamPanel::sizeHint ( | ) const`[virtual]`

| Return our visible size as the sizeHint.

virtual QSizePolicy CCamPanel::sizePolicy ( | ) const`[virtual]`

## Member Data Documentation

QImage CCamPanel::ImgRGB`[protected]`

| Ready-to-use QImage object for RGB image.

QImage CCamPanel::ImgU`[protected]`

| Ready-to-use QImage object for U data.

QImage CCamPanel::ImgV`[protected]`

| Ready-to-use QImage object for V data.

QImage CCamPanel::ImgY`[protected]`

| Ready-to-use QImage object for Y data.

bool CCamPanel::MenuVisible`[protected]`

QPixmap CCamPanel::PixGraph`[protected]`

| Ready-to-use QPixmap for graphs.

int CCamPanel::half_h`[protected]`

| Half image height; set by SetImageSize();.

int CCamPanel::half_w`[protected]`

| Half image width; set by SetImageSize();.

int CCamPanel::image_h`[protected]`

| Image height; set by SetImageSize();.

int CCamPanel::image_w`[protected]`

| Image width; set by SetImageSize();.

QPopupMenu* CCamPanel::pMenu`[protected]`

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

- CamPanel.cc
- CamPanel.h