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/FWGeometryTableView.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::processGUIEvents()
00400 {
00401 gSystem->ProcessEvents();
00402 }
00403
00404 void
00405 FWGUIManager::newItem(const FWEventItem* iItem)
00406 {
00407 #if defined(THIS_WILL_NEVER_BE_DEFINED)
00408 m_selectionItemsComboBox->AddEntry(iItem->name().c_str(),iItem->id());
00409 if(iItem->id()==0) {
00410 m_selectionItemsComboBox->Select(0);
00411 }
00412 #endif
00413 }
00414
00415 void
00416 FWGUIManager::addData()
00417 {
00418 if (0==m_dataAdder) {
00419 m_dataAdder = new FWGUIEventDataAdder(100,100,
00420 (FWEventItemsManager*) m_context->eventItemsManager(),
00421 m_cmsShowMainFrame,
00422 m_context->metadataManager());
00423 }
00424 m_dataAdder->show();
00425 }
00426
00427
00428
00429
00430
00431 TEveWindow*
00432 FWGUIManager::getSwapCandidate()
00433 {
00434 TEveWindow* swapCandidate =0;
00435
00436 if ( gEve->GetWindowManager()->GetCurrentWindow())
00437 {
00438 swapCandidate = gEve->GetWindowManager()->GetCurrentWindow();
00439 }
00440 else
00441 {
00442
00443 TEveCompositeFrame* pef;
00444 TGFrameElementPack *pel;
00445
00446
00447 TGPack* pp = m_viewPrimPack->GetPack();
00448 if ( pp->GetList()->GetSize() > 2)
00449 {
00450 pel = (TGFrameElementPack*) pp->GetList()->At(1);
00451 if (pel->fState)
00452 {
00453 pef = dynamic_cast<TEveCompositeFrame*>(pel->fFrame);
00454 if ( pef && pef->GetEveWindow())
00455 swapCandidate = pef->GetEveWindow();
00456 }
00457 }
00458 if (swapCandidate == 0)
00459 {
00460
00461 TGPack* sp = m_viewSecPack->GetPack();
00462 Int_t nf = sp->GetList()->GetSize();
00463 TIter frame_iterator(sp->GetList());
00464 for (Int_t i=0; i<nf; ++i) {
00465 pel = (TGFrameElementPack*)frame_iterator();
00466 pef = dynamic_cast<TEveCompositeFrame*>(pel->fFrame);
00467 if ( pef && pef->GetEveWindow())
00468 {
00469 swapCandidate = pef->GetEveWindow() ;
00470 break;
00471 }
00472 }
00473 }
00474 }
00475
00476 return swapCandidate;
00477 }
00478
00479 void
00480 FWGUIManager::checkSubviewAreaIconState(TEveWindow* )
00481 {
00482
00483
00484
00485
00486 TEveWindow* current = getSwapCandidate();
00487 bool checkInfoBtn = m_viewPopup ? m_viewPopup->mapped() : 0;
00488 TEveWindow* selected = m_viewPopup ? m_viewPopup->getEveWindow() : 0;
00489
00490 for (ViewMap_i it = m_viewMap.begin(); it != m_viewMap.end(); it++)
00491 {
00492 FWGUISubviewArea* ar = FWGUISubviewArea::getToolBarFromWindow(it->first);
00493 ar->setSwapIcon(current != it->first);
00494 if (checkInfoBtn && selected)
00495 ar->setInfoButton(selected == it->first);
00496 }
00497 }
00498
00499 void
00500 FWGUIManager::subviewIsBeingDestroyed(FWGUISubviewArea* sva)
00501 {
00502 if(sva->isSelected()) {
00503 setViewPopup(0);
00504 }
00505
00506 CmsShowTaskExecutor::TaskFunctor f;
00507 f = boost::bind(&FWGUIManager::subviewDestroy, this, sva);
00508 m_tasks->addTask(f);
00509 m_tasks->startDoingTasks();
00510 }
00511
00512 void
00513 FWGUIManager::subviewDestroy(FWGUISubviewArea* sva)
00514 {
00515 TEveWindow* ew = sva->getEveWindow();
00516 FWViewBase* viewBase = m_viewMap[ew];
00517 m_viewMap.erase(ew);
00518 viewBase->destroy();
00519 }
00520
00521 void
00522 FWGUIManager::subviewDestroyAll()
00523 {
00524 std::vector<FWGUISubviewArea*> sd;
00525 for(ViewMap_i wIt = m_viewMap.begin(); wIt != m_viewMap.end(); ++wIt)
00526 {
00527 FWGUISubviewArea* ar = FWGUISubviewArea::getToolBarFromWindow(wIt->first);
00528 sd.push_back(ar);
00529 }
00530
00531 for (std::vector<FWGUISubviewArea*>::iterator i= sd.begin(); i !=sd.end(); ++i)
00532 {
00533 if((*i)->isSelected())
00534 setViewPopup(0);
00535 subviewDestroy(*i);
00536 }
00537
00538 gSystem->ProcessEvents();
00539 gSystem->Sleep(200);
00540
00541
00542
00543 while (m_viewPrimPack->HasChildren())
00544 {
00545 TEveWindow* w = dynamic_cast<TEveWindow*>(m_viewPrimPack->FirstChild());
00546 if (w) w->DestroyWindowAndSlot();
00547 }
00548
00549 gSystem->Sleep(200);
00550 m_viewSecPack = 0;
00551 gSystem->ProcessEvents();
00552
00553 }
00554
00555 void
00556 FWGUIManager::subviewInfoSelected(FWGUISubviewArea* sva)
00557 {
00558
00559 TEveWindow* ew = sva->getEveWindow();
00560 for(ViewMap_i wIt = m_viewMap.begin(); wIt != m_viewMap.end(); ++wIt)
00561 {
00562 if (wIt->first != ew)
00563 FWGUISubviewArea::getToolBarFromWindow(wIt->first)->setInfoButton(kFALSE);
00564 }
00565 setViewPopup(sva->getEveWindow());
00566 }
00567
00568 void
00569 FWGUIManager::subviewInfoUnselected(FWGUISubviewArea* sva)
00570 {
00571 m_viewPopup->UnmapWindow();
00572 }
00573
00574 void
00575 FWGUIManager::subviewSwapped(FWGUISubviewArea* sva)
00576 {
00577 TEveWindow* curr = getSwapCandidate();
00578 TEveWindow* swap = sva->getEveWindow();
00579 if (curr) swap->SwapWindow(curr);
00580
00581 checkSubviewAreaIconState(0);
00582 }
00583
00584 TGVerticalFrame*
00585 FWGUIManager::createList(TGCompositeFrame *p)
00586 {
00587 TGVerticalFrame *listFrame = new TGVerticalFrame(p, p->GetWidth(), p->GetHeight());
00588
00589 TGHorizontalFrame* addFrame = new TGHorizontalFrame(listFrame, p->GetWidth(), 10, kRaisedFrame);
00590 TGLabel* addLabel = new TGLabel(addFrame,"Summary View");
00591 addFrame->AddFrame(addLabel, new TGLayoutHints(kLHintsCenterX, 0,0,2,2));
00592 listFrame->AddFrame(addFrame, new TGLayoutHints(kLHintsExpandX | kLHintsTop));
00593
00594 m_summaryManager = new FWSummaryManager(listFrame,
00595 m_context->selectionManager(),
00596 (FWEventItemsManager*) m_context->eventItemsManager(),
00597 this,
00598 m_context->modelChangeManager(),
00599 m_context->colorManager());
00600
00601 const unsigned int backgroundColor=0x2f2f2f;
00602 TGTextButton* addDataButton = new TGTextButton(m_summaryManager->widget(), "Add Collection");
00603 addDataButton->ChangeOptions(kRaisedFrame);
00604 addDataButton->SetBackgroundColor(backgroundColor);
00605 addDataButton->SetTextColor(0xFFFFFF);
00606 addDataButton->SetToolTipText("Show additional collections");
00607 addDataButton->Connect("Clicked()", "FWGUIManager", this, "addData()");
00608 m_summaryManager->widget()->AddFrame(addDataButton, new TGLayoutHints(kLHintsExpandX|kLHintsLeft|kLHintsTop));
00609 listFrame->AddFrame(m_summaryManager->widget(), new TGLayoutHints(kLHintsExpandX|kLHintsExpandY));
00610
00611 return listFrame;
00612 }
00613
00614 void
00615 FWGUIManager::createViews(TEveWindowSlot *slot)
00616 {
00617 m_viewPrimPack = slot->MakePack();
00618 m_viewPrimPack->SetHorizontal();
00619 m_viewPrimPack->SetElementName("Views");
00620 m_viewPrimPack->SetShowTitleBar(kFALSE);
00621 m_viewSecPack = 0;
00622 }
00623
00624 void
00625 FWGUIManager::createEDIFrame() {
00626 if (m_ediFrame == 0) {
00627 m_ediFrame = new CmsShowEDI(m_cmsShowMainFrame, 200, 200, m_context->selectionManager(),m_context->colorManager());
00628 m_ediFrame->CenterOnParent(kTRUE,TGTransientFrame::kTopRight);
00629 m_cmsShowMainFrame->bindCSGActionKeys(m_ediFrame);
00630 }
00631 }
00632
00633 void
00634 FWGUIManager::showEDIFrame(int iToShow)
00635 {
00636 createEDIFrame();
00637 if(-1 != iToShow) {
00638 m_ediFrame->show(static_cast<FWDataCategories> (iToShow));
00639 }
00640 m_ediFrame->MapRaised();
00641 }
00642
00643 void
00644 FWGUIManager::showCommonPopup()
00645 {
00646 if (! m_commonPopup)
00647 {
00648 m_commonPopup = new CmsShowCommonPopup(m_context->commonPrefs(), m_cmsShowMainFrame, 200, 200);
00649 m_cmsShowMainFrame->bindCSGActionKeys(m_commonPopup);
00650 }
00651 m_commonPopup->MapRaised();
00652 }
00653
00654 void
00655 FWGUIManager::createModelPopup()
00656 {
00657 m_modelPopup = new CmsShowModelPopup(m_detailViewManager,m_context->selectionManager(), m_context->colorManager(), m_cmsShowMainFrame, 200, 200);
00658 m_modelPopup->CenterOnParent(kTRUE,TGTransientFrame::kRight);
00659 m_cmsShowMainFrame->bindCSGActionKeys(m_modelPopup);
00660 }
00661
00662 void
00663 FWGUIManager::showModelPopup()
00664 {
00665 if (!m_modelPopup) createModelPopup();
00666 m_modelPopup->MapRaised();
00667 }
00668
00669 void
00670 FWGUIManager::popupViewClosed()
00671 {
00672 if (m_viewPopup->getEveWindow())
00673 {
00674 FWGUISubviewArea* sa = FWGUISubviewArea::getToolBarFromWindow(m_viewPopup->getEveWindow());
00675 sa->setInfoButton(kFALSE);
00676 }
00677 }
00678
00679 void
00680 FWGUIManager::showViewPopup() {
00681
00682 setViewPopup(0);
00683 }
00684
00685 void
00686 FWGUIManager::setViewPopup(TEveWindow* ew) {
00687 FWViewBase* vb = ew ? m_viewMap[ew] : 0;
00688 if (m_viewPopup == 0)
00689 {
00690 m_viewPopup = new CmsShowViewPopup(0, 200, 200, m_context->colorManager(), vb, ew);
00691 m_viewPopup->closed_.connect(sigc::mem_fun(*m_guiManager, &FWGUIManager::popupViewClosed));
00692 }
00693 else
00694 {
00695 m_viewPopup->UnmapWindow();
00696 }
00697 m_viewPopup->reset(vb, ew);
00698 m_viewPopup->MapRaised();
00699 }
00700
00701 void
00702 FWGUIManager::showInvMassDialog()
00703 {
00704 if (! m_invMassDialog)
00705 {
00706 m_invMassDialog = new FWInvMassDialog(m_context->selectionManager());
00707 m_cmsShowMainFrame->bindCSGActionKeys(m_invMassDialog);
00708 }
00709 m_invMassDialog->MapRaised();
00710 }
00711
00712 void
00713 FWGUIManager::createHelpPopup ()
00714 {
00715 if (m_helpPopup == 0) {
00716 m_helpPopup = new CmsShowHelpPopup("help.html", "CmsShow Help",
00717 m_cmsShowMainFrame,
00718 800, 600);
00719 m_helpPopup->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
00720 }
00721 m_helpPopup->MapWindow();
00722 }
00723
00724
00725 void
00726 FWGUIManager::createShortcutPopup ()
00727 {
00728 if (m_shortcutPopup == 0) {
00729 m_shortcutPopup = new CmsShowHelpPopup("shortcuts.html",
00730 getAction(cmsshow::sKeyboardShort)->getName().c_str(),
00731 m_cmsShowMainFrame, 800, 600);
00732
00733 m_shortcutPopup->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
00734 }
00735 m_shortcutPopup->MapWindow();
00736 }
00737
00738 void FWGUIManager::createHelpGLPopup ()
00739 {
00740 if (m_helpGLPopup == 0) {
00741 m_helpGLPopup = new CmsShowHelpPopup("helpGL.html",
00742 getAction(cmsshow::sHelpGL)->getName().c_str(),
00743 m_cmsShowMainFrame, 800, 600);
00744
00745 m_helpGLPopup->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
00746 }
00747 m_helpGLPopup->MapWindow();
00748 }
00749
00750 void
00751 FWGUIManager::showSelectedModelContextMenu(Int_t iGlobalX, Int_t iGlobalY, FWViewContextMenuHandlerBase* iHandler)
00752 {
00753 if(!m_context->selectionManager()->selected().empty()) {
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 static const char* kFileTypes[] = {"Fireworks Configuration files","*.fwc",
00786 "All Files","*",
00787 0,0};
00788
00789 static TString dir(".");
00790
00791 TGFileInfo fi;
00792 fi.fFileTypes = kFileTypes;
00793 fi.fIniDir = StrDup(dir);
00794 new TGFileDialog(gClient->GetDefaultRoot(), m_cmsShowMainFrame, mode, &fi);
00795 dir = fi.fIniDir;
00796 if (fi.fFilename == 0)
00797 return false;
00798 std::string name = fi.fFilename;
00799
00800 std::string ext = kFileTypes[fi.fFileTypeIdx + 1] + 1;
00801 if (ext.size() != 0 && name.find(ext) == name.npos)
00802 name += ext;
00803 result = name;
00804 return true;
00805 }
00806
00807
00811 void
00812 FWGUIManager::promptForLoadConfigurationFile()
00813 {
00814 std::string name;
00815 if (!promptForConfigurationFile(name, kFDOpen))
00816 return;
00817
00818
00819 loadFromConfigurationFile_(name);
00820 }
00821
00825 void
00826 FWGUIManager::promptForSaveConfigurationFile()
00827 {
00828 std::string name;
00829 if (!promptForConfigurationFile(name, kFDSave))
00830 return;
00831 writeToConfigurationFile_(name);
00832 }
00833
00834 void
00835 FWGUIManager::exportImageOfMainView()
00836 {
00837 TGFrameElementPack* frameEL = (TGFrameElementPack*) m_viewPrimPack->GetPack()->GetList()->At(1);
00838 TEveCompositeFrame* ef = dynamic_cast<TEveCompositeFrame*>(frameEL->fFrame);
00839 m_viewMap[ef->GetEveWindow()]->promptForSaveImageTo(m_cmsShowMainFrame);
00840 }
00841
00842 void
00843 FWGUIManager::exportImagesOfAllViews()
00844 {
00845 try {
00846 static TString dir(".");
00847 const char * kImageExportTypes[] = {"PNG", "*.png",
00848 "GIF", "*.gif",
00849 "JPEG", "*.jpg",
00850 "PDF", "*.pdf",
00851 "Encapsulated PostScript", "*.eps",
00852 0, 0};
00853
00854 TGFileInfo fi;
00855 fi.fFileTypes = kImageExportTypes;
00856 fi.fIniDir = StrDup(dir);
00857 new TGFileDialog(gClient->GetDefaultRoot(), m_cmsShowMainFrame,
00858 kFDSave,&fi);
00859 dir = fi.fIniDir;
00860 if (fi.fFilename != 0) {
00861 std::string name = fi.fFilename;
00862
00863
00864
00865 std::string ext = kImageExportTypes[fi.fFileTypeIdx + 1] + 1;
00866 if (name.find(ext) == name.npos)
00867 name += ext;
00868
00869 name.insert(name.rfind('.'), "-%d_%d_%d_%s");
00870 exportAllViews(name);
00871 }
00872 }
00873 catch (std::runtime_error &e) { std::cout << e.what() << std::endl; }
00874 }
00875
00876 void
00877 FWGUIManager::exportAllViews(const std::string& format)
00878 {
00879
00880
00881
00882
00883
00884
00885
00886 typedef std::list<TEveViewer*> viewer_list_t;
00887 typedef viewer_list_t::iterator viewer_list_i;
00888
00889 typedef std::map<TString, viewer_list_t> name_map_t;
00890 typedef name_map_t::iterator name_map_i;
00891
00892 name_map_t vls;
00893
00894 for (ViewMap_i i = m_viewMap.begin(); i != m_viewMap.end(); ++i)
00895 {
00896 TEveViewer *ev = dynamic_cast<TEveViewer*>(i->first);
00897 if (ev)
00898 {
00899 TString name(ev->GetElementName());
00900 name.ReplaceAll(" ", "");
00901 viewer_list_t &l = vls[name];
00902 viewer_list_i li = l.begin();
00903 while (li != l.end() && (*li)->GetGLViewer()->ViewportDiagonal() < ev->GetGLViewer()->ViewportDiagonal())
00904 ++li;
00905 l.insert(li, ev);
00906 }
00907 }
00908
00909 const edm::EventBase *event = getCurrentEvent();
00910 for (name_map_i i = vls.begin(); i != vls.end(); ++i)
00911 {
00912 bool multi_p = (i->second.size() > 1);
00913 int view_count = 1;
00914 for (viewer_list_i j = i->second.begin(); j != i->second.end(); ++j, ++view_count)
00915 {
00916 TString view_name(i->first);
00917 if (multi_p)
00918 {
00919 view_name += "_";
00920 view_name += view_count;
00921 }
00922 TString file;
00923 file.Form(format.c_str(), event->id().run(), event->id().event(),
00924 event->luminosityBlock(), view_name.Data());
00925 (*j)->GetGLViewer()->SavePicture(file);
00926 }
00927 }
00928 }
00929
00930 static const std::string kMainWindow("main window");
00931 static const std::string kViews("views");
00932 static const std::string kViewArea("view area");
00933 static const std::string kUndocked("undocked views");
00934 static const std::string kControllers("controllers");
00935 static const std::string kCollectionController("collection");
00936 static const std::string kViewController("view");
00937 static const std::string kObjectController("object");
00938 static const std::string kCommonController("common");
00939
00940 static
00941 void
00942 addWindowInfoTo(const TGFrame* iMain,
00943 FWConfiguration& oTo)
00944 {
00945 Window_t wdummy;
00946 Int_t ax,ay;
00947 gVirtualX->TranslateCoordinates(iMain->GetId(),
00948 gClient->GetDefaultRoot()->GetId(),
00949 0,0,
00950 ax,ay,
00951 wdummy);
00952 {
00953 std::stringstream s;
00954 s<<ax;
00955 oTo.addKeyValue("x",FWConfiguration(s.str()));
00956 }
00957 {
00958 std::stringstream s;
00959 s<<ay;
00960 oTo.addKeyValue("y",FWConfiguration(s.str()));
00961 }
00962 {
00963 std::stringstream s;
00964 s<<iMain->GetWidth();
00965 oTo.addKeyValue("width",FWConfiguration(s.str()));
00966 }
00967 {
00968 std::stringstream s;
00969 s<<iMain->GetHeight();
00970 oTo.addKeyValue("height",FWConfiguration(s.str()));
00971 }
00972 }
00973
00974 class areaInfo
00975 {
00976
00977 public:
00978 areaInfo (TGFrameElementPack* frameElement)
00979 {
00980 eveWindow = 0;
00981 originalSlot = 0;
00982 undockedMainFrame = 0;
00983 weight = frameElement->fWeight;
00984 undocked = !frameElement->fState;
00985
00986 TEveCompositeFrame *eveFrame = dynamic_cast<TEveCompositeFrame*>(frameElement->fFrame);
00987 assert(eveFrame);
00988
00989 if (frameElement->fState)
00990 eveWindow = eveFrame->GetEveWindow();
00991 else
00992 originalSlot = eveFrame->GetEveWindow();
00993 }
00994
00995 areaInfo () {}
00996
00997 Float_t weight;
00998 Bool_t undocked;
00999 TEveWindow *eveWindow;
01000 TGMainFrame *undockedMainFrame;
01001 TEveWindow *originalSlot;
01002 };
01003
01004 static
01005 void
01006 addAreaInfoTo(areaInfo& pInfo,
01007 FWConfiguration& oTo)
01008 {
01009 {
01010 std::stringstream s;
01011 s << pInfo.weight;
01012 oTo.addKeyValue("weight", FWConfiguration(s.str()));
01013 }
01014 {
01015 std::stringstream s;
01016 s<< pInfo.undocked;
01017 oTo.addKeyValue("undocked", FWConfiguration(s.str()));
01018 }
01019
01020 if (pInfo.undockedMainFrame)
01021 {
01022 FWConfiguration temp(oTo);
01023 addWindowInfoTo(pInfo.undockedMainFrame, temp);
01024 oTo.addKeyValue("UndockedWindowPos", temp);
01025 }
01026 }
01027
01028
01029 void
01030 FWGUIManager::addTo(FWConfiguration& oTo) const
01031 {
01032 Int_t cfgVersion=3;
01033
01034 FWConfiguration mainWindow(cfgVersion);
01035 float leftWeight, rightWeight;
01036 addWindowInfoTo(m_cmsShowMainFrame, mainWindow);
01037 {
01038
01039 {
01040 std::stringstream ss;
01041 ss << m_cmsShowMainFrame->getSummaryViewWeight();
01042 mainWindow.addKeyValue("summaryWeight",FWConfiguration(ss.str()));
01043 }
01044
01045
01046 if ( m_viewPrimPack->GetPack()->GetList()->GetSize() > 2)
01047 {
01048 TGFrameElementPack *frameEL;
01049 frameEL = (TGFrameElementPack*) m_viewPrimPack->GetPack()->GetList()->At(1);
01050 leftWeight = frameEL->fWeight;
01051 frameEL = (TGFrameElementPack*) m_viewPrimPack->GetPack()->GetList()->At(3);
01052 rightWeight = frameEL->fWeight;
01053 }
01054 else
01055 {
01056 leftWeight = 0;
01057 rightWeight = 1;
01058 }
01059 std::stringstream sL;
01060 sL<<leftWeight;
01061 mainWindow.addKeyValue("leftWeight",FWConfiguration(sL.str()));
01062 std::stringstream sR;
01063 sR<<rightWeight;
01064 mainWindow.addKeyValue("rightWeight",FWConfiguration(sR.str()));
01065 }
01066 oTo.addKeyValue(kMainWindow, mainWindow, true);
01067
01068
01069
01070 std::vector<areaInfo> wpacked;
01071 if (leftWeight > 0)
01072 {
01073 TGPack* pp = m_viewPrimPack->GetPack();
01074 TGFrameElementPack *frameEL = (TGFrameElementPack*) pp->GetList()->At(1);
01075 if (frameEL->fWeight > 0)
01076 wpacked.push_back(areaInfo(frameEL));
01077 }
01078 TGPack* sp = m_viewSecPack->GetPack();
01079 Int_t nf = sp->GetList()->GetSize();
01080 TIter frame_iterator(sp->GetList());
01081 for (Int_t i=0; i<nf; ++i) {
01082 TGFrameElementPack *seFE = (TGFrameElementPack*)frame_iterator();
01083 if (seFE->fWeight)
01084 wpacked.push_back(areaInfo(seFE));
01085 }
01086
01087
01088
01089 for(ViewMap_i wIt = m_viewMap.begin(); wIt != m_viewMap.end(); ++wIt)
01090 {
01091 TEveWindow* ew = wIt->first;
01092 TEveCompositeFrameInMainFrame* mainFrame = dynamic_cast<TEveCompositeFrameInMainFrame*>(ew->GetEveFrame());
01093 if (mainFrame)
01094 {
01095 for(std::vector<areaInfo>::iterator pIt = wpacked.begin(); pIt != wpacked.end(); ++pIt)
01096 {
01097 if ((*pIt).originalSlot && mainFrame->GetOriginalSlot() == (*pIt).originalSlot)
01098 {
01099 (*pIt).eveWindow = wIt->first;
01100 (*pIt).undockedMainFrame = (TGMainFrame*)mainFrame;
01101
01102 break;
01103 }
01104 }
01105 }
01106 }
01107
01108
01109
01110 FWConfiguration views(1);
01111 FWConfiguration viewArea(cfgVersion);
01112 for(std::vector<areaInfo>::iterator it = wpacked.begin(); it != wpacked.end(); ++it)
01113 {
01114 TEveWindow* ew = (*it).eveWindow;
01115 if (ew) {
01116 FWViewBase* wb = m_viewMap[ew];
01117 FWConfiguration tempWiew(wb->version());
01118 wb->addTo(tempWiew);
01119 views.addKeyValue(wb->typeName(), tempWiew, true);
01120 FWConfiguration tempArea(cfgVersion);
01121 addAreaInfoTo((*it), tempArea);
01122 viewArea.addKeyValue(wb->typeName(), tempArea, true);
01123 }
01124 }
01125 oTo.addKeyValue(kViews, views, true);
01126 oTo.addKeyValue(kViewArea, viewArea, true);
01127
01128
01129
01130 FWConfiguration controllers(1);
01131 {
01132 if(0!=m_ediFrame && m_ediFrame->IsMapped()) {
01133 FWConfiguration temp(1);
01134 addWindowInfoTo(m_ediFrame, temp);
01135 controllers.addKeyValue(kCollectionController,temp,true);
01136 }
01137 if(0!=m_viewPopup && m_viewPopup->IsMapped()) {
01138 FWConfiguration temp(1);
01139 addWindowInfoTo(m_viewPopup, temp);
01140 controllers.addKeyValue(kViewController,temp,true);
01141 }
01142 if(0!=m_modelPopup && m_modelPopup->IsMapped()) {
01143 FWConfiguration temp(1);
01144 addWindowInfoTo(m_modelPopup, temp);
01145 controllers.addKeyValue(kObjectController,temp,true);
01146 }
01147 if(0!=m_commonPopup && m_commonPopup->IsMapped()) {
01148 FWConfiguration temp(1);
01149 addWindowInfoTo(m_commonPopup, temp);
01150 controllers.addKeyValue(kCommonController,temp,true);
01151 }
01152 }
01153 oTo.addKeyValue(kControllers,controllers,true);
01154 }
01155
01156
01157 void
01158 FWGUIManager::setWindowInfoFrom(const FWConfiguration& iFrom,
01159 TGMainFrame* iFrame)
01160 {
01161 int x = atoi(iFrom.valueForKey("x")->value().c_str()) + m_WMOffsetX;
01162 int y = atoi(iFrom.valueForKey("y")->value().c_str()) + m_WMOffsetY;
01163 if (y < m_WMDecorH) y = m_WMDecorH;
01164 int width = atoi(iFrom.valueForKey("width")->value().c_str());
01165 int height = atoi(iFrom.valueForKey("height")->value().c_str());
01166 iFrame->MoveResize(x,y,width,height);
01167 iFrame->SetWMPosition(x, y);
01168 }
01169
01170 void
01171 FWGUIManager::setFrom(const FWConfiguration& iFrom) {
01172
01173 if (m_viewSecPack) subviewDestroyAll();
01174
01175 const FWConfiguration* mw = iFrom.valueForKey(kMainWindow);
01176 assert(mw != 0);
01177
01178
01179 m_cmsShowMainFrame->MapWindow();
01180 setWindowInfoFrom(*mw, m_cmsShowMainFrame);
01181 m_cmsShowMainFrame->MapSubwindows();
01182 m_cmsShowMainFrame->Layout();
01183 m_cmsShowMainFrame->MapRaised();
01184
01185
01186 float_t leftWeight =1;
01187 float_t rightWeight=1;
01188 if ( mw->version() >= 2 ) {
01189 leftWeight = atof(mw->valueForKey("leftWeight")->value().c_str());
01190 rightWeight = atof(mw->valueForKey("rightWeight")->value().c_str());
01191 }
01192
01193 if ( mw->version() >= 3 ) {
01194 float summaryWeight = atof(mw->valueForKey("summaryWeight")->value().c_str());
01195 m_cmsShowMainFrame->setSummaryViewWeight(summaryWeight);
01196 }
01197
01198 TEveWindowSlot* primSlot = (leftWeight > 0) ? m_viewPrimPack->NewSlotWithWeight(leftWeight) : 0;
01199 m_viewSecPack = m_viewPrimPack->NewSlotWithWeight(rightWeight)->MakePack();
01200 m_viewSecPack->SetVertical();
01201 m_viewSecPack->SetShowTitleBar(kFALSE);
01202
01203
01204 const FWConfiguration* views = iFrom.valueForKey(kViews); assert(0!=views);
01205 const FWConfiguration::KeyValues* keyVals = views->keyValues();
01206 const FWConfiguration* viewArea = iFrom.valueForKey(kViewArea);
01207
01208
01209 if ( viewArea->version() > 1)
01210 {
01211 const FWConfiguration::KeyValues* akv = viewArea->keyValues();
01212 FWConfiguration::KeyValuesIt areaIt = akv->begin();
01213
01214 for(FWConfiguration::KeyValuesIt it = keyVals->begin(); it!= keyVals->end(); ++it)
01215 {
01216 float weight = atof((areaIt->second).valueForKey("weight")->value().c_str());
01217 TEveWindowSlot* slot = ( m_viewMap.size() || (primSlot == 0) ) ? m_viewSecPack->NewSlotWithWeight(weight) : primSlot;
01218 std::string name = FWViewType::checkNameWithViewVersion(it->first, it->second.version());
01219 ViewMap_i lastViewIt = createView(name, slot);
01220 lastViewIt->second->setFrom(it->second);
01221
01222 bool undocked = atof((areaIt->second).valueForKey("undocked")->value().c_str());
01223 if (undocked)
01224 {
01225 TEveWindow* lastWindow = lastViewIt->first;
01226 lastWindow->UndockWindow();
01227 TEveCompositeFrameInMainFrame* emf = dynamic_cast<TEveCompositeFrameInMainFrame*>(lastWindow->GetEveFrame());
01228 const TGMainFrame* mf = dynamic_cast<const TGMainFrame*>(emf->GetParent());
01229 m_cmsShowMainFrame->bindCSGActionKeys(mf);
01230 TGMainFrame* mfp = (TGMainFrame*)mf;
01231 const FWConfiguration* mwc = (areaIt->second).valueForKey("UndockedWindowPos");
01232 setWindowInfoFrom(*mwc, mfp);
01233 }
01234 areaIt++;
01235 }
01236 }
01237 else
01238 {
01239 for(FWConfiguration::KeyValuesIt it = keyVals->begin(); it!= keyVals->end(); ++it) {
01240 std::string name = FWViewType::checkNameWithViewVersion(it->first, it->second.version());
01241 createView(name, m_viewMap.size() ? m_viewSecPack->NewSlot() : primSlot);
01242
01243 ViewMap_i lastViewIt = m_viewMap.end(); lastViewIt--;
01244 lastViewIt->second->setFrom(it->second);
01245 }
01246
01247 const FWConfiguration* undocked = iFrom.valueForKey(kUndocked);
01248 if(0!=undocked) {
01249 fwLog(fwlog::kWarning) << "Restrore of undocked windows with old window management not supported." << std::endl;
01250 }
01251 }
01252
01253
01254 const FWConfiguration* controllers = iFrom.valueForKey(kControllers);
01255 if(0!=controllers) {
01256 const FWConfiguration::KeyValues* keyVals = controllers->keyValues();
01257 if(0!=keyVals) {
01258
01259 for(FWConfiguration::KeyValuesIt it = keyVals->begin(); it != keyVals->end(); ++it)
01260 {
01261 const std::string& controllerName = it->first;
01262
01263 if(controllerName == kCollectionController) {
01264 showEDIFrame();
01265 setWindowInfoFrom(it->second,m_ediFrame);
01266 } else if (controllerName == kViewController) {
01267 setViewPopup(0);
01268 setWindowInfoFrom(it->second, m_viewPopup);
01269 } else if (controllerName == kObjectController) {
01270 showModelPopup();
01271 setWindowInfoFrom(it->second, m_modelPopup);
01272 } else if (controllerName == kCommonController) {
01273 showCommonPopup();
01274 setWindowInfoFrom(it->second, m_commonPopup);
01275 }
01276 }
01277 }
01278 }
01279
01280
01281 for(ViewMap_i it = m_viewMap.begin(); it != m_viewMap.end(); ++it)
01282 {
01283 if (it->second->typeId() == FWViewType::kGeometryTable)
01284 {
01285 FWGeometryTableView* gv = ( FWGeometryTableView*)it->second;
01286 gv->populate3DViewsFromConfig();
01287 }
01288 }
01289
01290
01291 checkSubviewAreaIconState(0);
01292
01293
01294 }
01295
01296 void
01297 FWGUIManager::openEveBrowserForDebugging() const
01298 {
01299 gEve->GetBrowser()->MapWindow();
01300 }
01301
01302
01303
01304
01305 void
01306 FWGUIManager::delaySliderChanged(Int_t val)
01307 {
01308 Float_t sec = val*0.001;
01309 m_cmsShowMainFrame->setPlayDelayGUI(sec, kFALSE);
01310 changedDelayBetweenEvents_.emit(sec);
01311 }
01312
01313 void
01314 FWGUIManager::setDelayBetweenEvents(Float_t val)
01315 {
01316 m_cmsShowMainFrame->setPlayDelayGUI(val, kTRUE);
01317 }
01318
01319 void FWGUIManager::runIdChanged()
01320 {
01321 m_cmsShowMainFrame->m_lumiEntry->SetText("", kFALSE);
01322 m_cmsShowMainFrame->m_lumiEntry->SetFocus();
01323 }
01324
01325 void FWGUIManager::lumiIdChanged()
01326 {
01327 m_cmsShowMainFrame->m_eventEntry->SetText("", kFALSE);
01328 m_cmsShowMainFrame->m_eventEntry->SetFocus();
01329 }
01330
01331 void FWGUIManager::eventIdChanged()
01332 {
01333 changedEventId_.emit(m_cmsShowMainFrame->m_runEntry->GetUIntNumber(),
01334 m_cmsShowMainFrame->m_lumiEntry->GetUIntNumber(),
01335 m_cmsShowMainFrame->m_eventEntry->GetUIntNumber());
01336 }
01337
01338 void
01339 FWGUIManager::finishUpColorChange()
01340 {
01341 if (m_commonPopup) m_commonPopup->colorSetChanged();
01342 if (m_modelPopup) m_modelPopup->colorSetChanged();
01343 if (m_ediFrame) m_ediFrame->colorSetChanged();
01344
01345 gEve->FullRedraw3D();
01346 }
01347
01348
01349 void
01350 FWGUIManager::showEventFilterGUI()
01351 {
01352 showEventFilterGUI_.emit(m_cmsShowMainFrame);
01353 }
01354
01355 void
01356 FWGUIManager::filterButtonClicked()
01357 {
01358 filterButtonClicked_.emit();
01359 }
01360
01361 void
01362 FWGUIManager::setFilterButtonText(const char* txt)
01363 {
01364 m_cmsShowMainFrame->m_filterShowGUIBtn->SetText(txt);
01365 }
01366
01367 void
01368 FWGUIManager::setFilterButtonIcon(int state)
01369 {
01370 int i = state*3;
01371 m_cmsShowMainFrame->m_filterEnableBtn->setIcons(m_cmsShowMainFrame->m_filterIcons[i],
01372 m_cmsShowMainFrame->m_filterIcons[i+1],
01373 m_cmsShowMainFrame->m_filterIcons[i+2]);
01374 }
01375
01376 void
01377 FWGUIManager::updateEventFilterEnable(bool btnEnabled)
01378 {
01379 m_cmsShowMainFrame->m_filterEnableBtn->SetEnabled(btnEnabled);
01380 }
01381
01382 void
01383 FWGUIManager::measureWMOffsets()
01384 {
01385 const Int_t x = 100, y = 100;
01386
01387 TGMainFrame *mf1 = new TGMainFrame(0, 0, 0);
01388 mf1->MapWindow();
01389 mf1->Move(x, y);
01390
01391
01392 {
01393 TGMainFrame *mf2 = new TGMainFrame(0, 0, 0);
01394 mf2->MapWindow();
01395 while (!mf2->IsMapped()) gClient->HandleInput();
01396 delete mf2;
01397 }
01398 {
01399 Int_t xm, ym;
01400 Window_t childdum;
01401 WindowAttributes_t attr;
01402 gVirtualX->TranslateCoordinates(mf1->GetId(), gClient->GetDefaultRoot()->GetId(),
01403 0, 0, xm, ym, childdum);
01404 gVirtualX->GetWindowAttributes(mf1->GetId(), attr);
01405 m_WMOffsetX = x - xm;
01406 m_WMOffsetY = y - ym;
01407 m_WMDecorH = attr.fY;
01408 fwLog(fwlog::kDebug) << Form("FWGUIManager::measureWMOffsets: required (%d,%d), measured(%d, %d) => dx=%d, dy=%d; decor_h=%d.\n",
01409 x, y, xm, ym, m_WMOffsetX, m_WMOffsetY, m_WMDecorH);
01410 }
01411 delete mf1;
01412 }
01413
01414 void
01415 FWGUIManager::resetWMOffsets()
01416 {
01417 m_WMOffsetX = m_WMOffsetY = m_WMDecorH = 0;
01418 }