interactive (adding listeners to) DAE model in flex + papervision - apache-flex

I have a DAE model that is parsed into several parts. I am able to deal with them separately, such as changing their material or colour but I am having problems adding click or hover listeners over the children.
For example, lets say I have a model of a kitty where each facial feature is a child. I want to be able to hover or click the features and have a window pop up explaining the feature.
I've tried parsing the model and adding listeners but it doesn't seem to work.
Thanks in advance!
L

Hard to pin point the problem from your description, but you could check the following:
Make sure your viewport is interactive
Make sure the material your material is interactive
Make sure the DisplayObject3D you assign the listener to is not null.
Point 3, with collada objects, you can have nested objects, make sure you add a listener to an object that has geometry, not an empty(no geometry) container. With points 1,2, both viewport and material have a Boolean property called interactive which must be set to true for mouse events.
HTH

Related

Cocos3D - Take various screenshots in the background

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.

JavaFX nodes - How to make them resizable by the end user?

I am developing a JavaFX application where a class I have developed (extended from javafx.scene.Parent) is created on-the-fly based on what entry the user has clicked in a ListView control.
Just to be clear about this node, it is not created using a layout tool like SceneBuilder, it is created at runtime based on the user's actions.
The constructor for my custom node class creates a VBox and a Label and uses passed coordinates (X,Y) in the constructor method to set its own Layout coords. I then use a custom utility class to make the node draggable. This new node is then added to the main application Pane.
However, I have failed to find out how I can make these nodes resizable by the user. That is, allow the user to mouse over the corner of the node, hold and drag to resize. An operation that all users are used to, no matter what the OS.
Has anyone done anything like this in JavaFX? (My searches on the subject only seem to pull up subjects on the automatic resizing that a parent node does with its child nodes.)
Many thanks,
Ian.
As you can see on the documentation of VBox you can only define minimum, prefered and maximum range, there's not really a way to make it manually resizable.
The only proper solution to solve your problem is to develop your own class to do it, because what you want seems very specific, with your problem description, I don't think use some layouts or panels will do what you exactly want.
I found something that you can use : Dragging to resize a JavaFX Region
This allows you to resize a region, all you have to do after is to put you VBox in this region, but notice in this article that :
Only height resizing is currently implemented.
This code won't work in JavaFX8, you'll have to check the comment to see how it worls in JavaFX8
Hope this helps.

'Manual' multi-selection in QTableView and partially hidden grid

I know that topic about multi-select arise at least once, but honestly neither can't find it anymore, nor remember that it had and decent solution.
There are two questions I propose to discuss:
1) Creating a behaviour similar to MS Excel cell's selection. So user click one cell in QTableView and gets clicked cell highlighted and in additional several 'dependant' cells change appearance (get selected or just gets highlighted in any way). In Excel it's widely used to show cell formula dependencies.
I know there are several approaches to solve it. Most simple one is to modify view selection with dependant cell in any of appropriate signal handlers (for example QAbastractModelView clicked()). That way does the job but has ugly side effect, that due to fact that signals delivered after redraw of selected cell occurs so dependant selection is drawn after first cell which produce flickering.
Second approach is go Delegate way.. That's also have some issues because you get paintEvent only for selected cell, so there is not that much you can do about 'dependent' cells. Actually I was able to solve it through this way, by catching on-click, modifying selection and using completely custom delegate which draws everything as soon as complete selection is formed, so actually it skips first redraw, but again I wasn't completely satisfy with results although visually it looked completely right.. mostly because overall TableView response time decreased a lot. Reasons for that is Qt draws native selection right after mouse click received before sending any signals to user classes and in case of this approach paintEvent in delegate arrives after several main loops. So there is a noticeable delay in case of using 'draw selection in delegate' in compare to 'draw native selection'.
I am already starting to think that best option can be completely overwrite most of QTableView to add support for such selection schemas, but may be there are more straight approach?
2) Second question (I put them together because there are something common issues).
Let say you have a grid representing financial information by months and within a month there are several columns of information, so block of N columns repeated M times. Obvious way to make such grid more readable is to use different style for vertical lines in grid for first data column in each month. Let's say to make them 1-2 pixels wider.
As you cannot specify grid style per cell, what I did was to setGrid(false) and then draw my own grid lines as a cell content in delegate.
But then I faced a problems from point 1. Then you instruct Qt to use delegate on certain cell, before delegate will get a paintEvent Qt clears a background of the cell. And in case of hidden grid the background rect which Qt clears is one pixel bigger then required. Probably it can be consider to be a Qt bug because they dont respect grid visibility, but this results in removing grid lines in neighbour cell, so you have to draw in delegate not only cell own grid, but also recalculate proper cell rectangle, check if Qt made a mistake (by analysing QPainter rect), decide if whats being removed from neighbour cell needs restore and repaint it also. This leads to really complicated delegate logic and I cannot consider it to be a decent solution.
So question 2 can be rephrased as do we know a decent way to style a grid per cell in QTableView?
OMG,so many words,can you just pick the most important info?
I'd do something like that:
Create a delegate. Subclass QAbstractTableModel and reimplement data method. Your implementation should return cell text for Qt::DisplayRole, but also can return whatever you want if role is one of your user-defined roles (like font or color or whatever of cell's text. You can use any role number above Qt::UserRole). Your model should emit dataChanged signal to notify QTableView that the content is changed and should be redrawn.
Then in delegate you just request this data using your overloaded QAbstractTableModel::data and draw it the way you want.

Setting Polygon ROI with mouse in Qt

Anyone have any idea how I can implement this? I'd like to have a function basically exactly like impoly in matlab or the "polygon sections" tool in imageJ, where you click to form a polygonal section and then each node can be adjusted, etc. I'd also like to have access to this function from Qt since I'm trying to make a gui for a small program I wrote.
Also, I'd like to avoid making calls to the matlab function because it's part of the image processing toolbox which isnt free. Thanks.
I think the best way to implement this is using the Qt Graphics View framework. Create a scene with an Item displaying your image in the back and add draggable Items on top representing the corners of your polygon.
Your selection tool should probably be a subclass of QGraphicsObject hosting the polygon corners as child items and a QGraphicsPolygonItem below the corners being updated whenever the user readjusts the selection. As QGraphicsObject inherits QObject, you can emit signals with a QPolygonF or QPolygon argument whenever the selection changes, informing other parts of your application
This demo should be a good example of the corner-adjust functionality you need.
Qt Pathstroke Demo
(uh well, the example implements the drawing and dragging of the control points from scratch.. I'm sure you can do it by using QGraphicsEllipseItem instead and react on their position changes)
I think you would need to code this yourself. There is an excellent example in the C++ GUI Programming with Qt 4 book (there's a PDF copy floating around online; I think it's legal) where they show you how to create a diagram with nodes and links. The chapter is called "Item-based rendering with Graphics View".
The basic idea is that you have some draggable nodes, which are QGraphicsItems with the ItemIsMovable flag set to true, and then some links that connect them, which are QGraphicsLineItems. All of these would go into a composite QGraphicsItem representing the ROI, and all of those would go into a QGraphicsScene, which would be displayed by a QGraphicsView.
Bottom line: there isn't a built-in copy of the MATLAB function, but all the tools are there for you.

Make a custom component or extend the List component for a 2D top down view MAP in flex 4?

Hy!
I'm building a top view 2D map, that it's objects are stored on the server.
The kind of objects are 10 and might be a photo, label, button, lists, mix of them or labels with tooltips.
The component must request the "areas" that are missing on screen.
An area is 1000x1000 px and is cached in flex.
To move in the map, will be like in google maps (drag-and-drop)
I should be able to have another list and move objects from one to another using drag-an-drop on objects. Ex.: I grab an objects from a list and I move it on this map, I release the mouse button and the item is placed there.
Now the problem is: I build a custom component for this trying to emulate the item renderer for performance and recyclage, implement drag-and-drop on objects and request the areas that are missing?
or
I extend the List component from spark and I add some features as multiple kind of itemrenderers and use recycle on them. Of course it must be able to request the missing areas on the screen and cache it's data.
Maybe create a custom layout is needed too.
What I need is something that must be really fluid, so the lighter this component is, the better!
Thanks for your help! (:
UPDATE:
*There will be not any object over another.
*I will not use hitTest on bitmaps because all bitmaps are wrapped in another component,as they,for now are itemrenderers.
Anyway I already begin to do this using a class that extends the SkinnableDataContainer and a custom layout. As the layout is not like a grid, is sparse, random items at diferent points(x, y).
Now I have this problem: https://stackoverflow.com/questions/4192934/how-to-get-the-localx-and-localy-relative-to-item-renderer-and-not-to-the-spark
Maybe you could use a combination of some of the following:
A canvas background (for layered components), looks fluid if using hitTest. Split up the canvas using constraintColumn/constraintRow for a grid layout.
Use hitTest (on items bitmapdata) for collision detection, and move the items to a new position (if items are dropped on top of one another).
Use a combo of mouseDown, mouseMove, mouseUP (example here) for drag n drop.
Use a 2D/3D indexed array to track the position of items (example here)

Resources