Пример #1
0
void TApp::onFrameSwitched() {
  updateXshLevel();
  int row = m_currentFrame->getFrameIndex();
  TCellSelection *sel =
      dynamic_cast<TCellSelection *>(TSelection::getCurrent());

  if (sel && !sel->isRowSelected(row)) {
    sel->selectNone();
  }
}
Пример #2
0
void PaletteViewerPanel::onCurrentButtonToggled(bool isCurrent) {
  if (isActive() == isCurrent) return;

  TApp *app          = TApp::instance();
  TPaletteHandle *ph = app->getPaletteController()->getCurrentLevelPalette();
  // Se sono sulla palette del livello corrente e le palette e' vuota non
  // consento di bloccare il pannello.
  if (isActive() && !ph->getPalette()) {
    m_isCurrentButton->setPressed(true);
    return;
  }

  setActive(isCurrent);
  m_paletteViewer->enableSaveAction(isCurrent);

  // Cambio il livello corrente
  if (isCurrent) {
    std::set<TXshSimpleLevel *> levels;
    TXsheet *xsheet = app->getCurrentXsheet()->getXsheet();
    int row, column;
    findPaletteLevels(levels, row, column, m_paletteHandle->getPalette(),
                      xsheet);
    // Se non trovo livelli riferiti alla palette setto il palette viewer alla
    // palette del livello corrente.
    if (levels.empty()) {
      m_paletteViewer->setPaletteHandle(ph);
      update();
      return;
    }
    TXshSimpleLevel *level = *levels.begin();
    // Se sto editando l'xsheet devo settare come corrente anche la colonna e il
    // frame.
    if (app->getCurrentFrame()->isEditingScene()) {
      int currentColumn = app->getCurrentColumn()->getColumnIndex();
      if (currentColumn != column)
        app->getCurrentColumn()->setColumnIndex(column);
      int currentRow = app->getCurrentFrame()->getFrameIndex();
      TXshCell cell  = xsheet->getCell(currentRow, column);
      if (cell.isEmpty() || cell.getSimpleLevel() != level)
        app->getCurrentFrame()->setFrameIndex(row);

      TCellSelection *selection = dynamic_cast<TCellSelection *>(
          app->getCurrentSelection()->getSelection());
      if (selection) selection->selectNone();
    }
    app->getCurrentLevel()->setLevel(level);
    m_paletteViewer->setPaletteHandle(ph);
  } else {
    m_paletteHandle->setPalette(ph->getPalette());
    m_paletteViewer->setPaletteHandle(m_paletteHandle);
  }
  update();
}
Пример #3
0
void TimeStretchPopup::updateValues(TSelection *selection) {
  int from = 0, to = 0, newRange = 0;
  if (m_currentStretchType == eWholeXsheet) {
    TXsheet *xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
    newRange        = xsheet->getFrameCount();
  } else {
    TCellSelection *cellCelection = dynamic_cast<TCellSelection *>(selection);
    if (cellCelection) {
      int c0, c1;
      cellCelection->getSelectedCells(from, c0, to, c1);
      newRange = to - from + 1;
    }
  }

  m_newRangeFld->setText(QString::number(newRange));
  m_oldRange->setText(QString::number(newRange));
}
Пример #4
0
int BinarizePopup::getSelectedFrames()
{
	m_frames.clear();
	TSelection *selection = TSelection::getCurrent();
	TCellSelection *cellSelection;
	TFilmstripSelection *filmstripSelection;
	int count = 0;
	if ((cellSelection = dynamic_cast<TCellSelection *>(selection))) {
		std::set<TRasterImage *> images;
		int r0, c0, r1, c1;
		cellSelection->getSelectedCells(r0, c0, r1, c1);
		TXsheet *xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
		int c, r;
		for (c = c0; c <= c1; c++) {
			for (r = r0; r <= r1; r++) {
				TXshCell cell = xsheet->getCell(r, c);
				TRasterImageP rasImage = cell.getImage(false);
				if (!rasImage || !rasImage->getRaster())
					continue;
				Frames::value_type item(cell.getSimpleLevel(), cell.getFrameId());
				Frames::iterator it;
				it = std::lower_bound(m_frames.begin(), m_frames.end(), item);
				if (it == m_frames.end() || *it != item) {
					m_frames.insert(it, item);
					count++;
				}
			}
		}
	} else if ((filmstripSelection = dynamic_cast<TFilmstripSelection *>(selection))) {
		TXshSimpleLevel *sl = TApp::instance()->getCurrentLevel()->getSimpleLevel();
		if (sl) {
			std::set<TFrameId> fids = filmstripSelection->getSelectedFids();
			std::set<TFrameId>::iterator it;
			for (it = fids.begin(); it != fids.end(); ++it) {
				TRasterImageP rasImage = sl->getFrame(*it, false);
				if (!!rasImage && !!rasImage->getRaster()) {
					m_frames.push_back(std::make_pair(sl, *it));
					count++;
				}
			}
		}
	} else {
	}
	m_frameIndex = 0;
	return count;
}
Пример #5
0
void AntialiasPopup::apply()
{
	TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(TSelection::getCurrent());
	int threshold = m_thresholdField->getValue();
	int softness = m_softnessField->getValue();
	if (cellSelection) {
		std::set<TImage *> images;
		int r0, c0, r1, c1;
		cellSelection->getSelectedCells(r0, c0, r1, c1);
		TXsheet *xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
		bool oneImageChanged = false;
		int c, r;
		TUndoManager::manager()->beginBlock();
		for (c = c0; c <= c1; c++)
			for (r = r0; r <= r1; r++) {
				TXshCell cell = xsheet->getCell(r, c);
				TImageP image = cell.getImage(true);
				if (!image)
					continue;
				if (images.find(image.getPointer()) != images.end())
					continue;
				TRasterP ras = image->raster();
				if (!ras)
					continue;
				images.insert(image.getPointer());
				oneImageChanged = true;
				TUndoManager::manager()->add(new TRasterAntialiasUndo(threshold, softness, r, c, ras->clone()));
				onChange(ras, threshold, softness);
				TXshSimpleLevel *simpleLevel = cell.getSimpleLevel();
				assert(simpleLevel);
				simpleLevel->touchFrame(cell.getFrameId());
				simpleLevel->setDirtyFlag(true);
				IconGenerator::instance()->invalidate(simpleLevel, cell.getFrameId());
			}
		TUndoManager::manager()->endBlock();
		if (oneImageChanged) {
			close();
			return;
		}
	}
	TFilmstripSelection *filmstripSelection = dynamic_cast<TFilmstripSelection *>(TSelection::getCurrent());
	if (filmstripSelection) {
		TXshSimpleLevel *simpleLevel = TApp::instance()->getCurrentLevel()->getSimpleLevel();
		if (simpleLevel) {
			std::set<TFrameId> fids = filmstripSelection->getSelectedFids();
			std::set<TFrameId>::iterator it = fids.begin();
			bool oneImageChanged = false;
			for (it; it != fids.end(); it++) {
				TImageP image = simpleLevel->getFrame(*it, true);
				if (!image)
					continue;
				TRasterP ras = image->raster();
				if (!ras)
					continue;
				oneImageChanged = true;
				onChange(ras, threshold, softness);
				simpleLevel->touchFrame(*it);
				simpleLevel->setDirtyFlag(true);
				IconGenerator::instance()->invalidate(simpleLevel, *it);
			}
			if (oneImageChanged) {
				close();
				return;
			}
		}
	}

	DVGui::error(QObject::tr("The current selection is invalid."));
	return;
}
void AdjustLevelsPopup::apply()
{
	//Retrieve parameters
	int in0[5], in1[5], out0[5], out1[5];
	getParameters(in0, in1, out0, out1);

	//Operate depending on the selection kind
	TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(TSelection::getCurrent());
	if (cellSelection) {
		std::set<TRasterImage *> images; //Multiple cells may yield the same image...

		int r0, c0, r1, c1;
		cellSelection->getSelectedCells(r0, c0, r1, c1);
		TXsheet *xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
		bool oneImageChanged = false;

		TUndoManager::manager()->beginBlock();
		{
			int c, r;
			for (c = c0; c <= c1; c++) {
				for (r = r0; r <= r1; r++) {
					const TXshCell &cell = xsheet->getCell(r, c);

					TRasterImageP rasImage = (TRasterImageP)cell.getImage(true);
					if (!rasImage)
						continue;

					if (images.find(rasImage.getPointer()) != images.end())
						continue;

					TRasterP ras = rasImage->getRaster();
					if (!ras)
						continue;

					images.insert(rasImage.getPointer());
					oneImageChanged = true;

					TUndoManager::manager()->add(new AdjustLevelsUndo(in0, in1, out0, out1, r, c, ras->clone()));
					TRop::rgbmAdjust(ras, ras, in0, in1, out0, out1);

					TXshSimpleLevel *simpleLevel = cell.getSimpleLevel();
					assert(simpleLevel);
					simpleLevel->touchFrame(cell.getFrameId());
					simpleLevel->setDirtyFlag(true);

					IconGenerator::instance()->invalidate(simpleLevel, cell.getFrameId());
				}
			}
		}
		TUndoManager::manager()->endBlock();

		if (oneImageChanged) {
			close();
			return;
		}
	}

	TFilmstripSelection *filmstripSelection = dynamic_cast<TFilmstripSelection *>(TSelection::getCurrent());
	if (filmstripSelection) {
		TXshSimpleLevel *simpleLevel = TApp::instance()->getCurrentLevel()->getSimpleLevel();
		if (simpleLevel) {
			std::set<TFrameId> fids = filmstripSelection->getSelectedFids();
			bool oneImageChanged = false;

			std::set<TFrameId>::iterator it = fids.begin();
			for (it; it != fids.end(); it++) {
				TRasterImageP rasImage = (TRasterImageP)simpleLevel->getFrame(*it, true);
				if (!rasImage)
					continue;

				TRasterP ras = rasImage->getRaster();
				if (!ras)
					continue;

				oneImageChanged = true;
				TRop::rgbmAdjust(ras, ras, in0, in1, out0, out1);

				simpleLevel->touchFrame(*it);
				simpleLevel->setDirtyFlag(true);

				IconGenerator::instance()->invalidate(simpleLevel, *it);
			}

			if (oneImageChanged) {
				close();
				return;
			}
		}
	}

	DVGui::error(QObject::tr("The current selection is invalid."));
	return;
}
Пример #7
0
void LinesFadePopup::apply()
{
	TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(TSelection::getCurrent());
	TPixel32 color = m_linesColorField->getColor();
	int intensity = m_intensity->getValue();

	if (cellSelection) {
		std::set<TRasterImage *> images;
		int r0, c0, r1, c1;
		cellSelection->getSelectedCells(r0, c0, r1, c1);
		TXsheet *xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
		bool oneImageChanged = false;
		int c, r;
		TUndoManager::manager()->beginBlock();
		for (c = c0; c <= c1; c++)
			for (r = r0; r <= r1; r++) {
				TXshCell cell = xsheet->getCell(r, c);
				TRasterImageP rasImage = (TRasterImageP)cell.getImage(true);
				if (!rasImage)
					continue;
				if (images.find(rasImage.getPointer()) != images.end())
					continue;
				TRaster32P ras = rasImage->getRaster();
				if (!ras)
					continue;
				images.insert(rasImage.getPointer());
				TUndoManager::manager()->add(new TLineFadeUndo(color, intensity, r, c, ras->clone()));
				oneImageChanged = true;
				onChange(ras, ras, color, intensity);
				TXshSimpleLevel *simpleLevel = cell.getSimpleLevel();
				assert(simpleLevel);
				simpleLevel->touchFrame(cell.getFrameId());
				simpleLevel->setDirtyFlag(true);
				IconGenerator::instance()->invalidate(simpleLevel, cell.getFrameId());
			}
		TUndoManager::manager()->endBlock();
		images.clear();
		if (oneImageChanged) {
			close();
			return;
		}
	}
	TFilmstripSelection *filmstripSelection = dynamic_cast<TFilmstripSelection *>(TSelection::getCurrent());
	if (filmstripSelection) {
		TXshSimpleLevel *simpleLevel = TApp::instance()->getCurrentLevel()->getSimpleLevel();
		if (simpleLevel) {
			std::set<TFrameId> fids = filmstripSelection->getSelectedFids();
			bool oneImageChanged = false;
			for (auto const& fid : fids) {
				TRasterImageP rasImage = (TRasterImageP)simpleLevel->getFrame(fid, true);
				;
				if (!rasImage)
					continue;
				TRaster32P ras = rasImage->getRaster();
				if (!ras)
					continue;
				oneImageChanged = true;
				onChange(ras, ras, color, intensity);
				simpleLevel->touchFrame(fid);
				simpleLevel->setDirtyFlag(true);
				IconGenerator::instance()->invalidate(simpleLevel, fid);
			}
			if (oneImageChanged) {
				close();
				return;
			}
		}
	}

	DVGui::error(QObject::tr("The current selection is invalid."));
	return;
}
Пример #8
0
/*! Update popup value.
                Take current level and act on level type set popup value.
*/
void LevelSettingsPopup::updateLevelSettings() {
  TApp *app = TApp::instance();
  TXshLevelP selectedLevel;
  CastSelection *castSelection =
      dynamic_cast<CastSelection *>(app->getCurrentSelection()->getSelection());
  TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(
      app->getCurrentSelection()->getSelection());
  TColumnSelection *columnSelection = dynamic_cast<TColumnSelection *>(
      app->getCurrentSelection()->getSelection());
  FxSelection *fxSelection =
      dynamic_cast<FxSelection *>(app->getCurrentSelection()->getSelection());

  /*--セル選択の場合--*/
  if (cellSelection) {
    TXsheet *currentXsheet = app->getCurrentXsheet()->getXsheet();
    if (currentXsheet && !cellSelection->isEmpty()) {
      selectedLevel = 0;
      int r0, c0, r1, c1;
      cellSelection->getSelectedCells(r0, c0, r1, c1);
      for (int c = c0; c <= c1; c++) {
        for (int r = r0; r <= r1; r++) {
          if (currentXsheet->getCell(r, c).m_level) {
            selectedLevel = currentXsheet->getCell(r, c).m_level;
            break;
          }
        }
        if (selectedLevel) break;
      }
    } else
      selectedLevel = app->getCurrentLevel()->getLevel();
  }
  /*--カラム選択の場合--*/
  else if (columnSelection) {
    TXsheet *currentXsheet = app->getCurrentXsheet()->getXsheet();
    if (currentXsheet && !columnSelection->isEmpty()) {
      selectedLevel   = 0;
      int sceneLength = currentXsheet->getFrameCount();

      std::set<int> columnIndices = columnSelection->getIndices();
      std::set<int>::iterator it;
      /*-- 選択Columnを探索、最初に見つかったLevelの内容を表示 --*/
      for (it = columnIndices.begin(); it != columnIndices.end(); ++it) {
        int columnIndex = *it;
        for (int r = 0; r < sceneLength; r++) {
          if (currentXsheet->getCell(r, columnIndex).m_level) {
            selectedLevel = currentXsheet->getCell(r, columnIndex).m_level;
            break;
          }
        }
        if (selectedLevel) break;
      }
    } else
      selectedLevel = app->getCurrentLevel()->getLevel();
  } else if (castSelection) {
    std::vector<TXshLevel *> levels;
    castSelection->getSelectedLevels(levels);

    int selectedLevelSize                    = levels.size();
    if (selectedLevelSize > 0) selectedLevel = levels[selectedLevelSize - 1];
  }
  /*-- Fx選択(Schematicノード選択)の場合 --*/
  else if (fxSelection) {
    selectedLevel           = 0;
    TXsheet *currentXsheet  = app->getCurrentXsheet()->getXsheet();
    QList<TFxP> selectedFxs = fxSelection->getFxs();
    if (currentXsheet && !selectedFxs.isEmpty()) {
      for (int f = 0; f < selectedFxs.size(); f++) {
        TLevelColumnFx *lcfx =
            dynamic_cast<TLevelColumnFx *>(selectedFxs.at(f).getPointer());
        if (lcfx) {
          int firstRow = lcfx->getXshColumn()->getCellColumn()->getFirstRow();
          TXshLevelP levelP =
              lcfx->getXshColumn()->getCellColumn()->getCell(firstRow).m_level;
          if (levelP) {
            selectedLevel = levelP;
            break;
          }
        }
      }
      if (!selectedLevel) selectedLevel = app->getCurrentLevel()->getLevel();
    } else
      selectedLevel = app->getCurrentLevel()->getLevel();
    // std::cout<<"fxSelection is current!"<<std::endl;
  } else
    selectedLevel = app->getCurrentLevel()->getLevel();

  m_sl  = dynamic_cast<TXshSimpleLevel *>(selectedLevel.getPointer());
  m_pl  = dynamic_cast<TXshPaletteLevel *>(selectedLevel.getPointer());
  m_cl  = dynamic_cast<TXshChildLevel *>(selectedLevel.getPointer());
  m_sdl = dynamic_cast<TXshSoundLevel *>(selectedLevel.getPointer());

  bool isSimpleLevel = m_sl;
  bool isChildLevel  = m_cl;
  bool isRasterLevel = m_sl && (m_sl->getType() & RASTER_TYPE);
  bool isTzpLevel    = m_sl && (m_sl->getType() == TZP_XSHLEVEL);
  bool isMeshLevel   = m_sl && (m_sl->getType() == MESH_XSHLEVEL);

  bool hasDpiEditing = (isRasterLevel || isMeshLevel);

  // name
  if (selectedLevel) {
    m_nameFld->setText(::to_string(selectedLevel->getName()).c_str());
    m_nameFld->setEnabled(true);
  } else {
    m_nameFld->setText(tr(""));
    m_nameFld->setEnabled(false);
  }

  // path
  if (m_sl) {
    m_pathFld->setPath(toQString(m_sl->getPath()));
    if (m_scanPathFld)
      m_scanPathFld->setPath(toQString(m_sl->getScannedPath()));
  } else if (m_pl) {
    m_pathFld->setPath(toQString(m_pl->getPath()));
    if (m_scanPathFld) m_scanPathFld->setPath(tr(""));
  } else if (m_sdl) {
    m_pathFld->setPath(toQString(m_sdl->getPath()));
    if (m_scanPathFld) m_scanPathFld->setPath(tr(""));
  } else {
    m_pathFld->setPath(tr(""));
    if (m_scanPathFld) m_scanPathFld->setPath(tr(""));
  }

  // leveltype
  QString levelTypeString = QString(tr(""));
  if (m_sl) {
    switch (m_sl->getType()) {
    case TZI_XSHLEVEL:
      levelTypeString = tr("Scan level");
      break;
    case PLI_XSHLEVEL:
      levelTypeString = tr("Toonz Vector level");
      break;
    case TZP_XSHLEVEL:
      levelTypeString = tr("Toonz Raster level");
      break;
    case OVL_XSHLEVEL:
      levelTypeString = tr("Raster level");
      break;
    case MESH_XSHLEVEL:
      levelTypeString = tr("Mesh level");
      break;
    default:
      levelTypeString = "?";
      break;
    }
  } else if (m_pl)
    levelTypeString = tr("Palette level");
  else if (m_sdl)
    levelTypeString = tr("Sound Column");

  m_typeLabel->setText(levelTypeString);

  // dpi & res & resampling
  if (hasDpiEditing) {
    LevelProperties::DpiPolicy dpiPolicy =
        m_sl->getProperties()->getDpiPolicy();
    assert(dpiPolicy == LevelProperties::DP_ImageDpi ||
           dpiPolicy == LevelProperties::DP_CustomDpi);
    m_dpiTypeOm->setCurrentIndex(
        (dpiPolicy == LevelProperties::DP_ImageDpi) ? 0 : 1);

    // dpi field
    TPointD dpi = m_sl->getDpi();
    m_dpiFld->setText(dpiToString(dpi));
    m_dpiFld->setCursorPosition(0);

    // image dpi
    m_imageDpiLabel->setText(dpiToString(m_sl->getImageDpi()));

    if (isRasterLevel) {
      // size field
      TDimensionD size(0, 0);
      TDimension res = m_sl->getResolution();
      if (res.lx > 0 && res.ly > 0 && dpi.x > 0 && dpi.y > 0) {
        size.lx = res.lx / dpi.x;
        size.ly = res.ly / dpi.y;
        m_widthFld->setValue(tround(size.lx * 100.0) / 100.0);
        m_heightFld->setValue(tround(size.ly * 100.0) / 100.0);
      } else {
        m_widthFld->setText(tr(""));
        m_heightFld->setText(tr(""));
      }

      // image res
      TDimension imageRes = m_sl->getResolution();
      m_imageResLabel->setText(QString::number(imageRes.lx) + "x" +
                               QString::number(imageRes.ly));

      // subsampling
      m_subsamplingFld->setValue(m_sl->getProperties()->getSubsampling());

      // doPremultiply
      m_doPremultiply->setChecked(m_sl->getProperties()->doPremultiply());
      if (m_whiteTransp)
        m_whiteTransp->setChecked(m_sl->getProperties()->whiteTransp());

      m_antialiasSoftness->setValue(m_sl->getProperties()->antialiasSoftness());
      m_doAntialias->setChecked(m_sl->getProperties()->antialiasSoftness() > 0);
    }
  } else {
    m_dpiFld->setText(tr(""));
    m_widthFld->setText(tr(""));
    m_heightFld->setText(tr(""));

    m_cameraDpiLabel->setText(tr(""));
    m_imageDpiLabel->setText(tr(""));
    m_imageResLabel->setText(tr(""));

    m_subsamplingFld->setText(tr(""));

    m_doPremultiply->setChecked(false);
    m_doAntialias->setChecked(false);
    if (m_whiteTransp) m_whiteTransp->setChecked(false);
  }

  // camera dpi
  m_cameraDpiLabel->setText(dpiToString(getCurrentCameraDpi()));

  m_nameFld->setEnabled((isSimpleLevel || isChildLevel || !!m_pl || !!m_sdl));
  m_pathFld->setEnabled((isSimpleLevel || !!m_sdl || !!m_pl));
  if (m_scanPathLabel) m_scanPathLabel->setEnabled(isTzpLevel);
  if (m_scanPathFld) m_scanPathFld->setEnabled(isTzpLevel);
  m_typeLabel->setEnabled(isSimpleLevel || !!m_pl || !!m_sdl);
  m_dpiTypeOm->setEnabled((isSimpleLevel && m_sl->getImageDpi() != TPointD()));
  m_squarePixCB->setEnabled(hasDpiEditing);
  m_dpiLabel->setEnabled(hasDpiEditing);
  m_dpiFld->setEnabled(hasDpiEditing);
  m_widthLabel->setEnabled(isRasterLevel);
  m_widthFld->setEnabled(isRasterLevel);
  m_heightLabel->setEnabled(isRasterLevel);
  m_heightFld->setEnabled(isRasterLevel);
  m_useCameraDpiBtn->setEnabled(hasDpiEditing);
  m_subsamplingLabel->setEnabled(
      (isRasterLevel && m_sl && !m_sl->getProperties()->getDirtyFlag()));
  m_subsamplingFld->setEnabled(
      (isRasterLevel && m_sl && !m_sl->getProperties()->getDirtyFlag()));
  m_doPremultiply->setEnabled(m_sl && isRasterLevel && !isTzpLevel);
  m_doAntialias->setEnabled(m_sl && isRasterLevel);
  if (m_whiteTransp)
    m_whiteTransp->setEnabled(m_sl && isRasterLevel && !isTzpLevel);
}