pfGUIViewer(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
NAMEpfGUIViewer - Abstract base class for all pfViewers which require
interaction with X
FUNCTION SPECIFICATION
#include <Performer/pfx/pfGUIViewer.h>
pfGUIViewer::pfGUIViewer(pfPipe* p = NULL,
int numChannels = 1,
int stereoMode = PFVIEWER_MONO);
static pfType * pfGUIViewer::getClassType(void);
virtual void pfGUIViewer::addWorkProc() = 0;
virtual void pfGUIViewer::removeWorkProc() = 0;
virtual void pfGUIViewer::guiMainLoop() = 0;
virtual void pfGUIViewer::show() = 0;
int pfGUIViewer::mapUnmapCB(int evenType);
void* pfGUIViewer::getWidget();
void pfGUIViewer::setWidget(void* widget);
void pfGUIViewer::getMainWindow();
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfGUIViewer is derived from the parent class
pfViewer, so each of these member functions of class pfViewer are also
directly usable with objects of class pfGUIViewer. This is also true for
ancestor classes of class pfViewer.
pfLightSource* pfViewer::getHeadLight() const;
void pfViewer::setHeadLight(pfLightSource *headlight);
pfEarthSky * pfViewer::getESky() const;
void pfViewer::setESky(pfEarthSky *eSky);
void pfViewer::loadModel(char *filename, int optimize = 1);
void pfViewer::setSceneGraph(pfNode *newRoot,
int optimize = 0);
pfNode * pfViewer::getSceneGraph() const;
pfChannel * pfViewer::getChannel(int i = 0);
int pfViewer::getNumChannels() const;
pfPipeWindow* pfViewer::getPipeWindow() const;
void pfViewer::resetToHomePosition();
void pfViewer::saveHomePosition();
pfScene* pfViewer::getScene(int whichChannel = 0) const;
int pfViewer::getWidth() const;
Page 1
pfGUIViewer(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
int pfViewer::getHeight() const;
void pfViewer::setWidth(int width);
void pfViewer::setHeight(int height);
void pfViewer::setWinSizes(int width, int height);
void pfViewer::setOriginSize(int origX, int origY,
orig width, int height);
void pfViewer::getXOrigin() const;
void pfViewer::getYOrigin() const;
Window pfViewer::getXWin();
Window pfViewer::getGXWin();
void pfViewer::setDisplay(Display *);
Display* pfViewer::getDisplay() const;
pfCoord& pfViewer::getView();
void pfViewer::setInterOcularDistance(float distance);
void pfViewer::setConvergenceRatio(float ratio);
void pfViewer::setView(pfCoord& view);
pfDrawAction * pfViewer::getDrawAction(int i = 0);
void pfViewer::setDrawAction(int i,
pfDrawAction *drawAction);
int pfViewer::getStereoMode();
void viewAll();
virtual void pfViewer::show();
void pfViewer::setLoadNewModelFlag(int flag);
void pfViewer::setLoadFilename(const char *filename);
void pfViewer::setXWin(Window win);
void pfViewer::setGXWin(Window win);
Since the class pfViewer is itself derived from the parent class
pfObject, objects of class pfGUIViewer can also be used with these
functions designed for objects of class pfObject.
void* pfObject::operator new(size_t);
void* pfObject::operator new(size_t, pfFluxMemory *fmem);
void pfObject::setUserData(void *data);
void pfObject::setUserData(int slot, void *data);
void* pfObject::getUserData(pfObject *obj);
void* pfObject::getUserData(pfObject *obj, int slot);
int pfObject::getNumUserData();
Since the class pfObject is itself derived from the parent class
pfMemory, objects of class pfGUIViewer can also be used with these
functions designed for objects of class pfMemory.
void* pfMemory::getData(const void *ptr);
pfType * pfMemory::getType();
int pfMemory::isOfType(pfType *type);
int pfMemory::isExactType(pfType *type);
const char * pfMemory::getTypeName();
Page 2
pfGUIViewer(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
int pfMemory::copy(pfMemory *src);
int pfMemory::compare(const pfMemory *mem);
void pfMemory::print(uint which, uint verbose, char *prefix,
FILE *file);
int pfMemory::getArena(void *ptr);
void* pfMemory::getArena();
int pfMemory::ref();
int pfMemory::unref();
int pfMemory::unrefDelete();
int pfMemory::unrefGetRef();
int pfMemory::getRef();
int pfMemory::checkDelete();
int pfMemory::isFluxed();
void * pfMemory::getArena();
int pfMemory::getSize();
DESCRIPTION
A pfGUIViewer is an abstract base class which derives from pfViewer and
describes the functionality that one must implement if interested in
developing new classes which are based on pfPipeWindows of type
PFWIN_TYPE_X. This class is ideal for developing viewers which require
integrating OpenGL Performer applications with GUI toolkits such as
OSF/Motif, Viewkit, GTK, etc ...
As samples of how this can be done, the libpfx library provides three
classes which derive from pfGUIViewer:
pfMotifViewer
pfViewkitViewer
pfGTKViewer
In order to implement your own pfGUIViewer you must implement the
following methods:
pfGUIViewer::addWorkProc()pfGUIViewer::removeWorkProc()pfGUIViewer::guiMainLoop()pfGUIViewer::show()
The pfGUIViewer::addWorkProc() method must wrap the GUIs function for
adding a work procedure that will call pfViewerManager::simFrame(). For
example, using Xt, this function is simply a call to
XtAppAddWorkProc(appContext,(XtWorkProc)pfViewerManager::simFrame(),0);.
Note that in addition to specifying the work procedure, you need to
specify (in the constructor for the class) what the return value for this
work procedure should be in order for the GUI toolkit to continue
executing this work procedure. For Xt based applications, this is FALSE
and for GTK based applications, this value is TRUE. It must be set via
the pfViewerManager::setReturnValueForCallbacks() static method. Note
that this is the value that is returned by pfViewerManager::simFrame()
and is of no importance if you have forked the draw proc by using
PFVMAN_FORK_GUI parameter in pfViewerManager::config().
Page 3
pfGUIViewer(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
The pfGUIViewer::removeWorkProc() method must wrap the GUIs function for
removing the work procedure that was added via
pfGUIViewer::addWorkProc(). For Xt based applications this involves a
call to XtAppRemoveWorkProc().
The pfGUIViewer::guiMainLoop() method must wrap the GUIs toolkit's
function for invoking the main application loop. For Xt based
applications, this involves a call to XtAppMainLoop(). Note the the
application should not call pfGUIViewer::guiMainLoop() directly. This
method will get invoked appropriately by the pfViewerManager.
The final method that must be implemented in order to derive from
pfGUIViewer is pfGUIViewer::show(). This method takes care of mapping the
window onto the screen and setting the Window IDs that will be used by
OpenGL Performer to do it's rendering. For example, when developping an
Xt based version of this viewer, one could implement the show method as
follows:
XtRealizeWidget(_topLevel);
XSync(XtDisplay(_topLevel), FALSE);
setXWin(XtWindow(_topLevel));
setGXWin(XtWindow(_glWidget));
Note that one must specify in this function (or earlier if known) the
Window IDs for both the X Window and GFX Window which OpenGL Performer
will use for rendering. In the example above, the _topLevel widget
corresponds to the application's top level widget whereas the the
_glWidget corresponds to the widget of type glwMDrawingAreaWidgetClass
(in the case of OSF/Motif) where the rendering will occur.
Last but not least, in the constructor for the pfGUIviewer derived class,
you must add an event handler that will get called when windows get
mapped and/or unmapped. This can be done for Xt based applications via
XtAddEventHandler() and using a StructureNotifyMask as event mask. The
implementation for the callback function should be of the form:
class yourClass : public pfGUIViewer {
protected:
...
static void getTopInput(Widget *,void *,XEvent *);
...
};
void yourClass::getTopInput(Widget *,
void *callData,
XEvent *event)
{
pfGUIViewer *v = (pfGUIViewer *)callData;
switch(event->type) {
case MapNotify: v->mapUnmapCB(PFGUI_MAP); break;
case UnmapNotify: v->mapUnmapCB(PFGUI_UNMAP); break;
Page 4
pfGUIViewer(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
default: break;
}
}
This instructs the pfGUIviewer to take appropriate action (such
temporarily stopping the draw process, or adding/removing work
procedures) when the window is unmapped and resuming the process when the
window is remapped.
NOTES
Due to packaging issues, for the beta release of libpfx on IRIX, support
for the pfGTKViewer has been disabled. On Linux, support for
pfViewkitViewer has been disabled for the same reason.
Also noteworthy, it is not currently possible to mix pfGUIViewers of more
than one type in a given application.
The libpfx source code, object code and documentation are provided as
unsupported software. Routines are subject to change in future releases.
The most recent version of this software may be found at the following
URL: http://oss.sgi.com/projects/performer/.
SEE ALSO
pfMotifViewer, pfViewkitViewer, pfGTKViewer, pfViewer, pfViewerManager
Page 5