Public Member Functions

iil4mitkItem Class Reference

The items are objects that can be displayed by the widget. When the widget demands an update of the display, each item draws itself into the viewport. If the user wants to interact with some item, each item provides the information whether it has been picked by the user. More...

#include <item.h>

Inheritance diagram for iil4mitkItem:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 iil4mitkItem ()
 The constructor.
virtual ~iil4mitkItem ()
virtual void display (iil4mitkWidget *widget)=0
 Displays the item.
virtual void remove (iil4mitkWidget *widget)
 Frees the resources of the item for the given widget.
void move (const float x, const float y)
 Sets the position of the item.
float x () const
 Gets the position of the item.
float y () const
virtual float width () const
 Gets the size of the item.
virtual float height () const
virtual void setColor (const float red, const float green, const float blue, const float alpha)
 Sets the color of the item.
float red () const
 Gets the color channels.
float green () const
float blue () const
float alpha () const
void setLineWidth (const float width)
 Sets the widht of the isocontour.
float lineWidth () const
 Gets the width of the isocontour.
void setPickable (const bool on)
 Sets the flag whether the user can pick the item.
bool pickable () const
 Checks if the user can pick the item.
virtual iil4mitkItempicked (iil4mitkWidget *widget, const float x, const float y)
 Checks if the item has been picked by the user.
void setScalable (const bool scalable)
 Sets if items should be scaled when the viewport is zoomed. If so, items will grow as far as the viewport is zoomed. Otherwise, items will keep its size constant.
bool scalable () const
 Checks if items will be scaled when the viewport changes.
void setConstraint (iil4mitkWidget *widget)
 Sets the given widget as a constraint for rendering, i.e., the contents are rendered only if the widget that demands the rendering is the same as the given one.
iil4mitkWidgetconstraint () const
 Gets the widget which the rendering is constraint to.
void setVisible (const bool visible)
 Makes the item visible or hidden, respectively.
bool visible () const
 Checks if the item will be visible.
void show ()
 Shows the item.
void hide ()
 Hides the item.

Detailed Description

The items are objects that can be displayed by the widget. When the widget demands an update of the display, each item draws itself into the viewport. If the user wants to interact with some item, each item provides the information whether it has been picked by the user.

Definition at line 26 of file item.h.


Constructor & Destructor Documentation

iil4mitkItem::iil4mitkItem (  )

The constructor.

Definition at line 4 of file item.cpp.

        : _x (0.0), _y (0.0), _red (1.0), _green (1.0), _blue (1.0), _alpha (1.0), _lineWidth (0.0), _constraint (0), _visible (true), _pickable (false), _scalable (true)
{
}
virtual iil4mitkItem::~iil4mitkItem (  ) [inline, virtual]

Definition at line 35 of file item.h.

{}

Member Function Documentation

float iil4mitkItem::alpha (  ) const

Definition at line 74 of file item.cpp.

Referenced by iil4mitkPicImage::copyImage(), iil4mitkPicImage::display(), iil4mitkImage::display(), and setColor().

{
    return _alpha;
}
float iil4mitkItem::blue (  ) const

Definition at line 68 of file item.cpp.

Referenced by iil4mitkPicImage::display(), iil4mitkImage::display(), and setColor().

{
    return _blue;
}
iil4mitkWidget * iil4mitkItem::constraint (  ) const

Gets the widget which the rendering is constraint to.

Definition at line 131 of file item.cpp.

Referenced by iil4mitkImage::display().

{
        return _constraint;
}
virtual void iil4mitkItem::display ( iil4mitkWidget widget ) [pure virtual]

Displays the item.

Note:
Make sure that the proper OpenGL context has been made current.

Implemented in iil4mitkImage, and iil4mitkPicImage.

float iil4mitkItem::green (  ) const

Definition at line 62 of file item.cpp.

Referenced by iil4mitkPicImage::display(), iil4mitkImage::display(), and setColor().

{
    return _green;
}
float iil4mitkItem::height (  ) const [virtual]

Reimplemented in iil4mitkImage.

Definition at line 40 of file item.cpp.

Referenced by picked().

{
    return 0.0;
}
void iil4mitkItem::hide (  )

Hides the item.

Definition at line 149 of file item.cpp.

References setVisible().

{
        setVisible (false);
}
float iil4mitkItem::lineWidth (  ) const

Gets the width of the isocontour.

Definition at line 86 of file item.cpp.

{
        return _lineWidth;
}
void iil4mitkItem::move ( const float  x,
const float  y 
)

Sets the position of the item.

Definition at line 15 of file item.cpp.

References x(), and y().

{
    _x = x;
    _y = y;
}
bool iil4mitkItem::pickable (  ) const

Checks if the user can pick the item.

Returns:
If the item is allowed to be picked, true is returned.

Definition at line 98 of file item.cpp.

Referenced by picked().

{
    return _pickable;
}
iil4mitkItem * iil4mitkItem::picked ( iil4mitkWidget widget,
const float  x,
const float  y 
) [virtual]

Checks if the item has been picked by the user.

Parameters:
widgetthe widget which caused an event
x,ythe point the user has picked
Returns:
the picked item, or null if no item has been picked

Definition at line 104 of file item.cpp.

References height(), pickable(), visible(), width(), and x().

{
    if (!pickable () || !visible ()) return NULL;

    bool p = !((x < this->x ()) || (y < this->y ()) || (x > this->x () + this->width ()) || (y > this->y () + this->height ()));
    iil4mitkItem* obj = (p ? this : NULL);
    return obj;
}
float iil4mitkItem::red (  ) const

Gets the color channels.

Definition at line 56 of file item.cpp.

Referenced by iil4mitkPicImage::display(), iil4mitkImage::display(), and setColor().

{
    return _red;
}
void iil4mitkItem::remove ( iil4mitkWidget widget ) [virtual]

Frees the resources of the item for the given widget.

Note:
Make sure that the proper OpenGL context has been made current.

Reimplemented in iil4mitkImage.

Definition at line 10 of file item.cpp.

{
}
bool iil4mitkItem::scalable (  ) const

Checks if items will be scaled when the viewport changes.

Definition at line 120 of file item.cpp.

Referenced by setScalable().

{
        return _scalable;
}
void iil4mitkItem::setColor ( const float  red,
const float  green,
const float  blue,
const float  alpha 
) [virtual]

Sets the color of the item.

Parameters:
red,green,bluethe channels of the rgb color model
alphathe opacity. If alpha is equal to one, the item is rendered opaque, otherwise it is rendered semi-transparent. If alpha is zero, the item won't be visible.

Definition at line 47 of file item.cpp.

References alpha(), blue(), green(), and red().

Referenced by mitk::ImageMapperGL2D::ApplyProperties().

{
    _red = red;
    _green = green;
    _blue = blue;
    _alpha = alpha;
}
void iil4mitkItem::setConstraint ( iil4mitkWidget widget )

Sets the given widget as a constraint for rendering, i.e., the contents are rendered only if the widget that demands the rendering is the same as the given one.

Parameters:
widgetthe widget which the rendering is constraint to. If null is given, the constraint will be removed.

Definition at line 126 of file item.cpp.

                                                   {
        _constraint = widget;
}
void iil4mitkItem::setLineWidth ( const float  width )

Sets the widht of the isocontour.

Parameters:
widththe line width

Definition at line 80 of file item.cpp.

References width().

{
        _lineWidth = width;
}
void iil4mitkItem::setPickable ( const bool  on )

Sets the flag whether the user can pick the item.

Definition at line 92 of file item.cpp.

{
    _pickable = on;
}
void iil4mitkItem::setScalable ( const bool  scalable )

Sets if items should be scaled when the viewport is zoomed. If so, items will grow as far as the viewport is zoomed. Otherwise, items will keep its size constant.

Definition at line 114 of file item.cpp.

References scalable().

{
        _scalable = scalable;
}
void iil4mitkItem::setVisible ( const bool  visible )

Makes the item visible or hidden, respectively.

Parameters:
visibleIf true the item is displayed, otherwise it is not.

Definition at line 137 of file item.cpp.

References visible().

Referenced by hide(), and show().

{
    _visible = visible;
}
void iil4mitkItem::show (  )

Shows the item.

Definition at line 155 of file item.cpp.

References setVisible().

{
        setVisible (true);
}
bool iil4mitkItem::visible (  ) const

Checks if the item will be visible.

Returns:
If the item will be displayed, true is returned.

Definition at line 143 of file item.cpp.

Referenced by iil4mitkImage::display(), picked(), and setVisible().

{
    return _visible;
}
float iil4mitkItem::width (  ) const [virtual]

Gets the size of the item.

Note:
The method may be helpful for picking.

Reimplemented in iil4mitkImage.

Definition at line 34 of file item.cpp.

Referenced by picked(), and setLineWidth().

{
    return 0.0;
}
float iil4mitkItem::x (  ) const

Gets the position of the item.

Definition at line 22 of file item.cpp.

Referenced by iil4mitkImage::copyImage(), iil4mitkPicImage::display(), move(), picked(), and iil4mitkImage::setRegion().

{
    return _x;
}
float iil4mitkItem::y (  ) const

Definition at line 28 of file item.cpp.

Referenced by iil4mitkPicImage::display(), move(), and iil4mitkImage::setRegion().

{
    return _y;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines