00001
00002
00003 #include "VisReco/VisDetector/interface/VisDetIvTwig.h"
00004 #include "VisFramework/VisConfigService/interface/VisConfigurationService.h"
00005 #include "Iguana/GLBrowsers/interface/Ig3DShapeManager.h"
00006 #include "Iguana/Models/interface/IgTextRep.h"
00007 #include "Iguana/GLModels/interface/Ig3DRep.h"
00008 #include "Iguana/GLModels/interface/IgRPhiRep.h"
00009 #include "Iguana/GLModels/interface/IgRZRep.h"
00010 #include "Iguana/Studio/interface/IgQtLock.h"
00011 #include <classlib/utils/DebugAids.h>
00012 #include <sstream>
00013 #include <iostream>
00014 #include <iomanip>
00015
00016
00017
00018
00019
00020
00021 const char* const IV_NONE =
00022 "#Inventor V2.1 ascii\n"
00023 "\n"
00024 " Separator {\n"
00025 "}\n";
00026
00027
00028
00029
00030
00031
00032
00033 VisDetIvTwig::VisDetIvTwig (IgState *state, IgTwig *parent,
00034 std::string name, std::string fileName1,
00035 std::string fileName2, std::string fileName3)
00036 : IgSimpleTwig (parent, name, true, false, true),
00037 m_name (name)
00038 {
00039 Ig3DShapeManager *shapeManager = Ig3DShapeManager::get (state);
00040 ASSERT (shapeManager);
00041
00042 SoNode *none = emptyNode ();
00043
00044 SoNode *det3d = shapeManager->lookup (fileName1);
00045 if (det3d)
00046 {
00047 m_dets.push_back (det3d);
00048 m_dets.back ()->ref ();
00049 }
00050 else
00051 {
00052 m_dets.push_back (none);
00053 m_dets.back ()->ref ();
00054 }
00055
00056
00057 SoNode *detRPhi = shapeManager->lookup (fileName2);
00058 if (detRPhi)
00059 {
00060 m_dets.push_back (detRPhi);
00061 m_dets.back ()->ref ();
00062 }
00063 else
00064 {
00065 m_dets.push_back (none);
00066 m_dets.back ()->ref ();
00067 }
00068
00069 SoNode *detRZ = shapeManager->lookup (fileName3);
00070 if (detRZ)
00071 {
00072 m_dets.push_back (detRZ);
00073 m_dets.back ()->ref ();
00074 }
00075 else
00076 {
00077 m_dets.push_back (none);
00078 m_dets.back ()->ref ();
00079 }
00080
00081 const edm::ParameterSet *pset = VisConfigurationService::pSet ();
00082 if (pset)
00083 {
00084 std::vector<std::string> twigs;
00085 twigs = pset->getUntrackedParameter<std::vector<std::string> > ("EnabledTwigs", twigs);
00086 if (std::find (twigs.begin (), twigs.end (), fullName ()) != twigs.end ())
00087 selfVisible (true);
00088 }
00089 }
00090
00091 VisDetIvTwig::~VisDetIvTwig (void)
00092 {
00093 for (std::vector<SoNode *>::iterator i = m_dets.begin (), iEnd = m_dets.end (); i != iEnd; ++i)
00094 {
00095 (*i)->unref ();
00096 }
00097 m_dets.clear ();
00098 }
00099
00101 void
00102 VisDetIvTwig::update (IgTextRep *rep)
00103 {
00104
00105 std::ostringstream text;
00106 text << "<table width='100%'><tr><td>" << m_name << "</td><td>"
00107 << "</table>";
00108
00109
00110 IgQtLock ();
00111
00112 rep->setText (text.str ());
00113 }
00114
00116 void
00117 VisDetIvTwig::update (Ig3DRep *rep)
00118 {
00119
00120 IgQtLock ();
00121
00122 if (m_dets.size () > 0)
00123 {
00124 rep->clear ();
00125 rep->node ()->addChild (m_dets [0]);
00126 }
00127 }
00128
00129 void
00130 VisDetIvTwig::update (IgRPhiRep *rep)
00131 {
00132 IgQtLock ();
00133
00134 if (m_dets.size () >= 2)
00135 {
00136 rep->clear ();
00137 rep->node ()->addChild (m_dets [1]);
00138 }
00139 }
00140
00141 void
00142 VisDetIvTwig::update (IgRZRep *rep)
00143 {
00144 IgQtLock ();
00145
00146 if (m_dets.size () >= 3)
00147 {
00148 rep->clear ();
00149 rep->node ()->addChild (m_dets [2]);
00150 }
00151 }
00152
00153 SoNode*
00154 VisDetIvTwig::emptyNode (void)
00155 {
00156 SoInput in;
00157 in.putBack (IV_NONE);
00158
00159 SoNode *result;
00160 SoDB::read (&in, result);
00161
00162 return result;
00163 }