summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RELEASE_NOTES2
-rw-r--r--src/Camera.h6
-rw-r--r--src/GLView.cc4
-rw-r--r--src/export_png.cc8
-rw-r--r--src/openscad.cc34
5 files changed, 40 insertions, 14 deletions
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 2147d1d..b2058df 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -6,7 +6,7 @@ o Console output is now enabled on Windows through the openscad.com executable
o Added basic syntax highlighting in the editor
o Mac: Added document icon
o Mac: Added auto-update check
-o Commandline output to PNG. '-o o.png' = OpenCSG, '-o o.png --render' = CGAL
+o Commandline output to PNG, with two types of cameras, imgsize, CGAL & OpenCSG
o Regression test now creates single monolithic .html file for easier uploading
Bugfixes:
diff --git a/src/Camera.h b/src/Camera.h
index b35ef0c..f7cd257 100644
--- a/src/Camera.h
+++ b/src/Camera.h
@@ -16,7 +16,6 @@ There are two different types of cameras represented in this class:
#include <vector>
#include <Eigen/Geometry>
-#include <boost/variant.hpp>
class Camera
{
@@ -37,6 +36,8 @@ public:
Eigen::Vector3d cameradir(1, 1, -0.5);
eye = center - 500 * cameradir;
}
+ pixel_width = 512;
+ pixel_height = 512;
}
void setup( std::vector<double> params ) {
@@ -63,6 +64,9 @@ public:
Eigen::Vector3d object_trans;
Eigen::Vector3d object_rot;
double viewer_distance;
+
+ unsigned int pixel_width;
+ unsigned int pixel_height;
};
diff --git a/src/GLView.cc b/src/GLView.cc
index 6598ed5..72818f3 100644
--- a/src/GLView.cc
+++ b/src/GLView.cc
@@ -39,8 +39,8 @@ void GLView::resizeGL(int w, int h)
shaderinfo[9] = w;
shaderinfo[10] = h;
#endif
- this->width = w;
- this->height = h;
+ cam.pixel_width = w;
+ cam.pixel_height = h;
glViewport(0, 0, w, h);
w_h_ratio = sqrt((double)w / (double)h);
}
diff --git a/src/export_png.cc b/src/export_png.cc
index f185e3d..33fb85b 100644
--- a/src/export_png.cc
+++ b/src/export_png.cc
@@ -14,10 +14,8 @@
void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, Camera &cam, std::ostream &output)
{
OffscreenView *glview;
- int w = RenderSettings::inst()->img_width;
- int h = RenderSettings::inst()->img_height;
try {
- glview = new OffscreenView( w, h );
+ glview = new OffscreenView( cam.pixel_width, cam.pixel_height );
} catch (int error) {
fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i.\n", error);
return;
@@ -66,10 +64,8 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output)
return;
}
- int w = RenderSettings::inst()->img_width;
- int h = RenderSettings::inst()->img_height;
try {
- csgInfo.glview = new OffscreenView( w, h );
+ 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;
diff --git a/src/openscad.cc b/src/openscad.cc
index 2a04cc7..f8c53df 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -36,6 +36,7 @@
#include "printutils.h"
#include "handle_dep.h"
#include "parsersettings.h"
+#include "rendersettings.h"
#include <string>
#include <vector>
@@ -74,10 +75,13 @@ namespace fs = boost::filesystem;
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[ --viewport=x,y,z,xrot,yrot,zrot,dist ] filename\n",
- progname, tab, "", tab, "");
+ fprintf(stderr,"Usage: %s [ -o output_file [ -d deps_file ] ]\\\n"
+ "%*s[ -m make_command ] [ -D var=val [..] ] [ --render ] \\\n"
+ "%*s[ --gimbalcam=x,y,z,xrot,yrot,zrot,dist ] \\\n"
+ "%*s[ --vectorcam=eyex,eyey,eyez,centerx,centery,centerz] \\\n"
+ "%*s[ --imgsize=width,height ] \\\n"
+ " filename\n",
+ progname, tab, "", tab, "", tab, "", tab, "");
exit(1);
}
@@ -131,6 +135,23 @@ Camera determine_camera( po::variables_map vm )
return camera;
}
+std::pair<int,int> get_imgsize( po::variables_map vm )
+{
+ int w = RenderSettings::inst()->img_width;
+ int h = RenderSettings::inst()->img_height;
+ if (vm.count("imgsize")) {
+ vector<string> strs;
+ split(strs, vm["imgsize"].as<string>(), is_any_of(","));
+ if ( strs.size() != 2 ) {
+ fprintf(stderr,"Need 2 numbers for imgsize\n");
+ } else {
+ w = lexical_cast<int>( strs[0] );
+ h = lexical_cast<int>( strs[0] );
+ }
+ }
+ return std::pair<int,int>(w,h);
+}
+
int main(int argc, char **argv)
{
int rc = 0;
@@ -174,6 +195,8 @@ int main(int argc, char **argv)
("version,v", "print the version")
("render", "if exporting a png image, do a full CGAL render")
("gimbalcam", po::value<string>(), "=x,y,z,xrot,yrot,zrot,dist for exporting png")
+ ("vectorcam", po::value<string>(), "=eyex,y,z,centerx,y,z for exporting png")
+ ("imgsize", po::value<string>(), "=width,height for exporting png")
("o,o", po::value<string>(), "out-file")
("s,s", po::value<string>(), "stl-file")
("x,x", po::value<string>(), "dxf-file")
@@ -249,6 +272,9 @@ int main(int argc, char **argv)
currentdir = boosty::stringy(fs::current_path());
Camera camera = determine_camera( vm );
+ std::pair<int,int> imgsize = get_imgsize( vm );
+ camera.pixel_width = imgsize.first;
+ camera.pixel_height = imgsize.second;
QDir exdir(QApplication::instance()->applicationDirPath());
#ifdef Q_WS_MAC
contact: Jan Huwald // Impressum