Results 1 to 2 of 2

Thread: Combining OpenCascade into a Qt4 QtCreator application

  1. #1
    Join Date
    Sep 2013
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Combining OpenCascade into a Qt4 QtCreator application

    Hi,

    Can anyone show me how to render/paint/display an object created by opencascade?

    I have a very simple functional piece of opencascade code that creates a 3D cylinder:

    Qt Code:
    1. #include <BRepPrimAPI_MakeCylinder.hxx>
    2. #include <gp_Ax2.hxx>
    3. #include <gp_Pnt.hxx>
    4. #include <TopoDS.hxx>
    5. #include <AIS_Shape.hxx>
    6.  
    7. TopoDS_Shape MakeCylinder(const Standard_Real radius , const Standard_Real length)
    8. {
    9.  
    10. // Create coordinates & geometry
    11. gp_Pnt origin(0 , 0 , 0);
    12. gp_Dir direction = gp::DZ();
    13. gp_Ax2 axis(origin , direction);
    14.  
    15. // Create a cylinder
    16. BRepPrimAPI_MakeCylinder cylinder(axis , radius , length);
    17. TopoDS_Shape shape = cylinder.Shape();
    18.  
    19. return shape;
    20. }
    To copy to clipboard, switch view to plain text mode 

    I have created an empty widget application using qtcreator, and that has generated main.cpp, widget.cpp, widget.h, and widget.ui:

    foo.jpg

    Qt Code:
    1. #include <QApplication>
    2. #include "widget.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. Widget w;
    8. w.show();
    9.  
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. #include "widget.h"
    2. #include "ui_widget.h"
    3.  
    4. Widget::Widget(QWidget *parent) :
    5. QWidget(parent),
    6. ui(new Ui::Widget)
    7. {
    8. ui->setupUi(this);
    9. }
    10.  
    11. Widget::~Widget()
    12. {
    13. delete ui;
    14. }
    To copy to clipboard, switch view to plain text mode 

    To call my piece of opencascade code I have changed 'Widget' to this:

    Qt Code:
    1. Widget::Widget(QWidget *parent) :
    2. QWidget(parent),
    3. ui(new Ui::Widget)
    4. {
    5. ui->setupUi(this);
    6.  
    7. // I added this:
    8. QApplication::setOverrideCursor( Qt::WaitCursor );
    9. TopoDS_Shape aCylinder = MakeCylinder(50,400);
    10. Handle(AIS_Shape) AISBottle = new AIS_Shape(aCylinder);
    11. QApplication::restoreOverrideCursor();
    12. // Now what?
    13. }
    To copy to clipboard, switch view to plain text mode 

    As you can see I still need to display my image somehow? This would appear to be such a simple thing to do, but I am completely new to Qt and opencascade, so the tutorial example at the opencascade website goes totally over my head.
    Please can someone help me?

    I am currently using Qt Creator version 2.5.0 on Debian. The opencascade version in Debian is based on opencascade 6.5.2, and I think Qt is version 4.8.2.

    Many thanks!
    Thomas

  2. #2
    Join Date
    Oct 2014
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Smile Re: Combining OpenCascade into a Qt4 QtCreator application

    Hi Thomas,

    I think you can refer the Qt samples in the samples folder of OpenCASCADE.

    Or you can refer to the following website:
    http://www.opencascade.org/org/forum...25208/?forum=5

    Regards,
    Xing

Similar Threads

  1. Replies: 5
    Last Post: 25th April 2011, 08:04
  2. QtCreator 2.0 crashes application working in QtCreator 1.3
    By been_1990 in forum Qt Programming
    Replies: 2
    Last Post: 21st September 2010, 12:58
  3. 64 bit application using QTCreator on windows?
    By eyeofhell in forum Qt Tools
    Replies: 1
    Last Post: 21st September 2010, 03:06
  4. OpenCASCADE sample for qt is giving problem
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 1st December 2009, 10:02
  5. OpenCascade in QT application
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 4
    Last Post: 26th November 2009, 14:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.