CMS 3D CMS Logo

VisCMSMagFieldTwig.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "VisReco/VisMagneticField/interface/VisCMSMagFieldTwig.h"
00004 #include "VisReco/VisMagneticField/interface/VisCMSMagField.h"
00005 #include "VisReco/VisMagneticField/interface/xtypeinfo.h"
00006 #include "VisFramework/VisFrameworkBase/interface/debug.h"
00007 #include "Iguana/Inventor/interface/IgSoFieldPlane.h"
00008 #include "Iguana/Framework/interface/IgBrowserMethods.h"
00009 #include "Iguana/Framework/interface/IgRepSet.h"
00010 #include "Iguana/GLBrowsers/interface/Ig3DFieldPlanesCategory.h"
00011 #include "Iguana/GLModels/interface/IgCommon3DReps.h"
00012 #include "Iguana/GLModels/interface/Ig3DModel.h"
00013 #include "Iguana/GLModels/interface/Ig3DRep.h"
00014 #include "Iguana/GLModels/interface/xtypeinfo.h"
00015 #include "Iguana/Models/interface/IgTextModel.h"
00016 #include "Iguana/Models/interface/IgSimpleTextRep.h"
00017 #include "Iguana/Models/interface/xtypeinfo.h"
00018 #include "CLHEP/Units/SystemOfUnits.h"
00019 #include <sstream>
00020 
00021 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00022 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00023 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00024 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00025 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00026 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00027 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00028 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00029 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00030 
00031 VisCMSMagFieldTwig::VisCMSMagFieldTwig (IgTwig *parent, IgState *state)
00032     : IgSimpleTwig (parent, "Magnetic Field", true, false, true),
00033       m_fieldProxy (new VisCMSMagField),
00034       m_fieldPlane (new IgSoFieldPlane),
00035       m_done (false),
00036       m_fieldDone (false)
00037 {
00038     Ig3DFieldPlanesCategory *fieldPlanesCategory = Ig3DFieldPlanesCategory::get (state);
00039     if (! fieldPlanesCategory)
00040         fieldPlanesCategory = new Ig3DFieldPlanesCategory (state);
00041     fieldPlanesCategory->registerMe (state);
00042     m_fieldPlane->ref ();
00043     fieldPlanesCategory->addOne (m_fieldPlane);
00044 }
00045 
00046 void
00047 VisCMSMagFieldTwig::onNewEvent (const edm::Event &event,
00048                                 const edm::EventSetup &eventSetup)
00049 {
00050     LOG (1, trace, LFfwvis, "VisCMSMagFieldTwig[" << name ()
00051          << "]::onNewEvent()\n");
00052 
00053     if (! m_done)
00054     {
00055         m_fieldProxy->setField (eventSetup);
00056         m_done = true;
00057     }
00058 
00059     IgRepSet::invalidate (this, SELF_MASK);
00060 }
00061 
00062 IgSoFieldPlane*
00063 VisCMSMagFieldTwig::getFieldPlane ()
00064 { return m_fieldPlane; }
00065 
00066 bool
00067 VisCMSMagFieldTwig::fieldProxy (IgSbField *&field, SbBox3f &worldbox)
00068 {
00069     // Get the current magnetic field
00070     // FIXME: Need to convert the cm to m somewhere.
00071     // The field is using cm.
00072     if (m_fieldProxy->valid ())
00073     {
00074         field = m_fieldProxy;
00075         //world dimensions: cube with each side 18+18 meters long
00076         SbBox3f world (-18.0,  // Xmin
00077                        -18.0,  // Ymin
00078                        -18.0,  // Zmin
00079                         18.0,  // Xmax
00080                         18.0,  // Ymax
00081                         18.0); // Zmax
00082         worldbox = world;
00083         m_fieldDone = true;
00084     }
00085     else
00086         field = 0;
00087     
00088     return field != 0;
00089 }
00090  
00094 MMM_DEFUN_FUNC(void,IgBrowserMethods::,doUpdate,
00095                (VisCMSMagFieldTwig *twig, Ig3DRep *rep, unsigned mask))
00096 {
00097     // Let base class implementation handle the basics.
00098     mmm_doUpdate ((IgTwig *) twig, rep, mask);
00099     
00100     // Get the current magnetic field if twig is visible
00101     IgSbField           *field = 0;
00102     SbBox3f             worldbox;
00103     
00104     if ((! twig->visible () ) || (! twig->fieldProxy (field, worldbox)))
00105         return;
00106 
00107     IgSoFieldPlane      *repnode = twig->getFieldPlane ();
00108     repnode->field (field, worldbox);
00109     rep->node ()->addChild (repnode);
00110 }
00111   
00112 MMM_DEFUN_FUNC(void,IgBrowserMethods::,doUpdate,
00113                (VisCMSMagFieldTwig *, IgTextRep *rep, unsigned))
00114 {
00115     std::ostringstream text;
00116     text << "<table width='100%'><tr><td>Name</td><td>"
00117          << "Magnetic Field</td></tr></table>\n";
00118     
00119     rep->setText (text.str ());
00120 }

Generated on Tue Jun 9 17:50:18 2009 for CMSSW by  doxygen 1.5.4