Commit 840869d7 authored by Dirk Wilden's avatar Dirk Wilden

enhanced LoadSaveInterface

+some ViewerSnapshot code

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5346 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 42483677
......@@ -105,7 +105,14 @@ class LoadSaveInterface {
* @param _id Id of the new object
*/
virtual void fileOpened( int /*_id*/ ) {};
/** \brief An empty object has been added
*
* This slot is called if an empty object has been added by the core.\n
* @param _id Id of the new object
*/
virtual void addedEmptyObject( int /*_id*/ ) {};
};
Q_DECLARE_INTERFACE(LoadSaveInterface,"OpenFlipper.LoadSaveInterface/1.0")
......
......@@ -1043,6 +1043,12 @@ void Core::applicationSnapshotName(QString _name){
coreWidget_->applicationSnapshotName(_name);
}
void Core::viewerSnapshot(){
if ( OpenFlipper::Options::gui() )
coreWidget_->viewerSnapshot();
}
void Core::resizeViewer(int _width, int _height ){
if ( OpenFlipper::Options::gui() ){
//+40 / +20 corresponds to the bottom and right scrollbar
......
......@@ -191,6 +191,9 @@ signals:
/// Tell the plugins that a file has been opened ( -> Database)
void openedFile( int _id );
/// Tell the plugins that an empty object has been added
void emptyObjectAdded( int _id);
/// Called after all plugins are loaded
void pluginsInitialized();
......@@ -315,6 +318,9 @@ public slots:
/// Set the baseName for the application snapshot
void applicationSnapshotName(QString _name);
/// Take a snapshot from all viewers
void viewerSnapshot();
/// resize the examinerViewer
void resizeViewer(int _width, int _height );
......
......@@ -871,6 +871,10 @@ void Core::loadPlugin(QString filename, bool silent){
connect(plugin , SIGNAL( emptyObjectAdded( int ) ) ,
this , SLOT( slotEmptyObjectAdded ( int ) ),Qt::DirectConnection);
if ( checkSlot(plugin,"addedEmptyObject(int)" ) )
connect(this , SIGNAL( emptyObjectAdded( int ) ) ,
plugin , SLOT( addedEmptyObject( int ) ),Qt::DirectConnection);
if ( checkSignal(plugin,"getAllFilters(QStringList&)" ) )
connect(plugin , SIGNAL( getAllFilters( QStringList& ) ) ,
this , SLOT( slotGetAllFilters ( QStringList& ) ),Qt::DirectConnection);
......
......@@ -270,6 +270,8 @@ void Core::slotLoad(QString _filename, DataType _type, int& _id) {
BaseObjectData* object;
PluginFunctions::getObject(_id,object);
emit emptyObjectAdded( _id );
///@todo : set a default path for new objects
// QString filename = object->path() + OpenFlipper::Options::dirSeparator() + object->name();
......
......@@ -617,7 +617,7 @@ public:
// void viewerSnapshotDialog();
/// Create a snapshot of the whole app
// void viewerSnapshot();
void viewerSnapshot();
/// Create a snapshot of the whole app with fileDialog
void applicationSnapshotDialog();
......
......@@ -306,37 +306,71 @@ void CoreWidget::applicationSnapshot() {
}
///Take a snapshot of all viewers
// void CoreWidget::viewerSnapshot() {
//
// QFileInfo fi(snapshotName_);
//
// QString suggest = fi.path() + QDir::separator() +fi.baseName() + "." + QString::number(snapshotCounter_++) + ".";
//
// QString format="png";
//
// if (fi.completeSuffix() == "ppm")
// format="ppmraw";
//
// suggest += format;
//
// switch ( coreWidget_->baseLayout_->mode() ){
//
// case QtMultiViewLayout::SingleView:
//
// QImage img;
// examiner_widgets_[PluginFunctions::activeExaminer()]->snapshot(img);
void CoreWidget::viewerSnapshot() {
QFileInfo fi(snapshotName_);
QString suggest = fi.path() + QDir::separator() +fi.baseName() + "." + QString::number(snapshotCounter_++) + ".";
QString format="png";
if (fi.completeSuffix() == "ppm")
format="ppmraw";
suggest += format;
switch ( baseLayout_->mode() ){
case QtMultiViewLayout::SingleView:
{
QImage finalImage;
examiner_widgets_[PluginFunctions::activeExaminer()]->snapshot(finalImage);
finalImage.save(suggest);
break;
}
case QtMultiViewLayout::Grid:
{
// QImage img0,img1,img2,img3;
//
// img.save(suggest);
// QImage finalImage(img0.width() + img1.width(), img0.height() + img2.height(), QImage::Format_ARGB32_Premultiplied);
//
// break;
// case QtMultiViewLayout::Grid:
// break;
// case QtMultiViewLayout::HSplit:
// break;
// default: break;
// examiner_widgets_[0]->snapshot(finalImage, 0, 0);
// examiner_widgets_[1]->snapshot(finalImage,examiner_widgets_[0]->glWidth(), 0);
// examiner_widgets_[2]->snapshot(finalImage,0, examiner_widgets_[0]->glHeight());
// examiner_widgets_[3]->snapshot(finalImage,examiner_widgets_[0]->glWidth(),examiner_widgets_[0]->glHeight());
//
// }
// }
// finalImage.save(suggest);
break;
}
case QtMultiViewLayout::HSplit:
{
QImage img0,img1,img2,img3;
examiner_widgets_[0]->snapshot(img0);
examiner_widgets_[1]->snapshot(img1);
examiner_widgets_[2]->snapshot(img2);
examiner_widgets_[3]->snapshot(img3);
QImage finalImage(img0.width() + img1.width(), img0.height(), QImage::Format_ARGB32_Premultiplied);
// finalImage.paintEngine()->drawImage(QRectF(0,0,img0.width(),img0.height()),img0, QRectF(0,0,img0.width(),img0.height()) );
// finalImage.paintEngine()->drawImage(QRectF(img0.width(),0,img1.width(),img1.height()),img1, QRectF(0,0,img1.width(),img1.height()) );
// finalImage.paintEngine()->drawImage(QRectF(img0.width(),img1.height(),img2.width(),img2.height()),img2, QRectF(0,0,img2.width(),img2.height()) );
// finalImage.paintEngine()->drawImage(QRectF(img0.width(),img2.height(),img3.width(),img3.height()),img3, QRectF(0,0,img3.width(),img3.height()) );
finalImage.save(suggest);
break;
}
default: break;
}
}
void CoreWidget::applicationSnapshotName(QString _name) {
......
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