LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using an image with position dependent callbacks...

Hi All!

I have the following issue.

I would like to use an image representing a complex flowchart in order to activate some blocks of my system just by clicking on the corresponding part of the schematic.

I read that one solution that has been proposed is to superimpose to the overall image some small images that activate different callbacks.

However, aligning the above mentioned small images to the original one while mantaining the correct scale factor and overlap is driving me crazy.

Is there some way to pre-process the image (something like a gif map commonly found on websites) to solve it?

Any comment and suggestion will be really appreciated.

Finally, is there a reason why in a CVI panel it is not possible to draw a shape (like an arrow for instance)??

Thank you for the attention

 

Francesco

 

 

0 Kudos
Message 1 of 7
(3,851 Views)

One approach to this problem is to draw your image on a Canvas control, and assign a callback to the control. Within the callback, trap EVENT_LEFT_CLICK, at which point the parameters eventData1 and eventData2 will supply the mouse coordinates at which the click occurred. You can then do some elementary comparisons on these values to see if the coordinates are within regions of the image that you want to detect.

 

Check out the CanvasDraw* functions - for example you might be able to use CanvasDrawPoly() to draw an arrow shape.

 

JR

0 Kudos
Message 2 of 7
(3,838 Views)

Hi JR,

I will try your solution. However I found this discussion of a problem that is similar to mine. Unfortunately, the author did not comment on the successfullness of its operation.

Do you have hany comment on this??

Thanks

 

Francesco

 

0 Kudos
Message 3 of 7
(3,836 Views)

That discussion seemed to focus on manipulating a Visio drawing within CVI, as an ActiveX control. (So that the nodes can be edited or updated, for example.) It does not seem to me to be a suitable approach for your problem, which as I understand it is simply to detect "sweet spots" within a static image.

 

JR

0 Kudos
Message 4 of 7
(3,832 Views)

You are right, in principle. But what I would like to do is also to highlight selected paths/blocks and probably ta Visio ActiveX can be the solution. However, I am not sure if it is possible to do this since I am still reading some documentation from MS about it. Unfortunately, the CVI documentation is quite vague on those topics.

Ciao

 

Francesco 

0 Kudos
Message 5 of 7
(3,829 Views)

Hi!

I finally decided for the solution suggested by JR. However, as far as I remember, there should be a function that automatically detect if the mouse pointer is within a rectangular region. Unfortunately, I do not remember it and I cannot find it in the funcion tree...  Do someone by chance remember this function??

thanks

 

Francesco

0 Kudos
Message 6 of 7
(3,803 Views)

I would probably use something along the following lines:

 

int InArea (int top, int left, int height, int width, int mouseX, int mouseY) {

 

    if (mouseX < left)

        return 0;

    if (mouseY < top)

        return 0;

    if (mouseX >= left + width)

        return 0;

    if (mouseY >= top + height)

        return 0;

    return 1;

}

 

Possibly in conjunction with an array of structures, defining the required areas and any associated data (eg constants for subsequent switch () operations; function pointers etc).

 

JR

0 Kudos
Message 7 of 7
(3,794 Views)