16 #include <boost/bind.hpp>
26 #include "TGLIncludes.h"
27 #include "TGLViewer.h"
28 #include "TEveBrowser.h"
29 #include "TEveManager.h"
31 #include "TEveWindow.h"
32 #include "TEveViewer.h"
33 #include "TEveWindowManager.h"
34 #include "TEveSelection.h"
35 #include "TVirtualX.h"
102 m_detailViewManager(0),
103 m_viewManagerManager(iVMMgr),
104 m_contextMenuHandler(0),
105 m_navigator(navigator),
116 m_WMOffsetX(0), m_WMOffsetY(0), m_WMDecorH(0)
129 TEveCompositeFrame::SetupFrameMarkup(foo, 20, 4,
false);
134 UInt_t
width = gClient->GetDisplayWidth();
135 UInt_t height =
static_cast<UInt_t
>(gClient->GetDisplayHeight()*.8);
139 while(width > 2000) {
142 width =
static_cast<UInt_t
>(width*.8);
197 TQObject::Connect(gEve->GetWindowManager(),
"WindowSelected(TEveWindow*)",
"FWGUIManager",
this,
"checkSubviewAreaIconState(TEveWindow*)");
198 TQObject::Connect(gEve->GetWindowManager(),
"WindowDocked(TEveWindow*)" ,
"FWGUIManager",
this,
"checkSubviewAreaIconState(TEveWindow*)");
199 TQObject::Connect(gEve->GetWindowManager(),
"WindowUndocked(TEveWindow*)",
"FWGUIManager",
this,
"checkSubviewAreaIconState(TEveWindow*)");
229 gEve->GetWindowManager()->Disconnect(
"WindowSelected(TEveWindow*)",
this,
"checkSubviewAreaIconState(TEveWindow*)");
230 gEve->GetWindowManager()->Disconnect(
"WindowDocked(TEveWindow*)",
this,
"checkSubviewAreaIconState(TEveWindow*)");
231 gEve->GetWindowManager()->Disconnect(
"WindowUndocked(TEveWindow*)",
this,
"checkSubviewAreaIconState(TEveWindow*)");
234 gEve->GetSelection()->Disconnect();
235 gEve->GetHighlight()->Disconnect();
236 gEve->GetSelection()->RemoveElements();
237 gEve->GetHighlight()->RemoveElements();
242 TEveCompositeFrameInMainFrame* mainFrame =
dynamic_cast<TEveCompositeFrameInMainFrame*
>((*wIt).first->GetEveFrame());
244 if (mainFrame) mainFrame->UnmapWindow();
246 (*wIt).second->destroy();
282 throw std::runtime_error(
std::string(
"Unable to create view named ")+iName+
" because it is unknown");
298 TEveCompositeFrame *ef = slot->GetEveFrame();
299 FWViewBase* viewBase = itFind->second(slot, iName);
304 TEveWindow *eveWindow = ef->GetEveWindow();
305 eveWindow->SetElementName(iName.c_str());
307 std::pair<ViewMap_i,bool> insertPair =
m_viewMap.insert(std::make_pair(eveWindow, viewBase));
308 return insertPair.first;
326 snprintf(title,127,
"cmsShow: %s", subtitle);
334 TEveViewerList* viewers = gEve->GetViewers();
335 for (TEveElement::List_i
i=viewers->BeginChildren();
i!= viewers->EndChildren(); ++
i)
337 TEveViewer*
ev =
dynamic_cast<TEveViewer*
>(*i);
339 ev->GetGLViewer()->DeleteOverlayAnnotations();
403 #if defined(THIS_WILL_NEVER_BE_DEFINED)
404 m_selectionItemsComboBox->AddEntry(iItem->
name().c_str(),iItem->
id());
406 m_selectionItemsComboBox->Select(0);
430 TEveWindow* swapCandidate =0;
432 if ( gEve->GetWindowManager()->GetCurrentWindow())
434 swapCandidate = gEve->GetWindowManager()->GetCurrentWindow();
439 TEveCompositeFrame* pef;
440 TGFrameElementPack *pel;
444 if ( pp->GetList()->GetSize() > 2)
446 pel = (TGFrameElementPack*) pp->GetList()->At(1);
449 pef =
dynamic_cast<TEveCompositeFrame*
>(pel->fFrame);
450 if ( pef && pef->GetEveWindow())
451 swapCandidate = pef->GetEveWindow();
454 if (swapCandidate == 0)
458 TIter frame_iterator(sp->GetList());
459 while ((pel = (TGFrameElementPack*)frame_iterator()))
461 pef =
dynamic_cast<TEveCompositeFrame*
>(pel->fFrame);
462 if ( pef && pef->GetEveWindow() && pel->fState)
464 swapCandidate = pef->GetEveWindow() ;
470 return swapCandidate;
488 if (checkInfoBtn && selected)
517 std::vector<FWGUISubviewArea*>
sd;
524 for (std::vector<FWGUISubviewArea*>::iterator
i= sd.begin();
i !=sd.end(); ++
i)
526 if ((*i)->isSelected())
531 gSystem->ProcessEvents();
538 TEveWindow*
w =
dynamic_cast<TEveWindow*
>(
m_viewPrimPack->FirstChild());
539 if (w) w->DestroyWindowAndSlot();
544 gSystem->ProcessEvents();
555 if (wIt->first != ew)
572 if (curr) swap->SwapWindow(curr);
580 TGVerticalFrame *listFrame =
new TGVerticalFrame(p, p->GetWidth(), p->GetHeight());
582 TGHorizontalFrame* addFrame =
new TGHorizontalFrame(listFrame, p->GetWidth(), 10, kRaisedFrame);
583 TGLabel* addLabel =
new TGLabel(addFrame,
"Summary View");
584 addFrame->AddFrame(addLabel,
new TGLayoutHints(kLHintsCenterX, 0,0,2,2));
585 listFrame->AddFrame(addFrame,
new TGLayoutHints(kLHintsExpandX | kLHintsTop));
594 const unsigned int backgroundColor=0x2f2f2f;
596 addDataButton->ChangeOptions(kRaisedFrame);
597 addDataButton->SetBackgroundColor(backgroundColor);
598 addDataButton->SetTextColor(0xFFFFFF);
599 addDataButton->SetToolTipText(
"Show additional collections");
600 addDataButton->Connect(
"Clicked()",
"FWGUIManager",
this,
"addData()");
601 m_summaryManager->
widget()->AddFrame(addDataButton,
new TGLayoutHints(kLHintsExpandX|kLHintsLeft|kLHintsTop));
623 m_ediFrame->CenterOnParent(kTRUE,TGTransientFrame::kTopRight);
654 m_modelPopup->CenterOnParent(kTRUE,TGTransientFrame::kRight);
718 m_helpPopup->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
746 m_helpGLPopup->CenterOnParent(kTRUE,TGTransientFrame::kBottomRight);
788 const static char* kFileTypes[] = {
"Fireworks Configuration files",
"*.fwc",
792 static TString
dir(
".");
795 fi.fFileTypes = kFileTypes;
796 fi.fIniDir = StrDup(dir);
799 if (fi.fFilename == 0)
803 std::string ext = kFileTypes[fi.fFileTypeIdx + 1] + 1;
804 if (ext.size() != 0 && name.find(ext) == name.npos)
842 TGFrameElementPack* frameEL = (TGFrameElementPack*)
m_viewPrimPack->GetPack()->GetList()->At(1);
843 TEveCompositeFrame* ef =
dynamic_cast<TEveCompositeFrame*
>(frameEL->fFrame);
856 static TString
dir(
".");
857 const char * kImageExportTypes[] = {
"PNG",
"*.png",
861 "Encapsulated PostScript",
"*.eps",
865 fi.fFileTypes = kImageExportTypes;
866 fi.fIniDir = StrDup(dir);
870 if (fi.fFilename != 0) {
875 std::string ext = kImageExportTypes[fi.fFileTypeIdx + 1] + 1;
876 if (name.find(ext) == name.npos)
879 name.insert(name.rfind(
'.'),
"-%u_%u_%u_%s");
883 catch (std::runtime_error &
e) {
std::cout << e.what() << std::endl; }
896 typedef std::list<FWTEveViewer*> viewer_list_t;
897 typedef viewer_list_t::iterator viewer_list_i;
899 typedef std::map<TString, viewer_list_t> name_map_t;
900 typedef name_map_t::iterator name_map_i;
909 TString
name(ev->GetElementName());
910 name.ReplaceAll(
" ",
"");
911 viewer_list_t &
l = vls[
name];
912 viewer_list_i li = l.begin();
913 while (li != l.end() && (*li)->GetGLViewer()->ViewportDiagonal() < ev->GetGLViewer()->ViewportDiagonal())
919 std::vector<std::thread> workers;
921 for (name_map_i
i = vls.begin();
i != vls.end(); ++
i)
923 bool multi_p = (
i->second.size() > 1);
925 for (viewer_list_i
j =
i->second.begin();
j !=
i->second.end(); ++
j, ++view_count)
927 TString view_name(
i->first);
931 view_name += view_count;
934 file.Form(format.c_str(),
event->id().run(),
event->id().event(),
935 event->luminosityBlock(), view_name.Data());
937 if (GLEW_EXT_framebuffer_object)
940 workers.push_back((*j)->CaptureAndSaveImage(file, height));
946 (*j)->GetGLViewer()->SavePicture(file);
948 (*j)->GetGLViewer()->SavePictureHeight(file, height);
953 for (
auto &
w : workers)
976 gVirtualX->TranslateCoordinates(iMain->GetId(),
977 gClient->GetDefaultRoot()->GetId(),
993 s<<iMain->GetWidth();
998 s<<iMain->GetHeight();
1012 weight = frameElement->fWeight;
1015 TEveCompositeFrame *eveFrame =
dynamic_cast<TEveCompositeFrame*
>(frameElement->fFrame);
1018 if (frameElement->fState)
1039 std::stringstream
s;
1044 std::stringstream
s;
1064 float leftWeight, rightWeight;
1069 std::stringstream
ss;
1077 TGFrameElementPack *frameEL;
1078 frameEL = (TGFrameElementPack*)
m_viewPrimPack->GetPack()->GetList()->At(1);
1079 leftWeight = frameEL->fWeight;
1080 frameEL = (TGFrameElementPack*)
m_viewPrimPack->GetPack()->GetList()->At(3);
1081 rightWeight = frameEL->fWeight;
1088 std::stringstream sL;
1091 std::stringstream sR;
1099 std::vector<areaInfo> wpacked;
1103 TGFrameElementPack *frameEL = (TGFrameElementPack*) pp->GetList()->At(1);
1104 if (frameEL->fWeight > 0)
1105 wpacked.push_back(
areaInfo(frameEL));
1108 TGFrameElementPack *seFE;
1109 TIter frame_iterator(sp->GetList());
1110 while ((seFE = (TGFrameElementPack*)frame_iterator() ))
1120 TEveWindow* ew = wIt->first;
1121 TEveCompositeFrameInMainFrame* mainFrame =
dynamic_cast<TEveCompositeFrameInMainFrame*
>(ew->GetEveFrame());
1124 for(std::vector<areaInfo>::iterator pIt = wpacked.begin(); pIt != wpacked.end(); ++pIt)
1126 if ((*pIt).originalSlot && mainFrame->GetOriginalSlot() == (*pIt).originalSlot)
1128 (*pIt).eveWindow = wIt->first;
1129 (*pIt).undockedMainFrame = (TGMainFrame*)mainFrame;
1141 for(std::vector<areaInfo>::iterator it = wpacked.begin(); it != wpacked.end(); ++it)
1143 TEveWindow* ew = (*it).eveWindow;
1147 wb->
addTo(tempWiew);
1188 TGMainFrame* iFrame)
1195 iFrame->MoveResize(x,y,width,height);
1196 iFrame->SetWMPosition(x, y);
1215 float_t leftWeight =1;
1216 float_t rightWeight=1;
1223 float summaryWeight = atof(mw->
valueForKey(
"summaryWeight")->
value().c_str());
1227 TEveWindowSlot* primSlot = (leftWeight > 0) ?
m_viewPrimPack->NewSlotWithWeight(leftWeight) : 0;
1245 float weight = atof((areaIt->second).valueForKey(
"weight")->value().c_str());
1246 TEveWindowSlot* slot = (
m_viewMap.size() || (primSlot == 0) ) ?
m_viewSecPack->NewSlotWithWeight(weight) : primSlot;
1249 lastViewIt->second->setFrom(it->second);
1251 bool undocked = atof((areaIt->second).valueForKey(
"undocked")->value().c_str());
1254 TEveWindow* lastWindow = lastViewIt->first;
1255 lastWindow->UndockWindow();
1256 TEveCompositeFrameInMainFrame* emf =
dynamic_cast<TEveCompositeFrameInMainFrame*
>(lastWindow->GetEveFrame());
1258 const TGMainFrame* mf =
dynamic_cast<const TGMainFrame*
>(emf->GetParent());
1261 TGMainFrame* mfp = (TGMainFrame*)mf;
1262 const FWConfiguration* mwc = (areaIt->second).valueForKey(
"UndockedWindowPos");
1277 lastViewIt->second->setFrom(it->second);
1282 fwLog(
fwlog::kWarning) <<
"Restrore of undocked windows with old window management not supported." << std::endl;
1288 if (0 != controllers)
1334 gEve->GetBrowser()->MapWindow();
1343 Float_t sec = val*0.001;
1395 gEve->FullRedraw3D();
1435 const Int_t
x = 100,
y = 100;
1437 TGMainFrame *mf1 =
new TGMainFrame(0, 0, 0);
1443 TGMainFrame *mf2 =
new TGMainFrame(0, 0, 0);
1445 while (!mf2->IsMapped()) gClient->HandleInput();
1451 WindowAttributes_t
attr;
1452 gVirtualX->TranslateCoordinates(mf1->GetId(), gClient->GetDefaultRoot()->GetId(),
1453 0, 0, xm, ym, childdum);
1454 gVirtualX->GetWindowAttributes(mf1->GetId(),
attr);
1458 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