#include <gfx/gxscaler.h>
Public Types | |
typedef int | Mode |
Public Member Functions | |
GxScaler () | |
Default constructor. | |
GxScaler (nub::ref< GxNode > child) | |
Construct with a given child object. | |
Mode | getMode () const |
Get the current scaling mode. | |
void | setMode (Mode new_mode) |
Change the current scaling mode. | |
void | setWidth (double new_width) |
Set the desired scaled width of the child object. | |
void | setHeight (double new_height) |
Set the desired scaled height of the child object. | |
void | setMaxDim (double new_max_dimension) |
Set the desired maximum scaled dimension of the child object. | |
void | setAspectRatio (double new_aspect_ratio) |
Set the desired scaled aspect ratio of the child object. | |
void | setWidthFactor (double f) |
Set the desired width scaling factor. | |
void | setHeightFactor (double f) |
Set the desired height scaling factor. | |
double | scaledWidth () const |
Get the scaled width of the child object. | |
double | scaledHeight () const |
Get the scaled height of the child object. | |
double | scaledMaxDim () const |
Get the maximum scaled dimension of the child object. | |
double | aspectRatio () const |
Get the scaled aspect ratio of the child object. | |
double | widthFactor () const |
Get the width scaling factor. | |
double | heightFactor () const |
Get the height scaling factor. | |
virtual void | read_from (io::reader &reader) |
virtual void | write_to (io::writer &writer) const |
virtual void | draw (Gfx::Canvas &canvas) const |
Draw the object on canvas. | |
virtual void | getBoundingCube (Gfx::Bbox &bbox) const |
const nub::ref< GxNode > & | child () const |
Get the bin's child node. | |
void | setChild (const nub::ref< GxNode > &child) |
Set the bin's child node. | |
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. | |
virtual io::version_id | class_version_id () const |
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. | |
Static Public Member Functions | |
static GxScaler * | make () |
Factory function. | |
Public Attributes | |
nub::signal0 | sigNodeChanged |
Signal that will be triggered whenever the node changes state. | |
Static Public Attributes | |
static const Mode | NATIVE_SCALING = 1 |
static const Mode | MAINTAIN_ASPECT_SCALING = 2 |
static const Mode | FREE_SCALING = 3 |
Definition at line 40 of file gxscaler.h.
typedef int GxScaler::Mode |
The symbolic constants of type ScalingMode
provide several ways to scale an object with respect to the OpenGL coordinate system. The current mode can be get/set with getMode()
and setMode()
. The default scaling mode is NATIVE_SCALING
.
Definition at line 53 of file gxscaler.h.
void GxScaler::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.
Implements io::serializable.
Definition at line 203 of file gxscaler.cc.
References io::reader::read_value().
void GxScaler::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.
Implements io::serializable.
Definition at line 212 of file gxscaler.cc.
References io::writer::write_value().
void GxScaler::getBoundingCube | ( | Gfx::Bbox & | bbox | ) | const [virtual] |
Subclasses override this to transform the bounding box according to how that subclass is rendered.
Implements GxNode.
Definition at line 238 of file gxscaler.cc.
References aspectRatio(), GxBin::child(), Gfx::Bbox::cube(), NATIVE_SCALING, Gfx::Bbox::pop(), Gfx::Bbox::push(), and Gfx::Bbox::scale().
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.
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.
io::version_id io::serializable::class_version_id | ( | ) | const [virtual, inherited] |
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 in GxCache, GxPerspectiveCamera, GxFixedScaleCamera, GxPsyphyCamera, GxColor, GxCylinder, GxDisk, GxDrawStyle, GxLighting, GxLine, GxMaterial, GxPixmap, GxPointSet, GxShapeKit, GxSphere, GxText, GxTransform, io::proxy< C >, io::const_proxy< C >, Block, CloneFace, EventResponseHdlr, ExptDriver, Face, Fish, FixPt, Gabor, GaborArray, House, Jitter, MaskHatch, MorphyFace, TimingHandler, TimingHdlr, and Trial.
nub::uid nub::object::id | ( | ) | const throw () [inherited] |
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 Mode GxScaler::NATIVE_SCALING = 1 [static] |
This is the default scaling mode. No additional scaling is done beyond whatever happens in the subclass's grRender()
implementation.
Definition at line 58 of file gxscaler.h.
Referenced by draw(), getBoundingCube(), setHeight(), setMaxDim(), and setWidth().
const Mode GxScaler::MAINTAIN_ASPECT_SCALING = 2 [static] |
In this mode, the native aspect ratio of the object will be maintained. Thus, requests to change one of the object's dimensions (width or height) will affect the other dimension so as to maintain the native aspect ratio. In this mode, getAspectRatio()
should always return 1.0.
Definition at line 65 of file gxscaler.h.
Referenced by Gabor::Gabor(), GxText::GxText(), MorphyFace::MorphyFace(), setHeight(), and setWidth().
const Mode GxScaler::FREE_SCALING = 3 [static] |
In this mode, the width and height of the object may be set independently of each other.
Definition at line 69 of file gxscaler.h.
Referenced by aspectRatio(), and setAspectRatio().