8282-type fold_tv () :: basic_tv () | {'we' ,[we_transform_fun ()],basic_tv ()}.
8383
8484-type inf_or_float () :: 'infinity' | float ().
85+ -type inf_or_int () :: 'infinity' | integer ().
8586-type limit2 () :: {inf_or_float (),inf_or_float ()}.
87+ -type limit2i () :: {inf_or_int (),inf_or_int ()}.
8688
8789-type unit () :: 'angle' | {'angle' ,limit2 ()}
8890 | 'distance' | {'distance' ,limit2 ()}
9496 | 'percent' | {'percent' ,limit2 ()}
9597 | 'rx' | {'rx' ,limit2 ()}
9698 | 'skip'
99+ | 'count' | {'count' ,limit2i ()}
97100 | plugin_unit_kludge ().
98101
99102% % FIXME: Should wrap in a tuple, e.e. {custom,CustomType}.
@@ -533,6 +536,9 @@ drag_help(Units) ->
533536 percent ->
534537 Msg = zmove_help (? __ (2 ," Scale" )),
535538 {4 ,S ,[Msg |MsgAcc ]};
539+ count ->
540+ Msg = zmove_help (? __ (7 ," Count" )),
541+ {4 ,S ,[Msg |MsgAcc ]};
536542 _ when S ->
537543 Msg = zmove_help (wings_util :stringify (P )),
538544 {4 ,S ,[Msg |MsgAcc ]};
@@ -548,6 +554,9 @@ drag_help(Units) ->
548554 percent ->
549555 Msg = p4_help (? __ (2 ," Scale" )),
550556 {5 ,S ,[Msg |MsgAcc ]};
557+ count ->
558+ Msg = zmove_help (? __ (7 ," Count" )),
559+ {5 ,S ,[Msg |MsgAcc ]};
551560 _ when S ->
552561 Msg = p4_help (wings_util :stringify (P )),
553562 {5 ,S ,[Msg |MsgAcc ]};
@@ -563,6 +572,9 @@ drag_help(Units) ->
563572 percent ->
564573 Msg = p5_help (? __ (2 ," Scale" )),
565574 {6 ,S ,[Msg |MsgAcc ]};
575+ count ->
576+ Msg = zmove_help (? __ (7 ," Count" )),
577+ {6 ,S ,[Msg |MsgAcc ]};
566578 _ when S ->
567579 Msg = p5_help (wings_util :stringify (P )),
568580 {6 ,S ,[Msg |MsgAcc ]};
@@ -893,6 +905,8 @@ make_move_1([{percent,_}=Unit|Units], [V|Vals]) ->
893905 [clamp (Unit , V / 100 )|make_move_1 (Units , Vals )];
894906make_move_1 ([percent |Units ], [V |Vals ]) ->
895907 [V / 100 |make_move_1 (Units , Vals )];
908+ make_move_1 ([count |Units ], [V |Vals ]) ->
909+ [trunc (V )|make_move_1 (Units , Vals )];
896910make_move_1 ([{U ,{_Min ,_Max }}= Unit |Units ], [V |Vals ]) ->
897911 make_move_1 ([U |Units ], [clamp (Unit , V )|Vals ]);
898912make_move_1 ([_U |Units ], [V |Vals ]) ->
@@ -1096,7 +1110,11 @@ round_to_constraint([], [], _, Acc) -> reverse(Acc).
10961110
10971111constrain_1 ([falloff ], _ , # drag {falloff = Falloff }) ->
10981112 [Falloff ];
1099- constrain_1 ([_ |Us ], [D |Ds ], Drag ) ->
1113+ constrain_1 ([{count ,_ }= U |Us ], [D |Ds ], Drag ) ->
1114+ [clamp (U , trunc (D ))|constrain_1 (Us , Ds , Drag )];
1115+ constrain_1 ([count |Us ], [D |Ds ], Drag ) ->
1116+ [trunc (D )|constrain_1 (Us , Ds , Drag )];
1117+ constrain_1 ([_U |Us ], [D |Ds ], Drag ) ->
11001118 [D |constrain_1 (Us , Ds , Drag )];
11011119constrain_1 ([], _ , _ ) -> [].
11021120
@@ -1364,6 +1382,8 @@ unit(percent, P) ->
13641382 trim (io_lib :format (" ~.2f % " , [P * 100.0 ]));
13651383unit (falloff , R ) ->
13661384 [" R: " |trim (io_lib :format (" ~10.2f " , [R ]))];
1385+ unit (count , R ) ->
1386+ [" C: " |trim (io_lib :format (" ~10w " , [trunc (R )]))];
13671387unit (skip ,_ ) ->
13681388 % % the atom 'skip' can be used as a place holder. See wpc_arc.erl
13691389 [];
@@ -1379,39 +1399,48 @@ trim([[_|_]=H|T]) ->
13791399trim (S ) -> S .
13801400
13811401normalize (Move , # drag {mode_fun = ModeFun ,mode_data = ModeData ,
1382- st = # st {shapes = Shs0 }= St }) ->
1402+ st = # st {shapes = Shs0 , sel = Sel0 }= St }) ->
13831403 ModeFun (done , ModeData ),
13841404 gl :disable (gl_rescale_normal ()),
1385- Shs = wings_dl :map (fun (D , Sh ) ->
1405+ { Shs , Sel } = wings_dl :map (fun (D , Sh ) ->
13861406 normalize_fun (D , Move , Sh )
1387- end , Shs0 ),
1388- St # st {shapes = Shs }.
1407+ end , {Shs0 ,Sel0 }),
1408+ if Sel =/= Sel0 -> wings_draw :refresh_dlists (St );
1409+ true -> ignore
1410+ end ,
1411+ St # st {shapes = Shs ,sel = Sel }.
13891412
1390- normalize_fun (# dlo {drag = none }= D , _Move , Shs ) -> {D ,Shs };
1413+ normalize_fun (# dlo {drag = none }= D , _Move , ShsSel ) -> {D ,ShsSel };
13911414normalize_fun (# dlo {drag = {matrix ,_ ,_ ,_ },transparent = # we {id = Id }= We ,
1392- proxy_data = PD }= D0 , _Move , Shs0 ) when ? IS_LIGHT (We ) ->
1415+ proxy_data = PD }= D0 , _Move , { Shs0 , Sel } ) when ? IS_LIGHT (We ) ->
13931416 Shs = gb_trees :update (Id , We , Shs0 ),
13941417 D = D0 # dlo {work = none ,smooth = none ,drag = none ,src_we = We ,transparent = false ,
13951418 proxy_data = wings_proxy :invalidate (PD , dl )},
1396- {wings_draw :changed_we (D , D ),Shs };
1397- normalize_fun (# dlo {drag = {matrix ,_ ,_ ,Matrix },src_we = # we {id = Id }= We0 ,
1398- proxy_data = PD }= D0 ,
1399- _Move , Shs0 ) ->
1419+ {wings_draw :changed_we (D , D ),{Shs ,Sel }};
1420+ normalize_fun (# dlo {drag = {matrix ,_ ,_ ,Matrix },src_sel = {_ ,DSel },src_we = # we {id = Id }= We0 ,
1421+ proxy_data = PD }= D0 , _Move , {Shs0 ,Sel }) ->
14001422 We1 = We0 # we {temp = []},
14011423 We = wings_we :transform_vs (Matrix , We1 ),
14021424 Shs = gb_trees :update (Id , We , Shs0 ),
14031425 D = D0 # dlo {work = none ,smooth = none ,edges = none ,sel = none ,drag = none ,src_we = We ,
14041426 mirror = none ,proxy_data = wings_proxy :invalidate (PD , dl )},
1405- {wings_draw :changed_we (D , D ),Shs };
1406- normalize_fun (# dlo {drag = {general ,Fun },src_we = # we {id = Id }= We0 }= D0 , Move , Shs ) ->
1427+ {wings_draw :changed_we (D , D ),{Shs ,update_sel (Id ,DSel ,Sel )}};
1428+ normalize_fun (# dlo {drag = {general ,Fun }, src_sel = {_ ,DSel }, src_we = # we {id = Id }= We0 }= D0 ,
1429+ Move , {Shs ,Sel }) ->
14071430 D1 = Fun ({finish ,Move }, D0 ),
14081431 We = We0 # we {temp = []},
14091432 D = D1 # dlo {drag = none ,sel = none ,src_we = We },
1410- {wings_draw :changed_we (D , D ),gb_trees :update (Id , We , Shs )};
1411- normalize_fun (# dlo {src_we = # we {id = Id }}= D0 , _Move , Shs ) ->
1433+ {wings_draw :changed_we (D , D ),{ gb_trees :update (Id , We , Shs ), update_sel ( Id , DSel , Sel )} };
1434+ normalize_fun (# dlo {src_sel = { _ , DSel }, src_we = # we {id = Id }}= D0 , _Move , { Shs , Sel } ) ->
14121435 # dlo {src_we = We0 } = D = wings_draw :join (D0 ),
14131436 We = We0 # we {temp = []},
1414- {D ,gb_trees :update (Id , We , Shs )}.
1437+ {D ,{gb_trees :update (Id , We , Shs ),update_sel (Id ,DSel ,Sel )}}.
1438+
1439+ update_sel (Id , DSel , Sel ) ->
1440+ case orddict :is_key (Id ,Sel ) of
1441+ true -> orddict :store (Id ,DSel ,Sel );
1442+ false -> Sel
1443+ end .
14151444
14161445% %%
14171446% %% Redrawing while dragging.
0 commit comments