void RenderCommand::rasterRender(bool isPreview) { ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); if (isPreview) { //Let the PreviewFxManager own the rest. Just pass him the current output node. PreviewFxManager::instance()->showNewPreview((TFx *)scene->getXsheet()->getFxDag()->getCurrentOutputFx()); return; } string ext = m_fp.getType(); #ifdef WIN32 if (ext == "avi" && !isPreview) { TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext); string codecName = props->getProperty(0)->getValueAsString(); TDimension res = scene->getCurrentCamera()->getRes(); if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) { QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format.")); MsgBox(WARNING, msg); return; } } #endif; //Extract output properties TOutputProperties *prop = isPreview ? scene->getProperties()->getPreviewProperties() : scene->getProperties()->getOutputProperties(); //Build thread count /*-- Dedicated CPUs のコンボボックス (Single, Half, All) --*/ int index = prop->getThreadIndex(); const int procCount = TSystem::getProcessorCount(); const int threadCounts[3] = {1, procCount / 2, procCount}; int threadCount = threadCounts[index]; /*-- MovieRendererを作る。Previewの場合はファイルパスは空 --*/ MovieRenderer movieRenderer(scene, isPreview ? TFilePath() : m_fp, threadCount, isPreview); TRenderSettings rs = prop->getRenderSettings(); //Build raster granularity size index = prop->getMaxTileSizeIndex(); const int maxTileSizes[4] = { (std::numeric_limits<int>::max)(), TOutputProperties::LargeVal, TOutputProperties::MediumVal, TOutputProperties::SmallVal}; rs.m_maxTileSize = maxTileSizes[index]; //Build #ifdef BRAVODEMO rs.m_mark = loadBravo(scene->getCurrentCamera()->getRes()); #endif /*-- RenderSettingsをセット --*/ movieRenderer.setRenderSettings(rs); /*-- カメラDPIの取得、セット --*/ TPointD cameraDpi = isPreview ? scene->getCurrentPreviewCamera()->getDpi() : scene->getCurrentCamera()->getDpi(); movieRenderer.setDpi(cameraDpi.x, cameraDpi.y); movieRenderer.enablePrecomputing(true); /*-- プログレス ダイアログの作成 --*/ RenderListener *listener = new RenderListener(movieRenderer.getTRenderer(), m_fp, ((m_numFrames - 1) / m_step) + 1, isPreview); QObject::connect(listener, SIGNAL(canceled()), &movieRenderer, SLOT(onCanceled())); movieRenderer.addListener(listener); bool fieldRendering = rs.m_fieldPrevalence != TRenderSettings::NoField; /*-- buildSceneFxの進行状況を表示するプログレスバー --*/ QProgressBar *buildSceneProgressBar = new QProgressBar(TApp::instance()->getMainWindow()); buildSceneProgressBar->setAttribute(Qt::WA_DeleteOnClose); buildSceneProgressBar->setWindowFlags(Qt::SubWindow | Qt::Dialog | Qt::WindowStaysOnTopHint); buildSceneProgressBar->setMinimum(0); buildSceneProgressBar->setMaximum(m_numFrames - 1); buildSceneProgressBar->setValue(0); buildSceneProgressBar->move(600, 500); buildSceneProgressBar->setWindowTitle("Building Schematic..."); buildSceneProgressBar->show(); for (int i = 0; i < m_numFrames; ++i, m_r += m_stepd) { buildSceneProgressBar->setValue(i); if (rs.m_stereoscopic) scene->shiftCameraX(-rs.m_stereoscopicShift / 2); TFxPair fx; fx.m_frameA = buildSceneFx(scene, m_r, rs.m_shrinkX, isPreview); if (fieldRendering && !isPreview) fx.m_frameB = buildSceneFx(scene, m_r + 0.5 / m_timeStretchFactor, rs.m_shrinkX, isPreview); else if (rs.m_stereoscopic) { scene->shiftCameraX(rs.m_stereoscopicShift); fx.m_frameB = buildSceneFx(scene, m_r + 0.5 / m_timeStretchFactor, rs.m_shrinkX, isPreview); scene->shiftCameraX(-rs.m_stereoscopicShift / 2); } else fx.m_frameB = TRasterFxP(); /*-- movieRendererにフレーム毎のFxを登録 --*/ movieRenderer.addFrame(m_r, fx); } /*-- プログレスバーを閉じる --*/ buildSceneProgressBar->close(); //resetViewer(); //TODO cancella le immagini dell'eventuale render precedente //FileViewerPopupPool::instance()->getCurrent()->onClose(); movieRenderer.start(); }
void MetaEditorSupportPlugin::generateEditorWithQrmc() { qrmc::MetaCompiler metaCompiler(*mLogicalRepoApi, "."); IdList const metamodels = mLogicalRepoApi->children(Id::rootId()); QProgressBar *progress = new QProgressBar(mMainWindowInterface->windowWidget()); progress->show(); int const progressBarWidth = 240; int const progressBarHeight = 20; QApplication::processEvents(); QRect const screenRect = qApp->desktop()->availableGeometry(); progress->move(screenRect.width() / 2 - progressBarWidth / 2, screenRect.height() / 2 - progressBarHeight / 2); progress->setFixedWidth(progressBarWidth); progress->setFixedHeight(progressBarHeight); progress->setRange(0, 100); int forEditor = 60 / metamodels.size(); foreach (Id const &key, metamodels) { QString const objectType = key.element(); if (objectType == "MetamodelDiagram" && mLogicalRepoApi->isLogicalElement(key)) { QString nameOfTheDirectory = mLogicalRepoApi->stringProperty(key, "name of the directory"); QString nameOfMetamodel = mLogicalRepoApi->stringProperty(key, "name"); QString nameOfPlugin = nameOfTheDirectory.split("/").last(); if (QMessageBox::question(mMainWindowInterface->windowWidget() , tr("loading..") , QString(tr("Do you want to compile and load editor %1?")).arg(nameOfPlugin) , QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) { continue; } progress->setValue(5); const QString normalizedName = nameOfMetamodel.at(0).toUpper() + nameOfMetamodel.mid(1); const bool stateOfLoad = mMainWindowInterface->pluginLoaded(normalizedName); if (!mMainWindowInterface->unloadPlugin(normalizedName)) { progress->close(); delete progress; return; } if (!metaCompiler.compile(nameOfMetamodel)) { // generating source code for all metamodels QMessageBox::warning(mMainWindowInterface->windowWidget() , tr("error") , tr("Cannot generate source code for editor ") + nameOfPlugin); continue; } progress->setValue(20); QStringList qmakeArgs; qmakeArgs.append("CONFIG+=" + mLogicalRepoApi->stringProperty(key, "buildConfiguration")); qmakeArgs.append(nameOfMetamodel + ".pro"); QProcess builder; builder.setWorkingDirectory(nameOfTheDirectory); const QStringList environment = QProcess::systemEnvironment(); builder.setEnvironment(environment); builder.start(SettingsManager::value("pathToQmake").toString(), qmakeArgs); qDebug() << "qmake"; if ((builder.waitForFinished()) && (builder.exitCode() == 0)) { progress->setValue(40); builder.start(SettingsManager::value("pathToMake").toString()); bool finished = builder.waitForFinished(100000); qDebug() << "make"; if (finished && (builder.exitCode() == 0)) { if (stateOfLoad) { QMessageBox::warning(mMainWindowInterface->windowWidget() , tr("Attention!"), tr("Please restart QReal.")); progress->close(); delete progress; return; } qDebug() << "make ok"; progress->setValue(progress->value() + forEditor / 2); if (!nameOfMetamodel.isEmpty()) { if (!mMainWindowInterface->unloadPlugin(normalizedName)) { QMessageBox::warning(mMainWindowInterface->windowWidget() , tr("error") , tr("cannot unload plugin ") + normalizedName); progress->close(); delete progress; continue; } } QString suffix = ""; if (mLogicalRepoApi->stringProperty(key, "buildConfiguration") == "debug") { suffix = "-d"; } QString const generatedPluginFileName = SettingsManager::value("prefix").toString() + nameOfMetamodel + suffix + "." + SettingsManager::value("pluginExtension").toString() ; if (mMainWindowInterface->loadPlugin(generatedPluginFileName, normalizedName)) { progress->setValue(progress->value() + forEditor / 2); } } progress->setValue(100); } } }
MainWindow::MainWindow() : mUi(new Ui::MainWindowUi()) , mListenerManager(NULL) , mPropertyModel(NULL) { QSettings settings("SPbSU", "QReal"); //bool showSplash = settings.value("Splashscreen", true).toBool(); bool showSplash = false; QSplashScreen* splash = new QSplashScreen(QPixmap(":/icons/kroki3.PNG"), Qt::SplashScreen | Qt::WindowStaysOnTopHint); QProgressBar *progress = new QProgressBar((QWidget*) splash); progress->move(20,270); progress->setFixedWidth(600); progress->setFixedHeight(15); progress->setRange(0, 100); // Step 1: splash screen loaded, progress bar initialized. progress->setValue(5); if (showSplash) { splash->show(); QApplication::processEvents(); } mUi->setupUi(this); #if defined(Q_WS_WIN) mUi->menuSvn->setEnabled(false); // Doesn't work under Windows anyway. #endif mUi->tabs->setTabsClosable(true); mUi->tabs->setMovable(true); if (!showSplash) mUi->actionShowSplash->setChecked(false); mUi->minimapView->setRenderHint(QPainter::Antialiasing, true); // Step 2: Ui is ready, splash screen shown. progress->setValue(20); mUi->actionShow_grid->setChecked(settings.value("ShowGrid", true).toBool()); mUi->actionShow_alignment->setChecked(settings.value("ShowAlignment", true).toBool()); mUi->actionSwitch_on_grid->setChecked(settings.value("ActivateGrid", false).toBool()); mUi->actionSwitch_on_alignment->setChecked(settings.value("ActivateAlignment", true).toBool()); connect(mUi->actionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(mUi->actionShowSplash, SIGNAL(toggled(bool)), this, SLOT (toggleShowSplash(bool))); connect(mUi->actionOpen, SIGNAL(triggered()), this, SLOT(open())); connect(mUi->actionSave, SIGNAL(triggered()), this, SLOT(saveAll())); connect(mUi->actionSave_as, SIGNAL(triggered()), this, SLOT(saveAs())); connect(mUi->actionPrint, SIGNAL(triggered()), this, SLOT(print())); connect(mUi->actionMakeSvg, SIGNAL(triggered()), this, SLOT(makeSvg())); connect(mUi->actionDeleteFromDiagram, SIGNAL(triggered()), this, SLOT(deleteFromDiagram())); connect(mUi->tabs, SIGNAL(currentChanged(int)), this, SLOT(changeMiniMapSource(int))); connect(mUi->tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(mUi->actionCheckout, SIGNAL(triggered()), this, SLOT(doCheckout())); connect(mUi->actionCommit, SIGNAL(triggered()), this, SLOT(doCommit())); connect(mUi->actionExport_to_XMI, SIGNAL(triggered()), this, SLOT(exportToXmi())); connect(mUi->actionGenerate_to_Java, SIGNAL(triggered()), this, SLOT(generateToJava())); connect(mUi->actionGenerate_to_Hascol, SIGNAL(triggered()), this, SLOT(generateToHascol())); connect(mUi->actionShape_Edit, SIGNAL(triggered()), this, SLOT(openShapeEditor())); connect(mUi->actionGenerate_Editor, SIGNAL(triggered()), this, SLOT(generateEditor())); connect(mUi->actionGenerate_Editor_qrmc, SIGNAL(triggered()), this, SLOT(generateEditorWithQRMC())); connect(mUi->actionParse_Editor_xml, SIGNAL(triggered()), this, SLOT(parseEditorXml())); connect(mUi->actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferencesDialog())); connect(mUi->actionParse_Hascol_sources, SIGNAL(triggered()), this, SLOT(parseHascol())); connect(mUi->actionParse_Java_Libraries, SIGNAL(triggered()), this, SLOT(parseJavaLibraries())); connect(mUi->actionPlugins, SIGNAL(triggered()), this, SLOT(settingsPlugins())); connect(mUi->actionShow_grid, SIGNAL(toggled(bool)), this, SLOT(showGrid(bool))); connect(mUi->actionShow_alignment, SIGNAL(toggled(bool)), this, SLOT(showAlignment(bool))); connect(mUi->actionSwitch_on_grid, SIGNAL(toggled(bool)), this, SLOT(switchGrid(bool))); connect(mUi->actionSwitch_on_alignment, SIGNAL(toggled(bool)), this, SLOT(switchAlignment(bool))); connect(mUi->actionHelp, SIGNAL(triggered()), this, SLOT(showHelp())); connect(mUi->actionAbout, SIGNAL(triggered()), this, SLOT(showAbout())); connect(mUi->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(mUi->actionShow, SIGNAL(triggered()), this, SLOT(showGestures())); connect(mUi->minimapZoomSlider, SIGNAL(valueChanged(int)), this, SLOT(adjustMinimapZoom(int))); connect(mUi->actionDebug, SIGNAL(triggered()), this, SLOT(debug())); connect(mUi->actionDebug_Single_step, SIGNAL(triggered()), this, SLOT(debugSingleStep())); connect(mUi->actionClear, SIGNAL(triggered()), this, SLOT(exterminate())); connect(mUi->save_metamodel, SIGNAL(triggered()), this, SLOT(saveMetaModel())); adjustMinimapZoom(mUi->minimapZoomSlider->value()); initGridProperties(); // Step 3: Ui connects are done. progress->setValue(40); QString workingDir = settings.value("workingDir", ".").toString(); mRootIndex = QModelIndex(); mModels = new models::Models(workingDir, mEditorManager); mPropertyModel = new PropertyEditorModel(mEditorManager, mModels->logicalModelAssistApi()); mUi->paletteDock->setWidget(mUi->paletteToolbox); mUi->errorDock->setWidget(mUi->errorListWidget); mUi->errorListWidget->init(this); mUi->errorDock->setVisible(false); mUi->propertyEditor->setModel(mPropertyModel); mUi->propertyEditor->verticalHeader()->hide(); mUi->propertyEditor->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); mUi->propertyEditor->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch); mUi->propertyEditor->setItemDelegate(&mDelegate); connect(mUi->graphicalModelExplorer, SIGNAL(clicked(QModelIndex const &)), this, SLOT(graphicalModelExplorerClicked(QModelIndex))); connect(mUi->logicalModelExplorer, SIGNAL(clicked(QModelIndex const &)), this, SLOT(logicalModelExplorerClicked(QModelIndex))); mUi->graphicalModelExplorer->addAction(mUi->actionDeleteFromDiagram); mUi->logicalModelExplorer->addAction(mUi->actionDeleteFromDiagram); // Step 4: Property editor and model explorers are initialized. progress->setValue(60); loadPlugins(); showMaximized(); // Step 5: Plugins are loaded. progress->setValue(70); settings.beginGroup("MainWindow"); if (!settings.value("maximized", true).toBool()) { showNormal(); resize(settings.value("size", QSize(1024, 800)).toSize()); move(settings.value("pos", QPoint(0, 0)).toPoint()); } settings.endGroup(); // Step 6: Save loaded, models initialized. progress->setValue(80); mListenerManager = new ListenerManager(mEditorManager.listeners() , mModels->logicalModelAssistApi(), mModels->graphicalModelAssistApi()); TypeList missingPlugins = mEditorManager.checkNeededPlugins(mModels->logicalRepoApi(), mModels->graphicalRepoApi()); if (!missingPlugins.isEmpty()) { QString text = "These plugins are not present, but needed to load the save:\n"; foreach (NewType const type, missingPlugins) { text += type.editor() + "\n"; QMessageBox::warning(this, tr("Some plugins are missing"), text); close(); return; }
void ProfileWizard::createProfile(int result) { if (_profile_edit->isComplete() ) { bts::profile_config conf; conf.firstname = _profile_edit->ui.first_name->text().toUtf8().constData(); conf.firstname = fc::trim( conf.firstname ); conf.middlename = _profile_edit->ui.middle_name->text().toUtf8().constData(); conf.middlename = fc::trim( conf.middlename ); conf.lastname = _profile_edit->ui.last_name->text().toUtf8().constData(); conf.lastname = fc::trim( conf.lastname ); conf.brainkey = _profile_edit->ui.brainkey->text().toUtf8().constData(); conf.brainkey = fc::trim( conf.brainkey ); std::string password = _profile_edit->ui.local_password1->text().toUtf8().constData(); std::string profile_name = conf.firstname + " " + conf.lastname; auto app = bts::application::instance(); fc::thread* main_thread = &fc::thread::current(); QProgressBar* progress = new QProgressBar(); progress->setWindowTitle( "Creating Profile" ); progress->setMaximum(1000); progress->resize( 640, 20 ); progress->show(); int x=(qApp->desktop()->width() - progress->width())/2; int y=(qApp->desktop()->height() - progress->height())/2; progress->move(x,y); auto profile = app->create_profile(profile_name, conf, password, [=]( double p ) { main_thread->async( [=](){ progress->setValue( 1000*p ); qApp->sendPostedEvents(); qApp->processEvents(); if( p >= 1.0 ) progress->deleteLater(); } ).wait(); } ); assert(profile != nullptr); //store myself as contact /* std::string dac_id_string = _nym_page->_profile_nym_ui.keyhotee_id->text().toStdString(); bts::addressbook::wallet_contact myself; myself.wallet_index = 0; myself.first_name = conf.firstname; myself.last_name = conf.lastname; myself.set_dac_id(dac_id_string); auto priv_key = profile->get_keychain().get_identity_key(myself.dac_id_string); myself.public_key = priv_key.get_public_key(); profile->get_addressbook()->store_contact(myself); //store myself as identity bts::addressbook::wallet_identity new_identity; static_cast<bts::addressbook::contact&>(new_identity) = myself; profile->store_identity(new_identity); bts::application::instance()->add_receive_key(priv_key); */ _mainApp.displayMainWindow(); } }
void ProgressListDelegate::updateItemWidgets(const QList<QWidget*> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const { if (!index.isValid()) { return; } QPushButton *pauseResumeButton = static_cast<QPushButton*>(widgets[0]); QPushButton *cancelButton = static_cast<QPushButton*>(widgets[1]); cancelButton->setToolTip(i18n("Cancel")); QProgressBar *progressBar = static_cast<QProgressBar*>(widgets[2]); QPushButton *clearButton = static_cast<QPushButton*>(widgets[3]); int percent = d->getPercent(index); cancelButton->setVisible(percent < 100); pauseResumeButton->setVisible(percent < 100); clearButton->setVisible(percent > 99); KJob::Capabilities capabilities = (KJob::Capabilities) index.model()->data(index, JobView::Capabilities).toInt(); cancelButton->setEnabled(capabilities & KJob::Killable); pauseResumeButton->setEnabled(capabilities & KJob::Suspendable); JobView::JobState state = (JobView::JobState) index.model()->data(index, JobView::State).toInt(); switch (state) { case JobView::Running: pauseResumeButton->setToolTip(i18n("Pause")); pauseResumeButton->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-pause"))); break; case JobView::Suspended: pauseResumeButton->setToolTip(i18n("Resume")); pauseResumeButton->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start"))); break; default: Q_ASSERT(0); break; } QSize progressBarButtonSizeHint; if (percent < 100) { QSize cancelButtonSizeHint = cancelButton->sizeHint(); cancelButton->move(option.rect.width() - d->separatorPixels - cancelButtonSizeHint.width(), option.rect.height() - d->separatorPixels - cancelButtonSizeHint.height()); QSize pauseResumeButtonSizeHint = pauseResumeButton->sizeHint(); pauseResumeButton->move(option.rect.width() - d->separatorPixels * 2 - pauseResumeButtonSizeHint.width() - cancelButtonSizeHint.width(), option.rect.height() - d->separatorPixels - pauseResumeButtonSizeHint.height()); progressBarButtonSizeHint = pauseResumeButtonSizeHint; } else { progressBarButtonSizeHint = clearButton->sizeHint(); clearButton->resize(progressBarButtonSizeHint); clearButton->move(option.rect.width() - d->separatorPixels - progressBarButtonSizeHint.width(), option.rect.height() - d->separatorPixels - progressBarButtonSizeHint.height()); } progressBar->setValue(percent); QFontMetrics fm(QApplication::font()); QSize progressBarSizeHint = progressBar->sizeHint(); progressBar->resize(QSize(option.rect.width() - d->getCurrentLeftMargin(fm.height()) - d->rightMargin, progressBarSizeHint.height())); progressBar->move(d->getCurrentLeftMargin(fm.height()), option.rect.height() - d->separatorPixels * 2 - progressBarButtonSizeHint.height() - progressBarSizeHint.height()); }