示例#1
0
void FilterManagerImpl::applyToTarget()
{
  bool cancelled = false;

  ImagesCollector images(m_sprite,
                         (m_target & TARGET_ALL_LAYERS) == TARGET_ALL_LAYERS,
                         (m_target & TARGET_ALL_FRAMES) == TARGET_ALL_FRAMES,
                         true); // we will write in each image
  if (images.empty())
    return;

  // Initialize writting operation
  DocumentReader doc_reader(m_document);
  DocumentWriter doc_writer(doc_reader);
  UndoTransaction undo(m_document, m_filter->getName(), undo::ModifyDocument);

  m_progressBase = 0.0f;
  m_progressWidth = 1.0f / images.size();

  // For each target image
  for (ImagesCollector::ItemsIterator it = images.begin();
       it != images.end() && !cancelled;
       ++it) {
    applyToImage(it->layer(), it->image(), it->cel()->getX(), it->cel()->getY());

    // Is there a delegate to know if the process was cancelled by the user?
    if (m_progressDelegate)
      cancelled = m_progressDelegate->isCancelled();

    // Make progress
    m_progressBase += m_progressWidth;
  }

  undo.commit();
}
示例#2
0
void FilterManagerImpl::applyToTarget()
{
  bool cancelled = false;

  ImagesCollector images(m_sprite,
			 (m_target & TARGET_ALL_LAYERS) == TARGET_ALL_LAYERS,
			 (m_target & TARGET_ALL_FRAMES) == TARGET_ALL_FRAMES,
			 true);	// we will write in each image
  if (images.empty())
    return;

  // Initialize writting operation
  DocumentReader doc_reader(m_document);
  DocumentWriter doc_writer(doc_reader);
  undo::UndoHistory* undo = m_document->getUndoHistory();

  // Open group of undo operations
  if (images.size() > 1) {
    if (undo->isEnabled())
      undo->pushUndoer(new undoers::OpenGroup());
  }
  
  m_progressBase = 0.0f;
  m_progressWidth = 1.0f / images.size();

  // For each target image
  for (ImagesCollector::ItemsIterator it = images.begin();
       it != images.end() && !cancelled;
       ++it) {
    applyToImage(it->layer(), it->image(), it->cel()->getX(), it->cel()->getY());

    // Is there a delegate to know if the process was cancelled by the user?
    if (m_progressDelegate)
      cancelled = m_progressDelegate->isCancelled();

    // Make progress
    m_progressBase += m_progressWidth;
  }

  // Close group of undo operations
  if (images.size() > 1) {
    if (undo->isEnabled())
      undo->pushUndoer(new undoers::CloseGroup());
  }
}