For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

V3d_OrthographicView forward declaration

Omar Olarte's picture
Forums: 

I'm triyng to implement a "simple" QT widget with an OCC window on it. here is my code :

1. QOCCWidget.h
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
class QOCCWidget : public QGLWidget
{
Q_OBJECT

public:

/**
* \fn QOCCWidget(QWidget* parent = 0 , const char* name = 0, int wflags = 0);
* \brief Constructor
* \param parent QWidget* = 0
* \param name const char* = 0
* \param wflags int = 0
*/
QOCCWidget(QWidget* parent = 0 , const char* name = 0, int wflags = 0):QGLWidget(QGLFormat(DoubleBuffer | DepthBuffer | AlphaChannel | DirectRendering), parent, name, 0, wflags)
{
#ifndef WNT
XSynchronize(x11Display(), TRUE);// QApplication::syncX();
#endif
myDevice=new Graphic3d_GraphicDevice("");
myWindow=new Xw_Window(myDevice,winId());
}
const Handle(Graphic3d_GraphicDevice)& GraphicDevice() const { return myDevice; }
const Handle(Xw_Window)& Window() const { return myWindow; }
void SetView(const Handle(V3d_View)& aView){
myView=aView;
myView->SetWindow(myWindow);
}
const Handle(V3d_View)& View() const { return myView; }

protected:
virtual void paintEvent(QPaintEvent *){
if (!myView.IsNull()) myView->Redraw();
}
virtual void resizeEvent(QResizeEvent *){
if (!myView.IsNull()) myView->MustBeResized();
}

private:
Handle(Graphic3d_GraphicDevice) myDevice;
Handle(Xw_Window) myWindow;
Handle(V3d_View) myView;
};

2. main.cpp

#include
#include"qoccwidget.h"
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
QOCCWidget *ventana=new QOCCWidget();
TCollection_ExtendedString Name("Test");
TCollection_AsciiString Domain("DBMReflex");
Handle(V3d_Viewer) aViewer=new V3d_Viewer(ventana->GraphicDevice(),Name.ToExtString(),Domain.ToCString(),1000.0,V3d_XposYnegZpos,Quantity_NOC_BLACK,V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT,Standard_True,V3d_TEX_ALL);
Handle(V3d_OrthographicView) aView= new V3d_OrthographicView(aViewer); ventana->SetView(aView);
ventana->show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}

I obtain the major part of this code of a message of this forum.

When I tried to compile it ..

main.cpp: In function `int main(int, char**)':
main.cpp:21: error: invalid use of undefined type `struct V3d_PerspectiveView'
/home/OpenCASCADE5.2/ros/inc/Handle_V3d_PerspectiveView.hxx:39: error: forward declaration of `struct V3d_PerspectiveView'

What happen?
Anyone have an idea?

Roman Lygin's picture

Omar,

Doesn't the Qt widget wrapping the OCC viewer, demonstrated in the Qt sample, shipped with OCC demonstrate good enough functionality you are trying to implement ?
Why to reinvent the wheel ?
Roman

Stephane Routelous's picture

you have to include V3d_PerspectiveView
#include