/* ----------------------------------------------------------------------------- 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/02/2010 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 -> [ctrlpartname ctrlspeed ctrlenable] in let getEdCtrlTextLineValue ctrlpartname -> partname in let getEdCtrlFloatValue ctrlspeed -> speed in let getEdCtrlCheckState ctrlenable -> enable in ["object" partname]:: ["speed" ftoa speed]:: ["enable" itoa enable]:: nil;; /*! \brief Callback on resources browser selection * * Prototype: fun [S I [PInstance EdWindow V3Dview EdControl]] I * * \param S : selected resource name * \param I : selected resource type * \param [PInstance EdWindow V3Dview EdControl] : * - PInstance : plugIT instance * - EdWindow : plugIT Editor window structure * - V3Dview : default 3D view structure * - EdControl : text control for object name * * \return I : 0 **/ fun cbSelectObj(val, type, p)= let p -> [inst winstr viewstr ctrlobjname] in let V3DgetDefaultSession viewstr -> sessionstr in let V3DgetObjectByName sessionstr val -> obj in if obj == nil then nil else setEdCtrlTextLineValue ctrlobjname val; 0;; /*! \brief Callback on close resources browser * * Prototype: fun [EdControl] I * * \param EdControl : browse button * * \return I : 0 **/ fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; /*! \brief Callback on click browse button and open resources browser * * Prototype: fun [EdControl [PInstance EdWindow V3Dview EdControl S]] I * * \param EdControl : browse button * \param [PInstance EdWindow V3Dview EdControl S] : * - PInstance : plugIT instance * - EdWindow : plugIT Editor window structure * - V3Dview : default 3D view structure * - EdControl : text control for object name * - S : current object name * * \return I : 0 **/ fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlobjname objname] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeParticle objname mkfun3 @cbSelectObj [inst winstr viewstr ctrlobjname] mkfun1 @cbCloseRes ctrlbtn 0; ); 0;; fun cbRefreshBtn(pickbtn, p)= let p -> [ctrlobjname] in setEdCtrlTextLineValue ctrlobjname ""; 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 getPluginInstanceUserEvents inst -> levent in let [420 100] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "object") -> objname in let atof (getPluginInstanceParam inst "speed") -> speed in let if speed == nil then 1.0 else speed -> speed in let atoi (getPluginInstanceParam inst "enable") -> enable in let if enable == nil then 0 else enable -> enable in let crEdFrameWindow _channel ewinstr 0 0 iw 200 EDWIN_RESIZE_MW nil (loc "OS3DPARTICLE_0003") (loc "OS3DPARTICLE_0001") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 185 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DPARTICLE_0002") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 140 20 objname nil EDWIN_RESIZE_MW -> ctrlobjname in let crEdCtrlButton winstr 325 ypos 55 20 "..." nil -> pickbtn in let crEdCtrlButton winstr 385 ypos 35 20 "X" nil -> refreshobjname in let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DPARTICLE_0009") nil -> labelspeed in let crEdCtrlFloat winstr 180 ypos 100 20 speed 0.0 100000.0 0.1 6 nil EDWIN_RESIZE_MW -> ctrlspeed in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DPARTICLE_0005") EDWIN_RESIZE_MW -> ctrlenable in ( setEdCtrlCheckState ctrlenable enable; setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlobjname objname]; setEdCtrlTextLineEnable ctrlobjname 0; setEdCtrlButtonCb refreshobjname mkfun2 @cbRefreshBtn [ctrlobjname]; [mkfun1 @cbCloseEdit [ctrlobjname ctrlspeed ctrlenable] nil]; ); );;