CMS 3D CMS Logo

IgWebRZService Class Reference

#include <Iguana/WebFramework/interface/IgWebRZService.h>

Inheritance diagram for IgWebRZService:

IgWebService

List of all members.

Public Member Functions

void browse (Arguments *args)
void create (Arguments *arguments)
void doCreate (IgState *state, const std::string &name)
 IgWebRZService (IgState *state)

Static Public Member Functions

static const char * catalogLabel (void)

Private Attributes

IgStatem_state


Detailed Description

Definition at line 20 of file IgWebRZService.h.


Constructor & Destructor Documentation

IgWebRZService::IgWebRZService ( IgState state  ) 

Definition at line 32 of file IgWebRZService.cc.

References browse(), create(), lat::CreateCallback(), and IgWebService::registerCallback().

00033     : IgWebService (state)
00034 {
00035     
00036     registerCallback ("create", lat::CreateCallback (this, &IgWebRZService::create));
00037     registerCallback ("browse", lat::CreateCallback (this, &IgWebRZService::browse));
00038 }


Member Function Documentation

void IgWebRZService::browse ( Arguments args  ) 

Definition at line 94 of file IgWebRZService.cc.

References a, IgOIVBrowser::addToLog(), IgWebService::Arguments::args(), ASSERT, IgOIVBrowser::browse(), IgOIVBrowser::clearLog(), dd, DBSPlugin::get(), IgOIVBrowser::getCamera(), IgOIVBrowser::getJPGBuffer(), IgBrowserManager::lookup(), IgOIVBrowser::moveCameraScreen(), IgWebService::Arguments::outputDevice(), IgDocumentData::root(), IgOIVBrowser::spin(), split, IgWebService::state(), IgWebService::Arguments::state(), IgOIVBrowser::viewAll(), x, y, z, and IgOIVBrowser::zoom().

Referenced by IgWebRZService().

00095 {
00096     using namespace lat;
00097     IgState *state = arguments->state ();
00098     QIODevice *outputDevice = arguments->outputDevice ();    
00099     ArgumentsMap &args = *arguments->args ();
00100     
00101     IgDocumentData *dd = IgDocumentData::get (state);
00102     IgBrowserManager *manager = IgBrowserManager::get (state);
00103 
00104     std::string rootName = "";
00105     if (args.find ("root") != args.end ())
00106         rootName = args["root"];
00107     
00108     IgTwig *twig = dynamic_cast <IgTwig *> (dd->root (rootName));
00109     
00110     std::string browserName = "";
00111     if (args.find ("browserName") != args.end ())
00112         browserName = args["browserName"];
00113 
00114     
00115     IgOIVBrowser *browser = manager->lookup<IgOIVBrowser> (browserName);
00116     ASSERT (browser);
00117 
00118     browser->browse (twig);
00119     browser->viewAll ();
00120     
00121     if (args.find ("position") != args.end ())
00122     {
00123         float x, y, z;   
00124         StringList coords = StringOps::split (args["position"], ",");
00125         if (coords.size () == 3)
00126         {
00127             x = strtof (coords[0].c_str (), 0);
00128             y = strtof (coords[1].c_str (), 0);
00129             z = strtof (coords[2].c_str (), 0);                 
00130             browser->getCamera ()->position = SbVec3f (x, y ,z);                    
00131         }
00132     }
00133 
00134     if (args.find ("orientation") != args.end ())
00135     {
00136         float x,y,z,a;              
00137         StringList coords = StringOps::split (args["orientation"], ",");
00138         if (coords.size () == 4)
00139         {
00140             x = strtof (coords[0].c_str (), 0);
00141             y = strtof (coords[1].c_str (), 0);
00142             z = strtof (coords[2].c_str (), 0);                 
00143             a = strtof (coords[3].c_str (), 0);                 
00144             browser->getCamera ()->orientation 
00145                 = SbRotation (SbVec3f (x, y ,z), a);                
00146         }
00147     }
00148 
00149     if (args.find ("pointAt") != args.end ())
00150     {
00151         float x,y,z;                
00152         StringList coords = StringOps::split (args["pointAt"], ",");
00153         if (coords.size () == 3)
00154         {
00155             x = strtof (coords[0].c_str (), 0);
00156             y = strtof (coords[1].c_str (), 0);
00157             z = strtof (coords[2].c_str (), 0);                 
00158             browser->getCamera ()->pointAt (SbVec3f (x, y ,z));             
00159         }
00160     }
00161                 
00162 
00163     if (args.find ("viewAll") != args.end ())
00164     {
00165         browser->viewAll ();                
00166     }
00167 
00168     if (args.find ("moveCameraScreen") != args.end ())
00169     {
00170         float x, y;
00171         StringList coords 
00172             = StringOps::split (args["moveCameraScreen"], ",");
00173         if (coords.size () == 2)
00174         {
00175             x = strtof (coords[0].c_str (), 0);
00176             y = strtof (coords[1].c_str (), 0);
00177             browser->moveCameraScreen (SbVec2f (x, y));                 
00178         }                   
00179     }
00180 
00181     if (args.find ("zoom") != args.end ())
00182     {
00183         float diffValue = 0;
00184         diffValue = strtof (args["zoom"].c_str (), 0);
00185         browser->zoom (diffValue);
00186     }
00187 
00188     if (args.find ("spin") != args.end ())
00189     {
00190         float x, y;
00191         StringList pos 
00192             = StringOps::split (args["spin"], ",");
00193         if (pos.size () == 2)
00194         {
00195             x = strtof (pos[0].c_str (), 0);
00196             y = strtof (pos[1].c_str (), 0);
00197             const SbVec2f posn (x, y);
00198             // FIXME: all this should be done in some eventHandling function.
00199             browser->addToLog (posn, SbTime::getTimeOfDay ());                  
00200             browser->spin (posn);                       
00201         } 
00202     }
00203     
00204     if (args.find ("lastSpin") != args.end ())
00205     {
00206         float x, y;
00207         StringList pos 
00208             = StringOps::split (args["lastSpin"], ",");
00209         if (pos.size () == 2)
00210         {
00211             x = strtof (pos[0].c_str (), 0);
00212             y = strtof (pos[1].c_str (), 0);
00213                         
00214             const SbVec2f posn (x, y);
00215             // FIXME: all this should be done in some eventHandling function.
00216             browser->addToLog (posn, SbTime::getTimeOfDay ());                  
00217             browser->spin (posn);                       
00218         }                   
00219         browser->clearLog ();               
00220     }
00221                                                 
00222     QByteArray tmpArray = browser->getJPGBuffer ();
00223     outputDevice->writeBlock (tmpArray.data (), tmpArray.size ());
00224 }

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

Definition at line 227 of file IgWebRZService.cc.

00228 {
00229     return "RZ";
00230 }

void IgWebRZService::create ( Arguments arguments  ) 

Definition at line 42 of file IgWebRZService.cc.

References IgWebService::Arguments::args(), doCreate(), IgWebService::Arguments::outputDevice(), IgWebService::sendDone(), IgWebService::state(), and IgWebService::Arguments::state().

Referenced by IgWebRZService().

00043 {    
00044     IgState *state = arguments->state ();
00045     QIODevice *outputDevice = arguments->outputDevice ();    
00046     ArgumentsMap &args = *arguments->args ();
00047 
00048 
00049     std::string lookupName = "";
00050     
00051     if (args.find ("name") != args.end ())
00052         lookupName = args["name"];
00053 
00054     doCreate (state, lookupName);
00055     this->sendDone (outputDevice);    
00056 }

void IgWebRZService::doCreate ( IgState state,
const std::string &  name 
)

Definition at line 59 of file IgWebRZService.cc.

References IgBrowserManager::add(), ASSERT, DBSPlugin::get(), IgOIVBrowser::getCamera(), LOG, IgBrowserManager::lookup(), IgOIVBrowser::setCamera(), IgOIVBrowser::setCameraType(), and GsfMatrixTools::trace().

Referenced by create().

00060 {
00061     IgBrowserManager *manager =  IgBrowserManager::get (state);
00062     ASSERT (manager);
00063 
00064     IgOIVBrowser *browser = manager->lookup<IgOIVBrowser> (name);
00065     
00066     if (browser == 0)
00067     {
00068         // FIXME: UGLY hack to get the RZ view working... 
00069         LOG (0, trace, LFwebRZ, "Creating RZ browser");
00070         
00071         browser = new IgOIVBrowser (state, 0, (Ig3DBaseModel *) -3);
00072         browser->setCamera ();    
00073         browser->setCameraType (SoOrthographicCamera::getClassTypeId ());           
00074 
00075         SoOrthographicCamera * const camera 
00076             = dynamic_cast <SoOrthographicCamera *> (browser->getCamera ());
00077         if (!camera) return; // probably a scene-less viewer
00078 
00079         camera->position = SbVec3f (-14.815891, 0, 0);
00080         camera->orientation = SbRotation (SbVec3f (-0, -1, -0), 1.5707964);
00081         camera->aspectRatio = 1;
00082         camera->focalDistance = 14.815891;
00083         camera->height = 12.273887;
00084         camera->nearDistance = 0.1;
00085         camera->farDistance = 32767;
00086 
00087 
00088         manager->add (browser, name);
00089     }    
00090 }


Member Data Documentation

IgState* IgWebRZService::m_state [private]

Reimplemented from IgWebService.

Definition at line 33 of file IgWebRZService.h.


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