00001
00002 #include "VisFramework/VisApplication/src/VisApplicationMain.h"
00003 #include "VisFramework/VisConfigService/interface/VisConfigurationService.h"
00004 #include "Iguana/Framework/interface/IgDocumentDataRoot.h"
00005 #include "Iguana/GLBrowsers/interface/Ig3DShapeManager.h"
00006 #include "Iguana/Studio/interface/IgStudioDriver.h"
00007 #include "Iguana/Studio/interface/IgDocument.h"
00008 #include "Iguana/Studio/interface/IgDocumentData.h"
00009 #include "Iguana/Studio/interface/IgPage.h"
00010 #include "Iguana/Studio/interface/IgQtWorkspace.h"
00011 #include "Iguana/Framework/interface/IgTwig.h"
00012 #include "Iguana/Studio/interface/IgViewDB.h"
00013 #include "Iguana/Studio/interface/IgView.h"
00014 #include "Iguana/Studio/interface/IgQWorkspaceSite.h"
00015 #include "Iguana/Studio/interface/IgQDockWindowSite.h"
00016 #include "Iguana/Studio/interface/IgQtAppStatusBarService.h"
00017 #include "Iguana/Studio/interface/IgQToolBoxSite.h"
00018 #include "Iguana/Framework/interface/IgBrowser.h"
00019 #include "Iguana/Framework/interface/IgBrowserDB.h"
00020 #include "Iguana/Framework/interface/IgRepSet.h"
00021 #include "Iguana/Framework/interface/IgSelectionService.h"
00022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00023 #include <qapplication.h>
00024 #include <qtimer.h>
00025 #undef emit // zap qt macro
00026 #include <classlib/utils/DebugAids.h>
00027 #include <iostream>
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 IG_DEFINE_STATE_ELEMENT (VisApplicationMain, "Services/Studio/Session Types/CMSSW");
00038
00039
00040
00041
00042
00043 VisApplicationMain::VisApplicationMain (IgState *state)
00044 : m_state (state),
00045 m_studio (0),
00046 m_document (0)
00047 {
00048 ASSERT (m_state);
00049 m_state->put (s_key, this);
00050 }
00051
00052 bool
00053 VisApplicationMain::setup (IgStudioDriver *into)
00054 {
00055 ASSERT (m_state);
00056 ASSERT (! m_studio);
00057
00058 ASSERT (into);
00059 m_studio = into;
00060
00061
00062 QApplication::setOverrideCursor (Qt::waitCursor);
00063 IgQtAppStatusBarService::get (m_state)
00064 ->setMessage ("Loading CMSSW Application...");
00065
00066 Ig3DShapeManager *shapeManager = Ig3DShapeManager::get (m_state);
00067 if (! shapeManager) shapeManager = new Ig3DShapeManager (m_state);
00068 ASSERT (shapeManager);
00069
00070
00071 ASSERT (! m_document);
00072 m_document = new IgDocument (m_studio);
00073 m_document->setName ("CMSSW Visualisation");
00074 IgDocumentDataRoot::currentRoot ("CMSSW");
00075
00076
00077 IgPage *page = new IgPage (m_document);
00078
00079 IgQToolBoxSite *toolbox = new IgQToolBoxSite (page->state (),
00080 page->stackArea ());
00081
00082
00083
00084 m_document->addContentProxy ("Framework/Core");
00085
00086 const edm::ParameterSet *pset = VisConfigurationService::pSet ();
00087 if(! pset)
00088 {
00089 edm::ParameterSet p;
00090 VisConfigurationService *visServise = new VisConfigurationService (p);
00091 pset = visServise->pSet ();
00092 delete visServise;
00093 }
00094
00095 std::vector<IgBrowser *> browserDB;
00096 bool flag = true;
00097
00098
00099 flag = pset->getUntrackedParameter<bool> ("TwigBrowser", true);
00100
00101 if (flag)
00102 {
00103 IgBrowser *fullTreeBrowser = IgBrowserDB::get()->create ("Twig", page->state (),
00104 toolbox->hostWithName ("CMS Event and Detector"));
00105 ASSERT (fullTreeBrowser);
00106
00107
00108
00109
00110
00111
00112 IgTwig *root = IgDocumentData::get (m_document->state ())->root ("", true);
00113 ASSERT (root);
00114 IgSimpleTwig *fullTwigsBranch = new IgSimpleTwig (root, "CMS Event and Detector");
00115
00116
00117 flag = pset->getUntrackedParameter<bool> ("EventDataCollections", true);
00118 if (flag)
00119 {
00120
00121 IgBrowser *provenanceTreeBrowser = IgBrowserDB::get()->create ("Twig", page->state (),
00122 toolbox->hostWithName ("Event Data Collections"));
00123
00124 ASSERT (provenanceTreeBrowser);
00125 IgSimpleTwig *provenanceTwigsBranch = new IgSimpleTwig (root, "Event Collections");
00126
00127 fullTreeBrowser->browse (fullTwigsBranch);
00128 provenanceTreeBrowser->browse (provenanceTwigsBranch);
00129 }
00130 else
00131 {
00132 fullTreeBrowser->browse (root);
00133 }
00134
00135
00136
00137
00138 }
00139
00140
00141 flag = pset->getUntrackedParameter<bool> ("TextBrowser", true);
00142 if (flag)
00143 {
00144 browserDB.push_back (IgBrowserDB::get()->create ("Text", page->state (),
00145 new IgQDockWindowSite (page->state (),
00146 page->bottomDockArea ())));
00147 }
00148
00149 IgQtSite::selfFrom (page)->show ();
00150
00151 std::vector<std::string> views;
00152 views = pset->getUntrackedParameter<std::vector<std::string> > ("Views", views);
00153
00154
00155 if (views.empty ())
00156 {
00157 views.push_back ("RPhi Window");
00158 }
00159
00160 for (unsigned int i = 0; i < views.size (); i++)
00161 {
00162
00163 IgBrowser *browser = dynamic_cast<IgBrowser *>(IgViewDB::get ()->create (views [i], page));
00164
00165 ASSERT (browser);
00166 browserDB.push_back (browser);
00167 }
00168
00169 IgRepresentable *obj = IgDocumentData::get (page->state ())->root ();
00170 for (unsigned int i = 0; i < browserDB.size (); i++)
00171 browserDB [i]->browse (obj);
00172
00173 std::vector<std::string> proxies;
00174 proxies = pset->getUntrackedParameter<std::vector<std::string> >
00175 ("ContentProxies", proxies);
00176
00177
00178
00179 m_document->addContentProxy ("Event/Core Content");
00180
00181
00182
00183 if (proxies.empty ())
00184 {
00185 proxies.push_back ("Framework/EventSetup");
00186 proxies.push_back ("Reco/MuonCSC");
00187 proxies.push_back ("Reco/MuonRPC");
00188 proxies.push_back ("Reco/MuonDT");
00189 proxies.push_back ("Reco/Ecal");
00190 proxies.push_back ("Reco/Hcal");
00191 proxies.push_back ("Reco/Jets");
00192 proxies.push_back ("Reco/Tracker");
00193 proxies.push_back ("Reco/Muon");
00194 proxies.push_back ("Reco/Detector");
00195
00196
00197
00198 proxies.push_back ("Simulation/Hits");
00199
00200 proxies.push_back ("Reco/CMS Magnetic Field");
00201 }
00202
00203 for (unsigned int i = 0; i < proxies.size (); i++)
00204 {
00205 m_document->addContentProxy (proxies [i]);
00206 }
00207
00208 std::vector<std::string> services;
00209 services.push_back ("Services/Framework/GUI/");
00210 services = pset->getUntrackedParameter<std::vector<std::string> >
00211 ("Services", services);
00212 for (unsigned int i = 0; i < services.size (); i++)
00213 {
00214 std::string service = services [i];
00215 if (service.size () == 0) continue;
00216 if (service [service.size () - 1] == '/')
00217 m_document->load (service, true);
00218 else
00219 m_document->load (service, false);
00220 }
00221
00222 IgRepSet::invalidate (m_document->data ()->root (), IgTwig::STRUCTURE_MASK);
00223
00224 std::string appMode = "normal";
00225 appMode = pset->getUntrackedParameter<std::string> ("VisAppMode", appMode);
00226 if (appMode == "maximized")
00227 page->showMaximized ();
00228 else if (appMode == "full screen")
00229 page->showFullScreen ();
00230
00231
00232
00233 if (views.size () > 1)
00234 {
00235 QWorkspace *ws = dynamic_cast <QWorkspace *>(IgQtSite::hostFrom (page->workspace ()));
00236 QTimer::singleShot (2000, ws, SLOT (tile ()));
00237 }
00238
00239 IgQtAppStatusBarService::get (m_state)
00240 ->setMessage ("CMSSW Application is loaded.");
00241
00242 QApplication::restoreOverrideCursor ();
00243
00244 return true;
00245 }