summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2013-09-12 05:17:17 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2013-09-12 05:17:17 (GMT)
commit6af6c311a12a0211545e29666c92f1806ca0c7e8 (patch)
tree5af3769a2bbd2cdc44508152cc1d2c72b2331e77 /src
parentb53dde04e2a13c066cfa0c552fe5bd0cdd1b8dbd (diff)
cmdline throwntogether, integrate w chrysn tests, update resize tests
Diffstat (limited to 'src')
-rw-r--r--src/PlatformUtils.cc43
-rw-r--r--src/PlatformUtils.h3
-rw-r--r--src/export.h1
-rw-r--r--src/export_png.cc37
-rw-r--r--src/mainwin.cc34
-rw-r--r--src/openscad.cc29
6 files changed, 116 insertions, 31 deletions
diff --git a/src/PlatformUtils.cc b/src/PlatformUtils.cc
index 5dd007d..ccc2bc0 100644
--- a/src/PlatformUtils.cc
+++ b/src/PlatformUtils.cc
@@ -38,3 +38,46 @@ std::string PlatformUtils::libraryPath()
}
return boosty::stringy( path );
}
+
+#include "version_check.h"
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+std::string PlatformUtils::info()
+{
+ std::stringstream s;
+
+#if defined(__GNUG__) && !defined(__clang__)
+ std::string compiler_info( "GCC " + std::string(TOSTRING(__VERSION__)) );
+#elif defined(_MSC_VER)
+ std::string compiler_info( "MSVC " + std::string(TOSTRING(_MSC_FULL_VER)) );
+#elif defined(__clang__)
+ std::string compiler_info( "Clang " + std::string(TOSTRING(__clang_version__)) );
+#else
+ std::string compiler_info( "unknown compiler" );
+#endif
+
+#if defined( __MINGW64__ )
+ std::string mingwstatus("MingW64");
+#elif defined( __MINGW32__ )
+ std::string mingwstatus("MingW32");
+#else
+ std::string mingwstatus("No");
+#endif
+
+#ifndef OPENCSG_VERSION_STRING
+#define OPENCSG_VERSION_STRING "unknown, <1.3.2"
+#endif
+
+ s << "OpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION)
+ << "\nCompiler: " << compiler_info
+ << "\nCompile date: " << __DATE__
+ << "\nBoost version: " << BOOST_LIB_VERSION
+ << "\nEigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION
+ << "\nCGAL version: " << TOSTRING(CGAL_VERSION)
+ << "\nOpenCSG version: " << OPENCSG_VERSION_STRING
+ << "\nQt version: " << qVersion()
+ << "\nMingW build: " << mingwstatus;
+
+ return s.str();
+}
+
diff --git a/src/PlatformUtils.h b/src/PlatformUtils.h
index 089b3ca..f718bb2 100644
--- a/src/PlatformUtils.h
+++ b/src/PlatformUtils.h
@@ -4,11 +4,10 @@
#include <string>
namespace PlatformUtils {
-
std::string documentsPath();
std::string libraryPath();
bool createLibraryPath();
-
+ std::string info();
}
#endif
diff --git a/src/export.h b/src/export.h
index a565561..5dae7e0 100644
--- a/src/export.h
+++ b/src/export.h
@@ -12,6 +12,7 @@ void export_off(CGAL_Nef_polyhedron *root_N, std::ostream &output);
void export_dxf(CGAL_Nef_polyhedron *root_N, std::ostream &output);
void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, Camera &c, std::ostream &output);
void export_png_with_opencsg(Tree &tree, Camera &c, std::ostream &output);
+void export_png_with_throwntogether(Tree &tree, Camera &c, std::ostream &output);
#endif
diff --git a/src/export_png.cc b/src/export_png.cc
index c6c191c..fcc64fc 100644
--- a/src/export_png.cc
+++ b/src/export_png.cc
@@ -96,5 +96,42 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output)
#endif
}
+#include "ThrownTogetherRenderer.h"
+void export_png_with_throwntogether(Tree &tree, Camera &cam, std::ostream &output)
+{
+ CsgInfo csgInfo = CsgInfo();
+ if ( !csgInfo.compile_chains( tree ) ) {
+ fprintf(stderr,"Couldn't initialize OpenCSG chains\n");
+ return;
+ }
+
+ try {
+ csgInfo.glview = new OffscreenView( cam.pixel_width, cam.pixel_height );
+ } catch (int error) {
+ fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i.\n", error);
+ return;
+ }
+
+ ThrownTogetherRenderer thrownTogetherRenderer( csgInfo.root_chain,
+ csgInfo.highlights_chain, csgInfo.background_chain );
+
+ if (cam.type == Camera::NONE) {
+ cam.type = Camera::VECTOR;
+ double radius = 1.0;
+ if (csgInfo.root_chain) {
+ BoundingBox bbox = csgInfo.root_chain->getBoundingBox();
+ cam.center = (bbox.min() + bbox.max()) / 2;
+ radius = (bbox.max() - bbox.min()).norm() / 2;
+ }
+ Vector3d cameradir(1, 1, -0.5);
+ cam.eye = cam.center - radius*1.8*cameradir;
+ }
+
+ csgInfo.glview->setCamera( cam );
+ csgInfo.glview->setRenderer(&thrownTogetherRenderer);
+ csgInfo.glview->paintGL();
+ csgInfo.glview->save(output);
+}
+
#endif // ENABLE_CGAL
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 3d50d6f..3104ed3 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -101,10 +101,6 @@
#endif // ENABLE_CGAL
-#ifndef OPENCSG_VERSION_STRING
-#define OPENCSG_VERSION_STRING "unknown, <1.3.2"
-#endif
-
#include "boosty.h"
extern QString examplesdir;
@@ -1828,34 +1824,18 @@ MainWindow::helpManual()
QDesktopServices::openUrl(QUrl("http://www.openscad.org/documentation.html"));
}
-#define STRINGIFY(x) #x
-#define TOSTRING(x) STRINGIFY(x)
void MainWindow::helpLibrary()
{
- QString libinfo;
- libinfo.sprintf("Boost version: %s\n"
- "Eigen version: %d.%d.%d\n"
- "CGAL version: %s\n"
- "OpenCSG version: %s\n"
- "Qt version: %s\n\n",
- BOOST_LIB_VERSION,
- EIGEN_WORLD_VERSION, EIGEN_MAJOR_VERSION, EIGEN_MINOR_VERSION,
- TOSTRING(CGAL_VERSION),
- OPENCSG_VERSION_STRING,
- qVersion());
-
-#if defined( __MINGW64__ )
- libinfo += QString("Compiled for MingW64\n\n");
-#elif defined( __MINGW32__ )
- libinfo += QString("Compiled for MingW32\n\n");
-#endif
+ std::string basicinfo = PlatformUtils::info();
+ QString info( basicinfo.c_str() );
+ info += QString(qglview->getRendererInfo().c_str());
if (!this->openglbox) {
- this->openglbox = new QMessageBox(QMessageBox::Information,
- "OpenGL Info", "OpenSCAD Detailed Library Info ",
- QMessageBox::Ok, this);
+ this->openglbox = new QMessageBox(QMessageBox::Information,
+ "OpenGL Info", "OpenSCAD Detailed Library and Build Information",
+ QMessageBox::Ok, this);
}
- this->openglbox->setDetailedText(libinfo + QString(qglview->getRendererInfo().c_str()));
+ this->openglbox->setDetailedText( info );
this->openglbox->show();
}
diff --git a/src/openscad.cc b/src/openscad.cc
index e657cb0..56b8acf 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -37,6 +37,7 @@
#include "handle_dep.h"
#include "parsersettings.h"
#include "rendersettings.h"
+#include "PlatformUtils.h"
#include <string>
#include <vector>
@@ -50,6 +51,7 @@
#include "csgterm.h"
#include "CSGTermEvaluator.h"
+#include "CsgInfo.h"
#include <QApplication>
#include <QString>
@@ -82,12 +84,13 @@ static void help(const char *progname)
{
int tab = int(strlen(progname))+8;
fprintf(stderr,"Usage: %s [ -o output_file [ -d deps_file ] ]\\\n"
- "%*s[ -m make_command ] [ -D var=val [..] ] [ --render ] \\\n"
+ "%*s[ -m make_command ] [ -D var=val [..] ] \\\n"
"%*s[ --camera=translatex,y,z,rotx,y,z,dist | \\\n"
"%*s --camera=eyex,y,z,centerx,y,z ] \\\n"
"%*s[ --imgsize=width,height ] [ --projection=(o)rtho|(p)ersp] \\\n"
+ "%*s[ --render | --preview[=throwntogether] ] \\\n"
"%*sfilename\n",
- progname, tab, "", tab, "", tab, "", tab, "", tab, "");
+ progname, tab, "", tab, "", tab, "", tab, "", tab, "", tab, "");
exit(1);
}
@@ -99,6 +102,23 @@ static void version()
exit(1);
}
+static void info()
+{
+ std::cout << PlatformUtils::info() << "\n\n";
+
+ CsgInfo csgInfo = CsgInfo();
+ try {
+ csgInfo.glview = new OffscreenView(512,512);
+ } catch (int error) {
+ fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i. Exiting.\n", error);
+ exit(1);
+ }
+
+ std::cout << csgInfo.glview->getRendererInfo() << "\n";
+
+ exit(0);
+}
+
std::string commandline_commands;
std::string currentdir;
QString examplesdir;
@@ -199,7 +219,9 @@ int main(int argc, char **argv)
desc.add_options()
("help,h", "help message")
("version,v", "print the version")
+ ("info", "print information about the building process")
("render", "if exporting a png image, do a full CGAL render")
+ ("preview", po::value<string>(), "if exporting a png image, do an OpenCSG(default) or ThrownTogether preview")
("camera", po::value<string>(), "parameters for camera when exporting png")
("imgsize", po::value<string>(), "=width,height for exporting png")
("projection", po::value<string>(), "(o)rtho or (p)erspective when exporting png")
@@ -231,6 +253,7 @@ int main(int argc, char **argv)
if (vm.count("help")) help(argv[0]);
if (vm.count("version")) version();
+ if (vm.count("info")) info();
if (vm.count("o")) {
// FIXME: Allow for multiple output files?
@@ -513,6 +536,8 @@ int main(int argc, char **argv)
else {
if (vm.count("render")) {
export_png_with_cgal(&root_N, camera, fstream);
+ } else if (vm.count("preview") && vm["preview"].as<string>() == "throwntogether" ) {
+ export_png_with_throwntogether(tree, camera, fstream);
} else {
export_png_with_opencsg(tree, camera, fstream);
}
contact: Jan Huwald // Impressum