00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <boost/bind.hpp>
00018 #include <stdexcept>
00019 #include <iostream>
00020 #include <cstdio>
00021 #include <sstream>
00022
00023 #include "TGButton.h"
00024 #include "TGLabel.h"
00025 #include "TSystem.h"
00026 #include "TGLViewer.h"
00027 #include "TEveBrowser.h"
00028 #include "TEveManager.h"
00029 #include "TGPack.h"
00030 #include "TEveWindow.h"
00031 #include "TEveViewer.h"
00032 #include "TEveWindowManager.h"
00033 #include "TEveSelection.h"
00034 #include "TVirtualX.h"
00035 #include "TFile.h"
00036
00037
00038 #include "Fireworks/Core/interface/FWGUIManager.h"
00039 #include "Fireworks/Core/interface/Context.h"
00040 #include "Fireworks/Core/interface/FWGUISubviewArea.h"
00041
00042 #include "Fireworks/Core/interface/FWSelectionManager.h"
00043 #include "Fireworks/Core/interface/FWEventItemsManager.h"
00044 #include "Fireworks/Core/interface/FWSummaryManager.h"
00045 #include "Fireworks/Core/interface/FWColorManager.h"
00046 #include "Fireworks/Core/interface/FWDetailViewManager.h"
00047 #include "Fireworks/Core/interface/FWViewBase.h"
00048 #include "Fireworks/Core/interface/FWViewType.h"
00049 #include "Fireworks/Core/interface/FWGeometryTableViewBase.h"
00050 #include "Fireworks/Core/interface/FWJobMetadataManager.h"
00051 #include "Fireworks/Core/interface/FWInvMassDialog.h"
00052
00053 #include "Fireworks/Core/interface/FWConfiguration.h"
00054
00055 #include "Fireworks/Core/interface/CmsShowMainFrame.h"
00056 #include "Fireworks/Core/interface/FWNavigatorBase.h"
00057
00058 #include "Fireworks/Core/src/FWGUIEventDataAdder.h"
00059 #include "Fireworks/Core/src/FWNumberEntry.h"
00060
00061 #include "Fireworks/Core/interface/CSGAction.h"
00062
00063 #include "Fireworks/Core/interface/ActionsList.h"
00064
00065 #include "Fireworks/Core/interface/CmsShowEDI.h"
00066 #include "Fireworks/Core/interface/CmsShowCommonPopup.h"
00067 #include "Fireworks/Core/interface/CmsShowModelPopup.h"
00068 #include "Fireworks/Core/interface/CmsShowViewPopup.h"
00069
00070 #include "Fireworks/Core/interface/CmsShowHelpPopup.h"
00071
00072 #include "Fireworks/Core/src/CmsShowTaskExecutor.h"
00073
00074 #include "Fireworks/Core/interface/FWTypeToRepresentations.h"
00075 #include "Fireworks/Core/interface/FWIntValueListener.h"
00076 #include "Fireworks/Core/interface/FWCustomIconsButton.h"
00077
00078 #include "Fireworks/Core/src/FWModelContextMenuHandler.h"
00079
00080 #include "Fireworks/Core/interface/fwLog.h"
00081
00082 #include "FWCore/Common/interface/EventBase.h"
00083
00084
00085
00086
00087
00088
00089
00090 FWGUIManager* FWGUIManager::m_guiManager = 0;
00091
00092
00093
00094
00095 FWGUIManager::FWGUIManager(fireworks::Context* ctx,
00096 const FWViewManagerManager* iVMMgr,
00097 FWNavigatorBase* navigator):
00098 m_context(ctx),
00099 m_summaryManager(0),
00100 m_detailViewManager(0),
00101 m_viewManagerManager(iVMMgr),
00102 m_contextMenuHandler(0),
00103 m_navigator(navigator),
00104 m_dataAdder(0),
00105 m_ediFrame(0),
00106 m_modelPopup(0),
00107 m_viewPopup(0),
00108 m_commonPopup(0),
00109 m_invMassDialog(0),
00110 m_helpPopup(0),
00111 m_shortcutPopup(0),
00112 m_helpGLPopup(0),
00113 m_tasks(new CmsShowTaskExecutor),
00114 m_WMOffsetX(0), m_WMOffsetY(0), m_WMDecorH(0)
00115 {
00116 m_guiManager = this;
00117
00118 measureWMOffsets();
00119
00120 FWEventItemsManager* im = (FWEventItemsManager*) m_context->eventItemsManager();
00121 im->newItem_.connect(boost::bind(&FWGUIManager::newItem, this, _1) );
00122
00123 m_context->colorManager()->colorsHaveChangedFinished_.connect(boost::bind(&FWGUIManager::finishUpColorChange,this));
00124
00125
00126 TEveCompositeFrame::IconBarCreator_foo foo = &FWGUIManager::makeGUIsubview;
00127 TEveCompositeFrame::SetupFrameMarkup(foo, 20, 4, false);
00128
00129 {
00130
00131
00132 UInt_t width = gClient->GetDisplayWidth();
00133 UInt_t height = static_cast<UInt_t>(gClient->GetDisplayHeight()*.8);
00134
00135
00136
00137 while(width > 2000) {
00138 width /= 2;
00139 }
00140 width = static_cast<UInt_t>(width*.8);
00141 m_cmsShowMainFrame = new CmsShowMainFrame(gClient->GetRoot(),
00142 width,
00143 height,
00144 this);
00145 m_cmsShowMainFrame->SetCleanup(kDeepCleanup);
00146
00147
00148
00149
00150
00151
00152
00153 for (int i = 0 ; i < FWViewType::kTypeSize; ++i)
00154 {
00155 bool separator = (i == FWViewType::kGlimpse || i == FWViewType::kTableHLT || i == FWViewType::kLegoPFECAL);
00156 CSGAction* action = m_cmsShowMainFrame->createNewViewerAction(FWViewType::idToName(i), separator);
00157 action->activated.connect(boost::bind(&FWGUIManager::newViewSlot, this, FWViewType::idToName(i)));
00158 }
00159
00160 m_detailViewManager = new FWDetailViewManager(m_context->colorManager());
00161 m_contextMenuHandler = new FWModelContextMenuHandler(m_context->selectionManager(), m_detailViewManager, m_context->colorManager(), this);
00162
00163
00164 getAction(cmsshow::sExportImage)->activated.connect(sigc::mem_fun(*this, &FWGUIManager::exportImageOfMainView));
00165 getAction(cmsshow::sExportAllImages)->activated.connect(sigc::mem_fun(*this, &FWGUIManager::exportImagesOfAllViews));
00166 getAction(cmsshow::sLoadConfig)->activated.connect(sigc::mem_fun(*this, &FWGUIManager::promptForLoadConfigurationFile));
00167 getAction(cmsshow::sSaveConfig)->activated.connect(writeToPresentConfigurationFile_);
00168 getAction(cmsshow::sSaveConfigAs)->activated.connect(sigc::mem_fun(*this,&FWGUIManager::promptForSaveConfigurationFile));
00169 getAction(cmsshow::sShowEventDisplayInsp)->activated.connect(boost::bind( &FWGUIManager::showEDIFrame,this,-1));
00170 getAction(cmsshow::sShowMainViewCtl)->activated.connect(sigc::mem_fun(*m_guiManager, &FWGUIManager::showViewPopup));
00171 getAction(cmsshow::sShowObjInsp)->activated.connect(sigc::mem_fun(*m_guiManager, &FWGUIManager::showModelPopup));
00172
00173 getAction(cmsshow::sBackgroundColor)->activated.connect(sigc::mem_fun(m_context->colorManager(), &FWColorManager::switchBackground));
00174 getAction(cmsshow::sShowCommonInsp)->activated.connect(sigc::mem_fun(*m_guiManager, &FWGUIManager::showCommonPopup));
00175
00176 getAction(cmsshow::sShowInvMassDialog)->activated.connect(sigc::mem_fun(*m_guiManager, &FWGUIManager::showInvMassDialog));
00177
00178 getAction(cmsshow::sShowAddCollection)->activated.connect(sigc::mem_fun(*m_guiManager, &FWGUIManager::addData));
00179 assert(getAction(cmsshow::sHelp) != 0);
00180 getAction(cmsshow::sHelp)->activated.connect(sigc::mem_fun(*m_guiManager, &FWGUIManager::createHelpPopup));
00181 assert(getAction(cmsshow::sKeyboardShort) != 0);
00182 getAction(cmsshow::sKeyboardShort)->activated.connect(sigc::mem_fun(*m_guiManager, &FWGUIManager::createShortcutPopup));
00183 getAction(cmsshow::sHelpGL)->activated.connect(sigc::mem_fun(*m_guiManager, &FWGUIManager::createHelpGLPopup));
00184
00185
00186 m_cmsShowMainFrame->m_delaySliderListener->valueChanged_.connect(boost::bind(&FWGUIManager::delaySliderChanged,this,_1));
00187
00188 TQObject::Connect(m_cmsShowMainFrame->m_runEntry, "ReturnPressed()", "FWGUIManager", this, "runIdChanged()");
00189 TQObject::Connect(m_cmsShowMainFrame->m_lumiEntry, "ReturnPressed()", "FWGUIManager", this, "lumiIdChanged()");
00190 TQObject::Connect(m_cmsShowMainFrame->m_eventEntry, "ReturnPressed()", "FWGUIManager", this, "eventIdChanged()");
00191
00192 TQObject::Connect(m_cmsShowMainFrame->m_filterShowGUIBtn, "Clicked()", "FWGUIManager", this, "showEventFilterGUI()");
00193 TQObject::Connect(m_cmsShowMainFrame->m_filterEnableBtn, "Clicked()", "FWGUIManager", this, "filterButtonClicked()");
00194
00195 TQObject::Connect(gEve->GetWindowManager(), "WindowSelected(TEveWindow*)", "FWGUIManager", this, "checkSubviewAreaIconState(TEveWindow*)");
00196 TQObject::Connect(gEve->GetWindowManager(), "WindowDocked(TEveWindow*)" , "FWGUIManager", this, "checkSubviewAreaIconState(TEveWindow*)");
00197 TQObject::Connect(gEve->GetWindowManager(), "WindowUndocked(TEveWindow*)", "FWGUIManager", this, "checkSubviewAreaIconState(TEveWindow*)");
00198 }
00199 }
00200
00201 void FWGUIManager::connectSubviewAreaSignals(FWGUISubviewArea* a)
00202 {
00203 a->goingToBeDestroyed_.connect(boost::bind(&FWGUIManager::subviewIsBeingDestroyed, this, _1));
00204 a->selected_.connect(boost::bind(&FWGUIManager::subviewInfoSelected, this, _1));
00205 a->unselected_.connect(boost::bind(&FWGUIManager::subviewInfoUnselected, this, _1));
00206 a->swap_.connect(boost::bind(&FWGUIManager::subviewSwapped, this, _1));
00207 }
00208
00209
00210
00211
00212 FWGUIManager::~FWGUIManager()
00213 {
00214 delete m_invMassDialog;
00215 delete m_summaryManager;
00216 delete m_detailViewManager;
00217 delete m_cmsShowMainFrame;
00218 delete m_viewPopup;
00219 delete m_ediFrame;
00220 delete m_contextMenuHandler;
00221
00222 }
00223
00224 void
00225 FWGUIManager::evePreTerminate()
00226 {
00227 gEve->GetWindowManager()->Disconnect("WindowSelected(TEveWindow*)", this, "checkSubviewAreaIconState(TEveWindow*)");
00228 gEve->GetWindowManager()->Disconnect("WindowDocked(TEveWindow*)", this, "checkSubviewAreaIconState(TEveWindow*)");
00229 gEve->GetWindowManager()->Disconnect("WindowUndocked(TEveWindow*)", this, "checkSubviewAreaIconState(TEveWindow*)");
00230
00231
00232 gEve->GetSelection()->Disconnect();
00233 gEve->GetHighlight()->Disconnect();
00234 gEve->GetSelection()->RemoveElements();
00235 gEve->GetHighlight()->RemoveElements();
00236
00237 m_cmsShowMainFrame->UnmapWindow();
00238 for(ViewMap_i wIt = m_viewMap.begin(); wIt != m_viewMap.end(); ++wIt)
00239 {
00240 TEveCompositeFrameInMainFrame* mainFrame = dynamic_cast<TEveCompositeFrameInMainFrame*>((*wIt).first->GetEveFrame());
00241
00242 if (mainFrame) mainFrame->UnmapWindow();
00243
00244 (*wIt).second->destroy();
00245 }
00246 }
00247
00248
00249
00250
00251
00252 TGFrame*
00253 FWGUIManager::makeGUIsubview(TEveCompositeFrame* cp, TGCompositeFrame* parent, Int_t height)
00254 {
00255 TGFrame* frame = new FWGUISubviewArea(cp, parent, height);
00256 return frame;
00257 }
00258
00259 void
00260 FWGUIManager::registerViewBuilder(const std::string& iName,
00261 ViewBuildFunctor& iBuilder)
00262 {
00263 m_nameToViewBuilder[iName]=iBuilder;
00264 }
00265
00266
00267 void
00268 FWGUIManager::newViewSlot(const std::string& iName)
00269 {
00270
00271 createView(iName);
00272 }
00273
00274 FWGUIManager::ViewMap_i
00275 FWGUIManager::createView(const std::string& iName, TEveWindowSlot* slot)
00276 {
00277 NameToViewBuilder::iterator itFind = m_nameToViewBuilder.find(iName);
00278 assert (itFind != m_nameToViewBuilder.end());
00279 if(itFind == m_nameToViewBuilder.end()) {
00280 throw std::runtime_error(std::string("Unable to create view named ")+iName+" because it is unknown");
00281 }
00282
00283 if (!slot)
00284 {
00285 if (m_viewSecPack)
00286 {
00287 slot = m_viewSecPack->NewSlot();
00288 }
00289 else
00290 {
00291 slot = m_viewPrimPack->NewSlot();
00292 m_viewSecPack = m_viewPrimPack->NewSlot()->MakePack();
00293 m_viewSecPack->SetShowTitleBar(kFALSE);
00294 }
00295 }
00296 TEveCompositeFrame *ef = slot->GetEveFrame();
00297 FWViewBase* viewBase = itFind->second(slot, iName);
00298
00299 FWViewContextMenuHandlerBase* base= viewBase->contextMenuHandler();
00300 viewBase->openSelectedModelContextMenu_.connect(boost::bind(&FWGUIManager::showSelectedModelContextMenu ,m_guiManager,_1,_2,base));
00301
00302 TEveWindow *eveWindow = ef->GetEveWindow();
00303 eveWindow->SetElementName(iName.c_str());
00304
00305 std::pair<ViewMap_i,bool> insertPair = m_viewMap.insert(std::make_pair(eveWindow, viewBase));
00306 return insertPair.first;
00307 }
00308
00309
00310
00311
00312
00313
00314 void
00315 FWGUIManager::enableActions(bool enable)
00316 {
00317 m_cmsShowMainFrame->enableActions(enable);
00318 }
00319
00320 void
00321 FWGUIManager::titleChanged(const char *subtitle)
00322 {
00323 char title[128];
00324 snprintf(title,127,"cmsShow: %s", subtitle);
00325 m_cmsShowMainFrame->SetWindowName(title);
00326 }
00327
00328 void
00329 FWGUIManager::eventChangedCallback() {
00330
00331
00332 TEveViewerList* viewers = gEve->GetViewers();
00333 for (TEveElement::List_i i=viewers->BeginChildren(); i!= viewers->EndChildren(); ++i)
00334 {
00335 TEveViewer* ev = dynamic_cast<TEveViewer*>(*i);
00336 if (ev)
00337 ev->GetGLViewer()->DeleteOverlayAnnotations();
00338 }
00339
00340 m_cmsShowMainFrame->loadEvent(*getCurrentEvent());
00341 m_detailViewManager->newEventCallback();
00342 }
00343
00344 CSGAction*
00345 FWGUIManager::getAction(const std::string name)
00346 {
00347 return m_cmsShowMainFrame->getAction(name);
00348 }
00349
00350 CSGContinuousAction*
00351 FWGUIManager::playEventsAction()
00352 {
00353 return m_cmsShowMainFrame->playEventsAction();
00354 }
00355
00356 CSGContinuousAction*
00357 FWGUIManager::playEventsBackwardsAction()
00358 {
00359 return m_cmsShowMainFrame->playEventsBackwardsAction();
00360 }
00361
00362 CSGContinuousAction*
00363 FWGUIManager::loopAction()
00364 {
00365 return m_cmsShowMainFrame->loopAction();
00366 }
00367
00368 void
00369 FWGUIManager::disablePrevious()
00370 {
00371 m_cmsShowMainFrame->enablePrevious(false);
00372 }
00373
00374 void
00375 FWGUIManager::disableNext()
00376 {
00377 m_cmsShowMainFrame->enableNext(false);
00378 }
00379
00380 void
00381 FWGUIManager::setPlayMode(bool play)
00382 {
00383 m_cmsShowMainFrame->m_runEntry->SetEnabled(!play);
00384 m_cmsShowMainFrame->m_eventEntry->SetEnabled(!play);
00385 }
00386
00387 void
00388 FWGUIManager::updateStatus(const char* status) {
00389 m_cmsShowMainFrame->updateStatusBar(status);
00390 }
00391
00392 void
00393 FWGUIManager::clearStatus()
00394 {
00395 m_cmsShowMainFrame->clearStatusBar();
00396 }
00397
00398 void
00399 FWGUIManager::newItem(const FWEventItem* iItem)
00400 {
00401 #if defined(THIS_WILL_NEVER_BE_DEFINED)
00402 m_selectionItemsComboBox->AddEntry(iItem->name().c_str(),iItem->id());
00403 if(iItem->id()==0) {
00404 m_selectionItemsComboBox->Select(0);
00405 }
00406 #endif
00407 }
00408
00409 void
00410 FWGUIManager::addData()
00411 {
00412 if (0==m_dataAdder) {
00413 m_dataAdder = new FWGUIEventDataAdder(100,100,
00414 (FWEventItemsManager*) m_context->eventItemsManager(),
00415 m_cmsShowMainFrame,
00416 m_context->metadataManager());
00417 }
00418 m_dataAdder->show();
00419 }
00420
00421
00422
00423
00424
00425 TEveWindow*
00426 FWGUIManager::getSwapCandidate()
00427 {
00428 TEveWindow* swapCandidate =0;
00429
00430 if ( gEve->GetWindowManager()->GetCurrentWindow())
00431 {
00432 swapCandidate = gEve->GetWindowManager()->GetCurrentWindow();
00433 }
00434 else
00435 {
00436
00437 TEveCompositeFrame* pef;
00438 TGFrameElementPack *pel;
00439
00440
00441 TGPack* pp = m_viewPrimPack->GetPack();
00442 if ( pp->GetList()->GetSize() > 2)
00443 {
00444 pel = (TGFrameElementPack*) pp->GetList()->At(1);
00445 if (pel->fState)
00446 {
00447 pef = dynamic_cast<TEveCompositeFrame*>(pel->fFrame);
00448 if ( pef && pef->GetEveWindow())
00449 swapCandidate = pef->GetEveWindow();
00450 }
00451 }
00452 if (swapCandidate == 0)
00453 {
00454
00455 TGPack* sp = m_viewSecPack->GetPack();
00456 TIter frame_iterator(sp->GetList());
00457 while ((pel = (TGFrameElementPack*)frame_iterator()))
00458 {
00459 pef = dynamic_cast<TEveCompositeFrame*>(pel->fFrame);
00460 if ( pef && pef->GetEveWindow() && pel->fState)
00461 {
00462 swapCandidate = pef->GetEveWindow() ;
00463 break;
00464 }
00465 }
00466 }
00467 }
00468 return swapCandidate;
00469 }
00470
00471 void
00472 FWGUIManager::checkSubviewAreaIconState(TEveWindow* )
00473 {
00474
00475
00476
00477
00478 TEveWindow* current = getSwapCandidate();
00479 bool checkInfoBtn = m_viewPopup ? m_viewPopup->mapped() : 0;
00480 TEveWindow* selected = m_viewPopup ? m_viewPopup->getEveWindow() : 0;
00481
00482 for (ViewMap_i it = m_viewMap.begin(); it != m_viewMap.end(); it++)
00483 {
00484 FWGUISubviewArea* ar = FWGUISubviewArea::getToolBarFromWindow(it->first);
00485 ar->setSwapIcon(current != it->first);
00486 if (checkInfoBtn && selected)
00487 ar->setInfoButton(selected == it->first);
00488 }
00489 }
00490
00491 void
00492 FWGUIManager::subviewIsBeingDestroyed(FWGUISubviewArea* sva)
00493 {
00494 if (sva->isSelected())
00495 setViewPopup(0);
00496
00497 CmsShowTaskExecutor::TaskFunctor f;
00498 f = boost::bind(&FWGUIManager::subviewDestroy, this, sva);
00499 m_tasks->addTask(f);
00500 m_tasks->startDoingTasks();
00501 }
00502
00503 void
00504 FWGUIManager::subviewDestroy(FWGUISubviewArea* sva)
00505 {
00506 TEveWindow* ew = sva->getEveWindow();
00507 FWViewBase* viewBase = m_viewMap[ew];
00508 m_viewMap.erase(ew);
00509 viewBase->destroy();
00510 }
00511
00512 void
00513 FWGUIManager::subviewDestroyAll()
00514 {
00515 std::vector<FWGUISubviewArea*> sd;
00516 for(ViewMap_i wIt = m_viewMap.begin(); wIt != m_viewMap.end(); ++wIt)
00517 {
00518 FWGUISubviewArea* ar = FWGUISubviewArea::getToolBarFromWindow(wIt->first);
00519 sd.push_back(ar);
00520 }
00521
00522 for (std::vector<FWGUISubviewArea*>::iterator i= sd.begin(); i !=sd.end(); ++i)
00523 {
00524 if ((*i)->isSelected())
00525 setViewPopup(0);
00526 subviewDestroy(*i);
00527 }
00528
00529 gSystem->ProcessEvents();
00530 gSystem->Sleep(200);
00531
00532
00533
00534 while (m_viewPrimPack->HasChildren())
00535 {
00536 TEveWindow* w = dynamic_cast<TEveWindow*>(m_viewPrimPack->FirstChild());
00537 if (w) w->DestroyWindowAndSlot();
00538 }
00539
00540 gSystem->Sleep(200);
00541 m_viewSecPack = 0;
00542 gSystem->ProcessEvents();
00543
00544 }
00545
00546 void
00547 FWGUIManager::subviewInfoSelected(FWGUISubviewArea* sva)
00548 {
00549
00550 TEveWindow* ew = sva->getEveWindow();
00551 for(ViewMap_i wIt = m_viewMap.begin(); wIt != m_viewMap.end(); ++wIt)
00552 {
00553 if (wIt->first != ew)
00554 FWGUISubviewArea::getToolBarFromWindow(wIt->first)->setInfoButton(kFALSE);
00555 }
00556 setViewPopup(sva->getEveWindow());
00557 }
00558
00559 void
00560 FWGUIManager::subviewInfoUnselected(FWGUISubviewArea* sva)
00561 {
00562 m_viewPopup->UnmapWindow();
00563 }
00564
00565 void
00566 FWGUIManager::subviewSwapped(FWGUISubviewArea* sva)
00567 {
00568 TEveWindow* curr = getSwapCandidate();
00569 TEveWindow* swap = sva->getEveWindow();
00570 if (curr) swap->SwapWindow(curr);
00571
00572 checkSubviewAreaIconState(0);
00573 }
00574
00575 TGVerticalFrame*
00576 FWGUIManager::createList(TGCompositeFrame *p)
00577 {
00578 TGVerticalFrame *listFrame = new TGVerticalFrame(p, p->GetWidth(), p->GetHeight());
00579
00580 TGHorizontalFrame* addFrame = new TGHorizontalFrame(listFrame, p->GetWidth(), 10, kRaisedFrame);
00581 TGLabel* addLabel = new TGLabel(addFrame,"Summary View");
00582 addFrame->AddFrame(addLabel, new TGLayoutHints(kLHintsCenterX, 0,0,2,2));
00583 listFrame->AddFrame(addFrame, new TGLayoutHints(kLHintsExpandX | kLHintsTop));
00584
00585 m_summaryManager = new FWSummaryManager(listFrame,
00586 m_context->selectionManager(),
00587 (FWEventItemsManager*) m_context->eventItemsManager(),
00588 this,
00589 m_context->modelChangeManager(),
00590 m_context->colorManager());
00591
00592 const unsigned int backgroundColor=0x2f2f2f;
00593 TGTextButton* addDataButton = new TGTextButton(m_summaryManager->widget(), "Add Collection");
00594 addDataButton->ChangeOptions(kRaisedFrame);
00595 addDataButton->SetBackgroundColor(backgroundColor);
00596 addDataButton->SetTextColor(0xFFFFFF);
00597 addDataButton->SetToolTipText("Show additional collections");
00598 addDataButton->Connect("Clicked()", "FWGUIManager", this, "addData()");
00599 m_summaryManager->widget()->AddFrame(addDataButton, new TGLayoutHints(kLHintsExpandX|kLHintsLeft|kLHintsTop));
00600 listFrame->AddFrame(m_summaryManager->widget(), new TGLayoutHints(kLHintsExpandX|kLHintsExpandY));
00601
00602 return listFrame;
00603 }
00604
00605 void
00606 FWGUIManager::createViews(TEveWindowSlot *slot)
00607 {
00608 m_viewPrimPack = slot->MakePack();
00609 m_viewPrimPack->SetHorizontal();
00610 m_viewPrimPack->SetElementName("Views");
00611 m_viewPrimPack->SetShowTitleBar(kFALSE);
00612 m_viewSecPack = 0;
00613 }
00614
00615 void
00616 FWGUIManager::createEDIFrame()
00617 {
00618 if (m_ediFrame == 0)
00619 {
00620 m_ediFrame = new CmsShowEDI(m_cmsShowMainFrame, 200, 200, m_context->selectionManager(),m_context->colorManager());
00621 m_ediFrame->CenterOnParent(kTRUE,TGTransientFrame::kTopRight);
00622 m_cmsShowMainFrame->bindCSGActionKeys(m_ediFrame);
00623 }
00624 }
00625
00626 void
00627 FWGUIManager::showEDIFrame(int iToShow)
00628 {
00629 createEDIFrame();
00630 if (-1 != iToShow)
00631 {
00632 m_ediFrame->show(static_cast<FWDataCategories>(iToShow));
00633 }
00634 m_ediFrame->MapRaised();
00635 }
00636
00637 void
00638 FWGUIManager::showCommonPopup()
00639 {
00640 if (! m_commonPopup)
00641 {
00642 m_commonPopup = new CmsShowCommonPopup(m_context->commonPrefs(), m_cmsShowMainFrame, 200, 200);
00643 m_cmsShowMainFrame->bindCSGActionKeys(m_commonPopup);
00644 }
00645 m_commonPopup->MapRaised();
00646 }
00647
00648 void
00649 FWGUIManager::createModelPopup()
00650 {
00651 m_modelPopup = new CmsShowModelPopup(m_detailViewManager,m_context->selectionManager(), m_context->colorManager(), m_cmsShowMainFrame, 200, 200);
00652 m_modelPopup->CenterOnParent(kTRUE,TGTransientFrame::kRight);
00653 m_cmsShowMainFrame->bindCSGActionKeys(m_modelPopup);
00654 }
00655
00656 void
00657 FWGUIManager::showModelPopup()
00658 {
00659 if (! m_modelPopup) createModelPopup();
00660 m_modelPopup->MapRaised();
00661 }
00662
00663 void
00664 FWGUIManager::popupViewClosed()
00665 {
00666 if (m_viewPopup->getEveWindow())
00667 {
00668 FWGUISubviewArea* sa = FWGUISubviewArea::getToolBarFromWindow(m_viewPopup->getEveWindow());
00669 sa->setInfoButton(kFALSE);
00670 }
00671 }
00672
00673 void
00674 FWGUIManager::showViewPopup()
00675 {
00676
00677 setViewPopup(0);
00678 }
00679
00680 void
00681 FWGUIManager::setViewPopup(TEveWindow* ew)
00682 {
00683 FWViewBase* vb = ew ? m_viewMap[ew] : 0;
00684 if (m_viewPopup == 0)
00685 {
00686 m_viewPopup = new CmsShowViewPopup(0, 200, 200, m_context->colorManager(), vb, ew);
00687 m_viewPopup->closed_.connect(sigc::mem_fun(*m_guiManager, &FWGUIManager::popupViewClosed));
00688 }
00689 else
00690 {
00691 m_viewPopup->UnmapWindow();
00692 }
00693 m_viewPopup->reset(vb, ew);
00694 m_viewPopup->MapRaised();
00695 }
00696
00697 void
00698 FWGUIManager::showInvMassDialog()
00699 {
00700 if (! m_invMassDialog)
00701 {
00702 m_invMassDialog = new FWInvMassDialog(m_context->selectionManager());
00703 m_cmsShowMainFrame->bindCSGActionKeys(m_invMassDialog);
00704 }
00705 m_invMassDialog->MapRaised();
00706 }
00707
00708 void
00709 FWGUIManager::createHelpPopup ()
00710 {
00711 if (m_helpPopup == 0)
00712 {
00713 m_helpPopup = new CmsShowHelpPopup("help.html", "CmsShow Help",
00714 m_cmsShowMainFrame,
00715 800, 600);
00716 m_helpPopup->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
00717 }
00718 m_helpPopup->MapWindow();
00719 }
00720
00721
00722 void
00723 FWGUIManager::createShortcutPopup ()
00724 {
00725 if (m_shortcutPopup == 0)
00726 {
00727 m_shortcutPopup = new CmsShowHelpPopup("shortcuts.html",
00728 getAction(cmsshow::sKeyboardShort)->getName().c_str(),
00729 m_cmsShowMainFrame, 800, 600);
00730
00731 m_shortcutPopup->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
00732 }
00733 m_shortcutPopup->MapWindow();
00734 }
00735
00736 void FWGUIManager::createHelpGLPopup ()
00737 {
00738 if (m_helpGLPopup == 0)
00739 {
00740 m_helpGLPopup = new CmsShowHelpPopup("helpGL.html",
00741 getAction(cmsshow::sHelpGL)->getName().c_str(),
00742 m_cmsShowMainFrame, 800, 600);
00743
00744 m_helpGLPopup->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
00745 }
00746 m_helpGLPopup->MapWindow();
00747 }
00748
00749 void
00750 FWGUIManager::showSelectedModelContextMenu(Int_t iGlobalX, Int_t iGlobalY, FWViewContextMenuHandlerBase* iHandler)
00751 {
00752 if (! m_context->selectionManager()->selected().empty())
00753 {
00754 m_contextMenuHandler->showSelectedModelContext(iGlobalX,iGlobalY, iHandler);
00755 }
00756 }
00757
00758
00759
00760
00761
00762 FWGUIManager*
00763 FWGUIManager::getGUIManager()
00764 {
00765 return m_guiManager;
00766 }
00767
00768 const edm::EventBase*
00769 FWGUIManager::getCurrentEvent() const
00770 {
00771 return m_navigator->getCurrentEvent();
00772 }
00773
00782 bool
00783 FWGUIManager::promptForConfigurationFile(std::string &result, enum EFileDialogMode mode)
00784 {
00785
00786 const static char* kFileTypes[] = {"Fireworks Configuration files","*.fwc",
00787 "All Files","*",
00788 0,0};
00789
00790 static TString dir(".");
00791
00792 TGFileInfo fi;
00793 fi.fFileTypes = kFileTypes;
00794 fi.fIniDir = StrDup(dir);
00795 new TGFileDialog(gClient->GetDefaultRoot(), m_cmsShowMainFrame, mode, &fi);
00796 dir = fi.fIniDir;
00797 if (fi.fFilename == 0)
00798 return false;
00799 std::string name = fi.fFilename;
00800
00801 std::string ext = kFileTypes[fi.fFileTypeIdx + 1] + 1;
00802 if (ext.size() != 0 && name.find(ext) == name.npos)
00803 name += ext;
00804 result = name;
00805 return true;
00806 }
00807
00808
00812 void
00813 FWGUIManager::promptForLoadConfigurationFile()
00814 {
00815 std::string name;
00816 if (!promptForConfigurationFile(name, kFDOpen))
00817 return;
00818
00819
00820 loadFromConfigurationFile_(name);
00821 }
00822
00826 void
00827 FWGUIManager::promptForSaveConfigurationFile()
00828 {
00829 std::string name;
00830 if (!promptForConfigurationFile(name, kFDSave))
00831 return;
00832 writeToConfigurationFile_(name);
00833 }
00834
00835 void
00836 FWGUIManager::exportImageOfMainView()
00837 {
00838 if (m_viewPrimPack->GetPack()->GetList()->GetSize() > 2)
00839 {
00840 TGFrameElementPack* frameEL = (TGFrameElementPack*) m_viewPrimPack->GetPack()->GetList()->At(1);
00841 TEveCompositeFrame* ef = dynamic_cast<TEveCompositeFrame*>(frameEL->fFrame);
00842 m_viewMap[ef->GetEveWindow()]->promptForSaveImageTo(m_cmsShowMainFrame);
00843 }
00844 else
00845 {
00846 fwLog(fwlog::kError) << "Main view has been destroyed." << std::endl;
00847 }
00848 }
00849
00850 void
00851 FWGUIManager::exportImagesOfAllViews()
00852 {
00853 try {
00854 static TString dir(".");
00855 const char * kImageExportTypes[] = {"PNG", "*.png",
00856 "GIF", "*.gif",
00857 "JPEG", "*.jpg",
00858 "PDF", "*.pdf",
00859 "Encapsulated PostScript", "*.eps",
00860 0, 0};
00861
00862 TGFileInfo fi;
00863 fi.fFileTypes = kImageExportTypes;
00864 fi.fIniDir = StrDup(dir);
00865 new TGFileDialog(gClient->GetDefaultRoot(), m_cmsShowMainFrame,
00866 kFDSave,&fi);
00867 dir = fi.fIniDir;
00868 if (fi.fFilename != 0) {
00869 std::string name = fi.fFilename;
00870
00871
00872
00873 std::string ext = kImageExportTypes[fi.fFileTypeIdx + 1] + 1;
00874 if (name.find(ext) == name.npos)
00875 name += ext;
00876
00877 name.insert(name.rfind('.'), "-%u_%u_%u_%s");
00878 exportAllViews(name);
00879 }
00880 }
00881 catch (std::runtime_error &e) { std::cout << e.what() << std::endl; }
00882 }
00883
00884 void
00885 FWGUIManager::exportAllViews(const std::string& format)
00886 {
00887
00888
00889
00890
00891
00892
00893
00894 typedef std::list<TEveViewer*> viewer_list_t;
00895 typedef viewer_list_t::iterator viewer_list_i;
00896
00897 typedef std::map<TString, viewer_list_t> name_map_t;
00898 typedef name_map_t::iterator name_map_i;
00899
00900 name_map_t vls;
00901
00902 for (ViewMap_i i = m_viewMap.begin(); i != m_viewMap.end(); ++i)
00903 {
00904 TEveViewer *ev = dynamic_cast<TEveViewer*>(i->first);
00905 if (ev)
00906 {
00907 TString name(ev->GetElementName());
00908 name.ReplaceAll(" ", "");
00909 viewer_list_t &l = vls[name];
00910 viewer_list_i li = l.begin();
00911 while (li != l.end() && (*li)->GetGLViewer()->ViewportDiagonal() < ev->GetGLViewer()->ViewportDiagonal())
00912 ++li;
00913 l.insert(li, ev);
00914 }
00915 }
00916
00917 const edm::EventBase *event = getCurrentEvent();
00918 for (name_map_i i = vls.begin(); i != vls.end(); ++i)
00919 {
00920 bool multi_p = (i->second.size() > 1);
00921 int view_count = 1;
00922 for (viewer_list_i j = i->second.begin(); j != i->second.end(); ++j, ++view_count)
00923 {
00924 TString view_name(i->first);
00925 if (multi_p)
00926 {
00927 view_name += "_";
00928 view_name += view_count;
00929 }
00930 TString file;
00931 file.Form(format.c_str(), event->id().run(), event->id().event(),
00932 event->luminosityBlock(), view_name.Data());
00933 (*j)->GetGLViewer()->SavePicture(file);
00934 }
00935 }
00936 }
00937
00938 static const std::string kMainWindow("main window");
00939 static const std::string kViews("views");
00940 static const std::string kViewArea("view area");
00941 static const std::string kUndocked("undocked views");
00942 static const std::string kControllers("controllers");
00943 static const std::string kCollectionController("collection");
00944 static const std::string kViewController("view");
00945 static const std::string kObjectController("object");
00946 static const std::string kCommonController("common");
00947
00948 static
00949 void
00950 addWindowInfoTo(const TGFrame* iMain,
00951 FWConfiguration& oTo)
00952 {
00953 Window_t wdummy;
00954 Int_t ax,ay;
00955 gVirtualX->TranslateCoordinates(iMain->GetId(),
00956 gClient->GetDefaultRoot()->GetId(),
00957 0,0,
00958 ax,ay,
00959 wdummy);
00960 {
00961 std::stringstream s;
00962 s<<ax;
00963 oTo.addKeyValue("x",FWConfiguration(s.str()));
00964 }
00965 {
00966 std::stringstream s;
00967 s<<ay;
00968 oTo.addKeyValue("y",FWConfiguration(s.str()));
00969 }
00970 {
00971 std::stringstream s;
00972 s<<iMain->GetWidth();
00973 oTo.addKeyValue("width",FWConfiguration(s.str()));
00974 }
00975 {
00976 std::stringstream s;
00977 s<<iMain->GetHeight();
00978 oTo.addKeyValue("height",FWConfiguration(s.str()));
00979 }
00980 }
00981
00982 class areaInfo
00983 {
00984
00985 public:
00986 areaInfo (TGFrameElementPack* frameElement)
00987 {
00988 eveWindow = 0;
00989 originalSlot = 0;
00990 undockedMainFrame = 0;
00991 weight = frameElement->fWeight;
00992 undocked = !frameElement->fState;
00993
00994 TEveCompositeFrame *eveFrame = dynamic_cast<TEveCompositeFrame*>(frameElement->fFrame);
00995 assert(eveFrame);
00996
00997 if (frameElement->fState)
00998 eveWindow = eveFrame->GetEveWindow();
00999 else
01000 originalSlot = eveFrame->GetEveWindow();
01001 }
01002
01003 areaInfo () : weight(0), undocked(false) {}
01004
01005 Float_t weight;
01006 Bool_t undocked;
01007 TEveWindow *eveWindow;
01008 TGMainFrame *undockedMainFrame;
01009 TEveWindow *originalSlot;
01010 };
01011
01012 static
01013 void
01014 addAreaInfoTo(areaInfo& pInfo,
01015 FWConfiguration& oTo)
01016 {
01017 {
01018 std::stringstream s;
01019 s << pInfo.weight;
01020 oTo.addKeyValue("weight", FWConfiguration(s.str()));
01021 }
01022 {
01023 std::stringstream s;
01024 s<< pInfo.undocked;
01025 oTo.addKeyValue("undocked", FWConfiguration(s.str()));
01026 }
01027
01028 if (pInfo.undockedMainFrame)
01029 {
01030 FWConfiguration temp(oTo);
01031 addWindowInfoTo(pInfo.undockedMainFrame, temp);
01032 oTo.addKeyValue("UndockedWindowPos", temp);
01033 }
01034 }
01035
01036
01037 void
01038 FWGUIManager::addTo(FWConfiguration& oTo) const
01039 {
01040 Int_t cfgVersion=3;
01041
01042 FWConfiguration mainWindow(cfgVersion);
01043 float leftWeight, rightWeight;
01044 addWindowInfoTo(m_cmsShowMainFrame, mainWindow);
01045 {
01046
01047 {
01048 std::stringstream ss;
01049 ss << m_cmsShowMainFrame->getSummaryViewWeight();
01050 mainWindow.addKeyValue("summaryWeight",FWConfiguration(ss.str()));
01051 }
01052
01053
01054 if ( m_viewPrimPack->GetPack()->GetList()->GetSize() > 2)
01055 {
01056 TGFrameElementPack *frameEL;
01057 frameEL = (TGFrameElementPack*) m_viewPrimPack->GetPack()->GetList()->At(1);
01058 leftWeight = frameEL->fWeight;
01059 frameEL = (TGFrameElementPack*) m_viewPrimPack->GetPack()->GetList()->At(3);
01060 rightWeight = frameEL->fWeight;
01061 }
01062 else
01063 {
01064 leftWeight = 0;
01065 rightWeight = 1;
01066 }
01067 std::stringstream sL;
01068 sL<<leftWeight;
01069 mainWindow.addKeyValue("leftWeight",FWConfiguration(sL.str()));
01070 std::stringstream sR;
01071 sR<<rightWeight;
01072 mainWindow.addKeyValue("rightWeight",FWConfiguration(sR.str()));
01073 }
01074 oTo.addKeyValue(kMainWindow, mainWindow, true);
01075
01076
01077
01078 std::vector<areaInfo> wpacked;
01079 if (leftWeight > 0)
01080 {
01081 TGPack* pp = m_viewPrimPack->GetPack();
01082 TGFrameElementPack *frameEL = (TGFrameElementPack*) pp->GetList()->At(1);
01083 if (frameEL->fWeight > 0)
01084 wpacked.push_back(areaInfo(frameEL));
01085 }
01086 TGPack* sp = m_viewSecPack->GetPack();
01087 TGFrameElementPack *seFE;
01088 TIter frame_iterator(sp->GetList());
01089 while ((seFE = (TGFrameElementPack*)frame_iterator() ))
01090 {
01091 if (seFE->fWeight)
01092 wpacked.push_back(areaInfo(seFE));
01093 }
01094
01095
01096
01097 for(ViewMap_i wIt = m_viewMap.begin(); wIt != m_viewMap.end(); ++wIt)
01098 {
01099 TEveWindow* ew = wIt->first;
01100 TEveCompositeFrameInMainFrame* mainFrame = dynamic_cast<TEveCompositeFrameInMainFrame*>(ew->GetEveFrame());
01101 if (mainFrame)
01102 {
01103 for(std::vector<areaInfo>::iterator pIt = wpacked.begin(); pIt != wpacked.end(); ++pIt)
01104 {
01105 if ((*pIt).originalSlot && mainFrame->GetOriginalSlot() == (*pIt).originalSlot)
01106 {
01107 (*pIt).eveWindow = wIt->first;
01108 (*pIt).undockedMainFrame = (TGMainFrame*)mainFrame;
01109
01110 break;
01111 }
01112 }
01113 }
01114 }
01115
01116
01117
01118 FWConfiguration views(1);
01119 FWConfiguration viewArea(cfgVersion);
01120 for(std::vector<areaInfo>::iterator it = wpacked.begin(); it != wpacked.end(); ++it)
01121 {
01122 TEveWindow* ew = (*it).eveWindow;
01123 if (ew) {
01124 FWViewBase* wb = m_viewMap[ew];
01125 FWConfiguration tempWiew(wb->version());
01126 wb->addTo(tempWiew);
01127 views.addKeyValue(wb->typeName(), tempWiew, true);
01128 FWConfiguration tempArea(cfgVersion);
01129 addAreaInfoTo((*it), tempArea);
01130 viewArea.addKeyValue(wb->typeName(), tempArea, true);
01131 }
01132 }
01133 oTo.addKeyValue(kViews, views, true);
01134 oTo.addKeyValue(kViewArea, viewArea, true);
01135
01136
01137
01138 FWConfiguration controllers(1);
01139 {
01140 if(0!=m_ediFrame && m_ediFrame->IsMapped()) {
01141 FWConfiguration temp(1);
01142 addWindowInfoTo(m_ediFrame, temp);
01143 controllers.addKeyValue(kCollectionController,temp,true);
01144 }
01145 if(0!=m_viewPopup && m_viewPopup->IsMapped()) {
01146 FWConfiguration temp(1);
01147 addWindowInfoTo(m_viewPopup, temp);
01148 controllers.addKeyValue(kViewController,temp,true);
01149 }
01150 if(0!=m_modelPopup && m_modelPopup->IsMapped()) {
01151 FWConfiguration temp(1);
01152 addWindowInfoTo(m_modelPopup, temp);
01153 controllers.addKeyValue(kObjectController,temp,true);
01154 }
01155 if(0!=m_commonPopup && m_commonPopup->IsMapped()) {
01156 FWConfiguration temp(1);
01157 addWindowInfoTo(m_commonPopup, temp);
01158 controllers.addKeyValue(kCommonController,temp,true);
01159 }
01160 }
01161 oTo.addKeyValue(kControllers,controllers,true);
01162 }
01163
01164
01165 void
01166 FWGUIManager::setWindowInfoFrom(const FWConfiguration& iFrom,
01167 TGMainFrame* iFrame)
01168 {
01169 int x = atoi(iFrom.valueForKey("x")->value().c_str()) + m_WMOffsetX;
01170 int y = atoi(iFrom.valueForKey("y")->value().c_str()) + m_WMOffsetY;
01171 if (y < m_WMDecorH) y = m_WMDecorH;
01172 int width = atoi(iFrom.valueForKey("width")->value().c_str());
01173 int height = atoi(iFrom.valueForKey("height")->value().c_str());
01174 iFrame->MoveResize(x,y,width,height);
01175 iFrame->SetWMPosition(x, y);
01176 }
01177
01178 void
01179 FWGUIManager::setFrom(const FWConfiguration& iFrom) {
01180
01181 if (m_viewSecPack) subviewDestroyAll();
01182
01183 const FWConfiguration* mw = iFrom.valueForKey(kMainWindow);
01184 assert(mw != 0);
01185
01186
01187 m_cmsShowMainFrame->MapWindow();
01188 setWindowInfoFrom(*mw, m_cmsShowMainFrame);
01189 m_cmsShowMainFrame->MapSubwindows();
01190 m_cmsShowMainFrame->Layout();
01191 m_cmsShowMainFrame->MapRaised();
01192
01193
01194 float_t leftWeight =1;
01195 float_t rightWeight=1;
01196 if ( mw->version() >= 2 ) {
01197 leftWeight = atof(mw->valueForKey("leftWeight")->value().c_str());
01198 rightWeight = atof(mw->valueForKey("rightWeight")->value().c_str());
01199 }
01200
01201 if ( mw->version() >= 3 ) {
01202 float summaryWeight = atof(mw->valueForKey("summaryWeight")->value().c_str());
01203 m_cmsShowMainFrame->setSummaryViewWeight(summaryWeight);
01204 }
01205
01206 TEveWindowSlot* primSlot = (leftWeight > 0) ? m_viewPrimPack->NewSlotWithWeight(leftWeight) : 0;
01207 m_viewSecPack = m_viewPrimPack->NewSlotWithWeight(rightWeight)->MakePack();
01208 m_viewSecPack->SetVertical();
01209 m_viewSecPack->SetShowTitleBar(kFALSE);
01210
01211
01212 const FWConfiguration* views = iFrom.valueForKey(kViews); assert(0!=views);
01213 const FWConfiguration::KeyValues* keyVals = views->keyValues();
01214 const FWConfiguration* viewArea = iFrom.valueForKey(kViewArea);
01215
01216
01217 if ( viewArea->version() > 1)
01218 {
01219 const FWConfiguration::KeyValues* akv = viewArea->keyValues();
01220 FWConfiguration::KeyValuesIt areaIt = akv->begin();
01221
01222 for(FWConfiguration::KeyValuesIt it = keyVals->begin(); it!= keyVals->end(); ++it)
01223 {
01224 float weight = atof((areaIt->second).valueForKey("weight")->value().c_str());
01225 TEveWindowSlot* slot = ( m_viewMap.size() || (primSlot == 0) ) ? m_viewSecPack->NewSlotWithWeight(weight) : primSlot;
01226 std::string name = FWViewType::checkNameWithViewVersion(it->first, it->second.version());
01227 ViewMap_i lastViewIt = createView(name, slot);
01228 lastViewIt->second->setFrom(it->second);
01229
01230 bool undocked = atof((areaIt->second).valueForKey("undocked")->value().c_str());
01231 if (undocked)
01232 {
01233 TEveWindow* lastWindow = lastViewIt->first;
01234 lastWindow->UndockWindow();
01235 TEveCompositeFrameInMainFrame* emf = dynamic_cast<TEveCompositeFrameInMainFrame*>(lastWindow->GetEveFrame());
01236 if (emf ) {
01237 const TGMainFrame* mf = dynamic_cast<const TGMainFrame*>(emf->GetParent());
01238 if (mf) {
01239 m_cmsShowMainFrame->bindCSGActionKeys(mf);
01240 TGMainFrame* mfp = (TGMainFrame*)mf;
01241 const FWConfiguration* mwc = (areaIt->second).valueForKey("UndockedWindowPos");
01242 setWindowInfoFrom(*mwc, mfp);
01243 }
01244 }
01245 }
01246 areaIt++;
01247 }
01248 }
01249 else
01250 {
01251 for(FWConfiguration::KeyValuesIt it = keyVals->begin(); it!= keyVals->end(); ++it) {
01252 std::string name = FWViewType::checkNameWithViewVersion(it->first, it->second.version());
01253 createView(name, m_viewMap.size() ? m_viewSecPack->NewSlot() : primSlot);
01254
01255 ViewMap_i lastViewIt = m_viewMap.end(); lastViewIt--;
01256 lastViewIt->second->setFrom(it->second);
01257 }
01258
01259 const FWConfiguration* undocked = iFrom.valueForKey(kUndocked);
01260 if(0!=undocked) {
01261 fwLog(fwlog::kWarning) << "Restrore of undocked windows with old window management not supported." << std::endl;
01262 }
01263 }
01264
01265
01266 const FWConfiguration* controllers = iFrom.valueForKey(kControllers);
01267 if (0 != controllers)
01268 {
01269 const FWConfiguration::KeyValues* keyVals = controllers->keyValues();
01270 if (0 != keyVals)
01271 {
01272
01273 for(FWConfiguration::KeyValuesIt it = keyVals->begin(); it != keyVals->end(); ++it)
01274 {
01275 const std::string& controllerName = it->first;
01276
01277 if (controllerName == kCollectionController) {
01278 showEDIFrame();
01279 setWindowInfoFrom(it->second,m_ediFrame);
01280 } else if (controllerName == kViewController) {
01281 setViewPopup(0);
01282 setWindowInfoFrom(it->second, m_viewPopup);
01283 } else if (controllerName == kObjectController) {
01284 showModelPopup();
01285 setWindowInfoFrom(it->second, m_modelPopup);
01286 } else if (controllerName == kCommonController) {
01287 showCommonPopup();
01288 setWindowInfoFrom(it->second, m_commonPopup);
01289 }
01290 }
01291 }
01292 }
01293
01294
01295 for(ViewMap_i it = m_viewMap.begin(); it != m_viewMap.end(); ++it)
01296 {
01297 if (it->second->typeId() >= FWViewType::kGeometryTable)
01298 {
01299 FWGeometryTableViewBase* gv = ( FWGeometryTableViewBase*)it->second;
01300 gv->populate3DViewsFromConfig();
01301 }
01302 }
01303
01304
01305 checkSubviewAreaIconState(0);
01306
01307
01308 }
01309
01310 void
01311 FWGUIManager::openEveBrowserForDebugging() const
01312 {
01313 gEve->GetBrowser()->MapWindow();
01314 }
01315
01316
01317
01318
01319 void
01320 FWGUIManager::delaySliderChanged(Int_t val)
01321 {
01322 Float_t sec = val*0.001;
01323 m_cmsShowMainFrame->setPlayDelayGUI(sec, kFALSE);
01324 changedDelayBetweenEvents_.emit(sec);
01325 }
01326
01327 void
01328 FWGUIManager::setDelayBetweenEvents(Float_t val)
01329 {
01330 m_cmsShowMainFrame->setPlayDelayGUI(val, kTRUE);
01331 }
01332
01333 void FWGUIManager::runIdChanged()
01334 {
01335 m_cmsShowMainFrame->m_lumiEntry->SetText("", kFALSE);
01336 m_cmsShowMainFrame->m_lumiEntry->SetFocus();
01337 }
01338
01339 void FWGUIManager::lumiIdChanged()
01340 {
01341 m_cmsShowMainFrame->m_eventEntry->SetText("", kFALSE);
01342 m_cmsShowMainFrame->m_eventEntry->SetFocus();
01343 }
01344
01345 void FWGUIManager::eventIdChanged()
01346 {
01347 changedEventId_.emit(m_cmsShowMainFrame->m_runEntry->GetUIntNumber(),
01348 m_cmsShowMainFrame->m_lumiEntry->GetUIntNumber(),
01349 m_cmsShowMainFrame->m_eventEntry->GetUIntNumber());
01350 }
01351
01352 void
01353 FWGUIManager::finishUpColorChange()
01354 {
01355 if (m_commonPopup) m_commonPopup->colorSetChanged();
01356 if (m_modelPopup) m_modelPopup->colorSetChanged();
01357 if (m_ediFrame) m_ediFrame->colorSetChanged();
01358
01359 gEve->FullRedraw3D();
01360 }
01361
01362
01363 void
01364 FWGUIManager::showEventFilterGUI()
01365 {
01366 showEventFilterGUI_.emit(m_cmsShowMainFrame);
01367 }
01368
01369 void
01370 FWGUIManager::filterButtonClicked()
01371 {
01372 filterButtonClicked_.emit();
01373 }
01374
01375 void
01376 FWGUIManager::setFilterButtonText(const char* txt)
01377 {
01378 m_cmsShowMainFrame->m_filterShowGUIBtn->SetText(txt);
01379 }
01380
01381 void
01382 FWGUIManager::setFilterButtonIcon(int state)
01383 {
01384 int i = state*3;
01385 m_cmsShowMainFrame->m_filterEnableBtn->setIcons(m_cmsShowMainFrame->m_filterIcons[i],
01386 m_cmsShowMainFrame->m_filterIcons[i+1],
01387 m_cmsShowMainFrame->m_filterIcons[i+2]);
01388 }
01389
01390 void
01391 FWGUIManager::updateEventFilterEnable(bool btnEnabled)
01392 {
01393 m_cmsShowMainFrame->m_filterEnableBtn->SetEnabled(btnEnabled);
01394 }
01395
01396 void
01397 FWGUIManager::measureWMOffsets()
01398 {
01399 const Int_t x = 100, y = 100;
01400
01401 TGMainFrame *mf1 = new TGMainFrame(0, 0, 0);
01402 mf1->MapWindow();
01403 mf1->Move(x, y);
01404
01405
01406 {
01407 TGMainFrame *mf2 = new TGMainFrame(0, 0, 0);
01408 mf2->MapWindow();
01409 while (!mf2->IsMapped()) gClient->HandleInput();
01410 delete mf2;
01411 }
01412 {
01413 Int_t xm, ym;
01414 Window_t childdum;
01415 WindowAttributes_t attr;
01416 gVirtualX->TranslateCoordinates(mf1->GetId(), gClient->GetDefaultRoot()->GetId(),
01417 0, 0, xm, ym, childdum);
01418 gVirtualX->GetWindowAttributes(mf1->GetId(), attr);
01419 m_WMOffsetX = x - xm;
01420 m_WMOffsetY = y - ym;
01421 m_WMDecorH = attr.fY;
01422 fwLog(fwlog::kDebug) << Form("FWGUIManager::measureWMOffsets: required (%d,%d), measured(%d, %d) => dx=%d, dy=%d; decor_h=%d.\n",
01423 x, y, xm, ym, m_WMOffsetX, m_WMOffsetY, m_WMDecorH);
01424 }
01425 delete mf1;
01426 }
01427
01428 void
01429 FWGUIManager::resetWMOffsets()
01430 {
01431 m_WMOffsetX = m_WMOffsetY = m_WMDecorH = 0;
01432 }