/*
-----------------------------------------------------------------------------
This source file is part of OpenSpace3D
For the latest info, see http://www.openspace3d.com
Copyright (c) 2016 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 : 05/29/2016
Author : Bourineau Bastien
*/
/*! \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 -> [ctrlpin1 ctrlpin2 ctrlpin3 ctrlpin4 ctrlspeed1 ctrlspeed2] in
let (getSelectedEdCtrlSelect ctrlpin1) -> pin1 in
let (getSelectedEdCtrlSelect ctrlpin2) -> pin2 in
let (getSelectedEdCtrlSelect ctrlpin3) -> pin3 in
let (getSelectedEdCtrlSelect ctrlpin4) -> pin4 in
let itoa (ftoi (getEdCtrlFloatValue ctrlspeed1)) -> speed1 in
let itoa (ftoi (getEdCtrlFloatValue ctrlspeed2)) -> speed2 in
["pin1" pin1]::
["pin2" pin2]::
["pin3" pin3]::
["pin4" pin4]::
["speed1" speed1]::
["speed2" speed2]::
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(winstr, inst, viewstr, applybtn)=
let [400 165] -> [iw ih] in
(
setEdWindowSize winstr iw ih;
let atoi (getPluginInstanceParam inst "pin1") -> pin1 in
let if pin1 == nil then 6 else pin1 -> pin1 in
let atoi (getPluginInstanceParam inst "pin2") -> pin2 in
let if pin2 == nil then 13 else pin2 -> pin2 in
let atoi (getPluginInstanceParam inst "pin3") -> pin3 in
let if pin3 == nil then 19 else pin3 -> pin3 in
let atoi (getPluginInstanceParam inst "pin4") -> pin4 in
let if pin4 == nil then 26 else pin4 -> pin4 in
let atoi (getPluginInstanceParam inst "speed1") -> speed1 in
let if speed1 == nil then 0 else speed1 -> speed1 in
let atoi (getPluginInstanceParam inst "speed2") -> speed2 in
let if speed2 == nil then 0 else speed2 -> speed2 in
let 10 -> ypos in
let crEdCtrlLabel winstr 10 ypos + 2 160 20 (loc "OS3DGPIOMOTORDRIVER_0001") nil -> labelpin1 in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin1 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOMOTORDRIVER_0002") nil -> labelpin2 in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin2 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOMOTORDRIVER_0003") nil -> labelpin3 in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin3 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOMOTORDRIVER_0004") nil -> labelpin4 in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin4 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOMOTORDRIVER_0005") nil -> labelspeed1 in
let crEdCtrlFloat winstr 180 ypos 110 20 itof speed1 (-.100.0) 100.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlspeed1 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOMOTORDRIVER_0006") nil -> labelspeed1 in
let crEdCtrlFloat winstr 180 ypos 110 20 itof speed2 (-.100.0) 100.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlspeed2 in
(
let 2 -> i in
while i < 28 do
(
addEdCtrlSelect ctrlpin1 itoa i;
addEdCtrlSelect ctrlpin2 itoa i;
addEdCtrlSelect ctrlpin3 itoa i;
addEdCtrlSelect ctrlpin4 itoa i;
set i = i + 1;
);
selectEdCtrlSelect ctrlpin1 itoa pin1;
selectEdCtrlSelect ctrlpin2 itoa pin2;
selectEdCtrlSelect ctrlpin3 itoa pin3;
selectEdCtrlSelect ctrlpin4 itoa pin4;
[mkfun1 @cbCloseEdit [ctrlpin1 ctrlpin2 ctrlpin3 ctrlpin4 ctrlspeed1 ctrlspeed2] nil];
);
);;