Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Why nothing is drawn in this program

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Why nothing is drawn in this program


Chronological Thread 
  • From: Alex Tsui <>
  • To:
  • Subject: Re: [cgal-discuss] Why nothing is drawn in this program
  • Date: Thu, 6 Sep 2012 09:13:02 -0700

Hi,

Before this line:
scene.addItem(&arcItem);

Try to add this:
scene.setSceneRect( arcItem.boundingRect() );

This should set the view to fit the arc in the visible area.

--Alex

On Thu, Sep 6, 2012 at 6:03 AM, Wang Hetao <> wrote:
I got help from Alex Tsui this afternoon about how to draw arcs with Qt. see:
http://cgal-discuss.949826.n4.nabble.com/How-to-draw-arcs-under-Qt-td4655803.html

I wrote a program according to his guidance as follows:
#include <CGAL/Exact_circular_kernel_2.h>
#include <CGAL/Qt/CircularArcGraphicsItem.h>
#include <CGAL/Qt/GraphicsViewNavigation.h>
#include <CGAL/Qt/PainterOstream.h>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QRectF>
#include <QPen>
#include <QWidget>
#include <QPainter>
#include <QColor>
#include <QApplication>

typedef CGAL::Exact_circular_kernel_2 Circular_K;
typedef CGAL::Qt::CircularArcGraphicsItem<Circular_K>
CircularArcGraphicsItem;
typedef CGAL::Point_2<Circular_K> CK_Point;
typedef CGAL::Circle_2<Circular_K> CK_Circle;
typedef CGAL::Circular_arc_2<Circular_K> Circular_arc;
typedef CGAL::Circular_arc_point_2<Circular_K> Circular_arc_point;

int main(int argc, char *argv[]){
    QApplication app(argc, argv);
    QGraphicsScene scene;
    QWidget widget;
    QPainter painter;
    QGraphicsView view(&scene);
    CGAL::Qt::GraphicsViewNavigation navigation;

    CK_Circle circle(CK_Point(100, 100), 100*100);
    CircularArcGraphicsItem arcItem;
    arcItem.setArc(Circular_arc(circle, Circular_arc_point(CK_Point(100,
0)), Circular_arc_point(CK_Point(0, 100))));
    arcItem.setEdgesPen(QPen(QColor(255, 0, 0)));
    scene.addItem(&arcItem);

    view.installEventFilter(&navigation);
    view.viewport()->installEventFilter(&navigation);
    view.show();

    //widget.show();

    return app.exec();
}

It can be complied and run properly, and a white window appeared. I intended
to draw a red circular arc on it but nothing was drawn.

I'm so confused now, The program should be correct but the result is wrong.

Thx for your reply.

PS: If you want to compile the program above under Qt IDE, the following two
lines should be added in your project file(suffix is .pro):
LIBS += -L /usr/local/bin/ -lCGAL
LIBS += -L /usr/local/bin/ -lCGAL_Qt4




--
View this message in context: http://cgal-discuss.949826.n4.nabble.com/Why-nothing-is-drawn-in-this-program-tp4655807.html
Sent from the cgal-discuss mailing list archive at Nabble.com.

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss






Archive powered by MHonArc 2.6.18.

Top of Page