Jeremy Bullock f15907
#include "stopmotion.h"
Jeremy Bullock f15907
Jeremy Bullock f15907
#ifdef WIN32
Jeremy Bullock f15907
#include <windows.h></windows.h>
Jeremy Bullock f15907
#include <mfobjects.h></mfobjects.h>
Jeremy Bullock f15907
#include <mfapi.h></mfapi.h>
Jeremy Bullock f15907
#include <mfidl.h></mfidl.h>
Jeremy Bullock f15907
#pragma comment(lib, "Mfplat.lib")
Jeremy Bullock f15907
#pragma comment(lib, "Mf.lib")
Jeremy Bullock f15907
#pragma comment(lib, "Mfreadwrite.lib")
Jeremy Bullock f15907
#pragma comment(lib, "mfuuid.lib")
Jeremy Bullock f15907
#pragma comment(lib, "shlwapi.lib")
Jeremy Bullock f15907
#endif
Jeremy Bullock f15907
Jeremy Bullock f15907
// TnzCore includes
Jeremy Bullock f15907
#include "menubarcommandids.h"
Jeremy Bullock f15907
#include "tapp.h"
Jeremy Bullock f15907
#include "tenv.h"
Jeremy Bullock f15907
#include "tsystem.h"
Jeremy Bullock f15907
#include "filebrowsermodel.h"
Jeremy Bullock f15907
#include "penciltestpopup.h"
Jeremy Bullock f15907
#include "tlevel_io.h"
Jeremy Bullock f15907
#include "toutputproperties.h"
Jeremy Bullock f15907
Jeremy Bullock f15907
#include "toonz/namebuilder.h"
Jeremy Bullock f15907
#include "toonz/preferences.h"
Jeremy Bullock f15907
#include "toonz/tcamera.h"
Jeremy Bullock f15907
#include "toonz/tcolumnhandle.h"
Jeremy Bullock f15907
#include "toonz/tframehandle.h"
Jeremy Bullock f15907
#include "toonz/levelset.h"
Jeremy Bullock f15907
#include "toonz/sceneproperties.h"
Jeremy Bullock f15907
#include "toonz/toonzscene.h"
Jeremy Bullock f15907
#include "toonz/tscenehandle.h"
Jeremy Bullock f15907
#include "toonz/stage.h"
Jeremy Bullock f15907
#include "toonz/txsheethandle.h"
Jeremy Bullock f15907
#include "toonz/txshlevelhandle.h"
Jeremy Bullock f15907
#include "toonz/txshsimplelevel.h"
Jeremy Bullock f15907
#include "toonz/levelproperties.h"
Jeremy Bullock f15907
#include "toonz/tstageobjecttree.h"
Jeremy Bullock f15907
Jeremy Bullock f15907
#include "toonzqt/menubarcommand.h"
Jeremy Bullock f15907
Jeremy Bullock f15907
#include <qapplication></qapplication>
Jeremy Bullock f15907
#include <qcamera></qcamera>
Jeremy Bullock f15907
#include <qcamerainfo></qcamerainfo>
Jeremy Bullock f15907
#include <qcoreapplication></qcoreapplication>
Jeremy Bullock f15907
#include <qdesktopwidget></qdesktopwidget>
Jeremy Bullock f15907
#include <qdialog></qdialog>
Jeremy Bullock f15907
#include <qfile></qfile>
Jeremy Bullock f15907
#include <qstring></qstring>
Jeremy Bullock f15907
#include <qtimer></qtimer>
Jeremy Bullock f15907
Jeremy Bullock f15907
// Connected camera
Jeremy Bullock f15907
TEnv::IntVar StopMotionUseScaledImages("StopMotionUseScaledImages", 0);
Jeremy Bullock f15907
TEnv::IntVar StopMotionOpacity("StopMotionOpacity", 100);
Jeremy Bullock f15907
TEnv::IntVar StopMotionUseDirectShow("StopMotionUseDirectShow", 1);
Jeremy Bullock f15907
TEnv::IntVar StopMotionAlwaysLiveView("StopMotionAlwaysLiveView", 0);
Jeremy Bullock f15907
Jeremy Bullock f15907
TEnv::IntVar StopMotionBlackCapture("StopMotionBlackCapture", 0);
Jeremy Bullock f15907
TEnv::IntVar StopMotionPlaceOnXSheet("StopMotionPlaceOnXSheet", 1);
Jeremy Bullock f15907
TEnv::IntVar StopMotionReviewTime("StopMotionReviewTime", 1);
Jeremy Bullock f15907
TEnv::IntVar StopMotionUseMjpg("StopMotionUseMjpg", 1);
Jeremy Bullock f15907
TEnv::IntVar StopMotionUseNumpad("StopMotionUseNumpad", 0);
Jeremy Bullock f15907
Jeremy Bullock f15907
// Connected camera
Jeremy Bullock f15907
TEnv::StringVar StopMotionCameraName("CamCapCameraName", "");
Jeremy Bullock f15907
// Camera resolution
Jeremy Bullock f15907
TEnv::StringVar StopMotionCameraResolution("CamCapCameraResolution", "");
Jeremy Bullock f15907
Jeremy Bullock f15907
namespace {
Jeremy Bullock f15907
bool l_quitLoop = false;
Jeremy Bullock f15907
Jeremy Bullock f15907
TPointD getCurrentCameraDpi() {
Jeremy Bullock f15907
  TCamera *camera =
Jeremy Bullock f15907
      TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
Jeremy Bullock f15907
  TDimensionD size = camera->getSize();
Jeremy Bullock f15907
  TDimension res   = camera->getRes();
Jeremy Bullock f15907
  return TPointD(res.lx / size.lx, res.ly / size.ly);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
bool findCell(TXsheet *xsh, int col, const TXshCell &targetCell,
Jeremy Bullock f15907
              int &bottomRowWithTheSameLevel) {
Jeremy Bullock f15907
  bottomRowWithTheSameLevel = -1;
Jeremy Bullock f15907
  TXshColumnP column        = const_cast<txsheet *="">(xsh)->getColumn(col);</txsheet>
Jeremy Bullock f15907
  if (!column) return false;
Jeremy Bullock f15907
Jeremy Bullock f15907
  TXshCellColumn *cellColumn = column->getCellColumn();
Jeremy Bullock f15907
  if (!cellColumn) return false;
Jeremy Bullock f15907
Jeremy Bullock f15907
  int r0, r1;
Jeremy Bullock f15907
  if (!cellColumn->getRange(r0, r1)) return false;
Jeremy Bullock f15907
Jeremy Bullock f15907
  for (int r = r0; r <= r1; r++) {
Jeremy Bullock f15907
    TXshCell cell = cellColumn->getCell(r);
Jeremy Bullock f15907
    if (cell == targetCell) {
Jeremy Bullock f15907
      bottomRowWithTheSameLevel = r;
Jeremy Bullock f15907
      return true;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    if (cell.m_level == targetCell.m_level) bottomRowWithTheSameLevel = r;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  return false;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QChar numToLetter(int letterNum) {
Jeremy Bullock f15907
  switch (letterNum) {
Jeremy Bullock f15907
  case 0:
Jeremy Bullock f15907
    return QChar();
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  case 1:
Jeremy Bullock f15907
    return 'A';
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  case 2:
Jeremy Bullock f15907
    return 'B';
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  case 3:
Jeremy Bullock f15907
    return 'C';
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  case 4:
Jeremy Bullock f15907
    return 'D';
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  case 5:
Jeremy Bullock f15907
    return 'E';
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  case 6:
Jeremy Bullock f15907
    return 'F';
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  case 7:
Jeremy Bullock f15907
    return 'G';
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  case 8:
Jeremy Bullock f15907
    return 'H';
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  case 9:
Jeremy Bullock f15907
    return 'I';
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  default:
Jeremy Bullock f15907
    return QChar();
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QString convertToFrameWithLetter(int value, int length = -1) {
Jeremy Bullock f15907
  QString str;
Jeremy Bullock f15907
  str.setNum((int)(value / 10));
Jeremy Bullock f15907
  while (str.length() < length) str.push_front("0");
Jeremy Bullock f15907
  QChar letter = numToLetter(value % 10);
Jeremy Bullock f15907
  if (!letter.isNull()) str.append(letter);
Jeremy Bullock f15907
  return str;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QString fidsToString(const std::vector<tframeid> &fids,</tframeid>
Jeremy Bullock f15907
                     bool letterOptionEnabled) {
Jeremy Bullock f15907
  if (fids.empty()) return StopMotion::tr("No", "frame id");
Jeremy Bullock f15907
  QString retStr("");
Jeremy Bullock f15907
  if (letterOptionEnabled) {
Jeremy Bullock f15907
    bool beginBlock = true;
Jeremy Bullock f15907
    for (int f = 0; f < fids.size() - 1; f++) {
Jeremy Bullock f15907
      int num      = fids[f].getNumber();
Jeremy Bullock f15907
      int next_num = fids[f + 1].getNumber();
Jeremy Bullock f15907
Jeremy Bullock f15907
      if (num % 10 == 0 && num + 10 == next_num) {
Jeremy Bullock f15907
        if (beginBlock) {
Jeremy Bullock f15907
          retStr += convertToFrameWithLetter(num) + " - ";
Jeremy Bullock f15907
          beginBlock = false;
Jeremy Bullock f15907
        }
Jeremy Bullock f15907
      } else {
Jeremy Bullock f15907
        retStr += convertToFrameWithLetter(num) + ", ";
Jeremy Bullock f15907
        beginBlock = true;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    retStr += convertToFrameWithLetter(fids.back().getNumber());
Jeremy Bullock f15907
  } else {
Jeremy Bullock f15907
    bool beginBlock = true;
Jeremy Bullock f15907
    for (int f = 0; f < fids.size() - 1; f++) {
Jeremy Bullock f15907
      int num      = fids[f].getNumber();
Jeremy Bullock f15907
      int next_num = fids[f + 1].getNumber();
Jeremy Bullock f15907
      if (num + 1 == next_num) {
Jeremy Bullock f15907
        if (beginBlock) {
Jeremy Bullock f15907
          retStr += QString::number(num) + " - ";
Jeremy Bullock f15907
          beginBlock = false;
Jeremy Bullock f15907
        }
Jeremy Bullock f15907
      } else {
Jeremy Bullock f15907
        retStr += QString::number(num) + ", ";
Jeremy Bullock f15907
        beginBlock = true;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    retStr += QString::number(fids.back().getNumber());
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  return retStr;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
bool getRasterLevelSize(TXshLevel *level, TDimension &dim) {
Jeremy Bullock f15907
  std::vector<tframeid> fids;</tframeid>
Jeremy Bullock f15907
  level->getFids(fids);
Jeremy Bullock f15907
  if (fids.empty()) return false;
Jeremy Bullock f15907
  TXshSimpleLevel *simpleLevel = level->getSimpleLevel();
Jeremy Bullock f15907
  if (!simpleLevel) return false;
Jeremy Bullock f15907
  TRasterImageP rimg = (TRasterImageP)simpleLevel->getFrame(fids[0], false);
Jeremy Bullock f15907
  if (!rimg || rimg->isEmpty()) return false;
Jeremy Bullock f15907
Jeremy Bullock f15907
  dim = rimg->getRaster()->getSize();
Jeremy Bullock f15907
  return true;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
};  // namespace
Jeremy Bullock f15907
Jeremy Bullock f15907
//=============================================================================
Jeremy Bullock f15907
//=============================================================================
Jeremy Bullock f15907
Jeremy Bullock f15907
JpgConverter::JpgConverter() {}
Jeremy Bullock f15907
JpgConverter::~JpgConverter() {}
Jeremy Bullock f15907
Jeremy Bullock f15907
void JpgConverter::setStream(EdsStreamRef stream) { m_stream = stream; }
Jeremy Bullock f15907
Jeremy Bullock f15907
void JpgConverter::convertFromJpg() {
Jeremy Bullock f15907
  unsigned __int64 mySize = 0;
Jeremy Bullock f15907
  unsigned char *data     = NULL;
Jeremy Bullock f15907
  EdsError err            = EdsGetPointer(m_stream, (EdsVoid **)&data);
Jeremy Bullock f15907
  err                     = EdsGetLength(m_stream, &mySize);
Jeremy Bullock f15907
Jeremy Bullock f15907
  int width, height, pixelFormat;
Jeremy Bullock f15907
  int inSubsamp, inColorspace;
Jeremy Bullock f15907
  tjhandle tjInstance   = NULL;
Jeremy Bullock f15907
  unsigned char *imgBuf = NULL;
Jeremy Bullock f15907
  tjInstance            = tjInitDecompress();
Jeremy Bullock f15907
  tjDecompressHeader3(tjInstance, data, mySize, &width, &height, &inSubsamp,
Jeremy Bullock f15907
                      &inColorspace);
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (width < 0 || height < 0) {
Jeremy Bullock f15907
    emit(imageReady(false));
Jeremy Bullock f15907
    return;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  pixelFormat = TJPF_BGRX;
Jeremy Bullock f15907
  imgBuf = (unsigned char *)tjAlloc(width * height * tjPixelSize[pixelFormat]);
Jeremy Bullock f15907
  int flags = 0;
Jeremy Bullock f15907
#ifdef WIN32
Jeremy Bullock f15907
  flags |= TJFLAG_BOTTOMUP;
Jeremy Bullock f15907
#endif
Jeremy Bullock f15907
  int factorsNum;
Jeremy Bullock f15907
  tjscalingfactor scalingFactor = {1, 1};
Jeremy Bullock f15907
  tjscalingfactor *factor       = tjGetScalingFactors(&factorsNum);
Jeremy Bullock f15907
  int i                         = 0;
Jeremy Bullock f15907
  int tempWidth, tempHeight;
Jeremy Bullock f15907
  while (i < factorsNum) {
Jeremy Bullock f15907
    scalingFactor = factor[i];
Jeremy Bullock f15907
    i++;
Jeremy Bullock f15907
    tempWidth  = TJSCALED(width, scalingFactor);
Jeremy Bullock f15907
    tempHeight = TJSCALED(height, scalingFactor);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  tjDecompress2(tjInstance, data, mySize, imgBuf, width,
Jeremy Bullock f15907
                width * tjPixelSize[pixelFormat], height, pixelFormat, flags);
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_finalImage = TRaster32P(width, height);
Jeremy Bullock f15907
  m_finalImage->lock();
Jeremy Bullock f15907
  uchar *rawData = m_finalImage->getRawData();
Jeremy Bullock f15907
  memcpy(rawData, imgBuf, width * height * tjPixelSize[pixelFormat]);
Jeremy Bullock f15907
  m_finalImage->unlock();
Jeremy Bullock f15907
Jeremy Bullock f15907
  tjFree(imgBuf);
Jeremy Bullock f15907
  imgBuf = NULL;
Jeremy Bullock f15907
  tjDestroy(tjInstance);
Jeremy Bullock f15907
  tjInstance = NULL;
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (m_stream != NULL) {
Jeremy Bullock f15907
    EdsRelease(m_stream);
Jeremy Bullock f15907
    m_stream = NULL;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  data = NULL;
Jeremy Bullock f15907
  emit(imageReady(true));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
void JpgConverter::run() { convertFromJpg(); }
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
StopMotion::StopMotion() {
Jeremy Bullock f15907
  m_opacity         = StopMotionOpacity;
Jeremy Bullock f15907
  m_useScaledImages = StopMotionUseScaledImages;
Jeremy Bullock f15907
  buildAvMap();
Jeremy Bullock f15907
  buildIsoMap();
Jeremy Bullock f15907
  buildTvMap();
Jeremy Bullock f15907
  buildModeMap();
Jeremy Bullock f15907
  buildExposureMap();
Jeremy Bullock f15907
  buildWhiteBalanceMap();
Jeremy Bullock f15907
  buildColorTemperatures();
Jeremy Bullock f15907
  buildImageQualityMap();
Jeremy Bullock f15907
  buildPictureStyleMap();
Jeremy Bullock f15907
  m_useDirectShow      = StopMotionUseDirectShow;
Jeremy Bullock f15907
  m_useMjpg            = StopMotionUseMjpg;
Jeremy Bullock f15907
  m_alwaysLiveView     = StopMotionAlwaysLiveView;
Jeremy Bullock f15907
  m_blackCapture       = StopMotionBlackCapture;
Jeremy Bullock f15907
  m_placeOnXSheet      = StopMotionPlaceOnXSheet;
Jeremy Bullock f15907
  m_reviewTime         = StopMotionReviewTime;
Jeremy Bullock f15907
  m_useNumpadShortcuts = StopMotionUseNumpad;
Jeremy Bullock f15907
  m_numpadForStyleSwitching =
Jeremy Bullock f15907
      Preferences::instance()->isUseNumpadForSwitchingStylesEnabled();
Jeremy Bullock f15907
  setUseNumpadShortcuts(m_useNumpadShortcuts);
Jeremy Bullock f15907
  m_turnOnRewind = Preferences::instance()->rewindAfterPlaybackEnabled();
Jeremy Bullock f15907
  m_timer        = new QTimer(this);
Jeremy Bullock f15907
  m_reviewTimer  = new QTimer(this);
Jeremy Bullock f15907
  m_reviewTimer->setSingleShot(true);
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_fullScreen1 = new QDialog();
Jeremy Bullock f15907
  m_fullScreen1->setModal(false);
Jeremy Bullock f15907
  m_fullScreen1->setStyleSheet("background-color:black;");
Jeremy Bullock f15907
  m_screenCount = QApplication::desktop()->screenCount();
Jeremy Bullock f15907
  if (m_screenCount > 1) {
Jeremy Bullock f15907
    m_fullScreen2 = new QDialog();
Jeremy Bullock f15907
    m_fullScreen2->setModal(false);
Jeremy Bullock f15907
    m_fullScreen2->setStyleSheet("background-color:black;");
Jeremy Bullock f15907
    if (m_screenCount == 3) {
Jeremy Bullock f15907
      m_fullScreen3 = new QDialog();
Jeremy Bullock f15907
      m_fullScreen3->setModal(false);
Jeremy Bullock f15907
      m_fullScreen3->setStyleSheet("background-color:black;");
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet();
Jeremy Bullock f15907
  TSceneHandle *sceneHandle   = TApp::instance()->getCurrentScene();
Jeremy Bullock f15907
  TFrameHandle *frameHandle   = TApp::instance()->getCurrentFrame();
Jeremy Bullock f15907
  bool ret                    = true;
Jeremy Bullock f15907
Jeremy Bullock f15907
  ret = ret &&
Jeremy Bullock f15907
        connect(xsheetHandle, SIGNAL(xsheetSwitched()), this, SLOT(update()));
Jeremy Bullock f15907
  ret = ret && connect(m_reviewTimer, SIGNAL(timeout()), this,
Jeremy Bullock f15907
                       SLOT(onReviewTimeout()));
Jeremy Bullock f15907
  ret = ret && connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimeout()));
Jeremy Bullock f15907
  ret =
Jeremy Bullock f15907
      ret && connect(this, SIGNAL(newImageReady()), this, SLOT(importImage()));
Jeremy Bullock f15907
  ret = ret && connect(sceneHandle, SIGNAL(sceneSwitched()), this,
Jeremy Bullock f15907
                       SLOT(onSceneSwitched()));
Jeremy Bullock f15907
  ret = ret && connect(frameHandle, SIGNAL(isPlayingStatusChanged()), this,
Jeremy Bullock f15907
                       SLOT(onPlaybackChanged()));
Jeremy Bullock f15907
  assert(ret);
Jeremy Bullock f15907
Jeremy Bullock f15907
  ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
Jeremy Bullock f15907
Jeremy Bullock f15907
  setToNextNewLevel();
Jeremy Bullock f15907
  m_filePath = scene->getDefaultLevelPath(OVL_TYPE, m_levelName.toStdWString())
Jeremy Bullock f15907
                   .getParentDir()
Jeremy Bullock f15907
                   .getQString();
Jeremy Bullock f15907
Jeremy Bullock f15907
  // set handler for a camera detected
Jeremy Bullock f15907
  initializeCanonSDK();
Jeremy Bullock f15907
  if (!m_error)
Jeremy Bullock f15907
    m_error = EdsSetCameraAddedHandler(StopMotion::handleCameraAddedEvent,
Jeremy Bullock f15907
                                       (EdsVoid *)this);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
StopMotion::~StopMotion() {
Jeremy Bullock f15907
  if (m_liveViewStatus != LiveViewClosed) endLiveView();
Jeremy Bullock f15907
  if (m_sessionOpen) closeCameraSession();
Jeremy Bullock f15907
  if (m_camera) releaseCamera();
Jeremy Bullock f15907
  if (m_cameraList != NULL) releaseCameraList();
Jeremy Bullock f15907
  if (m_isSDKLoaded) closeCanonSDK();
Jeremy Bullock f15907
  setUseNumpadShortcuts(false);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::onSceneSwitched() {
Jeremy Bullock f15907
  TApp *app         = TApp::instance();
Jeremy Bullock f15907
  ToonzScene *scene = app->getCurrentScene()->getScene();
Jeremy Bullock f15907
  TXsheet *xsh      = TApp::instance()->getCurrentXsheet()->getXsheet();
Jeremy Bullock f15907
  setToNextNewLevel();
Jeremy Bullock f15907
  m_filePath = scene->getDefaultLevelPath(OVL_TYPE, m_levelName.toStdWString())
Jeremy Bullock f15907
                   .getParentDir()
Jeremy Bullock f15907
                   .getQString();
Jeremy Bullock f15907
  m_frameNumber       = 1;
Jeremy Bullock f15907
  m_xSheetFrameNumber = 0;
Jeremy Bullock f15907
Jeremy Bullock f15907
  TLevelSet *levelSet = scene->getLevelSet();
Jeremy Bullock f15907
  std::vector<txshlevel *=""> levels;</txshlevel>
Jeremy Bullock f15907
  levelSet->listLevels(levels);
Jeremy Bullock f15907
  int size = levels.size();
Jeremy Bullock f15907
  for (int i = 0; i < size; i++) {
Jeremy Bullock f15907
    TXshLevel *level = levels[i];
Jeremy Bullock f15907
    if (level->getType() == OVL_XSHLEVEL) {
Jeremy Bullock f15907
      TXshSimpleLevel *sl    = 0;
Jeremy Bullock f15907
      sl                     = level->getSimpleLevel();
Jeremy Bullock f15907
      bool isStopMotionLevel = sl->getProperties()->isStopMotionLevel();
Jeremy Bullock f15907
      if (isStopMotionLevel) {
Jeremy Bullock f15907
        m_filePath    = sl->getPath().getParentDir().getQString();
Jeremy Bullock f15907
        m_levelName   = QString::fromStdWString(sl->getName());
Jeremy Bullock f15907
        m_frameNumber = sl->getFrameCount() + 1;
Jeremy Bullock f15907
        setXSheetFrameNumber(xsh->getFrameCount() + 1);
Jeremy Bullock f15907
        break;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  emit(levelNameChanged(m_levelName));
Jeremy Bullock f15907
  emit(filePathChanged(m_filePath));
Jeremy Bullock f15907
  emit(frameNumberChanged(m_frameNumber));
Jeremy Bullock f15907
  emit(xSheetFrameNumberChanged(m_xSheetFrameNumber));
Jeremy Bullock f15907
  refreshFrameInfo();
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::onPlaybackChanged() {
Jeremy Bullock f15907
  if (TApp::instance()->getCurrentFrame()->isPlaying() || m_liveViewStatus == 0)
Jeremy Bullock f15907
    return;
Jeremy Bullock f15907
Jeremy Bullock f15907
  int r0, r1, step;
Jeremy Bullock f15907
  ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
Jeremy Bullock f15907
  scene->getProperties()->getPreviewProperties()->getRange(r0, r1, step);
Jeremy Bullock f15907
  if (r1 > -1) return;
Jeremy Bullock f15907
Jeremy Bullock f15907
  int frame     = TApp::instance()->getCurrentFrame()->getFrame();
Jeremy Bullock f15907
  int lastFrame = TApp::instance()->getCurrentFrame()->getMaxFrameIndex();
Jeremy Bullock f15907
  if (frame == 0 || frame == lastFrame) {
Jeremy Bullock f15907
    TApp::instance()->getCurrentFrame()->setFrame(m_xSheetFrameNumber - 1);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setOpacity(int opacity) {
Jeremy Bullock f15907
  m_opacity         = opacity;
Jeremy Bullock f15907
  StopMotionOpacity = m_opacity;
Jeremy Bullock f15907
  emit(opacityChanged(m_opacity));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::lowerOpacity() {
Jeremy Bullock f15907
  int opacity = round((double)m_opacity / 255.0 * 10.0);
Jeremy Bullock f15907
  opacity *= 10;
Jeremy Bullock f15907
  opacity -= 10;
Jeremy Bullock f15907
  m_opacity         = double(opacity) / 100.0 * 255.0;
otakuto 158f9f
  m_opacity         = std::max(0, m_opacity);
Jeremy Bullock f15907
  StopMotionOpacity = m_opacity;
Jeremy Bullock f15907
  emit(opacityChanged(m_opacity));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::raiseOpacity() {
Jeremy Bullock f15907
  int opacity = round((double)m_opacity / 255.0 * 10.0);
Jeremy Bullock f15907
  opacity *= 10;
Jeremy Bullock f15907
  opacity += 10;
Jeremy Bullock f15907
  m_opacity         = double(opacity) / 100.0 * 255.0;
otakuto 158f9f
  m_opacity         = std::min(255, m_opacity);
Jeremy Bullock f15907
  StopMotionOpacity = m_opacity;
Jeremy Bullock f15907
  emit(opacityChanged(m_opacity));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setUseScaledImages(bool on) {
Jeremy Bullock f15907
  m_useScaledImages         = on;
Jeremy Bullock f15907
  StopMotionUseScaledImages = int(on);
Jeremy Bullock f15907
  emit(scaleFullSizeImagesSignal(on));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setAlwaysLiveView(bool on) {
Jeremy Bullock f15907
  m_alwaysLiveView         = on;
Jeremy Bullock f15907
  StopMotionAlwaysLiveView = int(on);
Jeremy Bullock f15907
  emit(liveViewOnAllFramesSignal(on));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setBlackCapture(bool on) {
Jeremy Bullock f15907
  m_blackCapture         = on;
Jeremy Bullock f15907
  StopMotionBlackCapture = int(on);
Jeremy Bullock f15907
  emit(blackCaptureSignal(on));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setPlaceOnXSheet(bool on) {
Jeremy Bullock f15907
  m_placeOnXSheet         = on;
Jeremy Bullock f15907
  StopMotionPlaceOnXSheet = int(on);
Jeremy Bullock f15907
  emit(placeOnXSheetSignal(on));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setReviewTime(int time) {
Jeremy Bullock f15907
  m_reviewTime         = time;
Jeremy Bullock f15907
  StopMotionReviewTime = time;
Jeremy Bullock f15907
  emit(reviewTimeChangedSignal(time));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setUseMjpg(bool on) {
Jeremy Bullock f15907
  m_useMjpg         = on;
Jeremy Bullock f15907
  StopMotionUseMjpg = int(on);
Jeremy Bullock f15907
  emit(useMjpgSignal(on));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::jumpToCameraFrame() {
Jeremy Bullock f15907
  TApp::instance()->getCurrentFrame()->setFrame(m_xSheetFrameNumber - 1);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setUseNumpadShortcuts(bool on) {
Jeremy Bullock f15907
  m_useNumpadShortcuts = on;
Jeremy Bullock f15907
  StopMotionUseNumpad  = int(on);
Jeremy Bullock f15907
  emit(useNumpadSignal(on));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::toggleNumpadShortcuts(bool on) {
Jeremy Bullock f15907
  // can't just return if this feature is off
Jeremy Bullock f15907
  // it could have been toggled while the camera was active
Jeremy Bullock f15907
  if (!m_useNumpadShortcuts) on = false;
shun-iwasawa 2c27a4
  CommandManager *comm = CommandManager::instance();
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (on) {
Jeremy Bullock f15907
    // if turning it on, get all old shortcuts
Jeremy Bullock f15907
    if (m_numpadForStyleSwitching) {
shun-iwasawa 2c27a4
      Preferences::instance()->setValue(useNumpadForSwitchingStyles, false);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    std::string shortcut;
Jeremy Bullock f15907
    QAction *action;
Jeremy Bullock f15907
    for (int i = 0; i <= 9; i++) {
Jeremy Bullock f15907
      shortcut = QString::number(i).toStdString();
Jeremy Bullock f15907
      action   = comm->getActionFromShortcut(shortcut);
Jeremy Bullock f15907
      if (action) {
Jeremy Bullock f15907
        m_oldActionMap.insert(
Jeremy Bullock f15907
            std::pair<std::string, *="" qaction="">(shortcut, action));</std::string,>
Jeremy Bullock f15907
        action->setShortcut(QKeySequence(""));
Jeremy Bullock f15907
        action = NULL;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    shortcut = "+";
Jeremy Bullock f15907
    action   = comm->getActionFromShortcut(shortcut);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      m_oldActionMap.insert(
Jeremy Bullock f15907
          std::pair<std::string, *="" qaction="">(shortcut, action));</std::string,>
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    shortcut = "-";
Jeremy Bullock f15907
    action   = comm->getActionFromShortcut(shortcut);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      m_oldActionMap.insert(
Jeremy Bullock f15907
          std::pair<std::string, *="" qaction="">(shortcut, action));</std::string,>
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    shortcut = "Return";
Jeremy Bullock f15907
    action   = comm->getActionFromShortcut(shortcut);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      m_oldActionMap.insert(
Jeremy Bullock f15907
          std::pair<std::string, *="" qaction="">(shortcut, action));</std::string,>
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    shortcut = "*";
Jeremy Bullock f15907
    action   = comm->getActionFromShortcut(shortcut);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      m_oldActionMap.insert(
Jeremy Bullock f15907
          std::pair<std::string, *="" qaction="">(shortcut, action));</std::string,>
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
Jeremy Bullock f15907
    // now set all new shortcuts
Jeremy Bullock f15907
    action = comm->getAction(MI_PrevDrawing);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(QKeySequence("1"));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_NextDrawing);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(QKeySequence("2"));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionJumpToCamera);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(QKeySequence("3"));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_Loop);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(QKeySequence("8"));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_Play);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(QKeySequence("0"));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionRaiseOpacity);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(QKeySequence("+"));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionLowerOpacity);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(QKeySequence("-"));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionCapture);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(QKeySequence("Enter"));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionToggleLiveView);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(QKeySequence("5"));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionToggleZoom);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(QKeySequence("*"));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
Jeremy Bullock f15907
  } else {
Jeremy Bullock f15907
    // unset the new shortcuts first
Jeremy Bullock f15907
    QAction *action;
Jeremy Bullock f15907
    action = comm->getAction(MI_PrevDrawing);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(
Jeremy Bullock f15907
          QKeySequence(comm->getShortcutFromAction(action).c_str()));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_NextDrawing);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(
Jeremy Bullock f15907
          QKeySequence(comm->getShortcutFromAction(action).c_str()));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionJumpToCamera);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(
Jeremy Bullock f15907
          QKeySequence(comm->getShortcutFromAction(action).c_str()));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_Loop);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(
Jeremy Bullock f15907
          QKeySequence(comm->getShortcutFromAction(action).c_str()));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_Play);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(
Jeremy Bullock f15907
          QKeySequence(comm->getShortcutFromAction(action).c_str()));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionCapture);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(
Jeremy Bullock f15907
          QKeySequence(comm->getShortcutFromAction(action).c_str()));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionLowerOpacity);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(
Jeremy Bullock f15907
          QKeySequence(comm->getShortcutFromAction(action).c_str()));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionRaiseOpacity);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(
Jeremy Bullock f15907
          QKeySequence(comm->getShortcutFromAction(action).c_str()));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionToggleLiveView);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(
Jeremy Bullock f15907
          QKeySequence(comm->getShortcutFromAction(action).c_str()));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    action = comm->getAction(MI_StopMotionToggleZoom);
Jeremy Bullock f15907
    if (action) {
Jeremy Bullock f15907
      action->setShortcut(
Jeremy Bullock f15907
          QKeySequence(comm->getShortcutFromAction(action).c_str()));
Jeremy Bullock f15907
      action = NULL;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
Jeremy Bullock f15907
    // now put back the old shortcuts
Jeremy Bullock f15907
    auto it = m_oldActionMap.begin();
Jeremy Bullock f15907
    while (it != m_oldActionMap.end()) {
Jeremy Bullock f15907
      it->second->setShortcut(QKeySequence(it->first.c_str()));
Jeremy Bullock f15907
      it++;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    if (m_numpadForStyleSwitching) {
Jeremy Bullock f15907
      std::string shortcut;
Jeremy Bullock f15907
      QAction *action;
Jeremy Bullock f15907
      for (int i = 0; i <= 9; i++) {
Jeremy Bullock f15907
        shortcut = QString::number(i).toStdString();
Jeremy Bullock f15907
        action   = comm->getActionFromShortcut(shortcut);
Jeremy Bullock f15907
        if (action) {
Jeremy Bullock f15907
          action->setShortcut(QKeySequence(""));
Jeremy Bullock f15907
          action = NULL;
Jeremy Bullock f15907
        }
Jeremy Bullock f15907
      }
shun-iwasawa 2c27a4
      Preferences::instance()->setValue(useNumpadForSwitchingStyles, true);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setXSheetFrameNumber(int frameNumber) {
Jeremy Bullock f15907
  m_xSheetFrameNumber = frameNumber;
Jeremy Bullock f15907
  loadLineUpImage();
Jeremy Bullock f15907
  emit(xSheetFrameNumberChanged(m_xSheetFrameNumber));
Jeremy Bullock f15907
  TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
bool StopMotion::loadLineUpImage() {
Jeremy Bullock f15907
  if (m_liveViewStatus < 1) return false;
Jeremy Bullock f15907
  m_hasLineUpImage = false;
Jeremy Bullock f15907
  // first see if the level exists in the current level set
Jeremy Bullock f15907
  ToonzScene *currentScene = TApp::instance()->getCurrentScene()->getScene();
Jeremy Bullock f15907
  TLevelSet *levelSet      = currentScene->getLevelSet();
Jeremy Bullock f15907
Jeremy Bullock f15907
  std::wstring levelName = m_levelName.toStdWString();
Jeremy Bullock f15907
Jeremy Bullock f15907
  // level with the same name
Jeremy Bullock f15907
  TXshLevel *level_sameName = levelSet->getLevel(levelName);
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath levelFp = TFilePath(m_filePath) +
Jeremy Bullock f15907
                      TFilePath(levelName + L".." + m_fileType.toStdWString());
Jeremy Bullock f15907
Jeremy Bullock f15907
  // level with the same path
Jeremy Bullock f15907
  TXshLevel *level_samePath = levelSet->getLevel(*(currentScene), levelFp);
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath actualLevelFp = currentScene->decodeFilePath(levelFp);
Jeremy Bullock f15907
  TXshSimpleLevelP sl;
Jeremy Bullock f15907
  if (level_sameName && level_samePath && level_sameName == level_samePath) {
Jeremy Bullock f15907
    sl                 = dynamic_cast<txshsimplelevel *="">(level_sameName);</txshsimplelevel>
Jeremy Bullock f15907
    bool isRasterLevel = sl && (sl->getType() == OVL_XSHLEVEL);
Jeremy Bullock f15907
    if (!isRasterLevel) {
Jeremy Bullock f15907
      return false;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  } else
Jeremy Bullock f15907
    return false;
Jeremy Bullock f15907
Jeremy Bullock f15907
  // next we need to find the column the level is on
Jeremy Bullock f15907
Jeremy Bullock f15907
  TApp *app    = TApp::instance();
Jeremy Bullock f15907
  TXsheet *xsh = currentScene->getXsheet();
Jeremy Bullock f15907
  int row;
Jeremy Bullock f15907
  if (m_xSheetFrameNumber == 1) {
Jeremy Bullock f15907
    row = 0;
Jeremy Bullock f15907
  } else {
Jeremy Bullock f15907
    row = m_xSheetFrameNumber - 2;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  int col = app->getCurrentColumn()->getColumnIndex();
Jeremy Bullock f15907
Jeremy Bullock f15907
  int foundCol = -1;
Jeremy Bullock f15907
  // most possibly, it's in the current column
Jeremy Bullock f15907
  int rowCheck;
Jeremy Bullock f15907
  findCell(xsh, col, TXshCell(level_sameName, TFrameId(1)), rowCheck);
Jeremy Bullock f15907
  if (rowCheck >= 0) {
Jeremy Bullock f15907
    foundCol = col;
Jeremy Bullock f15907
  } else {
Jeremy Bullock f15907
    // search entire xsheet
Jeremy Bullock f15907
    for (int c = 0; c < xsh->getColumnCount(); c++) {
Jeremy Bullock f15907
      if (c == col) continue;
Jeremy Bullock f15907
      findCell(xsh, c, TXshCell(level_sameName, TFrameId(1)), rowCheck);
Jeremy Bullock f15907
      if (rowCheck >= 0) {
Jeremy Bullock f15907
        foundCol = c;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (rowCheck < 0) return false;
Jeremy Bullock f15907
Jeremy Bullock f15907
  // note found row represents the last row found that uses
Jeremy Bullock f15907
  // the active level
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFrameId frameId = xsh->getCell(row, foundCol).getFrameId();
Jeremy Bullock f15907
Jeremy Bullock f15907
  int frameNumber = frameId.getNumber();
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (m_usingWebcam) {
Jeremy Bullock f15907
    if (frameNumber > 0) {
Jeremy Bullock f15907
      m_lineUpImage    = sl->getFrame(frameId, false)->raster();
Jeremy Bullock f15907
      m_hasLineUpImage = true;
Jeremy Bullock f15907
      return true;
Jeremy Bullock f15907
    } else
Jeremy Bullock f15907
      return false;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  // now check to see if a file actually exists there
Jeremy Bullock f15907
  TFilePath liveViewFolder = currentScene->decodeFilePath(
Jeremy Bullock f15907
      TFilePath(m_filePath) + TFilePath(levelName + L"_LiveView"));
Jeremy Bullock f15907
  TFilePath liveViewFp = currentScene->decodeFilePath(
Jeremy Bullock f15907
      liveViewFolder + TFilePath(levelName + L"..jpg"));
Jeremy Bullock f15907
  TFilePath liveViewFile(liveViewFp.withFrame(frameNumber));
Jeremy Bullock f15907
  if (TFileStatus(liveViewFile).doesExist()) {
Jeremy Bullock f15907
    if (loadJpg(liveViewFile, m_lineUpImage)) {
Jeremy Bullock f15907
      m_hasLineUpImage = true;
Jeremy Bullock f15907
      return true;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  return false;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setFrameNumber(int frameNumber) {
Jeremy Bullock f15907
  m_frameNumber = frameNumber;
Jeremy Bullock f15907
  emit(frameNumberChanged(m_frameNumber));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::nextFrame() {
Jeremy Bullock f15907
  if (Preferences::instance()->isShowFrameNumberWithLettersEnabled()) {
Jeremy Bullock f15907
    int f = m_frameNumber;
Jeremy Bullock f15907
    if (f % 10 == 0)  // next number
Jeremy Bullock f15907
      m_frameNumber = ((int)(f / 10) + 1) * 10;
Jeremy Bullock f15907
    else  // next alphabet
Jeremy Bullock f15907
      m_frameNumber = f + 1;
Jeremy Bullock f15907
  } else
Jeremy Bullock f15907
    m_frameNumber = m_frameNumber + 1;
Jeremy Bullock f15907
  emit(frameNumberChanged(m_frameNumber));
Jeremy Bullock f15907
  refreshFrameInfo();
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::lastFrame() {}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::previousFrame() {
Jeremy Bullock f15907
  int f = m_frameNumber;
Jeremy Bullock f15907
  if (f > 1) {
Jeremy Bullock f15907
    if (Preferences::instance()->isShowFrameNumberWithLettersEnabled()) {
Jeremy Bullock f15907
      if (f % 10 == 0)  // next number
Jeremy Bullock f15907
        m_frameNumber = ((int)(f / 10) - 1) * 10;
Jeremy Bullock f15907
      else  // next alphabet
Jeremy Bullock f15907
        m_frameNumber = f - 1;
Jeremy Bullock f15907
    } else
Jeremy Bullock f15907
      m_frameNumber = f - 1;
Jeremy Bullock f15907
    emit(frameNumberChanged(m_frameNumber));
Jeremy Bullock f15907
    refreshFrameInfo();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setLevelName(QString levelName) { m_levelName = levelName; }
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::nextName() {
Jeremy Bullock f15907
  std::unique_ptr<flexiblenamecreator> nameCreator(new FlexibleNameCreator());</flexiblenamecreator>
Jeremy Bullock f15907
  if (!nameCreator->setCurrent(m_levelName.toStdWString())) {
Jeremy Bullock f15907
    setToNextNewLevel();
Jeremy Bullock f15907
    return;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  std::wstring levelName = nameCreator->getNext();
Jeremy Bullock f15907
  updateLevelNameAndFrame(levelName);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::previousName() {
Jeremy Bullock f15907
  std::unique_ptr<flexiblenamecreator> nameCreator(new FlexibleNameCreator());</flexiblenamecreator>
Jeremy Bullock f15907
Jeremy Bullock f15907
  std::wstring levelName;
Jeremy Bullock f15907
Jeremy Bullock f15907
  // if the current level name is non-sequencial, then try to switch the last
Jeremy Bullock f15907
  // sequencial level in the scene.
Jeremy Bullock f15907
  if (!nameCreator->setCurrent(m_levelName.toStdWString())) {
Jeremy Bullock f15907
    TLevelSet *levelSet =
Jeremy Bullock f15907
        TApp::instance()->getCurrentScene()->getScene()->getLevelSet();
Jeremy Bullock f15907
    nameCreator->setCurrent(L"ZZ");
Jeremy Bullock f15907
    for (;;) {
Jeremy Bullock f15907
      levelName = nameCreator->getPrevious();
Jeremy Bullock f15907
      if (levelSet->getLevel(levelName) != 0) break;
Jeremy Bullock f15907
      if (levelName == L"A") {
Jeremy Bullock f15907
        setToNextNewLevel();
Jeremy Bullock f15907
        return;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  } else
Jeremy Bullock f15907
    levelName = nameCreator->getPrevious();
Jeremy Bullock f15907
Jeremy Bullock f15907
  updateLevelNameAndFrame(levelName);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setFileType(QString fileType) {
Jeremy Bullock f15907
  m_fileType = fileType;
Jeremy Bullock f15907
  emit(fileTypeChanged(m_fileType));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setFilePath(QString filePath) {
Jeremy Bullock f15907
  m_filePath = filePath;
Jeremy Bullock f15907
Jeremy Bullock f15907
  ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
Jeremy Bullock f15907
  TFilePath saveInPath(filePath.toStdWString());
Jeremy Bullock f15907
  scene->getProperties()->setCameraCaptureSaveInPath(saveInPath);
Jeremy Bullock f15907
  refreshFrameInfo();
Jeremy Bullock f15907
Jeremy Bullock f15907
  emit(filePathChanged(m_filePath));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setSubsamplingValue(int subsampling) {
Jeremy Bullock f15907
  m_subsampling = subsampling;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::getSubsampling() {
Jeremy Bullock f15907
  ToonzScene *currentScene = TApp::instance()->getCurrentScene()->getScene();
Jeremy Bullock f15907
  TLevelSet *levelSet      = currentScene->getLevelSet();
Jeremy Bullock f15907
Jeremy Bullock f15907
  std::wstring levelName = m_levelName.toStdWString();
Jeremy Bullock f15907
Jeremy Bullock f15907
  // level with the same name
Jeremy Bullock f15907
  TXshLevel *level_sameName = levelSet->getLevel(levelName);
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath levelFp = TFilePath(m_filePath) +
Jeremy Bullock f15907
                      TFilePath(levelName + L".." + m_fileType.toStdWString());
Jeremy Bullock f15907
Jeremy Bullock f15907
  // level with the same path
Jeremy Bullock f15907
  TXshLevel *level_samePath = levelSet->getLevel(*(currentScene), levelFp);
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath actualLevelFp = currentScene->decodeFilePath(levelFp);
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (level_sameName && level_samePath && level_sameName == level_samePath) {
Jeremy Bullock f15907
    TXshSimpleLevelP m_sl;
Jeremy Bullock f15907
    m_sl               = dynamic_cast<txshsimplelevel *="">(level_sameName);</txshsimplelevel>
Jeremy Bullock f15907
    bool isRasterLevel = m_sl && (m_sl->getType() == OVL_XSHLEVEL);
Jeremy Bullock f15907
    if (isRasterLevel) {
Jeremy Bullock f15907
      int currSubsampling = m_sl->getProperties()->getSubsampling();
Jeremy Bullock f15907
      m_subsampling       = currSubsampling;
Jeremy Bullock f15907
      emit(subsamplingChanged(m_subsampling));
Jeremy Bullock f15907
    } else
Jeremy Bullock f15907
      emit(subsamplingChanged(-1));
Jeremy Bullock f15907
  } else
Jeremy Bullock f15907
    emit(subsamplingChanged(-1));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::update() { getSubsampling(); }
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setSubsampling() {
Jeremy Bullock f15907
  ToonzScene *currentScene = TApp::instance()->getCurrentScene()->getScene();
Jeremy Bullock f15907
  TLevelSet *levelSet      = currentScene->getLevelSet();
Jeremy Bullock f15907
Jeremy Bullock f15907
  std::wstring levelName = m_levelName.toStdWString();
Jeremy Bullock f15907
Jeremy Bullock f15907
  // level with the same name
Jeremy Bullock f15907
  TXshLevel *level_sameName = levelSet->getLevel(levelName);
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath levelFp = TFilePath(m_filePath) +
Jeremy Bullock f15907
                      TFilePath(levelName + L".." + m_fileType.toStdWString());
Jeremy Bullock f15907
Jeremy Bullock f15907
  // level with the same path
Jeremy Bullock f15907
  TXshLevel *level_samePath = levelSet->getLevel(*(currentScene), levelFp);
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath actualLevelFp = currentScene->decodeFilePath(levelFp);
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (level_sameName && level_samePath && level_sameName == level_samePath) {
Jeremy Bullock f15907
    TXshSimpleLevelP m_sl;
Jeremy Bullock f15907
    m_sl               = dynamic_cast<txshsimplelevel *="">(level_sameName);</txshsimplelevel>
Jeremy Bullock f15907
    bool isRasterLevel = m_sl && (m_sl->getType() & RASTER_TYPE);
Jeremy Bullock f15907
    if (isRasterLevel) {
Jeremy Bullock f15907
      int currSubsampling = m_sl->getProperties()->getSubsampling();
Jeremy Bullock f15907
      int newSubsampling  = m_subsampling;
Jeremy Bullock f15907
      if (currSubsampling != newSubsampling) {
Jeremy Bullock f15907
        m_sl->getProperties()->setSubsampling(newSubsampling);
Jeremy Bullock f15907
        m_sl->invalidateFrames();
Jeremy Bullock f15907
        TApp::instance()->getCurrentScene()->setDirtyFlag(true);
Jeremy Bullock f15907
        TApp::instance()
Jeremy Bullock f15907
            ->getCurrentXsheet()
Jeremy Bullock f15907
            ->getXsheet()
Jeremy Bullock f15907
            ->getStageObjectTree()
Jeremy Bullock f15907
            ->invalidateAll();
Jeremy Bullock f15907
        TApp::instance()->getCurrentLevel()->notifyLevelChange();
Jeremy Bullock f15907
        emit(subsamplingChanged(m_subsampling));
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::onTimeout() {
Jeremy Bullock f15907
  int currentFrame = TApp::instance()->getCurrentFrame()->getFrame();
Jeremy Bullock f15907
  // int destinationFrame = m_xSheetFrameNumber - 1;
Jeremy Bullock f15907
  if (m_liveViewStatus > 0 && m_liveViewStatus < 3 &&
Jeremy Bullock f15907
      !TApp::instance()->getCurrentFrame()->isPlaying()) {
Jeremy Bullock f15907
    if (getAlwaysLiveView() || (currentFrame == m_xSheetFrameNumber - 1)) {
Jeremy Bullock f15907
      if (!m_usingWebcam)
Jeremy Bullock f15907
        downloadEVFData();
Jeremy Bullock f15907
      else
Jeremy Bullock f15907
        getWebcamImage();
Jeremy Bullock f15907
      if (getAlwaysLiveView() && currentFrame != m_xSheetFrameNumber - 1 ||
Jeremy Bullock f15907
          m_pickLiveViewZoom) {
Jeremy Bullock f15907
        m_showLineUpImage = false;
Jeremy Bullock f15907
      } else {
Jeremy Bullock f15907
        m_showLineUpImage = true;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    } else if (m_liveViewStatus == 2) {
Jeremy Bullock f15907
      m_liveViewStatus = 3;
Jeremy Bullock f15907
      TApp::instance()->getCurrentScene()->notifySceneChanged();
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  } else if (m_liveViewStatus == 3 && !m_userCalledPause) {
Jeremy Bullock f15907
    if (getAlwaysLiveView() || (currentFrame == m_xSheetFrameNumber - 1)) {
Jeremy Bullock f15907
      if (!m_usingWebcam)
Jeremy Bullock f15907
        downloadEVFData();
Jeremy Bullock f15907
      else
Jeremy Bullock f15907
        getWebcamImage();
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::onReviewTimeout() {
Jeremy Bullock f15907
  if (m_liveViewStatus > 0) {
Jeremy Bullock f15907
    m_liveViewStatus = 2;
Jeremy Bullock f15907
    m_timer->start(40);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  TApp::instance()->getCurrentFrame()->setFrame(m_xSheetFrameNumber - 1);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
bool StopMotion::importImage() {
Jeremy Bullock f15907
  if (getBlackCapture()) {
Jeremy Bullock f15907
    m_fullScreen1->hide();
Jeremy Bullock f15907
Jeremy Bullock f15907
    if (m_screenCount > 1) {
Jeremy Bullock f15907
      m_fullScreen2->hide();
Jeremy Bullock f15907
Jeremy Bullock f15907
      if (m_screenCount == 3) {
Jeremy Bullock f15907
        m_fullScreen3->hide();
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (getReviewTime() > 0) {
Jeremy Bullock f15907
    m_reviewTimer->start(getReviewTime() * 1000);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  TApp *app         = TApp::instance();
Jeremy Bullock f15907
  ToonzScene *scene = app->getCurrentScene()->getScene();
Jeremy Bullock f15907
  TXsheet *xsh      = scene->getXsheet();
Jeremy Bullock f15907
Jeremy Bullock f15907
  std::wstring levelName = m_levelName.toStdWString();
Jeremy Bullock f15907
  if (levelName.empty()) {
Jeremy Bullock f15907
    DVGui::error(
Jeremy Bullock f15907
        tr("No level name specified: please choose a valid level name"));
Jeremy Bullock f15907
    return false;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (m_usingWebcam) {
Jeremy Bullock f15907
    m_newImage = m_liveViewImage;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  int frameNumber = m_frameNumber;
Jeremy Bullock f15907
Jeremy Bullock f15907
  /* create parent directory if it does not exist */
Jeremy Bullock f15907
  TFilePath parentDir     = scene->decodeFilePath(TFilePath(m_filePath));
Jeremy Bullock f15907
  TFilePath fullResFolder = scene->decodeFilePath(
Jeremy Bullock f15907
      TFilePath(m_filePath) + TFilePath(levelName + L"_FullRes"));
Jeremy Bullock f15907
  TFilePath liveViewFolder = scene->decodeFilePath(
Jeremy Bullock f15907
      TFilePath(m_filePath) + TFilePath(levelName + L"_LiveView"));
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath levelFp = TFilePath(m_filePath) +
Jeremy Bullock f15907
                      TFilePath(levelName + L".." + m_fileType.toStdWString());
Jeremy Bullock f15907
  TFilePath actualLevelFp = scene->decodeFilePath(levelFp);
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath fullResFp =
Jeremy Bullock f15907
      scene->decodeFilePath(fullResFolder + TFilePath(levelName + L"..jpg"));
Jeremy Bullock f15907
  TFilePath fullResFile(fullResFp.withFrame(frameNumber));
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath liveViewFp =
Jeremy Bullock f15907
      scene->decodeFilePath(liveViewFolder + TFilePath(levelName + L"..jpg"));
Jeremy Bullock f15907
  TFilePath liveViewFile(liveViewFp.withFrame(frameNumber));
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath tempFile = parentDir + "temp.jpg";
Jeremy Bullock f15907
Jeremy Bullock f15907
  TXshSimpleLevel *sl = 0;
Jeremy Bullock f15907
  TXshLevel *level    = scene->getLevelSet()->getLevel(levelName);
Jeremy Bullock f15907
  enum State { NEWLEVEL = 0, ADDFRAME, OVERWRITE } state;
Jeremy Bullock f15907
Jeremy Bullock f15907
  /* if the level already exists in the scene cast */
Jeremy Bullock f15907
  if (level) {
Jeremy Bullock f15907
    /* if the existing level is not a raster level, then return */
Jeremy Bullock f15907
    if (level->getType() != OVL_XSHLEVEL) {
Jeremy Bullock f15907
      DVGui::error(
Jeremy Bullock f15907
          tr("The level name specified is already used: please choose a "
Jeremy Bullock f15907
             "different level name."));
Jeremy Bullock f15907
      return false;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    /* if the existing level does not match file path and pixel size, then
Jeremy Bullock f15907
     * return */
Jeremy Bullock f15907
    sl = level->getSimpleLevel();
Jeremy Bullock f15907
    if (scene->decodeFilePath(sl->getPath()) != actualLevelFp) {
Jeremy Bullock f15907
      DVGui::error(
Jeremy Bullock f15907
          tr("The save in path specified does not match with the existing "
Jeremy Bullock f15907
             "level."));
Jeremy Bullock f15907
      return false;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    if (sl->getProperties()->getImageRes() !=
Jeremy Bullock f15907
        TDimension(m_newImage->getLx(), m_newImage->getLy())) {
Jeremy Bullock f15907
      DVGui::error(tr(
Jeremy Bullock f15907
          "The captured image size does not match with the existing level."));
Jeremy Bullock f15907
      return false;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    /* if the level already have the same frame, then ask if overwrite it */
Jeremy Bullock f15907
    TFilePath frameFp(actualLevelFp.withFrame(frameNumber));
Jeremy Bullock f15907
    if (TFileStatus(frameFp).doesExist()) {
Jeremy Bullock f15907
      QString question =
Jeremy Bullock f15907
          tr("File %1 already exists.\nDo you want to overwrite it?")
Jeremy Bullock f15907
              .arg(toQString(frameFp));
Jeremy Bullock f15907
      int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"),
Jeremy Bullock f15907
                              QObject::tr("Cancel"));
Jeremy Bullock f15907
      if (ret == 0 || ret == 2) return false;
Jeremy Bullock f15907
      state = OVERWRITE;
Jeremy Bullock f15907
    } else
Jeremy Bullock f15907
      state = ADDFRAME;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  /* if the level does not exist in the scene cast */
Jeremy Bullock f15907
  else {
Jeremy Bullock f15907
    /* if the file does exist, load it first */
Jeremy Bullock f15907
    if (TSystem::doesExistFileOrLevel(actualLevelFp)) {
Jeremy Bullock f15907
      level = scene->loadLevel(actualLevelFp);
Jeremy Bullock f15907
      if (!level) {
Jeremy Bullock f15907
        DVGui::error(tr("Failed to load %1.").arg(toQString(actualLevelFp)));
Jeremy Bullock f15907
        return false;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
Jeremy Bullock f15907
      /* if the loaded level does not match in pixel size, then return */
Jeremy Bullock f15907
      sl = level->getSimpleLevel();
shun-iwasawa 2c27a4
      if (!sl || sl->getProperties()->getImageRes() !=
shun-iwasawa 2c27a4
                     TDimension(m_newImage->getLx(), m_newImage->getLy())) {
Jeremy Bullock f15907
        DVGui::error(
Jeremy Bullock f15907
            tr("The captured image size does not match with the existing "
Jeremy Bullock f15907
               "level."));
Jeremy Bullock f15907
        return false;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
Jeremy Bullock f15907
      /* confirm overwrite */
Jeremy Bullock f15907
      TFilePath frameFp(actualLevelFp.withFrame(frameNumber));
Jeremy Bullock f15907
      if (TFileStatus(frameFp).doesExist()) {
Jeremy Bullock f15907
        QString question =
Jeremy Bullock f15907
            tr("File %1 already exists.\nDo you want to overwrite it?")
Jeremy Bullock f15907
                .arg(toQString(frameFp));
Jeremy Bullock f15907
        int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"),
Jeremy Bullock f15907
                                QObject::tr("Cancel"));
Jeremy Bullock f15907
        if (ret == 0 || ret == 2) return false;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    /* if the file does not exist, then create a new level */
Jeremy Bullock f15907
    else {
Jeremy Bullock f15907
      TXshLevel *level = scene->createNewLevel(OVL_XSHLEVEL, levelName,
Jeremy Bullock f15907
                                               TDimension(), 0, levelFp);
shun-iwasawa 2c27a4
      sl               = level->getSimpleLevel();
Jeremy Bullock f15907
      sl->setPath(levelFp, true);
Jeremy Bullock f15907
      sl->getProperties()->setDpiPolicy(LevelProperties::DP_CustomDpi);
Jeremy Bullock f15907
      TPointD dpi;
Jeremy Bullock f15907
      // Right now always set the dpi to scale to the camera width
Jeremy Bullock f15907
      if (Preferences::instance()->getPixelsOnly() && false)
Jeremy Bullock f15907
        dpi = getCurrentCameraDpi();
Jeremy Bullock f15907
      // Compute the dpi so that the image will fit
Jeremy Bullock f15907
      // to the camera frame
Jeremy Bullock f15907
      else {
Jeremy Bullock f15907
        TCamera *camera =
Jeremy Bullock f15907
            TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
Jeremy Bullock f15907
        TDimensionD size  = camera->getSize();
Jeremy Bullock f15907
        double minimumDpi = std::min(m_newImage->getLx() / size.lx,
Jeremy Bullock f15907
                                     m_newImage->getLy() / size.ly);
shun-iwasawa 2c27a4
        dpi               = TPointD(minimumDpi, minimumDpi);
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      sl->getProperties()->setDpi(dpi.x);
Jeremy Bullock f15907
      sl->getProperties()->setImageDpi(dpi);
Jeremy Bullock f15907
      sl->getProperties()->setImageRes(
Jeremy Bullock f15907
          TDimension(m_newImage->getLx(), m_newImage->getLy()));
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
Jeremy Bullock f15907
    state = NEWLEVEL;
Jeremy Bullock f15907
    getSubsampling();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (!TFileStatus(parentDir).doesExist()) {
Jeremy Bullock f15907
    QString question;
Jeremy Bullock f15907
    question = tr("Folder %1 doesn't exist.\nDo you want to create it?")
Jeremy Bullock f15907
                   .arg(toQString(parentDir));
Jeremy Bullock f15907
    int ret = DVGui::MsgBox(question, QObject::tr("Yes"), QObject::tr("No"));
Jeremy Bullock f15907
    if (ret == 0 || ret == 2) return false;
Jeremy Bullock f15907
    try {
Jeremy Bullock f15907
      TSystem::mkDir(parentDir);
Jeremy Bullock f15907
      DvDirModel::instance()->refreshFolder(parentDir.getParentDir());
Jeremy Bullock f15907
    } catch (...) {
Jeremy Bullock f15907
      DVGui::error(tr("Unable to create") + toQString(parentDir));
Jeremy Bullock f15907
      return false;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (!m_usingWebcam) {
Jeremy Bullock f15907
    if (!TFileStatus(fullResFolder).doesExist()) {
Jeremy Bullock f15907
      try {
Jeremy Bullock f15907
        TSystem::mkDir(fullResFolder);
Jeremy Bullock f15907
        DvDirModel::instance()->refreshFolder(fullResFolder.getParentDir());
Jeremy Bullock f15907
      } catch (...) {
Jeremy Bullock f15907
        DVGui::error(tr("Unable to create") + toQString(fullResFolder));
Jeremy Bullock f15907
        return false;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    if (!TFileStatus(liveViewFolder).doesExist()) {
Jeremy Bullock f15907
      try {
Jeremy Bullock f15907
        TSystem::mkDir(liveViewFolder);
Jeremy Bullock f15907
        DvDirModel::instance()->refreshFolder(liveViewFolder.getParentDir());
Jeremy Bullock f15907
      } catch (...) {
Jeremy Bullock f15907
        DVGui::error(tr("Unable to create") + toQString(liveViewFolder));
Jeremy Bullock f15907
        return false;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  // move the temp file
Jeremy Bullock f15907
  if (!m_usingWebcam) {
Jeremy Bullock f15907
    if (m_useScaledImages) {
Jeremy Bullock f15907
      TSystem::copyFile(fullResFile, tempFile);
Jeremy Bullock f15907
      TSystem::deleteFile(tempFile);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    if (m_hasLineUpImage) {
Jeremy Bullock f15907
      saveJpg(m_lineUpImage, liveViewFile);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFrameId fid(frameNumber);
Jeremy Bullock f15907
  TPointD levelDpi = sl->getDpi();
Jeremy Bullock f15907
  /* create the raster */
Jeremy Bullock f15907
  TRaster32P raster = m_newImage;
Jeremy Bullock f15907
Jeremy Bullock f15907
  TRasterImageP ri(raster);
Jeremy Bullock f15907
  ri->setDpi(levelDpi.x, levelDpi.y);
Jeremy Bullock f15907
Jeremy Bullock f15907
  /* setting the frame */
Jeremy Bullock f15907
  sl->setFrame(fid, ri);
Jeremy Bullock f15907
Jeremy Bullock f15907
  /* set dirty flag */
Jeremy Bullock f15907
  sl->getProperties()->setDirtyFlag(true);
Jeremy Bullock f15907
  sl->getProperties()->setIsStopMotion(true);
Jeremy Bullock f15907
  sl->setIsReadOnly(true);
Jeremy Bullock f15907
Jeremy Bullock f15907
  // if (m_saveOnCaptureCB->isChecked()) sl->save();
Jeremy Bullock f15907
  // for now always save.  This can be tweaked later
Jeremy Bullock f15907
  sl->save();
Jeremy Bullock f15907
Jeremy Bullock f15907
  /* placement in xsheet */
Jeremy Bullock f15907
  if (!getPlaceOnXSheet()) {
Jeremy Bullock f15907
    postImportProcess();
Jeremy Bullock f15907
    return true;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  int row = m_xSheetFrameNumber - 1;
Jeremy Bullock f15907
  int col = app->getCurrentColumn()->getColumnIndex();
Jeremy Bullock f15907
Jeremy Bullock f15907
  // if the level is newly created or imported, then insert a new column
Jeremy Bullock f15907
  if (state == NEWLEVEL) {
Jeremy Bullock f15907
    if (!xsh->isColumnEmpty(col)) {
Jeremy Bullock f15907
      col += 1;
Jeremy Bullock f15907
      xsh->insertColumn(col);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    xsh->insertCells(row, col);
Jeremy Bullock f15907
    xsh->setCell(row, col, TXshCell(sl, fid));
Jeremy Bullock f15907
    app->getCurrentColumn()->setColumnIndex(col);
Jeremy Bullock f15907
    if (getReviewTime() == 0) app->getCurrentFrame()->setFrame(row + 1);
Jeremy Bullock f15907
    m_xSheetFrameNumber = row + 2;
Jeremy Bullock f15907
    emit(xSheetFrameNumberChanged(m_xSheetFrameNumber));
Jeremy Bullock f15907
    postImportProcess();
Jeremy Bullock f15907
    // if (m_newImage->getLx() > 2000) {
Jeremy Bullock f15907
    //  m_subsampling = 4;
Jeremy Bullock f15907
    //  setSubsampling();
Jeremy Bullock f15907
    //}
Jeremy Bullock f15907
    return true;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  // state == OVERWRITE, ADDFRAME
Jeremy Bullock f15907
Jeremy Bullock f15907
  // if the same cell is already in the column, then just replace the content
Jeremy Bullock f15907
  // and do not set a new cell
Jeremy Bullock f15907
  int foundCol, foundRow = -1;
Jeremy Bullock f15907
  // most possibly, it's in the current column
Jeremy Bullock f15907
  int rowCheck;
Jeremy Bullock f15907
  if (findCell(xsh, col, TXshCell(sl, fid), rowCheck)) {
Jeremy Bullock f15907
    postImportProcess();
Jeremy Bullock f15907
    return true;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (rowCheck >= 0) {
Jeremy Bullock f15907
    foundRow = rowCheck;
Jeremy Bullock f15907
    foundCol = col;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  // search entire xsheet
Jeremy Bullock f15907
  for (int c = 0; c < xsh->getColumnCount(); c++) {
Jeremy Bullock f15907
    if (c == col) continue;
Jeremy Bullock f15907
    if (findCell(xsh, c, TXshCell(sl, fid), rowCheck)) {
Jeremy Bullock f15907
      postImportProcess();
Jeremy Bullock f15907
      return true;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    if (rowCheck >= 0) {
Jeremy Bullock f15907
      foundRow = rowCheck;
Jeremy Bullock f15907
      foundCol = c;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  // note found row represents the last row found that uses
Jeremy Bullock f15907
  // the active level
Jeremy Bullock f15907
Jeremy Bullock f15907
  // if there is a column containing the same level
Jeremy Bullock f15907
  if (foundRow >= 0) {
Jeremy Bullock f15907
    // put the cell at the bottom
Jeremy Bullock f15907
    xsh->insertCells(row, foundCol);
Jeremy Bullock f15907
    xsh->setCell(row, foundCol, TXshCell(sl, fid));
Jeremy Bullock f15907
    app->getCurrentColumn()->setColumnIndex(foundCol);
Jeremy Bullock f15907
    if (getReviewTime() == 0) app->getCurrentFrame()->setFrame(row + 1);
Jeremy Bullock f15907
    m_xSheetFrameNumber = row + 2;
Jeremy Bullock f15907
    emit(xSheetFrameNumberChanged(m_xSheetFrameNumber));
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  // if the level is registered in the scene, but is not placed in the xsheet,
Jeremy Bullock f15907
  // then insert a new column
Jeremy Bullock f15907
  else {
Jeremy Bullock f15907
    if (!xsh->isColumnEmpty(col)) {
Jeremy Bullock f15907
      col += 1;
Jeremy Bullock f15907
      xsh->insertColumn(col);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    xsh->setCell(row, col, TXshCell(sl, fid));
Jeremy Bullock f15907
    app->getCurrentColumn()->setColumnIndex(col);
Jeremy Bullock f15907
    if (getReviewTime() == 0) app->getCurrentFrame()->setFrame(row + 1);
Jeremy Bullock f15907
    m_xSheetFrameNumber = row + 2;
Jeremy Bullock f15907
    emit(xSheetFrameNumberChanged(m_xSheetFrameNumber));
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  postImportProcess();
Jeremy Bullock f15907
  return true;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::captureImage() {
Jeremy Bullock f15907
  if (!m_usingWebcam && !m_sessionOpen) {
shun-iwasawa 2c27a4
    DVGui::warning(tr("Please start live view before capturing an image."));
Jeremy Bullock f15907
    return;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (m_usingWebcam) {
Jeremy Bullock f15907
    if (!m_hasLiveViewImage) {
shun-iwasawa 2c27a4
      DVGui::warning(
shun-iwasawa 2c27a4
          tr("Cannot capture webcam image unless live view is active."));
Jeremy Bullock f15907
      return;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    if (getReviewTime() > 0) {
Jeremy Bullock f15907
      m_timer->stop();
Jeremy Bullock f15907
      if (m_liveViewStatus > 0) {
Jeremy Bullock f15907
        m_liveViewStatus = 3;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    m_lineUpImage    = m_liveViewImage;
Jeremy Bullock f15907
    m_hasLineUpImage = true;
Jeremy Bullock f15907
    emit(newLiveViewImageReady());
Jeremy Bullock f15907
    importImage();
Jeremy Bullock f15907
    return;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (getBlackCapture()) {
Jeremy Bullock f15907
    m_fullScreen1->showFullScreen();
Jeremy Bullock f15907
    m_fullScreen1->setGeometry(QApplication::desktop()->screenGeometry(0));
Jeremy Bullock f15907
    if (m_screenCount > 1) {
Jeremy Bullock f15907
      m_fullScreen2->showFullScreen();
Jeremy Bullock f15907
      m_fullScreen2->setGeometry(QApplication::desktop()->screenGeometry(1));
Jeremy Bullock f15907
Jeremy Bullock f15907
      if (m_screenCount == 3) {
Jeremy Bullock f15907
        m_fullScreen3->showFullScreen();
Jeremy Bullock f15907
        m_fullScreen3->setGeometry(QApplication::desktop()->screenGeometry(2));
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    // this allows the full screen qdialogs to go full screen before
Jeremy Bullock f15907
    // taking a photo
Jeremy Bullock f15907
    qApp->processEvents(QEventLoop::AllEvents, 1500);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (getReviewTime() > 0) {
Jeremy Bullock f15907
    m_timer->stop();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (m_liveViewStatus > 0) {
Jeremy Bullock f15907
    m_liveViewStatus = 3;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (m_hasLiveViewImage) {
Jeremy Bullock f15907
    m_lineUpImage    = m_liveViewImage;
Jeremy Bullock f15907
    m_hasLineUpImage = true;
Jeremy Bullock f15907
    emit(newLiveViewImageReady());
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  TApp *app         = TApp::instance();
Jeremy Bullock f15907
  ToonzScene *scene = app->getCurrentScene()->getScene();
Jeremy Bullock f15907
Jeremy Bullock f15907
  int frameNumber        = m_frameNumber;
Jeremy Bullock f15907
  std::wstring levelName = m_levelName.toStdWString();
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath parentDir = scene->decodeFilePath(TFilePath(m_filePath));
Jeremy Bullock f15907
  TFilePath tempFile  = parentDir + "temp.jpg";
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (!TFileStatus(parentDir).doesExist()) {
Jeremy Bullock f15907
    TSystem::mkDir(parentDir);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  m_tempFile = tempFile.getQString();
Jeremy Bullock f15907
  takePicture();
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::saveJpg(TRaster32P image, TFilePath path) {
Jeremy Bullock f15907
  unsigned char *jpegBuf = NULL; /* Dynamically allocate the JPEG buffer */
Jeremy Bullock f15907
  unsigned long jpegSize = 0;
Jeremy Bullock f15907
  int pixelFormat        = TJPF_BGRX;
Jeremy Bullock f15907
  int outQual            = 95;
Jeremy Bullock f15907
  int subSamp            = TJSAMP_411;
Jeremy Bullock f15907
  bool success           = false;
Jeremy Bullock f15907
  tjhandle tjInstance;
Jeremy Bullock f15907
Jeremy Bullock f15907
  int width  = image->getLx();
Jeremy Bullock f15907
  int height = image->getLy();
Jeremy Bullock f15907
  int flags  = 0;
Jeremy Bullock f15907
#ifdef WIN32
Jeremy Bullock f15907
  flags |= TJFLAG_BOTTOMUP;
Jeremy Bullock f15907
#endif
Jeremy Bullock f15907
Jeremy Bullock f15907
  image->lock();
Jeremy Bullock f15907
  uchar *rawData = image->getRawData();
Jeremy Bullock f15907
  if ((tjInstance = tjInitCompress()) != NULL) {
Jeremy Bullock f15907
    if (tjCompress2(tjInstance, rawData, width, 0, height, pixelFormat,
Jeremy Bullock f15907
                    &jpegBuf, &jpegSize, subSamp, outQual, flags) >= 0) {
Jeremy Bullock f15907
      success = true;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  image->unlock();
Jeremy Bullock f15907
  tjDestroy(tjInstance);
Jeremy Bullock f15907
  tjInstance = NULL;
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (success) {
Jeremy Bullock f15907
    /* Write the JPEG image to disk. */
Jeremy Bullock f15907
    QFile fullImage(path.getQString());
Jeremy Bullock f15907
    fullImage.open(QIODevice::WriteOnly);
Jeremy Bullock f15907
    QDataStream dataStream(&fullImage);
Jeremy Bullock f15907
    dataStream.writeRawData((const char *)jpegBuf, jpegSize);
Jeremy Bullock f15907
    fullImage.close();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  tjFree(jpegBuf);
Jeremy Bullock f15907
  jpegBuf = NULL;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
bool StopMotion::loadJpg(TFilePath path, TRaster32P &image) {
Jeremy Bullock f15907
  long size;
Jeremy Bullock f15907
  int inSubsamp, inColorspace, width, height;
Jeremy Bullock f15907
  unsigned long jpegSize;
Jeremy Bullock f15907
  unsigned char *jpegBuf;
Jeremy Bullock f15907
  FILE *jpegFile;
Jeremy Bullock f15907
  QString qPath      = path.getQString();
Jeremy Bullock f15907
  QByteArray ba      = qPath.toLocal8Bit();
Jeremy Bullock f15907
  const char *c_path = ba.data();
Jeremy Bullock f15907
  bool success       = true;
Jeremy Bullock f15907
  tjhandle tjInstance;
Jeremy Bullock f15907
Jeremy Bullock f15907
  /* Read the JPEG file into memory. */
Jeremy Bullock f15907
  if ((jpegFile = fopen(c_path, "rb")) == NULL) success = false;
Jeremy Bullock f15907
  if (success && fseek(jpegFile, 0, SEEK_END) < 0 ||
Jeremy Bullock f15907
      ((size = ftell(jpegFile)) < 0) || fseek(jpegFile, 0, SEEK_SET) < 0)
shun-iwasawa 2c27a4
    success = false;
Jeremy Bullock f15907
  if (success && size == 0) success = false;
shun-iwasawa 2c27a4
  jpegSize = (unsigned long)size;
Jeremy Bullock f15907
  if (success && (jpegBuf = (unsigned char *)tjAlloc(jpegSize)) == NULL)
Jeremy Bullock f15907
    success = false;
Jeremy Bullock f15907
  if (success && fread(jpegBuf, jpegSize, 1, jpegFile) < 1) success = false;
Jeremy Bullock f15907
  fclose(jpegFile);
Jeremy Bullock f15907
  jpegFile = NULL;
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (success && (tjInstance = tjInitDecompress()) == NULL) success = false;
Jeremy Bullock f15907
shun-iwasawa 2c27a4
  if (success && tjDecompressHeader3(tjInstance, jpegBuf, jpegSize, &width,
shun-iwasawa 2c27a4
                                     &height, &inSubsamp, &inColorspace) < 0)
Jeremy Bullock f15907
    success = false;
Jeremy Bullock f15907
Jeremy Bullock f15907
  int pixelFormat       = TJPF_BGRX;
Jeremy Bullock f15907
  unsigned char *imgBuf = NULL;
Jeremy Bullock f15907
  if (success &&
Jeremy Bullock f15907
      (imgBuf = tjAlloc(width * height * tjPixelSize[pixelFormat])) == NULL)
Jeremy Bullock f15907
    success = false;
Jeremy Bullock f15907
Jeremy Bullock f15907
  int flags = 0;
Jeremy Bullock f15907
#ifdef WIN32
Jeremy Bullock f15907
  flags |= TJFLAG_BOTTOMUP;
Jeremy Bullock f15907
#endif
shun-iwasawa 2c27a4
  if (success && tjDecompress2(tjInstance, jpegBuf, jpegSize, imgBuf, width, 0,
shun-iwasawa 2c27a4
                               height, pixelFormat, flags) < 0)
Jeremy Bullock f15907
    success = false;
Jeremy Bullock f15907
  tjFree(jpegBuf);
Jeremy Bullock f15907
  jpegBuf = NULL;
Jeremy Bullock f15907
  tjDestroy(tjInstance);
Jeremy Bullock f15907
  tjInstance = NULL;
Jeremy Bullock f15907
Jeremy Bullock f15907
  image = TRaster32P(width, height);
Jeremy Bullock f15907
  image->lock();
Jeremy Bullock f15907
  uchar *rawData = image->getRawData();
Jeremy Bullock f15907
  memcpy(rawData, imgBuf, width * height * tjPixelSize[pixelFormat]);
Jeremy Bullock f15907
  image->unlock();
Jeremy Bullock f15907
Jeremy Bullock f15907
  tjFree(imgBuf);
Jeremy Bullock f15907
  imgBuf = NULL;
Jeremy Bullock f15907
Jeremy Bullock f15907
  return success;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::postImportProcess() {
Jeremy Bullock f15907
  if (Preferences::instance()->isShowFrameNumberWithLettersEnabled()) {
Jeremy Bullock f15907
    int f = m_frameNumber;
Jeremy Bullock f15907
    if (f % 10 == 0)  // next number
Jeremy Bullock f15907
      m_frameNumber = ((int)(f / 10) + 1) * 10;
Jeremy Bullock f15907
    else  // next alphabet
Jeremy Bullock f15907
      m_frameNumber = f + 1;
Jeremy Bullock f15907
  } else
Jeremy Bullock f15907
    m_frameNumber += 1;
Jeremy Bullock f15907
  emit(frameNumberChanged(m_frameNumber));
Jeremy Bullock f15907
  /* notify */
Jeremy Bullock f15907
  refreshFrameInfo();
Jeremy Bullock f15907
  TApp::instance()->getCurrentScene()->notifySceneChanged();
Jeremy Bullock f15907
  TApp::instance()->getCurrentScene()->notifyCastChange();
Jeremy Bullock f15907
  TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
// Refresh information that how many & which frames are saved for the current
Jeremy Bullock f15907
// level
Jeremy Bullock f15907
void StopMotion::refreshFrameInfo() {
Jeremy Bullock f15907
  if ((!m_sessionOpen && m_liveViewStatus < 2) && !m_usingWebcam) {
Jeremy Bullock f15907
    m_frameInfoText = "";
Jeremy Bullock f15907
    return;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  QString tooltipStr, labelStr;
Jeremy Bullock f15907
  enum InfoType { NEW = 0, ADD, OVERWRITE, WARNING } infoType(WARNING);
Jeremy Bullock f15907
Jeremy Bullock f15907
  static QColor infoColors[4] = {Qt::cyan, Qt::green, Qt::yellow, Qt::red};
Jeremy Bullock f15907
Jeremy Bullock f15907
  ToonzScene *currentScene = TApp::instance()->getCurrentScene()->getScene();
Jeremy Bullock f15907
  TLevelSet *levelSet      = currentScene->getLevelSet();
Jeremy Bullock f15907
Jeremy Bullock f15907
  std::wstring levelName = m_levelName.toStdWString();
Jeremy Bullock f15907
  int frameNumber        = m_frameNumber;
Jeremy Bullock f15907
Jeremy Bullock f15907
  TDimension stopMotionRes;
Jeremy Bullock f15907
  bool checkRes = true;
Jeremy Bullock f15907
  if (m_usingWebcam)
Jeremy Bullock f15907
    stopMotionRes = m_liveViewImageDimensions;
Jeremy Bullock f15907
Jeremy Bullock f15907
  else if (m_useScaledImages || !getCurrentImageQuality().contains("Large")) {
Jeremy Bullock f15907
    stopMotionRes = m_proxyImageDimensions;
Jeremy Bullock f15907
    if (m_proxyImageDimensions == TDimension(0, 0)) {
Jeremy Bullock f15907
      checkRes = false;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  } else
Jeremy Bullock f15907
    stopMotionRes = m_fullImageDimensions;
Jeremy Bullock f15907
Jeremy Bullock f15907
  bool letterOptionEnabled =
Jeremy Bullock f15907
      Preferences::instance()->isShowFrameNumberWithLettersEnabled();
Jeremy Bullock f15907
Jeremy Bullock f15907
  // level with the same name
Jeremy Bullock f15907
  TXshLevel *level_sameName = levelSet->getLevel(levelName);
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath levelFp = TFilePath(m_filePath) +
Jeremy Bullock f15907
                      TFilePath(levelName + L".." + m_fileType.toStdWString());
Jeremy Bullock f15907
Jeremy Bullock f15907
  // level with the same path
Jeremy Bullock f15907
  TXshLevel *level_samePath = levelSet->getLevel(*(currentScene), levelFp);
Jeremy Bullock f15907
Jeremy Bullock f15907
  TFilePath actualLevelFp = currentScene->decodeFilePath(levelFp);
Jeremy Bullock f15907
Jeremy Bullock f15907
  // level existence
Jeremy Bullock f15907
  bool levelExist = TSystem::doesExistFileOrLevel(actualLevelFp);
Jeremy Bullock f15907
Jeremy Bullock f15907
  // frame existence
Jeremy Bullock f15907
  TFilePath frameFp(actualLevelFp.withFrame(frameNumber));
shun-iwasawa 2c27a4
  bool frameExist = false;
Jeremy Bullock f15907
  if (levelExist) frameExist = TFileStatus(frameFp).doesExist();
Jeremy Bullock f15907
Jeremy Bullock f15907
  // reset acceptable camera size
Jeremy Bullock f15907
  m_allowedCameraSize = QSize();
Jeremy Bullock f15907
Jeremy Bullock f15907
  // ### CASE 1 ###
Jeremy Bullock f15907
  // If there is no same level registered in the scene cast
Jeremy Bullock f15907
  if (!level_sameName && !level_samePath) {
Jeremy Bullock f15907
    // If there is a level in the file system
Jeremy Bullock f15907
    if (levelExist) {
Jeremy Bullock f15907
      TLevelReaderP lr;
Jeremy Bullock f15907
      TLevelP level_p;
Jeremy Bullock f15907
      try {
Jeremy Bullock f15907
        lr = TLevelReaderP(actualLevelFp);
Jeremy Bullock f15907
      } catch (...) {
Jeremy Bullock f15907
        // TODO: output something
Jeremy Bullock f15907
        m_frameInfoText = tr("UNDEFINED WARNING");
Jeremy Bullock f15907
        return;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      if (!lr) {
Jeremy Bullock f15907
        // TODO: output something
Jeremy Bullock f15907
        m_frameInfoText = tr("UNDEFINED WARNING");
Jeremy Bullock f15907
        return;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      try {
Jeremy Bullock f15907
        level_p = lr->loadInfo();
Jeremy Bullock f15907
      } catch (...) {
Jeremy Bullock f15907
        // TODO: output something
Jeremy Bullock f15907
        m_frameInfoText = tr("UNDEFINED WARNING");
Jeremy Bullock f15907
        return;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      if (!level_p) {
Jeremy Bullock f15907
        // TODO: output something
Jeremy Bullock f15907
        m_frameInfoText = tr("UNDEFINED WARNING");
Jeremy Bullock f15907
        return;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      int frameCount      = level_p->getFrameCount();
Jeremy Bullock f15907
      TLevel::Iterator it = level_p->begin();
Jeremy Bullock f15907
      std::vector<tframeid> fids;</tframeid>
Jeremy Bullock f15907
      for (int i = 0; it != level_p->end(); ++it, ++i)
Jeremy Bullock f15907
        fids.push_back(it->first);
Jeremy Bullock f15907
Jeremy Bullock f15907
      tooltipStr +=
Jeremy Bullock f15907
          tr("The level is not registered in the scene, but exists in the file "
Jeremy Bullock f15907
             "system.");
Jeremy Bullock f15907
Jeremy Bullock f15907
      // check resolution
Jeremy Bullock f15907
      const TImageInfo *ii;
Jeremy Bullock f15907
      try {
Jeremy Bullock f15907
        ii = lr->getImageInfo(fids[0]);
Jeremy Bullock f15907
      } catch (...) {
Jeremy Bullock f15907
        // TODO: output something
Jeremy Bullock f15907
        m_frameInfoText = tr("UNDEFINED WARNING");
Jeremy Bullock f15907
        return;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      TDimension dim(ii->m_lx, ii->m_ly);
Jeremy Bullock f15907
      // if the saved images has not the same resolution as the current camera
Jeremy Bullock f15907
      // resolution
Jeremy Bullock f15907
      if (checkRes && m_hasLiveViewImage && stopMotionRes != dim) {
Jeremy Bullock f15907
        tooltipStr += tr("\nWARNING : Image size mismatch. The saved image "
Jeremy Bullock f15907
                         "size is %1 x %2.")
Jeremy Bullock f15907
                          .arg(dim.lx)
Jeremy Bullock f15907
                          .arg(dim.ly);
Jeremy Bullock f15907
        labelStr += tr("WARNING ");
Jeremy Bullock f15907
        infoType = WARNING;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      // if the resolutions are matched
Jeremy Bullock f15907
      {
Jeremy Bullock f15907
        if (frameCount == 1)
Jeremy Bullock f15907
          tooltipStr += tr("\nFrame %1 exists.")
Jeremy Bullock f15907
                            .arg(fidsToString(fids, letterOptionEnabled));
Jeremy Bullock f15907
        else
Jeremy Bullock f15907
          tooltipStr += tr("\nFrames %1 exist.")
Jeremy Bullock f15907
                            .arg(fidsToString(fids, letterOptionEnabled));
Jeremy Bullock f15907
        // if the frame exists, then it will be overwritten
Jeremy Bullock f15907
        if (frameExist) {
Jeremy Bullock f15907
          labelStr += tr("OVERWRITE 1 of");
Jeremy Bullock f15907
          infoType = OVERWRITE;
Jeremy Bullock f15907
        } else {
Jeremy Bullock f15907
          labelStr += tr("ADD to");
Jeremy Bullock f15907
          infoType = ADD;
Jeremy Bullock f15907
        }
Jeremy Bullock f15907
        if (frameCount == 1)
Jeremy Bullock f15907
          labelStr += tr(" %1 frame").arg(frameCount);
Jeremy Bullock f15907
        else
Jeremy Bullock f15907
          labelStr += tr(" %1 frames").arg(frameCount);
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      m_allowedCameraSize = QSize(dim.lx, dim.ly);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    // If no level exists in the file system, then it will be a new level
Jeremy Bullock f15907
    else {
Jeremy Bullock f15907
      tooltipStr += tr("The level will be newly created.");
Jeremy Bullock f15907
      labelStr += tr("NEW");
Jeremy Bullock f15907
      infoType = NEW;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  // ### CASE 2 ###
Jeremy Bullock f15907
  // If there is already the level registered in the scene cast
Jeremy Bullock f15907
  else if (level_sameName && level_samePath &&
Jeremy Bullock f15907
           level_sameName == level_samePath) {
Jeremy Bullock f15907
    tooltipStr += tr("The level is already registered in the scene.");
Jeremy Bullock f15907
    if (!levelExist) tooltipStr += tr("\nNOTE : The level is not saved.");
Jeremy Bullock f15907
Jeremy Bullock f15907
    std::vector<tframeid> fids;</tframeid>
Jeremy Bullock f15907
    level_sameName->getFids(fids);
Jeremy Bullock f15907
Jeremy Bullock f15907
    // check resolution
Jeremy Bullock f15907
    TDimension dim;
Jeremy Bullock f15907
    bool ret = getRasterLevelSize(level_sameName, dim);
Jeremy Bullock f15907
    if (!ret) {
Jeremy Bullock f15907
      tooltipStr +=
Jeremy Bullock f15907
          tr("\nWARNING : Failed to get image size of the existing level %1.")
Jeremy Bullock f15907
              .arg(QString::fromStdWString(levelName));
Jeremy Bullock f15907
      labelStr += tr("WARNING ");
Jeremy Bullock f15907
      infoType = WARNING;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    // if the saved images has not the same resolution as the current camera
Jeremy Bullock f15907
    // resolution
Jeremy Bullock f15907
    else if (checkRes && m_hasLiveViewImage && stopMotionRes != dim) {
Jeremy Bullock f15907
      tooltipStr += tr("\nWARNING : Image size mismatch. The existing level "
Jeremy Bullock f15907
                       "size is %1 x %2.")
Jeremy Bullock f15907
                        .arg(dim.lx)
Jeremy Bullock f15907
                        .arg(dim.ly);
Jeremy Bullock f15907
      labelStr += tr("WARNING ");
Jeremy Bullock f15907
      infoType = WARNING;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    // if the resolutions are matched
Jeremy Bullock f15907
    {
Jeremy Bullock f15907
      int frameCount = fids.size();
Jeremy Bullock f15907
      if (fids.size() == 1)
Jeremy Bullock f15907
        tooltipStr += tr("\nFrame %1 exists.")
Jeremy Bullock f15907
                          .arg(fidsToString(fids, letterOptionEnabled));
Jeremy Bullock f15907
      else
Jeremy Bullock f15907
        tooltipStr += tr("\nFrames %1 exist.")
Jeremy Bullock f15907
                          .arg(fidsToString(fids, letterOptionEnabled));
Jeremy Bullock f15907
      // Check if the target frame already exist in the level
Jeremy Bullock f15907
      bool hasFrame = false;
Jeremy Bullock f15907
      for (int f = 0; f < frameCount; f++) {
Jeremy Bullock f15907
        if (fids.at(f).getNumber() == frameNumber) {
Jeremy Bullock f15907
          hasFrame = true;
Jeremy Bullock f15907
          break;
Jeremy Bullock f15907
        }
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      // If there is already the frame then it will be overwritten
Jeremy Bullock f15907
      if (hasFrame) {
Jeremy Bullock f15907
        labelStr += tr("OVERWRITE 1 of");
Jeremy Bullock f15907
        infoType = OVERWRITE;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      // Or, the frame will be added to the level
Jeremy Bullock f15907
      else {
Jeremy Bullock f15907
        labelStr += tr("ADD to");
Jeremy Bullock f15907
        infoType = ADD;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      if (frameCount == 1)
Jeremy Bullock f15907
        labelStr += tr(" %1 frame").arg(frameCount);
Jeremy Bullock f15907
      else
Jeremy Bullock f15907
        labelStr += tr(" %1 frames").arg(frameCount);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    m_allowedCameraSize = QSize(dim.lx, dim.ly);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  // ### CASE 3 ###
Jeremy Bullock f15907
  // If there are some conflicts with the existing level.
Jeremy Bullock f15907
  else {
Jeremy Bullock f15907
    if (level_sameName) {
Jeremy Bullock f15907
      TFilePath anotherPath = level_sameName->getPath();
Jeremy Bullock f15907
      tooltipStr +=
Jeremy Bullock f15907
          tr("WARNING : Level name conflicts. There already is a level %1 in the scene with the path\
Jeremy Bullock f15907
                        \n          %2.")
Jeremy Bullock f15907
              .arg(QString::fromStdWString(levelName))
Jeremy Bullock f15907
              .arg(toQString(anotherPath));
Jeremy Bullock f15907
      // check resolution
Jeremy Bullock f15907
      TDimension dim;
Jeremy Bullock f15907
      bool ret = getRasterLevelSize(level_sameName, dim);
Jeremy Bullock f15907
      if (ret && checkRes && m_hasLiveViewImage && stopMotionRes != dim)
Jeremy Bullock f15907
        tooltipStr += tr("\nWARNING : Image size mismatch. The size of level "
Jeremy Bullock f15907
                         "with the same name is is %1 x %2.")
Jeremy Bullock f15907
                          .arg(dim.lx)
Jeremy Bullock f15907
                          .arg(dim.ly);
Jeremy Bullock f15907
      m_allowedCameraSize = QSize(dim.lx, dim.ly);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    if (level_samePath) {
Jeremy Bullock f15907
      std::wstring anotherName = level_samePath->getName();
Jeremy Bullock f15907
      if (!tooltipStr.isEmpty()) tooltipStr += QString("\n");
Jeremy Bullock f15907
      tooltipStr +=
Jeremy Bullock f15907
          tr("WARNING : Level path conflicts. There already is a level with the path %1\
Jeremy Bullock f15907
                        \n          in the scene with the name %2.")
Jeremy Bullock f15907
              .arg(toQString(levelFp))
Jeremy Bullock f15907
              .arg(QString::fromStdWString(anotherName));
Jeremy Bullock f15907
      // check resolution
Jeremy Bullock f15907
      TDimension dim;
Jeremy Bullock f15907
      bool ret = getRasterLevelSize(level_samePath, dim);
Jeremy Bullock f15907
      if (ret && checkRes && m_hasLiveViewImage && stopMotionRes != dim)
Jeremy Bullock f15907
        tooltipStr += tr("\nWARNING : Image size mismatch. The size of level "
Jeremy Bullock f15907
                         "with the same path is %1 x %2.")
Jeremy Bullock f15907
                          .arg(dim.lx)
Jeremy Bullock f15907
                          .arg(dim.ly);
Jeremy Bullock f15907
      m_allowedCameraSize = QSize(dim.lx, dim.ly);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    labelStr += tr("WARNING");
Jeremy Bullock f15907
    infoType = WARNING;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  QColor infoColor   = infoColors[(int)infoType];
Jeremy Bullock f15907
  m_infoColorName    = infoColor.name();
Jeremy Bullock f15907
  m_frameInfoText    = labelStr;
Jeremy Bullock f15907
  m_frameInfoToolTip = tooltipStr;
Jeremy Bullock f15907
  emit(frameInfoTextChanged(m_frameInfoText));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::updateLevelNameAndFrame(std::wstring levelName) {
Jeremy Bullock f15907
  if (levelName != m_levelName.toStdWString()) {
Jeremy Bullock f15907
    m_levelName = QString::fromStdWString(levelName);
Jeremy Bullock f15907
    loadLineUpImage();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  emit(levelNameChanged(m_levelName));
Jeremy Bullock f15907
  // m_previousLevelButton->setDisabled(levelName == L"A");
Jeremy Bullock f15907
Jeremy Bullock f15907
  // set the start frame 10 if the option in preferences
Jeremy Bullock f15907
  // "Show ABC Appendix to the Frame Number in Xsheet Cell" is active.
Jeremy Bullock f15907
  // (frame 10 is displayed as "1" with this option)
Jeremy Bullock f15907
  bool withLetter =
Jeremy Bullock f15907
      Preferences::instance()->isShowFrameNumberWithLettersEnabled();
Jeremy Bullock f15907
Jeremy Bullock f15907
  TLevelSet *levelSet =
Jeremy Bullock f15907
      TApp::instance()->getCurrentScene()->getScene()->getLevelSet();
Jeremy Bullock f15907
  TXshLevel *level_p = levelSet->getLevel(levelName);
Jeremy Bullock f15907
  int startFrame;
Jeremy Bullock f15907
  if (!level_p) {
Jeremy Bullock f15907
    startFrame = withLetter ? 10 : 1;
Jeremy Bullock f15907
  } else {
Jeremy Bullock f15907
    std::vector<tframeid> fids;</tframeid>
Jeremy Bullock f15907
    level_p->getFids(fids);
Jeremy Bullock f15907
    if (fids.empty()) {
Jeremy Bullock f15907
      startFrame = withLetter ? 10 : 1;
Jeremy Bullock f15907
    } else {
Jeremy Bullock f15907
      int lastNum = fids.back().getNumber();
Jeremy Bullock f15907
      startFrame  = withLetter ? ((int)(lastNum / 10) + 1) * 10 : lastNum + 1;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  m_frameNumber = startFrame;
Jeremy Bullock f15907
  emit(frameNumberChanged(startFrame));
Jeremy Bullock f15907
  refreshFrameInfo();
Jeremy Bullock f15907
  getSubsampling();
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setToNextNewLevel() {
Jeremy Bullock f15907
  const std::unique_ptr<namebuilder> nameBuilder(NameBuilder::getBuilder(L""));</namebuilder>
Jeremy Bullock f15907
Jeremy Bullock f15907
  TLevelSet *levelSet =
Jeremy Bullock f15907
      TApp::instance()->getCurrentScene()->getScene()->getLevelSet();
Jeremy Bullock f15907
  ToonzScene *scene      = TApp::instance()->getCurrentScene()->getScene();
Jeremy Bullock f15907
  std::wstring levelName = L"";
Jeremy Bullock f15907
Jeremy Bullock f15907
  // Select a different unique level name in case it already exists (either in
Jeremy Bullock f15907
  // scene or on disk)
Jeremy Bullock f15907
  TFilePath fp;
Jeremy Bullock f15907
  TFilePath actualFp;
Jeremy Bullock f15907
  for (;;) {
Jeremy Bullock f15907
    levelName = nameBuilder->getNext();
Jeremy Bullock f15907
Jeremy Bullock f15907
    if (levelSet->getLevel(levelName) != 0) continue;
Jeremy Bullock f15907
Jeremy Bullock f15907
    fp = TFilePath(m_filePath) +
Jeremy Bullock f15907
         TFilePath(levelName + L".." + m_fileType.toStdWString());
Jeremy Bullock f15907
    actualFp = scene->decodeFilePath(fp);
Jeremy Bullock f15907
Jeremy Bullock f15907
    if (TSystem::doesExistFileOrLevel(actualFp)) {
Jeremy Bullock f15907
      continue;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
Jeremy Bullock f15907
    break;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  updateLevelNameAndFrame(levelName);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::refreshCameraList() { emit(updateCameraList()); }
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::changeCameras(int index) {
Jeremy Bullock f15907
  QList<qcamerainfo> cameras = QCameraInfo::availableCameras();</qcamerainfo>
Jeremy Bullock f15907
Jeremy Bullock f15907
  // if selected the non-connected state, then disconnect the current camera
Jeremy Bullock f15907
  if (index == 0) {
Jeremy Bullock f15907
    m_active               = false;
Jeremy Bullock f15907
    m_webcamDeviceName     = QString();
Jeremy Bullock f15907
    m_webcamDescription    = QString();
Jeremy Bullock f15907
    m_webcamIndex          = -1;
Jeremy Bullock f15907
    m_proxyDpi             = TPointD(0.0, 0.0);
Jeremy Bullock f15907
    m_proxyImageDimensions = TDimension(0, 0);
Jeremy Bullock f15907
Jeremy Bullock f15907
    if (m_sessionOpen || m_usingWebcam) {
Jeremy Bullock f15907
      if (m_liveViewStatus > 0) {
Jeremy Bullock f15907
        endLiveView();
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      closeCameraSession();
Jeremy Bullock f15907
      m_usingWebcam = false;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
Jeremy Bullock f15907
    setTEnvCameraName("");
Jeremy Bullock f15907
Jeremy Bullock f15907
    emit(newCameraSelected(index, false));
Jeremy Bullock f15907
    toggleNumpadShortcuts(false);
Jeremy Bullock f15907
    return;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  // There is a "Select Camera" as the first index
Jeremy Bullock f15907
  index -= 1;
Jeremy Bullock f15907
  m_active = true;
Jeremy Bullock f15907
Jeremy Bullock f15907
  // Check if its a webcam or DSLR
Jeremy Bullock f15907
  // Webcams are listed first, so see if one of them is selected
Jeremy Bullock f15907
  if (index > cameras.size() - 1) {
Jeremy Bullock f15907
    m_usingWebcam = false;
Jeremy Bullock f15907
  } else {
Jeremy Bullock f15907
    m_usingWebcam = true;
Jeremy Bullock f15907
    m_webcamIndex = index;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  // in case the camera is not changed
Jeremy Bullock f15907
  if (m_usingWebcam) {
Jeremy Bullock f15907
    if (cameras.at(index).deviceName() == m_webcamDeviceName) {
Jeremy Bullock f15907
      return;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
Jeremy Bullock f15907
    if (m_sessionOpen) {
Jeremy Bullock f15907
      if (m_liveViewStatus > 0) {
Jeremy Bullock f15907
        endLiveView();
Jeremy Bullock f15907
        closeCameraSession();
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
Jeremy Bullock f15907
    setWebcam(new QCamera(cameras.at(index)));
Jeremy Bullock f15907
    m_webcamDeviceName  = cameras.at(index).deviceName();
Jeremy Bullock f15907
    m_webcamDescription = cameras.at(index).description();
Jeremy Bullock f15907
Jeremy Bullock f15907
#ifdef MACOSX
Jeremy Bullock f15907
    // this line is needed only in macosx
Jeremy Bullock f15907
    m_stopMotion->getWebcam()->setViewfinder(m_dummyViewFinder);
Jeremy Bullock f15907
#endif
Jeremy Bullock f15907
Jeremy Bullock f15907
    // loading new camera
Jeremy Bullock f15907
    getWebcam()->load();
Jeremy Bullock f15907
Jeremy Bullock f15907
    m_webcamResolutions.clear();
Jeremy Bullock f15907
Jeremy Bullock f15907
    m_webcamResolutions = getWebcam()->supportedViewfinderResolutions();
Jeremy Bullock f15907
    int sizeCount       = m_webcamResolutions.count();
Jeremy Bullock f15907
Jeremy Bullock f15907
    int width;
Jeremy Bullock f15907
    int height;
Jeremy Bullock f15907
    for (int s = 0; s < m_webcamResolutions.size(); s++) {
Jeremy Bullock f15907
      width  = m_webcamResolutions.at(s).width();
Jeremy Bullock f15907
      height = m_webcamResolutions.at(s).height();
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
Jeremy Bullock f15907
    getWebcam()->unload();
Jeremy Bullock f15907
Jeremy Bullock f15907
    setWebcamResolution(
Jeremy Bullock f15907
        QString(QString::number(width) + " x " + QString::number(height)));
Jeremy Bullock f15907
    setTEnvCameraName(m_webcamDescription.toStdString());
Jeremy Bullock f15907
    emit(newCameraSelected(index + 1, true));
Jeremy Bullock f15907
    emit(webcamResolutionsChanged());
Jeremy Bullock f15907
    emit(newWebcamResolutionSelected(sizeCount - 1));
Jeremy Bullock f15907
Jeremy Bullock f15907
  } else {
Jeremy Bullock f15907
    m_webcamDeviceName  = QString();
Jeremy Bullock f15907
    m_webcamDescription = QString();
Jeremy Bullock f15907
    m_webcamIndex       = -1;
Jeremy Bullock f15907
    openCameraSession();
Jeremy Bullock f15907
    setTEnvCameraName(getCameraName());
Jeremy Bullock f15907
    emit(newCameraSelected(index + 1, false));
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (m_useNumpadShortcuts) toggleNumpadShortcuts(true);
Jeremy Bullock f15907
  m_liveViewDpi = TPointD(0.0, 0.0);
Jeremy Bullock f15907
  refreshFrameInfo();
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QList<qcamerainfo> StopMotion::getWebcams() {</qcamerainfo>
Jeremy Bullock f15907
  m_webcams.clear();
Jeremy Bullock f15907
  m_webcams = QCameraInfo::availableCameras();
Jeremy Bullock f15907
  return m_webcams;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setWebcam(QCamera *camera) { m_webcam = camera; }
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
bool StopMotion::translateIndex(int index) {
Jeremy Bullock f15907
  // We are using Qt to get the camera info and supported resolutions, but
Jeremy Bullock f15907
  // we are using OpenCV to actually get the images.
Jeremy Bullock f15907
  // The camera index from OpenCV and from Qt don't always agree,
Jeremy Bullock f15907
  // So this checks the name against the correct index.
Jeremy Bullock f15907
  m_webcamIndex = index;
Jeremy Bullock f15907
Jeremy Bullock f15907
#ifdef WIN32
Jeremy Bullock f15907
shun-iwasawa 2c27a4
  // Thanks to:
shun-iwasawa 2c27a4
  // https://elcharolin.wordpress.com/2017/08/28/webcam-capture-with-the-media-foundation-sdk/
shun-iwasawa 2c27a4
  // for the webcam enumeration here
Jeremy Bullock f15907
Jeremy Bullock f15907
#define CLEAN_ATTRIBUTES()                                                     \
Jeremy Bullock f15907
  if (attributes) {                                                            \
Jeremy Bullock f15907
    attributes->Release();                                                     \
Jeremy Bullock f15907
    attributes = NULL;                                                         \
Jeremy Bullock f15907
  }                                                                            \
Jeremy Bullock f15907
  for (DWORD i = 0; i < count; i++) {                                          \
Jeremy Bullock f15907
    if (&devices[i]) {                                                         \
Jeremy Bullock f15907
      devices[i]->Release();                                                   \
Jeremy Bullock f15907
      devices[i] = NULL;                                                       \
Jeremy Bullock f15907
    }                                                                          \
Jeremy Bullock f15907
  }                                                                            \
Jeremy Bullock f15907
  CoTaskMemFree(devices);                                                      \
Jeremy Bullock f15907
  return hr;
Jeremy Bullock f15907
Jeremy Bullock f15907
  HRESULT hr = S_OK;
Jeremy Bullock f15907
Jeremy Bullock f15907
  // this is important!!
Jeremy Bullock f15907
  hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
Jeremy Bullock f15907
Jeremy Bullock f15907
  UINT32 count              = 0;
Jeremy Bullock f15907
  IMFAttributes *attributes = NULL;
Jeremy Bullock f15907
  IMFActivate **devices     = NULL;
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (FAILED(hr)) {
Jeremy Bullock f15907
    CLEAN_ATTRIBUTES()
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  // Create an attribute store to specify enumeration parameters.
Jeremy Bullock f15907
  hr = MFCreateAttributes(&attributes, 1);
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (FAILED(hr)) {
Jeremy Bullock f15907
    CLEAN_ATTRIBUTES()
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  // The attribute to be requested is devices that can capture video
Jeremy Bullock f15907
  hr = attributes->SetGUID(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
Jeremy Bullock f15907
                           MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID);
Jeremy Bullock f15907
  if (FAILED(hr)) {
Jeremy Bullock f15907
    CLEAN_ATTRIBUTES()
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  // Enummerate the video capture devices
Jeremy Bullock f15907
  hr = MFEnumDeviceSources(attributes, &devices, &count);
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (FAILED(hr)) {
Jeremy Bullock f15907
    CLEAN_ATTRIBUTES()
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  // if there are any available devices
Jeremy Bullock f15907
  if (count > 0) {
Jeremy Bullock f15907
    WCHAR *nameString = NULL;
Jeremy Bullock f15907
    // Get the human-friendly name of the device
Jeremy Bullock f15907
    UINT32 cchName;
Jeremy Bullock f15907
Jeremy Bullock f15907
    for (int i = 0; i < count; i++) {
Jeremy Bullock f15907
      hr = devices[i]->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME,
Jeremy Bullock f15907
                                          &nameString, &cchName);
Jeremy Bullock f15907
      std::string desc = m_webcamDescription.toStdString();
Jeremy Bullock f15907
      if (nameString == m_webcamDescription.toStdWString()) {
Jeremy Bullock f15907
        m_webcamIndex = i;
Jeremy Bullock f15907
        break;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      // devices[0]->ShutdownObject();
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
Jeremy Bullock f15907
    CoTaskMemFree(nameString);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  // clean
Jeremy Bullock f15907
  CLEAN_ATTRIBUTES()
Jeremy Bullock f15907
#else
Jeremy Bullock f15907
  return true;
Jeremy Bullock f15907
#endif
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
bool StopMotion::initWebcam(int index) {
Jeremy Bullock f15907
  if (!m_useDirectShow) {
Jeremy Bullock f15907
    // the webcam order obtained from Qt isn't always the same order as
Jeremy Bullock f15907
    // the one obtained from OpenCV without DirectShow
Jeremy Bullock f15907
    translateIndex(index);
Jeremy Bullock f15907
    m_cvWebcam.open(m_webcamIndex);
Jeremy Bullock f15907
  } else {
Jeremy Bullock f15907
    m_webcamIndex = index;
Jeremy Bullock f15907
    m_cvWebcam.open(m_webcamIndex, cv::CAP_DSHOW);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (m_cvWebcam.isOpened() == false) {
Jeremy Bullock f15907
    return false;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  return true;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::releaseWebcam() {
Jeremy Bullock f15907
  m_cvWebcam.release();
Jeremy Bullock f15907
  m_liveViewStatus = 0;
Jeremy Bullock f15907
  emit(liveViewStopped());
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setWebcamResolution(QString resolution) {
Jeremy Bullock f15907
  m_cvWebcam.release();
Jeremy Bullock f15907
Jeremy Bullock f15907
  // resolution is written in the itemText with the format "<width> x</width>
Jeremy Bullock f15907
  // <height>" (e.g. "800 x 600")</height>
Jeremy Bullock f15907
  QStringList texts = resolution.split(' ');
Jeremy Bullock f15907
  // the splited text must be "<width>" "x" and "<height>"</height></width>
Jeremy Bullock f15907
  if (texts.size() != 3) return;
Jeremy Bullock f15907
  int tempStatus   = m_liveViewStatus;
Jeremy Bullock f15907
  m_liveViewStatus = 0;
Jeremy Bullock f15907
  bool startTimer  = false;
Jeremy Bullock f15907
  if (m_timer->isActive()) {
Jeremy Bullock f15907
    m_timer->stop();
Jeremy Bullock f15907
    startTimer = true;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  qApp->processEvents(QEventLoop::AllEvents, 1000);
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_webcamWidth  = texts[0].toInt();
Jeremy Bullock f15907
  m_webcamHeight = texts[2].toInt();
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_liveViewDpi    = TPointD(0.0, 0.0);
Jeremy Bullock f15907
  m_liveViewStatus = tempStatus;
Jeremy Bullock f15907
  if (startTimer) m_timer->start(40);
Jeremy Bullock f15907
Jeremy Bullock f15907
  // update env
Jeremy Bullock f15907
  setTEnvCameraResolution(resolution.toStdString());
Jeremy Bullock f15907
Jeremy Bullock f15907
  refreshFrameInfo();
Jeremy Bullock f15907
Jeremy Bullock f15907
  int index = m_webcamResolutions.indexOf(QSize(m_webcamWidth, m_webcamHeight));
Jeremy Bullock f15907
  emit(newWebcamResolutionSelected(index));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::getWebcamImage() {
Jeremy Bullock f15907
  bool error = false;
Jeremy Bullock f15907
  cv::Mat imgOriginal;
Jeremy Bullock f15907
  cv::Mat imgCorrected;
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (m_cvWebcam.isOpened() == false) {
Jeremy Bullock f15907
    initWebcam(m_webcamIndex);
Jeremy Bullock f15907
    // mjpg is used by many webcams
Jeremy Bullock f15907
    // opencv runs very slow on some webcams without it.
Jeremy Bullock f15907
    if (m_useMjpg) {
Jeremy Bullock f15907
      m_cvWebcam.set(cv::CAP_PROP_FOURCC,
Jeremy Bullock f15907
                     cv::VideoWriter::fourcc('m', 'j', 'p', 'g'));
Jeremy Bullock f15907
      m_cvWebcam.set(cv::CAP_PROP_FOURCC,
Jeremy Bullock f15907
                     cv::VideoWriter::fourcc('M', 'J', 'P', 'G'));
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    m_cvWebcam.set(3, m_webcamWidth);
Jeremy Bullock f15907
    m_cvWebcam.set(4, m_webcamHeight);
Jeremy Bullock f15907
    if (!m_cvWebcam.isOpened()) {
Jeremy Bullock f15907
      m_hasLiveViewImage = false;
Jeremy Bullock f15907
      error              = true;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  bool blnFrameReadSuccessfully =
Jeremy Bullock f15907
      m_cvWebcam.read(imgOriginal);  // get next frame
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (!blnFrameReadSuccessfully ||
Jeremy Bullock f15907
      imgOriginal.empty()) {  // if frame not read successfully
Jeremy Bullock f15907
    std::cout << "error: frame not read from webcam\n";
Jeremy Bullock f15907
    error = true;  // print error message to std out
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (!error) {
Jeremy Bullock f15907
    cv::cvtColor(imgOriginal, imgCorrected, cv::COLOR_BGR2BGRA);
Jeremy Bullock f15907
    cv::flip(imgCorrected, imgCorrected, 0);
Jeremy Bullock f15907
    int width  = m_cvWebcam.get(3);
Jeremy Bullock f15907
    int height = m_cvWebcam.get(4);
Jeremy Bullock f15907
    int size   = imgCorrected.total() * imgCorrected.elemSize();
Jeremy Bullock f15907
Jeremy Bullock f15907
    m_liveViewImage = TRaster32P(width, height);
Jeremy Bullock f15907
    m_liveViewImage->lock();
Jeremy Bullock f15907
    uchar *imgBuf  = imgCorrected.data;
Jeremy Bullock f15907
    uchar *rawData = m_liveViewImage->getRawData();
Jeremy Bullock f15907
    memcpy(rawData, imgBuf, size);
Jeremy Bullock f15907
    m_liveViewImage->unlock();
Jeremy Bullock f15907
    m_hasLiveViewImage = true;
Jeremy Bullock f15907
    m_liveViewStatus   = 2;
Jeremy Bullock f15907
    if (m_hasLiveViewImage &&
Jeremy Bullock f15907
        (m_liveViewDpi.x == 0.0 || m_liveViewImageDimensions.lx == 0)) {
Jeremy Bullock f15907
      TCamera *camera =
Jeremy Bullock f15907
          TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
Jeremy Bullock f15907
      TDimensionD size = camera->getSize();
Jeremy Bullock f15907
      m_liveViewImageDimensions =
Jeremy Bullock f15907
          TDimension(m_liveViewImage->getLx(), m_liveViewImage->getLy());
Jeremy Bullock f15907
      double minimumDpi = std::min(m_liveViewImageDimensions.lx / size.lx,
Jeremy Bullock f15907
                                   m_liveViewImageDimensions.ly / size.ly);
shun-iwasawa 2c27a4
      m_liveViewDpi     = TPointD(minimumDpi, minimumDpi);
Jeremy Bullock f15907
Jeremy Bullock f15907
      m_fullImageDimensions = m_liveViewImageDimensions;
Jeremy Bullock f15907
Jeremy Bullock f15907
      m_fullImageDpi = m_liveViewDpi;
Jeremy Bullock f15907
Jeremy Bullock f15907
      emit(newDimensions());
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
Jeremy Bullock f15907
    emit(newLiveViewImageReady());
Jeremy Bullock f15907
  } else
Jeremy Bullock f15907
    m_hasLiveViewImage = false;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::setUseDirectShow(int state) {
Jeremy Bullock f15907
  m_useDirectShow         = state;
Jeremy Bullock f15907
  StopMotionUseDirectShow = state;
Jeremy Bullock f15907
  emit(useDirectShowSignal(state));
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
bool StopMotion::toggleLiveView() {
Jeremy Bullock f15907
  if ((m_sessionOpen || m_usingWebcam) && m_liveViewStatus == 0) {
Jeremy Bullock f15907
    m_liveViewDpi             = TPointD(0.0, 0.0);
Jeremy Bullock f15907
    m_liveViewImageDimensions = TDimension(0, 0);
Jeremy Bullock f15907
    if (!m_usingWebcam) {
Jeremy Bullock f15907
      startLiveView();
Jeremy Bullock f15907
    } else
Jeremy Bullock f15907
      m_liveViewStatus = 1;
Jeremy Bullock f15907
    loadLineUpImage();
Jeremy Bullock f15907
    m_timer->start(40);
Jeremy Bullock f15907
    emit(liveViewChanged(true));
Jeremy Bullock f15907
    Preferences::instance()->setValue(rewindAfterPlayback, false);
shun-iwasawa 2c27a4
    TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
Jeremy Bullock f15907
    return true;
Jeremy Bullock f15907
  } else if ((m_sessionOpen || m_usingWebcam) && m_liveViewStatus > 0) {
Jeremy Bullock f15907
    if (!m_usingWebcam)
Jeremy Bullock f15907
      endLiveView();
Jeremy Bullock f15907
    else
Jeremy Bullock f15907
      releaseWebcam();
Jeremy Bullock f15907
    m_timer->stop();
Jeremy Bullock f15907
    emit(liveViewChanged(false));
Jeremy Bullock f15907
    if (m_turnOnRewind) {
shun-iwasawa 2c27a4
      Preferences::instance()->setValue(rewindAfterPlayback, true);
Jeremy Bullock f15907
    }
shun-iwasawa 2c27a4
    TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
Jeremy Bullock f15907
    return false;
Jeremy Bullock f15907
  } else {
Jeremy Bullock f15907
    DVGui::warning(tr("No camera selected."));
Jeremy Bullock f15907
    return false;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::pauseLiveView() {
Jeremy Bullock f15907
  if (m_liveViewStatus == 2) {
Jeremy Bullock f15907
    m_liveViewStatus  = 3;
Jeremy Bullock f15907
    m_userCalledPause = true;
Jeremy Bullock f15907
    emit(liveViewStopped());
Jeremy Bullock f15907
  } else if (m_liveViewStatus == 3) {
Jeremy Bullock f15907
    m_liveViewStatus  = 2;
Jeremy Bullock f15907
    m_userCalledPause = false;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::initializeCanonSDK() {
Jeremy Bullock f15907
  m_error = EdsInitializeSDK();
Jeremy Bullock f15907
  if (m_error == EDS_ERR_OK) {
Jeremy Bullock f15907
    m_isSDKLoaded = true;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  return m_error;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsCameraListRef StopMotion::getCameraList() {
Jeremy Bullock f15907
  if (!m_isSDKLoaded) initializeCanonSDK();
Jeremy Bullock f15907
  if (m_isSDKLoaded) {
Jeremy Bullock f15907
    m_error = EdsGetCameraList(&m_cameraList);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  return m_cameraList;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::releaseCameraList() {
Jeremy Bullock f15907
  if (m_cameraList != NULL) m_error = EdsRelease(m_cameraList);
Jeremy Bullock f15907
  return m_error;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
int StopMotion::getCameraCount() {
Jeremy Bullock f15907
  if (m_cameraList == NULL) {
Jeremy Bullock f15907
    getCameraList();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (m_cameraList != NULL) {
Jeremy Bullock f15907
    m_error = EdsGetChildCount(m_cameraList, &m_count);
Jeremy Bullock f15907
    if (m_count == 0) {
Jeremy Bullock f15907
      m_error          = EDS_ERR_DEVICE_NOT_FOUND;
Jeremy Bullock f15907
      m_sessionOpen    = false;
Jeremy Bullock f15907
      m_liveViewStatus = 0;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    return m_count;
Jeremy Bullock f15907
  } else
Jeremy Bullock f15907
    return -1;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::getCamera(int index) {
Jeremy Bullock f15907
  if (m_count == 0) {
Jeremy Bullock f15907
    m_error = EDS_ERR_DEVICE_NOT_FOUND;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (m_count > 0) {
Jeremy Bullock f15907
    m_error = EdsGetChildAtIndex(m_cameraList, index, &m_camera);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  return m_error;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::releaseCamera() {
Jeremy Bullock f15907
  if (m_camera != NULL) {
Jeremy Bullock f15907
    m_error = EdsRelease(m_camera);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  return m_error;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::cameraAdded() {
Jeremy Bullock f15907
  if (!m_active) refreshCameraList();
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::closeCanonSDK() {
Jeremy Bullock f15907
  if (m_isSDKLoaded) {
Jeremy Bullock f15907
    EdsTerminateSDK();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::openCameraSession() {
Jeremy Bullock f15907
  if (m_camera != NULL) {
shun-iwasawa 2c27a4
    m_error = EdsOpenSession(m_camera);
Jeremy Bullock f15907
    if (m_error == EDS_ERR_OK) m_sessionOpen = true;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  m_error =
Jeremy Bullock f15907
      EdsSetObjectEventHandler(m_camera, kEdsObjectEvent_All,
Jeremy Bullock f15907
                               StopMotion::handleObjectEvent, (EdsVoid *)this);
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_error = EdsSetPropertyEventHandler(m_camera, kEdsPropertyEvent_All,
Jeremy Bullock f15907
                                       StopMotion::handlePropertyEvent,
Jeremy Bullock f15907
                                       (EdsVoid *)this);
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_error = EdsSetCameraStateEventHandler(m_camera, kEdsStateEvent_All,
Jeremy Bullock f15907
                                          StopMotion::handleStateEvent,
Jeremy Bullock f15907
                                          (EdsVoid *)this);
Jeremy Bullock f15907
Jeremy Bullock f15907
  // We can't handle raw images yet, so make sure we are getting jpgs
Jeremy Bullock f15907
  if (getCurrentImageQuality().contains("RAW"))
Jeremy Bullock f15907
    setImageQuality("Large Fine Jpeg");
Jeremy Bullock f15907
shun-iwasawa 2c27a4
  EdsUInt32 saveto        = kEdsSaveTo_Host;
shun-iwasawa 2c27a4
  m_error                 = EdsSetPropertyData(m_camera, kEdsPropID_SaveTo, 0,
Jeremy Bullock f15907
                               sizeof(EdsUInt32), &saveto);
Jeremy Bullock f15907
  EdsCapacity newCapacity = {0x7FFFFFFF, 0x1000, 1};
Jeremy Bullock f15907
  m_error                 = EdsSetCapacity(m_camera, newCapacity);
Jeremy Bullock f15907
  return m_error;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::closeCameraSession() {
Jeremy Bullock f15907
  if (m_camera != NULL) {
Jeremy Bullock f15907
    m_error       = EdsCloseSession(m_camera);
Jeremy Bullock f15907
    m_sessionOpen = false;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  return m_error;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::refreshOptions() {
Jeremy Bullock f15907
  getAvailableShutterSpeeds();
Jeremy Bullock f15907
  getAvailableIso();
Jeremy Bullock f15907
  getAvailableApertures();
Jeremy Bullock f15907
  getAvailableExposureCompensations();
Jeremy Bullock f15907
  getAvailableWhiteBalances();
Jeremy Bullock f15907
  buildColorTemperatures();
Jeremy Bullock f15907
  getAvailableImageQualities();
Jeremy Bullock f15907
  getAvailablePictureStyles();
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
std::string StopMotion::getCameraName() {
Jeremy Bullock f15907
  EdsChar name[EDS_MAX_NAME];
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsDataType dataType;
Jeremy Bullock f15907
  EdsUInt32 dataSize;
Jeremy Bullock f15907
  m_error = EdsGetPropertySize(m_camera, kEdsPropID_ProductName, 0, &dataType,
Jeremy Bullock f15907
                               &dataSize);
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (m_error == EDS_ERR_OK) {
Jeremy Bullock f15907
    m_error =
Jeremy Bullock f15907
        EdsGetPropertyData(m_camera, kEdsPropID_ProductName, 0, dataSize, name);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  m_cameraName = name;
Jeremy Bullock f15907
  return m_cameraName;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QString StopMotion::getMode() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsDataType modeType;
Jeremy Bullock f15907
  EdsUInt32 size;
Jeremy Bullock f15907
  EdsUInt32 data;
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertySize(m_camera, kEdsPropID_AEMode, 0, &modeType, &size);
Jeremy Bullock f15907
  err = EdsGetPropertyData(m_camera, kEdsPropID_AEMode, 0, sizeof(size), &data);
Jeremy Bullock f15907
Jeremy Bullock f15907
  return QString::fromStdString(m_modeMap[data]);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::getAvailableIso() {
Jeremy Bullock f15907
  EdsPropertyDesc *IsoDesc = new EdsPropertyDesc;
Jeremy Bullock f15907
  EdsError err             = EDS_ERR_OK;
Jeremy Bullock f15907
  m_isoOptions.clear();
Jeremy Bullock f15907
Jeremy Bullock f15907
  err       = EdsGetPropertyDesc(m_camera, kEdsPropID_ISOSpeed, IsoDesc);
Jeremy Bullock f15907
  int count = IsoDesc->numElements;
Jeremy Bullock f15907
  if (count > 0) {
Jeremy Bullock f15907
    int i = 0;
Jeremy Bullock f15907
    while (i < count) {
Jeremy Bullock f15907
      m_isoOptions.push_back(
Jeremy Bullock f15907
          QString::fromStdString(m_isoMap[IsoDesc->propDesc[i]]));
Jeremy Bullock f15907
      i++;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  delete IsoDesc;
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::getAvailableShutterSpeeds() {
Jeremy Bullock f15907
  EdsPropertyDesc *TvDesc = new EdsPropertyDesc;
Jeremy Bullock f15907
  EdsError err            = EDS_ERR_OK;
Jeremy Bullock f15907
  m_shutterSpeedOptions.clear();
Jeremy Bullock f15907
Jeremy Bullock f15907
  err       = EdsGetPropertyDesc(m_camera, kEdsPropID_Tv, TvDesc);
Jeremy Bullock f15907
  int count = TvDesc->numElements;
Jeremy Bullock f15907
  if (count > 0) {
Jeremy Bullock f15907
    int i = 0;
Jeremy Bullock f15907
    while (i < count) {
Jeremy Bullock f15907
      m_shutterSpeedOptions.push_back(
Jeremy Bullock f15907
          QString::fromStdString(m_tvMap[TvDesc->propDesc[i]]));
Jeremy Bullock f15907
      i++;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  delete TvDesc;
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::getAvailableApertures() {
Jeremy Bullock f15907
  EdsPropertyDesc *AvDesc = new EdsPropertyDesc;
Jeremy Bullock f15907
  EdsError err            = EDS_ERR_OK;
Jeremy Bullock f15907
  m_apertureOptions.clear();
Jeremy Bullock f15907
Jeremy Bullock f15907
  err       = EdsGetPropertyDesc(m_camera, kEdsPropID_Av, AvDesc);
Jeremy Bullock f15907
  int count = AvDesc->numElements;
Jeremy Bullock f15907
  if (count > 0) {
Jeremy Bullock f15907
    int i = 0;
Jeremy Bullock f15907
    while (i < count) {
Jeremy Bullock f15907
      m_apertureOptions.push_back(
Jeremy Bullock f15907
          QString::fromStdString(m_avMap[AvDesc->propDesc[i]]));
Jeremy Bullock f15907
      i++;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  delete AvDesc;
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::getAvailableExposureCompensations() {
Jeremy Bullock f15907
  EdsPropertyDesc *exposureDesc = new EdsPropertyDesc;
Jeremy Bullock f15907
  EdsError err                  = EDS_ERR_OK;
Jeremy Bullock f15907
  m_exposureOptions.clear();
Jeremy Bullock f15907
shun-iwasawa 2c27a4
  err       = EdsGetPropertyDesc(m_camera, kEdsPropID_ExposureCompensation,
Jeremy Bullock f15907
                           exposureDesc);
Jeremy Bullock f15907
  int count = exposureDesc->numElements;
Jeremy Bullock f15907
  if (count > 0) {
Jeremy Bullock f15907
    int i = 0;
Jeremy Bullock f15907
    while (i < count) {
Jeremy Bullock f15907
      m_exposureOptions.push_back(
Jeremy Bullock f15907
          QString::fromStdString(m_exposureMap[exposureDesc->propDesc[i]]));
Jeremy Bullock f15907
      i++;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  delete exposureDesc;
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::getAvailableWhiteBalances() {
Jeremy Bullock f15907
  EdsPropertyDesc *whiteBalanceDesc = new EdsPropertyDesc;
Jeremy Bullock f15907
  EdsError err                      = EDS_ERR_OK;
Jeremy Bullock f15907
  m_whiteBalanceOptions.clear();
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertyDesc(m_camera, kEdsPropID_WhiteBalance, whiteBalanceDesc);
Jeremy Bullock f15907
  int count = whiteBalanceDesc->numElements;
Jeremy Bullock f15907
  if (count > 0) {
Jeremy Bullock f15907
    int i = 0;
Jeremy Bullock f15907
    while (i < count) {
Jeremy Bullock f15907
      m_whiteBalanceOptions.push_back(QString::fromStdString(
Jeremy Bullock f15907
          m_whiteBalanceMap[whiteBalanceDesc->propDesc[i]]));
Jeremy Bullock f15907
      i++;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  delete whiteBalanceDesc;
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::getAvailableImageQualities() {
Jeremy Bullock f15907
  EdsPropertyDesc *imageQualityDesc = new EdsPropertyDesc;
Jeremy Bullock f15907
  EdsError err                      = EDS_ERR_OK;
Jeremy Bullock f15907
  m_imageQualityOptions.clear();
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertyDesc(m_camera, kEdsPropID_ImageQuality, imageQualityDesc);
Jeremy Bullock f15907
  int count = imageQualityDesc->numElements;
Jeremy Bullock f15907
  if (count > 0) {
Jeremy Bullock f15907
    int i = 0;
Jeremy Bullock f15907
    while (i < count) {
Jeremy Bullock f15907
      QString quality = QString::fromStdString(
Jeremy Bullock f15907
          m_imageQualityMap[imageQualityDesc->propDesc[i]]);
Jeremy Bullock f15907
      if (!quality.contains("RAW")) {
Jeremy Bullock f15907
        m_imageQualityOptions.push_back(quality);
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      i++;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  delete imageQualityDesc;
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::getAvailablePictureStyles() {
Jeremy Bullock f15907
  EdsPropertyDesc *pictureStyleDesc = new EdsPropertyDesc;
Jeremy Bullock f15907
  EdsError err                      = EDS_ERR_OK;
Jeremy Bullock f15907
  m_pictureStyleOptions.clear();
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertyDesc(m_camera, kEdsPropID_PictureStyle, pictureStyleDesc);
Jeremy Bullock f15907
  int count = pictureStyleDesc->numElements;
Jeremy Bullock f15907
  if (count > 0) {
Jeremy Bullock f15907
    int i = 0;
Jeremy Bullock f15907
    while (i < count) {
Jeremy Bullock f15907
      m_pictureStyleOptions.push_back(QString::fromStdString(
Jeremy Bullock f15907
          m_pictureStyleMap[pictureStyleDesc->propDesc[i]]));
Jeremy Bullock f15907
      i++;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  delete pictureStyleDesc;
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::buildColorTemperatures() {
Jeremy Bullock f15907
  m_colorTempOptions.clear();
Jeremy Bullock f15907
  int i = 2800;
Jeremy Bullock f15907
  while (i <= 10000) {
Jeremy Bullock f15907
    m_colorTempOptions.push_back(QString::number(i));
Jeremy Bullock f15907
    i += 100;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QString StopMotion::getCurrentShutterSpeed() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsDataType tvType;
Jeremy Bullock f15907
  EdsUInt32 size;
Jeremy Bullock f15907
  EdsUInt32 data;
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertySize(m_camera, kEdsPropID_Tv, 0, &tvType, &size);
Jeremy Bullock f15907
  err = EdsGetPropertyData(m_camera, kEdsPropID_Tv, 0, sizeof(size), &data);
Jeremy Bullock f15907
Jeremy Bullock f15907
  return QString::fromStdString(m_tvMap[data]);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QString StopMotion::getCurrentIso() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsDataType isoType;
Jeremy Bullock f15907
  EdsUInt32 size;
Jeremy Bullock f15907
  EdsUInt32 data;
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertySize(m_camera, kEdsPropID_ISOSpeed, 0, &isoType, &size);
Jeremy Bullock f15907
  err =
Jeremy Bullock f15907
      EdsGetPropertyData(m_camera, kEdsPropID_ISOSpeed, 0, sizeof(size), &data);
Jeremy Bullock f15907
Jeremy Bullock f15907
  return QString::fromStdString(m_isoMap[data]);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QString StopMotion::getCurrentAperture() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsDataType avType;
Jeremy Bullock f15907
  EdsUInt32 size;
Jeremy Bullock f15907
  EdsUInt32 data;
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertySize(m_camera, kEdsPropID_Av, 0, &avType, &size);
Jeremy Bullock f15907
  err = EdsGetPropertyData(m_camera, kEdsPropID_Av, 0, sizeof(size), &data);
Jeremy Bullock f15907
Jeremy Bullock f15907
  return QString::fromStdString(m_avMap[data]);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QString StopMotion::getCurrentExposureCompensation() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsDataType exposureType;
Jeremy Bullock f15907
  EdsUInt32 size;
Jeremy Bullock f15907
  EdsUInt32 data;
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertySize(m_camera, kEdsPropID_ExposureCompensation, 0,
Jeremy Bullock f15907
                           &exposureType, &size);
Jeremy Bullock f15907
  err = EdsGetPropertyData(m_camera, kEdsPropID_ExposureCompensation, 0,
Jeremy Bullock f15907
                           sizeof(size), &data);
Jeremy Bullock f15907
Jeremy Bullock f15907
  return QString::fromStdString(m_exposureMap[data]);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QString StopMotion::getCurrentWhiteBalance() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsDataType whiteBalanceType;
Jeremy Bullock f15907
  EdsUInt32 size;
Jeremy Bullock f15907
  EdsUInt32 data;
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertySize(m_camera, kEdsPropID_WhiteBalance, 0,
Jeremy Bullock f15907
                           &whiteBalanceType, &size);
Jeremy Bullock f15907
  err = EdsGetPropertyData(m_camera, kEdsPropID_WhiteBalance, 0, sizeof(size),
Jeremy Bullock f15907
                           &data);
Jeremy Bullock f15907
  std::string wbString = m_whiteBalanceMap[data];
Jeremy Bullock f15907
  return QString::fromStdString(m_whiteBalanceMap[data]);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QString StopMotion::getCurrentImageQuality() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsDataType imageQualityType;
Jeremy Bullock f15907
  EdsUInt32 size;
Jeremy Bullock f15907
  EdsUInt32 data;
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertySize(m_camera, kEdsPropID_ImageQuality, 0,
Jeremy Bullock f15907
                           &imageQualityType, &size);
Jeremy Bullock f15907
  err = EdsGetPropertyData(m_camera, kEdsPropID_ImageQuality, 0, sizeof(size),
Jeremy Bullock f15907
                           &data);
Jeremy Bullock f15907
  std::string wbString = m_imageQualityMap[data];
Jeremy Bullock f15907
  return QString::fromStdString(m_imageQualityMap[data]);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QString StopMotion::getCurrentPictureStyle() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsDataType pictureStyleType;
Jeremy Bullock f15907
  EdsUInt32 size;
Jeremy Bullock f15907
  EdsUInt32 data;
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertySize(m_camera, kEdsPropID_PictureStyle, 0,
Jeremy Bullock f15907
                           &pictureStyleType, &size);
Jeremy Bullock f15907
  err = EdsGetPropertyData(m_camera, kEdsPropID_PictureStyle, 0, sizeof(size),
Jeremy Bullock f15907
                           &data);
Jeremy Bullock f15907
  std::string wbString = m_pictureStyleMap[data];
Jeremy Bullock f15907
  return QString::fromStdString(m_pictureStyleMap[data]);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
QString StopMotion::getCurrentColorTemperature() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsDataType colorTempType;
Jeremy Bullock f15907
  EdsUInt32 size;
Jeremy Bullock f15907
  EdsUInt32 data;
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertySize(m_camera, kEdsPropID_ColorTemperature, 0,
Jeremy Bullock f15907
                           &colorTempType, &size);
Jeremy Bullock f15907
  err = EdsGetPropertyData(m_camera, kEdsPropID_ColorTemperature, 0,
Jeremy Bullock f15907
                           sizeof(size), &data);
Jeremy Bullock f15907
Jeremy Bullock f15907
  return QString::number(data);
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::setShutterSpeed(QString shutterSpeed) {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsUInt32 value;
Jeremy Bullock f15907
  auto it = m_tvMap.begin();
Jeremy Bullock f15907
  while (it != m_tvMap.end()) {
Jeremy Bullock f15907
    if (it->second == shutterSpeed.toStdString()) {
Jeremy Bullock f15907
      value = it->first;
Jeremy Bullock f15907
      break;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    it++;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_Tv, 0, sizeof(value), &value);
Jeremy Bullock f15907
  emit(shutterSpeedChangedSignal(shutterSpeed));
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::setIso(QString iso) {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsUInt32 value;
Jeremy Bullock f15907
  auto it = m_isoMap.begin();
Jeremy Bullock f15907
  while (it != m_isoMap.end()) {
Jeremy Bullock f15907
    if (it->second == iso.toStdString()) {
Jeremy Bullock f15907
      value = it->first;
Jeremy Bullock f15907
      break;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    it++;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_ISOSpeed, 0, sizeof(value),
Jeremy Bullock f15907
                           &value);
Jeremy Bullock f15907
  emit(isoChangedSignal(iso));
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::setAperture(QString aperture) {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsUInt32 value;
Jeremy Bullock f15907
  auto it = m_avMap.begin();
Jeremy Bullock f15907
  while (it != m_avMap.end()) {
Jeremy Bullock f15907
    if (it->second == aperture.toStdString()) {
Jeremy Bullock f15907
      value = it->first;
Jeremy Bullock f15907
      break;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    it++;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_Av, 0, sizeof(value), &value);
Jeremy Bullock f15907
  emit(apertureChangedSignal(aperture));
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::setExposureCompensation(QString exposure) {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsUInt32 value;
Jeremy Bullock f15907
  auto it = m_exposureMap.begin();
Jeremy Bullock f15907
  while (it != m_exposureMap.end()) {
Jeremy Bullock f15907
    if (it->second == exposure.toStdString()) {
Jeremy Bullock f15907
      value = it->first;
Jeremy Bullock f15907
      break;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    it++;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_ExposureCompensation, 0,
Jeremy Bullock f15907
                           sizeof(value), &value);
Jeremy Bullock f15907
  emit(exposureChangedSignal(exposure));
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::setWhiteBalance(QString whiteBalance) {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsUInt32 value;
Jeremy Bullock f15907
  auto it = m_whiteBalanceMap.begin();
Jeremy Bullock f15907
  while (it != m_whiteBalanceMap.end()) {
Jeremy Bullock f15907
    if (it->second == whiteBalance.toStdString()) {
Jeremy Bullock f15907
      value = it->first;
Jeremy Bullock f15907
      break;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    it++;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_WhiteBalance, 0, sizeof(value),
Jeremy Bullock f15907
                           &value);
Jeremy Bullock f15907
  emit(whiteBalanceChangedSignal(whiteBalance));
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::setImageQuality(QString quality) {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsUInt32 value;
Jeremy Bullock f15907
  auto it = m_imageQualityMap.begin();
Jeremy Bullock f15907
  while (it != m_imageQualityMap.end()) {
Jeremy Bullock f15907
    if (it->second == quality.toStdString()) {
Jeremy Bullock f15907
      value = it->first;
Jeremy Bullock f15907
      break;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    it++;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_ImageQuality, 0, sizeof(value),
Jeremy Bullock f15907
                           &value);
Jeremy Bullock f15907
  emit(imageQualityChangedSignal(quality));
Jeremy Bullock f15907
  m_proxyImageDimensions = TDimension(0, 0);
Jeremy Bullock f15907
  m_proxyDpi             = TPointD(0.0, 0.0);
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::setPictureStyle(QString style) {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsUInt32 value;
Jeremy Bullock f15907
  auto it = m_pictureStyleMap.begin();
Jeremy Bullock f15907
  while (it != m_pictureStyleMap.end()) {
Jeremy Bullock f15907
    if (it->second == style.toStdString()) {
Jeremy Bullock f15907
      value = it->first;
Jeremy Bullock f15907
      break;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    it++;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_PictureStyle, 0, sizeof(value),
Jeremy Bullock f15907
                           &value);
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_PictureStyle, 0, sizeof(value),
Jeremy Bullock f15907
                           &value);
Jeremy Bullock f15907
  emit(pictureStyleChangedSignal(style));
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::setColorTemperature(QString temp) {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsUInt32 value;
Jeremy Bullock f15907
  value = temp.toInt();
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_ColorTemperature, 0,
Jeremy Bullock f15907
                           sizeof(value), &value);
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_ColorTemperature, 0,
Jeremy Bullock f15907
                           sizeof(value), &value);
Jeremy Bullock f15907
  emit(colorTemperatureChangedSignal(temp));
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::downloadImage(EdsBaseRef object) {
Jeremy Bullock f15907
  EdsError err        = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsStreamRef stream = NULL;
Jeremy Bullock f15907
  EdsDirectoryItemInfo dirItemInfo;
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetDirectoryItemInfo(object, &dirItemInfo);
Jeremy Bullock f15907
  err = EdsCreateMemoryStream(0, &stream);
Jeremy Bullock f15907
  err = EdsDownload(object, dirItemInfo.size, stream);
Jeremy Bullock f15907
  EdsDownloadComplete(object);
Jeremy Bullock f15907
Jeremy Bullock f15907
  // tj code
Jeremy Bullock f15907
Jeremy Bullock f15907
  unsigned __int64 mySize = 0;
Jeremy Bullock f15907
  unsigned char *data     = NULL;
Jeremy Bullock f15907
  err                     = EdsGetPointer(stream, (EdsVoid **)&data);
Jeremy Bullock f15907
  err                     = EdsGetLength(stream, &mySize);
Jeremy Bullock f15907
Jeremy Bullock f15907
  int width, height, pixelFormat;
Jeremy Bullock f15907
  // long size;
Jeremy Bullock f15907
  int inSubsamp, inColorspace;
Jeremy Bullock f15907
  // unsigned long jpegSize;
Jeremy Bullock f15907
  tjhandle tjInstance   = NULL;
Jeremy Bullock f15907
  unsigned char *imgBuf = NULL;
Jeremy Bullock f15907
  tjInstance            = tjInitDecompress();
Jeremy Bullock f15907
  tjDecompressHeader3(tjInstance, data, mySize, &width, &height, &inSubsamp,
Jeremy Bullock f15907
                      &inColorspace);
Jeremy Bullock f15907
Jeremy Bullock f15907
  pixelFormat = TJPF_BGRX;
Jeremy Bullock f15907
  imgBuf = (unsigned char *)tjAlloc(width * height * tjPixelSize[pixelFormat]);
Jeremy Bullock f15907
  int flags = 0;
Jeremy Bullock f15907
#ifdef WIN32
Jeremy Bullock f15907
  flags |= TJFLAG_BOTTOMUP;
Jeremy Bullock f15907
#endif
Jeremy Bullock f15907
  int tempWidth, tempHeight;
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (m_useScaledImages) {
Jeremy Bullock f15907
    int factorsNum;
Jeremy Bullock f15907
    tjscalingfactor scalingFactor = {1, 1};
Jeremy Bullock f15907
    tjscalingfactor *factor       = tjGetScalingFactors(&factorsNum);
Jeremy Bullock f15907
    int intRatio                  = (float)width / (float)height * 100.0;
Jeremy Bullock f15907
    int i                         = 0;
Jeremy Bullock f15907
Jeremy Bullock f15907
    TCamera *camera =
Jeremy Bullock f15907
        TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
Jeremy Bullock f15907
    TDimension res = camera->getRes();
Jeremy Bullock f15907
Jeremy Bullock f15907
    // find the scaling factor that is at least as big as the current camera
Jeremy Bullock f15907
    while (i < factorsNum) {
Jeremy Bullock f15907
      scalingFactor = factor[i];
Jeremy Bullock f15907
      tempWidth     = TJSCALED(width, scalingFactor);
Jeremy Bullock f15907
      if (tempWidth < res.lx && i > 0) {
Jeremy Bullock f15907
        scalingFactor = factor[i - 1];
Jeremy Bullock f15907
        break;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      i++;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    // make sure the scaling factor has the right aspect ratio
Jeremy Bullock f15907
    while (i >= 0) {
Jeremy Bullock f15907
      tempWidth  = TJSCALED(width, scalingFactor);
Jeremy Bullock f15907
      tempHeight = TJSCALED(height, scalingFactor);
Jeremy Bullock f15907
      if ((int)((float)tempWidth / (float)tempHeight * 100.0) == intRatio) {
Jeremy Bullock f15907
        break;
Jeremy Bullock f15907
      }
Jeremy Bullock f15907
      i--;
Jeremy Bullock f15907
      scalingFactor = factor[i];
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  } else {
Jeremy Bullock f15907
    tempWidth  = width;
Jeremy Bullock f15907
    tempHeight = height;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (m_useScaledImages || !getCurrentImageQuality().contains("Large")) {
Jeremy Bullock f15907
    TCamera *camera =
Jeremy Bullock f15907
        TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
Jeremy Bullock f15907
    TDimensionD size       = camera->getSize();
Jeremy Bullock f15907
    m_proxyImageDimensions = TDimension(tempWidth, tempHeight);
Jeremy Bullock f15907
    double minimumDpi      = std::min(m_proxyImageDimensions.lx / size.lx,
Jeremy Bullock f15907
                                 m_proxyImageDimensions.ly / size.ly);
shun-iwasawa 2c27a4
    m_proxyDpi             = TPointD(minimumDpi, minimumDpi);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  tjDecompress2(tjInstance, data, mySize, imgBuf, tempWidth,
Jeremy Bullock f15907
                tempWidth * tjPixelSize[pixelFormat], tempHeight, pixelFormat,
Jeremy Bullock f15907
                flags);
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_newImage = TRaster32P(tempWidth, tempHeight);
Jeremy Bullock f15907
  m_newImage->lock();
Jeremy Bullock f15907
  uchar *rawData = m_newImage->getRawData();
Jeremy Bullock f15907
  memcpy(rawData, imgBuf, tempWidth * tempHeight * tjPixelSize[pixelFormat]);
Jeremy Bullock f15907
  m_newImage->unlock();
Jeremy Bullock f15907
Jeremy Bullock f15907
  tjFree(imgBuf);
Jeremy Bullock f15907
  imgBuf = NULL;
Jeremy Bullock f15907
  tjDestroy(tjInstance);
Jeremy Bullock f15907
  tjInstance = NULL;
Jeremy Bullock f15907
Jeremy Bullock f15907
  // end tj code
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (m_useScaledImages) {
Jeremy Bullock f15907
    QFile fullImage(m_tempFile);
Jeremy Bullock f15907
    fullImage.open(QIODevice::WriteOnly);
Jeremy Bullock f15907
    QDataStream dataStream(&fullImage);
Jeremy Bullock f15907
    dataStream.writeRawData((const char *)data, mySize);
Jeremy Bullock f15907
    fullImage.close();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  EdsRelease(stream);
Jeremy Bullock f15907
  stream = NULL;
Jeremy Bullock f15907
  if (object) EdsRelease(object);
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (err == EDS_ERR_OK) {
Jeremy Bullock f15907
    emit(newImageReady());
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::takePicture() {
Jeremy Bullock f15907
  EdsError err;
Jeremy Bullock f15907
  err = EdsSendCommand(m_camera, kEdsCameraCommand_PressShutterButton,
Jeremy Bullock f15907
                       kEdsCameraCommand_ShutterButton_Completely_NonAF);
Jeremy Bullock f15907
  err = EdsSendCommand(m_camera, kEdsCameraCommand_PressShutterButton,
Jeremy Bullock f15907
                       kEdsCameraCommand_ShutterButton_OFF);
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::startLiveView() {
Jeremy Bullock f15907
  if (m_camera && m_sessionOpen) {
Jeremy Bullock f15907
    EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
    // Get the output device for the live view image
Jeremy Bullock f15907
    EdsUInt32 device;
Jeremy Bullock f15907
    err = EdsGetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
Jeremy Bullock f15907
                             sizeof(device), &device);
Jeremy Bullock f15907
    // PC live view starts by setting the PC as the output device for the live
Jeremy Bullock f15907
    // view image.
Jeremy Bullock f15907
    if (err == EDS_ERR_OK) {
Jeremy Bullock f15907
      device |= kEdsEvfOutputDevice_PC;
Jeremy Bullock f15907
      err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
Jeremy Bullock f15907
                               sizeof(device), &device);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    if (err == EDS_ERR_OK) {
Jeremy Bullock f15907
      m_liveViewStatus = LiveViewStarting;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    // A property change event notification is issued from the camera if
Jeremy Bullock f15907
    // property settings are made successfully. Start downloading of the live
Jeremy Bullock f15907
    // view image once the property change notification arrives.
Jeremy Bullock f15907
    return err;
Jeremy Bullock f15907
  } else
Jeremy Bullock f15907
    return EDS_ERR_DEVICE_NOT_FOUND;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::endLiveView() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  // Get the output device for the live view image
Jeremy Bullock f15907
  EdsUInt32 device;
Jeremy Bullock f15907
  err = EdsGetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
Jeremy Bullock f15907
                           sizeof(device), &device);
Jeremy Bullock f15907
  // PC live view ends if the PC is disconnected from the live view image output
Jeremy Bullock f15907
  // device.
Jeremy Bullock f15907
  if (err == EDS_ERR_OK) {
Jeremy Bullock f15907
    device &= ~kEdsEvfOutputDevice_PC;
Jeremy Bullock f15907
    err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
Jeremy Bullock f15907
                             sizeof(device), &device);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  m_liveViewStatus = LiveViewClosed;
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::zoomLiveView() {
Jeremy Bullock f15907
  if (!m_sessionOpen) return EDS_ERR_DEVICE_INVALID;
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (m_liveViewZoom == 1) {
Jeremy Bullock f15907
    m_liveViewZoom = 5;
Jeremy Bullock f15907
    m_zooming      = true;
Jeremy Bullock f15907
  } else if (m_liveViewZoom == 5) {
Jeremy Bullock f15907
    m_liveViewZoom = 1;
Jeremy Bullock f15907
    m_zooming      = false;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_Zoom, 0,
Jeremy Bullock f15907
                           sizeof(m_liveViewZoom), &m_liveViewZoom);
Jeremy Bullock f15907
  if (m_liveViewZoom == 5) setZoomPoint();
Jeremy Bullock f15907
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::makeZoomPoint(TPointD pos) {
Jeremy Bullock f15907
  m_liveViewZoomPickPoint = pos;
Jeremy Bullock f15907
  double maxFullWidth =
Jeremy Bullock f15907
      (double)m_fullImageDimensions.lx / m_fullImageDpi.x * Stage::inch;
Jeremy Bullock f15907
  double maxFullHeight =
Jeremy Bullock f15907
      (double)m_fullImageDimensions.ly / m_fullImageDpi.y * Stage::inch;
Jeremy Bullock f15907
  double newX             = m_liveViewZoomPickPoint.x + maxFullWidth / 2.0;
Jeremy Bullock f15907
  double newY             = -m_liveViewZoomPickPoint.y + maxFullHeight / 2.0;
Jeremy Bullock f15907
  m_calculatedZoomPoint.x = newX / Stage::inch * m_fullImageDpi.x;
Jeremy Bullock f15907
  m_calculatedZoomPoint.y = newY / Stage::inch * m_fullImageDpi.x;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::setZoomPoint() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
Jeremy Bullock f15907
  EdsPoint zoomPoint;
Jeremy Bullock f15907
  if (m_liveViewZoomPickPoint == TPointD(0.0, 0.0)) {
Jeremy Bullock f15907
    m_calculatedZoomPoint =
Jeremy Bullock f15907
        TPoint(m_fullImageDimensions.lx / 2, m_fullImageDimensions.ly / 2);
Jeremy Bullock f15907
    m_finalZoomPoint.x = m_calculatedZoomPoint.x - (m_zoomRect.x / 2);
Jeremy Bullock f15907
    m_finalZoomPoint.y = m_calculatedZoomPoint.y - (m_zoomRect.y / 2);
Jeremy Bullock f15907
  } else {
Jeremy Bullock f15907
    m_finalZoomPoint.x = m_calculatedZoomPoint.x - (m_zoomRect.x / 2);
Jeremy Bullock f15907
    m_finalZoomPoint.y = m_calculatedZoomPoint.y - (m_zoomRect.y / 2);
Jeremy Bullock f15907
    if (m_finalZoomPoint.x < 0) m_finalZoomPoint.x = 0;
Jeremy Bullock f15907
    if (m_finalZoomPoint.y < 0) m_finalZoomPoint.y = 0;
Jeremy Bullock f15907
    if (m_finalZoomPoint.x > m_fullImageDimensions.lx - (m_zoomRect.x)) {
Jeremy Bullock f15907
      m_finalZoomPoint.x = m_fullImageDimensions.lx - (m_zoomRect.x);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    if (m_finalZoomPoint.y > m_fullImageDimensions.ly - (m_zoomRect.y)) {
Jeremy Bullock f15907
      m_finalZoomPoint.y = m_fullImageDimensions.ly - (m_zoomRect.y);
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  zoomPoint.x = m_finalZoomPoint.x;
Jeremy Bullock f15907
  zoomPoint.y = m_finalZoomPoint.y;
Jeremy Bullock f15907
Jeremy Bullock f15907
  // make sure this is set AFTER starting zoom
Jeremy Bullock f15907
  err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_ZoomPosition, 0,
Jeremy Bullock f15907
                           sizeof(zoomPoint), &zoomPoint);
Jeremy Bullock f15907
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::downloadEVFData() {
Jeremy Bullock f15907
  EdsError err            = EDS_ERR_OK;
Jeremy Bullock f15907
  EdsStreamRef stream     = NULL;
Jeremy Bullock f15907
  EdsEvfImageRef evfImage = NULL;
Jeremy Bullock f15907
Jeremy Bullock f15907
  // Create memory stream.
Jeremy Bullock f15907
  err = EdsCreateMemoryStream(0, &stream);
Jeremy Bullock f15907
  // Create EvfImageRef.
Jeremy Bullock f15907
  if (err == EDS_ERR_OK) {
Jeremy Bullock f15907
    err = EdsCreateEvfImageRef(stream, &evfImage);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  // Download live view image data.
Jeremy Bullock f15907
  if (err == EDS_ERR_OK) {
Jeremy Bullock f15907
    err = EdsDownloadEvfImage(m_camera, evfImage);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  EdsDataType evfZoom;
Jeremy Bullock f15907
  EdsDataType evfZoomPos;
Jeremy Bullock f15907
  EdsDataType evfZoomRect;
Jeremy Bullock f15907
  EdsUInt32 size;
Jeremy Bullock f15907
  EdsUInt32 sizePos;
Jeremy Bullock f15907
  EdsUInt32 sizeRect;
Jeremy Bullock f15907
  EdsUInt32 sizeImagePos;
Jeremy Bullock f15907
  EdsUInt32 sizeCoordSys;
Jeremy Bullock f15907
  EdsUInt32 zoomAmount;
Jeremy Bullock f15907
  EdsPoint zoomPos;
Jeremy Bullock f15907
  EdsRect zoomRect;
Jeremy Bullock f15907
  EdsPoint imagePos;
Jeremy Bullock f15907
  EdsSize coordSys;
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_Zoom, 0, &evfZoom, &size);
Jeremy Bullock f15907
  err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_Zoom, 0, sizeof(size),
Jeremy Bullock f15907
                           &zoomAmount);
Jeremy Bullock f15907
Jeremy Bullock f15907
  // this is the top corner? of the zoomed image
Jeremy Bullock f15907
  err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_ZoomPosition, 0,
Jeremy Bullock f15907
                           &evfZoomPos, &sizePos);
Jeremy Bullock f15907
  err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomPosition, 0, sizePos,
Jeremy Bullock f15907
                           &zoomPos);
Jeremy Bullock f15907
  // this is the top corner of the zoomed image and the size of the zoomed image
Jeremy Bullock f15907
  err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_ZoomRect, 0, &evfZoomRect,
Jeremy Bullock f15907
                           &sizeRect);
Jeremy Bullock f15907
  err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomRect, 0, sizeRect,
Jeremy Bullock f15907
                           &zoomRect);
Jeremy Bullock f15907
Jeremy Bullock f15907
  err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_ImagePosition, 0,
Jeremy Bullock f15907
                           &evfZoomRect, &sizeImagePos);
Jeremy Bullock f15907
  err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_ImagePosition, 0,
Jeremy Bullock f15907
                           sizeImagePos, &imagePos);
Jeremy Bullock f15907
  // this returns the size of the full image
Jeremy Bullock f15907
  err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_CoordinateSystem, 0,
Jeremy Bullock f15907
                           &evfZoomRect, &sizeCoordSys);
Jeremy Bullock f15907
  err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_CoordinateSystem, 0,
Jeremy Bullock f15907
                           sizeCoordSys, &coordSys);
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_zoomRect = TPoint(zoomRect.size.width, zoomRect.size.height);
Jeremy Bullock f15907
  if (zoomAmount == 5 && m_zoomRect == TPoint(0, 0)) {
Jeremy Bullock f15907
    setZoomPoint();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  // Get the incidental data of the image.
Jeremy Bullock f15907
  if (err == EDS_ERR_OK) {
Jeremy Bullock f15907
    JpgConverter *converter = new JpgConverter;
Jeremy Bullock f15907
    converter->setStream(stream);
Jeremy Bullock f15907
    converter->setScale(m_useScaledImages);
Jeremy Bullock f15907
Jeremy Bullock f15907
    connect(converter, SIGNAL(imageReady(bool)), this, SLOT(onImageReady(bool)),
Jeremy Bullock f15907
            Qt::QueuedConnection);
Jeremy Bullock f15907
    connect(converter, SIGNAL(finished()), this, SLOT(onFinished()),
Jeremy Bullock f15907
            Qt::QueuedConnection);
Jeremy Bullock f15907
Jeremy Bullock f15907
    converter->start();
Jeremy Bullock f15907
Jeremy Bullock f15907
    while (!l_quitLoop)
Jeremy Bullock f15907
      QCoreApplication::processEvents(QEventLoop::AllEvents |
Jeremy Bullock f15907
                                      QEventLoop::WaitForMoreEvents);
Jeremy Bullock f15907
Jeremy Bullock f15907
    l_quitLoop         = false;
Jeremy Bullock f15907
    m_liveViewImage    = converter->getImage();
Jeremy Bullock f15907
    m_hasLiveViewImage = true;
Jeremy Bullock f15907
    delete converter;
Jeremy Bullock f15907
    if (!m_converterSucceeded) return EDS_ERR_UNEXPECTED_EXCEPTION;
Jeremy Bullock f15907
Jeremy Bullock f15907
    // make sure not to set to LiveViewOpen if it has been turned off
Jeremy Bullock f15907
    if (m_liveViewStatus > 0) {
Jeremy Bullock f15907
      m_liveViewStatus = LiveViewOpen;
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
    emit(newLiveViewImageReady());
Jeremy Bullock f15907
Jeremy Bullock f15907
    if (m_hasLiveViewImage &&
Jeremy Bullock f15907
        (m_liveViewDpi.x == 0.0 || m_liveViewImageDimensions.lx == 0)) {
Jeremy Bullock f15907
      TCamera *camera =
Jeremy Bullock f15907
          TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
Jeremy Bullock f15907
      TDimensionD size = camera->getSize();
Jeremy Bullock f15907
      m_liveViewImageDimensions =
Jeremy Bullock f15907
          TDimension(m_liveViewImage->getLx(), m_liveViewImage->getLy());
Jeremy Bullock f15907
      double minimumDpi = std::min(m_liveViewImageDimensions.lx / size.lx,
Jeremy Bullock f15907
                                   m_liveViewImageDimensions.ly / size.ly);
shun-iwasawa 2c27a4
      m_liveViewDpi     = TPointD(minimumDpi, minimumDpi);
Jeremy Bullock f15907
Jeremy Bullock f15907
      m_fullImageDimensions = TDimension(coordSys.width, coordSys.height);
Jeremy Bullock f15907
      minimumDpi            = std::min(m_fullImageDimensions.lx / size.lx,
Jeremy Bullock f15907
                            m_fullImageDimensions.ly / size.ly);
shun-iwasawa 2c27a4
      m_fullImageDpi        = TPointD(minimumDpi, minimumDpi);
Jeremy Bullock f15907
Jeremy Bullock f15907
      emit(newDimensions());
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (stream != NULL) {
Jeremy Bullock f15907
    EdsRelease(stream);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  stream = NULL;
Jeremy Bullock f15907
  if (evfImage != NULL) {
Jeremy Bullock f15907
    EdsRelease(evfImage);
Jeremy Bullock f15907
    evfImage = NULL;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  // calculate dpi data
Jeremy Bullock f15907
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::focusNear() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  err          = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
Jeremy Bullock f15907
                       kEdsEvfDriveLens_Near1);
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::focusFar() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  err          = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
Jeremy Bullock f15907
                       kEdsEvfDriveLens_Far1);
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::focusNear2() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  err          = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
Jeremy Bullock f15907
                       kEdsEvfDriveLens_Near2);
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::focusFar2() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  err          = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
Jeremy Bullock f15907
                       kEdsEvfDriveLens_Far2);
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::focusNear3() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  err          = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
Jeremy Bullock f15907
                       kEdsEvfDriveLens_Near3);
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::focusFar3() {
Jeremy Bullock f15907
  EdsError err = EDS_ERR_OK;
Jeremy Bullock f15907
  err          = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
Jeremy Bullock f15907
                       kEdsEvfDriveLens_Far3);
Jeremy Bullock f15907
  return err;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::onImageReady(const bool &status) {
Jeremy Bullock f15907
  m_converterSucceeded = status;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::onFinished() { l_quitLoop = true; }
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::handleObjectEvent(EdsObjectEvent event, EdsBaseRef object,
Jeremy Bullock f15907
                                       EdsVoid *context) {
Jeremy Bullock f15907
  if (event == kEdsObjectEvent_DirItemRequestTransfer) {
Jeremy Bullock f15907
    instance()->downloadImage(object);
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  return EDS_ERR_OK;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::handlePropertyEvent(EdsPropertyEvent event,
Jeremy Bullock f15907
                                         EdsPropertyID property,
Jeremy Bullock f15907
                                         EdsUInt32 param, EdsVoid *context) {
Jeremy Bullock f15907
  if (property == kEdsPropID_Evf_OutputDevice &&
Jeremy Bullock f15907
      event == kEdsPropertyEvent_PropertyChanged) {
Jeremy Bullock f15907
    if (instance()->m_liveViewStatus == LiveViewStarting)
Jeremy Bullock f15907
      instance()->m_liveViewStatus = LiveViewOpen;
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (property == kEdsPropID_AEMode &&
Jeremy Bullock f15907
      event == kEdsPropertyEvent_PropertyChanged) {
Jeremy Bullock f15907
    emit(instance()->modeChanged());
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (property == kEdsPropID_Av &&
Jeremy Bullock f15907
      event == kEdsPropertyEvent_PropertyDescChanged) {
Jeremy Bullock f15907
    emit(instance()->apertureOptionsChanged());
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  if (property == kEdsPropID_Tv &&
Jeremy Bullock f15907
      event == kEdsPropertyEvent_PropertyDescChanged) {
Jeremy Bullock f15907
    emit(instance()->shutterSpeedOptionsChanged());
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (property == kEdsPropID_ISOSpeed &&
Jeremy Bullock f15907
      event == kEdsPropertyEvent_PropertyDescChanged) {
Jeremy Bullock f15907
    emit(instance()->isoOptionsChanged());
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (property == kEdsPropID_ExposureCompensation &&
Jeremy Bullock f15907
      event == kEdsPropertyEvent_PropertyDescChanged) {
Jeremy Bullock f15907
    emit(instance()->exposureOptionsChanged());
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (property == kEdsPropID_WhiteBalance &&
Jeremy Bullock f15907
      event == kEdsPropertyEvent_PropertyDescChanged) {
Jeremy Bullock f15907
    emit(instance()->whiteBalanceOptionsChanged());
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (property == kEdsPropID_PictureStyle &&
Jeremy Bullock f15907
      event == kEdsPropertyEvent_PropertyDescChanged) {
Jeremy Bullock f15907
    emit(instance()->pictureStyleOptionsChanged());
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  if (property == kEdsPropID_ImageQuality &&
Jeremy Bullock f15907
      event == kEdsPropertyEvent_PropertyDescChanged) {
Jeremy Bullock f15907
    emit(instance()->imageQualityOptionsChanged());
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
Jeremy Bullock f15907
  return EDS_ERR_OK;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::handleStateEvent(EdsStateEvent event, EdsUInt32 parameter,
Jeremy Bullock f15907
                                      EdsVoid *context) {
Jeremy Bullock f15907
  if (event == kEdsStateEvent_Shutdown) {
Jeremy Bullock f15907
    if (instance()->m_sessionOpen) {
Jeremy Bullock f15907
      instance()->closeCameraSession();
Jeremy Bullock f15907
      instance()->releaseCamera();
Jeremy Bullock f15907
      instance()->m_liveViewStatus = LiveViewClosed;
Jeremy Bullock f15907
      emit(instance()->cameraChanged());
Jeremy Bullock f15907
    }
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
  return EDS_ERR_OK;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
EdsError StopMotion::handleCameraAddedEvent(EdsVoid *context) {
Jeremy Bullock f15907
  instance()->cameraAdded();
Jeremy Bullock f15907
  return EDS_ERR_OK;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::buildAvMap() {
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x00, "00"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x08, "1"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x0B, "1.1"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x0C, "1.2"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x0D, "1.2"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x10, "1.4"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x13, "1.6"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x14, "1.8"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x15, "1.8"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x18, "2"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x1B, "2.2"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x1C, "2.5"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x1D, "2.5"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x20, "2.8"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x23, "3.2"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x24, "3.5"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x25, "3.5"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x28, "4"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x2B, "4.5"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x2C, "4.5"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x2D, "5.0"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x30, "5.6"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x33, "6.3"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x34, "6.7"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x35, "7.1"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x38, "8"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x3B, "9"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x3C, "9.5"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x3D, "10"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x40, "11"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x43, "13"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x44, "13"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x45, "14"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x48, "16"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x4B, "18"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x4C, "19"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x4D, "20"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x50, "22"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x53, "25"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x54, "27"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x55, "29"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x58, "32"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x5B, "36"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x5C, "38"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x5D, "40"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x60, "45"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x63, "51"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x64, "54"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x65, "57"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x68, "64"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x6B, "72"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x6C, "76"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x6D, "80"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0x70, "91"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0xFF, "Auto"));</edsuint32,>
Jeremy Bullock f15907
  m_avMap.insert(std::pair<edsuint32, *="" char="" const="">(0xffffffff, "unknown"));</edsuint32,>
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::buildIsoMap() {
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x00, "Auto"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x28, "6"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x30, "12"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x38, "25"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x40, "50"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x48, "100"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x4b, "125"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x4d, "160"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x50, "200"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x53, "250"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x55, "320"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x58, "400"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x5b, "500"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x5d, "640"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x60, "800"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x63, "1000"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x65, "1250"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x68, "1600"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x6b, "2000"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x6d, "2500"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x70, "3200"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x73, "4000"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x75, "5000"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x78, "6400"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x7b, "8000"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x7d, "10000"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x80, "12800"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x83, "16000"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x85, "20000"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x88, "25600"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x8b, "32000"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x8d, "40000"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x90, "51200"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0x98, "102400"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0xa0, "204800"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0xa8, "409600"));</edsuint32,>
Jeremy Bullock f15907
  m_isoMap.insert(std::pair<edsuint32, *="" char="" const="">(0xffffffff, "unknown"));</edsuint32,>
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::buildTvMap() {
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x04, "Auto"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x0c, "Bulb"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x10, "30\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x13, "25\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x14, "20\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x15, "20\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x18, "15\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x1B, "13\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x1C, "10\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x1D, "10\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x20, "8\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x23, "6\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x24, "6\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x25, "5\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x28, "4\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x2B, "3\"2"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x2C, "3\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x2D, "2\"5"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x30, "2\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x33, "1\"6"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x34, "1\"5"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x35, "1\"3"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x38, "1\""));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x3B, "0\"8"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x3C, "0\"7"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x3D, "0\"6"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x40, "0\"5"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x43, "0\"4"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x44, "0\"3"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x45, "0\"3"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x48, "1/4"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x4B, "1/5"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x4C, "1/6"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x4D, "1/6"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x50, "1/8"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x53, "1/10"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x54, "1/10"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x55, "1/13"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x58, "1/15"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x5B, "1/20"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x5C, "1/20"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x5D, "1/25"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x60, "1/30"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x63, "1/40"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x64, "1/45"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x65, "1/50"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x68, "1/60"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x6B, "1/80"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x6C, "1/90"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x6D, "1/100"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x70, "1/125"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x73, "1/160"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x74, "1/180"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x75, "1/200"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x78, "1/250"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x7B, "1/320"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x7C, "1/350"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x7D, "1/400"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x80, "1/500"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x83, "1/640"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x84, "1/750"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x85, "1/800"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x88, "1/1000"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x8B, "1/1250"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x8C, "1/1500"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x8D, "1/1600"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x90, "1/2000"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x93, "1/2500"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x94, "1/3000"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x95, "1/3200"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x98, "1/4000"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x9B, "1/5000"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x9C, "1/6000"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0x9D, "1/6400"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0xA0, "1/8000"));</edsuint32,>
Jeremy Bullock f15907
  m_tvMap.insert(std::pair<edsuint32, *="" char="" const="">(0xffffffff, "unknown"));</edsuint32,>
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::buildModeMap() {
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(0, "P"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(1, "Tv"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(2, "Av"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(3, "M"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(55, "FV"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(4, "Bulb"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(5, "A-DEP"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(6, "DEP"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(7, "C1"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(16, "C2"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(17, "C3"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(8, "Lock"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(9, "GreenMode"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(10, "Night Portrait"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(11, "Sports"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(13, "LandScape"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(14, "Close-Up"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(15, "No Strobo"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(12, "Portrait"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(19, "Creative Auto"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(20, "Movies"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(25, "SCN"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(22, "Scene Intelligent Auto"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(29, "Creative filters"));</edsuint32,>
Jeremy Bullock f15907
  m_modeMap.insert(std::pair<edsuint32, *="" char="" const="">(0xffffffff, "unknown"));</edsuint32,>
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::buildExposureMap() {
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x28, "+5"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x25, "+4 2/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x24, "+4 1/2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x23, "+4 1/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x20, "+4"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x1D, "+3 2/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x1C, "+3 1/2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x1B, "+3 1/3"));</edsuint32,>
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x18, "+3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x15, "+2 2/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x14, "+2 1/2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x13, "+2 1/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x10, "+2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x0d, "+1 2/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x0c, "+1 1/2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x0b, "+1 1/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x08, "+1"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x05, "+2/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x04, "+1/2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x03, "+1/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0x00, "0"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xfd, "-1/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xfc, "-1/2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xfb, "-2/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xf8, "-1"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xf5, "-1 1/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xf4, "-1 1/2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xf3, "-1 2/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xf0, "-2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xed, "-2 1/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xec, "-2 1/2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xeb, "-2 2/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xe8, "-3"));</edsuint32,>
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xE5, "-3 1/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xE4, "-3 1/2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xE3, "-3 2/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xE0, "-4"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xDD, "-4 1/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xDC, "-4 1/2"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xDB, "-4 2/3"));</edsuint32,>
Jeremy Bullock f15907
  m_exposureMap.insert(std::pair<edsuint32, *="" char="" const="">(0xD8, "-5"));</edsuint32,>
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_exposureMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(0xffffffff, "unknown"));</edsuint32,>
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::buildWhiteBalanceMap() {
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(0, "Auto: Ambience Priority"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(1, "Daylight"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(2, "Cloudy"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(3, "Tungsten"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(4, "Fluorescent"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(5, "Flash"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(6, "Manual"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(8, "Shade"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(9, "Color Temperature"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(10, "Custom 1"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(11, "Custom 2"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(12, "Custom 3"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(15, "Manual 2"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(16, "Manual 3"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(18, "Manual 4"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(19, "Manual 5"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(20, "Custom 4"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(std::pair<edsuint32, *="" char="" const="">(21, "Custom 5"));</edsuint32,>
Jeremy Bullock f15907
  m_whiteBalanceMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(23, "Auto: White Priority"));</edsuint32,>
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::buildImageQualityMap() {
Jeremy Bullock f15907
  m_imageQualityMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(EdsImageQuality_LR, "RAW"));</edsuint32,>
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRLJF, "RAW + Large Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRMJF, "RAW + Middle Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRSJF, "RAW + Small Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRLJN, "RAW + Large Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRMJN, "RAW + Middle Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRSJN, "RAW + Small Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRS1JF, "RAW + Small1 Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRS1JN, "RAW + Small1 Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRS2JF, "RAW + Small2 Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRS3JF, "RAW + Small3 Jpeg"));
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRLJ, "RAW + Large Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRM1J, "RAW + Middle1 Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRM2J, "RAW + Middle2 Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LRSJ, "RAW + Small Jpeg"));
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MR, "Middle Raw(Small RAW1)"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRLJF, "Middle Raw(Small RAW1) + Large Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRMJF, "Middle Raw(Small RAW1) + Middle Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRSJF, "Middle Raw(Small RAW1) + Small Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRLJN, "Middle Raw(Small RAW1) + Large Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRMJN, "Middle Raw(Small RAW1) + Middle Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRSJN, "Middle Raw(Small RAW1) + Small Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRS1JF, "Middle RAW + Small1 Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRS1JN, "Middle RAW + Small1 Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRS2JF, "Middle RAW + Small2 Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRS3JF, "Middle RAW + Small3 Jpeg"));
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRLJ, "Middle Raw + Large Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRM1J, "Middle Raw + Middle1 Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRM2J, "Middle Raw + Middle2 Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MRSJ, "Middle Raw + Small Jpeg"));
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SR, "Small RAW(Small RAW2)"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRLJF, "Small RAW(Small RAW2) + Large Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRMJF, "Small RAW(Small RAW2) + Middle Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRSJF, "Small RAW(Small RAW2) + Small Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRLJN, "Small RAW(Small RAW2) + Large Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRMJN, "Small RAW(Small RAW2) + Middle Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRSJN, "Small RAW(Small RAW2) + Small Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRS1JF, "Small RAW + Small1 Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRS1JN, "Small RAW + Small1 Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRS2JF, "Small RAW + Small2 Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRS3JF, "Small RAW + Small3 Jpeg"));
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRLJ, "Small RAW + Large Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRM1J, "Small RAW + Middle1 Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRM2J, "Small RAW + Middle2 Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SRSJ, "Small RAW + Small Jpeg"));
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_imageQualityMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(EdsImageQuality_CR, "CRAW"));</edsuint32,>
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRLJF, "CRAW + Large Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRMJF, "CRAW + Middle Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRM1JF, "CRAW + Middle1 Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRM2JF, "CRAW + Middle2 Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRSJF, "CRAW + Small Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRS1JF, "CRAW + Small1 Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRS2JF, "CRAW + Small2 Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRS3JF, "CRAW + Small3 Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRLJN, "CRAW + Large Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRMJN, "CRAW + Middle Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRM1JN, "CRAW + Middle1 Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRM2JN, "CRAW + Middle2 Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRSJN, "CRAW + Small Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRS1JN, "CRAW + Small1 Normal Jpeg"));
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRLJ, "CRAW + Large Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRM1J, "CRAW + Middle1 Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRM2J, "CRAW + Middle2 Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_CRSJ, "CRAW + Small Jpeg"));
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LJF, "Large Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_LJN, "Large Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MJF, "Middle Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_MJN, "Middle Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SJF, "Small Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_SJN, "Small Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_S1JF, "Small1 Fine Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      EdsImageQuality_S1JN, "Small1 Normal Jpeg"));
Jeremy Bullock f15907
  m_imageQualityMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(EdsImageQuality_S2JF, "Small2 Jpeg"));</edsuint32,>
Jeremy Bullock f15907
  m_imageQualityMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(EdsImageQuality_S3JF, "Small3 Jpeg"));</edsuint32,>
Jeremy Bullock f15907
Jeremy Bullock f15907
  m_imageQualityMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(EdsImageQuality_LJ, "Large Jpeg"));</edsuint32,>
Jeremy Bullock f15907
  m_imageQualityMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(EdsImageQuality_M1J, "Middle1 Jpeg"));</edsuint32,>
Jeremy Bullock f15907
  m_imageQualityMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(EdsImageQuality_M2J, "Middle2 Jpeg"));</edsuint32,>
Jeremy Bullock f15907
  m_imageQualityMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(EdsImageQuality_SJ, "Small Jpeg"));</edsuint32,>
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
Jeremy Bullock f15907
void StopMotion::buildPictureStyleMap() {
Jeremy Bullock f15907
  m_pictureStyleMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      kEdsPictureStyle_Standard, "Standard"));
Jeremy Bullock f15907
  m_pictureStyleMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      kEdsPictureStyle_Portrait, "Portrait"));
Jeremy Bullock f15907
  m_pictureStyleMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      kEdsPictureStyle_Landscape, "Landscape"));
Jeremy Bullock f15907
  m_pictureStyleMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(kEdsPictureStyle_Neutral, "Neutral"));</edsuint32,>
Jeremy Bullock f15907
  m_pictureStyleMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      kEdsPictureStyle_Faithful, "Faithful"));
Jeremy Bullock f15907
  m_pictureStyleMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      kEdsPictureStyle_Monochrome, "Monochrome"));
Jeremy Bullock f15907
  m_pictureStyleMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(kEdsPictureStyle_Auto, "Auto"));</edsuint32,>
Jeremy Bullock f15907
  m_pictureStyleMap.insert(std::pair<edsuint32, *="" char="" const="">(</edsuint32,>
Jeremy Bullock f15907
      kEdsPictureStyle_FineDetail, "Fine Detail"));
Jeremy Bullock f15907
  m_pictureStyleMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(kEdsPictureStyle_User1, "User 1"));</edsuint32,>
Jeremy Bullock f15907
  m_pictureStyleMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(kEdsPictureStyle_User2, "User 2"));</edsuint32,>
Jeremy Bullock f15907
  m_pictureStyleMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(kEdsPictureStyle_User3, "User 3"));</edsuint32,>
Jeremy Bullock f15907
  m_pictureStyleMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(kEdsPictureStyle_PC1, "Computer 1"));</edsuint32,>
Jeremy Bullock f15907
  m_pictureStyleMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(kEdsPictureStyle_PC2, "Computer 2"));</edsuint32,>
Jeremy Bullock f15907
  m_pictureStyleMap.insert(
Jeremy Bullock f15907
      std::pair<edsuint32, *="" char="" const="">(kEdsPictureStyle_PC3, "Computer 3"));</edsuint32,>
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
std::string StopMotion::getTEnvCameraName() { return StopMotionCameraName; }
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
void StopMotion::setTEnvCameraName(std::string name) {
Jeremy Bullock f15907
  StopMotionCameraName = name;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
std::string StopMotion::getTEnvCameraResolution() {
Jeremy Bullock f15907
  return StopMotionCameraResolution;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
//-----------------------------------------------------------------
Jeremy Bullock f15907
void StopMotion::setTEnvCameraResolution(std::string resolution) {
Jeremy Bullock f15907
  StopMotionCameraResolution = resolution;
Jeremy Bullock f15907
}
Jeremy Bullock f15907
Jeremy Bullock f15907
//=============================================================================
Jeremy Bullock f15907
Jeremy Bullock f15907
class StopMotionCaptureCommand : public MenuItemHandler {
Jeremy Bullock f15907
public:
Jeremy Bullock f15907
  StopMotionCaptureCommand() : MenuItemHandler(MI_StopMotionCapture) {}
Jeremy Bullock f15907
  void execute() {
Jeremy Bullock f15907
    StopMotion *sm = StopMotion::instance();
Jeremy Bullock f15907
    if (sm->m_liveViewStatus > 0) sm->captureImage();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
} StopMotionCaptureCommand;
Jeremy Bullock f15907
Jeremy Bullock f15907
//=============================================================================
Jeremy Bullock f15907
Jeremy Bullock f15907
class StopMotionRaiseOpacityCommand : public MenuItemHandler {
Jeremy Bullock f15907
public:
Jeremy Bullock f15907
  StopMotionRaiseOpacityCommand()
Jeremy Bullock f15907
      : MenuItemHandler(MI_StopMotionRaiseOpacity) {}
Jeremy Bullock f15907
  void execute() {
Jeremy Bullock f15907
    StopMotion *sm = StopMotion::instance();
Jeremy Bullock f15907
    if (sm->m_liveViewStatus > 0) sm->raiseOpacity();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
} StopMotionRaiseOpacityCommand;
Jeremy Bullock f15907
Jeremy Bullock f15907
//=============================================================================
Jeremy Bullock f15907
Jeremy Bullock f15907
class StopMotionLowerOpacityCommand : public MenuItemHandler {
Jeremy Bullock f15907
public:
Jeremy Bullock f15907
  StopMotionLowerOpacityCommand()
Jeremy Bullock f15907
      : MenuItemHandler(MI_StopMotionLowerOpacity) {}
Jeremy Bullock f15907
  void execute() {
Jeremy Bullock f15907
    StopMotion *sm = StopMotion::instance();
Jeremy Bullock f15907
    if (sm->m_liveViewStatus > 0) sm->lowerOpacity();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
} StopMotionLowerOpacityCommand;
Jeremy Bullock f15907
Jeremy Bullock f15907
//=============================================================================
Jeremy Bullock f15907
Jeremy Bullock f15907
class StopMotionToggleLiveViewCommand : public MenuItemHandler {
Jeremy Bullock f15907
public:
Jeremy Bullock f15907
  StopMotionToggleLiveViewCommand()
Jeremy Bullock f15907
      : MenuItemHandler(MI_StopMotionToggleLiveView) {}
Jeremy Bullock f15907
  void execute() {
Jeremy Bullock f15907
    StopMotion *sm = StopMotion::instance();
Jeremy Bullock f15907
    sm->pauseLiveView();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
} StopMotionToggleLiveViewCommand;
Jeremy Bullock f15907
Jeremy Bullock f15907
//=============================================================================
Jeremy Bullock f15907
Jeremy Bullock f15907
class StopMotionToggleZoomCommand : public MenuItemHandler {
Jeremy Bullock f15907
public:
Jeremy Bullock f15907
  StopMotionToggleZoomCommand() : MenuItemHandler(MI_StopMotionToggleZoom) {}
Jeremy Bullock f15907
  void execute() {
Jeremy Bullock f15907
    StopMotion *sm = StopMotion::instance();
Jeremy Bullock f15907
    sm->zoomLiveView();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
} StopMotionToggleZoomCommand;
Jeremy Bullock f15907
Jeremy Bullock f15907
//=============================================================================
Jeremy Bullock f15907
Jeremy Bullock f15907
class StopMotionLowerSubsamplingCommand : public MenuItemHandler {
Jeremy Bullock f15907
public:
Jeremy Bullock f15907
  StopMotionLowerSubsamplingCommand()
Jeremy Bullock f15907
      : MenuItemHandler(MI_StopMotionLowerSubsampling) {}
Jeremy Bullock f15907
  void execute() {
Jeremy Bullock f15907
    StopMotion *sm = StopMotion::instance();
Jeremy Bullock f15907
    sm->setSubsamplingValue(std::max(1, sm->getSubsamplingValue() - 1));
Jeremy Bullock f15907
    sm->setSubsampling();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
} StopMotionLowerSubsamplingCommand;
Jeremy Bullock f15907
Jeremy Bullock f15907
//=============================================================================
Jeremy Bullock f15907
Jeremy Bullock f15907
class StopMotionRaiseSubsamplingCommand : public MenuItemHandler {
Jeremy Bullock f15907
public:
Jeremy Bullock f15907
  StopMotionRaiseSubsamplingCommand()
Jeremy Bullock f15907
      : MenuItemHandler(MI_StopMotionRaiseSubsampling) {}
Jeremy Bullock f15907
  void execute() {
Jeremy Bullock f15907
    StopMotion *sm = StopMotion::instance();
Jeremy Bullock f15907
    sm->setSubsamplingValue(std::min(30, sm->getSubsamplingValue() + 1));
Jeremy Bullock f15907
    sm->setSubsampling();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
} StopMotionRaiseSubsamplingCommand;
Jeremy Bullock f15907
Jeremy Bullock f15907
//=============================================================================
Jeremy Bullock f15907
Jeremy Bullock f15907
class StopMotionJumpToCameraCommand : public MenuItemHandler {
Jeremy Bullock f15907
public:
Jeremy Bullock f15907
  StopMotionJumpToCameraCommand()
Jeremy Bullock f15907
      : MenuItemHandler(MI_StopMotionJumpToCamera) {}
Jeremy Bullock f15907
  void execute() {
Jeremy Bullock f15907
    StopMotion *sm = StopMotion::instance();
Jeremy Bullock f15907
    sm->jumpToCameraFrame();
Jeremy Bullock f15907
  }
Jeremy Bullock f15907
} StopMotionJumpToCameraCommand;