diff options
author | don bright <hugh.m.bright@gmail.com> | 2011-12-09 16:49:55 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2011-12-09 16:49:55 (GMT) |
commit | a4a64e7c26a0eb523f5b271c9d90f091e5933ebb (patch) | |
tree | 6e247c3f46c23a6c85b4740a2ff99abaa25fe9bd | |
parent | 51f24b998ba555d15f924ccd4fb5b46219f6537b (diff) | |
parent | f577f91d25071f5ad1a9fdb6ed7c6dd3aa4c1008 (diff) |
Merge remote-tracking branch 'upstream/master' into cakebaby
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | RELEASE_NOTES | 1 | ||||
-rw-r--r-- | doc/TODO.txt | 4 | ||||
-rw-r--r-- | openscad.pro | 6 | ||||
-rw-r--r-- | src/CGALEvaluator.cc | 22 | ||||
-rw-r--r-- | src/GLView.h | 5 | ||||
-rw-r--r-- | src/MainWindow.h | 3 | ||||
-rw-r--r-- | src/MainWindow.ui | 6 | ||||
-rw-r--r-- | src/OpenCSGWarningDialog.cc | 23 | ||||
-rw-r--r-- | src/OpenCSGWarningDialog.h | 16 | ||||
-rw-r--r-- | src/OpenCSGWarningDialog.ui | 93 | ||||
-rw-r--r-- | src/Preferences.cc | 17 | ||||
-rw-r--r-- | src/Preferences.h | 1 | ||||
-rw-r--r-- | src/Preferences.ui | 18 | ||||
-rw-r--r-- | src/cgaladv_convexhull2.cc | 54 | ||||
-rw-r--r-- | src/glview.cc | 100 | ||||
-rw-r--r-- | src/mainwin.cc | 14 | ||||
-rw-r--r-- | testdata/scad/features/hull2-tests.scad | 9 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/OffscreenContext.mm | 26 | ||||
-rw-r--r-- | tests/csgtestcore.cc | 2 | ||||
-rw-r--r-- | tests/regression/cgalpngtest/hull2-tests-expected.png | bin | 7531 -> 7121 bytes | |||
-rw-r--r-- | tests/regression/dumptest/hull2-tests-expected.txt | 24 | ||||
-rw-r--r-- | tests/regression/opencsgtest/hull2-tests-expected.png | bin | 8078 -> 7924 bytes | |||
-rw-r--r-- | tests/regression/throwntogethertest/hull2-tests-expected.png | bin | 4151 -> 7924 bytes |
25 files changed, 313 insertions, 136 deletions
@@ -35,7 +35,7 @@ numbers in brackets specify the versions which have been used for development. Other versions may or may not work as well.. * Qt4 (4.4 - 4.7): - http://www.qtsoftware.com/ + http://www.qt.nokia.com/ * CGAL (3.6 - 3.9): http://www.cgal.org/ diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 2681482..1bf3d8a 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -4,6 +4,7 @@ OpenSCAD 20xx.yy Features: o The MCAD library is now bundled with OpenSCAD o hull() Now supports 3D objects +o hull() with 2D object can now use for loops and boolean operations as children o Added import and export of the OFF file format o New import() statement reads the correct file format based on the filename extension (.stl, .dxf and .off is supported) diff --git a/doc/TODO.txt b/doc/TODO.txt index 4212c21..560e270 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -71,6 +71,8 @@ o 3D View thicknesses, distances, slot thicknesses etc. - Add option to change lights, e.g. add an optional camera light - 2D objects are rendered at z = -0.1 - why? + - Rewrite to use VBOs or smth. - avoid inline calculations + - Rewrite to a higher-level library (e.g. OSG)? o Editor wishlist - More infrastructure for external editor (allow communication from the outside) - Preferences GUI for the features below @@ -138,7 +140,6 @@ o 2D Subsystem o Built-in modules - extrude*: Allow the base 2D primitive to have a Z value - rotate_extrude(): Allow for specification of start/stop/sweep angle? - - Convex hull of 3D objects o Advanced Transformations - Add statement for refinement via surface subdivision - Add statement for intersections in cartesian product of childs @@ -236,7 +237,6 @@ MISSING TESTS: o all functions o mirror o scale -o 3D hull o open polyline from dxf using new method o linear_extrude DXF o rotate_extrude DXF diff --git a/openscad.pro b/openscad.pro index 4a1c0f3..31c1e15 100644 --- a/openscad.pro +++ b/openscad.pro @@ -159,7 +159,8 @@ include(boost.pri) FORMS += src/MainWindow.ui \ - src/Preferences.ui + src/Preferences.ui \ + src/OpenCSGWarningDialog.ui HEADERS += src/renderer.h \ src/ThrownTogetherRenderer.h \ @@ -168,6 +169,7 @@ HEADERS += src/renderer.h \ src/GLView.h \ src/MainWindow.h \ src/Preferences.h \ + src/OpenCSGWarningDialog.h \ src/builtin.h \ src/context.h \ src/csgterm.h \ @@ -247,6 +249,7 @@ SOURCES += src/openscad.cc \ src/highlighter.cc \ src/printutils.cc \ src/Preferences.cc \ + src/OpenCSGWarningDialog.cc \ src/progress.cc \ src/editor.cc \ src/traverser.cc \ @@ -274,7 +277,6 @@ SOURCES += src/cgalutils.cc \ src/CGALRenderer.cc \ src/CGAL_Nef_polyhedron.cc \ src/CGAL_Nef_polyhedron_DxfData.cc \ - src/cgaladv_convexhull2.cc \ src/cgaladv_minkowski2.cc } diff --git a/src/CGALEvaluator.cc b/src/CGALEvaluator.cc index 1772354..684ab42 100644 --- a/src/CGALEvaluator.cc +++ b/src/CGALEvaluator.cc @@ -116,13 +116,12 @@ CGAL_Nef_polyhedron CGALEvaluator::applyToChildren(const AbstractNode &node, CGA return N; } -extern CGAL_Nef_polyhedron2 *convexhull2(std::list<CGAL_Nef_polyhedron2*> a); - CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) { CGAL_Nef_polyhedron N; std::list<CGAL_Nef_polyhedron2*> polys; - std::list<CGAL_Polyhedron::Vertex::Point_3> points; + std::list<CGAL_Nef_polyhedron2::Point> points2d; + std::list<CGAL_Polyhedron::Vertex::Point_3> points3d; int dim = 0; BOOST_FOREACH(const ChildItem &item, this->visitedchildren[node.index()]) { const AbstractNode *chnode = item.first; @@ -137,23 +136,32 @@ CGAL_Nef_polyhedron CGALEvaluator::applyHull(const CgaladvNode &node) continue; } if (dim == 2) { - polys.push_back(chN.p2.get()); + CGAL_Nef_polyhedron2::Explorer explorer = chN.p2->explorer(); + BOOST_FOREACH(const CGAL_Nef_polyhedron2::Explorer::Vertex &vh, + std::make_pair(explorer.vertices_begin(), explorer.vertices_end())) { + if (explorer.is_standard(&vh)) { + points2d.push_back(explorer.point(&vh)); + } + } } else if (dim == 3) { CGAL_Polyhedron P; chN.p3->convert_to_Polyhedron(P); - std::transform(P.vertices_begin(), P.vertices_end(), std::back_inserter(points), + std::transform(P.vertices_begin(), P.vertices_end(), std::back_inserter(points3d), boost::bind(static_cast<const CGAL_Polyhedron::Vertex::Point_3&(CGAL_Polyhedron::Vertex::*)() const>(&CGAL_Polyhedron::Vertex::point), _1)); } chnode->progress_report(); } if (dim == 2) { - N = CGAL_Nef_polyhedron(convexhull2(polys)); + std::list<CGAL_Nef_polyhedron2::Point> result; + CGAL::convex_hull_2(points2d.begin(), points2d.end(),std:: back_inserter(result)); + N = CGAL_Nef_polyhedron(new CGAL_Nef_polyhedron2(result.begin(), result.end(), + CGAL_Nef_polyhedron2::INCLUDED)); } else if (dim == 3) { CGAL_Polyhedron P; - CGAL::convex_hull_3(points.begin(), points.end(), P); + CGAL::convex_hull_3(points3d.begin(), points3d.end(), P); N = CGAL_Nef_polyhedron(new CGAL_Nef_polyhedron3(P)); } return N; diff --git a/src/GLView.h b/src/GLView.h index c31e7af..5552e4b 100644 --- a/src/GLView.h +++ b/src/GLView.h @@ -32,7 +32,8 @@ public: void setShowCrosshairs(bool enabled) { this->showcrosshairs = enabled; } bool orthoMode() const { return this->orthomode; } void setOrthoMode(bool enabled) { this->orthomode = enabled; } - + const QString &getRendererInfo() const { return this->rendererInfo; } + public: QLabel *statusLabel; double object_rot_x; @@ -52,6 +53,8 @@ private: void init(); Renderer *renderer; + QString rendererInfo; + bool showfaces; bool showedges; bool showaxes; diff --git a/src/MainWindow.h b/src/MainWindow.h index b2d0f60..0f2a922 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -86,6 +86,8 @@ private: void loadViewSettings(); void loadDesignSettings(); + class QMessageBox *openglbox; + private slots: void actionNew(); void actionOpen(); @@ -156,6 +158,7 @@ public slots: void helpAbout(); void helpHomepage(); void helpManual(); + void helpOpenGL(); void quit(); void actionReloadCompile(); void checkAutoReload(); diff --git a/src/MainWindow.ui b/src/MainWindow.ui index dc73c05..d1bdb00 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -218,6 +218,7 @@ <addaction name="helpActionAbout"/> <addaction name="helpActionHomepage"/> <addaction name="helpActionManual"/> + <addaction name="helpActionOpenGLInfo"/> </widget> <addaction name="menu_File"/> <addaction name="menu_Edit"/> @@ -666,6 +667,11 @@ <string>Export as CSG...</string> </property> </action> + <action name="helpActionOpenGLInfo"> + <property name="text"> + <string>OpenGL info</string> + </property> + </action> </widget> <customwidgets> <customwidget> diff --git a/src/OpenCSGWarningDialog.cc b/src/OpenCSGWarningDialog.cc new file mode 100644 index 0000000..fdaaa50 --- /dev/null +++ b/src/OpenCSGWarningDialog.cc @@ -0,0 +1,23 @@ +#include "OpenCSGWarningDialog.h" +#include "Preferences.h" + +OpenCSGWarningDialog::OpenCSGWarningDialog(QWidget *parent) +{ + setupUi(this); + + connect(this->showBox, SIGNAL(toggled(bool)), + Preferences::inst()->openCSGWarningBox, SLOT(setChecked(bool))); + connect(this->showBox, SIGNAL(toggled(bool)), + Preferences::inst(), SLOT(openCSGWarningChanged(bool))); + + connect(this->enableOpenCSGBox, SIGNAL(toggled(bool)), + Preferences::inst()->enableOpenCSGBox, SLOT(setChecked(bool))); + connect(this->enableOpenCSGBox, SIGNAL(toggled(bool)), + Preferences::inst(), SLOT(enableOpenCSGChanged(bool))); +} + +void OpenCSGWarningDialog::setText(const QString &text) +{ + this->warningText->setPlainText(text); +} + diff --git a/src/OpenCSGWarningDialog.h b/src/OpenCSGWarningDialog.h new file mode 100644 index 0000000..5d9c8fa --- /dev/null +++ b/src/OpenCSGWarningDialog.h @@ -0,0 +1,16 @@ +#ifndef OPENCSGWARNINGDIALOG_H_ +#define OPENCSGWARNINGDIALOG_H_ + +#include "ui_OpenCSGWarningDialog.h" + +class OpenCSGWarningDialog : public QDialog, public Ui::OpenCSGWarningDialog +{ + Q_OBJECT; +public: + OpenCSGWarningDialog(QWidget *parent); + +public slots: + void setText(const QString &text); +}; + +#endif diff --git a/src/OpenCSGWarningDialog.ui b/src/OpenCSGWarningDialog.ui new file mode 100644 index 0000000..f902521 --- /dev/null +++ b/src/OpenCSGWarningDialog.ui @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>OpenCSGWarningDialog</class> + <widget class="QDialog" name="OpenCSGWarningDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>412</width> + <height>275</height> + </rect> + </property> + <property name="windowTitle"> + <string>OpenGL Warning</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTextEdit" name="warningText"> + <property name="readOnly"> + <bool>true</bool> + </property> + <property name="html"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html></string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="enableOpenCSGBox"> + <property name="text"> + <string>Enable OpenCSG</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QCheckBox" name="showBox"> + <property name="text"> + <string>Show this message again</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="closeButton"> + <property name="text"> + <string>Close</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>closeButton</sender> + <signal>clicked()</signal> + <receiver>OpenCSGWarningDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>361</x> + <y>246</y> + </hint> + <hint type="destinationlabel"> + <x>205</x> + <y>137</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/Preferences.cc b/src/Preferences.cc index d240a9f..577ed4a 100644 --- a/src/Preferences.cc +++ b/src/Preferences.cc @@ -40,7 +40,8 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) this->defaultmap["3dview/colorscheme"] = this->colorSchemeChooser->currentItem()->text(); this->defaultmap["editor/fontfamily"] = this->fontChooser->currentText(); this->defaultmap["editor/fontsize"] = this->fontSize->currentText().toUInt(); - this->defaultmap["editor/opengl20_warning_show"] = true; + this->defaultmap["advanced/opencsg_show_warning"] = true; + this->defaultmap["advanced/enable_opencsg_opengl1x"] = false; // Toolbar QActionGroup *group = new QActionGroup(this); @@ -98,7 +99,7 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) this, SLOT(fontFamilyChanged(const QString &))); connect(this->fontSize, SIGNAL(editTextChanged(const QString &)), this, SLOT(fontSizeChanged(const QString &))); - connect(this->openCSGWarningBox, SIGNAL(clicked(bool)), + connect(this->openCSGWarningBox, SIGNAL(toggled(bool)), this, SLOT(openCSGWarningChanged(bool))); updateGUI(); } @@ -154,7 +155,14 @@ void Preferences::openCSGWarningChanged(bool state) { QSettings settings; - settings.setValue("editor/opengl20_warning_show",state); + settings.setValue("advanced/opencsg_show_warning",state); +} + +void +Preferences::enableOpenCSGChanged(bool state) +{ + QSettings settings; + settings.setValue("advanced/enable_opencsg_opengl1x", state); } void Preferences::keyPressEvent(QKeyEvent *e) @@ -215,7 +223,8 @@ void Preferences::updateGUI() this->fontSize->setEditText(fontsize); } - this->openCSGWarningBox->setChecked(getValue("editor/opengl20_warning_show").toBool()); + this->openCSGWarningBox->setChecked(getValue("advanced/opencsg_show_warning").toBool()); + this->enableOpenCSGBox->setChecked(getValue("advanced/enable_opencsg_opengl1x").toBool()); } void Preferences::apply() const diff --git a/src/Preferences.h b/src/Preferences.h index bdc707d..add1a11 100644 --- a/src/Preferences.h +++ b/src/Preferences.h @@ -35,6 +35,7 @@ public slots: void fontFamilyChanged(const QString &); void fontSizeChanged(const QString &); void openCSGWarningChanged(bool); + void enableOpenCSGChanged(bool); signals: void requestRedraw() const; diff --git a/src/Preferences.ui b/src/Preferences.ui index 556172c..6b80674 100644 --- a/src/Preferences.ui +++ b/src/Preferences.ui @@ -185,6 +185,16 @@ <property name="text"> <string>Show OpenCSG capability warning</string> </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="enableOpenCSGBox"> + <property name="text"> + <string>Enable OpenCSG for OpenGL 1.x</string> + </property> </widget> </item> <item> @@ -239,7 +249,7 @@ <bool>true</bool> </property> <property name="icon"> - <iconset> + <iconset resource="../openscad.qrc"> <normaloff>:/icons/prefs3DView.png</normaloff>:/icons/prefs3DView.png</iconset> </property> <property name="text"> @@ -251,7 +261,7 @@ <bool>true</bool> </property> <property name="icon"> - <iconset> + <iconset resource="../openscad.qrc"> <normaloff>:/icons/prefsAdvanced.png</normaloff>:/icons/prefsAdvanced.png</iconset> </property> <property name="text"> @@ -263,7 +273,7 @@ <bool>true</bool> </property> <property name="icon"> - <iconset> + <iconset resource="../openscad.qrc"> <normaloff>:/icons/prefsEditor.png</normaloff>:/icons/prefsEditor.png</iconset> </property> <property name="text"> @@ -272,7 +282,7 @@ </action> </widget> <resources> - <include location="openscad.qrc"/> + <include location="../openscad.qrc"/> </resources> <connections/> </ui> diff --git a/src/cgaladv_convexhull2.cc b/src/cgaladv_convexhull2.cc deleted file mode 100644 index 492df3c..0000000 --- a/src/cgaladv_convexhull2.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - * OpenSCAD (www.openscad.org) - * Copyright (C) 2009-2011 Clifford Wolf <clifford@clifford.at> and - * Marius Kintel <marius@kintel.net> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * As a special exception, you have permission to link this program - * with the CGAL library and distribute executables, as long as you - * follow the requirements of the GNU GPL in regard to all of the - * software in the executable aside from CGAL. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef ENABLE_CGAL - -#include "cgal.h" -#include <CGAL/convex_hull_2.h> - -extern CGAL_Poly2 nef2p2(CGAL_Nef_polyhedron2 p); - -CGAL_Nef_polyhedron2 *convexhull2(std::list<CGAL_Nef_polyhedron2*> a) -{ - std::list<CGAL_Nef_polyhedron2::Point> points; - - std::list<CGAL_Nef_polyhedron2*>::iterator i; - for (i=a.begin(); i!=a.end(); i++) { - CGAL_Poly2 ap=nef2p2(**i); - for (size_t j=0;j<ap.size();j++) { - double x=to_double(ap[j].x()),y=to_double(ap[j].y()); - CGAL_Nef_polyhedron2::Point p=CGAL_Nef_polyhedron2::Point(x,y); - points.push_back(p); - } - } - - std::list<CGAL_Nef_polyhedron2::Point> result; - CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(result)); - - return new CGAL_Nef_polyhedron2(result.begin(),result.end(),CGAL_Nef_polyhedron2::INCLUDED); -} - -#endif diff --git a/src/glview.cc b/src/glview.cc index bc287b5..bd53b1b 100644 --- a/src/glview.cc +++ b/src/glview.cc @@ -39,6 +39,9 @@ #include <QTimer> #include <QTextEdit> #include <QVBoxLayout> +#include <QErrorMessage> +#include "OpenCSGWarningDialog.h" + #include "mathc99.h" #include <stdio.h> @@ -133,31 +136,45 @@ void GLView::initializeGL() fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); } + this->rendererInfo.sprintf("GLEW version %s\n" + "OpenGL version %s\n" + "%s (%s)\n\n" + "Extensions:\n" + "%s\n", + glewGetString(GLEW_VERSION), + glGetString(GL_RENDERER), + glGetString(GL_VENDOR), + glGetString(GL_VERSION), + glGetString(GL_EXTENSIONS)); + + const char *openscad_disable_gl20_env = getenv("OPENSCAD_DISABLE_GL20"); if (openscad_disable_gl20_env && !strcmp(openscad_disable_gl20_env, "0")) { openscad_disable_gl20_env = NULL; } // All OpenGL 2 contexts are OpenCSG capable - if (GLEW_VERSION_2_0 && !openscad_disable_gl20_env) this->is_opencsg_capable = true; - // If OpenGL < 2, check for extensions - else if (GLEW_ARB_framebuffer_object) this->is_opencsg_capable = true; - else if (GLEW_EXT_framebuffer_object && GLEW_EXT_packed_depth_stencil) { - this->is_opencsg_capable = true; + if (GLEW_VERSION_2_0) { + if (!openscad_disable_gl20_env) { + this->is_opencsg_capable = true; + this->has_shaders = true; + } } + // If OpenGL < 2, check for extensions + else { + if (GLEW_ARB_framebuffer_object) this->is_opencsg_capable = true; + else if (GLEW_EXT_framebuffer_object && GLEW_EXT_packed_depth_stencil) { + this->is_opencsg_capable = true; + } #ifdef WIN32 - else if (WGLEW_ARB_pbuffer && WGLEW_ARB_pixel_format) this->is_opencsg_capable = true; + else if (WGLEW_ARB_pbuffer && WGLEW_ARB_pixel_format) this->is_opencsg_capable = true; #elif !defined(__APPLE__) - else if (GLXEW_SGIX_pbuffer && GLXEW_SGIX_fbconfig) this->is_opencsg_capable = true; + else if (GLXEW_SGIX_pbuffer && GLXEW_SGIX_fbconfig) this->is_opencsg_capable = true; #endif + } - if (GLEW_VERSION_2_0 && !openscad_disable_gl20_env) this->has_shaders = true; - - if (!this->is_opencsg_capable) { - opencsg_support = false; - QSettings settings; - // FIXME: This should be an OpenCSG capability warning, not an OpenGL 2 warning - if (settings.value("editor/opengl20_warning_show",true).toBool()) { + if (!GLEW_VERSION_2_0 || !this->is_opencsg_capable) { + if (Preferences::inst()->getValue("advanced/opencsg_show_warning").toBool()) { QTimer::singleShot(0, this, SLOT(display_opencsg_warning())); } } @@ -252,9 +269,19 @@ void GLView::initializeGL() #ifdef ENABLE_OPENCSG void GLView::display_opencsg_warning() { - // data - QString title = QString("OpenGL context is not OpenCSG capable"); + OpenCSGWarningDialog *dialog = new OpenCSGWarningDialog(this); + QString message; + if (this->is_opencsg_capable) { + message += "Warning: You may experience OpenCSG rendering errors.\n\n"; + } + else { + message += "Warning: Missing OpenGL capabilities for OpenCSG - OpenCSG has been disabled.\n\n"; + dialog->enableOpenCSGBox->hide(); + } + message += "It is highly recommended to use OpenSCAD on a system with " + "OpenGL 2.0 or later.\n" + "Your renderer information is as follows:\n"; QString rendererinfo; rendererinfo.sprintf("GLEW version %s\n" "%s (%s)\n" @@ -262,44 +289,13 @@ void GLView::display_opencsg_warning() glewGetString(GLEW_VERSION), glGetString(GL_RENDERER), glGetString(GL_VENDOR), glGetString(GL_VERSION)); + message += rendererinfo; - QString message = QString("Warning: Missing OpenGL capabilities for OpenCSG - OpenCSG has been disabled.\n\n" - "It is highly recommended to use OpenSCAD on a system with OpenGL 2.0, " - "or support for the framebuffer_object or pbuffer extensions. " - "Your renderer information is as follows:\n\n%1").arg(rendererinfo); - - QString note = QString("Uncheck to hide this message in the future"); - - // presentation - QDialog *dialog = new QDialog(this); - dialog->setSizeGripEnabled(true); - dialog->setWindowTitle(title); - dialog->resize(500,300); - - QVBoxLayout *layout = new QVBoxLayout(dialog); - dialog->setLayout(layout); - - QTextEdit *textEdit = new QTextEdit(dialog); - textEdit->setPlainText(message); - layout->addWidget(textEdit); - - QCheckBox *checkbox = new QCheckBox(note,dialog); - checkbox->setCheckState(Qt::Checked); - layout->addWidget(checkbox); - - QDialogButtonBox *buttonbox = - new QDialogButtonBox( QDialogButtonBox::Ok, Qt::Horizontal,dialog); - layout->addWidget(buttonbox); - buttonbox->button(QDialogButtonBox::Ok)->setFocus(); - buttonbox->button(QDialogButtonBox::Ok)->setDefault(true); - - // action - connect(buttonbox, SIGNAL(accepted()), dialog, SLOT(accept())); - connect(checkbox, SIGNAL(clicked(bool)), - Preferences::inst()->openCSGWarningBox, SLOT(setChecked(bool))); - connect(checkbox, SIGNAL(clicked(bool)), - Preferences::inst(), SLOT(openCSGWarningChanged(bool))); + dialog->setText(message); + dialog->enableOpenCSGBox->setChecked(Preferences::inst()->getValue("advanced/enable_opencsg_opengl1x").toBool()); dialog->exec(); + + opencsg_support = this->is_opencsg_capable && Preferences::inst()->getValue("advanced/enable_opencsg_opengl1x").toBool(); } #endif diff --git a/src/mainwin.cc b/src/mainwin.cc index c81f2f2..4b4321d 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -312,6 +312,7 @@ MainWindow::MainWindow(const QString &filename) connect(this->helpActionAbout, SIGNAL(triggered()), this, SLOT(helpAbout())); connect(this->helpActionHomepage, SIGNAL(triggered()), this, SLOT(helpHomepage())); connect(this->helpActionManual, SIGNAL(triggered()), this, SLOT(helpManual())); + connect(this->helpActionOpenGLInfo, SIGNAL(triggered()), this, SLOT(helpOpenGL())); console->setReadOnly(true); @@ -1752,6 +1753,18 @@ MainWindow::helpManual() QDesktopServices::openUrl(QUrl("http://en.wikibooks.org/wiki/OpenSCAD_User_Manual")); } +void MainWindow::helpOpenGL() +{ + if (!this->openglbox) { + this->openglbox = new QMessageBox(QMessageBox::Information, + "OpenGL Info", "Detailed OpenGL Info", + QMessageBox::Ok, this); + + } + this->openglbox->setDetailedText(this->glview->getRendererInfo()); + this->openglbox->show(); +} + /*! FIXME: In MDI mode, should this be called on both reload functions? */ @@ -1822,3 +1835,4 @@ void MainWindow::clearCurrentOutput() { set_output_handler(NULL, NULL); } + diff --git a/testdata/scad/features/hull2-tests.scad b/testdata/scad/features/hull2-tests.scad index 3bea3c5..e656e6a 100644 --- a/testdata/scad/features/hull2-tests.scad +++ b/testdata/scad/features/hull2-tests.scad @@ -13,7 +13,6 @@ module concave2dSimple() { } } -// Works correctly module convex2dHole() { hull() { translate([15,10,0]) circle(10); @@ -24,7 +23,15 @@ module convex2dHole() { } } +module hull2dForLoop() { + hull() { + for(x = [0,10]) + for(y=[0,10]) + translate([x,y]) circle(3); + } +} convex2dHole(); translate([40,0,0]) convex2dSimple(); translate([0,-20,0]) concave2dSimple(); +translate([30,-25,0]) hull2dForLoop(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bb05ce7..585c3b1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -275,8 +275,7 @@ set(CGAL_SOURCES ../src/CGALCache.cc ../src/PolySetCGALEvaluator.cc ../src/CGAL_Nef_polyhedron_DxfData.cc - ../src/cgaladv_minkowski2.cc - ../src/cgaladv_convexhull2.cc) + ../src/cgaladv_minkowski2.cc) set(COMMON_SOURCES ../src/nodedumper.cc diff --git a/tests/OffscreenContext.mm b/tests/OffscreenContext.mm index eb06615..ea46275 100644 --- a/tests/OffscreenContext.mm +++ b/tests/OffscreenContext.mm @@ -2,9 +2,11 @@ #include "imageutils.h" #include "fbo.h" #include <iostream> +#include <sstream> #import <AppKit/AppKit.h> // for NSOpenGL... - +#include <CoreServices/CoreServices.h> +#include <sys/utsname.h> #define REPORTGLERROR(task) { GLenum tGLErr = glGetError(); if (tGLErr != GL_NO_ERROR) { std::cout << "OpenGL error " << tGLErr << " while " << task << "\n"; } } @@ -17,13 +19,27 @@ struct OffscreenContext fbo_t *fbo; }; -string offscreen_context_getinfo(OffscreenContext *ctx) +std::string offscreen_context_getinfo(OffscreenContext *ctx) { - stringstream out; + std::stringstream out; + + struct utsname name; + uname(&name); + + SInt32 majorVersion,minorVersion,bugFixVersion; + + Gestalt(gestaltSystemVersionMajor, &majorVersion); + Gestalt(gestaltSystemVersionMinor, &minorVersion); + Gestalt(gestaltSystemVersionBugFix, &bugFixVersion); + + char *arch = "unknown"; + if (sizeof(int*) == 4) arch = "32-bit"; + else if (sizeof(int*) == 8) arch = "64-bit"; + out << "GL context creator: Cocoa / CGL\n" << "PNG generator: Core Foundation\n" - << "OS info: Mac OSX\n" - << "Machine: Apple(TM) Mac(TM)\n"; + << "OS info: Mac OS X " << majorVersion << "." << minorVersion << "." << bugFixVersion << " (" << name.machine << " kernel)\n" + << "Machine: " << arch << "\n"; return out.str(); } diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 4cdc5d8..3ea0e36 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -327,7 +327,7 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) csgInfo.root_chain = new CSGChain(); csgInfo.root_chain->import(csgInfo.root_norm_term); - fprintf(stderr, "Normalized CSG tree has %d elements\n", csgInfo.root_chain->polysets.size()); + fprintf(stderr, "Normalized CSG tree has %d elements\n", int(csgInfo.root_chain->polysets.size())); if (csgInfo.highlight_terms.size() > 0) { cerr << "Compiling highlights (" << csgInfo.highlight_terms.size() << " CSG Trees)...\n"; diff --git a/tests/regression/cgalpngtest/hull2-tests-expected.png b/tests/regression/cgalpngtest/hull2-tests-expected.png Binary files differindex 256b349..508974f 100644 --- a/tests/regression/cgalpngtest/hull2-tests-expected.png +++ b/tests/regression/cgalpngtest/hull2-tests-expected.png diff --git a/tests/regression/dumptest/hull2-tests-expected.txt b/tests/regression/dumptest/hull2-tests-expected.txt index 87365a6..d060d1d 100644 --- a/tests/regression/dumptest/hull2-tests-expected.txt +++ b/tests/regression/dumptest/hull2-tests-expected.txt @@ -32,4 +32,28 @@ } } } + multmatrix([[1, 0, 0, 30], [0, 1, 0, -25], [0, 0, 1, 0], [0, 0, 0, 1]]) { + group() { + hull() { + group() { + group() { + multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + circle($fn = 0, $fa = 12, $fs = 1, r = 3); + } + multmatrix([[1, 0, 0, 0], [0, 1, 0, 10], [0, 0, 1, 0], [0, 0, 0, 1]]) { + circle($fn = 0, $fa = 12, $fs = 1, r = 3); + } + } + group() { + multmatrix([[1, 0, 0, 10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + circle($fn = 0, $fa = 12, $fs = 1, r = 3); + } + multmatrix([[1, 0, 0, 10], [0, 1, 0, 10], [0, 0, 1, 0], [0, 0, 0, 1]]) { + circle($fn = 0, $fa = 12, $fs = 1, r = 3); + } + } + } + } + } + } diff --git a/tests/regression/opencsgtest/hull2-tests-expected.png b/tests/regression/opencsgtest/hull2-tests-expected.png Binary files differindex 66ee6b2..46b266b 100644 --- a/tests/regression/opencsgtest/hull2-tests-expected.png +++ b/tests/regression/opencsgtest/hull2-tests-expected.png diff --git a/tests/regression/throwntogethertest/hull2-tests-expected.png b/tests/regression/throwntogethertest/hull2-tests-expected.png Binary files differindex 221cbaf..46b266b 100644 --- a/tests/regression/throwntogethertest/hull2-tests-expected.png +++ b/tests/regression/throwntogethertest/hull2-tests-expected.png |