charles-sharman / ccad

pythonocc wrapper
GNU Lesser General Public License v3.0
21 stars 11 forks source link

Display is Unix specific #2

Closed tpaviot closed 10 years ago

tpaviot commented 10 years ago

The display part of ccad relies on the Xw_Window class. This is only available on Unices, on Windows it is WNT_Window and on OSX Cocoa_Window.

charles-sharman commented 10 years ago

I could add the changes you recommend but have no way to debug it, since I don't possess a Windows or OSX box. The conversion of your Display.cpp to work in pure python was non-trivial. I think it's best to do a sys.platform check at the beginning. If it's not Unix, it defaults to pythonocc's SimpleGui.

The project either need a Windows and OSX developer, or display needs to be rewritten for wx or qt. The wx/qt alternative is unattractive to me, because you can't view multiple displays simultaneously. That is, wx/qt threads don't play nicely with OCC, or something like that.

If you're okay with the SimpleGui concession, I'll make it now but keep this issue open for the day when it can more properly be fixed.

tpaviot commented 10 years ago

The Display.cpp file was coded into c++ because it was impossible to get it work in pure python for all platforms. I don't understand why you reinvent the wheel while you could use what is already done in the pythonocc wrapper. You could extend or customize the OCCViewer module. But using SimpleGui if importing pygtk fails seems to be ok.

Another point: I think that model and display should be as independent from each other as possible. For instance, someone should be interested in using ccad on a server side, only for modeling and STEP export, without any need for a visualization. Then import ccad should not implicitely import the graphical stuff, it should be explicit.

charles-sharman commented 10 years ago

At one time, you called my python-only window calls "clever" but I guess you found they didn't work over all platforms. Your comments prompted considerable investigation, including learning qt. I won't bore you with details. The results below should fill-in some of them. I created 3 branches all of which only change display.py currently

gtk -- This is a branch which eliminates the gtkglext dependency but keeps gtk. It also tries to instance a WNT_Window on a Windows machine, and a Cocoa_Window on an OSX machine in python. It may be useful, because gktglext is harder to install on Windows than gtk.

qt -- This is a branch which eliminates gtk as the manager and uses qt4 instead. It includes all capability from the gtk branch in qt4 code, including the hooks for Windows and OSX.

qtDisplay -- This is the same as the qt branch, but it removes the python-level window calls and uses pythonOCC's Display3d.cpp.

It turns out my previous statements were wrong. It is not the use of gtk that makes ccad's display.py thread-safe; it is the use of the python-level window calls. The qt branch is also thread-safe. The qtDisplay branch is not thread-safe. You may only open one view window at a time in that branch. See the comments at the beginning of that branch's display.py for bug details.

All of these claims are only verified in Linux. I don't know how each branch will work on other platforms, and that's why I published them all. So, I'd like users with Windows or OSX capability to try the various branches and let me know how they do. Once I get feedback, I'll merge the best branch. However, even if qtDisplay turns out to be the best-working branch, I would insist on keeping the multiple-viewer capability in Linux, thus merging qt and qtDisplay. Until we get developers contributing significant portions, I don't want to lose my capabilities for the sake of other's compatibility.

If it's true that the python windows calls don't work on all platforms, we ought to understand why Display3d is not thread safe and fix it. Given confirmation and time, I may try to find that out.

charles-sharman commented 10 years ago

Doug helped debug the Windows issues with me. With some changes, the qtDisplay branch ultimately worked on Windows. To maintain the multiple viewing abilities in Linux, I merged the qt and qtDisplay branch into a display.py that works on both platforms. ccad no longer depends on gtk. I also updated the documentation accordingly, along with a section of how to separately use the model module. Finally, I updated the version to 0.11, and removed the various branches. So, ccad now works on Linux and Windows. I will close this issue. If Mac users find ccad still doesn't work, they can open a new issue.