/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ //proto cbCloseEdit = fun [] [[S S] r1];; fun cbDestroyEdit()= 0;; fun getEvents(file)= let _CRml _channel 1 1 0.5 -> ml in let _MlLoadData ml _checkpack file -> _ in let _MlGetCategories ml -> lnames in let sizelist lnames -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( set ndata = ["EVENT" (nth_list lnames i)]::ndata; set i = i + 1; ); _DSml ml; ndata; );; fun cbCloseEdit(p)= let p -> [inst ctrldata ctrlfeatures ctrlthreshold ctrldetectmode ctrllearn] in let getEdCtrlTextLineValue ctrldata -> datapath in let (if ((datapath == nil) || ((strlen datapath) == 0)) then strcatn "tmp/ml/"::inst.INST_sName::".xlm"::nil else datapath) -> datapath in let ftoi getEdCtrlFloatValue ctrlfeatures -> nbfeatures in let getEdCtrlFloatValue ctrlthreshold -> threshold in let getEdCtrlCheckState ctrllearn -> learnmode in let getEdCtrlCheckState ctrldetectmode -> detectmode in ["path" datapath]:: ["nbfeatures" itoa nbfeatures]:: ["threshold" ftoa threshold]:: ["learnmode" itoa learnmode]:: ["detectmode" itoa detectmode]:: (getEvents datapath);; fun cbDlgGetFile(dlg, p, pfile)= let p -> [inst ctrlbtn winstr ctrlfile] in ( if pfile == nil then nil else let _PtoScol pfile -> file in if file == nil then ( _DLGMessageBox _channel winstr.EDW_win (loc "OS3DML_0003") (loc "OS3DML_0015") 0; 0; ) else ( setEdCtrlTextLineValue ctrlfile file; 0; ); setEdCtrlButtonEnable ctrlbtn 1; ); 0;; fun cbBtnPickFile(ctrlbtn, p)= let p -> [inst winstr ctrlfile] in let getEdCtrlTextLineValue ctrlfile -> fpath in let getPathFile fpath "" -> [fpath fname] in ( setEdCtrlButtonEnable ctrlbtn 0; _DLGrflopen _DLGOpenFile _channel winstr.EDW_win fpath fname "MLData\0*.xlm;\0All\0*.*\0\0" @cbDlgGetFile [inst ctrlbtn winstr ctrlfile]; ); 0;; fun cbRefreshBtn(pickbtn, p)= let p -> [ctrlfile] in setEdCtrlTextLineValue ctrlfile ""; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [420 190] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "path") -> datapath in let atof (getPluginInstanceParam inst "nbfeatures") -> nbfeatures in let if nbfeatures == nil then 1.0 else nbfeatures -> nbfeatures in let atof (getPluginInstanceParam inst "threshold") -> threshold in let if threshold == nil then 0.5 else threshold -> threshold in let atoi (getPluginInstanceParam inst "learnmode") -> learnmode in let if learnmode == nil then 0 else learnmode -> learnmode in let atoi (getPluginInstanceParam inst "detectmode") -> detectmode in let if detectmode == nil then 0 else detectmode -> detectmode in let crEdFrameWindow _channel ewinstr 0 0 iw 60 EDWIN_RESIZE_MW nil (loc "OS3DML_0004") (loc "OS3DML_0008") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 45 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DML_0001") nil -> labelobj in let crEdCtrlTextLine winstr 180 ypos 140 20 datapath nil EDWIN_RESIZE_MW -> ctrldata in let crEdCtrlButton winstr 325 ypos 55 20 "..." nil -> filebtn in let crEdCtrlButton winstr 385 ypos 35 20 "X" nil -> refreshfilename in let crEdFrameWindow _channel ewinstr 0 0 iw 130 EDWIN_RESIZE_MW nil (loc "OS3DML_0006") (loc "OS3DML_0008") -> 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 ((set ypos = 10) + 2) 180 20 (loc "OS3DML_0011") nil -> labelfeatures in let crEdCtrlFloat winstr 200 ypos 100 20 nbfeatures 1.0 100.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlfeatures in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 180 20 (loc "OS3DML_0002") nil -> labelthreshold in let crEdCtrlFloat winstr 200 ypos 100 20 threshold 0.1 1.0 0.1 4 nil EDWIN_RESIZE_MW -> ctrlthreshold in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DML_0010") EDWIN_RESIZE_MW -> ctrldetectmode in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DML_0007") EDWIN_RESIZE_MW -> ctrllearn in ( setEdCtrlCheckState ctrldetectmode detectmode; setEdCtrlCheckState ctrllearn learnmode; setEdCtrlButtonCb filebtn mkfun2 @cbBtnPickFile [inst winstr ctrldata]; setEdCtrlTextLineEnable ctrldata 0; setEdCtrlButtonCb refreshfilename mkfun2 @cbRefreshBtn [ctrldata]; [mkfun1 @cbCloseEdit [inst ctrldata ctrlfeatures ctrlthreshold ctrldetectmode ctrllearn] @cbDestroyEdit]; ); );;