CMS 3D CMS Logo

VisEventIdTwig.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "VisFramework/VisFrameworkBase/interface/VisEventIdTwig.h"
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "Iguana/Models/interface/IgTextRep.h"
00006 #include "Iguana/GLModels/interface/Ig3DRep.h"
00007 #include "Iguana/GLModels/interface/IgLegoRep.h"
00008 #include "Iguana/GLModels/interface/IgRPhiRep.h"
00009 #include "Iguana/GLModels/interface/IgRZRep.h"
00010 #include "Iguana/Framework/interface/IgRepSet.h"
00011 #include "Iguana/Inventor/interface/IgSbColorMap.h"
00012 #include "Iguana/Studio/interface/IgQtLock.h"
00013 #include <Inventor/nodes/SoAnnotation.h>
00014 #include <Inventor/nodes/SoFont.h>
00015 #include <Inventor/nodes/SoMaterial.h>
00016 #include <Inventor/nodes/SoSeparator.h>
00017 #include <Inventor/nodes/SoText2.h>
00018 #include <Inventor/nodes/SoTranslation.h>
00019 #include <qstring.h>
00020 #include <sstream>
00021 #include <iomanip>
00022 #include <classlib/utils/Error.h>
00023 #include "boost/date_time/posix_time/posix_time.hpp"
00024 #include <sys/time.h> 
00025 
00026 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00027 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00028 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00029 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00030 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00031 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00032 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00033 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00034 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00035 
00036 VisEventIdTwig::VisEventIdTwig (IgState *state, IgTwig *parent,
00037                                 const std::string &name /* = "" */)
00038     : VisQueuedTwig (state, parent, name),
00039       m_text ("no info")
00040 {}
00041 
00042 void
00043 VisEventIdTwig::configChanged (void)
00044 { IgRepSet::invalidate (this, SELF_MASK); }
00045 
00046 void
00047 VisEventIdTwig::onNewEvent (const edm::Event &event,
00048                             const edm::EventSetup &eventSetup)
00049 {    
00050     // Get debugging dump.
00051     VisQueuedTwig::onNewEvent (event, eventSetup);
00052     const edm::Timestamp time = event.time ();
00053 
00054     timeval eventTime;
00055     eventTime.tv_sec = time.value () >> 32;
00056     eventTime.tv_usec = 0xFFFFFFFF & time.value ();
00057 
00058     boost::posix_time::ptime bt0 = boost::posix_time::from_time_t(0);
00059     boost::posix_time::ptime bt = bt0 + boost::posix_time::seconds(eventTime.tv_sec)
00060       + boost::posix_time::microseconds(eventTime.tv_usec);
00061 
00062     std::cout << "Time: " << bt << std::endl;
00063 
00064     std::stringstream oss;
00065     oss << bt;
00066     std::string contents (oss.str ());
00067 
00068     m_text = (QString ("%1 GMT: Run %2, Event %3, LS %4, Orbit %5, BX %6")
00069               .arg (contents.c_str ())
00070               .arg (event.id ().run ())
00071               .arg (event.id ().event ())
00072               .arg (event.luminosityBlock ())
00073               .arg (event.orbitNumber ())
00074               .arg (event.bunchCrossing ())
00075               .latin1 ());
00076 
00077     VisQueuedTwig::onBaseInvalidate ();
00078 }
00079 
00080 void
00081 VisEventIdTwig::update (IgTextRep *rep)
00082 {
00083     // Get debugging dump.
00084     VisQueuedTwig::update (rep);
00085 
00086     IgQtLock ();
00087     rep->setText (m_text);
00088 }
00089 
00090 void
00091 VisEventIdTwig::update (Ig3DRep *rep)
00092 {
00093     // Get debugging dump.
00094     VisQueuedTwig::update (rep);
00095 
00096     IgQtLock ();
00097     rep->clear ();
00098 
00099     SoAnnotation *sep = new SoAnnotation;
00100     SoMaterial *mat = new SoMaterial;
00101     float rgbcomponents [4];
00102     IgSbColorMap::unpack (0x8b898900, rgbcomponents); // snow4
00103     mat->diffuseColor.setValue (SbColor (rgbcomponents));
00104     sep->addChild (mat);
00105 
00106 // //     QWidget *w = SoQt::getTopLevelWidget (void);
00107 // //     SbVec2s view = SoQt::getWidgetSize (w);
00108     
00109 //     // Set the viewport in the OpenGL canvas. Dimensions are calculated
00110 //     // as a percentage of the total canvas size.
00111 //     SbVec2s view = PUBLIC(this)->getGLSize();
00112 //     const int pixelarea =
00113 //      int(float(this->axiscrossSize)/100.0f * SoQtMin(view[0], view[1]));
00114 // #if 0 // middle of canvas
00115 //     SbVec2s origin(view[0]/2 - pixelarea/2, view[1]/2 - pixelarea/2);
00116 // #endif // middle of canvas
00117 // #if 1 // lower right of canvas
00118 //     SbVec2s origin(view[0] - pixelarea, 0);
00119 // #endif // lower right of canvas
00120 //     glViewport(origin[0], origin[1], pixelarea, pixelarea);
00121 
00122     SoText2  *eventLabel = new SoText2;
00123     eventLabel->string = m_text.c_str ();
00124 
00125     SoFont* labelFont = new SoFont;
00126     labelFont->size.setValue (18.0);
00127     labelFont->name.setValue ("Arial");
00128     sep->addChild (labelFont);
00129 
00130     SoTranslation *eventLabelTranslation = new SoTranslation;
00131             
00132     SbVec3f pos = SbVec3f (-11.0,
00133                            7.0,
00134                            0.0);
00135 
00136     eventLabelTranslation->translation = pos;
00137     sep->addChild (eventLabelTranslation);
00138     sep->addChild (eventLabel);
00139 
00140     rep->node ()->addChild (sep);
00141 }
00142 
00143 void
00144 VisEventIdTwig::update (IgRPhiRep *rep)
00145 {
00146     // Get debugging dump.
00147     VisQueuedTwig::update (rep);
00148 
00149     IgQtLock ();
00150     rep->clear ();
00151 
00152     SoAnnotation *sep = new SoAnnotation;    
00153 
00154     SoMaterial *mat = new SoMaterial;
00155     float rgbcomponents [4];
00156     IgSbColorMap::unpack (0x8b898900, rgbcomponents); // snow4
00157     mat->diffuseColor.setValue (SbColor (rgbcomponents));
00158     sep->addChild (mat);
00159 
00160     SoText2  *eventLabel = new SoText2;
00161     eventLabel->string = m_text.c_str ();
00162 
00163     SoFont* labelFont = new SoFont;
00164     labelFont->size.setValue (18.0);
00165     labelFont->name.setValue ("Arial");
00166     sep->addChild (labelFont);
00167 
00168     SoTranslation *eventLabelTranslation = new SoTranslation;
00169             
00170     SbVec3f pos = SbVec3f (-3.0,
00171                            8.0,
00172                            0.0);
00173 
00174     eventLabelTranslation->translation = pos;
00175     sep->addChild (eventLabelTranslation);
00176     sep->addChild (eventLabel);
00177 
00178     rep->node ()->addChild (sep);
00179 }
00180 
00181 void
00182 VisEventIdTwig::update (IgRZRep *rep)
00183 {
00184     // Get debugging dump.
00185     VisQueuedTwig::update (rep);
00186 
00187     IgQtLock ();
00188     rep->clear ();
00189 
00190     SoAnnotation *sep = new SoAnnotation;    
00191 
00192     SoMaterial *mat = new SoMaterial;
00193     float rgbcomponents [4];
00194     IgSbColorMap::unpack (0x8b898900, rgbcomponents); // snow4
00195     mat->diffuseColor.setValue (SbColor (rgbcomponents));
00196     sep->addChild (mat);
00197 
00198     SoText2  *eventLabel = new SoText2;
00199     eventLabel->string = m_text.c_str ();
00200 
00201     SoFont* labelFont = new SoFont;
00202     labelFont->size.setValue (18.0);
00203     labelFont->name.setValue ("Arial");
00204     sep->addChild (labelFont);
00205 
00206     SoTranslation *eventLabelTranslation = new SoTranslation;
00207             
00208     SbVec3f pos = SbVec3f (-11.0,
00209                            8.0,
00210                            0.0);
00211 
00212     eventLabelTranslation->translation = pos;
00213     sep->addChild (eventLabelTranslation);
00214     sep->addChild (eventLabel);
00215 
00216     rep->node ()->addChild (sep);
00217 }
00218 
00219 void
00220 VisEventIdTwig::update (IgLegoRep *rep)
00221 {
00222     // Get debugging dump.
00223     VisQueuedTwig::update (rep);
00224 
00225     IgQtLock ();
00226     rep->clear ();
00227 
00228     SoAnnotation *sep = new SoAnnotation;    
00229 
00230     SoMaterial *mat = new SoMaterial;
00231     float rgbcomponents [4];
00232     IgSbColorMap::unpack (0x8b898900, rgbcomponents); // snow4
00233     mat->diffuseColor.setValue (SbColor (rgbcomponents));
00234     sep->addChild (mat);
00235 
00236     SoText2  *eventLabel = new SoText2;
00237     eventLabel->string = m_text.c_str ();
00238 
00239     SoFont* labelFont = new SoFont;
00240     labelFont->size.setValue (18.0);
00241     labelFont->name.setValue ("Arial");
00242     sep->addChild (labelFont);
00243 
00244     SoTranslation *eventLabelTranslation = new SoTranslation;
00245             
00246     SbVec3f pos = SbVec3f (-11.0,
00247                            7.0,
00248                            0.0);
00249 
00250     eventLabelTranslation->translation = pos;
00251     sep->addChild (eventLabelTranslation);
00252     sep->addChild (eventLabel);
00253 
00254     rep->node ()->addChild (sep);
00255 }

Generated on Tue Jun 9 17:49:56 2009 for CMSSW by  doxygen 1.5.4