Changeset 639


Ignore:
Timestamp:
Dec 5, 2007, 7:02:02 PM (17 years ago)
Author:
garnier
Message:

amelioration du ticket #66

Location:
trunk/geant4/visualization/OpenGL
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/visualization/OpenGL/include/G4OpenGLQtExportDialog.hh

    r633 r639  
    5757      @param parent : parent widget
    5858      @param name : name of the saved file with extention
     59      @param format : format of save file in lower case
    5960      @param height : height of the original file
    6061      @param width : width of the original file
    6162  */
    62   G4OpenGLQtExportDialog(QWidget* parent, QString name, int height =0, int width=0);
     63  G4OpenGLQtExportDialog(QWidget* parent, QString name, QString format, int height =0, int width=0);
    6364
    6465  /** Destroys G4OpenGLQtExportDialog */
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtExportDialog.cc

    r638 r639  
    5151 QWidget* parent
    5252,QString nomFich
     53,QString format
    5354 ,int aHeight
    5455 ,int aWidth
     
    7576
    7677 
    77   if (nomFich.endsWith(".jpg") ||
    78       nomFich.endsWith(".jpeg")) {
     78  if ((format == "jpg") ||
     79      (format == "jpeg")) {
    7980   
    8081    QGroupBox *imageGroupBox = new QGroupBox(tr("Image quality"),this);
     
    114115  // This is not working for PS and PDF images, it does nothing.
    115116  // Image is staying in color mode
    116   //  if ((nomFich.endsWith(".ps")) || (nomFich.endsWith(".pdf")) || (nomFich.endsWith(".eps"))) {
    117   if ((nomFich.endsWith(".eps"))) {
    118 
     117  //  if ((format == "ps") || (format == "pdf") || (format == "eps")) {
     118
     119 if (format == ".eps") {
    119120
    120121    QWidget * EPSWidgetGroupBox; // widget containing group button
     
    157158  // Not implented. Should deal with alpha channel
    158159
    159 //   if(nomFich.endsWith(".tif") ||
    160 //      nomFich.endsWith(".tiff") ||
    161 //      nomFich.endsWith(".jpg") ||
    162 //      nomFich.endsWith(".jpeg") ||
    163 //      nomFich.endsWith(".png") ||
    164 //      nomFich.endsWith(".xpm")) {
     160//   if((format == "tif") ||
     161//      (format == "tiff") ||
     162//      (format == "jpg") ||
     163//      (format == "jpeg") ||
     164//      (format == "png") ||
     165//      (format == "xpm")) {
    165166
    166167//     QGroupBox *transparencyGroupBox = new QGroupBox(tr("Transparency"),this);
     
    186187  QButtonGroup * sizeButtonGroupBox; // group button
    187188  QLayout *sizeGroupBoxLayout;
     189
    188190#if QT_VERSION < 0x040000
    189191  sizeButtonGroupBox = new QButtonGroup ( 2,Qt::Vertical, tr("Size"),this);
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r638 r639  
    10621062  filters += "ps;;";
    10631063  filters += "pdf";
    1064   QString* selectedFilter = new QString();
     1064  QString* selectedFormat = new QString();
    10651065#if QT_VERSION < 0x040000
    10661066  QString nomFich =  QFileDialog::getSaveFileName ( ".",
     
    10691069                                                    "Save file dialog",
    10701070                                                    tr("Save as ..."),
    1071                                                     selectedFilter );
     1071                                                    selectedFormat );
    10721072#else
    10731073  QString nomFich =  QFileDialog::getSaveFileName ( GLWindow,
     
    10751075                                                    ".",
    10761076                                                    filters,
    1077                                                     selectedFilter );
     1077                                                    selectedFormat );
    10781078#endif
    10791079  // bmp jpg jpeg png ppm xbm xpm
     
    10821082  }
    10831083#if QT_VERSION < 0x040000
    1084   nomFich += "."+selectedFilter->lower();
    1085 #ifdef GEANT4_QT_DEBUG
    1086   printf("G4OpenGLQtViewer::name %s\n",nomFich.ascii());
    1087 #endif
    1088 #else
    1089   nomFich += "."+selectedFilter->toLower();
    1090 #ifdef GEANT4_QT_DEBUG
    1091   printf("G4OpenGLQtViewer::name %s\n",nomFich.toStdString().c_str());
    1092 #endif
    1093 #endif
    1094   G4OpenGLQtExportDialog* exportDialog= new G4OpenGLQtExportDialog(GLWindow,nomFich,fWindow->height(),fWindow->width());
     1084  nomFich += "."+QString(selectedFormat->ascii());
     1085  QString format = selectedFormat->lower();
     1086#else
     1087  nomFich += "."+QString(selectedFormat->toStdString().c_str());
     1088  QString format = selectedFormat->toLower();
     1089#endif
     1090  G4OpenGLQtExportDialog* exportDialog= new G4OpenGLQtExportDialog(GLWindow,nomFich,format,fWindow->height(),fWindow->width());
    10951091  if(  exportDialog->exec()) {
    10961092
     
    11191115      image = fWindow->grabFrameBuffer();
    11201116    }   
    1121     // jpeg format
    1122     if (nomFich.endsWith(".eps")) {
     1117    if (format == QString("eps")) {
    11231118      generateEPS(nomFich,exportDialog->getNbColor(),image);
    1124     } else if (nomFich.endsWith(".ps") ||nomFich.endsWith(".pdf")) {
     1119    } else if ((format == "ps") || (format == "pdf")) {
    11251120      generatePS_PDF(nomFich,exportDialog->getNbColor(),image);
    1126     } else if (nomFich.endsWith(".tif") ||
    1127                nomFich.endsWith(".tiff") ||
    1128                nomFich.endsWith(".jpg") ||
    1129                nomFich.endsWith(".jpeg") ||
    1130                nomFich.endsWith(".png") ||
    1131                nomFich.endsWith(".ppm") ||
    1132                nomFich.endsWith(".bmp") ||
    1133                nomFich.endsWith(".xbm") ||
    1134                nomFich.endsWith(".xpm")) {
     1121  } else if ((format == "tif") ||
     1122             (format == "tiff") ||
     1123             (format == "jpg") ||
     1124             (format == "jpeg") ||
     1125             (format == "png") ||
     1126             (format == "pbm") ||
     1127             (format == "pgm") ||
     1128             (format == "ppm") ||
     1129             (format == "bmp") ||
     1130             (format == "xbm") ||
     1131             (format == "xpm")) {
     1132#if QT_VERSION < 0x040000
     1133      bool res = image.save(nomFich,selectedFormat->ascii(),exportDialog->getSliderValue());
     1134#else
    11351135      bool res = image.save(nomFich,0,exportDialog->getSliderValue());
     1136#endif
    11361137      if (res == false) {
    11371138        G4cerr << "Error while saving file...\n" << G4endl;
    11381139      }
    1139 #ifdef GEANT4_QT_DEBUG
    1140       printf("saving ELSE %d\n",res);
    1141 #endif
    11421140    } else {
    11431141      G4cerr << "This version of G4UI Could not generate the selected format\n" << G4endl;
Note: See TracChangeset for help on using the changeset viewer.