CMS 3D CMS Logo

VisApplicationMain.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
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 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00030 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00031 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00032 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00033 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00034 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00035 
00036 
00037 IG_DEFINE_STATE_ELEMENT (VisApplicationMain, "Services/Studio/Session Types/CMSSW");
00038 
00039 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00040 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00041 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
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     // Try to instantiate it
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     // Create document
00071     ASSERT (! m_document);
00072     m_document = new IgDocument (m_studio);
00073     m_document->setName ("CMSSW Visualisation");
00074     IgDocumentDataRoot::currentRoot ("CMSSW");
00075 
00076     // Fill a document
00077     IgPage *page = new IgPage (m_document);
00078 
00079     IgQToolBoxSite *toolbox = new IgQToolBoxSite (page->state (), 
00080                                                   page->stackArea ());
00081     // Load Framework core data proxy first
00082     // which are always needed and MUST be before 
00083     // VisConfigurationService accesses the ParameterSet
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     // Checking for Twig Browser
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 //      IgState *provenanceTreeBrowserState = new IgState (page->state ());    
00108 //      new IgSelectionService (provenanceTreeBrowserState);
00109     
00110 //      IgBrowser *provenanceTreeBrowser = IgBrowserDB::get()->create ("Twig", provenanceTreeBrowserState,
00111 //                                                                     toolbox->hostWithName ("Event Data Collections"));
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         // Checking for Event Collections Browser
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 //      IgBrowser *rootTreeBrowser = IgBrowserDB::get()->create ("Twig", provenanceTreeBrowserState,
00136 //                                                               toolbox->hostWithName ("Full Tree"));
00137 //      rootTreeBrowser->browse (root);
00138     }
00139     
00140     // Checking for Text Browser
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     // By default
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         //std::cout << "View:" << views [i] << "." << std::endl;
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     // Always load the dynamic event content proxy.
00178     // It prints also run and event number on the status bar.
00179     m_document->addContentProxy ("Event/Core Content");
00180     
00181     // When there is no proxies defined in 
00182     // the parameter set we'll load all of them:
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 //      proxies.push_back ("Simulation/Data Formats");
00197 //      proxies.push_back ("Simulation/Geometry");
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     // If there is more then one view, tile them.
00232     // One view will be maximized.
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 }

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