/* ----------------------------------------------------------------------------- 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 getMaterialsList(ctrlmatlist)= let getEdCtrlListElems ctrlmatlist -> matlist in let nil -> matparamlist in let getEdCtrlListNbElems ctrlmatlist -> nbMaterials in let 0 -> i in ( while (i < nbMaterials) do ( let nth_list matlist i -> mat in let [(strcat "material_" (itoa i)) mat] -> matparam in set matparamlist = matparam::matparamlist; set i = i + 1; ); matparamlist; );; fun cbCloseEdit(p)= let p -> [ctrlobjname ctrlidx ctrlwhole ctrlmatlist ctrltitle ctrlok ctrlcancel ctrlloop ctrlinit] in let getEdCtrlTextLineValue ctrlobjname -> objname in let getSelectedEdCtrlSelectPos ctrlidx -> idx in let getEdCtrlCheckState ctrlwhole -> whole in let getEdCtrlTextLineValue ctrltitle -> title in let getEdCtrlTextLineValue ctrlok -> okbutton in let getEdCtrlTextLineValue ctrlcancel -> cancelbutton in let getEdCtrlCheckState ctrlloop -> loop in let getEdCtrlCheckState ctrlinit -> init in ["object" objname]:: ["idx" itoa idx]:: ["whole" itoa whole]:: ["title" title]:: ["okbutton" okbutton]:: ["cancelbutton" cancelbutton]:: ["loop" itoa loop]:: ["init" itoa init]:: (getMaterialsList ctrlmatlist);; fun fillIdSelector(viewstr, ctrlidx, objname)= if objname == nil then nil else let V3DgetDefaultSession viewstr -> sessionstr in let SO3SceneGetObject (V3DgetSession sessionstr) objname -> obj in let SO3EntityMaterialList obj -> lmat in let nil -> lid in ( let (sizelist lmat) - 1-> i in while i >= 0 do ( set lid = (itoa i)::lid; set i = i - 1; ); fillEdCtrlSelect ctrlidx lid; ); selectEdCtrlSelectByPos ctrlidx 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; fillIdSelector viewstr ctrlidx val; selectEdCtrlSelectByPos ctrlidx 0; 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] in setEdCtrlTextLineValue ctrlobjname ""; 0;; fun cbAddList(ctrlstr, p)= let p -> [ctrlmatlist ctrlmatname] in let getSelectedEdCtrlSelect ctrlmatname -> value in if (value == nil) || (!strcmp "" strtrim value) then nil else ( let getEdCtrlListElems ctrlmatlist -> lelem in if (isStringInListi lelem value) then nil else ( addEdCtrlList ctrlmatlist value nil nil; selectEdCtrlSelectByPos ctrlmatname 0; ); ); 0;; fun cbDelList(ctrlstr, p)= let p -> [ctrlmatlist ctrlmatname] in let getSelectedEdCtrlList ctrlmatlist -> [name _ _] in delEdCtrlList ctrlmatlist name; 0;; fun fillMaterialSelector(inst, viewstr, ctrlmatname)= let V3DgetDefaultSession viewstr -> sessionstr in let getGroupName currentProject inst.INST_groupstr.GRP_xmlMark -> grpname in let SO3SceneParseMaterialsFromGroup (V3DgetSession sessionstr) grpname -> lmats in let nil -> lmatnames in ( let (sizelist lmats) - 1-> i in while i >= 0 do ( let nth_list lmats i -> mat in let SO3MaterialGetName mat -> matname in set lmatnames = matname::lmatnames; set i = i - 1; ); fillEdCtrlSelect ctrlmatname (quicksort lmatnames @suppDoublon); ); selectEdCtrlSelectByPos ctrlmatname 0; 0;; fun cbWholeObject(ctrlcheck, state, ctrlidx)= setEdCtrlSelectEnable ctrlidx !state; 0;; fun loadMaterialsList(inst)= let 0 -> i in let nil -> matlist in let getPluginInstanceParam inst (strcat "material_" (itoa i)) -> mat in ( while (mat != nil) do ( set i = i + 1; set matlist = mat::matlist; set mat = getPluginInstanceParam inst (strcat "material_" (itoa i)); ); revertlist matlist; );; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [455 470] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "object") -> objname in let atoi (getPluginInstanceParam inst "idx") -> idx in let if idx == nil then 0 else idx -> idx in let atoi (getPluginInstanceParam inst "whole") -> whole in let if whole == nil then 0 else whole -> whole in let getPluginInstanceParam inst "title" -> title in let if title == nil then "" else title -> title in let getPluginInstanceParam inst "okbutton" -> okbutton in let if okbutton == nil then "" else okbutton -> okbutton in let getPluginInstanceParam inst "cancelbutton" -> cancelbutton in let if cancelbutton == nil then "" else cancelbutton -> cancelbutton in let atoi (getPluginInstanceParam inst "loop") -> loop in let if loop == nil then 1 else loop -> loop in let atoi (getPluginInstanceParam inst "init") -> init in let if init == nil then 0 else init -> init in let crEdFrameWindow _channel ewinstr 0 0 iw 110 EDWIN_RESIZE_MW nil (loc "OS3DMATLIST_0014") (loc "OS3DMATLIST_0005") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 85 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 (ypos + 2) 170 20 (loc "OS3DMATLIST_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 crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DMATLIST_0002") nil -> labelidx in let crEdCtrlSelect winstr 180 ypos (iw-10-180) 120 EDWIN_RESIZE_MW -> ctrlidx in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DMATLIST_0004") EDWIN_RESIZE_MW -> ctrlwhole in let crEdFrameWindow _channel ewinstr 0 0 iw 165 EDWIN_RESIZE_MW nil (loc "OS3DMATLIST_0003") (loc "OS3DMATLIST_0006") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 140 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 170 20 (loc "OS3DMATLIST_0008") nil -> labelmat in let crEdCtrlList winstr 10 (set ypos = ypos + 25) (iw - 20) 60 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlmatlist in let crEdCtrlSelect winstr 10 (set ypos = ypos + 65) (iw-10-60) 120 EDWIN_RESIZE_MW -> ctrlmatname in let crEdCtrlButton winstr (iw - 55) ypos 20 20 "+" EDWIN_RESIZE_MW -> ctrlbtnadd in let crEdCtrlButton winstr (iw - 30) ypos 20 20 "-" EDWIN_RESIZE_MW -> ctrlbtndel in let crEdFrameWindow _channel ewinstr 0 0 iw 110 EDWIN_RESIZE_MW nil (loc "OS3DMATLIST_0010") (loc "OS3DMATLIST_0005") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 85 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 170 20 (loc "OS3DMATLIST_0011") nil -> labeltitle in let crEdCtrlTextLine winstr 180 ypos (iw-10-180) 20 title nil EDWIN_RESIZE_MW -> ctrltitle in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DMATLIST_0012") nil -> labelok in let crEdCtrlTextLine winstr 180 ypos (iw-10-180) 20 okbutton nil EDWIN_RESIZE_MW -> ctrlok in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DMATLIST_0013") nil -> labelcancel in let crEdCtrlTextLine winstr 180 ypos (iw-10-180) 20 cancelbutton nil EDWIN_RESIZE_MW -> ctrlcancel in let crEdFrameWindow _channel ewinstr 0 0 iw 85 EDWIN_RESIZE_MW nil (loc "OS3DMATLIST_0006") (loc "OS3DMATLIST_0005") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 60 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DMATLIST_0009") EDWIN_RESIZE_MW -> ctrlloop in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DMATLIST_0001") EDWIN_RESIZE_MW -> ctrlinit in ( setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlobjname ctrlidx ctrlmatname objname]; setEdCtrlTextLineEnable ctrlobjname 0; setEdCtrlButtonCb refreshobjname mkfun2 @cbRefreshBtnSpec [ctrlobjname]; fillIdSelector viewstr ctrlidx objname; selectEdCtrlSelectByPos ctrlidx idx; setEdCtrlSelectEnable ctrlidx !whole; setEdCtrlCheckState ctrlwhole whole; setEdCtrlCheckCbState ctrlwhole mkfun3 @cbWholeObject ctrlidx; fillEdCtrlList ctrlmatlist (loadMaterialsList inst); fillMaterialSelector inst viewstr ctrlmatname; setEdCtrlButtonCb ctrlbtnadd mkfun2 @cbAddList [ctrlmatlist ctrlmatname]; setEdCtrlButtonCb ctrlbtndel mkfun2 @cbDelList [ctrlmatlist ctrlmatname]; setEdCtrlCheckState ctrlloop loop; setEdCtrlCheckState ctrlinit init; [mkfun1 @cbCloseEdit [ctrlobjname ctrlidx ctrlwhole ctrlmatlist ctrltitle ctrlok ctrlcancel ctrlloop ctrlinit] nil]; ); );;