Closed mnesarco closed 4 years ago
Are you using Wayland? If so you need to run export QT_QPA_PLATFORM=xcb
then the example.
Edit: Nevernind that is only for the Qt viewer
@frmdstryr I am not using wayland. I use Linux Mint (Cinnamon/xorg)
Ok, it looks like the same issue as https://github.com/trelau/pyOCCT/issues/32 (not sure what happened with that one).
I'd recommend giving the Qt Viewer a try (just install PyQt5 and change the example use from OCCT.Visualization.QtViewer import ViewerQt
instead.
@frmdstryr
Ok, it looks like the same issue as #32 (not sure what happened with that one).
I'd recommend giving the Qt Viewer a try (just install PyQt5 and change the example use
from OCCT.Visualization.QtViewer import ViewerQt
instead.
Different error now.
Modified Example code i am trying to run:
https://github.com/trelau/pyOCCT/blob/master/examples/bop_assys.py
import time
from OCCT.BOPAlgo import BOPAlgo_Options
from OCCT.BRepAlgoAPI import BRepAlgoAPI_Fuse
from OCCT.TopTools import TopTools_ListOfShape
from OCCT.Exchange import ExchangeBasic
from OCCT.Visualization.QtViewer import ViewerQt # Changed as suggested
fn = './models/wing_assy.brep'
wing_assy = ExchangeBasic.read_brep(fn)
fn = './models/fuse_assy.brep'
fuse_assy = ExchangeBasic.read_brep(fn)
BOPAlgo_Options.SetParallelMode_(True)
bop = BRepAlgoAPI_Fuse()
args = TopTools_ListOfShape()
args.Append(wing_assy)
bop.SetArguments(args)
tools = TopTools_ListOfShape()
tools.Append(fuse_assy)
bop.SetTools(tools)
print('Starting fuse...')
start = time.time()
bop.Build()
print('Complete in ', time.time() - start, ' seconds.')
v = ViewerQt() # Changed as suggested
v.add(bop.Shape())
v.start()
Error:
(pyocct) mnesarco@devel03:examples$ python bop_assys.py
Starting fuse...
Complete in 21.40282702445984 seconds.
Traceback (most recent call last):
File "bop_assys.py", line 48, in <module>
v = ViewerQt()
File "/home/mnesarco/miniconda3/envs/pyocct/lib/python3.8/site-packages/OCCT/Visualization/QtViewer.py", line 496, in __init__
self._the_view = QOpenCascadeWidget()
File "/home/mnesarco/miniconda3/envs/pyocct/lib/python3.8/site-packages/OCCT/Visualization/QtViewer.py", line 101, in __init__
window = Xw_Window(self.display_connection, hwnd)
AttributeError: 'QOpenCascadeWidget' object has no attribute 'display_connection'
You'll need to make the change from #61. Looks like there was an accidental mistake in a recent refactoring that was not caught as it's primarily tested on windows.
@frmdstryr
You'll need to make the change from #61. Looks like there was an accidental mistake in a recent refactoring that was not caught as it's primarily tested on windows.
It works... but two windows appear, one black an the other gray, the solid is shown only if I do click the gray window but keypress events seems to be sent to both windows:
The message in console is:
TKOpenGl | Type: Other | ID: 0 | Severity: Medium | Message:
OpenGl_Window::CreateWindow: window Visual is incomplete: no depth buffer, no stencil buffer
Hi @trelau , I have been working with the QtViewer and it seems that the solution to the black screen is so simple:
You forgot to pass the parent to the QOpenCascadeWidget, so it creates a new window.
self._the_view = QOpenCascadeWidget()
The simple fix:
self._the_view = QOpenCascadeWidget(self)
I have also changed QOpenGLWidget to QGLWidget due to deprecation of QOpenGLWidget.
Complete patch:
diff --git a/OCCT/Visualization/QtViewer.py b/OCCT/Visualization/QtViewer.py
index b1c0a9a..5c75adc 100644
--- a/OCCT/Visualization/QtViewer.py
+++ b/OCCT/Visualization/QtViewer.py
@@ -36,7 +36,8 @@ from OCCT.V3d import V3d_Viewer, V3d_TypeOfOrientation
from OCCT.gp import gp_Pnt
from qtpy import QtCore
from qtpy.QtGui import QPalette, QIcon
-from qtpy.QtWidgets import QApplication, QMainWindow, QOpenGLWidget, QFrame, QVBoxLayout
+from qtpy.QtWidgets import QApplication, QMainWindow, QFrame, QVBoxLayout
+from qtpy.QtOpenGL import QGLWidget
try:
from OCCT.SMDSAbs import SMDSAbs_Node
@@ -51,7 +52,7 @@ except ImportError:
__all__ = ['ViewerQt']
-class QOpenCascadeWidget(QOpenGLWidget):
+class QOpenCascadeWidget(QGLWidget):
"""
View for displaying shapes.
@@ -493,7 +494,7 @@ class ViewerQt(QMainWindow):
frame = QFrame(self)
layout = QVBoxLayout(frame)
layout.setContentsMargins(0, 0, 0, 0)
- self._the_view = QOpenCascadeWidget()
+ self._the_view = QOpenCascadeWidget(self)
layout.addWidget(self._the_view)
self.setCentralWidget(frame)
self.show()
Nice catch, can you create a pull request?
Fixed by #62
Unless I'm doing something very wrong (which is far from impossible) #61 and #62 aren't included in the current conda package.
Also, there should probably be something about using qtviewer on the readme so linux users don't have to dig around in closed issues to figure out how to get pyocct to run.
Unless I'm doing something very wrong (which is far from impossible) #61 and #62 aren't included in the current conda package.
Also, there should probably be something about using qtviewer on the readme so linux users don't have to dig around in closed issues to figure out how to get pyocct to run.
I'm having the same issue. It might be obvious for someone that knows anaconda, but I'm new to it.
I tried to install PyQt5 using conda:
conda install -c conda-forge pyqt5-sip
Ant then I get this error: ModuleNotFoundError: No module named 'PySide'
. I tried to install PySide, but there is no package for Python 3.8:
conda search -c conda-forge pyside
...
pyside 1.2.4 py36_8 conda-forge
Tried with pip install (will it screw my conda environment? let's do it anyway), and it also fails:
pip install pyside
Collecting pyside
Downloading PySide-1.2.4.tar.gz (9.3 MB)
|████████████████████████████████| 9.3 MB 1.4 MB/s
ERROR: Command errored out with exit status 1:
command: /home/francisg/miniconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-bwqbpsld/pyside/setup.py'"'"'; __file__='"'"'/tmp/pip-install-bwqbpsld/pyside/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-uj7p_m8c
cwd: /tmp/pip-install-bwqbpsld/pyside/
Complete output (1 lines):
only these python versions are supported: [(2, 6), (2, 7), (3, 2), (3, 3), (3, 4)]
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
But actually, there is PySide2. And PySide6. It looks like its needed, but replaces in some way pyqt? I don't know, I'm confused.
Qt is a large dependency and a bit tricky to setup, so it would be nice to have some info, maybe just a link to other existing doc.
Examples does not run in Linux:
Expected Behavior
Examples should run
Steps to Reproduce (for bugs)
python bop_speed.py
Your Environment