Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
WindowFramework Class Reference

This encapsulates the data that is normally associated with a single window, or with a single display region within a window. More...

#include "windowFramework.h"

Inheritance diagram for WindowFramework:
TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

Public Types

enum  BackgroundType {
  BT_other = 0, BT_default, BT_black, BT_gray,
  BT_white, BT_none
}
 
enum  SplitType { ST_default, ST_horizontal, ST_vertical }
 

Public Member Functions

void adjust_dimensions ()
 Reevaluates the dimensions of the window, presumably after the window has been resized by the user or some other force. More...
 
void center_trackball (const NodePath &object)
 Centers the trackball on the indicated object, and scales the trackball motion suitably. More...
 
void enable_keyboard ()
 Creates a ButtonThrower to listen to button presses and throw them as events. More...
 
virtual TypeHandle force_init_type ()
 
bool get_anim_controls () const
 Returns the current state of the anim_controls flag. More...
 
NodePath get_aspect_2d ()
 Returns the node under the 2-d scene graph that is scaled to suit the window's aspect ratio. More...
 
BackgroundType get_background_type () const
 Returns the current background type setting. More...
 
NodePath get_button_thrower ()
 Returns the node in the data graph corresponding to the ButtonThrower object associated with this window. More...
 
Cameraget_camera (int n) const
 Returns the nth camera associated with the window. More...
 
NodePath get_camera_group ()
 Returns the node above the collection of 3-d cameras in the scene graph. More...
 
DisplayRegionget_display_region_2d () const
 Returns the default DisplayRegion created for the 2-d scene (render2d). More...
 
DisplayRegionget_display_region_3d () const
 Returns the default DisplayRegion created for the 3-d scene (render). More...
 
GraphicsOutputget_graphics_output () const
 Returns a pointer to the underlying GraphicsOutput object. More...
 
GraphicsWindowget_graphics_window () const
 Returns a pointer to the underlying GraphicsWindow object, if it is in fact a window; or NULL if it is not. More...
 
bool get_lighting () const
 Returns the current state of the lighting flag. More...
 
NodePath get_mouse ()
 Returns the node in the data graph corresponding to the mouse associated with this window. More...
 
int get_num_cameras () const
 Returns the number of 3-d cameras associated with the window. More...
 
bool get_one_sided_reverse () const
 Returns the current state of the one_sided_reverse flag. More...
 
PandaFrameworkget_panda_framework () const
 Returns a pointer to the associated PandaFramework object. More...
 
bool get_perpixel () const
 Returns the current state of the perpixel flag. More...
 
NodePath get_pixel_2d ()
 Returns a special root that uses units in pixels that are relative to the window. More...
 
NodePath get_render ()
 Returns the root of the 3-d scene graph. More...
 
NodePath get_render_2d ()
 Returns the root of the 2-d scene graph. More...
 
bool get_texture () const
 Returns the current state of the texture flag. More...
 
bool get_two_sided () const
 Returns the current state of the two_sided flag. More...
 
virtual TypeHandle get_type () const
 
bool get_wireframe () const
 Returns the current state of the wireframe flag. More...
 
bool get_wireframe_filled () const
 Returns the current state of the wireframe_filled flag. More...
 
NodePath load_default_model (const NodePath &parent)
 Loads our favorite blue triangle. More...
 
NodePath load_model (const NodePath &parent, Filename filename)
 Loads up the indicated model and returns the new NodePath, or the empty NodePath if the model could not be loaded. More...
 
bool load_models (const NodePath &parent, int argc, char *argv[], int first_arg=1)
 Loads up all the model files listed in the indicated argument list. More...
 
bool load_models (const NodePath &parent, const pvector< Filename > &files)
 Loads up all the model files listed in the indicated argument list. More...
 
void loop_animations (int hierarchy_match_flags=PartGroup::HMF_ok_part_extra|PartGroup::HMF_ok_anim_extra)
 Looks for characters and their matching animation files in the scene graph; binds and loops any matching animations found. More...
 
NodePath make_camera ()
 Makes a new 3-d camera for the window. More...
 
void next_anim_control ()
 Rotates the animation controls through all of the available animations. More...
 
void set_anim_controls (bool enable)
 Creates an onscreen animation slider for frame-stepping through the animations. More...
 
void set_background_type (BackgroundType type)
 Sets the background of the window to one of the pre-canned background types (or to BT_other, which indicates the user intends to set up his own special background mode). More...
 
void set_lighting (bool enable)
 Turns lighting on (true) or off (false). More...
 
void set_one_sided_reverse (bool enable)
 Toggles one-sided reverse mode. More...
 
void set_perpixel (bool enable)
 Turns per-pixel lighting on (true) or off (false). More...
 
void set_texture (bool enable)
 Forces textures off (false) or restores default rendering (true). More...
 
void set_two_sided (bool enable)
 Forces two-sided rendering (true) or restores default rendering (false). More...
 
void set_wireframe (bool enable, bool filled=false)
 Forces wireframe state (true) or restores default rendering (false). More...
 
void setup_trackball ()
 Sets up the mouse to trackball around the camera. More...
 
WindowFrameworksplit_window (SplitType split_type=ST_default)
 Divides the window into two display regions, each of which gets its own trackball and keyboard events. More...
 
void stagger_animations ()
 Walks through all the animations that were bound by loop_animations() and staggers their play rate slightly so that they will not remain perfectly in sync. More...
 
- Public Member Functions inherited from TypedWritableReferenceCount
 TypedWritableReferenceCount (const TypedWritableReferenceCount &copy)
 
virtual ReferenceCountas_reference_count ()
 Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More...
 
void operator= (const TypedWritableReferenceCount &copy)
 
- Public Member Functions inherited from TypedWritable
 TypedWritable (const TypedWritable &copy)
 
virtual int complete_pointers (TypedWritable **p_list, BamReader *manager)
 Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). More...
 
vector_uchar encode_to_bam_stream () const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. More...
 
bool encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More...
 
virtual void fillin (DatagramIterator &scan, BamReader *manager)
 This internal function is intended to be called by each class's make_from_bam() method to read in all of the relevant data from the BamFile for the new object. More...
 
virtual void finalize (BamReader *manager)
 Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed. More...
 
UpdateSeq get_bam_modified () const
 Returns the current bam_modified counter. More...
 
void mark_bam_modified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More...
 
void operator= (const TypedWritable &copy)
 
virtual bool require_fully_complete () const
 Some objects require all of their nested pointers to have been completed before the objects themselves can be completed. More...
 
virtual void update_bam_nested (BamWriter *manager)
 Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. More...
 
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file. More...
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static TextFontget_shuttle_controls_font ()
 Returns a font that contains the shuttle controls icons. More...
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedWritableReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
static PT (TypedWritableReferenceCount) decode_from_bam_stream(vector_uchar data
 
- Static Public Member Functions inherited from TypedWritable
static bool decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr)
 Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes. More...
 
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

Friends

class PandaFramework
 

Additional Inherited Members

- Public Attributes inherited from TypedWritableReferenceCount
static BamReaderreader = nullptr)
 
- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 
- Static Public Attributes inherited from TypedWritable
static TypedWritable *const Null = nullptr
 

Detailed Description

This encapsulates the data that is normally associated with a single window, or with a single display region within a window.

(In the case where a window has been subdivided with split_window(), there may be multiple WindowFrameworks objects that share the same GraphicsOutput pointer, but reference different display regions within that window).

Definition at line 51 of file windowFramework.h.

Member Function Documentation

◆ adjust_dimensions()

void WindowFramework::adjust_dimensions ( )

Reevaluates the dimensions of the window, presumably after the window has been resized by the user or some other force.

Adjusts the render film size, aspect2d scale (aspect ratio) and the dimensionsas of pixel_2d according to the new window shape, or new config setting.

Definition at line 794 of file windowFramework.cxx.

◆ center_trackball()

void WindowFramework::center_trackball ( const NodePath object)

Centers the trackball on the indicated object, and scales the trackball motion suitably.

Definition at line 461 of file windowFramework.cxx.

◆ enable_keyboard()

void WindowFramework::enable_keyboard ( )

Creates a ButtonThrower to listen to button presses and throw them as events.

Definition at line 405 of file windowFramework.cxx.

◆ get_anim_controls()

bool WindowFramework::get_anim_controls ( ) const
inline

Returns the current state of the anim_controls flag.

Definition at line 82 of file windowFramework.I.

◆ get_aspect_2d()

NodePath WindowFramework::get_aspect_2d ( )

Returns the node under the 2-d scene graph that is scaled to suit the window's aspect ratio.

Definition at line 299 of file windowFramework.cxx.

References NodePath::attach_new_node(), get_mouse(), get_render_2d(), NodePath::is_empty(), TypedObject::is_of_type(), NodePath::node(), and PGTop::set_mouse_watcher().

◆ get_background_type()

WindowFramework::BackgroundType WindowFramework::get_background_type ( ) const
inline

Returns the current background type setting.

Definition at line 146 of file windowFramework.I.

◆ get_button_thrower()

NodePath WindowFramework::get_button_thrower ( )

Returns the node in the data graph corresponding to the ButtonThrower object associated with this window.

Definition at line 396 of file windowFramework.cxx.

◆ get_camera()

Camera * WindowFramework::get_camera ( int  n) const
inline

Returns the nth camera associated with the window.

Definition at line 57 of file windowFramework.I.

◆ get_camera_group()

NodePath WindowFramework::get_camera_group ( )

Returns the node above the collection of 3-d cameras in the scene graph.

This node may be moved around to represent the viewpoint.

Definition at line 225 of file windowFramework.cxx.

References NodePath::attach_new_node(), get_render(), and NodePath::is_empty().

Referenced by make_camera().

◆ get_display_region_2d()

DisplayRegion * WindowFramework::get_display_region_2d ( ) const
inline

Returns the default DisplayRegion created for the 2-d scene (render2d).

Definition at line 66 of file windowFramework.I.

◆ get_display_region_3d()

DisplayRegion * WindowFramework::get_display_region_3d ( ) const
inline

Returns the default DisplayRegion created for the 3-d scene (render).

Definition at line 74 of file windowFramework.I.

◆ get_graphics_output()

GraphicsOutput * WindowFramework::get_graphics_output ( ) const
inline

Returns a pointer to the underlying GraphicsOutput object.

Definition at line 39 of file windowFramework.I.

Referenced by PandaFramework::all_windows_closed(), and PandaFramework::close_all_windows().

◆ get_graphics_window()

GraphicsWindow * WindowFramework::get_graphics_window ( ) const
inline

Returns a pointer to the underlying GraphicsWindow object, if it is in fact a window; or NULL if it is not.

Definition at line 27 of file windowFramework.I.

◆ get_lighting()

bool WindowFramework::get_lighting ( ) const
inline

Returns the current state of the lighting flag.

Definition at line 130 of file windowFramework.I.

◆ get_mouse()

NodePath WindowFramework::get_mouse ( )

Returns the node in the data graph corresponding to the mouse associated with this window.

Definition at line 364 of file windowFramework.cxx.

References NodePath::is_empty().

Referenced by get_aspect_2d().

◆ get_num_cameras()

int WindowFramework::get_num_cameras ( ) const
inline

Returns the number of 3-d cameras associated with the window.

A window usually has only one camera, but it may have multiple cameras if there are multiple display regions within the window.

Definition at line 49 of file windowFramework.I.

◆ get_one_sided_reverse()

bool WindowFramework::get_one_sided_reverse ( ) const
inline

Returns the current state of the one_sided_reverse flag.

Definition at line 122 of file windowFramework.I.

◆ get_panda_framework()

PandaFramework * WindowFramework::get_panda_framework ( ) const
inline

Returns a pointer to the associated PandaFramework object.

Definition at line 18 of file windowFramework.I.

◆ get_perpixel()

bool WindowFramework::get_perpixel ( ) const
inline

Returns the current state of the perpixel flag.

Definition at line 138 of file windowFramework.I.

◆ get_pixel_2d()

NodePath WindowFramework::get_pixel_2d ( )

Returns a special root that uses units in pixels that are relative to the window.

The upperleft corner of the window is (0, 0), the lowerleft corner is (xsize, -ysize), in this coordinate system.

Definition at line 337 of file windowFramework.cxx.

References NodePath::attach_new_node(), get_render_2d(), and NodePath::is_empty().

◆ get_render()

NodePath WindowFramework::get_render ( )

◆ get_render_2d()

NodePath WindowFramework::get_render_2d ( )

◆ get_shuttle_controls_font()

TextFont * WindowFramework::get_shuttle_controls_font ( )
static

Returns a font that contains the shuttle controls icons.

Definition at line 1107 of file windowFramework.cxx.

References BamFile::open_read().

◆ get_texture()

bool WindowFramework::get_texture ( ) const
inline

Returns the current state of the texture flag.

Definition at line 106 of file windowFramework.I.

◆ get_two_sided()

bool WindowFramework::get_two_sided ( ) const
inline

Returns the current state of the two_sided flag.

Definition at line 114 of file windowFramework.I.

◆ get_wireframe()

bool WindowFramework::get_wireframe ( ) const
inline

Returns the current state of the wireframe flag.

Definition at line 90 of file windowFramework.I.

◆ get_wireframe_filled()

bool WindowFramework::get_wireframe_filled ( ) const
inline

Returns the current state of the wireframe_filled flag.

Definition at line 98 of file windowFramework.I.

◆ load_default_model()

NodePath WindowFramework::load_default_model ( const NodePath parent)

Loads our favorite blue triangle.

This is intended to provide some default geometry to have *something* to look at for testing, when no other models are provided.

Definition at line 656 of file windowFramework.cxx.

◆ load_model()

NodePath WindowFramework::load_model ( const NodePath parent,
Filename  filename 
)

Loads up the indicated model and returns the new NodePath, or the empty NodePath if the model could not be loaded.

Definition at line 585 of file windowFramework.cxx.

Referenced by load_models().

◆ load_models() [1/2]

bool WindowFramework::load_models ( const NodePath parent,
int  argc,
char *  argv[],
int  first_arg = 1 
)

Loads up all the model files listed in the indicated argument list.

If first_arg is supplied, it is the first argument in the list to consider.

Returns true if all models loaded successfully, or false if at least one of them had an error.

Definition at line 548 of file windowFramework.cxx.

◆ load_models() [2/2]

bool WindowFramework::load_models ( const NodePath parent,
const pvector< Filename > &  files 
)

Loads up all the model files listed in the indicated argument list.

Returns true if all models loaded successfully, or false if at least one of them had an error.

Definition at line 565 of file windowFramework.cxx.

References NodePath::is_empty(), and load_model().

◆ loop_animations()

void WindowFramework::loop_animations ( int  hierarchy_match_flags = PartGroup::HMF_ok_part_extra | PartGroup::HMF_ok_anim_extra)

Looks for characters and their matching animation files in the scene graph; binds and loops any matching animations found.

Definition at line 713 of file windowFramework.cxx.

References auto_bind(), get_render(), and AnimControlCollection::loop_all().

◆ make_camera()

NodePath WindowFramework::make_camera ( )

Makes a new 3-d camera for the window.

Definition at line 1129 of file windowFramework.cxx.

References NodePath::attach_new_node(), and get_camera_group().

◆ next_anim_control()

void WindowFramework::next_anim_control ( )

Rotates the animation controls through all of the available animations.

If the animation controls are not already enabled, enables them at sets to the first animation; if they are already enabled, steps to the next animation; if that is the last animation, disables the animation controls.

Definition at line 743 of file windowFramework.cxx.

References AnimControlCollection::get_num_anims, AnimControlCollection::loop_all(), and set_anim_controls().

◆ set_anim_controls()

void WindowFramework::set_anim_controls ( bool  enable)

Creates an onscreen animation slider for frame-stepping through the animations.

Definition at line 777 of file windowFramework.cxx.

Referenced by next_anim_control().

◆ set_background_type()

void WindowFramework::set_background_type ( WindowFramework::BackgroundType  type)

Sets the background of the window to one of the pre-canned background types (or to BT_other, which indicates the user intends to set up his own special background mode).

Definition at line 1048 of file windowFramework.cxx.

Referenced by PandaFramework::set_background_type().

◆ set_lighting()

void WindowFramework::set_lighting ( bool  enable)

Turns lighting on (true) or off (false).

Definition at line 1002 of file windowFramework.cxx.

References NodePath::clear_light(), get_render(), and NodePath::set_light().

Referenced by PandaFramework::set_lighting().

◆ set_one_sided_reverse()

void WindowFramework::set_one_sided_reverse ( bool  enable)

Toggles one-sided reverse mode.

In this mode, the front sides of one-sided polygons are culled instead of the back side.

Definition at line 978 of file windowFramework.cxx.

References get_render().

◆ set_perpixel()

void WindowFramework::set_perpixel ( bool  enable)

Turns per-pixel lighting on (true) or off (false).

Definition at line 1026 of file windowFramework.cxx.

References get_render().

Referenced by PandaFramework::set_perpixel().

◆ set_texture()

void WindowFramework::set_texture ( bool  enable)

Forces textures off (false) or restores default rendering (true).

Definition at line 934 of file windowFramework.cxx.

References get_render(), and NodePath::set_texture_off().

Referenced by PandaFramework::set_texture().

◆ set_two_sided()

void WindowFramework::set_two_sided ( bool  enable)

Forces two-sided rendering (true) or restores default rendering (false).

Definition at line 954 of file windowFramework.cxx.

References get_render(), and NodePath::set_two_sided().

Referenced by PandaFramework::set_two_sided().

◆ set_wireframe()

void WindowFramework::set_wireframe ( bool  enable,
bool  filled = false 
)

Forces wireframe state (true) or restores default rendering (false).

Definition at line 892 of file windowFramework.cxx.

References NodePath::clear_two_sided(), and get_render().

Referenced by PandaFramework::set_wireframe().

◆ setup_trackball()

void WindowFramework::setup_trackball ( )

Sets up the mouse to trackball around the camera.

Definition at line 434 of file windowFramework.cxx.

◆ split_window()

WindowFramework * WindowFramework::split_window ( SplitType  split_type = ST_default)

Divides the window into two display regions, each of which gets its own trackball and keyboard events.

The new window pointer is returned.

There is not an interface for recombining divided windows.

Definition at line 846 of file windowFramework.cxx.

References DisplayRegion::get_window, and DisplayRegion::set_dimensions.

◆ stagger_animations()

void WindowFramework::stagger_animations ( )

Walks through all the animations that were bound by loop_animations() and staggers their play rate slightly so that they will not remain perfectly in sync.

Definition at line 727 of file windowFramework.cxx.


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