Exemplo n.º 1
0
void CastTreeViewer::dragMoveEvent(QDragMoveEvent *event) {
  if (!event->mimeData()->hasFormat("application/vnd.toonz.levels") ||
      m_dropFilePath != TFilePath())
    return;

  m_dropTargetItem  = itemAt(event->pos());
  ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
  QString rootName  = QString("Root");
  if (scene) {
    std::wstring name =
        (scene->isUntitled()) ? L"Untitled" : scene->getSceneName();
    rootName = rootName.fromStdWString(name);
  }
  if (m_dropTargetItem &&
          m_dropTargetItem->data(0, Qt::DisplayRole).toString() ==
              AudioFolderName ||
      m_dropFilePath != TFilePath() &&
          m_dropTargetItem->data(0, Qt::DisplayRole).toString() == rootName)
    m_dropTargetItem = 0;

  if (!m_dropTargetItem)
    event->ignore();
  else
    event->acceptProposedAction();
  viewport()->update();
}
Exemplo n.º 2
0
void CastTreeViewer::onSceneNameChanged() {
  QTreeWidgetItem *root = topLevelItem(0);
  if (!root) return;
  ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
  QString rootName  = QString("Root");
  if (scene) {
    std::wstring name =
        (scene->isUntitled()) ? L"Untitled" : scene->getSceneName();
    rootName = rootName.fromStdWString(name);
  }
  root->setText(0, rootName);
}
Exemplo n.º 3
0
void CastTreeViewer::rebuildCastTree()
{
	clear();
	ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
	QString rootName = QString("Root");
	if (scene) {
		wstring name = (scene->isUntitled()) ? L"Untitled" : scene->getSceneName();
		rootName = rootName.fromStdWString(name);
	}

	QTreeWidgetItem *root = new QTreeWidgetItem((QTreeWidgetItem *)0, QStringList(rootName));
	static QPixmap clapboard(":Resources/clapboard.png");
	root->setIcon(0, clapboard);
	insertTopLevelItem(0, root);
	populateFolder(root);
}
Exemplo n.º 4
0
void ComboViewerPanel::changeWindowTitle() {
  TApp *app         = TApp::instance();
  ToonzScene *scene = app->getCurrentScene()->getScene();
  if (!scene) return;
  int frame = app->getCurrentFrame()->getFrame();

  // put the titlebar texts in this string
  QString name;

  // if the frame type is "scene editing"
  if (app->getCurrentFrame()->isEditingScene()) {
    QString sceneName = QString::fromStdWString(scene->getSceneName());
    if (sceneName.isEmpty()) sceneName = tr("Untitled");

    if (app->getCurrentScene()->getDirtyFlag()) sceneName += QString(" *");
    name = tr("Scene: ") + sceneName;
    if (frame >= 0)
      name =
          name + tr("   ::   Frame: ") + tr(std::to_string(frame + 1).c_str());
    int col = app->getCurrentColumn()->getColumnIndex();
    if (col < 0) {
      setWindowTitle(name);
      return;
    }
    TXsheet *xsh  = app->getCurrentXsheet()->getXsheet();
    TXshCell cell = xsh->getCell(frame, col);
    if (cell.isEmpty()) {
      setWindowTitle(name);
      return;
    }
    assert(cell.m_level.getPointer());
    TFilePath fp(cell.m_level->getName());
    QString imageName =
        QString::fromStdWString(fp.withFrame(cell.m_frameId).getWideString());
    name = name + tr("   ::   Level: ") + imageName;

    if (m_sceneViewer->isPreviewEnabled()) {
      name = name + "  ::  Zoom : " +
             QString::number((int)(100.0 *
                                   sqrt(m_sceneViewer->getViewMatrix().det()) *
                                   m_sceneViewer->getDpiFactor())) +
             "%";
    }

    // If the current level exists and some option is set in the preference,
    // set the zoom value to the current level's dpi
    else if (Preferences::instance()
                 ->isActualPixelViewOnSceneEditingModeEnabled() &&
             TApp::instance()->getCurrentLevel()->getSimpleLevel() &&
             !CleanupPreviewCheck::instance()
                  ->isEnabled()  // cleanup preview must be OFF
             &&
             !CameraTestCheck::instance()
                  ->isEnabled())  // camera test mode must be OFF neither
    {
      name = name + "  ::  Zoom : " +
             QString::number((int)(100.0 *
                                   sqrt(m_sceneViewer->getViewMatrix().det()) *
                                   m_sceneViewer->getDpiFactor())) +
             "%";
    }

  }
  // if the frame type is "level editing"
  else {
    TXshLevel *level = app->getCurrentLevel()->getLevel();
    if (level) {
      TFilePath fp(level->getName());
      QString imageName = QString::fromStdWString(
          fp.withFrame(app->getCurrentFrame()->getFid()).getWideString());

      name = name + tr("Level: ") + imageName;

      name = name + "  ::  Zoom : " +
             QString::number((int)(100.0 *
                                   sqrt(m_sceneViewer->getViewMatrix().det()) *
                                   m_sceneViewer->getDpiFactor())) +
             "%";
    }
  }
  setWindowTitle(name);
}
Exemplo n.º 5
0
  bool addFrame(ToonzScene &scene, int row, bool isLast) {
    assert(m_status == 3);
    if (!m_started) start(scene);

    TDimension cameraRes   = scene.getCurrentCamera()->getRes();
    TDimensionD cameraSize = scene.getCurrentCamera()->getSize();

    TPointD center(0.5 * cameraSize.lx, 0.5 * cameraSize.ly);

    double sx = (double)m_offlineGlContext.getLx() / (double)cameraRes.lx;
    double sy = (double)m_offlineGlContext.getLy() / (double)cameraRes.ly;
    double sc = std::min(sx, sy);

    // TAffine cameraAff =
    // scene.getXsheet()->getPlacement(TStageObjectId::CameraId(0), row);
    TAffine cameraAff = scene.getXsheet()->getCameraAff(row);

    double dpiScale =
        (1.0 / Stage::inch) * (double)cameraRes.lx / cameraSize.lx;

    // TAffine viewAff = TScale(dpiScale*sc) * TTranslation(center)*
    // cameraAff.inv();
    TAffine viewAff = TTranslation(0.5 * cameraRes.lx, 0.5 * cameraRes.ly) *
                      TScale(dpiScale * sc) * cameraAff.inv();

    TRect clipRect(m_offlineGlContext.getBounds());
    TPixel32 bgColor = scene.getProperties()->getBgColor();

    m_offlineGlContext.makeCurrent();
    TPixel32 bgClearColor = m_bgColor;

    if (m_alphaEnabled && m_alphaNeeded) {
      const double maxValue = 255.0;
      double alpha          = (double)bgClearColor.m / maxValue;
      bgClearColor.r *= alpha;
      bgClearColor.g *= alpha;
      bgClearColor.b *= alpha;
    }
    m_offlineGlContext.clear(bgClearColor);

    Stage::VisitArgs args;
    args.m_scene = &scene;
    args.m_xsh   = scene.getXsheet();
    args.m_row   = row;
    args.m_col   = m_columnIndex;
    args.m_osm   = &m_osMask;

    ImagePainter::VisualSettings vs;
    Stage::OpenGlPainter painter(viewAff, clipRect, vs, false, true);

    Stage::visit(painter, args);
    /*
painter,
&scene,
scene.getXsheet(), row,
m_columnIndex, m_osMask,
false,0);
*/
    TImageWriterP writer = m_lw->getFrameWriter(m_frameIndex++);
    if (!writer) return false;

#ifdef MACOSX
    glFinish();  // per fissare il bieco baco su Mac/G3
#endif

    TRaster32P raster = m_offlineGlContext.getRaster();

#ifdef MACOSX
    if (m_alphaEnabled && m_alphaNeeded)
      checkAndCorrectPremultipliedImage(raster);
#endif

    if (Preferences::instance()->isSceneNumberingEnabled())
      TRasterImageUtils::addSceneNumbering(TRasterImageP(raster),
                                           m_frameIndex - 1,
                                           scene.getSceneName(), row + 1);
    TRasterImageP img(raster);
    writer->save(img);

    return true;
  }