Changeset 9

Show
Ignore:
Timestamp:
03/11/07 17:41:03 (5 years ago)
Author:
mirko
Message:

Better command line parsing,

Location:
trunk/pdfcube/src
Files:
3 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdfcube/src/Makefile.am

    r7 r9  
    11bin_PROGRAMS = pdfcube 
    22 
    3 pdfcube_SOURCES = pdfcube.cc 
    4 pdfcube_CXXFLAGS=-Wall -Weffc++ 
     3pdfcube_SOURCES = pdfcube.cc cmdline.c cmdline.h 
     4 
     5pdfcube_CXXFLAGS=-Wall -Weffc++  
    56 
    67INCLUDES = $(glib_CFLAGS) $(gtk_CFLAGS) $(gtkglext_CFLAGS) $(poppler_CFLAGS) $(poppler_glib_CFLAGS) 
  • trunk/pdfcube/src/llcube.cc

    r3 r9  
     1// -*- mode: C++ -*- 
     2// 
     3// PDF-Cube source file - llcube.cc (low level cube code) 
     4//  
     5// Copyright (C) 2006 Mirko Maischberger <mirko.maischberger@gmail.com> 
     6// 
     7// This program is free software; you can redistribute it and/or modify 
     8// it under the terms of the GNU General Public License as published by 
     9// the Free Software Foundation; either version 2 of the License, or 
     10// (at your option) any later version. 
     11// 
     12// This program is distributed in the hope that it will be useful, 
     13// but WITHOUT ANY WAPRANTY; without even the implied warranty of 
     14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     15// GNU General Public License for more details. 
     16// 
     17// You should have received a copy of the GNU General Public License 
     18// along with this program; if not, write to the Free Software 
     19// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
     20 
    121namespace 100allora { 
    222   
     
    5171           point3d<GLfloat>& looking_at,  
    5272           GLfloat perspective,  
    53            GLfloat angley, GLfloat anglex, GLfloat anglez) 
     73           GLfloat anglex, GLfloat angley, GLfloat anglez) 
    5474    { } 
    5575     
     
    178198    point3d camera_position; 
    179199    point3d looking_at; 
    180  
    181  
    182200  } 
    183  
    184201} 
  • trunk/pdfcube/src/pdfcube.cc

    r3 r9  
    3333#include <gtk/gtkgl.h> 
    3434 
    35 // OpenGL (-lglut) 
     35// OpenGL 
    3636#include <GL/gl.h> 
    3737#include <GL/glu.h> 
     
    3939// PDF to GdkPixbuf (pkg-config poppler-glib) 
    4040#include <poppler.h> 
     41 
     42#include "cmdline.h" 
    4143 
    4244using namespace std; 
     
    5456// Globals (will be moved inside classes some day) 
    5557 
    56 static gboolean fullscreen = TRUE; 
     58static gboolean fullscreen = FALSE; 
    5759static gboolean animating = FALSE; 
    5860 
     
    733735    double w, h; 
    734736    poppler_page_get_size(page, &w, &h); 
    735     poppler_page_render_to_pixbuf(page, 0,0,iWidth,iHeight,1.0*iWidth/w,0,pm); 
     737    poppler_page_render_to_pixbuf(page, 0, 0, iWidth, iHeight, 
     738                                  ((double)iWidth)/w, 0, pm); 
    736739  } 
    737740 
     
    14751478  GdkGLConfig *glconfig; 
    14761479 
     1480  gengetopt_args_info args_info; 
     1481   
     1482  if(cmdline_parser(argc, argv, &args_info) != 0) 
     1483    exit(1); 
     1484      
    14771485  /* Initialize GTK. */ 
    14781486  gtk_init (&argc, &argv); 
     
    14841492  glconfig = configure_gl(); 
    14851493 
    1486   if(argc < 2) 
    1487     { 
    1488       perror("usage: pdfcube file_uri [cube_page ...]"); 
     1494  if(args_info.inputs_num != 1) 
     1495    { 
     1496      cerr << "You must specify a PDF file name"; 
    14891497      exit(1); 
    14901498    } 
    1491   gchar *absoluteFileName = get_absolute_file_name (argv[1]); 
     1499 
     1500  gchar *absoluteFileName = get_absolute_file_name (args_info.inputs[0]); 
    14921501  gchar *filename_uri = g_filename_to_uri (absoluteFileName, NULL, NULL); 
    14931502  g_free (absoluteFileName); 
     
    15141523    } 
    15151524   
    1516   for(int ii = 2; ii < argc; ii++)     
    1517     { 
    1518       page_transition[atoi(argv[ii])] = true; 
    1519     } 
     1525  for(int ii = 0; ii < args_info.cube_given; ii++)     
     1526    { 
     1527      assert(args_info.cube_arg[ii] >= 2); 
     1528      assert(args_info.cube_arg[ii] <= pc->pages()+1); 
     1529      page_transition[args_info.cube_arg[ii]-2] = true; 
     1530    } 
     1531   
    15201532 
    15211533  /* Create and show the application window. */ 
    15221534  window = create_window(glconfig); 
     1535   
     1536  if(args_info.fullscreen_given) fullscreen = true; 
    15231537 
    15241538  if(fullscreen)