PylonRecorder/pylonrecorder.h

151 lines
4.2 KiB
C++

#ifndef IMAGEVIEWER_H
#define IMAGEVIEWER_H
#include <QMainWindow>
#include <QTimer>
#include <QSpinBox>
#include <QCheckBox>
#include <QSettings>
#include <pylon/PylonIncludes.h>
#include "pylonwrapper.h"
#include "dualcamwrapper.h"
#include "imagebuffer.h"
#include "grabber.h"
#include "dualcamgrabber.h"
#include "writer.h"
#include "projectsettings.h"
#include "camconfig.h"
#include "camids.h"
#include "util.h"
#include <QImage>
#if defined(QT_PRINTSUPPORT_LIB)
# include <QtPrintSupport/qtprintsupportglobal.h>
# if QT_CONFIG(printer)
# include <QPrinter>
#include <QProgressBar>
# endif
#endif
QT_BEGIN_NAMESPACE
class QAction;
class QLabel;
class QMenu;
class QScrollArea;
class QScrollBar;
QT_END_NAMESPACE
//! [0]
class PylonRecorder : public QMainWindow
{
Q_OBJECT
public:
PylonRecorder(QWidget *parent = nullptr);
~PylonRecorder();
bool loadFile(const QString &);
private slots:
void grabStillFromPylon();
void open();
void saveAs();
void print();
void copy();
void paste();
void zoomIn();
void zoomOut();
void normalSize();
void fitToWindow();
void about();
void connectCamera();
void disconnectCamera();
void startRecording();
void stopRecording();
void quitApplication();
void displaySingleFrame();
void displayBufferPressure();
void displayActivity();
void writerDone();
void selectStorageLocation();
void cameraConfigurationAccepted();
void cameraConfigurationAborted();
void setCameraIDs();
void cameraIDAccepted();
private:
void createActions();
void updateActions();
void applySettings();
void storeSettings();
void editProjectMetadata();
void setExperimentName();
void setExperimenterName();
void setSubjectID();
QColor progressColor(int value);
std::string createFilename(const std::string &suffix="", const std::string &extension=".raw");
void cameraConfiguration();
VideoSpecs getVideoSpecs(const ImageSettings &settings);
void startSinglecamRecording();
void startDualcamRecording();
bool saveFile(const QString &fileName);
void setImage(const QImage &newImage);
void scaleImage(double factor);
void applyScaling();
void adjustScrollBar(QScrollBar *scrollBar, double factor);
void detectCameras();
int defaultBufferSize = 3000, defaultFrameRate = 30, movieCount = 0, defaultExposureTime = 6000, defaultGain=13;
QSettings *settings = new QSettings;
QImage image;
QTimer *frameTimer, *pressureTimer, *labelTimer;
QLabel *imageLabel, *writingLabel, *grabbingLabel, *cameraConnectedLabel, *fileLabel;
QCheckBox *dryRunCheckBox;
QProgressBar *pressureBar;
QProgressBar *loadBar;
QScrollArea *scrollArea;
double scaleFactor = 1;
PylonWrapper *singlecam;
DualcamWrapper *dualcam;
ImageBuffer *buffer;
Grabber *singlecamgrabber;
DualcamGrabber *dualcamgrabber;
Writer *writer;
CameraLayout layout;
bool grabbing, stopRequest, writing, labelSwitch, dryRun, cameraOpened, camsconfigured;
QPalette progressPalette;
QString activeLabelStyleHigh = "QLabel { font-size: 10pt;font-family: Arial; color : red; }";
QString activeLabelStyleLow = "QLabel { font-size: 10pt;font-family: Arial; color : cmyk(0, 255, 255, 0, 50); }";
QString inactiveLabelStyle = ("QLabel { font-size: 10pt;font-family: Arial; color :gray; }");
QSpinBox *framerateSpinner, *buffersizeSpinner, *exposureSpinner, *gainSpinner;
QAction *selectStorageAction, *storeSettingsAction;
QAction *projectSettingsAction;
QString storageLocation = "";
ProjectMetadata mdata;
Pylon::DeviceInfoList_t deviceList;
Pylon::PylonAutoInitTerm autoInitTerm;
CamConfigurator *cameraConfigDialog;
CameraID *cameraIdDialog;
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
QPrinter printer;
#endif
QAction *saveAsAct;
QAction *printAct;
QAction *copyAct;
QAction *zoomInAct;
QAction *zoomOutAct;
QAction *normalSizeAct;
QAction *fitToWindowAct;
QAction *grab_still_action;
QAction *grab_continuous_action;
QAction *grab_stop_action;
QAction *connect_camera_action;
QAction *disconnect_camera_action;
QAction *set_cam_identifier_action;
};
#endif