diff --git a/.travis.yml b/.travis.yml
index e58c8fee13..d59f4398dd 100755
--- a/.travis.yml
+++ b/.travis.yml
@@ -102,19 +102,19 @@ jobs:
- CMAKE_ARGS="-DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/cc"
- CACHE_NAME=JOB3
- - os: osx
- osx_image: xcode11.6
- language: cpp
- cache:
- - ccache: true
- - directories:
- - $HOME/.ccache
- - $HOME/Library/Caches/Homebrew
- - /usr/local/Homebrew
- env:
- - CMAKE_OPTS="-DBUILD_QT5=ON -DBUILD_ENABLE_CXX_STD='C++17' -DUSE_PYTHON3=1 -DCMAKE_CXX_FLAGS='-Wno-deprecated-declarations' -DBUILD_FEM_NETGEN=1 -DBUILD_FEM=1 -DBUILD_TECHDRAW=0 -DCMAKE_PREFIX_PATH='/usr/local/opt/qt/lib/cmake;/usr/local/opt/nglib/Contents/Resources' -DBUILD_FEM_NETGEN:BOOL=ON -DFREECAD_USE_EXTERNAL_KDL=ON -DCMAKE_BUILD_TYPE=Release"
- - PATH=/usr/local/bin:$PATH
- - CACHE_NAME=OSX1
+ # - os: osx
+ # osx_image: xcode11.6
+ # language: cpp
+ # cache:
+ # - ccache: true
+ # - directories:
+ # - $HOME/.ccache
+ # - $HOME/Library/Caches/Homebrew
+ # - /usr/local/Homebrew
+ # env:
+ # - CMAKE_OPTS="-DBUILD_QT5=ON -DBUILD_ENABLE_CXX_STD='C++17' -DUSE_PYTHON3=1 -DCMAKE_CXX_FLAGS='-Wno-deprecated-declarations' -DBUILD_FEM_NETGEN=1 -DBUILD_FEM=1 -DBUILD_TECHDRAW=0 -DCMAKE_PREFIX_PATH='/usr/local/opt/qt/lib/cmake;/usr/local/opt/nglib/Contents/Resources' -DBUILD_FEM_NETGEN:BOOL=ON -DFREECAD_USE_EXTERNAL_KDL=ON -DCMAKE_BUILD_TYPE=Release"
+ # - PATH=/usr/local/bin:$PATH
+ # - CACHE_NAME=OSX1
- os: windows
language: cpp
diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp
index 0f24076cb5..ea4c6a76d9 100644
--- a/src/Gui/Application.cpp
+++ b/src/Gui/Application.cpp
@@ -1923,6 +1923,15 @@ void Application::runApplication(void)
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
+ // Use software rendering for OpenGL
+#if QT_VERSION >= 0x050400
+ ParameterGrp::handle hOpenGL = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/OpenGL");
+ bool useSoftwareOpenGL = hOpenGL->GetBool("UseSoftwareOpenGL", false);
+ if (useSoftwareOpenGL) {
+ QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
+ }
+#endif // QT_VERSION >= 0x050400
+
// A new QApplication
Base::Console().Log("Init: Creating Gui::Application and QApplication\n");
diff --git a/src/Gui/DlgSettings3DView.ui b/src/Gui/DlgSettings3DView.ui
index 65cc2d9fe6..9df215caba 100644
--- a/src/Gui/DlgSettings3DView.ui
+++ b/src/Gui/DlgSettings3DView.ui
@@ -108,6 +108,24 @@ will be shown at the lower left corner in opened files
Rendering
+ -
+
+
+ This option is useful for troubleshooting graphics card and driver problems.
+
+Changing this option requires a restart of the application.
+
+
+ Use software OpenGL
+
+
+ UseSoftwareOpenGL
+
+
+ OpenGL
+
+
+
-
diff --git a/src/Gui/DlgSettings3DViewImp.cpp b/src/Gui/DlgSettings3DViewImp.cpp
index 134aae1336..b1fe1d71aa 100644
--- a/src/Gui/DlgSettings3DViewImp.cpp
+++ b/src/Gui/DlgSettings3DViewImp.cpp
@@ -93,6 +93,7 @@ void DlgSettings3DViewImp::saveSettings()
ui->CheckBox_WbByTab->onSave();
ui->CheckBox_ShowFPS->onSave();
ui->spinPickRadius->onSave();
+ ui->CheckBox_use_SW_OpenGL->onSave();
ui->CheckBox_useVBO->onSave();
ui->FloatSpinBox_EyeDistance->onSave();
ui->checkBoxBacklight->onSave();
@@ -109,6 +110,7 @@ void DlgSettings3DViewImp::loadSettings()
ui->CheckBox_WbByTab->onRestore();
ui->CheckBox_ShowFPS->onRestore();
ui->spinPickRadius->onRestore();
+ ui->CheckBox_use_SW_OpenGL->onRestore();
ui->CheckBox_useVBO->onRestore();
ui->FloatSpinBox_EyeDistance->onRestore();
ui->checkBoxBacklight->onRestore();
diff --git a/src/Mod/Arch/importWebGL.py b/src/Mod/Arch/importWebGL.py
index 3bc1f75c94..f8d2e27cea 100644
--- a/src/Mod/Arch/importWebGL.py
+++ b/src/Mod/Arch/importWebGL.py
@@ -1,5 +1,6 @@
#***************************************************************************
#* Copyright (c) 2013 Yorik van Havre *
+#* Copyright (c) 2020 Travis Apple *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
@@ -18,233 +19,792 @@
#* USA *
#* *
#***************************************************************************
+#
+# REFS:
+# https://github.com/mrdoob/three.js/blob/master/examples/webgl_interactive_buffergeometry.html
+# https://threejs.org/examples/#webgl_buffergeometry_lines
+# https://forum.freecadweb.org/viewtopic.php?t=51245
+# https://forum.freecadweb.org/viewtopic.php?t=29487
+# https://threejs.org/examples/#webgl_raycast_sprite
+#
+# Params for export()
+# 'colors' is of the form: {'Body': [1,0,0], 'Body001': [1,1,0], 'Body002': [1,0,1] }
+# 'camera' is of the form: "PerspectiveCamera {\n viewportMapping ADJUST_CAMERA\n position 30.242626 -51.772324 85.63475\n orientation -0.4146691 0.088459305 -0.90566254 4.7065201\nnearDistance 53.126431\n farDistance 123.09125\n aspectRatio 1\n focalDistance 104.53851\n heightAngle 0.78539819\n\n}"
+# The 'camera' string for the active document may be generated from: import OfflineRenderingUtils; OfflineRenderingUtils.getCamera(FreeCAD.ActiveDocument.FileName);
+#
+# Development reload oneliner:
+# def re(): from importlib import reload;import importWebGL;reload(importWebGL);o=FreeCAD.getDocument("YourDocName");importWebGL.export([o.getObject("YourBodyName")],u"C:/path/to/your/file.htm");
-"""FreeCAD webgl exporter
+"""FreeCAD WebGL Exporter"""
-options: importWebGL.wireframeStyle = "faceloop" (can also be "multimaterial" or None)
-importWebGL.template = a complete html file, where $CameraData is a placeholder for the
-FreeCAD camera, and $ObjectsData a placeholder for the FreeCAD objects.
-importWebGL.linewidth = an integer, specifying the width of lines in "faceloop" mode"""
-
-import FreeCAD,Draft,Part,DraftGeomUtils
+import FreeCAD,Mesh,Draft,Part,DraftGeomUtils,Arch,OfflineRenderingUtils,json,six
if FreeCAD.GuiUp:
import FreeCADGui
from DraftTools import translate
else:
FreeCADGui = None
- # \cond
- def translate(ctxt,txt,utf8_decode=True):
- return txt
- # \endcond
+ def translate(ctxt, txt): return txt
+
+if open.__module__ in ['__builtin__','io']: pythonopen = open
## @package importWebGL
# \ingroup ARCH
-# \brief WebGL file format exporter
+# \brief FreeCAD WebGL Exporter
#
# This module provides tools to export HTML files containing the
# exported objects in WebGL format and a simple three.js-based viewer.
-tab = " " # the tab size
-wireframeStyle = "faceloop" # this can be "faceloop", "multimaterial", or None
-cameraPosition = None # set this to a tuple to change, for ex. (0,0,0)
-linewidth = 1
-template = """
-
-
- FreeCAD model
-
+disableCompression = False # Compress object data before sending to JS
+base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!#$%&()*+-:;/=>?@[]^_,.{|}~`' # safe str chars for js in all cases
+baseFloat = ',.-0123456789'
-
+
+
+ """
- var camera, controls, scene, renderer;
-
- window.onload = function() {
-
- var SCREEN_WIDTH = window.innerWidth, SCREEN_HEIGHT = window.innerHeight;
- var VIEW_ANGLE = 35, ASPECT = SCREEN_WIDTH / SCREEN_HEIGHT, NEAR = 0.1, FAR = 200000;
-
- renderer = new THREE.WebGLRenderer();
- renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
- document.body.appendChild( renderer.domElement );
-
- scene = new THREE.Scene();
-
- camera = new THREE.PerspectiveCamera(
- VIEW_ANGLE, // Field of view
- ASPECT, // Aspect ratio
- NEAR, // Near plane
- FAR // Far plane
- );
- $CameraData // placeholder for the FreeCAD camera
-
- controls = new THREE.TrackballControls( camera );
- controls.rotateSpeed = 1.0;
- controls.zoomSpeed = 1.2;
- controls.panSpeed = 0.8;
- controls.noZoom = false;
- controls.noPan = false;
- controls.staticMoving = true;
- controls.dynamicDampingFactor = 0.3;
- controls.keys = [ 65, 83, 68 ];
-
- $ObjectsData // placeholder for the FreeCAD objects
-
- var light = new THREE.PointLight( 0xFFFF00 );
- light.position.set( -10000, -10000, 10000 );
- scene.add( light );
-
- renderer.render( scene, camera );
-
- animate();
- };
-
- function animate(){
- requestAnimationFrame( animate );
- render();
- };
-
- function render(){
- controls.update();
- renderer.render( scene, camera );
- };
-
-
-
-