基于MATLAB的仿windows画图板功能的实现
生活随笔
收集整理的這篇文章主要介紹了
基于MATLAB的仿windows画图板功能的实现
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.仿真預(yù)覽
2.部分核心代碼
% --- Executes on selection change in popupmenu2. function popupmenu2_Callback(hObject, eventdata, handles) % hObject handle to popupmenu2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu2 global rgb; str=get(handles.popupmenu2,'string'); index=get(handles.popupmenu2,'value'); str1=char(str(index)); switch (str1)case 'red'rgb=[1,0,0];case 'green'rgb=[0,1,0];case 'blue'rgb=[0,0,1];case 'black'rgb=[0,0,0]; end set(handles.edit1,'foregroundcolor',rgb); set(handles.edit2,'foregroundcolor',rgb); set(handles.text3,'foregroundcolor',rgb); % --- Executes during object creation, after setting all properties. function popupmenu2_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called% Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white'); end% --- Executes on mouse press over axes background. function axes1_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % set(gcf, 'Interruptible', 'off','BusyAction', 'cancel'); % set(gcf, 'WindowButtonMotionFcn', '','Interruptible', 'off'); cla set(handles.edit1,'string',''); set(handles.edit2,'string',''); set(handles.text3,'string',''); set(handles.pushbutton2,'enable','off'); set(handles.pushbutton3,'enable','off'); % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [FileName,PathName] = uiputfile({'*.jpg','JPEG(*.jpg)';...'*.bmp','Bitmap(*.bmp)';...'*.gif','GIF(*.gif)';...'*.*', 'All Files (*.*)'},...'Save Picture','Untitled'); if FileName==0return; elseh=getframe(handles.axes1);imwrite(h.cdata,[PathName,FileName]); end% --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) CleanGlobals; close(gcf);% --- Executes on selection change in popupmenu3. function popupmenu3_Callback(hObject, eventdata, handles) % hObject handle to popupmenu3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu3 global graph flag h mark; h=[]; str=get(handles.popupmenu3,'string'); index=get(handles.popupmenu3,'value'); graph=char(str(index)); popu={}; switch(graph)case '點(diǎn)線'popu={'. 點(diǎn)';'+ 號(hào)';'O 圈';'* 號(hào)';'v 三角號(hào)'};set(handles.popupmenu1,'string',popu);set(handles.popupmenu1,'value',1);set(handles.text4,'string','選擇marker')mark='.';otherwisepopu={'- 實(shí)線';'--虛線';': 點(diǎn)線';'-.虛點(diǎn)線';};set(handles.popupmenu1,'string',popu);set(handles.popupmenu1,'value',1);set(handles.text4,'string','選擇LineTyple')mark='-'; endC-02
總結(jié)
以上是生活随笔為你收集整理的基于MATLAB的仿windows画图板功能的实现的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 基于PSO算法的带时间窗的车辆路径问题的
- 下一篇: 通过MATLAB提取图像的深度信息