Skip to content

Commit

Permalink
cleanup tab spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
donbright committed Mar 4, 2013
1 parent 689fdad commit 94d4acf
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 59 deletions.
2 changes: 1 addition & 1 deletion scripts/check-dependencies.sh
Expand Up @@ -514,7 +514,7 @@ main()
dep_minver=$find_min_version_result
compare_version $dep_minver $dep_sysver
dep_compare=$compare_version_result
pretty_print $depname $dep_minver $dep_sysver $dep_compare
pretty_print $depname $dep_minver $dep_sysver $dep_compare
done
check_old_local
check_misc
Expand Down
2 changes: 1 addition & 1 deletion scripts/uni-get-dependencies.sh
Expand Up @@ -33,7 +33,7 @@ get_freebsd_deps()
get_netbsd_deps()
{
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()
Expand Down
51 changes: 25 additions & 26 deletions src/GLView.cc
Expand Up @@ -15,9 +15,9 @@ GLView::GLView()
showfaces = true;
showaxes = false;
showcrosshairs = false;
renderer = NULL;
cam = Camera();
far_far_away = RenderSettings->inst()->far_gl_clip_limit;
renderer = NULL;
cam = Camera();
far_far_away = RenderSettings->inst()->far_gl_clip_limit;
#ifdef ENABLE_OPENCSG
is_opencsg_capable = false;
has_shaders = false;
Expand All @@ -30,7 +30,7 @@ GLView::GLView()

void GLView::setRenderer(Renderer* r)
{
renderer = r;
renderer = r;
}

void GLView::resizeGL(int w, int h)
Expand All @@ -57,8 +57,7 @@ void GLView::setupGimbalCamOrtho(double distance, bool offset)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(offset)
glTranslated(-0.8, -0.8, 0);
if (offset) glTranslated(-0.8, -0.8, 0);
double l = distance/10;
glOrtho(-w_h_ratio*l, +w_h_ratio*l,
-(1/w_h_ratio)*l, +(1/w_h_ratio)*l,
Expand Down Expand Up @@ -87,16 +86,16 @@ void GLView::setupVectorCamOrtho(bool offset)

void GLView::setCamera( Camera &cam )
{
this->cam = cam;
this->cam = cam;
}

void GLView::paintGL()
{
if (cam.type == Camera::GIMBAL) gimbalCamPaintGL();
else if (cam.type == Camera::VECTOR) vectorCamPaintGL();
else if (cam.type == Camera::NONE) {
fprintf(stderr,"paintGL with null camera\n");
}
if (cam.type == Camera::GIMBAL) gimbalCamPaintGL();
else if (cam.type == Camera::VECTOR) vectorCamPaintGL();
else if (cam.type == Camera::NONE) {
fprintf(stderr,"paintGL with null camera\n");
}
}

#ifdef ENABLE_OPENCSG
Expand Down Expand Up @@ -271,7 +270,7 @@ void GLView::initializeGL()
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
#ifdef ENABLE_OPENCSG
enable_opencsg_shaders();
enable_opencsg_shaders();
#endif
}

Expand Down Expand Up @@ -317,9 +316,9 @@ void GLView::gimbalCamPaintGL()
glEnable(GL_LIGHTING);

if (cam.projection == Camera::ORTHOGONAL)
GLView::setupGimbalCamOrtho(cam.viewer_distance);
GLView::setupGimbalCamOrtho(cam.viewer_distance);
else
GLView::setupGimbalCamPerspective();
GLView::setupGimbalCamPerspective();

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
Expand Down Expand Up @@ -357,12 +356,12 @@ void GLView::gimbalCamPaintGL()

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
glDepthFunc(GL_ALWAYS);

GLView::setupGimbalCamOrtho(1000,true);
GLView::setupGimbalCamOrtho(1000,true);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
Expand Down Expand Up @@ -411,10 +410,10 @@ void GLView::showSmallaxes()

// FIXME: This was an attempt to keep contrast with background, but is suboptimal
// (e.g. nearly invisible against a gray background).
// int r,g,b;
// r=g=b=0;
// bgcol.getRgb(&r, &g, &b);
// glColor3f((255.0f-r)/255.0f, (255.0f-g)/255.0f, (255.0f-b)/255.0f);
// int r,g,b;
// r=g=b=0;
// bgcol.getRgb(&r, &g, &b);
// glColor3f((255.0f-r)/255.0f, (255.0f-g)/255.0f, (255.0f-b)/255.0f);
glColor3f(0.0f, 0.0f, 0.0f);
glBegin(GL_LINES);
// X Label
Expand All @@ -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);
// FIXME - depends on gimbal camera 'viewer distance'.. how to fix this
// for VectorCamera?
// FIXME - depends on gimbal camera 'viewer distance'.. how to fix this
// for VectorCamera?
glEnd();

//Restore perspective for next paint
Expand All @@ -438,9 +437,9 @@ void GLView::showSmallaxes()

void GLView::showAxes()
{
// FIXME: doesn't work under Vector Camera
// Large gray axis cross inline with the model
// FIXME: This is always gray - adjust color to keep contrast with background
// FIXME: doesn't work under Vector Camera
// Large gray axis cross inline with the model
// FIXME: This is always gray - adjust color to keep contrast with background
glLineWidth(1);
glColor3d(0.5, 0.5, 0.5);
glBegin(GL_LINES);
Expand Down
5 changes: 2 additions & 3 deletions src/GLView.h
Expand Up @@ -33,7 +33,6 @@ class GLView
public:
GLView();
void setRenderer(Renderer* r);
Renderer *renderer;

void initializeGL();
void resizeGL(int w, int h);
Expand All @@ -56,6 +55,8 @@ class GLView
virtual bool save(const char *filename) = 0;
virtual std::string getRendererInfo() const = 0;

Renderer *renderer;
Camera cam;
size_t far_far_away;
size_t width;
size_t height;
Expand All @@ -66,8 +67,6 @@ class GLView
bool showedges;
bool showcrosshairs;

Camera cam;

#ifdef ENABLE_OPENCSG
GLint shaderinfo[11];
bool is_opencsg_capable;
Expand Down
10 changes: 5 additions & 5 deletions src/OffscreenContextWGL.cc
Expand Up @@ -126,8 +126,8 @@ bool create_wgl_dummy_context(OffscreenContext &ctx)
int chosenformat;
HDC dev_context = GetDC( window );
if ( dev_context == NULL ) {
cerr << "MS GDI - GetDC failed\n";
return false;
cerr << "MS GDI - GetDC failed\n";
return false;
}

ZeroMemory( &pixformat, sizeof( pixformat ) );
Expand Down Expand Up @@ -187,7 +187,7 @@ OffscreenContext *create_offscreen_context(int w, int h)
return NULL;
}

return create_offscreen_context_common( ctx );
return create_offscreen_context_common( ctx );
}

bool teardown_offscreen_context(OffscreenContext *ctx)
Expand All @@ -207,8 +207,8 @@ bool teardown_offscreen_context(OffscreenContext *ctx)

bool save_framebuffer(OffscreenContext *ctx, std::ostream &output)
{
if (!ctx) return false;
if (!ctx) return false;
wglSwapLayerBuffers( ctx->dev_context, WGL_SWAP_MAIN_PLANE );
return save_framebuffer_common( ctx, output );
return save_framebuffer_common( ctx, output );
}

2 changes: 1 addition & 1 deletion src/OffscreenView.cc
Expand Up @@ -23,7 +23,7 @@ OffscreenView::~OffscreenView()
#ifdef ENABLE_OPENCSG
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

Expand Down
2 changes: 1 addition & 1 deletion src/OffscreenView.h
Expand Up @@ -22,7 +22,7 @@ class OffscreenView : public GLView

// overrides
bool save(const char *filename);
std::string getRendererInfo() const;
std::string getRendererInfo() const;
#ifdef ENABLE_OPENCSG
void display_opencsg_warning();
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/QGLView.cc
Expand Up @@ -63,7 +63,7 @@ static bool running_under_wine = false;

void QGLView::init()
{
cam.type = Camera::GIMBAL;
cam.type = Camera::GIMBAL;
cam.object_rot << 35, 0, -25;
cam.object_trans << 0, 0, 0;
cam.viewer_distance = 500;
Expand All @@ -89,7 +89,7 @@ void QGLView::initializeGL()
if (GLEW_OK != err) {
fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
}
GLView::initializeGL();
GLView::initializeGL();
}

std::string QGLView::getRendererInfo() const
Expand Down
2 changes: 1 addition & 1 deletion src/export.cc
Expand Up @@ -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);
try {
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_const_iterator VCI;
Expand Down
26 changes: 13 additions & 13 deletions src/export_png.cc
Expand Up @@ -75,22 +75,22 @@ void export_png_with_opencsg(Tree &tree, Camera &cam, std::ostream &output)

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;
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(&opencsgRenderer);
OpenCSG::setContext(0);
OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject);
csgInfo.glview->paintGL();
csgInfo.glview->save(output);
csgInfo.glview->setRenderer(&opencsgRenderer);
OpenCSG::setContext(0);
OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject);
csgInfo.glview->paintGL();
csgInfo.glview->save(output);
#else
fprintf(stderr,"This openscad was built without OpenCSG support\n");
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/imageutils.cc
Expand Up @@ -5,15 +5,15 @@

void flip_image(const unsigned char *src, unsigned char *dst, size_t pixelsize, size_t width, size_t height)
{
assert( src && dst );
size_t rowBytes = pixelsize * width;
for (size_t i = 0 ; i < height ; i++) {
assert( src && dst );
size_t rowBytes = pixelsize * width;
for (size_t i = 0 ; i < height ; i++) {
memmove(dst + (height - i - 1) * rowBytes, src + i * rowBytes, rowBytes);
}
}

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 );
if (fstream.is_open()) {
write_png( fstream, pixels, width, height );
Expand Down
2 changes: 1 addition & 1 deletion src/openscad.cc
Expand Up @@ -194,7 +194,7 @@ int main(int argc, char **argv)
("version,v", "print the version")
("render", "if exporting a png image, do a full CGAL render")
("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")
("o,o", po::value<string>(), "out-file")
("s,s", po::value<string>(), "stl-file")
Expand Down

0 comments on commit 94d4acf

Please sign in to comment.