- Timestamp:
- Sep 26, 2007, 12:17:30 PM (17 years ago)
- Location:
- trunk/geant4/visualization
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/G4History.macro
r580 r586 59 59 /gui/addButton viewer "Update scene" "/vis/scene/notifyHandlers" 60 60 /N03/event/printModulo 100 61 /run/beamOn 1 -
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtExportDialog.hh
r585 r586 58 58 int getWidth(); 59 59 int getHeight(); 60 int getTransparency(); 61 int getNbColor(); 60 62 61 63 public slots: … … 74 76 QPushButton* buttonOk; 75 77 QPushButton* buttonCancel; 76 // QButtonGroup* GroupBox1, *GroupBox2; 77 QCheckBox* boxEPS,*boxTransparency; 78 QCheckBox* transparencyEPS,*boxTransparency; 78 79 QCheckBox* ratioCheckBox; 79 80 QSlider * qualitySlider; -
trunk/geant4/visualization/OpenGL/include/G4OpenGLQtViewer.hh
r585 r586 48 48 #include <QMenu> 49 49 #include <QPoint> 50 #include <QImage> 50 51 51 52 class G4OpenGLSceneHandler; … … 79 80 void createRadioAction(QAction *,QAction *, const std::string&,unsigned int a=1); 80 81 void rescaleImage(int, int); 81 82 int generateEPS(QString,int,QImage); 83 82 84 QMenu *fContextMenu; 83 85 bool fMouseAction; // 1: rotate 0:move -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtExportDialog.cc
r585 r586 92 92 QVBoxLayout *EPSGroupBoxLayout = new QVBoxLayout; 93 93 94 boxEPS = new QCheckBox( "boxEPS" );95 boxEPS->setText( "save background" );96 boxEPS->setChecked( true );94 transparencyEPS = new QCheckBox( "transparencyEPS" ); 95 transparencyEPS->setText( "save background" ); 96 transparencyEPS->setChecked( true ); 97 97 98 98 color = new QRadioButton("Color"); … … 100 100 color->setChecked( true ); 101 101 BW->setChecked( false ); 102 103 connect( color, SIGNAL( toggled(bool) ), BW, SLOT( setChecked(bool) ) ); 104 connect( BW, SIGNAL( toggled(bool) ), color, SLOT( setChecked(bool) ) ); 105 106 107 EPSGroupBoxLayout->addWidget(boxEPS); 102 103 104 EPSGroupBoxLayout->addWidget(transparencyEPS); 108 105 EPSGroupBoxLayout->addWidget(color); 109 106 EPSGroupBoxLayout->addWidget(BW); … … 157 154 ratioCheckBox->setVisible(modify->isChecked()); 158 155 159 connect( original, SIGNAL( toggled(bool) ), modify, SLOT( setChecked(bool) ) ); 160 connect( modify, SIGNAL( toggled(bool) ), original, SLOT( setChecked(bool) ) ); 161 connect( modify, SIGNAL( toggled(bool) ), this, SLOT( changeSizeBox(bool) ) ); 156 connect( original, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(true)) ); 157 connect( modify, SIGNAL( clicked(bool) ), this, SLOT( changeSizeBox(false) ) ); 162 158 163 159 // height … … 235 231 } 236 232 237 238 void G4OpenGLQtExportDialog::changeSizeBox(bool aChange) 239 { 240 heightWidget->setVisible(modify->isChecked()); 241 widthWidget->setVisible(modify->isChecked()); 242 ratioCheckBox->setVisible(modify->isChecked()); 233 int G4OpenGLQtExportDialog::getTransparency() 234 { 235 return boxTransparency->isChecked(); 236 } 237 238 int G4OpenGLQtExportDialog::getColorValue() 239 { 240 if (!color->isChecked()) 241 return 1; 242 if (color->isChecked() && transparencyEPS->isChecked()) 243 return 4; 244 return 3; 245 } 246 247 248 void G4OpenGLQtExportDialog::changeSizeBox(bool aClick) 249 { 250 if (aClick) { 251 modify->toggle(); 252 } else { 253 original->toggle(); 254 } 255 if ( original->isChecked()) { 256 heightWidget->setVisible(false); 257 widthWidget->setVisible(false); 258 ratioCheckBox->setVisible(false); 259 } else { 260 heightWidget->setVisible(true); 261 widthWidget->setVisible(true); 262 ratioCheckBox->setVisible(true); 263 } 243 264 } 244 265 -
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r585 r586 659 659 QList<QByteArray> formats = QImageWriter::supportedImageFormats (); 660 660 for (int i = 0; i < formats.size(); ++i) { 661 filters +=formats.at(i); 662 if ((i+1) <formats.size()) { 663 filters += ";;"; 664 } 665 } 661 filters +=formats.at(i)+";;"; 662 // if ((i+1) <formats.size()) { 663 // filters += ";;"; 664 // } 665 } 666 filters += "eps"; 666 667 QString* selectedFilter = new QString(); 667 668 QString nomFich = QFileDialog::getSaveFileName ( GLWindow, … … 680 681 681 682 printf("rescaling before\n"); 682 QPixmap * pixmap = new QPixmap(fWindow->renderPixmap (exportDialog->getWidth(),exportDialog->getHeight() )) ;//fWindow->grabFrameBuffer(); 683 // QPixmap * pixmap = new QPixmap(fWindow->renderPixmap (exportDialog->getWidth(),exportDialog->getHeight() )) ; 684 QImage image = fWindow->grabFrameBuffer(); 683 685 printf("rescaling after\n"); 684 686 687 685 688 if ((exportDialog->getWidth() !=fWindow->width()) || 686 689 (exportDialog->getWidth() !=fWindow->width())) { … … 694 697 nomFich.endsWith(".jpeg")) { 695 698 // grabFrameBuffer() :: Returns an image of the frame buffer. If withAlpha is true the alpha channel is included. 696 pixmap->save(nomFich,0,exportDialog->getSliderValue());699 image.save(nomFich,0,exportDialog->getSliderValue()); 697 700 printf("saving jpeg quality : %d\n",exportDialog->getSliderValue()); 698 701 } else if (nomFich.endsWith(".eps")) { 699 printf("saving EPS\n");702 generateEPS(nomFich,exportDialog->getNbColor(),image); 700 703 } else if (nomFich.endsWith(".tif") || 701 704 nomFich.endsWith(".tiff") || … … 704 707 nomFich.endsWith(".bmp") || 705 708 nomFich.endsWith(".xpm")) { 706 pixmap->save(nomFich,0,exportDialog->getSliderValue());709 image.save(nomFich,0,exportDialog->getSliderValue()); 707 710 printf("saving ELSE\n"); 708 711 } else { … … 940 943 ,int aHeight 941 944 ){ 942 printf(""); 945 printf("should rescale \n"); 946 } 947 948 /** 949 Generate Postscript form image 950 @param aFilename : name of file 951 @param aInColor : numbers of colors : 1->BW 2->RGB 3->RGB+Alpha 952 @param aImage : Image to print 953 */ 954 int G4OpenGLQtViewer::generateEPS ( 955 QString aFilename 956 ,int aInColor 957 ,QImage aImage 958 ) 959 { 960 961 printf("saving EPS\n"); 962 963 FILE* fp; 964 965 const uchar * pixels = aImage.bits (); 966 // pixels = grabPixels (inColour, width, height); 967 968 if (pixels == NULL) 969 return 1; 970 971 fp = fopen (aFilename.toStdString().c_str(), "w"); 972 if (fp == NULL) { 973 return 2; 974 } 975 976 fprintf (fp, "%%!PS-Adobe-2.0 EPSF-1.2\n"); 977 fprintf (fp, "%%%%Title: %s\n", aFilename.toStdString().c_str()); 978 fprintf (fp, "%%%%Creator: OpenGL pixmap render output\n"); 979 fprintf (fp, "%%%%BoundingBox: 0 0 %d %d\n", fWindow->width(), fWindow->height()); 980 fprintf (fp, "%%%%EndComments\n"); 981 fprintf (fp, "gsave\n"); 982 fprintf (fp, "/bwproc {\n"); 983 fprintf (fp, " rgbproc\n"); 984 fprintf (fp, " dup length 3 idiv string 0 3 0 \n"); 985 fprintf (fp, " 5 -1 roll {\n"); 986 fprintf (fp, " add 2 1 roll 1 sub dup 0 eq\n"); 987 fprintf (fp, " { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n"); 988 fprintf (fp, " 3 1 roll 5 -1 roll } put 1 add 3 0 \n"); 989 fprintf (fp, " { 2 1 roll } ifelse\n"); 990 fprintf (fp, " }forall\n"); 991 fprintf (fp, " pop pop pop\n"); 992 fprintf (fp, "} def\n"); 993 fprintf (fp, "systemdict /colorimage known not {\n"); 994 fprintf (fp, " /colorimage {\n"); 995 fprintf (fp, " pop\n"); 996 fprintf (fp, " pop\n"); 997 fprintf (fp, " /rgbproc exch def\n"); 998 fprintf (fp, " { bwproc } image\n"); 999 fprintf (fp, " } def\n"); 1000 fprintf (fp, "} if\n"); 1001 fprintf (fp, "/picstr %d string def\n", fWindow->width() * aInColor); 1002 fprintf (fp, "%d %d scale\n", fWindow->width(), fWindow->height()); 1003 fprintf (fp, "%d %d %d\n", fWindow->width(), fWindow->height(), 8); 1004 fprintf (fp, "[%d 0 0 %d 0 0]\n", fWindow->width(), fWindow->height()); 1005 fprintf (fp, "{currentfile picstr readhexstring pop}\n"); 1006 fprintf (fp, "false %d\n", aInColor); 1007 // fprintf (fp, "%%BeginData: %d ASCII Bytes\n",size); 1008 fprintf (fp, "colorimage\n"); 1009 1010 printf("boucle jusque :%d/%d par ligne:%d \n",fWindow->width()*fWindow->height()*aInColor,aImage.numBytes(),aImage.bytesPerLine ()); 1011 1012 int pos =0; 1013 for (int i = 0;i<fWindow->width()*fWindow->height()*aInColor; i++) { 1014 fprintf (fp, "%02hx ", pixels[i]); 1015 if (++pos >= aImage.bytesPerLine ()) { 1016 fprintf (fp, "\n"); 1017 pos = 0; 1018 } 1019 } 1020 1021 if (pos) 1022 fprintf (fp, "\n"); 1023 1024 fprintf (fp, "grestore\n"); 1025 fprintf (fp, "showpage\n"); 1026 // delete pixels; 1027 fclose (fp); 1028 return 0; 943 1029 } 944 1030 #endif
Note: See TracChangeset
for help on using the changeset viewer.