/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ /* Version : 1.0 First version : 01/05/2011 Author : Aymeric Suteau */ /*! \brief Callback on plugIT instance editor closed * * Prototype: fun [] [[S S] r1] * * \return [[S S] r1] : parameters to save in the instance XML data **/ fun cbCloseEdit(p)= let p -> [ctrlWidth ctrlHeigth ctrlCamera ctrlFps ctrlShowVideo ctrlFormat ctrlQuality] in let ftoi getEdCtrlFloatValue ctrlWidth -> width in let ftoi getEdCtrlFloatValue ctrlHeigth -> heigth in let getSelectedEdCtrlSelectPos ctrlCamera -> cameraIndex in let ftoi getEdCtrlFloatValue ctrlFps -> fps in let getEdCtrlCheckState ctrlShowVideo -> showVideo in let getSelectedEdCtrlSelectPos ctrlFormat -> format in let ftoi getEdCtrlFloatValue ctrlQuality -> quality in ["width" itoa width]:: ["heigth" itoa heigth]:: ["cameraIndex" itoa cameraIndex]:: ["fps" itoa fps]:: ["showVideo" itoa showVideo]:: ["format" itoa format]:: ["quality" itoa quality]:: nil;; /*! \brief Callback on capture format changed * * Prototype: fun [] [[S S] r1] * * \return [[S S] r1] : parameters to save in the instance XML data **/ fun cbChangeFormat(ctrlFormat, pos, elem, ctrlQuality)= if (pos == 0) then setEdCtrlFloatEnable ctrlQuality 1 else setEdCtrlFloatEnable ctrlQuality 0; 0;; /*! \brief Callback on plugIT instance editor opened * * Prototype: fun [EdWindow PInstance V3Dview] I * * \param EdWindow : editor window structure * \param PInstance : plugIT instance * \param V3Dview : default 3D view structure * * \return @fun [] [[S S] r1] : Callback to call on close **/ fun dynamicedit(winstr, inst, viewstr, applybtn)= let [400 185] -> [iw ih] in let 10 -> ypos in ( // Define window size setEdWindowSize winstr iw ih; setEdWindowSize winstr iw ih; // Get parameters let atof (getPluginInstanceParam inst "width") -> width in let if width == nil then 640.0 else width -> width in let atof (getPluginInstanceParam inst "heigth") -> heigth in let if heigth == nil then 480.0 else heigth -> heigth in let atoi(getPluginInstanceParam inst "cameraIndex") -> cameraIndex in let if cameraIndex == nil then 0 else cameraIndex -> cameraIndex in let atof(getPluginInstanceParam inst "fps") -> fps in let if fps == nil then 25.0 else fps -> fps in let atoi (getPluginInstanceParam inst "showVideo") -> showVideo in let if showVideo == nil then 0 else showVideo -> showVideo in let atoi(getPluginInstanceParam inst "format") -> format in let if format == nil then 0 else format -> format in let atof(getPluginInstanceParam inst "quality") -> quality in let if quality == nil then 100.0 else quality -> quality in // Create controls for plugIT window // Select list for available cameras let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 140 20 (loc "OS3DCAMERASNAPSHOT_0008") nil -> cameraLabel in let crEdCtrlSelect winstr 160 ypos 240 120 CB_AHSCROLL -> ctrlCamera in // Float controls for frame width, frame heigth and fps let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 140 20 (loc "OS3DCAMERASNAPSHOT_0010") nil -> labelWidth in let crEdCtrlFloat winstr 160 ypos 100 20 width 1.0 1000000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlWidth in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 140 20 (loc "OS3DCAMERASNAPSHOT_0009") nil -> labelHeigth in let crEdCtrlFloat winstr 160 ypos 100 20 heigth 1.0 1000000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlHeigth in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 140 20 (loc "OS3DCAMERASNAPSHOT_0012") nil -> labelFPS in let crEdCtrlFloat winstr 160 ypos 100 20 fps 1.0 25.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlFps in // Saving format let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 140 20 (loc "OS3DCAMERASNAPSHOT_0007") nil -> labelFormat in let crEdCtrlSelect winstr 160 ypos 100 120 CB_AHSCROLL -> ctrlFormat in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 140 20 (loc "OS3DCAMERASNAPSHOT_0011") nil -> labelQuality in let crEdCtrlFloat winstr 160 ypos 100 20 quality 1.0 100.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlQuality in // Check box to show frame window or not let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) (iw - 20) 20 (loc "OS3DCAMERASNAPSHOT_0013") EDWIN_RESIZE_MW -> ctrlShowVideo in ( // Init components values and states setEdCtrlCheckState ctrlShowVideo showVideo; fillEdCtrlSelect ctrlFormat "JPEG"::"BMP"::nil; selectEdCtrlSelectByPos ctrlFormat format; setEdCtrlSelectCb ctrlFormat mkfun4 @cbChangeFormat ctrlQuality; if (format == 0) then setEdCtrlFloatEnable ctrlQuality 1 else setEdCtrlFloatEnable ctrlQuality 0; // Get list of available cameras let 0 -> i in let nil -> listOfCameras in let _ENUMcapDevices i -> cap in ( while (cap != nil) do ( set listOfCameras = cap::listOfCameras; set i = i + 1; set cap = _ENUMcapDevices i; ); // Update driver list fillEdCtrlSelect ctrlCamera listOfCameras; selectEdCtrlSelectByPos ctrlCamera cameraIndex; ); // Define callback when plugIT window is closed [mkfun1 @cbCloseEdit [ctrlWidth ctrlHeigth ctrlCamera ctrlFps ctrlShowVideo ctrlFormat ctrlQuality] nil]; ); );;