From 7b526bc27ab70f362332640987bc3f8c363b3659 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 23 Nov 2013 20:00:19 -0500 Subject: Added test for polygon with hole diff --git a/testdata/scad/features/polygon-tests.scad b/testdata/scad/features/polygon-tests.scad index b4e92b6..0cd259f 100644 --- a/testdata/scad/features/polygon-tests.scad +++ b/testdata/scad/features/polygon-tests.scad @@ -15,4 +15,10 @@ translate([-2,0,0]) polygon(points); translate([-2,-2,0]) polygon(points=points, paths=[[0,1,2,3], [4,5,6,7]]); translate([2,-4,0]) polygon([[0,0], [1,0], [1,1], [0,0]]); +// With hole +translate([-2,-4,0]) + polygon(points=[[0,0], [1,0], [1,1], [0,1], [0.2,0.2], [0.8,0.2], [0.8,0.8], [0.2,0.8]], + paths=[[0,1,2,3],[4,5,6,7]] +); + // FIXME: convexity diff --git a/tests/regression/cgalpngtest/polygon-tests-expected.png b/tests/regression/cgalpngtest/polygon-tests-expected.png index 5ceabe8..28e4e9f 100644 Binary files a/tests/regression/cgalpngtest/polygon-tests-expected.png and b/tests/regression/cgalpngtest/polygon-tests-expected.png differ diff --git a/tests/regression/dumptest/polygon-tests-expected.csg b/tests/regression/dumptest/polygon-tests-expected.csg index 56995a5..e19bcb0 100644 --- a/tests/regression/dumptest/polygon-tests-expected.csg +++ b/tests/regression/dumptest/polygon-tests-expected.csg @@ -33,4 +33,7 @@ group() { multmatrix([[1, 0, 0, 2], [0, 1, 0, -4], [0, 0, 1, 0], [0, 0, 0, 1]]) { polygon(points = [[0, 0], [1, 0], [1, 1], [0, 0]], paths = undef, convexity = 1); } + multmatrix([[1, 0, 0, -2], [0, 1, 0, -4], [0, 0, 1, 0], [0, 0, 0, 1]]) { + polygon(points = [[0, 0], [1, 0], [1, 1], [0, 1], [0.2, 0.2], [0.8, 0.2], [0.8, 0.8], [0.2, 0.8]], paths = [[0, 1, 2, 3], [4, 5, 6, 7]], convexity = 1); + } } diff --git a/tests/regression/opencsgtest/polygon-tests-expected.png b/tests/regression/opencsgtest/polygon-tests-expected.png index fe84a80..94bd131 100644 Binary files a/tests/regression/opencsgtest/polygon-tests-expected.png and b/tests/regression/opencsgtest/polygon-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/polygon-tests-expected.png b/tests/regression/throwntogethertest/polygon-tests-expected.png index 779b878..2ce6b75 100644 Binary files a/tests/regression/throwntogethertest/polygon-tests-expected.png and b/tests/regression/throwntogethertest/polygon-tests-expected.png differ -- cgit v0.10.1 From 91c2b8909ce670e65d341f98fc5f7e456622bba4 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 23 Nov 2013 22:10:05 -0500 Subject: Added test for implicit union of render() children diff --git a/testdata/scad/features/render-2d-tests.scad b/testdata/scad/features/render-2d-tests.scad index 683ffe4..f8df115 100644 --- a/testdata/scad/features/render-2d-tests.scad +++ b/testdata/scad/features/render-2d-tests.scad @@ -1,6 +1,11 @@ render() { difference() { - square(100, center=true); - circle(r=30); + square(10, center=true); + circle(r=3); } } + +translate([12,0,0]) render() { + square(10, center=true); + circle(r=3); +} diff --git a/tests/regression/cgalpngtest/render-2d-tests-expected.png b/tests/regression/cgalpngtest/render-2d-tests-expected.png index 19ea16a..2418968 100644 Binary files a/tests/regression/cgalpngtest/render-2d-tests-expected.png and b/tests/regression/cgalpngtest/render-2d-tests-expected.png differ diff --git a/tests/regression/dumptest/render-2d-tests-expected.csg b/tests/regression/dumptest/render-2d-tests-expected.csg index 75739b3..bcc5e96 100644 --- a/tests/regression/dumptest/render-2d-tests-expected.csg +++ b/tests/regression/dumptest/render-2d-tests-expected.csg @@ -1,8 +1,14 @@ group() { render(convexity = 1) { difference() { - square(size = [100, 100], center = true); - circle($fn = 0, $fa = 12, $fs = 2, r = 30); + square(size = [10, 10], center = true); + circle($fn = 0, $fa = 12, $fs = 2, r = 3); + } + } + multmatrix([[1, 0, 0, 12], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + render(convexity = 1) { + square(size = [10, 10], center = true); + circle($fn = 0, $fa = 12, $fs = 2, r = 3); } } } diff --git a/tests/regression/opencsgtest/render-2d-tests-expected.png b/tests/regression/opencsgtest/render-2d-tests-expected.png index 0bf6288..47e57dd 100644 Binary files a/tests/regression/opencsgtest/render-2d-tests-expected.png and b/tests/regression/opencsgtest/render-2d-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/render-2d-tests-expected.png b/tests/regression/throwntogethertest/render-2d-tests-expected.png index 0bf6288..47e57dd 100644 Binary files a/tests/regression/throwntogethertest/render-2d-tests-expected.png and b/tests/regression/throwntogethertest/render-2d-tests-expected.png differ -- cgit v0.10.1 From 825fbc7b9e7756ef8c2b49a85efd9abe3ebf8d95 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sun, 24 Nov 2013 19:01:11 -0600 Subject: revert to GMPQ number type kernel due to bugs like issue #481 diff --git a/src/cgal.h b/src/cgal.h index 45228be..efc53d3 100644 --- a/src/cgal.h +++ b/src/cgal.h @@ -48,9 +48,10 @@ typedef CGAL::Exact_predicates_exact_constructions_kernel CGAL_ExactKernel2; typedef CGAL::Polygon_2 CGAL_Poly2; typedef CGAL::Polygon_with_holes_2 CGAL_Poly2h; - //typedef CGAL::Cartesian CGAL_Kernel3; -typedef CGAL::Exact_predicates_exact_constructions_kernel CGAL_Kernel3; -typedef CGAL::Exact_predicates_exact_constructions_kernel::FT NT3; +typedef CGAL::Gmpq NT3; +typedef CGAL::Cartesian CGAL_Kernel3; +//typedef CGAL::Exact_predicates_exact_constructions_kernel::FT NT3; +//typedef CGAL::Exact_predicates_exact_constructions_kernel CGAL_Kernel3; typedef CGAL::Nef_polyhedron_3 CGAL_Nef_polyhedron3; typedef CGAL_Nef_polyhedron3::Aff_transformation_3 CGAL_Aff_transformation; -- cgit v0.10.1 From de2db22b5f82855b9cf42829c4dde3b4bd231273 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 25 Nov 2013 00:27:15 -0500 Subject: Split projection tests into cut vs. project diff --git a/testdata/scad/features/projection-cut-tests.scad b/testdata/scad/features/projection-cut-tests.scad new file mode 100644 index 0000000..0409a3e --- /dev/null +++ b/testdata/scad/features/projection-cut-tests.scad @@ -0,0 +1,15 @@ +// 2D child +projection(cut=true) { square(); } + +projection(cut=true) translate([20,0,0]) cube(10, center=true); + +// Boundary case: clipping the top of a cube +translate([0,20,0]) projection(cut=true) translate([0,0,-4.999999]) cube(10, center=true); + +// holes +translate([0,-10,0]) projection(cut=true) { + union() { + difference() { cube(5,center=true); cube(4,center=true); } + translate([2.1,2.1]) difference() { cube(5,center=true); cube(4,center=true); } + } +} diff --git a/testdata/scad/features/projection-tests.scad b/testdata/scad/features/projection-tests.scad index bc2111c..27d03fe 100644 --- a/testdata/scad/features/projection-tests.scad +++ b/testdata/scad/features/projection-tests.scad @@ -3,17 +3,25 @@ projection(); // No children projection() { } // 2D child -projection(cut=true) { square(); } +projection() { square(); } +// Simple projection(cut=false) cube(10); -projection(cut=true) translate([20,0,0]) cube(10, center=true); -// Boundary case: clipping the top of a cube -translate([0,20,0]) projection(cut=true) translate([0,0,-4.999999]) cube(10, center=true); -// holes -translate([0,-10,0]) projection(cut=true) { - union() { - difference() { cube(5,center=true); cube(4,center=true); } - translate([2.1,2.1]) difference() { cube(5,center=true); cube(4,center=true); } - } +// Two children +translate([-12,0]) projection(cut=false) { + cube(10); + difference() { + sphere(10); + cylinder(h=30, r=5, center=true); + } +} + +// Holes +translate([6,-12]) projection(cut=false) { + cube(10); + difference() { + sphere(10); + cylinder(h=30, r=5, center=true); + } } diff --git a/tests/regression/cgalpngtest/projection-cut-tests-expected.png b/tests/regression/cgalpngtest/projection-cut-tests-expected.png new file mode 100644 index 0000000..7189447 Binary files /dev/null and b/tests/regression/cgalpngtest/projection-cut-tests-expected.png differ diff --git a/tests/regression/cgalpngtest/projection-tests-expected.png b/tests/regression/cgalpngtest/projection-tests-expected.png index 3be3654..c0d5289 100644 Binary files a/tests/regression/cgalpngtest/projection-tests-expected.png and b/tests/regression/cgalpngtest/projection-tests-expected.png differ diff --git a/tests/regression/dumptest/projection-cut-tests-expected.csg b/tests/regression/dumptest/projection-cut-tests-expected.csg new file mode 100644 index 0000000..4c37fa2 --- /dev/null +++ b/tests/regression/dumptest/projection-cut-tests-expected.csg @@ -0,0 +1,33 @@ +group() { + projection(cut = true, convexity = 0) { + square(size = [1, 1], center = false); + } + projection(cut = true, convexity = 0) { + multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + cube(size = [10, 10, 10], center = true); + } + } + multmatrix([[1, 0, 0, 0], [0, 1, 0, 20], [0, 0, 1, 0], [0, 0, 0, 1]]) { + projection(cut = true, convexity = 0) { + multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, -4.999999], [0, 0, 0, 1]]) { + cube(size = [10, 10, 10], center = true); + } + } + } + multmatrix([[1, 0, 0, 0], [0, 1, 0, -10], [0, 0, 1, 0], [0, 0, 0, 1]]) { + projection(cut = true, convexity = 0) { + union() { + difference() { + cube(size = [5, 5, 5], center = true); + cube(size = [4, 4, 4], center = true); + } + multmatrix([[1, 0, 0, 2.1], [0, 1, 0, 2.1], [0, 0, 1, 0], [0, 0, 0, 1]]) { + difference() { + cube(size = [5, 5, 5], center = true); + cube(size = [4, 4, 4], center = true); + } + } + } + } + } +} diff --git a/tests/regression/dumptest/projection-tests-expected.csg b/tests/regression/dumptest/projection-tests-expected.csg index da3e5ce..04cd404 100644 --- a/tests/regression/dumptest/projection-tests-expected.csg +++ b/tests/regression/dumptest/projection-tests-expected.csg @@ -1,37 +1,27 @@ group() { projection(cut = false, convexity = 0); projection(cut = false, convexity = 0); - projection(cut = true, convexity = 0) { + projection(cut = false, convexity = 0) { square(size = [1, 1], center = false); } projection(cut = false, convexity = 0) { cube(size = [10, 10, 10], center = false); } - projection(cut = true, convexity = 0) { - multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { - cube(size = [10, 10, 10], center = true); - } - } - multmatrix([[1, 0, 0, 0], [0, 1, 0, 20], [0, 0, 1, 0], [0, 0, 0, 1]]) { - projection(cut = true, convexity = 0) { - multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, -4.999999], [0, 0, 0, 1]]) { - cube(size = [10, 10, 10], center = true); + multmatrix([[1, 0, 0, -12], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) { + projection(cut = false, convexity = 0) { + cube(size = [10, 10, 10], center = false); + difference() { + sphere($fn = 0, $fa = 12, $fs = 2, r = 10); + cylinder($fn = 0, $fa = 12, $fs = 2, h = 30, r1 = 5, r2 = 5, center = true); } } } - multmatrix([[1, 0, 0, 0], [0, 1, 0, -10], [0, 0, 1, 0], [0, 0, 0, 1]]) { - projection(cut = true, convexity = 0) { - union() { - difference() { - cube(size = [5, 5, 5], center = true); - cube(size = [4, 4, 4], center = true); - } - multmatrix([[1, 0, 0, 2.1], [0, 1, 0, 2.1], [0, 0, 1, 0], [0, 0, 0, 1]]) { - difference() { - cube(size = [5, 5, 5], center = true); - cube(size = [4, 4, 4], center = true); - } - } + multmatrix([[1, 0, 0, 6], [0, 1, 0, -12], [0, 0, 1, 0], [0, 0, 0, 1]]) { + projection(cut = false, convexity = 0) { + cube(size = [10, 10, 10], center = false); + difference() { + sphere($fn = 0, $fa = 12, $fs = 2, r = 10); + cylinder($fn = 0, $fa = 12, $fs = 2, h = 30, r1 = 5, r2 = 5, center = true); } } } diff --git a/tests/regression/opencsgtest/projection-cut-tests-expected.png b/tests/regression/opencsgtest/projection-cut-tests-expected.png new file mode 100644 index 0000000..5063301 Binary files /dev/null and b/tests/regression/opencsgtest/projection-cut-tests-expected.png differ diff --git a/tests/regression/opencsgtest/projection-tests-expected.png b/tests/regression/opencsgtest/projection-tests-expected.png index b808ffe..b3af1e1 100644 Binary files a/tests/regression/opencsgtest/projection-tests-expected.png and b/tests/regression/opencsgtest/projection-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/projection-cut-tests-expected.png b/tests/regression/throwntogethertest/projection-cut-tests-expected.png new file mode 100644 index 0000000..5063301 Binary files /dev/null and b/tests/regression/throwntogethertest/projection-cut-tests-expected.png differ diff --git a/tests/regression/throwntogethertest/projection-tests-expected.png b/tests/regression/throwntogethertest/projection-tests-expected.png index b808ffe..b3af1e1 100644 Binary files a/tests/regression/throwntogethertest/projection-tests-expected.png and b/tests/regression/throwntogethertest/projection-tests-expected.png differ -- cgit v0.10.1 From 7b64944738d91eb2eef92f93f526cc29436adf15 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Fri, 29 Nov 2013 00:16:40 -0300 Subject: Try to keep cursor and scroll in place on refresh When the file is saving, the cursor position was resetting to the top and you should keep scrolling by hand every time you save the file. This patch saves the scroll and cursor position and set it again after the file is refreshed so we can continue edition from where we were. diff --git a/src/mainwin.cc b/src/mainwin.cc index 5b986b1..8c21b20 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -75,6 +75,7 @@ #include #include #include +#include #include @@ -605,7 +606,15 @@ void MainWindow::refreshDocument() reader.setCodec("UTF-8"); QString text = reader.readAll(); PRINTB("Loaded design '%s'.", this->fileName.toLocal8Bit().constData()); + int y = editor->verticalScrollBar()->sliderPosition(); + // Save current cursor position + QTextCursor cursor = editor->textCursor(); + int n = cursor.position(); editor->setPlainText(text); + // Restore cursor position + cursor.setPosition(n); + editor->setTextCursor(cursor); + editor->verticalScrollBar()->setSliderPosition(y); } } setCurrentOutput(); -- cgit v0.10.1 From afe1fbcb53ff286b2f6efdb99efb6ed9947304f9 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Fri, 29 Nov 2013 01:40:28 -0300 Subject: Move main code inside Editor class Before open a new file now we cleanup the Editor, so the new file get the cursor on the first character. diff --git a/src/editor.cc b/src/editor.cc index 08bf005..069101f 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -108,3 +108,17 @@ void Editor::wheelEvent ( QWheelEvent * event ) } } +void Editor::setPlainText(const QString &text) +{ + int y = verticalScrollBar()->sliderPosition(); + // Save current cursor position + QTextCursor cursor = textCursor(); + int n = cursor.position(); + QTextEdit::setPlainText(text); + // Restore cursor position + if (n < text.length()) { + cursor.setPosition(n); + setTextCursor(cursor); + verticalScrollBar()->setSliderPosition(y); + } +} diff --git a/src/editor.h b/src/editor.h index 09484f5..8d092a9 100644 --- a/src/editor.h +++ b/src/editor.h @@ -2,6 +2,7 @@ #include #include #include +#include #include class Editor : public QTextEdit @@ -9,6 +10,7 @@ class Editor : public QTextEdit Q_OBJECT public: Editor(QWidget *parent) : QTextEdit(parent) { setAcceptRichText(false); } + void setPlainText(const QString &text); public slots: void zoomIn(); void zoomOut(); diff --git a/src/mainwin.cc b/src/mainwin.cc index 8c21b20..1ad8bc8 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -75,7 +75,6 @@ #include #include #include -#include #include @@ -505,6 +504,7 @@ MainWindow::openFile(const QString &new_filename) } #endif setFileName(actual_filename); + editor->setPlainText(""); fileChangedOnDisk(); // force cached autoReloadId to update refreshDocument(); @@ -606,15 +606,7 @@ void MainWindow::refreshDocument() reader.setCodec("UTF-8"); QString text = reader.readAll(); PRINTB("Loaded design '%s'.", this->fileName.toLocal8Bit().constData()); - int y = editor->verticalScrollBar()->sliderPosition(); - // Save current cursor position - QTextCursor cursor = editor->textCursor(); - int n = cursor.position(); editor->setPlainText(text); - // Restore cursor position - cursor.setPosition(n); - editor->setTextCursor(cursor); - editor->verticalScrollBar()->setSliderPosition(y); } } setCurrentOutput(); -- cgit v0.10.1