/*
-----------------------------------------------------------------------------
This source file is part of OpenSpace3D
For the latest info, see http://www.openspace3d.com
Copyright (c) 2015 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/20/2015
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 -> [ctrlmouse ctrlaim ctrldead ctrlspace ctrlobjref ctrlxmul ctrlymul ctrlzmul] in
["mouse" itoa (getEdCtrlCheckState ctrlmouse)]::
["aim" itoa (getEdCtrlCheckState ctrlaim)]::
["deadzone" itoa (ftoi (getEdCtrlFloatValue ctrldead))]::
["scaleX" ftoa (getEdCtrlFloatValue ctrlxmul)]::
["scaleY" ftoa (getEdCtrlFloatValue ctrlymul)]::
["scaleZ" ftoa (getEdCtrlFloatValue ctrlzmul)]::
["objRef" (getEdCtrlTextLineValue ctrlobjref)]::
["space" itoa (getSelectedEdCtrlSelectPos ctrlspace)]::
nil;;
fun cbSelectObj(val, type, p)=
let p -> [inst winstr viewstr ctrlobjname] in
let V3DgetDefaultSession viewstr -> sessionstr in
let SO3SceneGetObject (V3DgetSession sessionstr) val -> obj in
if (obj != nil) || (!strcmpi "Current camera" val) || (!strcmpi "Current camera shell" val) then
(
setEdCtrlTextLineValue ctrlobjname val;
)
else nil;
0;;
fun cbCloseRes(ctrlbtn)=
setEdCtrlButtonEnable ctrlbtn 1;
0;;
fun cbBtnPickObj(ctrlbtn, p)=
let p -> [inst winstr viewstr ctrlobjname objname] in
(
setEdCtrlButtonEnable ctrlbtn 0;
dlgSelectPluginInstanceResource inst winstr iTypeEntity|iTypeNode|iTypeLight|iTypeCamera|iTypeParticle|iTypeBone|iTypeCubeMap objname mkfun3 @cbSelectObj [inst winstr viewstr ctrlobjname] mkfun1 @cbCloseRes ctrlbtn 0;
);
0;;
fun cbRefreshBtn(pickbtn, p)=
let p -> [ctrlobjname] in
setEdCtrlTextLineValue ctrlobjname "";
0;;
fun cbSelSpace(ctrl, pos, elem, btn)=
setEdCtrlButtonEnable btn if (pos == 3) then 1 else 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(ewinstr, inst, viewstr, applybtn)=
let [420 210] -> [iw ih] in
(
setEdWindowSize ewinstr iw ih;
let atoi (getPluginInstanceParam inst "mouse") -> mouse in
let if mouse == nil then 0 else mouse -> mouse in
let atoi (getPluginInstanceParam inst "aim") -> aim in
let if aim == nil then 1 else aim -> aim in
let atof (getPluginInstanceParam inst "deadzone") -> deadzone in
let if deadzone == nil then 25.0 else deadzone -> deadzone in
let atof (getPluginInstanceParam inst "scaleX") -> ax in
let atof (getPluginInstanceParam inst "scaleY") -> ay in
let atof (getPluginInstanceParam inst "scaleZ") -> az in
let if ax == nil then 1.0 else ax -> ax in
let if ay == nil then 1.0 else ay -> ay in
let if az == nil then 1.0 else az -> az in
let atoi(getPluginInstanceParam inst "space") -> space in
let if space == nil then 1 else space -> space in
let (getPluginInstanceParam inst "objRef") -> objref in
let 10 -> ypos in
let crEdFrameWindow _channel ewinstr 0 0 iw 100 EDWIN_RESIZE_MW nil (loc "OS3DTOBII_0003") (loc "OS3DTOBII_0002") -> winfrm in
let crEdWindow _channel winfrm 0 18 iw 80 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in
let crEdCtrlLabel winstr 10 (set ypos = 10) + 2 160 20 (loc "OS3DTOBII_0004") nil -> labelport in
let crEdCtrlFloat winstr 180 ypos 100 20 deadzone 0.0 100.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrldead in
let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DTOBII_0001") EDWIN_RESIZE_MW -> ctrlmouse in
let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DTOBII_0005") EDWIN_RESIZE_MW -> ctrlaim in
let crEdFrameWindow _channel ewinstr 0 0 iw 100 EDWIN_RESIZE_MW nil (loc "OS3DTOBII_0006") (loc "OS3DTOBII_0002") -> winfrm in
let crEdWindow _channel winfrm 0 18 iw 80 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in
let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DTOBII_0007") nil -> labelcspace in
let crEdCtrlSelect winstr 180 ypos 145 120 EDWIN_RESIZE_MW -> ctrlspace in
let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTOBII_0008") nil -> labelref in
let crEdCtrlTextLine winstr 180 ypos 140 20 objref nil EDWIN_RESIZE_MW -> ctrlobjref in
let crEdCtrlButton winstr 325 ypos 55 20 "..." nil -> pickrefbtn in
let crEdCtrlButton winstr 385 ypos 35 20 "X" nil -> refreshobjrefname in
let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 150 20 (loc "OS3DTOBII_0009") nil -> labelcoef in
let crEdCtrlLabel winstr 165 ypos 20 20 "X :" nil -> labelx in
let crEdCtrlFloat winstr 185 ypos 65 20 ax (-.100000.0) 100000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlxmul in
let crEdCtrlLabel winstr 252 ypos 20 20 "Y :" nil -> labely in
let crEdCtrlFloat winstr 268 ypos 65 20 ay (-.100000.0) 100000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlymul in
let crEdCtrlLabel winstr 335 ypos 20 20 "Z :" nil -> labelZ in
let crEdCtrlFloat winstr 355 ypos 65 20 az (-.100000.0) 100000.0 0.01 5 nil EDWIN_RESIZE_MW -> ctrlzmul in
(
fillEdCtrlSelect ctrlspace (loc "OS3DTOBII_0010")::(loc "OS3DTOBII_0011")::(loc "OS3DTOBII_0012")::(loc "OS3DTOBII_0013")::nil;
selectEdCtrlSelectByPos ctrlspace space;
setEdCtrlSelectCb ctrlspace mkfun4 @cbSelSpace pickrefbtn;
setEdCtrlButtonCb pickrefbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlobjref objref];
setEdCtrlTextLineEnable ctrlobjref 0;
setEdCtrlButtonCb refreshobjrefname mkfun2 @cbRefreshBtn [ctrlobjref];
setEdCtrlCheckState ctrlmouse mouse;
setEdCtrlCheckState ctrlaim aim;
[mkfun1 @cbCloseEdit [ctrlmouse ctrlaim ctrldead ctrlspace ctrlobjref ctrlxmul ctrlymul ctrlzmul] nil];
);
);;