में जीयूआई पर माउस के साथ ड्राइंग करना मैं प्रोग्राम चलाने पर जीयूआई के साथ मैटलैब में एक प्रोग्राम करना चाहता हूं, उपयोगकर्ता GUI में अक्षों पर माउस के साथ कुछ भी आकर्षित कर सकता है, और मैं एक मैट्रिक्स में बनाई गई छवि को सहेजना चाहता हूं। मैं यह कैसे कर सकता हूं?matlab
matlab
उत्तर
अंत में मैं एक अच्छा कोड खोजने के लिए और मैं मेरे लिए अनुकूलित करने के लिए कुछ भागों को बदल दिया है। इस तरह के साथ, उपयोगकर्ता माउस के साथ कुल्हाड़ियों में anythings ड्राइंग कर सकते हैं:
function userDraw(handles)
%F=figure;
%setptr(F,'eraser'); %a custom cursor just for fun
A=handles.axesUserDraw; % axesUserDraw is tag of my axes
set(A,'buttondownfcn',@start_pencil)
function start_pencil(src,eventdata)
coords=get(src,'currentpoint'); %since this is the axes callback, src=gca
x=coords(1,1,1);
y=coords(1,2,1);
r=line(x, y, 'color', [0 .5 1], 'LineWidth', 2, 'hittest', 'off'); %turning hittset off allows you to draw new lines that start on top of an existing line.
set(gcf,'windowbuttonmotionfcn',{@continue_pencil,r})
set(gcf,'windowbuttonupfcn',@done_pencil)
function continue_pencil(src,eventdata,r)
%Note: src is now the figure handle, not the axes, so we need to use gca.
coords=get(gca,'currentpoint'); %this updates every time i move the mouse
x=coords(1,1,1);
y=coords(1,2,1);
%get the line's existing coordinates and append the new ones.
lastx=get(r,'xdata');
lasty=get(r,'ydata');
newx=[lastx x];
newy=[lasty y];
set(r,'xdata',newx,'ydata',newy);
function done_pencil(src,evendata)
%all this funciton does is turn the motion function off
set(gcf,'windowbuttonmotionfcn','')
set(gcf,'windowbuttonupfcn','')
ginput
फ़ंक्शन एक आकृति के भीतर म्यूक्लिक के निर्देशांक प्राप्त करता है। आप इन्हें लाइन, पॉलीगॉन इत्यादि के अंक के रूप में उपयोग कर सकते हैं।
यदि यह आपकी आवश्यकताओं के अनुरूप नहीं है तो आपको यह निर्धारित करने की आवश्यकता है कि आप वास्तव में उपयोगकर्ता को आकर्षित करने की अपेक्षा करते हैं।
मुक्तहस्त ड्राइंग के लिए यह उपयोगी हो सकता है:
http://www.mathworks.com/matlabcentral/fileexchange/7347-freehanddraw
मैं चरित्र है कि उपयोगकर्ता ड्राइंग, तो उपयोगकर्ता अक्षरांकीय चरित्र ड्राइंग में सक्षम होना चाहिए का पता लगाने के लिए एक कार्यक्रम विकसित किया है। –
ऊपर मेरा संपादन देखें। –
एक ही रास्ता मैं एक माउस का उपयोग कर matlab खिड़कियों के साथ बातचीत करने के लिए पता ginput है, लेकिन यह अब आप तरलता के साथ कुछ भी आकर्षित करने देगा।
अधिक जानकारी के लिए मैटलैब चेक http://undocumentedmatlab.com/ में जावा स्विंग घटकों का उपयोग करने के तरीके हैं।
संपादित करें: आप इसे भी देखना चाहेंगे।
http://blogs.mathworks.com/videos/2008/05/27/advanced-matlab-capture-mouse-movement/
- 1. MATLAB: MATLAB
- 2. कैसे MATLAB में MATLAB
- 3. matlab
- 4. MATLAB
- 5. MATLAB
- 6. MATLAB
- 7. matlab
- 8. Matlab
- 9. matlab
- 10. MATLAB
- 11. MATLAB
- 12. MATLAB
- 13. MATLAB
- 14. matlab
- 15. MATLAB
- 16. Matlab
- 17. Matlab
- 18. matlab
- 19. MATLAB
- 20. Matlab
- 21. MATLAB
- 22. MATLAB
- 23. Matlab
- 24. MATLAB
- 25. MATLAB
- 26. matlab
- 27. MATLAB
- 28. MATLAB
- 29. matlab
- 30. matlab
मैं इन फ़ंक्शन को आकर्षित करने के लिए कैसे उपयोग करूं? – mikeglaz