示例#1
0
void SceneSettingsPopup::setBgColor(const TPixel32 &bgColor, bool isDragging)
{
	TSceneProperties *sprop = getProperties();
	sprop->setBgColor(bgColor);
	// TODO: forse sarebbe meglio usare una notifica piu' specifica
	if (!isDragging)
		Previewer::clearAll();
	TApp::instance()->getCurrentScene()->notifySceneChanged();
}
示例#2
0
void SceneSettingsPopup::update()
{
	TSceneProperties *sprop = getProperties();

	QString str;
	m_frameRateFld->setValue(sprop->getOutputProperties()->getFrameRate());

	TPixel32 col1, col2;
	Preferences::instance()->getChessboardColors(col1, col2);
	m_bgColorFld->setChessboardColors(col1, col2);

	TPixel bgColor = sprop->getBgColor();
	m_bgColorFld->setColor(bgColor);

	m_fieldGuideFld->setValue(sprop->getFieldGuideSize());
	m_aspectRatioFld->setValue(sprop->getFieldGuideAspectRatio());

	UnitParameters::setFieldGuideAspectRatio(sprop->getFieldGuideAspectRatio());
	m_fullcolorSubsamplingFld->setValue(sprop->getFullcolorSubsampling());
	if (m_tlvSubsamplingFld)
		m_tlvSubsamplingFld->setValue(sprop->getTlvSubsampling());
	int markerDistance = 0, markerOffset = 0;
	sprop->getMarkers(markerDistance, markerOffset);
	m_markerIntervalFld->setValue(markerDistance);
	m_startFrameFld->setValue(markerOffset + 1);
}
示例#3
0
void SceneSettingsPopup::onFullColorSubsampEditingFinished()
{
	TSceneProperties *sprop = getProperties();
	int fullcolorSubsampling = sprop->getFullcolorSubsampling();
	int fullcolorSubsamplingFld = m_fullcolorSubsamplingFld->getValue();
	if (fullcolorSubsampling == fullcolorSubsamplingFld)
		return;
	sprop->setFullcolorSubsampling(fullcolorSubsamplingFld);
	TApp::instance()->getCurrentScene()->notifySceneChanged();
	TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}
示例#4
0
void SceneSettingsPopup::onFieldGuideSizeEditingFinished()
{
	TSceneProperties *sprop = getProperties();
	int fieldGuideSize = sprop->getFieldGuideSize();
	int fieldGuideSizefld = m_fieldGuideFld->text().toInt();
	if (fieldGuideSize == fieldGuideSizefld)
		return;
	sprop->setFieldGuideSize(fieldGuideSizefld);
	TApp::instance()->getCurrentScene()->notifySceneChanged();
	TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}
示例#5
0
void SceneSettingsPopup::onFieldGuideAspectRatioEditingFinished()
{
	TSceneProperties *sprop = getProperties();
	double fieldGuideAspectRatio = sprop->getFieldGuideAspectRatio();
	double aspectRatioFld = m_aspectRatioFld->text().toDouble();
	if (fieldGuideAspectRatio == aspectRatioFld)
		return;
	sprop->setFieldGuideAspectRatio(aspectRatioFld);
	TApp::instance()->getCurrentScene()->notifySceneChanged();
	TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
	UnitParameters::setFieldGuideAspectRatio(m_aspectRatioFld->text().toDouble());
}
示例#6
0
VectorizerParameters *VectorizerPopup::getParameters() const {
  assert(m_sceneHandle);

  ToonzScene *scene = m_sceneHandle->getScene();
  assert(scene);

  TSceneProperties *sceneProp = scene->getProperties();
  assert(sceneProp);

  assert(sceneProp->getVectorizerParameters());
  return sceneProp->getVectorizerParameters();
}
示例#7
0
void SceneSettingsPopup::onTlvSubsampEditingFinished()
{
	if (!m_tlvSubsamplingFld)
		return;
	TSceneProperties *sprop = getProperties();
	int tlvSubsampling = sprop->getTlvSubsampling();
	int tlvSubsamplingFld = m_tlvSubsamplingFld->getValue();
	if (tlvSubsamplingFld == tlvSubsampling)
		return;
	sprop->setTlvSubsampling(tlvSubsamplingFld);
	TApp::instance()->getCurrentScene()->notifySceneChanged();
	TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}
示例#8
0
void SceneSettingsPopup::onFrameRateEditingFinished()
{
	TSceneProperties *sprop = getProperties();
	double frameRate = sprop->getOutputProperties()->getFrameRate();
	double frameRateFldValue = m_frameRateFld->getValue();
	if (frameRate == frameRateFldValue)
		return;
	sprop->getOutputProperties()->setFrameRate(frameRateFldValue);
	TApp::instance()->getCurrentScene()->getScene()->updateSoundColumnFrameRate();
	TApp::instance()->getCurrentScene()->notifySceneChanged();
	TApp::instance()->getCurrentXsheet()->getXsheet()->updateFrameCount();
	TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}
示例#9
0
void SceneSettingsPopup::onStartFrameEditingFinished()
{
	TSceneProperties *sprop = getProperties();
	int distance, offset;
	sprop->getMarkers(distance, offset);
	int markerDistance = m_markerIntervalFld->text().toInt();
	int markerOffset = m_startFrameFld->text().toInt() - 1;
	assert(markerDistance == distance);
	if (offset == markerOffset)
		return;
	sprop->setMarkers(markerDistance, markerOffset);
	TApp::instance()->getCurrentScene()->notifySceneChanged();
	TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}
void RenderCommand::flashRender()
{
	ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
	TSceneProperties *sprop = scene->getProperties();
	FILE *fileP = fopen(m_fp, "wb");
	if (!fileP)
		return;
	ProgressDialog pb("rendering " + toQString(m_fp), "Cancel", 0, m_numFrames);
	pb.show();

	TDimension cameraSize = scene->getCurrentCamera()->getRes();
	double frameRate = sprop->getOutputProperties()->getFrameRate();
	TFlash flash(
		cameraSize.lx,
		cameraSize.ly,
		m_numFrames,
		frameRate,
		sprop->getOutputProperties()->getFileFormatProperties("swf"));
	flash.setBackgroundColor(sprop->getBgColor());

	std::vector<TXshSoundColumn *> columns;
	scene->getSoundColumns(columns);
	if (!columns.empty()) {
		TXsheet::SoundProperties *prop = new TXsheet::SoundProperties();
		prop->m_frameRate = frameRate;
		TSoundTrack *st = scene->getXsheet()->makeSound(prop);
		if (st)
			flash.putSound(st, 0);
	}

	int i = 0;
	for (i = 0; i < m_numFrames; ++i, m_r += m_stepd) {
		flash.beginFrame(m_step * i + 1);
		TRasterFxP rfx = buildSceneFx(scene, m_r, 0, false);
		assert(rfx);
		rfx->compute(flash, tround(m_r)); // WARNING: This should accept a DOUBLE...
#ifdef BRAVODEMO
		TRasterImageP ri(loadBravo(scene->getCurrentCamera()->getRes()));
		int lx = ri->getRaster()->getLx();
		int ly = ri->getRaster()->getLx();
		flash.pushMatrix();
		int dx = tround(0.1 * (cameraSize.lx - lx));
		int dy = tround(0.1 * (cameraSize.ly - ly));
		flash.multMatrix(TTranslation((cameraSize.lx - lx) / 2 - (dx > 0 ? dx : 0), -(cameraSize.ly - ly) / 2 + (dy > 0 ? dy : 0)));
		flash.draw(ri, 0);
		flash.popMatrix();
#endif
		flash.endFrame(i == m_numFrames - 1, 0, true);
		if (pb.wasCanceled())
			break;
		pb.setValue(i + 1);
	}

	flash.writeMovie(fileP);
	fclose(fileP);

	TSystem::showDocument(m_fp);
	//QDesktopServices::openUrl(QUrl(toQString(m_fp)));

	TImageCache::instance()->remove(toString(m_fp.getWideString() + L".0"));
	TNotifier::instance()->notify(TSceneNameChange());
}
bool RenderCommand::init(bool isPreview)
{
	ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
	TSceneProperties *sprop = scene->getProperties();
	/*-- Preview/Renderに応じてそれぞれのSettingを取得 --*/
	TOutputProperties &outputSettings = isPreview ? *sprop->getPreviewProperties() : *sprop->getOutputProperties();
	outputSettings.getRange(m_r0, m_r1, m_step);
	/*-- シーン全体のレンダリングの場合、m_r1をScene長に設定 --*/
	if (m_r0 == 0 && m_r1 == -1) {
		m_r0 = 0;
		m_r1 = scene->getFrameCount() - 1;
	}
	if (m_r0 < 0)
		m_r0 = 0;
	if (m_r1 >= scene->getFrameCount())
		m_r1 = scene->getFrameCount() - 1;
	if (m_r1 < m_r0) {
		MsgBox(WARNING, QObject::tr("The command cannot be executed because the scene is empty."));
		return false;
		// throw TException("empty scene");
		// non so perche', ma termina il programma
		// nonostante il try all'inizio
	}

	// Initialize the preview case

	/*TRenderSettings rs = sprop->getPreviewProperties()->getRenderSettings();
  TRenderSettings rso = sprop->getOutputProperties()->getRenderSettings();
  rs.m_stereoscopic=true;
  rs.m_stereoscopicShift=0.05;
  rso.m_stereoscopic=true;
  rso.m_stereoscopicShift=0.05;
  sprop->getPreviewProperties()->setRenderSettings(rs);
  sprop->getOutputProperties()->setRenderSettings(rso);*/

	if (isPreview) {
		/*-- PreviewではTimeStretchを考慮しないので、そのままフレーム値を格納してゆく --*/
		m_numFrames = (int)(m_r1 - m_r0 + 1);
		m_r = m_r0;
		m_stepd = m_step;
		m_multimediaRender = 0;
		return true;
	}

	// Full render case

	// Read the output filepath
	TFilePath fp = outputSettings.getPath();
	/*-- ファイル名が指定されていない場合は、シーン名を出力ファイル名にする --*/
	if (fp.getWideName() == L"")
		fp = fp.withName(scene->getScenePath().getName());
	/*-- ラスタ画像の場合、ファイル名にフレーム番号を追加 --*/
	if (TFileType::getInfo(fp) == TFileType::RASTER_IMAGE || fp.getType() == "pct" || fp.getType() == "pic" || fp.getType() == "pict") //pct e' un formato"livello" (ha i settings di quicktime) ma fatto di diversi frames
		fp = fp.withFrame(TFrameId::EMPTY_FRAME);
	fp = scene->decodeFilePath(fp);
	if (!TFileStatus(fp.getParentDir()).doesExist()) {
		try {
			TFilePath parent = fp.getParentDir();
			TSystem::mkDir(parent);
			DvDirModel::instance()->refreshFolder(parent.getParentDir());
		} catch (TException &e) {
			MsgBox(WARNING, QObject::tr("It is not possible to create folder : %1").arg(QString::fromStdString(toString(e.getMessage()))));
			return false;
		} catch (...) {
			MsgBox(WARNING, QObject::tr("It is not possible to create a folder."));
			return false;
		}
	}
	m_fp = fp;

	// Retrieve camera infos
	const TCamera *camera = isPreview ? scene->getCurrentPreviewCamera() : scene->getCurrentCamera();
	TDimension cameraSize = camera->getRes();
	TPointD cameraDpi = camera->getDpi();

	// Retrieve render interval/step/times
	double stretchTo = (double)outputSettings.getRenderSettings().m_timeStretchTo;
	double stretchFrom = (double)outputSettings.getRenderSettings().m_timeStretchFrom;

	m_timeStretchFactor = stretchTo / stretchFrom;
	m_stepd = m_step / m_timeStretchFactor;

	int stretchedR0 = tfloor(m_r0 * m_timeStretchFactor);
	int stretchedR1 = tceil((m_r1 + 1) * m_timeStretchFactor) - 1;

	m_r = stretchedR0 / m_timeStretchFactor;
	m_numFrames = (stretchedR1 - stretchedR0) / m_step + 1;

	// Update the multimedia render switch
	m_multimediaRender = outputSettings.getMultimediaRendering();

	return true;
}
bool VectorizerPopup::apply()
{
	std::set<TXshLevel *> levels;

	ToonzScene *scene = m_sceneHandle->getScene();
	if (!scene) {
		assert(scene);
		return false;
	}

	TSceneProperties *sceneProp = scene->getProperties();
	if (!sceneProp)
		return false;

	VectorizerParameters *vectorizerParameters = sceneProp->getVectorizerParameters();
	if (!vectorizerParameters)
		return false;

	int r0 = 0;
	int c0 = 0;
	int r1 = 0;
	int c1 = 0;
	bool isCellSelection = getSelectedLevels(levels, r0, c0, r1, c1);
	if (levels.empty()) {
		error(tr("The current selection is invalid."));
		return false;
	}

	//Initialize Progress bar
	m_progressDialog = new DVGui::ProgressDialog("", "Cancel", 0, 1);
	m_progressDialog->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint); //Don't show ? and X buttons
	m_progressDialog->setWindowTitle(QString("Convert To Vector..."));
	m_progressDialog->setAttribute(Qt::WA_DeleteOnClose);
	m_progressDialog->setWindowModality(Qt::WindowModal); //No user interaction is allowed during vectorization
	m_progressDialog->setFixedSize(200, 100);

	//Initialize vectorizer
	m_vectorizer = new Vectorizer;

	m_vectorizer->setParameters(*vectorizerParameters);

	connect(m_vectorizer, SIGNAL(frameName(QString)), this, SLOT(onFrameName(QString)), Qt::QueuedConnection);
	connect(m_vectorizer, SIGNAL(frameDone(int)), this, SLOT(onFrameDone(int)), Qt::QueuedConnection);
	connect(m_vectorizer, SIGNAL(partialDone(int, int)), this, SLOT(onPartialDone(int, int)), Qt::QueuedConnection);
	//We DON'T want the progress bar to be hidden at cancel press - since its modal
	//behavior prevents the user to interfere with a possibly still active vectorization.
	disconnect(m_progressDialog, SIGNAL(canceled()), m_progressDialog, SLOT(onCancel()));
	//We first inform the vectorizer of a cancel press;
	bool ret = connect(m_progressDialog, SIGNAL(canceled()), m_vectorizer, SLOT(cancel()));
	//which eventually transmits the command to vectorization core, allowing full-time cancels
	ret = ret && connect(m_progressDialog, SIGNAL(canceled()), m_vectorizer, SIGNAL(transmitCancel()));
	//Only after the vectorizer has terminated its process - or got cancelled, we are allowed
	//to proceed here.
	ret = ret && connect(m_vectorizer, SIGNAL(finished()), this, SLOT(onFinished()), Qt::QueuedConnection);
	assert(ret);

	int newIndexColumn = c1 + 1;
	std::set<TXshLevel *>::iterator it = levels.begin();
	for (it; it != levels.end(); it++) {
		TXshSimpleLevel *sl = dynamic_cast<TXshSimpleLevel *>(*it);
		if (!sl || !sl->getSimpleLevel() || !isLevelToConvert(sl)) {
			QString levelName = tr(toString(sl->getName()).c_str());
			QString errorMsg = tr("Cannot convert to vector the current selection.") + levelName;
			error(errorMsg);
			continue;
		}

		std::vector<TFrameId> fids;

		if (isCellSelection)
			getSelectedFids(fids, sl, r0, c0, r1, c1);
		else
			sl->getFids(fids);
		assert(fids.size() > 0);

		close();

		// Re-initialize progress Bar
		m_progressDialog->setMaximum(fids.size() * 100);
		m_progressDialog->setValue(0);
		m_currFrame = 0;

		// Re-initialize vectorizer
		m_vectorizer->setLevel(sl);
		m_vectorizer->setFids(fids);

		// Start vectorizing
		m_vectorizer->start();
		m_progressDialog->show();

		// Wait the vectorizer...
		while (!l_quitLoop)
			QCoreApplication::processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents);

		l_quitLoop = false;

		// Assign output X-sheet cells
		TXshSimpleLevel *vl = m_vectorizer->getVectorizedLevel();
		if (isCellSelection && vl) {
			TXsheet *xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
			xsheet->insertColumn(newIndexColumn);

			int r, c;
			for (c = c0; c <= c1; c++) {
				for (r = r0; r <= r1; r++) {
					TXshCell cell = xsheet->getCell(r, c);
					TXshSimpleLevel *level = (!cell.isEmpty()) ? cell.getSimpleLevel()
															   : 0;
					if (level != sl)
						continue;
					TFrameId curFid = cell.getFrameId();
					std::vector<TFrameId> newFids;
					vl->getFids(newFids);
					std::vector<TFrameId>::iterator it1 = newFids.begin();
					for (it1; it1 != newFids.end(); it1++) {
						TFrameId id = *it1;
						if (id.getNumber() == curFid.getNumber() ||			   // Hanno stesso numero di frame
							(id.getNumber() == 1 && curFid.getNumber() == -2)) // La vecchia cella non ha numero di frame
							xsheet->setCell(r, newIndexColumn, TXshCell(vl, id));
					}
				}
			}
			newIndexColumn += 1;
		} else if (vl) {
			std::vector<TFrameId> gomi;
			scene->getXsheet()->exposeLevel(0, scene->getXsheet()->getFirstFreeColumnIndex(), vl, gomi);
		}

		if (m_vectorizer->isCanceled())
			break;
	}

	m_progressDialog->close();
	delete m_vectorizer;

	TApp::instance()->getCurrentScene()->notifyCastChange();
	TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();

	return true;
}
示例#13
0
SceneSettingsPopup::SceneSettingsPopup()
	: QDialog(TApp::instance()->getMainWindow())
{
	setWindowTitle(tr("Scene Settings"));
	setObjectName("SceneSettings");
	TSceneProperties *sprop = getProperties();

	//Frame Rate
	double frameRate = sprop->getOutputProperties()->getFrameRate();
	m_frameRateFld = new DoubleLineEdit(this, frameRate);
	m_frameRateFld->setRange(1, 100);
	m_frameRateFld->setDecimals(2);

	//Camera BG color
	m_bgColorFld = new ColorField(this, true, sprop->getBgColor());

	//Field Guide Size - A/R
	int fieldGuideSize = sprop->getFieldGuideSize();
	m_fieldGuideFld = new IntLineEdit(this, fieldGuideSize, 0, 50);
	m_aspectRatioFld = new DoubleLineEdit(this, 1.38);
	m_aspectRatioFld->setRange(-10000.0, 10000.0);
	m_aspectRatioFld->setDecimals(5);

	//Image Subsampling  - Tlv Subsampling
	int fullcolorSubsampling = sprop->getFullcolorSubsampling();
	m_fullcolorSubsamplingFld = new IntLineEdit(this, fullcolorSubsampling, 1);

	int tlvSubsampling = sprop->getTlvSubsampling();
	m_tlvSubsamplingFld = new IntLineEdit(this, tlvSubsampling, 1);

	//Marker Interval - Start Frame
	int distance, offset;
	sprop->getMarkers(distance, offset);
	m_markerIntervalFld = new IntLineEdit(this, distance, 0);
	m_startFrameFld = new IntLineEdit(this, offset);

	// layout
	QGridLayout *mainLayout = new QGridLayout();
	mainLayout->setMargin(10);
	mainLayout->setHorizontalSpacing(5);
	mainLayout->setVerticalSpacing(15);
	{
		//Frame Rate
		mainLayout->addWidget(new QLabel(tr("Frame Rate:"), this), 0, 0, Qt::AlignRight | Qt::AlignVCenter);
		mainLayout->addWidget(m_frameRateFld, 0, 1);
		//Camera BG color
		mainLayout->addWidget(new QLabel(tr("Camera BG Color:"), this), 1, 0, Qt::AlignRight | Qt::AlignVCenter);
		mainLayout->addWidget(m_bgColorFld, 1, 1, 1, 4);
		//Field Guide Size - A/R
		mainLayout->addWidget(new QLabel(tr("Field Guide Size:"), this), 2, 0, Qt::AlignRight | Qt::AlignVCenter);
		mainLayout->addWidget(m_fieldGuideFld, 2, 1);
		mainLayout->addWidget(new QLabel(tr("A/R:"), this), 2, 2, Qt::AlignRight | Qt::AlignVCenter);
		mainLayout->addWidget(m_aspectRatioFld, 2, 3);
		//Image Subsampling  - Tlv Subsampling
		mainLayout->addWidget(new QLabel(tr("Image Subsampling:"), this), 3, 0, Qt::AlignRight | Qt::AlignVCenter);
		mainLayout->addWidget(m_fullcolorSubsamplingFld, 3, 1);
		if (m_tlvSubsamplingFld) {
			mainLayout->addWidget(new QLabel(tr("TLV Subsampling:"), this), 4, 0, Qt::AlignRight | Qt::AlignVCenter);
			mainLayout->addWidget(m_tlvSubsamplingFld, 4, 1);
		}
		//Marker Interval - Start Frame
		mainLayout->addWidget(new QLabel(tr("Marker Interval:"), this), 5, 0, Qt::AlignRight | Qt::AlignVCenter);
		mainLayout->addWidget(m_markerIntervalFld, 5, 1);
		mainLayout->addWidget(new QLabel(tr("  Start Frame:"), this), 5, 2, Qt::AlignRight | Qt::AlignVCenter);
		mainLayout->addWidget(m_startFrameFld, 5, 3);
	}
	mainLayout->setColumnStretch(0, 0);
	mainLayout->setColumnStretch(1, 0);
	mainLayout->setColumnStretch(2, 0);
	mainLayout->setColumnStretch(3, 0);
	mainLayout->setColumnStretch(4, 1);
	mainLayout->setRowStretch(6, 1);
	setLayout(mainLayout);

	//signal-slot connections
	bool ret = true;
	//Frame Rate
	ret = ret && connect(m_frameRateFld, SIGNAL(editingFinished()), this, SLOT(onFrameRateEditingFinished()));
	//Camera BG color
	ret = ret && connect(m_bgColorFld, SIGNAL(colorChanged(const TPixel32 &, bool)), this, SLOT(setBgColor(const TPixel32 &, bool)));
	//Field Guide Size - A/R
	ret = ret && connect(m_fieldGuideFld, SIGNAL(editingFinished()), this, SLOT(onFieldGuideSizeEditingFinished()));
	ret = ret && connect(m_aspectRatioFld, SIGNAL(editingFinished()), this, SLOT(onFieldGuideAspectRatioEditingFinished()));
	//Image Subsampling  - Tlv Subsampling
	ret = ret && connect(m_fullcolorSubsamplingFld, SIGNAL(editingFinished()), this, SLOT(onFullColorSubsampEditingFinished()));
	if (m_tlvSubsamplingFld)
		ret = ret && connect(m_tlvSubsamplingFld, SIGNAL(editingFinished()), this, SLOT(onTlvSubsampEditingFinished()));
	//Marker Interval - Start Frame
	ret = ret && connect(m_markerIntervalFld, SIGNAL(editingFinished()), this, SLOT(onMakerIntervalEditingFinished()));
	ret = ret && connect(m_startFrameFld, SIGNAL(editingFinished()), this, SLOT(onStartFrameEditingFinished()));
	assert(ret);
}