├── .gitignore ├── .travis.yml ├── Boost_OSX_Makefile.mak ├── DEVELOP.md ├── INSTALL.txt ├── MAC-OSX.md ├── MANIFEST.in ├── MSWINDOWS.txt ├── MakeVPython2.6.iss ├── MakeVPython2.7-32bit.iss ├── MakeVPython2.7-64bit.iss ├── MakeVPython2.7.iss ├── MakeVPython3.1.iss ├── MakeVPython3.2-64bit.iss ├── MakeVPython3.2.iss ├── README.md ├── VCBuild ├── .gitignore ├── VCBuild.txt ├── cvisual27-32bit.vcproj ├── cvisual27.ncb ├── cvisual27.sln ├── cvisual27.suo ├── cvisual27.vcproj ├── cvisual27.vcproj.BruceDesktop-PC.BruceDesktopW7.user ├── cvisual32.vcproj └── cvisual32.vcproj.BruceDesktop-PC.BruceDesktopW7.user ├── authors.txt ├── compilevisual.py ├── ez_setup.py ├── get_vpy_includes.py ├── include ├── GL │ └── glext.h ├── arrow.hpp ├── axial.hpp ├── box.hpp ├── cone.hpp ├── config.h ├── config.h.in ├── cylinder.hpp ├── display_kernel.hpp ├── ellipsoid.hpp ├── frame.hpp ├── label.hpp ├── light.hpp ├── material.hpp ├── mouse_manager.hpp ├── mouseobject.hpp ├── primitive.hpp ├── pyramid.hpp ├── python │ ├── arrayprim.hpp │ ├── convex.hpp │ ├── curve.hpp │ ├── extrusion.hpp │ ├── faces.hpp │ ├── num_util.hpp │ ├── numeric_texture.hpp │ ├── points.hpp │ ├── scalar_array.hpp │ ├── slice.hpp │ ├── vector_array.hpp │ └── wrap_vector.hpp ├── rectangular.hpp ├── renderable.hpp ├── ring.hpp ├── sphere.hpp ├── util │ ├── atomic_queue.hpp │ ├── displaylist.hpp │ ├── errors.hpp │ ├── extent.hpp │ ├── gl_enable.hpp │ ├── gl_extensions.hpp │ ├── gl_free.hpp │ ├── icososphere.hpp │ ├── quadric.hpp │ ├── rate.hpp │ ├── rgba.hpp │ ├── shader_program.hpp │ ├── sorted_model.hpp │ ├── texture.hpp │ ├── timer.hpp │ ├── tmatrix.hpp │ └── vector.hpp ├── vpython-config.h └── wrap_gl.hpp ├── license.txt ├── requirements.txt ├── requirements_test.txt ├── setup.cfg.example ├── setup.py ├── site-packages ├── vidle2 │ ├── AutoComplete.py │ ├── AutoCompleteWindow.py │ ├── AutoExpand.py │ ├── Bindings.py │ ├── CREDITS.txt │ ├── CallTipWindow.py │ ├── CallTips.py │ ├── ChangeLog │ ├── ClassBrowser.py │ ├── CodeContext.py │ ├── ColorDelegator.py │ ├── Debugger.py │ ├── Delegator.py │ ├── EditorWindow.py │ ├── FileList.py │ ├── FileRevert.py │ ├── FormatParagraph.py │ ├── GrepDialog.py │ ├── HISTORY.txt │ ├── HyperParser.py │ ├── IOBinding.py │ ├── Icons │ │ └── idle.icns │ ├── IdleHistory.py │ ├── MacBuildApp.py │ ├── Makefile.am │ ├── MultiCall.py │ ├── MultiStatusBar.py │ ├── NEWS.txt │ ├── ObjectBrowser.py │ ├── OutputWindow.py │ ├── ParenMatch.py │ ├── PathBrowser.py │ ├── Percolator.py │ ├── PyParse.py │ ├── PyShell.py │ ├── README.txt │ ├── RemoteDebugger.py │ ├── RemoteObjectBrowser.py │ ├── ReplaceDialog.py │ ├── RstripExtension.py │ ├── ScriptBinding.py │ ├── ScrolledList.py │ ├── SearchDialog.py │ ├── SearchDialogBase.py │ ├── SearchEngine.py │ ├── StackViewer.py │ ├── TODO.txt │ ├── ToolTip.py │ ├── TreeWidget.py │ ├── UndoDelegator.py │ ├── WidgetRedirector.py │ ├── WindowList.py │ ├── ZoomHeight.py │ ├── __init__.py │ ├── aboutDialog.py │ ├── config-extensions.def │ ├── config-highlight.def │ ├── config-keys.def │ ├── config-main.def │ ├── configDialog.py │ ├── configHandler.py │ ├── configHelpSourceEdit.py │ ├── configSectionNameDialog.py │ ├── dynOptionMenuWidget.py │ ├── extend.txt │ ├── help.txt │ ├── idle.bat │ ├── idle.py │ ├── idle.pyw │ ├── idlever.py │ ├── keybindingDialog.py │ ├── macosxSupport.py │ ├── pyclbr.py │ ├── rpc.py │ ├── run.py │ ├── tabbedpages.py │ ├── testcode.py │ ├── textView.py │ └── utils.py ├── vidle3 │ ├── AutoComplete.py │ ├── AutoCompleteWindow.py │ ├── AutoExpand.py │ ├── Bindings.py │ ├── CREDITS.txt │ ├── CallTipWindow.py │ ├── CallTips.py │ ├── ChangeLog │ ├── ClassBrowser.py │ ├── CodeContext.py │ ├── ColorDelegator.py │ ├── Debugger.py │ ├── Delegator.py │ ├── EditorWindow.py │ ├── FileList.py │ ├── FileRevert.py │ ├── FormatParagraph.py │ ├── GrepDialog.py │ ├── HISTORY.txt │ ├── HyperParser.py │ ├── IOBinding.py │ ├── Icons │ │ └── idle.icns │ ├── IdleHistory.py │ ├── Makefile.am │ ├── MultiCall.py │ ├── MultiStatusBar.py │ ├── NEWS.txt │ ├── ObjectBrowser.py │ ├── OutputWindow.py │ ├── ParenMatch.py │ ├── PathBrowser.py │ ├── Percolator.py │ ├── PyParse.py │ ├── PyShell.py │ ├── README.txt │ ├── RemoteDebugger.py │ ├── RemoteObjectBrowser.py │ ├── ReplaceDialog.py │ ├── RstripExtension.py │ ├── ScriptBinding.py │ ├── ScrolledList.py │ ├── SearchDialog.py │ ├── SearchDialogBase.py │ ├── SearchEngine.py │ ├── StackViewer.py │ ├── TODO.txt │ ├── ToolTip.py │ ├── TreeWidget.py │ ├── UndoDelegator.py │ ├── WidgetRedirector.py │ ├── WindowList.py │ ├── ZoomHeight.py │ ├── __init__.py │ ├── aboutDialog.py │ ├── config-extensions.def │ ├── config-highlight.def │ ├── config-keys.def │ ├── config-main.def │ ├── configDialog.py │ ├── configHandler.py │ ├── configHelpSourceEdit.py │ ├── configSectionNameDialog.py │ ├── dynOptionMenuWidget.py │ ├── extend.txt │ ├── help.txt │ ├── idle.bat │ ├── idle.py │ ├── idle.pyw │ ├── idlever.py │ ├── keybindingDialog.py │ ├── macosxSupport.py │ ├── rpc.py │ ├── run.py │ ├── tabbedpages.py │ ├── testcode.py │ ├── textView.py │ └── utils.py ├── vis │ ├── __init__.py │ ├── controls.py │ ├── factorial.py │ ├── filedialog.py │ ├── graph.py │ └── site_settings.py ├── visual │ ├── __init__.py │ ├── controls.py │ ├── docs │ │ ├── Templates │ │ │ └── template.dwt │ │ ├── VPython_Intro.pdf │ │ ├── VisualIntro.html │ │ ├── VisualRef-1.gif │ │ ├── VisualRef-2.gif │ │ ├── VisualRef-3.gif │ │ ├── VisualRef-4.gif │ │ ├── VisualRef-6.gif │ │ ├── VisualRef-7.gif │ │ ├── VisualRef.css │ │ ├── arrow.html │ │ ├── axes.gif │ │ ├── box.html │ │ ├── color.html │ │ ├── cone.html │ │ ├── controls.html │ │ ├── convex.html │ │ ├── curve.html │ │ ├── cylinder.html │ │ ├── defaults.html │ │ ├── delete.html │ │ ├── display.html │ │ ├── ellipsoid.html │ │ ├── extrusion.html │ │ ├── faces.html │ │ ├── factorial.html │ │ ├── files.html │ │ ├── float.html │ │ ├── frame.html │ │ ├── graph.html │ │ ├── helix.html │ │ ├── images │ │ │ ├── arc.jpg │ │ │ ├── arc_and_triangle_with_hole.jpg │ │ │ ├── arc_shape.jpg │ │ │ ├── arrow.jpg │ │ │ ├── box.jpg │ │ │ ├── circle.jpg │ │ │ ├── circle_frame.jpg │ │ │ ├── circle_shape.jpg │ │ │ ├── colors_abutting.jpg │ │ │ ├── combine_paths.jpg │ │ │ ├── cone.jpg │ │ │ ├── constructive_geometry.jpg │ │ │ ├── controls.jpg │ │ │ ├── convex.jpg │ │ │ ├── cross.jpg │ │ │ ├── cross_ellipse.jpg │ │ │ ├── cross_shape.jpg │ │ │ ├── curve.jpg │ │ │ ├── cylinder.jpg │ │ │ ├── ellipse.jpg │ │ │ ├── ellipse_shape.jpg │ │ │ ├── ellipsoid.jpg │ │ │ ├── extrusion.jpg │ │ │ ├── extrusion_twist.jpg │ │ │ ├── extrustion_scaling.jpg │ │ │ ├── faces.jpg │ │ │ ├── filedialog.jpg │ │ │ ├── frustum.jpg │ │ │ ├── gear.jpg │ │ │ ├── graph.jpg │ │ │ ├── helix.jpg │ │ │ ├── heptagon.jpg │ │ │ ├── hexagon.jpg │ │ │ ├── hexagon_shape.jpg │ │ │ ├── label.jpg │ │ │ ├── lathe.jpg │ │ │ ├── material_etc.jpg │ │ │ ├── ngon_shape.jpg │ │ │ ├── partial_circle_shape.jpg │ │ │ ├── pentagon.jpg │ │ │ ├── pentagon_shape.jpg │ │ │ ├── perimeter.jpg │ │ │ ├── perimeter_hollow.jpg │ │ │ ├── points.jpg │ │ │ ├── pyramid.jpg │ │ │ ├── rackgear.jpg │ │ │ ├── rectangle.jpg │ │ │ ├── rectangle_chamfered.jpg │ │ │ ├── rectangle_rotated.jpg │ │ │ ├── rectangle_rounded.jpg │ │ │ ├── rectangle_shape.jpg │ │ │ ├── rectangle_shape_chamfered.jpg │ │ │ ├── rectangle_shape_frame.jpg │ │ │ ├── rectangle_shape_rotated.jpg │ │ │ ├── rectangle_shape_rounded.jpg │ │ │ ├── ring.jpg │ │ │ ├── skin.jpg │ │ │ ├── sphere.jpg │ │ │ ├── star.jpg │ │ │ ├── star_shape.jpg │ │ │ ├── star_with_hole.jpg │ │ │ ├── starpath.jpg │ │ │ ├── text.jpg │ │ │ ├── text3d.jpg │ │ │ ├── text_extrusion.jpg │ │ │ ├── text_inverse.jpg │ │ │ ├── text_shape.jpg │ │ │ ├── trail.jpg │ │ │ ├── trapezoid.jpg │ │ │ ├── trapezoid_shape.jpg │ │ │ ├── triangle.jpg │ │ │ ├── triangle_circular_hole.jpg │ │ │ ├── triangle_frame.jpg │ │ │ ├── triangle_path.jpg │ │ │ ├── triangle_shape.jpg │ │ │ ├── triangle_with_hole.jpg │ │ │ ├── triangle_with_hole2.jpg │ │ │ ├── triangular_ring.jpg │ │ │ └── widgets.jpg │ │ ├── index.html │ │ ├── keyboard.html │ │ ├── label.html │ │ ├── license.txt │ │ ├── lights.html │ │ ├── materials.html │ │ ├── mouse.html │ │ ├── mouse_click.html │ │ ├── mouse_drag.html │ │ ├── navigation.js │ │ ├── new_features.html │ │ ├── options.html │ │ ├── paths.html │ │ ├── points.html │ │ ├── primitives.html │ │ ├── pyramid.html │ │ ├── rate.html │ │ ├── ring.gif │ │ ├── ring.html │ │ ├── rotation.html │ │ ├── shapes.html │ │ ├── sphere.html │ │ ├── spherebox.gif │ │ ├── text.html │ │ ├── trail.html │ │ └── vector.html │ ├── examples │ │ ├── bounce.py │ │ ├── bounce2.py │ │ ├── boxlighttest.py │ │ ├── camera.py │ │ ├── colorsliders.py │ │ ├── conch.py │ │ ├── controlstest.py │ │ ├── convex.py │ │ ├── crossproduct.py │ │ ├── crystal.py │ │ ├── differential_gear.py │ │ ├── dipole.py │ │ ├── doublependulum.py │ │ ├── drape.py │ │ ├── electric_motor.py │ │ ├── eventHandlers.py │ │ ├── extruded_columns.py │ │ ├── extrusion_examples.py │ │ ├── extrusion_overview.py │ │ ├── faces_cone.py │ │ ├── faces_heightfield.py │ │ ├── flower128.tga │ │ ├── gas.py │ │ ├── graphtest.py │ │ ├── gyro.py │ │ ├── gyro2.py │ │ ├── hanoi.py │ │ ├── keyinput.py │ │ ├── labels.py │ │ ├── lathe.py │ │ ├── lorenz.py │ │ ├── mandelbrot.py │ │ ├── material_test.py │ │ ├── medusa.py │ │ ├── orbit.py │ │ ├── planar.py │ │ ├── randombox.py │ │ ├── stars.py │ │ ├── stonehenge.py │ │ ├── text3D.py │ │ ├── texttest.py │ │ ├── texture_and_lighting.py │ │ ├── texturetest.py │ │ ├── tictac.py │ │ ├── tictacdat.py │ │ ├── toroid.py │ │ ├── toroid_drag.py │ │ ├── wave.py │ │ └── widgets.py │ ├── factorial.py │ ├── filedialog.py │ ├── graph.py │ ├── license.txt │ ├── text.py │ └── visual_all.py └── visual_common │ ├── .gitignore │ ├── BlueMarble.tga │ ├── __init__.py │ ├── brickbump.tga │ ├── controls.py │ ├── crayola.py │ ├── create_display.py │ ├── earth.tga │ ├── factorial.py │ ├── filedialog.py │ ├── graph.py │ ├── materials.py │ ├── paths.py │ ├── primitives.py │ ├── random.tga │ ├── rate_function.py │ ├── shapes.py │ ├── site_settings.py │ ├── turbulence3.tga │ └── wood.tga ├── src ├── Makefile.in ├── core │ ├── arrow.cpp │ ├── axial.cpp │ ├── box.cpp │ ├── cone.cpp │ ├── cylinder.cpp │ ├── display_kernel.cpp │ ├── ellipsoid.cpp │ ├── frame.cpp │ ├── label.cpp │ ├── light.cpp │ ├── material.cpp │ ├── mouse_manager.cpp │ ├── mouseobject.cpp │ ├── primitive.cpp │ ├── pyramid.cpp │ ├── rectangular.cpp │ ├── renderable.cpp │ ├── ring.cpp │ ├── sphere.cpp │ └── util │ │ ├── atomic_queue.cpp │ │ ├── displaylist.cpp │ │ ├── errors.cpp │ │ ├── extent.cpp │ │ ├── gl_extensions.cpp │ │ ├── gl_free.cpp │ │ ├── icososphere.cpp │ │ ├── quadric.cpp │ │ ├── rgba.cpp │ │ ├── shader_program.cpp │ │ ├── texture.cpp │ │ ├── tmatrix.cpp │ │ └── vector.cpp ├── gtk2 │ ├── apt-get-packages.sh │ ├── get_proc_address.cpp │ ├── makefile │ └── site-packages.pth ├── mac │ ├── PackageMaker │ │ ├── .gitignore │ │ ├── CVS │ │ │ ├── Entries │ │ │ ├── Repository │ │ │ └── Root │ │ ├── InstallReadme.txt │ │ ├── MacVIDLE-launchers.zip │ │ ├── VPY-6-py27.pmdoc.zip │ │ ├── Visual5_Python2.6_welcome.rtf │ │ ├── Visual5_Python3.1_welcome.rtf │ │ ├── Visual5_welcome.rtf │ │ ├── Visual6_welcome.rtf │ │ ├── buildPackage.py │ │ ├── copyFromInstalled.py │ │ ├── makeDependencyLinks.sh │ │ ├── packaging.txt │ │ ├── vpy_uninstall.app.zip │ │ └── vpy_uninstall.sh │ ├── get_proc_address.cpp │ └── makefile ├── python │ ├── arrayprim.cpp │ ├── convex.cpp │ ├── curve.cpp │ ├── cvisualmodule.cpp │ ├── extrusion.cpp │ ├── faces.cpp │ ├── num_util.cpp │ ├── numeric_texture.cpp │ ├── points.cpp │ ├── scalar_array.cpp │ ├── slice.cpp │ ├── vector_array.cpp │ ├── wrap_arrayobjects.cpp │ ├── wrap_display_kernel.cpp │ ├── wrap_primitive.cpp │ ├── wrap_rgba.cpp │ └── wrap_vector.cpp └── win32 │ └── get_proc_address.cpp ├── tests ├── __init__.py └── test_installation.py └── wxPython-src-2.9.5.0.patch /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.exe 7 | *.o 8 | *.so 9 | *.obj 10 | 11 | # Logs and databases # 12 | ###################### 13 | *.log 14 | *.pyc 15 | *.pyd 16 | # OS generated files # 17 | .DS_Store 18 | .DS_Store? 19 | ._* 20 | .Spotlight-V100 21 | .Trashes 22 | ehthumbs.db 23 | Thumbs.db 24 | /dependencies/ 25 | /build/ 26 | /dist/ 27 | *~ 28 | /VPython.egg-info/ 29 | 30 | # Distribute eggs and tarball 31 | distribute-* -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | # No longer support the 2008 version of Python 4 | # - "2.6" 5 | - "2.7" 6 | # vpython-wx and its dependencies are not Python3-compatible at this moment. 7 | # - "3.2" 8 | # - "3.3" 9 | 10 | # command to install dependencies 11 | # http://about.travis-ci.org/docs/user/build-configuration/#Installing-Packages-Using-apt 12 | before_install: 13 | - sudo apt-get update -qq 14 | - sudo apt-get install -qq libgtk2.0-dev libgtkglextmm-x11-1.2-dev libgtkmm-2.4-dev 15 | - sudo apt-get install python-dev 16 | - sudo apt-get install libboost-python-dev libboost-signals-dev 17 | - sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev 18 | - wget http://sourceforge.net/projects/wxpython/files/wxPython/2.9.4.0/wxPython-src-2.9.4.0.tar.bz2 19 | - tar xf wxPython-src-2.9.4.0.tar.bz2 20 | - cd wxPython-src-2.9.4.0/ 21 | - wget http://sourceforge.net/projects/wxpython/files/wxPython/2.9.4.0/wxPython-src-2.9.4.1.patch 22 | - patch -p0 < wxPython-src-2.9.4.1.patch 23 | - cd wxPython/ 24 | - python build-wxpython.py --build_dir=../bld 25 | - cd .. 26 | - export PYTHONPATH="$PWD/wxPython" 27 | - export LD_LIBRARY_PATH="$PWD/bld/lib" 28 | - cd .. 29 | # wxPython needs access to the X display, otherwise it will raise a SystemExit. 30 | # We need to "imitate" a monitor 31 | # http://about.travis-ci.org/docs/user/gui-and-headless-browsers/ 32 | - "export DISPLAY=:99.0" 33 | - "sh -e /etc/init.d/xvfb start" 34 | # Polygon2 needs to do an explicit download 35 | - wget https://bitbucket.org/jraedler/polygon2/downloads/Polygon2-2.0.6.zip 36 | - unzip Polygon2-2.0.6 37 | install: 38 | - "pip install -r requirements.txt" 39 | - "pip install ." 40 | - echo "Done with install part" 41 | - export PYTHONPATH=$PYTHONPATH:./site-packages 42 | - echo $PYTHONPATH 43 | # vidle2 and vidle3 seem to be confused. 44 | - ln -s vidle2 site-packages/vidle 45 | - ls . site-packages 46 | script: python -m unittest discover 2>&1 | tee unittest.out; tail -1 < unittest.out | grep -q OK 47 | # unittest does not set the exit code, so look for OK in the last line. 48 | # the complicated line is needed to both copy to stdout and set the exit code 49 | -------------------------------------------------------------------------------- /Boost_OSX_Makefile.mak: -------------------------------------------------------------------------------- 1 | SHELL = /bin/sh 2 | CXX = /usr/local/bin/g++-3.3.4 3 | 4 | VPATH = $(srcdir) $(srcdir)/converter $(srcdir)/detail $(srcdir)/object 5 | 6 | .DEFAULT = all 7 | 8 | boostroot = ../boost_1_31_0 9 | srcdir = $(boostroot)/libs/python/src 10 | boostincdir = $(boostroot) 11 | 12 | WARNINGFLAGS = 13 | OPTIMIZEFLAGS = -DNDEBUG -fpic -O3 14 | BOOSTFLAGS = -DBOOST_PYTHON_MAX_BASES=2 -DBOOST_PYTHON_SOURCE \ 15 | -DBOOST_PYTHON_DYNAMIC_LIB 16 | 17 | OBJS = aix_init_module.lo dict.lo errors.lo list.lo long.lo module.lo \ 18 | numeric.lo object_operators.lo object_protocol.lo str.lo tuple.lo \ 19 | arg_to_python_base.lo from_python.lo registry.lo \ 20 | type_id.lo class.lo enum.lo function.lo inheritance.lo iterator.lo \ 21 | life_support.lo pickle_support.lo builtin_converters.lo 22 | 23 | pythonroot = /sw 24 | pythonincdir = $(pythonroot)/include/python2.3 25 | 26 | DEPS = $(subst .lo,.d, $(OBJS)) 27 | 28 | %.lo: %.cpp 29 | $(CXX) -ftemplate-depth-120 $(WARNINGFLAGS) $(OPTIMIZEFLAGS) $(BOOSTFLAGS) -I$(pythonincdir) -I$(boostincdir) -c -o $@ $< 30 | 31 | %.d: %.cpp 32 | $(CXX) $(BOOSTFLAGS) -I$(pythonincdir) -I$(boostincdir) -MM -MF $@ -MT "$*.lo $@" $< 33 | 34 | DYLIB_FLAGS = -v -dynamiclib -undefined suppress -flat_namespace -compatibility_version 1.31.0 \ 35 | -current_version 1.31.0 36 | libboost_python.dylib: $(OBJS) 37 | ld -dynamic -m -r -d -o libboost_python.lo $^ 38 | $(CXX) $(DYLIB_FLAGS) -o $@ libboost_python.lo 39 | rm -f libboost_python.lo 40 | 41 | libboost_python.a: $(OBJS) 42 | ar rs $@ $^ 43 | 44 | 45 | all: libboost_python.dylib libboost_python.a 46 | -include $(DEPS) 47 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.md 2 | include setup.py 3 | include distribute_setup.py 4 | include site-packages/*.py 5 | include site-packages/*.txt 6 | include site-packages/*.def 7 | include site-packages/*.tga 8 | include site-packages/*.icns 9 | include site-packages/*.pdf 10 | include site-packages/*.html 11 | include site-packages/*.css 12 | include site-packages/*.gif 13 | include site-packages/*.js 14 | include site-packages/*.jpg 15 | include src/*.cpp 16 | include include/*.hpp 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Future development of VPython has moved to a new project 2 | 3 | This incarnation of VPython will not be developed further; see [this announcement](http://vpython.org/contents/announcements/evolution.html) for an explanation and [this history](https://matterandinteractions.wordpress.com/2016/04/27/a-time-line-for-vpython-development/) of the development of VPython. Development efforts are now focused on [VPython 7](https://github.com/BruceSherwood/vpython-jupyter), which runs with installed Python, including in a Jupyter notebook, and an in-browser version that requires no local installation at all and runs on mobile devices, at [glowscript.org](http://glowscript.org). 4 | 5 | The home of vpython on the web is still at [vpython.org](http://vpython.org). 6 | 7 | ## Read on for more information about the old VPython... 8 | 9 | vpython-wx 10 | ========== 11 | 12 | [![Build Status](https://travis-ci.org/BruceSherwood/vpython-wx.png?branch=master,stable)](https://travis-ci.org/BruceSherwood/vpython-wx) 13 | 14 | VPython 6, at [vpython.org](http://vpython.org), is based on the 15 | cross-platform library wxPython. It improves VPython 5.74 and earlier by 16 | eliminating most platform-dependent code and by eliminating the 17 | threading associated with rendering. 18 | 19 | The new version makes essential changes to the `rate` statement in VPython 20 | programs: 21 | 22 | * `rate` is now required; an animation loop **MUST** contain it. 23 | * `rate` still limits the number of loop iterations per second. 24 | * `rate` now updates the 3D scene when appropriate, about 30 times per second. 25 | * `rate` now handles mouse and keyboard events. 26 | * If the animation loop is missing the `rate` statement, the scene will not 27 | be updated until and unless the animation loop is completed. 28 | 29 | The heart of the user-interface code, creating windows and handling events, 30 | is the file *site-packages/visual_common/create_display.py*. It is 31 | imported by *visual/__init__.py* and by */vis/__init__.py*; *visual* 32 | imports *math* and *numpy* for convenience whereas *vis* doesn't. 33 | 34 | Please report issues to the 35 | [Github repository](https://github.com/BruceSherwood/vpython-wx), or to the 36 | [VPython forum](https://groups.google.com/forum/?fromgroups&hl=en#!forum/vpython-users). 37 | -------------------------------------------------------------------------------- /VCBuild/.gitignore: -------------------------------------------------------------------------------- 1 | cvisual/*.* 2 | libs/*.* 3 | /libs/ 4 | *.ncb 5 | *.suo 6 | *.sln 7 | *.htm 8 | *.idb 9 | *.pdb 10 | *.lib 11 | *.exp 12 | *.dep 13 | *.manifest 14 | -------------------------------------------------------------------------------- /VCBuild/VCBuild.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/VCBuild/VCBuild.txt -------------------------------------------------------------------------------- /VCBuild/cvisual27.ncb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/VCBuild/cvisual27.ncb -------------------------------------------------------------------------------- /VCBuild/cvisual27.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual C++ Express 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cvisual", "cvisual27.vcproj", "{6B195417-DC9C-499D-A16E-31FB23D526DF}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {6B195417-DC9C-499D-A16E-31FB23D526DF}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {6B195417-DC9C-499D-A16E-31FB23D526DF}.Debug|Win32.Build.0 = Debug|Win32 16 | {6B195417-DC9C-499D-A16E-31FB23D526DF}.Debug|x64.ActiveCfg = Debug|x64 17 | {6B195417-DC9C-499D-A16E-31FB23D526DF}.Debug|x64.Build.0 = Debug|x64 18 | {6B195417-DC9C-499D-A16E-31FB23D526DF}.Release|Win32.ActiveCfg = Release|Win32 19 | {6B195417-DC9C-499D-A16E-31FB23D526DF}.Release|Win32.Build.0 = Release|Win32 20 | {6B195417-DC9C-499D-A16E-31FB23D526DF}.Release|x64.ActiveCfg = Release|x64 21 | {6B195417-DC9C-499D-A16E-31FB23D526DF}.Release|x64.Build.0 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /VCBuild/cvisual27.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/VCBuild/cvisual27.suo -------------------------------------------------------------------------------- /authors.txt: -------------------------------------------------------------------------------- 1 | Original author of the Visual module: 2 | David Scherer 3 | 4 | Other members of the original design team at Carnegie Mellon: 5 | David Andersen 6 | Ruth Chabay 7 | Ari Heitner 8 | Ian Peters 9 | Bruce Sherwood 10 | 11 | Major contributor while an undergraduate at NCSU: 12 | Jonathan Brandmeyer 13 | 14 | Current maintainers: 15 | Bruce Sherwood 16 | 17 | Other significant contributors: 18 | Hugh Fisher (stereo code) 19 | Shaun Press (the pyramid and ellipsoid objects) 20 | John Zelle (stereo code) 21 | Kadir Haldenbilen (major contributions to extrusion object) 22 | Arthur Siegel (converted from numeric to numpy) 23 | Michael Temkine (Windows keyboard input; bug fixes) -------------------------------------------------------------------------------- /compilevisual.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | from visual.graph import * 3 | from visual.controls import * 4 | from visual.filedialog import * 5 | from visual.factorial import * 6 | from vis import * 7 | from vis.graph import * 8 | from vis.controls import * 9 | from vis.filedialog import * 10 | from vis.factorial import * 11 | text(text="3D", color=color.red, material=materials.wood) 12 | print(factorial(4)) 13 | print(version) 14 | sleep(0.1) 15 | get_file() 16 | 17 | # Run this little program to compile all the visual modules. 18 | # This is part of the production of a VPython installer for Windows. 19 | -------------------------------------------------------------------------------- /include/arrow.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_ARROW_HPP 2 | #define VPYTHON_ARROW_HPP 3 | 4 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 5 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | #include "primitive.hpp" 10 | #include "util/displaylist.hpp" 11 | 12 | namespace cvisual { 13 | 14 | /** A 3D 4-sided arrow, with adjustable head and shaft. **/ 15 | class arrow : public primitive 16 | { 17 | private: 18 | /** True if the width of the point and shaft should not vary with the length 19 | of the arrow. 20 | */ 21 | bool fixedwidth; 22 | 23 | /** If zero, then use automatic scaling for the width's of the parts of the 24 | arrow. If nonzero, they specify proportions for the arrow in world 25 | space. 26 | */ 27 | double headwidth; 28 | double headlength; 29 | double shaftwidth; 30 | 31 | void init_model(view& scene); 32 | bool degenerate(); 33 | 34 | /** Initializes these four variables with the effective geometry for the 35 | arrow. The resulting geometry is scaled to view space, but oriented 36 | and positioned in model space. The only requred transforms are 37 | reorientation and translation. 38 | */ 39 | void effective_geometry( 40 | double& headwidth, double& shaftwidth, double& length, 41 | double& headlength, double gcf); 42 | 43 | public: 44 | /** Default arrow. Pointing along +x, unit length, 45 | */ 46 | arrow(); 47 | arrow( const arrow& other); 48 | virtual ~arrow(); 49 | 50 | void set_headwidth( double hw); 51 | double get_headwidth(); 52 | 53 | void set_headlength( double hl); 54 | double get_headlength(); 55 | 56 | void set_shaftwidth( double sw); 57 | double get_shaftwidth(); 58 | 59 | void set_fixedwidth( bool fixed); 60 | bool is_fixedwidth(); 61 | 62 | void set_length( double l); 63 | double get_length(); 64 | 65 | protected: 66 | virtual void gl_pick_render(view&); 67 | virtual void gl_render(view&); 68 | 69 | virtual void grow_extent( extent&); 70 | virtual vector get_center() const; 71 | virtual void get_material_matrix(const view&, tmatrix& out); 72 | 73 | PRIMITIVE_TYPEINFO_DECL; 74 | }; 75 | 76 | } // !namespace cvisual 77 | 78 | #endif // !defined VPYTHON_ARROW_HPP 79 | -------------------------------------------------------------------------------- /include/axial.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_AXIAL_HPP 2 | #define VPYTHON_AXIAL_HPP 3 | 4 | #include "primitive.hpp" 5 | 6 | namespace cvisual { 7 | 8 | /** A subbase class used to only export 'radius' as a property once to Python. */ 9 | class axial : public primitive 10 | { 11 | protected: 12 | /// The radius of whatever body inherits from this class. 13 | double radius; 14 | axial(); 15 | axial( const axial& other); 16 | 17 | public: 18 | virtual ~axial(); 19 | void set_radius(double r); 20 | double get_radius(); 21 | virtual void get_material_matrix( const view&, tmatrix& out ); 22 | }; 23 | 24 | } // !namespace cvisual 25 | 26 | #endif // !defined VPYTHON_AXIAL_HPP 27 | -------------------------------------------------------------------------------- /include/box.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_BOX_HPP 2 | #define VPYTHON_BOX_HPP 3 | 4 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 5 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | #include "rectangular.hpp" 10 | #include "util/displaylist.hpp" 11 | 12 | namespace cvisual { 13 | 14 | class box : public rectangular 15 | { 16 | private: 17 | // True if the box should not be rendered. 18 | bool degenerate(); 19 | //static displaylist model; 20 | //static void init_model(displaylist& model, bool skip_right_face); 21 | static void init_model(view& scene, bool skip_right_face); 22 | friend class arrow; 23 | 24 | protected: 25 | //virtual void gl_pick_render( const view&); 26 | virtual void gl_pick_render( view&); 27 | //virtual void gl_render( const view&); 28 | virtual void gl_render( view&); 29 | virtual void grow_extent( extent& ); 30 | virtual void get_material_matrix( const view&, tmatrix& out ); 31 | 32 | PRIMITIVE_TYPEINFO_DECL; 33 | }; 34 | 35 | } // !namespace cvisual 36 | 37 | #endif // !defined VPYTHON_BOX_HPP 38 | -------------------------------------------------------------------------------- /include/cone.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_CONE_HPP 2 | #define VPYTHON_CONE_HPP 3 | 4 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 5 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | #include "axial.hpp" 10 | 11 | namespace cvisual { 12 | 13 | class cone : public axial 14 | { 15 | private: 16 | static void init_model(view& scene); 17 | bool degenerate(); 18 | 19 | public: 20 | cone(); 21 | 22 | void set_length( double l); 23 | double get_length(); 24 | 25 | protected: 26 | virtual void gl_pick_render(view&); 27 | virtual void gl_render(view&); 28 | virtual void grow_extent( extent&); 29 | virtual vector get_center() const; 30 | PRIMITIVE_TYPEINFO_DECL; 31 | }; 32 | 33 | } // !namespace cvisual 34 | 35 | #endif // !defined VPYTHON_CONE_HPP 36 | -------------------------------------------------------------------------------- /include/config.h: -------------------------------------------------------------------------------- 1 | #ifndef VISUAL_CONFIG_H 2 | #define VISUAL_CONFIG_H 3 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherrer and others. 4 | // See the file liscence.txt for complete liscence terms. 5 | // See the file authors.txt for a complete list of contributors. 6 | /* 7 | * Configuration header file. This file is automatically generated by configure. 8 | * You should change config.h.in and configure.ac rather than this file 9 | * See also platform.h 10 | */ 11 | 12 | /* 13 | * Set this to 1 if we are building on some Win32 platform 14 | */ 15 | #undef HAVE_WIN32_API 16 | 17 | /* 18 | * Set this to 1 if your platform supports GtkGLarea. 19 | */ 20 | #undef HAVE_GTK_GL_AREA 21 | 22 | /* 23 | * Set this to 1 if your platform supports GtkGLExtmm. 24 | * This support is experimental 25 | */ 26 | #define HAVE_GTK_GL_EXT_MM 27 | 28 | /* 29 | * Set this to 1 if you want to build Visual with support for Numeric 30 | */ 31 | #define VISUAL_HAVE_NUMERIC 1 32 | 33 | /* 34 | * Set this to 1 if you want to build Visual with support for Numarray 35 | */ 36 | #define VISUAL_HAVE_NUMARRAY 1 37 | 38 | #endif // !VISUAL_CONFIG_H 39 | -------------------------------------------------------------------------------- /include/config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef VISUAL_CONFIG_H 2 | #define VISUAL_CONFIG_H 3 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherrer and others. 4 | // See the file liscence.txt for complete liscence terms. 5 | // See the file authors.txt for a complete list of contributors. 6 | /* 7 | * Configuration header file. This file is automatically generated by configure. 8 | * You should change config.h.in and configure.ac rather than this file 9 | * See also platform.h 10 | */ 11 | 12 | /* 13 | * Set this to 1 if we are building on some Win32 platform 14 | */ 15 | #undef HAVE_WIN32_API 16 | 17 | /* 18 | * Set this to 1 if your platform supports GtkGLarea. 19 | */ 20 | #undef HAVE_GTK_GL_AREA 21 | 22 | /* 23 | * Set this to 1 if your platform supports GtkGLExtmm. 24 | * This support is experimental 25 | */ 26 | #undef HAVE_GTK_GL_EXT_MM 27 | 28 | /* 29 | * Set this to 1 if you want to build Visual with support for Numeric 30 | */ 31 | #undef VISUAL_HAVE_NUMERIC 32 | 33 | /* 34 | * Set this to 1 if you want to build Visual with support for Numarray 35 | */ 36 | #undef VISUAL_HAVE_NUMARRAY 37 | 38 | #endif // !VISUAL_CONFIG_H 39 | -------------------------------------------------------------------------------- /include/cylinder.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_CYLINDER_HPP 2 | #define VPYTHON_CYLINDER_HPP 3 | 4 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 5 | // Copyright (c) 2003, 2004 by Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | #include "axial.hpp" 10 | 11 | namespace cvisual { 12 | 13 | class cylinder : public axial 14 | { 15 | private: 16 | static void init_model(view& scene); 17 | bool degenerate(); 18 | 19 | public: 20 | cylinder(); 21 | cylinder( const cylinder&); 22 | virtual ~cylinder(); 23 | 24 | void set_length( double l); 25 | double get_length(); 26 | 27 | protected: 28 | virtual void gl_pick_render( view&); 29 | virtual void gl_render( view&); 30 | virtual void grow_extent( extent&); 31 | virtual vector get_center() const; 32 | PRIMITIVE_TYPEINFO_DECL; 33 | }; 34 | 35 | } // !namespace cvisual 36 | 37 | #endif // !defined VPYTHON_CYLINDER_HPP 38 | -------------------------------------------------------------------------------- /include/ellipsoid.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_ELLIPSOID_HPP 2 | #define VPYTHON_ELLIPSOID_HPP 3 | 4 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 5 | // Copyright (c) 2003, 2004 by Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | #include "sphere.hpp" 10 | 11 | namespace cvisual { 12 | 13 | class ellipsoid : public sphere 14 | { 15 | private: 16 | double height; 17 | double width; 18 | 19 | public: 20 | ellipsoid(); 21 | 22 | void set_length( double l); 23 | double get_length(); 24 | 25 | void set_height( double h); 26 | double get_height(); 27 | 28 | void set_width( double w); 29 | double get_width(); 30 | 31 | vector get_size(); 32 | void set_size( const vector&); 33 | 34 | protected: 35 | virtual vector get_scale(); 36 | virtual void grow_extent( extent&); 37 | virtual bool degenerate(); 38 | PRIMITIVE_TYPEINFO_DECL; 39 | }; 40 | 41 | } // !namespace cvisual 42 | 43 | #endif // !defined VPYTHON_ELLIPSOID_HPp 44 | -------------------------------------------------------------------------------- /include/light.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_LIGHT_HPP 2 | #define VPYTHON_LIGHT_HPP 3 | #pragma once 4 | 5 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | #include "util/tmatrix.hpp" 10 | #include "util/rgba.hpp" 11 | #include "renderable.hpp" 12 | 13 | namespace cvisual { 14 | 15 | class light : public renderable 16 | { 17 | protected: 18 | rgb color; 19 | 20 | virtual vertex get_vertex(double gcf) = 0; 21 | 22 | public: 23 | virtual rgb get_color() { return color; } 24 | virtual void set_color( const rgb& r ) { color = r; } 25 | 26 | // renderable protocol 27 | virtual void outer_render( const view& ) {} 28 | virtual vector get_center() const { return vector(); } 29 | virtual void set_material( shared_ptr ) { throw std::invalid_argument("light object does not have a material."); } 30 | virtual shared_ptr get_material() { throw std::invalid_argument("light object does not have a material."); } 31 | virtual bool is_light() { return true; } 32 | virtual void render_lights( view& ); 33 | }; 34 | 35 | class local_light : public light { 36 | protected: 37 | vector position; 38 | virtual vertex get_vertex(double gcf) { return vertex( position*gcf, 1.0 ); } 39 | public: 40 | virtual const vector& get_pos() { return position; } 41 | virtual void set_pos(const vector& v) { position = v; } 42 | }; 43 | 44 | class distant_light : public light { 45 | protected: 46 | vector direction; 47 | virtual vertex get_vertex(double gcf) { return vertex( direction, 0.0 ); } 48 | public: 49 | virtual const vector& get_direction() { return direction; } 50 | virtual void set_direction(const vector& v) { direction = v.norm(); } 51 | }; 52 | 53 | } // !namespace cvisual 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/material.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_MATERIAL_HPP 2 | #define VPYTHON_MATERIAL_HPP 3 | #pragma once 4 | 5 | #include "util/texture.hpp" 6 | #include "util/shader_program.hpp" 7 | 8 | namespace cvisual { 9 | 10 | class material { 11 | public: 12 | material(); 13 | 14 | void set_textures( std::vector< boost::shared_ptr< texture > > ); 15 | std::vector< boost::shared_ptr< texture > > get_textures(); 16 | 17 | void set_shader( const std::string& ); 18 | std::string get_shader(); 19 | 20 | void set_translucent( bool ); 21 | bool get_translucent(); 22 | 23 | shader_program* get_shader_program() { return shader.get(); } 24 | 25 | private: 26 | friend class apply_material; 27 | 28 | std::vector< boost::shared_ptr< texture > > textures; 29 | boost::scoped_ptr< shader_program > shader; 30 | bool translucent; 31 | }; 32 | 33 | class apply_material { 34 | public: 35 | apply_material( const view& v, material* m, tmatrix& material_matrix ); 36 | ~apply_material(); 37 | 38 | private: 39 | const view& v; 40 | use_shader_program sp; 41 | }; 42 | 43 | } // namespace cvisual 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /include/mouse_manager.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_MOUSE_MANAGER_HPP 2 | #define VPYTHON_MOUSE_MANAGER_HPP 3 | #pragma once 4 | 5 | #include "mouseobject.hpp" 6 | 7 | namespace cvisual { 8 | 9 | // mouse_manager is reponsible for translating physical mouse movements into VPython 10 | // mouse events and camera actions. 11 | 12 | class mouse_manager { 13 | public: 14 | mouse_manager( class display_kernel& display ); 15 | 16 | // Called by the display driver to report mouse movement 17 | // Ideally this should be called in event handlers so that each successive change in mouse state 18 | // is captured in order, but a driver might just call this periodically with the current state. 19 | // If the mouse is locked, but has "moved" by (dx,dy), the driver should pass get_x()+dx, get_y()+dy 20 | void report_mouse_state(int physical_button_count, bool is_button_down[], 21 | int old_x, int old_y, 22 | int new_x, int new_y, 23 | int shift_state_count, bool shift_state[] ); 24 | 25 | // Get the current position of the mouse cursor relative to the window client area 26 | int get_x(); 27 | int get_y(); 28 | 29 | mouse_t& get_mouse(); 30 | 31 | private: 32 | void update( bool new_buttons[], int old_px, int old_py, int new_px, int new_py, bool new_shift[] ); 33 | 34 | mouse_t mouse; 35 | display_kernel& display; 36 | 37 | bool buttons[2]; 38 | int px, py; 39 | bool left_down, left_dragging, left_semidrag; 40 | bool middle_down, middle_dragging, middle_semidrag; 41 | bool right_down, right_dragging, right_semidrag; 42 | }; 43 | 44 | } // namespace cvisual 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/pyramid.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_PYRAMID_HPP 2 | #define VPYTHON_PYRAMID_HPP 3 | 4 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 5 | // Copyright (c) 2003, 2004 by Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | #include "rectangular.hpp" 10 | #include "util/displaylist.hpp" 11 | 12 | #include 13 | 14 | namespace cvisual { 15 | 16 | using boost::scoped_ptr; 17 | 18 | class pyramid : public rectangular 19 | { 20 | private: 21 | static displaylist model; 22 | static void init_model(view& scene); 23 | friend class arrow; 24 | 25 | protected: 26 | virtual void gl_pick_render( view&); 27 | virtual void gl_render( view&); 28 | virtual void grow_extent( extent&); 29 | virtual vector get_center() const; 30 | virtual void get_material_matrix( const view&, tmatrix& out ); 31 | 32 | PRIMITIVE_TYPEINFO_DECL; 33 | }; 34 | 35 | } // !namespace cvisual 36 | 37 | #endif // !defined VPYTHON_PYRAMID_HPP 38 | -------------------------------------------------------------------------------- /include/python/convex.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_PYTHON_CONVEX_HPP 2 | #define VPYTHON_PYTHON_CONVEX_HPP 3 | 4 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 5 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | #include "renderable.hpp" 10 | #include "util/sorted_model.hpp" 11 | #include "python/arrayprim.hpp" 12 | 13 | #include 14 | 15 | namespace cvisual { namespace python { 16 | 17 | class convex : public arrayprim 18 | { 19 | private: 20 | struct face : triangle 21 | { 22 | double d; 23 | inline face( const vector& v1, const vector& v2, const vector& v3) 24 | : triangle( v1, v2, v3), d( normal.dot(corner[0])) 25 | { 26 | } 27 | 28 | inline bool visible_from( const vector& p) 29 | { return normal.dot(p) > d; } 30 | }; 31 | 32 | struct edge 33 | { 34 | vector v[2]; 35 | inline edge( vector a, vector b) 36 | { v[0]=a; v[1]=b; } 37 | 38 | inline bool 39 | operator==( const edge& b) const 40 | { 41 | // There are two cases where a pair of edges are equal, the first is 42 | // occurs when the endpoints are both the same, while the other occurs 43 | // when the edge have the same endpoints in opposite directions. 44 | // Since the first case never happens when we construct the hull, we 45 | // only test for the second case here. 46 | return (v[0] == b.v[1] && v[1] == b.v[0]); 47 | } 48 | }; 49 | 50 | struct jitter_table 51 | { 52 | enum { mask = 1023 }; 53 | enum { count = mask+1 }; 54 | double v[count]; 55 | 56 | jitter_table() 57 | { 58 | for(int i=0; i(rand()) / RAND_MAX - 0.5) * 2 * 1e-6; 60 | } 61 | }; 62 | static jitter_table jitter; // Use default construction for initialization. 63 | 64 | long last_checksum; 65 | long checksum() const; 66 | bool degenerate() const; 67 | 68 | // Hull construction routines. 69 | void recalc(); 70 | void add_point( size_t, vector); 71 | std::vector hull; 72 | vector min_extent, max_extent; 73 | 74 | public: 75 | convex(); 76 | 77 | void set_color( const rgb&); 78 | rgb get_color(); 79 | 80 | protected: 81 | virtual void gl_render(view&); 82 | virtual vector get_center() const; 83 | virtual void gl_pick_render(view&); 84 | virtual void grow_extent( extent&); 85 | virtual void get_material_matrix( const view&, tmatrix& out ); 86 | }; 87 | 88 | } } // !namespace cvisual::python 89 | 90 | #endif // !defined VPYTHON_PYTHON_CONVEX_HPP 91 | -------------------------------------------------------------------------------- /include/python/curve.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_PYTHON_CURVE_HPP 2 | #define VPYTHON_PYTHON_CURVE_HPP 3 | 4 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 5 | // Copyright (c) 2003, 2004 Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | #include "renderable.hpp" 10 | #include "util/displaylist.hpp" 11 | #include "python/num_util.hpp" 12 | #include "python/arrayprim.hpp" 13 | 14 | namespace cvisual { namespace python { 15 | 16 | using boost::python::list; 17 | using boost::python::numeric::array; 18 | 19 | class curve : public arrayprim_color 20 | { 21 | protected: 22 | // The pos and color arrays are always overallocated to make appends 23 | // faster. Whenever they are read from Python, we return a slice into the 24 | // array that starts at its beginning and runs up to the last used position 25 | // in the array. This is simmilar to many implementations of std::vector<>. 26 | bool antialias; 27 | double radius; 28 | 29 | static const int MAX_SIDES = 20; 30 | size_t sides; 31 | int curve_slice[512]; 32 | float curve_sc[2*MAX_SIDES]; 33 | 34 | // Returns true if the object is single-colored. 35 | bool monochrome(float* tcolor, size_t pcount); 36 | 37 | virtual void outer_render(view&); 38 | virtual void gl_render(view&); 39 | virtual vector get_center() const; 40 | virtual void gl_pick_render(view&); 41 | virtual void grow_extent( extent&); 42 | void get_material_matrix( const view& v, tmatrix& out ); 43 | 44 | // Returns true if the object is degenarate and should not be rendered. 45 | bool degenerate() const; 46 | 47 | public: 48 | curve(); 49 | 50 | inline bool get_antialias( void) { return antialias; } 51 | inline double get_radius( void) { return radius; } 52 | 53 | void set_antialias( bool); 54 | void set_radius( const double& r); 55 | 56 | private: 57 | bool adjust_colors( const view& scene, float* tcolor, size_t pcount); 58 | void thickline( const view&, double* spos, float* tcolor, size_t pcount, double scaled_radius); 59 | }; 60 | 61 | } } // !namespace cvisual::python 62 | 63 | #endif // !VPYTHON_PYTHON_CURVE_HPP 64 | -------------------------------------------------------------------------------- /include/python/faces.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_PYTHON_FACES_HPP 2 | #define VPYTHON_PYTHON_FACES_HPP 3 | 4 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 5 | // See the file license.txt for complete license terms. 6 | // See the file authors.txt for a complete list of contributors. 7 | 8 | #include "renderable.hpp" 9 | #include "python/arrayprim.hpp" 10 | 11 | #include 12 | 13 | namespace cvisual { namespace python { 14 | 15 | class faces : public arrayprim_color 16 | { 17 | protected: 18 | arrayprim_array normal; // An array of normal vectors for the faces. 19 | 20 | virtual void set_length(size_t); 21 | 22 | bool degenerate() const; 23 | virtual void gl_render(view&); 24 | virtual void gl_pick_render(view&); 25 | virtual vector get_center() const; 26 | virtual void grow_extent( extent&); 27 | virtual void get_material_matrix( const view&, tmatrix& ); 28 | 29 | public: 30 | faces(); 31 | 32 | // Add another vertex, normal, and color to the faces. 33 | void append_rgb( const vector&, const vector&, float red=-1, float green=-1, float blue=-1); 34 | void append( const vector&, const vector&, const rgb& ); 35 | void append( const vector&, const vector& ); 36 | void append( const vector& ); 37 | 38 | // This routine was adapted from faces_heightfield.py. It averages the normal 39 | // vectors at coincident vertices to smooth out boundaries between facets, 40 | // for normals that are within about 15 degrees of each other (cos > .95). 41 | // The intent is to smooth what should be smooth but preserve sharp corners. 42 | void smooth(); 43 | void smooth_d(const float); 44 | 45 | void make_normals(); 46 | void make_twosided(); 47 | 48 | boost::python::object get_normal(); 49 | void set_normal( const double_array& normal); 50 | void set_normal_v( const vector); 51 | }; 52 | 53 | } } // !namespace cvisual::python 54 | 55 | #endif // !defined VPYTHON_PYTHON_FACES_HPP 56 | -------------------------------------------------------------------------------- /include/python/numeric_texture.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 by Jonathan Brandmeyer and others. 2 | // See the file license.txt for complete license terms. 3 | // See the file authors.txt for a complete list of contributors. 4 | 5 | #ifndef VPYTHON_PYTHON_NUMERIC_TEXTURE_HPP 6 | #define VPYTHON_PYTHON_NUMERIC_TEXTURE_HPP 7 | 8 | #include 9 | #include "util/texture.hpp" 10 | #include "python/num_util.hpp" 11 | #include "wrap_gl.hpp" 12 | 13 | //AS removed include added typedef for VC++ compatibility. 14 | 15 | //#include 16 | typedef unsigned uint32_t; 17 | 18 | namespace cvisual { namespace python { 19 | 20 | /** 21 | * Python users can specify a texture as NxMxC, where N and M are preferred to 22 | * be powers of 2. C is the number of color channels, and must be one of 23 | * 1, 2, 3, or 4. The meaning of the texture is determined by its channels: 24 | * 1: luminance or opacity map (default: luminance) 25 | * 2: luminance-opacity 26 | * 3: RGB 27 | * 4: RGBA 28 | * 29 | * 30 | */ 31 | class numeric_texture : public texture 32 | { 33 | private: 34 | boost::python::numeric::array texdata; 35 | 36 | // A texture is data_width x data_height x data_channels 37 | size_t data_width; 38 | size_t data_height; 39 | size_t data_depth; 40 | size_t data_channels; 41 | NPY_TYPES data_type; // The type of C data in the memory object 42 | GLenum data_textype; // The type of GL texture object (GL_ALPHA, GL_RGB, etc) 43 | bool data_mipmapped; // true if the data should be mipmapped 44 | bool data_antialias; 45 | bool data_clamp; 46 | 47 | size_t tex_width; 48 | size_t tex_height; 49 | size_t tex_depth; 50 | size_t tex_channels; 51 | NPY_TYPES tex_type; 52 | GLenum tex_textype; 53 | bool tex_mipmapped; 54 | bool tex_antialias; 55 | bool tex_clamp; 56 | 57 | bool degenerate() const; 58 | bool should_reinitialize() const; 59 | 60 | protected: 61 | virtual void gl_init(const struct view&); 62 | virtual void gl_transform(void); 63 | 64 | public: 65 | virtual int enable_type() const; 66 | 67 | numeric_texture(); 68 | virtual ~numeric_texture(); 69 | 70 | void set_data( boost::python::numeric::array data); 71 | boost::python::numeric::array get_data(); 72 | 73 | void set_type( std::string requested_type); 74 | std::string get_type() const; 75 | 76 | void set_mipmapped( bool); 77 | bool is_mipmapped( void); 78 | 79 | void set_antialias( bool); 80 | bool is_antialiased( void); 81 | 82 | void set_clamp(bool x) { data_clamp = x; } 83 | bool get_clamp() { return data_clamp; } 84 | }; 85 | 86 | } } // !namespace cvisual::python 87 | 88 | #endif /* VPYTHON_PYTHON_NUMERIC_TEXTURE_HPP */ 89 | -------------------------------------------------------------------------------- /include/python/points.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_PYTYHON_POINTS_HPP 2 | #define VPYTHON_PYTYHON_POINTS_HPP 3 | 4 | #include "renderable.hpp" 5 | #include "python/num_util.hpp" 6 | #include "python/arrayprim.hpp" 7 | 8 | namespace cvisual { namespace python { 9 | 10 | class points : public arrayprim_color 11 | { 12 | private: 13 | // Specifies whether or not the size of the points should scale with the 14 | // world or with the screen. 15 | enum { WORLD, PIXELS } size_units; 16 | 17 | // Specifies the shape of the point. Future candidates are triangles, 18 | // diamonds, etc. 19 | enum { ROUND, SQUARE } points_shape; 20 | 21 | // The size of the points 22 | float size; 23 | 24 | bool degenerate() const; 25 | 26 | virtual void outer_render(view&); 27 | virtual void gl_render(view&); 28 | virtual vector get_center() const; 29 | virtual void gl_pick_render(view&); 30 | virtual void grow_extent( extent&); 31 | 32 | public: 33 | points(); 34 | 35 | void set_points_shape( const std::string& n_type); 36 | std::string get_points_shape( void); 37 | 38 | void set_size( float r); 39 | inline float get_size( void) { return size; } 40 | 41 | void set_size_units( const std::string& n_type); 42 | std::string get_size_units( void); 43 | }; 44 | 45 | } } // !namespace cvisual::python 46 | 47 | #endif /*VPYTHON_PYTYHON_POINTS_HPP*/ 48 | -------------------------------------------------------------------------------- /include/python/slice.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_PYTHON_SLICE_HPP 2 | #define VPYTHON_PYTHON_SLICE_HPP 3 | 4 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 5 | // See the file license.txt for complete license terms. 6 | // See the file authors.txt for a complete list of contributors. 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace cvisual { namespace python { 15 | 16 | using boost::python::slice_nil; 17 | namespace detail = boost::python::detail; 18 | 19 | class slice : public boost::python::object 20 | { 21 | public: 22 | // Equivalent to slice(::) 23 | slice(); 24 | 25 | // Each argument must be int, slice_nil, or implicitly convertable to int 26 | template 27 | slice( Integer1 start, Integer2 stop) 28 | : boost::python::object( boost::python::detail::new_reference( 29 | PySlice_New( object(start).ptr(), object(stop).ptr(), NULL))) 30 | {} 31 | 32 | template 33 | slice( Integer1 start, Integer2 stop, Integer3 stride) 34 | : boost::python::object( boost::python::detail::new_reference( 35 | PySlice_New( object(start).ptr(), object(stop).ptr(), 36 | object(stride).ptr()))) 37 | {} 38 | 39 | // Get the Python objects associated with the slice. In principle, these 40 | // may be any arbitrary Python type, but in practice they are usually 41 | // integers. If one or more parameter is ommited in the Python expression 42 | // that created this slice, than that parameter is None here, and compares 43 | // equal to a default-constructed boost::python::object. 44 | // If a user-defined type wishes to support slicing, then support for the 45 | // special meaning associated with negative indices is up to the user. 46 | boost::python::object start(); 47 | boost::python::object stop(); 48 | boost::python::object step(); 49 | 50 | public: 51 | // This declaration, in conjunction with the specialization of 52 | // object_manager_traits<> below, allows C++ functions accepting slice 53 | // arguments to be called from Python. These constructors should never 54 | // be used in client code. 55 | BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(slice, boost::python::object) 56 | }; 57 | } } // !namespace cvisual::python 58 | 59 | namespace boost { namespace python { namespace converter { 60 | 61 | template<> 62 | struct object_manager_traits 63 | : pytype_object_manager_traits<&PySlice_Type, cvisual::python::slice> 64 | { 65 | }; 66 | 67 | } } }// !namespace boost::python::converter 68 | 69 | #endif // !defined VVPYTHON_PYTHON_SLICE_HPP 70 | -------------------------------------------------------------------------------- /include/python/wrap_vector.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CVISUAL_PYTHON_WRAP_VECTOR_HPP 2 | #define CVISUAL_PYTHON_WRAP_VECTOR_HPP 3 | 4 | #include "util/vector.hpp" 5 | #include 6 | 7 | namespace cvisual { 8 | 9 | // Convert a general Python object to a Visual vector. This function may 10 | // throw. 11 | cvisual::vector tovector( boost::python::object); 12 | 13 | } // !namespace cvisual::python 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /include/rectangular.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_RECTANGULAR_HPP 2 | #define VPYTHON_RECTANGULAR_HPP 3 | 4 | #include "primitive.hpp" 5 | 6 | namespace cvisual { 7 | 8 | class rectangular : public primitive 9 | { 10 | protected: 11 | double width; 12 | double height; 13 | rectangular(); 14 | rectangular( const rectangular& other); 15 | 16 | void apply_transform( const view& ); 17 | 18 | public: 19 | virtual ~rectangular(); 20 | 21 | void set_length( double l); 22 | double get_length(); 23 | 24 | void set_height( double h); 25 | double get_height(); 26 | 27 | void set_width( double w); 28 | double get_width(); 29 | 30 | vector get_size(); 31 | void set_size( const vector&); 32 | }; 33 | 34 | } // !namespace cvisual 35 | 36 | #endif // !defined VPYTHON_RECTANGULAR_HPP 37 | -------------------------------------------------------------------------------- /include/ring.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_RING_HPP 2 | #define VPYTHON_RING_HPP 3 | 4 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 5 | // Copyright (c) 2003, 2004 by Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | #include "axial.hpp" 10 | 11 | #ifdef __GNUC__ 12 | # define NONNULL __attribute__((nonnull)) 13 | #else 14 | # define NONNULL 15 | #endif 16 | 17 | namespace cvisual { 18 | 19 | // This model representation is intended to be "sort of like" what a next generation 20 | // two phase renderer would use. Eventually, therefore, it should be replaced with 21 | // the real thing. 22 | struct fvertex { 23 | union { 24 | float v[3]; 25 | struct { float x, y, z; }; 26 | }; 27 | fvertex() {} // uninitialized! 28 | fvertex( const vector& v ) : x(v.x), y(v.y), z(v.z) {} 29 | }; 30 | 31 | class model { 32 | public: 33 | std::vector< unsigned short > indices; 34 | std::vector< fvertex > vertex_pos; 35 | std::vector< fvertex > vertex_normal; 36 | }; 37 | 38 | class ring : public axial 39 | { 40 | private: 41 | // The radius of the ring's body. If not specified, it is set to 1/10 of 42 | // the radius of the body. 43 | double thickness; 44 | PRIMITIVE_TYPEINFO_DECL; 45 | bool degenerate(); 46 | 47 | cvisual::model model; 48 | int model_rings, model_bands; 49 | double model_radius, model_thickness; 50 | 51 | public: 52 | ring(); 53 | virtual ~ring(); 54 | void set_thickness( double t); 55 | double get_thickness(); 56 | 57 | protected: 58 | virtual void gl_pick_render(view&); 59 | virtual void gl_render(view&); 60 | virtual void grow_extent( extent&); 61 | void get_material_matrix(const view&, tmatrix& out); 62 | 63 | void create_model( int rings, int bands, class model& m ); 64 | }; 65 | 66 | } // !namespace cvisual 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /include/sphere.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_SPHERE_HPP 2 | #define VPYTHON_SPHERE_HPP 3 | 4 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 5 | // Copyright (c) 2003, 2004 by Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | #include "axial.hpp" 10 | #include "util/displaylist.hpp" 11 | 12 | namespace cvisual { 13 | 14 | /** A simple monochrome sphere. 15 | */ 16 | class sphere : public axial 17 | { 18 | private: 19 | /** The level-of-detail cache. It is stored for the life of the program, and 20 | initialized when the first sphere is rendered. At one time there were 21 | going to be additional entries for the textured case, but that was 22 | not implemented. 23 | */ 24 | //static displaylist lod_cache[6]; 25 | /// True until the first sphere is rendered, then false. 26 | static void init_model(view& scene); 27 | 28 | public: 29 | /** Construct a unit sphere at the origin. */ 30 | sphere(); 31 | sphere( const sphere& other); 32 | virtual ~sphere(); 33 | 34 | protected: 35 | /** Renders a simple sphere with the #2 level of detail. */ 36 | virtual void gl_pick_render( view&); 37 | /** Renders the sphere. All of the spheres share the same basic set of 38 | * models, and then use matrix transforms to shape and position them. 39 | */ 40 | virtual void gl_render( view&); 41 | /** Extent reported using extent::add_sphere(). */ 42 | virtual void grow_extent( extent&); 43 | 44 | /** Exposed for the benefit of the ellipsoid object, which overrides it. 45 | * The default is to use for the scale. 46 | */ 47 | virtual vector get_scale(); 48 | /** Returns true if this object should not be drawn. Conditions are: 49 | * zero radius, or visible is false. (overridden by the ellipsoid class). 50 | */ 51 | virtual bool degenerate(); 52 | 53 | virtual void get_material_matrix( const view&, tmatrix& out ); 54 | 55 | PRIMITIVE_TYPEINFO_DECL; 56 | }; 57 | 58 | } // !namespace cvisual 59 | 60 | #endif // !defined VPYTHON_SPHERE_HPP 61 | -------------------------------------------------------------------------------- /include/util/atomic_queue.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_UTIL_ATOMIC_QUEUE_HPP 2 | #define VPYTHON_UTIL_ATOMIC_QUEUE_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace cvisual { 9 | 10 | // This class exists to separate out code that is not templated (and therefore 11 | // doesn't need to be in a header file) from code that is. This prevents 12 | // picking up the whole Python runtine throughout all of cvisual, thus making 13 | // compilation faster. 14 | class atomic_queue_impl 15 | { 16 | protected: 17 | volatile bool empty; 18 | 19 | atomic_queue_impl() : empty(true) 20 | {} 21 | 22 | void push_notify(); 23 | }; 24 | 25 | using boost::python::import; 26 | using boost::python::object; 27 | 28 | template 29 | class atomic_queue : private atomic_queue_impl 30 | { 31 | private: 32 | std::queue data; 33 | 34 | /** 35 | * Precondition - at least one item is in data 36 | */ 37 | T pop_impl() 38 | { 39 | T ret = data.front(); // get the oldest element 40 | data.pop(); // remove the oldest element 41 | if (data.empty()) 42 | empty = true; 43 | return ret; 44 | } 45 | 46 | public: 47 | atomic_queue() {} 48 | 49 | void push( const T& item) 50 | { 51 | data.push( item); 52 | } 53 | 54 | T peek() // assumes that data is not empty 55 | { 56 | return data.front(); 57 | } 58 | 59 | T pop() 60 | { 61 | return pop_impl(); 62 | } 63 | 64 | size_t size() const 65 | { 66 | return data.size(); 67 | } 68 | 69 | void clear() 70 | { 71 | while (!data.empty()) 72 | data.pop(); 73 | empty = true; 74 | } 75 | }; 76 | 77 | } // !namespace cvisual 78 | 79 | #endif // !defined VPYTHON_UTIL_ATOMIC_QUEUE_HPP 80 | -------------------------------------------------------------------------------- /include/util/displaylist.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_UTIL_DISPLAYLIST_HPP 2 | #define VPYTHON_UTIL_DISPLAYLIST_HPP 3 | 4 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 5 | // See the file license.txt for complete license terms. 6 | // See the file authors.txt for a complete list of contributors. 7 | 8 | #include 9 | 10 | namespace cvisual { 11 | 12 | using boost::shared_ptr; 13 | 14 | /** A manager for OpenGL displaylists */ 15 | class displaylist 16 | { 17 | private: 18 | shared_ptr impl; 19 | bool built; 20 | 21 | public: 22 | displaylist(); 23 | 24 | /** Begin compiling a new displaylist. Nothing is drawn to the screen 25 | when rendering commands into the displaylist. Be sure to call 26 | gl_compile_end() when you are done. 27 | */ 28 | void gl_compile_begin(); 29 | 30 | /** Completes compiling the displaylist. */ 31 | void gl_compile_end(); 32 | 33 | /** Perform the OpenGL commands cached with gl_compile_begin() and 34 | gl_compile_end(). */ 35 | void gl_render() const; 36 | 37 | /** @return true iff this object contains a compiled OpenGL program. */ 38 | //operator bool() const; 39 | bool compiled(); 40 | }; 41 | 42 | } // !namespace cvisual 43 | 44 | #endif // !defined VPYTHON_UTIL_DISPLAYLIST_HPP 45 | -------------------------------------------------------------------------------- /include/util/gl_enable.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_UTIL_GL_ENABLE_HPP 2 | #define VPYTHON_UTIL_GL_ENABLE_HPP 3 | 4 | #include "wrap_gl.hpp" 5 | 6 | namespace cvisual { 7 | 8 | // Stack-unwind safe versions of gl{Enable,Disable}{ClientState,}() 9 | class gl_enable 10 | { 11 | private: 12 | GLenum value; 13 | public: 14 | inline gl_enable( GLenum v) : value(v) 15 | { glEnable( value); } 16 | 17 | inline ~gl_enable() 18 | { glDisable( value); } 19 | }; 20 | 21 | class gl_enable_client 22 | { 23 | private: 24 | GLenum value; 25 | public: 26 | inline gl_enable_client( GLenum v) : value(v) 27 | { glEnableClientState( value); } 28 | 29 | inline ~gl_enable_client() 30 | { glDisableClientState( value); } 31 | }; 32 | 33 | class gl_disable 34 | { 35 | private: 36 | GLenum value; 37 | public: 38 | inline gl_disable( GLenum v) : value(v) 39 | { glDisable( value); } 40 | 41 | inline ~gl_disable() 42 | { glEnable( value); } 43 | }; 44 | 45 | } // !namespace cvisual 46 | 47 | #endif /*VPYTHON_UTIL_GL_ENABLE_HPP*/ 48 | -------------------------------------------------------------------------------- /include/util/gl_extensions.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_UTIL_GL_EXTENSIONS_HPP 2 | #define VPYTHON_UTIL_GL_EXTENSIONS_HPP 3 | #pragma once 4 | 5 | #include "wrap_gl.hpp" 6 | 7 | namespace cvisual { 8 | 9 | // GL extension functions wrapper - just the functions we currently need 10 | // This could be replaced by a library like GLEW, if it becomes a hassle to maintain. 11 | 12 | class gl_extensions { 13 | public: 14 | // All extensions will be unavailable until init() is called. 15 | gl_extensions(); 16 | 17 | // Must be initialized and used with the same OpenGL context current 18 | void init( class display_kernel& d ); 19 | 20 | // Extension: ARB_shader_objects 21 | bool ARB_shader_objects; 22 | PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB; 23 | PFNGLLINKPROGRAMARBPROC glLinkProgramARB; 24 | PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB; 25 | PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB; 26 | PFNGLSHADERSOURCEARBPROC glShaderSourceARB; 27 | PFNGLCOMPILESHADERARBPROC glCompileShaderARB; 28 | PFNGLATTACHOBJECTARBPROC glAttachObjectARB; 29 | PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; 30 | PFNGLGETHANDLEARBPROC glGetHandleARB; 31 | PFNGLUNIFORM1IARBPROC glUniform1iARB; 32 | PFNGLUNIFORMMATRIX4FVARBPROC glUniformMatrix4fvARB; 33 | PFNGLUNIFORM4FVARBPROC glUniform4fvARB; 34 | PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB; 35 | PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB; 36 | PFNGLGETINFOLOGARBPROC glGetInfoLogARB; 37 | 38 | // Extension: EXT_texture3D 39 | bool EXT_texture3D; 40 | PFNGLTEXIMAGE3DEXTPROC glTexImage3D; 41 | PFNGLTEXSUBIMAGE3DEXTPROC glTexSubImage3D; 42 | 43 | // Extension: ARB_multitexture 44 | bool ARB_multitexture; 45 | PFNGLACTIVETEXTUREARBPROC glActiveTexture; 46 | 47 | // Extension: ARB_point_parameters 48 | bool ARB_point_parameters; 49 | PFNGLPOINTPARAMETERFVARBPROC glPointParameterfvARB; 50 | }; 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/util/gl_free.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_UTIL_GL_FREE_HPP 2 | #define VPYTHON_UTIL_GL_FREE_HPP 3 | 4 | #include 5 | 6 | namespace cvisual { 7 | 8 | class gl_free_manager { 9 | public: 10 | // The callback will be called if the OpenGL context(s) are destroyed 11 | template 12 | void connect( T callback ) { on_shutdown().connect( callback ); } 13 | 14 | // The callback will be called the next time OpenGL objects may be freed, and 15 | // will no longer be called on shutdown(). 16 | template 17 | void free( T callback ) { on_next_frame().connect( callback ); on_shutdown().disconnect( callback ); } 18 | 19 | // Call with OpenGL context active 20 | void frame(); 21 | 22 | // Call when the context(s) are destroyed. The gl_free_manager can be reused. 23 | void shutdown(); 24 | 25 | private: 26 | boost::signal< void() > &on_shutdown(); 27 | boost::signal< void() > &on_next_frame(); 28 | }; 29 | 30 | // At present, there is just one of these, because all OpenGL contexts share server 31 | // objects through wglShareLists or equivalent. It is shutdown when all contexts are 32 | // shut down. If this design is changed in the 33 | // future, there will need to be an instance for each context. 34 | extern gl_free_manager on_gl_free; 35 | 36 | } // !namespace cvisual 37 | 38 | #endif // !defined VPYTHON_UTIL_GL_FREE_HPP 39 | -------------------------------------------------------------------------------- /include/util/icososphere.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_UTIL_ICOSOSPHERE_HPP 2 | #define VPYTHON_UTIL_ICOSOSPHERE_HPP 3 | 4 | #include 5 | 6 | namespace cvisual { 7 | 8 | class icososphere 9 | { 10 | boost::shared_array verts; 11 | boost::shared_array indices; 12 | int nverts; 13 | int ni; 14 | 15 | inline float* 16 | newe( int span) 17 | { 18 | float* e = verts.get() + 3*(nverts - 1); // one before the beginning 19 | nverts += span-1; 20 | return e; 21 | } 22 | 23 | void subdivide( int span, float* v1, float* v2, float *v3, 24 | float* s1, float* s2, float* s3, 25 | float* e1, float* e2, float* e3 ); 26 | public: 27 | icososphere( int depth); 28 | void gl_render(); 29 | }; 30 | 31 | } // !namespace cvisual 32 | #endif // !defined VPYTHON_UTIL_ICOSOSPHERE_HPP 33 | -------------------------------------------------------------------------------- /include/util/rate.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_UTIL_RATE_HPP 2 | #define VPYTHON_UTIL_RATE_HPP 3 | 4 | #include 5 | #include 6 | #include "util/rgba.hpp" 7 | 8 | namespace cvisual { 9 | 10 | using namespace boost::python; 11 | 12 | typedef void (wait_t)(double); 13 | 14 | void set_wait(object obj); 15 | 16 | /* 17 | typedef void (text_to_bitmap_t)(std::wstring& text, 18 | rgb& foreground, rgb& background, 19 | double height, std::wstring& font, 20 | std::wstring& style, std::wstring& weight); 21 | 22 | void set_text_to_bitmap(object obj); 23 | */ 24 | 25 | } // !namespace cvisual 26 | 27 | #endif // !defined VPYTHON_UTIL_RATE_HPP 28 | -------------------------------------------------------------------------------- /include/util/shader_program.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_UTIL_SHADER_PROGRAM_HPP 2 | #define VPYTHON_UTIL_SHADER_PROGRAM_HPP 3 | #pragma once 4 | 5 | #include "display_kernel.hpp" 6 | 7 | #ifdef __APPLE__ 8 | // The following are needed in order to be able to query the rendering properties 9 | #include 10 | #include 11 | #include 12 | #endif 13 | 14 | namespace cvisual { 15 | 16 | class shader_program { 17 | public: 18 | shader_program( const std::string& source ); 19 | ~shader_program(); 20 | 21 | const std::string& get_source() const { return source; } 22 | int get_uniform_location( const view& v, const char* name ); 23 | void set_uniform_matrix( const view& v, int loc, const tmatrix& in ); 24 | 25 | private: 26 | friend class use_shader_program; 27 | void realize( const view& ); 28 | 29 | void compile( const view&, int type, const std::string& source ); 30 | std::string getSection( const std::string& name ); 31 | 32 | static void gl_free( PFNGLDELETEOBJECTARBPROC, int ); 33 | 34 | std::string source; 35 | std::map uniforms; 36 | GLhandleARB program; 37 | PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; 38 | }; 39 | 40 | class use_shader_program { 41 | public: 42 | // use_shader_program(NULL) does nothing, rather than enabling the fixed function 43 | // pipeline explicitly. This is convenient, but maybe we need a way to do the other thing? 44 | use_shader_program( const view& v, shader_program* program ); 45 | use_shader_program( const view& v, shader_program& program ); 46 | ~use_shader_program(); 47 | 48 | bool ok() { return m_ok; } // true if the shader program was successfully invoked 49 | 50 | private: 51 | const view& v; 52 | GLhandleARB oldProgram; 53 | bool m_ok; 54 | void init( shader_program* program ); 55 | }; 56 | 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /include/util/timer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_UTIL_TIMER_HPP 2 | #define VPYTHON_UTIL_TIMER_HPP 3 | 4 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 5 | // See the file license.txt for complete license terms. 6 | // See the file authors.txt for a complete list of contributors. 7 | 8 | namespace cvisual { 9 | 10 | class timer 11 | { 12 | private: 13 | double start; ///< The system time at the last lap_start() call. 14 | double inv_tick_count; 15 | 16 | public: 17 | /** Construct a new timer. */ 18 | timer(); 19 | 20 | /** Time elapsed since timer was created. */ 21 | double elapsed(); 22 | }; 23 | 24 | } // !namespace cvisual 25 | 26 | #endif // !defined VPYTHON_UTIL_TIMER_HPP 27 | -------------------------------------------------------------------------------- /include/vpython-config.h: -------------------------------------------------------------------------------- 1 | #ifndef VPYTHON_CONFIG_H 2 | #define VPYTHON_CONFIG_H 3 | 4 | #include 5 | 6 | #ifndef M_PI 7 | # define M_PI 3.14159265359 8 | #endif 9 | 10 | #if defined _MSC_VER 11 | # pragma warning(disable: 4996) 12 | # pragma warning(disable: 4005) 13 | # pragma warning(disable: 4715) 14 | # pragma warning(disable: 4244) 15 | #define isnan _isnan 16 | #endif 17 | 18 | #define BOOST_DATE_TIME_NO_LIB 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/wrap_gl.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef VPYTHON_WRAP_GL_HPP 3 | #define VPYTHON_WRAP_GL_HPP 4 | 5 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 6 | // See the file license.txt for complete license terms. 7 | // See the file authors.txt for a complete list of contributors. 8 | 9 | //A header file to wrap around GL/gl.h on *nix and Windows. 10 | 11 | #if defined(_WIN32) 12 | #define WIN32_LEAN_AND_MEAN 1 13 | #define NOMINMAX 14 | #include 15 | #endif 16 | 17 | #if defined(__APPLE__) 18 | #define GL_GLEXT_LEGACY 19 | #include 20 | #include 21 | #include "GL/glext.h" 22 | #else 23 | #include 24 | #include 25 | #include 26 | #endif 27 | 28 | #endif // !defined VPYTHON_WRAP_GL_HPP 29 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | fonttools==2.4 2 | numpy 3 | # Polygon2-2.0.6/ needs to be an explicit download 4 | # ./Polygon2-2.0.6 5 | -e ./Polygon2-2.0.6 6 | -e . 7 | TTFQuery==1.0.5 8 | -------------------------------------------------------------------------------- /requirements_test.txt: -------------------------------------------------------------------------------- 1 | -r requirements.txt 2 | 3 | mock==1.0.1 4 | tox==1.5.0 5 | -------------------------------------------------------------------------------- /setup.cfg.example: -------------------------------------------------------------------------------- 1 | [build_ext] 2 | # 3 | # specify the boost lib/include files here if they are not found automatically 4 | # 5 | 6 | include-dirs=dependencies/boost_files 7 | library-dirs=dependencies/boost_files/mac_libs 8 | -------------------------------------------------------------------------------- /site-packages/vidle2/CREDITS.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/vidle2/CREDITS.txt -------------------------------------------------------------------------------- /site-packages/vidle2/Delegator.py: -------------------------------------------------------------------------------- 1 | class Delegator: 2 | 3 | # The cache is only used to be able to change delegates! 4 | 5 | def __init__(self, delegate=None): 6 | self.delegate = delegate 7 | self.__cache = {} 8 | 9 | def __getattr__(self, name): 10 | attr = getattr(self.delegate, name) # May raise AttributeError 11 | setattr(self, name, attr) 12 | self.__cache[name] = attr 13 | return attr 14 | 15 | def resetcache(self): 16 | for key in self.__cache.keys(): 17 | try: 18 | delattr(self, key) 19 | except AttributeError: 20 | pass 21 | self.__cache.clear() 22 | 23 | def cachereport(self): 24 | keys = self.__cache.keys() 25 | keys.sort() 26 | print keys 27 | 28 | def setdelegate(self, delegate): 29 | self.resetcache() 30 | self.delegate = delegate 31 | 32 | def getdelegate(self): 33 | return self.delegate 34 | -------------------------------------------------------------------------------- /site-packages/vidle2/FileRevert.py: -------------------------------------------------------------------------------- 1 | """ 2 | FileRevert is an extension that re-reads the currently open file and 3 | displays the possibly updated content. 4 | """ 5 | from Tkinter import * 6 | import tkMessageBox 7 | 8 | class FileRevert: 9 | 10 | menudefs = [('file', [('Revert', '<>')])] 11 | 12 | def __init__(self, editwin): 13 | self.text = editwin.text 14 | self.io = editwin.io 15 | 16 | def revert_file_event(self, event): 17 | fname = self.io.filename 18 | if fname is None: 19 | # No file associated. 20 | return 21 | 22 | if not self.io.get_saved(): 23 | msg = "Do you want to save a copy of %s before reverting?" % fname 24 | res = tkMessageBox.askyesnocancel( 25 | master=self.text, 26 | title="Save a copy", 27 | message=msg) 28 | if res is None: 29 | # Canceled. 30 | return 31 | elif res: 32 | self.io.save_a_copy(event) 33 | # XXX Maybe it would be better to not revert the file when 34 | # user cancels the dialog that saves a copy of the current 35 | # file. 36 | 37 | self.io.loadfile(fname) 38 | -------------------------------------------------------------------------------- /site-packages/vidle2/Icons/idle.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/vidle2/Icons/idle.icns -------------------------------------------------------------------------------- /site-packages/vidle2/MacBuildApp.py: -------------------------------------------------------------------------------- 1 | from bundlebuilder import AppBuilder, main 2 | 3 | a = AppBuilder( 4 | name='VIDLE.app', 5 | mainprogram='idle.py', 6 | argv_emulation=0, 7 | #iconfile= 8 | standalone=0, 9 | ) 10 | 11 | a.plist['CFBundleDocumentTypes'] = [ 12 | { "CFBundleTypeOSTypes" : [ 13 | "****" ], 14 | "CFBundleTypeRole" : "Viewer" }] 15 | 16 | main(a) 17 | -------------------------------------------------------------------------------- /site-packages/vidle2/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | # Makefile to distribute VIDLE 3 | 4 | AUTOMAKE_OPTIONS = foreign 5 | srcdir = @srcdir@ 6 | VPATH = @srcdir@ 7 | 8 | if BUILD_VIDLE 9 | vidlefiles = __init__.py \ 10 | aboutDialog.py AutoComplete.py AutoCompleteWindow.py AutoExpand.py Bindings.py \ 11 | CallTips.py CallTipWindow.py ChangeLog ClassBrowser.py CodeContext.py \ 12 | ColorDelegator.py configDialog.py \ 13 | config-extensions.def configHandler.py configHelpSourceEdit.py \ 14 | config-highlight.def config-keys.def config-main.def \ 15 | configSectionNameDialog.py CREDITS.txt \ 16 | Debugger.py Delegator.py dynOptionMenuWidget.py \ 17 | EditorWindow.py extend.txt FileList.py \ 18 | FileRevert.py FormatParagraph.py GrepDialog.py \ 19 | help.txt HISTORY.txt HyperParser.py Icons idle.bat \ 20 | idle.py idle.pyw IdleHistory.py idlever.py IOBinding.py \ 21 | keybindingDialog.py macosxSupport.py \ 22 | MultiCall.py MultiStatusBar.py NEWS.txt ObjectBrowser.py OutputWindow.py \ 23 | ParenMatch.py PathBrowser.py Percolator.py pyclbr.py PyParse.py PyShell.py \ 24 | README.txt RemoteDebugger.py RemoteObjectBrowser.py ReplaceDialog.py rpc.py \ 25 | RstripExtension.py run.py ScriptBinding.py ScrolledList.py SearchDialog.py SearchDialogBase.py \ 26 | SearchEngine.py StackViewer.py tabbedpages.py testcode.py textView.py \ 27 | TODO.txt ToolTip.py TreeWidget.py UndoDelegator.py utils.py WidgetRedirector.py \ 28 | WindowList.py ZoomHeight.py \ 29 | Icons/folder.gif Icons/idle.icns Icons/minusnode.gif Icons/openfolder.gif \ 30 | Icons/plusnode.gif Icons/python.gif Icons/tk.gif 31 | else 32 | vidlefiles = 33 | endif 34 | 35 | pkgdatadir = @visualvidledir@ 36 | 37 | dist_pkgdata_DATA = $(vidlefiles) 38 | 39 | -------------------------------------------------------------------------------- /site-packages/vidle2/MultiStatusBar.py: -------------------------------------------------------------------------------- 1 | from Tkinter import * 2 | 3 | class MultiStatusBar(Frame): 4 | 5 | def __init__(self, master=None, **kw): 6 | if master is None: 7 | master = Tk() 8 | Frame.__init__(self, master, **kw) 9 | self.labels = {} 10 | 11 | def set_label(self, name, text='', side=LEFT): 12 | if not self.labels.has_key(name): 13 | label = Label(self, bd=1, relief=SUNKEN, anchor=W) 14 | label.pack(side=side) 15 | self.labels[name] = label 16 | else: 17 | label = self.labels[name] 18 | label.config(text=text) 19 | 20 | def _test(): 21 | b = Frame() 22 | c = Text(b) 23 | c.pack(side=TOP) 24 | a = MultiStatusBar(b) 25 | a.set_label("one", "hello") 26 | a.set_label("two", "world") 27 | a.pack(side=BOTTOM, fill=X) 28 | b.pack() 29 | b.mainloop() 30 | 31 | if __name__ == '__main__': 32 | _test() 33 | -------------------------------------------------------------------------------- /site-packages/vidle2/RemoteObjectBrowser.py: -------------------------------------------------------------------------------- 1 | import rpc 2 | 3 | def remote_object_tree_item(item): 4 | wrapper = WrappedObjectTreeItem(item) 5 | oid = id(wrapper) 6 | rpc.objecttable[oid] = wrapper 7 | return oid 8 | 9 | class WrappedObjectTreeItem: 10 | # Lives in PYTHON subprocess 11 | 12 | def __init__(self, item): 13 | self.__item = item 14 | 15 | def __getattr__(self, name): 16 | value = getattr(self.__item, name) 17 | return value 18 | 19 | def _GetSubList(self): 20 | list = self.__item._GetSubList() 21 | return map(remote_object_tree_item, list) 22 | 23 | class StubObjectTreeItem: 24 | # Lives in IDLE process 25 | 26 | def __init__(self, sockio, oid): 27 | self.sockio = sockio 28 | self.oid = oid 29 | 30 | def __getattr__(self, name): 31 | value = rpc.MethodProxy(self.sockio, self.oid, name) 32 | return value 33 | 34 | def _GetSubList(self): 35 | list = self.sockio.remotecall(self.oid, "_GetSubList", (), {}) 36 | return [StubObjectTreeItem(self.sockio, oid) for oid in list] 37 | -------------------------------------------------------------------------------- /site-packages/vidle2/RstripExtension.py: -------------------------------------------------------------------------------- 1 | 'Provides "Strip trailing whitespace" under the "Format" menu.' 2 | 3 | __author__ = "Roger D. Serwy " 4 | 5 | class RstripExtension: 6 | 7 | menudefs = [ 8 | ('format', [None, 9 | ('Strip trailing whitespace', '<>'), 10 | ]),] 11 | 12 | def __init__(self, editwin): 13 | self.editwin = editwin 14 | self.editwin.text.bind("<>", self.do_rstrip) 15 | 16 | def do_rstrip(self, event=None): 17 | 18 | text = self.editwin.text 19 | undo = self.editwin.undo 20 | 21 | undo.undo_block_start() 22 | 23 | end_line = int(float(text.index('end'))) + 1 24 | for cur in range(1, end_line): 25 | txt = text.get('%i.0' % cur, '%i.0 lineend' % cur) 26 | cut = len(txt.rstrip()) 27 | text.delete('%i.%i' % (cur, cut), '%i.0 lineend' % cur) 28 | 29 | undo.undo_block_stop() 30 | -------------------------------------------------------------------------------- /site-packages/vidle2/SearchDialog.py: -------------------------------------------------------------------------------- 1 | from Tkinter import * 2 | import SearchEngine 3 | from SearchDialogBase import SearchDialogBase 4 | 5 | 6 | def _setup(text): 7 | root = text._root() 8 | engine = SearchEngine.get(root) 9 | if not hasattr(engine, "_searchdialog"): 10 | engine._searchdialog = SearchDialog(root, engine) 11 | return engine._searchdialog 12 | 13 | def find(text): 14 | pat = text.get("sel.first", "sel.last") 15 | return _setup(text).open(text,pat) 16 | 17 | def find_again(text): 18 | return _setup(text).find_again(text) 19 | 20 | def find_selection(text): 21 | return _setup(text).find_selection(text) 22 | 23 | class SearchDialog(SearchDialogBase): 24 | 25 | def create_widgets(self): 26 | f = SearchDialogBase.create_widgets(self) 27 | self.make_button("Find", self.default_command, 1) 28 | 29 | def default_command(self, event=None): 30 | if not self.engine.getprog(): 31 | return 32 | if self.find_again(self.text): 33 | self.close() 34 | 35 | def find_again(self, text): 36 | if not self.engine.getpat(): 37 | self.open(text) 38 | return False 39 | if not self.engine.getprog(): 40 | return False 41 | res = self.engine.search_text(text) 42 | if res: 43 | line, m = res 44 | i, j = m.span() 45 | first = "%d.%d" % (line, i) 46 | last = "%d.%d" % (line, j) 47 | try: 48 | selfirst = text.index("sel.first") 49 | sellast = text.index("sel.last") 50 | if selfirst == first and sellast == last: 51 | text.bell() 52 | return False 53 | except TclError: 54 | pass 55 | text.tag_remove("sel", "1.0", "end") 56 | text.tag_add("sel", first, last) 57 | text.mark_set("insert", self.engine.isback() and first or last) 58 | text.see("insert") 59 | return True 60 | else: 61 | text.bell() 62 | return False 63 | 64 | def find_selection(self, text): 65 | pat = text.get("sel.first", "sel.last") 66 | if pat: 67 | self.engine.setcookedpat(pat) 68 | return self.find_again(text) 69 | -------------------------------------------------------------------------------- /site-packages/vidle2/ZoomHeight.py: -------------------------------------------------------------------------------- 1 | # Sample extension: zoom a window to maximum height 2 | 3 | import re 4 | import sys 5 | import macosxSupport 6 | 7 | class ZoomHeight: 8 | 9 | menudefs = [ 10 | ('windows', [ 11 | ('_Zoom Height', '<>'), 12 | ]) 13 | ] 14 | 15 | def __init__(self, editwin): 16 | self.editwin = editwin 17 | 18 | def zoom_height_event(self, event): 19 | top = self.editwin.top 20 | zoom_height(top) 21 | 22 | def zoom_height(top): 23 | geom = top.wm_geometry() 24 | m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom) 25 | if not m: 26 | top.bell() 27 | return 28 | width, height, x, y = map(int, m.groups()) 29 | newheight = top.winfo_screenheight() 30 | if sys.platform == 'win32': 31 | newy = 0 32 | newheight = newheight - 72 33 | 34 | elif macosxSupport.runningAsOSXApp(): 35 | # The '88' below is a magic number that avoids placing the bottom 36 | # of the window below the panel on my machine. I don't know how 37 | # to calculate the correct value for this with tkinter. 38 | newy = 22 39 | newheight = newheight - newy - 88 40 | 41 | else: 42 | #newy = 24 43 | newy = 0 44 | #newheight = newheight - 96 45 | newheight = newheight - 88 46 | if height >= newheight: 47 | newgeom = "" 48 | else: 49 | newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy) 50 | top.wm_geometry(newgeom) 51 | -------------------------------------------------------------------------------- /site-packages/vidle2/__init__.py: -------------------------------------------------------------------------------- 1 | # Dummy file to make this a package. 2 | -------------------------------------------------------------------------------- /site-packages/vidle2/config-highlight.def: -------------------------------------------------------------------------------- 1 | # IDLE reads several config files to determine user preferences. This 2 | # file is the default config file for idle highlight theme settings. 3 | 4 | [IDLE Classic] 5 | normal-foreground= #000000 6 | normal-background= #ffffff 7 | keyword-foreground= #ff7700 8 | keyword-background= #ffffff 9 | builtin-foreground= #900090 10 | builtin-background= #ffffff 11 | comment-foreground= #dd0000 12 | comment-background= #ffffff 13 | string-foreground= #00aa00 14 | string-background= #ffffff 15 | definition-foreground= #0000ff 16 | definition-background= #ffffff 17 | hilite-foreground= #000000 18 | hilite-background= gray 19 | break-foreground= black 20 | break-background= #ffff55 21 | hit-foreground= #ffffff 22 | hit-background= #000000 23 | error-foreground= #000000 24 | error-background= #ff7777 25 | #cursor (only foreground can be set, restart IDLE) 26 | cursor-foreground= black 27 | #shell window 28 | stdout-foreground= blue 29 | stdout-background= #ffffff 30 | stderr-foreground= red 31 | stderr-background= #ffffff 32 | console-foreground= #770000 33 | console-background= #ffffff 34 | 35 | [IDLE New] 36 | normal-foreground= #000000 37 | normal-background= #ffffff 38 | keyword-foreground= #ff7700 39 | keyword-background= #ffffff 40 | builtin-foreground= #900090 41 | builtin-background= #ffffff 42 | comment-foreground= #dd0000 43 | comment-background= #ffffff 44 | string-foreground= #00aa00 45 | string-background= #ffffff 46 | definition-foreground= #0000ff 47 | definition-background= #ffffff 48 | hilite-foreground= #000000 49 | hilite-background= gray 50 | break-foreground= black 51 | break-background= #ffff55 52 | hit-foreground= #ffffff 53 | hit-background= #000000 54 | error-foreground= #000000 55 | error-background= #ff7777 56 | #cursor (only foreground can be set, restart IDLE) 57 | cursor-foreground= black 58 | #shell window 59 | stdout-foreground= blue 60 | stdout-background= #ffffff 61 | stderr-foreground= red 62 | stderr-background= #ffffff 63 | console-foreground= #770000 64 | console-background= #ffffff 65 | -------------------------------------------------------------------------------- /site-packages/vidle2/dynOptionMenuWidget.py: -------------------------------------------------------------------------------- 1 | """ 2 | OptionMenu widget modified to allow dynamic menu reconfiguration 3 | and setting of highlightthickness 4 | """ 5 | from Tkinter import OptionMenu 6 | from Tkinter import _setit 7 | import copy 8 | 9 | class DynOptionMenu(OptionMenu): 10 | """ 11 | unlike OptionMenu, our kwargs can include highlightthickness 12 | """ 13 | def __init__(self, master, variable, value, *values, **kwargs): 14 | #get a copy of kwargs before OptionMenu.__init__ munges them 15 | kwargsCopy=copy.copy(kwargs) 16 | if 'highlightthickness' in kwargs.keys(): 17 | del(kwargs['highlightthickness']) 18 | OptionMenu.__init__(self, master, variable, value, *values, **kwargs) 19 | self.config(highlightthickness=kwargsCopy.get('highlightthickness')) 20 | #self.menu=self['menu'] 21 | self.variable=variable 22 | self.command=kwargs.get('command') 23 | 24 | def SetMenu(self,valueList,value=None): 25 | """ 26 | clear and reload the menu with a new set of options. 27 | valueList - list of new options 28 | value - initial value to set the optionmenu's menubutton to 29 | """ 30 | self['menu'].delete(0,'end') 31 | for item in valueList: 32 | self['menu'].add_command(label=item, 33 | command=_setit(self.variable,item,self.command)) 34 | if value: 35 | self.variable.set(value) 36 | -------------------------------------------------------------------------------- /site-packages/vidle2/idle.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Working IDLE bat for Windows - uses start instead of absolute pathname 3 | start idle.pyw %1 %2 %3 %4 %5 %6 %7 %8 %9 4 | -------------------------------------------------------------------------------- /site-packages/vidle2/idle.py: -------------------------------------------------------------------------------- 1 | import os.path 2 | import os 3 | import sys 4 | from platform import platform 5 | 6 | 7 | # If we are working on a development version of IDLE, we need to prepend the 8 | # parent of this idlelib dir to sys.path. Otherwise, importing idlelib gets 9 | # the version installed with the Python used to call this module: 10 | idlelib_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 11 | sys.path.insert(0, idlelib_dir) 12 | 13 | if platform().lower().split('-')[0] in ('darwin','linux'): 14 | from visual_common import __file__ as fname 15 | docPath = os.path.join(os.path.split(os.path.split(fname)[0])[0],'visual','examples') 16 | os.chdir(docPath) 17 | 18 | import vidle.PyShell 19 | vidle.PyShell.main() 20 | -------------------------------------------------------------------------------- /site-packages/vidle2/idle.pyw: -------------------------------------------------------------------------------- 1 | try: 2 | import vidle.PyShell 3 | except ImportError: 4 | # IDLE is not installed, but maybe PyShell is on sys.path: 5 | try: 6 | import PyShell 7 | except ImportError: 8 | raise 9 | else: 10 | import os 11 | idledir = os.path.dirname(os.path.abspath(PyShell.__file__)) 12 | if idledir != os.getcwd(): 13 | # We're not in the IDLE directory, help the subprocess find run.py 14 | pypath = os.environ.get('PYTHONPATH', '') 15 | if pypath: 16 | os.environ['PYTHONPATH'] = pypath + ':' + idledir 17 | else: 18 | os.environ['PYTHONPATH'] = idledir 19 | PyShell.main() 20 | else: 21 | vidle.PyShell.main() 22 | -------------------------------------------------------------------------------- /site-packages/vidle2/idlever.py: -------------------------------------------------------------------------------- 1 | IDLE_VERSION = "2.7a0" 2 | -------------------------------------------------------------------------------- /site-packages/vidle2/testcode.py: -------------------------------------------------------------------------------- 1 | import string 2 | 3 | def f(): 4 | a = 0 5 | b = 1 6 | c = 2 7 | d = 3 8 | e = 4 9 | g() 10 | 11 | def g(): 12 | h() 13 | 14 | def h(): 15 | i() 16 | 17 | def i(): 18 | j() 19 | 20 | def j(): 21 | k() 22 | 23 | def k(): 24 | l() 25 | 26 | l = lambda: test() 27 | 28 | def test(): 29 | string.capwords(1) 30 | 31 | f() 32 | -------------------------------------------------------------------------------- /site-packages/vidle2/utils.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def tb_print_list(extracted_list, filename, normal=sys.stdout, 4 | highlight=sys.stderr): 5 | """An extended version of traceback.print_list which exclude 6 | "in " when printing traceback and highlight the entries 7 | that occur on the given filename.""" 8 | for fname, lineno, name, line in extracted_list: 9 | f = highlight if fname == filename else normal 10 | if name == '': 11 | f.write(' File "%s", line %d\n' % (fname, lineno)) 12 | else: 13 | f.write(' File "%s", line %d, in %s\n' % (fname, lineno, name)) 14 | if line: 15 | f.write(' %s\n' % line.strip()) 16 | -------------------------------------------------------------------------------- /site-packages/vidle3/CREDITS.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/vidle3/CREDITS.txt -------------------------------------------------------------------------------- /site-packages/vidle3/Delegator.py: -------------------------------------------------------------------------------- 1 | class Delegator: 2 | 3 | # The cache is only used to be able to change delegates! 4 | 5 | def __init__(self, delegate=None): 6 | self.delegate = delegate 7 | self.__cache = {} 8 | 9 | def __getattr__(self, name): 10 | attr = getattr(self.delegate, name) # May raise AttributeError 11 | setattr(self, name, attr) 12 | self.__cache[name] = attr 13 | return attr 14 | 15 | def resetcache(self): 16 | for key in self.__cache: 17 | try: 18 | delattr(self, key) 19 | except AttributeError: 20 | pass 21 | self.__cache.clear() 22 | 23 | def cachereport(self): 24 | keys = list(self.__cache.keys()) 25 | keys.sort() 26 | print(keys) 27 | 28 | def setdelegate(self, delegate): 29 | self.resetcache() 30 | self.delegate = delegate 31 | 32 | def getdelegate(self): 33 | return self.delegate 34 | -------------------------------------------------------------------------------- /site-packages/vidle3/FileRevert.py: -------------------------------------------------------------------------------- 1 | """ 2 | FileRevert is an extension that re-reads the currently open file and 3 | displays the possibly updated content. 4 | """ 5 | from tkinter import * 6 | import tkinter.messagebox as tkMessageBox 7 | 8 | class FileRevert: 9 | 10 | menudefs = [('file', [('Revert', '<>')])] 11 | 12 | def __init__(self, editwin): 13 | self.text = editwin.text 14 | self.io = editwin.io 15 | 16 | def revert_file_event(self, event): 17 | fname = self.io.filename 18 | if fname is None: 19 | # No file associated. 20 | return 21 | 22 | if not self.io.get_saved(): 23 | msg = "Do you want to save a copy of %s before reverting?" % fname 24 | res = tkMessageBox.askyesnocancel( 25 | master=self.text, 26 | title="Save a copy", 27 | message=msg) 28 | if res is None: 29 | # Canceled. 30 | return 31 | elif res: 32 | self.io.save_a_copy(event) 33 | # XXX Maybe it would be better to not revert the file when 34 | # user cancels the dialog that saves a copy of the current 35 | # file. 36 | 37 | self.io.loadfile(fname) 38 | -------------------------------------------------------------------------------- /site-packages/vidle3/Icons/idle.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/vidle3/Icons/idle.icns -------------------------------------------------------------------------------- /site-packages/vidle3/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | # Makefile to distribute VIDLE 3 | 4 | AUTOMAKE_OPTIONS = foreign 5 | srcdir = @srcdir@ 6 | VPATH = @srcdir@ 7 | 8 | if BUILD_VIDLE 9 | vidlefiles = __init__.py \ 10 | aboutDialog.py AutoComplete.py AutoCompleteWindow.py AutoExpand.py Bindings.py \ 11 | CallTips.py CallTipWindow.py ChangeLog ClassBrowser.py CodeContext.py \ 12 | ColorDelegator.py configDialog.py \ 13 | config-extensions.def configHandler.py configHelpSourceEdit.py \ 14 | config-highlight.def config-keys.def config-main.def \ 15 | configSectionNameDialog.py CREDITS.txt \ 16 | Debugger.py Delegator.py dynOptionMenuWidget.py \ 17 | EditorWindow.py extend.txt FileList.py \ 18 | FileRevert.py FormatParagraph.py GrepDialog.py \ 19 | help.txt HISTORY.txt HyperParser.py Icons idle.bat \ 20 | idle.py idle.pyw IdleHistory.py idlever.py IOBinding.py \ 21 | keybindingDialog.py macosxSupport.py \ 22 | MultiCall.py MultiStatusBar.py NEWS.txt ObjectBrowser.py OutputWindow.py \ 23 | ParenMatch.py PathBrowser.py Percolator.py PyParse.py PyShell.py \ 24 | README.txt RemoteDebugger.py RemoteObjectBrowser.py ReplaceDialog.py rpc.py \ 25 | RstripExtension.py run.py ScriptBinding.py ScrolledList.py SearchDialog.py SearchDialogBase.py \ 26 | SearchEngine.py StackViewer.py tabbedpages.py testcode.py textView.py \ 27 | TODO.txt ToolTip.py TreeWidget.py UndoDelegator.py utils.py WidgetRedirector.py \ 28 | WindowList.py ZoomHeight.py \ 29 | Icons/folder.gif Icons/idle.icns Icons/minusnode.gif Icons/openfolder.gif \ 30 | Icons/plusnode.gif Icons/python.gif Icons/tk.gif 31 | else 32 | vidlefiles = 33 | endif 34 | 35 | pkgdatadir = @visualvidledir@ 36 | 37 | dist_pkgdata_DATA = $(vidlefiles) 38 | 39 | -------------------------------------------------------------------------------- /site-packages/vidle3/MultiStatusBar.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | class MultiStatusBar(Frame): 4 | 5 | def __init__(self, master=None, **kw): 6 | if master is None: 7 | master = Tk() 8 | Frame.__init__(self, master, **kw) 9 | self.labels = {} 10 | 11 | def set_label(self, name, text='', side=LEFT): 12 | if name not in self.labels: 13 | label = Label(self, bd=1, relief=SUNKEN, anchor=W) 14 | label.pack(side=side) 15 | self.labels[name] = label 16 | else: 17 | label = self.labels[name] 18 | label.config(text=text) 19 | 20 | def _test(): 21 | b = Frame() 22 | c = Text(b) 23 | c.pack(side=TOP) 24 | a = MultiStatusBar(b) 25 | a.set_label("one", "hello") 26 | a.set_label("two", "world") 27 | a.pack(side=BOTTOM, fill=X) 28 | b.pack() 29 | b.mainloop() 30 | 31 | if __name__ == '__main__': 32 | _test() 33 | -------------------------------------------------------------------------------- /site-packages/vidle3/README.txt: -------------------------------------------------------------------------------- 1 | IDLE is Python's Tkinter-based Integrated DeveLopment Environment. 2 | 3 | IDLE emphasizes a lightweight, clean design with a simple user interface. 4 | Although it is suitable for beginners, even advanced users will find that 5 | IDLE has everything they really need to develop pure Python code. 6 | 7 | IDLE features a multi-window text editor with multiple undo, Python colorizing, 8 | and many other capabilities, e.g. smart indent, call tips, and autocompletion. 9 | 10 | The editor has comprehensive search functions, including searching through 11 | multiple files. Class browsers and path browsers provide fast access to 12 | code objects from a top level viewpoint without dealing with code folding. 13 | 14 | There is a Python Shell window which features colorizing and command recall. 15 | 16 | IDLE executes Python code in a separate process, which is restarted for each 17 | Run (F5) initiated from an editor window. The environment can also be 18 | restarted from the Shell window without restarting IDLE. 19 | 20 | This enhancement has often been requested, and is now finally available. The 21 | magic "reload/import *" incantations are no longer required when editing and 22 | testing a module two or three steps down the import chain. 23 | 24 | (Personal firewall software may warn about the connection IDLE makes to its 25 | subprocess using this computer's internal loopback interface. This connection 26 | is not visible on any external interface and no data is sent to or received 27 | from the Internet.) 28 | 29 | It is possible to interrupt tightly looping user code, even on Windows. 30 | 31 | Applications which cannot support subprocesses and/or sockets can still run 32 | IDLE in a single process. 33 | 34 | IDLE has an integrated debugger with stepping, persistent breakpoints, and call 35 | stack visibility. 36 | 37 | There is a GUI configuration manager which makes it easy to select fonts, 38 | colors, keybindings, and startup options. This facility includes a feature 39 | which allows the user to specify additional help sources, either locally or on 40 | the web. 41 | 42 | IDLE is coded in 100% pure Python, using the Tkinter GUI toolkit (Tk/Tcl) 43 | and is cross-platform, working on Unix, Mac, and Windows. 44 | 45 | IDLE accepts command line arguments. Try idle -h to see the options. 46 | 47 | 48 | If you find bugs or have suggestions or patches, let us know about 49 | them by using the Python issue tracker: 50 | 51 | http://bugs.python.org 52 | 53 | For further details and links, read the Help files and check the IDLE home 54 | page at 55 | 56 | http://www.python.org/idle/ 57 | 58 | There is a mail list for IDLE: idle-dev@python.org. You can join at 59 | 60 | http://mail.python.org/mailman/listinfo/idle-dev 61 | -------------------------------------------------------------------------------- /site-packages/vidle3/RemoteObjectBrowser.py: -------------------------------------------------------------------------------- 1 | from . import rpc 2 | 3 | def remote_object_tree_item(item): 4 | wrapper = WrappedObjectTreeItem(item) 5 | oid = id(wrapper) 6 | rpc.objecttable[oid] = wrapper 7 | return oid 8 | 9 | class WrappedObjectTreeItem: 10 | # Lives in PYTHON subprocess 11 | 12 | def __init__(self, item): 13 | self.__item = item 14 | 15 | def __getattr__(self, name): 16 | value = getattr(self.__item, name) 17 | return value 18 | 19 | def _GetSubList(self): 20 | list = self.__item._GetSubList() 21 | return list(map(remote_object_tree_item, list)) 22 | 23 | class StubObjectTreeItem: 24 | # Lives in IDLE process 25 | 26 | def __init__(self, sockio, oid): 27 | self.sockio = sockio 28 | self.oid = oid 29 | 30 | def __getattr__(self, name): 31 | value = rpc.MethodProxy(self.sockio, self.oid, name) 32 | return value 33 | 34 | def _GetSubList(self): 35 | list = self.sockio.remotecall(self.oid, "_GetSubList", (), {}) 36 | return [StubObjectTreeItem(self.sockio, oid) for oid in list] 37 | -------------------------------------------------------------------------------- /site-packages/vidle3/RstripExtension.py: -------------------------------------------------------------------------------- 1 | 'Provides "Strip trailing whitespace" under the "Format" menu.' 2 | 3 | __author__ = "Roger D. Serwy " 4 | 5 | class RstripExtension: 6 | 7 | menudefs = [ 8 | ('format', [None, 9 | ('Strip trailing whitespace', '<>'), 10 | ]),] 11 | 12 | def __init__(self, editwin): 13 | self.editwin = editwin 14 | self.editwin.text.bind("<>", self.do_rstrip) 15 | 16 | def do_rstrip(self, event=None): 17 | 18 | text = self.editwin.text 19 | undo = self.editwin.undo 20 | 21 | undo.undo_block_start() 22 | 23 | end_line = int(float(text.index('end'))) + 1 24 | for cur in range(1, end_line): 25 | txt = text.get('%i.0' % cur, '%i.0 lineend' % cur) 26 | cut = len(txt.rstrip()) 27 | text.delete('%i.%i' % (cur, cut), '%i.0 lineend' % cur) 28 | 29 | undo.undo_block_stop() 30 | -------------------------------------------------------------------------------- /site-packages/vidle3/SearchDialog.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | 3 | from . import SearchEngine 4 | from .SearchDialogBase import SearchDialogBase 5 | 6 | def _setup(text): 7 | root = text._root() 8 | engine = SearchEngine.get(root) 9 | if not hasattr(engine, "_searchdialog"): 10 | engine._searchdialog = SearchDialog(root, engine) 11 | return engine._searchdialog 12 | 13 | def find(text): 14 | pat = text.get("sel.first", "sel.last") 15 | return _setup(text).open(text,pat) 16 | 17 | def find_again(text): 18 | return _setup(text).find_again(text) 19 | 20 | def find_selection(text): 21 | return _setup(text).find_selection(text) 22 | 23 | class SearchDialog(SearchDialogBase): 24 | 25 | def create_widgets(self): 26 | f = SearchDialogBase.create_widgets(self) 27 | self.make_button("Find", self.default_command, 1) 28 | 29 | def default_command(self, event=None): 30 | if not self.engine.getprog(): 31 | return 32 | if self.find_again(self.text): 33 | self.close() 34 | 35 | def find_again(self, text): 36 | if not self.engine.getpat(): 37 | self.open(text) 38 | return False 39 | if not self.engine.getprog(): 40 | return False 41 | res = self.engine.search_text(text) 42 | if res: 43 | line, m = res 44 | i, j = m.span() 45 | first = "%d.%d" % (line, i) 46 | last = "%d.%d" % (line, j) 47 | try: 48 | selfirst = text.index("sel.first") 49 | sellast = text.index("sel.last") 50 | if selfirst == first and sellast == last: 51 | text.bell() 52 | return False 53 | except TclError: 54 | pass 55 | text.tag_remove("sel", "1.0", "end") 56 | text.tag_add("sel", first, last) 57 | text.mark_set("insert", self.engine.isback() and first or last) 58 | text.see("insert") 59 | return True 60 | else: 61 | text.bell() 62 | return False 63 | 64 | def find_selection(self, text): 65 | pat = text.get("sel.first", "sel.last") 66 | if pat: 67 | self.engine.setcookedpat(pat) 68 | return self.find_again(text) 69 | -------------------------------------------------------------------------------- /site-packages/vidle3/ZoomHeight.py: -------------------------------------------------------------------------------- 1 | # Sample extension: zoom a window to maximum height 2 | 3 | import re 4 | import sys 5 | 6 | from . import macosxSupport 7 | 8 | class ZoomHeight: 9 | 10 | menudefs = [ 11 | ('windows', [ 12 | ('_Zoom Height', '<>'), 13 | ]) 14 | ] 15 | 16 | def __init__(self, editwin): 17 | self.editwin = editwin 18 | 19 | def zoom_height_event(self, event): 20 | top = self.editwin.top 21 | zoom_height(top) 22 | 23 | def zoom_height(top): 24 | geom = top.wm_geometry() 25 | m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom) 26 | if not m: 27 | top.bell() 28 | return 29 | width, height, x, y = map(int, m.groups()) 30 | newheight = top.winfo_screenheight() 31 | if sys.platform == 'win32': 32 | newy = 0 33 | newheight = newheight - 72 34 | 35 | elif macosxSupport.runningAsOSXApp(): 36 | # The '88' below is a magic number that avoids placing the bottom 37 | # of the window below the panel on my machine. I don't know how 38 | # to calculate the correct value for this with tkinter. 39 | newy = 22 40 | newheight = newheight - newy - 88 41 | 42 | else: 43 | #newy = 24 44 | newy = 0 45 | #newheight = newheight - 96 46 | newheight = newheight - 88 47 | if height >= newheight: 48 | newgeom = "" 49 | else: 50 | newgeom = "%dx%d+%d+%d" % (width, newheight, x, newy) 51 | top.wm_geometry(newgeom) 52 | -------------------------------------------------------------------------------- /site-packages/vidle3/__init__.py: -------------------------------------------------------------------------------- 1 | # Dummy file to make this a package. 2 | # Imports are relative (e.g. from . import PyShell), but 3 | # in PyShell.py there is a specific reference to idlelib (or vidle) 4 | # in connection with using __import__ (constructed import). 5 | -------------------------------------------------------------------------------- /site-packages/vidle3/config-highlight.def: -------------------------------------------------------------------------------- 1 | # IDLE reads several config files to determine user preferences. This 2 | # file is the default config file for idle highlight theme settings. 3 | 4 | [IDLE Classic] 5 | normal-foreground= #000000 6 | normal-background= #ffffff 7 | keyword-foreground= #ff7700 8 | keyword-background= #ffffff 9 | builtin-foreground= #900090 10 | builtin-background= #ffffff 11 | comment-foreground= #dd0000 12 | comment-background= #ffffff 13 | string-foreground= #00aa00 14 | string-background= #ffffff 15 | definition-foreground= #0000ff 16 | definition-background= #ffffff 17 | hilite-foreground= #000000 18 | hilite-background= gray 19 | break-foreground= black 20 | break-background= #ffff55 21 | hit-foreground= #ffffff 22 | hit-background= #000000 23 | error-foreground= #000000 24 | error-background= #ff7777 25 | #cursor (only foreground can be set, restart IDLE) 26 | cursor-foreground= black 27 | #shell window 28 | stdout-foreground= blue 29 | stdout-background= #ffffff 30 | stderr-foreground= red 31 | stderr-background= #ffffff 32 | console-foreground= #770000 33 | console-background= #ffffff 34 | 35 | [IDLE New] 36 | normal-foreground= #000000 37 | normal-background= #ffffff 38 | keyword-foreground= #ff7700 39 | keyword-background= #ffffff 40 | builtin-foreground= #900090 41 | builtin-background= #ffffff 42 | comment-foreground= #dd0000 43 | comment-background= #ffffff 44 | string-foreground= #00aa00 45 | string-background= #ffffff 46 | definition-foreground= #0000ff 47 | definition-background= #ffffff 48 | hilite-foreground= #000000 49 | hilite-background= gray 50 | break-foreground= black 51 | break-background= #ffff55 52 | hit-foreground= #ffffff 53 | hit-background= #000000 54 | error-foreground= #000000 55 | error-background= #ff7777 56 | #cursor (only foreground can be set, restart IDLE) 57 | cursor-foreground= black 58 | #shell window 59 | stdout-foreground= blue 60 | stdout-background= #ffffff 61 | stderr-foreground= red 62 | stderr-background= #ffffff 63 | console-foreground= #770000 64 | console-background= #ffffff 65 | -------------------------------------------------------------------------------- /site-packages/vidle3/dynOptionMenuWidget.py: -------------------------------------------------------------------------------- 1 | """ 2 | OptionMenu widget modified to allow dynamic menu reconfiguration 3 | and setting of highlightthickness 4 | """ 5 | from tkinter import OptionMenu 6 | from tkinter import _setit 7 | import copy 8 | 9 | class DynOptionMenu(OptionMenu): 10 | """ 11 | unlike OptionMenu, our kwargs can include highlightthickness 12 | """ 13 | def __init__(self, master, variable, value, *values, **kwargs): 14 | #get a copy of kwargs before OptionMenu.__init__ munges them 15 | kwargsCopy=copy.copy(kwargs) 16 | if 'highlightthickness' in list(kwargs.keys()): 17 | del(kwargs['highlightthickness']) 18 | OptionMenu.__init__(self, master, variable, value, *values, **kwargs) 19 | self.config(highlightthickness=kwargsCopy.get('highlightthickness')) 20 | #self.menu=self['menu'] 21 | self.variable=variable 22 | self.command=kwargs.get('command') 23 | 24 | def SetMenu(self,valueList,value=None): 25 | """ 26 | clear and reload the menu with a new set of options. 27 | valueList - list of new options 28 | value - initial value to set the optionmenu's menubutton to 29 | """ 30 | self['menu'].delete(0,'end') 31 | for item in valueList: 32 | self['menu'].add_command(label=item, 33 | command=_setit(self.variable,item,self.command)) 34 | if value: 35 | self.variable.set(value) 36 | -------------------------------------------------------------------------------- /site-packages/vidle3/idle.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Working IDLE bat for Windows - uses start instead of absolute pathname 3 | start idle.pyw %1 %2 %3 %4 %5 %6 %7 %8 %9 4 | -------------------------------------------------------------------------------- /site-packages/vidle3/idle.py: -------------------------------------------------------------------------------- 1 | import os.path 2 | import os 3 | import sys 4 | from platform import platform 5 | 6 | # If we are working on a development version of IDLE, we need to prepend the 7 | # parent of this idlelib dir to sys.path. Otherwise, importing idlelib gets 8 | # the version installed with the Python used to call this module: 9 | idlelib_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 10 | sys.path.insert(0, idlelib_dir) 11 | 12 | if platform().lower().split('-')[0] in ('darwin','linux'): 13 | from visual_common import __file__ as fname 14 | docPath = os.path.join(os.path.split(os.path.split(fname)[0])[0],'visual','examples') 15 | os.chdir(docPath) 16 | 17 | import vidle.PyShell 18 | vidle.PyShell.main() 19 | -------------------------------------------------------------------------------- /site-packages/vidle3/idle.pyw: -------------------------------------------------------------------------------- 1 | try: 2 | from vidle import PyShell 3 | except ImportError: 4 | # IDLE is not installed, but maybe PyShell is on sys.path: 5 | try: 6 | import PyShell 7 | except ImportError: 8 | raise 9 | else: 10 | import os 11 | idledir = os.path.dirname(os.path.abspath(PyShell.__file__)) 12 | if idledir != os.getcwd(): 13 | # We're not in the IDLE directory, help the subprocess find run.py 14 | pypath = os.environ.get('PYTHONPATH', '') 15 | if pypath: 16 | os.environ['PYTHONPATH'] = pypath + ':' + idledir 17 | else: 18 | os.environ['PYTHONPATH'] = idledir 19 | PyShell.main() 20 | else: 21 | PyShell.main() 22 | -------------------------------------------------------------------------------- /site-packages/vidle3/idlever.py: -------------------------------------------------------------------------------- 1 | IDLE_VERSION = "3.1.2" 2 | -------------------------------------------------------------------------------- /site-packages/vidle3/testcode.py: -------------------------------------------------------------------------------- 1 | import string 2 | 3 | def f(): 4 | a = 0 5 | b = 1 6 | c = 2 7 | d = 3 8 | e = 4 9 | g() 10 | 11 | def g(): 12 | h() 13 | 14 | def h(): 15 | i() 16 | 17 | def i(): 18 | j() 19 | 20 | def j(): 21 | k() 22 | 23 | def k(): 24 | l() 25 | 26 | l = lambda: test() 27 | 28 | def test(): 29 | string.capwords(1) 30 | 31 | f() 32 | -------------------------------------------------------------------------------- /site-packages/vidle3/utils.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def tb_print_list(extracted_list, filename, normal=sys.stdout, 4 | highlight=sys.stderr): 5 | """An extended version of traceback.print_list which exclude 6 | "in " when printing traceback and highlight the entries 7 | that occur on the given filename.""" 8 | for fname, lineno, name, line in extracted_list: 9 | f = highlight if fname == filename else normal 10 | if name == '': 11 | f.write(' File "%s", line %d\n' % (fname, lineno)) 12 | else: 13 | f.write(' File "%s", line %d, in %s\n' % (fname, lineno, name)) 14 | if line: 15 | f.write(' %s\n' % line.strip()) 16 | -------------------------------------------------------------------------------- /site-packages/vis/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | 3 | import imp as _imp 4 | import sys as _sys 5 | 6 | from visual_common.create_display import * 7 | 8 | scene = display() 9 | -------------------------------------------------------------------------------- /site-packages/vis/controls.py: -------------------------------------------------------------------------------- 1 | from visual_common.controls import * 2 | -------------------------------------------------------------------------------- /site-packages/vis/factorial.py: -------------------------------------------------------------------------------- 1 | from visual_common.factorial import * 2 | -------------------------------------------------------------------------------- /site-packages/vis/filedialog.py: -------------------------------------------------------------------------------- 1 | from visual_common.filedialog import * 2 | -------------------------------------------------------------------------------- /site-packages/vis/graph.py: -------------------------------------------------------------------------------- 1 | from visual_common.graph import * 2 | -------------------------------------------------------------------------------- /site-packages/vis/site_settings.py: -------------------------------------------------------------------------------- 1 | # This file may be modified by the user (or site administrator, in a 2 | # multi-user environment) to change settings or modify VPython to work 3 | # around local configuration issues. 4 | 5 | ## Disabling shaders may be necessary on some systems where Visual fails 6 | ## to detect that the video hardware or drivers are incapable of competently 7 | ## rendering the shaders used to implement certain materials. This will 8 | ## revert all objects to legacy rendering regardless of what material is 9 | ## chosen: 10 | 11 | enable_shaders = True # Make False to disable shaders 12 | 13 | ## Alternatively, it might be possible to fix some systems by disabling 14 | ## only some materials, remapping them to ones that work: 15 | 16 | ##from visual_common import materials 17 | ##materials.rough = materials.marble 18 | -------------------------------------------------------------------------------- /site-packages/visual/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | 3 | from visual.visual_all import * # this statement not included in vis/__init__.py 4 | from visual_common.create_display import * 5 | 6 | scene = display() 7 | -------------------------------------------------------------------------------- /site-packages/visual/controls.py: -------------------------------------------------------------------------------- 1 | from visual_common.controls import * 2 | -------------------------------------------------------------------------------- /site-packages/visual/docs/Templates/template.dwt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Template 7 | 8 | 9 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
 

 

Home

27 |

If you're new to Python
28 | and VPython: Introduction

29 |

A VPython tutorial

30 |

Pictures of 3D objects

31 |

32 |

33 |

34 | 35 |

What's new in VPython 6

36 |

VPython web site
37 | VPython license
38 | Python web site
39 | Math module (sqrt etc.)
40 | Numpy module (arrays)

 
48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /site-packages/visual/docs/VPython_Intro.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/VPython_Intro.pdf -------------------------------------------------------------------------------- /site-packages/visual/docs/VisualRef-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/VisualRef-1.gif -------------------------------------------------------------------------------- /site-packages/visual/docs/VisualRef-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/VisualRef-2.gif -------------------------------------------------------------------------------- /site-packages/visual/docs/VisualRef-3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/VisualRef-3.gif -------------------------------------------------------------------------------- /site-packages/visual/docs/VisualRef-4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/VisualRef-4.gif -------------------------------------------------------------------------------- /site-packages/visual/docs/VisualRef-6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/VisualRef-6.gif -------------------------------------------------------------------------------- /site-packages/visual/docs/VisualRef-7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/VisualRef-7.gif -------------------------------------------------------------------------------- /site-packages/visual/docs/axes.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/axes.gif -------------------------------------------------------------------------------- /site-packages/visual/docs/images/arc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/arc.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/arc_and_triangle_with_hole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/arc_and_triangle_with_hole.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/arc_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/arc_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/arrow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/arrow.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/box.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/circle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/circle.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/circle_frame.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/circle_frame.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/circle_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/circle_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/colors_abutting.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/colors_abutting.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/combine_paths.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/combine_paths.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/cone.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/cone.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/constructive_geometry.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/constructive_geometry.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/controls.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/controls.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/convex.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/convex.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/cross.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/cross.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/cross_ellipse.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/cross_ellipse.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/cross_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/cross_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/curve.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/curve.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/cylinder.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/cylinder.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/ellipse.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/ellipse.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/ellipse_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/ellipse_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/ellipsoid.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/ellipsoid.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/extrusion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/extrusion.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/extrusion_twist.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/extrusion_twist.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/extrustion_scaling.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/extrustion_scaling.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/faces.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/faces.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/filedialog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/filedialog.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/frustum.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/frustum.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/gear.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/gear.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/graph.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/graph.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/helix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/helix.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/heptagon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/heptagon.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/hexagon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/hexagon.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/hexagon_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/hexagon_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/label.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/label.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/lathe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/lathe.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/material_etc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/material_etc.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/ngon_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/ngon_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/partial_circle_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/partial_circle_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/pentagon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/pentagon.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/pentagon_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/pentagon_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/perimeter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/perimeter.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/perimeter_hollow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/perimeter_hollow.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/points.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/points.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/pyramid.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/pyramid.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/rackgear.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/rackgear.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/rectangle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/rectangle.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/rectangle_chamfered.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/rectangle_chamfered.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/rectangle_rotated.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/rectangle_rotated.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/rectangle_rounded.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/rectangle_rounded.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/rectangle_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/rectangle_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/rectangle_shape_chamfered.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/rectangle_shape_chamfered.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/rectangle_shape_frame.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/rectangle_shape_frame.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/rectangle_shape_rotated.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/rectangle_shape_rotated.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/rectangle_shape_rounded.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/rectangle_shape_rounded.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/ring.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/ring.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/skin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/skin.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/sphere.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/sphere.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/star.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/star.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/star_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/star_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/star_with_hole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/star_with_hole.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/starpath.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/starpath.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/text.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/text.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/text3d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/text3d.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/text_extrusion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/text_extrusion.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/text_inverse.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/text_inverse.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/text_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/text_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/trail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/trail.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/trapezoid.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/trapezoid.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/trapezoid_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/trapezoid_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/triangle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/triangle.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/triangle_circular_hole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/triangle_circular_hole.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/triangle_frame.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/triangle_frame.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/triangle_path.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/triangle_path.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/triangle_shape.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/triangle_shape.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/triangle_with_hole.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/triangle_with_hole.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/triangle_with_hole2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/triangle_with_hole2.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/triangular_ring.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/triangular_ring.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/images/widgets.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/images/widgets.jpg -------------------------------------------------------------------------------- /site-packages/visual/docs/navigation.js: -------------------------------------------------------------------------------- 1 | function jumpMenu(obj){ 2 | eval("window.location='"+obj.options[obj.selectedIndex].value+"'"); 3 | } 4 | 5 | var s = '' 6 | s += '' 7 | s += '' 8 | s += '' 9 | s += '' 10 | s += '' 11 | s += '' 12 | s += '' 13 | s += '' 14 | s += '' 15 | s += '' 16 | s += '' 17 | s += '' 18 | s += '' 19 | s += '' 20 | s += '' 21 | s += '' 22 | s += '' 23 | s += '' 24 | s += '' 25 | document.getElementById("menu1").innerHTML = s 26 | 27 | s = '' 28 | s += '' 29 | s += '' 30 | s += '' 31 | s += '' 32 | s += '' 33 | s += '' 34 | s += '' 35 | s += '' 36 | s += '' 37 | s += '' 38 | s += '' 39 | s += '' 40 | s += '' 41 | s += '' 42 | s += '' 43 | s += '' 44 | s += '' 45 | document.getElementById("menu2").innerHTML = s 46 | 47 | s = '' 48 | s += '' 49 | s += '' 50 | s += '' 51 | s += '' 52 | s += '' 53 | s += '' 54 | document.getElementById("menu3").innerHTML = s 55 | 56 | -------------------------------------------------------------------------------- /site-packages/visual/docs/ring.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/ring.gif -------------------------------------------------------------------------------- /site-packages/visual/docs/spherebox.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/docs/spherebox.gif -------------------------------------------------------------------------------- /site-packages/visual/examples/bounce.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | floor = box(length=4, height=0.5, width=4, color=color.blue) 4 | 5 | ball = sphere(pos=(0,4,0), color=color.red) 6 | ball.velocity = vector(0,-1,0) 7 | 8 | dt = 0.01 9 | while 1: 10 | rate(100) 11 | ball.pos = ball.pos + ball.velocity*dt 12 | if ball.y < 1: 13 | ball.velocity.y = -ball.velocity.y 14 | else: 15 | ball.velocity.y = ball.velocity.y - 9.8*dt 16 | -------------------------------------------------------------------------------- /site-packages/visual/examples/bounce2.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | print(""" 4 | Right button drag or Ctrl-drag to rotate "camera" to view scene. 5 | Middle button or Alt-drag to drag up or down to zoom in or out. 6 | On a two-button mouse, middle is left + right. 7 | """) 8 | 9 | side = 4.0 10 | thk = 0.3 11 | s2 = 2*side - thk 12 | s3 = 2*side + thk 13 | wallR = box (pos=( side, 0, 0), size=(thk, s2, s3), color = color.red) 14 | wallL = box (pos=(-side, 0, 0), size=(thk, s2, s3), color = color.red) 15 | wallB = box (pos=(0, -side, 0), size=(s3, thk, s3), color = color.blue) 16 | wallT = box (pos=(0, side, 0), size=(s3, thk, s3), color = color.blue) 17 | wallBK = box(pos=(0, 0, -side), size=(s2, s2, thk), color = (0.7,0.7,0.7)) 18 | 19 | ball = sphere (color = color.green, radius = 0.4, make_trail=True, retain=200) 20 | ball.trail_object.radius = 0.05 21 | ball.mass = 1.0 22 | ball.p = vector (-0.15, -0.23, +0.27) 23 | 24 | side = side - thk*0.5 - ball.radius 25 | 26 | dt = 0.5 27 | t=0.0 28 | while True: 29 | rate(100) 30 | t = t + dt 31 | ball.pos = ball.pos + (ball.p/ball.mass)*dt 32 | if not (side > ball.x > -side): 33 | ball.p.x = -ball.p.x 34 | if not (side > ball.y > -side): 35 | ball.p.y = -ball.p.y 36 | if not (side > ball.z > -side): 37 | ball.p.z = -ball.p.z 38 | 39 | -------------------------------------------------------------------------------- /site-packages/visual/examples/boxlighttest.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | # Mikhail Temkine, University of Toronto, April 2007 4 | 5 | print(""" 6 | Box lighting test 7 | """) 8 | 9 | r = 3 10 | a1 = a2 = a3 = 0.0 11 | 12 | arrow(pos=(0, 4, 0), axis=(0, 1, 0), color=color.red) 13 | boxy = box(size=(3,3,3), color=(0.5, 0.5, 0.5), material=materials.rough) 14 | b1 = sphere(radius=0.3, pos=(r, 0, 0), 15 | color=color.magenta, material=materials.emissive) 16 | b2 = sphere(radius=0.3, pos=(0, 0, r), 17 | color=color.yellow, material=materials.emissive) 18 | b3 = arrow(radius=0.3, pos=(0, 0, r), 19 | color=color.green, material=materials.emissive) 20 | l1 = local_light(pos=b1.pos, color=b1.color) 21 | l2 = local_light(pos=b2.pos, color=b2.color) 22 | l3 = distant_light(direction=b3.pos, color=b3.color) 23 | 24 | while True: 25 | rate(100) 26 | l1.pos = b1.pos = r*vector(cos(a1), sin(a1), b1.z) 27 | a1 += 0.02 28 | l2.pos = b2.pos = (r+0.4)*vector(b2.x, sin(a2), cos(a2)) 29 | a2 += 0.055 30 | l3.direction = b3.pos = (r+3)*vector(sin(a3), b3.y, cos(a3)) 31 | b3.axis = b3.pos * -0.3 32 | a3 += 0.033 33 | 34 | -------------------------------------------------------------------------------- /site-packages/visual/examples/conch.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | # Kadir Haldenbilen, Feb. 2011 3 | 4 | scene.height = scene.width = 800 5 | scene.center = (0.3,-2.4,0) 6 | 7 | def spiral(nloop=1, tightness=1.0, dir=1.0, scale=1.0): 8 | 9 | spr = [] 10 | scale = [] 11 | clrs = [] 12 | zd = 0.01 13 | for t in range(1, 1024*nloop, 16): 14 | t *= 0.01 15 | x = tightness/10.0 * t * math.cos(t)*dir 16 | y = tightness/10.0 * t * math.sin(t) 17 | sc = sqrt(x*x+y*y) 18 | z = t/7.0 19 | spr.append((x,y,z)) 20 | clr = vector((z*cos(t), abs(sin(t)),abs(cos(t*2)))).norm() 21 | clrs.append(clr) 22 | scale.append((sc,sc)) 23 | return spr, scale, clrs 24 | 25 | path, scale, clrs = spiral(nloop=2, tightness=0.8) 26 | elps = shapes.circle(radius=0.69, thickness=0.01) 27 | 28 | ee = extrusion(frame=frame(), shape=elps, pos=path, scale=scale, color=clrs, material=materials.marble) 29 | ee.frame.rotate(angle=pi/2) 30 | 31 | -------------------------------------------------------------------------------- /site-packages/visual/examples/convex.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | from random import uniform 3 | 4 | # David Scherer 5 | 6 | scene.range = 3 7 | 8 | a = convex(color=(0.5,0,0)) 9 | b = convex(color=(0,0.5,0)) 10 | c = convex(color=(0,0,0.5)) 11 | d = convex(color=(0.5,0,0.5)) 12 | e = convex(color=(0.5,0.5,0)) 13 | f = convex(color=(0,0.5,0.5)) 14 | 15 | # circle 16 | t = arange(0,2*pi,0.1) 17 | e.pos = transpose( (sin(t), cos(t)+2, 0*t) ) 18 | 19 | # triangle 20 | t = arange(0,2*pi,2*pi/3) 21 | f.pos = transpose( (sin(t)-2, cos(t)+2, 0*t) ) 22 | 23 | # disk 24 | for t in arange(0,2*pi,0.1): 25 | a.append(pos = (cos(t),0,sin(t))) 26 | a.append(pos = (cos(t),0.2,sin(t))) 27 | 28 | # box 29 | for i in range(8): 30 | p = vector((i/4)%2 - 2.5, (i/2)%2 - 0.5, (i)%2 - 0.5) 31 | b.append(pos=p) 32 | 33 | # random sphere 34 | L = [] 35 | for i in range(1000): 36 | L.append(vector(2,0) + norm(vector(uniform(-1,1),uniform(-1,1),uniform(-1,1)))) 37 | c.pos = L 38 | 39 | # lat/long sphere 40 | L = [] 41 | for t in arange(0,2*pi,0.2): 42 | for s in arange(0,pi,0.1): 43 | L.append((cos(t)*sin(s)+2, sin(t)*sin(s)+2, cos(s))) 44 | d.pos = L 45 | 46 | # modify the disk 47 | p = a 48 | p.color = (p.color[0]*2, p.color[1]*2, p.color[2]*2) 49 | while 1: 50 | rate(10) 51 | if scene.mouse.clicked: 52 | c = scene.mouse.getclick() 53 | p.append(pos=c.pos) 54 | p.pos[-1] = scene.mouse.pos 55 | -------------------------------------------------------------------------------- /site-packages/visual/examples/dipole.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | print(""" 4 | Click to plot a normalized electric field vector. 5 | Vectors are blue if low magnitude, red if high. 6 | Right button drag or Ctrl-drag to rotate camera to view scene. 7 | 8 | Middle button drag or Alt-drag to zoom in or out. 9 | On a two-button mouse, middle is left + right. 10 | """) 11 | 12 | ec = 1.6e-19 # electron charge 13 | 14 | scene.title="Electric Field Vectors" 15 | scene.range = 2e-13 16 | 17 | charges = [ sphere( pos = (-1e-13,0,0), Q = ec, color=color.red, radius = 6e-15 ), 18 | sphere( pos = ( 1e-13,0,0), Q = -ec, color=color.blue, radius = 6e-15 ), 19 | ] 20 | 21 | def getfield(p): 22 | f = vector(0,0,0) 23 | for c in charges: 24 | f = f + (p-c.pos) * 8.988e9 * c.Q / mag(p-c.pos)**3 25 | return f 26 | 27 | while True: 28 | p = scene.mouse.getclick().pos 29 | f = getfield(p) 30 | m = mag(f) 31 | red = maximum( 1-1e17/m, 0 ) 32 | blue = minimum( 1e17/m, 1 ) 33 | if red >= blue: 34 | blue = blue/red 35 | red = 1.0 36 | else: 37 | red = red/blue 38 | blue = 1.0 39 | arrow( pos=p, axis=f * (4e-14/1e17), 40 | shaftwidth = 6e-15, 41 | color=(red,0,blue)) 42 | -------------------------------------------------------------------------------- /site-packages/visual/examples/eventHandlers.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | from visual import * 3 | 4 | s = sphere() 5 | instruct = """ 6 | Try mouse and keyboard events, 7 | and note the printed outputs. 8 | """ 9 | l = label(pos=s.pos, text=instruct) 10 | redrawCount = 0 11 | 12 | class RedrawCounter(object): 13 | redrawCount = 0 14 | 15 | def increment(self): 16 | self.redrawCount += 1 17 | 18 | def handleMouseDown(evt, arbArg): 19 | print("Mouse down!" + repr(evt.pos) + ':' + repr(arbArg) + ':' + evt.event) 20 | 21 | if m.enabled: 22 | m.stop() 23 | print("keydown events are now disabled") 24 | else: 25 | m.start() 26 | print("keydown events are now enabled") 27 | 28 | def handleMouseUp( evt ): 29 | print("Mouse up! " + evt.event) 30 | 31 | def handleMouseClick( evt ): 32 | print("Mouse click!" + evt.event) 33 | 34 | def handleKeyUp( evt ): 35 | print("The ", evt.key, "key has gone up:", evt.event) 36 | print(' evt.ctrl =', evt.ctrl, ', evt.alt =', evt.alt, ', evt.shift =', evt.shift) 37 | 38 | def handleKeyDown( evt ): 39 | print("The ", evt.key, "key has gone down", evt.event) 40 | print(' evt.ctrl =', evt.ctrl, ', evt.alt =', evt.alt, ', evt.shift =', evt.shift) 41 | if evt.key == 'R': 42 | print("There have been", redraw.redrawCount, "redraws") 43 | 44 | def handleMouseMove( evt, num ): 45 | print(evt) 46 | print(num) 47 | print("Mouse moved! pos=", repr(evt.pos), ":", evt.event) 48 | 49 | redraw = RedrawCounter() 50 | 51 | scene.bind('mousedown', handleMouseDown, scene) 52 | scene.bind('mouseup', handleMouseUp) 53 | scene.bind('click', handleMouseClick) 54 | 55 | m = scene.bind('keydown', handleKeyDown) 56 | scene.bind('keyup', handleKeyUp) 57 | scene.bind('redraw', redraw.increment) 58 | scene.bind('mousemove', handleMouseMove, 3.2) 59 | -------------------------------------------------------------------------------- /site-packages/visual/examples/faces_cone.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | # Example of use of faces object for building arbitrary shapes (here, a cone) 3 | # David Scherer July 2001 4 | 5 | f = frame() 6 | 7 | box( size=(0.5,0.5,0.5) ) 8 | 9 | # Make a cone (smooth shading, no bottom, normals are not quite physical) 10 | 11 | N = 20 12 | 13 | try: # numpy 14 | model = faces( pos = zeros( (N*3,3), float ), frame = f ) 15 | except: # older Numeric 16 | model = faces( pos = zeros( (N*3,3), Float ), frame = f ) 17 | 18 | t = arange(0,2*pi+2*pi/N,2*pi/N) 19 | 20 | # Vertex 0 of triangles 21 | model.pos[0::3, 0] = sin(t[:-1]) 22 | model.pos[0::3, 2] = cos(t[:-1]) 23 | 24 | # Vertex 1 of triangles 25 | model.pos[1::3, 0] = sin(t[1:]) 26 | model.pos[1::3, 2] = cos(t[1:]) 27 | 28 | # Vertex 2 of triangles (point of cone) 29 | model.pos[2::3, 1] = 2 30 | 31 | # Construct normals to the edges of the triangles 32 | model.normal = model.pos 33 | model.normal[2::3,0] = sin(t[1:]) 34 | model.normal[0::1,1] = 0.5 35 | model.normal[2::3,2] = cos(t[1:]) 36 | 37 | # Give each face a hue running from 0 to 1 38 | model.color = model.pos 39 | for vertex in range(3*N): 40 | hue = float(vertex // 3)/N 41 | model.color[vertex] = color.hsv_to_rgb((hue,1,1)) 42 | 43 | ##model.color = model.pos/2 + (0.5,0,0.5) # alternative coloring 44 | 45 | while True: 46 | rate(100) 47 | f.rotate(angle=0.01) 48 | -------------------------------------------------------------------------------- /site-packages/visual/examples/faces_heightfield.py: -------------------------------------------------------------------------------- 1 | ## Demonstrates some techniques for working with "faces", and 2 | ## shows how to build a height field (a common feature request) 3 | ## with it. 4 | ## David Scherer July 2001 5 | ## Revised January 2010 by Bruce Sherwood to use faces.smooth() function 6 | ## introduced with VPython 5.2 7 | ## Revised March 2010 by Bruce Sherwood to use faces.make_normals() and 8 | ## faces.make_twosided() functions introduced with VPython 5.3 9 | 10 | from visual import * 11 | 12 | class Model: 13 | def __init__(self): 14 | self.frame = frame() 15 | self.model = faces(frame=self.frame, color=color.cyan) 16 | self.vertices = [] 17 | 18 | def FacetedTriangle(self, v1, v2, v3, color=color.white): 19 | """Add a triangle to the model""" 20 | for v in (v1,v2,v3): 21 | self.vertices.append(v) 22 | 23 | def FacetedPolygon(self, *v): 24 | """Appends a planar polygon of any number of vertices to the model""" 25 | for t in range(len(v)-2): 26 | self.FacetedTriangle( v[0], v[t+1], v[t+2] ) 27 | 28 | def DrawNormals(self, scale): 29 | pos = self.model.pos 30 | normal = self.model.normal 31 | for i in range(len(pos)): 32 | arrow(pos=pos[i], axis=normal[i]*scale) 33 | 34 | class Mesh (Model): 35 | def __init__(self, xvalues, yvalues, zvalues): 36 | Model.__init__(self) 37 | 38 | points = zeros( xvalues.shape + (3,), float ) 39 | points[...,0] = xvalues 40 | points[...,1] = yvalues 41 | points[...,2] = zvalues 42 | 43 | for i in range(zvalues.shape[0]-1): 44 | for j in range(zvalues.shape[1]-1): 45 | self.FacetedPolygon( points[i,j], points[i,j+1], 46 | points[i+1,j+1], points[i+1,j] ) 47 | 48 | self.model.pos = self.vertices 49 | self.model.make_normals() 50 | self.model.smooth() 51 | self.model.make_twosided() 52 | 53 | ## Graph a function of two variables (a height field) 54 | x = arange(-1,1,2./20) 55 | y = arange(-1,1,2./20) 56 | 57 | z = zeros( (len(x),len(y)), float ) 58 | x,y = x[:,None]+z, y+z 59 | 60 | m = Mesh( x, (sin(x*pi)+sin(y*pi))*0.2, y ) 61 | ##m.DrawNormals(0.05) 62 | 63 | -------------------------------------------------------------------------------- /site-packages/visual/examples/flower128.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual/examples/flower128.tga -------------------------------------------------------------------------------- /site-packages/visual/examples/graphtest.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | from visual.graph import * 3 | 4 | # Using a graph-plotting module 5 | 6 | # If xmax, xmin, ymax, or ymin specified, the related axis is not autoscaled 7 | # Can turn off autoscaling with 8 | # oscillation.autoscale[0]=0 for x or oscillation.autoscale[1]=0 for y 9 | oscillation = gdisplay(xtitle='Time', ytitle='Response (click and drag mouse to see coordinates)') 10 | funct1 = gcurve(color=color.cyan) 11 | funct2 = gvbars(delta=0.5, color=color.red) 12 | funct3 = gdots(color=color.yellow) 13 | 14 | for t in arange(-30, 74, 1): 15 | funct1.plot( pos=(t, 5.0+5.0*cos(-0.2*t)*exp(0.015*t)) ) 16 | funct2.plot( pos=(t, 2.0+5.0*cos(-0.1*t)*exp(0.015*t)) ) 17 | funct3.plot( pos=(t, 5.0*cos(-0.03*t)*exp(0.015*t)) ) 18 | 19 | histo = gdisplay(title='Histogram', x=0, y=400, width=800,height=400) 20 | datalist1 = [5, 37, 12, 21, 25, 28, 8, 63, 52, 75, 7] 21 | data = ghistogram(bins=arange(-20, 80, 10), color=color.red) 22 | data.plot(data=datalist1) 23 | datalist2 = [7, 23, 25, 72, -15] 24 | data.plot(data=datalist2, accumulate=1) 25 | 26 | -------------------------------------------------------------------------------- /site-packages/visual/examples/keyinput.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | from visual import * 3 | prose = label() # initially blank text 4 | 5 | def keyInput(evt): 6 | s = evt.key 7 | if len(s) == 1: 8 | prose.text += s # append new character 9 | elif ((s == 'backspace' or s == 'delete') and 10 | len(prose.text)) > 0: 11 | if evt.shift: 12 | prose.text = '' # erase all text 13 | else: 14 | prose.text = prose.text[:-1] # erase letter 15 | 16 | scene.bind('keydown', keyInput) 17 | -------------------------------------------------------------------------------- /site-packages/visual/examples/labels.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | x = arrow( color=color.red) 4 | 5 | tip = label( text="tip", space=0.2, pos=(1,0), opacity=0.5) 6 | tail = label( text="tail", xoffset=20, yoffset=10, opacity=0.5) 7 | midp = label( text="a\nmidpoint", xoffset=10, yoffset=20, pos=(.5,0), opacity=0.5) 8 | 9 | print("""You should see a single arrow with three labels attached to it. 10 | Each label is translucent. The one at the tip should be centered at 11 | the tip. The head and tail labels have a single line of text. 12 | The midpoint label has two.""") 13 | -------------------------------------------------------------------------------- /site-packages/visual/examples/lathe.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | # Create a surface of revolution out of slices that are convex objects 4 | # By David Scherer 5 | 6 | def draw_slice(sweep, r, axis, frame, color): 7 | # comment in this line to see where the slices are: 8 | #color=(uniform(0,1),uniform(0,1),uniform(0,1)) 9 | 10 | ls = len(sweep) 11 | pos = zeros( (len(r)*ls, 3), float64 ) 12 | for j in range(len(r)): 13 | pos[j*ls:j*ls+ls] = sweep*r[j] + (axis[j],0,0) 14 | return convex(pos=pos, 15 | frame = frame, 16 | color = color, 17 | ) 18 | 19 | def revolution(radius, length, slices=32, color = (1,1,1), pos = (0,0,0)): 20 | r = absolute(radius) # radius is a list of radii for all the slices 21 | 22 | # sweep = unit circle in the yz plane 23 | t = arange(0,2*pi,2*pi/slices) 24 | sweep = zeros( (slices,3), float64) # Numeric array (rows=slices)*(columns=3) 25 | sweep[:,1] = cos(t) # set middle column to cos(t) 26 | sweep[:,2] = sin(t) # set final column to sin(t) 27 | 28 | # axis[i] = center of the ith slice of the surface 29 | axis = arange(0,length,float(length)/len(r)) 30 | 31 | group = frame(pos = pos) 32 | 33 | start = 0 34 | for i in range(1,len(r)-1): 35 | # if concave, show all convex slices up this point 36 | if (r[i+1] + r[i-1] - 2*r[i]) >= 0: # have encountered concave region 37 | draw_slice(sweep,r[start:i],axis[start:i], group, color) 38 | start = i-1 39 | draw_slice(sweep,r[start:],axis[start:], group, color) 40 | 41 | return group 42 | 43 | scene.autocenter = True 44 | t = arange(0,1,0.02) 45 | s = revolution(sin(t*12.)*0.5 + 1.0, 5.0, pos=(3,0,0), color=color.red) 46 | s.axis = (0,1,0) 47 | 48 | glass = revolution( [0.5, 0.1, 0.1, 0.1, 0.1, 0.2, 0.3, 0.4, 0.5], 49 | length=5.0, 50 | color=color.yellow) 51 | glass.axis = (0,1,0) 52 | -------------------------------------------------------------------------------- /site-packages/visual/examples/lorenz.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | print(""" 4 | Right button drag or Ctrl-drag to rotate "camera" to view scene. 5 | Middle button to drag or Alt-drag to zoom in or out. 6 | On a two-button mouse, middle is left + right. 7 | """) 8 | scene.title = "Lorenz differential equation" 9 | scene.center = vector(25,0,0) 10 | 11 | lorenz = curve( color = color.black, radius=0.3 ) 12 | 13 | # Draw grid 14 | for x in arange(0,51,10): 15 | box(pos=(x,0,0), axis=(0,0,50), height=0.4, width=0.4, color=(0.6,0.6,0.6) ) 16 | for z in arange(-25,26,10): 17 | box(pos=(25,0,z), axis=(50,0,0), height=0.4, width=0., color=(0.6,0.6,0.6) ) 18 | 19 | dt = 0.01 20 | y = vector(35, -10, -7) 21 | 22 | for t in arange(0,10,dt): 23 | # Integrate a funny differential equation 24 | dydt = vector( - 8.0/3*y[0] + y[1]*y[2], 25 | - 10*y[1] + 10*y[2], 26 | - y[1]*y[0] + 28*y[1] - y[2] ); 27 | y = y + dydt*dt 28 | 29 | # Draw lines colored by speed 30 | c = clip( [mag(dydt) * 0.005], 0, 1 )[0] 31 | 32 | lorenz.append( pos=y, color=(c,0, 1-c) ) 33 | 34 | rate( 500 ) 35 | -------------------------------------------------------------------------------- /site-packages/visual/examples/mandelbrot.py: -------------------------------------------------------------------------------- 1 | from __future__ import division 2 | from visual import * 3 | from visual.graph import * 4 | 5 | # Bruce Sherwood, Jan. 1, 2008 6 | # Use points object to make a pixel-like plot of a fractal 7 | 8 | XMIN = -2 9 | XMAX = 0.5 10 | YMIN = -1 11 | YMAX = 1 12 | g = gdisplay(width=750, height=600, xmin=XMIN, xmax=XMAX, ymin=YMIN, ymax=YMAX) 13 | pixels = gdots(shape='square', size=2) 14 | # Scale factor: 2 units (YMAX-YMIN) equals 600 screen pixels 15 | # Plot 2 by 2 gdots points 2*(2units/600pixels) apart: 16 | r = 2*2/600 17 | 18 | # Mandelbrot set (see Wikipedia, for example): 19 | max_iteration = 100 20 | for y0 in arange(YMIN, YMAX, r): # range over all pixel positions 21 | rate(100) 22 | for x0 in arange(XMIN, XMAX, r): 23 | z = z0 = complex(x0,y0) 24 | iteration = 0 25 | while ( abs(z) < 2 and iteration < max_iteration): 26 | z = z*z+z0 27 | iteration += 1 28 | # Leave points black if the iteration quickly escapes: 29 | if (.1 < iteration/max_iteration < 1): 30 | c = color.hsv_to_rgb((iteration/max_iteration-.1,1,1)) 31 | pixels.plot(pos=(x0,y0), color=c) 32 | 33 | -------------------------------------------------------------------------------- /site-packages/visual/examples/orbit.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | G = 6.7e-11 4 | 5 | giant = sphere(pos=(-1e11,0,0), radius=2e10, color=color.red, 6 | make_trail=True, interval=10, retain=200) 7 | giant.mass = 2e30 8 | giant.p = vector(0, 0, -1e4) * giant.mass 9 | 10 | dwarf = sphere(pos=(1.5e11,0,0), radius=1e10, color=color.yellow, 11 | make_trail=True, interval=10, retain=200) 12 | dwarf.mass = 1e30 13 | dwarf.p = -giant.p 14 | 15 | dt = 1e5 16 | 17 | while True: 18 | rate(200) 19 | 20 | dist = dwarf.pos - giant.pos 21 | force = G * giant.mass * dwarf.mass * dist / mag(dist)**3 22 | giant.p = giant.p + force*dt 23 | dwarf.p = dwarf.p - force*dt 24 | 25 | for star in [giant, dwarf]: 26 | star.pos = star.pos + star.p/star.mass * dt 27 | 28 | -------------------------------------------------------------------------------- /site-packages/visual/examples/planar.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | from random import uniform, randint 3 | 4 | scene.forward = (-0.25,-0.25,-1) 5 | 6 | nboxes = 8 7 | nlinks = 16 8 | maxgrid = 10 9 | 10 | # Create some random cylinders: 11 | nodes = [] 12 | for t in arange(-pi,pi,2*pi/nboxes): 13 | b = cylinder( pos=(10*sin(t),0,10*cos(t)) ) 14 | b.color = b.icolor = (0.5,0.5,1) 15 | height = uniform(0.5,4) 16 | b.axis = (0,height,0) 17 | nodes.append( b ) 18 | 19 | # Create some random links: 20 | links = [] 21 | for l in range(nlinks): 22 | while True: 23 | i = randint(0,nboxes-1) 24 | j = randint(0,nboxes-1) 25 | if i != j: break 26 | c = curve( ends=[nodes[i].pos,nodes[j].pos], radius=0.2 ) 27 | c.red = 0 28 | c.green = uniform(0.3,1) 29 | c.blue = 0 30 | c.pos = c.ends 31 | links.append(c) 32 | 33 | # Draw a grid: 34 | for i in range(maxgrid+1): 35 | curve(pos=[(2*i-maxgrid,0,-maxgrid),(2*i-maxgrid,0,maxgrid)], color=color.cyan) 36 | curve(pos=[(-maxgrid,0,2*i-maxgrid),(maxgrid,0,2*i-maxgrid)], color=color.cyan) 37 | box(pos=(0,-0.6,0),width=2*maxgrid,length=2*maxgrid,height=1,color=(0,0,0.1)) 38 | 39 | # Drag and drop loop 40 | drag = None 41 | while True: 42 | rate(100) 43 | if scene.mouse.events: 44 | c = scene.mouse.getevent() 45 | if drag and (c.drop or c.click): # drop the selected object 46 | newpos = c.project(normal=scene.up, d=yoffset)+offset 47 | if abs(newpos.x)<=maxgrid and abs(newpos.z)<=maxgrid: 48 | drag.pos = newpos 49 | drag.color = drag.icolor 50 | drag = None 51 | elif c.pick and hasattr(c.pick,"icolor"): # pick up the object 52 | drag = c.pick 53 | drag.color = color.white 54 | yoffset = c.pickpos.y 55 | offset = drag.pos-c.project(normal=scene.up, d=yoffset) 56 | if drag: 57 | newpos = scene.mouse.project(normal=scene.up, d=yoffset)+offset 58 | if abs(newpos.x)<=maxgrid and abs(newpos.z)<=maxgrid: 59 | drag.pos = newpos 60 | 61 | for lnk in links: lnk.pos = lnk.ends 62 | -------------------------------------------------------------------------------- /site-packages/visual/examples/randombox.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | from random import random, randrange 3 | 4 | ## this is mostly for experimenting with zooming and rotating 5 | 6 | print(""" 7 | Right button drag or Ctrl-drag to rotate "camera" to view scene. 8 | Middle button to drag or Alt-drag up or down to zoom in or out. 9 | On a two-button mouse, middle is left + right. 10 | """) 11 | 12 | def random_box (): 13 | xx = randrange (-55,54) 14 | yy = randrange (-55,54) 15 | zz = randrange (-55,54) 16 | x = randrange (1,11) 17 | y = randrange (1,11) 18 | z = randrange (1,11) 19 | red = random() 20 | green = random() 21 | blue = random() 22 | box (pos = vector(xx,yy,zz), length=x, height=y, width=z, 23 | color=(red,green,blue)) 24 | 25 | def wirecube (s): 26 | c=curve (color=color.white, radius=1) 27 | pts = [(-s, -s, -s),(-s, -s, s), (-s, s, s), 28 | (-s, s, -s), (-s, -s, -s), (s, -s, -s), 29 | (s, s, -s), (-s, s, -s), (s, s, -s), 30 | (s, s, s), (-s, s, s), (s, s, s), 31 | (s, -s, s), (-s, -s, s), (s, -s, s),(s, -s, -s)] 32 | for pt in pts: 33 | c.append(pos=pt) 34 | 35 | scene.title = "Random Boxes" 36 | side=60. 37 | wirecube (side) 38 | i = 0 39 | while i < 100: 40 | random_box() 41 | i = i + 1 42 | 43 | arrow(axis = (0,12,0), shaftwidth = 3.5, color=color.red ) 44 | 45 | ball=sphere(pos=(-side/2.,-side/2.,-side/2.), color=(1,1,0), radius=3) 46 | disk=cylinder(pos=(side/2., side/2., -side/2.), color=(.3,.3,1), axis=(1,1,0), 47 | radius=5) 48 | xx=arange(0,4*pi,pi/10.) 49 | spring=curve(color=(1,.7,.1), radius=0.4) 50 | for y in xx: 51 | spring.append(pos=(20+cos(2*y), y/2.-30, -20+sin(2*y)+30)) 52 | -------------------------------------------------------------------------------- /site-packages/visual/examples/text3D.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | scene.height = 500 4 | scene.width = 800 5 | scene.range = 4 6 | scene.autocenter = True 7 | title = text(text="My text is\ngreen", align='center', depth=-0.3, color=color.green) 8 | vertical = (title.upper_left-title.start).norm() 9 | height = curve(color=color.yellow, radius=0.02, 10 | pos=[title.start-.2*title.axis, 11 | title.start-.2*title.axis+title.height*vertical]) 12 | lheight = label(pos=.5*(height.pos[0]+height.pos[1]), 13 | xoffset=-30, yoffset=+10, text='height') 14 | descent = curve(color=color.yellow, radius=0.02, 15 | pos=[title.start+0.2*title.axis, 16 | title.start+0.2*title.axis-title.descent*vertical]) 17 | ldescent = label(pos=.5*(descent.pos[0]+descent.pos[1]), 18 | xoffset=-20, yoffset=-40, text='descent') 19 | width = curve(color=color.yellow, radius=0.02, 20 | pos=[title.upper_left+0.1*vertical, title.upper_right+0.1*vertical]) 21 | lwidth = label(pos=.5*(width.pos[0]+width.pos[1]), 22 | xoffset=10, yoffset=40, text='width') 23 | verticalspacing = curve(color=color.yellow, radius=0.02, 24 | pos=[title.start+title.widths[0]*title.axis, 25 | title.start+title.widths[0]*title.axis-vector(0,title.vertical_spacing,0)]) 26 | lverticalspacing = label(pos=.5*(verticalspacing.pos[0]+verticalspacing.pos[1]), 27 | xoffset=-25, yoffset=20, text='vertical_spacing') 28 | ul = label(pos=title.upper_left, text='upper_left', 29 | xoffset=-30, yoffset=30) 30 | ur = label(pos=title.upper_right, text='upper_right', 31 | xoffset=30, yoffset=30) 32 | lr = label(pos=title.lower_right, text='lower_right', 33 | xoffset=30, yoffset=-30) 34 | ll = label(pos=title.lower_left, text='lower_left', 35 | xoffset=-30, yoffset=-30) 36 | lc = label(pos=title.pos, text="pos (align='"+title.align+"')", 37 | xoffset=-20, yoffset=-20) 38 | ls = label(pos=title.start, text='start', 39 | xoffset=-60, yoffset=-30) 40 | for s in [ul, ur, lr, ll, lc, ls]: 41 | sphere(pos=s.pos, radius=0.05, color=color.red) 42 | -------------------------------------------------------------------------------- /site-packages/visual/examples/texttest.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | from visual.text import * 3 | 4 | print(""" 5 | This early 3D text machinery is limited to rather crude uppercase letters. 6 | It has been superceded by the text object introduced in Visual 5.3. 7 | """) 8 | 9 | # Display extruded text (uppercase only at present) 10 | # By default, display text along x axis, with letters pointing up parallel to y axis 11 | # Bruce Sherwood, Carnegie Mellon University, begun March 2000 12 | 13 | # Example with default values: 14 | # text(pos=(0,0,0), axis=(1,0,0), string='ABC', 15 | # height=1, depth=0, width=1, 16 | # color=currentdisplay.foreground, up=(0,1,0.3)) 17 | # axis is direction along which text advances 18 | # if width not specified, it is the same as height 19 | # depth is measured forward from pos 20 | # Only numbers and uppercase letters at present: others display as '*' 21 | 22 | scene.title = "3D Text" 23 | scene.fov = 0.001 24 | scene.range = 7 25 | text(pos=(0,3,0), string='ABC', color=color.red, depth=0.3, justify='center') 26 | text(pos=(0,-3,0), string='DEF', color=color.blue, depth=0.3, justify='center') 27 | message = text(pos=(0,0,0), string='CLICK TO CHANGE THIS', justify='center', 28 | color=color.yellow, axis=(1,0,1), 29 | depth=0.3, up=(0,1,-0.3)) 30 | scene.mouse.getclick() 31 | message.reshape(color=color.cyan, height=2) 32 | -------------------------------------------------------------------------------- /site-packages/visual/examples/texturetest.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | # Jonathan Brandmeyer 4 | scene.background = color.gray(0.8) 5 | 6 | checkerboard = array([[0,0,1,1], 7 | [0,0,1,1], 8 | [1,1,0,0], 9 | [1,1,0,0]], float) 10 | lum = materials.texture( data=checkerboard, 11 | mapping="rectangular", 12 | interpolate=False) 13 | op = materials.texture( data=checkerboard, 14 | channels=["luminance"], 15 | mapping="rectangular", 16 | interpolate=False) 17 | balp1 = box( axis=(0,0,1), color=color.orange, material=op) 18 | blum1 = box( axis=(0,0,1), color=color.orange, material=lum, pos=(-2, 0)) 19 | box( pos=(0, 2), color=color.orange, opacity=0.5) 20 | box( pos=(0,-2), color=color.orange) 21 | blum2 = box( pos=(0, 0, -2), axis=(0,0,1), color=color.orange, material=lum) 22 | z = arrow(color=color.green) 23 | z.axis *= 2 24 | 25 | scene.mouse.getclick() 26 | # Change the texture 27 | save = array(checkerboard[:,1]) 28 | checkerboard[:,1] = checkerboard[:,2] 29 | checkerboard[:,2] = save 30 | save = array(checkerboard[1,:]) 31 | checkerboard[1,:] = checkerboard[2,:] 32 | checkerboard[2,:] = save 33 | # Recreate and reassign the textures; Visual doesn't check for texture changes 34 | lum = materials.texture( data=checkerboard, 35 | mapping="rectangular", 36 | interpolate=False) 37 | op = materials.texture( mipmap=False, data=checkerboard, 38 | channels=["luminance"], 39 | mapping="rectangular", 40 | interpolate=False) 41 | balp1.material = op 42 | blum1.material = lum 43 | blum2.material = lum 44 | 45 | 46 | -------------------------------------------------------------------------------- /site-packages/visual/examples/toroid_drag.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | print(""" 4 | Drag or click to show the magnetic field interactively. 5 | Mark the magnetic field vector at the end of the drag. 6 | """) 7 | 8 | scene.width = 600 9 | scene.height = 600 10 | Rbig = 0.6 11 | L = 2*pi*Rbig 12 | Rsmall = 0.2 13 | k = 1E-7 # mu-zero/4pi 14 | I = 1.0 15 | Ncoils = 20 16 | Bscale = (2.*Rsmall)/(4*pi*1E-7*Ncoils*I/L) 17 | 18 | dphi = 2.*pi/Ncoils/50. 19 | phi = arange(0,2*pi+dphi,dphi) 20 | toroid=curve(x = Rbig*cos(phi)+Rsmall*cos(Ncoils*phi)*cos(phi), 21 | y = Rbig*sin(phi)+Rsmall*cos(Ncoils*phi)*sin(phi), 22 | z = -Rsmall*sin(Ncoils*phi)) 23 | toroid.color = (1,0.7,0.2) 24 | toroid.radius = 0.01 25 | 26 | delta = toroid.pos[1:] - toroid.pos[:-1] 27 | center = (toroid.pos[:-1] + toroid.pos[1:])/2. 28 | scene.range = 1.3*(Rbig+Rsmall) 29 | vwidth = L/100 30 | 31 | def BField(obs): 32 | r = obs-center 33 | rmag = mag(r) 34 | rmag.shape = (-1,1) 35 | try: # numpy 36 | return (k*I*cross(delta, r)/rmag**3).sum(axis=0) 37 | except: # old Numeric 38 | return sum(k*I*cross(delta, r)/rmag**3) 39 | 40 | Bvector = arrow(axis=(0,0,0), shaftwidth=vwidth, color=(0,1,1)) 41 | drag = False 42 | 43 | while True: 44 | rate(100) 45 | if drag: 46 | newobs = scene.mouse.pos 47 | if newobs != obs: 48 | obs = newobs 49 | Bvector.axis = Bscale*BField(obs) 50 | Bvector.pos = obs 51 | if scene.mouse.events: 52 | m = scene.mouse.getevent() 53 | if m.button == 'left': 54 | if m.press: 55 | obs = scene.mouse.pos 56 | Bvector.axis = Bscale*BField(obs) 57 | Bvector.pos = obs 58 | elif m.drag: 59 | drag = True 60 | obs = None # force update of position 61 | ## scene.cursor.visible = 0 # not yet implemented 62 | elif m.release or m.drop: 63 | drag = False 64 | ## scene.cursor.visible = 1 # not yet implemented 65 | arrow(pos=obs, axis=Bscale*BField(obs), shaftwidth=vwidth, color=(0,1,1)) 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /site-packages/visual/examples/wave.py: -------------------------------------------------------------------------------- 1 | from visual import * 2 | 3 | # David Scherer 4 | 5 | dt = 0.1 6 | 7 | g = [] 8 | for i in range(3): 9 | g.append(display(x = 0, y = 30 + 250*i, width=600, height=220)) 10 | 11 | g[0].title="k=6N/m mass=2.0kg" 12 | g[1].title="k=6N/m mass=1.0kg" 13 | g[2].title="k=6N/m mass=0.5kg" 14 | 15 | bands = [ curve( x = arange(-50,50), display=g[0], color=color.red, k = 6., mass = 2.0), 16 | curve( x = arange(-50,50), display=g[1], color=color.yellow, k = 6., mass = 1.0), 17 | curve( x = arange(-50,50), display=g[2], color=color.green, k = 6., mass = 0.5), 18 | ] 19 | 20 | for band in bands: 21 | band.radius = 0.5 22 | band.momentum = zeros((100,3),float) 23 | 24 | ### Uncomment exactly one of the following lines: ### 25 | 26 | band.momentum[:25,1] = sin(band.x[:25]*pi / 25.0)*3 # half-wave pulse 27 | ## band.momentum[:25,1] = sin(band.x[:25]*2*pi / 25.0)*5 # full-wave pulse 28 | ## band.momentum[:25,0] = sin(band.x[:25]*pi / 25.0)*5 # compression wave 29 | ## band.momentum[:,1] = sin(band.x * 4 * pi / 100.0)*2 # standing wave 30 | ## band.momentum[25,1] = 20 # single point impulse (messy) 31 | 32 | while True: 33 | rate(100) 34 | for band in bands: 35 | # Keep endpoints fixed: 36 | band.momentum[0] = band.momentum[-1] = vector(0,0,0) 37 | 38 | # Integrate velocity: 39 | band.pos = band.pos + (band.momentum/band.mass*dt) 40 | 41 | # force[n] is the force on point n from point n+1 (to the right): 42 | force = band.k * (band.pos[1:] - band.pos[:-1]) 43 | 44 | # all points but the last experience forces to the right: 45 | band.momentum[:-1] = band.momentum[:-1] + force * dt 46 | 47 | # all points but the first experience forces to the left: 48 | band.momentum[1:] = band.momentum[1:] - force * dt 49 | -------------------------------------------------------------------------------- /site-packages/visual/factorial.py: -------------------------------------------------------------------------------- 1 | from visual_common.factorial import * 2 | -------------------------------------------------------------------------------- /site-packages/visual/filedialog.py: -------------------------------------------------------------------------------- 1 | from visual_common.filedialog import * 2 | -------------------------------------------------------------------------------- /site-packages/visual/graph.py: -------------------------------------------------------------------------------- 1 | from visual_common.graph import * 2 | -------------------------------------------------------------------------------- /site-packages/visual_common/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyd 2 | *.so 3 | -------------------------------------------------------------------------------- /site-packages/visual_common/BlueMarble.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual_common/BlueMarble.tga -------------------------------------------------------------------------------- /site-packages/visual_common/__init__.py: -------------------------------------------------------------------------------- 1 | pass # dummy to make visual_common a package 2 | -------------------------------------------------------------------------------- /site-packages/visual_common/brickbump.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual_common/brickbump.tga -------------------------------------------------------------------------------- /site-packages/visual_common/crayola.py: -------------------------------------------------------------------------------- 1 | import colorsys 2 | 3 | black = (0,0,0) 4 | white = (1,1,1) 5 | 6 | red = (1,0,0) 7 | green = (0,1,0) 8 | blue = (0,0,1) 9 | 10 | yellow = (1,1,0) 11 | cyan = (0,1,1) 12 | magenta = (1,0,1) 13 | 14 | orange = (1,0.6,0) 15 | 16 | def gray(luminance): 17 | return (luminance,luminance,luminance) 18 | 19 | def rgb_to_hsv(T): 20 | if len(T) > 3: 21 | T = T[:3] 22 | return colorsys.rgb_to_hsv(*T) 23 | 24 | def hsv_to_rgb(T): 25 | if len(T) > 3: 26 | T = T[:3] 27 | return colorsys.hsv_to_rgb(*T) 28 | 29 | def rgb_to_grayscale(T): 30 | if len(T) > 3: 31 | T = T[:3] 32 | luminance = 0.21*T[0] + 0.71*T[1] + 0.07*T[2] 33 | return (luminance, luminance, luminance) 34 | -------------------------------------------------------------------------------- /site-packages/visual_common/earth.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual_common/earth.tga -------------------------------------------------------------------------------- /site-packages/visual_common/factorial.py: -------------------------------------------------------------------------------- 1 | # factorial and combin functions needed in statistical computations 2 | # Bruce Sherwood, Carnegie Mellon University, 2000 3 | # Important improvement to combin, Bruce Sherwood, April 2015 4 | 5 | from __future__ import division, print_function 6 | def factorial(x): 7 | if x <= 0.: 8 | if x == 0: return 1 9 | else: raise ValueError('Cannot take factorial of negative number %d' % x) 10 | fact = 1.0 11 | nn = 2 12 | while nn <= x: 13 | fact = fact*nn 14 | nn += 1 15 | if nn != x+1: raise ValueError('Argument of factorial must be an integer, not %0.1f' % x) 16 | return fact 17 | 18 | def combin(x, y): 19 | # combin(x,y) = factorial(x)/[factorial(y)*factorial(x-y)] 20 | z = x-y 21 | num = 1.0 22 | if y > z: 23 | y,z = z,y 24 | nn = z+1 25 | ny = 1 26 | while nn <= x: 27 | num = num*nn/ny 28 | nn += 1 29 | ny += 1 30 | if nn != x+1: raise ValueError('Illegal arguments (%d, %d) for combin function' % (x, y)) 31 | return num 32 | 33 | if __name__ == '__main__': 34 | print('factorial(6) = 6! =', factorial(6)) # should be 720 35 | print('combin(6,2) = 6!/(2!(6-2)!) =', combin(6,2)) # should be 15 36 | print('combin(1000,500) = 1000!/(500!(1000-500)!) =', combin(1000,500)) # should be 2.70288240945e+299 37 | 38 | -------------------------------------------------------------------------------- /site-packages/visual_common/random.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual_common/random.tga -------------------------------------------------------------------------------- /site-packages/visual_common/site_settings.py: -------------------------------------------------------------------------------- 1 | # This file may be modified by the user (or site administrator, in a 2 | # multi-user environment) to change settings or modify VPython to work 3 | # around local configuration issues. 4 | 5 | ## Disabling shaders may be necessary on some systems where Visual fails 6 | ## to detect that the video hardware or drivers are incapable of competently 7 | ## rendering the shaders used to implement certain materials. This will 8 | ## revert all objects to legacy rendering regardless of what material is 9 | ## chosen: 10 | 11 | ##from .ui import display 12 | ##display.enable_shaders = False 13 | 14 | ## Alternatively, it might be possible to fix some systems by disabling 15 | ## only some materials, remapping them to ones that work: 16 | 17 | ##from . import materials 18 | ##materials.rough = materials.diffuse\ 19 | -------------------------------------------------------------------------------- /site-packages/visual_common/turbulence3.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual_common/turbulence3.tga -------------------------------------------------------------------------------- /site-packages/visual_common/wood.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/site-packages/visual_common/wood.tga -------------------------------------------------------------------------------- /src/core/axial.cpp: -------------------------------------------------------------------------------- 1 | #include "axial.hpp" 2 | 3 | namespace cvisual { 4 | 5 | axial::axial() 6 | : radius(1.0) 7 | { 8 | } 9 | 10 | axial::axial( const axial& other) 11 | : primitive( other), radius( other.radius) 12 | { 13 | } 14 | 15 | axial::~axial() 16 | { 17 | } 18 | 19 | void 20 | axial::set_radius( double r) 21 | { 22 | radius = r; 23 | } 24 | 25 | double 26 | axial::get_radius() 27 | { 28 | return radius; 29 | } 30 | 31 | void 32 | axial::get_material_matrix(const view&, tmatrix& out) { 33 | out.translate( vector(.0005,.5,.5) ); 34 | vector scale( axis.mag(), radius, radius ); 35 | out.scale( scale * (.999 / std::max(scale.x, scale.y*2)) ); 36 | 37 | // Undo the rotation inside quadric::render_cylinder() and ::render_disk(): 38 | out = out * rotation( +.5*M_PI, vector(0,1,0) ); // xxx performance 39 | } 40 | 41 | } // !namespace cvisual 42 | -------------------------------------------------------------------------------- /src/core/ellipsoid.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2000, 2001, 2002, 2003 by David Scherer and others. 2 | // Copyright (c) 2003, 2004 by Jonathan Brandmeyer and others. 3 | // See the file license.txt for complete license terms. 4 | // See the file authors.txt for a complete list of contributors. 5 | 6 | #include "ellipsoid.hpp" 7 | 8 | namespace cvisual { 9 | 10 | ellipsoid::ellipsoid() 11 | : height(1.0), width(1.0) 12 | { 13 | } 14 | 15 | void 16 | ellipsoid::set_length( double l) 17 | { 18 | if (l < 0) 19 | throw std::runtime_error( "length cannot be negative"); 20 | axis = axis.norm() * l; 21 | } 22 | 23 | double 24 | ellipsoid::get_length() 25 | { 26 | return axis.mag(); 27 | } 28 | 29 | void 30 | ellipsoid::set_height( double h) 31 | { 32 | if (h < 0) 33 | throw std::runtime_error( "height cannot be negative"); 34 | height = h; 35 | } 36 | 37 | double 38 | ellipsoid::get_height() 39 | { 40 | return height; 41 | } 42 | 43 | void 44 | ellipsoid::set_width( double w) 45 | { 46 | if (w < 0) 47 | throw std::runtime_error( "width cannot be negative"); 48 | width = w; 49 | } 50 | 51 | double 52 | ellipsoid::get_width() 53 | { 54 | return width; 55 | } 56 | 57 | vector 58 | ellipsoid::get_size() 59 | { 60 | return vector(axis.mag(), height, width); 61 | } 62 | 63 | void 64 | ellipsoid::set_size( const vector& s) 65 | { 66 | if (s.x < 0) 67 | throw std::runtime_error( "length cannot be negative"); 68 | if (s.y < 0) 69 | throw std::runtime_error( "height cannot be negative"); 70 | if (s.z < 0) 71 | throw std::runtime_error( "width cannot be negative"); 72 | axis = axis.norm() * s.x; 73 | height = s.y; 74 | width = s.z; 75 | } 76 | 77 | vector 78 | ellipsoid::get_scale() 79 | { 80 | return vector( axis.mag(), height, width)*0.5; 81 | } 82 | 83 | bool 84 | ellipsoid::degenerate() 85 | { 86 | return !visible || height == 0.0 || width == 0.0 || axis.mag() == 0.0; 87 | } 88 | 89 | void 90 | ellipsoid::grow_extent( extent& world) 91 | { 92 | if (degenerate()) 93 | return; 94 | //world.add_sphere( pos, std::max( width, std::max( height, axis.mag()))); 95 | // TODO: not accurate (overestimates extent) 96 | vector s = vector(axis.mag(),height,width)*0.5; 97 | world.add_box( model_world_transform(1.0), -s, s ); 98 | 99 | world.add_body(); 100 | } 101 | 102 | PRIMITIVE_TYPEINFO_IMPL(ellipsoid) 103 | 104 | } // !namespace cvisual 105 | -------------------------------------------------------------------------------- /src/core/light.cpp: -------------------------------------------------------------------------------- 1 | #include "light.hpp" 2 | 3 | namespace cvisual { 4 | 5 | void light::render_lights( view& v ) { 6 | ++v.light_count[0]; 7 | 8 | vertex p = get_vertex( v.gcf ); 9 | for(int d=0; d<4; d++) v.light_pos.push_back(p[d]); 10 | for(int d=0; d<3; d++) v.light_color.push_back(color[d]); 11 | v.light_color.push_back( 1.0 ); 12 | } 13 | 14 | } // namespace cvisual 15 | -------------------------------------------------------------------------------- /src/core/material.cpp: -------------------------------------------------------------------------------- 1 | #include "material.hpp" 2 | 3 | namespace cvisual { 4 | 5 | material::material() : translucent(false) {} 6 | 7 | void 8 | material::set_textures( std::vector< boost::shared_ptr< texture > > tex ) { 9 | textures = tex; 10 | } 11 | 12 | std::vector< boost::shared_ptr< texture > > 13 | material::get_textures() { 14 | return textures; 15 | } 16 | 17 | void 18 | material::set_shader( const std::string& source ) { 19 | if (source.size()) 20 | shader.reset( new shader_program( source ) ); 21 | else 22 | shader.reset( NULL ); 23 | } 24 | 25 | std::string 26 | material::get_shader() { 27 | if (shader) 28 | return shader->get_source(); 29 | else 30 | return std::string(); 31 | } 32 | 33 | bool 34 | material::get_translucent() { 35 | return translucent; 36 | } 37 | 38 | void 39 | material::set_translucent( bool t ) { 40 | translucent = t; 41 | } 42 | 43 | apply_material::apply_material( const view& v, material* m, tmatrix& model_material ) 44 | : v(v), sp( v, m ? m->shader.get() : NULL ) 45 | { 46 | if (!m || !sp.ok()) return; 47 | char texa[] = "tex0"; 48 | for(size_t t=0; ttextures.size(); t++) { 49 | if (t && v.glext.ARB_multitexture) 50 | v.glext.glActiveTexture(GL_TEXTURE0 + t); 51 | m->textures[t]->gl_activate(v); 52 | 53 | if (m->shader && v.glext.ARB_shader_objects) { 54 | texa[3] = '0'+t; 55 | v.glext.glUniform1iARB( m->shader->get_uniform_location( v, texa ), t ); 56 | } 57 | if (!v.glext.ARB_multitexture) break; 58 | } 59 | 60 | // For compatibility, set the texture unit back 61 | if (m->textures.size() > 1 && v.glext.ARB_multitexture) 62 | v.glext.glActiveTexture(GL_TEXTURE0); 63 | 64 | int loc; 65 | if ( (loc = m->shader->get_uniform_location( v, "model_material" )) >= 0 ) { 66 | m->shader->set_uniform_matrix( v, loc, model_material ); 67 | } 68 | if ( (loc = m->shader->get_uniform_location( v, "light_count" )) >= 0 ) 69 | v.glext.glUniform1iARB( loc, v.light_count[0] ); 70 | 71 | if ( (loc = m->shader->get_uniform_location( v, "light_pos" )) >= 0 && v.light_count[0]) 72 | v.glext.glUniform4fvARB( loc, v.light_count[0], &v.light_pos[0] ); 73 | 74 | if ( (loc = m->shader->get_uniform_location( v, "light_color" )) >= 0 && v.light_count[0] ) 75 | v.glext.glUniform4fvARB( loc, v.light_count[0], &v.light_color[0] ); 76 | } 77 | 78 | apply_material::~apply_material() { 79 | } 80 | 81 | } // namespace cvisual 82 | -------------------------------------------------------------------------------- /src/core/rectangular.cpp: -------------------------------------------------------------------------------- 1 | #include "rectangular.hpp" 2 | 3 | namespace cvisual { 4 | 5 | rectangular::rectangular() 6 | : width(1.0), height(1.0) 7 | { 8 | } 9 | 10 | rectangular::rectangular( const rectangular& other) 11 | : primitive( other), width( other.width), height( other.height) 12 | { 13 | } 14 | 15 | rectangular::~rectangular() 16 | { 17 | } 18 | 19 | void 20 | rectangular::set_length( double l) 21 | { 22 | if (l < 0) 23 | throw std::runtime_error( "length cannot be negative"); 24 | axis = axis.norm() * l; 25 | } 26 | 27 | double 28 | rectangular::get_length() 29 | { 30 | return axis.mag(); 31 | } 32 | 33 | void 34 | rectangular::set_height( double h) 35 | { 36 | if (h < 0) 37 | throw std::runtime_error( "height cannot be negative"); 38 | height = h; 39 | } 40 | 41 | double 42 | rectangular::get_height() 43 | { 44 | return height; 45 | } 46 | 47 | void 48 | rectangular::set_width( double w) 49 | { 50 | if (w < 0) 51 | throw std::runtime_error( "width cannot be negative"); 52 | width = w; 53 | } 54 | 55 | double 56 | rectangular::get_width() 57 | { 58 | return width; 59 | } 60 | 61 | vector 62 | rectangular::get_size() 63 | { 64 | return vector(axis.mag(), height, width); 65 | } 66 | 67 | void 68 | rectangular::set_size( const vector& s) 69 | { 70 | if (s.x < 0) 71 | throw std::runtime_error( "length cannot be negative"); 72 | if (s.y < 0) 73 | throw std::runtime_error( "height cannot be negative"); 74 | if (s.z < 0) 75 | throw std::runtime_error( "width cannot be negative"); 76 | axis = axis.norm() * s.x; 77 | height = s.y; 78 | width = s.z; 79 | } 80 | 81 | void 82 | rectangular::apply_transform( const view& scene ) 83 | { 84 | // OpenGL needs to invert the modelview matrix to generate the normal matrix, 85 | // so try not to make it singular: 86 | double min_scale = std::max( axis.mag(), std::max(height,width) ) * 1e-6; 87 | vector size( std::max(min_scale,axis.mag()), 88 | std::max(min_scale,height), 89 | std::max(min_scale,width) ); 90 | 91 | model_world_transform( scene.gcf, size ).gl_mult(); 92 | } 93 | 94 | } // !namespace cvisual 95 | -------------------------------------------------------------------------------- /src/core/util/atomic_queue.cpp: -------------------------------------------------------------------------------- 1 | #include "util/atomic_queue.hpp" 2 | 3 | #include 4 | #include 5 | #include "util/errors.hpp" 6 | 7 | namespace cvisual { 8 | 9 | void 10 | atomic_queue_impl::push_notify() 11 | { 12 | empty = false; 13 | } 14 | 15 | } // !namespace cvisual 16 | -------------------------------------------------------------------------------- /src/core/util/displaylist.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 2 | // See the file license.txt for complete license terms. 3 | // See the file authors.txt for a complete list of contributors. 4 | 5 | #include "util/displaylist.hpp" 6 | #include "util/gl_free.hpp" 7 | #include "util/errors.hpp" 8 | #include "wrap_gl.hpp" 9 | #include 10 | #include 11 | #include 12 | using boost::lexical_cast; 13 | 14 | namespace cvisual { 15 | 16 | class displaylist_impl : boost::noncopyable { 17 | private: 18 | unsigned int handle; 19 | 20 | static void gl_free(unsigned int handle) { 21 | glDeleteLists( handle, 1 ); 22 | } 23 | 24 | public: 25 | displaylist_impl() { 26 | handle = glGenLists(1); 27 | on_gl_free.connect( boost::bind(&displaylist_impl::gl_free, handle) ); 28 | glNewList( handle, GL_COMPILE ); 29 | } 30 | ~displaylist_impl() { 31 | compile_end(); 32 | on_gl_free.free( boost::bind(&displaylist_impl::gl_free, handle) ); 33 | } 34 | 35 | void compile_end() { 36 | glEndList(); 37 | } 38 | 39 | void call() { 40 | glCallList( handle ); 41 | } 42 | 43 | //operator bool() { return handle && built; } 44 | }; 45 | 46 | // sphere.cpp, pyramid.cpp 47 | 48 | displaylist::displaylist() : built(false) {} 49 | 50 | void 51 | displaylist::gl_compile_begin() 52 | { 53 | impl.reset( new displaylist_impl ); 54 | } 55 | 56 | void 57 | displaylist::gl_compile_end() 58 | { 59 | impl->compile_end(); 60 | built = true; 61 | } 62 | 63 | void 64 | displaylist::gl_render() const 65 | { 66 | impl->call(); 67 | } 68 | 69 | //displaylist::operator bool() const { 70 | bool 71 | displaylist::compiled() { 72 | return built; 73 | } 74 | 75 | } // !namespace cvisual 76 | -------------------------------------------------------------------------------- /src/core/util/gl_extensions.cpp: -------------------------------------------------------------------------------- 1 | #include "util/gl_extensions.hpp" 2 | #include "display_kernel.hpp" 3 | 4 | namespace cvisual { 5 | 6 | template 7 | void getPFN( PFN& func, display_kernel& d, const char* name ) { 8 | func = reinterpret_cast( d.getProcAddress( name ) ); 9 | if (!func) 10 | throw std::runtime_error( 11 | ("Unable to get extension function: " + 12 | (std::string)name + " even though the extension is advertised.").c_str() ); 13 | } 14 | 15 | gl_extensions::gl_extensions() { 16 | memset( this, 0, sizeof(this) ); 17 | } 18 | 19 | void gl_extensions::init( display_kernel& d ) { 20 | #define F( name ) getPFN( name, d, #name ) 21 | 22 | if ( ARB_shader_objects = d.hasExtension( "GL_ARB_shader_objects" ) ) { 23 | F( glCreateProgramObjectARB ); 24 | F( glLinkProgramARB ); 25 | F( glUseProgramObjectARB ); 26 | F( glCreateShaderObjectARB ); 27 | F( glShaderSourceARB ); 28 | F( glCompileShaderARB ); 29 | F( glAttachObjectARB ); 30 | F( glDeleteObjectARB ); 31 | F( glGetHandleARB ); 32 | F( glUniform1iARB ); 33 | F( glUniformMatrix4fvARB ); 34 | F( glUniform4fvARB ); 35 | F( glGetUniformLocationARB ); 36 | F( glGetObjectParameterivARB ); 37 | F( glGetInfoLogARB ); 38 | } 39 | 40 | if ( EXT_texture3D = d.hasExtension( "GL_EXT_texture3D" ) ) { 41 | F( glTexImage3D ); 42 | F( glTexSubImage3D ); 43 | } 44 | 45 | if ( ARB_multitexture = d.hasExtension( "GL_ARB_multitexture" ) ) { 46 | F( glActiveTexture ); 47 | } 48 | 49 | if ( ARB_point_parameters = d.hasExtension( "GL_ARB_point_parameters" ) ) { 50 | F( glPointParameterfvARB ); 51 | } 52 | } 53 | 54 | } // namespace cvisual 55 | -------------------------------------------------------------------------------- /src/core/util/gl_free.cpp: -------------------------------------------------------------------------------- 1 | #include "util/gl_free.hpp" 2 | 3 | namespace cvisual { 4 | 5 | gl_free_manager on_gl_free; 6 | 7 | boost::signal< void() >& gl_free_manager::on_shutdown() { 8 | static boost::signal< void() >* i = new boost::signal< void() >; 9 | return *i; 10 | } 11 | 12 | boost::signal< void() >& gl_free_manager::on_next_frame() { 13 | static boost::signal< void() >* i = new boost::signal< void() >; 14 | return *i; 15 | } 16 | 17 | void 18 | gl_free_manager::frame() { 19 | on_next_frame()(); 20 | on_next_frame().disconnect_all_slots(); 21 | } 22 | 23 | void 24 | gl_free_manager::shutdown() { 25 | on_next_frame()(); 26 | on_next_frame().disconnect_all_slots(); 27 | on_shutdown()(); 28 | on_shutdown().disconnect_all_slots(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/core/util/quadric.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 2 | // See the file license.txt for complete license terms. 3 | // See the file authors.txt for a complete list of contributors. 4 | 5 | #include "wrap_gl.hpp" 6 | #include "util/quadric.hpp" 7 | #include "util/tmatrix.hpp" 8 | 9 | namespace cvisual { 10 | 11 | quadric::quadric() 12 | : q(0) 13 | { 14 | q = gluNewQuadric(); 15 | gluQuadricDrawStyle( q, GLU_FILL); 16 | gluQuadricNormals( q, GLU_SMOOTH); 17 | gluQuadricOrientation( q, GLU_OUTSIDE); 18 | } 19 | 20 | quadric::~quadric() 21 | { 22 | gluDeleteQuadric( q); 23 | } 24 | 25 | void 26 | quadric::set_draw_style( drawing_style style) 27 | { 28 | switch (style) { 29 | case POINT: 30 | gluQuadricDrawStyle( q, GLU_POINT); 31 | break; 32 | case LINE: 33 | gluQuadricDrawStyle( q, GLU_LINE); 34 | break; 35 | case FILL: 36 | gluQuadricDrawStyle( q, GLU_FILL); 37 | break; 38 | case SILHOUETTE: 39 | gluQuadricDrawStyle( q, GLU_SILHOUETTE); 40 | break; 41 | } 42 | } 43 | 44 | void 45 | quadric::set_normal_style( normal_style style) 46 | { 47 | switch (style) { 48 | case NONE: 49 | gluQuadricNormals( q, GLU_NONE); 50 | break; 51 | case FLAT: 52 | gluQuadricNormals( q, GLU_FLAT); 53 | break; 54 | case SMOOTH: 55 | gluQuadricNormals( q, GLU_SMOOTH); 56 | break; 57 | } 58 | } 59 | 60 | void 61 | quadric::set_orientation( orientation side) 62 | { 63 | if (side == OUTSIDE) 64 | gluQuadricOrientation( q, GLU_OUTSIDE); 65 | else 66 | gluQuadricOrientation( q, GLU_INSIDE); 67 | } 68 | 69 | void 70 | quadric::render_sphere( double radius, int slices, int stacks) 71 | { 72 | gluSphere( q, radius, slices, stacks); 73 | } 74 | 75 | void 76 | quadric::render_cylinder( double base_radius, double top_radius, double height, 77 | int slices, int stacks) 78 | { 79 | // GLU orients cylinders along the +z axis, and they must be 80 | // reoriented along the +x axis for VPython's convention of rendering along 81 | // the "axis" vector. 82 | gl_matrix_stackguard guard; 83 | glRotatef( 90, 0, 1, 0); 84 | gluCylinder( q, base_radius, top_radius, height, slices, stacks); 85 | } 86 | 87 | void 88 | quadric::render_cylinder( double radius, double height, int slices, int stacks) 89 | { 90 | gl_matrix_stackguard guard; 91 | glRotatef( 90, 0, 1, 0); 92 | gluCylinder( q, radius, radius, height, slices, stacks); 93 | } 94 | 95 | void 96 | quadric::render_disk( double radius, int slices, int rings, GLfloat rotation) 97 | { 98 | gl_matrix_stackguard guard; 99 | glRotatef( 90, 0, rotation, 0); 100 | gluDisk( q, 0.0, radius, slices, rings); 101 | } 102 | 103 | } // !namespace cvisual 104 | -------------------------------------------------------------------------------- /src/core/util/texture.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 2 | // See the file license.txt for complete license terms. 3 | // See the file authors.txt for a complete list of contributors. 4 | 5 | #include "wrap_gl.hpp" 6 | #include "util/texture.hpp" 7 | #include "util/errors.hpp" 8 | #include 9 | #include 10 | using boost::lexical_cast; 11 | 12 | namespace cvisual { 13 | 14 | texture::texture() 15 | : damaged(false), handle(0), have_opacity(false) 16 | { 17 | } 18 | 19 | texture::~texture() 20 | { 21 | if (handle) on_gl_free.free( boost::bind( &gl_free, handle ) ); 22 | } 23 | 24 | #if 0 25 | texture::operator bool() const 26 | { 27 | return handle != 0; 28 | } 29 | #endif 30 | 31 | int 32 | texture::enable_type() const { 33 | return GL_TEXTURE_2D; 34 | } 35 | 36 | void 37 | texture::gl_activate(const view& v) 38 | { 39 | damage_check(); 40 | if (damaged) { 41 | gl_init(v); 42 | damaged = false; 43 | check_gl_error(); 44 | } 45 | if (!handle) return; 46 | 47 | glBindTexture( enable_type(), handle ); 48 | this->gl_transform(); 49 | check_gl_error(); 50 | } 51 | 52 | bool 53 | texture::has_opacity() const 54 | { 55 | return have_opacity; 56 | } 57 | 58 | void 59 | texture::set_handle( const view&, unsigned h ) { 60 | if (handle) on_gl_free.free( boost::bind( &gl_free, handle ) ); 61 | 62 | handle = h; 63 | on_gl_free.connect( boost::bind(&texture::gl_free, handle) ); 64 | VPYTHON_NOTE( "Allocated texture number " + lexical_cast(handle)); 65 | } 66 | 67 | void 68 | texture::gl_free(GLuint handle) 69 | { 70 | VPYTHON_NOTE( "Deleting texture number " + lexical_cast(handle)); 71 | glDeleteTextures(1, &handle); 72 | } 73 | 74 | void 75 | texture::gl_transform() 76 | { 77 | } 78 | 79 | void 80 | texture::damage_check() 81 | { 82 | } 83 | 84 | void 85 | texture::damage() 86 | { 87 | damaged = true; 88 | } 89 | 90 | size_t 91 | next_power_of_two(size_t arg) 92 | { 93 | size_t ret = 2; 94 | // upper bound of 28 chosen to limit memory growth to about 256MB, which is 95 | // _much_ larger than most supported textures 96 | while (ret < arg && ret < (1 << 28)) 97 | ret <<= 1; 98 | return ret; 99 | } 100 | 101 | } // !namespace cvisual 102 | -------------------------------------------------------------------------------- /src/gtk2/apt-get-packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Helper script to grab all the packages vpython needs Run as root. 4 | # 5 | apt-get -q -y update 6 | apt-get -q -y install git 7 | apt-get -q -y install libgtk2.0-dev 8 | apt-get -q -y install libgtkglextmm-x11-1.2-dev 9 | apt-get -q -y install libgtkmm-2.4-dev 10 | apt-get -q -y install python-dev 11 | apt-get -q -y install python-setuptools 12 | apt-get -q -y install python-numpy 13 | apt-get -q -y install libboost-python-dev 14 | apt-get -q -y install libboost-signals-dev 15 | apt-get -q -y install libghc-gstreamer-dev 16 | apt-get -q -y install python-tk 17 | 18 | -------------------------------------------------------------------------------- /src/gtk2/get_proc_address.cpp: -------------------------------------------------------------------------------- 1 | #include "display_kernel.hpp" 2 | #include 3 | 4 | // Linux version of getProcAddress() 5 | 6 | namespace cvisual { 7 | 8 | display_kernel::EXTENSION_FUNCTION 9 | display_kernel::getProcAddress(const char* name) { 10 | return (EXTENSION_FUNCTION)glXGetProcAddress((const GLubyte *)name); 11 | } 12 | 13 | } // namespace cvisual 14 | -------------------------------------------------------------------------------- /src/gtk2/site-packages.pth: -------------------------------------------------------------------------------- 1 | /usr/local/lib/python2.6/site-packages 2 | -------------------------------------------------------------------------------- /src/mac/PackageMaker/.gitignore: -------------------------------------------------------------------------------- 1 | *.pmdoc 2 | VisualPythonInstaller 3 | *.app 4 | *.dmg 5 | -------------------------------------------------------------------------------- /src/mac/PackageMaker/CVS/Entries: -------------------------------------------------------------------------------- 1 | /VIDLE_launcher.zip/1.2/Mon Aug 16 19:24:56 2010/-kb/ 2 | D/VPython-Python2.6.pmdoc//// 3 | /VPython-Python2.6.zip/1.1/Mon Mar 14 17:23:40 2011/-kb/ 4 | D/VPython-Python2.7.pmdoc//// 5 | /VPython-Python2.7.zip/1.1/Mon Mar 14 17:23:40 2011/-kb/ 6 | D/VPython-Python3.1.pmdoc//// 7 | /VPython-Python3.1.zip/1.1/Mon Mar 14 17:23:40 2011/-kb/ 8 | D/VPython4.0betaPM.pmdoc//// 9 | /Visual5_Python2.6_welcome.rtf/1.1/Thu Dec 2 03:51:58 2010// 10 | /Visual5_Python3.1_welcome.rtf/1.1/Tue Oct 26 21:13:39 2010// 11 | /Visual5_welcome.rtf/1.2/Tue Aug 17 04:04:18 2010// 12 | /packaging.txt/1.14/Thu Dec 2 03:51:58 2010// 13 | -------------------------------------------------------------------------------- /src/mac/PackageMaker/CVS/Repository: -------------------------------------------------------------------------------- 1 | vpython-core2/src/mac/PackageMaker 2 | -------------------------------------------------------------------------------- /src/mac/PackageMaker/CVS/Root: -------------------------------------------------------------------------------- 1 | :extssh:bsherwood@visualpython.cvs.sourceforge.net:/cvsroot/visualpython 2 | -------------------------------------------------------------------------------- /src/mac/PackageMaker/InstallReadme.txt: -------------------------------------------------------------------------------- 1 | Mac Visual Python Installer 2 | =========================== 3 | 4 | Please find enclused the Visual Python .pkg installer and a very simple 5 | uninstall script. The intro to the .pkg installer reads: 6 | 7 | -------------------------------------------------------------------------------- 8 | 9 | The Python.org “Python 2.7” distribution must first be installed from python.org 10 | before installing this Python module. This installer installs everything you need 11 | (except for Python itself) to edit and run vpython programs on MacOS X. In 12 | addition to the visual module (6.11), this installer installs numpy-1.9.1, 13 | wxPython-3.0.2, TTFQuery-1.05, Polygon-2.07 and FontTools-2.4. 14 | 15 | -------------------------------------------------------------------------------- 16 | 17 | If you've used an earlier version of the VPython-6 installer and wish to 18 | uninstall before installing the new version (not strictly necessary, but 19 | tidier) you can use the included script: 20 | 21 | $ sudo sh -v vpy_uninstall.sh 22 | 23 | Or you can try the "vpy_uninstall.app" which is a simple Automator 24 | wrapper around the shell script. Note that "vpy_uninstall.app" will 25 | only work if the .dmg is mounted since it simply calls the script 26 | that's located on the .dmg! 27 | -------------------------------------------------------------------------------- /src/mac/PackageMaker/MacVIDLE-launchers.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/src/mac/PackageMaker/MacVIDLE-launchers.zip -------------------------------------------------------------------------------- /src/mac/PackageMaker/VPY-6-py27.pmdoc.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/src/mac/PackageMaker/VPY-6-py27.pmdoc.zip -------------------------------------------------------------------------------- /src/mac/PackageMaker/Visual5_Python2.6_welcome.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350 2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;} 3 | {\colortbl;\red255\green255\blue255;} 4 | \margl1440\margr1440\vieww9000\viewh8400\viewkind0 5 | \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural 6 | 7 | \f0\fs24 \cf0 Python 2.6 must first be installed from python.org before installing this Python module. This installer also installs numpy, the numeric array module for Python, which is required for Visual. This installer also installs the modules Polygon, ttfquery, and FontTools.} -------------------------------------------------------------------------------- /src/mac/PackageMaker/Visual5_Python3.1_welcome.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320 2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;} 3 | {\colortbl;\red255\green255\blue255;} 4 | \margl1440\margr1440\vieww9000\viewh8400\viewkind0 5 | \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural 6 | 7 | \f0\fs24 \cf0 Python 3.1 must first be installed from python.org before installing this Python module. This installer also installs numpy, the numeric array module for Python, which is required for Visual. This installer also installs the modules Polygon, ttfquery, and FontTools.} -------------------------------------------------------------------------------- /src/mac/PackageMaker/Visual5_welcome.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320 2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;} 3 | {\colortbl;\red255\green255\blue255;} 4 | \margl1440\margr1440\vieww9000\viewh8400\viewkind0 5 | \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural 6 | 7 | \f0\fs24 \cf0 Python 2.7 must first be installed from python.org before installing this Python module. This installer also installs numpy, the numeric array module for Python, which is required for Visual. This installer also installs the modules Polygon, ttfquery, and FontTools.} -------------------------------------------------------------------------------- /src/mac/PackageMaker/Visual6_welcome.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf1343\cocoasubrtf160 2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\froman\fcharset0 TimesNewRomanPSMT;} 3 | {\colortbl;\red255\green255\blue255;} 4 | \margl1440\margr1440\vieww12840\viewh16440\viewkind1\viewscale114 5 | \deftab720 6 | \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ri0 7 | 8 | \f0\fs24 \cf0 The Python.org \'93Python 2.7\'94 distribution must first be installed from python.org before installing this Python module. This installer installs everything you need (except for Python itself) to edit and run vpython programs on MacOS X. In addition to the visual module (6.11), this installer installs numpy-1.9.1, wxPython-3.0.0, TTFQuery-1.05, Polygon-2.07 and FontTools-2.4. 9 | \f1\fs22 \ 10 | } -------------------------------------------------------------------------------- /src/mac/PackageMaker/buildPackage.py: -------------------------------------------------------------------------------- 1 | """ 2 | script to actually build the package. 3 | 4 | if the command line argument is 'pkg' then Uses the command line PackageMaker and the 5 | pmdoc file to construct the package... 6 | 7 | if the command line argument is 'dmg' then use the hdutil program to create a .dmg 8 | 9 | manual step to sign for now: 10 | 11 | productsign --sign "Developer ID Installer: Silicon Prairie Ventures Inc" src/mac/PackageMaker/VisualPythonInstaller/VPython-Mac-Py2.7-6.11.pkg ~/outpath/VPython-Mac-Py2.7-6.11.pkg 12 | 13 | """ 14 | 15 | import os 16 | import sys 17 | import subprocess 18 | 19 | cwd = os.getcwd() 20 | dir_part = os.path.split(cwd)[1] 21 | 22 | if dir_part != 'vpython-wx': 23 | print("Please run this script from the vpython-wx directory, now in:" + os.getcwd()) 24 | sys.exit(1) 25 | 26 | import imp 27 | setup = imp.load_source('setup',os.path.join(cwd,'setup.py')) 28 | VERSION = setup.VERSION 29 | HOME_DIR=os.path.expanduser("~") 30 | PKG_MAKER_DIR="src/mac/PackageMaker" 31 | PKG_MAKER="/Applications/PackageMaker.app/Contents/MacOS/PackageMaker" 32 | PM_DOC=os.path.join(PKG_MAKER_DIR,'VPY-6-py27.pmdoc') 33 | PKG_DIR=os.path.join(PKG_MAKER_DIR,'VisualPythonInstaller') 34 | PKG_OUT=os.path.join(PKG_DIR,'VPython-Mac-Py2.7-' + VERSION + '.pkg') 35 | DMG_OUT=os.path.join(PKG_MAKER_DIR,'VPython-Mac-Py2.7-' + VERSION + '.dmg') 36 | 37 | if len(sys.argv)>1 and sys.argv[1]=='pkg': 38 | 39 | if not os.path.exists(PKG_DIR): 40 | os.makedirs(PKG_DIR) 41 | 42 | if os.path.exists(PKG_OUT): 43 | print "deleting old package" 44 | os.remove(PKG_OUT) 45 | 46 | cmdList = [PKG_MAKER,'--verbose','--doc',PM_DOC,'--out',PKG_OUT] 47 | print "Executing:", cmdList 48 | subprocess.call(cmdList) 49 | 50 | elif len(sys.argv)>1 and sys.argv[1]=='dmg': 51 | 52 | if os.path.exists(DMG_OUT): 53 | print "deleting old image" 54 | os.remove(DMG_OUT) 55 | 56 | cmdList = ['hdiutil','create','-volname','VPython-Mac-Py2.7-' + VERSION,'-fs','HFS+','-srcfolder',PKG_DIR,DMG_OUT] 57 | print "Executing:", cmdList 58 | subprocess.call(cmdList) 59 | else: 60 | print "Usage:", sys.argv[0], '[ pkg , dmg ]' 61 | -------------------------------------------------------------------------------- /src/mac/PackageMaker/makeDependencyLinks.sh: -------------------------------------------------------------------------------- 1 | # 2 | # after a fresh checkout from git, use this to point dependencies back to boost 3 | # I really should change this in setup.py to point there directly. Not today! 4 | # too many other changes to make. 5 | # 6 | 7 | mkdir -p dependencies/boost_files 8 | ln -s ~/Development/boost_1_52_0/boost ./dependencies/boost_files/boost 9 | ln -s ~/Development/boost_1_52_0/stage/lib ./dependencies/boost_files/mac_libs 10 | -------------------------------------------------------------------------------- /src/mac/PackageMaker/vpy_uninstall.app.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/src/mac/PackageMaker/vpy_uninstall.app.zip -------------------------------------------------------------------------------- /src/mac/PackageMaker/vpy_uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This is an experimental uninstall tool for VPython. It will uninstall VPython 4 | # and its dependencies from the python.org python site packages and wxPython 5 | # from /usr/local/lib. Beware it will delete all versions of these libraries 6 | # so if you have multiple versions, you should do this manually. 7 | # 8 | 9 | SITE_PATH="/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages" 10 | LIB_PATH="/usr/local/lib" 11 | APP_PATH="/Applications" 12 | 13 | for pck in 'FontTools' 'TTFQuery' 'ttfquery' 'Polygon' 'numpy' 'wxredirect' 'VPython' 14 | do 15 | rm -r $SITE_PATH/$pck* 16 | done 17 | 18 | rm -r $LIB_PATH/wxPython* 19 | rm -r $APP_PATH/VIDLE-Py2.7.app 20 | -------------------------------------------------------------------------------- /src/mac/get_proc_address.cpp: -------------------------------------------------------------------------------- 1 | #include "display_kernel.hpp" 2 | // Mac version of getProcAddress() 3 | 4 | #include 5 | 6 | namespace cvisual { 7 | 8 | display_kernel::EXTENSION_FUNCTION 9 | display_kernel::getProcAddress(const char* name) { 10 | void *lib = dlopen( (const char *)0L, RTLD_LAZY | RTLD_GLOBAL ); 11 | void *sym = dlsym( lib, name ); 12 | dlclose( lib ); 13 | return (EXTENSION_FUNCTION)sym; 14 | } 15 | 16 | } // namespace cvisual 17 | -------------------------------------------------------------------------------- /src/mac/makefile: -------------------------------------------------------------------------------- 1 | # In vpython-wx/src/mac execute sudo make setup to establish links 2 | # Note however that apparently $(abspath makefile) and $(abspath ../../site-packages/visual) 3 | # are ignored on OSX 10.4, which led to some puzzled grief. It was necessary to create 4 | # a link in site-packages by hand. 5 | # Be sure to specify what version of Python 6 | 7 | PYTHON_VERSION = 3.2 8 | PYTHON_FRAMEWORK = /Library/Frameworks/Python.framework/Versions/$(PYTHON_VERSION)/ 9 | SITE_PACKAGES = $(PYTHON_FRAMEWORK)lib/python$(PYTHON_VERSION)/site-packages/ 10 | TOP = ../vpython-wx/ 11 | DEPENDS = $(TOP)/dependencies/ 12 | BOOST = $(DEPENDS)boost_files/mac_libs/ 13 | SRC = $(TOP)/src/ 14 | VPATH = $(SRC)mac $(SRC)core/util $(SRC)core $(SRC)python $(SRC) 15 | 16 | # Used to use 4.0 compiler rather than 4.2 so as to build in a way compatible with OSX 10.5 17 | # Was -arch i386 18 | CXX = /usr/bin/g++-4.2 19 | CXXFLAGS = -fPIC -MMD -DNDEBUG \ 20 | -mmacosx-version-min=10.6 \ 21 | -arch x86_64 \ 22 | -DPIC -O2 -g -finline-functions \ 23 | -I$(TOP)include/mac -I$(TOP)include \ 24 | -I$(PYTHON_FRAMEWORK)include/python$(PYTHON_VERSION) \ 25 | -I$(SITE_PACKAGES)numpy/core/include \ 26 | -I$(DEPENDS)boost_files \ 27 | -F/System/Library/Frameworks/OpenGL.framework 28 | 29 | OBJS = arrayprim.o arrow.o axial.o box.o cone.o cylinder.o display_kernel.o ellipsoid.o \ 30 | frame.o label.o light.o material.o mouse_manager.o mouseobject.o primitive.o pyramid.o \ 31 | rectangular.o renderable.o ring.o sphere.o \ 32 | atomic_queue.o displaylist.o errors.o extent.o \ 33 | gl_extensions.o gl_free.o icososphere.o quadric.o \ 34 | get_proc_address.o \ 35 | rgba.o shader_program.o texture.o tmatrix.o vector.o\ 36 | convex.o curve.o cvisualmodule.o extrusion.o faces.o \ 37 | num_util.o numeric_texture.o points.o slice.o \ 38 | wrap_arrayobjects.o wrap_display_kernel.o wrap_primitive.o \ 39 | wrap_rgba.o wrap_vector.o 40 | 41 | cvisual.so : $(OBJS) 42 | $(CXX) -mmacosx-version-min=10.6 \ 43 | -bundle -bundle_loader $(PYTHON_FRAMEWORK)bin/python$(PYTHON_VERSION) -o cvisual.so \ 44 | $(OBJS) \ 45 | $(BOOST)libboost_python.a \ 46 | $(BOOST)libboost_signals.a \ 47 | -framework Cocoa -framework OpenGL -framework Python 48 | 49 | install : cvisual.so 50 | cp cvisual.so ../vpython-wx/site-packages/visual_common 51 | # sudo cp cvisual.so /Library/Frameworks/Python.framework/Versions/$(PYTHON_VERSION)/lib/python$(PYTHON_VERSION)/site-packages/visual_common 52 | 53 | clean : 54 | rm *.o 55 | rm *.d 56 | rm *.so 57 | 58 | # This command to be run from the vpython-wx/src/mac 59 | setup : 60 | mkdir -p ../../../vpython-wx/../mbuild 61 | ln -sfh $(abspath makefile) ../../../mbuild/makefile 62 | ln -sfh $(abspath ../../site-packages/visual) $(SITE_PACKAGES)visual 63 | 64 | -include *.d 65 | -------------------------------------------------------------------------------- /src/python/slice.cpp: -------------------------------------------------------------------------------- 1 | #include "python/slice.hpp" 2 | 3 | // Copyright (c) 2004 by Jonathan Brandmeyer and others. 4 | // See the file license.txt for complete license terms. 5 | // See the file authors.txt for a complete list of contributors. 6 | using namespace boost::python; 7 | 8 | namespace cvisual { namespace python { 9 | 10 | slice::slice() 11 | : object( detail::new_reference( 12 | PySlice_New( NULL, NULL, NULL))) 13 | { 14 | } 15 | 16 | object 17 | slice::start() 18 | { 19 | return object( detail::borrowed_reference( ((PySliceObject*)this->ptr())->start)); 20 | } 21 | 22 | object 23 | slice::stop() 24 | { 25 | return object( detail::borrowed_reference( ((PySliceObject*)this->ptr())->stop)); 26 | } 27 | 28 | object 29 | slice::step() 30 | { 31 | return object( detail::borrowed_reference( ((PySliceObject*)this->ptr())->step)); 32 | } 33 | 34 | } } // !namespace cvisual::python 35 | -------------------------------------------------------------------------------- /src/win32/get_proc_address.cpp: -------------------------------------------------------------------------------- 1 | #include "display_kernel.hpp" 2 | // Windows version of getProcAddress() 3 | 4 | namespace cvisual { 5 | 6 | display_kernel::EXTENSION_FUNCTION 7 | display_kernel::getProcAddress(const char* name) { 8 | return (EXTENSION_FUNCTION)::wglGetProcAddress( name ); 9 | } 10 | 11 | } // namespace cvisual 12 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceSherwood/vpython-wx/38df062e5532b79f632f4f2a1abae86754c264a9/tests/__init__.py -------------------------------------------------------------------------------- /tests/test_installation.py: -------------------------------------------------------------------------------- 1 | from unittest import TestCase 2 | 3 | 4 | class ImportsTestCase(TestCase): 5 | 6 | def test_import_vidle(self): 7 | import vidle 8 | 9 | def test_import_vis(self): 10 | import vis 11 | 12 | def test_import_visual(self): 13 | import visual 14 | 15 | def test_import_visual_common(self): 16 | import visual_common 17 | -------------------------------------------------------------------------------- /wxPython-src-2.9.5.0.patch: -------------------------------------------------------------------------------- 1 | --- wxPython-src-2.9.5.0/wxPython/src/gtk/html2_wrap.cpp 2013-05-18 12:47:49.000000000 -0600 2 | +++ wxPython-src-2.9.5.0-patch/wxPython/src/gtk/html2_wrap.cpp 2013-09-11 11:13:06.179333082 -0600 3 | @@ -2683,7 +2683,7 @@ 4 | #include 5 | #include 6 | 7 | - 8 | +class wxWebView; 9 | 10 | enum wxWebViewZoom 11 | { 12 | @@ -2784,12 +2784,12 @@ 13 | class wxWebView : public wxControl 14 | { 15 | public: 16 | - virtual bool Create(wxWindow*, wxWindowID, const wxString&, const wxPoint&, 17 | - const wxSize&, long style, const wxString&) { _RaiseError(); return false; } 18 | - static wxWebView* New(wxWebViewBackend) { _RaiseError(); return NULL; } 19 | - static wxWebView* New(wxWindow*, wxWindowID, const wxString&, const wxPoint& , 20 | - const wxSize& , const wxString&, long style, 21 | - const wxString&) { _RaiseError(); return NULL; } 22 | + virtual bool Create(wxWindow* parent, wxWindowID id, const wxString& url, const wxPoint& pos, 23 | + const wxSize& size, long style, const wxString& name) { _RaiseError(); return false; } 24 | + static wxWebView* New(const wxString& backend) { _RaiseError(); return NULL; } 25 | + static wxWebView* New(wxWindow* parent, wxWindowID id, const wxString& url, const wxPoint& pos, 26 | + const wxSize& size, const wxString& backend, long style, 27 | + const wxString& name) { _RaiseError(); return NULL; } 28 | 29 | virtual wxString GetCurrentTitle() const { return wxEmptyString; } 30 | virtual wxString GetCurrentURL() const { return wxEmptyString; } 31 | 32 | 33 | --- wxPython-src-2.9.5.0/wxPython/setup.py 2013-02-27 13:14:01.000000000 -0700 34 | +++ wxPython-src-2.9.5.0-patch/wxPython/setup.py 2013-09-11 09:54:08.882270829 -0600 35 | @@ -946,6 +946,7 @@ 36 | DATA_FILES += find_data_files('wx/tools/Editra/tests/syntax', '*') 37 | DATA_FILES += find_data_files('wx/tools/Editra', '[A-Z]*', recursive=False) 38 | 39 | +DATA_FILES += ["src/wx.pth"] 40 | 41 | ## import pprint 42 | ## pprint.pprint(DATA_FILES) 43 | --------------------------------------------------------------------------------