Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize creation of images for Online operation at P5 #7660

Merged
merged 6 commits into from Feb 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Fireworks/Core/BuildFile.xml
Expand Up @@ -32,6 +32,7 @@
<lib name="GuiHtml"/>
<lib name="GX11"/>
<lib name="RGL"/>
<lib name="GLEW"/>
<export>
<lib name="1"/>
</export>
20 changes: 12 additions & 8 deletions Fireworks/Core/interface/FWEveView.h
Expand Up @@ -34,6 +34,9 @@ class TEveScene;
class TEveWindowSlot;
class TEveCaloViz;

class FWTGLViewer;
class FWTEveViewer;

class FWEventAnnotation;
class CmsAnnotation;
class FWViewContextMenuHandlerGL;
Expand Down Expand Up @@ -70,10 +73,14 @@ class FWEveView : public FWViewBase
virtual void saveImageTo(const std::string& iName) const;
virtual void populateController(ViewerParameterGUI&) const;

TGLViewer* viewerGL() const;
TEveViewer* viewer() { return m_viewer; }
TEveScene* eventScene() { return m_eventScene;}
TEveScene* geoScene() { return m_geoScene; }
TGLViewer* viewerGL() const;
TEveViewer* viewer();

FWTGLViewer* fwViewerGL() const;
FWTEveViewer* fwViewer() { return m_viewer; }

TEveScene* eventScene() { return m_eventScene;}
TEveScene* geoScene() { return m_geoScene; }

TEveElement* ownedProducts() { return m_ownedProducts; }
FWViewContext* viewContext() { return m_viewContext.get(); }
Expand Down Expand Up @@ -110,7 +117,7 @@ class FWEveView : public FWViewBase

// ---------- member data --------------------------------

TEveViewer* m_viewer;
FWTEveViewer* m_viewer;
TEveScene* m_eventScene;
TEveElement* m_ownedProducts;
TEveScene* m_geoScene;
Expand All @@ -120,9 +127,6 @@ class FWEveView : public FWViewBase
ScaleAnnotation* m_energyMaxValAnnotation;
TGLCameraGuide* m_cameraGuide;




private:
// style parameters
#if ROOT_VERSION_CODE >= ROOT_VERSION(5,26,0)
Expand Down
68 changes: 68 additions & 0 deletions Fireworks/Core/interface/FWTEveViewer.h
@@ -0,0 +1,68 @@
#ifndef Subsystem_Package_FWTEveViewer_h
#define Subsystem_Package_FWTEveViewer_h
// -*- C++ -*-
//
// Package: Subsystem/Package
// Class : FWTEveViewer
//
/**\class FWTEveViewer FWTEveViewer.h "FWTEveViewer.h"

Description: [one line class summary]

Usage:
<usage>

*/
//
// Original Author:
// Created: Tue, 03 Feb 2015 21:46:04 GMT
//

// system include files

#include <thread>


// user include files

#include "TEveViewer.h"

// forward declarations

class FWTGLViewer;


class FWTEveViewer : public TEveViewer
{

public:
FWTEveViewer(const char* n="FWTEveViewer", const char* t="");
virtual ~FWTEveViewer();

// ---------- const member functions ---------------------

// ---------- static member functions --------------------

static bool SavePng(const TString& file, UChar_t* xx, int ww, int hh);
static bool SaveJpg(const TString& file, UChar_t* xx, int ww, int hh);

// ---------- member functions ---------------------------

FWTGLViewer* fwGlViewer() { return m_fwGlViewer; }

FWTGLViewer* SpawnFWTGLViewer();

std::thread CaptureAndSaveImage(const TString& file, int height=-1);

private:
FWTEveViewer(const FWTEveViewer&); // stop default

const FWTEveViewer& operator=(const FWTEveViewer&); // stop default

// ---------- member data --------------------------------

FWTGLViewer *m_fwGlViewer;
};


#endif
65 changes: 65 additions & 0 deletions Fireworks/Core/interface/FWTGLViewer.h
@@ -0,0 +1,65 @@
#ifndef Subsystem_Package_FWTGLViewer_h
#define Subsystem_Package_FWTGLViewer_h
// -*- C++ -*-
//
// Package: Subsystem/Package
// Class : FWTGLViewer
//
/**\class FWTGLViewer FWTGLViewer.h "FWTGLViewer.h"

Description: [one line class summary]

Usage:
<usage>

*/
//
// Original Author:
// Created: Tue, 03 Feb 2015 21:45:22 GMT
//

// system include files

// user include files

#include "TGLEmbeddedViewer.h"

// forward declarations

class TGWindow;
class TGLFBO;

class FWTGLViewer : public TGLEmbeddedViewer
{

public:
FWTGLViewer(const TGWindow *parent);
virtual ~FWTGLViewer();

// ---------- const member functions ---------------------

// ---------- static member functions --------------------

// ---------- member functions ---------------------------

void DrawHiLod(Bool_t swap_buffers);
void JustSwap();

TGLFBO* MakeFbo();
TGLFBO* MakeFboWidth (Int_t width, Bool_t pixel_object_scale=kTRUE);
TGLFBO* MakeFboHeight(Int_t height, Bool_t pixel_object_scale=kTRUE);
TGLFBO* MakeFboScale (Float_t scale, Bool_t pixel_object_scale=kTRUE);

TGLFBO* GenerateFbo(Int_t w, Int_t h, Float_t pixel_object_scale);

private:
FWTGLViewer(const FWTGLViewer&); // stop default

const FWTGLViewer& operator=(const FWTGLViewer&); // stop default

// ---------- member data --------------------------------

};


#endif
24 changes: 18 additions & 6 deletions Fireworks/Core/src/CmsShowMain.cc
Expand Up @@ -101,7 +101,8 @@ static const char* const kLiveCommandOpt = "live";
static const char* const kFieldCommandOpt = "field";
static const char* const kFreePaletteCommandOpt = "free-palette";
static const char* const kAutoSaveAllViews = "auto-save-all-views";
static const char* const kAutoSaveHeight = "auto-save-height";
static const char* const kAutoSaveType = "auto-save-type";
static const char* const kAutoSaveHeight = "auto-save-height";
static const char* const kEnableFPE = "enable-fpe";
static const char* const kZeroWinOffsets = "zero-window-offsets";
static const char* const kNoVersionCheck = "no-version-check";
Expand Down Expand Up @@ -167,9 +168,10 @@ CmsShowMain::CmsShowMain(int argc, char *argv[])
(kPortCommandOpt, po::value<unsigned int>(), "Listen to port for new data files to open")
(kLoopCommandOpt, "Loop events in play mode")
(kChainCommandOpt, po::value<unsigned int>(), "Chain up to a given number of recently open files. Default is 1 - no chain")
(kLiveCommandOpt, "Enforce playback mode if a user is not using display")
(kAutoSaveAllViews, po::value<std::string>(), "Auto-save all views with given prefix (run_event_lumi_view.png is appended)")
(kAutoSaveHeight, po::value<int>(), "Screenshots height when auto-save-all-views is enabled");
(kLiveCommandOpt, "Enforce playback mode if a user is not using display")
(kAutoSaveAllViews, po::value<std::string>(), "Auto-save all views with given prefix (run_event_lumi_view.<auto-save-type> is appended)")
(kAutoSaveType, po::value<std::string>(), "Image type of auto-saved views, png or jpg (png is default)")
(kAutoSaveHeight, po::value<int>(), "Screenshots height when auto-save-all-views is enabled");

po::options_description debugdesc("Debug");
debugdesc.add_options()
Expand Down Expand Up @@ -250,7 +252,7 @@ CmsShowMain::CmsShowMain(int argc, char *argv[])
if (access(configFilename(), R_OK) == -1)
{
fwLog(fwlog::kError) << "Specified configuration file does not exist. Quitting.\n";
exit(0);
exit(1);
}
} else {
if (vm.count(kNoConfigFileOpt)) {
Expand Down Expand Up @@ -347,8 +349,18 @@ CmsShowMain::CmsShowMain(int argc, char *argv[])
m_context->getField()->setUserField(vm[kFieldCommandOpt].as<double>());
}
if(vm.count(kAutoSaveAllViews)) {
std::string type = "png";
if(vm.count(kAutoSaveType)) {
type = vm[kAutoSaveType].as<std::string>();
if (type != "png" && type != "jpg")
{
fwLog(fwlog::kError) << "Specified auto-save type not supported. Quitting.\n";
exit(1);
}
}
std::string fmt = vm[kAutoSaveAllViews].as<std::string>();
fmt += "%u_%u_%llu_%s.png";
fmt += "%u_%u_%llu_%s.";
fmt += type;
setAutoSaveAllViewsFormat(fmt);
}
if (vm.count(kAutoSaveHeight)) {
Expand Down
25 changes: 17 additions & 8 deletions Fireworks/Core/src/FWEveView.cc
Expand Up @@ -26,7 +26,6 @@
#include "TGLCameraGuide.h"

#include "TGLEmbeddedViewer.h"
#include "TEveViewer.h"
#include "TGLScenePad.h"
#include "TEveManager.h"
#include "TEveElement.h"
Expand All @@ -37,6 +36,9 @@
#undef protected
#include "TGLOverlay.h"

#include "Fireworks/Core/interface/FWTEveViewer.h"
#include "Fireworks/Core/interface/FWTGLViewer.h"

#include "Fireworks/Core/interface/FWEveView.h"
#include "Fireworks/Core/interface/FWViewType.h"
#include "Fireworks/Core/interface/CmsShowViewPopup.h"
Expand Down Expand Up @@ -105,14 +107,9 @@ FWEveView::FWEveView(TEveWindowSlot* iParent, FWViewType::EType type, unsigned i
m_localEnergyScale( new FWViewEnergyScale(FWViewType::idToName(type), version)),
m_viewEnergyScaleEditor(0)
{
m_viewer = new TEveViewer(typeName().c_str());
m_viewer = new FWTEveViewer(typeName().c_str());

TGLEmbeddedViewer* embeddedViewer;
#if ROOT_VERSION_CODE >= ROOT_VERSION(5,25,4)
embeddedViewer = m_viewer->SpawnGLEmbeddedViewer(0);
#else
embeddedViewer = m_viewer->SpawnGLEmbeddedViewer();
#endif
FWTGLViewer *embeddedViewer = m_viewer->SpawnFWTGLViewer();
iParent->ReplaceWindow(m_viewer);
gEve->GetViewers()->AddElement(m_viewer);

Expand Down Expand Up @@ -199,6 +196,18 @@ FWEveView::viewerGL() const
return m_viewer->GetGLViewer();
}

TEveViewer*
FWEveView::viewer()
{
return m_viewer;
}

FWTGLViewer*
FWEveView::fwViewerGL() const
{
return m_viewer->fwGlViewer();
}

void
FWEveView::saveImageTo(const std::string& iName) const
{
Expand Down