How would I use Processing to make visually-appealing buttons that when clicked will send data through a serial port? Is this possible in Processing or would I need to use something else?
You're really talking about two different things:
How do I draw a button?
How you do this depends entirely on you. You could just draw a rectangle using the rect() function or a circle using the ellipse() function, then put some text in there with the text() function. Or you could load an image file and draw that using the image() function. It's entirely up to you.
How do I do something when the user clicks a button?
This is a little trickier, but still pretty easy in Processing. You would use the mouseX and mouseY variables and if statements to check whether that position is inside one of your buttons, and then do the correct thing if so.
Processing comes with several examples of buttons, you should take a look at those.
Another option is to use a GUI library, but that's probably overkill if you just want to show a couple buttons.
Related
Using Cocos3D, is it possible to take screenshot of the 3D model in the background without the user knowing it?
For pre-processing purpose and other usage, I want to take screenshots of the 3D model at various angles. Following the Render-To-Texture capability, I noticed when my scene is not visible, the drawSceneContentWithVisitor: method only execute once rather than at every rendering cycle. For obvious reason, the CC3GLFramebuffer* won't get updated with new data, hence, I'm only able to take the initial screenshot.
Thanks.
In Cocos3D, you can render your 3D scene to an off-screen surface. See the CC3DemoMashUp addTelevision and drawSceneContentWithVisitor: methods for an example of how to do this.
What is important is that the 3D drawing environment has been established when you perform your drawing. The safest place to do this is inside your drawSceneContentWithVisitor: method. But if you want to render somewhere else, you need to invoke the CC3Scene open3DWithVisitor: and CC3Scene close3DWithVisitor: methods before and after rendering. See the implementations of the CC3Scene processInitializeScene and open methods for examples of how to do that.
To render your scene from multiple viewpoints, you need to add multiple cameras to your scene, and set the camera property of your drawing visitor appropriately to select a camera before rendering. See how this is done in the CC3DemoMashUpScene addTelevision and drawToTVScreen methods. The drawToTVScreen method also shows how to handle clearing the color and depth buffers of your surface.
I'm trying to fiddle a bit with a Qt example regarding 2D Graphics.
Basically it is a small diagram editor. In the example, the author explains that the tracknodes() function is used to update the line's endpoints, when the user drags a connected node into a different position.
This actually does not happen. After looking at the code, I have the feeling it's because there is no event being called after moving the node QGraphicItem, in order to update the link's rendering.
I figured I have to find out where and how the QGraphicItem's movement is handled in order to send a wasDropped signal (or something like that) to a slot that re-renders the link. Does this make sense?
I'm pretty new to Qt/C++ in general, so I don't have a very clear idea on how to achieve this, does anyone have any pointers he/she could share?
He seems to be using the QGraphicsItem::itemChange virtual function to call the tracknodes() function which draws the lines. ItemChange should be called every time a node is moved. It's called in other cases as well but he only uses it for tracking the movement of the QGraphicsItem.
I've got a QTableView for which I want to display the last column always in edit mode. (It's a QComboBox where the user should be able to always change the value.)
I think I've seen the solution in the Qt documentation, but I can't find it anymore. Is there a simple way of doing it?
I think I could archive this effect by using openPersistentEditor() for every cell, but I'm looking for a better way. (Like specifying it only one time for the whole column.)
One way to get the automatic editing behaviour is to call the view's setEditTriggers() function with the QAbstractItemView::AllEditTriggers value.
To display the contents of a given column in a certain way, take a look at QAbstractItemView::setItemDelegateForColumn(). This will let you specify a custom delegate just for those items that need it. However, it won't automatically create an editor widget for each of them (there could in principle be thousands of them), but you could use the delegate to render each item in a way that makes it look like an editor widget.
There are two possibilities:
Using setIndexWidget, but Trolltech writes:
This function should only be used to
display static content within the
visible area corresponding to an item
of data. If you want to display custom
dynamic content or implement a custom
editor widget, subclass QItemDelegate
instead.
(And it breaks the Model/View pattern…)
Or using a delegate's paint method. But here you have to implement everything like enabled/disabled elements yourself.
The QAbstractItemModel::flags virtual function is called to test if an item is editable (see Qt::ItemIsEditable). Take a look at Making the Model Editable in the Model/View Programming documentation.
I can't see an easy way to do this, but you might be able to manage by using a delegate. I honestly don't know exactly how it would work, but you should be able to get something working if you try hard enough. If you get a proper delegate, you should be able to set it on a whole view, one cell of a view, or just a column or row.
I've written a simple calendar control to allow for selecting single days, weeks, months and so on. The simplicity comes from the fact that I don't really do any drawing myself, opting instead to create a bunch of boxes and labels to act as date cells for the calendar.
When a date or a date range is selected, I need to highlight that range. It's easily done by iterating through the cells and switching their style. [edit:] However, this seems to cause a delay during which the cells are first drawn as if the style name was blank, and then re-drawn with the correct style, despite the fact that I never explicitly set the style to null -- I alternate between "CalendarCell" and "CalendarCellSelected".
If this were Windows Forms, I'd call SuspendLayout on the parent container to make sure the controls are repainted only after I've finished the updates. What I'm looking to know is whether or not a similar solution exists for Flex. I'd like to avoid drawing the entire calendar "manually", so to speak, if that's at all possible.
edit: changed the problem description to more accurately reflect what I'm seeing.
Are you using callLater() at all?
If you use callLater() it may impove your visuals as it batches up changes until it needs to draw a frame or you force a frame draw with validateNow() or similar. It might be enough in your case.
Is your calendar control a UIComponent? Is it using the standard invalidation methods like commitProperties(), updateDisplayList(), etc?
What you might want to do is keep a private array of the cells that will have their styles changed, but then do the actual style switching in your commitProperties() override. I'm just not sure if setStyle() fires an validateNow() because the flickering is a bit surprising.
This may not be exactly what you're looking for, but David Coletta at Adobe has posted a video explaining an EventCoalescer that they use in Buzzword for deferring events that update specific areas of the app UI until the user has stopped moving the insertion point in the text, for example.
This blog post by Hans Van de Velde also has a similar solution, and actual code for it as well.
We are trying to create some tests that reference an vendors custom grid. Unfortunatly QTP only recognises it as a WinObject which is quite useless. We need to be able to navigate the grid and change cell values, double click on a cell(without using X,Y co-ordinates) etc.
Ideally we want to get QTP to understand that this object is a grid and treat it as one.
Any help would be greatly appreciated.
Thanks
Jon
What vendor?
I have a few suggestions:
Use key strokes to navigate the grid, rather than mouse clicks. Ctrl-Home to set focus to the top-left cell, then use up, down, left, right to move around. Use Enter keystroke to simulate double clicking. Often you can use Ctrl-A, Ctrl-C to copy the contents of the grid to the system clipboard, and use the clipboard API to retrieve the data.
You may be able to programmatically get/set the grid properties using the .Object property. .Object provides access to the underlying native properties and methods of the object, as opposed to the QTP methods and properties. You could do something like the following pseudo-code to set focus to a cell and change the value. Your code would differ depending on the vendor implementation. Consult the vendor's documentation to find out what methods and properties you would be able to use.
WinObject("mygrid").Object.CurRow = 1
WinObject("mygrid").Object.CurCol = 1
WinObject("mygrid").Object.Value = "my new value"
If the grid in question happens to be a Stingray Objective Grid, QTP has plugins specifically for that.
Same thing for Infragistics. They have a plug-in for QTP for the UltraWinGrid etc.
http://www.infragistics.com/dotnet/testadvantage.aspx#Overview
It is resonable to send the request to Support Center. If they will get a big number of requests - they will add support for your grid-vendor.
May be you forgot to load (install) AddIn for your grid-vendor.