Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Stop Motion Improvements by jeremybullock - require opencv for all builds

shun-iwasawa31accff7bc6e
diff --git a/.github/workflows/workflow_linux.yml b/.github/workflows/workflow_linux.yml
index 06fb4c9a6..e90d9c8cf 100644
--- a/.github/workflows/workflow_linux.yml
+++ b/.github/workflows/workflow_linux.yml
@@ -20,7 +20,7 @@ jobs:
- name: Install libraries
run: |
sudo apt-get update
- sudo apt-get install build-essential cmake pkg-config ninja-build ccache libboost-all-dev qt5-default qtbase5-dev libqt5svg5-dev qtscript5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtmultimedia5-dev libqt5multimedia5-plugins libsuperlu-dev liblz4-dev libusb-1.0-0-dev liblzo2-dev libpng-dev libjpeg-dev libglew-dev freeglut3-dev libfreetype6-dev libjson-c-dev qtwayland5 libmypaint-dev
+ sudo apt-get install build-essential cmake pkg-config ninja-build ccache libboost-all-dev qt5-default qtbase5-dev libqt5svg5-dev qtscript5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtmultimedia5-dev libqt5multimedia5-plugins libqt5serialport5-dev libsuperlu-dev liblz4-dev libusb-1.0-0-dev liblzo2-dev libpng-dev libjpeg-dev libglew-dev freeglut3-dev libfreetype6-dev libjson-c-dev qtwayland5 libmypaint-dev libopencv-dev libturbojpeg-dev
- uses: actions/cache@v1
with:
diff --git a/.github/workflows/workflow_macos.yml b/.github/workflows/workflow_macos.yml
index ffb0aa3a7..4668886c4 100644
--- a/.github/workflows/workflow_macos.yml
+++ b/.github/workflows/workflow_macos.yml
@@ -24,8 +24,11 @@ jobs:
done
}
brew update
- checkPkgAndInstall pkg-config glew lz4 libjpeg libpng lzo qt boost libusb libmypaint ccache ninja
-
+ checkPkgAndInstall pkg-config glew lz4 libjpeg libpng lzo qt boost libusb libmypaint ccache jpeg-turbo ninja
+ brew unlink gcc@8
+ brew unlink gcc@9
+ checkPkgAndInstall opencv
+
- uses: actions/cache@v1
with:
path: /Users/runner/.ccache
@@ -41,6 +44,7 @@ jobs:
- name: Build
run: |
+ export PKG_CONFIG_PATH="/usr/local/opt/jpeg-turbo/lib/pkgconfig:$PKG_CONFIG_PATH"
cd toonz
mkdir build
cd build
diff --git a/.github/workflows/workflow_windows.yml b/.github/workflows/workflow_windows.yml
index 94292e5ec..bc458e24a 100644
--- a/.github/workflows/workflow_windows.yml
+++ b/.github/workflows/workflow_windows.yml
@@ -44,7 +44,7 @@ jobs:
run: |
vcpkg install --clean-after-build --triplet x64-windows icu
vcpkg install --clean-after-build --triplet x64-windows-static json-c libjpeg-turbo libpng lz4 lzo openblas zlib
- vcpkg install --clean-after-build --triplet x64-windows freeglut glew
+ vcpkg install --clean-after-build --triplet x64-windows freeglut glew opencv
ls -Recurse C:/vcpkg/installed -Filter *.pdb | rm
- name: Cache Qt
@@ -128,6 +128,8 @@ jobs:
cp D:/a/opentoonz/opentoonz/libmypaint/build/Release/libmypaint.lib libmypaint/dist/64/libmypaint.lib
cp D:/a/opentoonz/opentoonz/superlu/build/SRC/Release/superlu.lib superlu/SuperLU_2015_64.lib
cp D:/a/opentoonz/opentoonz/thirdparty/tiff-4.0.3/prj/LibTIFF/x64/Release/LibTIFF.lib tiff-4.0.3/lib/LibTIFF-4.0.3_2015_64.lib
+ mkdir libjpeg-turbo64/lib
+ cp C:/vcpkg/installed/x64-windows-static/lib/turbojpeg.lib libjpeg-turbo64/lib/turbojpeg.lib
- name: Copy headers
run: |
@@ -138,10 +140,13 @@ jobs:
- name: Build
run: |
cd toonz
- mkdir build | Out-Null
+ if [ -d build ];then
+ ls build
+ fi
+ mkdir build
cd build
$env:CLCACHE_CL = '${{ env.CLCACHE_CL }}'
- cmake ../sources -G 'Visual Studio 16 2019' -Ax64 -DQT_PATH='D:/a/opentoonz/Qt/5.15.2/msvc2019_64' -DBOOST_ROOT="$env:BOOST_ROOT_1_72_0"
+ cmake ../sources -G 'Visual Studio 16 2019' -Ax64 -DQT_PATH='D:/a/opentoonz/Qt/5.15.2/msvc2019_64' -DOpenCV_DIR='C:/vcpkg/installed/x64-windows/share/opencv' -DBOOST_ROOT="$env:BOOST_ROOT_1_72_0"
cmake --build . --config Release
- name: Create Artifact
diff --git a/doc/how_to_build_linux.md b/doc/how_to_build_linux.md
index 2074d7ea6..ed7d1787c 100644
--- a/doc/how_to_build_linux.md
+++ b/doc/how_to_build_linux.md
@@ -13,11 +13,14 @@ Building OpenToonz from source requires the following dependencies:
- Lzo2
- FreeType
- LibMyPaint (1.3 or newer)
+- Jpeg-Turbo (1.4 or newer)
+- OpenCV 3.2 or newer
### Installing Dependencies on Debian / Ubuntu
```
-$ sudo apt-get install build-essential git cmake pkg-config libboost-all-dev qt5-default qtbase5-dev libqt5svg5-dev qtscript5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtmultimedia5-dev libsuperlu-dev liblz4-dev libusb-1.0-0-dev liblzo2-dev libpng-dev libjpeg-dev libglew-dev freeglut3-dev libfreetype6-dev libjson-c-dev qtwayland5 libqt5multimedia5-plugins
+$sudo apt-get install build-essential git cmake pkg-config libboost-all-dev qt5-default qtbase5-dev libqt5svg5-dev qtscript5-dev qttools5-dev qttools5-dev-tools libqt5opengl5-dev qtmultimedia5-dev libqt5multimedia5-plugins libqt5serialport5-dev libsuperlu-dev
+liblz4-dev libusb-1.0-0-dev liblzo2-dev libpng-dev libjpeg-dev libglew-dev freeglut3-dev libfreetype6-dev libjson-c-dev qtwayland5 libmypaint-dev libopencv-dev libturbojpeg-dev
```
For newest versions of OS you may install libmypaint from repository and don't need to build it from source:
@@ -28,6 +31,8 @@ $ sudo apt-get install libmypaint-dev
Notes:
* It's possible we also need `libgsl2` (or maybe `libopenblas-dev`)
+* We may also need `libegl1-mesa-dev libgles2-mesa-dev libglib2.0-dev liblzma-dev`
+* For Qt, MyPaint and OpenCV, you can alternatively build and install from source.
### Installing Dependencies on Fedora
(it may include some useless packages)
diff --git a/doc/how_to_build_win.md b/doc/how_to_build_win.md
index 1110ab6fa..843f9e541 100644
--- a/doc/how_to_build_win.md
+++ b/doc/how_to_build_win.md
@@ -18,7 +18,7 @@ This software can be built using Visual Studio 2015 or above and Qt 5.9 (later Q
### Qt
- https://www.qt.io/download-open-source/
- Qt is a cross-platform GUI framework.
-- Install Qt 5.9 (64-bit version, tested up to 5.9.9) with the [Qt Online Installer for Windows](http://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe).
+- Install Qt 5.9 or higher (64-bit version, tested up to 5.9.9) with the [Qt Online Installer for Windows](http://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe).
### boost
- Boost 1.55.0 or later is required (tested up to 1.61.0).
@@ -27,6 +27,15 @@ This software can be built using Visual Studio 2015 or above and Qt 5.9 (later Q
- Install the following patch (Make the changes listed in the patch file), if you use Boost 1.55.0 with Visual Studio 2013.
- https://svn.boost.org/trac/boost/attachment/ticket/9369/vc12_fix_has_member_function_callable_with.patch
+### OpenCV
+- v4.1.0 and later
+- https://opencv.org/
+- On configuring with CMake or in the environmental variables, specify `OpenCV_DIR` to the `build` folder in the install folder of OpenCV (like `C:/opencv/build`).
+
+### libjpeg-turbo
+- https://www.libjpeg-turbo.org/
+- Copy the lib and include folders from libjpeg-turbo64 into `$opentoonz/thirdparty/libjpeg-turbo64`.
+
## Acquiring the Source Code
- Note: You can also perform these next commands with Github for Desktop client.
- Clone the base repository.
@@ -67,21 +76,15 @@ Rename the following files:
- Compile the build.
- The output will be in the corresponding folder in `$opentoonz/toonz/build/`
-## Building with extended stop motion support for webcams and Canon DSLR cameras.
- You will need three additional libraries.
-- [OpenCV](https://opencv.org/) (v4.1.0 and later)
- - [libjpeg-turbo](https://www.libjpeg-turbo.org/)
- - The Canon SDK. This requires applying for the Canon developer program and downloading the SDK.
+## Building with Canon DSLR camera support
+ You will need the Canon SDK. This requires applying for the Canon developer program and downloading the SDK.
-Copy the following folders into the `$opentoonz/thirdparty` folder.
- - Copy the Header and library folders from the Canon SDK to `$opentoonz/thirdparty/canon`
- - Make sure that the library is the one from the EDSDK_64 folder.
- - Copy the lib and include folders from libjpeg-turbo64 into `$opentoonz/thirdparty/libjpeg-turbo64`.
+- Copy the Header and library folders from the Canon SDK to `$opentoonz/thirdparty/canon`
+ - Make sure that the library is the one from the EDSDK_64 folder.
-Check the checkbox in CMake to build with stop motion support.
-On configuring with CMake or in the environmental variables, specify `OpenCV_DIR` to the `build` folder in the install folder of OpenCV (like `C:/opencv/build`).
+Check the `WITH_CANON` checkbox in CMake to build with Canon DSLR camera support.
-To run the program with stop motion support, you will need to copy the .dll files from opencv2, libjpeg-turbo and the Canon SDK into the folder where your project is built.
+To run the program with Canon DSLR camera support, you will need to copy the .dll files from the Canon SDK into the folder where your project is built.
## Running the Program
### Setting Up the Program's Path
@@ -118,6 +121,8 @@ To run the program with stop motion support, you will need to copy the .dll file
3. Copy the following files to the same folder as `OpenToonz.exe`
- `$opentoonz/thirdparty/glut/3.7.6/lib/glut64.dll`
- `$opentoonz/thirdparty/glew/glew-1.9.0/bin/64bit/glew32.dll`
+ - `turbojpeg.dll` from libjpeg-turbo package
+ - `opencv_world***.dll` from OpenCV package
4. Copy the `srv` folder from the previous OpenToonz installation to the same folder as `OpenToonz.exe`
- If there is no `srv` folder, OpenToonz can still be used. However, various file formats such as `mov` cannot be used.
diff --git a/stuff/config/qss/Blue/Blue.qss b/stuff/config/qss/Blue/Blue.qss
index db2e06b82..a52fa678d 100644
--- a/stuff/config/qss/Blue/Blue.qss
+++ b/stuff/config/qss/Blue/Blue.qss
@@ -1699,6 +1699,12 @@ ProjectPopup QLabel {
#GearButton::menu-indicator {
image: url("");
}
+#LiveViewButton {
+ qproperty-icon: url('../Default/imgs/white/liveview.svg');
+}
+#LiveViewButton::menu-indicator {
+ image: "";
+}
#SubfolderButton {
padding-left: 5px;
padding-right: 5px;
diff --git a/stuff/config/qss/Dark/Dark.qss b/stuff/config/qss/Dark/Dark.qss
index 5cb7dc651..f0df1a81d 100644
--- a/stuff/config/qss/Dark/Dark.qss
+++ b/stuff/config/qss/Dark/Dark.qss
@@ -1699,6 +1699,12 @@ ProjectPopup QLabel {
#GearButton::menu-indicator {
image: url("");
}
+#LiveViewButton {
+ qproperty-icon: url('../Default/imgs/white/liveview.svg');
+}
+#LiveViewButton::menu-indicator {
+ image: "";
+}
#SubfolderButton {
padding-left: 5px;
padding-right: 5px;
diff --git a/stuff/config/qss/Default/Default.qss b/stuff/config/qss/Default/Default.qss
index 714762eae..b8aa8e88b 100644
--- a/stuff/config/qss/Default/Default.qss
+++ b/stuff/config/qss/Default/Default.qss
@@ -1699,6 +1699,12 @@ ProjectPopup QLabel {
#GearButton::menu-indicator {
image: url("");
}
+#LiveViewButton {
+ qproperty-icon: url('imgs/white/liveview.svg');
+}
+#LiveViewButton::menu-indicator {
+ image: "";
+}
#SubfolderButton {
padding-left: 5px;
padding-right: 5px;
diff --git a/stuff/config/qss/Default/imgs/black/liveview.svg b/stuff/config/qss/Default/imgs/black/liveview.svg
new file mode 100644
index 000000000..ff9a7856f
--- /dev/null
+++ b/stuff/config/qss/Default/imgs/black/liveview.svg
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="100%" height="100%" viewBox="0 0 18 17" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.4142;">
+ <path id="path821" d="M2,8.5C2,8.5 4.6,4 9,4C13.4,4 16,8.5 16,8.5C16,8.5 13.4,13 9,13C4.6,13 2,8.5 2,8.5Z" style="fill:rgb(230,230,230);fill-rule:nonzero;stroke:rgb(48,48,48);stroke-width:2px;"/>
+ <path id="path832" d="M2,8.5C2,8.5 4.6,4 9,4C13.4,4 16,8.5 16,8.5C16,8.5 13.4,13 9,13C4.6,13 2,8.5 2,8.5Z" style="fill:rgb(230,230,230);fill-rule:nonzero;"/>
+ <ellipse id="path21" cx="9" cy="8.5" rx="3.5" ry="3.6" style="fill:rgb(48,48,48);"/>
+ <circle id="path1450" cx="8" cy="7.5" r="1.5" style="fill:rgb(230,230,230);"/>
+ <g transform="matrix(1,0,0,1,0.734235,0.518659)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(189,189,189);stroke-width:2px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(1,0,0,1,0.734235,0.518659)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(48,48,48);stroke-width:1.5px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(6.12323e-17,-1,1,6.12323e-17,0.489235,16.2887)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(189,189,189);stroke-width:2px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(6.12323e-17,-1,1,6.12323e-17,0.489235,16.2887)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(48,48,48);stroke-width:1.5px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(-1,-1.22465e-16,1.22465e-16,-1,17.2961,16.5337)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(189,189,189);stroke-width:2px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(-1,-1.22465e-16,1.22465e-16,-1,17.2961,16.5337)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(48,48,48);stroke-width:1.5px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(-1.83697e-16,1,-1,-1.83697e-16,17.5411,0.763694)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(189,189,189);stroke-width:2px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(-1.83697e-16,1,-1,-1.83697e-16,17.5411,0.763694)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(48,48,48);stroke-width:1.5px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+</svg>
diff --git a/stuff/config/qss/Default/imgs/white/liveview.svg b/stuff/config/qss/Default/imgs/white/liveview.svg
new file mode 100644
index 000000000..ff9a7856f
--- /dev/null
+++ b/stuff/config/qss/Default/imgs/white/liveview.svg
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="100%" height="100%" viewBox="0 0 18 17" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.4142;">
+ <path id="path821" d="M2,8.5C2,8.5 4.6,4 9,4C13.4,4 16,8.5 16,8.5C16,8.5 13.4,13 9,13C4.6,13 2,8.5 2,8.5Z" style="fill:rgb(230,230,230);fill-rule:nonzero;stroke:rgb(48,48,48);stroke-width:2px;"/>
+ <path id="path832" d="M2,8.5C2,8.5 4.6,4 9,4C13.4,4 16,8.5 16,8.5C16,8.5 13.4,13 9,13C4.6,13 2,8.5 2,8.5Z" style="fill:rgb(230,230,230);fill-rule:nonzero;"/>
+ <ellipse id="path21" cx="9" cy="8.5" rx="3.5" ry="3.6" style="fill:rgb(48,48,48);"/>
+ <circle id="path1450" cx="8" cy="7.5" r="1.5" style="fill:rgb(230,230,230);"/>
+ <g transform="matrix(1,0,0,1,0.734235,0.518659)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(189,189,189);stroke-width:2px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(1,0,0,1,0.734235,0.518659)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(48,48,48);stroke-width:1.5px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(6.12323e-17,-1,1,6.12323e-17,0.489235,16.2887)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(189,189,189);stroke-width:2px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(6.12323e-17,-1,1,6.12323e-17,0.489235,16.2887)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(48,48,48);stroke-width:1.5px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(-1,-1.22465e-16,1.22465e-16,-1,17.2961,16.5337)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(189,189,189);stroke-width:2px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(-1,-1.22465e-16,1.22465e-16,-1,17.2961,16.5337)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(48,48,48);stroke-width:1.5px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(-1.83697e-16,1,-1,-1.83697e-16,17.5411,0.763694)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(189,189,189);stroke-width:2px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+ <g transform="matrix(-1.83697e-16,1,-1,-1.83697e-16,17.5411,0.763694)">
+ <path d="M0.684,4L0.684,0.929L3.513,0.929" style="fill:none;stroke:rgb(48,48,48);stroke-width:1.5px;stroke-linecap:round;stroke-miterlimit:1.5;"/>
+ </g>
+</svg>
diff --git a/stuff/config/qss/Default/less/layouts/popups.less b/stuff/config/qss/Default/less/layouts/popups.less
index e50c28753..f5260d9bc 100644
--- a/stuff/config/qss/Default/less/layouts/popups.less
+++ b/stuff/config/qss/Default/less/layouts/popups.less
@@ -99,6 +99,13 @@ ProjectPopup {
}
}
+#LiveViewButton {
+ qproperty-icon: url('@{img-url}/liveview.svg');
+ &::menu-indicator{
+ image:"";
+ }
+}
+
#SubfolderButton {
padding-left: 5px;
padding-right: 5px;
diff --git a/stuff/config/qss/Light/Light.qss b/stuff/config/qss/Light/Light.qss
index 53614f2fa..0e3bab441 100644
--- a/stuff/config/qss/Light/Light.qss
+++ b/stuff/config/qss/Light/Light.qss
@@ -1699,6 +1699,12 @@ ProjectPopup QLabel {
#GearButton::menu-indicator {
image: url("");
}
+#LiveViewButton {
+ qproperty-icon: url('../Default/imgs/black/liveview.svg');
+}
+#LiveViewButton::menu-indicator {
+ image: "";
+}
#SubfolderButton {
padding-left: 5px;
padding-right: 5px;
diff --git a/stuff/config/qss/Neutral/Neutral.qss b/stuff/config/qss/Neutral/Neutral.qss
index 908773e09..a312fc52b 100644
--- a/stuff/config/qss/Neutral/Neutral.qss
+++ b/stuff/config/qss/Neutral/Neutral.qss
@@ -1699,6 +1699,12 @@ ProjectPopup QLabel {
#GearButton::menu-indicator {
image: url("");
}
+#LiveViewButton {
+ qproperty-icon: url('../Default/imgs/black/liveview.svg');
+}
+#LiveViewButton::menu-indicator {
+ image: "";
+}
#SubfolderButton {
padding-left: 5px;
padding-right: 5px;
diff --git a/stuff/profiles/layouts/rooms/Default/menubar_template.xml b/stuff/profiles/layouts/rooms/Default/menubar_template.xml
index 98bdb8885..b671f8195 100644
--- a/stuff/profiles/layouts/rooms/Default/menubar_template.xml
+++ b/stuff/profiles/layouts/rooms/Default/menubar_template.xml
@@ -28,6 +28,7 @@
<menu title="Export">
<command>MI_SoundTrack</command>
<command>MI_ExportXDTS</command>
+ <command>MI_StopMotionExportImageSequence</command>
</menu>
<separator/>
<command>MI_PrintXsheet</command>
diff --git a/toonz/cmake/BundleInfo.plist.in b/toonz/cmake/BundleInfo.plist.in
index 4f674d2df..d56c1fb9a 100644
--- a/toonz/cmake/BundleInfo.plist.in
+++ b/toonz/cmake/BundleInfo.plist.in
@@ -32,5 +32,7 @@
<true/>
<key>NSHumanReadableCopyright</key>
<string>This Open Source Program is developed from Toonz, a software originally created by Digital Video, S.p.A., Rome Italy</string>
+ <key>NSCameraUsageDescription</key>
+ <string>OpenToonz needs access to the camera in order to use Camera Capture</string>
</dict>
</plist>
diff --git a/toonz/sources/CMakeLists.txt b/toonz/sources/CMakeLists.txt
index 1b4001981..e785a4c55 100644
--- a/toonz/sources/CMakeLists.txt
+++ b/toonz/sources/CMakeLists.txt
@@ -101,7 +101,7 @@ endif()
option(WITH_SYSTEM_LZO "Use the system LZO library instead of 'thirdpary'" ${_init_SYSTEM_LZO})
option(WITH_SYSTEM_SUPERLU "Use the system SuperLU library instead of 'thirdpary'" ${_init_SYSTEM_SUPERLU})
-option(WITH_STOPMOTION "Build with Stop Motion features - Requires Canon SDK" OFF)
+option(WITH_CANON "Build with Canon DSLR support - Requires Canon SDK" OFF)
option(WITH_TRANSLATION "Generate translation projects as well" ON)
# avoid using again
@@ -109,6 +109,27 @@ option_defaults_clear()
# end option(...)
+#-----------------------------------------------------------------------------
+# Platform Architecture
+
+if(BUILD_ENV_APPLE)
+ if(NOT PLATFORM)
+ set(PLATFORM 64)
+ endif()
+else() # Windows and Linux case
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(PLATFORM 64)
+ set(PLATFORM2 _64)
+ elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(PLATFORM 32)
+ set(PLATFORM2)
+ else()
+ message("Warning : CMAKE_SIZEOF_VOID_P = ${CMAKE_SIZEOF_VOID_P}")
+ set(PLATFORM 64)
+ set(PLATFORM2 _64)
+ endif()
+endif()
+message("PLATFORM:" ${PLATFORM})
#-----------------------------------------------------------------------------
# Third Party & System Libs
@@ -127,19 +148,7 @@ endif()
message(STATUS "Thirdpary Library Search path:" ${THIRDPARTY_LIBS_HINTS})
if(BUILD_ENV_MSVC)
- if(MSVC_VERSION GREATER 1800)
- if(CMAKE_SIZEOF_VOID_P EQUAL 4)
- set(QT_PATH "C:/Qt/5.9.2/msvc2015" CACHE PATH "Qt installation directory")
- else()
- set(QT_PATH "C:/Qt/5.9.2/msvc2015_64" CACHE PATH "Qt installation directory")
- endif()
- else()
- if(CMAKE_SIZEOF_VOID_P EQUAL 4)
- set(QT_PATH "C:/Qt/5.9.2/msvc2013" CACHE PATH "Qt installation directory")
- else()
- set(QT_PATH "C:/Qt/5.9.2/msvc2013_64" CACHE PATH "Qt installation directory")
- endif()
- endif()
+ set(QT_PATH "C:/Qt/5.9.2/msvc2015${PLATFORM2}" CACHE PATH "Qt installation directory")
if(NOT EXISTS ${QT_PATH})
message("Specify QT_PATH properly")
return()
@@ -154,32 +163,19 @@ if(BUILD_ENV_MSVC)
-D_USE_MATH_DEFINES
)
elseif(BUILD_ENV_APPLE)
- if(NOT PLATFORM)
- set(PLATFORM 64)
- endif()
- message("PLATFORM:" ${PLATFORM})
+ set(QT_PATH "~/Qt5.9.2/5.9.2/clang_${PLATFORM}/lib" CACHE PATH "Qt installation directory")
+ set(QT_LIB_PATH "${QT_PATH}/")
+ set(CMAKE_PREFIX_PATH "${QT_LIB_PATH}cmake/")
+ message("CMAKE_PREFIX_PATH:" ${CMAKE_PREFIX_PATH})
+ add_definitions(
+ -DMACOSX
+ -Di386
+ -D__MACOS__
+ )
if(PLATFORM EQUAL 64)
- set(QT_PATH "~/Qt5.9.2/5.9.2/clang_64/lib" CACHE PATH "Qt installation directory")
- set(QT_LIB_PATH "${QT_PATH}/")
- set(CMAKE_PREFIX_PATH "${QT_LIB_PATH}cmake/")
-
- message("CMAKE_PREFIX_PATH:" ${CMAKE_PREFIX_PATH})
- add_definitions(
- -DMACOSX
- -Di386
- )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -std=c++11 -stdlib=libc++ -fno-implicit-templates")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
elseif(PLATFORM EQUAL 32)
- set(QT_PATH "~/Qt5.9.2/5.9.2/clang_32/lib" CACHE PATH "Qt installation directory")
- set(QT_LIB_PATH "${QT_PATH}/")
- set(CMAKE_PREFIX_PATH "${QT_LIB_PATH}cmake/")
-
- message("CMAKE_PREFIX_PATH:" ${CMAKE_PREFIX_PATH})
- add_definitions(
- -DMACOSX
- -Di386
- )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -std=c++11 -stdlib=libc++ -fno-implicit-templates -D HAS_QUICKDRAW")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -m32")
@@ -189,12 +185,6 @@ elseif(BUILD_ENV_APPLE)
elseif(BUILD_ENV_UNIXLIKE)
# Needed for correct Qt detection
cmake_minimum_required(VERSION 2.8.12)
-
- if(CMAKE_SIZEOF_VOID_P MATCHES "8")
- set(PLATFORM 64)
- else()
- set(PLATFORM 32)
- endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-DLINUX)
elseif(CMAKE_SYSTEM_NAME MATCHES "^.*BSD$|DragonFly")
@@ -257,6 +247,7 @@ find_package(Qt5 REQUIRED
LinguistTools
Multimedia
MultimediaWidgets
+ SerialPort
)
set(QT_MINIMUM_VERSION 5.5.0)
@@ -266,7 +257,7 @@ if(Qt5Core_VERSION VERSION_LESS QT_MINIMUM_VERSION)
endif()
unset(QT_MINIMUM_VERSION)
-if(BUILD_ENV_MSVC AND NOT WITH_STOPMOTION)
+if(BUILD_ENV_MSVC)
include_directories(
SYSTEM
${SDKROOT}/glut/3.7.6/include
@@ -278,20 +269,21 @@ if(BUILD_ENV_MSVC AND NOT WITH_STOPMOTION)
)
endif()
-if(BUILD_ENV_MSVC AND WITH_STOPMOTION)
- find_package(OpenCV 4.1 REQUIRED)
+
+if(PLATFORM EQUAL 64)
+ if(BUILD_ENV_UNIXLIKE)
+ find_package(OpenCV 3.2 REQUIRED)
+ else() # Windows and MacOS case
+ find_package(OpenCV 4.1 REQUIRED)
+ endif()
include_directories(
- SYSTEM
- ${SDKROOT}/glut/3.7.6/include
- ${SDKROOT}/zlib-1.2.8
- ${SDKROOT}/LibJPEG/jpeg-9
- ${SDKROOT}/canon/Header
${SDKROOT}/libjpeg-turbo64/include
- ${OpenCV_INCLUDE_DIRS}
- )
- add_definitions(
- -DGLUT_NO_LIB_PRAGMA
)
+ if(WITH_CANON)
+ include_directories(
+ ${SDKROOT}/canon/Header
+ )
+ endif()
endif()
get_target_property(QtCore_location Qt5::Core LOCATION)
@@ -319,19 +311,7 @@ set(TFARM_Location)
set(QT_LIB) # avoid warning
if(BUILD_ENV_MSVC)
- if(CMAKE_SIZEOF_VOID_P EQUAL 4)
- set(PLATFORM 32)
- set(PLATFORM2)
- else()
- set(PLATFORM 64)
- set(PLATFORM2 _64)
- endif()
-
- if(MSVC_VERSION GREATER 1800)
- set(MSVC_LIB_VERSION 2015)
- else()
- set(MSVC_LIB_VERSION 2013)
- endif()
+ set(MSVC_LIB_VERSION 2015)
set(GLUT_LIB ${SDKROOT}/glut/3.7.6/lib/glut${PLATFORM}.lib)
set(GL_LIB opengl32.lib)
@@ -354,15 +334,19 @@ if(BUILD_ENV_MSVC)
set(SUPERLU_LIB ${SDKROOT}/superlu/SuperLU_${MSVC_LIB_VERSION}_${PLATFORM}.lib)
set(OPENBLAS_LIB ${SDKROOT}/openblas/libopenblas_${PLATFORM}.lib)
set(USB_LIB) # unused
- if (WITH_STOPMOTION)
- set(CANON_LIB ${SDKROOT}/canon/library/EDSDK.lib)
- set(TURBOJPEG_LIB ${SDKROOT}/libjpeg-turbo64/lib/turbojpeg.lib)
- endif()
+
if(PLATFORM EQUAL 32)
set(QT_LIB ${SDKROOT}/quicktime/QT73SDK/Libraries/QTMLClient.lib)
endif()
set(MYPAINT_LIB_INCLUDE_DIRS ${SDKROOT}/libmypaint/dist/${PLATFORM}/include/libmypaint)
set(MYPAINT_LIB_LDFLAGS ${SDKROOT}/libmypaint/dist/${PLATFORM}/libmypaint.lib)
+
+ if(PLATFORM EQUAL 64)
+ set(TURBOJPEG_LIB ${SDKROOT}/libjpeg-turbo64/lib/turbojpeg.lib)
+ if (WITH_CANON)
+ set(CANON_LIB ${SDKROOT}/canon/library/EDSDK.lib)
+ endif()
+ endif()
elseif(BUILD_ENV_APPLE)
find_library(GLUT_LIB GLUT)
find_library(GL_LIB OpenGL)
@@ -415,6 +399,17 @@ elseif(BUILD_ENV_APPLE)
message("LZO:" ${LZO_INCLUDE_DIR})
pkg_check_modules(MYPAINT_LIB REQUIRED libmypaint)
+
+ if(PLATFORM EQUAL 64)
+ pkg_check_modules(TURBOJPEG REQUIRED libturbojpeg)
+ find_library(TURBOJPEG_LIB turbojpeg ${TURBOJPEG_LIBRARY_DIRS})
+ message("**************** turbojpeg lib:" ${TURBOJPEG_LIB})
+
+ if (WITH_CANON)
+ set(CANON_LIB ${SDKROOT}/canon/Framework/EDSDK.framework)
+ endif()
+ endif()
+
elseif(BUILD_ENV_UNIXLIKE)
if(BUILD_TARGET_WIN)
find_library(GL_LIB opengl32)
@@ -479,6 +474,11 @@ elseif(BUILD_ENV_UNIXLIKE)
endif()
# Can be 'libmypaint' or 'libmypaint-1.x'
pkg_search_module(MYPAINT_LIB REQUIRED libmypaint libmypaint-1.3>=1.3)
+
+ if(PLATFORM EQUAL 64)
+ find_library(TURBOJPEG_LIB turbojpeg)
+ message("**************** turbojpeg lib:" ${TURBOJPEG_LIB})
+ endif()
endif()
@@ -521,14 +521,10 @@ if(BUILD_ENV_MSVC OR BUILD_ENV_APPLE)
HINTS
${THIRDPARTY_LIBS_HINTS}
PATH_SUFFIXES
- boost/boost_1_61_0/
- boost/boost_1_60_0/
- boost/boost_1_59_0/
- boost/boost_1_58_0/
- boost/boost_1_57_0/
- boost/boost_1_56_0/
- boost155/1.55.0_1/
- boost/boost_1_55_0/
+ boost/boost_1_75_0/
+ boost/boost_1_74_0/
+ boost/boost_1_73_0/
+ boost/boost_1_72_0/
)
find_package(Boost 1.55 REQUIRED)
else()
@@ -545,7 +541,7 @@ include_directories(
${MYPAINT_LIB_INCLUDE_DIRS}
)
-if(BUILD_TARGET_WIN AND PLATFORM EQUAL 64)
+if(PLATFORM EQUAL 64)
add_definitions(-Dx64)
endif()
diff --git a/toonz/sources/include/toonz/stagevisitor.h b/toonz/sources/include/toonz/stagevisitor.h
index 0baf5a935..e2072fbc5 100644
--- a/toonz/sources/include/toonz/stagevisitor.h
+++ b/toonz/sources/include/toonz/stagevisitor.h
@@ -13,6 +13,7 @@
// TnzLib includes
#include "toonz/imagepainter.h"
+#include "stageplayer.h"
#undef DVAPI
#undef DVVAR
@@ -97,6 +98,8 @@ public:
virtual void onImage(
const Player &player) = 0; //!< The \a visitation function.
+
+ virtual void onRasterImage(TRasterImage *ri, const Stage::Player &data) = 0;
// I've not checked the actual meaning of the methods below. They are unused
// in Toonz, but *are*
@@ -134,6 +137,12 @@ struct DVAPI VisitArgs {
int m_isGuidedDrawingEnabled;
int m_guidedFrontStroke;
int m_guidedBackStroke;
+#if defined(x64)
+ TRasterImageP m_liveViewImage = 0;
+ TRasterImageP m_lineupImage = 0;
+ Stage::Player m_liveViewPlayer;
+ Stage::Player m_lineupPlayer;
+#endif
public:
VisitArgs()
@@ -264,7 +273,7 @@ public:
void onImage(const Stage::Player &data) override;
void onVectorImage(TVectorImage *vi, const Stage::Player &data);
- void onRasterImage(TRasterImage *ri, const Stage::Player &data);
+ void onRasterImage(TRasterImage *ri, const Stage::Player &data) override;
void onToonzImage(TToonzImage *ri, const Stage::Player &data);
void beginMask() override;
@@ -307,6 +316,7 @@ public:
void setMinimumDistance(double d);
void onImage(const Stage::Player &data) override;
+ void onRasterImage(TRasterImage *ri, const Stage::Player &data) override {};
void beginMask() override;
void endMask() override;
void enableMask() override;
diff --git a/toonz/sources/include/toonzqt/menubarcommand.h b/toonz/sources/include/toonzqt/menubarcommand.h
index 3ec6cd4d2..c707508a2 100644
--- a/toonz/sources/include/toonzqt/menubarcommand.h
+++ b/toonz/sources/include/toonzqt/menubarcommand.h
@@ -64,7 +64,8 @@ enum CommandType {
ZoomCommandType,
MiscCommandType,
MenuCommandType,
- VisualizationButtonCommandType
+ VisualizationButtonCommandType,
+ StopMotionCommandType
};
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/stopmotion/canon.cpp b/toonz/sources/stopmotion/canon.cpp
new file mode 100644
index 000000000..bd43e8e3d
--- /dev/null
+++ b/toonz/sources/stopmotion/canon.cpp
@@ -0,0 +1,1850 @@
+#include "canon.h"
+#include "stopmotion.h"
+
+#include "tapp.h"
+#include "tenv.h"
+#include "toonz/stage.h"
+#include "toonz/tscenehandle.h"
+#include "toonz/tcamera.h"
+#include "toonz/toonzscene.h"
+
+#include <QCoreApplication>
+#include <QFile>
+
+TEnv::IntVar StopMotionUseScaledImages("StopMotionUseScaledImages", 1);
+
+namespace {
+bool l_quitLoop = false;
+}
+
+//-----------------------------------------------------------------------------
+
+Canon::Canon() {
+ m_useScaledImages = StopMotionUseScaledImages;
+#ifdef WITH_CANON
+ buildAvMap();
+ buildIsoMap();
+ buildTvMap();
+ buildModeMap();
+ buildExposureMap();
+ buildWhiteBalanceMap();
+ buildColorTemperatures();
+ buildImageQualityMap();
+ buildPictureStyleMap();
+#endif
+}
+
+Canon::~Canon() {}
+
+//-----------------------------------------------------------------
+
+void Canon::onImageReady(const bool& status) { m_converterSucceeded = status; }
+
+//-----------------------------------------------------------------
+
+void Canon::onFinished() { l_quitLoop = true; }
+
+//-----------------------------------------------------------------
+
+#ifdef WITH_CANON
+EdsError Canon::initializeCanonSDK() {
+ m_error = EdsInitializeSDK();
+ if (m_error == EDS_ERR_OK) {
+ m_isSDKLoaded = true;
+ }
+ if (!m_error)
+ m_error =
+ EdsSetCameraAddedHandler(Canon::handleCameraAddedEvent, (EdsVoid*)this);
+ return m_error;
+}
+
+//-----------------------------------------------------------------
+
+EdsCameraListRef Canon::getCameraList() {
+ if (!m_isSDKLoaded) initializeCanonSDK();
+ if (m_isSDKLoaded) {
+ m_error = EdsGetCameraList(&m_cameraList);
+ }
+ return m_cameraList;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::releaseCameraList() {
+ if (m_cameraList != NULL) m_error = EdsRelease(m_cameraList);
+ return m_error;
+}
+
+//-----------------------------------------------------------------
+
+int Canon::getCameraCount() {
+ if (m_cameraList == NULL) {
+ getCameraList();
+ }
+ if (m_cameraList != NULL) {
+ m_error = EdsGetChildCount(m_cameraList, &m_count);
+ if (m_count == 0) {
+ m_error = EDS_ERR_DEVICE_NOT_FOUND;
+ if (m_sessionOpen) {
+ StopMotion::instance()->m_liveViewStatus = 0;
+ m_sessionOpen = false;
+ }
+ }
+ return m_count;
+ } else
+ return -1;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::getCamera(int index) {
+ if (m_count == 0) {
+ m_error = EDS_ERR_DEVICE_NOT_FOUND;
+ }
+ if (m_count > 0) {
+ m_error = EdsGetChildAtIndex(m_cameraList, index, &m_camera);
+ }
+ return m_error;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::releaseCamera() {
+ if (m_camera != NULL) {
+ m_error = EdsRelease(m_camera);
+ }
+ return m_error;
+}
+
+//-----------------------------------------------------------------
+
+void Canon::cameraAdded() { StopMotion::instance()->refreshCameraList(); }
+
+//-----------------------------------------------------------------
+
+void Canon::closeCanonSDK() {
+ if (m_isSDKLoaded) {
+ EdsTerminateSDK();
+ }
+}
+
+//-----------------------------------------------------------------
+
+void Canon::closeAll() {
+#ifdef WITH_CANON
+ if (m_camera) releaseCamera();
+ if (m_cameraList != NULL) releaseCameraList();
+ if (m_isSDKLoaded) closeCanonSDK();
+#endif
+}
+
+//-----------------------------------------------------------------
+
+void Canon::resetCanon(bool liveViewOpen) {
+#ifdef WITH_CANON
+ m_proxyDpi = TPointD(0.0, 0.0);
+ m_proxyImageDimensions = TDimension(0, 0);
+
+ if (m_sessionOpen && getCameraCount() > 0) {
+ if (liveViewOpen) {
+ endCanonLiveView();
+ }
+ closeCameraSession();
+ }
+
+#endif
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::openCameraSession() {
+ if (m_camera != NULL) {
+ m_error = EdsOpenSession(m_camera);
+ if (m_error == EDS_ERR_OK) m_sessionOpen = true;
+ }
+ m_error = EdsSetObjectEventHandler(m_camera, kEdsObjectEvent_All,
+ Canon::handleObjectEvent, (EdsVoid*)this);
+
+ m_error =
+ EdsSetPropertyEventHandler(m_camera, kEdsPropertyEvent_All,
+ Canon::handlePropertyEvent, (EdsVoid*)this);
+
+ m_error = EdsSetCameraStateEventHandler(
+ m_camera, kEdsStateEvent_All, Canon::handleStateEvent, (EdsVoid*)this);
+
+ // We can't handle raw images yet, so make sure we are getting jpgs
+ if (getCurrentImageQuality().contains("RAW"))
+ setImageQuality("Large Fine Jpeg");
+
+ EdsUInt32 saveto = kEdsSaveTo_Host;
+ m_error = EdsSetPropertyData(m_camera, kEdsPropID_SaveTo, 0,
+ sizeof(EdsUInt32), &saveto);
+ EdsCapacity newCapacity = {0x7FFFFFFF, 0x1000, 1};
+ m_error = EdsSetCapacity(m_camera, newCapacity);
+ return m_error;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::closeCameraSession() {
+ if (m_camera != NULL) {
+ m_error = EdsCloseSession(m_camera);
+ m_sessionOpen = false;
+ }
+ return m_error;
+}
+
+//-----------------------------------------------------------------
+
+void Canon::refreshOptions() {
+ getAvailableShutterSpeeds();
+ getAvailableIso();
+ getAvailableApertures();
+ getAvailableExposureCompensations();
+ getAvailableWhiteBalances();
+ buildColorTemperatures();
+ getAvailableImageQualities();
+ getAvailablePictureStyles();
+}
+
+//-----------------------------------------------------------------
+
+std::string Canon::getCameraName() {
+ EdsChar name[EDS_MAX_NAME];
+ EdsError err = EDS_ERR_OK;
+ EdsDataType dataType;
+ EdsUInt32 dataSize;
+ m_error = EdsGetPropertySize(m_camera, kEdsPropID_ProductName, 0, &dataType,
+ &dataSize);
+
+ if (m_error == EDS_ERR_OK) {
+ m_error =
+ EdsGetPropertyData(m_camera, kEdsPropID_ProductName, 0, dataSize, name);
+ }
+ m_cameraName = name;
+ return m_cameraName;
+}
+
+//-----------------------------------------------------------------
+
+QString Canon::getMode() {
+ EdsError err = EDS_ERR_OK;
+ EdsDataType modeType;
+ EdsUInt32 size;
+ EdsUInt32 data;
+
+ err = EdsGetPropertySize(m_camera, kEdsPropID_AEMode, 0, &modeType, &size);
+ err = EdsGetPropertyData(m_camera, kEdsPropID_AEMode, 0, sizeof(size), &data);
+
+ return QString::fromStdString(m_modeMap[data]);
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::getAvailableIso() {
+ EdsPropertyDesc* IsoDesc = new EdsPropertyDesc;
+ EdsError err = EDS_ERR_OK;
+ m_isoOptions.clear();
+
+ err = EdsGetPropertyDesc(m_camera, kEdsPropID_ISOSpeed, IsoDesc);
+ int count = IsoDesc->numElements;
+ if (count > 0) {
+ int i = 0;
+ while (i < count) {
+ m_isoOptions.push_back(
+ QString::fromStdString(m_isoMap[IsoDesc->propDesc[i]]));
+ i++;
+ }
+ }
+ delete IsoDesc;
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::getAvailableShutterSpeeds() {
+ EdsPropertyDesc* TvDesc = new EdsPropertyDesc;
+ EdsError err = EDS_ERR_OK;
+ m_shutterSpeedOptions.clear();
+
+ err = EdsGetPropertyDesc(m_camera, kEdsPropID_Tv, TvDesc);
+ int count = TvDesc->numElements;
+ if (count > 0) {
+ int i = 0;
+ while (i < count) {
+ m_shutterSpeedOptions.push_back(
+ QString::fromStdString(m_tvMap[TvDesc->propDesc[i]]));
+ i++;
+ }
+ }
+ delete TvDesc;
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::getAvailableApertures() {
+ EdsPropertyDesc* AvDesc = new EdsPropertyDesc;
+ EdsError err = EDS_ERR_OK;
+ m_apertureOptions.clear();
+
+ err = EdsGetPropertyDesc(m_camera, kEdsPropID_Av, AvDesc);
+ int count = AvDesc->numElements;
+ if (count > 0) {
+ int i = 0;
+ while (i < count) {
+ m_apertureOptions.push_back(
+ QString::fromStdString(m_avMap[AvDesc->propDesc[i]]));
+ i++;
+ }
+ }
+ delete AvDesc;
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::getAvailableExposureCompensations() {
+ EdsPropertyDesc* exposureDesc = new EdsPropertyDesc;
+ EdsError err = EDS_ERR_OK;
+ m_exposureOptions.clear();
+
+ err = EdsGetPropertyDesc(m_camera, kEdsPropID_ExposureCompensation,
+ exposureDesc);
+ int count = exposureDesc->numElements;
+ if (count > 0) {
+ int i = 0;
+ while (i < count) {
+ m_exposureOptions.push_back(
+ QString::fromStdString(m_exposureMap[exposureDesc->propDesc[i]]));
+ i++;
+ }
+ }
+ delete exposureDesc;
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::getAvailableWhiteBalances() {
+ EdsPropertyDesc* whiteBalanceDesc = new EdsPropertyDesc;
+ EdsError err = EDS_ERR_OK;
+ m_whiteBalanceOptions.clear();
+
+ err = EdsGetPropertyDesc(m_camera, kEdsPropID_WhiteBalance, whiteBalanceDesc);
+ int count = whiteBalanceDesc->numElements;
+ if (count > 0) {
+ int i = 0;
+ while (i < count) {
+ m_whiteBalanceOptions.push_back(QString::fromStdString(
+ m_whiteBalanceMap[whiteBalanceDesc->propDesc[i]]));
+ i++;
+ }
+ }
+ delete whiteBalanceDesc;
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::getAvailableImageQualities() {
+ EdsPropertyDesc* imageQualityDesc = new EdsPropertyDesc;
+ EdsError err = EDS_ERR_OK;
+ m_imageQualityOptions.clear();
+
+ err = EdsGetPropertyDesc(m_camera, kEdsPropID_ImageQuality, imageQualityDesc);
+ int count = imageQualityDesc->numElements;
+ if (count > 0) {
+ int i = 0;
+ while (i < count) {
+ QString quality = QString::fromStdString(
+ m_imageQualityMap[imageQualityDesc->propDesc[i]]);
+ if (!quality.contains("RAW")) {
+ m_imageQualityOptions.push_back(quality);
+ }
+ i++;
+ }
+ }
+ delete imageQualityDesc;
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::getAvailablePictureStyles() {
+ EdsPropertyDesc* pictureStyleDesc = new EdsPropertyDesc;
+ EdsError err = EDS_ERR_OK;
+ m_pictureStyleOptions.clear();
+
+ err = EdsGetPropertyDesc(m_camera, kEdsPropID_PictureStyle, pictureStyleDesc);
+ int count = pictureStyleDesc->numElements;
+ if (count > 0) {
+ int i = 0;
+ while (i < count) {
+ m_pictureStyleOptions.push_back(QString::fromStdString(
+ m_pictureStyleMap[pictureStyleDesc->propDesc[i]]));
+ i++;
+ }
+ }
+ delete pictureStyleDesc;
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+void Canon::buildColorTemperatures() {
+ m_colorTempOptions.clear();
+ int i = 2800;
+ while (i <= 10000) {
+ m_colorTempOptions.push_back(QString::number(i));
+ i += 100;
+ }
+}
+
+//-----------------------------------------------------------------
+
+QString Canon::getCurrentShutterSpeed() {
+ EdsError err = EDS_ERR_OK;
+ EdsDataType tvType;
+ EdsUInt32 size;
+ EdsUInt32 data;
+
+ err = EdsGetPropertySize(m_camera, kEdsPropID_Tv, 0, &tvType, &size);
+ err = EdsGetPropertyData(m_camera, kEdsPropID_Tv, 0, sizeof(size), &data);
+
+ return QString::fromStdString(m_tvMap[data]);
+}
+
+//-----------------------------------------------------------------
+
+QString Canon::getCurrentIso() {
+ EdsError err = EDS_ERR_OK;
+ EdsDataType isoType;
+ EdsUInt32 size;
+ EdsUInt32 data;
+
+ err = EdsGetPropertySize(m_camera, kEdsPropID_ISOSpeed, 0, &isoType, &size);
+ err =
+ EdsGetPropertyData(m_camera, kEdsPropID_ISOSpeed, 0, sizeof(size), &data);
+
+ return QString::fromStdString(m_isoMap[data]);
+}
+
+//-----------------------------------------------------------------
+
+QString Canon::getCurrentAperture() {
+ EdsError err = EDS_ERR_OK;
+ EdsDataType avType;
+ EdsUInt32 size;
+ EdsUInt32 data;
+
+ err = EdsGetPropertySize(m_camera, kEdsPropID_Av, 0, &avType, &size);
+ err = EdsGetPropertyData(m_camera, kEdsPropID_Av, 0, sizeof(size), &data);
+
+ return QString::fromStdString(m_avMap[data]);
+}
+
+//-----------------------------------------------------------------
+
+QString Canon::getCurrentExposureCompensation() {
+ EdsError err = EDS_ERR_OK;
+ EdsDataType exposureType;
+ EdsUInt32 size;
+ EdsUInt32 data;
+
+ err = EdsGetPropertySize(m_camera, kEdsPropID_ExposureCompensation, 0,
+ &exposureType, &size);
+ err = EdsGetPropertyData(m_camera, kEdsPropID_ExposureCompensation, 0,
+ sizeof(size), &data);
+
+ return QString::fromStdString(m_exposureMap[data]);
+}
+
+//-----------------------------------------------------------------
+
+QString Canon::getCurrentWhiteBalance() {
+ EdsError err = EDS_ERR_OK;
+ EdsDataType whiteBalanceType;
+ EdsUInt32 size;
+ EdsUInt32 data;
+
+ err = EdsGetPropertySize(m_camera, kEdsPropID_WhiteBalance, 0,
+ &whiteBalanceType, &size);
+ err = EdsGetPropertyData(m_camera, kEdsPropID_WhiteBalance, 0, sizeof(size),
+ &data);
+ std::string wbString = m_whiteBalanceMap[data];
+ return QString::fromStdString(m_whiteBalanceMap[data]);
+}
+
+//-----------------------------------------------------------------
+
+QString Canon::getCurrentImageQuality() {
+ EdsError err = EDS_ERR_OK;
+ EdsDataType imageQualityType;
+ EdsUInt32 size;
+ EdsUInt32 data;
+
+ err = EdsGetPropertySize(m_camera, kEdsPropID_ImageQuality, 0,
+ &imageQualityType, &size);
+ err = EdsGetPropertyData(m_camera, kEdsPropID_ImageQuality, 0, sizeof(size),
+ &data);
+ std::string wbString = m_imageQualityMap[data];
+ return QString::fromStdString(m_imageQualityMap[data]);
+}
+
+//-----------------------------------------------------------------
+
+QString Canon::getCurrentPictureStyle() {
+ EdsError err = EDS_ERR_OK;
+ EdsDataType pictureStyleType;
+ EdsUInt32 size;
+ EdsUInt32 data;
+
+ err = EdsGetPropertySize(m_camera, kEdsPropID_PictureStyle, 0,
+ &pictureStyleType, &size);
+ err = EdsGetPropertyData(m_camera, kEdsPropID_PictureStyle, 0, sizeof(size),
+ &data);
+ std::string wbString = m_pictureStyleMap[data];
+ return QString::fromStdString(m_pictureStyleMap[data]);
+}
+
+//-----------------------------------------------------------------
+
+QString Canon::getCurrentColorTemperature() {
+ EdsError err = EDS_ERR_OK;
+ EdsDataType colorTempType;
+ EdsUInt32 size;
+ EdsUInt32 data;
+
+ err = EdsGetPropertySize(m_camera, kEdsPropID_ColorTemperature, 0,
+ &colorTempType, &size);
+ err = EdsGetPropertyData(m_camera, kEdsPropID_ColorTemperature, 0,
+ sizeof(size), &data);
+
+ return QString::number(data);
+}
+
+//-----------------------------------------------------------------
+
+QString Canon::getCurrentBatteryLevel() {
+ EdsError err = EDS_ERR_OK;
+ EdsDataType batteryLevelType;
+ EdsUInt32 size;
+ EdsUInt32 data;
+ QString result;
+
+ err = EdsGetPropertySize(m_camera, kEdsPropID_BatteryLevel, 0,
+ &batteryLevelType, &size);
+ err = EdsGetPropertyData(m_camera, kEdsPropID_BatteryLevel, 0, sizeof(size),
+ &data);
+ if (data == 0xffffffff) {
+ result = tr("AC Power");
+ } else if (data >= 80) {
+ result = tr("Full");
+ } else {
+ // at least the 60D reports battery values as 59, 49. . .
+ // round up
+ if (data % 10 == 9) data += 1;
+ result = QString::number(data) + "%";
+ }
+ return result;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::setShutterSpeed(QString shutterSpeed) {
+ EdsError err = EDS_ERR_OK;
+ EdsUInt32 value;
+ auto it = m_tvMap.begin();
+ while (it != m_tvMap.end()) {
+ if (it->second == shutterSpeed.toStdString()) {
+ value = it->first;
+ break;
+ }
+ it++;
+ }
+
+ err = EdsSetPropertyData(m_camera, kEdsPropID_Tv, 0, sizeof(value), &value);
+ emit(shutterSpeedChangedSignal(shutterSpeed));
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::setIso(QString iso) {
+ EdsError err = EDS_ERR_OK;
+ EdsUInt32 value;
+ auto it = m_isoMap.begin();
+ while (it != m_isoMap.end()) {
+ if (it->second == iso.toStdString()) {
+ value = it->first;
+ break;
+ }
+ it++;
+ }
+
+ err = EdsSetPropertyData(m_camera, kEdsPropID_ISOSpeed, 0, sizeof(value),
+ &value);
+ emit(isoChangedSignal(iso));
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::setAperture(QString aperture) {
+ EdsError err = EDS_ERR_OK;
+ EdsUInt32 value;
+ auto it = m_avMap.begin();
+ while (it != m_avMap.end()) {
+ if (it->second == aperture.toStdString()) {
+ value = it->first;
+ err =
+ EdsSetPropertyData(m_camera, kEdsPropID_Av, 0, sizeof(value), &value);
+ if (err == EDS_ERR_OK) {
+ break;
+ } else {
+ // some aperture values have two entries in the avMap
+ it++;
+ value = it->first;
+ err = EdsSetPropertyData(m_camera, kEdsPropID_Av, 0, sizeof(value),
+ &value);
+ break;
+ }
+ }
+ it++;
+ }
+ emit(apertureChangedSignal(aperture));
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::setExposureCompensation(QString exposure) {
+ EdsError err = EDS_ERR_OK;
+ EdsUInt32 value;
+ auto it = m_exposureMap.begin();
+ while (it != m_exposureMap.end()) {
+ if (it->second == exposure.toStdString()) {
+ value = it->first;
+ break;
+ }
+ it++;
+ }
+
+ err = EdsSetPropertyData(m_camera, kEdsPropID_ExposureCompensation, 0,
+ sizeof(value), &value);
+ emit(exposureChangedSignal(exposure));
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::setWhiteBalance(QString whiteBalance) {
+ EdsError err = EDS_ERR_OK;
+ EdsUInt32 value;
+ auto it = m_whiteBalanceMap.begin();
+ while (it != m_whiteBalanceMap.end()) {
+ if (it->second == whiteBalance.toStdString()) {
+ value = it->first;
+ break;
+ }
+ it++;
+ }
+
+ err = EdsSetPropertyData(m_camera, kEdsPropID_WhiteBalance, 0, sizeof(value),
+ &value);
+ emit(whiteBalanceChangedSignal(whiteBalance));
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::setImageQuality(QString quality) {
+ EdsError err = EDS_ERR_OK;
+ EdsUInt32 value;
+ auto it = m_imageQualityMap.begin();
+ while (it != m_imageQualityMap.end()) {
+ if (it->second == quality.toStdString()) {
+ value = it->first;
+ break;
+ }
+ it++;
+ }
+
+ err = EdsSetPropertyData(m_camera, kEdsPropID_ImageQuality, 0, sizeof(value),
+ &value);
+ emit(imageQualityChangedSignal(quality));
+ m_proxyImageDimensions = TDimension(0, 0);
+ m_proxyDpi = TPointD(0.0, 0.0);
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::setPictureStyle(QString style) {
+ EdsError err = EDS_ERR_OK;
+ EdsUInt32 value;
+ auto it = m_pictureStyleMap.begin();
+ while (it != m_pictureStyleMap.end()) {
+ if (it->second == style.toStdString()) {
+ value = it->first;
+ break;
+ }
+ it++;
+ }
+
+ err = EdsSetPropertyData(m_camera, kEdsPropID_PictureStyle, 0, sizeof(value),
+ &value);
+ err = EdsSetPropertyData(m_camera, kEdsPropID_PictureStyle, 0, sizeof(value),
+ &value);
+ emit(pictureStyleChangedSignal(style));
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::setColorTemperature(QString temp) {
+ EdsError err = EDS_ERR_OK;
+ EdsUInt32 value;
+ value = temp.toInt();
+
+ err = EdsSetPropertyData(m_camera, kEdsPropID_ColorTemperature, 0,
+ sizeof(value), &value);
+ err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_ColorTemperature, 0,
+ sizeof(value), &value);
+ emit(colorTemperatureChangedSignal(temp));
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+void Canon::setUseScaledImages(bool on) {
+ m_useScaledImages = on;
+ StopMotionUseScaledImages = int(on);
+ emit(scaleFullSizeImagesSignal(on));
+}
+
+//-----------------------------------------------------------------
+
+bool Canon::downloadImage(EdsBaseRef object) {
+ EdsError err = EDS_ERR_OK;
+ EdsStreamRef stream = NULL;
+ EdsDirectoryItemInfo dirItemInfo;
+
+ err = EdsGetDirectoryItemInfo(object, &dirItemInfo);
+ err = EdsCreateMemoryStream(0, &stream);
+ err = EdsDownload(object, dirItemInfo.size, stream);
+ EdsDownloadComplete(object);
+
+// tj code
+
+#ifdef MACOSX
+ UInt64 mySize = 0;
+#else
+ unsigned __int64 mySize = 0;
+#endif
+ unsigned char* data = NULL;
+ err = EdsGetPointer(stream, (EdsVoid**)&data);
+ err = EdsGetLength(stream, &mySize);
+
+ int width, height, pixelFormat;
+ // long size;
+ int inSubsamp, inColorspace;
+ // unsigned long jpegSize;
+ tjhandle tjInstance = NULL;
+ unsigned char* imgBuf = NULL;
+ tjInstance = tjInitDecompress();
+ tjDecompressHeader3(tjInstance, data, mySize, &width, &height, &inSubsamp,
+ &inColorspace);
+
+ pixelFormat = TJPF_BGRX;
+ imgBuf = (unsigned char*)tjAlloc(width * height * tjPixelSize[pixelFormat]);
+ int flags = 0;
+ flags |= TJFLAG_BOTTOMUP;
+ int tempWidth, tempHeight;
+
+ if (m_useScaledImages) {
+ int factorsNum;
+ tjscalingfactor scalingFactor = {1, 1};
+ tjscalingfactor* factor = tjGetScalingFactors(&factorsNum);
+ int intRatio = (float)width / (float)height * 100.0;
+ int i = 0;
+
+ TCamera* camera =
+ TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
+ TDimension res = camera->getRes();
+
+ // find the scaling factor that is at least as big as the current camera
+ while (i < factorsNum) {
+ scalingFactor = factor[i];
+ tempWidth = TJSCALED(width, scalingFactor);
+ if (tempWidth < res.lx && i > 0) {
+ scalingFactor = factor[i - 1];
+ break;
+ }
+ i++;
+ }
+ // make sure the scaling factor has the right aspect ratio
+ while (i >= 0) {
+ tempWidth = TJSCALED(width, scalingFactor);
+ tempHeight = TJSCALED(height, scalingFactor);
+ if ((int)((float)tempWidth / (float)tempHeight * 100.0) == intRatio) {
+ break;
+ }
+ i--;
+ scalingFactor = factor[i];
+ }
+ } else {
+ tempWidth = width;
+ tempHeight = height;
+ }
+
+ if (m_useScaledImages || !getCurrentImageQuality().contains("Large")) {
+ TCamera* camera =
+ TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
+ TDimensionD size = camera->getSize();
+ m_proxyImageDimensions = TDimension(tempWidth, tempHeight);
+ double minimumDpi = std::min(m_proxyImageDimensions.lx / size.lx,
+ m_proxyImageDimensions.ly / size.ly);
+ m_proxyDpi = TPointD(minimumDpi, minimumDpi);
+ }
+
+ tjDecompress2(tjInstance, data, mySize, imgBuf, tempWidth,
+ tempWidth * tjPixelSize[pixelFormat], tempHeight, pixelFormat,
+ flags);
+
+ StopMotion::instance()->m_newImage = TRaster32P(tempWidth, tempHeight);
+ StopMotion::instance()->m_newImage->lock();
+ uchar* rawData = StopMotion::instance()->m_newImage->getRawData();
+ memcpy(rawData, imgBuf, tempWidth * tempHeight * tjPixelSize[pixelFormat]);
+ StopMotion::instance()->m_newImage->unlock();
+
+ tjFree(imgBuf);
+ imgBuf = NULL;
+ tjDestroy(tjInstance);
+ tjInstance = NULL;
+
+ // end tj code
+
+ if (m_useScaledImages) {
+ QFile fullImage(StopMotion::instance()->m_tempFile);
+ fullImage.open(QIODevice::WriteOnly);
+ QDataStream dataStream(&fullImage);
+ dataStream.writeRawData((const char*)data, mySize);
+ fullImage.close();
+ }
+
+ EdsRelease(stream);
+ stream = NULL;
+ if (object) EdsRelease(object);
+
+ if (err == EDS_ERR_OK) {
+ emit(newCanonImageReady());
+ }
+
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::takePicture() {
+ EdsError err;
+ err = EdsSendCommand(m_camera, kEdsCameraCommand_PressShutterButton,
+ kEdsCameraCommand_ShutterButton_Completely_NonAF);
+ err = EdsSendCommand(m_camera, kEdsCameraCommand_PressShutterButton,
+ kEdsCameraCommand_ShutterButton_OFF);
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+void Canon::extendCameraOnTime() {
+ EdsError err;
+ EdsInt32 param = 0;
+ err = EdsSendCommand(m_camera, kEdsCameraCommand_ExtendShutDownTimer, param);
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::startCanonLiveView() {
+ if (m_camera && m_sessionOpen) {
+ EdsError err = EDS_ERR_OK;
+ // Get the output device for the live view image
+ EdsUInt32 device;
+ err = EdsGetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
+ sizeof(device), &device);
+ // PC live view starts by setting the PC as the output device for the live
+ // view image.
+ if (err == EDS_ERR_OK) {
+ device |= kEdsEvfOutputDevice_PC;
+ err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
+ sizeof(device), &device);
+ }
+ if (err == EDS_ERR_OK) {
+ StopMotion::instance()->m_liveViewStatus = 1;
+ }
+ // A property change event notification is issued from the camera if
+ // property settings are made successfully. Start downloading of the live
+ // view image once the property change notification arrives.
+ return err;
+ } else
+ return EDS_ERR_DEVICE_NOT_FOUND;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::endCanonLiveView() {
+ EdsError err = EDS_ERR_OK;
+ // Get the output device for the live view image
+ EdsUInt32 device;
+ err = EdsGetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
+ sizeof(device), &device);
+ // PC live view ends if the PC is disconnected from the live view image output
+ // device.
+ if (err == EDS_ERR_OK) {
+ device &= ~kEdsEvfOutputDevice_PC;
+ err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
+ sizeof(device), &device);
+ }
+ StopMotion::instance()->m_liveViewStatus = 0;
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::zoomLiveView() {
+ if (!m_sessionOpen || !StopMotion::instance()->m_liveViewStatus > 0)
+ return EDS_ERR_DEVICE_INVALID;
+ EdsError err = EDS_ERR_OK;
+ if (m_pickLiveViewZoom) toggleZoomPicking();
+ if (m_liveViewZoom == 1) {
+ m_liveViewZoom = 5;
+ m_zooming = true;
+ StopMotion::instance()->toggleNumpadForFocusCheck(true);
+ } else if (m_liveViewZoom == 5) {
+ m_liveViewZoom = 1;
+ m_zooming = false;
+ StopMotion::instance()->toggleNumpadForFocusCheck(false);
+ }
+
+ err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_Zoom, 0,
+ sizeof(m_liveViewZoom), &m_liveViewZoom);
+ if (m_liveViewZoom == 5) setZoomPoint();
+ emit(focusCheckToggled(m_liveViewZoom > 1));
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+void Canon::makeZoomPoint(TPointD pos) {
+ m_liveViewZoomPickPoint = pos;
+ calculateZoomPoint();
+}
+
+//-----------------------------------------------------------------
+
+void Canon::toggleZoomPicking() {
+ if (m_sessionOpen && StopMotion::instance()->m_liveViewStatus > 0 &&
+ !m_zooming) {
+ if (m_pickLiveViewZoom) {
+ m_pickLiveViewZoom = false;
+ StopMotion::instance()->toggleNumpadForFocusCheck(false);
+ } else {
+ m_pickLiveViewZoom = true;
+ if (m_liveViewZoomPickPoint == TPointD(0.0, 0.0)) {
+ makeZoomPoint(m_liveViewZoomPickPoint);
+ }
+ StopMotion::instance()->toggleNumpadForFocusCheck(true);
+ }
+ }
+ emit(pickFocusCheckToggled(m_pickLiveViewZoom));
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::setZoomPoint() {
+ // make sure this is set AFTER starting zoom
+ EdsError err = EDS_ERR_OK;
+ m_liveViewZoomReadyToPick = false;
+ EdsPoint zoomPoint;
+
+ calculateZoomPoint();
+
+ zoomPoint.x = m_finalZoomPoint.x;
+ zoomPoint.y = m_finalZoomPoint.y;
+
+ err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_ZoomPosition, 0,
+ sizeof(zoomPoint), &zoomPoint);
+ m_liveViewZoomReadyToPick = true;
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+void Canon::calculateZoomPoint() {
+ m_fullImageDimensions = StopMotion::instance()->m_fullImageDimensions;
+ m_fullImageDpi = StopMotion::instance()->m_fullImageDpi;
+
+ bool outOfBounds = false;
+ if (m_liveViewZoomPickPoint == TPointD(0.0, 0.0)) {
+ m_calculatedZoomPoint =
+ TPoint(m_fullImageDimensions.lx / 2, m_fullImageDimensions.ly / 2);
+ m_finalZoomPoint.x = m_calculatedZoomPoint.x - (m_zoomRectDimensions.x / 2);
+ m_finalZoomPoint.y = m_calculatedZoomPoint.y - (m_zoomRectDimensions.y / 2);
+ } else {
+ // get the image size in OpenToonz dimensions
+ double maxFullWidth =
+ (double)m_fullImageDimensions.lx / m_fullImageDpi.x * Stage::inch;
+ double maxFullHeight =
+ (double)m_fullImageDimensions.ly / m_fullImageDpi.y * Stage::inch;
+ // OpenToonz coordinates are based on center at 0, 0
+ // convert that to top left based coordinates
+ double newX = m_liveViewZoomPickPoint.x + maxFullWidth / 2.0;
+ double newY = -m_liveViewZoomPickPoint.y + maxFullHeight / 2.0;
+ // convert back to the normal image dimensions to talk to the camera
+ m_calculatedZoomPoint.x = newX / Stage::inch * m_fullImageDpi.x;
+ m_calculatedZoomPoint.y = newY / Stage::inch * m_fullImageDpi.x;
+ // the Canon SDK wants the top left corner of the zoom rect, not the center
+ m_finalZoomPoint.x = m_calculatedZoomPoint.x - (m_zoomRectDimensions.x / 2);
+ m_finalZoomPoint.y = m_calculatedZoomPoint.y - (m_zoomRectDimensions.y / 2);
+ // finally make sure everything actually fits on the image
+ if (m_finalZoomPoint.x < 0) {
+ m_finalZoomPoint.x = 0;
+ outOfBounds = true;
+ }
+ if (m_finalZoomPoint.y < 0) {
+ m_finalZoomPoint.y = 0;
+ outOfBounds = true;
+ }
+ if (m_finalZoomPoint.x >
+ m_fullImageDimensions.lx - (m_zoomRectDimensions.x)) {
+ m_finalZoomPoint.x = m_fullImageDimensions.lx - (m_zoomRectDimensions.x);
+ outOfBounds = true;
+ }
+ if (m_finalZoomPoint.y >
+ m_fullImageDimensions.ly - (m_zoomRectDimensions.y)) {
+ m_finalZoomPoint.y = m_fullImageDimensions.ly - (m_zoomRectDimensions.y);
+ outOfBounds = true;
+ }
+
+ // if out of bounds, recalculate backwards to get the correct location
+ if (outOfBounds) {
+ TPoint tempCalculated;
+ // recenter the point in the rect
+ tempCalculated.x = m_finalZoomPoint.x + (m_zoomRectDimensions.x / 2);
+ tempCalculated.y = m_finalZoomPoint.y + (m_zoomRectDimensions.y / 2);
+ // convert to OpenToonz Dimensions
+ newX = tempCalculated.x / m_fullImageDpi.x * Stage::inch;
+ newY = tempCalculated.y / m_fullImageDpi.y * Stage::inch;
+ // get center based coordinates
+ m_liveViewZoomPickPoint.x = newX - (maxFullWidth / 2.0);
+ m_liveViewZoomPickPoint.y = (newY - (maxFullHeight / 2.0)) * -1;
+ }
+ }
+
+ // calculate the zoom rectangle position on screen
+
+ // get the image size in OpenToonz dimensions
+ double maxFullWidth =
+ (double)m_fullImageDimensions.lx / m_fullImageDpi.x * Stage::inch;
+ double maxFullHeight =
+ (double)m_fullImageDimensions.ly / m_fullImageDpi.y * Stage::inch;
+ m_zoomRect =
+ TRect(m_finalZoomPoint.x, m_finalZoomPoint.y + m_zoomRectDimensions.y,
+ m_finalZoomPoint.x + m_zoomRectDimensions.x, m_finalZoomPoint.y);
+ TRect tempCalculated;
+
+ // convert to OpenToonz Dimensions
+ tempCalculated.x0 = m_zoomRect.x0 / m_fullImageDpi.x * Stage::inch;
+ tempCalculated.y0 = m_zoomRect.y0 / m_fullImageDpi.y * Stage::inch;
+ tempCalculated.x1 = m_zoomRect.x1 / m_fullImageDpi.x * Stage::inch;
+ tempCalculated.y1 = m_zoomRect.y1 / m_fullImageDpi.y * Stage::inch;
+ // get center based coordinates
+ m_zoomRect.x0 = tempCalculated.x0 - (maxFullWidth / 2.0);
+ m_zoomRect.y0 = (tempCalculated.y0 - (maxFullHeight / 2.0)) * -1;
+ m_zoomRect.x1 = tempCalculated.x1 - (maxFullWidth / 2.0);
+ m_zoomRect.y1 = (tempCalculated.y1 - (maxFullHeight / 2.0)) * -1;
+}
+
+//-----------------------------------------------------------------
+
+bool Canon::downloadEVFData() {
+ EdsError err = EDS_ERR_OK;
+ EdsStreamRef stream = NULL;
+ EdsEvfImageRef evfImage = NULL;
+
+ // Create memory stream.
+ err = EdsCreateMemoryStream(0, &stream);
+ // Create EvfImageRef.
+ if (err == EDS_ERR_OK) {
+ err = EdsCreateEvfImageRef(stream, &evfImage);
+ }
+ // Download live view image data.
+ if (err == EDS_ERR_OK) {
+ err = EdsDownloadEvfImage(m_camera, evfImage);
+ }
+
+ EdsDataType evfZoom;
+ EdsDataType evfZoomPos;
+ EdsDataType evfZoomRect;
+ EdsUInt32 size;
+ EdsUInt32 sizePos;
+ EdsUInt32 sizeRect;
+ EdsUInt32 sizeImagePos;
+ EdsUInt32 sizeCoordSys;
+ EdsUInt32 zoomAmount;
+ EdsPoint zoomPos;
+ EdsRect zoomRect;
+ EdsPoint imagePos;
+ EdsSize coordSys;
+
+ err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_Zoom, 0, &evfZoom, &size);
+ err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_Zoom, 0, sizeof(size),
+ &zoomAmount);
+
+ // this is the top left corner of the zoomed image
+ err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_ZoomPosition, 0,
+ &evfZoomPos, &sizePos);
+ err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomPosition, 0, sizePos,
+ &zoomPos);
+ // this is the size of the zoomed image
+ err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_ZoomRect, 0, &evfZoomRect,
+ &sizeRect);
+ err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomRect, 0, sizeRect,
+ &zoomRect);
+
+ err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_ImagePosition, 0,
+ &evfZoomRect, &sizeImagePos);
+ err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_ImagePosition, 0,
+ sizeImagePos, &imagePos);
+ // this returns the size of the full image
+ err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_CoordinateSystem, 0,
+ &evfZoomRect, &sizeCoordSys);
+ err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_CoordinateSystem, 0,
+ sizeCoordSys, &coordSys);
+
+ // Get the incidental data of the image.
+ if (err == EDS_ERR_OK) {
+ JpgConverter* converter = new JpgConverter;
+ converter->setStream(stream);
+ converter->setScale(m_useScaledImages);
+
+ connect(converter, SIGNAL(imageReady(bool)), this, SLOT(onImageReady(bool)),
+ Qt::QueuedConnection);
+ connect(converter, SIGNAL(finished()), this, SLOT(onFinished()),
+ Qt::QueuedConnection);
+
+ converter->start();
+
+ while (!l_quitLoop)
+ QCoreApplication::processEvents(QEventLoop::AllEvents |
+ QEventLoop::WaitForMoreEvents);
+
+ l_quitLoop = false;
+ StopMotion::instance()->m_liveViewImage = converter->getImage();
+ StopMotion::instance()->m_hasLiveViewImage = true;
+ delete converter;
+ if (stream != NULL) {
+ EdsRelease(stream);
+ }
+ stream = NULL;
+ if (evfImage != NULL) {
+ EdsRelease(evfImage);
+ evfImage = NULL;
+ }
+ if (!m_converterSucceeded) return EDS_ERR_UNEXPECTED_EXCEPTION;
+
+ // sometimes zoomRect returns the wrong dimensions if called too fast
+ if (zoomRect.size.width < 5000 && zoomRect.size.height < 5000) {
+ m_zoomRectDimensions = TPoint(zoomRect.size.width, zoomRect.size.height);
+ if (m_zoomRect == TRect(0, 0, 0, 0)) {
+ m_zoomRect = TRect(zoomPos.x, zoomPos.y + zoomRect.size.height,
+ zoomPos.x + zoomRect.size.width, zoomPos.y);
+ calculateZoomPoint();
+ }
+ }
+ if (zoomAmount == 5 && m_zoomRectDimensions == TPoint(0, 0)) {
+ setZoomPoint();
+ }
+ StopMotion::instance()->m_fullImageDimensions =
+ TDimension(coordSys.width, coordSys.height);
+
+ return true;
+ }
+
+ return false;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::focusNear() {
+ EdsError err = EDS_ERR_OK;
+ err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
+ kEdsEvfDriveLens_Near1);
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::focusFar() {
+ EdsError err = EDS_ERR_OK;
+ err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
+ kEdsEvfDriveLens_Far1);
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::focusNear2() {
+ EdsError err = EDS_ERR_OK;
+ err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
+ kEdsEvfDriveLens_Near2);
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::focusFar2() {
+ EdsError err = EDS_ERR_OK;
+ err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
+ kEdsEvfDriveLens_Far2);
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::focusNear3() {
+ EdsError err = EDS_ERR_OK;
+ err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
+ kEdsEvfDriveLens_Near3);
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::focusFar3() {
+ EdsError err = EDS_ERR_OK;
+ err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
+ kEdsEvfDriveLens_Far3);
+ return err;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::handleObjectEvent(EdsObjectEvent event, EdsBaseRef object,
+ EdsVoid* context) {
+ if (event == kEdsObjectEvent_DirItemRequestTransfer) {
+ instance()->downloadImage(object);
+ }
+
+ return EDS_ERR_OK;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::handlePropertyEvent(EdsPropertyEvent event,
+ EdsPropertyID property, EdsUInt32 param,
+ EdsVoid* context) {
+ if (property == kEdsPropID_Evf_OutputDevice &&
+ event == kEdsPropertyEvent_PropertyChanged) {
+ if (StopMotion::instance()->m_liveViewStatus == 1)
+ StopMotion::instance()->m_liveViewStatus = 2;
+ }
+ if (property == kEdsPropID_AEMode &&
+ event == kEdsPropertyEvent_PropertyChanged) {
+ emit(instance()->modeChanged());
+ }
+ if (property == kEdsPropID_BatteryLevel &&
+ event == kEdsPropertyEvent_PropertyChanged) {
+ emit(instance()->modeChanged());
+ }
+ if (property == kEdsPropID_Av &&
+ event == kEdsPropertyEvent_PropertyDescChanged) {
+ emit(instance()->apertureOptionsChanged());
+ }
+
+ if (property == kEdsPropID_Av && event == kEdsPropertyEvent_PropertyChanged) {
+ emit(instance()->apertureChangedSignal(instance()->getCurrentAperture()));
+ }
+
+ if (property == kEdsPropID_Tv &&
+ event == kEdsPropertyEvent_PropertyDescChanged) {
+ emit(instance()->shutterSpeedOptionsChanged());
+ }
+ if (property == kEdsPropID_Tv && event == kEdsPropertyEvent_PropertyChanged) {
+ emit(instance()->shutterSpeedChangedSignal(
+ instance()->getCurrentShutterSpeed()));
+ }
+ if (property == kEdsPropID_ISOSpeed &&
+ event == kEdsPropertyEvent_PropertyDescChanged) {
+ emit(instance()->isoOptionsChanged());
+ }
+ if (property == kEdsPropID_ISOSpeed &&
+ event == kEdsPropertyEvent_PropertyChanged) {
+ emit(instance()->isoChangedSignal(instance()->getCurrentIso()));
+ }
+ if (property == kEdsPropID_ExposureCompensation &&
+ event == kEdsPropertyEvent_PropertyDescChanged) {
+ emit(instance()->exposureOptionsChanged());
+ }
+ if (property == kEdsPropID_ExposureCompensation &&
+ event == kEdsPropertyEvent_PropertyChanged) {
+ emit(instance()->exposureChangedSignal(
+ instance()->getCurrentExposureCompensation()));
+ }
+ if (property == kEdsPropID_WhiteBalance &&
+ event == kEdsPropertyEvent_PropertyDescChanged) {
+ emit(instance()->whiteBalanceOptionsChanged());
+ }
+ if (property == kEdsPropID_WhiteBalance &&
+ event == kEdsPropertyEvent_PropertyChanged) {
+ emit(instance()->whiteBalanceChangedSignal(
+ instance()->getCurrentWhiteBalance()));
+ }
+ if (property == kEdsPropID_PictureStyle &&
+ event == kEdsPropertyEvent_PropertyDescChanged) {
+ emit(instance()->pictureStyleOptionsChanged());
+ }
+ if (property == kEdsPropID_PictureStyle &&
+ event == kEdsPropertyEvent_PropertyChanged) {
+ emit(instance()->pictureStyleChangedSignal(
+ instance()->getCurrentPictureStyle()));
+ }
+ if (property == kEdsPropID_ImageQuality &&
+ event == kEdsPropertyEvent_PropertyDescChanged) {
+ emit(instance()->imageQualityOptionsChanged());
+ }
+ if (property == kEdsPropID_ImageQuality &&
+ event == kEdsPropertyEvent_PropertyChanged) {
+ emit(instance()->imageQualityChangedSignal(
+ instance()->getCurrentImageQuality()));
+ }
+
+ return EDS_ERR_OK;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::handleStateEvent(EdsStateEvent event, EdsUInt32 parameter,
+ EdsVoid* context) {
+ if (event == kEdsStateEvent_Shutdown) {
+ instance()->m_sessionOpen = false;
+ instance()->releaseCamera();
+ if (instance()->m_sessionOpen && instance()->getCameraCount() > 0) {
+ //instance()->closeCameraSession();
+ }
+ StopMotion::instance()->m_liveViewStatus = 0;
+ emit(instance()->canonCameraChanged(QString("")));
+ }
+ if (event == kEdsStateEvent_WillSoonShutDown) {
+ instance()->extendCameraOnTime();
+ if (StopMotion::instance()->m_liveViewStatus > 1) {
+ StopMotion::instance()->toggleLiveView();
+ }
+ }
+ return EDS_ERR_OK;
+}
+
+//-----------------------------------------------------------------
+
+EdsError Canon::handleCameraAddedEvent(EdsVoid* context) {
+ instance()->cameraAdded();
+ return EDS_ERR_OK;
+}
+
+//-----------------------------------------------------------------
+
+void Canon::buildAvMap() {
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x00, "00"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x08, "1"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x0B, "1.1"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x0C, "1.2"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x0D, "1.2"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x10, "1.4"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x13, "1.6"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x14, "1.8"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x15, "1.8"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x18, "2"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x1B, "2.2"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x1C, "2.5"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x1D, "2.5"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x20, "2.8"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x23, "3.2"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x24, "3.5"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x25, "3.5"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x28, "4"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x2B, "4.5"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x2C, "4.5"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x2D, "5.0"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x30, "5.6"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x33, "6.3"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x34, "6.7"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x35, "7.1"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x38, "8"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x3B, "9"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x3C, "9.5"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x3D, "10"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x40, "11"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x43, "13"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x44, "13"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x45, "14"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x48, "16"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x4B, "18"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x4C, "19"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x4D, "20"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x50, "22"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x53, "25"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x54, "27"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x55, "29"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x58, "32"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x5B, "36"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x5C, "38"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x5D, "40"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x60, "45"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x63, "51"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x64, "54"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x65, "57"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x68, "64"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x6B, "72"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x6C, "76"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x6D, "80"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0x70, "91"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0xFF, "Auto"));
+ m_avMap.insert(std::pair<EdsUInt32, const char*>(0xffffffff, "unknown"));
+}
+
+//-----------------------------------------------------------------
+
+void Canon::buildIsoMap() {
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x00, "Auto"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x28, "6"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x30, "12"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x38, "25"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x40, "50"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x48, "100"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x4b, "125"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x4d, "160"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x50, "200"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x53, "250"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x55, "320"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x58, "400"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x5b, "500"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x5d, "640"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x60, "800"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x63, "1000"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x65, "1250"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x68, "1600"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x6b, "2000"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x6d, "2500"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x70, "3200"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x73, "4000"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x75, "5000"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x78, "6400"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x7b, "8000"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x7d, "10000"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x80, "12800"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x83, "16000"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x85, "20000"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x88, "25600"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x8b, "32000"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x8d, "40000"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x90, "51200"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0x98, "102400"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0xa0, "204800"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0xa8, "409600"));
+ m_isoMap.insert(std::pair<EdsUInt32, const char*>(0xffffffff, "unknown"));
+}
+
+//-----------------------------------------------------------------
+
+void Canon::buildTvMap() {
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x04, "Auto"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x0c, "Bulb"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x10, "30\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x13, "25\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x14, "20\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x15, "20\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x18, "15\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x1B, "13\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x1C, "10\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x1D, "10\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x20, "8\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x23, "6\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x24, "6\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x25, "5\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x28, "4\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x2B, "3\"2"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x2C, "3\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x2D, "2\"5"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x30, "2\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x33, "1\"6"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x34, "1\"5"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x35, "1\"3"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x38, "1\""));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x3B, "0\"8"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x3C, "0\"7"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x3D, "0\"6"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x40, "0\"5"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x43, "0\"4"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x44, "0\"3"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x45, "0\"3"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x48, "1/4"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x4B, "1/5"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x4C, "1/6"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x4D, "1/6"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x50, "1/8"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x53, "1/10"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x54, "1/10"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x55, "1/13"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x58, "1/15"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x5B, "1/20"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x5C, "1/20"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x5D, "1/25"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x60, "1/30"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x63, "1/40"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x64, "1/45"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x65, "1/50"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x68, "1/60"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x6B, "1/80"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x6C, "1/90"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x6D, "1/100"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x70, "1/125"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x73, "1/160"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x74, "1/180"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x75, "1/200"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x78, "1/250"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x7B, "1/320"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x7C, "1/350"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x7D, "1/400"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x80, "1/500"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x83, "1/640"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x84, "1/750"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x85, "1/800"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x88, "1/1000"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x8B, "1/1250"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x8C, "1/1500"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x8D, "1/1600"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x90, "1/2000"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x93, "1/2500"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x94, "1/3000"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x95, "1/3200"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x98, "1/4000"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x9B, "1/5000"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x9C, "1/6000"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0x9D, "1/6400"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0xA0, "1/8000"));
+ m_tvMap.insert(std::pair<EdsUInt32, const char*>(0xffffffff, "unknown"));
+}
+
+//-----------------------------------------------------------------
+
+void Canon::buildModeMap() {
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(0, "P"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(1, "Tv"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(2, "Av"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(3, "M"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(55, "FV"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(4, "Bulb"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(5, "A-DEP"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(6, "DEP"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(7, "C1"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(16, "C2"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(17, "C3"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(8, "Lock"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(9, "GreenMode"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(10, "Night Portrait"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(11, "Sports"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(13, "LandScape"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(14, "Close-Up"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(15, "No Strobo"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(12, "Portrait"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(19, "Creative Auto"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(20, "Movies"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(25, "SCN"));
+ m_modeMap.insert(
+ std::pair<EdsUInt32, const char*>(22, "Scene Intelligent Auto"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(29, "Creative filters"));
+ m_modeMap.insert(std::pair<EdsUInt32, const char*>(0xffffffff, "unknown"));
+}
+
+//-----------------------------------------------------------------
+
+void Canon::buildExposureMap() {
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x28, "+5"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x25, "+4 2/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x24, "+4 1/2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x23, "+4 1/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x20, "+4"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x1D, "+3 2/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x1C, "+3 1/2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x1B, "+3 1/3"));
+
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x18, "+3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x15, "+2 2/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x14, "+2 1/2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x13, "+2 1/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x10, "+2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x0d, "+1 2/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x0c, "+1 1/2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x0b, "+1 1/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x08, "+1"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x05, "+2/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x04, "+1/2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x03, "+1/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0x00, "0"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xfd, "-1/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xfc, "-1/2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xfb, "-2/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xf8, "-1"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xf5, "-1 1/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xf4, "-1 1/2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xf3, "-1 2/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xf0, "-2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xed, "-2 1/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xec, "-2 1/2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xeb, "-2 2/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xe8, "-3"));
+
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xE5, "-3 1/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xE4, "-3 1/2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xE3, "-3 2/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xE0, "-4"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xDD, "-4 1/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xDC, "-4 1/2"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xDB, "-4 2/3"));
+ m_exposureMap.insert(std::pair<EdsUInt32, const char*>(0xD8, "-5"));
+
+ m_exposureMap.insert(
+ std::pair<EdsUInt32, const char*>(0xffffffff, "unknown"));
+}
+
+//-----------------------------------------------------------------
+
+void Canon::buildWhiteBalanceMap() {
+ m_whiteBalanceMap.insert(
+ std::pair<EdsUInt32, const char*>(0, "Auto: Ambience Priority"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(1, "Daylight"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(2, "Cloudy"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(3, "Tungsten"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(4, "Fluorescent"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(5, "Flash"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(6, "Manual"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(8, "Shade"));
+ m_whiteBalanceMap.insert(
+ std::pair<EdsUInt32, const char*>(9, "Color Temperature"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(10, "Custom 1"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(11, "Custom 2"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(12, "Custom 3"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(15, "Manual 2"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(16, "Manual 3"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(18, "Manual 4"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(19, "Manual 5"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(20, "Custom 4"));
+ m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char*>(21, "Custom 5"));
+ m_whiteBalanceMap.insert(
+ std::pair<EdsUInt32, const char*>(23, "Auto: White Priority"));
+}
+
+//-----------------------------------------------------------------
+
+void Canon::buildImageQualityMap() {
+ m_imageQualityMap.insert(
+ std::pair<EdsUInt32, const char*>(EdsImageQuality_LR, "RAW"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRLJF, "RAW + Large Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRMJF, "RAW + Middle Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRSJF, "RAW + Small Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRLJN, "RAW + Large Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRMJN, "RAW + Middle Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRSJN, "RAW + Small Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRS1JF, "RAW + Small1 Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRS1JN, "RAW + Small1 Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRS2JF, "RAW + Small2 Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRS3JF, "RAW + Small3 Jpeg"));
+
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRLJ, "RAW + Large Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRM1J, "RAW + Middle1 Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRM2J, "RAW + Middle2 Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LRSJ, "RAW + Small Jpeg"));
+
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MR, "Middle Raw(Small RAW1)"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRLJF, "Middle Raw(Small RAW1) + Large Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRMJF, "Middle Raw(Small RAW1) + Middle Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRSJF, "Middle Raw(Small RAW1) + Small Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRLJN, "Middle Raw(Small RAW1) + Large Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRMJN, "Middle Raw(Small RAW1) + Middle Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRSJN, "Middle Raw(Small RAW1) + Small Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRS1JF, "Middle RAW + Small1 Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRS1JN, "Middle RAW + Small1 Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRS2JF, "Middle RAW + Small2 Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRS3JF, "Middle RAW + Small3 Jpeg"));
+
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRLJ, "Middle Raw + Large Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRM1J, "Middle Raw + Middle1 Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRM2J, "Middle Raw + Middle2 Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MRSJ, "Middle Raw + Small Jpeg"));
+
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SR, "Small RAW(Small RAW2)"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRLJF, "Small RAW(Small RAW2) + Large Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRMJF, "Small RAW(Small RAW2) + Middle Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRSJF, "Small RAW(Small RAW2) + Small Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRLJN, "Small RAW(Small RAW2) + Large Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRMJN, "Small RAW(Small RAW2) + Middle Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRSJN, "Small RAW(Small RAW2) + Small Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRS1JF, "Small RAW + Small1 Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRS1JN, "Small RAW + Small1 Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRS2JF, "Small RAW + Small2 Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRS3JF, "Small RAW + Small3 Jpeg"));
+
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRLJ, "Small RAW + Large Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRM1J, "Small RAW + Middle1 Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRM2J, "Small RAW + Middle2 Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SRSJ, "Small RAW + Small Jpeg"));
+
+ m_imageQualityMap.insert(
+ std::pair<EdsUInt32, const char*>(EdsImageQuality_CR, "CRAW"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRLJF, "CRAW + Large Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRMJF, "CRAW + Middle Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRM1JF, "CRAW + Middle1 Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRM2JF, "CRAW + Middle2 Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRSJF, "CRAW + Small Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRS1JF, "CRAW + Small1 Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRS2JF, "CRAW + Small2 Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRS3JF, "CRAW + Small3 Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRLJN, "CRAW + Large Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRMJN, "CRAW + Middle Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRM1JN, "CRAW + Middle1 Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRM2JN, "CRAW + Middle2 Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRSJN, "CRAW + Small Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRS1JN, "CRAW + Small1 Normal Jpeg"));
+
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRLJ, "CRAW + Large Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRM1J, "CRAW + Middle1 Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRM2J, "CRAW + Middle2 Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_CRSJ, "CRAW + Small Jpeg"));
+
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LJF, "Large Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_LJN, "Large Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MJF, "Middle Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_MJN, "Middle Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SJF, "Small Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_SJN, "Small Normal Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_S1JF, "Small1 Fine Jpeg"));
+ m_imageQualityMap.insert(std::pair<EdsUInt32, const char*>(
+ EdsImageQuality_S1JN, "Small1 Normal Jpeg"));
+ m_imageQualityMap.insert(
+ std::pair<EdsUInt32, const char*>(EdsImageQuality_S2JF, "Small2 Jpeg"));
+ m_imageQualityMap.insert(
+ std::pair<EdsUInt32, const char*>(EdsImageQuality_S3JF, "Small3 Jpeg"));
+
+ m_imageQualityMap.insert(
+ std::pair<EdsUInt32, const char*>(EdsImageQuality_LJ, "Large Jpeg"));
+ m_imageQualityMap.insert(
+ std::pair<EdsUInt32, const char*>(EdsImageQuality_M1J, "Middle1 Jpeg"));
+ m_imageQualityMap.insert(
+ std::pair<EdsUInt32, const char*>(EdsImageQuality_M2J, "Middle2 Jpeg"));
+ m_imageQualityMap.insert(
+ std::pair<EdsUInt32, const char*>(EdsImageQuality_SJ, "Small Jpeg"));
+}
+
+//-----------------------------------------------------------------
+
+void Canon::buildPictureStyleMap() {
+ m_pictureStyleMap.insert(
+ std::pair<EdsUInt32, const char*>(kEdsPictureStyle_Standard, "Standard"));
+ m_pictureStyleMap.insert(
+ std::pair<EdsUInt32, const char*>(kEdsPictureStyle_Portrait, "Portrait"));
+ m_pictureStyleMap.insert(std::pair<EdsUInt32, const char*>(
+ kEdsPictureStyle_Landscape, "Landscape"));
+ m_pictureStyleMap.insert(
+ std::pair<EdsUInt32, const char*>(kEdsPictureStyle_Neutral, "Neutral"));
+ m_pictureStyleMap.insert(
+ std::pair<EdsUInt32, const char*>(kEdsPictureStyle_Faithful, "Faithful"));
+ m_pictureStyleMap.insert(std::pair<EdsUInt32, const char*>(
+ kEdsPictureStyle_Monochrome, "Monochrome"));
+ m_pictureStyleMap.insert(
+ std::pair<EdsUInt32, const char*>(kEdsPictureStyle_Auto, "Auto"));
+ m_pictureStyleMap.insert(std::pair<EdsUInt32, const char*>(
+ kEdsPictureStyle_FineDetail, "Fine Detail"));
+ m_pictureStyleMap.insert(
+ std::pair<EdsUInt32, const char*>(kEdsPictureStyle_User1, "User 1"));
+ m_pictureStyleMap.insert(
+ std::pair<EdsUInt32, const char*>(kEdsPictureStyle_User2, "User 2"));
+ m_pictureStyleMap.insert(
+ std::pair<EdsUInt32, const char*>(kEdsPictureStyle_User3, "User 3"));
+ m_pictureStyleMap.insert(
+ std::pair<EdsUInt32, const char*>(kEdsPictureStyle_PC1, "Computer 1"));
+ m_pictureStyleMap.insert(
+ std::pair<EdsUInt32, const char*>(kEdsPictureStyle_PC2, "Computer 2"));
+ m_pictureStyleMap.insert(
+ std::pair<EdsUInt32, const char*>(kEdsPictureStyle_PC3, "Computer 3"));
+}
+#endif
\ No newline at end of file
diff --git a/toonz/sources/stopmotion/canon.h b/toonz/sources/stopmotion/canon.h
new file mode 100644
index 000000000..aba90b123
--- /dev/null
+++ b/toonz/sources/stopmotion/canon.h
@@ -0,0 +1,206 @@
+#pragma once
+
+#ifndef CANON_H
+#define CANON_H
+
+#ifdef WITH_CANON
+// Canon Includes
+#include "EDSDK.h"
+#include "EDSDKErrors.h"
+#include "EDSDKTypes.h"
+#endif
+
+#include "turbojpeg.h"
+
+// Toonz Includes
+#include "traster.h"
+#include "toonzqt/gutil.h"
+#include "toonzqt/dvdialog.h"
+
+#include "jpgconverter.h"
+
+#include <QObject>
+
+class QCamera;
+class QCameraInfo;
+class QDialog;
+class QTimer;
+class QSerialPort;
+
+#include <QThread>
+
+class Canon : public QObject {
+ Q_OBJECT
+
+public:
+ static Canon* instance() {
+ static Canon _instance;
+ return &_instance;
+ };
+
+private:
+#ifdef WITH_CANON
+ std::map<EdsUInt32, std::string> m_avMap, m_tvMap, m_isoMap, m_modeMap,
+ m_exposureMap, m_whiteBalanceMap, m_imageQualityMap, m_pictureStyleMap;
+ JpgConverter* m_converter;
+ static EdsError EDSCALLBACK handleObjectEvent(EdsObjectEvent event,
+ EdsBaseRef object,
+ EdsVoid* context);
+
+ static EdsError EDSCALLBACK handlePropertyEvent(EdsPropertyEvent event,
+ EdsPropertyID property,
+ EdsUInt32 param,
+ EdsVoid* context);
+
+ static EdsError EDSCALLBACK handleStateEvent(EdsStateEvent event,
+ EdsUInt32 parameter,
+ EdsVoid* context);
+ static EdsError EDSCALLBACK handleCameraAddedEvent(EdsVoid* context);
+
+ void buildAvMap();
+ void buildTvMap();
+ void buildIsoMap();
+ void buildModeMap();
+ void buildExposureMap();
+ void buildWhiteBalanceMap();
+ void buildImageQualityMap();
+ void buildPictureStyleMap();
+#endif
+
+private:
+ QStringList m_isoOptions, m_shutterSpeedOptions, m_apertureOptions,
+ m_exposureOptions, m_whiteBalanceOptions, m_colorTempOptions,
+ m_imageQualityOptions, m_pictureStyleOptions;
+
+public:
+ Canon();
+ ~Canon();
+
+#ifdef WITH_CANON
+ EdsError m_error = EDS_ERR_OK;
+ EdsUInt32 m_count = 0;
+ EdsCameraListRef m_cameraList = NULL;
+ EdsCameraRef m_camera = NULL;
+ EdsUInt32 m_liveViewZoom = 1;
+ bool m_isSDKLoaded = false;
+ bool m_sessionOpen = false;
+ bool m_zooming = false;
+ std::string m_cameraName;
+ TDimension m_proxyImageDimensions = TDimension(0, 0);
+ TPointD m_proxyDpi = TPointD(0.0, 0.0);
+ TPoint m_liveViewZoomOffset = TPoint(0, 0);
+ bool m_liveViewZoomReadyToPick = true;
+ TPointD m_liveViewZoomPickPoint = TPointD(0.0, 0.0);
+ TPoint m_zoomRectDimensions = TPoint(0, 0);
+ TPoint m_calculatedZoomPoint = TPoint(0, 0);
+ TPoint m_finalZoomPoint = TPoint(0, 0);
+ TRect m_zoomRect = TRect(0, 0, 0, 0);
+#endif
+ bool m_useScaledImages = true;
+ bool m_converterSucceeded = false;
+ bool m_pickLiveViewZoom = false;
+ TDimension m_fullImageDimensions = TDimension(0, 0);
+ TPointD m_fullImageDpi = TPointD(0.0, 0.0);
+
+// Canon Commands
+#ifdef WITH_CANON
+ void cameraAdded();
+ void closeAll();
+ void resetCanon(bool liveViewOpen);
+ void closeCanonSDK();
+ int getCameraCount();
+ std::string getCameraName();
+ EdsError initializeCanonSDK();
+ EdsCameraListRef getCameraList();
+ EdsError releaseCameraList();
+ EdsError getCamera(int index);
+ EdsError releaseCamera();
+ EdsError openCameraSession();
+ EdsError closeCameraSession();
+ bool downloadImage(EdsBaseRef object);
+ EdsError takePicture();
+ EdsError startCanonLiveView();
+ EdsError endCanonLiveView();
+ bool downloadEVFData();
+ QStringList getIsoOptions() { return m_isoOptions; }
+ QStringList getShutterSpeedOptions() { return m_shutterSpeedOptions; }
+ QStringList getApertureOptions() { return m_apertureOptions; }
+ QStringList getExposureOptions() { return m_exposureOptions; }
+ QStringList getWhiteBalanceOptions() { return m_whiteBalanceOptions; }
+ QStringList getColorTemperatureOptions() { return m_colorTempOptions; }
+ QStringList getImageQualityOptions() { return m_imageQualityOptions; }
+ QStringList getPictureStyleOptions() { return m_pictureStyleOptions; }
+ EdsError getAvailableShutterSpeeds();
+ EdsError getAvailableIso();
+ EdsError getAvailableApertures();
+ EdsError getAvailableExposureCompensations();
+ EdsError getAvailableWhiteBalances();
+ EdsError getAvailableImageQualities();
+ EdsError getAvailablePictureStyles();
+ void buildColorTemperatures();
+ QString getCurrentShutterSpeed();
+ QString getCurrentIso();
+ QString getCurrentAperture();
+ QString getCurrentExposureCompensation();
+ QString getCurrentWhiteBalance();
+ QString getCurrentColorTemperature();
+ QString getCurrentImageQuality();
+ QString getCurrentPictureStyle();
+ QString getCurrentBatteryLevel();
+ EdsError setShutterSpeed(QString shutterSpeed);
+ EdsError setIso(QString iso);
+ EdsError setAperture(QString aperture);
+ EdsError setExposureCompensation(QString exposure);
+ EdsError setWhiteBalance(QString whiteBalance);
+ EdsError setColorTemperature(QString temp);
+ EdsError setImageQuality(QString quality);
+ EdsError setPictureStyle(QString style);
+ QString getMode();
+ void refreshOptions();
+ EdsError zoomLiveView();
+ EdsError setZoomPoint();
+ void makeZoomPoint(TPointD pos);
+ void toggleZoomPicking();
+ void calculateZoomPoint();
+ EdsError focusNear();
+ EdsError focusFar();
+ EdsError focusNear2();
+ EdsError focusFar2();
+ EdsError focusNear3();
+ EdsError focusFar3();
+ void extendCameraOnTime();
+ void setUseScaledImages(bool on);
+ bool getUseScaledImages() { return m_useScaledImages; }
+#endif
+
+public slots:
+ void onImageReady(const bool&);
+ void onFinished();
+
+signals:
+ // canon signals
+ void apertureOptionsChanged();
+ void isoOptionsChanged();
+ void shutterSpeedOptionsChanged();
+ void exposureOptionsChanged();
+ void whiteBalanceOptionsChanged();
+ void colorTemperatureChanged();
+ void imageQualityOptionsChanged();
+ void pictureStyleOptionsChanged();
+ void apertureChangedSignal(QString);
+ void isoChangedSignal(QString);
+ void shutterSpeedChangedSignal(QString);
+ void exposureChangedSignal(QString);
+ void whiteBalanceChangedSignal(QString);
+ void colorTemperatureChangedSignal(QString);
+ void imageQualityChangedSignal(QString);
+ void pictureStyleChangedSignal(QString);
+ void modeChanged();
+ void focusCheckToggled(bool);
+ void pickFocusCheckToggled(bool);
+ void scaleFullSizeImagesSignal(bool);
+ void newCanonImageReady();
+ void canonCameraChanged(QString);
+};
+
+#endif // CANON_H
\ No newline at end of file
diff --git a/toonz/sources/stopmotion/jpgconverter.cpp b/toonz/sources/stopmotion/jpgconverter.cpp
new file mode 100644
index 000000000..ec785751d
--- /dev/null
+++ b/toonz/sources/stopmotion/jpgconverter.cpp
@@ -0,0 +1,181 @@
+#include "jpgconverter.h"
+
+#include <QFile>
+#include <QDataStream>
+//=============================================================================
+//=============================================================================
+
+JpgConverter::JpgConverter() {}
+JpgConverter::~JpgConverter() {}
+
+#ifdef WITH_CANON
+
+void JpgConverter::setStream(EdsStreamRef stream) { m_stream = stream; }
+
+void JpgConverter::convertFromJpg() {
+#ifdef MACOSX
+ UInt64 mySize = 0;
+#else
+ unsigned __int64 mySize = 0;
+#endif
+ unsigned char* data = NULL;
+ EdsError err = EdsGetPointer(m_stream, (EdsVoid**)&data);
+ err = EdsGetLength(m_stream, &mySize);
+
+ int width, height, pixelFormat;
+ int inSubsamp, inColorspace;
+ tjhandle tjInstance = NULL;
+ unsigned char* imgBuf = NULL;
+ tjInstance = tjInitDecompress();
+ tjDecompressHeader3(tjInstance, data, mySize, &width, &height, &inSubsamp,
+ &inColorspace);
+
+ if (width < 0 || height < 0) {
+ emit(imageReady(false));
+ return;
+ }
+
+ pixelFormat = TJPF_BGRX;
+ imgBuf = (unsigned char*)tjAlloc(width * height * tjPixelSize[pixelFormat]);
+ int flags = 0;
+ flags |= TJFLAG_BOTTOMUP;
+
+ int factorsNum;
+ tjscalingfactor scalingFactor = {1, 1};
+ tjscalingfactor* factor = tjGetScalingFactors(&factorsNum);
+ int i = 0;
+ int tempWidth, tempHeight;
+ while (i < factorsNum) {
+ scalingFactor = factor[i];
+ i++;
+ tempWidth = TJSCALED(width, scalingFactor);
+ tempHeight = TJSCALED(height, scalingFactor);
+ }
+ tjDecompress2(tjInstance, data, mySize, imgBuf, width,
+ width * tjPixelSize[pixelFormat], height, pixelFormat, flags);
+
+ m_finalImage = TRaster32P(width, height);
+ m_finalImage->lock();
+ uchar* rawData = m_finalImage->getRawData();
+ memcpy(rawData, imgBuf, width * height * tjPixelSize[pixelFormat]);
+ m_finalImage->unlock();
+
+ tjFree(imgBuf);
+ imgBuf = NULL;
+ tjDestroy(tjInstance);
+ tjInstance = NULL;
+
+ if (m_stream != NULL) {
+ EdsRelease(m_stream);
+ m_stream = NULL;
+ }
+ data = NULL;
+ emit(imageReady(true));
+}
+
+void JpgConverter::run() { convertFromJpg(); }
+
+#endif
+
+//-----------------------------------------------------------------------------
+
+void JpgConverter::saveJpg(TRaster32P image, TFilePath path) {
+ unsigned char* jpegBuf = NULL; /* Dynamically allocate the JPEG buffer */
+ unsigned long jpegSize = 0;
+ int pixelFormat = TJPF_BGRX;
+ int outQual = 95;
+ int subSamp = TJSAMP_411;
+ bool success = false;
+ tjhandle tjInstance;
+
+ int width = image->getLx();
+ int height = image->getLy();
+ int flags = 0;
+ flags |= TJFLAG_BOTTOMUP;
+
+ image->lock();
+ uchar* rawData = image->getRawData();
+ if ((tjInstance = tjInitCompress()) != NULL) {
+ if (tjCompress2(tjInstance, rawData, width, 0, height, pixelFormat,
+ &jpegBuf, &jpegSize, subSamp, outQual, flags) >= 0) {
+ success = true;
+ }
+ }
+ image->unlock();
+ tjDestroy(tjInstance);
+ tjInstance = NULL;
+
+ if (success) {
+ /* Write the JPEG image to disk. */
+ QFile fullImage(path.getQString());
+ fullImage.open(QIODevice::WriteOnly);
+ QDataStream dataStream(&fullImage);
+ dataStream.writeRawData((const char*)jpegBuf, jpegSize);
+ fullImage.close();
+ }
+ tjFree(jpegBuf);
+ jpegBuf = NULL;
+}
+
+//-----------------------------------------------------------------------------
+
+bool JpgConverter::loadJpg(TFilePath path, TRaster32P& image) {
+ long size;
+ int inSubsamp, inColorspace, width, height;
+ unsigned long jpegSize;
+ unsigned char* jpegBuf;
+ FILE* jpegFile;
+ QString qPath = path.getQString();
+ QByteArray ba = qPath.toLocal8Bit();
+ const char* c_path = ba.data();
+ bool success = true;
+ tjhandle tjInstance;
+
+ /* Read the JPEG file into memory. */
+ if ((jpegFile = fopen(c_path, "rb")) == NULL) success = false;
+ if (success && fseek(jpegFile, 0, SEEK_END) < 0 ||
+ ((size = ftell(jpegFile)) < 0) || fseek(jpegFile, 0, SEEK_SET) < 0)
+ success = false;
+ if (success && size == 0) success = false;
+ jpegSize = (unsigned long)size;
+ if (success && (jpegBuf = (unsigned char*)tjAlloc(jpegSize)) == NULL)
+ success = false;
+ if (success && fread(jpegBuf, jpegSize, 1, jpegFile) < 1) success = false;
+ fclose(jpegFile);
+ jpegFile = NULL;
+
+ if (success && (tjInstance = tjInitDecompress()) == NULL) success = false;
+
+ if (success &&
+ tjDecompressHeader3(tjInstance, jpegBuf, jpegSize, &width, &height,
+ &inSubsamp, &inColorspace) < 0)
+ success = false;
+
+ int pixelFormat = TJPF_BGRX;
+ unsigned char* imgBuf = NULL;
+ if (success &&
+ (imgBuf = tjAlloc(width * height * tjPixelSize[pixelFormat])) == NULL)
+ success = false;
+
+ int flags = 0;
+ flags |= TJFLAG_BOTTOMUP;
+ if (success &&
+ tjDecompress2(tjInstance, jpegBuf, jpegSize, imgBuf, width, 0, height,
+ pixelFormat, flags) < 0)
+ success = false;
+ tjFree(jpegBuf);
+ jpegBuf = NULL;
+ tjDestroy(tjInstance);
+ tjInstance = NULL;
+
+ image = TRaster32P(width, height);
+ image->lock();
+ uchar* rawData = image->getRawData();
+ memcpy(rawData, imgBuf, width * height * tjPixelSize[pixelFormat]);
+ image->unlock();
+
+ tjFree(imgBuf);
+ imgBuf = NULL;
+
+ return success;
+}
\ No newline at end of file
diff --git a/toonz/sources/stopmotion/jpgconverter.h b/toonz/sources/stopmotion/jpgconverter.h
new file mode 100644
index 000000000..0e2b8944e
--- /dev/null
+++ b/toonz/sources/stopmotion/jpgconverter.h
@@ -0,0 +1,61 @@
+#pragma once
+
+#ifndef JPGCONVERTER_H
+#define JPGCONVERTER_H
+
+//#include "opencv2/opencv.hpp"
+#include "turbojpeg.h"
+
+#ifdef WITH_CANON
+// Canon Includes
+#include "EDSDK.h"
+#include "EDSDKErrors.h"
+#include "EDSDKTypes.h"
+#endif
+
+// Toonz Includes
+#include "traster.h"
+#include "tfilepath.h"
+
+#include <QObject>
+#include <QThread>
+
+class QCamera;
+class QCameraInfo;
+
+//=============================================================================
+// JpgConverter
+//-----------------------------------------------------------------------------
+
+class JpgConverter : public QThread {
+ Q_OBJECT
+#ifdef WITH_CANON
+ EdsStreamRef m_stream;
+#endif
+ TRaster32P m_finalImage;
+ bool m_scale = false;
+ int m_scaleWidth = 0;
+
+public:
+ JpgConverter();
+ ~JpgConverter();
+ static void saveJpg(TRaster32P, TFilePath path);
+ static bool loadJpg(TFilePath path, TRaster32P& image);
+#ifdef WITH_CANON
+ void setStream(EdsStreamRef stream);
+ void setScale(bool scale) { m_scale = scale; }
+ void setScaleWidth(bool scaleWidth) { m_scaleWidth = scaleWidth; }
+ TRaster32P getImage() { return m_finalImage; }
+ void convertFromJpg();
+
+protected:
+ void run() override;
+#endif
+
+signals:
+ void imageReady(bool);
+};
+
+//#endif
+
+#endif // JPGCONVERTER_H
\ No newline at end of file
diff --git a/toonz/sources/stopmotion/stopmotion.cpp b/toonz/sources/stopmotion/stopmotion.cpp
index b400ece3f..4b69f3f6b 100644
--- a/toonz/sources/stopmotion/stopmotion.cpp
+++ b/toonz/sources/stopmotion/stopmotion.cpp
@@ -1,17 +1,5 @@
#include "stopmotion.h"
-#ifdef WIN32
-#include <Windows.h>
-#include <mfobjects.h>
-#include <mfapi.h>
-#include <mfidl.h>
-#pragma comment(lib, "Mfplat.lib")
-#pragma comment(lib, "Mf.lib")
-#pragma comment(lib, "Mfreadwrite.lib")
-#pragma comment(lib, "mfuuid.lib")
-#pragma comment(lib, "shlwapi.lib")
-#endif
-
// TnzCore includes
#include "menubarcommandids.h"
#include "tapp.h"
@@ -21,6 +9,8 @@
#include "penciltestpopup.h"
#include "tlevel_io.h"
#include "toutputproperties.h"
+#include "filebrowserpopup.h"
+#include "tunit.h"
#include "toonz/namebuilder.h"
#include "toonz/preferences.h"
@@ -34,10 +24,8 @@
#include "toonz/stage.h"
#include "toonz/txsheethandle.h"
#include "toonz/txshlevelhandle.h"
-#include "toonz/txshsimplelevel.h"
#include "toonz/levelproperties.h"
#include "toonz/tstageobjecttree.h"
-
#include "toonzqt/menubarcommand.h"
#include <QApplication>
@@ -49,18 +37,16 @@
#include <QFile>
#include <QString>
#include <QTimer>
+#include <QXmlStreamWriter>
+#include <QXmlStreamReader>
// Connected camera
-TEnv::IntVar StopMotionUseScaledImages("StopMotionUseScaledImages", 0);
TEnv::IntVar StopMotionOpacity("StopMotionOpacity", 100);
-TEnv::IntVar StopMotionUseDirectShow("StopMotionUseDirectShow", 1);
TEnv::IntVar StopMotionAlwaysLiveView("StopMotionAlwaysLiveView", 0);
-
-TEnv::IntVar StopMotionBlackCapture("StopMotionBlackCapture", 0);
TEnv::IntVar StopMotionPlaceOnXSheet("StopMotionPlaceOnXSheet", 1);
TEnv::IntVar StopMotionReviewTime("StopMotionReviewTime", 1);
-TEnv::IntVar StopMotionUseMjpg("StopMotionUseMjpg", 1);
TEnv::IntVar StopMotionUseNumpad("StopMotionUseNumpad", 0);
+TEnv::IntVar StopMotionDrawBeneathLevels("StopMotionDrawBeneathLevels", 1);
// Connected camera
TEnv::StringVar StopMotionCameraName("CamCapCameraName", "");
@@ -68,7 +54,6 @@ TEnv::StringVar StopMotionCameraName("CamCapCameraName", "");
TEnv::StringVar StopMotionCameraResolution("CamCapCameraResolution", "");
namespace {
-bool l_quitLoop = false;
TPointD getCurrentCameraDpi() {
TCamera *camera =
@@ -215,95 +200,22 @@ bool getRasterLevelSize(TXshLevel *level, TDimension &dim) {
}; // namespace
-//=============================================================================
-//=============================================================================
-
-JpgConverter::JpgConverter() {}
-JpgConverter::~JpgConverter() {}
-
-void JpgConverter::setStream(EdsStreamRef stream) { m_stream = stream; }
-
-void JpgConverter::convertFromJpg() {
- unsigned __int64 mySize = 0;
- unsigned char *data = NULL;
- EdsError err = EdsGetPointer(m_stream, (EdsVoid **)&data);
- err = EdsGetLength(m_stream, &mySize);
-
- int width, height, pixelFormat;
- int inSubsamp, inColorspace;
- tjhandle tjInstance = NULL;
- unsigned char *imgBuf = NULL;
- tjInstance = tjInitDecompress();
- tjDecompressHeader3(tjInstance, data, mySize, &width, &height, &inSubsamp,
- &inColorspace);
-
- if (width < 0 || height < 0) {
- emit(imageReady(false));
- return;
- }
-
- pixelFormat = TJPF_BGRX;
- imgBuf = (unsigned char *)tjAlloc(width * height * tjPixelSize[pixelFormat]);
- int flags = 0;
-#ifdef WIN32
- flags |= TJFLAG_BOTTOMUP;
-#endif
- int factorsNum;
- tjscalingfactor scalingFactor = {1, 1};
- tjscalingfactor *factor = tjGetScalingFactors(&factorsNum);
- int i = 0;
- int tempWidth, tempHeight;
- while (i < factorsNum) {
- scalingFactor = factor[i];
- i++;
- tempWidth = TJSCALED(width, scalingFactor);
- tempHeight = TJSCALED(height, scalingFactor);
- }
- tjDecompress2(tjInstance, data, mySize, imgBuf, width,
- width * tjPixelSize[pixelFormat], height, pixelFormat, flags);
-
- m_finalImage = TRaster32P(width, height);
- m_finalImage->lock();
- uchar *rawData = m_finalImage->getRawData();
- memcpy(rawData, imgBuf, width * height * tjPixelSize[pixelFormat]);
- m_finalImage->unlock();
-
- tjFree(imgBuf);
- imgBuf = NULL;
- tjDestroy(tjInstance);
- tjInstance = NULL;
+//-----------------------------------------------------------------------------
- if (m_stream != NULL) {
- EdsRelease(m_stream);
- m_stream = NULL;
- }
- data = NULL;
- emit(imageReady(true));
-}
+StopMotion::StopMotion() {
+ m_opacity = StopMotionOpacity;
-void JpgConverter::run() { convertFromJpg(); }
+ m_webcam = new Webcam();
+ m_canon = Canon::instance();
+ m_serial = new StopMotionSerial();
+ m_light = new StopMotionLight();
-//-----------------------------------------------------------------------------
+ m_alwaysLiveView = StopMotionAlwaysLiveView;
-StopMotion::StopMotion() {
- m_opacity = StopMotionOpacity;
- m_useScaledImages = StopMotionUseScaledImages;
- buildAvMap();
- buildIsoMap();
- buildTvMap();
- buildModeMap();
- buildExposureMap();
- buildWhiteBalanceMap();
- buildColorTemperatures();
- buildImageQualityMap();
- buildPictureStyleMap();
- m_useDirectShow = StopMotionUseDirectShow;
- m_useMjpg = StopMotionUseMjpg;
- m_alwaysLiveView = StopMotionAlwaysLiveView;
- m_blackCapture = StopMotionBlackCapture;
m_placeOnXSheet = StopMotionPlaceOnXSheet;
m_reviewTime = StopMotionReviewTime;
m_useNumpadShortcuts = StopMotionUseNumpad;
+ m_drawBeneathLevels = StopMotionDrawBeneathLevels;
m_numpadForStyleSwitching =
Preferences::instance()->isUseNumpadForSwitchingStylesEnabled();
setUseNumpadShortcuts(m_useNumpadShortcuts);
@@ -311,21 +223,15 @@ StopMotion::StopMotion() {
m_timer = new QTimer(this);
m_reviewTimer = new QTimer(this);
m_reviewTimer->setSingleShot(true);
+ m_intervalTimer = new QTimer(this);
+ m_countdownTimer = new QTimer(this);
+ m_webcamOverlayTimer = new QTimer(this);
- m_fullScreen1 = new QDialog();
- m_fullScreen1->setModal(false);
- m_fullScreen1->setStyleSheet("background-color:black;");
- m_screenCount = QApplication::desktop()->screenCount();
- if (m_screenCount > 1) {
- m_fullScreen2 = new QDialog();
- m_fullScreen2->setModal(false);
- m_fullScreen2->setStyleSheet("background-color:black;");
- if (m_screenCount == 3) {
- m_fullScreen3 = new QDialog();
- m_fullScreen3->setModal(false);
- m_fullScreen3->setStyleSheet("background-color:black;");
- }
- }
+ // Make the interval timer single-shot. When the capture finished, restart
+ // timer for next frame.
+ // This is because capturing and saving the image needs some time.
+ m_intervalTimer->setSingleShot(true);
+ m_webcamOverlayTimer->setSingleShot(true);
TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet();
TSceneHandle *sceneHandle = TApp::instance()->getCurrentScene();
@@ -337,12 +243,20 @@ StopMotion::StopMotion() {
ret = ret && connect(m_reviewTimer, SIGNAL(timeout()), this,
SLOT(onReviewTimeout()));
ret = ret && connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimeout()));
- ret =
- ret && connect(this, SIGNAL(newImageReady()), this, SLOT(importImage()));
+
ret = ret && connect(sceneHandle, SIGNAL(sceneSwitched()), this,
SLOT(onSceneSwitched()));
ret = ret && connect(frameHandle, SIGNAL(isPlayingStatusChanged()), this,
SLOT(onPlaybackChanged()));
+ ret = ret && connect(m_intervalTimer, SIGNAL(timeout()), this,
+ SLOT(onIntervalCaptureTimerTimeout()));
+ ret = ret && connect(m_webcamOverlayTimer, SIGNAL(timeout()), this,
+ SLOT(captureWebcamOnTimeout()));
+ ret = ret && connect(m_canon, SIGNAL(newCanonImageReady()), this,
+ SLOT(importImage()));
+ assert(ret);
+ ret = ret && connect(m_canon, SIGNAL(canonCameraChanged(QString)), this,
+ SLOT(onCanonCameraChanged(QString)));
assert(ret);
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
@@ -351,28 +265,22 @@ StopMotion::StopMotion() {
m_filePath = scene->getDefaultLevelPath(OVL_TYPE, m_levelName.toStdWString())
.getParentDir()
.getQString();
-
- // set handler for a camera detected
- initializeCanonSDK();
- if (!m_error)
- m_error = EdsSetCameraAddedHandler(StopMotion::handleCameraAddedEvent,
- (EdsVoid *)this);
}
//-----------------------------------------------------------------
StopMotion::~StopMotion() {
- if (m_liveViewStatus != LiveViewClosed) endLiveView();
- if (m_sessionOpen) closeCameraSession();
- if (m_camera) releaseCamera();
- if (m_cameraList != NULL) releaseCameraList();
- if (m_isSDKLoaded) closeCanonSDK();
- setUseNumpadShortcuts(false);
+ disconnectAllCameras();
+#ifdef WITH_CANON
+ m_canon->closeAll();
+#endif
}
//-----------------------------------------------------------------------------
void StopMotion::onSceneSwitched() {
+ disconnectAllCameras();
+
TApp *app = TApp::instance();
ToonzScene *scene = app->getCurrentScene()->getScene();
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
@@ -380,13 +288,14 @@ void StopMotion::onSceneSwitched() {
m_filePath = scene->getDefaultLevelPath(OVL_TYPE, m_levelName.toStdWString())
.getParentDir()
.getQString();
- m_frameNumber = 1;
- m_xSheetFrameNumber = 0;
+ m_frameNumber = 1;
+ m_liveViewImageMap.clear();
TLevelSet *levelSet = scene->getLevelSet();
std::vector<TXshLevel *> levels;
levelSet->listLevels(levels);
- int size = levels.size();
+ int size = levels.size();
+ bool found = false;
for (int i = 0; i < size; i++) {
TXshLevel *level = levels[i];
if (level->getType() == OVL_XSHLEVEL) {
@@ -398,10 +307,18 @@ void StopMotion::onSceneSwitched() {
m_levelName = QString::fromStdWString(sl->getName());
m_frameNumber = sl->getFrameCount() + 1;
setXSheetFrameNumber(xsh->getFrameCount() + 1);
+ loadXmlFile();
+ buildLiveViewMap(sl);
+ m_sl = sl;
+ found = true;
break;
}
}
}
+
+ if (!found) {
+ setXSheetFrameNumber(1);
+ }
emit(levelNameChanged(m_levelName));
emit(filePathChanged(m_filePath));
emit(frameNumberChanged(m_frameNumber));
@@ -411,8 +328,87 @@ void StopMotion::onSceneSwitched() {
//-----------------------------------------------------------------
+bool StopMotion::buildLiveViewMap(TXshSimpleLevel *sl) {
+ m_liveViewImageMap.clear();
+ TApp *app = TApp::instance();
+ ToonzScene *scene = app->getCurrentScene()->getScene();
+ TXsheet *xsh = scene->getXsheet();
+
+ std::wstring levelName = m_levelName.toStdWString();
+ if (levelName.empty()) {
+ return false;
+ }
+
+ if (m_usingWebcam) {
+ return false;
+ }
+
+ TFilePath liveViewFolder = scene->decodeFilePath(
+ TFilePath(m_filePath) + TFilePath(levelName + L"_LiveView"));
+
+ TFilePath levelFp = TFilePath(m_filePath) +
+ TFilePath(levelName + L".." + m_fileType.toStdWString());
+ TFilePath actualLevelFp = scene->decodeFilePath(levelFp);
+ TFilePath liveViewFp =
+ scene->decodeFilePath(liveViewFolder + TFilePath(levelName + L"..jpg"));
+
+ if (!TSystem::doesExistFileOrLevel(liveViewFolder)) return false;
+
+ int count = sl->getFrameCount();
+ std::vector<TFrameId> fids;
+ sl->getFids(fids);
+ for (TFrameId id : fids) {
+ int frameNumber = id.getNumber();
+ if (TSystem::doesExistFileOrLevel(liveViewFp.withFrame(frameNumber))) {
+ TRaster32P image;
+ JpgConverter::loadJpg(liveViewFp.withFrame(frameNumber), image);
+ m_liveViewImageMap.insert(std::pair<int, TRaster32P>(frameNumber, image));
+ }
+ }
+
+ if (m_liveViewImageMap.size() > 0) {
+ return true;
+ } else
+ return false;
+}
+
+//-----------------------------------------------------------------
+
+void StopMotion::disconnectAllCameras() {
+#ifdef WITH_CANON
+ if (m_liveViewStatus > LiveViewClosed) {
+ m_canon->resetCanon(true);
+ } else {
+ m_canon->resetCanon(false);
+ }
+#endif
+
+ if (m_usingWebcam) {
+ m_webcam->releaseWebcam();
+ m_usingWebcam = false;
+ }
+ m_webcam->clearWebcam();
+
+ m_liveViewStatus = LiveViewClosed;
+ setTEnvCameraName("");
+
+ m_isTimeLapse = false;
+ m_intervalStarted = false;
+ m_intervalTimer->stop();
+ m_countdownTimer->stop();
+ emit(intervalToggled(false));
+
+ emit(liveViewChanged(false));
+ emit(liveViewStopped());
+ emit(newCameraSelected(0, false));
+ toggleNumpadShortcuts(false);
+}
+
+//-----------------------------------------------------------------
+
void StopMotion::onPlaybackChanged() {
- if (TApp::instance()->getCurrentFrame()->isPlaying() || m_liveViewStatus == 0)
+ if (TApp::instance()->getCurrentFrame()->isPlaying() ||
+ m_liveViewStatus == LiveViewClosed)
return;
int r0, r1, step;
@@ -461,14 +457,6 @@ void StopMotion::raiseOpacity() {
//-----------------------------------------------------------------
-void StopMotion::setUseScaledImages(bool on) {
- m_useScaledImages = on;
- StopMotionUseScaledImages = int(on);
- emit(scaleFullSizeImagesSignal(on));
-}
-
-//-----------------------------------------------------------------
-
void StopMotion::setAlwaysLiveView(bool on) {
m_alwaysLiveView = on;
StopMotionAlwaysLiveView = int(on);
@@ -477,14 +465,6 @@ void StopMotion::setAlwaysLiveView(bool on) {
//-----------------------------------------------------------------
-void StopMotion::setBlackCapture(bool on) {
- m_blackCapture = on;
- StopMotionBlackCapture = int(on);
- emit(blackCaptureSignal(on));
-}
-
-//-----------------------------------------------------------------
-
void StopMotion::setPlaceOnXSheet(bool on) {
m_placeOnXSheet = on;
StopMotionPlaceOnXSheet = int(on);
@@ -501,16 +481,71 @@ void StopMotion::setReviewTime(int time) {
//-----------------------------------------------------------------
-void StopMotion::setUseMjpg(bool on) {
- m_useMjpg = on;
- StopMotionUseMjpg = int(on);
- emit(useMjpgSignal(on));
+void StopMotion::jumpToCameraFrame() {
+ if (m_liveViewStatus == LiveViewPaused && !m_userCalledPause) {
+ m_liveViewStatus = LiveViewOpen;
+ }
+ if (m_hasLineUpImage) m_showLineUpImage = true;
+ TApp::instance()->getCurrentFrame()->setFrame(m_xSheetFrameNumber - 1);
}
//-----------------------------------------------------------------
-void StopMotion::jumpToCameraFrame() {
- TApp::instance()->getCurrentFrame()->setFrame(m_xSheetFrameNumber - 1);
+void StopMotion::removeStopMotionFrame() {
+ if (m_xSheetFrameNumber == 1) return;
+ TApp *app = TApp::instance();
+ ToonzScene *scene = app->getCurrentScene()->getScene();
+ TXsheet *xsh = scene->getXsheet();
+
+ int row = m_xSheetFrameNumber - 2;
+
+ // find which column the level is on.
+ // check with the current column first
+ int col = app->getCurrentColumn()->getColumnIndex();
+ TXshCell cell = xsh->getCell(row, col);
+ TXshSimpleLevelP sl;
+ bool found = false;
+ if (!cell.isEmpty()) {
+ if (cell.getSimpleLevel() != 0) {
+ sl = cell.getSimpleLevel();
+ if (sl.getPointer()->getName() == m_levelName.toStdWString()) {
+ found = true;
+ }
+ }
+ }
+
+ if (!found) {
+ int cols = xsh->getColumnCount();
+ for (int i = 0; i < cols; i++) {
+ cell = xsh->getCell(row, i);
+ if (!cell.isEmpty()) {
+ if (cell.getSimpleLevel() != 0) {
+ sl = cell.getSimpleLevel();
+ if (sl.getPointer()->getName() == m_levelName.toStdWString()) {
+ found = true;
+ col = i;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (!found) {
+ // DVGui::error(tr("Could not find an xsheet level with the current
+ // level"));
+ return;
+ }
+
+ TXshCellColumn *xshCellColumn = xsh->getColumn(col)->getCellColumn();
+ if (!xshCellColumn) return;
+
+ xshCellColumn->removeCells(row, 1);
+
+ app->getCurrentScene()->getScene()->getXsheet()->updateFrameCount();
+ setXSheetFrameNumber(m_xSheetFrameNumber - 1);
+ app->getCurrentFrame()->prevFrame();
+ app->getCurrentScene()->notifySceneChanged();
+ app->getCurrentXsheet()->notifyXsheetChanged();
}
//-----------------------------------------------------------------
@@ -521,13 +556,86 @@ void StopMotion::setUseNumpadShortcuts(bool on) {
emit(useNumpadSignal(on));
}
+//-----------------------------------------------------------------
+
+void StopMotion::setDrawBeneathLevels(bool on) {
+ m_drawBeneathLevels = on;
+ StopMotionDrawBeneathLevels = int(on);
+ emit(drawBeneathLevelsSignal(on));
+}
+
+//-----------------------------------------------------------------
+
+void StopMotion::toggleInterval(bool on) {
+ m_isTimeLapse = on;
+ emit(intervalToggled(on));
+}
+
+//-----------------------------------------------------------------
+
+void StopMotion::startInterval() {
+ if (m_liveViewStatus > 1) {
+ m_intervalTimer->start(m_intervalTime * 1000);
+ if (m_intervalTime != 0) m_countdownTimer->start(100);
+ m_intervalStarted = true;
+ emit(intervalStarted());
+ } else {
+ DVGui::warning(tr("Please start live view before using time lapse."));
+ m_intervalStarted = false;
+ emit(intervalStopped());
+ }
+}
+
+//-----------------------------------------------------------------
+
+void StopMotion::stopInterval() {
+ m_intervalTimer->stop();
+ m_countdownTimer->stop();
+ m_intervalStarted = false;
+ emit(intervalStopped());
+}
+
+//-----------------------------------------------------------------
+
+void StopMotion::setIntervalAmount(int value) {
+ m_intervalTime = value;
+ emit(intervalAmountChanged(value));
+}
+
+//-----------------------------------------------------------------
+
+void StopMotion::onIntervalCaptureTimerTimeout() {
+ if (m_liveViewStatus > 0) {
+ captureImage();
+ } else {
+ DVGui::warning(tr("Please start live view before using time lapse."));
+ m_intervalStarted = false;
+ emit(intervalStopped());
+ }
+}
+
+//-----------------------------------------------------------------
+
+void StopMotion::restartInterval() {
+ // restart interval timer for capturing next frame (it is single shot)
+ if (m_isTimeLapse && m_intervalStarted) {
+ m_intervalTimer->start(m_intervalTime * 1000);
+ // restart the count down as well (for aligning the timing. It is not
+ // single shot)
+ if (m_intervalTime != 0) m_countdownTimer->start(100);
+ }
+}
+
+//-----------------------------------------------------------------
+
void StopMotion::toggleNumpadShortcuts(bool on) {
// can't just return if this feature is off
// it could have been toggled while the camera was active
if (!m_useNumpadShortcuts) on = false;
- CommandManager *comm = CommandManager::instance();
+ CommandManager *comm = CommandManager::instance();
if (on) {
+ m_oldActionMap.clear();
// if turning it on, get all old shortcuts
if (m_numpadForStyleSwitching) {
Preferences::instance()->setValue(useNumpadForSwitchingStyles, false);
@@ -549,6 +657,7 @@ void StopMotion::toggleNumpadShortcuts(bool on) {
if (action) {
m_oldActionMap.insert(
std::pair<std::string, QAction *>(shortcut, action));
+ action->setShortcut(QKeySequence(""));
action = NULL;
}
shortcut = "-";
@@ -556,6 +665,23 @@ void StopMotion::toggleNumpadShortcuts(bool on) {
if (action) {
m_oldActionMap.insert(
std::pair<std::string, QAction *>(shortcut, action));
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ shortcut = "Enter";
+ action = comm->getActionFromShortcut(shortcut);
+ if (action) {
+ m_oldActionMap.insert(
+ std::pair<std::string, QAction *>(shortcut, action));
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ shortcut = "Backspace";
+ action = comm->getActionFromShortcut(shortcut);
+ if (action) {
+ m_oldActionMap.insert(
+ std::pair<std::string, QAction *>(shortcut, action));
+ action->setShortcut(QKeySequence(""));
action = NULL;
}
shortcut = "Return";
@@ -563,6 +689,7 @@ void StopMotion::toggleNumpadShortcuts(bool on) {
if (action) {
m_oldActionMap.insert(
std::pair<std::string, QAction *>(shortcut, action));
+ action->setShortcut(QKeySequence(""));
action = NULL;
}
shortcut = "*";
@@ -570,16 +697,33 @@ void StopMotion::toggleNumpadShortcuts(bool on) {
if (action) {
m_oldActionMap.insert(
std::pair<std::string, QAction *>(shortcut, action));
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ shortcut = ".";
+ action = comm->getActionFromShortcut(shortcut);
+ if (action) {
+ m_oldActionMap.insert(
+ std::pair<std::string, QAction *>(shortcut, action));
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ shortcut = "/";
+ action = comm->getActionFromShortcut(shortcut);
+ if (action) {
+ m_oldActionMap.insert(
+ std::pair<std::string, QAction *>(shortcut, action));
+ action->setShortcut(QKeySequence(""));
action = NULL;
}
// now set all new shortcuts
- action = comm->getAction(MI_PrevDrawing);
+ action = comm->getAction(MI_PrevFrame);
if (action) {
action->setShortcut(QKeySequence("1"));
action = NULL;
}
- action = comm->getAction(MI_NextDrawing);
+ action = comm->getAction(MI_StopMotionNextFrame);
if (action) {
action->setShortcut(QKeySequence("2"));
action = NULL;
@@ -611,139 +755,292 @@ void StopMotion::toggleNumpadShortcuts(bool on) {
}
action = comm->getAction(MI_StopMotionCapture);
if (action) {
- action->setShortcut(QKeySequence("Enter"));
- action = NULL;
- }
- action = comm->getAction(MI_StopMotionToggleLiveView);
- if (action) {
- action->setShortcut(QKeySequence("5"));
- action = NULL;
- }
- action = comm->getAction(MI_StopMotionToggleZoom);
- if (action) {
- action->setShortcut(QKeySequence("*"));
- action = NULL;
- }
-
- } else {
- // unset the new shortcuts first
- QAction *action;
- action = comm->getAction(MI_PrevDrawing);
- if (action) {
- action->setShortcut(
- QKeySequence(comm->getShortcutFromAction(action).c_str()));
- action = NULL;
- }
- action = comm->getAction(MI_NextDrawing);
- if (action) {
- action->setShortcut(
- QKeySequence(comm->getShortcutFromAction(action).c_str()));
- action = NULL;
- }
- action = comm->getAction(MI_StopMotionJumpToCamera);
- if (action) {
- action->setShortcut(
- QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action->setShortcut(QKeySequence("Return"));
action = NULL;
}
- action = comm->getAction(MI_Loop);
- if (action) {
- action->setShortcut(
- QKeySequence(comm->getShortcutFromAction(action).c_str()));
- action = NULL;
- }
- action = comm->getAction(MI_Play);
+ action = comm->getAction(MI_StopMotionRemoveFrame);
if (action) {
- action->setShortcut(
- QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action->setShortcut(QKeySequence("Backspace"));
action = NULL;
}
- action = comm->getAction(MI_StopMotionCapture);
+ action = comm->getAction(MI_StopMotionToggleLiveView);
if (action) {
- action->setShortcut(
- QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action->setShortcut(QKeySequence("5"));
action = NULL;
}
- action = comm->getAction(MI_StopMotionLowerOpacity);
+ action = comm->getAction(MI_StopMotionToggleUseLiveViewImages);
if (action) {
- action->setShortcut(
- QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action->setShortcut(QKeySequence("."));
action = NULL;
}
- action = comm->getAction(MI_StopMotionRaiseOpacity);
+ action = comm->getAction(MI_StopMotionToggleZoom);
if (action) {
- action->setShortcut(
- QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action->setShortcut(QKeySequence("*"));
action = NULL;
}
- action = comm->getAction(MI_StopMotionToggleLiveView);
+ action = comm->getAction(MI_StopMotionPickFocusCheck);
if (action) {
- action->setShortcut(
- QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action->setShortcut(QKeySequence("/"));
action = NULL;
}
- action = comm->getAction(MI_StopMotionToggleZoom);
+ action = comm->getAction(MI_ShortPlay);
if (action) {
- action->setShortcut(
- QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action->setShortcut(QKeySequence("6"));
action = NULL;
}
- // now put back the old shortcuts
- auto it = m_oldActionMap.begin();
- while (it != m_oldActionMap.end()) {
- it->second->setShortcut(QKeySequence(it->first.c_str()));
- it++;
- }
- if (m_numpadForStyleSwitching) {
- std::string shortcut;
+ } else {
+ // unset the new shortcuts first
+ if (m_oldActionMap.size() > 0) {
QAction *action;
- for (int i = 0; i <= 9; i++) {
- shortcut = QString::number(i).toStdString();
- action = comm->getActionFromShortcut(shortcut);
- if (action) {
- action->setShortcut(QKeySequence(""));
- action = NULL;
- }
+ action = comm->getAction(MI_PrevFrame);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
}
- Preferences::instance()->setValue(useNumpadForSwitchingStyles, true);
- }
- }
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::setXSheetFrameNumber(int frameNumber) {
- m_xSheetFrameNumber = frameNumber;
- loadLineUpImage();
- emit(xSheetFrameNumberChanged(m_xSheetFrameNumber));
- TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
-}
-
-//-----------------------------------------------------------------
-
-bool StopMotion::loadLineUpImage() {
- if (m_liveViewStatus < 1) return false;
- m_hasLineUpImage = false;
- // first see if the level exists in the current level set
- ToonzScene *currentScene = TApp::instance()->getCurrentScene()->getScene();
- TLevelSet *levelSet = currentScene->getLevelSet();
-
- std::wstring levelName = m_levelName.toStdWString();
-
- // level with the same name
- TXshLevel *level_sameName = levelSet->getLevel(levelName);
-
- TFilePath levelFp = TFilePath(m_filePath) +
- TFilePath(levelName + L".." + m_fileType.toStdWString());
-
- // level with the same path
- TXshLevel *level_samePath = levelSet->getLevel(*(currentScene), levelFp);
-
- TFilePath actualLevelFp = currentScene->decodeFilePath(levelFp);
- TXshSimpleLevelP sl;
- if (level_sameName && level_samePath && level_sameName == level_samePath) {
- sl = dynamic_cast<TXshSimpleLevel *>(level_sameName);
+ action = comm->getAction(MI_StopMotionNextFrame);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionJumpToCamera);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_Loop);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_Play);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionCapture);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionLowerOpacity);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionRaiseOpacity);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionToggleLiveView);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionToggleUseLiveViewImages);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionToggleZoom);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_ShortPlay);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionPickFocusCheck);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionRemoveFrame);
+ if (action) {
+ action->setShortcut(
+ QKeySequence(comm->getShortcutFromAction(action).c_str()));
+ action = NULL;
+ }
+
+ // now put back the old shortcuts
+ auto it = m_oldActionMap.begin();
+ while (it != m_oldActionMap.end()) {
+ it->second->setShortcut(QKeySequence(it->first.c_str()));
+ it++;
+ }
+ if (m_numpadForStyleSwitching) {
+ std::string shortcut;
+ QAction *action;
+ for (int i = 0; i <= 9; i++) {
+ shortcut = QString::number(i).toStdString();
+ action = comm->getActionFromShortcut(shortcut);
+ if (action) {
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ }
+ Preferences::instance()->setValue(useNumpadForSwitchingStyles, true);
+ }
+ }
+ }
+}
+
+//-----------------------------------------------------------------
+
+void StopMotion::toggleNumpadForFocusCheck(bool on) {
+ CommandManager *comm = CommandManager::instance();
+ if (m_useNumpadShortcuts) {
+ if (on) {
+ QAction *action;
+ action = comm->getAction(MI_PrevFrame);
+ if (action) {
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionNextFrame);
+ if (action) {
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionJumpToCamera);
+ if (action) {
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ action = comm->getAction(MI_Loop);
+ if (action) {
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ action = comm->getAction(MI_Play);
+ if (action) {
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionToggleLiveView);
+ if (action) {
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ action = comm->getAction(MI_ShortPlay);
+ if (action) {
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionCapture);
+ if (action) {
+ action->setShortcut(QKeySequence(""));
+ action = NULL;
+ }
+ } else {
+ QAction *action;
+ action = comm->getAction(MI_PrevFrame);
+ if (action) {
+ action->setShortcut(QKeySequence("1"));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionNextFrame);
+ if (action) {
+ action->setShortcut(QKeySequence("2"));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionJumpToCamera);
+ if (action) {
+ action->setShortcut(QKeySequence("3"));
+ action = NULL;
+ }
+ action = comm->getAction(MI_Loop);
+ if (action) {
+ action->setShortcut(QKeySequence("8"));
+ action = NULL;
+ }
+ action = comm->getAction(MI_Play);
+ if (action) {
+ action->setShortcut(QKeySequence("0"));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionToggleLiveView);
+ if (action) {
+ action->setShortcut(QKeySequence("5"));
+ action = NULL;
+ }
+ action = comm->getAction(MI_ShortPlay);
+ if (action) {
+ action->setShortcut(QKeySequence("6"));
+ action = NULL;
+ }
+ action = comm->getAction(MI_StopMotionCapture);
+ if (action) {
+ action->setShortcut(QKeySequence("Return"));
+ action = NULL;
+ }
+ }
+ }
+}
+
+//-----------------------------------------------------------------
+
+void StopMotion::setXSheetFrameNumber(int frameNumber) {
+ m_xSheetFrameNumber = frameNumber;
+ TApp::instance()->getCurrentFrame()->setFrame(frameNumber - 1);
+ loadLineUpImage();
+ emit(xSheetFrameNumberChanged(m_xSheetFrameNumber));
+ m_serial->sendSerialData();
+ TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
+}
+
+//-----------------------------------------------------------------
+
+bool StopMotion::loadLineUpImage() {
+ if (m_liveViewStatus == LiveViewClosed || m_userCalledPause) return false;
+ int row;
+ if (m_xSheetFrameNumber == 1) {
+ row = 0;
+ } else {
+ row = m_xSheetFrameNumber - 2;
+ }
+ m_hasLineUpImage = loadLiveViewImage(row, m_lineUpImage);
+ return m_hasLineUpImage;
+}
+
+//-----------------------------------------------------------------
+
+bool StopMotion::loadLiveViewImage(int row, TRaster32P &image) {
+ // first see if the level exists in the current level set
+ ToonzScene *currentScene = TApp::instance()->getCurrentScene()->getScene();
+ TLevelSet *levelSet = currentScene->getLevelSet();
+
+ std::wstring levelName = m_levelName.toStdWString();
+
+ // level with the same name
+ TXshLevel *level_sameName = levelSet->getLevel(levelName);
+
+ TFilePath levelFp = TFilePath(m_filePath) +
+ TFilePath(levelName + L".." + m_fileType.toStdWString());
+
+ // level with the same path
+ TXshLevel *level_samePath = levelSet->getLevel(*(currentScene), levelFp);
+
+ // TFilePath actualLevelFp = currentScene->decodeFilePath(levelFp);
+ TXshSimpleLevelP sl;
+ if (level_sameName && level_samePath && level_sameName == level_samePath) {
+ sl = dynamic_cast<TXshSimpleLevel *>(level_sameName);
bool isRasterLevel = sl && (sl->getType() == OVL_XSHLEVEL);
if (!isRasterLevel) {
return false;
@@ -752,16 +1049,9 @@ bool StopMotion::loadLineUpImage() {
return false;
// next we need to find the column the level is on
-
TApp *app = TApp::instance();
TXsheet *xsh = currentScene->getXsheet();
- int row;
- if (m_xSheetFrameNumber == 1) {
- row = 0;
- } else {
- row = m_xSheetFrameNumber - 2;
- }
- int col = app->getCurrentColumn()->getColumnIndex();
+ int col = app->getCurrentColumn()->getColumnIndex();
int foundCol = -1;
// most possibly, it's in the current column
@@ -783,29 +1073,42 @@ bool StopMotion::loadLineUpImage() {
// note found row represents the last row found that uses
// the active level
-
+ TXshCell cell = xsh->getCell(row, foundCol);
+ if (!(cell.getSimpleLevel() != 0 &&
+ cell.getSimpleLevel() == level_sameName->getSimpleLevel())) {
+ return false;
+ }
TFrameId frameId = xsh->getCell(row, foundCol).getFrameId();
int frameNumber = frameId.getNumber();
if (m_usingWebcam) {
if (frameNumber > 0) {
- m_lineUpImage = sl->getFrame(frameId, false)->raster();
- m_hasLineUpImage = true;
+ image = sl->getFrame(frameId, false)->raster();
return true;
} else
return false;
}
- // now check to see if a file actually exists there
+ // first check if the image is in the live view map
+ std::map<int, TRaster32P>::iterator it;
+ it = m_liveViewImageMap.find(frameNumber);
+ if (it != m_liveViewImageMap.end()) {
+ image = m_liveViewImageMap.find(frameNumber)->second;
+ return true;
+ }
+
+ // it's not in the map
+ // now check to see if a file actually exists
+ // then put it in the map
TFilePath liveViewFolder = currentScene->decodeFilePath(
TFilePath(m_filePath) + TFilePath(levelName + L"_LiveView"));
TFilePath liveViewFp = currentScene->decodeFilePath(
liveViewFolder + TFilePath(levelName + L"..jpg"));
TFilePath liveViewFile(liveViewFp.withFrame(frameNumber));
if (TFileStatus(liveViewFile).doesExist()) {
- if (loadJpg(liveViewFile, m_lineUpImage)) {
- m_hasLineUpImage = true;
+ if (JpgConverter::loadJpg(liveViewFile, image)) {
+ m_liveViewImageMap.insert(std::pair<int, TRaster32P>(frameNumber, image));
return true;
}
}
@@ -1008,39 +1311,128 @@ void StopMotion::setSubsampling() {
void StopMotion::onTimeout() {
int currentFrame = TApp::instance()->getCurrentFrame()->getFrame();
- // int destinationFrame = m_xSheetFrameNumber - 1;
- if (m_liveViewStatus > 0 && m_liveViewStatus < 3 &&
- !TApp::instance()->getCurrentFrame()->isPlaying()) {
- if (getAlwaysLiveView() || (currentFrame == m_xSheetFrameNumber - 1)) {
- if (!m_usingWebcam)
- downloadEVFData();
- else
- getWebcamImage();
- if (getAlwaysLiveView() && currentFrame != m_xSheetFrameNumber - 1 ||
- m_pickLiveViewZoom) {
+
+ if ((m_liveViewStatus > LiveViewClosed && m_liveViewStatus < LiveViewPaused &&
+ !TApp::instance()->getCurrentFrame()->isPlaying()) ||
+ (m_liveViewStatus == LiveViewPaused && !m_userCalledPause)) {
+ if (getAlwaysLiveView() || (currentFrame >= m_xSheetFrameNumber - 2)) {
+ if (!m_usingWebcam) {
+#ifdef WITH_CANON
+ bool success = m_canon->downloadEVFData();
+ if (success) {
+ setLiveViewImage();
+ } else {
+ m_hasLiveViewImage = false;
+ }
+#endif
+ } else {
+ bool success = m_webcam->getWebcamImage(m_liveViewImage);
+ if (success) {
+ setLiveViewImage();
+ } else {
+ m_hasLiveViewImage = false;
+ }
+ }
+ if ((!getAlwaysLiveView() &&
+ !(currentFrame >= m_xSheetFrameNumber - 2)) ||
+ m_canon->m_pickLiveViewZoom) {
m_showLineUpImage = false;
} else {
m_showLineUpImage = true;
}
- } else if (m_liveViewStatus == 2) {
- m_liveViewStatus = 3;
+ } else if (m_liveViewStatus == LiveViewOpen) {
+ m_liveViewStatus = LiveViewPaused;
TApp::instance()->getCurrentScene()->notifySceneChanged();
}
- } else if (m_liveViewStatus == 3 && !m_userCalledPause) {
- if (getAlwaysLiveView() || (currentFrame == m_xSheetFrameNumber - 1)) {
- if (!m_usingWebcam)
- downloadEVFData();
- else
- getWebcamImage();
- }
}
+ // else if (m_liveViewStatus == LiveViewPaused && !m_userCalledPause) {
+ // if (getAlwaysLiveView() || (currentFrame == m_xSheetFrameNumber - 1)) {
+ // if (!m_usingWebcam) {
+ //#ifdef WITH_CANON
+ // bool success = m_canon->downloadEVFData();
+ // if (success) {
+ // setLiveViewImage();
+ // } else {
+ // m_hasLiveViewImage = false;
+ // }
+ //#endif
+ // } else {
+ // bool success = m_webcam->getWebcamImage(m_liveViewImage);
+ // if (success) {
+ // setLiveViewImage();
+ // } else {
+ // m_hasLiveViewImage = false;
+ // }
+ // }
+ // }
+ // }
}
//-----------------------------------------------------------------------------
+void StopMotion::setLiveViewImage() {
+ m_hasLiveViewImage = true;
+
+ // make sure not to set to LiveViewOpen if it has been turned off
+ if (m_liveViewStatus > LiveViewClosed && !m_userCalledPause) {
+ m_liveViewStatus = LiveViewOpen;
+ }
+
+ if (m_liveViewDpi.x == 0.0 || m_liveViewImageDimensions.lx == 0) {
+ TCamera *camera =
+ TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
+ TDimensionD size = camera->getSize();
+ m_liveViewImageDimensions =
+ TDimension(m_liveViewImage->getLx(), m_liveViewImage->getLy());
+ double minimumDpi = std::min(m_liveViewImageDimensions.lx / size.lx,
+ m_liveViewImageDimensions.ly / size.ly);
+ m_liveViewDpi = TPointD(minimumDpi, minimumDpi);
+
+ if (!m_usingWebcam) {
+ minimumDpi = std::min(m_fullImageDimensions.lx / size.lx,
+ m_fullImageDimensions.ly / size.ly);
+ m_fullImageDpi = TPointD(minimumDpi, minimumDpi);
+ } else {
+ m_fullImageDimensions = m_liveViewImageDimensions;
+ m_fullImageDpi = m_liveViewDpi;
+ }
+
+ emit(newDimensions());
+ }
+ emit(newLiveViewImageReady());
+}
+//
+////-----------------------------------------------------------------------------
+//
+// void StopMotion::setLiveViewImage() {
+// m_hasLiveViewImage = true;
+// m_liveViewStatus = LiveViewOpen;
+// if (m_hasLiveViewImage &&
+// (m_liveViewDpi.x == 0.0 || m_liveViewImageDimensions.lx == 0)) {
+// TCamera* camera =
+// TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
+// TDimensionD size = camera->getSize();
+// m_liveViewImageDimensions =
+// TDimension(m_liveViewImage->getLx(), m_liveViewImage->getLy());
+// double minimumDpi = std::min(m_liveViewImageDimensions.lx / size.lx,
+// m_liveViewImageDimensions.ly / size.ly);
+// m_liveViewDpi = TPointD(minimumDpi, minimumDpi);
+//
+// m_fullImageDimensions = m_liveViewImageDimensions;
+//
+// m_fullImageDpi = m_liveViewDpi;
+//
+// emit(newDimensions());
+// }
+//
+// emit(newLiveViewImageReady());
+//}
+
+//-----------------------------------------------------------------------------
+
void StopMotion::onReviewTimeout() {
- if (m_liveViewStatus > 0) {
- m_liveViewStatus = 2;
+ if (m_liveViewStatus > LiveViewClosed) {
+ m_liveViewStatus = LiveViewOpen;
m_timer->start(40);
}
TApp::instance()->getCurrentFrame()->setFrame(m_xSheetFrameNumber - 1);
@@ -1049,21 +1441,6 @@ void StopMotion::onReviewTimeout() {
//-----------------------------------------------------------------------------
bool StopMotion::importImage() {
- if (getBlackCapture()) {
- m_fullScreen1->hide();
-
- if (m_screenCount > 1) {
- m_fullScreen2->hide();
-
- if (m_screenCount == 3) {
- m_fullScreen3->hide();
- }
- }
- }
- if (getReviewTime() > 0) {
- m_reviewTimer->start(getReviewTime() * 1000);
- }
-
TApp *app = TApp::instance();
ToonzScene *scene = app->getCurrentScene()->getScene();
TXsheet *xsh = scene->getXsheet();
@@ -1078,6 +1455,9 @@ bool StopMotion::importImage() {
if (m_usingWebcam) {
m_newImage = m_liveViewImage;
}
+
+ m_light->hideOverlays();
+
int frameNumber = m_frameNumber;
/* create parent directory if it does not exist */
@@ -1090,7 +1470,7 @@ bool StopMotion::importImage() {
TFilePath levelFp = TFilePath(m_filePath) +
TFilePath(levelName + L".." + m_fileType.toStdWString());
TFilePath actualLevelFp = scene->decodeFilePath(levelFp);
-
+ TFilePath actualFile(actualLevelFp.withFrame(frameNumber));
TFilePath fullResFp =
scene->decodeFilePath(fullResFolder + TFilePath(levelName + L"..jpg"));
TFilePath fullResFile(fullResFp.withFrame(frameNumber));
@@ -1154,8 +1534,9 @@ bool StopMotion::importImage() {
/* if the loaded level does not match in pixel size, then return */
sl = level->getSimpleLevel();
- if (!sl || sl->getProperties()->getImageRes() !=
- TDimension(m_newImage->getLx(), m_newImage->getLy())) {
+ if (!sl ||
+ sl->getProperties()->getImageRes() !=
+ TDimension(m_newImage->getLx(), m_newImage->getLy())) {
DVGui::error(
tr("The captured image size does not match with the existing "
"level."));
@@ -1177,7 +1558,7 @@ bool StopMotion::importImage() {
else {
TXshLevel *level = scene->createNewLevel(OVL_XSHLEVEL, levelName,
TDimension(), 0, levelFp);
- sl = level->getSimpleLevel();
+ sl = level->getSimpleLevel();
sl->setPath(levelFp, true);
sl->getProperties()->setDpiPolicy(LevelProperties::DP_CustomDpi);
TPointD dpi;
@@ -1192,7 +1573,7 @@ bool StopMotion::importImage() {
TDimensionD size = camera->getSize();
double minimumDpi = std::min(m_newImage->getLx() / size.lx,
m_newImage->getLy() / size.ly);
- dpi = TPointD(minimumDpi, minimumDpi);
+ dpi = TPointD(minimumDpi, minimumDpi);
}
sl->getProperties()->setDpi(dpi.x);
sl->getProperties()->setImageDpi(dpi);
@@ -1241,12 +1622,23 @@ bool StopMotion::importImage() {
// move the temp file
if (!m_usingWebcam) {
- if (m_useScaledImages) {
+ if (m_canon->m_useScaledImages) {
TSystem::copyFile(fullResFile, tempFile);
TSystem::deleteFile(tempFile);
}
if (m_hasLineUpImage) {
- saveJpg(m_lineUpImage, liveViewFile);
+ JpgConverter::saveJpg(m_lineUpImage, liveViewFile);
+ // check the live view image map to see if there is already
+ // an image with this framenumber. Overwrite if it exists
+ std::map<int, TRaster32P>::iterator it;
+ it = m_liveViewImageMap.find(frameNumber);
+ if (it != m_liveViewImageMap.end()) {
+ m_liveViewImageMap.find(frameNumber)->second = m_lineUpImage;
+ return true;
+ } else {
+ m_liveViewImageMap.insert(
+ std::pair<int, TRaster32P>(m_frameNumber, m_lineUpImage));
+ }
}
}
@@ -1269,6 +1661,11 @@ bool StopMotion::importImage() {
// if (m_saveOnCaptureCB->isChecked()) sl->save();
// for now always save. This can be tweaked later
sl->save();
+ m_sl = sl;
+ if (getReviewTime() > 0 && !m_isTimeLapse) {
+ m_liveViewStatus = LiveViewPaused;
+ m_reviewTimer->start(getReviewTime() * 1000);
+ }
/* placement in xsheet */
if (!getPlaceOnXSheet()) {
@@ -1287,7 +1684,8 @@ bool StopMotion::importImage() {
xsh->insertCells(row, col);
xsh->setCell(row, col, TXshCell(sl, fid));
app->getCurrentColumn()->setColumnIndex(col);
- if (getReviewTime() == 0) app->getCurrentFrame()->setFrame(row + 1);
+ if (getReviewTime() == 0 || m_isTimeLapse)
+ app->getCurrentFrame()->setFrame(row + 1);
m_xSheetFrameNumber = row + 2;
emit(xSheetFrameNumberChanged(m_xSheetFrameNumber));
postImportProcess();
@@ -1335,7 +1733,8 @@ bool StopMotion::importImage() {
xsh->insertCells(row, foundCol);
xsh->setCell(row, foundCol, TXshCell(sl, fid));
app->getCurrentColumn()->setColumnIndex(foundCol);
- if (getReviewTime() == 0) app->getCurrentFrame()->setFrame(row + 1);
+ if (getReviewTime() == 0 || m_isTimeLapse)
+ app->getCurrentFrame()->setFrame(row + 1);
m_xSheetFrameNumber = row + 2;
emit(xSheetFrameNumberChanged(m_xSheetFrameNumber));
}
@@ -1348,7 +1747,8 @@ bool StopMotion::importImage() {
}
xsh->setCell(row, col, TXshCell(sl, fid));
app->getCurrentColumn()->setColumnIndex(col);
- if (getReviewTime() == 0) app->getCurrentFrame()->setFrame(row + 1);
+ if (getReviewTime() == 0 || m_isTimeLapse)
+ app->getCurrentFrame()->setFrame(row + 1);
m_xSheetFrameNumber = row + 2;
emit(xSheetFrameNumberChanged(m_xSheetFrameNumber));
}
@@ -1359,20 +1759,46 @@ bool StopMotion::importImage() {
//-----------------------------------------------------------------
void StopMotion::captureImage() {
- if (!m_usingWebcam && !m_sessionOpen) {
+ if (m_isTimeLapse && !m_intervalStarted) {
+ startInterval();
+ return;
+ }
+ if (m_isTimeLapse && m_intervalStarted && m_intervalTimer->isActive()) {
+ stopInterval();
+ return;
+ }
+ if (!m_hasLiveViewImage || m_liveViewStatus != LiveViewOpen) {
+ DVGui::warning(tr("Cannot capture image unless live view is active."));
+ return;
+ }
+
+ bool sessionOpen = false;
+#ifdef WITH_CANON
+ sessionOpen = m_canon->m_sessionOpen;
+#endif
+ if ((!m_usingWebcam && !sessionOpen) || m_userCalledPause) {
DVGui::warning(tr("Please start live view before capturing an image."));
return;
}
+
if (m_usingWebcam) {
- if (!m_hasLiveViewImage) {
- DVGui::warning(
- tr("Cannot capture webcam image unless live view is active."));
- return;
- }
- if (getReviewTime() > 0) {
+ captureWebcamImage();
+ } else {
+ captureDslrImage();
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotion::captureWebcamImage() {
+ if (m_light->useOverlays()) {
+ m_light->showOverlays();
+ m_webcamOverlayTimer->start(500);
+ } else {
+ if (getReviewTime() > 0 && !m_isTimeLapse) {
m_timer->stop();
- if (m_liveViewStatus > 0) {
- m_liveViewStatus = 3;
+ if (m_liveViewStatus > LiveViewClosed) {
+ // m_liveViewStatus = LiveViewPaused;
}
}
m_lineUpImage = m_liveViewImage;
@@ -1381,29 +1807,34 @@ void StopMotion::captureImage() {
importImage();
return;
}
- if (getBlackCapture()) {
- m_fullScreen1->showFullScreen();
- m_fullScreen1->setGeometry(QApplication::desktop()->screenGeometry(0));
- if (m_screenCount > 1) {
- m_fullScreen2->showFullScreen();
- m_fullScreen2->setGeometry(QApplication::desktop()->screenGeometry(1));
+}
- if (m_screenCount == 3) {
- m_fullScreen3->showFullScreen();
- m_fullScreen3->setGeometry(QApplication::desktop()->screenGeometry(2));
- }
+//-----------------------------------------------------------------------------
+void StopMotion::captureWebcamOnTimeout() {
+ if (getReviewTime() > 0 && !m_isTimeLapse) {
+ m_timer->stop();
+ if (m_liveViewStatus > LiveViewClosed) {
+ // m_liveViewStatus = LiveViewPaused;
}
- // this allows the full screen qdialogs to go full screen before
- // taking a photo
- qApp->processEvents(QEventLoop::AllEvents, 1500);
}
+ m_lineUpImage = m_liveViewImage;
+ m_hasLineUpImage = true;
+ emit(newLiveViewImageReady());
+ importImage();
+ return;
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotion::captureDslrImage() {
+ m_light->showOverlays();
- if (getReviewTime() > 0) {
+ if (getReviewTime() > 0 && !m_isTimeLapse) {
m_timer->stop();
}
- if (m_liveViewStatus > 0) {
- m_liveViewStatus = 3;
+ if (m_liveViewStatus > LiveViewClosed && !m_isTimeLapse) {
+ // m_liveViewStatus = LiveViewPaused;
}
if (m_hasLiveViewImage) {
@@ -1425,117 +1856,16 @@ void StopMotion::captureImage() {
TSystem::mkDir(parentDir);
}
m_tempFile = tempFile.getQString();
- takePicture();
-}
-
-//-----------------------------------------------------------------------------
-
-void StopMotion::saveJpg(TRaster32P image, TFilePath path) {
- unsigned char *jpegBuf = NULL; /* Dynamically allocate the JPEG buffer */
- unsigned long jpegSize = 0;
- int pixelFormat = TJPF_BGRX;
- int outQual = 95;
- int subSamp = TJSAMP_411;
- bool success = false;
- tjhandle tjInstance;
-
- int width = image->getLx();
- int height = image->getLy();
- int flags = 0;
-#ifdef WIN32
- flags |= TJFLAG_BOTTOMUP;
-#endif
- image->lock();
- uchar *rawData = image->getRawData();
- if ((tjInstance = tjInitCompress()) != NULL) {
- if (tjCompress2(tjInstance, rawData, width, 0, height, pixelFormat,
- &jpegBuf, &jpegSize, subSamp, outQual, flags) >= 0) {
- success = true;
- }
- }
- image->unlock();
- tjDestroy(tjInstance);
- tjInstance = NULL;
-
- if (success) {
- /* Write the JPEG image to disk. */
- QFile fullImage(path.getQString());
- fullImage.open(QIODevice::WriteOnly);
- QDataStream dataStream(&fullImage);
- dataStream.writeRawData((const char *)jpegBuf, jpegSize);
- fullImage.close();
- }
- tjFree(jpegBuf);
- jpegBuf = NULL;
-}
-
-//-----------------------------------------------------------------------------
-
-bool StopMotion::loadJpg(TFilePath path, TRaster32P &image) {
- long size;
- int inSubsamp, inColorspace, width, height;
- unsigned long jpegSize;
- unsigned char *jpegBuf;
- FILE *jpegFile;
- QString qPath = path.getQString();
- QByteArray ba = qPath.toLocal8Bit();
- const char *c_path = ba.data();
- bool success = true;
- tjhandle tjInstance;
-
- /* Read the JPEG file into memory. */
- if ((jpegFile = fopen(c_path, "rb")) == NULL) success = false;
- if (success && fseek(jpegFile, 0, SEEK_END) < 0 ||
- ((size = ftell(jpegFile)) < 0) || fseek(jpegFile, 0, SEEK_SET) < 0)
- success = false;
- if (success && size == 0) success = false;
- jpegSize = (unsigned long)size;
- if (success && (jpegBuf = (unsigned char *)tjAlloc(jpegSize)) == NULL)
- success = false;
- if (success && fread(jpegBuf, jpegSize, 1, jpegFile) < 1) success = false;
- fclose(jpegFile);
- jpegFile = NULL;
-
- if (success && (tjInstance = tjInitDecompress()) == NULL) success = false;
-
- if (success && tjDecompressHeader3(tjInstance, jpegBuf, jpegSize, &width,
- &height, &inSubsamp, &inColorspace) < 0)
- success = false;
-
- int pixelFormat = TJPF_BGRX;
- unsigned char *imgBuf = NULL;
- if (success &&
- (imgBuf = tjAlloc(width * height * tjPixelSize[pixelFormat])) == NULL)
- success = false;
-
- int flags = 0;
-#ifdef WIN32
- flags |= TJFLAG_BOTTOMUP;
+#ifdef WITH_CANON
+ m_canon->takePicture();
#endif
- if (success && tjDecompress2(tjInstance, jpegBuf, jpegSize, imgBuf, width, 0,
- height, pixelFormat, flags) < 0)
- success = false;
- tjFree(jpegBuf);
- jpegBuf = NULL;
- tjDestroy(tjInstance);
- tjInstance = NULL;
-
- image = TRaster32P(width, height);
- image->lock();
- uchar *rawData = image->getRawData();
- memcpy(rawData, imgBuf, width * height * tjPixelSize[pixelFormat]);
- image->unlock();
-
- tjFree(imgBuf);
- imgBuf = NULL;
-
- return success;
}
//-----------------------------------------------------------------------------
void StopMotion::postImportProcess() {
+ saveXmlFile();
if (Preferences::instance()->isShowFrameNumberWithLettersEnabled()) {
int f = m_frameNumber;
if (f % 10 == 0) // next number
@@ -1547,6 +1877,9 @@ void StopMotion::postImportProcess() {
emit(frameNumberChanged(m_frameNumber));
/* notify */
refreshFrameInfo();
+
+ if (m_isTimeLapse && m_intervalStarted) restartInterval();
+
TApp::instance()->getCurrentScene()->notifySceneChanged();
TApp::instance()->getCurrentScene()->notifyCastChange();
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
@@ -1554,10 +1887,350 @@ void StopMotion::postImportProcess() {
//-----------------------------------------------------------------------------
-// Refresh information that how many & which frames are saved for the current
-// level
-void StopMotion::refreshFrameInfo() {
- if ((!m_sessionOpen && m_liveViewStatus < 2) && !m_usingWebcam) {
+void StopMotion::saveXmlFile() {
+ TApp *app = TApp::instance();
+ ToonzScene *scene = app->getCurrentScene()->getScene();
+ TXsheet *xsh = scene->getXsheet();
+
+ std::wstring levelName = m_levelName.toStdWString();
+ TFilePath parentDir = scene->decodeFilePath(TFilePath(m_filePath));
+ TFilePath tempFile = parentDir + TFilePath(levelName + L".xml");
+ QString xmlFileName = tempFile.getQString();
+ QFile xmlFile(xmlFileName);
+ xmlFile.open(QIODevice::WriteOnly);
+ QXmlStreamWriter xmlWriter(&xmlFile);
+ xmlWriter.setAutoFormatting(true);
+ xmlWriter.writeStartDocument();
+ xmlWriter.writeStartElement("body");
+ xmlWriter.writeStartElement("SceneInfo");
+ xmlWriter.writeTextElement("LevelName", QString::fromStdWString(levelName));
+ xmlWriter.writeTextElement("CurrentFrame",
+ QString::number(m_xSheetFrameNumber));
+ xmlWriter.writeEndElement();
+
+ xmlWriter.writeStartElement("CameraInfo");
+ if (m_usingWebcam) {
+ xmlWriter.writeTextElement("Webcam", "yes");
+ xmlWriter.writeTextElement("CameraName", m_webcam->getWebcamDescription());
+ xmlWriter.writeTextElement("CameraResolutionX",
+ QString::number(m_webcam->getWebcamWidth()));
+ xmlWriter.writeTextElement("CameraResolutionY",
+ QString::number(m_webcam->getWebcamHeight()));
+ } else {
+ xmlWriter.writeTextElement("Webcam", "no");
+#ifdef WITH_CANON
+ xmlWriter.writeTextElement("CameraName",
+ QString::fromStdString(m_canon->m_cameraName));
+ xmlWriter.writeTextElement("Aperture", m_canon->getCurrentAperture());
+ xmlWriter.writeTextElement("ShutterSpeed",
+ m_canon->getCurrentShutterSpeed());
+ xmlWriter.writeTextElement("ISO", m_canon->getCurrentIso());
+ xmlWriter.writeTextElement("PictureStyle",
+ m_canon->getCurrentPictureStyle());
+ xmlWriter.writeTextElement("ImageQuality",
+ m_canon->getCurrentImageQuality());
+ xmlWriter.writeTextElement("WhiteBalance",
+ m_canon->getCurrentWhiteBalance());
+ xmlWriter.writeTextElement("ColorTemperature",
+ m_canon->getCurrentColorTemperature());
+ xmlWriter.writeTextElement("ExposureCompensation",
+ m_canon->getCurrentExposureCompensation());
+ xmlWriter.writeTextElement("FocusCheckLocationX",
+ QString::number(m_canon->m_finalZoomPoint.x));
+ xmlWriter.writeTextElement("FocusCheckLocationY",
+ QString::number(m_canon->m_finalZoomPoint.y));
+#endif
+ }
+ xmlWriter.writeEndElement();
+
+ xmlWriter.writeStartElement("Images");
+ xmlWriter.writeTextElement("Frame", "Yes");
+ xmlWriter.writeEndElement();
+ xmlWriter.writeEndElement();
+ xmlWriter.writeEndDocument();
+ xmlFile.close();
+}
+
+//-----------------------------------------------------------------------------
+
+bool StopMotion::loadXmlFile() {
+ TApp *app = TApp::instance();
+ ToonzScene *scene = app->getCurrentScene()->getScene();
+ TXsheet *xsh = scene->getXsheet();
+
+ bool webcam = false;
+ bool foundCamera = false;
+ QString text;
+ int x;
+ int y;
+
+ std::wstring levelName = m_levelName.toStdWString();
+ TFilePath parentDir = scene->decodeFilePath(TFilePath(m_filePath));
+ TFilePath tempFile = parentDir + TFilePath(levelName + L".xml");
+ QString xmlFileName = tempFile.getQString();
+ QFile xmlFile(xmlFileName);
+ if (!xmlFile.exists()) return false;
+ xmlFile.open(QIODevice::ReadOnly);
+
+ QXmlStreamReader xmlReader;
+ xmlReader.setDevice(&xmlFile);
+ xmlReader.readNext();
+ while (!xmlReader.atEnd()) {
+ if (xmlReader.isStartElement()) {
+ if (xmlReader.name() == "Webcam") {
+ text = xmlReader.readElementText();
+ if (text == "yes") webcam = true;
+ }
+ if (xmlReader.name() == "CameraName") {
+ text = xmlReader.readElementText();
+ if (webcam) {
+ QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
+ if (cameras.size() > 0) {
+ for (int i = 0; i < cameras.size(); i++) {
+ if (cameras.at(i).description() == text) {
+ changeCameras(i + 1);
+ foundCamera = true;
+ break;
+ }
+ }
+ }
+ } else {
+#ifdef WITH_CANON
+ QString camName = "";
+ if (m_canon->getCameraCount() > 0) {
+ m_canon->openCameraSession();
+ camName = QString::fromStdString(m_canon->getCameraName());
+ m_canon->closeCameraSession();
+ }
+ if (text == camName) {
+ changeCameras(-1);
+ foundCamera = true;
+ }
+#endif
+ }
+ }
+ if (xmlReader.name() == "CameraResolutionX") {
+ text = xmlReader.readElementText();
+ x = text.toInt();
+ }
+ if (xmlReader.name() == "CameraResolutionY") {
+ text = xmlReader.readElementText();
+ y = text.toInt();
+ if (foundCamera == true && webcam == true) {
+ setWebcamResolution(
+ QString(QString::number(x) + " x " + QString::number(y)));
+ }
+ }
+#ifdef WITH_CANON
+ if (xmlReader.name() == "Aperture") {
+ text = xmlReader.readElementText();
+ if (foundCamera == true && webcam == false) {
+ m_canon->setAperture(text);
+ }
+ }
+ if (xmlReader.name() == "ShutterSpeed") {
+ text = xmlReader.readElementText();
+ if (foundCamera == true && webcam == false) {
+ m_canon->setShutterSpeed(text);
+ }
+ }
+ if (xmlReader.name() == "ISO") {
+ text = xmlReader.readElementText();
+ if (foundCamera == true && webcam == false) {
+ m_canon->setIso(text);
+ }
+ }
+ if (xmlReader.name() == "PictureStyle") {
+ text = xmlReader.readElementText();
+ if (foundCamera == true && webcam == false) {
+ m_canon->setPictureStyle(text);
+ }
+ }
+ if (xmlReader.name() == "ImageQuality") {
+ text = xmlReader.readElementText();
+ if (foundCamera == true && webcam == false) {
+ m_canon->setImageQuality(text);
+ }
+ }
+ if (xmlReader.name() == "WhiteBalance") {
+ text = xmlReader.readElementText();
+ if (foundCamera == true && webcam == false) {
+ m_canon->setWhiteBalance(text);
+ }
+ }
+ if (xmlReader.name() == "ColorTemperature") {
+ text = xmlReader.readElementText();
+ if (foundCamera == true && webcam == false) {
+ m_canon->setColorTemperature(text);
+ }
+ }
+ if (xmlReader.name() == "ExposureCompensation") {
+ text = xmlReader.readElementText();
+ if (foundCamera == true && webcam == false) {
+ m_canon->setExposureCompensation(text);
+ }
+ }
+ if (xmlReader.name() == "FocusCheckLocationX") {
+ text = xmlReader.readElementText();
+ m_canon->m_finalZoomPoint.x = text.toInt();
+ }
+ if (xmlReader.name() == "FocusCheckLocationY") {
+ text = xmlReader.readElementText();
+ m_canon->m_finalZoomPoint.y = text.toInt();
+ }
+#endif
+ }
+ xmlReader.readNext();
+ }
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+
+bool StopMotion::exportImageSequence() {
+ TApp *app = TApp::instance();
+ ToonzScene *scene = app->getCurrentScene()->getScene();
+ TXsheet *xsh = scene->getXsheet();
+
+ std::wstring levelName = m_levelName.toStdWString();
+
+ if (levelName.empty()) {
+ DVGui::error(
+ tr("No level name specified: please choose a valid level name"));
+ return false;
+ }
+ int frameNumber = m_frameNumber;
+
+ TFilePath parentDir = scene->decodeFilePath(TFilePath(m_filePath));
+ TFilePath fullResFolder = scene->decodeFilePath(
+ TFilePath(m_filePath) + TFilePath(levelName + L"_FullRes"));
+ TFilePath liveViewFolder = scene->decodeFilePath(
+ TFilePath(m_filePath) + TFilePath(levelName + L"_LiveView"));
+
+ TFilePath levelFp = TFilePath(m_filePath) +
+ TFilePath(levelName + L".." + m_fileType.toStdWString());
+ TFilePath actualLevelFp = scene->decodeFilePath(levelFp);
+
+ TFilePath fullResFp =
+ scene->decodeFilePath(fullResFolder + TFilePath(levelName + L"..jpg"));
+ TFilePath fullResFile(fullResFp.withFrame(frameNumber));
+
+ TFilePath liveViewFp =
+ scene->decodeFilePath(liveViewFolder + TFilePath(levelName + L"..jpg"));
+ TFilePath liveViewFile(liveViewFp.withFrame(frameNumber));
+
+ TFilePath tempFile = parentDir + "temp.jpg";
+
+ TXshSimpleLevel *sl = 0;
+ TXshLevel *level = scene->getLevelSet()->getLevel(levelName);
+
+ if (level == NULL) {
+ DVGui::error(tr("No level exists with the current name."));
+ return false;
+ }
+
+ /* if the existing level is not a raster level, then return */
+ if (level->getType() != OVL_XSHLEVEL) {
+ DVGui::error(tr("This is not an image level."));
+ return false;
+ }
+ if (!level->getSimpleLevel()->getProperties()->isStopMotionLevel()) {
+ DVGui::error(tr("This is not a stop motion level."));
+ return false;
+ }
+ sl = level->getSimpleLevel();
+
+ if (scene->decodeFilePath(sl->getPath()) != actualLevelFp) {
+ DVGui::error(
+ tr("The save in path specified does not match with the existing "
+ "level."));
+ return false;
+ }
+
+ // find which column the level is on.
+ // check with the first column
+ int col = TApp::instance()->getCurrentColumn()->getColumnIndex();
+ int r0, r1, row;
+ xsh->getColumn(col)->getRange(r0, r1);
+ TXshSimpleLevel *colLevel = xsh->getCell(r0, col).getSimpleLevel();
+ if (colLevel != sl) {
+ int cols = xsh->getColumnCount();
+ for (int i = 0; i < cols; i++) {
+ xsh->getColumn(col)->getRange(r0, r1);
+ colLevel = xsh->getCell(r0, col).getSimpleLevel();
+ if (colLevel == sl) {
+ col = i;
+ break;
+ }
+ }
+ DVGui::error(tr("Could not find an xsheet level with the current level"));
+ return false;
+ }
+
+ row = r0;
+ xsh->getColumn(col)->getLevelRange(row, r0, r1);
+
+ GenericSaveFilePopup *m_saveSequencePopup =
+ new GenericSaveFilePopup("Export Image Sequence");
+ m_saveSequencePopup->setFileMode(true);
+ TFilePath fp = m_saveSequencePopup->getPath();
+ if (fp == TFilePath()) {
+ DVGui::error(tr("No export path given."));
+ return false;
+ }
+
+ TFilePath sourceFile;
+ TFilePath exportFilePath =
+ scene->decodeFilePath(fp + TFilePath(levelName + L"..jpg"));
+ TFilePath exportFile;
+ int exportFrameNumber = 1;
+ for (int i = r0; i <= r1; i++) {
+ int cellNumber = xsh->getCell(i, col).getFrameId().getNumber();
+ fullResFile = fullResFp.withFrame(cellNumber);
+ if (TFileStatus(fullResFile).doesExist()) {
+ sourceFile = fullResFile;
+ } else {
+ sourceFile = actualLevelFp.withFrame(cellNumber);
+ }
+
+ if (!TFileStatus(sourceFile).doesExist()) {
+ DVGui::error(tr("Could not find the source file."));
+ return false;
+ }
+ exportFile = exportFilePath.withFrame(exportFrameNumber);
+ if (TFileStatus(exportFile).doesExist()) {
+ QString question = tr("Overwrite existing files?");
+ int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"),
+ QObject::tr("Cancel"));
+ if (ret == 0 || ret == 2) return false;
+ }
+ TSystem::copyFile(exportFile, sourceFile);
+ exportFrameNumber++;
+ if (!TFileStatus(exportFile).doesExist()) {
+ DVGui::error(tr("An error occurred. Aborting."));
+ return false;
+ }
+ }
+ QString message1 = tr("Successfully exported ");
+ QString message2 = tr(" images.");
+ QString finalMessage =
+ message1 + QString::number(exportFrameNumber - 1) + message2;
+ DVGui::MsgBoxInPopup(DVGui::MsgType(DVGui::INFORMATION), finalMessage);
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+
+// Refresh information that how many & which frames are saved for the current
+// level
+void StopMotion::refreshFrameInfo() {
+ bool sessionOpen = false;
+
+#ifdef WITH_CANON
+ sessionOpen = m_canon->m_sessionOpen;
+#endif
+
+ if ((!sessionOpen && m_liveViewStatus < LiveViewOpen) && !m_usingWebcam) {
m_frameInfoText = "";
return;
}
@@ -1574,16 +2247,18 @@ void StopMotion::refreshFrameInfo() {
int frameNumber = m_frameNumber;
TDimension stopMotionRes;
- bool checkRes = true;
- if (m_usingWebcam)
- stopMotionRes = m_liveViewImageDimensions;
-
- else if (m_useScaledImages || !getCurrentImageQuality().contains("Large")) {
- stopMotionRes = m_proxyImageDimensions;
- if (m_proxyImageDimensions == TDimension(0, 0)) {
+ bool checkRes = true;
+ if (m_usingWebcam) stopMotionRes = m_liveViewImageDimensions;
+#ifdef WITH_CANON
+ else if (m_canon->m_useScaledImages ||
+ !m_canon->getCurrentImageQuality().contains("Large")) {
+ stopMotionRes = m_canon->m_proxyImageDimensions;
+ if (m_canon->m_proxyImageDimensions == TDimension(0, 0)) {
checkRes = false;
}
- } else
+ }
+#endif
+ else
stopMotionRes = m_fullImageDimensions;
bool letterOptionEnabled =
@@ -1605,7 +2280,7 @@ void StopMotion::refreshFrameInfo() {
// frame existence
TFilePath frameFp(actualLevelFp.withFrame(frameNumber));
- bool frameExist = false;
+ bool frameExist = false;
if (levelExist) frameExist = TFileStatus(frameFp).doesExist();
// reset acceptable camera size
@@ -1820,8 +2495,8 @@ void StopMotion::refreshFrameInfo() {
void StopMotion::updateLevelNameAndFrame(std::wstring levelName) {
if (levelName != m_levelName.toStdWString()) {
m_levelName = QString::fromStdWString(levelName);
- loadLineUpImage();
}
+ m_liveViewImageMap.clear();
emit(levelNameChanged(m_levelName));
// m_previousLevelButton->setDisabled(levelName == L"A");
@@ -1847,6 +2522,14 @@ void StopMotion::updateLevelNameAndFrame(std::wstring levelName) {
startFrame = withLetter ? ((int)(lastNum / 10) + 1) * 10 : lastNum + 1;
}
}
+ if (level_p) {
+ TXshSimpleLevel *sl = level_p->getSimpleLevel();
+ if (sl && sl->getType() == OVL_XSHLEVEL &&
+ sl->getProperties()->isStopMotionLevel()) {
+ buildLiveViewMap(sl);
+ }
+ }
+ loadLineUpImage();
m_frameNumber = startFrame;
emit(frameNumberChanged(startFrame));
refreshFrameInfo();
@@ -1888,255 +2571,170 @@ void StopMotion::setToNextNewLevel() {
//-----------------------------------------------------------------
-void StopMotion::refreshCameraList() { emit(updateCameraList()); }
+void StopMotion::refreshCameraList() {
+ QString camera = "";
+ bool hasCamera = false;
+#ifdef WITH_CANON
+ if (m_canon->m_sessionOpen && m_canon->getCameraCount() > 0 &&
+ !m_usingWebcam && m_canon->m_cameraName == m_canon->getCameraName()) {
+ hasCamera = true;
+ camera = QString::fromStdString(m_canon->m_cameraName);
+ }
+#endif
+ if (m_usingWebcam) {
+ QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
+ if (m_usingWebcam && cameras.size() > 0) {
+ for (int i = 0; i < cameras.size(); i++) {
+ if (cameras.at(i).description() == m_webcam->getWebcamDescription()) {
+ hasCamera = true;
+ camera = m_webcam->getWebcamDescription();
+ break;
+ }
+ }
+ }
+ }
+ if (!hasCamera) disconnectAllCameras();
+ emit(updateCameraList(camera));
+}
//-----------------------------------------------------------------
void StopMotion::changeCameras(int index) {
+ // note: index is negative if this is called to load DSLR from load settings
+
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
// if selected the non-connected state, then disconnect the current camera
if (index == 0) {
- m_active = false;
- m_webcamDeviceName = QString();
- m_webcamDescription = QString();
- m_webcamIndex = -1;
- m_proxyDpi = TPointD(0.0, 0.0);
- m_proxyImageDimensions = TDimension(0, 0);
-
- if (m_sessionOpen || m_usingWebcam) {
- if (m_liveViewStatus > 0) {
- endLiveView();
- }
- closeCameraSession();
- m_usingWebcam = false;
- }
-
- setTEnvCameraName("");
-
- emit(newCameraSelected(index, false));
- toggleNumpadShortcuts(false);
+ disconnectAllCameras();
+ stopInterval();
return;
}
// There is a "Select Camera" as the first index
index -= 1;
- m_active = true;
+
+ // first see if the index didn't actually change
+ if (cameras.size() > 0 && index < cameras.size() && index >= 0) {
+ if (cameras.at(index).deviceName() == m_webcam->getWebcamDeviceName()) {
+ return;
+ }
+ }
+
+#ifdef WITH_CANON
+ if ((index > cameras.size() - 1) && m_canon->m_sessionOpen) return;
+#endif
+
+ // close live view if open
+ if (m_liveViewStatus > LiveViewClosed) {
+ toggleLiveView();
+ }
// Check if its a webcam or DSLR
// Webcams are listed first, so see if one of them is selected
- if (index > cameras.size() - 1) {
+ if (index < 0 || index > cameras.size() - 1) {
m_usingWebcam = false;
} else {
m_usingWebcam = true;
- m_webcamIndex = index;
+ m_webcam->setWebcamIndex(index);
}
// in case the camera is not changed
if (m_usingWebcam) {
- if (cameras.at(index).deviceName() == m_webcamDeviceName) {
- return;
- }
-
- if (m_sessionOpen) {
- if (m_liveViewStatus > 0) {
- endLiveView();
- closeCameraSession();
- }
+#ifdef WITH_CANON
+ if (m_canon->m_sessionOpen && m_canon->getCameraCount() > 0) {
+ m_canon->closeCameraSession();
}
-
- setWebcam(new QCamera(cameras.at(index)));
- m_webcamDeviceName = cameras.at(index).deviceName();
- m_webcamDescription = cameras.at(index).description();
-
-#ifdef MACOSX
- // this line is needed only in macosx
- m_stopMotion->getWebcam()->setViewfinder(m_dummyViewFinder);
#endif
+ m_webcam->setWebcam(new QCamera(cameras.at(index)));
+ m_webcam->setWebcamDeviceName(cameras.at(index).deviceName());
+ m_webcam->setWebcamDescription(cameras.at(index).description());
+
// loading new camera
- getWebcam()->load();
+ m_webcam->getWebcam()->load();
- m_webcamResolutions.clear();
+ m_webcam->refreshWebcamResolutions();
- m_webcamResolutions = getWebcam()->supportedViewfinderResolutions();
- int sizeCount = m_webcamResolutions.count();
+ QList<QSize> webcamResolutions = m_webcam->getWebcamResolutions();
+ int sizeCount = webcamResolutions.count() - 1;
int width;
int height;
- for (int s = 0; s < m_webcamResolutions.size(); s++) {
- width = m_webcamResolutions.at(s).width();
- height = m_webcamResolutions.at(s).height();
+ for (int s = 0; s < webcamResolutions.size(); s++) {
+ width = webcamResolutions.at(s).width();
+ height = webcamResolutions.at(s).height();
+ }
+ // see if we can set the webcam resolution to the current camera resolution
+ TDimension res = TApp::instance()
+ ->getCurrentScene()
+ ->getScene()
+ ->getCurrentCamera()
+ ->getRes();
+ if (webcamResolutions.contains(QSize(res.lx, res.ly))) {
+ width = res.lx;
+ height = res.ly;
+ sizeCount = webcamResolutions.indexOf(QSize(res.lx, res.ly));
}
- getWebcam()->unload();
+ m_webcam->getWebcam()->unload();
setWebcamResolution(
QString(QString::number(width) + " x " + QString::number(height)));
- setTEnvCameraName(m_webcamDescription.toStdString());
+ setTEnvCameraName(m_webcam->getWebcamDescription().toStdString());
emit(newCameraSelected(index + 1, true));
emit(webcamResolutionsChanged());
- emit(newWebcamResolutionSelected(sizeCount - 1));
+ emit(newWebcamResolutionSelected(sizeCount));
} else {
- m_webcamDeviceName = QString();
- m_webcamDescription = QString();
- m_webcamIndex = -1;
- openCameraSession();
- setTEnvCameraName(getCameraName());
- emit(newCameraSelected(index + 1, false));
- }
- if (m_useNumpadShortcuts) toggleNumpadShortcuts(true);
- m_liveViewDpi = TPointD(0.0, 0.0);
- refreshFrameInfo();
-}
-
-//-----------------------------------------------------------------
-
-QList<QCameraInfo> StopMotion::getWebcams() {
- m_webcams.clear();
- m_webcams = QCameraInfo::availableCameras();
- return m_webcams;
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::setWebcam(QCamera *camera) { m_webcam = camera; }
-
-//-----------------------------------------------------------------
-
-bool StopMotion::translateIndex(int index) {
- // We are using Qt to get the camera info and supported resolutions, but
- // we are using OpenCV to actually get the images.
- // The camera index from OpenCV and from Qt don't always agree,
- // So this checks the name against the correct index.
- m_webcamIndex = index;
-
-#ifdef WIN32
-
- // Thanks to:
- // https://elcharolin.wordpress.com/2017/08/28/webcam-capture-with-the-media-foundation-sdk/
- // for the webcam enumeration here
-
-#define CLEAN_ATTRIBUTES() \
- if (attributes) { \
- attributes->Release(); \
- attributes = NULL; \
- } \
- for (DWORD i = 0; i < count; i++) { \
- if (&devices[i]) { \
- devices[i]->Release(); \
- devices[i] = NULL; \
- } \
- } \
- CoTaskMemFree(devices); \
- return hr;
-
- HRESULT hr = S_OK;
-
- // this is important!!
- hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
-
- UINT32 count = 0;
- IMFAttributes *attributes = NULL;
- IMFActivate **devices = NULL;
-
- if (FAILED(hr)) {
- CLEAN_ATTRIBUTES()
- }
- // Create an attribute store to specify enumeration parameters.
- hr = MFCreateAttributes(&attributes, 1);
-
- if (FAILED(hr)) {
- CLEAN_ATTRIBUTES()
- }
-
- // The attribute to be requested is devices that can capture video
- hr = attributes->SetGUID(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
- MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID);
- if (FAILED(hr)) {
- CLEAN_ATTRIBUTES()
- }
- // Enummerate the video capture devices
- hr = MFEnumDeviceSources(attributes, &devices, &count);
-
- if (FAILED(hr)) {
- CLEAN_ATTRIBUTES()
- }
- // if there are any available devices
- if (count > 0) {
- WCHAR *nameString = NULL;
- // Get the human-friendly name of the device
- UINT32 cchName;
-
- for (int i = 0; i < count; i++) {
- hr = devices[i]->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME,
- &nameString, &cchName);
- std::string desc = m_webcamDescription.toStdString();
- if (nameString == m_webcamDescription.toStdWString()) {
- m_webcamIndex = i;
- break;
- }
- // devices[0]->ShutdownObject();
+#ifdef WITH_CANON
+ m_canon->openCameraSession();
+ setTEnvCameraName(m_canon->getCameraName());
+ if (index == -2) {
+ index = cameras.size();
}
+ m_webcam->clearWebcam();
- CoTaskMemFree(nameString);
- }
- // clean
- CLEAN_ATTRIBUTES()
-#else
- return true;
+ emit(newCameraSelected(index + 1, false));
#endif
-}
-
-//-----------------------------------------------------------------
-
-bool StopMotion::initWebcam(int index) {
- if (!m_useDirectShow) {
- // the webcam order obtained from Qt isn't always the same order as
- // the one obtained from OpenCV without DirectShow
- translateIndex(index);
- m_cvWebcam.open(m_webcamIndex);
- } else {
- m_webcamIndex = index;
- m_cvWebcam.open(m_webcamIndex, cv::CAP_DSHOW);
}
- if (m_cvWebcam.isOpened() == false) {
- return false;
+ if (m_useNumpadShortcuts) toggleNumpadShortcuts(true);
+ m_liveViewDpi = TPointD(0.0, 0.0);
+ m_hasLineUpImage = false;
+ m_hasLiveViewImage = false;
+ if (m_isTimeLapse && m_intervalStarted) {
+ stopInterval();
}
-
- return true;
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::releaseWebcam() {
- m_cvWebcam.release();
- m_liveViewStatus = 0;
emit(liveViewStopped());
+ emit(liveViewChanged(false));
+ refreshFrameInfo();
+ // after all live view data is cleared, start it again.
+ toggleLiveView();
}
-
//-----------------------------------------------------------------
void StopMotion::setWebcamResolution(QString resolution) {
- m_cvWebcam.release();
+ m_webcam->releaseWebcam();
// resolution is written in the itemText with the format "<width> x
// <height>" (e.g. "800 x 600")
QStringList texts = resolution.split(' ');
- // the splited text must be "<width>" "x" and "<height>"
+ // the split text must be "<width>" "x" and "<height>"
if (texts.size() != 3) return;
+
int tempStatus = m_liveViewStatus;
- m_liveViewStatus = 0;
- bool startTimer = false;
+ m_liveViewStatus = LiveViewClosed;
+
+ bool startTimer = false;
if (m_timer->isActive()) {
m_timer->stop();
startTimer = true;
}
+
qApp->processEvents(QEventLoop::AllEvents, 1000);
- m_webcamWidth = texts[0].toInt();
- m_webcamHeight = texts[2].toInt();
+ m_webcam->setWebcamWidth(texts[0].toInt());
+ m_webcam->setWebcamHeight(texts[2].toInt());
m_liveViewDpi = TPointD(0.0, 0.0);
m_liveViewStatus = tempStatus;
@@ -2147,117 +2745,52 @@ void StopMotion::setWebcamResolution(QString resolution) {
refreshFrameInfo();
- int index = m_webcamResolutions.indexOf(QSize(m_webcamWidth, m_webcamHeight));
+ int index = m_webcam->getIndexOfResolution();
emit(newWebcamResolutionSelected(index));
}
//-----------------------------------------------------------------
-void StopMotion::getWebcamImage() {
- bool error = false;
- cv::Mat imgOriginal;
- cv::Mat imgCorrected;
-
- if (m_cvWebcam.isOpened() == false) {
- initWebcam(m_webcamIndex);
- // mjpg is used by many webcams
- // opencv runs very slow on some webcams without it.
- if (m_useMjpg) {
- m_cvWebcam.set(cv::CAP_PROP_FOURCC,
- cv::VideoWriter::fourcc('m', 'j', 'p', 'g'));
- m_cvWebcam.set(cv::CAP_PROP_FOURCC,
- cv::VideoWriter::fourcc('M', 'J', 'P', 'G'));
- }
- m_cvWebcam.set(3, m_webcamWidth);
- m_cvWebcam.set(4, m_webcamHeight);
- if (!m_cvWebcam.isOpened()) {
- m_hasLiveViewImage = false;
- error = true;
- }
- }
-
- bool blnFrameReadSuccessfully =
- m_cvWebcam.read(imgOriginal); // get next frame
-
- if (!blnFrameReadSuccessfully ||
- imgOriginal.empty()) { // if frame not read successfully
- std::cout << "error: frame not read from webcam\n";
- error = true; // print error message to std out
- }
-
- if (!error) {
- cv::cvtColor(imgOriginal, imgCorrected, cv::COLOR_BGR2BGRA);
- cv::flip(imgCorrected, imgCorrected, 0);
- int width = m_cvWebcam.get(3);
- int height = m_cvWebcam.get(4);
- int size = imgCorrected.total() * imgCorrected.elemSize();
-
- m_liveViewImage = TRaster32P(width, height);
- m_liveViewImage->lock();
- uchar *imgBuf = imgCorrected.data;
- uchar *rawData = m_liveViewImage->getRawData();
- memcpy(rawData, imgBuf, size);
- m_liveViewImage->unlock();
- m_hasLiveViewImage = true;
- m_liveViewStatus = 2;
- if (m_hasLiveViewImage &&
- (m_liveViewDpi.x == 0.0 || m_liveViewImageDimensions.lx == 0)) {
- TCamera *camera =
- TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
- TDimensionD size = camera->getSize();
- m_liveViewImageDimensions =
- TDimension(m_liveViewImage->getLx(), m_liveViewImage->getLy());
- double minimumDpi = std::min(m_liveViewImageDimensions.lx / size.lx,
- m_liveViewImageDimensions.ly / size.ly);
- m_liveViewDpi = TPointD(minimumDpi, minimumDpi);
-
- m_fullImageDimensions = m_liveViewImageDimensions;
-
- m_fullImageDpi = m_liveViewDpi;
-
- emit(newDimensions());
- }
-
- emit(newLiveViewImageReady());
- } else
- m_hasLiveViewImage = false;
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::setUseDirectShow(int state) {
- m_useDirectShow = state;
- StopMotionUseDirectShow = state;
- emit(useDirectShowSignal(state));
-}
+bool StopMotion::toggleLiveView() {
+ bool sessionOpen = false;
-//-----------------------------------------------------------------
+#ifdef WITH_CANON
+ sessionOpen = m_canon->m_sessionOpen;
+#endif
-bool StopMotion::toggleLiveView() {
- if ((m_sessionOpen || m_usingWebcam) && m_liveViewStatus == 0) {
+ if ((sessionOpen || m_usingWebcam) && m_liveViewStatus == LiveViewClosed) {
m_liveViewDpi = TPointD(0.0, 0.0);
m_liveViewImageDimensions = TDimension(0, 0);
if (!m_usingWebcam) {
- startLiveView();
+#ifdef WITH_CANON
+ m_canon->startCanonLiveView();
+#endif
} else
- m_liveViewStatus = 1;
+ m_liveViewStatus = LiveViewStarting;
loadLineUpImage();
m_timer->start(40);
emit(liveViewChanged(true));
Preferences::instance()->setValue(rewindAfterPlayback, false);
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
return true;
- } else if ((m_sessionOpen || m_usingWebcam) && m_liveViewStatus > 0) {
- if (!m_usingWebcam)
- endLiveView();
- else
- releaseWebcam();
+ } else if ((sessionOpen || m_usingWebcam) &&
+ m_liveViewStatus > LiveViewClosed) {
+ if (!m_usingWebcam) {
+#ifdef WITH_CANON
+ m_canon->endCanonLiveView();
+#endif
+ } else {
+ m_webcam->releaseWebcam();
+ }
+
m_timer->stop();
+ emit(liveViewStopped());
emit(liveViewChanged(false));
if (m_turnOnRewind) {
Preferences::instance()->setValue(rewindAfterPlayback, true);
}
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
+ m_liveViewStatus = LiveViewClosed;
return false;
} else {
DVGui::warning(tr("No camera selected."));
@@ -2268,1651 +2801,46 @@ bool StopMotion::toggleLiveView() {
//-----------------------------------------------------------------
void StopMotion::pauseLiveView() {
- if (m_liveViewStatus == 2) {
- m_liveViewStatus = 3;
+ if (m_liveViewStatus == LiveViewOpen) {
+ m_liveViewStatus = LiveViewPaused;
m_userCalledPause = true;
emit(liveViewStopped());
- } else if (m_liveViewStatus == 3) {
- m_liveViewStatus = 2;
+ } else if (m_liveViewStatus == LiveViewPaused) {
+ m_liveViewStatus = LiveViewOpen;
m_userCalledPause = false;
+ } else if (m_liveViewStatus == LiveViewClosed) {
+ toggleLiveView();
}
}
//-----------------------------------------------------------------
-EdsError StopMotion::initializeCanonSDK() {
- m_error = EdsInitializeSDK();
- if (m_error == EDS_ERR_OK) {
- m_isSDKLoaded = true;
- }
- return m_error;
+void StopMotion::toggleAlwaysUseLiveViewImages() {
+ m_alwaysUseLiveViewImages = !m_alwaysUseLiveViewImages;
+ emit(alwaysUseLiveViewImagesToggled(m_alwaysUseLiveViewImages));
+ TApp::instance()->getCurrentScene()->notifySceneChanged();
}
//-----------------------------------------------------------------
-EdsCameraListRef StopMotion::getCameraList() {
- if (!m_isSDKLoaded) initializeCanonSDK();
- if (m_isSDKLoaded) {
- m_error = EdsGetCameraList(&m_cameraList);
- }
- return m_cameraList;
+void StopMotion::onCanonCameraChanged(QString camera) {
+ emit(cameraChanged(camera));
}
//-----------------------------------------------------------------
-
-EdsError StopMotion::releaseCameraList() {
- if (m_cameraList != NULL) m_error = EdsRelease(m_cameraList);
- return m_error;
+std::string StopMotion::getTEnvCameraName() { return StopMotionCameraName; }
+//-----------------------------------------------------------------
+void StopMotion::setTEnvCameraName(std::string name) {
+ StopMotionCameraName = name;
}
-
//-----------------------------------------------------------------
-
-int StopMotion::getCameraCount() {
- if (m_cameraList == NULL) {
- getCameraList();
- }
- if (m_cameraList != NULL) {
- m_error = EdsGetChildCount(m_cameraList, &m_count);
- if (m_count == 0) {
- m_error = EDS_ERR_DEVICE_NOT_FOUND;
- m_sessionOpen = false;
- m_liveViewStatus = 0;
- }
- return m_count;
- } else
- return -1;
+std::string StopMotion::getTEnvCameraResolution() {
+ return StopMotionCameraResolution;
}
-
//-----------------------------------------------------------------
-
-EdsError StopMotion::getCamera(int index) {
- if (m_count == 0) {
- m_error = EDS_ERR_DEVICE_NOT_FOUND;
- }
- if (m_count > 0) {
- m_error = EdsGetChildAtIndex(m_cameraList, index, &m_camera);
- }
- return m_error;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::releaseCamera() {
- if (m_camera != NULL) {
- m_error = EdsRelease(m_camera);
- }
- return m_error;
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::cameraAdded() {
- if (!m_active) refreshCameraList();
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::closeCanonSDK() {
- if (m_isSDKLoaded) {
- EdsTerminateSDK();
- }
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::openCameraSession() {
- if (m_camera != NULL) {
- m_error = EdsOpenSession(m_camera);
- if (m_error == EDS_ERR_OK) m_sessionOpen = true;
- }
- m_error =
- EdsSetObjectEventHandler(m_camera, kEdsObjectEvent_All,
- StopMotion::handleObjectEvent, (EdsVoid *)this);
-
- m_error = EdsSetPropertyEventHandler(m_camera, kEdsPropertyEvent_All,
- StopMotion::handlePropertyEvent,
- (EdsVoid *)this);
-
- m_error = EdsSetCameraStateEventHandler(m_camera, kEdsStateEvent_All,
- StopMotion::handleStateEvent,
- (EdsVoid *)this);
-
- // We can't handle raw images yet, so make sure we are getting jpgs
- if (getCurrentImageQuality().contains("RAW"))
- setImageQuality("Large Fine Jpeg");
-
- EdsUInt32 saveto = kEdsSaveTo_Host;
- m_error = EdsSetPropertyData(m_camera, kEdsPropID_SaveTo, 0,
- sizeof(EdsUInt32), &saveto);
- EdsCapacity newCapacity = {0x7FFFFFFF, 0x1000, 1};
- m_error = EdsSetCapacity(m_camera, newCapacity);
- return m_error;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::closeCameraSession() {
- if (m_camera != NULL) {
- m_error = EdsCloseSession(m_camera);
- m_sessionOpen = false;
- }
- return m_error;
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::refreshOptions() {
- getAvailableShutterSpeeds();
- getAvailableIso();
- getAvailableApertures();
- getAvailableExposureCompensations();
- getAvailableWhiteBalances();
- buildColorTemperatures();
- getAvailableImageQualities();
- getAvailablePictureStyles();
-}
-
-//-----------------------------------------------------------------
-
-std::string StopMotion::getCameraName() {
- EdsChar name[EDS_MAX_NAME];
- EdsError err = EDS_ERR_OK;
- EdsDataType dataType;
- EdsUInt32 dataSize;
- m_error = EdsGetPropertySize(m_camera, kEdsPropID_ProductName, 0, &dataType,
- &dataSize);
-
- if (m_error == EDS_ERR_OK) {
- m_error =
- EdsGetPropertyData(m_camera, kEdsPropID_ProductName, 0, dataSize, name);
- }
- m_cameraName = name;
- return m_cameraName;
-}
-
-//-----------------------------------------------------------------
-
-QString StopMotion::getMode() {
- EdsError err = EDS_ERR_OK;
- EdsDataType modeType;
- EdsUInt32 size;
- EdsUInt32 data;
-
- err = EdsGetPropertySize(m_camera, kEdsPropID_AEMode, 0, &modeType, &size);
- err = EdsGetPropertyData(m_camera, kEdsPropID_AEMode, 0, sizeof(size), &data);
-
- return QString::fromStdString(m_modeMap[data]);
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::getAvailableIso() {
- EdsPropertyDesc *IsoDesc = new EdsPropertyDesc;
- EdsError err = EDS_ERR_OK;
- m_isoOptions.clear();
-
- err = EdsGetPropertyDesc(m_camera, kEdsPropID_ISOSpeed, IsoDesc);
- int count = IsoDesc->numElements;
- if (count > 0) {
- int i = 0;
- while (i < count) {
- m_isoOptions.push_back(
- QString::fromStdString(m_isoMap[IsoDesc->propDesc[i]]));
- i++;
- }
- }
- delete IsoDesc;
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::getAvailableShutterSpeeds() {
- EdsPropertyDesc *TvDesc = new EdsPropertyDesc;
- EdsError err = EDS_ERR_OK;
- m_shutterSpeedOptions.clear();
-
- err = EdsGetPropertyDesc(m_camera, kEdsPropID_Tv, TvDesc);
- int count = TvDesc->numElements;
- if (count > 0) {
- int i = 0;
- while (i < count) {
- m_shutterSpeedOptions.push_back(
- QString::fromStdString(m_tvMap[TvDesc->propDesc[i]]));
- i++;
- }
- }
- delete TvDesc;
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::getAvailableApertures() {
- EdsPropertyDesc *AvDesc = new EdsPropertyDesc;
- EdsError err = EDS_ERR_OK;
- m_apertureOptions.clear();
-
- err = EdsGetPropertyDesc(m_camera, kEdsPropID_Av, AvDesc);
- int count = AvDesc->numElements;
- if (count > 0) {
- int i = 0;
- while (i < count) {
- m_apertureOptions.push_back(
- QString::fromStdString(m_avMap[AvDesc->propDesc[i]]));
- i++;
- }
- }
- delete AvDesc;
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::getAvailableExposureCompensations() {
- EdsPropertyDesc *exposureDesc = new EdsPropertyDesc;
- EdsError err = EDS_ERR_OK;
- m_exposureOptions.clear();
-
- err = EdsGetPropertyDesc(m_camera, kEdsPropID_ExposureCompensation,
- exposureDesc);
- int count = exposureDesc->numElements;
- if (count > 0) {
- int i = 0;
- while (i < count) {
- m_exposureOptions.push_back(
- QString::fromStdString(m_exposureMap[exposureDesc->propDesc[i]]));
- i++;
- }
- }
- delete exposureDesc;
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::getAvailableWhiteBalances() {
- EdsPropertyDesc *whiteBalanceDesc = new EdsPropertyDesc;
- EdsError err = EDS_ERR_OK;
- m_whiteBalanceOptions.clear();
-
- err = EdsGetPropertyDesc(m_camera, kEdsPropID_WhiteBalance, whiteBalanceDesc);
- int count = whiteBalanceDesc->numElements;
- if (count > 0) {
- int i = 0;
- while (i < count) {
- m_whiteBalanceOptions.push_back(QString::fromStdString(
- m_whiteBalanceMap[whiteBalanceDesc->propDesc[i]]));
- i++;
- }
- }
- delete whiteBalanceDesc;
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::getAvailableImageQualities() {
- EdsPropertyDesc *imageQualityDesc = new EdsPropertyDesc;
- EdsError err = EDS_ERR_OK;
- m_imageQualityOptions.clear();
-
- err = EdsGetPropertyDesc(m_camera, kEdsPropID_ImageQuality, imageQualityDesc);
- int count = imageQualityDesc->numElements;
- if (count > 0) {
- int i = 0;
- while (i < count) {
- QString quality = QString::fromStdString(
- m_imageQualityMap[imageQualityDesc->propDesc[i]]);
- if (!quality.contains("RAW")) {
- m_imageQualityOptions.push_back(quality);
- }
- i++;
- }
- }
- delete imageQualityDesc;
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::getAvailablePictureStyles() {
- EdsPropertyDesc *pictureStyleDesc = new EdsPropertyDesc;
- EdsError err = EDS_ERR_OK;
- m_pictureStyleOptions.clear();
-
- err = EdsGetPropertyDesc(m_camera, kEdsPropID_PictureStyle, pictureStyleDesc);
- int count = pictureStyleDesc->numElements;
- if (count > 0) {
- int i = 0;
- while (i < count) {
- m_pictureStyleOptions.push_back(QString::fromStdString(
- m_pictureStyleMap[pictureStyleDesc->propDesc[i]]));
- i++;
- }
- }
- delete pictureStyleDesc;
- return err;
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::buildColorTemperatures() {
- m_colorTempOptions.clear();
- int i = 2800;
- while (i <= 10000) {
- m_colorTempOptions.push_back(QString::number(i));
- i += 100;
- }
-}
-
-//-----------------------------------------------------------------
-
-QString StopMotion::getCurrentShutterSpeed() {
- EdsError err = EDS_ERR_OK;
- EdsDataType tvType;
- EdsUInt32 size;
- EdsUInt32 data;
-
- err = EdsGetPropertySize(m_camera, kEdsPropID_Tv, 0, &tvType, &size);
- err = EdsGetPropertyData(m_camera, kEdsPropID_Tv, 0, sizeof(size), &data);
-
- return QString::fromStdString(m_tvMap[data]);
-}
-
-//-----------------------------------------------------------------
-
-QString StopMotion::getCurrentIso() {
- EdsError err = EDS_ERR_OK;
- EdsDataType isoType;
- EdsUInt32 size;
- EdsUInt32 data;
-
- err = EdsGetPropertySize(m_camera, kEdsPropID_ISOSpeed, 0, &isoType, &size);
- err =
- EdsGetPropertyData(m_camera, kEdsPropID_ISOSpeed, 0, sizeof(size), &data);
-
- return QString::fromStdString(m_isoMap[data]);
-}
-
-//-----------------------------------------------------------------
-
-QString StopMotion::getCurrentAperture() {
- EdsError err = EDS_ERR_OK;
- EdsDataType avType;
- EdsUInt32 size;
- EdsUInt32 data;
-
- err = EdsGetPropertySize(m_camera, kEdsPropID_Av, 0, &avType, &size);
- err = EdsGetPropertyData(m_camera, kEdsPropID_Av, 0, sizeof(size), &data);
-
- return QString::fromStdString(m_avMap[data]);
-}
-
-//-----------------------------------------------------------------
-
-QString StopMotion::getCurrentExposureCompensation() {
- EdsError err = EDS_ERR_OK;
- EdsDataType exposureType;
- EdsUInt32 size;
- EdsUInt32 data;
-
- err = EdsGetPropertySize(m_camera, kEdsPropID_ExposureCompensation, 0,
- &exposureType, &size);
- err = EdsGetPropertyData(m_camera, kEdsPropID_ExposureCompensation, 0,
- sizeof(size), &data);
-
- return QString::fromStdString(m_exposureMap[data]);
-}
-
-//-----------------------------------------------------------------
-
-QString StopMotion::getCurrentWhiteBalance() {
- EdsError err = EDS_ERR_OK;
- EdsDataType whiteBalanceType;
- EdsUInt32 size;
- EdsUInt32 data;
-
- err = EdsGetPropertySize(m_camera, kEdsPropID_WhiteBalance, 0,
- &whiteBalanceType, &size);
- err = EdsGetPropertyData(m_camera, kEdsPropID_WhiteBalance, 0, sizeof(size),
- &data);
- std::string wbString = m_whiteBalanceMap[data];
- return QString::fromStdString(m_whiteBalanceMap[data]);
-}
-
-//-----------------------------------------------------------------
-
-QString StopMotion::getCurrentImageQuality() {
- EdsError err = EDS_ERR_OK;
- EdsDataType imageQualityType;
- EdsUInt32 size;
- EdsUInt32 data;
-
- err = EdsGetPropertySize(m_camera, kEdsPropID_ImageQuality, 0,
- &imageQualityType, &size);
- err = EdsGetPropertyData(m_camera, kEdsPropID_ImageQuality, 0, sizeof(size),
- &data);
- std::string wbString = m_imageQualityMap[data];
- return QString::fromStdString(m_imageQualityMap[data]);
-}
-
-//-----------------------------------------------------------------
-
-QString StopMotion::getCurrentPictureStyle() {
- EdsError err = EDS_ERR_OK;
- EdsDataType pictureStyleType;
- EdsUInt32 size;
- EdsUInt32 data;
-
- err = EdsGetPropertySize(m_camera, kEdsPropID_PictureStyle, 0,
- &pictureStyleType, &size);
- err = EdsGetPropertyData(m_camera, kEdsPropID_PictureStyle, 0, sizeof(size),
- &data);
- std::string wbString = m_pictureStyleMap[data];
- return QString::fromStdString(m_pictureStyleMap[data]);
-}
-
-//-----------------------------------------------------------------
-
-QString StopMotion::getCurrentColorTemperature() {
- EdsError err = EDS_ERR_OK;
- EdsDataType colorTempType;
- EdsUInt32 size;
- EdsUInt32 data;
-
- err = EdsGetPropertySize(m_camera, kEdsPropID_ColorTemperature, 0,
- &colorTempType, &size);
- err = EdsGetPropertyData(m_camera, kEdsPropID_ColorTemperature, 0,
- sizeof(size), &data);
-
- return QString::number(data);
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::setShutterSpeed(QString shutterSpeed) {
- EdsError err = EDS_ERR_OK;
- EdsUInt32 value;
- auto it = m_tvMap.begin();
- while (it != m_tvMap.end()) {
- if (it->second == shutterSpeed.toStdString()) {
- value = it->first;
- break;
- }
- it++;
- }
-
- err = EdsSetPropertyData(m_camera, kEdsPropID_Tv, 0, sizeof(value), &value);
- emit(shutterSpeedChangedSignal(shutterSpeed));
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::setIso(QString iso) {
- EdsError err = EDS_ERR_OK;
- EdsUInt32 value;
- auto it = m_isoMap.begin();
- while (it != m_isoMap.end()) {
- if (it->second == iso.toStdString()) {
- value = it->first;
- break;
- }
- it++;
- }
-
- err = EdsSetPropertyData(m_camera, kEdsPropID_ISOSpeed, 0, sizeof(value),
- &value);
- emit(isoChangedSignal(iso));
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::setAperture(QString aperture) {
- EdsError err = EDS_ERR_OK;
- EdsUInt32 value;
- auto it = m_avMap.begin();
- while (it != m_avMap.end()) {
- if (it->second == aperture.toStdString()) {
- value = it->first;
- break;
- }
- it++;
- }
-
- err = EdsSetPropertyData(m_camera, kEdsPropID_Av, 0, sizeof(value), &value);
- emit(apertureChangedSignal(aperture));
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::setExposureCompensation(QString exposure) {
- EdsError err = EDS_ERR_OK;
- EdsUInt32 value;
- auto it = m_exposureMap.begin();
- while (it != m_exposureMap.end()) {
- if (it->second == exposure.toStdString()) {
- value = it->first;
- break;
- }
- it++;
- }
-
- err = EdsSetPropertyData(m_camera, kEdsPropID_ExposureCompensation, 0,
- sizeof(value), &value);
- emit(exposureChangedSignal(exposure));
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::setWhiteBalance(QString whiteBalance) {
- EdsError err = EDS_ERR_OK;
- EdsUInt32 value;
- auto it = m_whiteBalanceMap.begin();
- while (it != m_whiteBalanceMap.end()) {
- if (it->second == whiteBalance.toStdString()) {
- value = it->first;
- break;
- }
- it++;
- }
-
- err = EdsSetPropertyData(m_camera, kEdsPropID_WhiteBalance, 0, sizeof(value),
- &value);
- emit(whiteBalanceChangedSignal(whiteBalance));
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::setImageQuality(QString quality) {
- EdsError err = EDS_ERR_OK;
- EdsUInt32 value;
- auto it = m_imageQualityMap.begin();
- while (it != m_imageQualityMap.end()) {
- if (it->second == quality.toStdString()) {
- value = it->first;
- break;
- }
- it++;
- }
-
- err = EdsSetPropertyData(m_camera, kEdsPropID_ImageQuality, 0, sizeof(value),
- &value);
- emit(imageQualityChangedSignal(quality));
- m_proxyImageDimensions = TDimension(0, 0);
- m_proxyDpi = TPointD(0.0, 0.0);
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::setPictureStyle(QString style) {
- EdsError err = EDS_ERR_OK;
- EdsUInt32 value;
- auto it = m_pictureStyleMap.begin();
- while (it != m_pictureStyleMap.end()) {
- if (it->second == style.toStdString()) {
- value = it->first;
- break;
- }
- it++;
- }
-
- err = EdsSetPropertyData(m_camera, kEdsPropID_PictureStyle, 0, sizeof(value),
- &value);
- err = EdsSetPropertyData(m_camera, kEdsPropID_PictureStyle, 0, sizeof(value),
- &value);
- emit(pictureStyleChangedSignal(style));
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::setColorTemperature(QString temp) {
- EdsError err = EDS_ERR_OK;
- EdsUInt32 value;
- value = temp.toInt();
-
- err = EdsSetPropertyData(m_camera, kEdsPropID_ColorTemperature, 0,
- sizeof(value), &value);
- err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_ColorTemperature, 0,
- sizeof(value), &value);
- emit(colorTemperatureChangedSignal(temp));
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::downloadImage(EdsBaseRef object) {
- EdsError err = EDS_ERR_OK;
- EdsStreamRef stream = NULL;
- EdsDirectoryItemInfo dirItemInfo;
-
- err = EdsGetDirectoryItemInfo(object, &dirItemInfo);
- err = EdsCreateMemoryStream(0, &stream);
- err = EdsDownload(object, dirItemInfo.size, stream);
- EdsDownloadComplete(object);
-
- // tj code
-
- unsigned __int64 mySize = 0;
- unsigned char *data = NULL;
- err = EdsGetPointer(stream, (EdsVoid **)&data);
- err = EdsGetLength(stream, &mySize);
-
- int width, height, pixelFormat;
- // long size;
- int inSubsamp, inColorspace;
- // unsigned long jpegSize;
- tjhandle tjInstance = NULL;
- unsigned char *imgBuf = NULL;
- tjInstance = tjInitDecompress();
- tjDecompressHeader3(tjInstance, data, mySize, &width, &height, &inSubsamp,
- &inColorspace);
-
- pixelFormat = TJPF_BGRX;
- imgBuf = (unsigned char *)tjAlloc(width * height * tjPixelSize[pixelFormat]);
- int flags = 0;
-#ifdef WIN32
- flags |= TJFLAG_BOTTOMUP;
-#endif
- int tempWidth, tempHeight;
-
- if (m_useScaledImages) {
- int factorsNum;
- tjscalingfactor scalingFactor = {1, 1};
- tjscalingfactor *factor = tjGetScalingFactors(&factorsNum);
- int intRatio = (float)width / (float)height * 100.0;
- int i = 0;
-
- TCamera *camera =
- TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
- TDimension res = camera->getRes();
-
- // find the scaling factor that is at least as big as the current camera
- while (i < factorsNum) {
- scalingFactor = factor[i];
- tempWidth = TJSCALED(width, scalingFactor);
- if (tempWidth < res.lx && i > 0) {
- scalingFactor = factor[i - 1];
- break;
- }
- i++;
- }
- // make sure the scaling factor has the right aspect ratio
- while (i >= 0) {
- tempWidth = TJSCALED(width, scalingFactor);
- tempHeight = TJSCALED(height, scalingFactor);
- if ((int)((float)tempWidth / (float)tempHeight * 100.0) == intRatio) {
- break;
- }
- i--;
- scalingFactor = factor[i];
- }
- } else {
- tempWidth = width;
- tempHeight = height;
- }
-
- if (m_useScaledImages || !getCurrentImageQuality().contains("Large")) {
- TCamera *camera =
- TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
- TDimensionD size = camera->getSize();
- m_proxyImageDimensions = TDimension(tempWidth, tempHeight);
- double minimumDpi = std::min(m_proxyImageDimensions.lx / size.lx,
- m_proxyImageDimensions.ly / size.ly);
- m_proxyDpi = TPointD(minimumDpi, minimumDpi);
- }
-
- tjDecompress2(tjInstance, data, mySize, imgBuf, tempWidth,
- tempWidth * tjPixelSize[pixelFormat], tempHeight, pixelFormat,
- flags);
-
- m_newImage = TRaster32P(tempWidth, tempHeight);
- m_newImage->lock();
- uchar *rawData = m_newImage->getRawData();
- memcpy(rawData, imgBuf, tempWidth * tempHeight * tjPixelSize[pixelFormat]);
- m_newImage->unlock();
-
- tjFree(imgBuf);
- imgBuf = NULL;
- tjDestroy(tjInstance);
- tjInstance = NULL;
-
- // end tj code
-
- if (m_useScaledImages) {
- QFile fullImage(m_tempFile);
- fullImage.open(QIODevice::WriteOnly);
- QDataStream dataStream(&fullImage);
- dataStream.writeRawData((const char *)data, mySize);
- fullImage.close();
- }
-
- EdsRelease(stream);
- stream = NULL;
- if (object) EdsRelease(object);
-
- if (err == EDS_ERR_OK) {
- emit(newImageReady());
- }
-
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::takePicture() {
- EdsError err;
- err = EdsSendCommand(m_camera, kEdsCameraCommand_PressShutterButton,
- kEdsCameraCommand_ShutterButton_Completely_NonAF);
- err = EdsSendCommand(m_camera, kEdsCameraCommand_PressShutterButton,
- kEdsCameraCommand_ShutterButton_OFF);
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::startLiveView() {
- if (m_camera && m_sessionOpen) {
- EdsError err = EDS_ERR_OK;
- // Get the output device for the live view image
- EdsUInt32 device;
- err = EdsGetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
- sizeof(device), &device);
- // PC live view starts by setting the PC as the output device for the live
- // view image.
- if (err == EDS_ERR_OK) {
- device |= kEdsEvfOutputDevice_PC;
- err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
- sizeof(device), &device);
- }
- if (err == EDS_ERR_OK) {
- m_liveViewStatus = LiveViewStarting;
- }
- // A property change event notification is issued from the camera if
- // property settings are made successfully. Start downloading of the live
- // view image once the property change notification arrives.
- return err;
- } else
- return EDS_ERR_DEVICE_NOT_FOUND;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::endLiveView() {
- EdsError err = EDS_ERR_OK;
- // Get the output device for the live view image
- EdsUInt32 device;
- err = EdsGetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
- sizeof(device), &device);
- // PC live view ends if the PC is disconnected from the live view image output
- // device.
- if (err == EDS_ERR_OK) {
- device &= ~kEdsEvfOutputDevice_PC;
- err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_OutputDevice, 0,
- sizeof(device), &device);
- }
- m_liveViewStatus = LiveViewClosed;
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::zoomLiveView() {
- if (!m_sessionOpen) return EDS_ERR_DEVICE_INVALID;
- EdsError err = EDS_ERR_OK;
-
- if (m_liveViewZoom == 1) {
- m_liveViewZoom = 5;
- m_zooming = true;
- } else if (m_liveViewZoom == 5) {
- m_liveViewZoom = 1;
- m_zooming = false;
- }
-
- err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_Zoom, 0,
- sizeof(m_liveViewZoom), &m_liveViewZoom);
- if (m_liveViewZoom == 5) setZoomPoint();
-
- return err;
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::makeZoomPoint(TPointD pos) {
- m_liveViewZoomPickPoint = pos;
- double maxFullWidth =
- (double)m_fullImageDimensions.lx / m_fullImageDpi.x * Stage::inch;
- double maxFullHeight =
- (double)m_fullImageDimensions.ly / m_fullImageDpi.y * Stage::inch;
- double newX = m_liveViewZoomPickPoint.x + maxFullWidth / 2.0;
- double newY = -m_liveViewZoomPickPoint.y + maxFullHeight / 2.0;
- m_calculatedZoomPoint.x = newX / Stage::inch * m_fullImageDpi.x;
- m_calculatedZoomPoint.y = newY / Stage::inch * m_fullImageDpi.x;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::setZoomPoint() {
- EdsError err = EDS_ERR_OK;
-
- EdsPoint zoomPoint;
- if (m_liveViewZoomPickPoint == TPointD(0.0, 0.0)) {
- m_calculatedZoomPoint =
- TPoint(m_fullImageDimensions.lx / 2, m_fullImageDimensions.ly / 2);
- m_finalZoomPoint.x = m_calculatedZoomPoint.x - (m_zoomRect.x / 2);
- m_finalZoomPoint.y = m_calculatedZoomPoint.y - (m_zoomRect.y / 2);
- } else {
- m_finalZoomPoint.x = m_calculatedZoomPoint.x - (m_zoomRect.x / 2);
- m_finalZoomPoint.y = m_calculatedZoomPoint.y - (m_zoomRect.y / 2);
- if (m_finalZoomPoint.x < 0) m_finalZoomPoint.x = 0;
- if (m_finalZoomPoint.y < 0) m_finalZoomPoint.y = 0;
- if (m_finalZoomPoint.x > m_fullImageDimensions.lx - (m_zoomRect.x)) {
- m_finalZoomPoint.x = m_fullImageDimensions.lx - (m_zoomRect.x);
- }
- if (m_finalZoomPoint.y > m_fullImageDimensions.ly - (m_zoomRect.y)) {
- m_finalZoomPoint.y = m_fullImageDimensions.ly - (m_zoomRect.y);
- }
- }
-
- zoomPoint.x = m_finalZoomPoint.x;
- zoomPoint.y = m_finalZoomPoint.y;
-
- // make sure this is set AFTER starting zoom
- err = EdsSetPropertyData(m_camera, kEdsPropID_Evf_ZoomPosition, 0,
- sizeof(zoomPoint), &zoomPoint);
-
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::downloadEVFData() {
- EdsError err = EDS_ERR_OK;
- EdsStreamRef stream = NULL;
- EdsEvfImageRef evfImage = NULL;
-
- // Create memory stream.
- err = EdsCreateMemoryStream(0, &stream);
- // Create EvfImageRef.
- if (err == EDS_ERR_OK) {
- err = EdsCreateEvfImageRef(stream, &evfImage);
- }
- // Download live view image data.
- if (err == EDS_ERR_OK) {
- err = EdsDownloadEvfImage(m_camera, evfImage);
- }
-
- EdsDataType evfZoom;
- EdsDataType evfZoomPos;
- EdsDataType evfZoomRect;
- EdsUInt32 size;
- EdsUInt32 sizePos;
- EdsUInt32 sizeRect;
- EdsUInt32 sizeImagePos;
- EdsUInt32 sizeCoordSys;
- EdsUInt32 zoomAmount;
- EdsPoint zoomPos;
- EdsRect zoomRect;
- EdsPoint imagePos;
- EdsSize coordSys;
-
- err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_Zoom, 0, &evfZoom, &size);
- err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_Zoom, 0, sizeof(size),
- &zoomAmount);
-
- // this is the top corner? of the zoomed image
- err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_ZoomPosition, 0,
- &evfZoomPos, &sizePos);
- err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomPosition, 0, sizePos,
- &zoomPos);
- // this is the top corner of the zoomed image and the size of the zoomed image
- err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_ZoomRect, 0, &evfZoomRect,
- &sizeRect);
- err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomRect, 0, sizeRect,
- &zoomRect);
-
- err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_ImagePosition, 0,
- &evfZoomRect, &sizeImagePos);
- err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_ImagePosition, 0,
- sizeImagePos, &imagePos);
- // this returns the size of the full image
- err = EdsGetPropertySize(evfImage, kEdsPropID_Evf_CoordinateSystem, 0,
- &evfZoomRect, &sizeCoordSys);
- err = EdsGetPropertyData(evfImage, kEdsPropID_Evf_CoordinateSystem, 0,
- sizeCoordSys, &coordSys);
-
- m_zoomRect = TPoint(zoomRect.size.width, zoomRect.size.height);
- if (zoomAmount == 5 && m_zoomRect == TPoint(0, 0)) {
- setZoomPoint();
- }
-
- // Get the incidental data of the image.
- if (err == EDS_ERR_OK) {
- JpgConverter *converter = new JpgConverter;
- converter->setStream(stream);
- converter->setScale(m_useScaledImages);
-
- connect(converter, SIGNAL(imageReady(bool)), this, SLOT(onImageReady(bool)),
- Qt::QueuedConnection);
- connect(converter, SIGNAL(finished()), this, SLOT(onFinished()),
- Qt::QueuedConnection);
-
- converter->start();
-
- while (!l_quitLoop)
- QCoreApplication::processEvents(QEventLoop::AllEvents |
- QEventLoop::WaitForMoreEvents);
-
- l_quitLoop = false;
- m_liveViewImage = converter->getImage();
- m_hasLiveViewImage = true;
- delete converter;
- if (!m_converterSucceeded) return EDS_ERR_UNEXPECTED_EXCEPTION;
-
- // make sure not to set to LiveViewOpen if it has been turned off
- if (m_liveViewStatus > 0) {
- m_liveViewStatus = LiveViewOpen;
- }
- emit(newLiveViewImageReady());
-
- if (m_hasLiveViewImage &&
- (m_liveViewDpi.x == 0.0 || m_liveViewImageDimensions.lx == 0)) {
- TCamera *camera =
- TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
- TDimensionD size = camera->getSize();
- m_liveViewImageDimensions =
- TDimension(m_liveViewImage->getLx(), m_liveViewImage->getLy());
- double minimumDpi = std::min(m_liveViewImageDimensions.lx / size.lx,
- m_liveViewImageDimensions.ly / size.ly);
- m_liveViewDpi = TPointD(minimumDpi, minimumDpi);
-
- m_fullImageDimensions = TDimension(coordSys.width, coordSys.height);
- minimumDpi = std::min(m_fullImageDimensions.lx / size.lx,
- m_fullImageDimensions.ly / size.ly);
- m_fullImageDpi = TPointD(minimumDpi, minimumDpi);
-
- emit(newDimensions());
- }
- }
-
- if (stream != NULL) {
- EdsRelease(stream);
- }
- stream = NULL;
- if (evfImage != NULL) {
- EdsRelease(evfImage);
- evfImage = NULL;
- }
-
- // calculate dpi data
-
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::focusNear() {
- EdsError err = EDS_ERR_OK;
- err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
- kEdsEvfDriveLens_Near1);
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::focusFar() {
- EdsError err = EDS_ERR_OK;
- err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
- kEdsEvfDriveLens_Far1);
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::focusNear2() {
- EdsError err = EDS_ERR_OK;
- err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
- kEdsEvfDriveLens_Near2);
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::focusFar2() {
- EdsError err = EDS_ERR_OK;
- err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
- kEdsEvfDriveLens_Far2);
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::focusNear3() {
- EdsError err = EDS_ERR_OK;
- err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
- kEdsEvfDriveLens_Near3);
- return err;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::focusFar3() {
- EdsError err = EDS_ERR_OK;
- err = EdsSendCommand(m_camera, kEdsCameraCommand_DriveLensEvf,
- kEdsEvfDriveLens_Far3);
- return err;
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::onImageReady(const bool &status) {
- m_converterSucceeded = status;
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::onFinished() { l_quitLoop = true; }
-
-//-----------------------------------------------------------------
-//-----------------------------------------------------------------
-
-EdsError StopMotion::handleObjectEvent(EdsObjectEvent event, EdsBaseRef object,
- EdsVoid *context) {
- if (event == kEdsObjectEvent_DirItemRequestTransfer) {
- instance()->downloadImage(object);
- }
-
- return EDS_ERR_OK;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::handlePropertyEvent(EdsPropertyEvent event,
- EdsPropertyID property,
- EdsUInt32 param, EdsVoid *context) {
- if (property == kEdsPropID_Evf_OutputDevice &&
- event == kEdsPropertyEvent_PropertyChanged) {
- if (instance()->m_liveViewStatus == LiveViewStarting)
- instance()->m_liveViewStatus = LiveViewOpen;
- }
- if (property == kEdsPropID_AEMode &&
- event == kEdsPropertyEvent_PropertyChanged) {
- emit(instance()->modeChanged());
- }
-
- if (property == kEdsPropID_Av &&
- event == kEdsPropertyEvent_PropertyDescChanged) {
- emit(instance()->apertureOptionsChanged());
- }
-
- if (property == kEdsPropID_Tv &&
- event == kEdsPropertyEvent_PropertyDescChanged) {
- emit(instance()->shutterSpeedOptionsChanged());
- }
- if (property == kEdsPropID_ISOSpeed &&
- event == kEdsPropertyEvent_PropertyDescChanged) {
- emit(instance()->isoOptionsChanged());
- }
- if (property == kEdsPropID_ExposureCompensation &&
- event == kEdsPropertyEvent_PropertyDescChanged) {
- emit(instance()->exposureOptionsChanged());
- }
- if (property == kEdsPropID_WhiteBalance &&
- event == kEdsPropertyEvent_PropertyDescChanged) {
- emit(instance()->whiteBalanceOptionsChanged());
- }
- if (property == kEdsPropID_PictureStyle &&
- event == kEdsPropertyEvent_PropertyDescChanged) {
- emit(instance()->pictureStyleOptionsChanged());
- }
- if (property == kEdsPropID_ImageQuality &&
- event == kEdsPropertyEvent_PropertyDescChanged) {
- emit(instance()->imageQualityOptionsChanged());
- }
-
- return EDS_ERR_OK;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::handleStateEvent(EdsStateEvent event, EdsUInt32 parameter,
- EdsVoid *context) {
- if (event == kEdsStateEvent_Shutdown) {
- if (instance()->m_sessionOpen) {
- instance()->closeCameraSession();
- instance()->releaseCamera();
- instance()->m_liveViewStatus = LiveViewClosed;
- emit(instance()->cameraChanged());
- }
- }
- return EDS_ERR_OK;
-}
-
-//-----------------------------------------------------------------
-
-EdsError StopMotion::handleCameraAddedEvent(EdsVoid *context) {
- instance()->cameraAdded();
- return EDS_ERR_OK;
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::buildAvMap() {
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x00, "00"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x08, "1"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x0B, "1.1"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x0C, "1.2"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x0D, "1.2"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x10, "1.4"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x13, "1.6"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x14, "1.8"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x15, "1.8"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x18, "2"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x1B, "2.2"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x1C, "2.5"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x1D, "2.5"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x20, "2.8"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x23, "3.2"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x24, "3.5"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x25, "3.5"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x28, "4"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x2B, "4.5"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x2C, "4.5"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x2D, "5.0"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x30, "5.6"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x33, "6.3"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x34, "6.7"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x35, "7.1"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x38, "8"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x3B, "9"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x3C, "9.5"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x3D, "10"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x40, "11"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x43, "13"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x44, "13"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x45, "14"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x48, "16"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x4B, "18"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x4C, "19"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x4D, "20"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x50, "22"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x53, "25"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x54, "27"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x55, "29"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x58, "32"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x5B, "36"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x5C, "38"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x5D, "40"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x60, "45"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x63, "51"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x64, "54"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x65, "57"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x68, "64"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x6B, "72"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x6C, "76"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x6D, "80"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0x70, "91"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0xFF, "Auto"));
- m_avMap.insert(std::pair<EdsUInt32, const char *>(0xffffffff, "unknown"));
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::buildIsoMap() {
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x00, "Auto"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x28, "6"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x30, "12"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x38, "25"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x40, "50"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x48, "100"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x4b, "125"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x4d, "160"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x50, "200"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x53, "250"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x55, "320"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x58, "400"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x5b, "500"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x5d, "640"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x60, "800"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x63, "1000"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x65, "1250"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x68, "1600"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x6b, "2000"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x6d, "2500"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x70, "3200"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x73, "4000"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x75, "5000"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x78, "6400"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x7b, "8000"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x7d, "10000"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x80, "12800"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x83, "16000"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x85, "20000"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x88, "25600"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x8b, "32000"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x8d, "40000"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x90, "51200"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0x98, "102400"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0xa0, "204800"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0xa8, "409600"));
- m_isoMap.insert(std::pair<EdsUInt32, const char *>(0xffffffff, "unknown"));
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::buildTvMap() {
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x04, "Auto"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x0c, "Bulb"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x10, "30\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x13, "25\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x14, "20\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x15, "20\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x18, "15\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x1B, "13\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x1C, "10\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x1D, "10\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x20, "8\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x23, "6\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x24, "6\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x25, "5\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x28, "4\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x2B, "3\"2"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x2C, "3\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x2D, "2\"5"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x30, "2\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x33, "1\"6"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x34, "1\"5"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x35, "1\"3"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x38, "1\""));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x3B, "0\"8"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x3C, "0\"7"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x3D, "0\"6"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x40, "0\"5"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x43, "0\"4"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x44, "0\"3"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x45, "0\"3"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x48, "1/4"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x4B, "1/5"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x4C, "1/6"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x4D, "1/6"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x50, "1/8"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x53, "1/10"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x54, "1/10"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x55, "1/13"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x58, "1/15"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x5B, "1/20"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x5C, "1/20"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x5D, "1/25"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x60, "1/30"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x63, "1/40"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x64, "1/45"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x65, "1/50"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x68, "1/60"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x6B, "1/80"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x6C, "1/90"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x6D, "1/100"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x70, "1/125"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x73, "1/160"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x74, "1/180"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x75, "1/200"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x78, "1/250"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x7B, "1/320"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x7C, "1/350"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x7D, "1/400"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x80, "1/500"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x83, "1/640"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x84, "1/750"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x85, "1/800"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x88, "1/1000"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x8B, "1/1250"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x8C, "1/1500"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x8D, "1/1600"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x90, "1/2000"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x93, "1/2500"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x94, "1/3000"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x95, "1/3200"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x98, "1/4000"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x9B, "1/5000"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x9C, "1/6000"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0x9D, "1/6400"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0xA0, "1/8000"));
- m_tvMap.insert(std::pair<EdsUInt32, const char *>(0xffffffff, "unknown"));
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::buildModeMap() {
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(0, "P"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(1, "Tv"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(2, "Av"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(3, "M"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(55, "FV"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(4, "Bulb"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(5, "A-DEP"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(6, "DEP"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(7, "C1"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(16, "C2"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(17, "C3"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(8, "Lock"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(9, "GreenMode"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(10, "Night Portrait"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(11, "Sports"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(13, "LandScape"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(14, "Close-Up"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(15, "No Strobo"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(12, "Portrait"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(19, "Creative Auto"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(20, "Movies"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(25, "SCN"));
- m_modeMap.insert(
- std::pair<EdsUInt32, const char *>(22, "Scene Intelligent Auto"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(29, "Creative filters"));
- m_modeMap.insert(std::pair<EdsUInt32, const char *>(0xffffffff, "unknown"));
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::buildExposureMap() {
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x28, "+5"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x25, "+4 2/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x24, "+4 1/2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x23, "+4 1/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x20, "+4"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x1D, "+3 2/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x1C, "+3 1/2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x1B, "+3 1/3"));
-
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x18, "+3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x15, "+2 2/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x14, "+2 1/2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x13, "+2 1/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x10, "+2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x0d, "+1 2/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x0c, "+1 1/2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x0b, "+1 1/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x08, "+1"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x05, "+2/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x04, "+1/2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x03, "+1/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0x00, "0"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xfd, "-1/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xfc, "-1/2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xfb, "-2/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xf8, "-1"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xf5, "-1 1/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xf4, "-1 1/2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xf3, "-1 2/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xf0, "-2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xed, "-2 1/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xec, "-2 1/2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xeb, "-2 2/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xe8, "-3"));
-
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xE5, "-3 1/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xE4, "-3 1/2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xE3, "-3 2/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xE0, "-4"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xDD, "-4 1/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xDC, "-4 1/2"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xDB, "-4 2/3"));
- m_exposureMap.insert(std::pair<EdsUInt32, const char *>(0xD8, "-5"));
-
- m_exposureMap.insert(
- std::pair<EdsUInt32, const char *>(0xffffffff, "unknown"));
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::buildWhiteBalanceMap() {
- m_whiteBalanceMap.insert(
- std::pair<EdsUInt32, const char *>(0, "Auto: Ambience Priority"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(1, "Daylight"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(2, "Cloudy"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(3, "Tungsten"));
- m_whiteBalanceMap.insert(
- std::pair<EdsUInt32, const char *>(4, "Fluorescent"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(5, "Flash"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(6, "Manual"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(8, "Shade"));
- m_whiteBalanceMap.insert(
- std::pair<EdsUInt32, const char *>(9, "Color Temperature"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(10, "Custom 1"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(11, "Custom 2"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(12, "Custom 3"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(15, "Manual 2"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(16, "Manual 3"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(18, "Manual 4"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(19, "Manual 5"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(20, "Custom 4"));
- m_whiteBalanceMap.insert(std::pair<EdsUInt32, const char *>(21, "Custom 5"));
- m_whiteBalanceMap.insert(
- std::pair<EdsUInt32, const char *>(23, "Auto: White Priority"));
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::buildImageQualityMap() {
- m_imageQualityMap.insert(
- std::pair<EdsUInt32, const char *>(EdsImageQuality_LR, "RAW"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRLJF, "RAW + Large Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRMJF, "RAW + Middle Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRSJF, "RAW + Small Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRLJN, "RAW + Large Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRMJN, "RAW + Middle Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRSJN, "RAW + Small Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRS1JF, "RAW + Small1 Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRS1JN, "RAW + Small1 Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRS2JF, "RAW + Small2 Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRS3JF, "RAW + Small3 Jpeg"));
-
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRLJ, "RAW + Large Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRM1J, "RAW + Middle1 Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRM2J, "RAW + Middle2 Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LRSJ, "RAW + Small Jpeg"));
-
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MR, "Middle Raw(Small RAW1)"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRLJF, "Middle Raw(Small RAW1) + Large Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRMJF, "Middle Raw(Small RAW1) + Middle Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRSJF, "Middle Raw(Small RAW1) + Small Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRLJN, "Middle Raw(Small RAW1) + Large Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRMJN, "Middle Raw(Small RAW1) + Middle Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRSJN, "Middle Raw(Small RAW1) + Small Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRS1JF, "Middle RAW + Small1 Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRS1JN, "Middle RAW + Small1 Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRS2JF, "Middle RAW + Small2 Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRS3JF, "Middle RAW + Small3 Jpeg"));
-
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRLJ, "Middle Raw + Large Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRM1J, "Middle Raw + Middle1 Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRM2J, "Middle Raw + Middle2 Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MRSJ, "Middle Raw + Small Jpeg"));
-
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SR, "Small RAW(Small RAW2)"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRLJF, "Small RAW(Small RAW2) + Large Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRMJF, "Small RAW(Small RAW2) + Middle Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRSJF, "Small RAW(Small RAW2) + Small Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRLJN, "Small RAW(Small RAW2) + Large Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRMJN, "Small RAW(Small RAW2) + Middle Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRSJN, "Small RAW(Small RAW2) + Small Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRS1JF, "Small RAW + Small1 Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRS1JN, "Small RAW + Small1 Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRS2JF, "Small RAW + Small2 Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRS3JF, "Small RAW + Small3 Jpeg"));
-
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRLJ, "Small RAW + Large Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRM1J, "Small RAW + Middle1 Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRM2J, "Small RAW + Middle2 Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SRSJ, "Small RAW + Small Jpeg"));
-
- m_imageQualityMap.insert(
- std::pair<EdsUInt32, const char *>(EdsImageQuality_CR, "CRAW"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRLJF, "CRAW + Large Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRMJF, "CRAW + Middle Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRM1JF, "CRAW + Middle1 Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRM2JF, "CRAW + Middle2 Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRSJF, "CRAW + Small Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRS1JF, "CRAW + Small1 Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRS2JF, "CRAW + Small2 Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRS3JF, "CRAW + Small3 Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRLJN, "CRAW + Large Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRMJN, "CRAW + Middle Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRM1JN, "CRAW + Middle1 Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRM2JN, "CRAW + Middle2 Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRSJN, "CRAW + Small Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRS1JN, "CRAW + Small1 Normal Jpeg"));
-
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRLJ, "CRAW + Large Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRM1J, "CRAW + Middle1 Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRM2J, "CRAW + Middle2 Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_CRSJ, "CRAW + Small Jpeg"));
-
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LJF, "Large Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_LJN, "Large Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MJF, "Middle Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_MJN, "Middle Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SJF, "Small Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_SJN, "Small Normal Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_S1JF, "Small1 Fine Jpeg"));
- m_imageQualityMap.insert(std::pair<EdsUInt32, const char *>(
- EdsImageQuality_S1JN, "Small1 Normal Jpeg"));
- m_imageQualityMap.insert(
- std::pair<EdsUInt32, const char *>(EdsImageQuality_S2JF, "Small2 Jpeg"));
- m_imageQualityMap.insert(
- std::pair<EdsUInt32, const char *>(EdsImageQuality_S3JF, "Small3 Jpeg"));
-
- m_imageQualityMap.insert(
- std::pair<EdsUInt32, const char *>(EdsImageQuality_LJ, "Large Jpeg"));
- m_imageQualityMap.insert(
- std::pair<EdsUInt32, const char *>(EdsImageQuality_M1J, "Middle1 Jpeg"));
- m_imageQualityMap.insert(
- std::pair<EdsUInt32, const char *>(EdsImageQuality_M2J, "Middle2 Jpeg"));
- m_imageQualityMap.insert(
- std::pair<EdsUInt32, const char *>(EdsImageQuality_SJ, "Small Jpeg"));
-}
-
-//-----------------------------------------------------------------
-
-void StopMotion::buildPictureStyleMap() {
- m_pictureStyleMap.insert(std::pair<EdsUInt32, const char *>(
- kEdsPictureStyle_Standard, "Standard"));
- m_pictureStyleMap.insert(std::pair<EdsUInt32, const char *>(
- kEdsPictureStyle_Portrait, "Portrait"));
- m_pictureStyleMap.insert(std::pair<EdsUInt32, const char *>(
- kEdsPictureStyle_Landscape, "Landscape"));
- m_pictureStyleMap.insert(
- std::pair<EdsUInt32, const char *>(kEdsPictureStyle_Neutral, "Neutral"));
- m_pictureStyleMap.insert(std::pair<EdsUInt32, const char *>(
- kEdsPictureStyle_Faithful, "Faithful"));
- m_pictureStyleMap.insert(std::pair<EdsUInt32, const char *>(
- kEdsPictureStyle_Monochrome, "Monochrome"));
- m_pictureStyleMap.insert(
- std::pair<EdsUInt32, const char *>(kEdsPictureStyle_Auto, "Auto"));
- m_pictureStyleMap.insert(std::pair<EdsUInt32, const char *>(
- kEdsPictureStyle_FineDetail, "Fine Detail"));
- m_pictureStyleMap.insert(
- std::pair<EdsUInt32, const char *>(kEdsPictureStyle_User1, "User 1"));
- m_pictureStyleMap.insert(
- std::pair<EdsUInt32, const char *>(kEdsPictureStyle_User2, "User 2"));
- m_pictureStyleMap.insert(
- std::pair<EdsUInt32, const char *>(kEdsPictureStyle_User3, "User 3"));
- m_pictureStyleMap.insert(
- std::pair<EdsUInt32, const char *>(kEdsPictureStyle_PC1, "Computer 1"));
- m_pictureStyleMap.insert(
- std::pair<EdsUInt32, const char *>(kEdsPictureStyle_PC2, "Computer 2"));
- m_pictureStyleMap.insert(
- std::pair<EdsUInt32, const char *>(kEdsPictureStyle_PC3, "Computer 3"));
-}
-
-//-----------------------------------------------------------------
-std::string StopMotion::getTEnvCameraName() { return StopMotionCameraName; }
-//-----------------------------------------------------------------
-void StopMotion::setTEnvCameraName(std::string name) {
- StopMotionCameraName = name;
-}
-//-----------------------------------------------------------------
-std::string StopMotion::getTEnvCameraResolution() {
- return StopMotionCameraResolution;
-}
-//-----------------------------------------------------------------
-void StopMotion::setTEnvCameraResolution(std::string resolution) {
- StopMotionCameraResolution = resolution;
-}
+void StopMotion::setTEnvCameraResolution(std::string resolution) {
+ StopMotionCameraResolution = resolution;
+}
//=============================================================================
@@ -3963,17 +2891,6 @@ public:
//=============================================================================
-class StopMotionToggleZoomCommand : public MenuItemHandler {
-public:
- StopMotionToggleZoomCommand() : MenuItemHandler(MI_StopMotionToggleZoom) {}
- void execute() {
- StopMotion *sm = StopMotion::instance();
- sm->zoomLiveView();
- }
-} StopMotionToggleZoomCommand;
-
-//=============================================================================
-
class StopMotionLowerSubsamplingCommand : public MenuItemHandler {
public:
StopMotionLowerSubsamplingCommand()
@@ -4008,4 +2925,80 @@ public:
StopMotion *sm = StopMotion::instance();
sm->jumpToCameraFrame();
}
-} StopMotionJumpToCameraCommand;
\ No newline at end of file
+} StopMotionJumpToCameraCommand;
+
+//=============================================================================
+
+class StopMotionExportImageSequence : public MenuItemHandler {
+public:
+ StopMotionExportImageSequence()
+ : MenuItemHandler(MI_StopMotionExportImageSequence) {}
+ void execute() {
+ StopMotion *sm = StopMotion::instance();
+ sm->exportImageSequence();
+ }
+} StopMotionExportImageSequence;
+
+//=============================================================================
+
+class StopMotionRemoveFrame : public MenuItemHandler {
+public:
+ StopMotionRemoveFrame() : MenuItemHandler(MI_StopMotionRemoveFrame) {}
+ void execute() {
+ StopMotion *sm = StopMotion::instance();
+ sm->removeStopMotionFrame();
+ }
+} StopMotionRemoveFrame;
+
+//=============================================================================
+
+class StopMotionNextFrame : public MenuItemHandler {
+public:
+ StopMotionNextFrame() : MenuItemHandler(MI_StopMotionNextFrame) {}
+ void execute() {
+ StopMotion *sm = StopMotion::instance();
+ int index = TApp::instance()->getCurrentFrame()->getFrameIndex();
+ int maxInXSheet =
+ TApp::instance()->getCurrentXsheet()->getXsheet()->getFrameCount();
+ int max = std::max(maxInXSheet, sm->getXSheetFrameNumber() - 1);
+ if (index < max) {
+ TApp::instance()->getCurrentFrame()->setFrame(index + 1);
+ }
+ }
+} StopMotionNextFrame;
+
+//=============================================================================
+
+class StopMotionToggleUseLiveViewImagesCommand : public MenuItemHandler {
+public:
+ StopMotionToggleUseLiveViewImagesCommand()
+ : MenuItemHandler(MI_StopMotionToggleUseLiveViewImages) {}
+ void execute() {
+ StopMotion *sm = StopMotion::instance();
+ sm->toggleAlwaysUseLiveViewImages();
+ }
+} StopMotionToggleUseLiveViewImagesCommand;
+
+#ifdef WITH_CANON
+//=============================================================================
+
+class StopMotionPickFocusCheck : public MenuItemHandler {
+public:
+ StopMotionPickFocusCheck() : MenuItemHandler(MI_StopMotionPickFocusCheck) {}
+ void execute() {
+ StopMotion *sm = StopMotion::instance();
+ sm->m_canon->toggleZoomPicking();
+ }
+} StopMotionPickFocusCheck;
+
+//=============================================================================
+
+class StopMotionToggleZoomCommand : public MenuItemHandler {
+public:
+ StopMotionToggleZoomCommand() : MenuItemHandler(MI_StopMotionToggleZoom) {}
+ void execute() {
+ StopMotion *sm = StopMotion::instance();
+ sm->m_canon->zoomLiveView();
+ }
+} StopMotionToggleZoomCommand;
+#endif
\ No newline at end of file
diff --git a/toonz/sources/stopmotion/stopmotion.h b/toonz/sources/stopmotion/stopmotion.h
index 09f76fd36..3a5bd6716 100644
--- a/toonz/sources/stopmotion/stopmotion.h
+++ b/toonz/sources/stopmotion/stopmotion.h
@@ -3,58 +3,38 @@
#ifndef STOPMOTION_H
#define STOPMOTION_H
-#ifdef WITH_STOPMOTION
+#ifdef WITH_CANON
// Canon Includes
#include "EDSDK.h"
#include "EDSDKErrors.h"
#include "EDSDKTypes.h"
+#endif
+
+#if defined(x64)
#include "turbojpeg.h"
-#include "opencv2/opencv.hpp"
+#endif
// Toonz Includes
#include "traster.h"
#include "toonzqt/gutil.h"
#include "toonzqt/dvdialog.h"
+#include "webcam.h"
+#include "jpgconverter.h"
+#include "canon.h"
+#include "stopmotionserial.h"
+#include "stopmotionlight.h"
+
+#include "toonz/txshsimplelevel.h"
+
#include <QObject>
+#include <QThread>
class QCamera;
class QCameraInfo;
-class QDialog;
class QTimer;
enum ASPECT_RATIO { FOUR_THREE = 0, THREE_TWO, SIXTEEN_NINE, OTHER_RATIO };
-#endif
-
-#include <QThread>
-//=============================================================================
-// JpgConverter
-//-----------------------------------------------------------------------------
-
-class JpgConverter : public QThread {
- Q_OBJECT
-#ifdef WITH_STOPMOTION
- EdsStreamRef m_stream;
- TRaster32P m_finalImage;
- bool m_scale = false;
- int m_scaleWidth = 0;
-
-public:
- JpgConverter();
- ~JpgConverter();
- void setStream(EdsStreamRef stream);
- void setScale(bool scale) { m_scale = scale; }
- void setScaleWidth(bool scaleWidth) { m_scaleWidth = scaleWidth; }
- TRaster32P getImage() { return m_finalImage; }
- void convertFromJpg();
-
-protected:
- void run() override;
-
-#endif
-signals:
- void imageReady(bool);
-};
class StopMotion : public QObject { // Singleton
Q_OBJECT
@@ -64,65 +44,31 @@ public:
static StopMotion _instance;
return &_instance;
};
-#ifdef WITH_STOPMOTION
private:
StopMotion();
~StopMotion();
- int m_opacity = 255.0;
- int m_xSheetFrameNumber = 1;
+ // file stuff
int m_frameNumber = 1;
- int m_subsampling = 1;
+ int m_xSheetFrameNumber = 1;
QString m_levelName = "";
QString m_fileType = "jpg";
QString m_filePath = "+extras";
QString m_frameInfoText = "";
QString m_infoColorName = "";
QString m_frameInfoToolTip = "";
+
+ // options
+ int m_opacity = 255.0;
+ int m_subsampling = 1;
QSize m_allowedCameraSize;
- QStringList m_isoOptions, m_shutterSpeedOptions, m_apertureOptions,
- m_exposureOptions, m_whiteBalanceOptions, m_colorTempOptions,
- m_imageQualityOptions, m_pictureStyleOptions;
- std::map<EdsUInt32, std::string> m_avMap, m_tvMap, m_isoMap, m_modeMap,
- m_exposureMap, m_whiteBalanceMap, m_imageQualityMap, m_pictureStyleMap;
- QDialog *m_fullScreen1, *m_fullScreen2, *m_fullScreen3;
- int m_screenCount;
- bool m_useMjpg = true;
bool m_useNumpadShortcuts = false;
bool m_numpadForStyleSwitching = true;
bool m_turnOnRewind = false;
- QTimer* m_reviewTimer;
std::map<std::string, QAction*> m_oldActionMap;
-
- // Webcam Properties
- QList<QCameraInfo> m_webcams;
- QCamera* m_webcam;
- cv::VideoCapture m_cvWebcam;
-
- static EdsError EDSCALLBACK handleObjectEvent(EdsObjectEvent event,
- EdsBaseRef object,
- EdsVoid* context);
-
- static EdsError EDSCALLBACK handlePropertyEvent(EdsPropertyEvent event,
- EdsPropertyID property,
- EdsUInt32 param,
- EdsVoid* context);
-
- static EdsError EDSCALLBACK handleStateEvent(EdsStateEvent event,
- EdsUInt32 parameter,
- EdsVoid* context);
- static EdsError EDSCALLBACK handleCameraAddedEvent(EdsVoid* context);
-
- void buildAvMap();
- void buildTvMap();
- void buildIsoMap();
- void buildModeMap();
- void buildExposureMap();
- void buildWhiteBalanceMap();
- void buildImageQualityMap();
- void buildPictureStyleMap();
+ std::map<int, TRaster32P> m_liveViewImageMap;
public:
enum LiveViewStatus {
@@ -132,71 +78,39 @@ public:
LiveViewPaused
};
- JpgConverter* m_converter;
- bool m_useScaledImages = true;
- bool m_usingWebcam = false;
- bool m_blackCapture = true;
- bool m_placeOnXSheet = true;
- int m_reviewTime = 2;
- int m_liveViewStatus = LiveViewClosed;
- bool m_hasLiveViewImage, m_hasLineUpImage, m_showLineUpImage;
- bool m_alwaysLiveView = false;
- bool m_active = false;
- bool m_userCalledPause = false;
- bool m_converterSucceeded = false;
+ Webcam* m_webcam;
+ Canon* m_canon;
+ StopMotionSerial* m_serial;
+ StopMotionLight* m_light;
+
+ bool m_usingWebcam = false;
+ bool m_placeOnXSheet = true;
+ bool m_alwaysLiveView = false;
+ bool m_userCalledPause = false;
+ bool m_drawBeneathLevels = true;
+ bool m_isTimeLapse = false;
+ int m_reviewTime = 2;
QString m_tempFile;
+ TXshSimpleLevel* m_sl;
+
+ // timers
QTimer* m_timer;
- QList<QSize> m_webcamResolutions;
-
- // Canon Public Properties
- EdsError m_error = EDS_ERR_OK;
- bool m_isSDKLoaded = false;
- EdsUInt32 m_count = 0;
- EdsCameraListRef m_cameraList = NULL;
- EdsCameraRef m_camera = NULL;
- bool m_sessionOpen = false;
- bool m_zooming = false;
- std::string m_cameraName;
+ int m_intervalTime = 10;
+ bool m_intervalStarted = false;
+ QTimer* m_reviewTimer;
+ QTimer *m_intervalTimer, *m_countdownTimer, *m_webcamOverlayTimer;
+
+ // live view and images
+ int m_liveViewStatus = LiveViewClosed;
+ bool m_hasLiveViewImage, m_hasLineUpImage, m_showLineUpImage;
+ bool m_alwaysUseLiveViewImages = false;
TRaster32P m_liveViewImage, m_newImage, m_lineUpImage;
TDimension m_liveViewImageDimensions = TDimension(0, 0);
TDimension m_fullImageDimensions = TDimension(0, 0);
- TDimension m_proxyImageDimensions = TDimension(0, 0);
- TPointD m_proxyDpi = TPointD(0.0, 0.0);
TPointD m_liveViewDpi = TPointD(0.0, 0.0);
TPointD m_fullImageDpi = TPointD(0.0, 0.0);
- TPoint m_liveViewZoomOffset = TPoint(0, 0);
- EdsUInt32 m_liveViewZoom = 1;
- bool m_pickLiveViewZoom = false;
- TPointD m_liveViewZoomPickPoint = TPointD(0.0, 0.0);
- TPoint m_zoomRect = TPoint(0, 0);
- TPoint m_calculatedZoomPoint = TPoint(0, 0);
- TPoint m_finalZoomPoint = TPoint(0, 0);
-
- // Webcam Public Properties
- QString m_webcamDeviceName;
- QString m_webcamDescription;
- int m_webcamIndex = -1;
- bool m_useDirectShow = true;
- int m_webcamWidth = 0;
- int m_webcamHeight = 0;
- void setOpacity(int opacity);
- int getOpacity() { return m_opacity; }
- void setUseScaledImages(bool on);
- bool getUseScaledImages() { return m_useScaledImages; }
- void setAlwaysLiveView(bool on);
- bool getAlwaysLiveView() { return m_alwaysLiveView; }
- void setBlackCapture(bool on);
- bool getBlackCapture() { return m_blackCapture; }
- void setPlaceOnXSheet(bool on);
- bool getPlaceOnXSheet() { return m_placeOnXSheet; }
- void setUseMjpg(bool on);
- bool getUseMjpg() { return m_useMjpg; }
- void setUseNumpadShortcuts(bool on);
- bool getUseNumpadShortcuts() { return m_useNumpadShortcuts; }
- void toggleNumpadShortcuts(bool on);
- void setReviewTime(int time);
- int getReviewTime() { return m_reviewTime; }
+ // files and frames
void setXSheetFrameNumber(int frameNumber);
int getXSheetFrameNumber() { return m_xSheetFrameNumber; }
void setFrameNumber(int frameNumber);
@@ -214,167 +128,122 @@ public:
void lastFrame();
void nextName();
void previousName();
-
+ void refreshFrameInfo();
QString getFrameInfoText() { return m_frameInfoText; }
QString getInfoColorName() { return m_infoColorName; }
QString getFrameInfoToolTip() { return m_frameInfoToolTip; }
- bool toggleLiveView();
- void pauseLiveView();
- void getSubsampling();
- void setSubsampling();
- int getSubsamplingValue() { return m_subsampling; }
- void setSubsamplingValue(int subsampling);
- void captureImage();
- void postImportProcess();
- void refreshFrameInfo();
- void refreshCameraList();
- void changeCameras(int index);
- void raiseOpacity();
- void lowerOpacity();
- void jumpToCameraFrame();
+ // cameras
+ void setWebcamResolution(QString resolution);
std::string getTEnvCameraName();
void setTEnvCameraName(std::string name);
std::string getTEnvCameraResolution();
void setTEnvCameraResolution(std::string resolution);
+ void disconnectAllCameras();
+ void changeCameras(int index);
+ void refreshCameraList();
+
+ // commands
+ void jumpToCameraFrame();
+ void removeStopMotionFrame();
- void saveJpg(TRaster32P, TFilePath path);
- bool loadJpg(TFilePath path, TRaster32P& image);
+ // live view and images
+ bool toggleLiveView();
+ void pauseLiveView();
bool loadLineUpImage();
+ bool loadLiveViewImage(int row, TRaster32P& image);
+ void setLiveViewImage();
+ void captureImage();
+ void captureWebcamImage();
+ void captureDslrImage();
+ void postImportProcess();
+ void toggleAlwaysUseLiveViewImages();
+ bool buildLiveViewMap(TXshSimpleLevel* sl);
+
+ // time lapse
+ void toggleInterval(bool on);
+ void startInterval();
+ void stopInterval();
+ void setIntervalAmount(int value);
+ void restartInterval();
+
+ // options
+ void raiseOpacity();
+ void lowerOpacity();
+ void setOpacity(int opacity);
+ int getOpacity() { return m_opacity; }
+ void setAlwaysLiveView(bool on);
+ bool getAlwaysLiveView() { return m_alwaysLiveView; }
+ void setPlaceOnXSheet(bool on);
+ bool getPlaceOnXSheet() { return m_placeOnXSheet; }
+ void setUseNumpadShortcuts(bool on);
+ bool getUseNumpadShortcuts() { return m_useNumpadShortcuts; }
+ void toggleNumpadShortcuts(bool on);
+ void toggleNumpadForFocusCheck(bool on);
+ void setDrawBeneathLevels(bool on);
+ void setReviewTime(int time);
+ int getReviewTime() { return m_reviewTime; }
+ void getSubsampling();
+ void setSubsampling();
+ int getSubsamplingValue() { return m_subsampling; }
+ void setSubsamplingValue(int subsampling);
+
+ // saving and loading
+ void saveXmlFile();
+ bool loadXmlFile();
+ bool exportImageSequence();
- // Webcam Commands
- QList<QCameraInfo> getWebcams();
- QCamera* getWebcam() { return m_webcam; }
- void setWebcam(QCamera* camera);
- bool initWebcam(int index = 0);
- void releaseWebcam();
- void setWebcamResolution(QString resolution);
- void getWebcamImage();
- bool translateIndex(int index);
- bool getUseDirectShow() { return m_useDirectShow; }
- void setUseDirectShow(int state);
- QList<QSize> getWebcamResolutions() { return m_webcamResolutions; }
- // void changeResolutions(int index);
-
- // Canon Commands
- EdsError initializeCanonSDK();
- void closeCanonSDK();
- EdsCameraListRef getCameraList();
- EdsError releaseCameraList();
- int getCameraCount();
- EdsError getCamera(int index);
- EdsError releaseCamera();
- void cameraAdded();
- EdsError openCameraSession();
- EdsError closeCameraSession();
- std::string getCameraName();
- EdsError downloadImage(EdsBaseRef object);
- EdsError takePicture();
- EdsError startLiveView();
- EdsError endLiveView();
- EdsError downloadEVFData();
- QStringList getIsoOptions() { return m_isoOptions; }
- QStringList getShutterSpeedOptions() { return m_shutterSpeedOptions; }
- QStringList getApertureOptions() { return m_apertureOptions; }
- QStringList getExposureOptions() { return m_exposureOptions; }
- QStringList getWhiteBalanceOptions() { return m_whiteBalanceOptions; }
- QStringList getColorTemperatureOptions() { return m_colorTempOptions; }
- QStringList getImageQualityOptions() { return m_imageQualityOptions; }
- QStringList getPictureStyleOptions() { return m_pictureStyleOptions; }
- EdsError getAvailableShutterSpeeds();
- EdsError getAvailableIso();
- EdsError getAvailableApertures();
- EdsError getAvailableExposureCompensations();
- EdsError getAvailableWhiteBalances();
- EdsError getAvailableImageQualities();
- EdsError getAvailablePictureStyles();
- void buildColorTemperatures();
- QString getCurrentShutterSpeed();
- QString getCurrentIso();
- QString getCurrentAperture();
- QString getCurrentExposureCompensation();
- QString getCurrentWhiteBalance();
- QString getCurrentColorTemperature();
- QString getCurrentImageQuality();
- QString getCurrentPictureStyle();
- EdsError setShutterSpeed(QString shutterSpeed);
- EdsError setIso(QString iso);
- EdsError setAperture(QString aperture);
- EdsError setExposureCompensation(QString exposure);
- EdsError setWhiteBalance(QString whiteBalance);
- EdsError setColorTemperature(QString temp);
- EdsError setImageQuality(QString quality);
- EdsError setPictureStyle(QString style);
- QString getMode();
- void refreshOptions();
- EdsError zoomLiveView();
- EdsError setZoomPoint();
- void makeZoomPoint(TPointD pos);
- EdsError focusNear();
- EdsError focusFar();
- EdsError focusNear2();
- EdsError focusFar2();
- EdsError focusNear3();
- EdsError focusFar3();
-
-#endif // WITH_STOPMOTION
public slots:
- void onImageReady(const bool&);
- void onFinished();
+ // timers
void onTimeout();
void onReviewTimeout();
+ void onIntervalCaptureTimerTimeout();
+ void captureWebcamOnTimeout();
void update();
bool importImage();
void onSceneSwitched();
void onPlaybackChanged();
+ void onCanonCameraChanged(QString);
signals:
- void newLiveViewImageReady();
- void liveViewStopped();
- void newImageReady();
- void cameraChanged();
- void optionsChanged();
- void liveViewChanged(bool);
+ // camera stuff
+ void cameraChanged(QString);
void newCameraSelected(int, bool);
void webcamResolutionsChanged();
void newWebcamResolutionSelected(int);
+ void updateCameraList(QString);
- void apertureOptionsChanged();
- void isoOptionsChanged();
- void shutterSpeedOptionsChanged();
- void exposureOptionsChanged();
- void whiteBalanceOptionsChanged();
- void colorTemperatureChanged();
- void imageQualityOptionsChanged();
- void pictureStyleOptionsChanged();
- void apertureChangedSignal(QString);
- void isoChangedSignal(QString);
- void shutterSpeedChangedSignal(QString);
- void exposureChangedSignal(QString);
- void whiteBalanceChangedSignal(QString);
- void colorTemperatureChangedSignal(QString);
- void imageQualityChangedSignal(QString);
- void pictureStyleChangedSignal(QString);
- void modeChanged();
-
+ // live view and images
+ void newLiveViewImageReady();
+ void liveViewStopped();
+ void newImageReady();
+ void liveViewChanged(bool);
+ void liveViewOnAllFramesSignal(bool);
void newDimensions();
- void subsamplingChanged(int);
+ void alwaysUseLiveViewImagesToggled(bool);
+
+ // file stuff
void filePathChanged(QString);
void levelNameChanged(QString);
void fileTypeChanged(QString);
- void xSheetFrameNumberChanged(int);
void frameNumberChanged(int);
void frameInfoTextChanged(QString);
+ void xSheetFrameNumberChanged(int);
+
+ // options
+ void optionsChanged();
+ void subsamplingChanged(int);
void opacityChanged(int);
- void scaleFullSizeImagesSignal(bool);
- void blackCaptureSignal(bool);
- void liveViewOnAllFramesSignal(bool);
void placeOnXSheetSignal(bool);
- void useMjpgSignal(bool);
void useNumpadSignal(bool);
- void useDirectShowSignal(bool);
+ void drawBeneathLevelsSignal(bool);
void reviewTimeChangedSignal(int);
- void updateCameraList();
+
+ // time lapse
+ void intervalToggled(bool);
+ void intervalStarted();
+ void intervalStopped();
+ void intervalAmountChanged(int);
};
#endif // STOPMOTION_H
\ No newline at end of file
diff --git a/toonz/sources/stopmotion/stopmotioncontroller.cpp b/toonz/sources/stopmotion/stopmotioncontroller.cpp
index 69832c010..8347e453a 100644
--- a/toonz/sources/stopmotion/stopmotioncontroller.cpp
+++ b/toonz/sources/stopmotion/stopmotioncontroller.cpp
@@ -1,4 +1,5 @@
#include "stopmotioncontroller.h"
+#include "webcam.h"
// TnzLib includes
#include "toonz/levelset.h"
@@ -52,6 +53,7 @@
#include <QTimer>
#include <QToolButton>
#include <QToolTip>
+#include <QSerialPort>
#ifdef _WIN32
#include <dshow.h>
@@ -181,10 +183,14 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
m_tabBar->addSimpleTab(tr("Controls"));
m_tabBar->addSimpleTab(tr("Settings"));
m_tabBar->addSimpleTab(tr("Options"));
+ m_tabBar->addSimpleTab(tr("Light"));
+ m_tabBar->addSimpleTab(tr("Motion"));
m_tabBarContainer = new TabBarContainter(this);
- m_mainControlsPage = new QFrame();
- m_cameraSettingsPage = new QFrame();
- m_optionsPage = new QFrame();
+ m_mainControlsPage = new QFrame(this);
+ m_cameraSettingsPage = new QFrame(this);
+ m_optionsPage = new QFrame(this);
+ m_motionPage = new QFrame(this);
+ m_lightPage = new QFrame(this);
// **********************
// Make Control Page
@@ -195,35 +201,21 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
m_resolutionCombo = new QComboBox(this);
m_resolutionCombo->setFixedWidth(fontMetrics().width("0000 x 0000") + 25);
m_resolutionLabel = new QLabel(tr("Resolution: "), this);
+ m_cameraStatusLabel = new QLabel(tr("Camera Status"), this);
QPushButton *refreshCamListButton = new QPushButton(tr("Refresh"), this);
refreshCamListButton->setFixedHeight(28);
refreshCamListButton->setStyleSheet("padding: 0 2;");
QGroupBox *fileFrame = new QGroupBox(tr("File"), this);
m_levelNameEdit = new LevelNameLineEdit(this);
-#ifdef _WIN32
- m_captureFilterSettingsBtn = new QPushButton(this);
-#else
- m_captureFilterSettingsBtn = 0;
-#endif
- if (m_captureFilterSettingsBtn) {
- m_captureFilterSettingsBtn->setObjectName("GearButton");
- m_captureFilterSettingsBtn->setFixedSize(28, 28);
- m_captureFilterSettingsBtn->setIconSize(QSize(18, 18));
- m_captureFilterSettingsBtn->setToolTip(tr("Webcam Settings..."));
- }
-
// set the start frame 10 if the option in preferences
// "Show ABC Appendix to the Frame Number in Xsheet Cell" is active.
// (frame 10 is displayed as "1" with this option)
int startFrame =
Preferences::instance()->isShowFrameNumberWithLettersEnabled() ? 10 : 1;
- m_frameNumberEdit = new FrameNumberLineEdit(this, startFrame);
- m_frameInfoLabel = new QLabel("", this);
- m_fileTypeCombo = new QComboBox(this);
- m_fileFormatOptionButton = new QPushButton(tr("Options"), this);
- m_fileFormatOptionButton->setFixedHeight(28);
- m_fileFormatOptionButton->setStyleSheet("padding: 0 2;");
+ m_frameNumberEdit = new FrameNumberLineEdit(this, startFrame);
+ m_frameInfoLabel = new QLabel("", this);
+
m_xSheetFrameNumberEdit = new DVGui::IntLineEdit(this, 1, 1);
m_saveInFileFld =
new DVGui::FileField(this, m_saveInFolderPopup->getParentPath());
@@ -236,7 +228,13 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
QToolButton *nextXSheetFrameButton = new QToolButton(this);
m_previousXSheetFrameButton = new QToolButton(this);
m_onionOpacityFld = new DVGui::IntField(this);
- m_captureButton = new QPushButton(tr("Capture"), this);
+
+ // should choosing the file type is disabled for simplicty
+ // too many options can be a bad thing
+ m_fileTypeCombo = new QComboBox(this);
+ m_fileFormatOptionButton = new QPushButton(tr("Options"), this);
+ m_fileFormatOptionButton->setFixedHeight(28);
+ m_fileFormatOptionButton->setStyleSheet("padding: 0 2;");
// QPushButton *subfolderButton = new QPushButton(tr("Subfolder"), this);
m_fileTypeCombo->addItems({"jpg", "png", "tga", "tif"});
m_fileTypeCombo->setCurrentIndex(0);
@@ -289,11 +287,21 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
m_toggleLiveViewButton = new QPushButton(tr("Start Live View"));
m_toggleLiveViewButton->setObjectName("LargeSizedText");
m_toggleLiveViewButton->setFixedHeight(35);
+ m_captureButton = new QPushButton(tr("Capture"), this);
m_captureButton->setObjectName("LargeSizedText");
m_captureButton->setFixedHeight(35);
QCommonStyle style;
m_captureButton->setIcon(style.standardIcon(QStyle::SP_DialogOkButton));
m_captureButton->setIconSize(QSize(20, 20));
+ m_alwaysUseLiveViewImagesButton = new QPushButton();
+ // m_alwaysUseLiveViewImagesButton->setObjectName("LargeSizedText");
+ m_alwaysUseLiveViewImagesButton->setObjectName("LiveViewButton");
+ m_alwaysUseLiveViewImagesButton->setFixedHeight(35);
+ m_alwaysUseLiveViewImagesButton->setFixedWidth(35);
+ m_alwaysUseLiveViewImagesButton->setCheckable(true);
+ m_alwaysUseLiveViewImagesButton->setIconSize(QSize(25, 25));
+ m_alwaysUseLiveViewImagesButton->setToolTip(
+ tr("Show original live view images in timeline"));
// subfolderButton->setObjectName("SubfolderButton");
// subfolderButton->setIconSize(QSize(15, 15));
@@ -301,14 +309,18 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
m_levelNameEdit->setMaximumWidth(380);
m_saveInFolderPopup->hide();
- m_zoomButton = new QPushButton(tr("Zoom"), this);
+ m_zoomButton = new QPushButton(tr("Check"), this);
m_zoomButton->setFixedHeight(28);
- m_zoomButton->setStyleSheet("padding: 0 2;");
- m_zoomButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
- m_pickZoomButton = new QPushButton(tr("Pick Zoom"), this);
- m_pickZoomButton->setStyleSheet("padding: 0 2;");
- m_pickZoomButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+ m_zoomButton->setStyleSheet("padding: 5 2;");
+ m_zoomButton->setMaximumWidth(100);
+ m_zoomButton->setToolTip(tr("Zoom in to check focus"));
+ m_zoomButton->setCheckable(true);
+ m_pickZoomButton = new QPushButton(tr("Pick"), this);
+ m_pickZoomButton->setStyleSheet("padding: 5 2;");
+ m_pickZoomButton->setMaximumWidth(100);
m_pickZoomButton->setFixedHeight(28);
+ m_pickZoomButton->setToolTip(tr("Set focus check location"));
+ m_pickZoomButton->setCheckable(true);
m_focusNearButton = new QPushButton(tr("<"), this);
m_focusNearButton->setFixedSize(32, 28);
m_focusFarButton = new QPushButton(tr(">"), this);
@@ -337,16 +349,17 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
Qt::AlignRight);
camLay->addWidget(m_cameraListCombo, 0, 1, Qt::AlignLeft);
camLay->addWidget(refreshCamListButton, 0, 2, Qt::AlignLeft);
- if (m_captureFilterSettingsBtn) {
- camLay->addWidget(m_captureFilterSettingsBtn, 0, 3, Qt::AlignLeft);
- camLay->addWidget(m_resolutionLabel, 1, 0, Qt::AlignRight);
- camLay->addWidget(m_resolutionCombo, 1, 1, 1, 3, Qt::AlignLeft);
- camLay->setColumnStretch(3, 30);
- } else {
- camLay->addWidget(m_resolutionLabel, 1, 0, Qt::AlignRight);
- camLay->addWidget(m_resolutionCombo, 1, 1, 1, 2, Qt::AlignLeft);
- camLay->setColumnStretch(2, 30);
- }
+ // if (m_captureFilterSettingsBtn) {
+ // camLay->addWidget(m_captureFilterSettingsBtn, 0, 3, Qt::AlignLeft);
+ // camLay->addWidget(m_resolutionLabel, 1, 0, Qt::AlignRight);
+ // camLay->addWidget(m_resolutionCombo, 1, 1, 1, 3, Qt::AlignLeft);
+ // camLay->setColumnStretch(3, 30);
+ //} else {
+ //}
+ camLay->addWidget(m_resolutionLabel, 1, 0, Qt::AlignRight);
+ camLay->addWidget(m_resolutionCombo, 1, 1, 1, 2, Qt::AlignLeft);
+ camLay->setColumnStretch(2, 30);
+ camLay->addWidget(m_cameraStatusLabel, 2, 1, 1, 2, Qt::AlignLeft);
}
controlLayout->addLayout(camLay, 0);
@@ -446,21 +459,42 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
m_mainControlsPage->setLayout(controlLayout);
// Make Settings Page
-
- m_isoCombo = new QComboBox(this);
- m_shutterSpeedCombo = new QComboBox(this);
+ QVBoxLayout *innerSettingsLayout = new QVBoxLayout;
+ m_noCameraFrame = new QFrame();
+ QHBoxLayout *noCameraLayout = new QHBoxLayout();
+ noCameraLayout->addStretch();
+ noCameraLayout->addWidget(
+ new QLabel(tr("Select a camera to change settings.")));
+ noCameraLayout->addStretch();
+ m_noCameraFrame->setLayout(noCameraLayout);
+ innerSettingsLayout->addWidget(m_noCameraFrame);
+
+ m_apertureLabel = new QLabel(tr(""), this);
+ m_apertureSlider = new QSlider(Qt::Horizontal, this);
+ m_apertureSlider->setRange(0, 10);
+ m_apertureSlider->setTickInterval(1);
+ m_apertureSlider->setFixedWidth(260);
+ m_isoLabel = new QLabel(tr(""), this);
+ m_isoSlider = new QSlider(Qt::Horizontal, this);
+ m_isoSlider->setRange(0, 10);
+ m_isoSlider->setTickInterval(1);
+ m_isoSlider->setFixedWidth(260);
+ m_shutterSpeedLabel = new QLabel(tr(""), this);
+ m_shutterSpeedSlider = new QSlider(Qt::Horizontal, this);
+ m_shutterSpeedSlider->setRange(0, 10);
+ m_shutterSpeedSlider->setTickInterval(1);
+ m_shutterSpeedSlider->setFixedWidth(260);
+ m_kelvinValueLabel = new QLabel(tr("Temperature: "), this);
+ m_kelvinSlider = new QSlider(Qt::Horizontal, this);
+ m_kelvinSlider->setRange(0, 10);
+ m_kelvinSlider->setTickInterval(1);
+ m_kelvinSlider->setFixedWidth(260);
m_exposureCombo = new QComboBox(this);
- m_apertureCombo = new QComboBox(this);
m_whiteBalanceCombo = new QComboBox(this);
- m_kelvinCombo = new QComboBox(this);
m_imageQualityCombo = new QComboBox(this);
m_pictureStyleCombo = new QComboBox(this);
m_cameraSettingsLabel = new QLabel(tr("Camera Model"), this);
m_cameraModeLabel = new QLabel(tr("Camera Mode"), this);
- m_kelvinLabel = new QLabel(tr("Temperature: "), this);
- m_isoCombo->setFixedWidth(fontMetrics().width("000000") + 25);
- m_shutterSpeedCombo->setFixedWidth(fontMetrics().width("000000") + 25);
- m_apertureCombo->setFixedWidth(fontMetrics().width("000000") + 25);
m_exposureCombo->setFixedWidth(fontMetrics().width("000000") + 25);
QVBoxLayout *settingsLayout = new QVBoxLayout;
settingsLayout->setSpacing(0);
@@ -474,29 +508,44 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
Qt::AlignCenter);
settingsGridLayout->addWidget(m_cameraModeLabel, 1, 0, 1, 2,
Qt::AlignCenter);
- settingsGridLayout->addWidget(new QLabel(tr("Shutter Speed: ")), 2, 0,
- Qt::AlignRight);
- settingsGridLayout->addWidget(m_shutterSpeedCombo, 2, 1, Qt::AlignLeft);
- settingsGridLayout->addWidget(new QLabel(tr("Iso: ")), 3, 0,
- Qt::AlignRight);
- settingsGridLayout->addWidget(m_isoCombo, 3, 1, Qt::AlignLeft);
- settingsGridLayout->addWidget(new QLabel(tr("Aperture: ")), 4, 0,
- Qt::AlignRight);
- settingsGridLayout->addWidget(m_apertureCombo, 4, 1, Qt::AlignLeft);
- settingsGridLayout->addWidget(new QLabel(tr("Exposure: ")), 5, 0,
+ settingsGridLayout->addWidget(new QLabel(" ", this), 2, 0, 1, 2,
+ Qt::AlignCenter);
+ settingsGridLayout->addWidget(m_shutterSpeedLabel, 3, 0, 1, 2,
+ Qt::AlignCenter);
+ settingsGridLayout->addWidget(m_shutterSpeedSlider, 4, 0, 1, 2,
+ Qt::AlignCenter);
+
+ settingsGridLayout->addWidget(m_apertureLabel, 5, 0, 1, 2,
+ Qt::AlignCenter);
+ settingsGridLayout->addWidget(m_apertureSlider, 6, 0, 1, 2,
+ Qt::AlignCenter);
+
+ settingsGridLayout->addWidget(m_isoLabel, 7, 0, 1, 2, Qt::AlignCenter);
+ settingsGridLayout->addWidget(m_isoSlider, 8, 0, 1, 2, Qt::AlignCenter);
+ settingsGridLayout->addWidget(new QLabel(" ", this), 9, 0, 1, 2,
+ Qt::AlignCenter);
+ settingsGridLayout->addWidget(new QLabel(tr("White Balance: ")), 10, 0,
Qt::AlignRight);
- settingsGridLayout->addWidget(m_exposureCombo, 5, 1, Qt::AlignLeft);
- settingsGridLayout->addWidget(new QLabel(tr("Image Quality: ")), 6, 0,
+ settingsGridLayout->addWidget(m_whiteBalanceCombo, 10, 1, Qt::AlignLeft);
+ settingsGridLayout->addWidget(m_kelvinValueLabel, 11, 0, 1, 2,
+ Qt::AlignCenter);
+ settingsGridLayout->addWidget(m_kelvinSlider, 12, 0, 1, 2,
+ Qt::AlignCenter);
+ settingsGridLayout->addWidget(new QLabel(" ", this), 13, 0, 1, 2,
+ Qt::AlignCenter);
+ settingsGridLayout->addWidget(new QLabel(tr("Picture Style: ")), 14, 0,
Qt::AlignRight);
- settingsGridLayout->addWidget(m_imageQualityCombo, 6, 1, Qt::AlignLeft);
- settingsGridLayout->addWidget(new QLabel(tr("Picture Style: ")), 7, 0,
+ settingsGridLayout->addWidget(m_pictureStyleCombo, 14, 1, Qt::AlignLeft);
+ settingsGridLayout->addWidget(new QLabel(tr("Image Quality: ")), 15, 0,
Qt::AlignRight);
- settingsGridLayout->addWidget(m_pictureStyleCombo, 7, 1, Qt::AlignLeft);
- settingsGridLayout->addWidget(new QLabel(tr("White Balance: ")), 8, 0,
+ settingsGridLayout->addWidget(m_imageQualityCombo, 15, 1, Qt::AlignLeft);
+ settingsGridLayout->addWidget(new QLabel(tr("Exposure: ")), 16, 0,
Qt::AlignRight);
- settingsGridLayout->addWidget(m_whiteBalanceCombo, 8, 1, Qt::AlignLeft);
- settingsGridLayout->addWidget(m_kelvinLabel, 9, 0, Qt::AlignRight);
- settingsGridLayout->addWidget(m_kelvinCombo, 9, 1, Qt::AlignLeft);
+ settingsGridLayout->addWidget(m_exposureCombo, 16, 1, Qt::AlignLeft);
+ settingsGridLayout->addWidget(new QLabel(" ", this), 17, 0, 1, 2,
+ Qt::AlignCenter);
+ settingsGridLayout->addWidget(new QLabel(" ", this), 19, 0, 1, 2,
+ Qt::AlignCenter);
settingsGridLayout->setColumnStretch(1, 30);
}
@@ -515,18 +564,139 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
// settingsLayout->addStretch();
settingsLayout->addLayout(m_focusAndZoomLayout);
settingsLayout->addStretch();
- m_cameraSettingsPage->setLayout(settingsLayout);
+ m_dslrFrame = new QFrame();
+ m_dslrFrame->setLayout(settingsLayout);
+ innerSettingsLayout->addWidget(m_dslrFrame);
+ m_dslrFrame->hide();
+
+ QVBoxLayout *webcamSettingsLayout = new QVBoxLayout;
+ webcamSettingsLayout->setSpacing(0);
+ webcamSettingsLayout->setMargin(5);
+ QHBoxLayout *webcamLabelLayout = new QHBoxLayout();
+ m_webcamLabel = new QLabel("insert webcam name here", this);
+ webcamLabelLayout->addStretch();
+ webcamLabelLayout->addWidget(m_webcamLabel);
+ webcamLabelLayout->addStretch();
+ webcamSettingsLayout->addLayout(webcamLabelLayout);
+ webcamSettingsLayout->addSpacing(10);
+
+ // webcam focus
+ m_webcamAutoFocusGB = new QGroupBox(tr("Manual Focus"), this);
+ m_webcamAutoFocusGB->setCheckable(true);
+
+ m_webcamFocusSlider = new QSlider(Qt::Horizontal, this);
+ m_webcamFocusSlider->setRange(0, 255);
+ m_webcamFocusSlider->setTickInterval(5);
+
+ QHBoxLayout *webcamFocusLay = new QHBoxLayout();
+ webcamFocusLay->addWidget(new QLabel(tr("Focus: "), this), 0);
+ webcamFocusLay->addWidget(m_webcamFocusSlider, 1);
+ m_webcamAutoFocusGB->setLayout(webcamFocusLay);
+ webcamSettingsLayout->addWidget(m_webcamAutoFocusGB);
+ webcamSettingsLayout->addSpacing(5);
+
+ QGridLayout *webcamGridLay = new QGridLayout();
+ webcamGridLay->setMargin(0);
+ webcamGridLay->setSpacing(3);
+ webcamGridLay->setColumnStretch(0, 0);
+ webcamGridLay->setColumnStretch(1, 1);
+
+ // webcam exposure
+ m_webcamExposureSlider = new QSlider(Qt::Horizontal, this);
+ m_webcamExposureSlider->setRange(-13, -1);
+ m_webcamExposureSlider->setTickInterval(1);
+
+ QHBoxLayout *webcamExposureLay = new QHBoxLayout();
+ webcamExposureLay->addWidget(m_webcamExposureSlider, 1);
+ webcamGridLay->addWidget(new QLabel(tr("Exposure: "), this), 0, 0, 1, 1,
+ Qt::AlignRight);
+ webcamGridLay->addLayout(webcamExposureLay, 0, 1, 1, 1);
+
+ // webcam brightness
+ m_webcamBrightnessSlider = new QSlider(Qt::Horizontal, this);
+ m_webcamBrightnessSlider->setRange(0, 255);
+
+ QHBoxLayout *webcamBrightnessLay = new QHBoxLayout();
+ webcamBrightnessLay->addWidget(m_webcamBrightnessSlider, 1);
+ webcamGridLay->addWidget(new QLabel(tr("Brightness: "), this), 1, 0, 1, 1,
+ Qt::AlignRight);
+ webcamGridLay->addLayout(webcamBrightnessLay, 1, 1, 1, 1);
+
+ // webcam contrast
+ m_webcamContrastSlider = new QSlider(Qt::Horizontal, this);
+ m_webcamContrastSlider->setRange(0, 255);
+
+ QHBoxLayout *webcamContrastLay = new QHBoxLayout();
+ webcamContrastLay->addWidget(m_webcamContrastSlider, 1);
+ webcamGridLay->addWidget(new QLabel(tr("Contrast: "), this), 2, 0, 1, 1,
+ Qt::AlignRight);
+ webcamGridLay->addLayout(webcamContrastLay, 2, 1, 1, 1);
+
+ // webcam gain
+ m_webcamGainSlider = new QSlider(Qt::Horizontal, this);
+ m_webcamGainSlider->setRange(0, 255);
+
+ QHBoxLayout *webcamGainLay = new QHBoxLayout();
+ webcamGainLay->addWidget(m_webcamGainSlider, 1);
+ webcamGridLay->addWidget(new QLabel(tr("Gain: "), this), 3, 0, 1, 1,
+ Qt::AlignRight);
+ webcamGridLay->addLayout(webcamGainLay, 3, 1, 1, 1);
+
+ // webcam saturation
+ m_webcamSaturationSlider = new QSlider(Qt::Horizontal, this);
+ m_webcamSaturationSlider->setRange(0, 255);
+
+ QHBoxLayout *webcamSaturationLay = new QHBoxLayout();
+ webcamSaturationLay->addWidget(m_webcamSaturationSlider, 1);
+ webcamGridLay->addWidget(new QLabel(tr("Saturation: "), this), 4, 0, 1, 1,
+ Qt::AlignRight);
+ webcamGridLay->addLayout(webcamSaturationLay, 4, 1, 1, 1);
+
+#ifdef _WIN32
+ m_captureFilterSettingsBtn = new QPushButton(this);
+#else
+ m_captureFilterSettingsBtn = 0;
+#endif
+ if (m_captureFilterSettingsBtn) {
+ m_captureFilterSettingsBtn->setObjectName("GearButton");
+ m_captureFilterSettingsBtn->setFixedSize(128, 28);
+ m_captureFilterSettingsBtn->setText(tr("More"));
+ m_captureFilterSettingsBtn->setIconSize(QSize(15, 15));
+ m_captureFilterSettingsBtn->setToolTip(tr("Webcam Settings..."));
+ webcamGridLay->addWidget(m_captureFilterSettingsBtn, 5, 0, 1, 2,
+ Qt::AlignCenter);
+ }
+
+ webcamSettingsLayout->addLayout(webcamGridLay);
+
+ webcamSettingsLayout->addStretch();
+ m_webcamFrame = new QFrame();
+ m_webcamFrame->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Expanding);
+ m_webcamFrame->setLayout(webcamSettingsLayout);
+ innerSettingsLayout->addWidget(m_webcamFrame);
+ m_webcamFrame->hide();
+ innerSettingsLayout->addStretch();
+ m_cameraSettingsPage->setLayout(innerSettingsLayout);
// Make Options Page
- QGroupBox *webcamBox = new QGroupBox(tr("Webcam Options"), this);
- QGroupBox *dslrBox = new QGroupBox(tr("DSLR Options"), this);
+ QGroupBox *webcamBox = new QGroupBox(tr("Webcam Options"), this);
+ QGroupBox *dslrBox = new QGroupBox(tr("DSLR Options"), this);
+ QGroupBox *timerFrame = new QGroupBox(tr("Time Lapse"), this);
+ m_timerCB = new QCheckBox(tr("Use time lapse"), this);
+ m_timerIntervalFld = new DVGui::IntField(this);
+ timerFrame->setObjectName("CleanupSettingsFrame");
+ m_timerCB->setChecked(false);
+ m_timerIntervalFld->setRange(0, 60);
+ m_timerIntervalFld->setValue(10);
+ m_timerIntervalFld->setDisabled(true);
+
m_postCaptureReviewFld = new DVGui::IntField(this);
m_postCaptureReviewFld->setRange(0, 10);
m_subsamplingFld = new DVGui::IntField(this);
m_subsamplingFld->setRange(1, 30);
m_subsamplingFld->setDisabled(true);
- m_blackScreenForCapture = new QCheckBox(this);
m_placeOnXSheetCB = new QCheckBox(this);
m_placeOnXSheetCB->setToolTip(tr("Place the frame in the XSheet"));
@@ -536,6 +706,7 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
m_directShowCB = new QCheckBox(this);
m_useMjpgCB = new QCheckBox(this);
m_useNumpadCB = new QCheckBox(this);
+ m_drawBeneathCB = new QCheckBox(this);
m_liveViewOnAllFramesCB = new QCheckBox(this);
QVBoxLayout *optionsOutsideLayout = new QVBoxLayout;
@@ -546,9 +717,6 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
QGridLayout *dslrLayout = new QGridLayout;
QGridLayout *checkboxLayout = new QGridLayout;
- dslrLayout->addWidget(m_blackScreenForCapture, 0, 0, Qt::AlignRight);
- dslrLayout->addWidget(new QLabel(tr("Black Screen for Capture")), 0, 1,
- Qt::AlignLeft);
dslrLayout->addWidget(m_useScaledFullSizeImages, 1, 0, Qt::AlignRight);
dslrLayout->addWidget(new QLabel(tr("Use Reduced Resolution Images")), 1, 1,
Qt::AlignLeft);
@@ -556,6 +724,7 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
dslrBox->setLayout(dslrLayout);
dslrBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
optionsOutsideLayout->addWidget(dslrBox, Qt::AlignCenter);
+ dslrBox->hide();
webcamLayout->addWidget(m_directShowCB, 0, 0, Qt::AlignRight);
webcamLayout->addWidget(m_directShowLabel, 0, 1, Qt::AlignLeft);
@@ -566,17 +735,43 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
webcamBox->setLayout(webcamLayout);
webcamBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
optionsOutsideLayout->addWidget(webcamBox, Qt::AlignCenter);
+ webcamBox->hide();
+
+ QGridLayout *timerLay = new QGridLayout();
+ timerLay->setMargin(8);
+ timerLay->setHorizontalSpacing(3);
+ timerLay->setVerticalSpacing(5);
+ {
+ timerLay->addWidget(m_timerCB, 0, 0, 1, 2);
+
+ timerLay->addWidget(new QLabel(tr("Interval(sec):"), this), 1, 0,
+ Qt::AlignRight);
+ timerLay->addWidget(m_timerIntervalFld, 1, 1);
+ }
+ timerLay->setColumnStretch(0, 0);
+ timerLay->setColumnStretch(1, 1);
+ timerFrame->setLayout(timerLay);
+ optionsOutsideLayout->addWidget(timerFrame);
checkboxLayout->addWidget(m_placeOnXSheetCB, 0, 0, 1, 1, Qt::AlignRight);
- checkboxLayout->addWidget(new QLabel(tr("Place on XSheet")), 0, 1,
- Qt::AlignLeft);
- checkboxLayout->addWidget(m_useNumpadCB, 1, 0, Qt::AlignRight);
+ // checkboxLayout->addWidget(new QLabel(tr("Place on XSheet")), 0, 1,
+ // Qt::AlignLeft);
+ m_placeOnXSheetCB->hide();
+ checkboxLayout->addWidget(m_drawBeneathCB, 1, 0, Qt::AlignRight);
+ // checkboxLayout->addWidget(new QLabel(tr("Show Camera Below Other
+ // Levels")),
+ // 1, 1, Qt::AlignLeft);
+ m_drawBeneathCB->hide();
+
+ checkboxLayout->addWidget(m_useNumpadCB, 2, 0, Qt::AlignRight);
checkboxLayout->addWidget(
- new QLabel(tr("Use Numpad Shortcuts When Active")), 1, 1,
+ new QLabel(tr("Use Numpad Shortcuts When Active")), 2, 1,
Qt::AlignLeft);
- checkboxLayout->addWidget(m_liveViewOnAllFramesCB, 2, 0, Qt::AlignRight);
- checkboxLayout->addWidget(new QLabel(tr("Show Live View on All Frames")), 2,
- 1, Qt::AlignLeft);
+ checkboxLayout->addWidget(m_liveViewOnAllFramesCB, 3, 0, Qt::AlignRight);
+ m_liveViewOnAllFramesCB->hide();
+ // checkboxLayout->addWidget(new QLabel(tr("Show Live View on All Frames")),
+ // 3,
+ // 1, Qt::AlignLeft);
checkboxLayout->setColumnStretch(1, 30);
optionsOutsideLayout->addLayout(checkboxLayout, Qt::AlignLeft);
@@ -584,9 +779,10 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
optionsLayout->addWidget(new QLabel(tr("Capture Review Time: ")), 0, 0,
Qt::AlignRight);
optionsLayout->addWidget(m_postCaptureReviewFld, 0, 1);
- optionsLayout->addWidget(new QLabel(tr("Level Subsampling: ")), 1, 0,
- Qt::AlignRight);
+ // optionsLayout->addWidget(new QLabel(tr("Level Subsampling: ")), 1, 0,
+ // Qt::AlignRight);
optionsLayout->addWidget(m_subsamplingFld, 1, 1);
+ m_subsamplingFld->hide();
optionsLayout->setColumnStretch(1, 30);
optionsLayout->setRowStretch(2, 30);
optionsOutsideLayout->addLayout(optionsLayout, Qt::AlignLeft);
@@ -594,15 +790,107 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
m_optionsPage->setLayout(optionsOutsideLayout);
+ m_blackScreenForCapture = new QCheckBox(tr("Blackout all Screens"), this);
+ QVBoxLayout *lightOutsideLayout = new QVBoxLayout;
+ m_testLightsButton = new QPushButton(tr("Test"), this);
+ m_testLightsButton->setMaximumWidth(150);
+ m_testLightsButton->setFixedHeight(28);
+ m_testLightsButton->setSizePolicy(QSizePolicy::Maximum,
+ QSizePolicy::Maximum);
+ m_testLightsButton->setStyleSheet("padding: 2px;");
+ m_lightTestTimer = new QTimer(this);
+ m_lightTestTimer->setSingleShot(true);
+ m_screen1ColorFld = new DVGui::ColorField(
+ this, false, TPixel32(0, 0, 0, 255), 40, true, 60);
+
+ m_screen2ColorFld = new DVGui::ColorField(
+ this, false, TPixel32(0, 0, 0, 255), 40, true, 60);
+
+ m_screen3ColorFld = new DVGui::ColorField(
+ this, false, TPixel32(0, 0, 0, 255), 40, true, 60);
+
+ QGridLayout *lightTopLayout = new QGridLayout;
+ lightTopLayout->addWidget(m_blackScreenForCapture, 0, 0, Qt::AlignRight);
+ lightTopLayout->setColumnStretch(1, 30);
+ lightOutsideLayout->addLayout(lightTopLayout);
+
+ m_screen1Box = new QGroupBox(tr("Screen 1"), this);
+ m_screen1Box->setCheckable(true);
+ m_screen1Box->setChecked(false);
+ QGridLayout *screen1Layout = new QGridLayout;
+ screen1Layout->addWidget(m_screen1ColorFld, 0, 0, 1, 2, Qt::AlignLeft);
+ screen1Layout->setColumnStretch(1, 30);
+ m_screen1Box->setLayout(screen1Layout);
+ m_screen1Box->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
+ lightOutsideLayout->addWidget(m_screen1Box, Qt::AlignCenter);
+
+ m_screen2Box = new QGroupBox(tr("Screen 2"), this);
+ m_screen2Box->setCheckable(true);
+ m_screen2Box->setChecked(false);
+ QGridLayout *screen2Layout = new QGridLayout;
+ screen2Layout->addWidget(m_screen2ColorFld, 0, 0, 1, 2, Qt::AlignLeft);
+ screen2Layout->setColumnStretch(1, 30);
+ m_screen2Box->setLayout(screen2Layout);
+ m_screen2Box->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
+ lightOutsideLayout->addWidget(m_screen2Box, Qt::AlignCenter);
+
+ m_screen3Box = new QGroupBox(tr("Screen 3"), this);
+ m_screen3Box->setCheckable(true);
+ m_screen3Box->setChecked(false);
+ QGridLayout *screen3Layout = new QGridLayout;
+ screen3Layout->addWidget(m_screen3ColorFld, 0, 0, 1, 2, Qt::AlignLeft);
+ screen3Layout->setColumnStretch(1, 30);
+ m_screen3Box->setLayout(screen3Layout);
+ m_screen3Box->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
+ lightOutsideLayout->addWidget(m_screen3Box, Qt::AlignCenter);
+
+ QHBoxLayout *testLayout = new QHBoxLayout;
+ testLayout->addWidget(m_testLightsButton, Qt::AlignHCenter);
+ lightOutsideLayout->addLayout(testLayout);
+ lightOutsideLayout->addStretch();
+ m_lightPage->setLayout(lightOutsideLayout);
+
+ if (m_stopMotion->m_light->m_screenCount < 3) m_screen3Box->hide();
+ if (m_stopMotion->m_light->m_screenCount < 2) m_screen2Box->hide();
+
+ QVBoxLayout *motionOutsideLayout = new QVBoxLayout;
+ // QGridLayout* motionInsideLayout = new QGridLayout;
+ m_controlDeviceCombo = new QComboBox(this);
+ m_controlDeviceCombo->addItems(
+ m_stopMotion->m_serial->getAvailableSerialPorts());
+
+ QGroupBox *motionBox = new QGroupBox(tr("Motion Control"), this);
+ QGridLayout *motionLayout = new QGridLayout;
+ motionLayout->addWidget(new QLabel(tr("Port: ")), 0, 0, Qt::AlignRight);
+ motionLayout->addWidget(m_controlDeviceCombo, 0, 1, Qt::AlignLeft);
+ motionLayout->setColumnStretch(1, 30);
+ motionBox->setLayout(motionLayout);
+ motionBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
+ motionOutsideLayout->addWidget(motionBox, Qt::AlignCenter);
+ motionOutsideLayout->addStretch();
+
+ // motionOutsideLayout->addLayout(motionInsideLayout);
+ m_motionPage->setLayout(motionOutsideLayout);
+
QScrollArea *mainArea = makeChooserPageWithoutScrollBar(m_mainControlsPage);
QScrollArea *settingsArea =
makeChooserPageWithoutScrollBar(m_cameraSettingsPage);
QScrollArea *optionsArea = makeChooserPageWithoutScrollBar(m_optionsPage);
+ QScrollArea *lightArea = makeChooserPageWithoutScrollBar(m_lightPage);
+ QScrollArea *motionArea = makeChooserPageWithoutScrollBar(m_motionPage);
+
+ mainArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ settingsArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ optionsArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ lightArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ motionArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_stackedChooser = new QStackedWidget(this);
m_stackedChooser->addWidget(mainArea);
m_stackedChooser->addWidget(settingsArea);
m_stackedChooser->addWidget(optionsArea);
+ m_stackedChooser->addWidget(lightArea);
+ m_stackedChooser->addWidget(motionArea);
m_stackedChooser->setFocusPolicy(Qt::NoFocus);
QFrame *opacityFrame = new QFrame();
@@ -616,6 +904,7 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
QHBoxLayout *controlButtonLay = new QHBoxLayout();
controlButtonLay->addWidget(m_captureButton, 0);
controlButtonLay->addWidget(m_toggleLiveViewButton, 0);
+ controlButtonLay->addWidget(m_alwaysUseLiveViewImagesButton, 0);
controlButtonFrame->setLayout(controlButtonLay);
QVBoxLayout *mainLayout = new QVBoxLayout;
@@ -656,36 +945,36 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
SLOT(setPage(int)));
// Control Page
- ret = ret && connect(refreshCamListButton, SIGNAL(pressed()), this,
+ ret = ret && connect(refreshCamListButton, SIGNAL(clicked()), this,
SLOT(refreshCameraListCalled()));
ret = ret && connect(m_cameraListCombo, SIGNAL(activated(int)), this,
SLOT(onCameraListComboActivated(int)));
ret = ret && connect(m_resolutionCombo, SIGNAL(activated(const QString &)),
this, SLOT(onResolutionComboActivated(const QString &)));
if (m_captureFilterSettingsBtn)
- ret = ret && connect(m_captureFilterSettingsBtn, SIGNAL(pressed()), this,
+ ret = ret && connect(m_captureFilterSettingsBtn, SIGNAL(clicked()), this,
SLOT(onCaptureFilterSettingsBtnPressed()));
- ret = ret && connect(m_fileFormatOptionButton, SIGNAL(pressed()), this,
+ ret = ret && connect(m_fileFormatOptionButton, SIGNAL(clicked()), this,
SLOT(onFileFormatOptionButtonPressed()));
ret = ret && connect(m_levelNameEdit, SIGNAL(levelNameEdited()), this,
SLOT(onLevelNameEdited()));
ret = ret &&
- connect(nextLevelButton, SIGNAL(pressed()), this, SLOT(onNextName()));
- ret = ret && connect(m_previousLevelButton, SIGNAL(pressed()), this,
+ connect(nextLevelButton, SIGNAL(clicked()), this, SLOT(onNextName()));
+ ret = ret && connect(m_previousLevelButton, SIGNAL(clicked()), this,
SLOT(onPreviousName()));
- ret = ret && connect(nextOpenLevelButton, SIGNAL(pressed()), this,
+ ret = ret && connect(nextOpenLevelButton, SIGNAL(clicked()), this,
SLOT(onNextNewLevel()));
ret = ret &&
- connect(nextFrameButton, SIGNAL(pressed()), this, SLOT(onNextFrame()));
+ connect(nextFrameButton, SIGNAL(clicked()), this, SLOT(onNextFrame()));
ret = ret &&
- connect(lastFrameButton, SIGNAL(pressed()), this, SLOT(onLastFrame()));
- ret = ret && connect(m_previousFrameButton, SIGNAL(pressed()), this,
+ connect(lastFrameButton, SIGNAL(clicked()), this, SLOT(onLastFrame()));
+ ret = ret && connect(m_previousFrameButton, SIGNAL(clicked()), this,
SLOT(onPreviousFrame()));
- ret = ret && connect(nextXSheetFrameButton, SIGNAL(pressed()), this,
+ ret = ret && connect(nextXSheetFrameButton, SIGNAL(clicked()), this,
SLOT(onNextXSheetFrame()));
- ret = ret && connect(m_previousXSheetFrameButton, SIGNAL(pressed()), this,
+ ret = ret && connect(m_previousXSheetFrameButton, SIGNAL(clicked()), this,
SLOT(onPreviousXSheetFrame()));
- ret = ret && connect(m_setToCurrentXSheetFrameButton, SIGNAL(pressed()), this,
+ ret = ret && connect(m_setToCurrentXSheetFrameButton, SIGNAL(clicked()), this,
SLOT(setToCurrentXSheetFrame()));
ret = ret && connect(m_onionOpacityFld, SIGNAL(valueEditedByHand()), this,
SLOT(onOnionOpacityFldEdited()));
@@ -705,6 +994,11 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
SLOT(onXSheetFrameNumberChanged()));
ret = ret && connect(m_toggleLiveViewButton, SIGNAL(clicked()), this,
SLOT(onLiveViewToggleClicked()));
+ ret = ret && connect(m_alwaysUseLiveViewImagesButton, SIGNAL(clicked()), this,
+ SLOT(onAlwaysUseLiveViewImagesButtonClicked()));
+ ret =
+ ret && connect(m_stopMotion, SIGNAL(alwaysUseLiveViewImagesToggled(bool)),
+ this, SLOT(onAlwaysUseLiveViewImagesToggled(bool)));
ret = ret && connect(m_stopMotion, SIGNAL(filePathChanged(QString)), this,
SLOT(onFilePathChanged(QString)));
ret = ret && connect(m_stopMotion, SIGNAL(levelNameChanged(QString)), this,
@@ -725,8 +1019,7 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
this, SLOT(onScaleFullSizeImagesChanged(int)));
ret = ret && connect(m_liveViewOnAllFramesCB, SIGNAL(stateChanged(int)), this,
SLOT(onLiveViewOnAllFramesChanged(int)));
- ret = ret && connect(m_blackScreenForCapture, SIGNAL(stateChanged(int)), this,
- SLOT(onBlackScreenForCaptureChanged(int)));
+
ret = ret && connect(m_placeOnXSheetCB, SIGNAL(stateChanged(int)), this,
SLOT(onPlaceOnXSheetChanged(int)));
ret = ret && connect(m_directShowCB, SIGNAL(stateChanged(int)), this,
@@ -735,6 +1028,8 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
SLOT(onUseMjpgChanged(int)));
ret = ret && connect(m_useNumpadCB, SIGNAL(stateChanged(int)), this,
SLOT(onUseNumpadChanged(int)));
+ ret = ret && connect(m_drawBeneathCB, SIGNAL(stateChanged(int)), this,
+ SLOT(onDrawBeneathChanged(int)));
ret = ret && connect(m_postCaptureReviewFld, SIGNAL(valueEditedByHand()),
this, SLOT(onCaptureReviewFldEdited()));
ret = ret && connect(m_postCaptureReviewFld, SIGNAL(valueChanged(bool)), this,
@@ -745,128 +1040,236 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
SLOT(onSubsamplingSliderChanged(bool)));
ret = ret && connect(m_stopMotion, SIGNAL(subsamplingChanged(int)), this,
SLOT(onSubsamplingChanged(int)));
- ret = ret && connect(m_stopMotion, SIGNAL(scaleFullSizeImagesSignal(bool)),
- this, SLOT(onScaleFullSizeImagesSignal(bool)));
- ret = ret && connect(m_stopMotion, SIGNAL(blackCaptureSignal(bool)), this,
- SLOT(onBlackCaptureSignal(bool)));
+ ret = ret &&
+ connect(m_stopMotion->m_canon, SIGNAL(scaleFullSizeImagesSignal(bool)),
+ this, SLOT(onScaleFullSizeImagesSignal(bool)));
ret = ret && connect(m_stopMotion, SIGNAL(liveViewOnAllFramesSignal(bool)),
this, SLOT(onLiveViewOnAllFramesSignal(bool)));
ret = ret && connect(m_stopMotion, SIGNAL(placeOnXSheetSignal(bool)), this,
SLOT(onPlaceOnXSheetSignal(bool)));
- ret = ret && connect(m_stopMotion, SIGNAL(useDirectShowSignal(bool)), this,
- SLOT(onUseDirectShowSignal(bool)));
- ret = ret && connect(m_stopMotion, SIGNAL(useMjpgSignal(bool)), this,
- SLOT(onUseMjpgSignal(bool)));
+ ret =
+ ret && connect(m_stopMotion->m_webcam, SIGNAL(useDirectShowSignal(bool)),
+ this, SLOT(onUseDirectShowSignal(bool)));
+ ret = ret && connect(m_stopMotion->m_webcam, SIGNAL(useMjpgSignal(bool)),
+ this, SLOT(onUseMjpgSignal(bool)));
ret = ret && connect(m_stopMotion, SIGNAL(useNumpadSignal(bool)), this,
SLOT(onUseNumpadSignal(bool)));
+ ret = ret && connect(m_stopMotion, SIGNAL(drawBeneathLevelsSignal(bool)),
+ this, SLOT(onDrawBeneathSignal(bool)));
ret = ret && connect(m_stopMotion, SIGNAL(reviewTimeChangedSignal(int)), this,
SLOT(onReviewTimeChangedSignal(int)));
// From Stop Motion Main
ret = ret && connect(m_stopMotion, SIGNAL(newDimensions()), this,
SLOT(updateDimensions()));
- ret = ret && connect(m_stopMotion, SIGNAL(updateCameraList()), this,
- SLOT(refreshCameraList()));
+ ret = ret && connect(m_stopMotion, SIGNAL(updateCameraList(QString)), this,
+ SLOT(refreshCameraList(QString)));
ret = ret && connect(m_stopMotion, SIGNAL(liveViewChanged(bool)), this,
SLOT(onLiveViewChanged(bool)));
ret = ret && connect(m_stopMotion, SIGNAL(newCameraSelected(int, bool)), this,
SLOT(onNewCameraSelected(int, bool)));
- ret = ret && connect(m_stopMotion, SIGNAL(cameraChanged()), this,
- SLOT(refreshCameraList()));
+ ret = ret && connect(m_stopMotion, SIGNAL(cameraChanged(QString)), this,
+ SLOT(refreshCameraList(QString)));
ret = ret && connect(m_stopMotion, SIGNAL(optionsChanged()), this,
SLOT(refreshOptionsLists()));
// EOS Connections
ret = ret &&
- connect(m_zoomButton, SIGNAL(pressed()), this, SLOT(onZoomPressed()));
- ret = ret && connect(m_pickZoomButton, SIGNAL(pressed()), this,
+ connect(m_zoomButton, SIGNAL(clicked()), this, SLOT(onZoomPressed()));
+ ret = ret && connect(m_pickZoomButton, SIGNAL(clicked()), this,
SLOT(onPickZoomPressed()));
- ret = ret && connect(m_focusNearButton, SIGNAL(pressed()), this,
+ ret = ret && connect(m_focusNearButton, SIGNAL(clicked()), this,
SLOT(onFocusNear()));
ret = ret &&
- connect(m_focusFarButton, SIGNAL(pressed()), this, SLOT(onFocusFar()));
- ret = ret && connect(m_focusNear2Button, SIGNAL(pressed()), this,
+ connect(m_focusFarButton, SIGNAL(clicked()), this, SLOT(onFocusFar()));
+ ret = ret && connect(m_focusNear2Button, SIGNAL(clicked()), this,
SLOT(onFocusNear2()));
- ret = ret && connect(m_focusFar2Button, SIGNAL(pressed()), this,
+ ret = ret && connect(m_focusFar2Button, SIGNAL(clicked()), this,
SLOT(onFocusFar2()));
- ret = ret && connect(m_focusNear3Button, SIGNAL(pressed()), this,
+ ret = ret && connect(m_focusNear3Button, SIGNAL(clicked()), this,
SLOT(onFocusNear3()));
- ret = ret && connect(m_focusFar3Button, SIGNAL(pressed()), this,
+ ret = ret && connect(m_focusFar3Button, SIGNAL(clicked()), this,
SLOT(onFocusFar3()));
- ret = ret && connect(m_stopMotion, SIGNAL(apertureChangedSignal(QString)),
- this, SLOT(onApertureChangedSignal(QString)));
- ret = ret && connect(m_stopMotion, SIGNAL(isoChangedSignal(QString)), this,
- SLOT(onIsoChangedSignal(QString)));
- ret = ret && connect(m_stopMotion, SIGNAL(shutterSpeedChangedSignal(QString)),
- this, SLOT(onShutterSpeedChangedSignal(QString)));
- ret = ret && connect(m_stopMotion, SIGNAL(exposureChangedSignal(QString)),
- this, SLOT(onExposureChangedSignal(QString)));
- ret = ret && connect(m_stopMotion, SIGNAL(whiteBalanceChangedSignal(QString)),
- this, SLOT(onWhiteBalanceChangedSignal(QString)));
- ret = ret && connect(m_stopMotion, SIGNAL(imageQualityChangedSignal(QString)),
- this, SLOT(onImageQualityChangedSignal(QString)));
- ret = ret && connect(m_stopMotion, SIGNAL(pictureStyleChangedSignal(QString)),
- this, SLOT(onPictureStyleChangedSignal(QString)));
ret = ret &&
- connect(m_stopMotion, SIGNAL(colorTemperatureChangedSignal(QString)),
- this, SLOT(onColorTemperatureChangedSignal(QString)));
- ret = ret && connect(m_apertureCombo, SIGNAL(currentIndexChanged(int)), this,
+ connect(m_stopMotion->m_canon, SIGNAL(apertureChangedSignal(QString)),
+ this, SLOT(onApertureChangedSignal(QString)));
+ ret = ret && connect(m_stopMotion->m_canon, SIGNAL(isoChangedSignal(QString)),
+ this, SLOT(onIsoChangedSignal(QString)));
+ ret = ret && connect(m_stopMotion->m_canon,
+ SIGNAL(shutterSpeedChangedSignal(QString)), this,
+ SLOT(onShutterSpeedChangedSignal(QString)));
+ ret = ret &&
+ connect(m_stopMotion->m_canon, SIGNAL(exposureChangedSignal(QString)),
+ this, SLOT(onExposureChangedSignal(QString)));
+ ret = ret && connect(m_stopMotion->m_canon,
+ SIGNAL(whiteBalanceChangedSignal(QString)), this,
+ SLOT(onWhiteBalanceChangedSignal(QString)));
+ ret = ret && connect(m_stopMotion->m_canon,
+ SIGNAL(imageQualityChangedSignal(QString)), this,
+ SLOT(onImageQualityChangedSignal(QString)));
+ ret = ret && connect(m_stopMotion->m_canon,
+ SIGNAL(pictureStyleChangedSignal(QString)), this,
+ SLOT(onPictureStyleChangedSignal(QString)));
+ ret = ret && connect(m_stopMotion->m_canon,
+ SIGNAL(colorTemperatureChangedSignal(QString)), this,
+ SLOT(onColorTemperatureChangedSignal(QString)));
+ ret = ret && connect(m_apertureSlider, SIGNAL(valueChanged(int)), this,
SLOT(onApertureChanged(int)));
- ret = ret && connect(m_shutterSpeedCombo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(onShutterSpeedChanged(int)));
- ret = ret && connect(m_isoCombo, SIGNAL(currentIndexChanged(int)), this,
+ ret = ret && connect(m_shutterSpeedSlider, SIGNAL(valueChanged(int)), this,
+ SLOT(onShutterSpeedChanged(int)));
+ ret = ret && connect(m_isoSlider, SIGNAL(valueChanged(int)), this,
SLOT(onIsoChanged(int)));
ret = ret && connect(m_exposureCombo, SIGNAL(currentIndexChanged(int)), this,
SLOT(onExposureChanged(int)));
ret = ret && connect(m_whiteBalanceCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(onWhiteBalanceChanged(int)));
- ret = ret && connect(m_kelvinCombo, SIGNAL(currentIndexChanged(int)), this,
+ ret = ret && connect(m_kelvinSlider, SIGNAL(valueChanged(int)), this,
SLOT(onColorTemperatureChanged(int)));
ret = ret && connect(m_imageQualityCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(onImageQualityChanged(int)));
ret = ret && connect(m_pictureStyleCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(onPictureStyleChanged(int)));
- ret = ret && connect(m_stopMotion, SIGNAL(apertureOptionsChanged()), this,
- SLOT(refreshApertureList()));
- ret = ret && connect(m_stopMotion, SIGNAL(shutterSpeedOptionsChanged()), this,
- SLOT(refreshShutterSpeedList()));
- ret = ret && connect(m_stopMotion, SIGNAL(isoOptionsChanged()), this,
+ ret = ret && connect(m_stopMotion->m_canon, SIGNAL(apertureOptionsChanged()),
+ this, SLOT(refreshApertureList()));
+ ret = ret &&
+ connect(m_stopMotion->m_canon, SIGNAL(shutterSpeedOptionsChanged()),
+ this, SLOT(refreshShutterSpeedList()));
+ ret = ret && connect(m_stopMotion->m_canon, SIGNAL(isoOptionsChanged()), this,
SLOT(refreshIsoList()));
- ret = ret && connect(m_stopMotion, SIGNAL(exposureOptionsChanged()), this,
- SLOT(refreshExposureList()));
- ret = ret && connect(m_stopMotion, SIGNAL(whiteBalanceOptionsChanged()), this,
- SLOT(refreshWhiteBalanceList()));
- ret = ret && connect(m_stopMotion, SIGNAL(imageQualityOptionsChanged()), this,
- SLOT(refreshImageQualityList()));
- ret = ret && connect(m_stopMotion, SIGNAL(pictureStyleOptionsChanged()), this,
- SLOT(refreshPictureStyleList()));
+ ret = ret && connect(m_stopMotion->m_canon, SIGNAL(exposureOptionsChanged()),
+ this, SLOT(refreshExposureList()));
ret = ret &&
- connect(m_stopMotion, SIGNAL(modeChanged()), this, SLOT(refreshMode()));
+ connect(m_stopMotion->m_canon, SIGNAL(whiteBalanceOptionsChanged()),
+ this, SLOT(refreshWhiteBalanceList()));
+ ret = ret &&
+ connect(m_stopMotion->m_canon, SIGNAL(imageQualityOptionsChanged()),
+ this, SLOT(refreshImageQualityList()));
+ ret = ret &&
+ connect(m_stopMotion->m_canon, SIGNAL(pictureStyleOptionsChanged()),
+ this, SLOT(refreshPictureStyleList()));
+ ret = ret && connect(m_stopMotion->m_canon, SIGNAL(modeChanged()), this,
+ SLOT(refreshMode()));
+ ret = ret && connect(m_stopMotion->m_canon, SIGNAL(focusCheckToggled(bool)),
+ this, SLOT(onFocusCheckToggled(bool)));
+ ret =
+ ret && connect(m_stopMotion->m_canon, SIGNAL(pickFocusCheckToggled(bool)),
+ this, SLOT(onPickFocusCheckToggled(bool)));
// Webcam Specific Connections
ret = ret && connect(m_stopMotion, SIGNAL(webcamResolutionsChanged()), this,
SLOT(onWebcamResolutionsChanged()));
ret = ret && connect(m_stopMotion, SIGNAL(newWebcamResolutionSelected(int)),
this, SLOT(onNewWebcamResolutionSelected(int)));
+ ret = ret && connect(m_webcamFocusSlider, SIGNAL(valueChanged(int)), this,
+ SLOT(onWebcamFocusSliderChanged(int)));
+ ret = ret && connect(m_webcamAutoFocusGB, SIGNAL(toggled(bool)), this,
+ SLOT(onWebcamAutofocusToggled(bool)));
+ ret = ret && connect(m_webcamExposureSlider, SIGNAL(valueChanged(int)), this,
+ SLOT(onWebcamExposureSliderChanged(int)));
+ ret = ret && connect(m_webcamBrightnessSlider, SIGNAL(valueChanged(int)),
+ this, SLOT(onWebcamBrightnessSliderChanged(int)));
+ ret = ret && connect(m_webcamContrastSlider, SIGNAL(valueChanged(int)), this,
+ SLOT(onWebcamContrastSliderChanged(int)));
+ ret = ret && connect(m_webcamGainSlider, SIGNAL(valueChanged(int)), this,
+ SLOT(onWebcamGainSliderChanged(int)));
+ ret = ret && connect(m_webcamSaturationSlider, SIGNAL(valueChanged(int)),
+ this, SLOT(onWebcamSaturationSliderChanged(int)));
+
+ // Lighting Connections
+ ret = ret &&
+ connect(m_screen1ColorFld, SIGNAL(colorChanged(const TPixel32 &, bool)),
+ this, SLOT(setScreen1Color(const TPixel32 &, bool)));
+ ret = ret &&
+ connect(m_screen2ColorFld, SIGNAL(colorChanged(const TPixel32 &, bool)),
+ this, SLOT(setScreen2Color(const TPixel32 &, bool)));
+ ret = ret &&
+ connect(m_screen3ColorFld, SIGNAL(colorChanged(const TPixel32 &, bool)),
+ this, SLOT(setScreen3Color(const TPixel32 &, bool)));
+ ret = ret && connect(m_screen1Box, SIGNAL(toggled(bool)), this,
+ SLOT(onScreen1OverlayToggled(bool)));
+ ret = ret && connect(m_screen2Box, SIGNAL(toggled(bool)), this,
+ SLOT(onScreen2OverlayToggled(bool)));
+ ret = ret && connect(m_screen3Box, SIGNAL(toggled(bool)), this,
+ SLOT(onScreen3OverlayToggled(bool)));
+ ret = ret && connect(m_lightTestTimer, SIGNAL(timeout()), this,
+ SLOT(onTestLightsTimeout()));
+ ret = ret && connect(m_testLightsButton, SIGNAL(clicked()), this,
+ SLOT(onTestLightsPressed()));
+ ret = ret &&
+ connect(m_stopMotion->m_light, SIGNAL(screen1ColorChanged(TPixel32)),
+ this, SLOT(onScreen1ColorChanged(TPixel32)));
+ ret = ret &&
+ connect(m_stopMotion->m_light, SIGNAL(screen2ColorChanged(TPixel32)),
+ this, SLOT(onScreen2ColorChanged(TPixel32)));
+ ret = ret &&
+ connect(m_stopMotion->m_light, SIGNAL(screen3ColorChanged(TPixel32)),
+ this, SLOT(onScreen3ColorChanged(TPixel32)));
+ ret =
+ ret && connect(m_stopMotion->m_light, SIGNAL(screen1OverlayChanged(bool)),
+ this, SLOT(onScreen1OverlayChanged(bool)));
+ ret =
+ ret && connect(m_stopMotion->m_light, SIGNAL(screen2OverlayChanged(bool)),
+ this, SLOT(onScreen2OverlayChanged(bool)));
+ ret =
+ ret && connect(m_stopMotion->m_light, SIGNAL(screen3OverlayChanged(bool)),
+ this, SLOT(onScreen3OverlayChanged(bool)));
+ ret = ret && connect(m_blackScreenForCapture, SIGNAL(stateChanged(int)), this,
+ SLOT(onBlackScreenForCaptureChanged(int)));
+ ret = ret && connect(m_stopMotion->m_light, SIGNAL(blackCaptureSignal(bool)),
+ this, SLOT(onBlackCaptureSignal(bool)));
+
+ // Serial Port Connections
+ ret = ret && connect(m_controlDeviceCombo, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(serialPortChanged(int)));
+
+ // Time Lapse
+ ret = ret && connect(m_timerCB, SIGNAL(toggled(bool)), this,
+ SLOT(onIntervalTimerCBToggled(bool)));
+ ret = ret && connect(m_timerIntervalFld, SIGNAL(valueChanged(bool)), this,
+ SLOT(onIntervalSliderValueChanged(bool)));
+ ret = ret && connect(m_stopMotion, SIGNAL(intervalAmountChanged(int)), this,
+ SLOT(onIntervalAmountChanged(int)));
+ ret = ret && connect(m_stopMotion, SIGNAL(intervalToggled(bool)), this,
+ SLOT(onIntervalToggled(bool)));
+ ret = ret && connect(m_stopMotion, SIGNAL(intervalStarted()), this,
+ SLOT(onIntervalStarted()));
+ ret = ret && connect(m_stopMotion, SIGNAL(intervalStopped()), this,
+ SLOT(onIntervalStopped()));
+ ret = ret && connect(m_stopMotion->m_intervalTimer, SIGNAL(timeout()), this,
+ SLOT(onIntervalCaptureTimerTimeout()));
+ ret = ret && connect(m_stopMotion->m_countdownTimer, SIGNAL(timeout()), this,
+ SLOT(onIntervalCountDownTimeout()));
assert(ret);
m_placeOnXSheetCB->setChecked(
m_stopMotion->getPlaceOnXSheet() == true ? true : false);
- m_useScaledFullSizeImages->setChecked(m_stopMotion->m_useScaledImages);
+ m_useScaledFullSizeImages->setChecked(
+ m_stopMotion->m_canon->m_useScaledImages);
m_onionOpacityFld->setValue(double(100 * m_stopMotion->getOpacity()) / 255.0);
- m_directShowCB->setChecked(m_stopMotion->getUseDirectShow());
- m_useMjpgCB->setChecked(m_stopMotion->getUseMjpg());
+ m_directShowCB->setChecked(m_stopMotion->m_webcam->getUseDirectShow());
+ m_useMjpgCB->setChecked(m_stopMotion->m_webcam->getUseMjpg());
m_useNumpadCB->setChecked(m_stopMotion->getUseNumpadShortcuts());
+ m_drawBeneathCB->setChecked(m_stopMotion->m_drawBeneathLevels);
m_liveViewOnAllFramesCB->setChecked(m_stopMotion->getAlwaysLiveView());
m_blackScreenForCapture->setChecked(
- m_stopMotion->getBlackCapture() == true ? true : false);
+ m_stopMotion->m_light->getBlackCapture() == true ? true : false);
+ if (m_stopMotion->m_light->getBlackCapture()) {
+ m_screen1Box->setDisabled(true);
+ m_screen2Box->setDisabled(true);
+ m_screen3Box->setDisabled(true);
+ }
m_postCaptureReviewFld->setValue(m_stopMotion->getReviewTime());
- refreshCameraList();
+ refreshCameraList(QString(""));
onSceneSwitched();
m_stopMotion->setToNextNewLevel();
m_saveInFileFld->setPath(m_stopMotion->getFilePath());
+
+#ifndef _WIN32
+ m_directShowCB->hide();
+ m_directShowLabel->hide();
+#endif
}
//-----------------------------------------------------------------------------
@@ -876,14 +1279,18 @@ StopMotionController::~StopMotionController() {}
//-----------------------------------------------------------------------------
void StopMotionController::setPage(int index) {
- if (m_stopMotion->m_usingWebcam && index > 0) index += 1;
+ if (index > 0 && m_tabBar->tabText(1) != tr("Settings")) {
+ index += 1;
+ }
m_stackedChooser->setCurrentIndex(index);
}
//-----------------------------------------------------------------------------
void StopMotionController::onScaleFullSizeImagesChanged(int checked) {
- m_stopMotion->setUseScaledImages(checked > 0 ? true : false);
+#ifdef WITH_CANON
+ m_stopMotion->m_canon->setUseScaledImages(checked > 0 ? true : false);
+#endif
}
//-----------------------------------------------------------------------------
@@ -907,13 +1314,118 @@ void StopMotionController::onLiveViewOnAllFramesSignal(bool on) {
//-----------------------------------------------------------------------------
void StopMotionController::onBlackScreenForCaptureChanged(int checked) {
- m_stopMotion->setBlackCapture(checked);
+ m_stopMotion->m_light->setBlackCapture(checked);
}
//-----------------------------------------------------------------------------
void StopMotionController::onBlackCaptureSignal(bool on) {
+ m_blackScreenForCapture->blockSignals(true);
m_blackScreenForCapture->setChecked(on);
+ m_screen1Box->setDisabled(on);
+ m_screen2Box->setDisabled(on);
+ m_screen3Box->setDisabled(on);
+ m_blackScreenForCapture->blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::setScreen1Color(const TPixel32 &bgColor,
+ bool isDragging) {
+ m_stopMotion->m_light->setScreen1Color(bgColor);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::setScreen2Color(const TPixel32 &bgColor,
+ bool isDragging) {
+ m_stopMotion->m_light->setScreen2Color(bgColor);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::setScreen3Color(const TPixel32 &bgColor,
+ bool isDragging) {
+ m_stopMotion->m_light->setScreen3Color(bgColor);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onScreen1OverlayToggled(bool on) {
+ m_stopMotion->m_light->setScreen1UseOverlay(on);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onScreen2OverlayToggled(bool on) {
+ m_stopMotion->m_light->setScreen2UseOverlay(on);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onScreen3OverlayToggled(bool on) {
+ m_stopMotion->m_light->setScreen3UseOverlay(on);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onScreen1ColorChanged(TPixel32 color) {
+ m_screen1ColorFld->blockSignals(true);
+ m_screen1ColorFld->setColor(color);
+ m_screen1ColorFld->blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onScreen2ColorChanged(TPixel32 color) {
+ m_screen2ColorFld->blockSignals(true);
+ m_screen2ColorFld->setColor(color);
+ m_screen2ColorFld->blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onScreen3ColorChanged(TPixel32 color) {
+ m_screen3ColorFld->blockSignals(true);
+ m_screen3ColorFld->setColor(color);
+ m_screen3ColorFld->blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onScreen1OverlayChanged(bool on) {
+ m_screen1Box->blockSignals(true);
+ m_screen1Box->setChecked(on);
+ m_screen1Box->blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onScreen2OverlayChanged(bool on) {
+ m_screen2Box->blockSignals(true);
+ m_screen2Box->setChecked(on);
+ m_screen2Box->blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onScreen3OverlayChanged(bool on) {
+ m_screen3Box->blockSignals(true);
+ m_screen3Box->setChecked(on);
+ m_screen3Box->blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onTestLightsPressed() {
+ m_stopMotion->m_light->showOverlays();
+ m_lightTestTimer->start(2000);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onTestLightsTimeout() {
+ m_stopMotion->m_light->hideOverlays();
}
//-----------------------------------------------------------------------------
@@ -931,7 +1443,7 @@ void StopMotionController::onPlaceOnXSheetSignal(bool on) {
//-----------------------------------------------------------------------------
void StopMotionController::onUseDirectShowChanged(int checked) {
- m_stopMotion->setUseDirectShow(checked);
+ m_stopMotion->m_webcam->setUseDirectShow(checked);
}
//-----------------------------------------------------------------------------
@@ -943,7 +1455,7 @@ void StopMotionController::onUseDirectShowSignal(bool on) {
//-----------------------------------------------------------------------------
void StopMotionController::onUseMjpgChanged(int checked) {
- m_stopMotion->setUseMjpg(checked);
+ m_stopMotion->m_webcam->setUseMjpg(checked);
}
//-----------------------------------------------------------------------------
@@ -966,6 +1478,18 @@ void StopMotionController::onUseNumpadSignal(bool on) {
//-----------------------------------------------------------------------------
+void StopMotionController::onDrawBeneathChanged(int checked) {
+ m_stopMotion->setDrawBeneathLevels(checked);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onDrawBeneathSignal(bool on) {
+ m_drawBeneathCB->setChecked(on);
+}
+
+//-----------------------------------------------------------------------------
+
void StopMotionController::onCaptureReviewFldEdited() {
m_stopMotion->setReviewTime(m_postCaptureReviewFld->getValue());
}
@@ -1057,12 +1581,15 @@ void StopMotionController::refreshCameraListCalled() {
//-----------------------------------------------------------------------------
-void StopMotionController::refreshCameraList() {
+void StopMotionController::refreshCameraList(QString activeCamera) {
+ m_cameraListCombo->blockSignals(true);
m_cameraListCombo->clear();
-
- QList<QCameraInfo> webcams = m_stopMotion->getWebcams();
-
- int count = m_stopMotion->getCameraCount() + webcams.count();
+ m_cameraStatusLabel->hide();
+ QList<QCameraInfo> webcams = m_stopMotion->m_webcam->getWebcams();
+ int count = webcams.count();
+#ifdef WITH_CANON
+ count += m_stopMotion->m_canon->getCameraCount();
+#endif
if (count < 1) {
m_cameraListCombo->addItem(tr("No camera detected."));
m_cameraSettingsLabel->setText(tr("No camera detected"));
@@ -1082,52 +1609,58 @@ void StopMotionController::refreshCameraList() {
maxTextLength = std::max(maxTextLength, fontMetrics().width(camDesc));
}
}
- if (m_stopMotion->getCameraCount() > 0) {
+#ifdef WITH_CANON
+ if (m_stopMotion->m_canon->getCameraCount() > 0) {
QString name;
- m_stopMotion->getCamera(0);
- m_stopMotion->openCameraSession();
- name = QString::fromStdString(m_stopMotion->getCameraName());
- m_stopMotion->closeCameraSession();
+ m_stopMotion->m_canon->getCamera(0);
+ bool open = m_stopMotion->m_canon->m_sessionOpen;
+ if (!open) m_stopMotion->m_canon->openCameraSession();
+ name = QString::fromStdString(m_stopMotion->m_canon->getCameraName());
+ if (!open) m_stopMotion->m_canon->closeCameraSession();
m_cameraSettingsLabel->setText(name);
m_cameraListCombo->addItem(name);
maxTextLength = std::max(maxTextLength, fontMetrics().width(name));
}
+#endif
m_cameraListCombo->setMaximumWidth(maxTextLength + 25);
m_cameraListCombo->setEnabled(true);
m_cameraListCombo->setCurrentIndex(0);
m_captureButton->setEnabled(true);
m_toggleLiveViewButton->setEnabled(true);
}
+ if (activeCamera != "") m_cameraListCombo->setCurrentText(activeCamera);
+ m_cameraListCombo->blockSignals(false);
m_stopMotion->updateLevelNameAndFrame(m_levelNameEdit->text().toStdWString());
refreshOptionsLists();
+#ifdef WITH_CANON
refreshMode();
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::refreshOptionsLists() {
- m_apertureCombo->blockSignals(true);
- m_isoCombo->blockSignals(true);
- m_shutterSpeedCombo->blockSignals(true);
+ m_apertureSlider->blockSignals(true);
+ m_isoSlider->blockSignals(true);
+ m_shutterSpeedSlider->blockSignals(true);
m_exposureCombo->blockSignals(true);
m_whiteBalanceCombo->blockSignals(true);
- m_kelvinCombo->blockSignals(true);
+ m_kelvinSlider->blockSignals(true);
m_imageQualityCombo->blockSignals(true);
m_pictureStyleCombo->blockSignals(true);
- m_isoCombo->clear();
- m_shutterSpeedCombo->clear();
- m_apertureCombo->clear();
+ // m_isoCombo->clear();
+ // m_shutterSpeedCombo->clear();
+ // m_apertureSlider->clear();
m_exposureCombo->clear();
-
- if (m_stopMotion->getCameraCount() == 0) {
- m_resolutionCombo->setDisabled(true);
- m_shutterSpeedCombo->setDisabled(true);
- m_isoCombo->setDisabled(true);
- m_apertureCombo->setDisabled(true);
+#ifdef WITH_CANON
+ if (m_stopMotion->m_canon->getCameraCount() == 0) {
+ m_shutterSpeedSlider->setDisabled(true);
+ m_isoSlider->setDisabled(true);
+ m_apertureSlider->setDisabled(true);
m_exposureCombo->setDisabled(true);
m_whiteBalanceCombo->setDisabled(true);
- m_kelvinCombo->setDisabled(true);
+ m_kelvinSlider->setDisabled(true);
m_imageQualityCombo->setDisabled(true);
m_pictureStyleCombo->setDisabled(true);
return;
@@ -1140,178 +1673,248 @@ void StopMotionController::refreshOptionsLists() {
refreshWhiteBalanceList();
refreshImageQualityList();
refreshPictureStyleList();
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::refreshMode() {
- if (m_stopMotion->getCameraCount() == 0) {
+#ifdef WITH_CANON
+ if (m_stopMotion->m_canon->getCameraCount() == 0) {
m_cameraModeLabel->setText("");
+ m_cameraStatusLabel->hide();
return;
}
- QString mode = m_stopMotion->getMode();
+ QString mode = m_stopMotion->m_canon->getMode();
+ QString battery = m_stopMotion->m_canon->getCurrentBatteryLevel();
m_cameraModeLabel->setText(tr("Mode: ") + mode);
+ m_cameraStatusLabel->setText("Mode: " + mode + " - Battery: " + battery);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::refreshApertureList() {
- m_apertureCombo->blockSignals(true);
- m_apertureCombo->clear();
- m_stopMotion->getAvailableApertures();
- m_apertureCombo->addItems(m_stopMotion->getApertureOptions());
-
- if (m_apertureCombo->count() == 0) {
- m_apertureCombo->addItem(tr("Auto"));
- m_apertureCombo->setDisabled(true);
+#ifdef WITH_CANON
+ m_apertureSlider->blockSignals(true);
+ int count = 0;
+ m_stopMotion->m_canon->getAvailableApertures();
+ count = m_stopMotion->m_canon->getApertureOptions().size();
+
+ if (count == 0) {
+ m_apertureLabel->setText(tr("Aperture: Auto"));
+ m_apertureSlider->setDisabled(true);
+ m_apertureSlider->setRange(0, 0);
} else {
- m_apertureCombo->setEnabled(true);
- m_apertureCombo->setCurrentText(m_stopMotion->getCurrentAperture());
+ m_apertureSlider->setEnabled(true);
+ m_apertureLabel->setText(tr("Aperture: ") +
+ m_stopMotion->m_canon->getCurrentAperture());
+ m_apertureSlider->setRange(0, count - 1);
+ m_apertureSlider->setValue(
+ m_stopMotion->m_canon->getApertureOptions().lastIndexOf(
+ m_stopMotion->m_canon->getCurrentAperture()));
}
- m_apertureCombo->blockSignals(false);
+ m_apertureSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::refreshShutterSpeedList() {
- m_shutterSpeedCombo->blockSignals(true);
- m_shutterSpeedCombo->clear();
- m_stopMotion->getAvailableShutterSpeeds();
- m_shutterSpeedCombo->addItems(m_stopMotion->getShutterSpeedOptions());
-
- if (m_shutterSpeedCombo->count() == 0) {
- m_shutterSpeedCombo->addItem(tr("Auto"));
- m_shutterSpeedCombo->setDisabled(true);
+#ifdef WITH_CANON
+ m_shutterSpeedSlider->blockSignals(true);
+ int count = 0;
+ m_stopMotion->m_canon->getAvailableShutterSpeeds();
+ count = m_stopMotion->m_canon->getShutterSpeedOptions().size();
+
+ if (count == 0) {
+ m_shutterSpeedLabel->setText(tr("Shutter Speed: Auto"));
+ m_shutterSpeedSlider->setDisabled(true);
+ m_shutterSpeedSlider->setRange(0, 0);
} else {
- m_shutterSpeedCombo->setEnabled(true);
- m_shutterSpeedCombo->setCurrentText(m_stopMotion->getCurrentShutterSpeed());
+ m_shutterSpeedSlider->setEnabled(true);
+ m_shutterSpeedLabel->setText(
+ tr("Shutter Speed: ") +
+ m_stopMotion->m_canon->getCurrentShutterSpeed());
+ m_shutterSpeedSlider->setRange(0, count - 1);
+ m_shutterSpeedSlider->setValue(
+ m_stopMotion->m_canon->getShutterSpeedOptions().lastIndexOf(
+ m_stopMotion->m_canon->getCurrentShutterSpeed()));
}
- m_shutterSpeedCombo->blockSignals(false);
+ m_shutterSpeedSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::refreshIsoList() {
- m_isoCombo->blockSignals(true);
- m_isoCombo->clear();
- m_stopMotion->getAvailableIso();
- m_isoCombo->addItems(m_stopMotion->getIsoOptions());
-
- if (m_isoCombo->count() == 0) {
- m_isoCombo->addItem(tr("Auto"));
- m_isoCombo->setDisabled(true);
+#ifdef WITH_CANON
+ m_isoSlider->blockSignals(true);
+ int count = 0;
+ m_stopMotion->m_canon->getAvailableIso();
+ count = m_stopMotion->m_canon->getIsoOptions().size();
+
+ if (count == 0) {
+ m_isoLabel->setText(tr("Iso: ") + tr("Auto"));
+ m_isoSlider->setDisabled(true);
+ m_isoSlider->setRange(0, 0);
} else {
- m_isoCombo->setEnabled(true);
- std::string currIso = m_stopMotion->getCurrentIso().toStdString();
- m_isoCombo->setCurrentText(m_stopMotion->getCurrentIso());
+ m_isoSlider->setEnabled(true);
+ m_isoLabel->setText(tr("Iso: ") + m_stopMotion->m_canon->getCurrentIso());
+ m_isoSlider->setRange(0, count - 1);
+ m_isoSlider->setValue(m_stopMotion->m_canon->getIsoOptions().lastIndexOf(
+ m_stopMotion->m_canon->getCurrentIso()));
}
- m_isoCombo->blockSignals(false);
+ m_isoSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::refreshExposureList() {
+#ifdef WITH_CANON
m_exposureCombo->blockSignals(true);
m_exposureCombo->clear();
- m_stopMotion->getAvailableExposureCompensations();
- m_exposureCombo->addItems(m_stopMotion->getExposureOptions());
-
+ m_stopMotion->m_canon->getAvailableExposureCompensations();
+ QStringList options = m_stopMotion->m_canon->getExposureOptions();
+ m_exposureCombo->addItems(options);
+ int maxTextLength = 0;
+ for (int i = 0; i < options.size(); i++) {
+ maxTextLength = std::max(maxTextLength, fontMetrics().width(options.at(i)));
+ }
if (m_exposureCombo->count() == 0) {
m_exposureCombo->addItem(tr("Disabled"));
m_exposureCombo->setDisabled(true);
+ m_exposureCombo->setMaximumWidth(fontMetrics().width("Disabled") + 25);
} else {
m_exposureCombo->setEnabled(true);
m_exposureCombo->setCurrentText(
- m_stopMotion->getCurrentExposureCompensation());
+ m_stopMotion->m_canon->getCurrentExposureCompensation());
+ m_exposureCombo->setMaximumWidth(maxTextLength + 25);
}
m_exposureCombo->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::refreshWhiteBalanceList() {
+#ifdef WITH_CANON
m_whiteBalanceCombo->blockSignals(true);
m_whiteBalanceCombo->clear();
- m_stopMotion->getAvailableWhiteBalances();
- m_whiteBalanceCombo->addItems(m_stopMotion->getWhiteBalanceOptions());
-
+ m_stopMotion->m_canon->getAvailableWhiteBalances();
+ QStringList options = m_stopMotion->m_canon->getWhiteBalanceOptions();
+ m_whiteBalanceCombo->addItems(options);
+ int maxTextLength = 0;
+ for (int i = 0; i < options.size(); i++) {
+ maxTextLength = std::max(maxTextLength, fontMetrics().width(options.at(i)));
+ }
if (m_whiteBalanceCombo->count() == 0) {
m_whiteBalanceCombo->addItem(tr("Disabled"));
m_whiteBalanceCombo->setDisabled(true);
+ m_whiteBalanceCombo->setMaximumWidth(fontMetrics().width("Disabled") + 25);
} else {
m_whiteBalanceCombo->setEnabled(true);
- m_whiteBalanceCombo->setCurrentText(m_stopMotion->getCurrentWhiteBalance());
+ m_whiteBalanceCombo->setCurrentText(
+ m_stopMotion->m_canon->getCurrentWhiteBalance());
+ m_whiteBalanceCombo->setMaximumWidth(maxTextLength + 25);
}
m_whiteBalanceCombo->blockSignals(false);
refreshColorTemperatureList();
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::refreshColorTemperatureList() {
- m_kelvinCombo->blockSignals(true);
- m_kelvinCombo->clear();
- m_kelvinCombo->addItems(m_stopMotion->getColorTemperatureOptions());
- std::string ct = m_stopMotion->getCurrentWhiteBalance().toStdString();
- int kCount = m_kelvinCombo->count();
- if (m_kelvinCombo->count() == 0 ||
- m_stopMotion->getCurrentWhiteBalance() != "Color Temperature") {
+#ifdef WITH_CANON
+ m_kelvinSlider->blockSignals(true);
+ int count = 0;
+ count = m_stopMotion->m_canon->getColorTemperatureOptions().size();
+
+ if (count == 0 ||
+ m_stopMotion->m_canon->getCurrentWhiteBalance() != "Color Temperature") {
// m_kelvinCombo->addItem(tr("Disabled"));
- m_kelvinCombo->setDisabled(true);
- m_kelvinCombo->hide();
- m_kelvinLabel->hide();
+ m_kelvinSlider->setDisabled(true);
+ m_kelvinSlider->hide();
+ m_kelvinValueLabel->hide();
} else {
- m_kelvinCombo->show();
- m_kelvinLabel->show();
- m_kelvinCombo->setEnabled(true);
- m_kelvinCombo->setCurrentText(m_stopMotion->getCurrentColorTemperature());
+ m_kelvinSlider->show();
+ m_kelvinValueLabel->show();
+ m_kelvinSlider->setEnabled(true);
+ m_kelvinSlider->setRange(0, count - 1);
+ m_kelvinValueLabel->setText(
+ tr("Temperature: ") +
+ m_stopMotion->m_canon->getCurrentColorTemperature());
}
- m_kelvinCombo->blockSignals(false);
+ m_kelvinSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::refreshImageQualityList() {
+#ifdef WITH_CANON
m_imageQualityCombo->blockSignals(true);
m_imageQualityCombo->clear();
- m_stopMotion->getAvailableImageQualities();
- m_imageQualityCombo->addItems(m_stopMotion->getImageQualityOptions());
-
+ m_stopMotion->m_canon->getAvailableImageQualities();
+ QStringList options = m_stopMotion->m_canon->getImageQualityOptions();
+ m_imageQualityCombo->addItems(options);
+ int maxTextLength = 0;
+ for (int i = 0; i < options.size(); i++) {
+ maxTextLength = std::max(maxTextLength, fontMetrics().width(options.at(i)));
+ }
if (m_imageQualityCombo->count() == 0) {
m_imageQualityCombo->addItem(tr("Disabled"));
m_imageQualityCombo->setDisabled(true);
+ m_imageQualityCombo->setMaximumWidth(fontMetrics().width("Disabled") + 25);
} else {
m_imageQualityCombo->setEnabled(true);
- m_imageQualityCombo->setCurrentText(m_stopMotion->getCurrentImageQuality());
+ m_imageQualityCombo->setCurrentText(
+ m_stopMotion->m_canon->getCurrentImageQuality());
+ m_imageQualityCombo->setMaximumWidth(maxTextLength + 25);
}
m_imageQualityCombo->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::refreshPictureStyleList() {
+#ifdef WITH_CANON
m_pictureStyleCombo->blockSignals(true);
m_pictureStyleCombo->clear();
- m_stopMotion->getAvailablePictureStyles();
- m_pictureStyleCombo->addItems(m_stopMotion->getPictureStyleOptions());
-
+ m_stopMotion->m_canon->getAvailablePictureStyles();
+ QStringList options = m_stopMotion->m_canon->getPictureStyleOptions();
+ m_pictureStyleCombo->addItems(
+ m_stopMotion->m_canon->getPictureStyleOptions());
+ int maxTextLength = 0;
+ for (int i = 0; i < options.size(); i++) {
+ maxTextLength = std::max(maxTextLength, fontMetrics().width(options.at(i)));
+ }
if (m_pictureStyleCombo->count() == 0) {
m_pictureStyleCombo->addItem(tr("Disabled"));
m_pictureStyleCombo->setDisabled(true);
+ m_pictureStyleCombo->setMaximumWidth(fontMetrics().width("Disabled") + 25);
} else {
m_pictureStyleCombo->setEnabled(true);
- m_pictureStyleCombo->setCurrentText(m_stopMotion->getCurrentPictureStyle());
+ m_pictureStyleCombo->setCurrentText(
+ m_stopMotion->m_canon->getCurrentPictureStyle());
+ m_pictureStyleCombo->setMaximumWidth(maxTextLength + 25);
}
m_pictureStyleCombo->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onCameraListComboActivated(int comboIndex) {
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
- if (cameras.size() + m_stopMotion->getCameraCount() !=
- m_cameraListCombo->count() - 1)
- return;
+ int cameraCount = cameras.size();
+#ifdef WITH_CANON
+ cameraCount += m_stopMotion->m_canon->getCameraCount();
+#endif
+ if (cameraCount != m_cameraListCombo->count() - 1) return;
m_stopMotion->changeCameras(comboIndex);
}
@@ -1325,22 +1928,45 @@ void StopMotionController::onNewCameraSelected(int index, bool useWebcam) {
m_cameraListCombo->setCurrentIndex(index);
m_resolutionCombo->hide();
m_resolutionLabel->hide();
- }
- if (useWebcam) {
- if (m_tabBar->tabText(1) == tr("Settings")) {
- m_tabBar->removeTab(1);
- }
+ m_cameraStatusLabel->hide();
+ m_pickZoomButton->setStyleSheet("border:1px solid rgb(0, 0, 0, 0);");
+ m_zoomButton->setStyleSheet("border:1px solid rgb(0, 0, 0, 0);");
+ m_pickZoomButton->setChecked(false);
+ m_zoomButton->setChecked(false);
+ m_dslrFrame->hide();
+ m_webcamFrame->hide();
+ m_noCameraFrame->show();
+ m_alwaysUseLiveViewImagesButton->hide();
+ // if (m_tabBar->tabText(1) == tr("Settings")) {
+ // m_tabBar->removeTab(1);
+ //}
+ } else if (useWebcam) {
m_resolutionCombo->show();
m_resolutionCombo->setEnabled(true);
m_resolutionLabel->show();
- m_captureFilterSettingsBtn->show();
+ if (m_captureFilterSettingsBtn) m_captureFilterSettingsBtn->show();
+ m_cameraStatusLabel->hide();
+ m_webcamFrame->show();
+ m_dslrFrame->hide();
+ m_noCameraFrame->hide();
+ m_alwaysUseLiveViewImagesButton->hide();
+ getWebcamStatus();
+ // if (m_tabBar->tabText(1) == tr("Options")) {
+ // m_tabBar->insertTab(1, tr("Settings"));
+ //}
+ m_webcamLabel->setText(m_cameraListCombo->currentText());
} else {
m_resolutionCombo->hide();
m_resolutionLabel->hide();
- m_captureFilterSettingsBtn->hide();
- if (m_tabBar->tabText(1) == tr("Options")) {
- m_tabBar->insertTab(1, tr("Settings"));
- }
+ if (m_captureFilterSettingsBtn) m_captureFilterSettingsBtn->hide();
+ m_cameraStatusLabel->show();
+ m_dslrFrame->show();
+ m_webcamFrame->hide();
+ m_noCameraFrame->hide();
+ m_alwaysUseLiveViewImagesButton->show();
+ // if (m_tabBar->tabText(1) == tr("Options")) {
+ // m_tabBar->insertTab(1, tr("Settings"));
+ //}
}
}
@@ -1348,7 +1974,7 @@ void StopMotionController::onNewCameraSelected(int index, bool useWebcam) {
void StopMotionController::onWebcamResolutionsChanged() {
m_resolutionCombo->clear();
- QList<QSize> resolutions = m_stopMotion->getWebcamResolutions();
+ QList<QSize> resolutions = m_stopMotion->m_webcam->getWebcamResolutions();
for (int s = 0; s < resolutions.size(); s++) {
m_resolutionCombo->addItem(QString("%1 x %2")
.arg(resolutions.at(s).width())
@@ -1368,17 +1994,90 @@ void StopMotionController::onResolutionComboActivated(const QString &itemText) {
m_stopMotion->setWebcamResolution(itemText);
}
+////-----------------------------------------------------------------------------
+//
+// void StopMotionController::onWebcamFocusFldEdited() {
+// int value = m_webcamFocusSlider->getValue();
+// value = value + abs((value % 5) - 5);
+// m_stopMotion->m_webcam->setWebcamFocusValue(value);
+//}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onWebcamAutofocusToggled(bool on) {
+ m_stopMotion->m_webcam->setWebcamAutofocusStatus(!on);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onWebcamFocusSliderChanged(int value) {
+ // int value = m_webcamFocusSlider->getValue();
+ value = value + abs((value % 5) - 5);
+ m_stopMotion->m_webcam->setWebcamFocusValue(value);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onWebcamExposureSliderChanged(int value) {
+ m_stopMotion->m_webcam->setWebcamExposureValue(value);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onWebcamBrightnessSliderChanged(int value) {
+ m_stopMotion->m_webcam->setWebcamBrightnessValue(value);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onWebcamContrastSliderChanged(int value) {
+ m_stopMotion->m_webcam->setWebcamContrastValue(value);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onWebcamGainSliderChanged(int value) {
+ m_stopMotion->m_webcam->setWebcamGainValue(value);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onWebcamSaturationSliderChanged(int value) {
+ m_stopMotion->m_webcam->setWebcamSaturationValue(value);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::getWebcamStatus() {
+ m_webcamAutoFocusGB->setChecked(
+ !m_stopMotion->m_webcam->getWebcamAutofocusStatus());
+ m_webcamFocusSlider->setValue(m_stopMotion->m_webcam->getWebcamFocusValue());
+ m_webcamExposureSlider->setValue(
+ m_stopMotion->m_webcam->getWebcamExposureValue());
+ m_webcamBrightnessSlider->setValue(
+ m_stopMotion->m_webcam->getWebcamBrightnessValue());
+ m_webcamContrastSlider->setValue(
+ m_stopMotion->m_webcam->getWebcamContrastValue());
+ m_webcamGainSlider->setValue(m_stopMotion->m_webcam->getWebcamGainValue());
+ m_webcamSaturationSlider->setValue(
+ m_stopMotion->m_webcam->getWebcamSaturationValue());
+}
+
//-----------------------------------------------------------------------------
void StopMotionController::onCaptureFilterSettingsBtnPressed() {
- if (!m_stopMotion->getWebcam() || m_stopMotion->m_webcamDeviceName.isNull())
+ if (!m_stopMotion->m_webcam->getWebcam() ||
+ m_stopMotion->m_webcam->getWebcamDeviceName().isNull())
return;
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
for (int c = 0; c < cameras.size(); c++) {
- if (cameras.at(c).deviceName() == m_stopMotion->m_webcamDeviceName) {
+ if (cameras.at(c).deviceName() ==
+ m_stopMotion->m_webcam->getWebcamDeviceName()) {
#ifdef _WIN32
- openCaptureFilterSettings(this, cameras.at(c).description());
+ m_stopMotion->m_webcam->openSettingsWindow();
+// openCaptureFilterSettings(this, cameras.at(c).description());
+
#endif
return;
}
@@ -1460,178 +2159,417 @@ void StopMotionController::onFrameCaptured(QImage &image) {}
//-----------------------------------------------------------------------------
void StopMotionController::onApertureChanged(int index) {
- m_stopMotion->setAperture(m_apertureCombo->currentText());
+#ifdef WITH_CANON
+ m_apertureSlider->blockSignals(true);
+ QStringList apertureOptions = m_stopMotion->m_canon->getApertureOptions();
+ m_stopMotion->m_canon->setAperture(
+ apertureOptions.at(m_apertureSlider->value()));
+ m_apertureSlider->setRange(0, apertureOptions.size() - 1);
+ m_apertureSlider->setValue(
+ apertureOptions.lastIndexOf(m_stopMotion->m_canon->getCurrentAperture()));
+ m_apertureLabel->setText(tr("Aperture: ") +
+ m_stopMotion->m_canon->getCurrentAperture());
+ m_apertureSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onApertureChangedSignal(QString text) {
- m_apertureCombo->setCurrentText(m_stopMotion->getCurrentAperture());
+#ifdef WITH_CANON
+ m_apertureSlider->blockSignals(true);
+ QStringList apertureOptions = m_stopMotion->m_canon->getApertureOptions();
+ m_apertureLabel->setText(tr("Aperture: ") +
+ m_stopMotion->m_canon->getCurrentAperture());
+ m_apertureSlider->setRange(0, apertureOptions.size() - 1);
+ m_apertureSlider->setValue(
+ apertureOptions.lastIndexOf(m_stopMotion->m_canon->getCurrentAperture()));
+ m_apertureSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onShutterSpeedChanged(int index) {
- m_stopMotion->setShutterSpeed(m_shutterSpeedCombo->currentText());
+#ifdef WITH_CANON
+ m_shutterSpeedSlider->blockSignals(true);
+ QStringList shutterSpeedOptions =
+ m_stopMotion->m_canon->getShutterSpeedOptions();
+ m_stopMotion->m_canon->setShutterSpeed(
+ shutterSpeedOptions.at(m_shutterSpeedSlider->value()));
+ m_shutterSpeedSlider->setRange(0, shutterSpeedOptions.size() - 1);
+ m_shutterSpeedSlider->setValue(shutterSpeedOptions.lastIndexOf(
+ m_stopMotion->m_canon->getCurrentShutterSpeed()));
+ m_shutterSpeedLabel->setText(tr("Shutter Speed: ") +
+ m_stopMotion->m_canon->getCurrentShutterSpeed());
+ m_shutterSpeedSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onShutterSpeedChangedSignal(QString text) {
- m_shutterSpeedCombo->setCurrentText(m_stopMotion->getCurrentShutterSpeed());
+#ifdef WITH_CANON
+ m_shutterSpeedSlider->blockSignals(true);
+ QStringList shutterSpeedOptions =
+ m_stopMotion->m_canon->getShutterSpeedOptions();
+ m_shutterSpeedLabel->setText(tr("Shutter Speed: ") +
+ m_stopMotion->m_canon->getCurrentShutterSpeed());
+ m_shutterSpeedSlider->setRange(0, shutterSpeedOptions.size() - 1);
+ m_shutterSpeedSlider->setValue(shutterSpeedOptions.lastIndexOf(
+ m_stopMotion->m_canon->getCurrentShutterSpeed()));
+ m_shutterSpeedSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onIsoChanged(int index) {
- m_stopMotion->setIso(m_isoCombo->currentText());
+#ifdef WITH_CANON
+ m_isoSlider->blockSignals(true);
+ QStringList isoOptions = m_stopMotion->m_canon->getIsoOptions();
+ m_stopMotion->m_canon->setIso(isoOptions.at(m_isoSlider->value()));
+ m_isoSlider->setRange(0, isoOptions.size() - 1);
+ m_isoSlider->setValue(
+ isoOptions.lastIndexOf(m_stopMotion->m_canon->getCurrentIso()));
+ m_isoLabel->setText(tr("Iso: ") + m_stopMotion->m_canon->getCurrentIso());
+ m_isoSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onIsoChangedSignal(QString text) {
- m_isoCombo->setCurrentText(m_stopMotion->getCurrentIso());
+#ifdef WITH_CANON
+ m_isoSlider->blockSignals(true);
+ QStringList isoOptions = m_stopMotion->m_canon->getIsoOptions();
+ m_isoSlider->setRange(0, isoOptions.size() - 1);
+ m_isoSlider->setValue(
+ isoOptions.lastIndexOf(m_stopMotion->m_canon->getCurrentIso()));
+ m_isoLabel->setText(tr("Iso: ") + m_stopMotion->m_canon->getCurrentIso());
+ m_isoSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onExposureChanged(int index) {
- m_stopMotion->setExposureCompensation(m_exposureCombo->currentText());
+#ifdef WITH_CANON
+ m_exposureCombo->blockSignals(true);
+ m_stopMotion->m_canon->setExposureCompensation(
+ m_exposureCombo->currentText());
+ m_exposureCombo->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onExposureChangedSignal(QString text) {
+#ifdef WITH_CANON
+ m_exposureCombo->blockSignals(true);
m_exposureCombo->setCurrentText(
- m_stopMotion->getCurrentExposureCompensation());
+ m_stopMotion->m_canon->getCurrentExposureCompensation());
+ m_exposureCombo->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onWhiteBalanceChanged(int index) {
- m_stopMotion->setWhiteBalance(m_whiteBalanceCombo->currentText());
+#ifdef WITH_CANON
+ m_whiteBalanceCombo->blockSignals(true);
+ m_stopMotion->m_canon->setWhiteBalance(m_whiteBalanceCombo->currentText());
+ m_whiteBalanceCombo->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onWhiteBalanceChangedSignal(QString text) {
- m_whiteBalanceCombo->setCurrentText(m_stopMotion->getCurrentWhiteBalance());
+#ifdef WITH_CANON
+ m_whiteBalanceCombo->blockSignals(true);
+ m_whiteBalanceCombo->setCurrentText(
+ m_stopMotion->m_canon->getCurrentWhiteBalance());
refreshColorTemperatureList();
+ m_whiteBalanceCombo->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onColorTemperatureChanged(int index) {
- m_stopMotion->setColorTemperature(m_kelvinCombo->currentText());
+#ifdef WITH_CANON
+ m_kelvinSlider->blockSignals(true);
+ QStringList kelvinOptions =
+ m_stopMotion->m_canon->getColorTemperatureOptions();
+ m_stopMotion->m_canon->setColorTemperature(
+ kelvinOptions.at(m_kelvinSlider->value()));
+ m_kelvinSlider->setRange(0, kelvinOptions.size() - 1);
+ m_kelvinSlider->setValue(kelvinOptions.lastIndexOf(
+ m_stopMotion->m_canon->getCurrentColorTemperature()));
+ m_kelvinValueLabel->setText(
+ tr("Temperature: ") +
+ m_stopMotion->m_canon->getCurrentColorTemperature());
+ m_kelvinSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onColorTemperatureChangedSignal(QString text) {
- m_kelvinCombo->setCurrentText(m_stopMotion->getCurrentColorTemperature());
+#ifdef WITH_CANON
+ m_kelvinSlider->blockSignals(true);
+ QStringList kelvinOptions =
+ m_stopMotion->m_canon->getColorTemperatureOptions();
+ m_kelvinSlider->setRange(0, kelvinOptions.size() - 1);
+ m_kelvinSlider->setValue(kelvinOptions.lastIndexOf(
+ m_stopMotion->m_canon->getCurrentColorTemperature()));
+ m_kelvinValueLabel->setText(
+ tr("Temperature: ") +
+ m_stopMotion->m_canon->getCurrentColorTemperature());
+ m_kelvinSlider->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onImageQualityChanged(int index) {
- m_stopMotion->setImageQuality(m_imageQualityCombo->currentText());
+#ifdef WITH_CANON
+ m_imageQualityCombo->blockSignals(true);
+ m_stopMotion->m_canon->setImageQuality(m_imageQualityCombo->currentText());
+ m_imageQualityCombo->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onImageQualityChangedSignal(QString text) {
- m_imageQualityCombo->setCurrentText(m_stopMotion->getCurrentImageQuality());
+#ifdef WITH_CANON
+ m_imageQualityCombo->blockSignals(true);
+ m_imageQualityCombo->setCurrentText(
+ m_stopMotion->m_canon->getCurrentImageQuality());
+ m_imageQualityCombo->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onPictureStyleChanged(int index) {
- m_stopMotion->setPictureStyle(m_pictureStyleCombo->currentText());
+#ifdef WITH_CANON
+ m_pictureStyleCombo->blockSignals(true);
+ m_stopMotion->m_canon->setPictureStyle(m_pictureStyleCombo->currentText());
+ m_pictureStyleCombo->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
void StopMotionController::onPictureStyleChangedSignal(QString text) {
- m_pictureStyleCombo->setCurrentText(m_stopMotion->getCurrentPictureStyle());
+#ifdef WITH_CANON
+ m_pictureStyleCombo->blockSignals(true);
+ m_pictureStyleCombo->setCurrentText(
+ m_stopMotion->m_canon->getCurrentPictureStyle());
+ m_pictureStyleCombo->blockSignals(false);
+#endif
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onFocusCheckToggled(bool on) {
+#ifdef WITH_CANON
+ if (on) {
+ m_zoomButton->setStyleSheet("border:1px solid rgb(0, 255, 0, 255);");
+ } else {
+ m_zoomButton->setStyleSheet("border:1px solid rgb(0, 0, 0, 0);");
+ }
+ m_zoomButton->blockSignals(true);
+ m_zoomButton->setChecked(on);
+ m_zoomButton->blockSignals(false);
+#endif
}
//-----------------------------------------------------------------------------
-void StopMotionController::onZoomPressed() { m_stopMotion->zoomLiveView(); }
+void StopMotionController::onPickFocusCheckToggled(bool on) {
+#ifdef WITH_CANON
+ if (on) {
+ m_pickZoomButton->setStyleSheet("border:1px solid rgb(0, 255, 0, 255);");
+
+ } else {
+ m_pickZoomButton->setStyleSheet("border:1px solid rgb(0, 0, 0, 0);");
+ }
+ m_pickZoomButton->blockSignals(true);
+ m_pickZoomButton->setChecked(on);
+ m_pickZoomButton->blockSignals(false);
+#endif
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onZoomPressed() {
+#ifdef WITH_CANON
+ m_stopMotion->m_canon->zoomLiveView();
+#endif
+}
//-----------------------------------------------------------------------------
void StopMotionController::onPickZoomPressed() {
- m_stopMotion->m_pickLiveViewZoom = true;
+#ifdef WITH_CANON
+ m_stopMotion->m_canon->toggleZoomPicking();
+#endif
}
//-----------------------------------------------------------------------------
-void StopMotionController::onFocusNear() { m_stopMotion->focusNear(); }
+void StopMotionController::onFocusNear() {
+#ifdef WITH_CANON
+ m_stopMotion->m_canon->focusNear();
+#endif
+}
//-----------------------------------------------------------------------------
-void StopMotionController::onFocusFar() { m_stopMotion->focusFar(); }
+void StopMotionController::onFocusFar() {
+#ifdef WITH_CANON
+ m_stopMotion->m_canon->focusFar();
+#endif
+}
//-----------------------------------------------------------------------------
-void StopMotionController::onFocusNear2() { m_stopMotion->focusNear2(); }
+void StopMotionController::onFocusNear2() {
+#ifdef WITH_CANON
+ m_stopMotion->m_canon->focusNear2();
+#endif
+}
//-----------------------------------------------------------------------------
-void StopMotionController::onFocusFar2() { m_stopMotion->focusFar2(); }
+void StopMotionController::onFocusFar2() {
+#ifdef WITH_CANON
+ m_stopMotion->m_canon->focusFar2();
+#endif
+}
//-----------------------------------------------------------------------------
-void StopMotionController::onFocusNear3() { m_stopMotion->focusNear3(); }
+void StopMotionController::onFocusNear3() {
+#ifdef WITH_CANON
+ m_stopMotion->m_canon->focusNear3();
+#endif
+}
//-----------------------------------------------------------------------------
-void StopMotionController::onFocusFar3() { m_stopMotion->focusFar3(); }
+void StopMotionController::onFocusFar3() {
+#ifdef WITH_CANON
+ m_stopMotion->m_canon->focusFar3();
+#endif
+}
//-----------------------------------------------------------------------------
-void StopMotionController::showEvent(QShowEvent *event) {}
+void StopMotionController::showEvent(QShowEvent *event) {
+ bool hasCanon = false;
+ bool hasWebcam = false;
+#ifdef WITH_CANON
+ m_stopMotion->m_canon->initializeCanonSDK();
+ if (!m_stopMotion->m_canon->m_sessionOpen) {
+ m_dslrFrame->hide();
+ m_alwaysUseLiveViewImagesButton->hide();
+ } else {
+ m_dslrFrame->show();
+ m_alwaysUseLiveViewImagesButton->show();
+ hasCanon = true;
+ }
+#else
+ m_dslrFrame->hide();
+ m_alwaysUseLiveViewImagesButton->hide();
+#endif
+ if (!m_stopMotion->m_usingWebcam) {
+ m_resolutionCombo->hide();
+ m_resolutionLabel->hide();
+ m_webcamFrame->hide();
+ } else {
+ hasWebcam = true;
+ m_webcamFrame->show();
+ }
+
+ if (!hasWebcam && !hasCanon) {
+ m_noCameraFrame->show();
+ } else {
+ m_noCameraFrame->hide();
+ }
+}
//-----------------------------------------------------------------------------
void StopMotionController::hideEvent(QHideEvent *event) {
- // disconnect(m_apertureCombo, SIGNAL(currentIndexChanged(int)), this,
- // SLOT(onApertureChanged(int)));
- // disconnect(m_shutterSpeedCombo, SIGNAL(currentIndexChanged(int)), this,
- // SLOT(onShutterSpeedChanged(int)));
- // disconnect(m_isoCombo, SIGNAL(currentIndexChanged(int)), this,
- // SLOT(onIsoChanged(int)));
- // disconnect(m_exposureCombo, SIGNAL(currentIndexChanged(int)), this,
- // SLOT(onExposureChanged(int)));
-
- // disconnect(m_stopMotion, SIGNAL(cameraChanged()), this,
- // SLOT(refreshCameraList()));
- // disconnect(m_stopMotion, SIGNAL(optionsChanged()), this,
- // SLOT(refreshOptionsLists()));
- // disconnect(m_stopMotion, SIGNAL(apertureOptionsChanged()), this,
- // SLOT(refreshApertureList()));
- // disconnect(m_stopMotion, SIGNAL(shutterSpeedOptionsChanged()), this,
- // SLOT(refreshShutterSpeedList()));
- // disconnect(m_stopMotion, SIGNAL(isoOptionsChanged()), this,
- // SLOT(refreshIsoList()));
- // disconnect(m_stopMotion, SIGNAL(exposureOptionsChanged()), this,
- // SLOT(refreshExposureList()));
- // disconnect(m_stopMotion, SIGNAL(modeChanged()), this, SLOT(refreshMode()));
+ // stop interval timer if it is active
+ if (m_timerCB->isChecked() && m_captureButton->isChecked()) {
+ m_captureButton->setChecked(false);
+ onCaptureButtonClicked(false);
+ }
}
-////-----------------------------------------------------------------------------
-//
-// void StopMotionController::keyPressEvent(QKeyEvent *event) {
-// // override return (or enter) key as shortcut key for capturing
-// if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
-// // show button-clicking animation followed by calling
-// // onCaptureButtonClicked()
-// m_captureButton->animateClick();
-// event->accept();
-// } else
-// event->ignore();
-//}
+//-----------------------------------------------------------------------------
+
+void StopMotionController::keyPressEvent(QKeyEvent *event) {
+ int key = event->key();
+ TFrameHandle *fh = TApp::instance()->getCurrentFrame();
+ int origFrame = fh->getFrame();
+#ifdef WITH_CANON
+ if ((m_stopMotion->m_canon->m_pickLiveViewZoom ||
+ m_stopMotion->m_canon->m_zooming) &&
+ (key == Qt::Key_Left || key == Qt::Key_Right || key == Qt::Key_Up ||
+ key == Qt::Key_Down || key == Qt::Key_2 || key == Qt::Key_4 ||
+ key == Qt::Key_6 || key == Qt::Key_8)) {
+ if (m_stopMotion->m_canon->m_liveViewZoomReadyToPick == true) {
+ if (key == Qt::Key_Left || key == Qt::Key_4) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.x -= 10;
+ }
+ if (key == Qt::Key_Right || key == Qt::Key_6) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.x += 10;
+ }
+ if (key == Qt::Key_Up || key == Qt::Key_8) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.y += 10;
+ }
+ if (key == Qt::Key_Down || key == Qt::Key_2) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.y -= 10;
+ }
+ if (m_stopMotion->m_canon->m_zooming) {
+ m_stopMotion->m_canon->setZoomPoint();
+ }
+ }
+ m_stopMotion->m_canon->calculateZoomPoint();
+ event->accept();
+ } else if (m_stopMotion->m_canon->m_pickLiveViewZoom &&
+ (key == Qt::Key_Escape || key == Qt::Key_Enter ||
+ key == Qt::Key_Return)) {
+ m_stopMotion->m_canon->toggleZoomPicking();
+ } else
+#endif
+ if (key == Qt::Key_Up || key == Qt::Key_Left) {
+ fh->prevFrame();
+ event->accept();
+ } else if (key == Qt::Key_Down || key == Qt::Key_Right) {
+ fh->nextFrame();
+ event->accept();
+ } else if (key == Qt::Key_Home) {
+ fh->firstFrame();
+ event->accept();
+ } else if (key == Qt::Key_End) {
+ fh->lastFrame();
+ event->accept();
+ } else if (key == Qt::Key_Return || key == Qt::Key_Enter) {
+ m_captureButton->animateClick();
+ event->accept();
+ }
+
+ else
+ event->ignore();
+}
//
////-----------------------------------------------------------------------------
//
@@ -1645,6 +2583,20 @@ void StopMotionController::onLiveViewToggleClicked() {
//-----------------------------------------------------------------------------
+void StopMotionController::onAlwaysUseLiveViewImagesButtonClicked() {
+ m_stopMotion->toggleAlwaysUseLiveViewImages();
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onAlwaysUseLiveViewImagesToggled(bool on) {
+ m_alwaysUseLiveViewImagesButton->blockSignals(true);
+ m_alwaysUseLiveViewImagesButton->setChecked(on);
+ m_alwaysUseLiveViewImagesButton->blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+
void StopMotionController::onLiveViewChanged(bool on) {
if (on) {
m_toggleLiveViewButton->setText(tr("Stop Live View"));
@@ -1676,7 +2628,88 @@ void StopMotionController::onOpacityChanged(int opacity) {
//-----------------------------------------------------------------------------
void StopMotionController::onCaptureButtonClicked(bool on) {
- m_stopMotion->captureImage();
+ if (m_timerCB->isChecked()) {
+ // start interval capturing
+ if (on) {
+ m_stopMotion->startInterval();
+ }
+ // stop interval capturing
+ else {
+ m_stopMotion->stopInterval();
+ }
+ }
+ // capture immediately
+ else {
+ m_stopMotion->captureImage();
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onIntervalTimerCBToggled(bool on) {
+ m_stopMotion->toggleInterval(on);
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onIntervalSliderValueChanged(bool on) {
+ m_stopMotion->setIntervalAmount(m_timerIntervalFld->getValue());
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onIntervalCaptureTimerTimeout() {
+ if (m_stopMotion->m_liveViewStatus < 1) {
+ onCaptureButtonClicked(false);
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+void StopMotionController::onIntervalCountDownTimeout() {
+ m_captureButton->setText(QString::number(
+ m_stopMotion->m_intervalTimer->isActive()
+ ? (m_stopMotion->m_intervalTimer->remainingTime() / 1000 + 1)
+ : 0));
+}
+
+//-----------------------------------------------------------------------------
+void StopMotionController::onIntervalAmountChanged(int value) {
+ m_timerIntervalFld->blockSignals(true);
+ m_timerIntervalFld->setValue(value);
+ m_timerIntervalFld->blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+void StopMotionController::onIntervalToggled(bool on) {
+ m_timerCB->blockSignals(true);
+ m_timerIntervalFld->setEnabled(on);
+ m_captureButton->setCheckable(on);
+ if (on)
+ m_captureButton->setText(tr("Start Capturing"));
+ else
+ m_captureButton->setText(tr("Capture"));
+ m_timerCB->blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+void StopMotionController::onIntervalStarted() {
+ m_captureButton->setText(tr("Stop Capturing"));
+ m_timerCB->setDisabled(true);
+ m_timerIntervalFld->setDisabled(true);
+ m_captureButton->blockSignals(true);
+ m_captureButton->setChecked(true);
+ m_captureButton->blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+void StopMotionController::onIntervalStopped() {
+ m_captureButton->setText(tr("Start Capturing"));
+ m_timerCB->setDisabled(false);
+ m_timerIntervalFld->setDisabled(false);
+ m_captureButton->blockSignals(true);
+ m_captureButton->setChecked(false);
+ m_captureButton->blockSignals(false);
}
//-----------------------------------------------------------------------------
@@ -1727,4 +2760,10 @@ void StopMotionController::onSceneSwitched() {
//-----------------------------------------------------------------------------
+void StopMotionController::serialPortChanged(int index) {
+ m_stopMotion->m_serial->setSerialPort(m_controlDeviceCombo->currentText());
+}
+
+//-----------------------------------------------------------------------------
+
void StopMotionController::updateStopMotion() {}
diff --git a/toonz/sources/stopmotion/stopmotioncontroller.h b/toonz/sources/stopmotion/stopmotioncontroller.h
index 2f66707b1..dda7ceaca 100644
--- a/toonz/sources/stopmotion/stopmotioncontroller.h
+++ b/toonz/sources/stopmotion/stopmotioncontroller.h
@@ -10,6 +10,7 @@
// TnzQt includes
#include "toonzqt/tabbar.h"
#include "toonzqt/gutil.h"
+#include "toonzqt/colorfield.h"
// Qt includes
#include <QWidget>
@@ -48,6 +49,7 @@ class QPushButton;
class QTabWidget;
class QToolBar;
class QTimer;
+class QGroupBox;
//=============================================================================
// StopMotionController
@@ -65,33 +67,50 @@ class StopMotionController final : public QWidget {
QFrame *m_mainControlsPage;
QFrame *m_cameraSettingsPage;
QFrame *m_optionsPage;
+ QFrame *m_motionPage;
+ QFrame *m_lightPage;
+ QFrame *m_dslrFrame;
+ QFrame *m_webcamFrame;
+ QFrame *m_noCameraFrame;
QStackedWidget *m_stackedChooser;
- TabBarContainter *m_tabBarContainer; //!< Tabs container for style types.
- QPushButton *m_toggleLiveViewButton, *m_setToCurrentXSheetFrameButton;
- QPushButton *m_fileFormatOptionButton, *m_captureButton, *m_zoomButton,
+ TabBarContainter *m_tabBarContainer; //!< Tabs container for pages
+ QPushButton *m_toggleLiveViewButton, *m_setToCurrentXSheetFrameButton,
+ *m_alwaysUseLiveViewImagesButton;
+ QPushButton *m_captureButton, *m_zoomButton, *m_fileFormatOptionButton,
*m_pickZoomButton, *m_focusNearButton, *m_focusFarButton,
*m_focusNear2Button, *m_focusNear3Button, *m_focusFar2Button,
- *m_focusFar3Button, *m_captureFilterSettingsBtn;
+ *m_focusFar3Button, *m_captureFilterSettingsBtn, *m_testLightsButton;
QHBoxLayout *m_focusAndZoomLayout;
QLabel *m_frameInfoLabel, *m_cameraSettingsLabel, *m_cameraModeLabel,
- *m_kelvinLabel, *m_resolutionLabel, *m_directShowLabel;
+ *m_resolutionLabel, *m_directShowLabel, *m_cameraStatusLabel,
+ *m_apertureLabel, *m_kelvinValueLabel, *m_isoLabel, *m_shutterSpeedLabel,
+ *m_webcamLabel;
QToolButton *m_previousLevelButton, *m_previousFrameButton,
*m_previousXSheetFrameButton;
-
- QComboBox *m_cameraListCombo, *m_fileTypeCombo, *m_isoCombo,
- *m_shutterSpeedCombo, *m_exposureCombo, *m_apertureCombo,
- *m_whiteBalanceCombo, *m_kelvinCombo, *m_resolutionCombo,
- *m_imageQualityCombo, *m_pictureStyleCombo;
+ QSlider *m_apertureSlider, *m_shutterSpeedSlider, *m_isoSlider,
+ *m_kelvinSlider, *m_webcamFocusSlider, *m_webcamWhiteBalanceSlider,
+ *m_webcamExposureSlider, *m_webcamBrightnessSlider,
+ *m_webcamContrastSlider, *m_webcamGainSlider, *m_webcamSaturationSlider;
+ QComboBox *m_cameraListCombo, *m_exposureCombo, *m_fileTypeCombo,
+ *m_whiteBalanceCombo, *m_resolutionCombo, *m_imageQualityCombo,
+ *m_pictureStyleCombo, *m_controlDeviceCombo;
LevelNameLineEdit *m_levelNameEdit;
QCheckBox *m_blackScreenForCapture, *m_useScaledFullSizeImages,
*m_placeOnXSheetCB, *m_directShowCB, *m_liveViewOnAllFramesCB,
- *m_useMjpgCB, *m_useNumpadCB;
+ *m_useMjpgCB, *m_useNumpadCB, *m_drawBeneathCB, *m_timerCB;
DVGui::FileField *m_saveInFileFld;
DVGui::IntLineEdit *m_xSheetFrameNumberEdit;
FrameNumberLineEdit *m_frameNumberEdit;
DVGui::IntField *m_onionOpacityFld, *m_postCaptureReviewFld,
*m_subsamplingFld;
PencilTestSaveInFolderPopup *m_saveInFolderPopup;
+ DVGui::IntField *m_timerIntervalFld;
+ DVGui::ColorField *m_screen1ColorFld, *m_screen2ColorFld, *m_screen3ColorFld;
+ QGroupBox *m_screen1Box;
+ QGroupBox *m_screen2Box;
+ QGroupBox *m_screen3Box;
+ QGroupBox *m_webcamAutoFocusGB;
+ QTimer *m_lightTestTimer;
public:
StopMotionController(QWidget *parent = 0);
@@ -99,23 +118,16 @@ public:
protected:
void updateStopMotion();
- void showEvent(QShowEvent *event);
- void hideEvent(QHideEvent *event);
+ void showEvent(QShowEvent *event) override;
+ void hideEvent(QHideEvent *event) override;
// void mousePressEvent(QMouseEvent *event) override;
// void keyPressEvent(QKeyEvent *event);
+ void keyPressEvent(QKeyEvent *event) override;
protected slots:
- void refreshCameraList();
+ void refreshCameraList(QString activeCamera = "");
void refreshCameraListCalled();
void refreshOptionsLists();
- void refreshApertureList();
- void refreshShutterSpeedList();
- void refreshIsoList();
- void refreshExposureList();
- void refreshWhiteBalanceList();
- void refreshColorTemperatureList();
- void refreshImageQualityList();
- void refreshPictureStyleList();
void onCameraListComboActivated(int index);
void onResolutionComboActivated(const QString &itemText);
void onCaptureFilterSettingsBtnPressed();
@@ -127,6 +139,7 @@ protected slots:
void onPreviousFrame();
void onNextNewLevel();
void onLastFrame();
+
void onFileTypeActivated();
void onFrameNumberChanged();
void onXSheetFrameNumberChanged();
@@ -143,12 +156,44 @@ protected slots:
void onUseDirectShowChanged(int checked);
void onLiveViewOnAllFramesChanged(int checked);
void onUseNumpadChanged(int checked);
+ void onDrawBeneathChanged(int checked);
void updateDimensions();
void onSaveInPathEdited();
void onSceneSwitched();
void onPreviousXSheetFrame();
void onNextXSheetFrame();
void setToCurrentXSheetFrame();
+
+ // motion control
+ void serialPortChanged(int);
+
+ // time lapse
+ void onIntervalTimerCBToggled(bool);
+ void onIntervalSliderValueChanged(bool);
+ void onIntervalCaptureTimerTimeout();
+ void onIntervalCountDownTimeout();
+ void onIntervalAmountChanged(int);
+ void onIntervalToggled(bool);
+ void onIntervalStarted();
+ void onIntervalStopped();
+
+ // lights and screens
+ void setScreen1Color(const TPixel32 &value, bool isDragging);
+ void setScreen2Color(const TPixel32 &value, bool isDragging);
+ void setScreen3Color(const TPixel32 &value, bool isDragging);
+ void onScreen1OverlayToggled(bool);
+ void onScreen2OverlayToggled(bool);
+ void onScreen3OverlayToggled(bool);
+ void onTestLightsPressed();
+ void onTestLightsTimeout();
+ void onScreen1ColorChanged(TPixel32);
+ void onScreen2ColorChanged(TPixel32);
+ void onScreen3ColorChanged(TPixel32);
+ void onScreen1OverlayChanged(bool);
+ void onScreen2OverlayChanged(bool);
+ void onScreen3OverlayChanged(bool);
+
+ // canon stuff
void onApertureChanged(int index);
void onShutterSpeedChanged(int index);
void onIsoChanged(int index);
@@ -157,7 +202,6 @@ protected slots:
void onColorTemperatureChanged(int index);
void onImageQualityChanged(int index);
void onPictureStyleChanged(int index);
- void refreshMode();
void onZoomPressed();
void onPickZoomPressed();
void onFocusNear();
@@ -166,6 +210,28 @@ protected slots:
void onFocusFar2();
void onFocusNear3();
void onFocusFar3();
+ void onApertureChangedSignal(QString);
+ void onIsoChangedSignal(QString);
+ void onShutterSpeedChangedSignal(QString);
+ void onExposureChangedSignal(QString);
+ void onWhiteBalanceChangedSignal(QString);
+ void onColorTemperatureChangedSignal(QString);
+ void onImageQualityChangedSignal(QString);
+ void onPictureStyleChangedSignal(QString);
+ void refreshApertureList();
+ void refreshShutterSpeedList();
+ void refreshIsoList();
+ void refreshExposureList();
+ void refreshWhiteBalanceList();
+ void refreshColorTemperatureList();
+ void refreshImageQualityList();
+ void refreshPictureStyleList();
+ void refreshMode();
+ void onFocusCheckToggled(bool on);
+ void onPickFocusCheckToggled(bool on);
+ void onAlwaysUseLiveViewImagesButtonClicked();
+ void onAlwaysUseLiveViewImagesToggled(bool);
+
void onCaptureReviewFldEdited();
void onCaptureReviewSliderChanged(bool ignore);
void onSubsamplingFldEdited();
@@ -186,18 +252,21 @@ protected slots:
void onUseDirectShowSignal(bool);
void onReviewTimeChangedSignal(int);
void onUseNumpadSignal(bool);
+ void onDrawBeneathSignal(bool);
void onLiveViewChanged(bool);
void onNewCameraSelected(int, bool);
+
+ // webcam
void onWebcamResolutionsChanged();
void onNewWebcamResolutionSelected(int);
- void onApertureChangedSignal(QString);
- void onIsoChangedSignal(QString);
- void onShutterSpeedChangedSignal(QString);
- void onExposureChangedSignal(QString);
- void onWhiteBalanceChangedSignal(QString);
- void onColorTemperatureChangedSignal(QString);
- void onImageQualityChangedSignal(QString);
- void onPictureStyleChangedSignal(QString);
+ void onWebcamAutofocusToggled(bool);
+ void onWebcamFocusSliderChanged(int value);
+ void onWebcamExposureSliderChanged(int value);
+ void onWebcamBrightnessSliderChanged(int value);
+ void onWebcamContrastSliderChanged(int value);
+ void onWebcamGainSliderChanged(int value);
+ void onWebcamSaturationSliderChanged(int value);
+ void getWebcamStatus();
public slots:
void openSaveInFolderPopup();
diff --git a/toonz/sources/stopmotion/stopmotionlight.cpp b/toonz/sources/stopmotion/stopmotionlight.cpp
new file mode 100644
index 000000000..2a949e489
--- /dev/null
+++ b/toonz/sources/stopmotion/stopmotionlight.cpp
@@ -0,0 +1,178 @@
+#include "stopmotionlight.h"
+
+#include "tenv.h"
+#include "stopmotion.h"
+
+#include <QDialog>
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QWindow>
+
+TEnv::IntVar StopMotionBlackCapture("StopMotionBlackCapture", 0);
+
+//=============================================================================
+//=============================================================================
+
+StopMotionLight::StopMotionLight() {
+ m_blackCapture = StopMotionBlackCapture;
+
+ m_fullScreen1 = new QDialog();
+ m_fullScreen1->setModal(false);
+ m_fullScreen1->setStyleSheet("background-color:black;");
+ m_screenCount = QApplication::desktop()->screenCount();
+ if (m_screenCount > 1) {
+ m_fullScreen2 = new QDialog();
+ m_fullScreen2->setModal(false);
+ m_fullScreen2->setStyleSheet("background-color:black;");
+ if (m_screenCount > 2) {
+ m_fullScreen3 = new QDialog();
+ m_fullScreen3->setModal(false);
+ m_fullScreen3->setStyleSheet("background-color:black;");
+ }
+ }
+}
+StopMotionLight::~StopMotionLight() {}
+
+//-----------------------------------------------------------------
+
+void StopMotionLight::setBlackCapture(bool on) {
+ m_blackCapture = on;
+ StopMotionBlackCapture = int(on);
+ emit(blackCaptureSignal(on));
+}
+
+//-----------------------------------------------------------------
+
+void StopMotionLight::setScreen1Color(TPixel32 color) {
+ m_screen1Color = color;
+ emit(screen1ColorChanged(color));
+}
+
+//-----------------------------------------------------------------
+
+void StopMotionLight::setScreen2Color(TPixel32 color) {
+ m_screen2Color = color;
+ emit(screen2ColorChanged(color));
+}
+
+//-----------------------------------------------------------------
+
+void StopMotionLight::setScreen3Color(TPixel32 color) {
+ m_screen3Color = color;
+ emit(screen3ColorChanged(color));
+}
+
+//-----------------------------------------------------------------
+
+void StopMotionLight::setScreen1UseOverlay(bool on) {
+ m_useScreen1Overlay = on;
+ emit(screen1OverlayChanged(on));
+}
+
+//-----------------------------------------------------------------
+
+void StopMotionLight::setScreen2UseOverlay(bool on) {
+ m_useScreen2Overlay = on;
+ emit(screen2OverlayChanged(on));
+}
+
+//-----------------------------------------------------------------
+
+void StopMotionLight::setScreen3UseOverlay(bool on) {
+ m_useScreen3Overlay = on;
+ emit(screen3OverlayChanged(on));
+}
+
+//-----------------------------------------------------------------
+
+void StopMotionLight::showOverlays() {
+ if (getBlackCapture()) {
+ m_fullScreen1->setStyleSheet("background-color: rgb(0,0,0);");
+ if (m_screenCount > 1) {
+ m_fullScreen2->setStyleSheet("background-color: rgb(0,0,0);");
+ }
+ if (m_screenCount > 2) {
+ m_fullScreen3->setStyleSheet("background-color: rgb(0,0,0);");
+ }
+ } else {
+ QString style1 = QString("background-color: rgb(%1,%2,%3);")
+ .arg(m_screen1Color.r)
+ .arg(m_screen1Color.g)
+ .arg(m_screen1Color.b);
+ m_fullScreen1->setStyleSheet(style1);
+ if (m_screenCount > 1) {
+ QString style2 = QString("background-color: rgb(%1,%2,%3);")
+ .arg(m_screen2Color.r)
+ .arg(m_screen2Color.g)
+ .arg(m_screen2Color.b);
+ m_fullScreen2->setStyleSheet(style2);
+ }
+ if (m_screenCount > 2) {
+ QString style3 = QString("background-color: rgb(%1,%2,%3);")
+ .arg(m_screen3Color.r)
+ .arg(m_screen3Color.g)
+ .arg(m_screen3Color.b);
+ m_fullScreen3->setStyleSheet(style3);
+ }
+ }
+ bool shown = false;
+ bool isTimeLapse = StopMotion::instance()->m_isTimeLapse;
+ if ((getBlackCapture() || m_useScreen1Overlay) && !isTimeLapse) {
+ m_fullScreen1->showFullScreen();
+ m_fullScreen1->setGeometry(QApplication::desktop()->screenGeometry(0));
+ shown = true;
+ }
+ if (m_screenCount > 1 && (getBlackCapture() || m_useScreen2Overlay) &&
+ !isTimeLapse) {
+ m_fullScreen2->showFullScreen();
+ m_fullScreen2->setGeometry(QApplication::desktop()->screenGeometry(1));
+ shown = true;
+ }
+ if (m_screenCount > 2 && (getBlackCapture() || m_useScreen3Overlay) &&
+ !isTimeLapse) {
+ m_fullScreen3->showFullScreen();
+ m_fullScreen3->setGeometry(QApplication::desktop()->screenGeometry(2));
+ shown = true;
+ }
+
+ if (shown) {
+ // this allows the full screen qdialogs to go full screen before
+ // taking a photo
+ qApp->processEvents(QEventLoop::AllEvents, 1500);
+ }
+ m_overlaysReady = true;
+}
+
+//-----------------------------------------------------------------
+
+void StopMotionLight::hideOverlays() {
+ if ((getBlackCapture() || m_useScreen1Overlay)) {
+#ifndef WIN32
+ m_fullScreen1->showNormal();
+#endif
+ m_fullScreen1->close();
+ m_fullScreen1->windowHandle()->close();
+ }
+ if (m_screenCount > 1 && (getBlackCapture() || m_useScreen2Overlay)) {
+#ifndef WIN32
+ m_fullScreen2->showNormal();
+#endif
+ m_fullScreen2->close();
+ m_fullScreen2->windowHandle()->close();
+ }
+ if (m_screenCount > 2 && (getBlackCapture() || m_useScreen3Overlay)) {
+#ifndef WIN32
+ m_fullScreen3->showNormal();
+#endif
+ m_fullScreen3->close();
+ m_fullScreen3->windowHandle()->close();
+ }
+ m_overlaysReady = false;
+}
+
+//-----------------------------------------------------------------
+
+bool StopMotionLight::useOverlays() {
+ return m_blackCapture || m_useScreen1Overlay || m_useScreen2Overlay ||
+ m_useScreen3Overlay;
+}
diff --git a/toonz/sources/stopmotion/stopmotionlight.h b/toonz/sources/stopmotion/stopmotionlight.h
new file mode 100644
index 000000000..3bd06a800
--- /dev/null
+++ b/toonz/sources/stopmotion/stopmotionlight.h
@@ -0,0 +1,54 @@
+#pragma once
+
+#ifndef STOPMOTIONLIGHT_H
+#define STOPMOTIONLIGHT_H
+
+#include <QObject>
+
+#include "traster.h"
+
+class QDialog;
+
+//=============================================================================
+// StopMotionLight
+//-----------------------------------------------------------------------------
+
+class StopMotionLight : public QObject {
+ Q_OBJECT
+
+public:
+ StopMotionLight();
+ ~StopMotionLight();
+
+ QDialog *m_fullScreen1, *m_fullScreen2, *m_fullScreen3;
+ bool m_useScreen1Overlay = false;
+ bool m_useScreen2Overlay = false;
+ bool m_useScreen3Overlay = false;
+ bool m_blackCapture = true;
+ bool m_overlaysReady = false;
+ int m_screenCount = 1;
+ TPixel32 m_screen1Color, m_screen2Color,
+ m_screen3Color = TPixel32(0, 0, 0, 255);
+
+ void setBlackCapture(bool on);
+ bool getBlackCapture() { return m_blackCapture; }
+ void setScreen1Color(TPixel32 color);
+ void setScreen2Color(TPixel32 color);
+ void setScreen3Color(TPixel32 color);
+ void setScreen1UseOverlay(bool on);
+ void setScreen2UseOverlay(bool on);
+ void setScreen3UseOverlay(bool on);
+ void showOverlays();
+ void hideOverlays();
+ bool useOverlays();
+
+signals:
+ void blackCaptureSignal(bool);
+ void screen1ColorChanged(TPixel32);
+ void screen2ColorChanged(TPixel32);
+ void screen3ColorChanged(TPixel32);
+ void screen1OverlayChanged(bool);
+ void screen2OverlayChanged(bool);
+ void screen3OverlayChanged(bool);
+};
+#endif // STOPMOTIONLIGHT_H
\ No newline at end of file
diff --git a/toonz/sources/stopmotion/stopmotionserial.cpp b/toonz/sources/stopmotion/stopmotionserial.cpp
new file mode 100644
index 000000000..d4fdc20d3
--- /dev/null
+++ b/toonz/sources/stopmotion/stopmotionserial.cpp
@@ -0,0 +1,106 @@
+#include "stopmotionserial.h"
+#include "stopmotion.h"
+#include <QSerialPort>
+#include <QSerialPortInfo>
+//=============================================================================
+//=============================================================================
+
+StopMotionSerial::StopMotionSerial() { m_serialPort = new QSerialPort(this); }
+StopMotionSerial::~StopMotionSerial() {}
+
+//-----------------------------------------------------------------
+
+QStringList StopMotionSerial::getAvailableSerialPorts() {
+ QList<QSerialPortInfo> list = QSerialPortInfo::availablePorts();
+ QStringList ports;
+ ports.push_back(tr("No Device"));
+ int size = list.size();
+ for (int i = 0; i < size; i++) {
+ std::string desc = list.at(i).description().toStdString();
+ std::string port = list.at(i).portName().toStdString();
+ std::string maker = list.at(i).manufacturer().toStdString();
+ ports.push_back(list.at(i).portName());
+ if (list.at(i).hasProductIdentifier()) {
+ std::string id =
+ QString::number(list.at(i).productIdentifier()).toStdString();
+ }
+ if (list.at(i).hasVendorIdentifier()) {
+ std::string id =
+ QString::number(list.at(i).vendorIdentifier()).toStdString();
+ }
+ }
+ return ports;
+}
+
+//-----------------------------------------------------------------
+
+bool StopMotionSerial::setSerialPort(QString port) {
+ if (m_serialPort->isOpen()) m_serialPort->close();
+ QList<QSerialPortInfo> list = QSerialPortInfo::availablePorts();
+ QStringList ports;
+ bool success = false;
+ int size = list.size();
+ for (int i = 0; i < size; i++) {
+ if (port == list.at(i).portName()) {
+ m_serialPort->setPort(list.at(i));
+ }
+ }
+ // m_serialPort->setBaudRate(9600);
+ bool connected = m_serialPort->open(QIODevice::ReadWrite);
+ if (connected) {
+ success = m_serialPort->setBaudRate(QSerialPort::Baud9600) &
+ m_serialPort->setParity(QSerialPort::NoParity) &
+ m_serialPort->setDataBits(QSerialPort::Data8) &
+ m_serialPort->setStopBits(QSerialPort::OneStop) &
+ m_serialPort->setFlowControl(QSerialPort::NoFlowControl);
+ std::string fNumber =
+ std::to_string(StopMotion::instance()->getXSheetFrameNumber());
+ char const* fNumberChar = fNumber.c_str();
+ m_serialPort->write(fNumberChar);
+ m_serialPort->waitForBytesWritten(10);
+ QByteArray DataReceive = m_serialPort->readLine();
+ while (m_serialPort->waitForReadyRead(30)) {
+ DataReceive += m_serialPort->readLine();
+ }
+ QByteArray response = DataReceive;
+ QString s(response);
+ std::string text = response.toStdString();
+ //}
+ }
+ return success;
+}
+
+//-----------------------------------------------------------------
+
+void StopMotionSerial::sendSerialData() {
+ if (m_serialPort->isOpen()) {
+ std::string fNumber =
+ std::to_string(StopMotion::instance()->getXSheetFrameNumber());
+ char const* fNumberChar = fNumber.c_str();
+ m_serialPort->write(fNumberChar);
+ m_serialPort->waitForBytesWritten(10);
+ QByteArray DataReceive = m_serialPort->readLine();
+ while (m_serialPort->waitForReadyRead(30)) {
+ DataReceive += m_serialPort->readLine();
+ }
+ QByteArray response = DataReceive;
+ QString s(response);
+ std::string text = response.toStdString();
+ }
+
+ // for not data sending is not implemented yet, just the frame number.
+ // These lines are here to be a reference for using column data as movement.
+ // TDoubleParam *param =
+ // TApp::instance()->getCurrentScene()->getScene()->getXsheet()->getStageObjectTree()->getStageObject(0)->getParam(TStageObject::T_X);
+ // double value =
+ // TApp::instance()->getCurrentScene()->getScene()->getXsheet()->getStageObjectTree()->getStageObject(0)->getParam(TStageObject::T_X,
+ // m_xSheetFrameNumber - 1);
+ // QString isCam =
+ // TApp::instance()->getCurrentScene()->getScene()->getXsheet()->getStageObjectTree()->getStageObject(0)->getId().isCamera()
+ // ? "yep" : "nope";
+ // std::string name =
+ // TApp::instance()->getCurrentScene()->getScene()->getXsheet()->getStageObjectTree()->getStageObject(0)->getName();
+ // TMeasure *measure =param->getMeasure();
+ // const TUnit *unit = measure->getCurrentUnit();
+ // double newValue = unit->convertTo(value);
+}
diff --git a/toonz/sources/stopmotion/stopmotionserial.h b/toonz/sources/stopmotion/stopmotionserial.h
new file mode 100644
index 000000000..ebaa6cd60
--- /dev/null
+++ b/toonz/sources/stopmotion/stopmotionserial.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#ifndef STOPMOTIONSERIAL_H
+#define STOPMOTIONSERIAL_H
+
+#include <QObject>
+
+class QSerialPort;
+
+//=============================================================================
+// StopMotionSerial
+//-----------------------------------------------------------------------------
+
+class StopMotionSerial : public QObject {
+ Q_OBJECT
+
+public:
+ StopMotionSerial();
+ ~StopMotionSerial();
+
+ QStringList m_controlBaudRates, m_serialDevices;
+
+ QSerialPort* m_serialPort;
+
+ // motion control
+ QStringList getAvailableSerialPorts();
+ bool setSerialPort(QString port);
+ void sendSerialData();
+};
+#endif // STOPMOTIONSERIAL_H
\ No newline at end of file
diff --git a/toonz/sources/stopmotion/webcam.cpp b/toonz/sources/stopmotion/webcam.cpp
new file mode 100644
index 000000000..d09de8193
--- /dev/null
+++ b/toonz/sources/stopmotion/webcam.cpp
@@ -0,0 +1,500 @@
+#include "webcam.h"
+#include "tenv.h"
+
+#ifdef WIN32
+#include <Windows.h>
+#include <mfobjects.h>
+#include <mfapi.h>
+#include <mfidl.h>
+#pragma comment(lib, "Mfplat.lib")
+#pragma comment(lib, "Mf.lib")
+#pragma comment(lib, "Mfreadwrite.lib")
+#pragma comment(lib, "mfuuid.lib")
+#pragma comment(lib, "shlwapi.lib")
+#endif
+
+#include <QCamera>
+#include <QCameraInfo>
+#include <QApplication>
+
+TEnv::IntVar StopMotionUseDirectShow("StopMotionUseDirectShow", 1);
+TEnv::IntVar StopMotionUseMjpg("StopMotionUseMjpg", 1);
+//-----------------------------------------------------------------------------
+
+Webcam::Webcam() {
+ m_useDirectShow = StopMotionUseDirectShow;
+ m_useMjpg = StopMotionUseMjpg;
+}
+
+//-----------------------------------------------------------------
+
+Webcam::~Webcam() {}
+
+//-----------------------------------------------------------------
+
+QList<QCameraInfo> Webcam::getWebcams() {
+ m_webcams.clear();
+ m_webcams = QCameraInfo::availableCameras();
+ return m_webcams;
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::setWebcam(QCamera* camera) { m_webcam = camera; }
+
+//-----------------------------------------------------------------
+
+bool Webcam::initWebcam(int index) {
+#ifdef WIN32
+ if (!m_useDirectShow) {
+ // the webcam order obtained from Qt isn't always the same order as
+ // the one obtained from OpenCV without DirectShow
+ translateIndex(index);
+ m_cvWebcam.open(m_webcamIndex);
+ } else {
+ m_webcamIndex = index;
+ m_cvWebcam.open(m_webcamIndex, cv::CAP_DSHOW);
+ }
+ if (m_cvWebcam.isOpened() == false) {
+ return false;
+ }
+#else
+ m_webcamIndex = index;
+ m_cvWebcam.open(index);
+ if (m_cvWebcam.isOpened() == false) {
+ return false;
+ }
+#endif
+ // mjpg is used by many webcams
+ // opencv runs very slow on some webcams without it.
+ if (m_useMjpg) {
+ m_cvWebcam.set(cv::CAP_PROP_FOURCC,
+ cv::VideoWriter::fourcc('m', 'j', 'p', 'g'));
+ m_cvWebcam.set(cv::CAP_PROP_FOURCC,
+ cv::VideoWriter::fourcc('M', 'J', 'P', 'G'));
+ }
+ m_cvWebcam.set(3, m_webcamWidth);
+ m_cvWebcam.set(4, m_webcamHeight);
+
+ return true;
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::releaseWebcam() { m_cvWebcam.release(); }
+
+//-----------------------------------------------------------------
+
+int Webcam::getIndexOfResolution() {
+ return m_webcamResolutions.indexOf(QSize(m_webcamWidth, m_webcamHeight));
+}
+
+//-----------------------------------------------------------------
+
+bool Webcam::getWebcamImage(TRaster32P& tempImage) {
+ bool error = false;
+ cv::Mat imgOriginal;
+ cv::Mat imgCorrected;
+
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ // mjpg is used by many webcams
+ // opencv runs very slow on some webcams without it.
+ if (m_useMjpg) {
+ m_cvWebcam.set(cv::CAP_PROP_FOURCC,
+ cv::VideoWriter::fourcc('m', 'j', 'p', 'g'));
+ m_cvWebcam.set(cv::CAP_PROP_FOURCC,
+ cv::VideoWriter::fourcc('M', 'J', 'P', 'G'));
+ }
+ m_cvWebcam.set(3, m_webcamWidth);
+ m_cvWebcam.set(4, m_webcamHeight);
+
+ if (!m_cvWebcam.isOpened()) {
+ error = true;
+ }
+ }
+
+ bool blnFrameReadSuccessfully =
+ m_cvWebcam.read(imgOriginal); // get next frame
+
+ if (!blnFrameReadSuccessfully ||
+ imgOriginal.empty()) { // if frame not read successfully
+ std::cout << "error: frame not read from webcam\n";
+ error = true; // print error message to std out
+ }
+
+ if (!error) {
+ cv::cvtColor(imgOriginal, imgCorrected, cv::COLOR_BGR2BGRA);
+ cv::flip(imgCorrected, imgCorrected, 0);
+ int width = m_cvWebcam.get(3);
+ int height = m_cvWebcam.get(4);
+ int size = imgCorrected.total() * imgCorrected.elemSize();
+
+ tempImage = TRaster32P(width, height);
+ // m_liveViewImage = TRaster32P(width, height);
+ tempImage->lock();
+ uchar* imgBuf = imgCorrected.data;
+ uchar* rawData = tempImage->getRawData();
+ memcpy(rawData, imgBuf, size);
+ tempImage->unlock();
+ }
+ if (error) {
+ return false;
+ } else {
+ return true;
+ }
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::setUseDirectShow(int state) {
+ m_useDirectShow = state;
+ StopMotionUseDirectShow = state;
+ emit(useDirectShowSignal(state));
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::setUseMjpg(bool on) {
+ m_useMjpg = on;
+ StopMotionUseMjpg = int(on);
+ emit(useMjpgSignal(on));
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::clearWebcam() {
+ m_webcamDescription = QString();
+ m_webcamDeviceName = QString();
+ m_webcamIndex = -1;
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::clearWebcamResolutions() { m_webcamResolutions.clear(); }
+
+//-----------------------------------------------------------------
+
+void Webcam::refreshWebcamResolutions() {
+ clearWebcamResolutions();
+ m_webcamResolutions = getWebcam()->supportedViewfinderResolutions();
+}
+
+//-----------------------------------------------------------------
+
+bool Webcam::getWebcamAutofocusStatus() {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return false;
+ }
+ }
+ if (m_cvWebcam.isOpened()) {
+ double value = m_cvWebcam.get(cv::CAP_PROP_AUTOFOCUS);
+ if (value > 0.0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return false;
+}
+
+//-----------------------------------------------------------------
+void Webcam::setWebcamAutofocusStatus(bool on) {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return;
+ }
+ }
+ if (m_cvWebcam.isOpened()) {
+ double value = on ? 1.0 : 0.0;
+ m_cvWebcam.set(cv::CAP_PROP_AUTOFOCUS, value);
+ value = m_cvWebcam.get(cv::CAP_PROP_AUTOFOCUS);
+ }
+}
+
+//-----------------------------------------------------------------
+int Webcam::getWebcamFocusValue() {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return 0;
+ }
+ }
+ if (m_cvWebcam.isOpened()) {
+ double value = m_cvWebcam.get(cv::CAP_PROP_FOCUS);
+ return static_cast<int>(value);
+ }
+ return 0.0;
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::setWebcamFocusValue(int value) {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return;
+ }
+ }
+ m_cvWebcam.set(cv::CAP_PROP_FOCUS, value);
+ value = m_cvWebcam.get(cv::CAP_PROP_FOCUS);
+}
+
+//-----------------------------------------------------------------
+int Webcam::getWebcamExposureValue() {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return 0;
+ }
+ }
+ if (m_cvWebcam.isOpened()) {
+ double value = m_cvWebcam.get(cv::CAP_PROP_EXPOSURE);
+ return static_cast<int>(value);
+ }
+ return 0.0;
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::setWebcamExposureValue(int value) {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return;
+ }
+ }
+ m_cvWebcam.set(cv::CAP_PROP_AUTO_EXPOSURE, 0.25);
+ m_cvWebcam.set(cv::CAP_PROP_EXPOSURE, value);
+ value = m_cvWebcam.get(cv::CAP_PROP_EXPOSURE);
+ getWebcamExposureValue();
+}
+
+//-----------------------------------------------------------------
+int Webcam::getWebcamBrightnessValue() {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return 0;
+ }
+ }
+ if (m_cvWebcam.isOpened()) {
+ double value = m_cvWebcam.get(cv::CAP_PROP_BRIGHTNESS);
+ return static_cast<int>(value);
+ }
+ return 0.0;
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::setWebcamBrightnessValue(int value) {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return;
+ }
+ }
+ m_cvWebcam.set(cv::CAP_PROP_BRIGHTNESS, value);
+ value = m_cvWebcam.get(cv::CAP_PROP_BRIGHTNESS);
+}
+
+//-----------------------------------------------------------------
+int Webcam::getWebcamContrastValue() {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return 0;
+ }
+ }
+ if (m_cvWebcam.isOpened()) {
+ double value = m_cvWebcam.get(cv::CAP_PROP_CONTRAST);
+ return static_cast<int>(value);
+ }
+ return 0.0;
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::setWebcamContrastValue(int value) {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return;
+ }
+ }
+ m_cvWebcam.set(cv::CAP_PROP_CONTRAST, value);
+ value = m_cvWebcam.get(cv::CAP_PROP_CONTRAST);
+}
+
+//-----------------------------------------------------------------
+int Webcam::getWebcamGainValue() {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return 0;
+ }
+ }
+ if (m_cvWebcam.isOpened()) {
+ double value = m_cvWebcam.get(cv::CAP_PROP_GAIN);
+ return static_cast<int>(value);
+ }
+ return 0.0;
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::setWebcamGainValue(int value) {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return;
+ }
+ }
+ m_cvWebcam.set(cv::CAP_PROP_GAIN, value);
+ value = m_cvWebcam.get(cv::CAP_PROP_GAIN);
+}
+
+//-----------------------------------------------------------------
+int Webcam::getWebcamSaturationValue() {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return 0;
+ }
+ }
+ if (m_cvWebcam.isOpened()) {
+ double value = m_cvWebcam.get(cv::CAP_PROP_SATURATION);
+ return static_cast<int>(value);
+ }
+ return 0.0;
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::setWebcamSaturationValue(int value) {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return;
+ }
+ }
+ m_cvWebcam.set(cv::CAP_PROP_SATURATION, value);
+ value = m_cvWebcam.get(cv::CAP_PROP_SATURATION);
+}
+
+//-----------------------------------------------------------------
+
+void Webcam::openSettingsWindow() {
+ if (m_cvWebcam.isOpened() == false) {
+ initWebcam(m_webcamIndex);
+
+ if (!m_cvWebcam.isOpened()) {
+ return;
+ }
+ }
+ m_cvWebcam.set(cv::CAP_PROP_SETTINGS, 1.0);
+}
+
+//-----------------------------------------------------------------
+
+bool Webcam::translateIndex(int index) {
+ // We are using Qt to get the camera info and supported resolutions, but
+ // we are using OpenCV to actually get the images.
+ // The camera index from OpenCV and from Qt don't always agree,
+ // So this checks the name against the correct index.
+ m_webcamIndex = index;
+
+#ifdef WIN32
+
+// Thanks to:
+// https://elcharolin.wordpress.com/2017/08/28/webcam-capture-with-the-media-foundation-sdk/
+// for the webcam enumeration here
+
+#define CLEAN_ATTRIBUTES() \
+ if (attributes) { \
+ attributes->Release(); \
+ attributes = NULL; \
+ } \
+ for (DWORD i = 0; i < count; i++) { \
+ if (&devices[i]) { \
+ devices[i]->Release(); \
+ devices[i] = NULL; \
+ } \
+ } \
+ CoTaskMemFree(devices); \
+ return hr;
+
+ HRESULT hr = S_OK;
+
+ // this is important!!
+ hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
+
+ UINT32 count = 0;
+ IMFAttributes* attributes = NULL;
+ IMFActivate** devices = NULL;
+
+ if (FAILED(hr)) {
+ CLEAN_ATTRIBUTES()
+ }
+ // Create an attribute store to specify enumeration parameters.
+ hr = MFCreateAttributes(&attributes, 1);
+
+ if (FAILED(hr)) {
+ CLEAN_ATTRIBUTES()
+ }
+
+ // The attribute to be requested is devices that can capture video
+ hr = attributes->SetGUID(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
+ MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID);
+ if (FAILED(hr)) {
+ CLEAN_ATTRIBUTES()
+ }
+ // Enummerate the video capture devices
+ hr = MFEnumDeviceSources(attributes, &devices, &count);
+
+ if (FAILED(hr)) {
+ CLEAN_ATTRIBUTES()
+ }
+ // if there are any available devices
+ if (count > 0) {
+ WCHAR* nameString = NULL;
+ // Get the human-friendly name of the device
+ UINT32 cchName;
+
+ for (int i = 0; i < count; i++) {
+ hr = devices[i]->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME,
+ &nameString, &cchName);
+ std::string desc = m_webcamDescription.toStdString();
+ if (nameString == m_webcamDescription.toStdWString()) {
+ m_webcamIndex = i;
+ break;
+ }
+ // devices[0]->ShutdownObject();
+ }
+
+ CoTaskMemFree(nameString);
+ }
+ // clean
+ CLEAN_ATTRIBUTES()
+#else
+ return true;
+#endif
+}
\ No newline at end of file
diff --git a/toonz/sources/stopmotion/webcam.h b/toonz/sources/stopmotion/webcam.h
new file mode 100644
index 000000000..3f1a4bd81
--- /dev/null
+++ b/toonz/sources/stopmotion/webcam.h
@@ -0,0 +1,104 @@
+#pragma once
+
+#ifndef WEBCAM_H
+#define WEBCAM_H
+
+#include "opencv2/opencv.hpp"
+
+// Toonz Includes
+#include "traster.h"
+#include "toonzqt/gutil.h"
+
+#include <QObject>
+
+class QCamera;
+class QCameraInfo;
+
+class Webcam : public QObject {
+ Q_OBJECT
+
+public:
+ Webcam();
+ ~Webcam();
+
+ void setWebcamDeviceName(QString name) { m_webcamDeviceName = name; }
+ QString getWebcamDeviceName() { return m_webcamDeviceName; }
+
+ void setWebcamDescription(QString desc) { m_webcamDescription = desc; }
+ QString getWebcamDescription() { return m_webcamDescription; }
+
+ void setWebcamIndex(int index) { m_webcamIndex = index; }
+ int getWebcamIndex() { return m_webcamIndex; }
+
+ int getWebcamWidth() { return m_webcamWidth; }
+ int getWebcamHeight() { return m_webcamHeight; }
+ void setWebcamWidth(int width) { m_webcamWidth = width; }
+ void setWebcamHeight(int height) { m_webcamHeight = height; }
+
+ void releaseWebcam();
+ void clearWebcam();
+ QList<QCameraInfo> getWebcams();
+ QCamera* getWebcam() { return m_webcam; }
+ void setWebcam(QCamera* camera);
+ bool initWebcam(int index = 0);
+ bool getWebcamImage(TRaster32P& tempImage);
+
+ bool translateIndex(int index);
+
+ QList<QSize> getWebcamResolutions() { return m_webcamResolutions; }
+ int getIndexOfResolution();
+ void clearWebcamResolutions();
+ void refreshWebcamResolutions();
+
+ void setUseMjpg(bool on);
+ bool getUseMjpg() { return m_useMjpg; }
+ bool getUseDirectShow() { return m_useDirectShow; }
+ void setUseDirectShow(int state);
+
+ bool getWebcamAutofocusStatus();
+ void setWebcamAutofocusStatus(bool on);
+
+ int getWebcamFocusValue();
+ void setWebcamFocusValue(int value);
+
+ int getWebcamExposureValue();
+ void setWebcamExposureValue(int value);
+
+ int getWebcamBrightnessValue();
+ void setWebcamBrightnessValue(int value);
+
+ int getWebcamContrastValue();
+ void setWebcamContrastValue(int value);
+
+ int getWebcamGainValue();
+ void setWebcamGainValue(int value);
+
+ int getWebcamSaturationValue();
+ void setWebcamSaturationValue(int value);
+
+ void openSettingsWindow();
+
+private:
+ // Webcam Properties
+ QList<QCameraInfo> m_webcams;
+ QCamera* m_webcam;
+ cv::VideoCapture m_cvWebcam;
+ QList<QSize> m_webcamResolutions;
+ // Webcam Public Properties
+ QString m_webcamDeviceName;
+ QString m_webcamDescription;
+ int m_webcamIndex = -1;
+ bool m_useDirectShow = true;
+ int m_webcamWidth = 0;
+ int m_webcamHeight = 0;
+ bool m_useMjpg = true;
+
+ int m_webcamFocusValue = 0;
+ bool m_webcamAutofocusStatus = true;
+
+signals:
+ void useMjpgSignal(bool);
+ void useDirectShowSignal(bool);
+};
+
+#endif // WEBCAM_H
\ No newline at end of file
diff --git a/toonz/sources/tnzcore/CMakeLists.txt b/toonz/sources/tnzcore/CMakeLists.txt
index d9b2a661f..c34f3aa82 100644
--- a/toonz/sources/tnzcore/CMakeLists.txt
+++ b/toonz/sources/tnzcore/CMakeLists.txt
@@ -354,7 +354,7 @@ elseif(BUILD_ENV_UNIXLIKE)
endif()
target_link_libraries(tnzcore
- Qt5::OpenGL Qt5::Network Qt5::Multimedia
+ Qt5::Core Qt5::OpenGL Qt5::Network Qt5::Multimedia
${GL_LIB} ${GLUT_LIB} ${QT_LIB} ${Z_LIB} ${JPEG_LIB} ${LZ4_LIB}
${EXTRA_LIBS}
)
diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txt
index 0906e39c4..7b9b27c63 100644
--- a/toonz/sources/toonz/CMakeLists.txt
+++ b/toonz/sources/toonz/CMakeLists.txt
@@ -123,20 +123,25 @@ set(MOC_HEADERS
expressionreferencemanager.h
)
-if(WITH_STOPMOTION)
-set(MOC_HEADERS
- ${MOC_HEADERS}
- ../stopmotion/stopmotion.h
- ../stopmotion/stopmotioncontroller.h
- cameracapturelevelcontrol.h
- penciltestpopup.h
-)
+if(PLATFORM EQUAL 64)
+ set(MOC_HEADERS
+ ${MOC_HEADERS}
+ ../stopmotion/stopmotion.h
+ ../stopmotion/stopmotioncontroller.h
+ ../stopmotion/webcam.h
+ ../stopmotion/jpgconverter.h
+ ../stopmotion/canon.h
+ ../stopmotion/stopmotionserial.h
+ ../stopmotion/stopmotionlight.h
+ cameracapturelevelcontrol.h
+ penciltestpopup.h
+ )
else()
-set(MOC_HEADERS
- ${MOC_HEADERS}
- cameracapturelevelcontrol_qt.h
- penciltestpopup_qt.h
-)
+ set(MOC_HEADERS
+ ${MOC_HEADERS}
+ cameracapturelevelcontrol_qt.h
+ penciltestpopup_qt.h
+ )
endif()
set(HEADERS
@@ -360,20 +365,25 @@ set(SOURCES
predict3d.cpp
)
-if(WITH_STOPMOTION)
-set(SOURCES
- ${SOURCES}
- ../stopmotion/stopmotion.cpp
- ../stopmotion/stopmotioncontroller.cpp
- cameracapturelevelcontrol.cpp
- penciltestpopup.cpp
-)
+if(PLATFORM EQUAL 64)
+ set(SOURCES
+ ${SOURCES}
+ ../stopmotion/stopmotion.cpp
+ ../stopmotion/stopmotioncontroller.cpp
+ ../stopmotion/webcam.cpp
+ ../stopmotion/jpgconverter.cpp
+ ../stopmotion/canon.cpp
+ ../stopmotion/stopmotionserial.cpp
+ ../stopmotion/stopmotionlight.cpp
+ cameracapturelevelcontrol.cpp
+ penciltestpopup.cpp
+ )
else()
-set(SOURCES
- ${SOURCES}
- cameracapturelevelcontrol_qt.cpp
- penciltestpopup_qt.cpp
-)
+ set(SOURCES
+ ${SOURCES}
+ cameracapturelevelcontrol_qt.cpp
+ penciltestpopup_qt.cpp
+ )
endif()
if(WITH_TRANSLATION)
@@ -430,19 +440,20 @@ message("Bin: " ${CMAKE_CURRENT_BINARY_DIR})
include_directories(
../../sources/toonzfarm/include
../../sources/toonzqt
+ ../../sources/stopmotion
)
-if (WITH_STOPMOTION)
-include_directories(../../sources/stopmotion)
- add_definitions(-DWITH_STOPMOTION)
+if (WITH_CANON)
+ add_definitions(-DWITH_CANON)
endif()
if(BUILD_ENV_APPLE)
include_directories(../../sources/mousedragfilter)
+ if(PLATFORM EQUAL 64)
+ include_directories(${TURBOJPEG_INCLUDE_DIRS})
+ endif()
endif()
-
-
if(BUILD_TARGET_WIN)
if(PLATFORM EQUAL 32)
include_directories(
@@ -452,19 +463,19 @@ if(BUILD_TARGET_WIN)
endif()
endif()
-if(BUILD_ENV_MSVC AND WITH_STOPMOTION)
+if(BUILD_ENV_MSVC)
+ set(EXTRA_LIBS)
+ if(PLATFORM EQUAL 64)
+ set(EXTRA_LIBS ${EXTRA_LIBS} Qt5::SerialPort ${TURBOJPEG_LIB} ${OpenCV_LIBS})
+ if(WITH_CANON)
+ set(EXTRA_LIBS ${EXTRA_LIBS} ${CANON_LIB})
+ endif()
+ endif()
target_link_libraries(OpenToonz
Qt5::WinMain Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Xml
Qt5::Script Qt5::Widgets Qt5::PrintSupport Qt5::Multimedia
${GL_LIB} ${GLUT_LIB}
- ${CANON_LIB} ${TURBOJPEG_LIB} ${OpenCV_LIBS} strmiids
- tnzcore tnzbase toonzlib colorfx tnzext image sound toonzqt tnztools tnzstdfx tfarm
- )
-elseif(BUILD_ENV_MSVC)
- target_link_libraries(OpenToonz
- Qt5::WinMain Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Xml
- Qt5::Script Qt5::Widgets Qt5::PrintSupport Qt5::Multimedia
- ${GL_LIB} ${GLUT_LIB} strmiids
+ ${EXTRA_LIBS} strmiids
tnzcore tnzbase toonzlib colorfx tnzext image sound toonzqt tnztools tnzstdfx tfarm
)
elseif(BUILD_ENV_APPLE)
@@ -474,6 +485,13 @@ elseif(BUILD_ENV_APPLE)
# 変なところにライブラリ生成するカスども
set(EXTRA_LIBS ${EXTRA_LIBS} "$<TARGET_FILE:tnzstdfx>" "$<TARGET_FILE:tfarm>")
+ set(X64ONLY_LIBS)
+ if(PLATFORM EQUAL 64)
+ set(X64ONLY_LIBS ${X64ONLY_LIBS} Qt5::SerialPort ${TURBOJPEG_LIB} ${OpenCV_LIBS})
+ if(WITH_CANON)
+ set(X64ONLY_LIBS ${X64ONLY_LIBS} ${CANON_LIB})
+ endif()
+ endif()
add_dependencies(OpenToonz tnzcore tnzbase toonzlib colorfx tnzext image sound toonzqt tnztools tnzstdfx tfarm)
@@ -481,7 +499,7 @@ elseif(BUILD_ENV_APPLE)
Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Xml
Qt5::Script Qt5::Widgets Qt5::PrintSupport Qt5::Multimedia Qt5::MultimediaWidgets
${GL_LIB} ${GLUT_LIB}
- ${COCOA_LIB} ${EXTRA_LIBS} mousedragfilter
+ ${COCOA_LIB} ${EXTRA_LIBS} ${X64ONLY_LIBS} mousedragfilter
)
elseif(BUILD_ENV_UNIXLIKE)
@@ -491,6 +509,9 @@ elseif(BUILD_ENV_UNIXLIKE)
set(EXTRA_LIBS ${EXTRA_LIBS} "$<TARGET_FILE:tnzstdfx>" "$<TARGET_FILE:tfarm>")
set(EXTRA_LIBS ${EXTRA_LIBS} ${Boost_LIBRARIES} ${OPENBLAS_LIB})
+ if(PLATFORM EQUAL 64)
+ set(EXTRA_LIBS ${EXTRA_LIBS} Qt5::SerialPort ${TURBOJPEG_LIB} ${OpenCV_LIBS})
+ endif()
if(BUILD_TARGET_WIN)
set(EXTRA_LIBS ${EXTRA_LIBS} Qt5::WinMain -lstrmiids -mwindows)
diff --git a/toonz/sources/toonz/autoinputcellnumberpopup.cpp b/toonz/sources/toonz/autoinputcellnumberpopup.cpp
index afb5ff41d..83261d292 100644
--- a/toonz/sources/toonz/autoinputcellnumberpopup.cpp
+++ b/toonz/sources/toonz/autoinputcellnumberpopup.cpp
@@ -6,7 +6,7 @@
#include "cellselection.h"
#include "columnselection.h"
-#ifdef WITH_STOPMOTION
+#if defined(x64)
#include "penciltestpopup.h"
#else
#include "penciltestpopup_qt.h"
diff --git a/toonz/sources/toonz/filebrowserpopup.cpp b/toonz/sources/toonz/filebrowserpopup.cpp
index 7183dbd23..d6f35d2e4 100644
--- a/toonz/sources/toonz/filebrowserpopup.cpp
+++ b/toonz/sources/toonz/filebrowserpopup.cpp
@@ -468,13 +468,13 @@ bool GenericSaveFilePopup::execute() {
// (yep, even if a DIFFERENT type was specified - next time do it right :P)
const QStringList &extList = m_browser->getFilterTypes();
- if (!extList.contains(QString::fromStdString(path.getType()))) {
+ if (!m_isDirectoryOnly && !extList.contains(QString::fromStdString(path.getType()))) {
path =
TFilePath(path.getWideString() + L"." + extList.first().toStdWString());
}
// Ask for user permission to overwrite if necessary
- if (TFileStatus(path).doesExist()) {
+ if (!m_isDirectoryOnly && TFileStatus(path).doesExist()) {
const QString &question =
QObject::tr("File %1 already exists.\nDo you want to overwrite it?")
.arg(toQString(path));
diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp
index dff4aed45..97e6202b0 100644
--- a/toonz/sources/toonz/mainwindow.cpp
+++ b/toonz/sources/toonz/mainwindow.cpp
@@ -1617,6 +1617,13 @@ QAction *MainWindow::createToolOptionsAction(const char *id,
//-----------------------------------------------------------------------------
+QAction *MainWindow::createStopMotionAction(const char *id, const QString &name,
+ const QString &defaultShortcut) {
+ return createAction(id, name, defaultShortcut, StopMotionCommandType);
+}
+
+//-----------------------------------------------------------------------------
+
QAction *MainWindow::createToggle(const char *id, const QString &name,
const QString &defaultShortcut,
bool startStatus, CommandType type) {
@@ -1732,6 +1739,10 @@ void MainWindow::defineActions() {
menuAct = createMenuRenderAction(MI_Preview, tr("&Preview"), "Ctrl+R");
menuAct->setIcon(createQIcon("preview"));
createMenuFileAction(MI_SoundTrack, tr("&Export Soundtrack"), "");
+#if defined(x64)
+ createStopMotionAction(MI_StopMotionExportImageSequence,
+ tr("&Export Stop Motion Image Sequence"), "");
+#endif
menuAct = createMenuRenderAction(MI_SavePreviewedFrames,
tr("&Save Previewed Frames"), "");
menuAct->setIcon(createQIcon("save_previewed_frames"));
@@ -2279,10 +2290,9 @@ void MainWindow::defineActions() {
createMenuWindowsAction(MI_OpenToolbar, tr("&Toolbar"), "");
createMenuWindowsAction(MI_OpenToolOptionBar, tr("&Tool Option Bar"), "");
createMenuWindowsAction(MI_OpenCommandToolbar, tr("&Command Bar"), "");
-#ifdef WITH_STOPMOTION
+#if defined(x64)
createMenuWindowsAction(MI_OpenStopMotionPanel, tr("&Stop Motion Controls"),
"");
-
#endif
menuAct = createMenuWindowsAction(MI_OpenLevelView, tr("&Viewer"), "");
menuAct->setIcon(createQIcon("viewer"));
@@ -2872,20 +2882,30 @@ void MainWindow::defineActions() {
ToolCommandType);
createMiscAction("A_FxSchematicToggle", tr("Toggle FX/Stage schematic"), "");
-#ifdef WITH_STOPMOTION
- createAction(MI_StopMotionCapture, tr("Capture Stop Motion Frame"), "");
- createAction(MI_StopMotionRaiseOpacity, tr("Raise Stop Motion Opacity"), "");
- createAction(MI_StopMotionLowerOpacity, tr("Lower Stop Motion Opacity"), "");
- createAction(MI_StopMotionToggleLiveView, tr("Toggle Stop Motion Live View"),
+#if defined(x64)
+ createStopMotionAction(MI_StopMotionCapture, tr("Capture Stop Motion Frame"), "");
+ createStopMotionAction(MI_StopMotionRaiseOpacity, tr("Raise Stop Motion Opacity"), "");
+ createStopMotionAction(MI_StopMotionLowerOpacity, tr("Lower Stop Motion Opacity"), "");
+ createStopMotionAction(MI_StopMotionToggleLiveView, tr("Toggle Stop Motion Live View"),
"");
- createAction(MI_StopMotionToggleZoom, tr("Toggle Stop Motion Zoom"), "");
- createAction(MI_StopMotionLowerSubsampling,
+#ifdef WITH_CANON
+ createStopMotionAction(MI_StopMotionToggleZoom, tr("Toggle Stop Motion Zoom"), "");
+ createStopMotionAction(MI_StopMotionPickFocusCheck,
+ tr("Pick Focus Check Location"), "");
+#endif // WITH_CANON
+ createStopMotionAction(MI_StopMotionLowerSubsampling,
tr("Lower Stop Motion Level Subsampling"), "");
- createAction(MI_StopMotionRaiseSubsampling,
+ createStopMotionAction(MI_StopMotionRaiseSubsampling,
tr("Raise Stop Motion Level Subsampling"), "");
- createAction(MI_StopMotionJumpToCamera, tr("Go to Stop Motion Insert Frame"),
+ createStopMotionAction(MI_StopMotionJumpToCamera, tr("Go to Stop Motion Insert Frame"),
"");
-#endif
+ createStopMotionAction(MI_StopMotionRemoveFrame,
+ tr("Remove frame before Stop Motion Camera"), "");
+ createStopMotionAction(MI_StopMotionNextFrame,
+ tr("Next Frame including Stop Motion Camera"), "");
+ createStopMotionAction(MI_StopMotionToggleUseLiveViewImages,
+ tr("Show original live view images."), "");
+#endif // x64
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/toonz/mainwindow.h b/toonz/sources/toonz/mainwindow.h
index 564310564..672637cb6 100644
--- a/toonz/sources/toonz/mainwindow.h
+++ b/toonz/sources/toonz/mainwindow.h
@@ -273,6 +273,8 @@ private:
const char *defaultShortcut);
QAction *createToolOptionsAction(const char *id, const QString &name,
const QString &defaultShortcut);
+ QAction *createStopMotionAction(const char *id, const QString &name,
+ const QString &defaultShortcut);
protected slots:
void onCurrentRoomChanged(int newRoomIndex);
diff --git a/toonz/sources/toonz/menubar.cpp b/toonz/sources/toonz/menubar.cpp
index d061b4448..ab47897a2 100644
--- a/toonz/sources/toonz/menubar.cpp
+++ b/toonz/sources/toonz/menubar.cpp
@@ -1105,6 +1105,9 @@ QMenuBar *StackedMenuBar::createFullMenuBar() {
{
addMenuItem(exportMenu, MI_SoundTrack);
addMenuItem(exportMenu, MI_ExportXDTS);
+#if defined(x64)
+ addMenuItem(exportMenu, MI_StopMotionExportImageSequence);
+#endif
}
fileMenu->addSeparator();
addMenuItem(fileMenu, MI_PrintXsheet);
@@ -1417,7 +1420,7 @@ QMenuBar *StackedMenuBar::createFullMenuBar() {
addMenuItem(windowsMenu, MI_OpenTMessage);
addMenuItem(windowsMenu, MI_OpenHistoryPanel);
addMenuItem(windowsMenu, MI_AudioRecording);
-#ifdef WITH_STOPMOTION
+#if defined(x64)
addMenuItem(windowsMenu, MI_OpenStopMotionPanel);
#endif
addMenuItem(windowsMenu, MI_StartupPopup);
diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.h
index 813aa1500..dd2e7d20b 100644
--- a/toonz/sources/toonz/menubarcommandids.h
+++ b/toonz/sources/toonz/menubarcommandids.h
@@ -421,9 +421,14 @@
#define MI_StopMotionLowerOpacity "MI_StopMotionLowerOpacity"
#define MI_StopMotionToggleLiveView "MI_StopMotionToggleLiveView"
#define MI_StopMotionToggleZoom "MI_StopMotionToggleZoom"
+#define MI_StopMotionToggleUseLiveViewImages "MI_StopMotionToggleUseLiveViewImages"
#define MI_StopMotionLowerSubsampling "MI_StopMotionLowerSubsampling"
#define MI_StopMotionRaiseSubsampling "MI_StopMotionRaiseSubsampling"
#define MI_StopMotionJumpToCamera "MI_StopMotionJumpToCamera"
+#define MI_StopMotionPickFocusCheck "MI_StopMotionPickFocusCheck"
+#define MI_StopMotionExportImageSequence "MI_StopMotionExportImageSequence"
+#define MI_StopMotionRemoveFrame "MI_StopMotionRemoveFrame"
+#define MI_StopMotionNextFrame "MI_StopMotionNextFrame"
#define MI_OpenOnlineManual "MI_OpenOnlineManual"
#define MI_OpenWhatsNew "MI_OpenWhatsNew"
diff --git a/toonz/sources/toonz/penciltestpopup.cpp b/toonz/sources/toonz/penciltestpopup.cpp
index 899065087..ebabc132f 100644
--- a/toonz/sources/toonz/penciltestpopup.cpp
+++ b/toonz/sources/toonz/penciltestpopup.cpp
@@ -1283,7 +1283,11 @@ PencilTestPopup::PencilTestPopup()
m_captureButton = new QPushButton(tr("Capture\n[Return key]"), this);
QPushButton* closeButton = new QPushButton(tr("Close"), this);
+#ifdef WIN32
m_captureFilterSettingsBtn = new QPushButton(this);
+#else
+ m_captureFilterSettingsBtn = nullptr;
+#endif
QPushButton* subfolderButton = new QPushButton(tr("Subfolder"), this);
@@ -1341,13 +1345,14 @@ PencilTestPopup::PencilTestPopup()
QCommonStyle style;
m_captureButton->setIcon(style.standardIcon(QStyle::SP_DialogOkButton));
m_captureButton->setIconSize(QSize(30, 30));
-
- m_captureFilterSettingsBtn->setObjectName("GearButton");
- m_captureFilterSettingsBtn->setFixedSize(24, 24);
- m_captureFilterSettingsBtn->setIconSize(QSize(16, 16));
- m_captureFilterSettingsBtn->setIcon(createQIcon("gear"));
- m_captureFilterSettingsBtn->setToolTip(tr("Options"));
- m_captureFilterSettingsBtn->setMenu(createOptionsMenu());
+ if (m_captureFilterSettingsBtn) {
+ m_captureFilterSettingsBtn->setObjectName("GearButton");
+ m_captureFilterSettingsBtn->setFixedSize(24, 24);
+ m_captureFilterSettingsBtn->setIconSize(QSize(16, 16));
+ m_captureFilterSettingsBtn->setIcon(createQIcon("gear"));
+ m_captureFilterSettingsBtn->setToolTip(tr("Options"));
+ m_captureFilterSettingsBtn->setMenu(createOptionsMenu());
+ }
subfolderButton->setObjectName("SubfolderButton");
subfolderButton->setIconSize(QSize(16, 16));
@@ -1929,6 +1934,7 @@ void PencilTestPopup::onTimeout() { getWebcamImage(); }
//-----------------------------------------------------------------------------
int PencilTestPopup::translateIndex(int camIndex) {
+#ifdef WIN32
// We are using Qt to get the camera info and supported resolutions, but
// we are using OpenCV to actually get the images.
// The camera index from OpenCV and from Qt don't always agree,
@@ -2004,6 +2010,8 @@ int PencilTestPopup::translateIndex(int camIndex) {
}
// clean
CLEAN_ATTRIBUTES()
+#endif // WIN32
+ return camIndex;
}
//-----------------------------------------------------------------------------
@@ -2016,6 +2024,7 @@ void PencilTestPopup::getWebcamImage() {
if (m_cvWebcam.isOpened() == false) {
if (m_cameraListCombo->currentIndex() <= 0) return;
int camIndex = m_cameraListCombo->currentIndex() - 1;
+#ifdef WIN32
if (!m_useDirectShow) {
// the webcam order obtained from Qt isn't always the same order as
// the one obtained from OpenCV without DirectShow
@@ -2023,6 +2032,9 @@ void PencilTestPopup::getWebcamImage() {
} else {
m_cvWebcam.open(camIndex, cv::CAP_DSHOW);
}
+#else
+ m_cvWebcam.open(translateIndex(camIndex));
+#endif
// mjpg is used by many webcams
// opencv runs very slow on some webcams without it.
if (m_useMjpg) {
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index cf4e81519..48e9dbc36 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -11,7 +11,9 @@
#include "menubarcommandids.h"
#include "ruler.h"
#include "locatorpopup.h"
+#if defined(x64)
#include "../stopmotion/stopmotion.h"
+#endif
// TnzTools includes
#include "tools/cursors.h"
@@ -781,7 +783,7 @@ SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent)
, m_isBusyOnTabletMove(false) {
m_visualSettings.m_sceneProperties =
TApp::instance()->getCurrentScene()->getScene()->getProperties();
-#ifdef WITH_STOPMOTION
+#if defined(x64)
m_stopMotion = StopMotion::instance();
#endif
// Enables multiple key input.
@@ -1065,13 +1067,14 @@ void SceneViewer::showEvent(QShowEvent *) {
ret = ret &&
connect(app, SIGNAL(tabletLeft()), this, SLOT(resetTabletStatus()));
-
+#if defined(x64)
if (m_stopMotion) {
ret = ret && connect(m_stopMotion, SIGNAL(newLiveViewImageReady()), this,
SLOT(onNewStopMotionImageReady()));
ret = ret && connect(m_stopMotion, SIGNAL(liveViewStopped()), this,
SLOT(onStopMotionLiveViewStopped()));
}
+#endif
assert(ret);
if (m_hRuler && m_vRuler) {
@@ -1130,12 +1133,14 @@ void SceneViewer::hideEvent(QHideEvent *) {
disconnect(app, SIGNAL(tabletLeft()), this, SLOT(resetTabletStatus()));
+#if defined(x64)
if (m_stopMotion) {
disconnect(m_stopMotion, SIGNAL(newImageReady()), this,
SLOT(onNewStopMotionImageReady()));
disconnect(m_stopMotion, SIGNAL(liveViewStopped()), this,
SLOT(onStopMotionLiveViewStopped()));
}
+#endif
// hide locator
if (m_locator && m_locator->isVisible()) m_locator->hide();
@@ -1157,42 +1162,40 @@ int SceneViewer::getHGuideCount() {
double SceneViewer::getVGuide(int index) { return m_vRuler->getGuide(index); }
double SceneViewer::getHGuide(int index) { return m_hRuler->getGuide(index); }
+#if defined(x64)
//-----------------------------------------------------------------------------
void SceneViewer::onNewStopMotionImageReady() {
-#ifdef WITH_STOPMOTION
if (m_stopMotion->m_hasLineUpImage) {
// if (m_hasStopMotionLineUpImage) delete m_stopMotionLineUpImage;
- // is there a way to do this without cloning the image twice?
- // TRasterImageP image = m_stopMotion->m_lineUpImage->clone();
m_stopMotionLineUpImage =
(TRasterImageP)m_stopMotion->m_lineUpImage->clone();
- // m_stopMotionLineUpImage = (TRasterImage *)image->cloneImage();
m_stopMotionLineUpImage->setDpi(m_stopMotion->m_liveViewDpi.x,
m_stopMotion->m_liveViewDpi.y);
m_hasStopMotionLineUpImage = true;
}
if (m_stopMotion->m_hasLiveViewImage) {
// if (m_hasStopMotionImage) delete m_stopMotionImage;
- // is there a way to do this without cloning the image twice?
- // TRasterImageP image = m_stopMotion->m_liveViewImage->clone();
m_stopMotionImage = m_stopMotion->m_liveViewImage->clone();
- // m_stopMotionImage = (TRasterImage *)image->cloneImage();
m_stopMotionImage->setDpi(m_stopMotion->m_liveViewDpi.x,
m_stopMotion->m_liveViewDpi.y);
m_hasStopMotionImage = true;
- if (m_stopMotion->m_pickLiveViewZoom) {
+ if (m_stopMotion->m_canon->m_pickLiveViewZoom) {
setToolCursor(this, ToolCursor::ZoomCursor);
}
onSceneChanged();
}
-#endif
}
//-----------------------------------------------------------------------------
-void SceneViewer::onStopMotionLiveViewStopped() { onSceneChanged(); }
+void SceneViewer::onStopMotionLiveViewStopped() {
+ m_hasStopMotionImage = false;
+ m_hasStopMotionLineUpImage = false;
+ onSceneChanged();
+}
+#endif //x64
//-----------------------------------------------------------------------------
void SceneViewer::onPreferenceChanged(const QString &prefName) {
@@ -1624,6 +1627,41 @@ void SceneViewer::drawOverlay() {
}
}
+#ifdef WITH_CANON
+ if (m_stopMotion->m_liveViewStatus == StopMotion::LiveViewOpen &&
+ app->getCurrentFrame()->getFrame() ==
+ m_stopMotion->getXSheetFrameNumber() - 1) {
+ int x0, x1, y0, y1;
+ rect().getCoords(&x0, &y0, &x1, &y1);
+ x0 = (-(x1 / 2)) + 15;
+ y0 = ((y1 / 2)) - 15;
+ tglDrawDisk(TPointD(x0, y0), 10);
+ }
+
+ // draw Stop Motion Zoom Box
+ if (m_stopMotion->m_liveViewStatus == 2 &&
+ m_stopMotion->m_canon->m_pickLiveViewZoom) {
+ glPushMatrix();
+ tglMultMatrix(m_drawCameraAff);
+ m_pixelSize = sqrt(tglGetPixelSize2()) * getDevPixRatio();
+ TRect rect = m_stopMotion->m_canon->m_zoomRect;
+
+ glColor3d(1.0, 0.0, 0.0);
+
+ // border
+ glBegin(GL_LINE_STRIP);
+ glVertex2d(rect.x0, rect.y0);
+ glVertex2d(rect.x0, rect.y1 - m_pixelSize);
+ glVertex2d(rect.x1 - m_pixelSize, rect.y1 - m_pixelSize);
+ glVertex2d(rect.x1 - m_pixelSize, rect.y0);
+ glVertex2d(rect.x0, rect.y0);
+ glEnd();
+
+ glPopMatrix();
+ }
+
+#endif
+
// safe area
if (safeAreaToggle.getStatus() && m_drawEditingLevel == false &&
!is3DView()) {
@@ -2000,31 +2038,65 @@ void SceneViewer::drawScene() {
args.m_guidedFrontStroke = guidedFrontStroke;
args.m_guidedBackStroke = guidedBackStroke;
- Stage::visit(painter, args);
- }
-
-#ifdef WITH_STOPMOTION
- if (!frameHandle->isPlaying() && m_stopMotion->m_liveViewStatus == 2) {
- if (m_hasStopMotionLineUpImage && m_stopMotion->m_showLineUpImage) {
- Stage::Player smPlayer;
- double dpiX, dpiY;
- m_stopMotionLineUpImage->getDpi(dpiX, dpiY);
- smPlayer.m_dpiAff = TScale(Stage::inch / dpiX, Stage::inch / dpiY);
- smPlayer.m_opacity = 255;
- painter.onRasterImage(m_stopMotionLineUpImage.getPointer(), smPlayer);
- }
- if (m_hasStopMotionImage) {
- Stage::Player smPlayer;
- double dpiX, dpiY;
- m_stopMotionImage->getDpi(dpiX, dpiY);
- smPlayer.m_dpiAff = TScale(Stage::inch / dpiX, Stage::inch / dpiY);
- bool hide_opacity =
- m_stopMotion->m_zooming || m_stopMotion->m_pickLiveViewZoom;
- smPlayer.m_opacity = hide_opacity ? 255.0 : m_stopMotion->getOpacity();
- painter.onRasterImage(m_stopMotionImage.getPointer(), smPlayer);
+#if defined(x64)
+ if (m_stopMotion->m_alwaysUseLiveViewImages &&
+ m_stopMotion->m_liveViewStatus > 0 &&
+ frame != m_stopMotion->getXSheetFrameNumber() - 1 &&
+ m_hasStopMotionImage && !m_stopMotion->m_reviewTimer->isActive()) {
+ TRaster32P image;
+ bool hasImage = m_stopMotion->loadLiveViewImage(frame, image);
+ if (hasImage) {
+ Stage::Player smPlayer;
+ double dpiX, dpiY;
+ m_stopMotionImage->getDpi(dpiX, dpiY);
+ smPlayer.m_dpiAff = TScale(Stage::inch / dpiX, Stage::inch / dpiY);
+ smPlayer.m_opacity = 255;
+ smPlayer.m_sl = m_stopMotion->m_sl;
+ args.m_liveViewImage = static_cast<TRasterImageP>(image);
+ args.m_liveViewPlayer = smPlayer;
+ // painter.onRasterImage(static_cast<TRasterImageP>(image).getPointer(),
+ // smPlayer);
+ }
}
- }
+ if (//!m_stopMotion->m_drawBeneathLevels &&
+ m_stopMotion->m_liveViewStatus == 2 &&
+ ( //! frameHandle->isPlaying() ||
+ frame == m_stopMotion->getXSheetFrameNumber() - 1)) {
+ if (m_hasStopMotionLineUpImage && m_stopMotion->m_showLineUpImage) {
+ Stage::Player smPlayer;
+ double dpiX, dpiY;
+ m_stopMotionLineUpImage->getDpi(dpiX, dpiY);
+ smPlayer.m_dpiAff = TScale(Stage::inch / dpiX, Stage::inch / dpiY);
+ smPlayer.m_opacity = 255;
+ smPlayer.m_sl = m_stopMotion->m_sl;
+ args.m_lineupImage = m_stopMotionLineUpImage;
+ args.m_lineupPlayer = smPlayer;
+ // painter.onRasterImage(m_stopMotionLineUpImage.getPointer(),
+ // smPlayer);
+ }
+ if (m_hasStopMotionImage) {
+ Stage::Player smPlayer;
+ double dpiX, dpiY;
+ m_stopMotionImage->getDpi(dpiX, dpiY);
+ smPlayer.m_dpiAff = TScale(Stage::inch / dpiX, Stage::inch / dpiY);
+ bool hide_opacity = false;
+#ifdef WITH_CANON
+ hide_opacity = m_stopMotion->m_canon->m_zooming ||
+ m_stopMotion->m_canon->m_pickLiveViewZoom ||
+ !m_hasStopMotionLineUpImage;
#endif
+ smPlayer.m_opacity =
+ hide_opacity ? 255.0 : m_stopMotion->getOpacity();
+ smPlayer.m_sl = m_stopMotion->m_sl;
+ args.m_liveViewImage = m_stopMotionImage;
+ args.m_liveViewPlayer = smPlayer;
+ // painter.onRasterImage(m_stopMotionImage.getPointer(), smPlayer);
+ }
+ }
+#endif //x64
+ Stage::visit(painter, args);
+ }
+
assert(glGetError() == 0);
painter.flushRasterImages();
diff --git a/toonz/sources/toonz/sceneviewer.h b/toonz/sources/toonz/sceneviewer.h
index 6b6311b7a..df62cdc15 100644
--- a/toonz/sources/toonz/sceneviewer.h
+++ b/toonz/sources/toonz/sceneviewer.h
@@ -145,11 +145,12 @@ class SceneViewer final : public GLWidgetForHighDpi,
TRaster32P m_3DSideL;
TRaster32P m_3DSideR;
TRaster32P m_3DTop;
+#if defined(x64)
TRasterImageP m_stopMotionImage, m_stopMotionLineUpImage;
StopMotion *m_stopMotion = NULL;
bool m_hasStopMotionImage = false;
bool m_hasStopMotionLineUpImage = false;
-
+#endif
TPointD m_sideRasterPos;
TPointD m_topRasterPos;
QString m_toolDisableReason;
@@ -444,8 +445,10 @@ public slots:
void releaseBusyOnTabletMove() { m_isBusyOnTabletMove = false; }
void onContextAboutToBeDestroyed();
+#if defined(x64)
void onNewStopMotionImageReady();
void onStopMotionLiveViewStopped();
+#endif
void onPreferenceChanged(const QString &prefName);
signals:
diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp
index cfb52b7da..e7fb90c68 100644
--- a/toonz/sources/toonz/sceneviewerevents.cpp
+++ b/toonz/sources/toonz/sceneviewerevents.cpp
@@ -17,7 +17,7 @@
#include "locatorpopup.h"
#include "cellselection.h"
-#ifdef WITH_STOPMOTION
+#if defined(x64)
#include "stopmotion.h"
#endif
@@ -574,6 +574,15 @@ void SceneViewer::onMove(const TMouseEvent &event) {
TPointD worldPos = winToWorld(curPos);
TPointD pos = tool->getMatrix().inv() * worldPos;
+#ifdef WITH_CANON
+ // grab screen picking for stop motion live view zoom
+ if ((event.buttons() & Qt::LeftButton) &&
+ StopMotion::instance()->m_canon->m_pickLiveViewZoom) {
+ StopMotion::instance()->m_canon->makeZoomPoint(pos);
+ return;
+ }
+#endif
+
if (m_locator) {
m_locator->onChangeViewAff(worldPos);
}
@@ -610,8 +619,8 @@ void SceneViewer::onMove(const TMouseEvent &event) {
}
if (!cursorSet) setToolCursor(this, tool->getCursorId());
-#ifdef WITH_STOPMOTION
- if (StopMotion::instance()->m_pickLiveViewZoom)
+#ifdef WITH_CANON
+ if (StopMotion::instance()->m_canon->m_pickLiveViewZoom)
setToolCursor(this, ToolCursor::ZoomCursor);
#endif
m_pos = curPos;
@@ -756,13 +765,11 @@ void SceneViewer::onPress(const TMouseEvent &event) {
pos.y /= m_dpiScale.y;
}
-#ifdef WITH_STOPMOTION
+#ifdef WITH_CANON
// grab screen picking for stop motion live view zoom
- if (StopMotion::instance()->m_pickLiveViewZoom) {
- StopMotion::instance()->m_pickLiveViewZoom = false;
- StopMotion::instance()->makeZoomPoint(pos);
- if (tool) setToolCursor(this, tool->getCursorId());
- if (m_mouseButton != Qt::RightButton) return;
+ if (StopMotion::instance()->m_canon->m_pickLiveViewZoom) {
+ StopMotion::instance()->m_canon->makeZoomPoint(pos);
+ return;
}
#endif
@@ -1350,6 +1357,52 @@ void SceneViewer::keyPressEvent(QKeyEvent *event) {
if (m_freezedStatus != NO_FREEZED) return;
int key = event->key();
+
+#ifdef WITH_CANON
+ if ((m_stopMotion->m_canon->m_pickLiveViewZoom ||
+ m_stopMotion->m_canon->m_zooming) &&
+ (key == Qt::Key_Left || key == Qt::Key_Right || key == Qt::Key_Up ||
+ key == Qt::Key_Down || key == Qt::Key_2 || key == Qt::Key_4 ||
+ key == Qt::Key_6 || key == Qt::Key_8)) {
+ if (m_stopMotion->m_canon->m_liveViewZoomReadyToPick == true) {
+ if (key == Qt::Key_Left || key == Qt::Key_4) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.x -= 10;
+ }
+ if (key == Qt::Key_Right || key == Qt::Key_6) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.x += 10;
+ }
+ if (key == Qt::Key_Up || key == Qt::Key_8) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.y += 10;
+ }
+ if (key == Qt::Key_Down || key == Qt::Key_2) {
+ m_stopMotion->m_canon->m_liveViewZoomPickPoint.y -= 10;
+ }
+ if (m_stopMotion->m_canon->m_zooming) {
+ m_stopMotion->m_canon->setZoomPoint();
+ }
+ }
+ m_stopMotion->m_canon->calculateZoomPoint();
+ event->accept();
+ return;
+ }
+ else if (m_stopMotion->m_canon->m_pickLiveViewZoom &&
+ (key == Qt::Key_Escape || key == Qt::Key_Enter ||
+ key == Qt::Key_Return)) {
+ m_stopMotion->m_canon->toggleZoomPicking();
+ event->accept();
+ return;
+ }
+ else
+#endif
+#if defined(x64)
+ if (m_stopMotion->m_liveViewStatus == 2 &&
+ (key == Qt::Key_Enter || key == Qt::Key_Return)) {
+ m_stopMotion->captureImage();
+ event->accept();
+ return;
+ }
+#endif
+
// resolving priority and tool-specific key events in this lambda
auto ret = [&]() -> bool {
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
diff --git a/toonz/sources/toonz/shortcutpopup.cpp b/toonz/sources/toonz/shortcutpopup.cpp
index e79c4b470..24178ec61 100644
--- a/toonz/sources/toonz/shortcutpopup.cpp
+++ b/toonz/sources/toonz/shortcutpopup.cpp
@@ -230,6 +230,7 @@ ShortcutTree::ShortcutTree(QWidget *parent) : QTreeWidget(parent) {
addFolder(tr("Tools"), ToolCommandType);
addFolder(tr("Tool Modifiers"), ToolModifierCommandType);
+ addFolder(tr("Stop Motion"), StopMotionCommandType);
addFolder(tr("Visualization"), ZoomCommandType);
addFolder(tr("Misc"), MiscCommandType);
addFolder(tr("RGBA Channels"), RGBACommandType);
diff --git a/toonz/sources/toonz/tpanels.cpp b/toonz/sources/toonz/tpanels.cpp
index 48c427cb6..994ae532b 100644
--- a/toonz/sources/toonz/tpanels.cpp
+++ b/toonz/sources/toonz/tpanels.cpp
@@ -28,7 +28,7 @@
#include "expressionreferencemanager.h"
-#ifdef WITH_STOPMOTION
+#if defined(x64)
#include "stopmotioncontroller.h"
#endif
@@ -1353,7 +1353,6 @@ public:
panel->setObjectName(getPanelType());
panel->setWindowTitle(QObject::tr("Viewer"));
panel->setMinimumSize(220, 280);
- // panel->resize(700, 600);
return panel;
}
void initialize(TPanel *panel) override { assert(0); }
@@ -1405,7 +1404,7 @@ OpenFloatingPanel openHistoryPanelCommand(MI_OpenHistoryPanel, "HistoryPanel",
QObject::tr("History"));
//=============================================================================
-#ifdef WITH_STOPMOTION
+#if defined(x64)
//=============================================================================
// StopMotion Controller
//-----------------------------------------------------------------------------
@@ -1431,7 +1430,7 @@ OpenFloatingPanel openStopMotionPanelCommand(
QObject::tr("Stop Motion Controller"));
//-----------------------------------------------------------------------------
-#endif
+#endif // x64
//=============================================================================
// FxSettings
diff --git a/toonz/sources/toonz/xshrowviewer.cpp b/toonz/sources/toonz/xshrowviewer.cpp
index 3813afdfc..088741b9b 100644
--- a/toonz/sources/toonz/xshrowviewer.cpp
+++ b/toonz/sources/toonz/xshrowviewer.cpp
@@ -12,7 +12,9 @@
#include "cellselection.h"
#include "menubarcommandids.h"
#include "toonzqt/menubarcommand.h"
+#if defined(x64)
#include "../stopmotion/stopmotion.h"
+#endif
#include "toonz/toonzscene.h"
#include "tconvert.h"
@@ -371,7 +373,7 @@ void RowArea::drawCurrentRowGadget(QPainter &p, int r0, int r1) {
p.fillRect(header, m_viewer->getCurrentRowBgColor());
}
-#ifdef WITH_STOPMOTION
+#if defined(x64)
//-----------------------------------------------------------------------------
void RowArea::drawStopMotionCameraIndicator(QPainter &p) {
@@ -874,12 +876,11 @@ void RowArea::paintEvent(QPaintEvent *event) {
// current frame
drawCurrentRowGadget(p, r0, r1);
-#ifdef WITH_STOPMOTION
+#if defined(x64)
StopMotion *stopMotion = StopMotion::instance();
if (stopMotion->getPlaceOnXSheet() && (stopMotion->m_liveViewStatus > 0)) {
drawStopMotionCameraIndicator(p);
}
-
#endif
if (TApp::instance()->getCurrentFrame()->isEditingScene() &&
diff --git a/toonz/sources/toonz/xshrowviewer.h b/toonz/sources/toonz/xshrowviewer.h
index 3bf9763ff..67c664c31 100644
--- a/toonz/sources/toonz/xshrowviewer.h
+++ b/toonz/sources/toonz/xshrowviewer.h
@@ -55,7 +55,7 @@ class RowArea final : public QWidget {
void drawCurrentTimeLine(QPainter &p);
void drawShiftTraceMarker(QPainter &p);
-#ifdef WITH_STOPMOTION
+#if defined(x64)
void drawStopMotionCameraIndicator(QPainter &p);
#endif
diff --git a/toonz/sources/toonzlib/stage.cpp b/toonz/sources/toonzlib/stage.cpp
index f35967577..59feba47d 100644
--- a/toonz/sources/toonzlib/stage.cpp
+++ b/toonz/sources/toonzlib/stage.cpp
@@ -212,6 +212,13 @@ public:
const ImagePainter::VisualSettings *m_vs;
+#if defined(x64)
+ TRasterImageP m_liveViewImage;
+ TRasterImageP m_lineupImage;
+ Stage::Player m_liveViewPlayer;
+ Stage::Player m_lineupPlayer;
+#endif
+
public:
StageBuilder();
virtual ~StageBuilder();
@@ -361,7 +368,29 @@ void StageBuilder::addCell(PlayerSet &players, ToonzScene *scene, TXsheet *xsh,
TXshCell cell = xsh->getCell(row, col);
TXshLevel *xl = cell.m_level.getPointer();
+
+#if defined(x64)
+ // check the previous row for a stop motion layer
+ if (!xl) {
+ if (!m_liveViewImage) return;
+ cell = xsh->getCell(row - 1, col);
+ xl = cell.m_level.getPointer();
+ if (!xl) {
+ return;
+ }
+ else {
+ xl = cell.m_level.getPointer();
+ TXshSimpleLevel *sl = xl->getSimpleLevel();
+ if (sl && sl == m_liveViewPlayer.m_sl) {
+ row -= 1;
+ }
+ else
+ return;
+ }
+ }
+#else
if (!xl) return;
+#endif
ZPlacement cameraPlacement;
if (m_subXSheetStack.empty())
@@ -815,6 +844,7 @@ void StageBuilder::visit(PlayerSet &players, Visitor &visitor, bool isPlaying) {
std::vector<int> masks;
int m = players.size();
int h = 0;
+ bool stopMotionShown = false;
for (; h < m; h++) {
Player &player = players[h];
unsigned int i = 0;
@@ -838,7 +868,37 @@ void StageBuilder::visit(PlayerSet &players, Visitor &visitor, bool isPlaying) {
}
}
player.m_isPlaying = isPlaying;
+
+#if defined(x64)
+ if (m_liveViewImage && player.m_sl == m_liveViewPlayer.m_sl) {
+ if (m_lineupImage) {
+ m_lineupPlayer.m_sl = NULL;
+ visitor.onRasterImage(m_lineupImage.getPointer(), m_lineupPlayer);
+ stopMotionShown = true;
+ }
+ if (m_liveViewImage) {
+ m_liveViewPlayer.m_sl = NULL;
+ visitor.onRasterImage(m_liveViewImage.getPointer(), m_liveViewPlayer);
+ stopMotionShown = true;
+ }
+ }
+ else {
+ visitor.onImage(player);
+ }
+ }
+ if (!stopMotionShown && (m_liveViewImage || m_lineupImage)) {
+ if (m_lineupImage) {
+ m_lineupPlayer.m_sl = NULL;
+ visitor.onRasterImage(m_lineupImage.getPointer(), m_lineupPlayer);
+ }
+ if (m_liveViewImage) {
+ m_liveViewPlayer.m_sl = NULL;
+ visitor.onRasterImage(m_liveViewImage.getPointer(), m_liveViewPlayer);
+ }
+#else
visitor.onImage(player);
+#endif
+
}
// vale solo per TAB pro
for (h = 0; h < (int)masks.size(); h++) visitor.disableMask();
@@ -877,6 +937,16 @@ void Stage::visit(Visitor &visitor, const VisitArgs &args) {
sb.m_isGuidedDrawingEnabled = args.m_isGuidedDrawingEnabled;
sb.m_guidedFrontStroke = args.m_guidedFrontStroke;
sb.m_guidedBackStroke = args.m_guidedBackStroke;
+#if defined(x64)
+ if (args.m_liveViewImage) {
+ sb.m_liveViewImage = args.m_liveViewImage;
+ sb.m_liveViewPlayer = args.m_liveViewPlayer;
+ }
+ if (args.m_lineupImage) {
+ sb.m_lineupImage = args.m_lineupImage;
+ sb.m_lineupPlayer = args.m_lineupPlayer;
+ }
+#endif
Player::m_onionSkinFrontSize = 0;
Player::m_onionSkinBackSize = 0;
Player::m_firstFrontOnionSkin = 0;
diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp
index 6bc50d586..99423db4a 100644
--- a/toonz/sources/toonzlib/txshsimplelevel.cpp
+++ b/toonz/sources/toonzlib/txshsimplelevel.cpp
@@ -1461,7 +1461,7 @@ void TXshSimpleLevel::save(const TFilePath &fp, const TFilePath &oldFp,
// backup
if (Preferences::instance()->isBackupEnabled() && dOldPath == dDstPath &&
- TSystem::doesExistFileOrLevel(dDstPath))
+ TSystem::doesExistFileOrLevel(dDstPath) && !getProperties()->isStopMotionLevel())
saveBackup(dDstPath);
if (isAreadOnlyLevel(dDstPath)) {