LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I select an area in a picture to create a control?

 
0 Kudos
Message 1 of 8
(4,062 Views)

I'm not exactly sure of what do you mean with this, but if you are trying to let the user click on a picture and act as if he had pressed a button when on a particular area you can intercept LEFT_CLICK event in the picture control callback and use eventData parameters that on mouse events contains cursor coordinates. Using ConvertMouseCoordinates permits you to translate panel coordinates to picture coordinates, so you can easily detect if the cursor is in a particular area of your picture regardless of its position on the panel.

 // Convert panel coordinates to picture coordinates
 ConvertMouseCoordinates (panel, control, 1, 0, &eventData2, &eventData1);
 // Display them on indicators on the panel
 SetCtrlVal (panel, PANEL_x, eventData2);
 SetCtrlVal (panel, PANEL_y, eventData1);

Another solution could be to cut out some little portion of the picture and use them in a picture button placed on top of the picture: this way you could use standard button callback without need to struggle with mouse coordinates and button frame could guide the user on where to click on the picture to operate on it.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 8
(4,049 Views)
Thanks for your answer, and by the way Let me Explain you what I would like to do.
 
basically we have products that Interface with the Technician at the time that those products are being tested, For example there are products that have buttons, right now we have a tool that shows the picture of the product and we manipulate some Led's callbacks pasted over the image to tell the Tech when He needs to press a product button.
 
I want to create a tool running a CVI application where we can load a Picture an then select an area to create callbacks then those new areas will have some definitions & Variables that can be used by another application to run the test. At this way we don't have to create a UIR per product.
 
About the idea to cut a portion of a Picture what are the functions to do that, because in this way I can paste or transfer this area to any variable that I can use in the future.
 
Regards!!
 
 
0 Kudos
Message 3 of 8
(4,038 Views)

Good afternoon,

 

The suggestions above are great.  The cutting of the picture would be done in some picture editor (not in CVI).  Create a smaller image containing a portion of your original image, and put inside of a picture button.  Superimpose that picture button so that you can’t tell that it’s not the original and generate a callback for the picture button.  When the user presses on that portion of the picture it will fire and event for the picture button.  The limitation of this is that the portions of pictures used will need to be rectangular and so if your product is curvy you will have to choose between making the image too small or too large….

 

Hope this helps-

Travis M
LabVIEW R&D
National Instruments
0 Kudos
Message 4 of 8
(4,022 Views)
Thanks! you are right but,
You mentioned (The cutting of the picture would be done in some picture editor (not in CVI)). This is exactly what I would like to do into CVI, Run a *.UIR application that can create things (Buttons, leds, etc) over some images loaded, so on this tool I will select areas then on a menu choose to create led's or buttons etc.
Finally I will use these new things in another application.
Any ideas???
 
Regards!
0 Kudos
Message 5 of 8
(3,996 Views)

Hello,

 

I assume that you want to generate these objects at design time since all CVI code must be compiled before running.  At design time, you can sort of get the functionality you want by placing a picture down, and placing a transparent-colored command button on top.  Make sure that you specify the z-plane order of the objects such that the transparent button is on top.  The button will catch the events – I think this will actually accomplish what you are asking, try it out and let me know how it goes 🙂

 

Thanks for posting -

Travis M
LabVIEW R&D
National Instruments
Message 6 of 8
(3,976 Views)

Hi!

tell me if I'm wrong, I think another process to check for events is having a timer and then verified into cycle if I press the mouse but my problem is at the time that I know where a press the mouse How can a select an area between two times that the mouse was pressed, as in paint for windows, I know that it is difficult since CVI is not a draw editor but I think that there's is some way to do a little work to generate something like this. Do you if there's any sample that I can use that can have a similar behavior.

Thanks for your help!!!

0 Kudos
Message 7 of 8
(3,946 Views)
Victor,
GetGlobalMouseState can help you a lot in your application. You should run samples\userint\mpustate.prj example and study it to check how to use this function. Since it returns mouse coodinates and mouse buttons state you can mimic a drag-and-drop operation that defines a rectangle on your panel.
 


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 8 of 8
(3,934 Views)