微信:HuangL1121
QQ号:1224848052
团队:MATLAB代做|MATLAB专业代做|硕士博士代写
地址:北京市-朝阳区-双柳北街18号院
当前位置:首页 > 其他专业 > 基于MATLAB的画图板的实现
项目案例
基于MATLAB的画图板的实现
基于MATLAB的画图板的实现
产品说明:

基于MATLAB的画图板的实现

% --- Executes during object creation, after setting all properties.
function figure1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
global flg mark rgb graph;
flg=0;   %f初始鼠标没有按下
graph='点线';
mark='.';
rgb=[1,0,0];
function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global flg  mark rgb x0 y0 x y rect graph;
flg=1;
set(handles.pushbutton2,'enable','on');
set(handles.pushbutton3,'enable','on');
currPt = get(gca, 'CurrentPoint');
x = currPt(1,1);
y = currPt(1,2);
switch(graph)
    case '点线'
        line(x,y, 'marker', mark,'color',rgb);
    otherwise
        line(x,y,'LineStyle',mark,'color',rgb);
end
x0=x;y0=y;
set(handles.edit1,'string',num2str(x));
set(handles.edit2,'string',num2str(y));
set(handles.text3,'string','Mouse down!');

% --- Executes on mouse motion over figure - except title and menu.
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global flg mark rgb x0 y0 x y rect graph h;
if flg
    switch(graph)
        case '点线'
            currPt=get(gca, 'CurrentPoint');
            x=currPt(1,1);
            y=currPt(1,2);
            line(x,y, 'marker', mark,'color',rgb);
        case '线形'
            x0=x;y0=y;
            currPt=get(gca, 'CurrentPoint');
            x=currPt(1,1);
            y=currPt(1,2);
            line([x0 x], [y0,y],'LineStyle',mark,'color',rgb);
        case '矩形'
            currPt=get(gca, 'CurrentPoint');
            x=currPt(1,1);
            y=currPt(1,2);
            if x~=x0
                if ~isempty(h)
                    set(h,'Visible','off')
                end
                rect=[min([x0,x]),min([y0,y]),abs(x-x0),abs(y-y0)];
                if rect(3)*rect(4)~=0
                    h=rectangle('Position',rect,'LineStyle',':');
                end
            end
        case '椭圆'
            currPt=get(gca, 'CurrentPoint');
            x=currPt(1,1);
            y=currPt(1,2);
            if x~=x0
                if ~isempty(h)
                    set(h,'Visible','off')
                end
                rect=[min([x0,x]),min([y0,y]),abs(x-x0),abs(y-y0)];
                if rect(3)*rect(4)~=0
                    h=rectangle('Position',rect,'Curvature',[1,1],'LineStyle',':');
                end
            end
    end
    set(handles.edit1,'string',num2str(x));
    set(handles.edit2,'string',num2str(y));
    set(handles.text3,'string','Mouse is moving!');
end

function figure1_WindowButtonUpFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global flg rgb mark h graph rect;
flg=0;
switch(graph)
    case '矩形'
        set(h,'Visible','off');h=[];
        if rect(3)*rect(4)~=0
            rectangle('Position',rect,'edgecolor',rgb,'LineStyle',mark)
        end
    case '椭圆'
        set(h,'Visible','off');h=[];
        if rect(3)*rect(4)~=0
            rectangle('Position',rect,'Curvature',[1,1],'edgecolor',rgb,'LineStyle',mark)
        end
end
set(handles.text3,'string','Mouse up!');
matlab代做|matlab专业代做|matlab淘宝代做

FPGA代做|FPGA专业代做|FPGA淘宝代做

simulink代做|simulink专业代做|simulink淘宝代做
QQ: 1224848052
网址1:www.hslogic.com
网址2:www.mat7lab.com


上一篇:基于FPGA的高速信号采集系统

版权所有: MATLAB代做|MATLAB专业代做|硕士博士代写 Copyright © 2018 All rights reserved.
微信:HuangL1121 QQ:1224848052
地址:北京市-朝阳区-双柳北街18号院

扫一扫,关注我们