CMS 3D CMS Logo

IgSpareBrowser Class Reference

Implements a generic 3DBaseBrowser modeled after IgRPhiBrowser. More...

#include <Iguana/GLBrowsers/interface/IgSpareBrowser.h>

Inheritance diagram for IgSpareBrowser:

Ig3DBaseBrowser IgBrowser

List of all members.

Public Slots

virtual void invertCamera (void)
virtual void setGridVisibility (bool enable)
virtual void toggleCameraType (void)
virtual void viewPlaneX (void)
virtual void viewPlaneY (void)
virtual void viewPlaneZ (void)

Public Member Functions

 IgSpareBrowser (IgState *state, IgSite *site, IgSpareModel *model=0)
bool isGridVisible (void)

Static Public Member Functions

static const char * catalogLabel (void)

Protected Member Functions

virtual QWidget * buildBottomTrim (QWidget *parent)
virtual void buildDecoration (QWidget *parent)
virtual QWidget * buildLeftTrim (QWidget *parent)
virtual QWidget * buildRightTrim (QWidget *parent)

Static Protected Member Functions

static SbBool eventCallback (void *closure, QEvent *event)

Private Member Functions

virtual void drawGrid (const bool enable)
virtual void init (void)

Private Attributes

bool m_grid


Detailed Description

Implements a generic 3DBaseBrowser modeled after IgRPhiBrowser.

This is intended to be used for specialist displays that need the utility of a IgRPhiBrowser, but which would interfere with its normal use.

Definition at line 28 of file IgSpareBrowser.h.


Constructor & Destructor Documentation

IgSpareBrowser::IgSpareBrowser ( IgState state,
IgSite site,
IgSpareModel model = 0 
)

Definition at line 18 of file IgSpareBrowser.cc.

References Ig3DBaseModel::attachPoint(), Ig3DBaseModel::encode(), Ig3DBaseRep::findMagic(), init(), m_grid, and prof2calltree::node.

00021     : Ig3DBaseBrowser (state,
00022                        site,
00023                        model ? model : new IgSpareModel (state)),
00024       m_grid (false)
00025 {
00026     init ();
00027 
00028     SoNode *node = model->attachPoint ()->findMagic (
00029                          Ig3DBaseModel::encode ("Default Grid Group"));
00030     if (node && dynamic_cast<SoGroup*>(node)->getNumChildren ())
00031         m_grid = true;
00032 }


Member Function Documentation

QWidget * IgSpareBrowser::buildBottomTrim ( QWidget *  parent  )  [protected, virtual]

Reimplemented from Ig3DBaseBrowser.

Definition at line 124 of file IgSpareBrowser.cc.

References HLT_VtxMuL3::result.

00125 {
00126     QWidget     *result = new QWidget (parent);
00127     result->setFixedHeight (0);
00128     return result;    
00129 }

void IgSpareBrowser::buildDecoration ( QWidget *  parent  )  [protected, virtual]

Definition at line 140 of file IgSpareBrowser.cc.

00141 {
00142     Ig3DBaseBrowser::buildDecoration (parent);    
00143     return;    
00144 }

QWidget * IgSpareBrowser::buildLeftTrim ( QWidget *  parent  )  [protected, virtual]

Reimplemented from Ig3DBaseBrowser.

Definition at line 116 of file IgSpareBrowser.cc.

References HLT_VtxMuL3::result.

00117 {
00118     QWidget     *result = new QWidget (parent);
00119     result->setFixedWidth (0);
00120     return result;    
00121 }

QWidget * IgSpareBrowser::buildRightTrim ( QWidget *  parent  )  [protected, virtual]

Reimplemented from Ig3DBaseBrowser.

Definition at line 132 of file IgSpareBrowser.cc.

References HLT_VtxMuL3::result.

00133 {
00134     QWidget     *result = new QWidget (parent);
00135     result->setFixedWidth (0);
00136     return result;    
00137 }

const char * IgSpareBrowser::catalogLabel ( void   )  [static]

Definition at line 15 of file IgSpareBrowser.cc.

00016 { return "Spare"; }

void IgSpareBrowser::drawGrid ( const bool  enable  )  [private, virtual]

Reimplemented from Ig3DBaseBrowser.

Definition at line 169 of file IgSpareBrowser.cc.

References Ig3DBaseModel::attachPoint(), Ig3DBaseModel::encode(), Ig3DBaseRep::findMagic(), group, in, IV_GRID, m_grid, Ig3DBaseRep::magic(), Ig3DBaseBrowser::model(), prof2calltree::node, and SiStripLorentzAngle_cfi::read.

Referenced by setGridVisibility().

00170 {
00171     SoGroup *group = 0;
00172     SoNode *node = model ()->attachPoint ()->findMagic (
00173                         Ig3DBaseModel::encode ("Default Grid Group"));
00174     if (!node)
00175     {
00176         group = new SoGroup;
00177         group->setName (Ig3DBaseModel::encode ("Default Grid Group"));
00178         model ()->attachPoint ()->magic ()->insertChild (group, 0);
00179     }
00180     else
00181     {
00182         group = dynamic_cast<SoGroup *> (node);
00183     }
00184 
00185     if (! enable)
00186     {
00187         if (group->getNumChildren () > 0)
00188             group->removeChild (0);
00189     }
00190     else if (group->getNumChildren () == 0)
00191     {
00192         SoNode *xyGrid;
00193         SoInput in;
00194         in.putBack (IV_GRID);
00195         SoDB::read (&in, xyGrid);
00196 
00197         xyGrid->setName (Ig3DBaseModel::encode ("XY Grid"));
00198         group->addChild (xyGrid);
00199     }
00200     m_grid = enable;
00201 }

SbBool IgSpareBrowser::eventCallback ( void closure,
QEvent *  event 
) [static, protected]

Reimplemented from Ig3DBaseBrowser.

Definition at line 59 of file IgSpareBrowser.cc.

References Ig3DBaseBrowser::eventCallback(), and cmssw-higgs-4mu::firstEvent.

Referenced by init().

00060 {
00061     static bool firstEvent = true;    
00062     static float oldX = 0.;
00063     static float oldY = 0.;
00064     IgSpareBrowser *browser = static_cast<IgSpareBrowser *> (closure);
00065     if (! browser->isViewing ())
00066         return false;
00067     if (! browser->getParentWidget ()->hasMouse () && firstEvent)
00068         return false;
00069     if (! Ig3DBaseBrowser::eventCallback (closure, event))
00070     {      
00071         if (QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent *> (event))
00072         {
00073             if (mouseEvent->type () == QEvent::MouseMove
00074                 && mouseEvent->stateAfter () == Qt::NoButton)
00075             {
00076                 if (! firstEvent)
00077                 {
00078                     firstEvent = true;
00079                     return true;
00080                 }
00081             }
00082             else if (mouseEvent->state () == Qt::LeftButton)
00083             {
00084                 if (mouseEvent->stateAfter () == Qt::NoButton)
00085                     firstEvent = true;
00086                 else if (mouseEvent->type () == QEvent::MouseMove)
00087                 {
00088                     if (firstEvent)
00089                     {
00090                         oldX = mouseEvent->x ();
00091                         oldY = mouseEvent->y ();
00092                         firstEvent = false;
00093                     }
00094                     else
00095                     {
00096                         float deltaX = mouseEvent->x () - oldX;
00097                         float deltaY = oldY - mouseEvent->y ();
00098                         SoCamera *camera = browser->getCamera ();
00099                         SbVec3f oldPosition = camera->position.getValue ();
00100                         camera->position = oldPosition - 
00101                                            SbVec3f (deltaX/10, deltaY/10, 0);
00102                         oldX = mouseEvent->x ();
00103                         oldY = mouseEvent->y ();
00104                     }
00105                     return true;
00106                 }
00107             }
00108             return false;
00109         }
00110         return false;
00111     }
00112     return true;
00113 }

void IgSpareBrowser::init ( void   )  [private, virtual]

Definition at line 35 of file IgSpareBrowser.cc.

References e, and eventCallback().

Referenced by IgSpareBrowser().

00036 {
00037     SoQtExaminerViewer::setCameraType (SoOrthographicCamera::getClassTypeId ());
00038     SoOrthographicCamera * const camera = dynamic_cast <SoOrthographicCamera *> (this->getCamera ());
00039     if (! camera) return; // probably a scene-less viewer
00040 
00041     if (SoQtViewer::isHeadlight ()) SoQtViewer::setHeadlight (false);
00042 
00043 //     camera->position = SbVec3f (0, 0, 1) * camera->position.getValue ().length ();
00044 //     camera->orientation = SbRotation::identity ();
00045 
00046     camera->position = SbVec3f (-2.3816285e-07, -5.9540713e-07, 14.8);
00047     camera->orientation = SbRotation (SbVec3f (0, 1, 0),  0);
00048     camera->aspectRatio = 1;
00049     camera->focalDistance = 14.815891;
00050     camera->height = 12.273887;
00051     camera->nearDistance = 0.1;
00052     camera->farDistance = 32767;
00053    
00054     setEventCallback (eventCallback, this); 
00055     setBackgroundColor (SbColor (1.0, 1.0, 1.0));
00056 }

void IgSpareBrowser::invertCamera ( void   )  [virtual, slot]

Reimplemented from Ig3DBaseBrowser.

Definition at line 154 of file IgSpareBrowser.cc.

00155 {
00156     SoCamera * const camera = this->getCamera ();
00157     if (!camera) return; // probably a scene-less viewer
00158 
00159     camera->position = camera->position.getValue () * -1.0F;    
00160 }

bool IgSpareBrowser::isGridVisible ( void   ) 

Reimplemented from Ig3DBaseBrowser.

Definition at line 204 of file IgSpareBrowser.cc.

References m_grid.

00205 {
00206     return m_grid;
00207 }

void IgSpareBrowser::setGridVisibility ( bool  enable  )  [virtual, slot]

Reimplemented from Ig3DBaseBrowser.

Definition at line 163 of file IgSpareBrowser.cc.

References drawGrid().

00164 {
00165     IgSpareBrowser::drawGrid (enable);
00166 }

void IgSpareBrowser::toggleCameraType ( void   )  [virtual, slot]

Reimplemented from Ig3DBaseBrowser.

Definition at line 147 of file IgSpareBrowser.cc.

References Ig3DBaseBrowser::toggleCameraType().

00148 {
00149     SoQtExaminerViewer::toggleCameraType ();
00150     Ig3DBaseBrowser::toggleCameraType ();    
00151 }

void IgSpareBrowser::viewPlaneX ( void   )  [virtual, slot]

Reimplemented from Ig3DBaseBrowser.

Definition at line 210 of file IgSpareBrowser.cc.

References f.

Referenced by IgSpareViewPropertiesCategory::alignAxis().

00211 {
00212     SoCamera * const camera = this->getCamera ();
00213     if (!camera) return; // probably a scene-less viewer
00214     
00215     camera->position = SbVec3f (-1, 0, 0) * camera->position.getValue ().length ();
00216     camera->orientation = SbRotation (SbVec3f (0, 1, 0), -M_PI / 2.f);
00217 }

void IgSpareBrowser::viewPlaneY ( void   )  [virtual, slot]

Reimplemented from Ig3DBaseBrowser.

Definition at line 220 of file IgSpareBrowser.cc.

References f.

Referenced by IgSpareViewPropertiesCategory::alignAxis().

00221 {
00222     SoCamera * const camera = this->getCamera ();
00223     if (!camera) return; // probably a scene-less viewer
00224 
00225     SbVec3f norient = SbVec3f (0, -1, 0);
00226     camera->position = -norient * camera->position.getValue().length();
00227     camera->orientation = SbRotation (SbVec3f (0, 0, 1), -M_PI / 2.f) * 
00228                           SbRotation (SbVec3f (0, 0, -1), norient);
00229 }

void IgSpareBrowser::viewPlaneZ ( void   )  [virtual, slot]

Reimplemented from Ig3DBaseBrowser.

Definition at line 232 of file IgSpareBrowser.cc.

Referenced by IgSpareViewPropertiesCategory::alignAxis().

00233 {
00234     SoCamera * const camera = this->getCamera ();
00235     if (!camera) return; // probably a scene-less viewer
00236   
00237     camera->position = SbVec3f (0, 0, 1) * camera->position.getValue ().length ();
00238     camera->orientation = SbRotation::identity ();
00239 }


Member Data Documentation

bool IgSpareBrowser::m_grid [private]

Reimplemented from Ig3DBaseBrowser.

Definition at line 56 of file IgSpareBrowser.h.

Referenced by drawGrid(), IgSpareBrowser(), and isGridVisible().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:25:44 2009 for CMSSW by  doxygen 1.5.4