diff --git a/src/matlab/lrgui.m b/src/matlab/lrgui.m index 9b74d2d..194b5d9 100644 --- a/src/matlab/lrgui.m +++ b/src/matlab/lrgui.m @@ -6,16 +6,20 @@ % Create and then hide the GUI as it is being constructed. - f = figure('Visible','off','Position',[360,500,450,285]); + f = figure('Visible','off','Position',[360,500,450,325]); % Construct the components. hnew = uicontrol('Style','pushbutton','String','New',... - 'Position',[315,240,70,25],... + 'Position',[315,280,70,25],... 'Callback',@newbutton_Callback); hrefine = uicontrol('Style','pushbutton',... 'String','Refine',... - 'Position',[315,200,70,25],... + 'Position',[315,240,70,25],... 'Callback',@refinebutton_Callback); + hraise = uicontrol('Style','pushbutton',... + 'String','Raise Order',... + 'Position',[315,200,90,25],... + 'Callback',@raisebutton_Callback); hload = uicontrol('Style','pushbutton','String','Load',... 'Position',[315,160,70,25],... 'Callback',@loadbutton_Callback); @@ -29,7 +33,7 @@ 'Position',[300,30,100,25],... 'Callback',@popup_menu_Callback); ha = axes('Units','Pixels','Position',[50,60,200,185]); - align([hnew,hrefine,hload,hsave,htext,hpopup],'Center','None'); + align([hnew,hrefine,hraise,hload,hsave,htext,hpopup],'Center','None'); % Create the data to plot. current_mesh = LRSplineSurface([3,3], [10,10]); @@ -43,6 +47,7 @@ hload.Units = 'normalized'; hsave.Units = 'normalized'; hrefine.Units = 'normalized'; + hraise.Units = 'normalized'; htext.Units = 'normalized'; hpopup.Units = 'normalized'; @@ -84,11 +89,9 @@ function popup_menu_Callback(source,eventdata) redraw_mesh(); end - % Push button callbacks. + %%% Push button callbacks. function newbutton_Callback(source,eventdata) - % Display surf plot of the currently selected data. - % surf(current_data); x = inputdlg({'p1', 'p2', 'n1', 'n2'}, 'New LR spline', [1 8], {'3' '3' '10' '10'}); if numel(x) > 0 p = [str2num(x{1}), str2num(x{2})]; @@ -99,8 +102,6 @@ function newbutton_Callback(source,eventdata) end function refinebutton_Callback(source,eventdata) - % Display contour plot of the currently selected data. - % contour(current_data); if ref_elements current_mesh.refine(refine_list, 'elements'); else @@ -109,6 +110,15 @@ function refinebutton_Callback(source,eventdata) redraw_mesh(); end + function raisebutton_Callback(source,eventdata) + if ref_elements + return; + else + current_mesh.localRaiseOrder(refine_list, 'basis'); + end + redraw_mesh(); + end + function loadbutton_Callback(source,eventdata) % Display mesh plot of the currently selected data. [file path] = uigetfile({'*.g2;*.lr', 'Geometry files (*.g2,*.lr)'}); @@ -126,12 +136,14 @@ function savebutton_Callback(source,eventdata) end end - % Keyboard callbacks (hotkeys) + %%% Keyboard callbacks (hotkeys) function keypress(src, e) switch e.Key case 'r' refinebutton_Callback(src, e); + case 'p' + raisebutton_Callback(src, e); case 'e' hpopup.Value = 1; popup_menu_Callback(hpopup,e); @@ -147,7 +159,7 @@ function keypress(src, e) end end - % Mouse callbacks + %%% Mouse callbacks function mouseclick(src,e) x = e.IntersectionPoint; @@ -160,13 +172,13 @@ function mouseclick(src,e) u1 = current_mesh.elements(i,3); v1 = current_mesh.elements(i,4); hold on; - patch([u0,u1,u1,u0], [v0,v0,v1,v1], [.8, .8, .8]); + patch([u0,u1,u1,u0], [v0,v0,v1,v1], [20,20,20,20], [.8, .8, .8]); refine_list = [refine_list, i]; else i = pick_basisfunction(u,v); n = size(current_mesh.knots,1); dots = get(gca,'children'); - dots(i).MarkerFaceColor = [1,0,0]; + dots(i).MarkerFaceColor = [.8,.8,.8]; refine_list = [refine_list, n+1-i]; end end @@ -187,13 +199,27 @@ function mouseclick(src,e) end function redraw_mesh() + c = [0, 0.4470, 0.7410; + 0.8500, 0.3250, 0.0980; + 0.9290, 0.6940, 0.1250; + 0.4940, 0.1840, 0.5560; + 0.4660, 0.6740, 0.1880; + 0.3010, 0.7450, 0.9330; + 0.6350, 0.0780, 0.1840]; refine_list = []; cla hold on; if ref_elements - current_mesh.plot('parametric'); + % current_mesh.plot('parametric'); + p = current_mesh.p(:,1); + current_mesh.surf(p,'parametric'); + caxis([1,7]); + colormap(c); + shading flat; + colorbar; else current_mesh.plot('parametric', 'basis'); + update_colors() end for line = get(gca, 'children')' set(line, 'HitTest', 'off'); @@ -201,4 +227,21 @@ function redraw_mesh() set(gca, 'ButtonDownFcn', @mouseclick); end + function update_colors() + c = [0, 0.4470, 0.7410; + 0.8500, 0.3250, 0.0980; + 0.9290, 0.6940, 0.1250; + 0.4940, 0.1840, 0.5560; + 0.4660, 0.6740, 0.1880; + 0.3010, 0.7450, 0.9330; + 0.6350, 0.0780, 0.1840]; + + n = size(current_mesh.knots,1); + for i=1:n + p = size(current_mesh.knots{i,1},2) - 2; + dots = get(gca,'children'); + dots(n+1-i).MarkerFaceColor = c(p,:); + end + end + end