Commit de35b2cd authored by Dirk Wilden's avatar Dirk Wilden

added option to specify dimension for snapshots

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6342 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f0b30860
......@@ -1090,13 +1090,42 @@ void Core::viewerSnapshot(){
void Core::resizeViewers(int _width, int _height ){
if ( OpenFlipper::Options::gui() ){
//+6,+22 to to get the correct dimension when using snapshotFunction
coreWidget_->glView_->resize(_width+6, _height+22);
lastWidth_ = coreWidget_->glView_->width();
lastHeight_ = coreWidget_->glView_->height();
//now take the snapshot
switch ( coreWidget_->baseLayout_->mode() ){
case QtMultiViewLayout::SingleView:
{
//+4,+20 to to get the correct dimension when using snapshotFunction
coreWidget_->glView_->resize(_width+4, _height+20);
break;
}
case QtMultiViewLayout::Grid:
{
//+6,+22 to to get the correct dimension when using snapshotFunction
coreWidget_->glView_->resize(_width+6, _height+22);
break;
}
case QtMultiViewLayout::HSplit:
{
//+6,+20 to to get the correct dimension when using snapshotFunction
coreWidget_->glView_->resize(_width+6, _height+20);
break;
}
default: break;
}
}
}
void Core::resizeApplication(int _width, int _height ){
if ( OpenFlipper::Options::gui() ){
lastWidth_ = coreWidget_->glView_->width();
lastHeight_ = coreWidget_->glView_->height();
coreWidget_->resize(_width, _height);
}
}
......
......@@ -465,6 +465,9 @@ private:
bool capture_;
int lastWidth_;
int lastHeight_;
/** @} */
//===========================================================================
/** @name Load / Save slots
......
......@@ -91,6 +91,15 @@ void Core::captureVideo() {
void Core::stopVideoCapture() {
videoTimer_.stop();
capture_ = false;
if ( OpenFlipper::Options::gui() ){
if (captureType_ == 1){
coreWidget_->glView_->resize(lastWidth_, lastHeight_);
} else {
coreWidget_->resize(lastWidth_, lastHeight_);
}
}
}
void Core::viewUpdated() {
......
......@@ -34,6 +34,7 @@ set (directories
../widgets/PluginDialog
../widgets/viewModeWidget
../widgets/videoCaptureDialog
../widgets/snapshotDialog
)
# collect all header,source and ui files
......
......@@ -22,7 +22,7 @@ DIRECTORIES = ../ ../Core ../Logging \
../widgets/coreWidget ../widgets/helpWidget \
../widgets/loadWidget ../widgets/optionsWidget ../widgets/PluginDialog \
../widgets/viewModeWidget \
../widgets/videoCaptureDialog
../widgets/videoCaptureDialog ../widgets/snapshotDialog
QMAKE_LIBDIR += $${TOPDIR}/OpenFlipper/PluginLib/lib/$${BUILDDIRECTORY}
......
......@@ -45,7 +45,7 @@
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/widgets/snapshotDialog/SnapshotDialog.hh>
//== IMPLEMENTATION ==========================================================
......@@ -267,24 +267,18 @@ void CoreWidget::applicationSnapshotDialog() {
suggest += format;
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDefaultSuffix("png");
dialog.setNameFilter("Images (*.png *.ppm *.jpg)");
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setConfirmOverwrite(true);
dialog.setDirectory( fi.path() );
dialog.selectFile( suggest );
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setWindowTitle("Save Snapshot");
bool ok = dialog.exec();
SnapshotDialog dialog(suggest, false, this);
std::cerr << "1" << std::endl;
dialog.hide();
int w = width();
int h = height();
connect(&dialog, SIGNAL(resizeApplication(int,int)), this, SIGNAL(resizeApplication(int,int)) );
bool ok = dialog.exec();
if ( ok ){
QString newName = dialog.selectedFiles()[0];
QString newName = dialog.filename->text();
if (newName != fi.path() + OpenFlipper::Options::dirSeparator() + suggest){
snapshotName_ = newName;
......@@ -297,6 +291,8 @@ void CoreWidget::applicationSnapshotDialog() {
QPixmap pic = QPixmap::grabWindow( winId() );
pic.save(newName);
emit resizeApplication(w,h);
}
}
......@@ -352,19 +348,17 @@ void CoreWidget::viewerSnapshotDialog() {
suggest += format;
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDefaultSuffix("png");
dialog.setNameFilter("Images (*.png *.ppm *.jpg)");
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setConfirmOverwrite(true);
dialog.setDirectory( fi.path() );
dialog.selectFile( suggest );
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setWindowTitle("Save Snapshot");
SnapshotDialog dialog(suggest, true, this);
if (dialog.exec()){
QString newName = dialog.selectedFiles()[0];
int w = glView_->width();
int h = glView_->height();
connect(&dialog, SIGNAL(resizeViewers(int,int)), this, SIGNAL(resizeViewers(int,int)) );
bool ok = dialog.exec();
if (ok){
QString newName = dialog.filename->text();
if (newName != fi.path() + OpenFlipper::Options::dirSeparator() + suggest){
snapshotName_ = newName;
......@@ -438,6 +432,8 @@ void CoreWidget::viewerSnapshotDialog() {
default: break;
}
glView_->resize(w, h);
}
}
......
#include "SnapshotDialog.hh"
#include <QtGui>
#include <QMessageBox>
#include <QFileDialog>
#include <QFileInfo>
#include <iostream>
#include <OpenFlipper/common/GlobalOptions.hh>
SnapshotDialog::SnapshotDialog(QString _suggest, bool _captureViewers, QWidget *parent)
: QDialog(parent),
captureViewers_(_captureViewers)
{
setupUi(this);
filename->setText( _suggest );
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()) );
connect(findButton, SIGNAL(clicked()), this, SLOT(findFile()) );
connect(okButton, SIGNAL(clicked()), this, SLOT(slotOk()) );
}
void SnapshotDialog::slotOk()
{
if (filename->text() == ""){
QMessageBox msgBox;
msgBox.setText("The Filename is empty!");
msgBox.exec();
return;
}
if ( captureViewers_ )
emit resizeViewers(snapWidth->value(), snapHeight->value());
else
emit resizeApplication(snapWidth->value(), snapHeight->value());
accept();
}
void SnapshotDialog::findFile()
{
QFileInfo fi( filename->text() );
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDefaultSuffix("png");
dialog.setNameFilter("Images (*.png *.ppm *.jpg)");
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setConfirmOverwrite(true);
dialog.setDirectory( fi.path() );
dialog.selectFile( filename->text() );
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setWindowTitle("Save Snapshot");
bool ok = dialog.exec();
if (ok)
filename->setText( dialog.selectedFiles()[0] );
}
\ No newline at end of file
#include "ui_SnapshotDialog.hh"
#include <QtGui>
class SnapshotDialog : public QDialog, public Ui::SnapshotDialog
{
Q_OBJECT
public:
SnapshotDialog(QString _suggest, bool _captureViewers, QWidget *parent = 0);
private:
bool captureViewers_;
private slots:
void slotOk();
void findFile();
signals:
void resizeViewers(int _width, int _height);
void resizeApplication(int _width, int _height);
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SnapshotDialog</class>
<widget class="QDialog" name="SnapshotDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>416</width>
<height>156</height>
</rect>
</property>
<property name="windowTitle">
<string>Start Video Capturing</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Output filename:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="filename"/>
</item>
<item>
<widget class="QToolButton" name="findButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string> Resolution </string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="snapWidth">
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>2000</number>
</property>
<property name="value">
<number>800</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="snapHeight">
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>2000</number>
</property>
<property name="value">
<number>600</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="okButton">
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../../../resources.qrc"/>
</resources>
<connections/>
</ui>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment