Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:01:12

0001 #ifndef Subsystem_Package_FWTEveViewer_h
0002 #define Subsystem_Package_FWTEveViewer_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Subsystem/Package
0006 // Class  :     FWTEveViewer
0007 //
0008 /**\class FWTEveViewer FWTEveViewer.h "FWTEveViewer.h"
0009 
0010  Description: [one line class summary]
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:
0018 //         Created:  Tue, 03 Feb 2015 21:46:04 GMT
0019 //
0020 
0021 // system include files
0022 
0023 #include <thread>
0024 #include <future>
0025 #include <mutex>
0026 #include <condition_variable>
0027 
0028 // user include files
0029 
0030 #include "TEveViewer.h"
0031 
0032 // forward declarations
0033 
0034 class FWTGLViewer;
0035 
0036 class FWTEveViewer : public TEveViewer {
0037 public:
0038   FWTEveViewer(const char* n = "FWTEveViewer", const char* t = "");
0039   ~FWTEveViewer() override;
0040 
0041   // ---------- const member functions ---------------------
0042 
0043   // ---------- static member functions --------------------
0044 
0045   static bool SavePng(const TString& file, UChar_t* xx, int ww, int hh);
0046   static bool SaveJpg(const TString& file, UChar_t* xx, int ww, int hh);
0047 
0048   // ---------- member functions ---------------------------
0049 
0050   FWTGLViewer* fwGlViewer() { return m_fwGlViewer; }
0051 
0052   FWTGLViewer* SpawnFWTGLViewer();
0053 
0054   std::future<int> CaptureAndSaveImage(const TString& file, int height = -1);
0055 
0056   FWTEveViewer(const FWTEveViewer&) = delete;  // stop default
0057 
0058   const FWTEveViewer& operator=(const FWTEveViewer&) = delete;  // stop default
0059 
0060 private:
0061   void spawn_image_thread();
0062 
0063   // ---------- member data --------------------------------
0064 
0065   FWTGLViewer* m_fwGlViewer;
0066 
0067   std::vector<unsigned char> m_imgBuffer;
0068 
0069   TString m_name;
0070   int m_ww, m_hh;
0071   bool m_thr_exit = false;
0072   std::thread* m_thr = nullptr;
0073   std::promise<int> m_prom;
0074   std::mutex m_moo;
0075   std::condition_variable m_cnd;
0076 };
0077 
0078 #endif