tinies
This commit is contained in:
parent
1b1068fba7
commit
d89ae953ec
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ moc*
|
||||
.qmake.stash
|
||||
qrc_resources.cpp
|
||||
recorder
|
||||
build/
|
@ -17,6 +17,7 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QStatusBar>
|
||||
#include <QToolBar>
|
||||
#include <QSettings>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
@ -125,6 +126,7 @@ PylonRecorder::~PylonRecorder(){
|
||||
delete writer;
|
||||
}
|
||||
|
||||
|
||||
bool PylonRecorder::loadFile(const QString &fileName) {
|
||||
QImageReader reader(fileName);
|
||||
reader.setAutoTransform(true);
|
||||
@ -146,6 +148,7 @@ bool PylonRecorder::loadFile(const QString &fileName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::setImage(const QImage &newImage) {
|
||||
image = newImage;
|
||||
// (image.colorSpace().isValid())
|
||||
@ -164,6 +167,7 @@ void PylonRecorder::setImage(const QImage &newImage) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool PylonRecorder::saveFile(const QString &fileName) {
|
||||
QImageWriter writer(fileName);
|
||||
|
||||
@ -178,6 +182,7 @@ bool PylonRecorder::saveFile(const QString &fileName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void initializeImageFileDialog(QFileDialog &dialog, QFileDialog::AcceptMode acceptMode) {
|
||||
static bool firstDialog = true;
|
||||
|
||||
@ -199,6 +204,7 @@ static void initializeImageFileDialog(QFileDialog &dialog, QFileDialog::AcceptMo
|
||||
dialog.setDefaultSuffix("jpg");
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::open() {
|
||||
QFileDialog dialog(this, tr("Open File"));
|
||||
initializeImageFileDialog(dialog, QFileDialog::AcceptOpen);
|
||||
@ -206,6 +212,7 @@ void PylonRecorder::open() {
|
||||
while (dialog.exec() == QDialog::Accepted && !loadFile(dialog.selectedFiles().first())) {}
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::saveAs() {
|
||||
QFileDialog dialog(this, tr("Save File As"));
|
||||
initializeImageFileDialog(dialog, QFileDialog::AcceptSave);
|
||||
@ -213,6 +220,7 @@ void PylonRecorder::saveAs() {
|
||||
while (dialog.exec() == QDialog::Accepted && !saveFile(dialog.selectedFiles().first())) {}
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::print() {
|
||||
Q_ASSERT(imageLabel->pixmap());
|
||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog)
|
||||
@ -231,12 +239,14 @@ void PylonRecorder::print() {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::copy() {
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
QGuiApplication::clipboard()->setImage(image);
|
||||
#endif // !QT_NO_CLIPBOARD
|
||||
}
|
||||
|
||||
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
static QImage clipboardImage() {
|
||||
if (const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData()) {
|
||||
@ -250,6 +260,7 @@ static QImage clipboardImage() {
|
||||
}
|
||||
#endif // !QT_NO_CLIPBOARD
|
||||
|
||||
|
||||
void PylonRecorder::paste() {
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
const QImage newImage = clipboardImage();
|
||||
@ -265,20 +276,24 @@ void PylonRecorder::paste() {
|
||||
#endif // !QT_NO_CLIPBOARD
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::zoomIn() {
|
||||
scaleImage(1.25);
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::zoomOut()
|
||||
{
|
||||
scaleImage(0.8);
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::normalSize() {
|
||||
imageLabel->adjustSize();
|
||||
scaleFactor = 1.0;
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::fitToWindow() {
|
||||
bool fitToWindow = fitToWindowAct->isChecked();
|
||||
scrollArea->setWidgetResizable(fitToWindow);
|
||||
@ -287,6 +302,7 @@ void PylonRecorder::fitToWindow() {
|
||||
updateActions();
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::about() {
|
||||
QMessageBox::about(this, tr("About Pylon Recorder"),
|
||||
tr("<p><b>Pylon Recorder</b><br> Simple recorder for video grabbing from pylon USB3 monochrome camera."
|
||||
@ -298,6 +314,7 @@ void PylonRecorder::about() {
|
||||
"<p>by Jan Grewe, <a href='http://www.neuroetho.uni-tuebingen.de'>Neuroethology Lab</a>, University of Tuebingen.</p>"));
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::createActions() {
|
||||
const QIcon connect_icon(":/images/connect.png");
|
||||
const QIcon disconnect_icon(":/images/disconnect.png");
|
||||
@ -367,6 +384,9 @@ void PylonRecorder::createActions() {
|
||||
grab_stop_action = camera_menu->addAction(stop_icon, tr("&stop grabbing"), this, &PylonRecorder::stopRecording);
|
||||
grab_stop_action->setShortcut(tr("Ctrl+Shift+Enter"));
|
||||
|
||||
QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
|
||||
settingsMenu->addAction(tr("Storage location"), this, &PylonRecorder::selectStorageLocation);
|
||||
|
||||
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||
helpMenu->addAction(tr("&About"), this, &PylonRecorder::about);
|
||||
helpMenu->addAction(tr("About &Qt"), &QApplication::aboutQt);
|
||||
@ -430,6 +450,7 @@ void PylonRecorder::createActions() {
|
||||
toolbar->addWidget(dryRunCheckBox);
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::updateActions() {
|
||||
saveAsAct->setEnabled(!image.isNull());
|
||||
copyAct->setEnabled(!image.isNull());
|
||||
@ -443,6 +464,7 @@ void PylonRecorder::updateActions() {
|
||||
grab_stop_action->setEnabled(grabbing);
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::scaleImage(double factor) {
|
||||
Q_ASSERT(imageLabel->pixmap());
|
||||
scaleFactor *= factor;
|
||||
@ -455,10 +477,12 @@ void PylonRecorder::scaleImage(double factor) {
|
||||
zoomOutAct->setEnabled(scaleFactor > 0.333);
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::applyScaling(){
|
||||
imageLabel->resize(scaleFactor * imageLabel->pixmap()->size());
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::quitApplication() {
|
||||
if (pylon->isOpen()) {
|
||||
if (grabbing) {
|
||||
@ -469,11 +493,13 @@ void PylonRecorder::quitApplication() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::adjustScrollBar(QScrollBar *scrollBar, double factor) {
|
||||
scrollBar->setValue(int(factor * scrollBar->value()
|
||||
+ ((factor - 1) * scrollBar->pageStep()/2)));
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::connectCamera() {
|
||||
std::string message;
|
||||
bool success = pylon->openCamera(message);
|
||||
@ -491,6 +517,7 @@ void PylonRecorder::connectCamera() {
|
||||
updateActions();
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::disconnectCamera() {
|
||||
pylon->closeCamera();
|
||||
statusBar()->showMessage(tr("Camera closed!"));
|
||||
@ -499,6 +526,7 @@ void PylonRecorder::disconnectCamera() {
|
||||
updateActions();
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::startRecording() {
|
||||
std::string filename = createFilename();
|
||||
fileLabel->setText(QString::fromStdString(filename));
|
||||
@ -541,6 +569,7 @@ void PylonRecorder::startRecording() {
|
||||
updateActions();
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::stopRecording() {
|
||||
if (!stopRequest) {
|
||||
frameTimer->stop();
|
||||
@ -556,6 +585,7 @@ void PylonRecorder::stopRecording() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::writerDone() {
|
||||
preassureTimer->stop();
|
||||
preassureBar->reset();
|
||||
@ -569,12 +599,14 @@ void PylonRecorder::writerDone() {
|
||||
updateActions();
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::displayActivity() {
|
||||
grabbingLabel->setStyleSheet((labelSwitch && grabbing) ? activeLabelStyleHigh : activeLabelStyleLow);
|
||||
writingLabel->setStyleSheet((labelSwitch && writing) ? activeLabelStyleHigh : activeLabelStyleLow);
|
||||
labelSwitch = !labelSwitch;
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::displaySingleFrame() {
|
||||
MyImage img;
|
||||
bool valid = buffer->readLast(img);
|
||||
@ -587,6 +619,7 @@ void PylonRecorder::displaySingleFrame() {
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
QColor PylonRecorder::progressColor(int value) {
|
||||
int c, m, k = 0, y = 255;
|
||||
c = 255 - 255 * value/100;
|
||||
@ -598,6 +631,7 @@ QColor PylonRecorder::progressColor(int value) {
|
||||
return QColor::fromCmyk(c, m, y, k);
|
||||
}
|
||||
|
||||
|
||||
std::string PylonRecorder::createFilename() {
|
||||
QDateTime dt(QDateTime::currentDateTimeUtc());
|
||||
QDate date = dt.date();
|
||||
@ -612,6 +646,7 @@ std::string PylonRecorder::createFilename() {
|
||||
return fname;
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::displayBufferPreassure() {
|
||||
int value = static_cast<int>(round(buffer->bufferPreassure()));
|
||||
preassureBar->setValue(value);
|
||||
@ -623,6 +658,7 @@ void PylonRecorder::displayBufferPreassure() {
|
||||
loadBar->setValue(load);
|
||||
}
|
||||
|
||||
|
||||
void PylonRecorder::grabStillFromPylon() {
|
||||
if (pylon->isOpen()) {
|
||||
MyImage img;
|
||||
@ -636,3 +672,7 @@ void PylonRecorder::grabStillFromPylon() {
|
||||
statusBar()->showMessage(tr("Camera is not open! Connect to camera first!"));
|
||||
}
|
||||
}
|
||||
|
||||
void PylonRecorder::selectStorageLocation() {
|
||||
std::cerr << "Select folder!!! " << std::endl;
|
||||
}
|
||||
|
@ -61,11 +61,10 @@ private slots:
|
||||
void displayBufferPreassure();
|
||||
void displayActivity();
|
||||
void writerDone();
|
||||
void selectStorageLocation();
|
||||
|
||||
private:
|
||||
void createActions();
|
||||
void createMenus();
|
||||
void createToolBar();
|
||||
void updateActions();
|
||||
QColor progressColor(int value);
|
||||
std::string createFilename();
|
||||
|
Loading…
Reference in New Issue
Block a user