shun-iwasawa 31accf
#pragma once
shun-iwasawa 31accf
shun-iwasawa 31accf
#ifndef CANON_H
shun-iwasawa 31accf
#define CANON_H
shun-iwasawa 31accf
shun-iwasawa 31accf
#ifdef WITH_CANON
shun-iwasawa 31accf
// Canon Includes
shun-iwasawa 31accf
#include "EDSDK.h"
shun-iwasawa 31accf
#include "EDSDKErrors.h"
shun-iwasawa 31accf
#include "EDSDKTypes.h"
shun-iwasawa 31accf
#endif
shun-iwasawa 31accf
shun-iwasawa 31accf
#include "turbojpeg.h"
shun-iwasawa 31accf
shun-iwasawa 31accf
// Toonz Includes
shun-iwasawa 31accf
#include "traster.h"
shun-iwasawa 31accf
#include "toonzqt/gutil.h"
shun-iwasawa 31accf
#include "toonzqt/dvdialog.h"
shun-iwasawa 31accf
shun-iwasawa 31accf
#include "jpgconverter.h"
shun-iwasawa 31accf
shun-iwasawa 31accf
#include <qobject></qobject>
shun-iwasawa 31accf
shun-iwasawa 31accf
class QCamera;
shun-iwasawa 31accf
class QCameraInfo;
shun-iwasawa 31accf
class QDialog;
shun-iwasawa 31accf
class QTimer;
shun-iwasawa 31accf
class QSerialPort;
shun-iwasawa 31accf
shun-iwasawa 31accf
#include <qthread></qthread>
shun-iwasawa 31accf
shun-iwasawa 31accf
class Canon : public QObject {
shun-iwasawa 31accf
  Q_OBJECT
shun-iwasawa 31accf
shun-iwasawa 31accf
public:
shun-iwasawa 31accf
  static Canon* instance() {
shun-iwasawa 31accf
    static Canon _instance;
shun-iwasawa 31accf
    return &_instance;
shun-iwasawa 31accf
  };
shun-iwasawa 31accf
shun-iwasawa 31accf
private:
shun-iwasawa 31accf
#ifdef WITH_CANON
shun-iwasawa 31accf
  std::map<edsuint32, std::string=""> m_avMap, m_tvMap, m_isoMap, m_modeMap,</edsuint32,>
shun-iwasawa 31accf
      m_exposureMap, m_whiteBalanceMap, m_imageQualityMap, m_pictureStyleMap;
shun-iwasawa 31accf
  JpgConverter* m_converter;
shun-iwasawa 31accf
  static EdsError EDSCALLBACK handleObjectEvent(EdsObjectEvent event,
shun-iwasawa 31accf
                                                EdsBaseRef object,
shun-iwasawa 31accf
                                                EdsVoid* context);
shun-iwasawa 31accf
shun-iwasawa 31accf
  static EdsError EDSCALLBACK handlePropertyEvent(EdsPropertyEvent event,
shun-iwasawa 31accf
                                                  EdsPropertyID property,
shun-iwasawa 31accf
                                                  EdsUInt32 param,
shun-iwasawa 31accf
                                                  EdsVoid* context);
shun-iwasawa 31accf
shun-iwasawa 31accf
  static EdsError EDSCALLBACK handleStateEvent(EdsStateEvent event,
shun-iwasawa 31accf
                                               EdsUInt32 parameter,
shun-iwasawa 31accf
                                               EdsVoid* context);
shun-iwasawa 31accf
  static EdsError EDSCALLBACK handleCameraAddedEvent(EdsVoid* context);
shun-iwasawa 31accf
shun-iwasawa 31accf
  void buildAvMap();
shun-iwasawa 31accf
  void buildTvMap();
shun-iwasawa 31accf
  void buildIsoMap();
shun-iwasawa 31accf
  void buildModeMap();
shun-iwasawa 31accf
  void buildExposureMap();
shun-iwasawa 31accf
  void buildWhiteBalanceMap();
shun-iwasawa 31accf
  void buildImageQualityMap();
shun-iwasawa 31accf
  void buildPictureStyleMap();
shun-iwasawa 31accf
#endif
shun-iwasawa 31accf
shun-iwasawa 31accf
private:
shun-iwasawa 31accf
  QStringList m_isoOptions, m_shutterSpeedOptions, m_apertureOptions,
shun-iwasawa 31accf
      m_exposureOptions, m_whiteBalanceOptions, m_colorTempOptions,
shun-iwasawa 31accf
      m_imageQualityOptions, m_pictureStyleOptions;
shun-iwasawa 31accf
shun-iwasawa 31accf
public:
shun-iwasawa 31accf
  Canon();
shun-iwasawa 31accf
  ~Canon();
shun-iwasawa 31accf
shun-iwasawa 31accf
#ifdef WITH_CANON
shun-iwasawa 31accf
  EdsError m_error              = EDS_ERR_OK;
shun-iwasawa 31accf
  EdsUInt32 m_count             = 0;
shun-iwasawa 31accf
  EdsCameraListRef m_cameraList = NULL;
shun-iwasawa 31accf
  EdsCameraRef m_camera         = NULL;
shun-iwasawa 31accf
  EdsUInt32 m_liveViewZoom      = 1;
shun-iwasawa 31accf
  bool m_isSDKLoaded            = false;
shun-iwasawa 31accf
  bool m_sessionOpen            = false;
shun-iwasawa 31accf
  bool m_zooming                = false;
shun-iwasawa 31accf
  std::string m_cameraName;
shun-iwasawa 31accf
  TDimension m_proxyImageDimensions = TDimension(0, 0);
shun-iwasawa 31accf
  TPointD m_proxyDpi                = TPointD(0.0, 0.0);
shun-iwasawa 31accf
  TPoint m_liveViewZoomOffset       = TPoint(0, 0);
shun-iwasawa 31accf
  bool m_liveViewZoomReadyToPick    = true;
shun-iwasawa 31accf
  TPointD m_liveViewZoomPickPoint   = TPointD(0.0, 0.0);
shun-iwasawa 31accf
  TPoint m_zoomRectDimensions       = TPoint(0, 0);
shun-iwasawa 31accf
  TPoint m_calculatedZoomPoint      = TPoint(0, 0);
shun-iwasawa 31accf
  TPoint m_finalZoomPoint           = TPoint(0, 0);
shun-iwasawa 31accf
  TRect m_zoomRect                  = TRect(0, 0, 0, 0);
shun-iwasawa 31accf
#endif
shun-iwasawa 31accf
  bool m_useScaledImages           = true;
shun-iwasawa 31accf
  bool m_converterSucceeded        = false;
shun-iwasawa 31accf
  bool m_pickLiveViewZoom          = false;
shun-iwasawa 31accf
  TDimension m_fullImageDimensions = TDimension(0, 0);
shun-iwasawa 31accf
  TPointD m_fullImageDpi           = TPointD(0.0, 0.0);
shun-iwasawa 31accf
shun-iwasawa 31accf
// Canon Commands
shun-iwasawa 31accf
#ifdef WITH_CANON
shun-iwasawa 31accf
  void cameraAdded();
shun-iwasawa 31accf
  void closeAll();
shun-iwasawa 31accf
  void resetCanon(bool liveViewOpen);
shun-iwasawa 31accf
  void closeCanonSDK();
shun-iwasawa 31accf
  int getCameraCount();
shun-iwasawa 31accf
  std::string getCameraName();
shun-iwasawa 31accf
  EdsError initializeCanonSDK();
shun-iwasawa 31accf
  EdsCameraListRef getCameraList();
shun-iwasawa 31accf
  EdsError releaseCameraList();
shun-iwasawa 31accf
  EdsError getCamera(int index);
shun-iwasawa 31accf
  EdsError releaseCamera();
shun-iwasawa 31accf
  EdsError openCameraSession();
shun-iwasawa 31accf
  EdsError closeCameraSession();
shun-iwasawa 31accf
  bool downloadImage(EdsBaseRef object);
shun-iwasawa 31accf
  EdsError takePicture();
shun-iwasawa 31accf
  EdsError startCanonLiveView();
shun-iwasawa 31accf
  EdsError endCanonLiveView();
shun-iwasawa 31accf
  bool downloadEVFData();
shun-iwasawa 31accf
  QStringList getIsoOptions() { return m_isoOptions; }
shun-iwasawa 31accf
  QStringList getShutterSpeedOptions() { return m_shutterSpeedOptions; }
shun-iwasawa 31accf
  QStringList getApertureOptions() { return m_apertureOptions; }
shun-iwasawa 31accf
  QStringList getExposureOptions() { return m_exposureOptions; }
shun-iwasawa 31accf
  QStringList getWhiteBalanceOptions() { return m_whiteBalanceOptions; }
shun-iwasawa 31accf
  QStringList getColorTemperatureOptions() { return m_colorTempOptions; }
shun-iwasawa 31accf
  QStringList getImageQualityOptions() { return m_imageQualityOptions; }
shun-iwasawa 31accf
  QStringList getPictureStyleOptions() { return m_pictureStyleOptions; }
shun-iwasawa 31accf
  EdsError getAvailableShutterSpeeds();
shun-iwasawa 31accf
  EdsError getAvailableIso();
shun-iwasawa 31accf
  EdsError getAvailableApertures();
shun-iwasawa 31accf
  EdsError getAvailableExposureCompensations();
shun-iwasawa 31accf
  EdsError getAvailableWhiteBalances();
shun-iwasawa 31accf
  EdsError getAvailableImageQualities();
shun-iwasawa 31accf
  EdsError getAvailablePictureStyles();
shun-iwasawa 31accf
  void buildColorTemperatures();
shun-iwasawa 31accf
  QString getCurrentShutterSpeed();
shun-iwasawa 31accf
  QString getCurrentIso();
shun-iwasawa 31accf
  QString getCurrentAperture();
shun-iwasawa 31accf
  QString getCurrentExposureCompensation();
shun-iwasawa 31accf
  QString getCurrentWhiteBalance();
shun-iwasawa 31accf
  QString getCurrentColorTemperature();
shun-iwasawa 31accf
  QString getCurrentImageQuality();
shun-iwasawa 31accf
  QString getCurrentPictureStyle();
shun-iwasawa 31accf
  QString getCurrentBatteryLevel();
shun-iwasawa 31accf
  EdsError setShutterSpeed(QString shutterSpeed);
shun-iwasawa 31accf
  EdsError setIso(QString iso);
shun-iwasawa 31accf
  EdsError setAperture(QString aperture);
shun-iwasawa 31accf
  EdsError setExposureCompensation(QString exposure);
shun-iwasawa 31accf
  EdsError setWhiteBalance(QString whiteBalance);
shun-iwasawa 31accf
  EdsError setColorTemperature(QString temp);
shun-iwasawa 31accf
  EdsError setImageQuality(QString quality);
shun-iwasawa 31accf
  EdsError setPictureStyle(QString style);
shun-iwasawa 31accf
  QString getMode();
shun-iwasawa 31accf
  void refreshOptions();
shun-iwasawa 31accf
  EdsError zoomLiveView();
shun-iwasawa 31accf
  EdsError setZoomPoint();
shun-iwasawa 31accf
  void makeZoomPoint(TPointD pos);
shun-iwasawa 31accf
  void toggleZoomPicking();
shun-iwasawa 31accf
  void calculateZoomPoint();
shun-iwasawa 31accf
  EdsError focusNear();
shun-iwasawa 31accf
  EdsError focusFar();
shun-iwasawa 31accf
  EdsError focusNear2();
shun-iwasawa 31accf
  EdsError focusFar2();
shun-iwasawa 31accf
  EdsError focusNear3();
shun-iwasawa 31accf
  EdsError focusFar3();
shun-iwasawa 31accf
  void extendCameraOnTime();
shun-iwasawa 31accf
  void setUseScaledImages(bool on);
shun-iwasawa 31accf
  bool getUseScaledImages() { return m_useScaledImages; }
shun-iwasawa 31accf
#endif
shun-iwasawa 31accf
shun-iwasawa 31accf
public slots:
shun-iwasawa 31accf
  void onImageReady(const bool&);
shun-iwasawa 31accf
  void onFinished();
shun-iwasawa 31accf
shun-iwasawa 31accf
signals:
shun-iwasawa 31accf
  // canon signals
shun-iwasawa 31accf
  void apertureOptionsChanged();
shun-iwasawa 31accf
  void isoOptionsChanged();
shun-iwasawa 31accf
  void shutterSpeedOptionsChanged();
shun-iwasawa 31accf
  void exposureOptionsChanged();
shun-iwasawa 31accf
  void whiteBalanceOptionsChanged();
shun-iwasawa 31accf
  void colorTemperatureChanged();
shun-iwasawa 31accf
  void imageQualityOptionsChanged();
shun-iwasawa 31accf
  void pictureStyleOptionsChanged();
shun-iwasawa 31accf
  void apertureChangedSignal(QString);
shun-iwasawa 31accf
  void isoChangedSignal(QString);
shun-iwasawa 31accf
  void shutterSpeedChangedSignal(QString);
shun-iwasawa 31accf
  void exposureChangedSignal(QString);
shun-iwasawa 31accf
  void whiteBalanceChangedSignal(QString);
shun-iwasawa 31accf
  void colorTemperatureChangedSignal(QString);
shun-iwasawa 31accf
  void imageQualityChangedSignal(QString);
shun-iwasawa 31accf
  void pictureStyleChangedSignal(QString);
shun-iwasawa 31accf
  void modeChanged();
shun-iwasawa 31accf
  void focusCheckToggled(bool);
shun-iwasawa 31accf
  void pickFocusCheckToggled(bool);
shun-iwasawa 31accf
  void scaleFullSizeImagesSignal(bool);
shun-iwasawa 31accf
  void newCanonImageReady();
shun-iwasawa 31accf
  void canonCameraChanged(QString);
shun-iwasawa 31accf
};
shun-iwasawa 31accf
shun-iwasawa 31accf
#endif  // CANON_H