-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoccview.cpp
105 lines (79 loc) · 2.7 KB
/
occview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "occview.h"
#include "occtwindow.h"
//OCC libraries
#include <Aspect_DisplayConnection.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <TCollection_AsciiString.hxx>
#include <Graphic3d_NameOfMaterial.hxx>
#include <V3d_TypeOfSurfaceDetail.hxx>
#include <Standard_Type.hxx>
OccView::OccView(QWidget *parent)
: QWidget(parent)
{
Handle_Aspect_DisplayConnection aDisplayConnection;
Handle_OpenGl_GraphicDriver aGraphicDriver;
// 1. Create a 3D viewer.
aDisplayConnection = new Aspect_DisplayConnection (qgetenv ("DISPLAY").constData());
aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);
mViewer = new V3d_Viewer(aGraphicDriver, Standard_ExtString("Visu3D"));
mViewer->SetDefaultLights();
mViewer->SetLightOn();
// 3. Create an interactive context.
mContext = new AIS_InteractiveContext(mViewer);
mContext->SetDisplayMode(AIS_Shaded);
if ( mView.IsNull() )
mView = mContext->CurrentViewer()->CreateView();
Handle(OcctWindow) hWnd = new OcctWindow( this );
mView->SetWindow (hWnd);
if ( !hWnd->IsMapped() )
{
hWnd->Map();
}
// mView->SetBackgroundColor (Quantity_NOC_BLACK);
mView->MustBeResized();
//Eixo x, y, z
mView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_GOLD, 0.08, V3d_ZBUFFER);
#if 0
Handle(OpenGl_GraphicDriver) aGraphicDriver;
if(aGraphicDriver.IsNull())
{
Handle(Aspect_DisplayConnection) aDisplayConnection;
aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);
}
TCollection_ExtendedString a3DName ("Visu3D");
mViewer = new V3d_Viewer (aGraphicDriver,
a3DName.ToExtString(),
"",
1000.0,
V3d_XposYnegZpos,
Quantity_NOC_GRAY30,
V3d_ZBUFFER,
V3d_GOURAUD,
V3d_WAIT,
Standard_True,
Standard_True,
V3d_TEX_NONE);
mViewer->SetDefaultLights();
mViewer->SetLightOn();
mContext = new AIS_InteractiveContext(mViewer);
if ( mView.IsNull() )
mView = mContext->CurrentViewer()->CreateView();
Handle(OcctWindow) hWnd = new OcctWindow( this );
mView->SetWindow (hWnd);
if ( !hWnd->IsMapped() )
{
hWnd->Map();
}
mView->SetBackgroundColor(Quantity_NOC_BLACK);
mView->MustBeResized();
#endif
}
void OccView::paintEvent(QPaintEvent *)
{
mView->Redraw();
}
void OccView::resizeEvent(QResizeEvent *)
{
mView->MustBeResized();
}