Changeset 580 for trunk/geant4/visualization/OpenGL/src
- Timestamp:
- Sep 20, 2007, 5:24:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc
r579 r580 45 45 #include "G4Normal3D.hh" 46 46 #include "G4Scene.hh" 47 #include "G4OpenGLQtExportDialog.h" 47 48 48 49 #include "G4Qt.hh" … … 52 53 #include <QtGui/qdialog.h> 53 54 #include <QtGui/qmenu.h> 55 #include <QImageWriter> 56 #include <QMessageBox> 54 57 #include <QFileDialog.h> 55 58 … … 653 656 654 657 void G4OpenGLQtViewer::actionCreateEPS() { 655 //QString QFileDialog::getSaveFileName ( QWidget * parent = 0, 656 // const QString & caption = QString(), 657 // const QString & dir = QString(), 658 // const QString & filter = QString(), 659 // QString * selectedFilter = 0, Options options = 0 ) 660 QString nomFich = QFileDialog::getSaveFileName(GLWindow, 661 "Choose a file", 662 ".", tr("Images (*.BMP *.GIF *.JPG *.JPEG *.PNG *.PBM *.PGM *.PPM *.TIFF *.XBM *.XPM)") ); 663 664 if(!nomFich.endsWith(".eps")) { 665 printf("G4OpenGLQtViewer::actionCreateEPS() COULD NOT GENERATE EPS FOR THE MOMENT\n"); 666 } else { 658 QString filters; 659 QList<QByteArray> formats = QImageWriter::supportedImageFormats (); 660 for (int i = 0; i < formats.size(); ++i) { 661 filters +="."+formats.at(i); 662 if ((i+1) <formats.size()) { 663 filters += ";;"; 664 } 665 } 666 667 QString nomFich = QFileDialog::getSaveFileName ( GLWindow, 668 tr("Save as ..."), 669 ".", 670 filters ); 671 // bmp jpg jpeg png ppm xbm xpm 672 if(nomFich.endsWith(".eps")) { 673 G4cerr << "This version of G4UI Could not generate EPS." << G4endl; 674 } else if(nomFich.endsWith(".jpg") || nomFich.endsWith(".jpeg")) { 675 G4cerr << "Should display a quality selector" << G4endl; 676 G4OpenGLQtExportDialog* exportDialog= new G4OpenGLQtExportDialog(false, this,"exportDialog",TRUE,WStyle_Tool|WDestructiveClose); 667 677 fWindow->grabFrameBuffer().save(nomFich); 668 } 678 } else { 679 fWindow->grabFrameBuffer().save(nomFich); 680 // grabFrameBuffer() :: Returns an image of the frame buffer. If withAlpha is true the alpha channel is included. 681 } 682 669 683 printf("G4OpenGLQtViewer::actionCreateEPS() \n"); 670 684 } 685 686 /* 687 // http://www.google.com/codesearch?hl=en&q=+jpg+Qt+quality+QDialog+show:FZkUoth8oiw:TONpW2mR-_c:tyTfrKMO-xI&sa=N&cd=2&ct=rc&cs_p=http://soft.proindependent.com/src/qtiplot-0.8.9.zip&cs_f=qtiplot-0.8.9/qtiplot/src/application.cpp#a0 688 void ApplicationWindow::exportLayer() 689 { 690 QWidget *w=ws->activeWindow(); 691 if (!w || !w->isA("MultiLayer")) 692 return; 693 694 Graph* g = ((MultiLayer*)w)->activeGraph(); 695 if (!g) 696 return; 697 698 ImageExportDialog *ied = new ImageExportDialog(this, 0); 699 ied->setDir(workingDir); 700 if ( ied->exec() == QDialog::Accepted ) 701 { 702 workingDir = ied->dirPath(); 703 QString fname = ied->selectedFile(); 704 QString selectedFilter = ied->selectedFilter(); 705 706 QFileInfo fi(fname); 707 QString baseName = fi.fileName(); 708 709 if (baseName.contains(".")==0) 710 fname.append(selectedFilter.remove("*")); 711 712 if ( QFile::exists(fname) && 713 QMessageBox::question(0, tr("QtiPlot - Overwrite File?"), 714 tr("A file called: <p><b>%1</b><p>already exists. " 715 "Do you want to overwrite it?") 716 .arg(fname), 717 tr("&Yes"), tr("&No"), 718 QString::null, 0, 1 ) ) 719 return ; 720 else 721 { 722 QFile f(fname); 723 if ( !f.open( IO_WriteOnly ) ) 724 { 725 QMessageBox::critical(0, tr("QtiPlot - Export Error"), 726 tr("Could not write to file: <br><h4> %1 </h4><p>Please verify that you have the right to write to this location!").arg(fname)); 727 return; 728 } 729 730 if (selectedFilter.contains(".eps")) 731 { 732 if (ied->showExportOptions()) 733 { 734 epsExportDialog *ed= new epsExportDialog (fname, this, "exportDialog", TRUE, WStyle_Tool|WDestructiveClose); 735 connect (ed, SIGNAL(exportToEPS(const QString&, int, QPrinter::Orientation, QPrinter::PageSize, QPrinter::ColorMode)), 736 g, SLOT(exportToEPS(const QString&, int, QPrinter::Orientation, QPrinter::PageSize, QPrinter::ColorMode))); 737 738 ed->showNormal(); 739 ed->setActiveWindow(); 740 } 741 else 742 g->exportToEPS(fname); 743 744 if (((MultiLayer*)w)->hasOverlapingLayers()) 745 ((MultiLayer*)w)->updateTransparency(); 746 return; 747 } 748 else if (selectedFilter.contains(".svg")) 749 { 750 g->exportToSVG(fname); 751 return; 752 } 753 // else if (selectedFilter.contains(".wmf")) 754 // { 755 // g->exportToWmf(fname); 756 // return; 757 } 758 QStringList list=QImage::outputFormatList (); 759 for (int i=0; i<(int)list.count(); i++) 760 { 761 if (selectedFilter.contains("."+(list[i]).lower())) 762 { 763 if (ied->showExportOptions()) 764 { 765 imageExportDialog* ed= new imageExportDialog(false, this,"exportDialog",TRUE,WStyle_Tool|WDestructiveClose); 766 connect (ed, SIGNAL(options(const QString&, const QString&, int, bool)), 767 g, SLOT(exportImage(const QString&, const QString&, int, bool))); 768 769 ed->setExportPath(fname, list[i]); 770 ed->enableTransparency(); 771 ed->showNormal(); 772 ed->setActiveWindow(); 773 } 774 else 775 g->exportImage(fname, list[i], 100, true); 776 777 if (((MultiLayer*)w)->hasOverlapingLayers()) 778 ((MultiLayer*)w)->updateTransparency(); 779 return; 780 } 781 } 782 } 783 } 784 } 785 786 void Graph::exportToSVG(const QString& fname) 787 { 788 // enable workaround for Qt3 misalignments 789 QwtPainter::setSVGMode(true); 790 QPicture picture; 791 QPainter p(&picture); 792 d_plot->print(&p, d_plot->rect()); 793 p.end(); 794 795 picture.save(fname, "svg"); 796 } 797 */ 798 671 799 672 800
Note:
See TracChangeset
for help on using the changeset viewer.
