16 #include <boost/bind.hpp>
27 #include "TGLIncludes.h"
28 #include "TGLViewer.h"
29 #include "TEveBrowser.h"
30 #include "TEveManager.h"
32 #include "TEveWindow.h"
33 #include "TEveViewer.h"
34 #include "TEveWindowManager.h"
35 #include "TEveSelection.h"
36 #include "TVirtualX.h"
103 m_detailViewManager(0),
104 m_viewManagerManager(iVMMgr),
105 m_contextMenuHandler(0),
106 m_navigator(navigator),
117 m_WMOffsetX(0), m_WMOffsetY(0), m_WMDecorH(0)
130 TEveCompositeFrame::SetupFrameMarkup(foo, 20, 4,
false);
135 UInt_t
width = gClient->GetDisplayWidth();
136 UInt_t height =
static_cast<UInt_t
>(gClient->GetDisplayHeight()*.8);
140 while(width > 2000) {
143 width =
static_cast<UInt_t
>(width*.8);
198 TQObject::Connect(gEve->GetWindowManager(),
"WindowSelected(TEveWindow*)",
"FWGUIManager",
this,
"checkSubviewAreaIconState(TEveWindow*)");
199 TQObject::Connect(gEve->GetWindowManager(),
"WindowDocked(TEveWindow*)" ,
"FWGUIManager",
this,
"checkSubviewAreaIconState(TEveWindow*)");
200 TQObject::Connect(gEve->GetWindowManager(),
"WindowUndocked(TEveWindow*)",
"FWGUIManager",
this,
"checkSubviewAreaIconState(TEveWindow*)");
230 gEve->GetWindowManager()->Disconnect(
"WindowSelected(TEveWindow*)",
this,
"checkSubviewAreaIconState(TEveWindow*)");
231 gEve->GetWindowManager()->Disconnect(
"WindowDocked(TEveWindow*)",
this,
"checkSubviewAreaIconState(TEveWindow*)");
232 gEve->GetWindowManager()->Disconnect(
"WindowUndocked(TEveWindow*)",
this,
"checkSubviewAreaIconState(TEveWindow*)");
235 gEve->GetSelection()->Disconnect();
236 gEve->GetHighlight()->Disconnect();
237 gEve->GetSelection()->RemoveElements();
238 gEve->GetHighlight()->RemoveElements();
243 TEveCompositeFrameInMainFrame* mainFrame =
dynamic_cast<TEveCompositeFrameInMainFrame*
>((*wIt).first->GetEveFrame());
245 if (mainFrame) mainFrame->UnmapWindow();
247 (*wIt).second->destroy();
283 throw std::runtime_error(
std::string(
"Unable to create view named ")+iName+
" because it is unknown");
299 TEveCompositeFrame *ef = slot->GetEveFrame();
300 FWViewBase* viewBase = itFind->second(slot, iName);
305 TEveWindow *eveWindow = ef->GetEveWindow();
306 eveWindow->SetElementName(iName.c_str());
308 std::pair<ViewMap_i,bool> insertPair =
m_viewMap.insert(std::make_pair(eveWindow, viewBase));
309 return insertPair.first;
327 snprintf(title,127,
"cmsShow: %s", subtitle);
335 TEveViewerList* viewers = gEve->GetViewers();
336 for (TEveElement::List_i
i=viewers->BeginChildren();
i!= viewers->EndChildren(); ++
i)
338 TEveViewer*
ev =
dynamic_cast<TEveViewer*
>(*i);
340 ev->GetGLViewer()->DeleteOverlayAnnotations();
404 #if defined(THIS_WILL_NEVER_BE_DEFINED)
405 m_selectionItemsComboBox->AddEntry(iItem->
name().c_str(),iItem->
id());
407 m_selectionItemsComboBox->Select(0);
431 TEveWindow* swapCandidate =0;
433 if ( gEve->GetWindowManager()->GetCurrentWindow())
435 swapCandidate = gEve->GetWindowManager()->GetCurrentWindow();
440 TEveCompositeFrame* pef;
441 TGFrameElementPack *pel;
445 if ( pp->GetList()->GetSize() > 2)
447 pel = (TGFrameElementPack*) pp->GetList()->At(1);
450 pef =
dynamic_cast<TEveCompositeFrame*
>(pel->fFrame);
451 if ( pef && pef->GetEveWindow())
452 swapCandidate = pef->GetEveWindow();
455 if (swapCandidate == 0)
459 TIter frame_iterator(sp->GetList());
460 while ((pel = (TGFrameElementPack*)frame_iterator()))
462 pef =
dynamic_cast<TEveCompositeFrame*
>(pel->fFrame);
463 if ( pef && pef->GetEveWindow() && pel->fState)
465 swapCandidate = pef->GetEveWindow() ;
471 return swapCandidate;
489 if (checkInfoBtn && selected)
518 std::vector<FWGUISubviewArea*>
sd;
525 for (std::vector<FWGUISubviewArea*>::iterator
i= sd.begin();
i !=sd.end(); ++
i)
527 if ((*i)->isSelected())
532 gSystem->ProcessEvents();
539 TEveWindow*
w =
dynamic_cast<TEveWindow*
>(
m_viewPrimPack->FirstChild());
540 if (w) w->DestroyWindowAndSlot();
545 gSystem->ProcessEvents();
556 if (wIt->first != ew)
573 if (curr) swap->SwapWindow(curr);
581 TGVerticalFrame *listFrame =
new TGVerticalFrame(p, p->GetWidth(), p->GetHeight());
583 TGHorizontalFrame* addFrame =
new TGHorizontalFrame(listFrame, p->GetWidth(), 10, kRaisedFrame);
584 TGLabel* addLabel =
new TGLabel(addFrame,
"Summary View");
585 addFrame->AddFrame(addLabel,
new TGLayoutHints(kLHintsCenterX, 0,0,2,2));
586 listFrame->AddFrame(addFrame,
new TGLayoutHints(kLHintsExpandX | kLHintsTop));
595 const unsigned int backgroundColor=0x2f2f2f;
597 addDataButton->ChangeOptions(kRaisedFrame);
598 addDataButton->SetBackgroundColor(backgroundColor);
599 addDataButton->SetTextColor(0xFFFFFF);
600 addDataButton->SetToolTipText(
"Show additional collections");
601 addDataButton->Connect(
"Clicked()",
"FWGUIManager",
this,
"addData()");
602 m_summaryManager->
widget()->AddFrame(addDataButton,
new TGLayoutHints(kLHintsExpandX|kLHintsLeft|kLHintsTop));
624 m_ediFrame->CenterOnParent(kTRUE,TGTransientFrame::kTopRight);
655 m_modelPopup->CenterOnParent(kTRUE,TGTransientFrame::kRight);
719 m_helpPopup->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
747 m_helpGLPopup->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
789 const static char* kFileTypes[] = {
"Fireworks Configuration files",
"*.fwc",
793 static TString
dir(
".");
796 fi.fFileTypes = kFileTypes;
797 fi.fIniDir = StrDup(dir);
800 if (fi.fFilename == 0)
804 std::string ext = kFileTypes[fi.fFileTypeIdx + 1] + 1;
805 if (ext.size() != 0 && name.find(ext) == name.npos)
843 TGFrameElementPack* frameEL = (TGFrameElementPack*)
m_viewPrimPack->GetPack()->GetList()->At(1);
844 TEveCompositeFrame* ef =
dynamic_cast<TEveCompositeFrame*
>(frameEL->fFrame);
857 static TString
dir(
".");
858 const char * kImageExportTypes[] = {
"PNG",
"*.png",
862 "Encapsulated PostScript",
"*.eps",
866 fi.fFileTypes = kImageExportTypes;
867 fi.fIniDir = StrDup(dir);
871 if (fi.fFilename != 0) {
876 std::string ext = kImageExportTypes[fi.fFileTypeIdx + 1] + 1;
877 if (name.find(ext) == name.npos)
880 name.insert(name.rfind(
'.'),
"-%u_%u_%u_%s");
884 catch (std::runtime_error &
e) {
std::cout << e.what() << std::endl; }
897 typedef std::list<FWTEveViewer*> viewer_list_t;
898 typedef viewer_list_t::iterator viewer_list_i;
900 typedef std::map<TString, viewer_list_t> name_map_t;
901 typedef name_map_t::iterator name_map_i;
910 TString
name(ev->GetElementName());
911 name.ReplaceAll(
" ",
"");
912 viewer_list_t &
l = vls[
name];
913 viewer_list_i li = l.begin();
914 while (li != l.end() && (*li)->GetGLViewer()->ViewportDiagonal() < ev->GetGLViewer()->ViewportDiagonal())
920 std::vector<std::future<int>> futures;
923 for (name_map_i
i = vls.begin();
i != vls.end(); ++
i)
925 bool multi_p = (
i->second.size() > 1);
927 for (viewer_list_i
j =
i->second.begin();
j !=
i->second.end(); ++
j, ++view_count)
929 TString view_name(
i->first);
933 view_name += view_count;
936 file.Form(format.c_str(),
event->id().run(),
event->id().event(),
937 event->luminosityBlock(), view_name.Data());
939 if (GLEW_EXT_framebuffer_object)
942 futures.push_back((*j)->CaptureAndSaveImage(file, height));
948 (*j)->GetGLViewer()->SavePicture(file);
950 (*j)->GetGLViewer()->SavePictureHeight(file, height);
955 for (
auto &
f : futures)
978 gVirtualX->TranslateCoordinates(iMain->GetId(),
979 gClient->GetDefaultRoot()->GetId(),
995 s<<iMain->GetWidth();
1000 s<<iMain->GetHeight();
1014 weight = frameElement->fWeight;
1017 TEveCompositeFrame *eveFrame =
dynamic_cast<TEveCompositeFrame*
>(frameElement->fFrame);
1020 if (frameElement->fState)
1041 std::stringstream
s;
1046 std::stringstream
s;
1066 float leftWeight, rightWeight;
1071 std::stringstream
ss;
1079 TGFrameElementPack *frameEL;
1080 frameEL = (TGFrameElementPack*)
m_viewPrimPack->GetPack()->GetList()->At(1);
1081 leftWeight = frameEL->fWeight;
1082 frameEL = (TGFrameElementPack*)
m_viewPrimPack->GetPack()->GetList()->At(3);
1083 rightWeight = frameEL->fWeight;
1090 std::stringstream sL;
1093 std::stringstream sR;
1101 std::vector<areaInfo> wpacked;
1105 TGFrameElementPack *frameEL = (TGFrameElementPack*) pp->GetList()->At(1);
1106 if (frameEL->fWeight > 0)
1107 wpacked.push_back(
areaInfo(frameEL));
1110 TGFrameElementPack *seFE;
1111 TIter frame_iterator(sp->GetList());
1112 while ((seFE = (TGFrameElementPack*)frame_iterator() ))
1122 TEveWindow* ew = wIt->first;
1123 TEveCompositeFrameInMainFrame* mainFrame =
dynamic_cast<TEveCompositeFrameInMainFrame*
>(ew->GetEveFrame());
1126 for(std::vector<areaInfo>::iterator pIt = wpacked.begin(); pIt != wpacked.end(); ++pIt)
1128 if ((*pIt).originalSlot && mainFrame->GetOriginalSlot() == (*pIt).originalSlot)
1130 (*pIt).eveWindow = wIt->first;
1131 (*pIt).undockedMainFrame = (TGMainFrame*)mainFrame;
1143 for(std::vector<areaInfo>::iterator it = wpacked.begin(); it != wpacked.end(); ++it)
1145 TEveWindow* ew = (*it).eveWindow;
1149 wb->
addTo(tempWiew);
1190 TGMainFrame* iFrame)
1197 iFrame->MoveResize(x,y,width,height);
1198 iFrame->SetWMPosition(x, y);
1217 float_t leftWeight =1;
1218 float_t rightWeight=1;
1225 float summaryWeight = atof(mw->
valueForKey(
"summaryWeight")->
value().c_str());
1229 TEveWindowSlot* primSlot = (leftWeight > 0) ?
m_viewPrimPack->NewSlotWithWeight(leftWeight) : 0;
1247 float weight = atof((areaIt->second).valueForKey(
"weight")->value().c_str());
1248 TEveWindowSlot* slot = (
m_viewMap.size() || (primSlot == 0) ) ?
m_viewSecPack->NewSlotWithWeight(weight) : primSlot;
1251 lastViewIt->second->setFrom(it->second);
1253 bool undocked = atof((areaIt->second).valueForKey(
"undocked")->value().c_str());
1256 TEveWindow* lastWindow = lastViewIt->first;
1257 lastWindow->UndockWindow();
1258 TEveCompositeFrameInMainFrame* emf =
dynamic_cast<TEveCompositeFrameInMainFrame*
>(lastWindow->GetEveFrame());
1260 const TGMainFrame* mf =
dynamic_cast<const TGMainFrame*
>(emf->GetParent());
1263 TGMainFrame* mfp = (TGMainFrame*)mf;
1264 const FWConfiguration* mwc = (areaIt->second).valueForKey(
"UndockedWindowPos");
1279 lastViewIt->second->setFrom(it->second);
1284 fwLog(
fwlog::kWarning) <<
"Restrore of undocked windows with old window management not supported." << std::endl;
1290 if (0 != controllers)
1336 gEve->GetBrowser()->MapWindow();
1345 Float_t sec = val*0.001;
1397 gEve->FullRedraw3D();
1437 const Int_t
x = 100,
y = 100;
1439 TGMainFrame *mf1 =
new TGMainFrame(0, 0, 0);
1445 TGMainFrame *mf2 =
new TGMainFrame(0, 0, 0);
1447 while (!mf2->IsMapped()) gClient->HandleInput();
1453 WindowAttributes_t
attr;
1454 gVirtualX->TranslateCoordinates(mf1->GetId(), gClient->GetDefaultRoot()->GetId(),
1455 0, 0, xm, ym, childdum);
1456 gVirtualX->GetWindowAttributes(mf1->GetId(),
attr);
1460 fwLog(
fwlog::kDebug) << Form(
"FWGUIManager::measureWMOffsets: required (%d,%d), measured(%d, %d) => dx=%d, dy=%d; decor_h=%d.\n",
const std::string sKeyboardShort
TGVerticalFrame * createList(TGCompositeFrame *p)
const std::set< FWModelId > & selected() const
TEveWindow * getEveWindow()
TGMainFrame * undockedMainFrame
void swap(ora::Record &rh, ora::Record &lh)
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
FWNumberEntryField * m_lumiEntry
sigc::signal< void > writeToPresentConfigurationFile_
TGCompositeFrame * widget() const
void bindCSGActionKeys(const TGMainFrame *f) const
ViewMap_t::iterator ViewMap_i
const std::string sShowCommonInsp
sigc::signal< void > filterButtonClicked_
virtual ULong64_t GetULong64Number()
virtual void SetUIntNumber(UInt_t n)
sigc::signal< void, FWGUISubviewArea * > unselected_
const KeyValues * keyValues() const
NameToViewBuilder m_nameToViewBuilder
void loadEvent(const edm::EventBase &event)
const FWEventItemsManager * eventItemsManager() const
CSGContinuousAction * playEventsBackwardsAction() const
void subviewIsBeingDestroyed(FWGUISubviewArea *)
FWSummaryManager * m_summaryManager
void subviewInfoSelected(FWGUISubviewArea *)
void setFilterButtonIcon(int)
void createViews(TEveWindowSlot *slot)
FWInvMassDialog * m_invMassDialog
void setViewPopup(TEveWindow *)
RunNumber_t const invalidRunNumber
const std::string & name() const
static void addAreaInfoTo(areaInfo &pInfo, FWConfiguration &oTo)
const std::string sBackgroundColor
static const std::string kViewController("view")
FWColorManager * colorManager() const
sigc::signal< void > activated
static void addWindowInfoTo(const TGFrame *iMain, FWConfiguration &oTo)
const std::string & typeName() const
void newViewSlot(const std::string &iName)
void populate3DViewsFromConfig()
void addTo(FWConfiguration &) const
unsigned int version() const
static FWGUIManager * m_guiManager
FWCustomIconsButton * m_filterEnableBtn
CSGContinuousAction * loopAction() const
void enableNext(bool enable=true)
static const std::string kViews("views")
void delaySliderChanged(Int_t)
static const std::string kObjectController("object")
void updateStatus(const char *status)
FWDetailViewManager * m_detailViewManager
FWIntValueListener * m_delaySliderListener
TEveWindowPack * m_viewPrimPack
void showEDIFrame(int iInfoToShow=-1)
Allowed values are -1 or ones from FWDataCategories enum.
static const std::string kCommonController("common")
const std::string sSaveConfigAs
boost::function2< FWViewBase *, TEveWindowSlot *, const std::string & > ViewBuildFunctor
unsigned int version() const
void setInfoButton(bool downp)
void enableActions(bool enable=true)
std::auto_ptr< CmsShowTaskExecutor > m_tasks
TEveWindowPack * m_viewSecPack
void setWindowInfoFrom(const FWConfiguration &iFrom, TGMainFrame *iFrame)
void registerViewBuilder(const std::string &iName, ViewBuildFunctor &iBuilder)
void checkSubviewAreaIconState(TEveWindow *)
void connectSubviewAreaSignals(FWGUISubviewArea *)
void createShortcutPopup()
const std::string sSaveConfig
static const std::string kCollectionController("collection")
CmsShowViewPopup * m_viewPopup
EventNumber_t const invalidEventNumber
const TGPicture * m_filterIcons[9]
sigc::signal< void, Float_t > changedDelayBetweenEvents_
TEveWindow * getSwapCandidate()
static const std::string kMainWindow("main window")
virtual void SetULong64Number(ULong64_t n)
sigc::signal< void > colorsHaveChangedFinished_
static TGFrame * makeGUIsubview(TEveCompositeFrame *cp, TGCompositeFrame *parent, Int_t height)
FWNavigatorBase * m_navigator
static const std::string kUndocked("undocked views")
sigc::signal< void, const TGWindow * > showEventFilterGUI_
void setDelayBetweenEvents(Float_t)
CSGAction * createNewViewerAction(const std::string &iActionName, bool seaprator)
void exportImagesOfAllViews()
TEveWindow * originalSlot
void subviewDestroy(FWGUISubviewArea *)
FWNumberEntryField * m_eventEntry
sigc::signal< void, FWGUISubviewArea * > goingToBeDestroyed_
CmsShowMainFrame * m_cmsShowMainFrame
sigc::signal< void, Int_t > valueChanged_
sigc::signal< void, FWEventItem * > newItem_
static FWGUISubviewArea * getToolBarFromWindow(TEveWindow *)
void newItem(const FWEventItem *)
void updateStatusBar(const char *status)
virtual UInt_t GetUIntNumber()
void filterButtonClicked()
const std::string sShowAddCollection
FWGUIEventDataAdder * m_dataAdder
void exportImageOfMainView()
virtual FWViewContextMenuHandlerBase * contextMenuHandler() const
const std::string sExportImage
FWSelectionManager * selectionManager() const
CmsShowModelPopup * m_modelPopup
static const std::string kViewArea("view area")
CmsShowCommonPopup * m_commonPopup
virtual const edm::EventBase * getCurrentEvent() const =0
static const std::string & checkNameWithViewVersion(const std::string &name, unsigned int viewVersion)
FWModelChangeManager * modelChangeManager() const
CmsShowHelpPopup * m_helpGLPopup
LuminosityBlockNumber_t const invalidLuminosityBlockNumber
const std::string sShowMainViewCtl
void setFrom(const FWConfiguration &)
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
void eventChangedCallback()
FWNumberEntryField * m_runEntry
const std::string & value(unsigned int iIndex=0) const
CSGAction * getAction(const std::string &name)
const edm::EventBase * getCurrentEvent() const
virtual void enableActions(bool enable=true)
ViewMap_i createView(const std::string &iName, TEveWindowSlot *slot=0)
void showSelectedModelContext(Int_t iX, Int_t iY, FWViewContextMenuHandlerBase *) const
NOTE: iX and iY are in global coordinates.
const std::string sShowObjInsp
CSGAction * getAction(const std::string name)
void updateEventFilterEnable(bool)
static FWGUIManager * getGUIManager()
CSGContinuousAction * loopAction()
fireworks::Context * m_context
FWJobMetadataManager * metadataManager() const
bool promptForConfigurationFile(std::string &result, enum EFileDialogMode mode)
CSGContinuousAction * playEventsBackwardsAction()
void finishUpColorChange()
void exportAllViews(const std::string &format, int height)
sigc::signal< void, FWGUISubviewArea * > swap_
void setFilterButtonText(const char *txt)
const std::string sShowInvMassDialog
CmsShowCommon * commonPrefs() const
sigc::signal< void, const std::string & > writeToConfigurationFile_
KeyValues::const_iterator KeyValuesIt
void setSummaryViewWeight(float)
const std::string sShowEventDisplayInsp
CSGContinuousAction * playEventsAction()
void enablePrevious(bool enable=true)
void subviewSwapped(FWGUISubviewArea *)
float getSummaryViewWeight() const
boost::function0< void > TaskFunctor
FWGUIManager(fireworks::Context *ctx, const FWViewManagerManager *iVMMgr, FWNavigatorBase *navigator)
void showEventFilterGUI()
static const std::string & idToName(int)
void subviewInfoUnselected(FWGUISubviewArea *)
void promptForSaveConfigurationFile()
const std::string sLoadConfig
void showSelectedModelContextMenu(Int_t iGlobalX, Int_t iGlobalY, FWViewContextMenuHandlerBase *iHandler)
const FWConfiguration * valueForKey(const std::string &iKey) const
const std::string sExportAllImages
volatile std::atomic< bool > shutdown_flag false
sigc::signal< void, const std::string & > loadFromConfigurationFile_
sigc::signal< void, FWGUISubviewArea * > selected_
TGTextButton * m_filterShowGUIBtn
areaInfo(TGFrameElementPack *frameElement)
void titleChanged(const char *title)
const std::string sHelpGL
void promptForLoadConfigurationFile()
FWModelContextMenuHandler * m_contextMenuHandler
void setPlayDelayGUI(Float_t val, Bool_t sliderChanged)
CSGContinuousAction * playEventsAction() const
sigc::signal< void, edm::RunNumber_t, edm::LuminosityBlockNumber_t, edm::EventNumber_t > changedEventId_
sigc::signal< void, Int_t, Int_t > openSelectedModelContextMenu_
static const std::string kControllers("controllers")
void show(FWDataCategories)
CmsShowHelpPopup * m_helpPopup
void openEveBrowserForDebugging() const
virtual void addTo(FWConfiguration &) const
CmsShowHelpPopup * m_shortcutPopup