mirror of https://github.com/vitalif/openscad
cleanup tab spacing
parent
689fdad0ac
commit
94d4acf765
|
@ -514,7 +514,7 @@ main()
|
||||||
dep_minver=$find_min_version_result
|
dep_minver=$find_min_version_result
|
||||||
compare_version $dep_minver $dep_sysver
|
compare_version $dep_minver $dep_sysver
|
||||||
dep_compare=$compare_version_result
|
dep_compare=$compare_version_result
|
||||||
pretty_print $depname $dep_minver $dep_sysver $dep_compare
|
pretty_print $depname $dep_minver $dep_sysver $dep_compare
|
||||||
done
|
done
|
||||||
check_old_local
|
check_old_local
|
||||||
check_misc
|
check_misc
|
||||||
|
|
|
@ -33,7 +33,7 @@ get_freebsd_deps()
|
||||||
get_netbsd_deps()
|
get_netbsd_deps()
|
||||||
{
|
{
|
||||||
sudo pkgin install bison boost cmake git bash eigen flex gmake gmp mpfr \
|
sudo pkgin install bison boost cmake git bash eigen flex gmake gmp mpfr \
|
||||||
qt4 glew cgal opencsg modular-xorg
|
qt4 glew cgal opencsg modular-xorg python27 py27-paramiko
|
||||||
}
|
}
|
||||||
|
|
||||||
get_opensuse_deps()
|
get_opensuse_deps()
|
||||||
|
|
|
@ -15,9 +15,9 @@ GLView::GLView()
|
||||||
showfaces = true;
|
showfaces = true;
|
||||||
showaxes = false;
|
showaxes = false;
|
||||||
showcrosshairs = false;
|
showcrosshairs = false;
|
||||||
renderer = NULL;
|
renderer = NULL;
|
||||||
cam = Camera();
|
cam = Camera();
|
||||||
far_far_away = RenderSettings->inst()->far_gl_clip_limit;
|
far_far_away = RenderSettings->inst()->far_gl_clip_limit;
|
||||||
#ifdef ENABLE_OPENCSG
|
#ifdef ENABLE_OPENCSG
|
||||||
is_opencsg_capable = false;
|
is_opencsg_capable = false;
|
||||||
has_shaders = false;
|
has_shaders = false;
|
||||||
|
@ -30,7 +30,7 @@ GLView::GLView()
|
||||||
|
|
||||||
void GLView::setRenderer(Renderer* r)
|
void GLView::setRenderer(Renderer* r)
|
||||||
{
|
{
|
||||||
renderer = r;
|
renderer = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLView::resizeGL(int w, int h)
|
void GLView::resizeGL(int w, int h)
|
||||||
|
@ -57,8 +57,7 @@ void GLView::setupGimbalCamOrtho(double distance, bool offset)
|
||||||
{
|
{
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
if(offset)
|
if (offset) glTranslated(-0.8, -0.8, 0);
|
||||||
glTranslated(-0.8, -0.8, 0);
|
|
||||||
double l = distance/10;
|
double l = distance/10;
|
||||||
glOrtho(-w_h_ratio*l, +w_h_ratio*l,
|
glOrtho(-w_h_ratio*l, +w_h_ratio*l,
|
||||||
-(1/w_h_ratio)*l, +(1/w_h_ratio)*l,
|
-(1/w_h_ratio)*l, +(1/w_h_ratio)*l,
|
||||||
|
@ -87,16 +86,16 @@ void GLView::setupVectorCamOrtho(bool offset)
|
||||||
|
|
||||||
void GLView::setCamera( Camera &cam )
|
void GLView::setCamera( Camera &cam )
|
||||||
{
|
{
|
||||||
this->cam = cam;
|
this->cam = cam;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLView::paintGL()
|
void GLView::paintGL()
|
||||||
{
|
{
|
||||||
if (cam.type == Camera::GIMBAL) gimbalCamPaintGL();
|
if (cam.type == Camera::GIMBAL) gimbalCamPaintGL();
|
||||||
else if (cam.type == Camera::VECTOR) vectorCamPaintGL();
|
else if (cam.type == Camera::VECTOR) vectorCamPaintGL();
|
||||||
else if (cam.type == Camera::NONE) {
|
else if (cam.type == Camera::NONE) {
|
||||||
fprintf(stderr,"paintGL with null camera\n");
|
fprintf(stderr,"paintGL with null camera\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_OPENCSG
|
#ifdef ENABLE_OPENCSG
|
||||||
|
@ -271,7 +270,7 @@ void GLView::initializeGL()
|
||||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
#ifdef ENABLE_OPENCSG
|
#ifdef ENABLE_OPENCSG
|
||||||
enable_opencsg_shaders();
|
enable_opencsg_shaders();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,9 +316,9 @@ void GLView::gimbalCamPaintGL()
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
|
|
||||||
if (cam.projection == Camera::ORTHOGONAL)
|
if (cam.projection == Camera::ORTHOGONAL)
|
||||||
GLView::setupGimbalCamOrtho(cam.viewer_distance);
|
GLView::setupGimbalCamOrtho(cam.viewer_distance);
|
||||||
else
|
else
|
||||||
GLView::setupGimbalCamPerspective();
|
GLView::setupGimbalCamPerspective();
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -357,12 +356,12 @@ void GLView::gimbalCamPaintGL()
|
||||||
|
|
||||||
void GLView::showSmallaxes()
|
void GLView::showSmallaxes()
|
||||||
{
|
{
|
||||||
// Fixme - this doesnt work in Vector Camera mode
|
// Fixme - this doesnt work in Vector Camera mode
|
||||||
|
|
||||||
// Small axis cross in the lower left corner
|
// Small axis cross in the lower left corner
|
||||||
glDepthFunc(GL_ALWAYS);
|
glDepthFunc(GL_ALWAYS);
|
||||||
|
|
||||||
GLView::setupGimbalCamOrtho(1000,true);
|
GLView::setupGimbalCamOrtho(1000,true);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
@ -411,10 +410,10 @@ void GLView::showSmallaxes()
|
||||||
|
|
||||||
// FIXME: This was an attempt to keep contrast with background, but is suboptimal
|
// FIXME: This was an attempt to keep contrast with background, but is suboptimal
|
||||||
// (e.g. nearly invisible against a gray background).
|
// (e.g. nearly invisible against a gray background).
|
||||||
// int r,g,b;
|
// int r,g,b;
|
||||||
// r=g=b=0;
|
// r=g=b=0;
|
||||||
// bgcol.getRgb(&r, &g, &b);
|
// bgcol.getRgb(&r, &g, &b);
|
||||||
// glColor3f((255.0f-r)/255.0f, (255.0f-g)/255.0f, (255.0f-b)/255.0f);
|
// glColor3f((255.0f-r)/255.0f, (255.0f-g)/255.0f, (255.0f-b)/255.0f);
|
||||||
glColor3f(0.0f, 0.0f, 0.0f);
|
glColor3f(0.0f, 0.0f, 0.0f);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
// X Label
|
// X Label
|
||||||
|
@ -427,8 +426,8 @@ void GLView::showSmallaxes()
|
||||||
glVertex3d(zlabel_x-3, zlabel_y-3, 0); glVertex3d(zlabel_x+3, zlabel_y-3, 0);
|
glVertex3d(zlabel_x-3, zlabel_y-3, 0); glVertex3d(zlabel_x+3, zlabel_y-3, 0);
|
||||||
glVertex3d(zlabel_x-3, zlabel_y+3, 0); glVertex3d(zlabel_x+3, zlabel_y+3, 0);
|
glVertex3d(zlabel_x-3, zlabel_y+3, 0); glVertex3d(zlabel_x+3, zlabel_y+3, 0);
|
||||||
glVertex3d(zlabel_x-3, zlabel_y-3, 0); glVertex3d(zlabel_x+3, zlabel_y+3, 0);
|
glVertex3d(zlabel_x-3, zlabel_y-3, 0); glVertex3d(zlabel_x+3, zlabel_y+3, 0);
|
||||||
// FIXME - depends on gimbal camera 'viewer distance'.. how to fix this
|
// FIXME - depends on gimbal camera 'viewer distance'.. how to fix this
|
||||||
// for VectorCamera?
|
// for VectorCamera?
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
//Restore perspective for next paint
|
//Restore perspective for next paint
|
||||||
|
@ -438,9 +437,9 @@ void GLView::showSmallaxes()
|
||||||
|
|
||||||
void GLView::showAxes()
|
void GLView::showAxes()
|
||||||
{
|
{
|
||||||
// FIXME: doesn't work under Vector Camera
|
// FIXME: doesn't work under Vector Camera
|
||||||
// Large gray axis cross inline with the model
|
// Large gray axis cross inline with the model
|
||||||
// FIXME: This is always gray - adjust color to keep contrast with background
|
// FIXME: This is always gray - adjust color to keep contrast with background
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glColor3d(0.5, 0.5, 0.5);
|
glColor3d(0.5, 0.5, 0.5);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
|
|
@ -33,7 +33,6 @@ class GLView
|
||||||
public:
|
public:
|
||||||
GLView();
|
GLView();
|
||||||
void setRenderer(Renderer* r);
|
void setRenderer(Renderer* r);
|
||||||
Renderer *renderer;
|
|
||||||
|
|
||||||
void initializeGL();
|
void initializeGL();
|
||||||
void resizeGL(int w, int h);
|
void resizeGL(int w, int h);
|
||||||
|
@ -56,6 +55,8 @@ public:
|
||||||
virtual bool save(const char *filename) = 0;
|
virtual bool save(const char *filename) = 0;
|
||||||
virtual std::string getRendererInfo() const = 0;
|
virtual std::string getRendererInfo() const = 0;
|
||||||
|
|
||||||
|
Renderer *renderer;
|
||||||
|
Camera cam;
|
||||||
size_t far_far_away;
|
size_t far_far_away;
|
||||||
size_t width;
|
size_t width;
|
||||||
size_t height;
|
size_t height;
|
||||||
|
@ -66,8 +67,6 @@ public:
|
||||||
bool showedges;
|
bool showedges;
|
||||||
bool showcrosshairs;
|
bool showcrosshairs;
|
||||||
|
|
||||||
Camera cam;
|
|
||||||
|
|
||||||
#ifdef ENABLE_OPENCSG
|
#ifdef ENABLE_OPENCSG
|
||||||
GLint shaderinfo[11];
|
GLint shaderinfo[11];
|
||||||
bool is_opencsg_capable;
|
bool is_opencsg_capable;
|
||||||
|
|
|
@ -126,8 +126,8 @@ bool create_wgl_dummy_context(OffscreenContext &ctx)
|
||||||
int chosenformat;
|
int chosenformat;
|
||||||
HDC dev_context = GetDC( window );
|
HDC dev_context = GetDC( window );
|
||||||
if ( dev_context == NULL ) {
|
if ( dev_context == NULL ) {
|
||||||
cerr << "MS GDI - GetDC failed\n";
|
cerr << "MS GDI - GetDC failed\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMemory( &pixformat, sizeof( pixformat ) );
|
ZeroMemory( &pixformat, sizeof( pixformat ) );
|
||||||
|
@ -187,7 +187,7 @@ OffscreenContext *create_offscreen_context(int w, int h)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return create_offscreen_context_common( ctx );
|
return create_offscreen_context_common( ctx );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool teardown_offscreen_context(OffscreenContext *ctx)
|
bool teardown_offscreen_context(OffscreenContext *ctx)
|
||||||
|
@ -207,8 +207,8 @@ bool teardown_offscreen_context(OffscreenContext *ctx)
|
||||||
|
|
||||||
bool save_framebuffer(OffscreenContext *ctx, std::ostream &output)
|
bool save_framebuffer(OffscreenContext *ctx, std::ostream &output)
|
||||||
{
|
{
|
||||||
if (!ctx) return false;
|
if (!ctx) return false;
|
||||||
wglSwapLayerBuffers( ctx->dev_context, WGL_SWAP_MAIN_PLANE );
|
wglSwapLayerBuffers( ctx->dev_context, WGL_SWAP_MAIN_PLANE );
|
||||||
return save_framebuffer_common( ctx, output );
|
return save_framebuffer_common( ctx, output );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ OffscreenView::~OffscreenView()
|
||||||
#ifdef ENABLE_OPENCSG
|
#ifdef ENABLE_OPENCSG
|
||||||
void OffscreenView::display_opencsg_warning()
|
void OffscreenView::display_opencsg_warning()
|
||||||
{
|
{
|
||||||
fprintf(stderr, "OpenSCAD recommended OpenGL version is 2.0. \n");
|
fprintf(stderr, "OpenSCAD recommended OpenGL version is 2.0. \n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
|
|
||||||
// overrides
|
// overrides
|
||||||
bool save(const char *filename);
|
bool save(const char *filename);
|
||||||
std::string getRendererInfo() const;
|
std::string getRendererInfo() const;
|
||||||
#ifdef ENABLE_OPENCSG
|
#ifdef ENABLE_OPENCSG
|
||||||
void display_opencsg_warning();
|
void display_opencsg_warning();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -63,7 +63,7 @@ static bool running_under_wine = false;
|
||||||
|
|
||||||
void QGLView::init()
|
void QGLView::init()
|
||||||
{
|
{
|
||||||
cam.type = Camera::GIMBAL;
|
cam.type = Camera::GIMBAL;
|
||||||
cam.object_rot << 35, 0, -25;
|
cam.object_rot << 35, 0, -25;
|
||||||
cam.object_trans << 0, 0, 0;
|
cam.object_trans << 0, 0, 0;
|
||||||
cam.viewer_distance = 500;
|
cam.viewer_distance = 500;
|
||||||
|
@ -89,7 +89,7 @@ void QGLView::initializeGL()
|
||||||
if (GLEW_OK != err) {
|
if (GLEW_OK != err) {
|
||||||
fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
|
fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
|
||||||
}
|
}
|
||||||
GLView::initializeGL();
|
GLView::initializeGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string QGLView::getRendererInfo() const
|
std::string QGLView::getRendererInfo() const
|
||||||
|
|
|
@ -42,7 +42,7 @@ void export_stl(CGAL_Nef_polyhedron *root_N, std::ostream &output)
|
||||||
CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION);
|
CGAL::Failure_behaviour old_behaviour = CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION);
|
||||||
try {
|
try {
|
||||||
CGAL_Polyhedron P;
|
CGAL_Polyhedron P;
|
||||||
root_N->p3->convert_to_Polyhedron(P);
|
root_N->p3->convert_to_Polyhedron(P);
|
||||||
|
|
||||||
typedef CGAL_Polyhedron::Vertex Vertex;
|
typedef CGAL_Polyhedron::Vertex Vertex;
|
||||||
typedef CGAL_Polyhedron::Vertex_const_iterator VCI;
|
typedef CGAL_Polyhedron::Vertex_const_iterator VCI;
|
||||||
|
|
|
@ -75,22 +75,22 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output)
|
||||||
|
|
||||||
if (cam.type == Camera::NONE) {
|
if (cam.type == Camera::NONE) {
|
||||||
cam.type = Camera::VECTOR;
|
cam.type = Camera::VECTOR;
|
||||||
double radius = 1.0;
|
double radius = 1.0;
|
||||||
if (csgInfo.root_chain) {
|
if (csgInfo.root_chain) {
|
||||||
BoundingBox bbox = csgInfo.root_chain->getBoundingBox();
|
BoundingBox bbox = csgInfo.root_chain->getBoundingBox();
|
||||||
cam.center = (bbox.min() + bbox.max()) / 2;
|
cam.center = (bbox.min() + bbox.max()) / 2;
|
||||||
radius = (bbox.max() - bbox.min()).norm() / 2;
|
radius = (bbox.max() - bbox.min()).norm() / 2;
|
||||||
}
|
}
|
||||||
Vector3d cameradir(1, 1, -0.5);
|
Vector3d cameradir(1, 1, -0.5);
|
||||||
cam.eye = cam.center - radius*1.8*cameradir;
|
cam.eye = cam.center - radius*1.8*cameradir;
|
||||||
}
|
}
|
||||||
|
|
||||||
csgInfo.glview->setCamera( cam );
|
csgInfo.glview->setCamera( cam );
|
||||||
csgInfo.glview->setRenderer(&opencsgRenderer);
|
csgInfo.glview->setRenderer(&opencsgRenderer);
|
||||||
OpenCSG::setContext(0);
|
OpenCSG::setContext(0);
|
||||||
OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject);
|
OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject);
|
||||||
csgInfo.glview->paintGL();
|
csgInfo.glview->paintGL();
|
||||||
csgInfo.glview->save(output);
|
csgInfo.glview->save(output);
|
||||||
#else
|
#else
|
||||||
fprintf(stderr,"This openscad was built without OpenCSG support\n");
|
fprintf(stderr,"This openscad was built without OpenCSG support\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
|
|
||||||
void flip_image(const unsigned char *src, unsigned char *dst, size_t pixelsize, size_t width, size_t height)
|
void flip_image(const unsigned char *src, unsigned char *dst, size_t pixelsize, size_t width, size_t height)
|
||||||
{
|
{
|
||||||
assert( src && dst );
|
assert( src && dst );
|
||||||
size_t rowBytes = pixelsize * width;
|
size_t rowBytes = pixelsize * width;
|
||||||
for (size_t i = 0 ; i < height ; i++) {
|
for (size_t i = 0 ; i < height ; i++) {
|
||||||
memmove(dst + (height - i - 1) * rowBytes, src + i * rowBytes, rowBytes);
|
memmove(dst + (height - i - 1) * rowBytes, src + i * rowBytes, rowBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool write_png(const char *filename, unsigned char *pixels, int width, int height) {
|
bool write_png(const char *filename, unsigned char *pixels, int width, int height) {
|
||||||
assert( filename && pixels );
|
assert( filename && pixels );
|
||||||
std::ofstream fstream( filename, std::ios::binary );
|
std::ofstream fstream( filename, std::ios::binary );
|
||||||
if (fstream.is_open()) {
|
if (fstream.is_open()) {
|
||||||
write_png( fstream, pixels, width, height );
|
write_png( fstream, pixels, width, height );
|
||||||
|
|
|
@ -194,7 +194,7 @@ int main(int argc, char **argv)
|
||||||
("version,v", "print the version")
|
("version,v", "print the version")
|
||||||
("render", "if exporting a png image, do a full CGAL render")
|
("render", "if exporting a png image, do a full CGAL render")
|
||||||
("camera", po::value<string>(), "parameters for camera when exporting png")
|
("camera", po::value<string>(), "parameters for camera when exporting png")
|
||||||
("imgsize", po::value<string>(), "=width,height for exporting png")
|
("imgsize", po::value<string>(), "=width,height for exporting png")
|
||||||
("projection", po::value<string>(), "(o)rtho or (p)erspective when exporting png")
|
("projection", po::value<string>(), "(o)rtho or (p)erspective when exporting png")
|
||||||
("o,o", po::value<string>(), "out-file")
|
("o,o", po::value<string>(), "out-file")
|
||||||
("s,s", po::value<string>(), "stl-file")
|
("s,s", po::value<string>(), "stl-file")
|
||||||
|
|
Loading…
Reference in New Issue