struct PosBar=[ PSBwin : ObjWin, PSBlist : ObjList, PSBminiSurface : ObjSurface, PSBtext : [[I ObjText] r1], PSBpos : [[S [I I I] [I I I]] r1], PSBsession : S3d, PSBshell : H3d, PSBclose : fun []I, PSBrename : fun [S S] I, PSBchangepos : fun [S [[I I I][I I I]]] I ]mkPosBar;; typeof PSbar=PosBar;; var PB_TEXTNAME =1;; var PB_TEXTX =2;; var PB_TEXTY =3;; var PB_TEXTZ =4;; var PB_TEXTA =5;; var PB_TEXTB =6;; var PB_TEXTC =7;; fun psbPaint (win, bar) = _BLTsurface bar.PSBwin 230 120 bar.PSBminiSurface 0 0 150 150; 0 ;; fun psbMakeView(bar,pos)= /* creation et initialisation de la camera */ let pos -> [[x y z][a b c]] in M3loadString session strcatn "camera POScameraH3 {\n":: (itoa x)::" "::(itoa y)::" "::(itoa z)::" ":: (itoa a)::" "::(itoa b)::" "::(itoa c):: "\n350 350 200 100\n 10 10000 10000}"::nil bar.PSBshell; let [150 150] -> [w h] in let M3getObj bar.PSBsession "POScameraH3" -> camerapos in let M3getCamera bar.PSBsession camerapos->[[d _] [x _] z] in ( M3setCamera bar.PSBsession camerapos [[d*(w>>1)/x d*(w>>1)/x] [w>>1 h>>1] z]; if bar.PSBminiSurface == nil then set bar.PSBminiSurface = _CRsurface _channel w h else nil; /* rendu de la scene avec la camera */ MX3render bar.PSBsession bar.PSBminiSurface camerapos 0 0 cel.Cel3dback; _BLTsurface bar.PSBwin 230 120 bar.PSBminiSurface 0 0 w h; M3unLink bar.PSBsession camerapos; M3delObj bar.PSBsession camerapos; ); 0 ;; fun psbSetText(bar,type,s)= let switch bar.PSBtext type -> txt in _SETtext txt s; 0 ;; fun psbSelectPosInDesc(bar,s)= if s==nil then nil else let search_in_list bar.PSBpos @posbyn s -> pos in if pos==nil then nil else let pos -> [npos [x y z] [a b c]] in { psbMakeView bar [[x y z] [a b c]]; /*psbSetText bar PB_TEXTNAME npos; psbSetText bar PB_TEXTX itoa x; psbSetText bar PB_TEXTY itoa y; psbSetText bar PB_TEXTZ itoa z; psbSetText bar PB_TEXTA itoa a; psbSetText bar PB_TEXTB itoa b; psbSetText bar PB_TEXTC itoa b;*/ }; 0;; fun search_pos(l,n)= if l==nil then 0 else let l -> [[pos _ _] nxt] in if (strcmp n pos)>0 then 1+search_pos nxt n else 0;; fun psbAddList(bar,lpos,paint)= if bar==nil then nil else if lpos==nil then bar else let lpos -> [[npos _ _] nxt] in let search_pos bar.PSBpos npos -> pos in { set bar.PSBpos=add_nth_in_list bar.PSBpos pos hd lpos; _ADDlist bar.PSBlist pos npos; psbAddList bar nxt paint };; fun psbDelList(bar,pos)= if bar==nil then nil else { set bar.PSBpos=removef_from_list bar.PSBpos @posbyn pos; let _GETlist bar.PSBlist -> [i s] in if i!=(-1) && !strcmp pos s then { _SSELlist bar.PSBlist nil; psbSelectPosInDesc bar nil; } else nil; _SDELlist bar.PSBlist pos; }; 0;; /* fun psbTextValidation(txt,param,s)= let param -> [bar type] in let _GETlist bar.PSBlist -> [i old] in if i!=(-1) then let _GETtext switch bar.PSBtext PB_TEXTNAME -> n in let [atoi _GETtext switch bar.PSBtext PB_TEXTX atoi _GETtext switch bar.PSBtext PB_TEXTY atoi _GETtext switch bar.PSBtext PB_TEXTZ ] -> v in let [atoi _GETtext switch bar.PSBtext PB_TEXTA atoi _GETtext switch bar.PSBtext PB_TEXTB atoi _GETtext switch bar.PSBtext PB_TEXTC ] -> a in if type==PB_TEXTNAME then if (strcmp old s) && (search_in_list bar.PSBpos @posbyn s)==nil then { C3DrenPos old s; psbDelList bar old; psbAddList bar [s v a]::nil 0; _SSELlist bar.PSBlist s; psbSelectPosInDesc bar s; 0 } else nil else { C3DmovPos n [v a] 1 BROAD_ALL; psbMakeView bar [v a]; } else nil; 0;; */ fun psbListClick(cplist,bar,i,s)= let nth_list bar.PSBpos i -> [n _ _ ] in psbSelectPosInDesc bar n; 0 ;; fun dsPosBar()= if PSbar == nil then nil else ( _DSsurface PSbar.PSBminiSurface; _DSwindow PSbar.PSBwin; set PSbar=nil ); 0;; fun psbClosing(win, bar)= exec bar.PSBclose with []; dsPosBar ;; fun psbAddClick(bar, npos) = let M3calcPosRef bar.PSBsession cam bar.PSBshell -> [v m] in let M3angularFromMatrix m ->a in { C3DaddPos npos [v a]; psbAddList bar [npos v a]::nil 0; _SSELlist bar.PSBlist npos; psbSelectPosInDesc bar npos; _DMSevent this (strcat ObName DYNEDITORmyOb ".posAdded") npos nil; /* Tony: Rajouté*/ 0 };; fun okpsbAskName (but, param) = let param -> [bar text win] in let _GETtext text -> npos in if (strextr npos) == nil then ( _SETtext text "pos_new"; nil ) else ( _DSwindow win; psbAddClick bar npos ) ;; fun cancelpsbAskName (but, win) = _DSwindow win ;; fun psbAskName (ro, bar) = let _CRwindow _channel bar.PSBwin 200 200 300 60 WN_MENU+WN_MINBOX _loc this "TOOL_NEWNAME" nil -> win in let _CReditText _channel win 10 5 180 20 ET_DOWN "pos_" -> text in let _CRbutton _channel win 10 30 85 20 0 _loc this "OK_BUTTON" nil -> ok in let _CRbutton _channel win 100 30 85 20 0 _loc this "CANCEL_BUTTON" nil -> cancel in ( _CBbutton ok @okpsbAskName [bar text win]; _CBbutton cancel @cancelpsbAskName win; ) ;; fun psbDelClick(ro,bar)= let _GETlist bar.PSBlist -> result in if result == nil then nil else if (sizelist bar.PSBpos) < 2 then ( _DLGMessageBox _channel bar.PSBwin (_loc this "POS_CANNOTDELETE" nil) (_loc this "POS_ATLEASTONE" nil) 0; nil ) else let result -> [i s] in ( C3DdelPos s; psbDelList bar s ) ;; fun psbUpdatePos (ro, bar) = let _GETlist bar.PSBlist -> result in if result == nil then nil else let result -> [i s] in let M3calcPosRef bar.PSBsession cam bar.PSBshell -> [v m] in let M3angularFromMatrix m -> a in ( C3DmovPos s [v a] 1 BROAD_ALL; psbMakeView bar [v a]; ) ;; /*fun crPSBText(p,name,x,y,xsize,isNumber,type)= let strcat name ":" -> label in let if isNumber then ET_DOWN|ET_NUMBER else ET_DOWN -> flags in let _CReditLine _channel p.PSBwin x y xsize 20 flags "" -> txt in ( _CBlineOk txt @psbTextValidation [p type]; set p.PSBtext=[type txt]::p.PSBtext; _CRtext _channel p.PSBwin x-xsize-2 y+2 xsize 20 ET_ALIGN_CENTER label; txt ) ;;*/ fun crPosBar(x,y,father,lpos,session,shell)= if PSbar != nil then ( _TOPwindow PSbar.PSBwin; 0 ) else let _CRwindow _channel father x y 400 300 WN_MENU (_loc this "TOOL_POS" nil) -> win in let mkPosBar[win _CRlist _channel win 10 10 200 280 LB_DOWN nil nil nil session shell nil nil nil ] -> bar in ( _CBwinClose win @psbClosing bar; _CBwinPaint win @psbPaint bar; _CBlistClick bar.PSBlist @psbListClick bar; _CBbutton _CRbutton _channel win 220 20 170 20 0 (_loc this "TOOL_ADD" nil) @psbAskName bar; _CBbutton _CRbutton _channel win 220 50 170 20 0 (_loc this "TOOL_UPDATE" nil) @psbUpdatePos bar; _CBbutton _CRbutton _channel win 220 80 170 20 0 (_loc this "TOOL_DEL" nil) @psbDelClick bar; /* les textes crPSBText bar (_loc this "TOOL_POSNAME" nil) 60 10 50 0 PB_TEXTNAME; crPSBText bar "x" 60 40 50 1 PB_TEXTX; crPSBText bar "y" 60 70 50 1 PB_TEXTY; crPSBText bar "z" 60 100 50 1 PB_TEXTZ; crPSBText bar "a" 60 130 50 1 PB_TEXTA; crPSBText bar "b" 60 160 50 1 PB_TEXTB; crPSBText bar "c" 60 190 50 1 PB_TEXTC;*/ set PSbar=psbAddList bar lpos 0; _SELlist PSbar.PSBlist 0; psbListClick nil PSbar 0 nil; 0 ) ;; fun initPSBClose(f)= set PSbar.PSBclose=f; 0;; fun psbAddPos(n,pos)= let pos -> [v a] in psbAddList PSbar [n v a]::nil 0; _SSELlist PSbar.PSBlist n; psbSelectPosInDesc PSbar n; 0;; fun psbDelPos(n)= psbDelList PSbar n;;