/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ fun cbCloseEdit(p)= let p -> [ctrlobjname ctrlwholeobj ctrlidx ctrlmatname ctrlinit] in let getEdCtrlTextLineValue ctrlobjname -> objname in let getEdCtrlCheckState ctrlwholeobj -> wholeobj in let getSelectedEdCtrlSelectPos ctrlidx -> idx in let getSelectedEdCtrlSelect ctrlmatname -> matname in let getEdCtrlCheckState ctrlinit -> init in ["object" objname]:: ["material" matname]:: ["idx" itoa idx]:: ["wholeobj" itoa wholeobj]:: ["init" itoa init]:: nil;; fun fillMaterialSelector(viewstr, ctrlselect, objname)= if objname == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) objname -> obj in let SO3EntityNumOfSubEntities obj -> nsubid in if (nsubid == nil) then nil else let nil -> lid in ( let nsubid - 1 -> i in while i >= 0 do ( set lid = (itoa i)::lid; set i = i - 1; ); fillEdCtrlSelect ctrlselect lid; ); selectEdCtrlSelectByPos ctrlselect 0; 0;; fun cbSelectObj(val, type, p)= let p -> [inst winstr viewstr ctrlobjname ctrlidx ctrlmatname] in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) val -> obj in if obj == nil then nil else ( setEdCtrlTextLineValue ctrlobjname val; fillMaterialSelector viewstr ctrlidx val; selectEdCtrlSelect ctrlmatname SO3MaterialGetName (SO3EntityGetMaterialByIndex obj 0); ); 0;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlobjname ctrlidx ctrlmatname objname] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeEntity objname mkfun3 @cbSelectObj [inst winstr viewstr ctrlobjname ctrlidx ctrlmatname] mkfun1 @cbCloseRes ctrlbtn 0; ); 0;; fun cbRefreshBtnSpec(pickbtn, p)= let p -> [ctrlobjname ctrlidx] in ( setEdCtrlTextLineValue ctrlobjname ""; fillEdCtrlSelect ctrlidx nil; ); 0;; fun cbWholeObject(ctrlcheck, state, ctrlidx)= setEdCtrlSelectEnable ctrlidx !state; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [455 185] -> [iw ih] in let getPluginInstanceUserActions inst -> laction in let getPluginInstanceUserEvents inst -> levent in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let getPluginInstanceParam inst "object" -> objname in let atoi (getPluginInstanceParam inst "wholeobj") -> wholeobj in let if (wholeobj == nil) then 0 else wholeobj -> wholeobj in let atoi (getPluginInstanceParam inst "idx") -> idx in let if (idx == nil) then 0 else idx -> idx in let (getPluginInstanceParam inst "material") -> matname in let atoi (getPluginInstanceParam inst "init") -> init in let if (init == nil) then 1 else init -> init in let crEdFrameWindow _channel ewinstr 0 0 iw 130 EDWIN_RESIZE_MW nil (loc "OS3DCHANGEMATERIAL_0003") (loc "OS3DCHANGEMATERIAL_0005") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 110 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 (ypos + 2) 170 20 (loc "OS3DCHANGEMATERIAL_0007") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos (iw-10-180-65-25) 20 objname nil EDWIN_RESIZE_MW -> ctrlobjname in let crEdCtrlButton winstr 360 ypos 55 20 "..." nil -> pickbtn in let crEdCtrlButton winstr 420 ypos 35 20 "X" nil -> refreshobjname in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DCHANGEMATERIAL_0008") EDWIN_RESIZE_MW -> ctrlwholeobj in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DCHANGEMATERIAL_0002") nil -> labelidx in let crEdCtrlSelect winstr 180 ypos (iw-10-180) 120 EDWIN_RESIZE_MW -> ctrlidx in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DCHANGEMATERIAL_0004") nil -> labelmat in let crEdCtrlSelect winstr 180 ypos (iw-10-180) 120 EDWIN_RESIZE_MW -> ctrlmatname in let crEdFrameWindow _channel ewinstr 0 0 iw 60 EDWIN_RESIZE_MW nil (loc "OS3DCHANGEMATERIAL_0006") (loc "OS3DCHANGEMATERIAL_0005") -> 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 "OS3DCHANGEMATERIAL_0001") EDWIN_RESIZE_MW -> ctrlinit in ( setEdCtrlCheckState ctrlinit init; setEdCtrlCheckState ctrlwholeobj wholeobj; setEdCtrlCheckCbState ctrlwholeobj mkfun3 @cbWholeObject ctrlidx; setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlobjname ctrlidx ctrlmatname objname]; setEdCtrlTextLineEnable ctrlobjname 0; setEdCtrlButtonCb refreshobjname mkfun2 @cbRefreshBtnSpec [ctrlobjname ctrlidx]; setEdCtrlSelectEnable ctrlidx !wholeobj; fillMaterialSelector viewstr ctrlidx objname; selectEdCtrlSelectByPos ctrlidx idx; let getGroupName currentProject inst.INST_groupstr.GRP_xmlMark -> grpname in let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneParseMaterialsFromGroup (V3DgetSession sessionstr) grpname -> l in let sizelist l -> size in let nil -> lmats in let 0 -> i in ( while i < size do ( let nth_list l i -> mat in let SO3MaterialGetName mat -> name in set lmats = name::lmats; set i = i + 1; ); fillEdCtrlSelect ctrlmatname quicksort lmats @suppDoublon; selectEdCtrlSelect ctrlmatname matname; ); [mkfun1 @cbCloseEdit [ctrlobjname ctrlwholeobj ctrlidx ctrlmatname ctrlinit] nil]; ); );;