/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2018 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 ----------------------------------------------------------------------------- */ //typeof curlAltitudeRequest = ObjCURL;; fun cbDestroyEdit(nav)= SO3WebNavigatorDestroy nav; /* if (curlAltitudeRequest == nil) then nil else ( killHttpRequest curlAltitudeRequest; set curlAltitudeRequest = nil; ); */ 0;; fun cbCloseEdit(p)= let p -> [ctrllong ctrllat ctrlobjname ctrlscale ctrldist ctrlenable] in let getEdCtrlFloatValue ctrllong -> long in let getEdCtrlFloatValue ctrllat -> lat in let getEdCtrlTextLineValue ctrlobjname -> objname in let getEdCtrlFloatValue ctrlscale -> scale in let getEdCtrlFloatValue ctrldist -> dist in let getEdCtrlCheckState ctrlenable -> enable in ["long" ftoa long]:: ["lat" ftoa lat]:: ["object" objname]:: ["scale" ftoa scale]:: ["dist" ftoa dist]:: ["enable" itoa enable]:: nil;; fun cbSelectObj(val, type, p)= let p -> [inst winstr viewstr ctrlobjname] in let SO3SceneGetObject (V3DgetSession c3dXsession) val -> obj in if (obj != nil) || (!strcmpi "Current camera" val) || (!strcmpi "Current camera shell" val) then ( setEdCtrlTextLineValue ctrlobjname val; ) else nil; 0;; fun cbCloseRes(ctrlbtn)= setEdCtrlButtonEnable ctrlbtn 1; 0;; fun cbBtnPickObj(ctrlbtn, p)= let p -> [inst winstr viewstr ctrlobjname objname] in ( setEdCtrlButtonEnable ctrlbtn 0; dlgSelectPluginInstanceResource inst winstr iTypeGroup|iTypeEntity|iTypeNode|iTypeLight|iTypeParticle|iTypeBone|iTypeCubeMap objname mkfun3 @cbSelectObj [inst winstr viewstr ctrlobjname] mkfun1 @cbCloseRes ctrlbtn 0; ); 0;; fun cbRefreshBtn(pickbtn, ctrlpath)= setEdCtrlTextLineValue ctrlpath ""; 0;; /* fun cbGetAltitude(url, data, ctrlalt)= addLogMessage data; let strreplace strreplace strreplace data "{" "" "}" "" (ctoa 34) "" -> str in let strToListSep str "," -> l in while (l != nil) do ( let hd l -> req in ( if ((strfind "elevation:" req 0) != nil) then let (substr req (strfind ":" req 0) + 2 (strlen req)) -> st1 in ( setEdCtrlFloatValueWithoutCallback ctrlalt (atof st1); ) else nil; ); set l = tl l; ); 0;; */ fun cbGetMapCoords(nav, p, mess, args)= let p -> [ctrllat ctrllong ctrlalt] in if (!strcmp mess "location") then ( setEdCtrlFloatValueWithoutCallback ctrllong (atof (hd args)); setEdCtrlFloatValueWithoutCallback ctrllat (atof (hd tl args)); /* if (curlAltitudeRequest == nil) then nil else ( killHttpRequest curlAltitudeRequest; set curlAltitudeRequest = nil; ); set curlAltitudeRequest = getUrl strcatn "https://api.open-elevation.com/api/v1/lookup?locations="::(hd tl args)::","::(hd args)::nil nil mkfun3 @cbGetAltitude ctrlalt; */ ) else nil; 0;; fun cbMapLocationChange(ctrl, value, p)= let p -> [nav ctrllat ctrllong ctrlalt] in let getEdCtrlFloatValue ctrllong -> long in let getEdCtrlFloatValue ctrllat -> lat in let getEdCtrlFloatValue ctrlalt -> alt in ( SO3WebNavigatorExecuteJavaScript nav strcatn "centerMap("::(ftoa long)::", "::(ftoa lat)::");"::nil nil nil nil; ); 0;; fun cbGetMapLoaded(nav, p, frame, status)= let p -> [ctrllat ctrllong ctrlalt] in cbMapLocationChange nil nil [nav ctrllat ctrllong ctrlalt]; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [430 500] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let strcatn (getPluginDirectory (getInstancePlugin inst))::"/res/location.html"::nil -> mappath in let atof (getPluginInstanceParam inst "long") -> long in let if (long == nil) then (-.1.548131) else long -> long in let atof (getPluginInstanceParam inst "lat") -> lat in let if (lat == nil) then 47.21357 else lat -> lat in let atof (getPluginInstanceParam inst "alt") -> alt in let if (alt == nil) then 8.0 else alt -> alt in let (getPluginInstanceParam inst "object") -> objname in let atof (getPluginInstanceParam inst "scale") -> scale in let if (scale == nil) then 1.0 else scale -> scale in let atof (getPluginInstanceParam inst "dist") -> dist in let if (dist == nil) then 10.0 else dist -> dist in let atoi (getPluginInstanceParam inst "enable") -> enable in let if enable == nil then 1 else enable -> enable in let crEdFrameWindow _channel ewinstr 0 0 iw 345 EDWIN_RESIZE_MW nil (loc "OS3DGPSLOCATION_0002") (loc "OS3DGPSLOCATION_0001") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 325 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let SO3WebNavigatorCreate _channel winstr.EDW_win 10 10 (iw - 20) 250 "google.com" -> nav in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 265) + 2) 160 20 (loc "OS3DGPSLOCATION_0003") nil -> labellong in let crEdCtrlFloat winstr 180 ypos 100 20 long (-.180.0) 180.0 0.00001 6 nil EDWIN_RESIZE_MW -> ctrllong in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DGPSLOCATION_0004") nil -> labellat in let crEdCtrlFloat winstr 180 ypos 100 20 lat (-.180.0) 180.0 0.00001 6 nil EDWIN_RESIZE_MW -> ctrllat in //let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DGPSLOCATION_0005") nil -> labelalt in //let crEdCtrlFloat winstr 180 ypos 100 20 alt (-.1000000.0) 1000000.0 0.0001 6 nil EDWIN_RESIZE_MW -> ctrlalt in let crEdFrameWindow _channel ewinstr 0 0 iw 105 EDWIN_RESIZE_MW nil (loc "OS3DGPSLOCATION_0006") (loc "OS3DGPSLOCATION_0001") -> 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) 160 20 (loc "OS3DGPSLOCATION_0007") 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 -> refreshbtn in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DGPSLOCATION_0008") nil -> labeldist in let crEdCtrlFloat winstr 180 ypos 100 20 dist 0.0 1000000.0 0.01 3 nil EDWIN_RESIZE_MW -> ctrldist in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DGPSLOCATION_0009") nil -> labelscale in let crEdCtrlFloat winstr 180 ypos 100 20 scale 0.0 1000000.0 0.01 3 nil EDWIN_RESIZE_MW -> ctrlscale in let crEdFrameWindow _channel ewinstr 0 0 iw 60 EDWIN_RESIZE_MW nil (loc "OS3DGPSLOCATION_0010") (loc "OS3DGPSLOCATION_0001") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 40 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) (iw - 20) 20 (loc "OS3DGPSLOCATION_0011") EDWIN_RESIZE_MW -> ctrlenable in ( SO3WebNavigatorLoadFile nav _checkpack mappath nil; SO3WebNavigatorCbOnExternalCall nav @cbGetMapCoords [ctrllat ctrllong nil]; SO3WebNavigatorCbOnLoadEnd nav @cbGetMapLoaded [ctrllat ctrllong nil]; setEdCtrlFloatCbChange ctrllong mkfun3 @cbMapLocationChange [nav ctrllat ctrllong nil]; setEdCtrlFloatCbChange ctrllat mkfun3 @cbMapLocationChange [nav ctrllat ctrllong nil]; setEdCtrlButtonCb pickbtn mkfun2 @cbBtnPickObj [inst winstr viewstr ctrlobjname objname]; setEdCtrlTextLineEnable ctrlobjname 0; setEdCtrlButtonCb refreshbtn mkfun2 @cbRefreshBtn ctrlobjname; setEdCtrlCheckState ctrlenable enable; [(mkfun1 @cbCloseEdit [ctrllong ctrllat ctrlobjname ctrlscale ctrldist ctrlenable]) mkfun1 @cbDestroyEdit nav]; ); );;