Subject: CGAL users discussion list
List archive
- From: Yvan Maillot <>
- To:
- Subject: Re: [cgal-discuss] Extending TriangulationGraphicsItem<T> problem
- Date: Mon, 26 Jul 2010 20:49:03 +0200 (CEST)
- Organization: uha
Hello,
I think that I found something about my problem. But I need to know if I'm wrong because I am new in CGAL et Qt. This might have to do that you do "painter->resetMatrix();" without doing "painter->setMatrix(matrix);" in spite of doing "QMatrix matrix = painter->matrix();" for drawing vertices in
template <typename T> void TriangulationGraphicsItem<T>::paintVertices(QPainter *painter)
{
if(visibleVertices()) {
Converter<Geom_traits> convert;
painter->setPen(verticesPen());
QMatrix matrix = painter->matrix();
painter->resetMatrix();
for(typename T::Finite_vertices_iterator it = t->finite_vertices_begin();
it != t->finite_vertices_end();
it++){
QPointF point = matrix.map(convert(it->point()));
painter->drawPoint(point);
}
}
}
My problem disapear if I add this statement "painter->setMatrix(matrix);" to the end of your method. But other problems arise, a segmentation fault when resizing. But I wonder why you don't do simply this :
template <typename T> void TriangulationGraphicsItem<T>::paintVertices(QPainter *painter)
{
if(visibleVertices()) {
painter->setPen(verticesPen());
for(typename T::Finite_vertices_iterator it = t->finite_vertices_begin();
it != t->finite_vertices_end();
it++){
painterostream << it->point();
}
}
}
With such definition of this method, it seems to work all the time, when resizing, moving, zooming and so on. But perhaps it leads to other bugs I haven't seen yet. At the moment, like I can't change TriangulationGraphicsItem.h, I draw vertices, edges and faces in my method with no calling the super method, but It is not really satisfying.
Can anybody tell me if it I'm right or where is my mistake and what can I do ?
If it is possible to change "template <typename T> void TriangulationGraphicsItem<T>::paintVertices(QPainter *painter)" like I suggest.
Best regards
Yvan
Le 24 juil. 2010, 18:23, Andreas Fabri <> a écrit:
> Hello,
>
> This might have to do that we call
>
> // Turn the vertical axis upside down
> this->graphicsView->matrix().scale(1, -1);
>
>
> in the constructor of the Mainwindow class of demos.
>
> andreas
>
>
>
> On 23/07/2010 21:00, Yvan Maillot wrote:
> > Hi Again,
> >
> > Sorry to post this again but I am looking for my mistake for a while, in vain.
> > Any idea ?
> >
> > I am trying to extend TriangulationGraphicsItem<T> with a class I called
> > TriangulationGraphicsItemWithFaces<T> in order to also draw faces (triangles)
> > of a Delaunay triangulation.
> >
> > To do this I have overridden the drawAll method like as follow. It almost
> > works: faces are drawn. But they are drawn at a wrong place. Faces are
> > translated compared with edges and vertices. Indeed, the origin of the faces
> > seems to be on the left top of the screen instead of being in the middle. I
> > also tried to use resetMatrix() and so on, and other stuff but nothing works.
> > I
> > don't know at all where I'm wrong.
> >
> > What can I do to fix this problem?
> >
> > Thanks for your help.
> >
> > Yvan
> >
> > // The overridden method
> > template<typename T>
> > void
> > TriangulationGraphicsItemWithFaces<T>::drawAll(QPainter *painter) {
> > // Calling drawAll method of the TriangulationGraphicsItem<T> super class
> > TriangulationGraphicsItem<T>::drawAll(painter);
> > if (visible_faces) {
> > if (TriangulationGraphicsItem<T>::t->number_of_vertices()> 2) {
> > QColor color(::Qt::blue);
> > color.setAlpha(150);
> > faces_brush.setColor(color);
> > faces_brush.setStyle(::Qt::SolidPattern);
> > painter->setBrush(faces_brush);
> > painter->setPen(::Qt::NoPen);
> >
> > for (typename T::Finite_faces_iterator fit =
> >
> > TriangulationGraphicsItem<T>::t->finite_faces_begin();
> > fit != TriangulationGraphicsItem<T>::t->finite_faces_end();
> > ++fit) {
> >
> > TriangulationGraphicsItem<T>::painterostream<<
> >
> > TriangulationGraphicsItem<T>::t->triangle(fit);
> >
> > }
> > }
> > }
> > }
> >
>
>
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>
- [cgal-discuss] Extending TriangulationGraphicsItem<T> problem, Yvan Maillot, 07/23/2010
- Re: [cgal-discuss] Extending TriangulationGraphicsItem<T> problem, Andreas Fabri, 07/24/2010
- Re: [cgal-discuss] Extending TriangulationGraphicsItem<T> problem, Yvan Maillot, 07/26/2010
- Re: [cgal-discuss] Extending TriangulationGraphicsItem<T> problem, Yvan Maillot, 07/26/2010
- Re: [cgal-discuss] Extending TriangulationGraphicsItem<T> problem, Andreas Fabri, 07/24/2010
- Re: [cgal-discuss] Extending TriangulationGraphicsItem<T> problem, Andreas Fabri, 07/24/2010
Archive powered by MHonArc 2.6.16.