Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Mv/bugs1.4.1 #17

Closed
wants to merge 12 commits into from

2 participants

Micheus Vieira Dan Gudmundsson
Micheus Vieira

I could solve two problems reported in the "Wings 1.4.1 Bug Reports" session.

I hope I have helped you.

Micheus Vieira

There is an other bug I can solve: UV Torus crashes (http://nendowingsmirai.yuku.com/sreply/48799/Wings-1-4-1-Bug-Reports).
I'm waiting for deerwood comments (by e-mail)

Dan Gudmundsson
Owner
dgud commented July 03, 2011

Great,

Dan Gudmundsson
Owner

You have changed plugins/primitives/wpc_torus_de.lang in one of your commits which is wrong,
it should be changed in plugins_src/...
I can merge this branch please rebase -i HEAD~5
and fix it

Dan Gudmundsson
Owner

I can not merge it..was what I meant

Micheus Vieira

Dan, I did what you asked me. I hope it could be OK now.

added some commits July 01, 2011
Micheus Vieira NOTE: Images loaded by "Import Image" now preserve its file extension…
… in its name shown in the Outline window as already is done by using "Make External". (Thanks to FranOnTheEdge that reported this issue) [Micheus]
ec89e65
Micheus Vieira NOTE: Fixed the crashing caused by the command "Select->Select By Non…
… Quadrangle" (all options); It was working fine on version 1.3.1. (Thanks to deerwood that reported this bug) [Micheus]
c696cd4
Micheus Vieira NOTE: Fixed UV Torus crachs. If a zero value has been inputted it wil…
…l be overwritten with 3;

  - added information for the fields U and V on Torus dialogs;
  - Deutsch translation of 'lang' file by deerwood;
(Thanks to deerwood that reported this bug) [Micheus]
51796e5
Micheus Vieira NOTE: Fixed the wrong placement of object in a folder after the proje…
…ct has been loaded/reloaded. (Thanks to deerwood that reported this bug) [Micheus]
b4b1c88
Micheus Vieira NOTE: Fixed the problem with the merge resource when the cameras in t…
…he merged file replaces that one in the intial file. Now, any existing cameras in both files are maintained. (Thanks to deerwood that reported this bug) [Micheus]
82dfb66
Micheus Vieira NOTE: Visible and Locked states of lights were not restored after the…
… project has been loaded, despite they have been saved. The cause was that these states have been saved many times in the file. It was because these fields was not deleted from 'proplist' as did with 'opengl' field. (Thanks to deerwood and instantly.ggaliens that reported this bug) [Micheus]
4402064
Micheus Vieira NOTE: It was added support for handling the multiple mouse buttons op…
…tions in the context menu of Outliner window.

The option Select by material in the Outliner window doesn't select the right elements if the selection mode isn't Face or Body. The function "select_material" was getting the "id"s of the faces and using them as "id"s of the other elements (for the edge/vertex selection mode). It was fixed and added new parameters that enable us to add support for "add to selection" and "remove from selection" in context menu.
(Thanks to deerwood that reported the bug and suggested the new options) [Micheus]
28c0a02
Micheus Vieira NOTE: When trying to saving a wings scene file to a path on the netwo…
…rk using unc path, an error occurs (Save failed: no such file or directory) and the file was not saved. For some reason the first slash is removed from the path name when Save dialog returns the file name in the function wings_file:export_filename_1/2 (after executed wings_plugin:call_ui()). The same occurs with Open dialog too. It seems to be a Erlang issue (I'm not sure). I did a workaround, then I could Save/Export/Import using an "unc" path without any problem. (Thanks to jentzenm.unofficialsony that reported this bug) [Micheus]
fd9b024
Micheus Vieira NOTE: Improvements to Information line management made it auto-sizabl…
…e when the message is longest than window width.
a19117f
Micheus Vieira wings_wm.erl: I noticed I forgot to add a space in the code line 1272…
…. In this case the first two words in the new line are concatenated:

Line: {0,Acc++[$\n]++E++[" "]}; % the last space I had forgotten
163cf33
Micheus Vieira Removed file "plugins/primitives/wpc_torus_de.lang" from branch. I ad…
…ded it to branch - my bad.
42b4fd3
Micheus Vieira NOTE: Fixed the wrong selection of elements when using the option Mat…
…erial->Select in the Outline window if selection mode isn't Face or Body. Also, its context menu supports multiple options and it was added two new options: "Add to selection" and "Remove from selection". (Thanks to deerwood that reported the bug and suggested the new options) [Micheus]
88d31e4
Dan Gudmundsson
Owner

Merged but not the last commit (added late december), please redo on new branch

Dan Gudmundsson dgud closed this January 09, 2012
Micheus Vieira

Dan, just have pulled a new branch: select_by_material (#23)
The change was applied over your latest "master" branch.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 12 unique commits by 1 author.

Dec 01, 2011
Micheus Vieira NOTE: Images loaded by "Import Image" now preserve its file extension…
… in its name shown in the Outline window as already is done by using "Make External". (Thanks to FranOnTheEdge that reported this issue) [Micheus]
ec89e65
Micheus Vieira NOTE: Fixed the crashing caused by the command "Select->Select By Non…
… Quadrangle" (all options); It was working fine on version 1.3.1. (Thanks to deerwood that reported this bug) [Micheus]
c696cd4
Micheus Vieira NOTE: Fixed UV Torus crachs. If a zero value has been inputted it wil…
…l be overwritten with 3;

  - added information for the fields U and V on Torus dialogs;
  - Deutsch translation of 'lang' file by deerwood;
(Thanks to deerwood that reported this bug) [Micheus]
51796e5
Micheus Vieira NOTE: Fixed the wrong placement of object in a folder after the proje…
…ct has been loaded/reloaded. (Thanks to deerwood that reported this bug) [Micheus]
b4b1c88
Micheus Vieira NOTE: Fixed the problem with the merge resource when the cameras in t…
…he merged file replaces that one in the intial file. Now, any existing cameras in both files are maintained. (Thanks to deerwood that reported this bug) [Micheus]
82dfb66
Micheus Vieira NOTE: Visible and Locked states of lights were not restored after the…
… project has been loaded, despite they have been saved. The cause was that these states have been saved many times in the file. It was because these fields was not deleted from 'proplist' as did with 'opengl' field. (Thanks to deerwood and instantly.ggaliens that reported this bug) [Micheus]
4402064
Micheus Vieira NOTE: It was added support for handling the multiple mouse buttons op…
…tions in the context menu of Outliner window.

The option Select by material in the Outliner window doesn't select the right elements if the selection mode isn't Face or Body. The function "select_material" was getting the "id"s of the faces and using them as "id"s of the other elements (for the edge/vertex selection mode). It was fixed and added new parameters that enable us to add support for "add to selection" and "remove from selection" in context menu.
(Thanks to deerwood that reported the bug and suggested the new options) [Micheus]
28c0a02
Micheus Vieira NOTE: When trying to saving a wings scene file to a path on the netwo…
…rk using unc path, an error occurs (Save failed: no such file or directory) and the file was not saved. For some reason the first slash is removed from the path name when Save dialog returns the file name in the function wings_file:export_filename_1/2 (after executed wings_plugin:call_ui()). The same occurs with Open dialog too. It seems to be a Erlang issue (I'm not sure). I did a workaround, then I could Save/Export/Import using an "unc" path without any problem. (Thanks to jentzenm.unofficialsony that reported this bug) [Micheus]
fd9b024
Micheus Vieira NOTE: Improvements to Information line management made it auto-sizabl…
…e when the message is longest than window width.
a19117f
Micheus Vieira wings_wm.erl: I noticed I forgot to add a space in the code line 1272…
…. In this case the first two words in the new line are concatenated:

Line: {0,Acc++[$\n]++E++[" "]}; % the last space I had forgotten
163cf33
Micheus Vieira Removed file "plugins/primitives/wpc_torus_de.lang" from branch. I ad…
…ded it to branch - my bad.
42b4fd3
Dec 29, 2011
Micheus Vieira NOTE: Fixed the wrong selection of elements when using the option Mat…
…erial->Select in the Outline window if selection mode isn't Face or Body. Also, its context menu supports multiple options and it was added two new options: "Add to selection" and "Remove from selection". (Thanks to deerwood that reported the bug and suggested the new options) [Micheus]
88d31e4
This page is out of date. Refresh to see the latest.
51  plugins_src/primitives/wpc_torus.erl
@@ -48,11 +48,15 @@ command(_, _) -> next.
48 48
 % ======= Regular Torus =======
49 49
 make_uv_torus(Ask) when is_atom(Ask) ->
50 50
     wpa:ask(Ask, ?__(1,"UV Torus Options"),
51  
-	    [{?__(2,"U Resolution"),80},
52  
-	     {?__(3,"V Resolution"),16},
  51
+	    [{?__(2,"U Resolution"),80,
  52
+	    	[{range,{0,infinity}},{info,?__(6,"Number of segments along major circumference (U, minimum is 3)")}]},
  53
+	     {?__(3,"V Resolution"),16,
  54
+	     	[{range,{0,infinity}},{info,?__(7,"Number of segments along minor circumference (V, minimum is 3)")}]},
53 55
 	     {?__(4,"Major Radius"),1.0},
54 56
 	     {?__(5,"Minor Radius"),0.2}],
55  
-	    fun(Res) -> {shape,{uvtorus,Res}} end);
  57
+	    fun(Res) ->
  58
+    		{shape,{uvtorus,Res}}
  59
+	    end);
56 60
 make_uv_torus([URES, VRES, MajR, MinR]) ->
57 61
     case {URES>0, VRES>0} of
58 62
 	{true, true} ->
@@ -63,23 +67,36 @@ make_uv_torus([URES, VRES, MajR, MinR]) ->
63 67
 	    Vres = VRES;
64 68
 	{true, false} ->
65 69
 	    Vres = trunc(URES/(MajR/MinR)),
66  
-	    Ures = URES
  70
+	    Ures = URES;
  71
+	{false, false} ->
  72
+	    Vres = 6,
  73
+	    Ures = trunc(Vres*(MajR/MinR))
67 74
     end,
68  
-    Vs = make_verts(Ures, Vres, MajR, MinR, none, none, 1),
69  
-    Fs = make_faces(Ures, Vres),
  75
+	Ures0=min_uv_torus_res(Ures),
  76
+	Vres0=min_uv_torus_res(Vres),
  77
+    Vs = make_verts(Ures0, Vres0, MajR, MinR, none, none, 1),
  78
+    Fs = make_faces(Ures0, Vres0),
70 79
     {new_shape,"UV Torus",Fs,Vs}.
  80
+min_uv_torus_res(Res) when Res =< 3 -> 3;
  81
+min_uv_torus_res(Res) -> Res.
71 82
 
72 83
 % ======= Lumpy Torus =======
73 84
 make_lu_torus(Ask) when is_atom(Ask) ->
74 85
     wpa:ask(Ask, ?__(1,"Lumpy Torus Options"),
75  
-	    [{?__(2,"U Resolution"),125},
76  
-	     {?__(3,"V Resolution"),25},
  86
+	    [{?__(2,"U Resolution"),125,
  87
+	    	[{range,{0,infinity}},{info,?__(8,"Number of segments along major circumference (U, minimum is 3)")}]},
  88
+	     {?__(3,"V Resolution"),25,
  89
+	     	[{range,{0,infinity}},{info,?__(9,"Number of segments along minor circumference (V, minimum is 3)")}]},
77 90
 	     {?__(4,"Major Radius"),1.0},
78 91
 	     {?__(5,"Minor Radius"),0.2},
79 92
 	     {?__(6,"Lumps"),8},
80 93
 	     {?__(7,"Lump Amplitude"),0.5}],
81  
-	    fun(Res) -> {shape,{lutorus,Res}} end);
82  
-make_lu_torus([Ures, Vres, MajR, MinR, Loops, LoopRad]) ->
  94
+	    fun(Res) -> 
  95
+			{shape,{lutorus,Res}}
  96
+		end);
  97
+make_lu_torus([Ures0, Vres0, MajR, MinR, Loops, LoopRad]) ->
  98
+	Ures=min_uv_torus_res(Ures0),
  99
+	Vres=min_uv_torus_res(Vres0),
83 100
     Vs = make_verts(Ures, Vres, MajR, MinR, Loops, LoopRad, 2),
84 101
     Fs = make_faces(Ures, Vres),
85 102
     {new_shape,"Lumpy Torus",Fs,Vs}.
@@ -87,14 +104,20 @@ make_lu_torus([Ures, Vres, MajR, MinR, Loops, LoopRad]) ->
87 104
 % ======= Spiral Torus =======
88 105
 make_sp_torus(Ask) when is_atom(Ask) ->
89 106
     wpa:ask(Ask, ?__(1,"Spiral Torus Options"),
90  
-	    [{?__(2,"U Resolution"),200},
91  
-	     {?__(3,"V Resolution"),20},
  107
+	    [{?__(2,"U Resolution"),200,
  108
+	    	[{range,{0,infinity}},{info,?__(8,"Number of segments along major circumference (U, minimum is 3)")}]},
  109
+	     {?__(3,"V Resolution"),20,
  110
+	     	[{range,{0,infinity}},{info,?__(9,"Number of segments along minor circumference (V, minimum is 3)")}]},
92 111
 	     {?__(4,"Major Radius"),1.0},
93 112
 	     {?__(5,"Minor Radius"),0.2},
94 113
 	     {?__(6,"Loops"),8},
95 114
 	     {?__(7,"Loop Radius "),0.2}],
96  
-	    fun(Res) -> {shape,{sptorus,Res}} end);
97  
-make_sp_torus([Ures, Vres, MajR, MinR, Loops, LoopRad]) ->
  115
+	    fun(Res) -> 
  116
+			{shape,{sptorus,Res}}
  117
+		end);
  118
+make_sp_torus([Ures0, Vres0, MajR, MinR, Loops, LoopRad]) ->
  119
+	Ures=min_uv_torus_res(Ures0),
  120
+	Vres=min_uv_torus_res(Vres0),
98 121
     Vs = make_verts(Ures, Vres, MajR, MinR, Loops, LoopRad, 3),
99 122
     Fs = make_faces(Ures, Vres),
100 123
     {new_shape,"Spiral Torus",Fs,Vs}.
18  src/wings_file.erl
@@ -56,7 +56,8 @@ import_filename_1(Ps0, Cont) ->
56 56
         _Other    -> ?__(1,"Import")
57 57
     end,
58 58
     Ps = Ps0 ++ [{title,String},{directory,Dir}],
59  
-    Fun = fun(Name) ->
  59
+    Fun = fun(Name0) ->
  60
+    	  Name=test_unc_path(Name0), 
60 61
 		  case catch Cont(Name) of
61 62
 		      {command_error,Error} ->
62 63
 			  wings_u:message(Error);
@@ -84,7 +85,8 @@ export_filename_1(Prop0, Cont) ->
84 85
     This = wings_wm:this(),
85 86
     Dir = wings_pref:get_value(current_directory),
86 87
     Prop = Prop0 ++ [{directory,Dir}],
87  
-    Fun = fun(Name) ->
  88
+    Fun = fun(Name0) ->
  89
+    	  Name=test_unc_path(Name0), 
88 90
 		  case catch Cont(Name) of
89 91
 		      {command_error,Error} ->
90 92
 			  wings_u:message(Error);
@@ -375,7 +377,7 @@ merge(Name, St0) ->
375 377
 			  wings_u:error_msg(?__(2,"Read failed: ") ++ Reason);
376 378
 		      #st{}=St ->
377 379
 			  set_cwd(dirname(Name)),
378  
-			  wings_shape:recreate_folder_system(St)
  380
+			  wings_shape:recreate_folder_system(St#st{saved=false})
379 381
 		  end
380 382
 	  end,
381 383
     use_autosave(Name, Fun).
@@ -399,7 +401,8 @@ save_as(Next, St) ->
399 401
     Ps = [{title,Title}|wings_prop()],
400 402
     export_filename(Ps, St, Cont).
401 403
 
402  
-save_now(Next, #st{file=Name}=St) ->
  404
+save_now(Next, #st{file=Name0}=St) ->
  405
+    Name=test_unc_path(Name0), 
403 406
     Backup = backup_filename(Name),
404 407
     file:rename(Name, Backup),
405 408
     file:delete(autosave_filename(Name)),
@@ -412,6 +415,13 @@ save_now(Next, #st{file=Name}=St) ->
412 415
 	{error,Reason} ->
413 416
 	    wings_u:error_msg(?__(1,"Save failed: ") ++ Reason)
414 417
     end.
  418
+    
  419
+test_unc_path([H|_]=FileName) when H=:=47 ->
  420
+	case string:str(FileName, "//") of
  421
+		1 -> FileName;
  422
+		_ -> "/"++FileName  % 47 is ascii code for "/"
  423
+	end;
  424
+test_unc_path(FileName) -> FileName.
415 425
 
416 426
 maybe_send_action(ignore) -> keep;
417 427
 maybe_send_action(Action) -> wings_wm:later({action,Action}).
2  src/wings_image.erl
@@ -103,7 +103,7 @@ from_file(Filename) ->
103 103
     Props = [{filename,Filename},{alignment,1}],
104 104
     case image_read(Props) of
105 105
 	#e3d_image{}=Image ->
106  
-	    Name = filename:rootname(filename:basename(Filename)),
  106
+	    Name = filename:basename(Filename),
107 107
 	    req({new,Image#e3d_image{name=Name},false});
108 108
 	{error,_}=Error -> Error
109 109
     end.
5  src/wings_io.erl
@@ -410,8 +410,11 @@ gradient_rect_burst(X, Y, W, H, Color) ->
410 410
     GradColors = [0.882353, 0.882353, 0.850980, 0.807843, 0.776471, 0.729412,
411 411
 		  0.701961, 0.666667, 0.619608, 0.741176, 0.733333, 0.760784,
412 412
 		  0.784314, 0.811765, 0.854902, 0.890196, 0.890196],
  413
+	K = if H=<17 -> H;
  414
+ 		true -> H-1
  415
+	end,
413 416
     Draw_Line = fun(Idx) ->
414  
-			GreyValue = lists:nth(round((Idx/H)*17)+1, GradColors),
  417
+			GreyValue = lists:nth(trunc((Idx/K)*17)+1, GradColors),
415 418
 			LineColor = mul_color(Color, GreyValue),
416 419
 			set_color(LineColor),
417 420
 			gl:vertex2f(X-0.5+W, Y-0.5+H-Idx),
24  src/wings_light.erl
@@ -680,7 +680,12 @@ import_fun({Name,Ps}, St) ->
680 680
     wings_shape:new(Name, import(Ps), St).
681 681
 
682 682
 import(Ps) ->
683  
-    OpenGL = proplists:get_value(opengl, Ps, []),
  683
+    Visible = proplists:get_value(visible, Ps, []),
  684
+    Locked = proplists:get_value(locked, Ps, []),
  685
+    Prop1 = proplists:delete(visible, Ps),
  686
+    Prop0 = proplists:delete(locked, Prop1),
  687
+
  688
+    OpenGL = proplists:get_value(opengl, Prop0, []),
684 689
     Type = proplists:get_value(type, OpenGL, point),
685 690
     Pos = proplists:get_value(position, OpenGL, ?DEF_POS),
686 691
     Diff = proplists:get_value(diffuse, OpenGL, {1.0,1.0,1.0,1.0}),
@@ -691,11 +696,13 @@ import(Ps) ->
691 696
     QuadAtt = proplists:get_value(quadratic_attenuation, OpenGL, 0.0),
692 697
     Angle = proplists:get_value(cone_angle, OpenGL, 30.0),
693 698
     SpotExp = proplists:get_value(spot_exponent, OpenGL, 0.0),
694  
-    Prop = proplists:delete(opengl, Ps),
  699
+    
  700
+    Prop = proplists:delete(opengl, Prop0),
695 701
     Light = #light{type=Type,diffuse=Diff,ambient=Amb,specular=Spec,
696 702
 		   aim=Aim,lin_att=LinAtt,quad_att=QuadAtt,
697 703
 		   spot_angle=Angle,spot_exp=SpotExp,prop=Prop},
698  
-    import_we(Light, OpenGL, Pos).
  704
+    We=import_we(Light, OpenGL, Pos),
  705
+    We#we{perm=import_perm(Visible, Locked)}.
699 706
 
700 707
 import_ambient(ambient, OpenGL) ->
701 708
     proplists:get_value(ambient, OpenGL, {0.1,0.1,0.1,1.0});
@@ -729,6 +736,17 @@ import_we(#light{}=Light, OpenGL, {X,Y,Z}) ->
729 736
     We = wings_we:build(Fs, Vs),
730 737
     Pst = proplists:get_value(pst, OpenGL, gb_trees:empty()),
731 738
     We#we{light=Light,pst=Pst}.
  739
+    
  740
+import_perm([]=_Visible,[]=_Locked) ->  % it will match when a new light is added to project  
  741
+    import_perm(true,false);
  742
+import_perm(false,false) ->
  743
+    [];
  744
+import_perm(true,false) ->
  745
+    0;
  746
+import_perm(true,true) ->
  747
+    1;
  748
+import_perm(false,true) ->
  749
+    3.
732 750
 
733 751
 import_fix_mesh(#e3d_mesh{fs=Fs0}=Mesh0) ->
734 752
     Fs = [import_fix_face(F) || F <- Fs0],
78  src/wings_material.erl
@@ -77,8 +77,8 @@ command({assign,Mat}, St) when is_atom(Mat) ->
77 77
     set_material(Mat, St);
78 78
 command({assign,Mat}, St) ->
79 79
     set_material(list_to_atom(Mat), St);
80  
-command({select,[Mat]}, St) ->
81  
-    select_material(list_to_atom(Mat), St);
  80
+command({select,[Mat,SelAct]}, St) ->
  81
+    {save_state,select_material(list_to_atom(Mat),SelAct, St)};
82 82
 command({duplicate,MatList}, St) ->
83 83
     duplicate_material(MatList, St);
84 84
 command({delete,MatList}, St) ->
@@ -182,23 +182,77 @@ make_fake_selection_1([#we{id=Id,mat=MatTab}|Shs], OldMat) ->
182 182
     end;
183 183
 make_fake_selection_1([], _) -> [].
184 184
 
185  
-select_material(Mat, #st{shapes=Shs}=St) ->
186  
-    Sel = foldl(fun(We, A) ->
187  
-			select_material_1(We, Mat, A)
  185
+select_material(Mat,SelAct,#st{selmode=SelMode,sel=Sel0,shapes=Shs}=St) ->
  186
+    Sel = foldl(fun(#we{id=Id,perm=Perm}=We, Acc) when ?IS_SELECTABLE(Perm) andalso not ?IS_ANY_LIGHT(We) ->
  187
+            Sel1=lists:keyfind(Id, 1, Sel0), % check if Id is already in previous selection
  188
+            Sel2=selected_we(SelMode, We, Mat), % get #we selection using Mat
  189
+            select_material_1(SelAct,Sel1,Sel2,Acc);
  190
+        (_, Acc) -> Acc  % process no selectable or light #we
188 191
 		end, [], gb_trees:values(Shs)),
189 192
     wings_sel:set(Sel, St).
190 193
 
191  
-select_material_1(#we{id=Id,fs=Ftab,perm=Perm}=We, Mat, Acc) when ?IS_SELECTABLE(Perm) ->
  194
+%% sel_rem - remove #we's using Mat from any previous selection
  195
+select_material_1(sel_rem,Sel1,Sel2,Acc) ->
  196
+    case Sel1 of
  197
+    false -> Acc; % #we ins't in previous selection - nothing to do
  198
+    _ ->
  199
+        case subtract_sel(Sel1,Sel2) of
  200
+        false -> Acc;
  201
+        {_,GbNew}=Sel3 -> 
  202
+        case gb_sets:is_empty(GbNew) of
  203
+            true -> Acc;
  204
+            _ -> [Sel3|Acc]
  205
+            end
  206
+        end
  207
+    end;
  208
+%% select - select #we's using Mat - the original behavior
  209
+%% sel_add - add #we's using Mat to any previous selection
  210
+select_material_1(SelAct,Sel1,Sel2,Acc) ->
  211
+    case Sel2 of
  212
+    false ->
  213
+        case SelAct of
  214
+        select -> Acc;
  215
+        sel_add -> 
  216
+            case concat_sel(Sel1,false) of
  217
+            [] -> Acc;
  218
+            Sel3 -> [Sel3|Acc]  % preserve previous selection of #we
  219
+            end
  220
+        end;
  221
+    Sel2 ->
  222
+        case SelAct of
  223
+        select -> [Sel2|Acc]; % we are building a new selection 
  224
+        sel_add -> [concat_sel(Sel1,Sel2)|Acc] % if so, we will update the previous selection
  225
+        end
  226
+    end.
  227
+
  228
+%% select the elements (face/edge/vertice) using the Mat
  229
+selected_we(SelMode,#we{id=Id,fs=Ftab,perm=Perm}=We, Mat) ->
192 230
     MatFaces = wings_facemat:mat_faces(gb_trees:to_list(Ftab), We),
193 231
     case keyfind(Mat, 1, MatFaces) of
194 232
 	false ->
195  
-	    Acc;
  233
+	    false;
196 234
 	{Mat,FaceInfoList} ->
197  
-	    Sel = [F || {F,_} <- FaceInfoList, F >= 0],
198  
-	    [{Id,gb_sets:from_ordset(Sel)}|Acc]
199  
-    end;
200  
-select_material_1(_, _, Acc) ->
201  
-    Acc.
  235
+	    Fs = [F || {F,_} <- FaceInfoList, F >= 0],
  236
+		SelItems = case SelMode of
  237
+			vertex -> wings_face:to_vertices(Fs, We);
  238
+			edge -> wings_face:to_edges(Fs, We);
  239
+			_ -> Fs
  240
+			end,
  241
+		{Id,gb_sets:from_ordset(SelItems)}
  242
+	end.
  243
+
  244
+concat_sel(false,false) -> [];
  245
+concat_sel(false,NewSel) -> NewSel;
  246
+concat_sel(OldSel,false) -> OldSel;
  247
+concat_sel({Id,GbSetOld},{Id,GbSetNew}) ->
  248
+    {Id,gb_sets:union(GbSetOld,GbSetNew)}.
  249
+
  250
+subtract_sel(false,false) -> false;
  251
+subtract_sel(false,_) -> false;
  252
+subtract_sel(OldSel,false) -> OldSel;
  253
+subtract_sel({Id,GbSetOld},{Id,GbSetNew}) ->
  254
+    {Id,gb_sets:subtract(GbSetOld,GbSetNew)}.
  255
+
202 256
 
203 257
 set_material(Mat, #st{selmode=face}=St) ->
204 258
     wings_sel:map(fun(Faces, We) ->
2  src/wings_msg.erl
@@ -23,7 +23,7 @@
23 23
 -include("wings.hrl").
24 24
 
25 25
 -import(lists, [reverse/1]).
26  
--define(SEP, [$\s,$\s,160]).			%Two and a half.
  26
+-define(SEP, [160,160,160,160,160]).    %Equivalent to two and a half space character width.
27 27
 -define(CSEP, 160).				%Short space.
28 28
 
29 29
 button(LmbMsg) ->
23  src/wings_outliner.erl
@@ -202,8 +202,10 @@ do_menu(Act, X, Y, #ost{os=Objs}) ->
202 202
 		    {?__(3,"Assign to Selection"),menu_cmd(assign_material, Name),
203 203
 		     ?__(4,"Assign the material to the selected faces or bodies")},
204 204
 		    separator,
205  
-		    {?__(5,"Select"),menu_cmd(select_material, Name),
206  
-		     ?__(6,"Select all faces that have this material")},
  205
+		    {?__(5,"Select"),select_menu(Name),
  206
+				{?__(6,"Select all elements that have this material"),
  207
+				 ?__(27,"Add all elements that have this material to selection"),
  208
+				 ?__(28,"Remove all elements that have this material from selection")},[]},
207 209
 		    separator,
208 210
 		    {?__(7,"Duplicate"),menu_cmd(duplicate_material, Name),
209 211
 		     ?__(8,"Duplicate this material")},
@@ -242,6 +244,16 @@ do_menu(Act, X, Y, #ost{os=Objs}) ->
242 244
 	true -> wings_menu:popup_menu(X, Y, outliner, Menu)
243 245
     end.
244 246
 
  247
+select_menu(Name) ->
  248
+    fun(1, _Ns) ->
  249
+	    button_menu_cmd(select_material, [Name,select]);
  250
+       (2, _Ns) ->
  251
+	    button_menu_cmd(select_material, [Name,sel_add]);
  252
+       (3, _Ns) ->
  253
+	    button_menu_cmd(select_material, [Name,sel_rem]);
  254
+       (_, _) -> ignore
  255
+    end.
  256
+
245 257
 image_menu(Id, Im) ->
246 258
     [{?__(1,"Show"),menu_cmd(show_image, Id),
247 259
       ?__(2,"Show the image in a window")}|image_menu_1(Id, Im)].
@@ -272,12 +284,15 @@ common_image_menu(Id) ->
272 284
 menu_cmd(Cmd, Id) ->
273 285
     {'VALUE',{Cmd,Id}}.
274 286
 
  287
+button_menu_cmd(Cmd, Id) ->
  288
+    {outliner,{Cmd,Id}}.
  289
+
275 290
 command({edit_material,Name}, _Ost) ->
276 291
     wings_wm:send(geom, {action,{material,{edit,Name}}});
277 292
 command({assign_material,Name}, _Ost) ->
278 293
     wings_wm:send(geom, {action,{material,{assign,Name}}});
279  
-command({select_material,Name}, _Ost) ->
280  
-    wings_wm:send(geom, {action,{material,{select,[Name]}}});
  294
+command({select_material,Parameters}, _Ost) ->
  295
+    wings_wm:send(geom, {action,{material,{select,Parameters}}});
281 296
 command({duplicate_material,Name}, _Ost) ->
282 297
     wings_wm:send(geom, {action,{material,{duplicate,[Name]}}});
283 298
 command({delete_material,Name}, _Ost) ->
2  src/wings_sel_cmd.erl
@@ -1704,7 +1704,7 @@ faces_with(Filter, #st{selmode=Mode}=St0) ->
1704 1704
 				  _ -> [{Id,gb_sets:from_list(Faces)}|Acc]
1705 1705
 				end
1706 1706
 			end, [], St),
1707  
-	{save_state,wings_sel:set(face,Sel,St0)}.
  1707
+    wings_sel:set(face,Sel,St0).
1708 1708
 
1709 1709
 faces_with(Filter, Face, We) ->
1710 1710
     Vs = wings_face:vertices(Face, We),
17  src/wings_shape.erl
@@ -40,7 +40,7 @@
40 40
 %% new(Name, We, St0) -> St.
41 41
 %%  Create a new object having the given name,
42 42
 %%  converting all unknown materials to default.
43  
-new(Name, We0, #st{shapes=Shapes0,onext=Oid,mat=Mat,pst=StPst}=St) ->
  43
+new(Name, #we{pst=WePst}=We0, #st{shapes=Shapes0,onext=Oid,mat=Mat,pst=StPst}=St) ->
44 44
     UsedMat = wings_facemat:used_materials(We0),
45 45
     We =
46 46
 	case lists:filter(
@@ -53,7 +53,20 @@ new(Name, We0, #st{shapes=Shapes0,onext=Oid,mat=Mat,pst=StPst}=St) ->
53 53
 		wings_facemat:assign(default, [F||{F,_}<-FMs], We0)
54 54
 	end,
55 55
     Shapes = gb_trees:insert(Oid, We#we{name=Name,id=Oid}, Shapes0),
56  
-    {DefaultFolder,_} = gb_trees:get(?FOLDERS, StPst),
  56
+    {DefaultFolder0,FldList} = gb_trees:get(?FOLDERS, StPst),
  57
+
  58
+	DefaultFolder=case gb_trees:is_empty(WePst) of  % check needed for compatibilty (old wings files hasn't this field)
  59
+	false ->
  60
+		WeFolder0 = gb_trees:get(wings_shape, WePst),  % checking for we's folder settings
  61
+		case lists:keymember(WeFolder0,1,FldList) of  % validating the folder
  62
+		true ->
  63
+			WeFolder0;
  64
+		false ->
  65
+			DefaultFolder0
  66
+		end;
  67
+	true ->
  68
+		DefaultFolder0
  69
+    end,
57 70
     add_to_folder(DefaultFolder, Oid, St#st{shapes=Shapes,onext=Oid+1}).
58 71
 
59 72
 %% new(We, Suffix, St0) -> St.
9  src/wings_view.erl
@@ -1375,8 +1375,13 @@ export_views_1([{View,Name}|Views]) ->
1375 1375
     [{view,Props}|export_views_1(Views)];
1376 1376
 export_views_1([]) -> [].
1377 1377
 
1378  
-import_views(Views, #st{views={CurrentView,_}}=St) ->
1379  
-    St#st{views={CurrentView,list_to_tuple(import_views_1(Views))}}.
  1378
+import_views(Views, #st{views={CurrentView,OldViews}}=St) ->
  1379
+	NewViews0=import_views_1(Views),
  1380
+	OldViews0 = case OldViews of
  1381
+	{} -> [];
  1382
+	OldViews1 -> tuple_to_list(OldViews1)
  1383
+	end,
  1384
+    St#st{views={CurrentView,list_to_tuple(OldViews0++NewViews0)}}.
1380 1385
 
1381 1386
 import_views_1([{view,As}|Views]) ->
1382 1387
     [import_view(As)|import_views_1(Views)];
120  src/wings_wm.erl
@@ -110,10 +110,12 @@ init() ->
110 110
 desktop_event(_) -> keep.
111 111
 
112 112
 message(Message) ->
113  
-    wings_io:putback_event({wm,{message,get(wm_active),Message}}).
  113
+	MsgData0=get_window_data(message),
  114
+	put_window_data(message,MsgData0#win{z=highest_z()}),
  115
+	wings_io:putback_event({wm,{message,get(wm_active),Message}}).
114 116
 
115 117
 message_right(Right) ->
116  
-    wings_io:putback_event({wm,{message_right,get(wm_active),Right}}).
  118
+	wings_io:putback_event({wm,{message_right,get(wm_active),Right}}).
117 119
 
118 120
 message(Message, Right) ->
119 121
     message(Message),
@@ -899,10 +901,10 @@ wm_event({message,Name,Msg}) ->
899 901
 	none -> ok;
900 902
 	#win{stk=[#se{msg=Msg}|_]} -> ok;
901 903
 	#win{stk=[Top0|Stk]}=Data0 ->
902  
-	    Top = Top0#se{msg=Msg},
903  
-	    Data = Data0#win{stk=[Top|Stk]},
904  
-	    put_window_data(Name, Data),
905  
-	    dirty()
  904
+		Top = Top0#se{msg=Msg},
  905
+		Data = Data0#win{stk=[Top|Stk]},
  906
+		put_window_data(Name, Data),
  907
+		dirty()
906 908
     end;
907 909
 wm_event({message_right,Name,Right0}) ->
908 910
     Right = lists:flatten(Right0),
@@ -910,10 +912,10 @@ wm_event({message_right,Name,Right0}) ->
910 912
 	none -> ok;
911 913
 	#win{stk=[#se{msg_right=Right}|_]} -> ok;
912 914
 	#win{stk=[Top0|Stk]}=Data0 ->
913  
-	    Top = Top0#se{msg_right=Right},
914  
-	    Data = Data0#win{stk=[Top|Stk]},
915  
-	    put_window_data(Name, Data),
916  
-	    dirty()
  915
+		Top = Top0#se{msg_right=Right},
  916
+		Data = Data0#win{stk=[Top|Stk]},
  917
+		put_window_data(Name, Data),
  918
+		dirty()
917 919
     end;
918 920
 wm_event({menubar,Name,Menubar}) ->
919 921
     case lookup_window_data(Name) of
@@ -1156,8 +1158,9 @@ message_event(redraw) ->
1156 1158
 	undefined -> keep;
1157 1159
 	Active ->
1158 1160
 	    #win{stk=[#se{msg=Msg,msg_right=Right}|_]} = get_window_data(Active),
1159  
-	    message_redraw(Msg, Right)
1160  
-    end;
  1161
+	    Msg0=calculate_win_size(Msg,Right),
  1162
+	    message_redraw(Msg0, Right)
  1163
+	end;
1161 1164
 message_event({action,_}=Action) ->
1162 1165
     send(geom, Action);
1163 1166
 message_event(got_focus) ->
@@ -1176,6 +1179,7 @@ message_redraw(Msg, Right) ->
1176 1179
 		 {unix,darwin} -> 27;
1177 1180
 		 _ -> 0
1178 1181
 	    end,
  1182
+
1179 1183
     case Right of
1180 1184
 	[] -> ok;
1181 1185
 	_ ->
@@ -1183,17 +1187,13 @@ message_redraw(Msg, Right) ->
1183 1187
 	    Cw = ?CHAR_WIDTH,
1184 1188
 	    CH = ?CHAR_HEIGHT,
1185 1189
 	    Lh = ?LINE_HEIGHT,
1186  
-	    MsgW = wings_text:width(lists:flatten(Msg)),
  1190
+
1187 1191
 	    RightW = wings_text:width(Right),
1188 1192
 	    RMarg = RMarg0 + 2*Cw,
1189  
-	    if
1190  
-		MsgW+RightW < W - RMarg ->
1191  
-		    Pos = W - RightW - RMarg,
1192  
-		    wings_io:sunken_rect(Pos-12, -CH, RightW+12, Lh, Col, Col),
1193  
-		    wings_io:set_color(wings_pref:get_value(info_line_text)),
1194  
-		    wings_io:text_at(Pos-6, -1, Right);
1195  
-		true -> ok
1196  
-	    end
  1193
+		Pos = W - RightW - RMarg,
  1194
+		wings_io:sunken_rect(Pos-12, -CH, RightW+12, Lh-1, Col, Col),
  1195
+		wings_io:set_color(wings_pref:get_value(info_line_text)),
  1196
+		wings_io:text_at(Pos-6, -1, Right)
1197 1197
     end,
1198 1198
     case OsType of
1199 1199
 	{unix,darwin} ->
@@ -1209,9 +1209,85 @@ message_setup() ->
1209 1209
     {W,H} = win_size(),
1210 1210
     wings_io:gradient_rect_burst(0, 0, W, H, wings_pref:get_value(info_line_bg)),
1211 1211
     wings_io:set_color(wings_pref:get_value(info_line_text)),
1212  
-    gl:translatef(10, H-5.375, 0),
  1212
+    gl:translatef(10, ?LINE_HEIGHT+2, 0),
1213 1213
     {W,H}.
1214 1214
 
  1215
+calculate_win_size(Msg,Right) ->
  1216
+% this '+24' came from message_redraw() used in 'sunken_rect' function
  1217
+    Right_W=wings_text:width(lists:flatten(Right))+24,
  1218
+
  1219
+    OsType = get(wings_os_type),
  1220
+    RMarg0 = case OsType of
  1221
+		 {unix,darwin} -> 27;
  1222
+		 _ -> 0
  1223
+	    end,
  1224
+
  1225
+	{Msg0,WinSize}=check_text_width(Msg,Right_W+RMarg0),
  1226
+	resize_msg_win(WinSize),
  1227
+	Msg0.
  1228
+
  1229
+resize_msg_win({X0,Y0,W0,H0}) ->
  1230
+	MsgData0=get_window_data(message),
  1231
+	put_window_data(message,MsgData0#win{x=X0,y=Y0,w=W0,h=H0}),
  1232
+    OldActive = put(wm_active, message),
  1233
+    {_,TopH} = get(wm_top_size),
  1234
+    Y = TopH-(Y0+H0),
  1235
+    ViewPort = {X0,Y,W0,H0},
  1236
+    case put(wm_viewport, ViewPort) of
  1237
+	ViewPort -> ok;
  1238
+	_ -> gl:viewport(X0,Y,W0,H0)
  1239
+    end,
  1240
+    case OldActive of
  1241
+	undefined -> none;
  1242
+	_ -> put(wm_active, OldActive)
  1243
+    end.
  1244
+
  1245
+check_text_width(Msg,RightW) ->
  1246
+	{W,H0}=win_size(desktop),
  1247
+    MaxW=W-RightW,
  1248
+	Msg0=strip_lines(Msg,MaxW),
  1249
+	NrLn=count_lines(Msg0),
  1250
+	InfoH = case NrLn of
  1251
+		1 -> ?LINE_HEIGHT;
  1252
+		_ -> round(NrLn*?LINE_HEIGHT)
  1253
+	end,
  1254
+	H=InfoH+trunc(?LINE_HEIGHT/2)-1,
  1255
+	Y = H0-InfoH+?CHAR_HEIGHT+2,
  1256
+	{Msg0,{0,Y,W,H}}.
  1257
+
  1258
+strip_lines(Msg,W) ->
  1259
+	Msg0=lists:flatten(Msg),
  1260
+	Tw=wings_text:width(Msg0),
  1261
+	if Tw=<W -> Msg;
  1262
+	true ->
  1263
+		break_line(Msg0,W)
  1264
+	end.
  1265
+
  1266
+break_line(Msg,W) ->
  1267
+	Msg0=split_msg(Msg,[]),
  1268
+	MsgSpl=string:tokens(Msg0," "),
  1269
+	{_,MsgSp2}=lists:foldl(fun(E,{WAcc,Acc}) ->
  1270
+			WAcc0 = WAcc+wings_text:width(E)+?CHAR_WIDTH,
  1271
+			if WAcc0>W ->
  1272
+				{0,Acc++[$\n]++E++[" "]};
  1273
+			true -> {WAcc0,Acc++E++[" "]}
  1274
+			end
  1275
+		end ,{0,[]}, MsgSpl),
  1276
+	MsgSp2.
  1277
+
  1278
+split_msg([],Acc) -> Acc;
  1279
+split_msg([{_Fmt,_Txt}=H|T],Acc) ->
  1280
+	split_msg(T,Acc++[H]);
  1281
+split_msg([H|T],Acc) ->
  1282
+	split_msg(T,Acc++[H]).
  1283
+
  1284
+count_lines([]) -> 1;
  1285
+count_lines([$\n|S]) ->
  1286
+	count_lines(S)+1;
  1287
+count_lines([_|S]) ->
  1288
+	count_lines(S).
  1289
+
  1290
+
1215 1291
 %%%
1216 1292
 %%% Toplevel: create a window and a controller window at the same time.
1217 1293
 %%% The controller adds a title bar (allowing the window to be moved) and
2  src/wings_wm_toplevel.erl
@@ -142,7 +142,7 @@ get_ctrl_event(Cs) ->
142 142
     {replace,fun(Ev) -> ctrl_event(Ev, Cs) end}.
143 143
 		     
144 144
 ctrl_event(redraw, Cs) ->
145  
-    ctrl_message(),
  145
+%    ctrl_message(),
146 146
     ctrl_redraw(Cs);
147 147
 ctrl_event(#mousebutton{button=1,state=?SDL_PRESSED},
148 148
 	   #ctrl{state=moving,prev_focus=Focus}=Cs) ->
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.