-
Notifications
You must be signed in to change notification settings - Fork 3
/
tryOCCDraw.py
48 lines (35 loc) · 1.49 KB
/
tryOCCDraw.py
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
import sys
from OCC.Display.qtDisplay import qtViewer3d
from PyQt4 import QtGui,QtCore
from UI.ptest import AppGUI
class ViewerMainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.graphicsView = MyQtViewer3d(self.viewer_centralwidget) # derived from qtViewer3d
self._graphicsinitialized = False
self.connect(self.graphicsView, QtCore.SIGNAL("sigGraphicsInitialised"), self.slotGraphicsInitialised)
def AssertGraphicsInitialized(self):
if not self._graphicsinitialized:
self.graphicsView.InitDriver()
def slotGraphicsInitialised(self):
self._graphicsinitialized = True
self.SetDefaultBackground()
class MyQtViewer3d(qtViewer3d):
def InitDriver(self):
qtViewer3d.InitDriver(self)
self._display.EnableAntiAliasing()
self.SetupTrihedron()
self.context = self._display.GetContext().GetObject() # AIS_InteractiveContext
self.emit(QtCore.SIGNAL("sigGraphicsInitialised"), ())
# Which Qt signal you could use to trigger a call to AssertGraphicsInitialized depends on your application of course.
# You might also try to simply override the paintEvent method:
def paintEvent(self, event):
QtGui.QMainWindow.paintEvent(self, event)
self. AssertGraphicsInitialized()
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
win = AppGUI()
win.show()
win.modelTab.InitDriver()
win.modelTab._display.Test()
app.exec_()