Summary: | svg export please (but only if convient and using QPainter) | ||
---|---|---|---|
Product: | [Applications] kalzium | Reporter: | Alan Horkan <alanhorkan> |
Component: | general | Assignee: | Carsten Niehaus <cniehaus> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | FreeBSD | ||
Latest Commit: | Version Fixed In: |
Description
Alan Horkan
2005-07-13 20:23:58 UTC
Good idea. Give us some time :) No hurry, I'm glad you accepted the idea. I'm looking for ways to help promote SVG and OpenClipart.org because I believe it is important to not just use open standards but promote them to hold back proprietary standards. I am also interested in seeing Karbon 14 succeed and being able to work well with other KDE applications could help create more interest in it and in SVG. When I realised QT provided built in SVG support it seemed like a perfect opportunity to encourage various KDE applications to embrace SVG and I filed a few other requests and included the words [SVG Everywhere] in the summaries. I'm looking for other places to suggest SVG too if you have any good ideas. I should have pointed you directly to the kchart svg exporter: http://websvn.kde.org/trunk/koffice/filters/kchart/svg/ Thanks again and although I would love to see this added I dont want to rush you or distract you from the main purpose of Kalzuim with this tangent. Now the following formats are supported: BMP EPS Jpeg2000 Jpeg Portable Bitmap Image Portable Pixmap Image Portable Graymap Image PCX PNG That is at least a good start I would say :) That is an excellent start, particularly Encapsulated Postscript (EPS) support is good as that is what most Vector Graphics applications use for document interchange but being able to work directly with SVG would be even better. With Microsoft coming out with XAML/WVG soon I think it is more important than ever to promote standards like SVG, but like I said before no pressure, no hurry. However, all those formats are not provided by kchart. They are provided by filter chains in the KOffice libs. Kchart itself only provides PNG and SVG. Just a status-update: Ok, we finally depend on Qt 4.3. I am now trying to implement this using some new fancy stuff in it :-) SVN commit 647745 by cniehaus: I added File->Save As... Now the table is "screenshot'ed" and saved in a file the user selects. Have not yet tried the SVG-thing, no idea if that is easy to do or not. cf http://doc.trolltech.com/4.3/qsvggenerator.html CCBUG:109037 M +21 -1 kalzium.cpp M +2 -0 kalzium.h M +2 -2 periodictableview.h --- trunk/KDE/kdeedu/kalzium/src/kalzium.cpp #647744:647745 @@ -72,8 +72,11 @@ #include <kicon.h> #include <kservicetypetrader.h> #include <kurl.h> +#include <kfiledialog.h> +#include <QFileDialog> + #define PeriodicTableView_MARGIN 5 #define IDS_ELEMENTINFO 7 @@ -195,16 +198,18 @@ #else m_EQSolverAction->setEnabled( false ); #endif - + // tools actions m_pPlotAction = actionCollection()->addAction( "tools_plotdata" ); m_pPlotAction->setText( i18n( "&Plot Data..." ) ); m_pPlotAction->setIcon( KIcon( "plot" ) ); connect( m_pPlotAction, SIGNAL( triggered() ), this, SLOT( slotPlotData() ) ); + m_pIsotopeTableAction= actionCollection()->addAction( "tools_isotopetable" ); m_pIsotopeTableAction->setText( i18n( "&Isotope Table..." ) ); m_pIsotopeTableAction->setIcon( KIcon( "isotopemap" ) ); connect( m_pIsotopeTableAction, SIGNAL( triggered() ), this, SLOT( slotIsotopeTable() ) ); + m_pGlossaryAction = actionCollection()->addAction( "tools_glossary" ); m_pGlossaryAction->setText(i18n( "&Glossary..." ) ); m_pGlossaryAction->setIcon( KIcon( "glossary" ) ); @@ -252,6 +257,7 @@ // the standard actions + KStandardAction::saveAs(this, SLOT(slotExportTable()), actionCollection()); KStandardAction::preferences(this, SLOT(showSettingsDialog()), actionCollection()); KStandardAction::quit( kapp, SLOT (closeAllWindows()),actionCollection() ); @@ -316,6 +322,20 @@ addDockWidget( Qt::BottomDockWidgetArea, m_InfoDock ); } +void Kalzium::slotExportTable() +{ + QPixmap pix = QPixmap::grabWidget( m_PeriodicTableView ); + + QString fileName = QFileDialog::getSaveFileName(this, i18n("Save Kalziums Tables in..."), + QString(), + i18n("Images (*.png *.xpm *.jpg)")); + +// QString fn = KFileDialog::getSaveFileName( ); //this methods causes an assert right now... + + pix.save( fileName ); + +} + void Kalzium::slotGlossary() { m_glossarydlg->show(); --- trunk/KDE/kdeedu/kalzium/src/kalzium.h #647744:647745 @@ -168,6 +168,8 @@ void slotPlotData(); + void slotExportTable(); + void slotUpdateSettings(); /** --- trunk/KDE/kdeedu/kalzium/src/periodictableview.h #647744:647745 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2003-2005, 2006 by Carsten Niehaus * + * Copyright (C) 2003-2007 by Carsten Niehaus * * cniehaus@kde.org * * * * This program is free software; you can redistribute it and/or modify * @@ -36,7 +36,7 @@ #include <chemicaldataobject.h> /** - * A PeriodicTableView is the widget on where we paint a periodic table. + * A PeriodicTableView is the widget on which we paint a periodic table. * * It does not contain any code for painting, as all the painting routines * belongs to KalziumPainter. SVN commit 647807 by cniehaus: Ok, the SVG-renderer is in place. Currently, I am getting an assertion when I start a KFileDialog. That is why the name of the svg-file is still hardcoded. I will fix that as soon as my kdelibs is fixed. But it already works, here is a demo-svg: http://websvn.kde.org/trunk/KDE/kdeedu/kalzium/ideas/svg-testoutput.svg?view=log BUG:109037 M +8 -5 kalzium.cpp M +14 -0 periodictableview.cpp M +5 -0 periodictableview.h --- trunk/KDE/kdeedu/kalzium/src/kalzium.cpp #647806:647807 @@ -74,7 +74,7 @@ #include <kurl.h> #include <kfiledialog.h> -#include <QFileDialog> +#include <QSvgGenerator> #define PeriodicTableView_MARGIN 5 @@ -326,13 +326,16 @@ { QPixmap pix = QPixmap::grabWidget( m_PeriodicTableView ); - QString fileName = QFileDialog::getSaveFileName(this, i18n("Save Kalziums Tables in..."), - QString(), - i18n("Images (*.png *.xpm *.jpg)")); + m_PeriodicTableView->generateSvg( "/home/kde4/test2.svg" ); + +//X QString fileName = QFileDialog::getSaveFileName(this, i18n("Save Kalziums Tables in..."), +//X QString(), +//X i18n("Images (*.png *.xpm *.jpg)")); + // QString fn = KFileDialog::getSaveFileName( ); //this methods causes an assert right now... - pix.save( fileName ); +//X pix.save( fileName ); } --- trunk/KDE/kdeedu/kalzium/src/periodictableview.cpp #647806:647807 @@ -42,6 +42,7 @@ #include <QColor> #include <QRect> #include <QDrag> +#include <QSvgGenerator> PeriodicTableView::PeriodicTableView( QWidget *parent ) : QWidget( parent ) @@ -106,6 +107,19 @@ return m_painter->mode(); } +void PeriodicTableView::generateSvg(const QString& filename) +{ + QSvgGenerator *svgGen = new QSvgGenerator(); + + QFile* file = new QFile(); + + svgGen->setFileName( filename ); + + m_painter->begin( svgGen ); + m_painter->drawAll(); + m_painter->end(); +} + void PeriodicTableView::paintEvent( QPaintEvent * e ) { if ( doFullDraw ) --- trunk/KDE/kdeedu/kalzium/src/periodictableview.h #647806:647807 @@ -73,6 +73,11 @@ */ void setValueLimit( int value, ChemicalDataObject::BlueObelisk type ); + /** + * Generate a SVG from the current table and save it in the file @p filename + */ + void generateSvg(const QString& filename); + /** * Sets the scheme to use. * @param nr is the index of the new scheme |