/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2020 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 ----------------------------------------------------------------------------- */ /*----------------------- Callbacks ------------------------*/ /* On close plugIT window */ fun cbCloseEdit(p)= let p -> [ctrlshowray ctrlraysrc ctrlautoclick ctrlautoclickdist ctrlinit] in let getSelectedEdCtrlSelectPos ctrlshowray -> showray in let getEdCtrlTextLineValue ctrlraysrc -> raysrc in let getEdCtrlCheckState ctrlautoclick -> autoclick in let getEdCtrlFloatValue ctrlautoclickdist -> autoclickdist in let getEdCtrlCheckState ctrlinit -> init in ["showray" itoa showray]:: ["raysrc" raysrc]:: ["autoclick" itoa autoclick]:: ["autoclickdist" ftoa autoclickdist]:: ["init" itoa init]:: nil;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; 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 cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlobjname objname] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeGroup|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 dynamicedit(ewinstr, inst, viewstr, applybtn)= let [450 185] -> [iw ih] in let 10 -> ypos in ( // Define window size setEdWindowSize ewinstr iw ih; // Get parameters values let atoi (getPluginInstanceParam inst "showray") -> showray in let if (showray == nil) then 1 else showray -> showray in let getPluginInstanceParam inst "raysrc" -> raysrc in let atoi (getPluginInstanceParam inst "autoclick") -> autoclick in let if (autoclick == nil) then 0 else autoclick -> autoclick in let atof (getPluginInstanceParam inst "autoclickdist") -> autoclickdist in let if (autoclickdist == nil) then 0.05 else autoclickdist -> autoclickdist in let atoi(getPluginInstanceParam inst "init") -> init in let if init == nil then 1 else init -> init in // Create components let crEdFrameWindow _channel ewinstr 0 0 iw 130 EDWIN_RESIZE_MW nil (loc "OS3DVPOINTER_0002") (loc "OS3DVPOINTER_0001") -> 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 ((set ypos = 10) + 2) 170 20 (loc "OS3DVPOINTER_0003") nil -> labelray in let crEdCtrlSelect winstr 180 ypos (iw - 180) 120 EDWIN_RESIZE_MW -> ctrlshowray in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DVPOINTER_0004") EDWIN_RESIZE_MW -> ctrlautoclick in let crEdCtrlLabel winstr 15 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DVPOINTER_0005") nil -> labeldist in let crEdCtrlFloat winstr 185 ypos 100 20 autoclickdist 0.001 100.0 0.01 3 nil EDWIN_RESIZE_MW -> ctrlautoclickdist in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DVPOINTER_0006") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 140 20 raysrc nil EDWIN_RESIZE_MW -> ctrlraysrc in let crEdCtrlButton winstr 325 ypos 55 20 "..." nil -> pickraysrcbtn in let crEdCtrlButton winstr 385 ypos 35 20 "X" nil -> refreshraysrcname in let crEdFrameWindow _channel ewinstr 0 0 iw 45 EDWIN_RESIZE_MW nil (loc "OS3DVPOINTER_0007") (loc "OS3DVPOINTER_0001") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 35 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DVPOINTER_0008") EDWIN_RESIZE_MW -> ctrlinit in ( fillEdCtrlSelect ctrlshowray (loc "OS3DVPOINTER_0009")::(loc "OS3DVPOINTER_0010")::(loc "OS3DVPOINTER_0011")::nil; selectEdCtrlSelectByPos ctrlshowray showray; setEdCtrlButtonCb pickraysrcbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlraysrc raysrc]; setEdCtrlTextLineEnable ctrlraysrc 0; setEdCtrlButtonCb refreshraysrcname mkfun2 @cbRefreshBtn [ctrlraysrc]; setEdCtrlCheckState ctrlautoclick autoclick; setEdCtrlCheckState ctrlinit init; [mkfun1 @cbCloseEdit [ctrlshowray ctrlraysrc ctrlautoclick ctrlautoclickdist ctrlinit] nil]; ); );;