Changeset 42

Show
Ignore:
Timestamp:
01/06/09 16:35:52 (3 years ago)
Author:
mirko
Message:

Removed --transition switch in favor of reading
transitions from the PDF file. Added a dialog to open files when
no file is given on the command line (this is so the first "GUI"
version of PDFCube).

Less 3D transition animation emphasis.

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r29 r42  
     12009-01-06  Mirko Maischberger  <mirko.maischberger@gmail.com> 
     2        * src/pdfcube.cc: Removed --transition switch in favor of reading 
     3        transitions from the PDF file. Added a dialog to open files when 
     4        no file is given on the command line (this is so the first "GUI" 
     5        version of PDFCube) 
     6         
    172008-11-23  Mirko Maischberger  <mirko.maischberger@gmail.com> 
    28        * man/: moved pdfcube.1 manpage inside man folder. 
  • trunk/src/pdfcube.cc

    r41 r42  
    6161#define DEFAULT_TITLE  "PDFCube" 
    6262#define N_FRAMES 30 
    63 #define TIMEOUT_INTERVAL 38 
     63#define TIMEOUT_INTERVAL 25 
    6464 
    6565////////////////////////////////////////////////////////////////////////// 
     
    9999static GLfloat clear_color[4] = { 0.6, 0.0, 0.0, 0.0 }; 
    100100static GLfloat top_color[4] = { 0.7, 0.6, 0.6, 0.0 }; 
    101 static double animation_emphasis = 3.0; 
     101static double animation_emphasis = 2.4; 
    102102 
    103103static bool 
     
    10391039    poppler_page_get_size(page, &w, &h); 
    10401040    poppler_page_render_to_pixbuf(page, 0, 0, iWidth, iHeight, 
    1041                                   1.0 * iWidth / w, 0, pm); 
     1041                                  ((double)iWidth)/w, 0, pm); 
    10421042  } 
    10431043 
     
    15411541        g_print("Advance key\n"); 
    15421542#endif 
    1543         if (page_transition[pc->page()]and sleeping()) 
     1543        if (page_transition[(pc->page()+1)%pc->pages()] and sleeping()) 
    15441544          start_animation(widget, CUBE_NEXT); 
    15451545        else if (sleeping()) 
     
    18691869    ("top-color,t", po::value<std::string>(), 
    18701870     "Cube top color in 'r:g:b' format again with reals in [0,1].") 
    1871     ("transitions,c", po::value<std::vector<int> >()->multitoken(),  
    1872      "Pages at wich to do a cube transition by default eg. 2 4 7\nMust be the last option on the command line.") 
    18731871    ("input-file,i", po::value<std::string>(), "PDF file to show.") 
    18741872    ("no-fullscreen,n",  
     
    18931891    cout << endl; 
    18941892    cout << "Usage examples:" << endl; 
     1893    cout << "  $ pdfcube" << endl; 
    18951894    cout << "  $ pdfcube presentation.pdf" << endl; 
    1896     cout << "  $ pdfcube presentation.pdf --bgcolor 0:0:0 --top-color 0.6:0.2:0.2 --transitions 1 5 7" 
    1897          << endl  
    1898          << "  (floating point numbers are locale aware on some C libraries)" 
    1899          << endl << endl << endl; 
     1895    cout <<  
     1896      "  $ pdfcube presentation.pdf --bgcolor 0:0:0 --top-color 0.6:0.2:0.2" << 
     1897      endl << endl << 
     1898      "  The \"Box\" transition present in PDF files is rendered as a 3D cube."  
     1899         << 
     1900      endl << 
     1901      "  (e.g in beamer you can use the \\transboxin command)" << 
     1902      endl << endl << 
     1903      "  If no file is given on the command line a file open dialog is shown."  
     1904         << 
     1905      endl << endl << 
     1906      "  NB: floating point numbers are locale aware on some C libraries." << 
     1907      endl << endl << endl; 
    19001908    return 0; 
    19011909  } 
     
    19671975 
    19681976  if (document == NULL) { 
    1969     perror("Invaild PDF file."); 
     1977    cerr << "Invaild PDF file." << endl; 
    19701978    exit(1); 
    19711979  } 
     
    19731981  pc = new pdfcube(document); 
    19741982 
     1983  // Read transitions form PDF file 
    19751984  page_transition = new bool[pc->pages()]; 
    1976   std::fill(&page_transition[0], &page_transition[pc->pages()], false); 
    1977   if(vm.count("transitions")) { 
    1978     vector<int> tr = vm["transitions"].as<std::vector<int> >(); 
    1979     for (std::vector<int>::iterator ii = tr.begin(); ii != tr.end(); ++ii) { 
    1980       if(*ii > pc->pages() || *ii < 1)  
     1985  for(int ii(0); ii != pc->pages(); ++ii) 
     1986    { 
     1987      PopplerPage* page =  
     1988        poppler_document_get_page(document, ii); 
     1989      PopplerPageTransition* transition =  
     1990        poppler_page_get_transition(page); 
     1991      if(!transition)  
    19811992        { 
    1982           cerr << "Transision after end of file." << endl; 
     1993          page_transition[ii] = false; 
    19831994        } 
    19841995      else 
    19851996        { 
    1986           page_transition[*ii-1] = true; 
    1987 #ifndef NDEBUG 
    1988           cerr << "Transision at: " << (*ii-1) << endl; 
    1989 #endif 
     1997          switch(transition->type) 
     1998            { 
     1999            case POPPLER_PAGE_TRANSITION_REPLACE: 
     2000              page_transition[ii] = false; 
     2001              break; 
     2002            case POPPLER_PAGE_TRANSITION_BOX: 
     2003              page_transition[ii] = true; 
     2004              break; 
     2005            default: 
     2006              cerr << "Unsuported transition type (" << transition->type  
     2007                   << ") at page " << (ii+1) << endl; 
     2008              break; 
     2009            } 
    19902010        } 
    19912011    } 
    1992   } 
    1993  
     2012   
    19942013  /* Create and show the application window. */ 
    19952014  window = create_window(glconfig);