LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Draw and move an arc .

Hope can draw an arc with cvi , and the line width and color is adjustable ,after drawing ,it can be moved to anywhere with mouse . Can realize this function with CVI 7 ? thanks .

David
0 Kudos
Message 1 of 6
(3,927 Views)
One way of doing is to overlay a transparent graph control on top of your UI panel. You can add a cursor to the graph that users can move around. The cursor itself can be transparent, so that it's not visible to users.
Whenever they move the cursor to a new position (by clicking and drawing anywhere in the plot area of the graph), you will receive an EVENT_COMMIT in the graph's callback. In that callback, you can get the graph cursor position, expressed in graph units. You can then call the PlotArc function using the position of the graph cursor as a guide.

There are a couple of issues to keep in mind. One is performance: plotting to a transparent graph is going to be slower than plotting to a normal graph. This will probably be okay, since you'll only be plotting a single plot occasionally, which is not very intensive. The other issue is where in the z-plane order to place the graph. The best solution here depends on the rest of your panel... if you place the graph at the top of the z-plane, users will be able to operate the graph cursor no matter where they click, but they will not be able to interact with the other controls in your panel using the mouse. The other possibility is to place the graph at the bottom of the z-plane order (in which case it won't even have to be transparent). The drawback here is that they will only be able to grab the cursor if they click on the panel (in between other controls). Also, the arc would be clipped by the other controls. A possible compromise would be for you to require them to do some special mouse-button combination to move the plot. You could catch this combination in the panel callback, and then bring the graph to the top at that exact instant, so that the graph gets the event, instead of some other control.

One last thing... you can also do this using a canvas control instead of a graph. The downside is that you don't have cursors, so you'd have to use the extended mouse events from the toolbox, but the upside is that you don't have to worry about graph units. You can deal with pixels directly. The canvas would also be faster.

Hope this gives you something to get started.

Luis
NI
0 Kudos
Message 2 of 6
(3,927 Views)
David,

There is also the possibility of creating a child panel that you shape like an arc, this is not very difficult and gives you better performance. It also becomes very easy to catch the user events since you can setup a callback for the shaped panel.

I have created a small example to get you started, it's not complete by far, but shows how to shape the panel as an arc, display it as a child window, catch some events and change some of the properties.

I hope this helps.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 3 of 6
(3,927 Views)
Thanks Luis . I think that I should be also available to draw an arbitrary shape on a canvas with the mouse move , and then move the sape anywhere , can do that with CVI ?

David
0 Kudos
Message 4 of 6
(3,927 Views)
Yes, after drawing the shape, you can move the canvas anywhere you like, and the shape will move with it.

Luis
0 Kudos
Message 5 of 6
(3,927 Views)
Juan ,

For this example , how to enlarge the arc via mouse, I want to change its curvature ,can save it as .wmf ,.bmp or .pcx format file ?

David
0 Kudos
Message 6 of 6
(3,927 Views)