07-10-2006 11:12 PM
07-11-2006 01:18 AM
You're already using the picture control, which is a step in the right direction. The closest thing I can think of (which I know) is the UML modeller which was made for one of the GOOP toolkits.
While you're right that the OS should do this, this is not possible in this case, since all LV front panel objects are handled by LV and not accessible to the OS (because LV runs on multiple platforms). LV can't do it either, since you're creating your own interface, so it's up to you.
Processing mouse events is relatively easy using the event structure. You can get Mouse Up, Down, Move, Enter and Leave events and write a few subVIs to convert their coords to work with your interface and identifying which control you're on and so on. Creating a ghost outline should be relatively easy if you know the size and shape of a control and keep redrawing over a base picture instead of using a shift register to keep the latest picture.
The cursor stuff (like resizing handles) can be handled by using the cursor VIs (in the Application Control palette).
In short, this is definitely doable, but you need to handle all the corner cases (like the mouse leaving the picture control) to avoid getting stuck with a weird image and you need to remember that the picture control is not the best performing display out there. As long as you keep to vectoric data, you should be alright, though.
Here you can find some examples of picture control (ab?)use.
07-11-2006 02:15 PM
07-11-2006 06:53 PM
07-12-2006 02:59 AM
I don't have any real experience in VB, but I can tell you that things which require dynamic UIs are not supported in the current state LV is in, because there is a very tight coupling between the UI and the code. There are ways around this (like creating "enough" controls and manipulating them or using the picture control), but they are ultimately not very efficient (the picture control, for instance, is simply a string describing how to build the vectoric elements and describing other stuff on a pixel-by-pixel basis and to change the image the string has to be modified).
So what you want is feasible (as long as the graphics demands are not too high), but you would have to create your own infrastructure and so it might be better to use another tool. As for whether someone has done it, as I said, I believe one of NI's (Endevo's, actually) GOOP toolkits has a UML modeller which basically does this, so I would try searching for that.
07-12-2006 09:10 AM
07-12-2006 09:33 AM
Wiebe@CARYA wrote:
Draw all the unique ID's as color values in a offscreen buffer (picture control)
Use an event to get the mouse down.
Lookup the pixel color in the offscreen buffer
Convert it to object ID.
That was my method until someone posted the VI shown in the attachment (I cleaned it up a little, documented it and added an example).
If you have a series of points for your shape, then this should be a better method.
Also, the picture control is just a string. If you dig into this string, you'll notice that you can make a buffer. In this buffer you can replace one single picture object. So you don't have to redraw all the entire picture. This way you can get a real performance boost. It's convenient to store object info in the same buffer.
It would seem to me that it would be better to have a buffer of the picture itself (the blue wire) which will depend on the z ordering (i.e. everything "under" the currently selected element will be the base picture and all the other stuff would be redrawn). I haven't done any real examining of the picture control VIs, but I would rather avoid manipulating the string myself if only for the reason that NI might (please?) change the implementation to something more efficient.
Draw the ghost outline in a separate picture control. Make this picture control transparent, and set it to the same size and position as the "real" drawing. Don't forget to use the events of the top level picture control! This way, you don't have to redraw the entire picture when you move only one object.
That's an interesting suggestion.
Tom, if you do create something, it would be nice if you post it. Maybe we can improve it and make it into a general template.
07-12-2006 09:42 AM
Just another thought....
Rather than doing all of the drawing work from scratch (ouch), if you develop all of the basic shapes as customized LV controls, a "proto-type" of each can be used to do the dynamic dragging and re-sizing stuff and only when the the object is "dropped" grab its image and stuff it in the picture.
I am thinking the prototypes would be hidden and off-screen. When the use indicates they want a "square" the "square control proto-type control" is made visable and positioned over the picture control where the mouse is.
Ben
07-12-2006 09:59 AM
07-12-2006 10:40 AM