Exemplo n.º 1
0
void FunctionViewer::refreshModel() {
  TXsheet *xsh = m_xshHandle ? m_xshHandle->getXsheet() : 0;

  m_functionGraph->getModel()->refreshData(xsh);

  if (xsh) {
    int rowCount = xsh->getFrameCount();
    m_numericalColumns->setRowCount(rowCount);
    m_numericalColumns->updateAll();

    ToonzScene *scene = xsh->getScene();
    if (!scene)  // This seems wrong. It should rather be
      return;    // asserted - though I'm not touching it now...

    TFilePath scenePath = scene->getScenePath().getParentDir();
    if (scene->isUntitled())
      scenePath =
          TProjectManager::instance()->getCurrentProject()->getScenesPath();

    m_treeView->setCurrentScenePath(scenePath);

    int distance, offset;
    scene->getProperties()->getMarkers(distance, offset);
    m_numericalColumns->setMarkRow(distance, offset);
  }

  m_treeView->updateAll();
  m_toolbar->setCurve(0);
}
Exemplo n.º 2
0
void ColumnCmd::resequence(int index) {
  if (!canResequence(index)) return;
  TXsheet *xsh       = TApp::instance()->getCurrentXsheet()->getXsheet();
  TXshColumn *column = xsh->getColumn(index);
  assert(column);
  TXshLevelColumn *lcolumn = column->getLevelColumn();
  assert(lcolumn);
  int r0 = 0, r1 = -1;
  lcolumn->getRange(r0, r1);
  assert(r0 <= r1);
  TXshCell cell = lcolumn->getCell(r0);
  assert(!cell.isEmpty());
  TXshChildLevel *xl = cell.m_level->getChildLevel();
  assert(xl);
  TXsheet *childXsh              = xl->getXsheet();
  int frameCount                 = childXsh->getFrameCount();
  if (frameCount < 1) frameCount = 1;

  TUndoManager::manager()->add(new ResequenceUndo(index, frameCount));

  lcolumn->clearCells(r0, r1 - r0 + 1);
  for (int i = 0; i < frameCount; i++) {
    cell.m_frameId = TFrameId(i + 1);
    lcolumn->setCell(r0 + i, cell);
  }

  xsh->updateFrameCount();

  TApp::instance()->getCurrentScene()->setDirtyFlag(true);
  TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}
Exemplo n.º 3
0
void RowArea::mousePressEvent(QMouseEvent *event)
{
	m_viewer->setQtModifiers(event->modifiers());
	if (event->button() == Qt::LeftButton) {
		bool playRangeModifierisClicked = false;

		TApp *app = TApp::instance();
		TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet();
		TPoint pos(event->pos().x(), event->pos().y());

		int row = m_viewer->yToRow(pos.y);

		QRect visibleRect = visibleRegion().boundingRect();
		int playR0, playR1, step;
		XsheetGUI::getPlayRange(playR0, playR1, step);

		bool playRangeEnabled = playR0 <= playR1;
		if (!playRangeEnabled) {
			TXsheet *xsh = m_viewer->getXsheet();
			playR1 = xsh->getFrameCount() - 1;
			playR0 = 0;
		}

		if (playR1 == -1) { //getFrameCount = 0 i.e. xsheet is empty
			setDragTool(XsheetGUI::DragTool::makeCurrentFrameModifierTool(m_viewer));
		} else if (m_xa <= pos.x && pos.x <= m_xa + 10 && (row == playR0 || row == playR1)) {
			if (!playRangeEnabled)
				XsheetGUI::setPlayRange(playR0, playR1, step);
			setDragTool(XsheetGUI::DragTool::makePlayRangeModifierTool(m_viewer));
			playRangeModifierisClicked = true;
		} else
			setDragTool(XsheetGUI::DragTool::makeCurrentFrameModifierTool(m_viewer));

		//when shift+click the row area, select a single row region in the cell area
		if (!playRangeModifierisClicked && 0 != (event->modifiers() & Qt::ShiftModifier)) {
			int filledCol;
			for (filledCol = xsh->getColumnCount() - 1; filledCol >= 0; filledCol--) {
				TXshColumn *currentColumn = xsh->getColumn(filledCol);
				if (!currentColumn)
					continue;
				if (!currentColumn->isEmpty())
					break;
			}

			m_viewer->getCellSelection()->selectNone();
			m_viewer->getCellSelection()->selectCells(row, 0, row, tmax(0, filledCol));
			m_viewer->updateCellRowAree();
		}

		m_viewer->dragToolClick(event);
		event->accept();
	} // left-click
	// pan by middle-drag
	else if (event->button() == Qt::MidButton) {
		m_pos = event->pos();
		m_isPanning = true;
	}
}
Exemplo n.º 4
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));
}
Exemplo n.º 5
0
void RowArea::drawPlayRange(QPainter &p, int r0, int r1)
{
	bool playRangeEnabled = XsheetGUI::isPlayRangeEnabled();

	// Update the play range internal fields
	if (playRangeEnabled) {
		int step;
		XsheetGUI::getPlayRange(m_r0, m_r1, step);
	}
	// if the preview range is not set, then put markers at the first and the last frames of the scene
	else {
		TXsheet *xsh = m_viewer->getXsheet();
		m_r1 = xsh->getFrameCount() - 1;
		if (m_r1 == -1)
			return;
		m_r0 = 0;
	}

	QColor ArrowColor = (playRangeEnabled) ? QColor(255, 255, 255) : grey150;
	p.setBrush(QBrush(ArrowColor));

	if (m_r0 > r0 - 1 && r1 + 1 > m_r0) {
		int y0 = m_viewer->rowToY(m_r0);
		drawArrow(p, QPointF(m_xa, y0 + 1),
				  QPointF(m_xa + 10, y0 + 1),
				  QPointF(m_xa, y0 + 11),
				  true, ArrowColor);
	}

	if (m_r1 > r0 - 1 && r1 + 1 > m_r1) {
		int y1 = m_viewer->rowToY(m_r1 + 1) - 12;
		drawArrow(p, QPointF(m_xa, y1 + 1),
				  QPointF(m_xa + 10, y1 + 11),
				  QPointF(m_xa, y1 + 11),
				  true, ArrowColor);
	}
}
Exemplo n.º 6
0
void RowArea::drawRows(QPainter &p, int r0, int r1)
{
	int playR0, playR1, step;
	XsheetGUI::getPlayRange(playR0, playR1, step);

	if (!XsheetGUI::isPlayRangeEnabled()) {
		TXsheet *xsh = m_viewer->getXsheet();
		playR1 = xsh->getFrameCount() - 1;
		playR0 = 0;
	}

#ifdef _WIN32
	static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Bold);
#else
	static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal);
#endif
	p.setFont(font);

	// marker interval
	int distance, offset;
	TApp::instance()->getCurrentScene()->getScene()->getProperties()->getMarkers(distance, offset);

	//default value
	if (distance == 0)
		distance = 6;

	QRect visibleRect = visibleRegion().boundingRect();

	int x0 = visibleRect.left();
	int x1 = visibleRect.right();
	int y0 = visibleRect.top();
	int y1 = visibleRect.bottom();

	for (int r = r0; r <= r1; r++) {
		int y = m_viewer->rowToY(r);

		//--- draw horizontal line
		QColor color = ((r - offset) % distance != 0) ? m_viewer->getLightLineColor() : m_viewer->getMarkerLineColor();
		p.setPen(color);
		p.drawLine(x0, y, x1, y);

		// draw frame text
		if (playR0 <= r && r <= playR1) {
			p.setPen(((r - m_r0) % step == 0) ? m_viewer->getPreviewFrameTextColor() : m_viewer->getTextColor());
		}
		//not in preview range
		else
			p.setPen(m_viewer->getTextColor());

		switch (m_viewer->getFrameDisplayStyle()) {
		case XsheetViewer::SecAndFrame: {
			int frameRate = TApp::instance()->getCurrentScene()->getScene()->getProperties()->getOutputProperties()->getFrameRate();
			QString str;
			int koma = (r + 1) % frameRate;
			if (koma == 1) {
				int sec = (r + 1) / frameRate;
				str = QString("%1' %2\"").arg(QString::number(sec).rightJustified(2, '0')).arg(QString::number(koma).rightJustified(2, '0'));
			} else {
				if (koma == 0)
					koma = frameRate;
				str = QString("%1\"").arg(QString::number(koma).rightJustified(2, '0'));
			}

			p.drawText(QRect(width() / 2 - 15, y + 1, width() / 2 + 7, RowHeight - 2), Qt::AlignRight | Qt::AlignBottom, str);

			break;
		}

		case XsheetViewer::Frame: {
			QString number = QString::number(r + 1);
			p.drawText(QRect(width() / 2 - 2, y + 1, width() / 2, RowHeight - 2), Qt::AlignHCenter | Qt::AlignBottom, number);
			break;
		}

		//6 second sheet (144frames per page)
		case XsheetViewer::SixSecSheet: {
			int frameRate = TApp::instance()->getCurrentScene()->getScene()->getProperties()->getOutputProperties()->getFrameRate();
			QString str;
			int koma = (r + 1) % (frameRate * 6);
			if ((r + 1) % frameRate == 1) {
				int page = (r + 1) / (frameRate * 6) + 1;
				str = QString("p%1  %2").arg(QString::number(page)).arg(QString::number(koma).rightJustified(3, '0'));
			} else {
				if (koma == 0)
					koma = frameRate * 6;
				str = QString("%1").arg(QString::number(koma).rightJustified(3, '0'));
			}
			p.drawText(QRect(width() / 2 - 21, y + 1, width() / 2 + 7, RowHeight - 2), Qt::AlignRight | Qt::AlignBottom, str);
			break;
		}
		//3 second sheet (72frames per page)
		case XsheetViewer::ThreeSecSheet: {
			int frameRate = TApp::instance()->getCurrentScene()->getScene()->getProperties()->getOutputProperties()->getFrameRate();
			QString str;
			int koma = (r + 1) % (frameRate * 3);
			if ((r + 1) % frameRate == 1) {
				int page = (r + 1) / (frameRate * 3) + 1;
				str = QString("p%1  %2").arg(QString::number(page)).arg(QString::number(koma).rightJustified(2, '0'));
			} else {
				if (koma == 0)
					koma = frameRate * 3;
				str = QString("%1").arg(QString::number(koma).rightJustified(2, '0'));
			}
			p.drawText(QRect(width() / 2 - 21, y + 1, width() / 2 + 7, RowHeight - 2), Qt::AlignRight | Qt::AlignBottom, str);
			break;
		}
		}
	}

	// hide the top-most horizontal line
	if (r0 == 0) {
		p.setPen(m_viewer->getLightLineColor());
		p.drawLine(x0, m_viewer->rowToY(0), x1, m_viewer->rowToY(0));
	}
}
Exemplo n.º 7
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);
}