#include "FWTEveViewer.h"
|
static bool | SaveJpg (const TString &file, UChar_t *xx, int ww, int hh) |
|
static bool | SavePng (const TString &file, UChar_t *xx, int ww, int hh) |
|
Description: [one line class summary]
Usage: <usage>
Definition at line 36 of file FWTEveViewer.h.
◆ FWTEveViewer() [1/2]
FWTEveViewer::FWTEveViewer |
( |
const char * |
n = "FWTEveViewer" , |
|
|
const char * |
t = "" |
|
) |
| |
◆ ~FWTEveViewer()
FWTEveViewer::~FWTEveViewer |
( |
| ) |
|
|
override |
◆ FWTEveViewer() [2/2]
◆ CaptureAndSaveImage()
std::future< int > FWTEveViewer::CaptureAndSaveImage |
( |
const TString & |
file, |
|
|
int |
height = -1 |
|
) |
| |
Definition at line 125 of file FWTEveViewer.cc.
126 static const TString eh(
"FWTEveViewer::CaptureAndSaveImage");
128 TGLFBO* fbo =
nullptr;
134 if (fbo ==
nullptr) {
135 ::Error(eh,
"Returned FBO is 0.");
136 m_prom = std::promise<int>();
138 return m_prom.get_future();
142 if (fbo->GetIsRescaled()) {
143 ww = TMath::Nint(fbo->GetW() * fbo->GetWScale());
144 hh = TMath::Nint(fbo->GetH() * fbo->GetHScale());
150 fbo->SetAsReadBuffer();
152 size_t bufsize = 3 * ww * hh;
157 glPixelStorei(GL_PACK_ALIGNMENT, 1);
158 glReadPixels(0, 0, ww, hh, GL_RGB, GL_UNSIGNED_BYTE, &
m_imgBuffer[0]);
160 if (
m_thr ==
nullptr)
164 std::unique_lock<std::mutex> lk(
m_moo);
166 m_prom = std::promise<int>();
174 return m_prom.get_future();
References FrontierConditions_GlobalTag_cff::file, m_cnd, m_fwGlViewer, m_hh, m_imgBuffer, m_moo, m_name, m_prom, m_thr, m_ww, FWTGLViewer::MakeFbo(), FWTGLViewer::MakeFboHeight(), and spawn_image_thread().
◆ fwGlViewer()
◆ operator=()
◆ SaveJpg()
bool FWTEveViewer::SaveJpg |
( |
const TString & |
file, |
|
|
UChar_t * |
xx, |
|
|
int |
ww, |
|
|
int |
hh |
|
) |
| |
|
static |
Definition at line 270 of file FWTEveViewer.cc.
271 struct jpeg_compress_struct JpegInfo;
272 struct jpeg_error_mgr
Error;
274 JpegInfo.err = jpeg_std_error(&
Error);
277 jpeg_create_compress(&JpegInfo);
279 FILE*
fp = fopen(
file,
"w");
280 jpeg_stdio_dest(&JpegInfo,
fp);
282 JpegInfo.image_width = ww;
283 JpegInfo.image_height = hh;
284 JpegInfo.input_components = 3;
285 JpegInfo.in_color_space = JCS_RGB;
287 jpeg_set_defaults(&JpegInfo);
289 JpegInfo.write_JFIF_header =
TRUE;
295 jpeg_start_compress(&JpegInfo,
TRUE);
297 std::vector<UChar_t*>
rows(hh);
300 for (
int i = 0;
i < hh;
i++,
j--) {
305 jpeg_write_scanlines(&JpegInfo, &
rows[0], hh);
308 jpeg_finish_compress(&JpegInfo);
313 jpeg_destroy_compress(&JpegInfo);
References FrontierConditions_GlobalTag_cff::file, personalPlayback::fp, mps_fire::i, dqmiolumiharvest::j, postprocess-scan-build::rows, TRUE, and geometryCSVtoXML::xx.
Referenced by spawn_image_thread().
◆ SavePng()
bool FWTEveViewer::SavePng |
( |
const TString & |
file, |
|
|
UChar_t * |
xx, |
|
|
int |
ww, |
|
|
int |
hh |
|
) |
| |
|
static |
Definition at line 185 of file FWTEveViewer.cc.
195 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
nullptr,
nullptr,
nullptr);
196 if (png_ptr ==
nullptr) {
197 printf(
"Error creating png write struct\n");
202 info_ptr = png_create_info_struct(png_ptr);
203 if (info_ptr ==
nullptr) {
204 printf(
"Error creating png info struct\n");
205 png_destroy_write_struct(&png_ptr, &info_ptr);
218 FILE*
fp = fopen(
file,
"w");
220 png_init_io(png_ptr,
fp);
223 png_set_IHDR(png_ptr,
230 PNG_COMPRESSION_TYPE_BASE,
231 PNG_FILTER_TYPE_BASE);
246 png_write_info(png_ptr, info_ptr);
248 std::vector<UChar_t*>
rows(hh);
251 for (
int i = 0;
i < hh;
i++,
j--) {
257 png_write_image(png_ptr, &
rows[0]);
260 png_write_end(png_ptr, info_ptr);
263 png_destroy_write_struct(&png_ptr, &info_ptr);
References FrontierConditions_GlobalTag_cff::file, personalPlayback::fp, mps_fire::i, dqmiolumiharvest::j, postprocess-scan-build::rows, and geometryCSVtoXML::xx.
Referenced by spawn_image_thread().
◆ spawn_image_thread()
void FWTEveViewer::spawn_image_thread |
( |
| ) |
|
|
private |
Definition at line 77 of file FWTEveViewer.cc.
78 std::unique_lock<std::mutex> lko(
m_moo);
80 m_thr =
new std::thread([=]() {
82 std::unique_lock<std::mutex> lk(
m_moo);
87 std::unique_lock<std::mutex> lk(
m_moo);
94 if (
m_name.EndsWith(
".jpg")) {
References m_cnd, m_hh, m_imgBuffer, m_moo, m_name, m_prom, m_thr, m_thr_exit, m_ww, SaveJpg(), and SavePng().
Referenced by CaptureAndSaveImage().
◆ SpawnFWTGLViewer()
Definition at line 109 of file FWTEveViewer.cc.
110 TGCompositeFrame* cf = GetGUICompositeFrame();
115 cf->AddFrame(fGLViewerFrame,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
117 fGLViewerFrame->MapWindow();
119 if (fEveFrame ==
nullptr)
References m_fwGlViewer.
Referenced by FWEveView::FWEveView().
◆ m_cnd
std::condition_variable FWTEveViewer::m_cnd |
|
private |
◆ m_fwGlViewer
◆ m_hh
◆ m_imgBuffer
std::vector<unsigned char> FWTEveViewer::m_imgBuffer |
|
private |
◆ m_moo
◆ m_name
TString FWTEveViewer::m_name |
|
private |
◆ m_prom
std::promise<int> FWTEveViewer::m_prom |
|
private |
◆ m_thr
std::thread* FWTEveViewer::m_thr = nullptr |
|
private |
◆ m_thr_exit
bool FWTEveViewer::m_thr_exit = false |
|
private |
◆ m_ww