00001
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
00027
00028
00029
00030
00031
00032
00033
00034
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
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
00084 VisQueuedTwig::update (rep);
00085
00086 IgQtLock ();
00087 rep->setText (m_text);
00088 }
00089
00090 void
00091 VisEventIdTwig::update (Ig3DRep *rep)
00092 {
00093
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);
00103 mat->diffuseColor.setValue (SbColor (rgbcomponents));
00104 sep->addChild (mat);
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
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
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);
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
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);
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
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);
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 }