Skip to content

Commit

Permalink
Fixed linux display, triedron, lighting.
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-sharman committed Mar 11, 2015
1 parent 38f7625 commit 69f0135
Show file tree
Hide file tree
Showing 127 changed files with 9,488 additions and 4,317 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Expand Up @@ -3,6 +3,8 @@ global-exclude *
include README LICENSE AUTHORS TODO setup.py MANIFEST.in
include __init__.py model.py display.py
include doc/*.rst doc/*.py doc/*.svg
# These includes are captured with xwd
include doc/example1_all_bricks.png doc/logo.png doc/sphere_example.png doc/display_spherebox1.png doc/display_wireframe.png doc/display_shaded.png doc/display_hlr.png doc/select_face.png doc/select_edge.png doc/select_vertex.png
include unittest/*.py
recursive-include doc/html *
prune doc/html/.*
2 changes: 1 addition & 1 deletion PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: ccad
Version: 0.12
Version: 0.13
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Expand Down
3 changes: 3 additions & 0 deletions README
Expand Up @@ -78,6 +78,9 @@ committing.**
To Build the Documentation (only for developers)
================================================

Some files are captured with xwd (window dump). They're commented in
MANIFEST.in. The remaining are generated with generate_images.py.

cd ccad-ver/doc
python generate_images.py
sphinx-build . html
Expand Down
101 changes: 35 additions & 66 deletions display.py
Expand Up @@ -27,7 +27,7 @@

from __future__ import print_function
# Globals
version = '0.12' # Change also in setup.py, doc/conf.py
version = '0.13' # Change also in setup.py, doc/conf.py
interactive = True
manager = 'qt'
app = None
Expand All @@ -40,13 +40,15 @@
try:
from PyQt4 import QtCore as _QtCore, QtGui as _QtGui
except ImportError:
from PySide import QtCore as _QtCore, QtGui as _QtGui
manager = 'none'
print("""
Warning: Cannot find python-qt4. You will not be able to use ccad's
display. Instead, you may use pythonocc's viewers. ccad shapes may
be displayed in pythonocc's viewers by using the .shape attribute.
For example:
try:
from PySide import QtCore as _QtCore, QtGui as _QtGui
except:
manager = 'none'
print("""
Warning: Cannot find python-qt4 or pyside. You will not be able to
use ccad's display. Instead, you may use pythonocc's viewers. ccad
shapes may be displayed in pythonocc's viewers by using the .shape
attribute. For example:
import ccad.model as cm
import OCC.Display.SimpleGui as SimpleGui
Expand All @@ -69,13 +71,7 @@
_TCollection_ExtendedString)
from OCC.TopExp import TopExp_Explorer as _TopExp_Explorer
from OCC.Visual3d import Visual3d_ViewOrientation as _Visual3d_ViewOrientation
# Use lower level window routines for linux to allow multiple viewing
# windows. Doesn't work on other platforms.
if _sys.platform.startswith('linux'):
from OCC.Xw import (Xw_Window as _Xw_Window,
Xw_WQ_3DQUALITY as _Xw_WQ_3DQUALITY)
else:
from OCC.Visualization import Display3d as _Display3d
from OCC.Visualization import Display3d as _Display3d

import ccad.model as _cm

Expand Down Expand Up @@ -286,8 +282,7 @@ def __init__(self, perspective=False):

# Some Initial Values
self.mode_shaded()
self.glarea.occ_view.SetBackgroundColor(
_Quantity.Quantity_TOC_RGB, 0.0, 0.0, 0.0)
self.set_background((0.0, 0.0, 0.0))
self.set_triedron(1)

# Set up some initial states
Expand Down Expand Up @@ -346,7 +341,6 @@ def keyPressEvent(self, event):
self.status_bar.setText('Key ' + hex(key))
if key in self.key_table.values():
try:
print('Got to 2')
cmd = self.key_table.keys()[self.key_table.values().index(key)]
eval('self.' + cmd)
except:
Expand All @@ -370,7 +364,6 @@ def mouseReleaseEvent(self, event):
if self.glarea.occ_context.MoreSelected():
if self.glarea.occ_context.HasSelectedShape():
self.selected = self.glarea.occ_context.SelectedShape()
#print "Current selection (single):",self.selected_shape
else:
self.selected = None
self.make_selection()
Expand Down Expand Up @@ -594,7 +587,7 @@ def set_foreground(self, color):
"""
self.foreground = color

def set_triedron(self, state, position='down_right',
def set_triedron(self, state, position='bottom_right',
color=(1.0, 1.0, 1.0), size=0.08):
"""
Controls the triedron, the little x, y, z coordinate display.
Expand All @@ -607,22 +600,23 @@ def set_triedron(self, state, position='down_right',
if not state:
self.glarea.occ_view.TriedronErase()
else:
local_positions = {'down_right': _Aspect.Aspect_TOTP_RIGHT_LOWER,
'down_left': _Aspect.Aspect_TOTP_LEFT_LOWER,
'up_right': _Aspect.Aspect_TOTP_RIGHT_UPPER,
'up_left': _Aspect.Aspect_TOTP_LEFT_UPPER}
local_positions = {'bottom_right': _Aspect.Aspect_TOTP_RIGHT_LOWER,
'bottom_left': _Aspect.Aspect_TOTP_LEFT_LOWER,
'top_right': _Aspect.Aspect_TOTP_RIGHT_UPPER,
'top_left': _Aspect.Aspect_TOTP_LEFT_UPPER}
local_position = local_positions[position]
# Can't set Triedron color RGB-wise!
#qcolor = Quantity_Color(
# color[0], color[1], color[2], Quantity_TOC_RGB)
#qcolor = _Quantity.Quantity_Color(
# color[0], color[1], color[2], _Quantity.Quantity_TOC_RGB)
if color == (1.0, 1.0, 1.0):
qcolor = _Quantity.Quantity_NOC_WHITE
else:
qcolor = _Quantity.Quantity_NOC_BLACK
self.glarea.occ_view.TriedronDisplay(local_position,
qcolor,
size,
_V3d.V3d_WIREFRAME)
_V3d.V3d_ZBUFFER)
#_V3d.V3d_WIREFRAME)

# Things to Show Functions
def display(self, shape, color=None, material='default', transparency=0.0,
Expand Down Expand Up @@ -685,7 +679,7 @@ def display(self, shape, color=None, material='default', transparency=0.0,
# Set Color
if not color:
color = self.foreground
#print 'color', color
#print('color', color)

#drawer = AIS_Drawer()
#handle_drawer = drawer.GetHandle()
Expand Down Expand Up @@ -719,7 +713,7 @@ def display(self, shape, color=None, material='default', transparency=0.0,
# Set Shading Type
aspect_shading = _Prs3d.Prs3d_ShadingAspect()
handle_aspect_shading = aspect_shading.GetHandle()
#print 'shading color', color
#print('shading color', color)
aspect_shading.SetColor(qcolor, _Aspect.Aspect_TOFM_BOTH_SIDE)
local_materials = {'brass': _Graphic3d.Graphic3d_NOM_BRASS,
'bronze': _Graphic3d.Graphic3d_NOM_BRONZE,
Expand Down Expand Up @@ -1013,7 +1007,7 @@ def about(self):
_QtGui.QMessageBox.about(
self,
'ccad viewer ' + str(version),
'\251 Copyright 2014 by Charles Sharman and Others')
'\251 Copyright 2015 by Charles Sharman and Others')

def save(self, name=''):
"""
Expand Down Expand Up @@ -1090,42 +1084,17 @@ def start(self, perspective=False):
# Set up the OCC hooks to the OpenGL space
window_handle = int(self.winId())

if _sys.platform.startswith('linux'):
# This lower level routine allows multiple viewing
# windows. Only works on linux.
gd = _Graphic3d.Graphic3d_GraphicDevice(_os.environ['DISPLAY'])
window = _Xw_Window(
gd.GetHandle(),
window_handle >> 16,
window_handle & 0xffff,
_Xw_WQ_3DQUALITY)
self.occ_viewer = _V3d.V3d_Viewer(
gd.GetHandle(),
_TCollection_ExtendedString('Viewer').ToExtString())
handle_occ_viewer = self.occ_viewer.GetHandle()
self.occ_viewer.Init()
if perspective:
self.handle_view = self.occ_viewer.DefaultPerspectiveView()
else:
self.handle_view = self.occ_viewer.DefaultOrthographicView()
self.occ_view = self.handle_view.GetObject()
self.occ_view.SetWindow(window.GetHandle())
if not window.IsMapped():
window.Map()
self.occ_context = _AIS.AIS_InteractiveContext(handle_occ_viewer)
handle_occ_context = self.occ_context.GetHandle()

else:

self.d3d = _Display3d()
self.d3d.Init(window_handle)

handle_occ_context = self.d3d.GetContext()
handle_occ_viewer = self.d3d.GetViewer()
self.handle_view = self.d3d.GetView()
self.occ_context = handle_occ_context.GetObject()
self.occ_viewer = handle_occ_viewer.GetObject()
self.occ_view = self.handle_view.GetObject()
self.d3d = _Display3d()
self.d3d.Init(window_handle)

handle_occ_context = self.d3d.GetContext()
handle_occ_viewer = self.d3d.GetViewer()
self.handle_view = self.d3d.GetView()
self.occ_context = handle_occ_context.GetObject()
self.occ_viewer = handle_occ_viewer.GetObject()
self.occ_viewer.SetDefaultLights()
self.occ_viewer.SetLightOn()
self.occ_view = self.handle_view.GetObject()

def sizeHint(self):
return _QtCore.QSize(self.SCR[0], self.SCR[1])
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Expand Up @@ -45,9 +45,9 @@
# built documents.
#
# The short X.Y version.
version = '0.12' # Change also in ../setup.py, ../display.py
version = '0.13' # Change also in ../setup.py, ../display.py
# The full version, including alpha/beta/rc tags.
release = '0.12'
release = '0.13'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
Binary file added doc/display_hlr.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/display_shaded.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/display_spherebox1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/display_wireframe.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/example1_all_bricks.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/html/.buildinfo
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 3dbff60cf84c006c5d067e84d92cde31
config: 8529eff79444ba87057f610b67d0aca3
tags: fbb0d17656682115ca4d033fb2f83ba1
Binary file modified doc/html/_images/boolean_common.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/boolean_cut.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/boolean_fuse.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/boolean_glue.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/brick_bottom.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/brick_iso.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/brick_side.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/brick_top.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/cube_edge.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/cube_face.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/cube_solid.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/cube_vertex.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/cube_wire.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/derived_helical_solid.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/derived_loft.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/derived_offset_face.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/derived_offset_solid.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/derived_pipe.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/derived_prism.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/derived_revol.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/html/_images/derived_slice.png
Binary file modified doc/html/_images/display_display.png
Binary file modified doc/html/_images/edge_arc.png
Binary file modified doc/html/_images/edge_arc_ellipse.png
Binary file modified doc/html/_images/edge_bezier.png
Binary file modified doc/html/_images/edge_circle.png
Binary file modified doc/html/_images/edge_ellipse.png
Binary file modified doc/html/_images/edge_segment.png
Binary file modified doc/html/_images/edge_spline.png
Binary file modified doc/html/_images/example1_box.png
Binary file modified doc/html/_images/example1_boxwknob.png
Binary file modified doc/html/_images/example1_boxwknobs.png
Binary file modified doc/html/_images/example1_brick.png
Binary file modified doc/html/_images/example1_brickpost.png
Binary file modified doc/html/_images/example1_innerbrick.png
Binary file modified doc/html/_images/example1_innerbrickfillet.png
Binary file modified doc/html/_images/example1_outerbrick.png
Binary file modified doc/html/_images/example1_post.png
Binary file modified doc/html/_images/face_face_from.png
Binary file modified doc/html/_images/face_filling.png
Binary file modified doc/html/_images/face_plane.png
Binary file modified doc/html/_images/from_svg.png
Binary file modified doc/html/_images/logging_face_fillet.png
Binary file modified doc/html/_images/logging_solid_chamfer.png
Binary file modified doc/html/_images/logging_solid_draft.png
Binary file modified doc/html/_images/logging_solid_fillet.png
Binary file modified doc/html/_images/logging_solid_simplify1.png
Binary file modified doc/html/_images/logging_solid_simplify2.png
Binary file modified doc/html/_images/solid_box.png
Binary file modified doc/html/_images/solid_cone.png
Binary file modified doc/html/_images/solid_cylinder.png
Binary file modified doc/html/_images/solid_sphere.png
Binary file modified doc/html/_images/solid_torus.png
Binary file modified doc/html/_images/solid_wedge.png
Binary file modified doc/html/_images/trms_mirror.png
Binary file modified doc/html/_images/trms_rotate.png
Binary file modified doc/html/_images/trms_scale.png
Binary file modified doc/html/_images/trms_translate.png
Binary file modified doc/html/_images/wire.png
Binary file modified doc/html/_images/wire_helix.png
Binary file modified doc/html/_images/wire_ngon.png
Binary file modified doc/html/_images/wire_polygon.png
Binary file modified doc/html/_images/wire_rectangle.png
Binary file added doc/html/_static/ajax-loader.gif

0 comments on commit 69f0135

Please sign in to comment.