void Data_analysis_gui::save_as_image() { // get a file name and the name of the filter to use to save the image. // 3 filters are available: PNG, BMP, and Postscript. Postscript is not // available on Windows (Qt limitation). Data_analysis_save_dialog* dialog = new Data_analysis_save_dialog( QString::null, QString::null, this, "Save Histogram as Image" ); if( dialog->exec() == QDialog::Rejected ) return; QStringList filename = dialog->selectedFiles(); QString selected_filter = dialog->selectedFilter(); QString format = selected_filter.section( ' ', 0, 0 ); if (format == "PNG" && (!filename[0].endsWith(".png",Qt::CaseInsensitive))) filename[0] += ".png"; if (format == "BMP" && (!filename[0].endsWith(".bmp",Qt::CaseInsensitive))) filename[0] += ".bmp"; if (format == "Postscript" && (!filename[0].endsWith(".ps",Qt::CaseInsensitive))) filename[0] += ".ps"; save_as_image( filename[0], format, dialog->write_stats_required(), dialog->paint_grid_required() ); }
Data_analysis_gui::Data_analysis_gui( QWidget* parent, const char* name ) : QWidget( parent, Qt::Window ) { plot_ = 0; scrollview_ = 0; if (name) setObjectName(name); setupUi(this); // QLayout* layout = this->layout(); // QSizeGrip* grip = new QSizeGrip( gripbox_, "grip" ); // layout->add( grip ); QVBoxLayout * vbox = new QVBoxLayout; vbox->addSpacing(-1); gripbox_->setLayout(vbox); /* gripbox_->setOrientation( Qt::Vertical ); gripbox_->setColumns( 2 ); gripbox_->addSpace( -1 ); */ vbox->addWidget(new QSizeGrip( gripbox_)); /* //add a status bar (mainly for its resize grip...) QLayout* layout = this->layout(); QStatusBar* statusbar = new QStatusBar( this, "statusbar" ); QSizePolicy policy( QSizePolicy::Preferred, QSizePolicy::Fixed ); statusbar->setSizePolicy( policy ); statusbar->setSizeGripEnabled( true ); QPushButton* close_button_ = new QPushButton( "Close", statusbar, "close_button" ); QPushButton* save_button_ = new QPushButton( "Save As Image", statusbar, "save_button" ); statusbar->addWidget( save_button_, 0, true ); QLayout* bar_layout = statusbar->layout(); bar_layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed ) ); statusbar->addWidget( close_button_, 0, true ); layout->add( statusbar ); */ init_display_area(); init_controls_area(); QObject::connect( (QObject*) close_button_, SIGNAL( clicked() ), this, SLOT( close_window() ) ); QObject::connect( (QObject*) save_button_, SIGNAL( clicked() ), this, SLOT( save_as_image() ) ); }
void ggEditor::tick( sf::Window* window ) { if ( *currentController != CTRL_EDITOR ) { return; } i->wspawn_count = wspawn_count; // If play pressed, hand control over to game. if ( i->btnPlay.doAction ) { i->btnPlay.doAction = false; i->loadInitialCellPattern(); *currentController = CTRL_GAME; } if ( i->btnStop.doAction ) i->btnStop.doAction = false; if ( i->btnPause.doAction ) i->btnPause.doAction = false; if ( i->btnReset.doAction ) { wspawn_count = 0; seed_count = 0; i->btnReset.doAction = false; } if ( i->btnSave.doAction ) { i->btnSave.doAction = false; std::string pathFileName = pop_file_dialog( DIALOG_SAVE, "\\patterns\\", window->getSystemHandle() ); if ( pathFileName != "" ) { save_as_image( pathFileName, i->cellsInitial ); } } if ( i->btnLoad.doAction ) { i->btnLoad.doAction = false; // TODO -> Figure out how to update seed and fountain count after loading std::string pathFileName = pop_file_dialog( DIALOG_OPEN, "\\patterns\\", window->getSystemHandle() ); if ( pathFileName.find("GardenGrow.exe") != std::string::npos ) { i->flagHelp = true; } else { i->flagHelp = false; } if ( pathFileName != "" ) { load_from_image( pathFileName, i->cellsInitial ); updateCount(); i->panX = 0.0f; i->panY = 0.0f; i->zoomLevel = 1.0f; } } }