[Qgis-developer] mapCanvasItem not able to display

nitin quick quick.nitin at gmail.com
Wed Oct 11 13:23:23 EDT 2006


I had managed to show points by making drawShape() (if show() do not
help much) a public function in custonItem class . And yes
custom-qgsCanvasItem::drawShape() do not get called on update().
Also Whatever elements i am drawing, i have set rtti() value 1234 but
in mouse press event collision list, it donot appear. Only rtti it
shows id 5, 11111.
Is there any issue in implementation of custom-qgscanvasitem class? as
i see it is pretty straight also i had tried this as dummy it is
working well.

quickNitin

On 10/11/06, nitin quick <quick.nitin at gmail.com> wrote:
> hi martin,
> probably you are correct, and my implementation have got quite few
> bugs which i had got rid off. About creating objects outside
> drawShape(), i will try to do it that way.
> I had tried show() but it donot works. setVisible() i will try.
> thanks
>
> regards
> quickNitin
>
> On 10/11/06, Martin Dobias <wonder.sk at gmail.com> wrote:
> > On 10/10/06, nitin quick <quick.nitin at gmail.com> wrote:
> > > greetings,
> > > I have some peculiar pbm.
> > > In a plugin, i am receiving some data through Qthread and storing in a
> > > struct. I am showing these as customised qgsmapcanvasitem over map on
> > > qgsmapcanvas but i couldn;'t do . This code is part of a plugin for
> > > qgis0.7.9  .here is what i have done:
> > >
> > > [...]
> > >
> > > here i am creating object adding to list, but everytime i am creating
> > > new. hat ican take acre of. But nohig is getting visible despite i
> > > have put code for update(). I am not calling drawShape(qpainter &P) of
> > > mymapcanvasitem since it is protected , if i make it public, item do
> > > appear but is it propr way. Also this way i am not able to move them.
> >
> > Hi,
> >
> > first of all, I don't like the way you use drawShape function... it
> > should be used just for painting the canvas item, not for creating
> > other map canvas items. Why not to send a signal from the worker
> > thread and create a slot which will add new canvas item and update
> > canvas?
> >
> > One more thought: do you call setVisible() or show() function in
> > canvas item construction to make your canvas item visible? It's hidden
> > by default.
> >
> >
> > > I also have query about function QgsMapCanvasItem::setRect(). why it
> > > is required.Do this has got anything to do with visibility of this
> > > objet. I have set complete map extent as visible in updateExtent()
> > > because i couldn't got reason for this.
> >
> > You have to specify canvas item position and size to let Q3Canas know
> > what portion of canvas you'll use for drawing. Normally you use move()
> > and setSize() functions from Q3CanvasItem. As map canvas items usually
> > work with map coordinates and not canvas coordinates, setRect() is a
> > convenience function to make setting this rectangle easier. There's
> > also function updatePosition() which is called from map canvas when
> > extent has changed or canvas is being panned. The default
> > implementation sets item's position and size regarding to rectangle
> > set by setRect(). This is how e.g. QgsRubberBand works.
> >
> > If you don't like this approach, you can override this behaviour by
> > using your custom updatePosition() function. This is used in
> > QgsVertexMarker.
> >
> > Probably a tutorial on creating own map canvas items and map tools
> > would be good ... probably an inspiration for Tim? ;-)
> >
> > Martin
> >
>



More information about the Qgis-developer mailing list