GxPixmap Class Reference

GxPixmap is a subclass of GxShapeKit for bitmap images. More...

#include <gfx/gxpixmap.h>

Inheritance diagram for GxPixmap:

Inheritance graph
[legend]
Collaboration diagram for GxPixmap:

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~GxPixmap () throw ()
 Virtual destructor ensures proper destruction of subclasses.
virtual io::version_id class_version_id () const
virtual void read_from (io::reader &reader)
virtual void write_to (io::writer &writer) const
void loadImage (const char *filename)
 Loads bitmap data from the image file at filename.
void loadImageStream (std::istream &ist)
 Loads PNM data from the given input stream.
void reload ()
 Reload bitmap data from the image file most recently loaded.
void queueImage (const char *filename)
 Queues the image file filename for loading.
void saveImage (const char *filename) const
 Writes bitmap data to the file filename.
void grabScreenRect (nub::soft_ref< Gfx::Canvas > canvas, const geom::rect< int > &rect)
 Grabs pixels from a rectangular area of the screen buffer.
void grabScreen (nub::soft_ref< Gfx::Canvas > canvas)
 Like grabScreen(), but grab pixels from the entire canvas window.
void grabWorldRect (nub::soft_ref< Gfx::Canvas > canvas, const geom::rect< double > &rect)
 Grabs pixels from a rectangular area of the screen buffer.
void flipContrast ()
 Flips the luminance contrast of the bitmap data.
void flipVertical ()
 Vertically inverts the image.
geom::vec2< int > size () const
 Get the image's size (x-width, y-height) in pixels.
geom::vec2< double > getZoom () const
 Get the (x,y) factors by which the bitmap will be scaled.
bool getUsingZoom () const
 Query whether zooming is currently to be used.
bool isPurgeable () const
 Query whether the image data are purgeable.
const char * filename () const
 Get the name (if any) of the source file for this bitmap image.
bool getAsBitmap () const
 Query whether the image will be rendered as 1-bit bitmap.
long int checkSum () const
 Get a checksum of all the bytes in the image data.
media::bmap_datadata ()
 Mutable access to internal bitmap data representation.
void setZoom (geom::vec2< double > zoom)
 Change the (x,y) factor by which the bitmap will be scaled.
void zoomTo (geom::vec2< int > sz)
 Zoom to a given size.
void setUsingZoom (bool val)
 Change whether zooming will be used.
void setPurgeable (bool val)
 Change whether the image data are purgeable.
void setAsBitmap (bool val)
 Change whether the image will be rendered as a 1-bit bitmap.
void scramble (int numsubcols, int numsubrows, int seed, bool allowMoveSubparts=true, bool allowFlipLeftRight=true, bool allowFlipTopBottom=true)
bool getBBVisibility () const
virtual void getBoundingCube (Gfx::Bbox &bbox) const
int getScalingMode () const
 Returns the current scaling mode.
double getWidth () const
 Returns the object's onscreen width in OpenGL units.
double getHeight () const
 Returns the object's onscreen height in OpenGL units.
double getAspectRatio () const
double getMaxDimension () const
 Returns the value of the larger of the object's width and height.
int getAlignmentMode () const
 Returns the current alignment mode.
double getCenterX () const
 Returns the x value of the location of the object's center.
double getCenterY () const
 Returns the x value of the location of the object's center.
int getPercentBorder () const
virtual int category () const
 Returns the value of the user-defined category.
int getRenderMode () const
 Returns the current rendering mode.
void setBBVisibility (bool visibility)
 Changes whether the bounding box will be visible when the object is drawn.
void setScalingMode (int mode)
void setWidth (double val)
void setHeight (double val)
void setAspectRatio (double val)
void setMaxDimension (double val)
void setAlignmentMode (int mode)
void setCenterX (double val)
void setCenterY (double val)
void setPercentBorder (int pixels)
virtual void setCategory (int val)
 Change the value of the user-defined category to val.
void setRenderMode (int mode)
void draw (Gfx::Canvas &canvas) const
virtual bool contains (GxNode *other) const
virtual rutz::fwd_iter< const
nub::ref< GxNode > > 
deepChildren ()
geom::rect< double > getBoundingBox (Gfx::Canvas &canvas) const
 Get the 2-D z-projection of the result of getBoundingCube().
void undraw (Gfx::Canvas &canvas) const
 Undraw the object from canvas by clearing the bounding box.
nub::uid id () const throw ()
rutz::fstring real_typename () const
 Returns the typename of the full object.
virtual rutz::fstring obj_typename () const
 Returns the (apparent) typename of the full object.
rutz::fstring unique_name () const
 Returns a short string describing the object by its typename and id.
void * operator new (size_t bytes)
void operator delete (void *space, size_t bytes)
void mark_as_volatile () throw ()
 Mark this object as a volatile (unshareable) object.
void incr_ref_count () const throw ()
 Increment the object's reference count.
void decr_ref_count () const throw ()
 Decrement the object's reference count.
void decr_ref_count_no_delete () const throw ()
 Decrement the object's reference count, but don't delete it.
bool is_shared () const throw ()
 Returns true if no external client has sole ownership of the object.
bool is_unshared () const throw ()
 Returns true if there is a sole external owner of the object.
bool is_not_shareable () const throw ()
ref_counts * get_counts () const throw ()
 Returns the object's reference count manager.
int dbg_ref_count () const throw ()
 FOR TEST/DEBUG ONLY! Returns the object's (strong) reference count.
int dbg_weak_ref_count () const throw ()
 FOR TEST/DEBUG ONLY! Returns the object's weak reference count.
void setFieldMap (const FieldMap &fields)
 Set the field map for this object.
const Fieldfield (const rutz::fstring &name) const
 Lookup the Field for a given name.
void touch () const
 Emit a signal saying that one of our values has changed.
void readFieldsFrom (io::reader &reader, const FieldMap &fields)
 Read all fields from the io::reader.
void writeFieldsTo (io::writer &writer, const FieldMap &fields, io::version_id svid) const
 Write all fields to the io::writer.
const FieldMapfields () const
 Get the FieldMap for this object.
virtual FieldContainerchild () const
 Get this container's child, if any. Default implementation returns null.

Static Public Member Functions

static GxPixmapmake ()
 Default creator.
static const FieldMapclassFields ()
 Get GxShapeKit's fields.

Public Attributes

nub::signal0 sigNodeChanged
 Signal that will be triggered whenever the node changes state.
nub::signal0itsSignal

Static Public Attributes

static rutz::tracer tracer
 This tracer dynamically controls the tracing of GxShapeKit member functions.

Protected Member Functions

 GxPixmap ()
 Create an empty bitmap.
virtual void grRender (Gfx::Canvas &canvas) const
 Implements the GxShapeKit rendering operation.
virtual void grGetBoundingBox (Gfx::Bbox &bbox) const


Detailed Description

GxPixmap is a subclass of GxShapeKit for bitmap images.

Definition at line 59 of file gxpixmap.h.


Member Function Documentation

io::version_id GxPixmap::class_version_id (  )  const [virtual]

Returns a serialization version id for the class. The default implementation returns zero. Classes should override this when they make a change that requires a change to their serialization protocol. Overriding versions of this function should follow the convention that a higher id refers to a later version of the class. Implementations of io::reader and io::writer will provide a way for a class to store and retrieve the serialization version of an object.

Reimplemented from GxShapeKit.

Definition at line 222 of file gxpixmap.cc.

void GxPixmap::read_from ( io::reader reader  )  [virtual]

Subclasses implement this method to save the object's state via the generic interface provided by io::reader. Parsing the format of the input is handled by the io::reader, so implementors of read_from() of don't need to deal with formatting.

Reimplemented from GxShapeKit.

Definition at line 228 of file gxpixmap.cc.

References io::reader::ensure_version_id(), queueImage(), io::reader::read_base_class(), io::reader::read_byte_array(), io::reader::read_value(), and SRC_POS.

void GxPixmap::write_to ( io::writer writer  )  const [virtual]

Subclasses implement this method to restore the object's state via the generic interface provided by io::writer. Formatting the output is handled by the io::writer, so implementors of write_to() of don't need to deal with formatting.

Reimplemented from GxShapeKit.

Definition at line 271 of file gxpixmap.cc.

References io::writer::ensure_output_version_id(), SRC_POS, io::writer::write_base_class(), io::writer::write_byte_array(), and io::writer::write_value().

void GxPixmap::loadImage ( const char *  filename  ) 

Loads bitmap data from the image file at filename.

The file must be in one of the supported image formats.

Definition at line 308 of file gxpixmap.cc.

References nub::signal0::emit(), and GxNode::sigNodeChanged.

void GxPixmap::reload (  ) 

Reload bitmap data from the image file most recently loaded.

This has the effect of reverting any changes that might have been made to the image data since loading. The underlying image file is not affected.

Definition at line 328 of file gxpixmap.cc.

References nub::signal0::emit(), and GxNode::sigNodeChanged.

void GxPixmap::queueImage ( const char *  filename  ) 

Queues the image file filename for loading.

The image will not actually be retrieved from the file until it is needed.

Definition at line 337 of file gxpixmap.cc.

References nub::signal0::emit(), and GxNode::sigNodeChanged.

Referenced by read_from().

void GxPixmap::saveImage ( const char *  filename  )  const

Writes bitmap data to the file filename.

The image file format is inferred from the given filename.

Definition at line 346 of file gxpixmap.cc.

void GxPixmap::grabScreenRect ( nub::soft_ref< Gfx::Canvas canvas,
const geom::rect< int > &  rect 
)

Grabs pixels from a rectangular area of the screen buffer.

The pixels are loaded into the GxPixmap's pixel array. The rectangle is specified in screen coordinates.

Referenced by grabScreen().

void GxPixmap::grabWorldRect ( nub::soft_ref< Gfx::Canvas canvas,
const geom::rect< double > &  rect 
)

Grabs pixels from a rectangular area of the screen buffer.

The pixels are loaded into the GxPixmap's pixel array. The rectangle is specified in world coordinates.

void GxPixmap::flipContrast (  ) 

Flips the luminance contrast of the bitmap data.

The actual math depends on the format of the bitmap data. The polarity of the contrast relative to its original value is computed and stored, so that it can be maintained throughout io operations.

Definition at line 390 of file gxpixmap.cc.

References nub::signal0::emit(), and GxNode::sigNodeChanged.

void GxPixmap::flipVertical (  ) 

Vertically inverts the image.

The total number of vertical flips in the object's history is computed and stored, so that the proper orientation polarity can be maintained across io operations.

Definition at line 402 of file gxpixmap.cc.

References nub::signal0::emit(), and GxNode::sigNodeChanged.

bool GxPixmap::isPurgeable (  )  const

Query whether the image data are purgeable.

If the image data are purgeable, they will be unloaded after every render, and then re-queued.

Definition at line 457 of file gxpixmap.cc.

Referenced by grRender().

void GxPixmap::grGetBoundingBox ( Gfx::Bbox bbox  )  const [protected, virtual]

Subclasses must override this function to return the bounding box in GL coordinates for the object's onscreen image.

Implements GxShapeKit.

Definition at line 439 of file gxpixmap.cc.

References Gfx::Bbox::drawScreenRect(), getZoom(), and size().

bool GxShapeKit::getBBVisibility (  )  const [inherited]

Queries whether the bounding box will be visible when the object is drawn.

Definition at line 266 of file gxshapekit.cc.

References GxShapeKitImpl::boundsOutline.

void GxShapeKit::getBoundingCube ( Gfx::Bbox bbox  )  const [virtual, inherited]

Overridden from GxNode. Extends the cube by the rect returned by grGetBoundingBox(), with additional transformations to reflect the scaling mode, alignment mode, and pixel border values. Subclasses of GxShapeKit should override grGetBoundingBox(), not getBoundingCube().

Implements GxNode.

Definition at line 272 of file gxshapekit.cc.

References GxShapeKitImpl::topNode.

double GxShapeKit::getAspectRatio (  )  const [inherited]

Returns the object's aspect ratio in OpenGL units. This measures how much the object is deformed relative to its native size. For both width and height, a scaling factor is computed as the ratio of the native dimension to the actual onscreen dimension. The aspect ratio is then the ratio of the width scaling factor to the height scaling factor.

Definition at line 297 of file gxshapekit.cc.

References GxShapeKitImpl::scaler.

int GxShapeKit::getPercentBorder (  )  const [inherited]

Returns the thickness (as a percentage of object size) of the border around the bounding box area.

Definition at line 327 of file gxshapekit.cc.

References GxShapeKitImpl::boundsOutline.

void GxShapeKit::setScalingMode ( int  mode  )  [inherited]

Changes the current scaling mode to mode, unless the requirements of mode (for example, requiring a bounding box) are not met, in which case the scaling mode is unchanged.

Definition at line 354 of file gxshapekit.cc.

References nub::signal0::emit(), GxShapeKitImpl::scaler, and GxNode::sigNodeChanged.

Referenced by Gabor::Gabor(), GxText::GxText(), and MorphyFace::MorphyFace().

void GxShapeKit::setWidth ( double  val  )  [inherited]

Changes the current width to val, unless the scaling mode is NATIVE_SCALING. If the scaling mode is MAINTAIN_ASPECT_SCALING, the height will be adjusted accordingly as well.

Definition at line 362 of file gxshapekit.cc.

References nub::signal0::emit(), GxShapeKitImpl::scaler, and GxNode::sigNodeChanged.

void GxShapeKit::setHeight ( double  val  )  [inherited]

Changes the current height to val, unless the scaling mode is NATIVE_SCALING. If the scaling mode is MAINTAIN_ASPECT_SCALING, the width will be adjusted accordingly as well.

Definition at line 370 of file gxshapekit.cc.

References nub::signal0::emit(), GxShapeKitImpl::scaler, and GxNode::sigNodeChanged.

Referenced by GxText::GxText().

void GxShapeKit::setAspectRatio ( double  val  )  [inherited]

Changes the aspect ratio to val, unless the scaling mode is NATIVE_SCALING or MAINTAIN_ASPECT_SCALING.

Definition at line 378 of file gxshapekit.cc.

References nub::signal0::emit(), GxShapeKitImpl::scaler, and GxNode::sigNodeChanged.

void GxShapeKit::setMaxDimension ( double  val  )  [inherited]

Sets the larger of width or height to val, unless the scaling mode is NATIVE_SCALING. If the scaling mode is MAINTAIN_ASPECT_SCALING, the other dimension will be adjusted accordingly as well.

Definition at line 386 of file gxshapekit.cc.

References nub::signal0::emit(), GxShapeKitImpl::scaler, and GxNode::sigNodeChanged.

Referenced by MorphyFace::MorphyFace().

void GxShapeKit::setAlignmentMode ( int  mode  )  [inherited]

Changes the current alignment mode to mode, unless the requirements of mode (for example, requiring a bounding box) are not met, in which case the scaling mode is unchanged.

Definition at line 394 of file gxshapekit.cc.

References GxShapeKitImpl::aligner, nub::signal0::emit(), and GxNode::sigNodeChanged.

Referenced by GxPixmap(), GxText::GxText(), and MaskHatch::MaskHatch().

void GxShapeKit::setCenterX ( double  val  )  [inherited]

Change the x value for the location of the object's center to val. This value is used only if the alignment mode is ARBITRARY_ON_CENTER.

Definition at line 402 of file gxshapekit.cc.

References GxShapeKitImpl::aligner, nub::signal0::emit(), and GxNode::sigNodeChanged.

void GxShapeKit::setCenterY ( double  val  )  [inherited]

Change the y value for the location of the object's center to val. This value is used only if the alignment mode is ARBITRARY_ON_CENTER.

Definition at line 410 of file gxshapekit.cc.

References GxShapeKitImpl::aligner, nub::signal0::emit(), and GxNode::sigNodeChanged.

void GxShapeKit::setPercentBorder ( int  pixels  )  [inherited]

Change the thickness (as a percentage of object size) of the border that will be added around the bounding box area.

Definition at line 418 of file gxshapekit.cc.

References GxShapeKitImpl::boundsOutline.

Referenced by GxPixmap(), and GxText::setStrokeWidth().

void GxShapeKit::setRenderMode ( int  mode  )  [inherited]

Changes the current rendering mode to mode, unless the requirements of mode (for example, requiring a bounding box) are not met, in which case the scaling mode is unchanged.

Definition at line 430 of file gxshapekit.cc.

References GxShapeKitImpl::cache, nub::signal0::emit(), and GxNode::sigNodeChanged.

Referenced by GxText::GxText().

void GxShapeKit::draw ( Gfx::Canvas canvas  )  const [virtual, inherited]

This function draws the object according to the GrRenderMode selected with setRenderMode().

Implements GxNode.

Definition at line 443 of file gxshapekit.cc.

References GxShapeKitImpl::topNode.

bool GxNode::contains ( GxNode other  )  const [virtual, inherited]

Returns true if other is contained within this node in the scene graph. The default implementation (for leaf nodes) returns true only if this == other. For composite nodes, the function will check recursively is other is contained within the composite structure. This function is used to avoid generated cycles in the scene graph.

Reimplemented in GxSeparator.

Definition at line 83 of file gxnode.cc.

rutz::fwd_iter< const nub::ref< GxNode > > GxNode::deepChildren (  )  [virtual, inherited]

Returns an iterator to all the children recursively contained in this object.

Reimplemented in GxSeparator.

Definition at line 89 of file gxnode.cc.

nub::uid nub::object::id (  )  const throw () [inherited]

Returns the unique id for this object. The unique id will always be strictly positive; zero is always an invalid unique id.

Definition at line 62 of file object.cc.

rutz::fstring nub::object::real_typename (  )  const [inherited]

Returns the typename of the full object.

The result is a demangled version of typeid(*this).name(), which should very closely resemble the way the object was declared in source code.

Definition at line 67 of file object.cc.

References rutz::demangled_name().

Referenced by nub::object::obj_typename().

rutz::fstring nub::object::obj_typename (  )  const [virtual, inherited]

Returns the (apparent) typename of the full object.

The default implementation just returns real_typename(). However, certain kinds of objects -- e.g., proxy objects -- might usefully choose to have obj_typename() return something besides the real_typename(), in order to masquerade as a different type of object.

Reimplemented in io::proxy< C >, io::const_proxy< C >, MtxObj, and TrialMemFuncEvent.

Definition at line 73 of file object.cc.

References nub::object::real_typename().

Referenced by io::legacy_reader::read_root(), and nub::object::unique_name().

void * nub::ref_counted::operator new ( size_t  bytes  )  [inherited]

Class-specific operator new; protected to ensure that clients use factory functions.

Definition at line 157 of file refcounted.cc.

void nub::ref_counted::operator delete ( void *  space,
size_t  bytes 
) [inherited]

Class-specific operator delete; private since deletion should only happen in ref_counted::decr_ref_count.

Definition at line 163 of file refcounted.cc.

void nub::ref_counted::incr_ref_count (  )  const throw () [inherited]

Increment the object's reference count.

This operation (on the strong reference count) is not permitted if the object is unshareable. Unshareable objects can only have their weak reference counts manipulated.

Definition at line 207 of file refcounted.cc.

References nub::ref_counts::acquire_strong().

Referenced by GxEmptyNode::make().

void nub::ref_counted::decr_ref_count (  )  const throw () [inherited]

Decrement the object's reference count.

If this causes the reference count to fall to zero or below, the pointee and the pointer will be destroyed by a call to 'delete this'. This operation (on the strong reference count) is not permitted if the object is unshareable. Unshareable objects can only have their weak reference counts manipulated.

Definition at line 212 of file refcounted.cc.

References nub::ref_counts::release_strong().

void nub::ref_counted::decr_ref_count_no_delete (  )  const throw () [inherited]

Decrement the object's reference count, but don't delete it.

Unlike decr_ref_count(), the object will NOT be delete'd if the reference count falls to zero. This operation (on the strong reference count) is not permitted if the object is unshareable. Unshareable objects can only have their weak reference counts manipulated.

Definition at line 221 of file refcounted.cc.

References nub::ref_counts::release_strong_no_delete().

bool nub::ref_counted::is_shared (  )  const throw () [inherited]

Returns true if no external client has sole ownership of the object.

This may occur if either (1) the reference count is greater than one, or (2) the object is_not_shareable(), meaning that the object itself is the only "owner".

Definition at line 226 of file refcounted.cc.

References rutz::mutex_atomic_int::atomic_get(), nub::ref_counted::is_not_shareable(), and nub::ref_counts::m_strong.

Referenced by nub::ref_counted::is_unshared().

bool nub::ref_counted::is_unshared (  )  const throw () [inherited]

Returns true if there is a sole external owner of the object.

This occurs if the reference count is one or less and the object is shareable.

Definition at line 236 of file refcounted.cc.

References nub::ref_counted::is_shared().

bool nub::ref_counted::is_not_shareable (  )  const throw () [inherited]

Returns true if the object is not shareable for any reason. This could be because its lifespan is volatile (such as objects representing on-screen windows that can be dismissed by the user). The default is for objects to be shareable; objects can declare themselves as unshareable by calling mark_as_volatile().

Definition at line 242 of file refcounted.cc.

References nub::ref_counts::m_volatile.

Referenced by nub::ref_counted::is_shared().

const Field & FieldContainer::field ( const rutz::fstring name  )  const [inherited]

Lookup the Field for a given name.

An exception will be thrown if no such Field is found.

Definition at line 176 of file fields.cc.

References FieldMap::field().


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

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:54:58 2008 by Doxygen version 1.5.5.