int FilmstripFrameHeadGadget::getCurrentFrame() const
{
	TXshSimpleLevel *level = m_filmstrip->getLevel();
	if (!level)
		return 0;
	return level->guessIndex(TApp::instance()->getCurrentFrame()->getFid());
}
示例#2
0
void Filmstrip::updateWindowTitle() {
  updateCurrentLevelComboItem();

  TXshSimpleLevel *level = m_frames->getLevel();

  QString levelName;

  if (!level) {
    parentWidget()->setWindowTitle(tr("Level Strip"));
    return;
  } else {
    levelName = QString::fromStdWString(level->getName());
    if (level->getProperties()->getDirtyFlag()) levelName += " *";
  }

  // parentWidget() is TPanel
  parentWidget()->setWindowTitle(tr("Level:  ") + levelName);

  TFrameHandle *fh = TApp::instance()->getCurrentFrame();
  if (fh->isEditingLevel() && fh->getFid().getNumber() >= 0)
    levelName += QString("  [#") + QString::number(fh->getFid().getNumber()) +
                 QString("]");

  m_chooseLevelCombo->setItemText(m_chooseLevelCombo->currentIndex(),
                                  levelName);
}
示例#3
0
void FilmstripFrames::drawFrameIcon(QPainter &p, const QRect &r, int index,
                                    const TFrameId &fid, int flags) {
  QPixmap pm;
  TXshSimpleLevel *sl = getLevel();
  if (sl) {
    pm = IconGenerator::instance()->getIcon(sl, fid);
  }
  if (!pm.isNull()) {
    p.drawPixmap(r.left(), r.top(), pm);

    if (sl && sl->getType() == PLI_XSHLEVEL && flags & F_INBETWEEN_RANGE) {
      int x1 = r.right();
      int x0 = x1 - 12;
      int y0 = r.top();
      int y1 = r.bottom();
      p.fillRect(x0, y0, x1 - x0 + 1, y1 - y0 + 1, QColor(180, 180, 180, 255));
      p.setPen(Qt::black);
      p.drawLine(x0 - 1, y0, x0 - 1, y1);

      QPixmap inbetweenPixmap(
          svgToPixmap(":Resources/filmstrip_inbetween.svg"));
      p.drawPixmap(
          x0 + 2,
          y1 - inbetweenPixmap.height() / inbetweenPixmap.devicePixelRatio() -
              3,
          inbetweenPixmap);
    }
  } else {
    // non riesco (per qualche ragione) a visualizzare l'icona
    p.fillRect(r, QColor(255, 200, 200));
    p.setPen(Qt::black);
    p.drawText(r, tr("no icon"), QTextOption(Qt::AlignCenter));
  }
}
void StudioPaletteCmd::updateAllLinkedStyles(TPaletteHandle *paletteHandle,
                                             TXsheetHandle *xsheetHandle) {
  if (!xsheetHandle) return;
  TXsheet *xsheet = xsheetHandle->getXsheet();
  if (!xsheet) return;
  ToonzScene *scene = xsheet->getScene();
  if (!scene) return;

  // emit signal only if something changed
  bool somethingChanged = false;

  StudioPalette *sp   = StudioPalette::instance();
  TLevelSet *levelSet = scene->getLevelSet();
  for (int i = 0; i < levelSet->getLevelCount(); i++) {
    TXshLevel *xl       = levelSet->getLevel(i);
    TXshSimpleLevel *sl = xl ? xl->getSimpleLevel() : 0;
    if (!sl) continue;
    TPalette *palette = sl->getPalette();
    if (palette) {
      somethingChanged = somethingChanged | sp->updateLinkedColors(palette);
      if (sl->getType() == TZP_XSHLEVEL) {
        std::vector<TFrameId> fids;
        sl->getFids(fids);
        std::vector<TFrameId>::iterator it;
        for (it = fids.begin(); it != fids.end(); ++it) {
          TFrameId fid   = *it;
          std::string id = sl->getImageId(fid);
        }
      }
    }
  }
  if (!paletteHandle || !paletteHandle->getPalette()) return;
  if (somethingChanged) paletteHandle->notifyColorStyleChanged();
}
示例#5
0
void TApp::onXshLevelSwitched(TXshLevel *) {
  TXshLevel *level = m_currentLevel->getLevel();
  if (level) {
    TXshSimpleLevel *simpleLevel = level->getSimpleLevel();

    // Devo aggiornare la paletta corrente
    if (simpleLevel) {
      m_paletteController->getCurrentLevelPalette()->setPalette(
          simpleLevel->getPalette());

      // Se il nuovo livello selezionato e' un ovl,
      // la paletta corrente e' una cleanup palette
      //  => setto come handle corrente quello della paletta di cleanup.
      TPalette *currentPalette =
          m_paletteController->getCurrentPalette()->getPalette();

      if (simpleLevel->getType() == OVL_XSHLEVEL && currentPalette &&
          currentPalette->isCleanupPalette())
        m_paletteController->editCleanupPalette();

      return;
    }

    TXshPaletteLevel *paletteLevel = level->getPaletteLevel();
    if (paletteLevel) {
      m_paletteController->getCurrentLevelPalette()->setPalette(
          paletteLevel->getPalette());
      return;
    }
  }

  m_paletteController->getCurrentLevelPalette()->setPalette(0);
}
示例#6
0
/*! Notify change of image in \b fid: update icon and notify level change.
*/
void TTool::notifyImageChanged(const TFrameId &fid) {
  onImageChanged();

  if (!m_application) return;

  m_application->getCurrentScene()->setDirtyFlag(true);
  if (m_application->getCurrentFrame()->isEditingLevel()) {
    TXshLevel *xl = m_application->getCurrentLevel()->getLevel();
    if (!xl) return;
    TXshSimpleLevel *sl = xl->getSimpleLevel();
    if (!sl) return;
    sl->setDirtyFlag(true);
    IconGenerator::instance()->invalidate(sl, fid);
    IconGenerator::instance()->invalidateSceneIcon();
  } else {
    int row = m_application->getCurrentFrame()->getFrame();
    int col = m_application->getCurrentColumn()->getColumnIndex();
    if (col < 0) return;
    TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
    if (!xsh) return;
    TXshCell cell       = xsh->getCell(row, col);
    TXshSimpleLevel *sl = cell.getSimpleLevel();
    if (sl) {
      IconGenerator::instance()->invalidate(sl, fid);
      IconGenerator::instance()->invalidateSceneIcon();
      sl->setDirtyFlag(true);
    }
  }
  m_application->getCurrentLevel()->notifyLevelChange();
}
示例#7
0
int FilmstripFrames::getFramesHeight() const {
  TXshSimpleLevel *level = getLevel();
  int frameCount         = level ? level->getFrameCount() : 1;
  int frameHeight = m_iconSize.height() + fs_frameSpacing + fs_iconMarginTop +
                    fs_iconMarginBottom;
  return frameHeight * (frameCount + 1);
}
示例#8
0
void StylePickerTool::mouseMove(const TPointD &pos, const TMouseEvent &e) {
  if (!m_passivePick.getValue()) return;
  /*--- PassiveにStyleを拾う機能 ---*/
  PaletteController *controller =
      TTool::getApplication()->getPaletteController();

  TImageP image    = getImage(false);
  TToonzImageP ti  = image;
  TVectorImageP vi = image;
  TXshSimpleLevel *level =
      getApplication()->getCurrentLevel()->getSimpleLevel();
  if ((!ti && !vi) || !level || !m_viewer->getGeometry().contains(pos)) {
    controller->notifyStylePassivePicked(-1, -1, -1);
    return;
  }

  int subsampling = level->getImageSubsampling(getCurrentFid());
  StylePicker picker(image);
  TPointD pickPos(TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5));
  int inkStyleId =
      picker.pickStyleId(pickPos, getPixelSize() * getPixelSize(), 1);
  int paintStyleId =
      picker.pickStyleId(pickPos, getPixelSize() * getPixelSize(), 0);
  int tone = picker.pickTone(pickPos);
  controller->notifyStylePassivePicked(inkStyleId, paintStyleId, tone);
}
示例#9
0
/*! update combo items when the contents of scene cast are changed
*/
void Filmstrip::updateChooseLevelComboItems() {
  // clear items
  m_chooseLevelCombo->clear();
  m_levels.clear();

  std::map<TXshSimpleLevel *, TFrameId> new_workingFrames;

  // correct and register items
  ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
  if (scene) {
    std::vector<TXshLevel *> levels;
    scene->getLevelSet()->listLevels(levels);
    std::vector<TXshLevel *>::iterator it;

    for (it = levels.begin(); it != levels.end(); ++it) {
      // register only TLV and PLI
      TXshSimpleLevel *sl = (*it)->getSimpleLevel();
      if (sl) {
        // register only used level in xsheet
        if (!scene->getTopXsheet()->isLevelUsed(sl)) continue;

        m_levels.push_back(sl);

        // create new m_workingFrames map with the new levelset
        TFrameId fId;
        std::map<TXshSimpleLevel *, TFrameId>::iterator WFit =
            m_workingFrames.find(sl);

        if (WFit != m_workingFrames.end())
          fId = WFit->second;
        else
          fId = sl->getFirstFid();

        new_workingFrames.insert(std::make_pair(sl, fId));

        QString levelName = QString::fromStdWString(sl->getName());
        if (sl->getProperties()->getDirtyFlag()) levelName += " *";

        // append the current working frame number to the item name
        if (fId != sl->getFirstFid() && fId.getNumber() >= 0)
          levelName +=
              QString("  [#") + QString::number(fId.getNumber()) + QString("]");

        m_chooseLevelCombo->addItem(levelName);
      }
    }
  }

  m_chooseLevelCombo->addItem(tr("- No Current Level -"));

  // swap the list
  m_workingFrames.clear();
  m_workingFrames = new_workingFrames;

  // synchronize the current index of combo to the current level
  updateCurrentLevelComboItem();
}
void FilmstripFrameHeadGadget::setCurrentFrame(int index) const
{
	TXshSimpleLevel *level = m_filmstrip->getLevel();
	if (!level)
		return;
	TFrameId fid = level->index2fid(index);
	if (fid >= TFrameId(1))
		TApp::instance()->getCurrentFrame()->setFid(fid);
}
示例#11
0
	void undo() const
	{
		TXshSimpleLevel *sl = getLevel();
		if (!sl)
			return;
		TRasterImageP ri = sl->getFrame(m_fid, true);
		if (!ri)
			return;

		TRasterImageP oldRaster = TImageCache::instance()->get(m_rasId, false);
		ri->getRaster()->copy(oldRaster->getRaster());
		notify(sl);
	}
		bool exportToMultifile()
		{
			ImageExporter exporter(*m_sl, m_opts);

			TXshLevelType outputLevelType = (m_path.getType() == "tlv") ? TZP_TYPE : OVL_TYPE;

			bool firstTime = true;
			for (int i = 0; i < m_sl->getFrameCount(); ++i) {
				if (m_progressCB->canceled())
					return false;

				// Prepare frame export path
				TFilePath fpout;

				if (m_opts.m_forRetas) {
					QString pathOut = QString::fromStdWString(m_path.getParentDir().getWideString()) +
									  "\\" + QString::fromStdString(m_path.getName()) +
									  QString::fromStdString(m_sl->index2fid(i).expand()) +
									  "." + QString::fromStdString(m_path.getType());
					fpout = TFilePath(pathOut.toStdString());
				} else
					fpout = TFilePath(m_path.withFrame(m_sl->index2fid(i)));

				// Ask for overwrite permission in case a level with the built path already exists
				if (firstTime) {
					firstTime = false;

					if (TSystem::doesExistFileOrLevel(fpout)) {
						QApplication::restoreOverrideCursor();
						bool overwrite = m_overwriteCB->overwriteRequest(fpout);
						QApplication::setOverrideCursor(Qt::WaitCursor);

						if (!overwrite)
							return false;
					}
				}

				// Retrieve the image to export at current frame
				TImageP img = exporter.exportedImage(m_sl->index2fid(i), outputLevelType);
				assert(img);

				// Save the prepared fullcolor image to file
				TImageWriter iw(fpout);
				iw.setProperties(m_opts.m_props);
				iw.save(img);

				m_progressCB->setValue(i + 1);
			}

			return true;
		}
示例#13
0
	void redo() const
	{
		TXshSimpleLevel *sl = getLevel();
		if (!sl)
			return;
		TRasterImageP ri = sl->getFrame(m_fid, true);
		if (!ri)
			return;
		TRaster32P ras = ri->getRaster();
		if (!ras)
			return;
		TBinarizer binarizer;
		binarizer.enableAlpha(m_alphaEnabled);
		binarizer.process(ras);
		notify(sl);
	}
示例#14
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;
}
	void undo() const
	{
		TXsheet *xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
		TXshCell cell = xsheet->getCell(m_r, m_c);
		TRasterImageP rasImage = (TRasterImageP)cell.getImage(true);
		if (!rasImage)
			return;
		rasImage->setRaster(((TRasterImageP)TImageCache::instance()->get(m_rasId, true))->getRaster()->clone());
		TXshSimpleLevel *simpleLevel = cell.getSimpleLevel();
		assert(simpleLevel);
		simpleLevel->touchFrame(cell.getFrameId());
		simpleLevel->setDirtyFlag(false);
		IconGenerator::instance()->invalidate(simpleLevel, cell.getFrameId());

		if (m_isLastInBlock) {
			TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
		}
	}
示例#16
0
void setCurrentColorWithUndo(const TPixel32 &color) {
  TTool::Application *app = TTool::getApplication();
  TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
  int styleId             = ph->getStyleIndex();
  TPalette *palette       = ph->getPalette();
  TXshSimpleLevel *level  = app->getCurrentLevel()->getSimpleLevel();
  if (palette)
    TUndoManager::manager()->add(
        new UndoPickRGBM(palette, styleId, color, level));

  setCurrentColor(color);

  if (level) {
    std::vector<TFrameId> fids;
    level->getFids(fids);
    invalidateIcons(level, fids);
  }
}
示例#17
0
	void undo() const
	{
		int i;
		//TPalette *palette = m_matchlinePalette->clone();
		//m_sl->setPalette(palette);
		for (i = 0; i < m_fids.size(); i++) {
			QString id = "DeleteMatchlineUndo" + QString::number((uintptr_t) this) + "-" + QString::number(i);
			TImageP img = TImageCache::instance()->get(id, false)->cloneImage();

			m_sl->setFrame(m_fids[i], img);
			ToolUtils::updateSaveBox(m_sl, m_fids[i]);
		}
		//TApp::instance()->getPaletteController()->getCurrentLevelPalette()->setPalette(palette);

		if (m_xl)
			invalidateIcons(m_xl, m_fids);
		m_sl->setDirtyFlag(true);
		TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
	}
示例#18
0
void MeshifyPopup::acquirePreview()
{
	m_viewer->clear();

	// Assign preview input to the viewer
	bool enabled = false;

	::xshPos(m_r, m_c);
	m_cell = TApp::instance()->getCurrentXsheet()->getXsheet()->getCell(m_r, m_c);

	// Redirect mesh case to texture
	TXshSimpleLevel *sl = m_cell.getSimpleLevel();
	if (sl && sl->getType() == MESH_XSHLEVEL) {
		// Mesh image case
		TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
		TStageObject *meshObj = xsh->getStageObject(TStageObjectId::ColumnId(m_c));

		const TStageObjectId &childId = ::firstChildLevelColumn(*xsh, *meshObj);
		if (childId.isColumn())
			// Retrieved the associated texture cell - redirect acquisition there
			m_cell = xsh->getCell(m_r, childId.getIndex());
	}

	if ((sl = m_cell.getSimpleLevel())) {
		// Standard image case
		m_viewer->m_img = sl->getFullsampledFrame(m_cell.getFrameId(), ImageManager::dontPutInCache);

		enabled = true;
	} else if (TXshChildLevel *cl = m_cell.getChildLevel()) {
		// Sub-xsheet case
		TXsheet *xsh = cl->getXsheet();
		int row = m_cell.getFrameId().getNumber() - 1;

		m_viewer->m_xsh = xsh, m_viewer->m_row = row;

		enabled = true;
	}

	m_okBtn->setEnabled(enabled);

	// Update the corresponding processed image in the viewer
	updateMeshPreview();
}
示例#19
0
static bool canMergeColumns(int column, int mColumn, bool forMatchlines) {
  TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();

  if (xsh->getColumn(column)->isLocked()) return false;

  int start, end;
  xsh->getCellRange(column, start, end);

  if (start > end) return false;
  std::vector<TXshCell> cell(end - start + 1);
  std::vector<TXshCell> mCell(end - start + 1);

  xsh->getCells(start, column, cell.size(), &(cell[0]));
  xsh->getCells(start, mColumn, cell.size(), &(mCell[0]));

  TXshSimpleLevel *level = 0, *mLevel = 0;
  TXshLevelP xl;

  for (int i = 0; i < (int)cell.size(); i++) {
    if (cell[i].isEmpty() || mCell[i].isEmpty()) continue;
    if (!level) {
      level = cell[i].getSimpleLevel();
      xl    = cell[i].m_level;
    }

    else if (level != cell[i].getSimpleLevel())
      return false;

    if (!mLevel)
      mLevel = mCell[i].getSimpleLevel();
    else if (mLevel != mCell[i].getSimpleLevel())
      return false;

    if (!mLevel || !level ||  // potrebbero non essere dei simplelevel
        (forMatchlines && (level->getType() != TZP_XSHLEVEL ||
                           mLevel->getType() != TZP_XSHLEVEL)))
      return false;
    else if (!forMatchlines) {
      if (level->getType() != mLevel->getType()) return false;
      if (level->getType() != PLI_XSHLEVEL && level->getType() != OVL_XSHLEVEL)
        return false;
      // Check level type write support. Based on TTool::updateEnabled()
      if (level->getType() == OVL_XSHLEVEL &&
          (level->getPath().getType() == "psd" ||     // PSD files.
           level->is16BitChannelLevel() ||            // 16bpc images.
           level->getProperties()->getBpp() == 1)) {  // Black & White images.
        return false;
      }
    }
  }
  return true;
}
示例#20
0
bool canMergeColumns(int column, int mColumn, bool forMatchlines) {
  TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
  int start, end;
  xsh->getCellRange(column, start, end);

  if (start > end) return false;
  std::vector<TXshCell> cell(end - start + 1);
  std::vector<TXshCell> mCell(end - start + 1);

  xsh->getCells(start, column, cell.size(), &(cell[0]));
  xsh->getCells(start, mColumn, cell.size(), &(mCell[0]));

  TXshSimpleLevel *level = 0, *mLevel = 0;
  TXshLevelP xl;

  for (int i = 0; i < (int)cell.size(); i++) {
    if (cell[i].isEmpty() || mCell[i].isEmpty()) continue;
    if (!level) {
      level = cell[i].getSimpleLevel();
      xl    = cell[i].m_level;
    }

    else if (level != cell[i].getSimpleLevel())
      return false;

    if (!mLevel)
      mLevel = mCell[i].getSimpleLevel();
    else if (mLevel != mCell[i].getSimpleLevel())
      return false;

    if (!mLevel || !level ||  // potrebbero non essere dei simplelevel
        (forMatchlines && (level->getType() != TZP_XSHLEVEL ||
                           mLevel->getType() != TZP_XSHLEVEL)))
      return false;
    else if (!forMatchlines) {
      if (level->getType() != mLevel->getType()) return false;
      if (level->getType() != PLI_XSHLEVEL && level->getType() != OVL_XSHLEVEL)
        return false;
    }
  }
  return true;
}
示例#21
0
void TApp::updateCurrentFrame() {
  ToonzScene *scene = m_currentScene->getScene();
  m_currentFrame->setSceneFrameSize(scene->getFrameCount());
  int f0, f1, step;
  scene->getProperties()->getPreviewProperties()->getRange(f0, f1, step);
  if (f0 > f1) {
    f0 = 0;
    f1 = scene->getFrameCount() - 1;
  }
  if (f0 != m_currentFrame->getStartFrame() ||
      f1 != m_currentFrame->getEndFrame()) {
    m_currentFrame->setFrameRange(f0, f1);
    std::vector<TFrameId> fids;
    TXshSimpleLevel *sl = m_currentLevel->getSimpleLevel();
    if (sl) {
      sl->getFids(fids);
      m_currentFrame->setFrameIds(fids);
    }
  }
}
示例#22
0
void TApp::onLevelColorStyleChanged() {
  onPaletteChanged();
  TXshLevel *level = m_currentLevel->getLevel();
  if (!level) return;
  TPalette *palette            = getCurrentPalette()->getPalette();
  TXshSimpleLevel *simpleLevel = level->getSimpleLevel();
  if (simpleLevel && simpleLevel->getPalette() == palette) {
    notifyPaletteChanged(simpleLevel);
  } else {
    TLevelSet *levelSet = getCurrentScene()->getScene()->getLevelSet();
    for (int i = 0; i < levelSet->getLevelCount(); i++) {
      if (levelSet->getLevel(i)) {
        simpleLevel = levelSet->getLevel(i)->getSimpleLevel();
        if (simpleLevel && simpleLevel->getPalette() == palette) {
          notifyPaletteChanged(simpleLevel);
        }
      }
    }
  }
}
示例#23
0
void BinarizePopup::apply()
{
	if (getSelectedFrames() <= 0) {
		DVGui::error(tr("No raster frames selected"));
		return;
	}

	DVGui::ProgressDialog pd(tr("Binarizing images"), tr("Cancel"), 0, (int)m_frames.size(), 0);
	pd.show();
	qApp->processEvents();

	TBinarizer binarizer;
	binarizer.enableAlpha(!!m_alphaChk->checkState());

	TUndoManager::manager()->beginBlock();
	int count = 0;
	Frames::iterator it;
	for (it = m_frames.begin(); it != m_frames.end(); ++it) {
		TXshSimpleLevel *sl = it->first;
		if (!!m_alphaChk->checkState())
			sl->getProperties()->setHasAlpha(true);
		TFrameId fid = it->second;
		TBinarizeUndo *undo = new TBinarizeUndo(sl, fid, binarizer.isAlphaEnabled());
		TUndoManager::manager()->add(undo);
		TRasterImageP ri = sl->getFrame(fid, true);
		if (!ri)
			continue; // should never happen
		TRaster32P ras32 = ri->getRaster();
		if (!ras32)
			continue; // not yet handled
		binarizer.process(ras32);
		pd.setValue(count++);
		qApp->processEvents();
		sl->touchFrame(fid);
		sl->setDirtyFlag(true);
		IconGenerator::instance()->invalidate(sl, fid);
	}
	TUndoManager::manager()->endBlock();
	TApp::instance()->getCurrentLevel()->notifyLevelChange();
	TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}
示例#24
0
/*! Notify change of current image: update icon and notify level change.
    If current object is a spline commit spline chenged.
    If current mode is EditingLevel touch current frame.
*/
void TTool::notifyImageChanged() {
  onImageChanged();

  if (!m_application) return;

  m_application->getCurrentScene()->setDirtyFlag(true);
  if (m_application->getCurrentFrame()->isEditingLevel()) {
    TXshLevel *xl = m_application->getCurrentLevel()->getLevel();
    if (!xl) return;
    TXshSimpleLevel *sl = xl->getSimpleLevel();
    if (!sl) return;
    TFrameId fid = m_application->getCurrentFrame()->getFid();
    sl->touchFrame(fid);
    // sl->setDirtyFlag(true);
    IconGenerator::instance()->invalidate(sl, fid);
    IconGenerator::instance()->invalidateSceneIcon();
  } else {
    TXsheet *xsh = m_application->getCurrentXsheet()->getXsheet();
    if (!xsh) return;

    TObjectHandle *currentObject = m_application->getCurrentObject();

    if (currentObject->isSpline()) {
      m_application->getCurrentObject()->commitSplineChanges();
      TStageObject *pegbar = xsh->getStageObject(currentObject->getObjectId());
      IconGenerator::instance()->invalidate(pegbar->getSpline());
    } else {
      int row = m_application->getCurrentFrame()->getFrame();
      int col = m_application->getCurrentColumn()->getColumnIndex();
      if (col < 0) return;
      TXshCell cell       = xsh->getCell(row, col);
      TXshSimpleLevel *sl = cell.getSimpleLevel();
      if (sl) {
        IconGenerator::instance()->invalidate(sl, cell.m_frameId);
        sl->touchFrame(cell.m_frameId);
        IconGenerator::instance()->invalidateSceneIcon();
      }
    }
  }
  m_application->getCurrentLevel()->notifyLevelChange();
}
示例#25
0
	void undo() const
	{
		std::map<TFrameId, QString>::const_iterator it = m_images.begin();
		TPalette *palette = m_palette->clone();
		m_level->setPalette(palette);
		vector<TFrameId> fids;
		for (; it != m_images.end(); ++it) //, ++mit)
		{
			QString id = "MergeCmappedUndo" + QString::number(m_mergeCmappedSessionId) + "-" + QString::number(it->first.getNumber());
			TImageP img = TImageCache::instance()->get(id, false)->cloneImage();
			img->setPalette(palette);
			m_level->setFrame(it->first, img);
			fids.push_back(it->first);
		}

		removeLevel(m_xl);

		TApp::instance()->getPaletteController()->getCurrentLevelPalette()->setPalette(palette);
		m_level->setDirtyFlag(true);
		TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
	}
	void redo() const
	{
		TXsheet *xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
		TXshCell cell = xsheet->getCell(m_r, m_c);
		TImageP image = (TRasterImageP)cell.getImage(true);
		if (!image)
			return;
		TRasterP ras = image->raster();
		if (!ras)
			return;

		onChange(ras, m_threshold, m_softness);
		TXshSimpleLevel *simpleLevel = cell.getSimpleLevel();
		assert(simpleLevel);
		simpleLevel->touchFrame(cell.getFrameId());
		simpleLevel->setDirtyFlag(false);
		IconGenerator::instance()->invalidate(simpleLevel, cell.getFrameId());
		if (m_isLastInBlock) {
			TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
		}
	}
示例#27
0
void Filmstrip::onFrameSwitched() {
  TFrameHandle *fh = TApp::instance()->getCurrentFrame();
  if (!fh->isEditingLevel()) return;

  TXshSimpleLevel *level = m_frames->getLevel();

  std::map<TXshSimpleLevel *, TFrameId>::iterator WFit;
  WFit = m_workingFrames.find(level);
  if (WFit == m_workingFrames.end()) return;

  WFit->second = fh->getFid();

  QString levelName = QString::fromStdWString(level->getName());
  if (level->getProperties()->getDirtyFlag()) levelName += " *";
  if (fh->getFid().getNumber() >= 0)
    levelName += QString("  [#") + QString::number(fh->getFid().getNumber()) +
                 QString("]");

  m_chooseLevelCombo->setItemText(m_chooseLevelCombo->currentIndex(),
                                  levelName);
}
示例#28
0
void RGBPickerTool::onImageChanged() {
  if (m_currentStyleId != 0 && m_makePick &&
      (m_pickType.getValue() == POLYLINE_PICK ||
       m_pickType.getValue() == RECT_PICK)) {
    TTool::Application *app = TTool::getApplication();
    TPaletteHandle *ph      = app->getPaletteController()->getCurrentPalette();
    int styleId             = ph->getStyleIndex();
    TPalette *palette       = ph->getPalette();
    TXshSimpleLevel *level  = app->getCurrentLevel()->getSimpleLevel();
    if (palette)
      TUndoManager::manager()->add(
          new UndoPickRGBM(palette, styleId, m_currentValue, level));
    setCurrentColor(m_currentValue);
    if (level) {
      std::vector<TFrameId> fids;
      level->getFids(fids);
      invalidateIcons(level, fids);
    }
  }
  m_makePick = false;
}
void AntialiasPopup::setCurrentSampleRaster()
{
	TRasterP sampleRas;

	m_startRas = TRasterP();
	TSelection *selection = TApp::instance()->getCurrentSelection()->getSelection();
	TCellSelection *cellSelection = dynamic_cast<TCellSelection *>(selection);
	TFilmstripSelection *filmstripSelection = dynamic_cast<TFilmstripSelection *>(selection);
	TImageP image;
	if (cellSelection) {
		TApp *app = TApp::instance();
		TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
		TXshCell cell = xsh->getCell(app->getCurrentFrame()->getFrameIndex(), app->getCurrentColumn()->getColumnIndex());
		TImageP aux = cell.getImage(true);
		if (aux)
			image = aux->cloneImage();
	} else if (filmstripSelection) {
		TApp *app = TApp::instance();
		TXshSimpleLevel *simpleLevel = app->getCurrentLevel()->getSimpleLevel();
		if (simpleLevel) {
			TImageP imageAux = simpleLevel->getFrame(app->getCurrentFrame()->getFid(), true);
			if (imageAux)
				image = imageAux->cloneImage();
		}
	}

	if (!image || !(sampleRas = image->raster())) {
		m_viewer->setImage(TImageP());
		m_viewer->update();
		m_okBtn->setEnabled(false);
		return;
	}

	m_okBtn->setEnabled(true);
	m_startRas = sampleRas->clone();
	onChange(m_startRas, sampleRas, m_thresholdField->getValue(), m_softnessField->getValue());

	m_viewer->setImage(image);
	m_viewer->update();
}
示例#30
0
void CameraTestToggleCommand::onPreviewDataChanged() {
  CleanupSettingsModel *model = CleanupSettingsModel::instance();

  // Retrieve level under cleanup
  TXshSimpleLevel *sl;
  TFrameId fid;
  model->getCleanupFrame(sl, fid);

  // In case the level changes, release all previously previewed images
  if (m_sl.getPointer() != sl) clean();

  m_sl = sl;
  if (sl) {
    if (!(sl->getFrameStatus(fid) & TXshSimpleLevel::CleanupPreview)) {
      m_fids.push_back(fid);
      sl->setFrameStatus(
          fid, sl->getFrameStatus(fid) | TXshSimpleLevel::CleanupPreview);
    }

    postProcess();
  }
}