void PreviewFileDialog::OnCurrentChanged(const QString & _filename) { filename = _filename; QPixmap pixmap; if (QFileInfo(filename).suffix() == QString("fract") && checkbox->isChecked()) { thumbWidget->show(); preview->hide(); cSettings parSettings(cSettings::formatFullText); parSettings.BeQuiet(true); if (parSettings.LoadFromFile(filename)) { progressBar->show(); cParameterContainer *par = new cParameterContainer; cFractalContainer *parFractal = new cFractalContainer; InitParams(par); for (int i = 0; i < NUMBER_OF_FRACTALS; i++) InitFractalParams(&parFractal->at(i)); /****************** TEMPORARY CODE FOR MATERIALS *******************/ InitMaterialParams(1, par); /*******************************************************************/ if (parSettings.Decode(par, parFractal)) { thumbWidget->AssignParameters(*par, *parFractal); thumbWidget->update(); } else { preview->setText(" "); info->setText(" "); } delete par; delete parFractal; } } else { thumbWidget->hide(); preview->show(); pixmap.load(filename); if (pixmap.isNull() || !checkbox->isChecked()) { preview->setText(" "); info->setText(" "); } else { preview->setPixmap(pixmap.scaled(200, 200, Qt::KeepAspectRatio, Qt::SmoothTransformation)); QString text = QString::number(pixmap.width()) + QString(" x ") + QString::number(pixmap.height()); info->setText(text); } } }
void Test::renderExamples() { // this renders all example files in a resolution of 5x5 px // and benchmarks the runtime QString examplePath = QDir::toNativeSeparators(systemData.sharedDir + QDir::separator() + "examples"); QDirIterator it(examplePath, QStringList() << "*.fract", QDir::Files); cParameterContainer *testPar = new cParameterContainer; cFractalContainer *testParFractal = new cFractalContainer; cAnimationFrames *testAnimFrames = new cAnimationFrames; cKeyframes *testKeyframes = new cKeyframes; testPar->SetContainerName("main"); InitParams(testPar); /****************** TEMPORARY CODE FOR MATERIALS *******************/ InitMaterialParams(1, testPar); /*******************************************************************/ for (int i = 0; i < NUMBER_OF_FRACTALS; i++) { testParFractal->at(i).SetContainerName(QString("fractal") + QString::number(i)); InitFractalParams(&testParFractal->at(i)); } bool stopRequest = false; cImage *image = new cImage(testPar->Get<int>("image_width"), testPar->Get<int>("image_height")); cRenderingConfiguration config; config.DisableRefresh(); config.DisableProgressiveRender(); while (it.hasNext()) { QString filename = it.next(); cSettings parSettings(cSettings::formatFullText); parSettings.BeQuiet(true); parSettings.LoadFromFile(filename); parSettings.Decode(testPar, testParFractal, testAnimFrames, testKeyframes); testPar->Set("image_width", 5); testPar->Set("image_height", 5); cRenderJob *renderJob = new cRenderJob(testPar, testParFractal, image, &stopRequest); renderJob->Init(cRenderJob::still, config); QVERIFY2(renderJob->Execute(), "example render failed."); delete renderJob; } delete image; delete testKeyframes; delete testAnimFrames; delete testParFractal; delete testPar; }
void Test::testKeyframe() { QString exampleKeyframeFile = QDir::toNativeSeparators(systemData.sharedDir + QDir::separator() + "examples" + QDir::separator() + "keyframe_anim_mandelbulb.fract"); cParameterContainer *testPar = new cParameterContainer; cFractalContainer *testParFractal = new cFractalContainer; cAnimationFrames *testAnimFrames = new cAnimationFrames; cKeyframes *testKeyframes = new cKeyframes; testPar->SetContainerName("main"); InitParams(testPar); /****************** TEMPORARY CODE FOR MATERIALS *******************/ InitMaterialParams(1, testPar); /*******************************************************************/ for (int i = 0; i < NUMBER_OF_FRACTALS; i++) { testParFractal->at(i).SetContainerName(QString("fractal") + QString::number(i)); InitFractalParams(&testParFractal->at(i)); } cImage *image = new cImage(testPar->Get<int>("image_width"), testPar->Get<int>("image_height")); cRenderingConfiguration config; config.DisableRefresh(); config.DisableProgressiveRender(); cSettings parSettings(cSettings::formatFullText); parSettings.BeQuiet(true); parSettings.LoadFromFile(exampleKeyframeFile); parSettings.Decode(testPar, testParFractal, testAnimFrames, testKeyframes); testPar->Set("image_width", 5); testPar->Set("image_height", 5); testPar->Set("keyframe_first_to_render", 50); testPar->Set("keyframe_last_to_render", 55); cKeyframeAnimation *testKeyframeAnimation = new cKeyframeAnimation( gMainInterface, testKeyframes, image, NULL, testPar, testParFractal, NULL); QVERIFY2(testKeyframeAnimation->slotRenderKeyframes(), "keyframe render failed."); delete image; delete testKeyframes; delete testAnimFrames; delete testParFractal; delete testPar; delete testKeyframeAnimation; testKeyframeAnimation = NULL; return; }
cRenderQueue::cRenderQueue(cImage *_image, RenderedImage *widget) : QObject() { image = _image; imageWidget = widget; queuePar = new cParameterContainer; queueParFractal = new cFractalContainer; queueAnimFrames = new cAnimationFrames; queueKeyframes = new cKeyframes; queuePar->SetContainerName("main"); InitParams(queuePar); /****************** TEMPORARY CODE FOR MATERIALS *******************/ InitMaterialParams(1, queuePar); /*******************************************************************/ for (int i = 0; i < NUMBER_OF_FRACTALS; i++) { queueParFractal->at(i).SetContainerName(QString("fractal") + QString::number(i)); InitFractalParams(&queueParFractal->at(i)); } queueFlightAnimation = new cFlightAnimation( gMainInterface, queueAnimFrames, image, imageWidget, queuePar, queueParFractal, this); queueKeyframeAnimation = new cKeyframeAnimation( gMainInterface, queueKeyframes, image, imageWidget, queuePar, queueParFractal, this); QObject::connect(queueFlightAnimation, SIGNAL(updateProgressAndStatus( const QString &, const QString &, double, cProgressText::enumProgressType)), this, SIGNAL(updateProgressAndStatus( const QString &, const QString &, double, cProgressText::enumProgressType))); QObject::connect(queueFlightAnimation, SIGNAL(updateProgressHide(cProgressText::enumProgressType)), this, SIGNAL(updateProgressHide(cProgressText::enumProgressType))); QObject::connect(queueFlightAnimation, SIGNAL(updateStatistics(cStatistics)), this, SIGNAL(updateStatistics(cStatistics))); QObject::connect(queueKeyframeAnimation, SIGNAL(updateProgressAndStatus( const QString &, const QString &, double, cProgressText::enumProgressType)), this, SIGNAL(updateProgressAndStatus( const QString &, const QString &, double, cProgressText::enumProgressType))); QObject::connect(queueKeyframeAnimation, SIGNAL(updateProgressHide(cProgressText::enumProgressType)), this, SIGNAL(updateProgressHide(cProgressText::enumProgressType))); QObject::connect(queueKeyframeAnimation, SIGNAL(updateStatistics(cStatistics)), this, SIGNAL(updateStatistics(cStatistics))); }
// adds dynamic actions to the toolbar (example settings) void RenderWindow::slotPopulateToolbar(bool completeRefresh) { WriteLog("cInterface::PopulateToolbar(QWidget *window, QToolBar *toolBar) started", 2); QDir toolbarDir = QDir(systemData.dataDirectory + "toolbar"); toolbarDir.setSorting(QDir::Time); QStringList toolbarFiles = toolbarDir.entryList(QDir::NoDotAndDotDot | QDir::Files); QSignalMapper *mapPresetsFromExamplesLoad = new QSignalMapper(this); QSignalMapper *mapPresetsFromExamplesRemove = new QSignalMapper(this); ui->toolBar->setIconSize( QSize(gPar->Get<int>("toolbar_icon_size"), gPar->Get<int>("toolbar_icon_size"))); QList<QAction *> actions = ui->toolBar->actions(); QStringList toolbarInActions; for (int i = 0; i < actions.size(); i++) { QAction *action = actions.at(i); if (action->objectName() == "actionAdd_Settings_to_Toolbar") continue; if (!toolbarFiles.contains(action->objectName()) || completeRefresh) { // preset has been removed ui->toolBar->removeAction(action); } else { toolbarInActions << action->objectName(); } } for (int i = 0; i < toolbarFiles.size(); i++) { if (toolbarInActions.contains(toolbarFiles.at(i))) { // already present continue; } QString filename = systemData.dataDirectory + "toolbar/" + toolbarFiles.at(i); cThumbnailWidget *thumbWidget = NULL; if (QFileInfo(filename).suffix() == QString("fract")) { WriteLogString("Generating thumbnail for preset", filename, 2); cSettings parSettings(cSettings::formatFullText); parSettings.BeQuiet(true); if (parSettings.LoadFromFile(filename)) { cParameterContainer *par = new cParameterContainer; cFractalContainer *parFractal = new cFractalContainer; InitParams(par); for (int i = 0; i < NUMBER_OF_FRACTALS; i++) InitFractalParams(&parFractal->at(i)); /****************** TEMPORARY CODE FOR MATERIALS *******************/ InitMaterialParams(1, par); /*******************************************************************/ if (parSettings.Decode(par, parFractal)) { thumbWidget = new cThumbnailWidget( gPar->Get<int>("toolbar_icon_size"), gPar->Get<int>("toolbar_icon_size"), 2, this); thumbWidget->UseOneCPUCore(true); thumbWidget->AssignParameters(*par, *parFractal); } delete par; delete parFractal; } } if (thumbWidget) { QWidgetAction *action = new QWidgetAction(this); QToolButton *buttonLoad = new QToolButton; QVBoxLayout *tooltipLayout = new QVBoxLayout; QToolButton *buttonRemove = new QToolButton; tooltipLayout->setContentsMargins(3, 3, 3, 3); tooltipLayout->addWidget(thumbWidget); QIcon iconDelete = QIcon::fromTheme("list-remove", QIcon(":system/icons/list-remove.svg")); buttonRemove->setIcon(iconDelete); buttonRemove->setMaximumSize(QSize(15, 15)); buttonRemove->setStyleSheet("margin-bottom: -2px; margin-left: -2px;"); tooltipLayout->addWidget(buttonRemove); buttonLoad->setToolTip(QObject::tr("Toolbar settings: ") + filename); buttonLoad->setLayout(tooltipLayout); action->setDefaultWidget(buttonLoad); action->setObjectName(toolbarFiles.at(i)); ui->toolBar->addAction(action); mapPresetsFromExamplesLoad->setMapping(buttonLoad, filename); mapPresetsFromExamplesRemove->setMapping(buttonRemove, filename); QApplication::connect(buttonLoad, SIGNAL(clicked()), mapPresetsFromExamplesLoad, SLOT(map())); QApplication::connect( buttonRemove, SIGNAL(clicked()), mapPresetsFromExamplesRemove, SLOT(map())); } } QApplication::connect( mapPresetsFromExamplesLoad, SIGNAL(mapped(QString)), this, SLOT(slotMenuLoadPreset(QString))); QApplication::connect(mapPresetsFromExamplesRemove, SIGNAL(mapped(QString)), this, SLOT(slotMenuRemovePreset(QString))); WriteLog("cInterface::PopulateToolbar(QWidget *window, QToolBar *toolBar) finished", 2); }