/* ----------------------------------------------------------------------------- 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 : 06/15/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 -> [ctrlSenderIp ctrlSenderPort ctrlReceiverIp ctrlReceiverPort ctrlNbPoints ctrlValidation ctrlDisplay ctrlSpeed ctrlForegroundBrightness ctrlBackgroundBrightness ctrlTargetShape ctrlTargetSize ctrlShowEyes] in let getEdCtrlTextLineValue ctrlSenderIp -> senderIp in let ftoi (getEdCtrlFloatValue ctrlSenderPort) -> senderPort in let getEdCtrlTextLineValue ctrlReceiverIp -> receiverIp in let ftoi (getEdCtrlFloatValue ctrlReceiverPort) -> receiverPort in let getSelectedEdCtrlSelect ctrlNbPoints -> nbPoints in //let getSelectedEdCtrlSelectPos ctrlValidation -> validation in let getEdCtrlCheckState ctrlValidation -> validation in let getSelectedEdCtrlSelectPos ctrlDisplay -> display in let getSelectedEdCtrlSelectPos ctrlSpeed -> speed in let ftoi (getEdCtrlFloatValue ctrlForegroundBrightness) -> foregroundBrightness in let ftoi (getEdCtrlFloatValue ctrlBackgroundBrightness) -> backgroundBrightness in let getSelectedEdCtrlSelectPos ctrlTargetShape -> targetShape in let ftoi (getEdCtrlFloatValue ctrlTargetSize) -> targetSize in let getEdCtrlCheckState ctrlShowEyes -> showEyes in ["senderIp" senderIp]:: ["senderPort" itoa senderPort]:: ["receiverIp" receiverIp]:: ["receiverPort" itoa receiverPort]:: ["nbPoints" nbPoints]:: ["validation" itoa validation]:: ["display" itoa display]:: ["speed" itoa speed]:: ["foregroundBrightness" itoa foregroundBrightness]:: ["backgroundBrightness" itoa backgroundBrightness]:: ["targetShape" itoa targetShape]:: ["targetSize" itoa targetSize]:: ["showEyes" itoa showEyes]:: nil;; /*! \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(ewinstr, inst, viewstr, applybtn)= let [420 440] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; // Retrieve parameters values let getPluginInstanceParam inst "senderIp" -> senderIp in let atof (getPluginInstanceParam inst "senderPort") -> senderPort in let getPluginInstanceParam inst "receiverIp" -> receiverIp in let atof (getPluginInstanceParam inst "receiverPort") -> receiverPort in let getPluginInstanceParam inst "nbPoints" -> nbPoints in let atoi(getPluginInstanceParam inst "validation") -> validation in let atoi(getPluginInstanceParam inst "display") -> display in let atoi(getPluginInstanceParam inst "speed") -> speed in let atof (getPluginInstanceParam inst "foregroundBrightness") -> foregroundBrightness in let atof (getPluginInstanceParam inst "backgroundBrightness") -> backgroundBrightness in let atoi (getPluginInstanceParam inst "targetShape") -> targetShape in let atof (getPluginInstanceParam inst "targetSize") -> targetSize in let atoi(getPluginInstanceParam inst "showEyes") -> showEyes in // Set parameters default values let if senderIp == nil then "127.0.0.1" else senderIp -> senderIp in let if senderPort == nil then 4444.0 else senderPort -> senderPort in let if receiverIp == nil then "127.0.0.1" else receiverIp -> receiverIp in let if receiverPort == nil then 5555.0 else receiverPort -> receiverPort in let if nbPoints == nil then "5" else nbPoints -> nbPoints in let if validation == nil then 1 else validation -> validation in let if display == nil then 0 else display -> display in let if speed == nil then 0 else speed -> speed in let if foregroundBrightness == nil then 20.0 else foregroundBrightness -> foregroundBrightness in let if backgroundBrightness == nil then 239.0 else backgroundBrightness -> backgroundBrightness in let if targetShape == nil then 0 else targetShape -> targetShape in let if targetSize == nil then 10.0 else targetSize -> targetSize in let if showEyes == nil then 1 else showEyes -> showEyes in // Create components for UDP connection let crEdFrameWindow _channel ewinstr 0 0 iw 140 EDWIN_RESIZE_MW nil (loc "OS3DEYETRACKING_0005") (loc "OS3DEYETRACKING_0008") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 120 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ypos + 2 170 20 (loc "OS3DEYETRACKING_0018") nil -> labelSenderIp in let crEdCtrlTextLine winstr 190 ypos 100 20 senderIp nil EDWIN_RESIZE_MW -> ctrlSenderIp in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DEYETRACKING_0019") nil -> labelSenderPort in let crEdCtrlFloat winstr 190 ypos 100 20 senderPort 1.0 65535.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlSenderPort in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DEYETRACKING_0013") nil -> labelReceiverIp in let crEdCtrlTextLine winstr 190 ypos 100 20 receiverIp nil EDWIN_RESIZE_MW -> ctrlReceiverIp in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DEYETRACKING_0014") nil -> labelReceiverPort in let crEdCtrlFloat winstr 190 ypos 100 20 receiverPort 1.0 65535.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlReceiverPort in // Create components for calibration process let crEdFrameWindow _channel ewinstr 0 0 iw 220 EDWIN_RESIZE_MW nil (loc "OS3DEYETRACKING_0002") (loc "OS3DEYETRACKING_0008") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 200 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 (set ypos = 10) 170 20 (loc "OS3DEYETRACKING_0010") nil -> labelNbPoints in let crEdCtrlSelect winstr 190 ypos 100 120 CB_AHSCROLL -> ctrlNbPoints in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DEYETRACKING_0006") nil -> labelDisplay in let crEdCtrlSelect winstr 190 ypos 100 120 CB_AHSCROLL -> ctrlDisplay in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DEYETRACKING_0012") nil -> labelSpeed in let crEdCtrlSelect winstr 190 ypos 100 120 CB_AHSCROLL -> ctrlSpeed in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DEYETRACKING_0007") nil -> labelForegroundBrightness in let crEdCtrlFloat winstr 190 ypos 100 20 foregroundBrightness 0.0 255.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlForegroundBrightness in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DEYETRACKING_0001") nil -> labelBackgroundBrightness in let crEdCtrlFloat winstr 190 ypos 100 20 backgroundBrightness 0.0 255.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlBackgroundBrightness in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DEYETRACKING_0015") nil -> labelTargetShape in let crEdCtrlSelect winstr 190 ypos 100 120 CB_AHSCROLL -> ctrlTargetShape in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DEYETRACKING_0016") nil -> labelTargetSize in let crEdCtrlFloat winstr 190 ypos 100 20 targetSize 1.0 50.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlTargetSize in // Create misc components let crEdFrameWindow _channel ewinstr 0 0 iw 80 EDWIN_RESIZE_MW nil (loc "OS3DEYETRACKING_0009") (loc "OS3DEYETRACKING_0008") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 60 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 170 20 (loc "OS3DEYETRACKING_0017") EDWIN_RESIZE_MW -> ctrlValidation in let crEdCtrlCheck winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DEYETRACKING_0011") EDWIN_RESIZE_MW -> ctrlShowEyes in ( // Fill out calibration method select list fillEdCtrlSelect ctrlNbPoints "2"::"5"::"9"::"13"::nil; selectEdCtrlSelect ctrlNbPoints nbPoints; set nbPoints = (getSelectedEdCtrlSelect ctrlNbPoints); // Fill out validation select list setEdCtrlCheckState ctrlValidation validation; setEdCtrlCheckState ctrlShowEyes showEyes; // Fill out display device select list fillEdCtrlSelect ctrlDisplay "Primary"::"Secondary"::nil; selectEdCtrlSelectByPos ctrlDisplay display; // Fill out display device select list fillEdCtrlSelect ctrlSpeed "Slow"::"Fast"::nil; selectEdCtrlSelectByPos ctrlSpeed speed; // Fill out target shape select list fillEdCtrlSelect ctrlTargetShape (loc "OS3DEYETRACKING_0003")::(loc "OS3DEYETRACKING_0004")::"Cross"::nil; selectEdCtrlSelectByPos ctrlTargetShape targetShape; // Define callback when plugIT window is closed [mkfun1 @cbCloseEdit [ctrlSenderIp ctrlSenderPort ctrlReceiverIp ctrlReceiverPort ctrlNbPoints ctrlValidation ctrlDisplay ctrlSpeed ctrlForegroundBrightness ctrlBackgroundBrightness ctrlTargetShape ctrlTargetSize ctrlShowEyes] nil]; ); );;