コード例 #1
0
bool Camera::loadKeyframes(const char* szFileName)
{
	std::ifstream ifsFile;

	ifsFile.open(szFileName, std::ios::in);
	if (!ifsFile.fail()) {
		int iCurveCount;
		int iNumKeyframes;

		ifsFile >> iNumKeyframes;
		if (iNumKeyframes <= 0)
			return false;
		mNumKeyframes = iNumKeyframes;

		ifsFile >> iCurveCount;

		if (iCurveCount != NUM_KEY_CURVES) {
			return false;
		}

		deleteCurves();
		createCurves(0.0f, 1.0f);

		for (int i = 0; i < iCurveCount; ++i) {
			mKeyframes[i]->fromStream(ifsFile);
		}

		return true;
	}
コード例 #2
0
bool Camera::setKeyframe(float t, float maxT)
{
	if (m_bSnapped)
		removeKeyframe(t);

	if (mNumKeyframes == 0) {
		// delete old curves
		deleteCurves();
		createCurves(t, maxT);
		mNumKeyframes++;
		return true;
	}

	// check if we're too close to a ctrl pt
	double TIME_EPSILON = 0.01;
	Point closestCtrlPt;
	Point azimuthPt(t, mAzimuth);
	mKeyframes[AZIMUTH]->getClosestControlPoint(azimuthPt, closestCtrlPt);
	if (fabs(t - closestCtrlPt.x) <= TIME_EPSILON)
		return false;

	mKeyframes[AZIMUTH]->addControlPoint(Point(t, mAzimuth));
	mKeyframes[ELEVATION]->addControlPoint(Point(t, mElevation));
	mKeyframes[DOLLY]->addControlPoint(Point(t, mDolly));
	mKeyframes[LOOKAT_X]->addControlPoint(Point(t, mLookAt[0]));
	mKeyframes[LOOKAT_Y]->addControlPoint(Point(t, mLookAt[1]));
	mKeyframes[LOOKAT_Z]->addControlPoint(Point(t, mLookAt[2]));

	mNumKeyframes++;

	return true;
}
コード例 #3
0
ファイル: CQPlotSubwidget.cpp プロジェクト: copasi/COPASI
bool CQPlotSubwidget::loadFromPlotSpec(const CPlotSpecification *pspec)
{
  if (!pspec) return false;

  mLastSelection.clear();
  //title
  titleLineEdit->setText(pspec->getTitle().c_str());
  //active?
  activeCheckBox->setChecked(pspec->isActive());
  //type
  mType = pspec->getType();

  mTaskTypes = pspec->getTaskTypes();

  txtTaskTypes->setText(FROM_UTF8(mTaskTypes));
  chkTaskTypes->setChecked(mTaskTypes.empty());

  switch (mType)
    {
#ifdef COPASI_BANDED_GRAPH

      case CPlotItem::bandedGraph:
#endif // COPASI_BANDED_GRAPH
      case CPlotItem::spectogram:
      case CPlotItem::plot2d:
        checkLogX->setChecked(pspec->isLogX());
        checkLogY->setChecked(pspec->isLogY());
        break;

      default:
        fatalError();
        break;
    }

  //clear tabWidget
  deleteCurves();
  mpListPlotItems->clearSelection();
  //reconstruct tabWidget from curve specs
  CDataVector<CPlotItem>::const_iterator it = pspec->getItems().begin();
  CDataVector<CPlotItem>::const_iterator end = pspec->getItems().end();
  QStringList PlotItems;

  for (; it != end; ++it)
    {
      QString title = FROM_UTF8(it->getTitle());
      PlotItems.append(title);
      CPlotItem *pItem = new CPlotItem(*it, NO_PARENT);
      // The copy has the same parent as the original, i.e., it has been added to the plot specification.
      const_cast< CPlotSpecification * >(pspec)->getItems().remove(pItem);
      mList.insert(title, pItem);
    }

  mpListPlotItems->addItems(PlotItems);

  if (pspec->getItems().size() > 0)
    {
      mpListPlotItems->setCurrentRow(0, QItemSelectionModel::Select);
    }
  else
    {
      // We need to clear the current items display
      selectPlotItem(NULL);
    }

  return true; //TODO really check
}