Changeset 26
- Timestamp:
- 11/20/08 16:01:24 (3 years ago)
- Location:
- branches/pdfcube-0.0.3
- Files:
-
- 3 added
- 4 modified
-
Makefile.am (modified) (1 diff)
-
configure.ac (modified) (3 diffs)
-
m4 (added)
-
m4/ax_boost_base.m4 (added)
-
m4/ax_boost_program_options.m4 (added)
-
src/Makefile.am (modified) (1 diff)
-
src/pdfcube.cc (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pdfcube-0.0.3/Makefile.am
r4 r26 1 1 ## top-level Makefile.am 2 2 3 #Include extra macros 4 ACLOCAL_AMFLAGS = -I m4 5 3 6 #Build in these directories: 4 SUBDIRS = src 7 SUBDIRS = src m4 5 8 6 9 #Distribute these directories: 7 DIST_SUBDIRS = src10 DIST_SUBDIRS = src m4 8 11 9 EXTRA_DIST =autogen.sh12 EXTRA_DIST = autogen.sh -
branches/pdfcube-0.0.3/configure.ac
r4 r26 12 12 AM_INIT_AUTOMAKE(pdfcube, 0.0.2) 13 13 14 AC_CONFIG_MACRO_DIR([m4]) 14 15 15 16 dnl ----------------------------------------------- … … 51 52 AC_CHECK_HEADERS(GL/glut.h) 52 53 54 AX_BOOST_BASE([1.33.1]) 55 AX_BOOST_PROGRAM_OPTIONS() 56 53 57 dnl ----------------------------------------------- 54 58 dnl Generates Makefiles. … … 56 60 57 61 AC_OUTPUT(Makefile \ 58 src/Makefile 62 src/Makefile \ 63 m4/Makefile 59 64 ) -
branches/pdfcube-0.0.3/src/Makefile.am
r3 r26 2 2 3 3 pdfcube_SOURCES = pdfcube.cc 4 pdfcube_CXXFLAGS =-Wall -Weffc++4 pdfcube_CXXFLAGS = -Wall -Weffc++ 5 5 6 INCLUDES = $(glib_CFLAGS) $(gtk_CFLAGS) $(gtkglext_CFLAGS) $(poppler_CFLAGS) $(poppler_glib_CFLAGS) 6 LDADD = $(glib_LIBS) $(gtk_LIBS) $(gtkglext_LIBS) $(poppler_LIBS) $(poppler_glib_LIBS) -lglut 7 INCLUDES = $(glib_CFLAGS) $(gtk_CFLAGS) $(gtkglext_CFLAGS) $(poppler_CFLAGS) $(poppler_glib_CFLAGS) $(BOOST_LDFLAGS) 7 8 8 LDADD = $(glib_LIBS) $(gtk_LIBS) $(gtkglext_LIBS) $(poppler_LIBS) $(poppler_glib_LIBS) -lglut 9 AM_CXXFLAGS = $(BOOST_CPPFLAGS) 10 AM_LDFLAGS=$(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) -
branches/pdfcube-0.0.3/src/pdfcube.cc
r25 r26 43 43 #include <poppler.h> 44 44 45 #include <boost/program_options.hpp> 46 45 47 using namespace std; 48 namespace po = boost::program_options; 46 49 47 50 ////////////////////////////////////////////////////////////////////////// … … 65 68 }; 66 69 67 static gboolean fullscreen = TRUE;70 static gboolean fullscreen; 68 71 static gboolean animating = FALSE; 69 72 animation active_animation = ANIM_NONE; … … 88 91 89 92 static GtkWidget *create_window(GdkGLConfig * glconfig); 93 94 95 static GLfloat clear_color[4] = { 0.6, 0.0, 0.0, 0.0 }; 96 static GLfloat top_color[4] = { 0.7, 0.6, 0.6, 0.0 }; 97 static double animation_emphasis = 3.0; 90 98 91 99 static bool … … 233 241 glPolygonMode(GL_FRONT, GL_FILL); 234 242 glEdgeFlag(GL_FALSE); 235 236 glClearColor( 0.6, 0.0, 0.0, 0.0);243 244 glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]); 237 245 glCullFace(GL_FRONT); 238 246 glDisable(GL_DEPTH_TEST); … … 248 256 glEnable(GL_AUTO_NORMAL); 249 257 glEnable(GL_NORMALIZE); 258 259 glEnable(GL_COLOR_MATERIAL); 260 250 261 #ifdef ENABLE_FOG 251 262 glEnable(GL_FOG); … … 336 347 glMatrixMode(GL_MODELVIEW); 337 348 glLoadIdentity(); 338 lookposz -= 2.0*zsteps[frame];339 lookposy = 3.0*xsteps[frame];349 lookposz -= animation_emphasis*zsteps[frame]; 350 lookposy = 1.5*animation_emphasis*xsteps[frame]; 340 351 gluLookAt(lookposx, lookposy, lookposz, 341 352 atx, aty, atz, 0, 1, 0); … … 764 775 // Initialization of animation vectors 765 776 void matrix_setup() { 766 float step_factor = 0.2 * double(N_FRAMES); //this is little buggy 767 float step = (step_factor) / (double(N_FRAMES)/2.0); 768 int i = 0; 769 for (i = 0; i < N_FRAMES / 2; i++) { 770 steps[i] = i * step; 771 if (steps[i] > step_factor) 772 steps[i] = step_factor; 773 } 774 for (i = N_FRAMES / 2; i < N_FRAMES; i++) { 775 steps[i] = step_factor - (i - double(N_FRAMES) / 2.0) * step; 776 if (steps[i] < 0) 777 steps[i] = 0; 778 } 779 // steps[N_FRAMES - 1] = 0; 780 #ifndef NDEBUG 781 cout << "Step " << step << endl; 777 double sum = 0.; 778 for(int i=0; i<N_FRAMES; i++) 779 { 780 steps[i] =std::pow(::sin(i*M_PI/double(N_FRAMES)), 2); 781 sum += steps[i]; 782 } 783 double factor = 90./sum; 784 for(int i=0; i<N_FRAMES; i++) 785 { 786 steps[i] *= factor; 787 } 788 #ifndef NDEBUG 782 789 cout << "Matrix "; 783 for (i = 0; i < N_FRAMES; i++)790 for (int i = 0; i < N_FRAMES; i++) 784 791 cout << steps[i] << " "; 785 792 cout << endl; … … 789 796 float xstep = 790 797 double (xstep_ratio) / (double(N_FRAMES-1) / 2.0); 791 for (i = 0; i < N_FRAMES / 2; i++) {798 for (int i = 0; i < N_FRAMES / 2; i++) { 792 799 xsteps[i] = i * xstep; 793 800 if (xsteps[i] > xstep_ratio) 794 801 xsteps[i] = xstep_ratio; 795 802 } 796 for (i = N_FRAMES / 2; i < N_FRAMES; i++) {803 for (int i = N_FRAMES / 2; i < N_FRAMES; i++) { 797 804 xsteps[i] = xstep_ratio - (i - double(N_FRAMES-1) / 2.0) * xstep; 798 805 if (xsteps[i] < 0.01) … … 803 810 cout << "Step x " << xstep << endl; 804 811 cout << "Matrix2 "; 805 for (i = 0; i < N_FRAMES; i++)812 for (int i = 0; i < N_FRAMES; i++) 806 813 cout << xsteps[i] << " "; 807 814 cout << endl; … … 810 817 float granular = 0.07; 811 818 float zstep = granular / (double(N_FRAMES) / 4.0); 812 for (i = 0; i < N_FRAMES / 4; i++) {819 for (int i = 0; i < N_FRAMES / 4; i++) { 813 820 zsteps[i] = -i * zstep; 814 821 } 815 for (i = N_FRAMES / 4; i < N_FRAMES / 2; i++) {822 for (int i = N_FRAMES / 4; i < N_FRAMES / 2; i++) { 816 823 zsteps[i] = -granular + (i - double(N_FRAMES) / 4.0) * zstep; 817 824 } 818 for (i = N_FRAMES / 2; i < N_FRAMES; i++) {825 for (int i = N_FRAMES / 2; i < N_FRAMES; i++) { 819 826 zsteps[i] = -zsteps[i - N_FRAMES / 2]; 820 827 } … … 823 830 cout << "Step z " << zstep << endl; 824 831 cout << "Matrix3 "; 825 for (i = 0; i < N_FRAMES; i++)832 for (int i = 0; i < N_FRAMES; i++) 826 833 cout << zsteps[i] << " "; 827 834 cout << endl; … … 830 837 float zoomstop = 0.38; 831 838 float zoomstep = (zoomstop / double (N_FRAMES-1)); 832 for (i = 0; i < N_FRAMES; i++) {839 for (int i = 0; i < N_FRAMES; i++) { 833 840 zoomsteps[i] = i * zoomstep; 834 841 } … … 837 844 cout << "Step zoom " << zoomstep << endl; 838 845 cout << "Matrix4 "; 839 for (i = 0; i < N_FRAMES; i++)846 for (int i = 0; i < N_FRAMES; i++) 840 847 cout << zoomsteps[i] << " "; 841 848 cout << endl; … … 844 851 float perspstart = 44.00; 845 852 float perspstop = 21.00; 846 for (i = 0; i < N_FRAMES; i++) {853 for (int i = 0; i < N_FRAMES; i++) { 847 854 perspsteps[i] = (cos(i*M_PI/(double(N_FRAMES)*2.0)))*(perspstart - perspstop)+perspstop; 848 855 } … … 850 857 // cout << "Step persp " << perspstep << endl; 851 858 cout << "Matrix5 "; 852 for (i = 0; i < N_FRAMES; i++)859 for (int i = 0; i < N_FRAMES; i++) 853 860 cout << perspsteps[i] << " "; 854 861 cout << endl; … … 857 864 float perspcstart = 44.00; 858 865 float perspcstop = 30.00; 859 for (i = 0; i < N_FRAMES; i++) {866 for (int i = 0; i < N_FRAMES; i++) { 860 867 perspstepsc[i] = (1.0+cos(i*M_PI/double(N_FRAMES)))/2.0*(perspcstart - perspcstop)+perspcstop; 861 868 } 862 869 #ifndef NDEBUG 863 870 cout << "Matrix6 "; 864 for (i = 0; i < N_FRAMES; i++)871 for (int i = 0; i < N_FRAMES; i++) 865 872 cout << perspstepsc[i] << " "; 866 873 cout << endl; … … 1039 1046 glNewList(cube_faces+i,GL_COMPILE); 1040 1047 glBegin(GL_QUADS); 1041 glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][4]) * tex_width, 1042 mapping[i][5] * tex_height); 1048 if(i<4) 1049 glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][4]) * tex_width, 1050 mapping[i][5] * tex_height); 1043 1051 glVertex3fv(&v[faces[i][0]][0]); 1044 1052 1045 glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][6]) * tex_width, 1046 mapping[i][7] * tex_height); 1053 if(i<4) 1054 glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][6]) * tex_width, 1055 mapping[i][7] * tex_height); 1047 1056 glVertex3fv(&v[faces[i][1]][0]); 1048 1057 1049 glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][0]) * tex_width, 1050 mapping[i][1] * tex_height); 1058 if(i<4) 1059 glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][0]) * tex_width, 1060 mapping[i][1] * tex_height); 1051 1061 glVertex3fv(&v[faces[i][2]][0]); 1052 1062 1053 glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][2]) * tex_width, 1054 mapping[i][3] * tex_height); 1063 if(i<4) 1064 glMultiTexCoord2f(GL_TEXTURE0_ARB,(1.0 - mapping[i][2]) * tex_width, 1065 mapping[i][3] * tex_height); 1055 1066 glVertex3fv(&v[faces[i][3]][0]); 1056 1067 glEnd(); … … 1081 1092 textures[texmap[2]]); 1082 1093 } else if (i <= 3) { 1094 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); 1083 1095 glDisable(GL_TEXTURE_RECTANGLE_ARB); 1084 glColor4f( 0.4, 0.0, 0.0, 1.0);1096 glColor4f(top_color[0], top_color[1], top_color[2], top_color[4]); 1085 1097 } else { 1098 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); 1086 1099 glDisable(GL_TEXTURE_RECTANGLE_ARB); 1087 glColor4f( 1.0, 1.0, 1.0, 1.0);1100 glColor4f(top_color[0], top_color[1], top_color[2], top_color[4]); 1088 1101 } 1089 1102 glPolygonMode(GL_FRONT, GL_FILL); … … 1096 1109 GLfloat 1097 1110 pdfcube::n[6][3] = { 1098 {0.0, 0.0, -1.0} 1099 , {1.0, 0.0, 0.0} 1100 , {0.0, 0.0, 1.0} 1101 , {-1.0, 0.0, 0.0} 1102 , 1103 {0.0, 1.0, 0.0} 1104 , {0.0, -1.0, 0.0} 1111 {0.0, 0.0, -1.0}, 1112 {1.0, 0.0, 0.0}, 1113 {0.0, 0.0, 1.0}, 1114 {-1.0, 0.0, 0.0}, 1115 {0.0, 1.0, 0.0}, 1116 {0.0, -1.0, 0.0} 1105 1117 }; 1106 1118 //bcube faces 1107 1119 GLint 1108 1120 pdfcube::faces[6][4] = { 1109 {7, 4, 0, 3} 1110 , {7, 6, 5, 4} 1111 , {5, 6, 2, 1} 1112 , {0, 1, 2, 3} 1113 , 1114 {3, 2, 6, 7} 1115 , {4, 5, 1, 0} 1121 {7, 4, 0, 3}, 1122 {7, 6, 5, 4}, 1123 {5, 6, 2, 1}, 1124 {0, 1, 2, 3}, 1125 {3, 2, 6, 7}, 1126 {4, 5, 1, 0} 1116 1127 }; 1117 1128 // face mapping … … 1133 1144 1134 1145 // the pdf-cube 1135 pdfcube * 1136 pc; 1146 pdfcube* pc; 1137 1147 1138 1148 ////////////////////////////////////////////////////////////////////////// … … 1827 1837 ////////////////////////////////////////////////////////////////////////// 1828 1838 // Main function: should we use getopts? (who doesn't?) 1839 // (update: we do, let's use boost::program_options ;)) 1829 1840 1830 1841 int 1831 1842 main(int argc, char *argv[]) 1832 1843 { 1844 1845 po::options_description opts("Available options"); 1846 1847 opts.add_options() 1848 ("help,h", 1849 "This help message.") 1850 ("bgcolor,b", po::value<std::string>(), 1851 "Background color is 'r,g,b' with real values between 0.0 and 1.0, no spaces.") 1852 ("top-color,t", po::value<std::string>(), 1853 "Cube top color in 'r,g,b' format again with reals in [0,1].") 1854 ("transitions,c", po::value<std::vector<int> >()->multitoken(), 1855 "Pages at wich to do a cube transition by default eg. 2 4 7\nMust be the last option on the command line.") 1856 ("input-file,i", po::value<std::string>(), "PDF file to show.") 1857 ("no-fullscreen,n", 1858 "Don't activate full-screen mode by default."); 1859 1860 po::positional_options_description p; 1861 p.add("input-file", -1); 1862 1863 po::variables_map vm; 1864 po::store(po::command_line_parser(argc, argv). 1865 options(opts).positional(p).run(), vm); 1866 po::notify(vm); 1867 1868 string input_file; 1869 1870 if(vm.count("help")) { 1871 cout << endl << "PDFCube 0.0.3" << endl; 1872 cout << "=============" << endl; 1873 cout << "Copyright (C) 2006-2008 Mirko Maischberger <mirko.maischberger@gmail.com>" << endl; 1874 cout << " 2008 Karol Sokolowski <sokoow@gmail.com>" << endl << endl; 1875 cout << opts << endl; 1876 cout << endl; 1877 cout << "Usage examples:" << endl; 1878 cout << " $ pdfcube presentation.pdf" << endl; 1879 cout << " $ pdfcube presentation.pdf --bgcolor 0,0,0 --top-color 0.6,0.2,0.2 --transitions 1 5 7" 1880 << endl << endl << endl; 1881 return 0; 1882 } 1883 1884 if (vm.count("input-file")) { 1885 input_file = vm["input-file"].as<std::string>(); 1886 } else { 1887 cerr << "You must specify an input PDF file on the command line." << endl; 1888 exit(1); 1889 } 1890 1891 if(vm.count("bgcolor")) { 1892 vector<double> cc; 1893 string v; 1894 std::istringstream iss(vm["bgcolor"].as<std::string>()); 1895 while(getline(iss, v, ',')) cc.push_back(::atof(v.c_str())); 1896 if(cc.size() != 3) 1897 { 1898 cerr << "You should specify 3 values for background-color." << endl; 1899 exit(1); 1900 } 1901 std::copy(&cc[0], &cc[3], &clear_color[0]); 1902 } 1903 1904 if(vm.count("top-color")) { 1905 vector<double> tc; 1906 string v; 1907 std::istringstream iss(vm["top-color"].as<std::string>()); 1908 while(getline(iss, v, ',')) tc.push_back(::atof(v.c_str())); 1909 if(tc.size() != 3) 1910 { 1911 cerr << "You should specify 3 values for top-color." << endl; 1912 exit(1); 1913 } 1914 std::copy(&tc[0], &tc[3], &top_color[0]); 1915 } 1916 1833 1917 GtkWidget * 1834 1918 window; … … 1845 1929 glconfig = configure_gl(); 1846 1930 1847 if (argc < 2) {1848 perror("usage: pdfcube file_uri [cube_page ...]");1849 exit(1);1850 }1851 1931 gchar * 1852 absoluteFileName = get_absolute_file_name( argv[1]);1932 absoluteFileName = get_absolute_file_name(input_file.c_str()); 1853 1933 gchar * 1854 1934 filename_uri = g_filename_to_uri(absoluteFileName, NULL, NULL); 1855 1935 g_free(absoluteFileName); 1856 1936 if (NULL == filename_uri) { 1857 cerr << " Errore nel nome del file" << endl;1937 cerr << "File name error." << endl; 1858 1938 } 1859 1939 PopplerDocument * … … 1861 1941 1862 1942 if (document == NULL) { 1863 perror(" invaild pdf file");1864 exit( 2);1943 perror("Invaild PDF file."); 1944 exit(1); 1865 1945 } 1866 1946 … … 1868 1948 1869 1949 page_transition = new bool[pc->pages()]; 1870 1871 for (int ii = 0; ii < pc->pages(); ii++) { 1872 page_transition[ii] = false; 1873 } 1874 1875 for (int ii = 2; ii < argc; ii++) { 1876 page_transition[atoi(argv[ii])] = true; 1950 if(vm.count("transitions")) { 1951 vector<int> tr = vm["transitions"].as<std::vector<int> >(); 1952 for(int ii = 0; ii < pc->pages(); ii++) { 1953 page_transition[ii] = false; 1954 } 1955 for (std::vector<int>::iterator ii = tr.begin(); ii != tr.end(); ++ii) { 1956 if(*ii > pc->pages()) 1957 cerr << "Transision after end of file." << endl; 1958 else 1959 page_transition[*ii-1] = true; 1960 } 1877 1961 } 1878 1962 1879 1963 /* Create and show the application window. */ 1880 1964 window = create_window(glconfig); 1881 1882 if (fullscreen) 1965 1966 if(vm.count("no-fullscreen")) 1967 fullscreen = FALSE; 1968 else 1969 fullscreen = TRUE; 1970 1971 if(fullscreen) 1883 1972 gtk_window_fullscreen((GtkWindow *) (window)); 1884 1973 1885 1974 gtk_widget_show(window); 1886 1975

