PDA

View Full Version : display graphics items on area



quantum.17
5th May 2010, 12:19
i am trying to design an application for simply viewing map areas and displaying some symbols on it.. As the number of symbols on map would vary and map can consists of several layers(that can be hidden or shown) i am trying to implement it on graphicsview framework in such a way that map will be represented by an item and capable of transforming from geographic world coordinates to its local coordinates (in pixel) and vice versa. Basically i have some problems in the following topics:

- Map item is for displaying a visual representation of an area in the world and it is set as parent to all other symbol items. The user should have some navigation utilities on this item such as moving to any direction and zooming in/out. The graphicsview uses this map item to get geographic world coordinates and draw gridlines in its paint method. Theoratically map area is considered as infinite which means that although when the user navigates to a direction continually, the map area (visual representation) will disappear but the gridlines should be updated accordingly. I achieve this by movingBy the map item. However this operation i think causes the scene to enlarge and after i try to center on the map item (so that it is center on the screen), the map item is not any more located on the center of the view..

- Each symbol has a pixmap to make it more meaningful to user so i derived it from QGraphicsPixmapItem.
- The symbols should not be affected from the zoom in/out events of the map item, so if the user zooms in the map, they should keep their positions right on the map while not getting larger. However the user can use another toolbar for them to be scaled independent of the map. So, i simply set ItemIgnoresTransformations flag for them.
- The symbols will also have context menu which is activated when the user right clicks on them, but when i set ItemIgnoresTransformations flag there seems something to be wrong on this context menu. Although the item is not getting larger as i zoom in on the map, the context menu for the symbol appears even if i right click on some point that is not close to/on the symbol. I am not entirely sure but the context menu seems to be called ignoring ItemIgnoresTransformations flag(the item's bound seems to get larger). To make sure the boundingRect is still right, in paint event of the symbol i draw a rectangle to visualize boundingRect but it seems to only cover the symbol and not the area within where i get right click events.

thanks