[Kst] extragear/graphics/kst/kst

Barth Netterfield netterfield at astro.utoronto.ca
Tue Aug 30 09:11:57 CEST 2005


SVN commit 454889 by netterfield:

Read a matrix to an image from the command line:
kst -M M1 l5b.fits



 M  +0 -2      datasources/qimagesource/qimagesource.cpp  
 M  +20 -1     main.cpp  


--- trunk/extragear/graphics/kst/kst/datasources/qimagesource/qimagesource.cpp #454888:454889
@@ -18,7 +18,6 @@
 #include "qimagesource.h"
 #include <qcolor.h>
 
-#include <stdio.h>
 
 QimagesourceSource::QimagesourceSource(KConfig *cfg, const QString& filename, const QString& type)
 : KstDataSource(cfg, filename, type) {
@@ -235,7 +234,6 @@
 }
 
 int understands_qimagesource(KConfig*, const QString& filename) {
-
   QString ftype( QImage::imageFormat( filename ) );
 
   if ( ftype.isEmpty() ) return 0;
--- trunk/extragear/graphics/kst/kst/main.cpp #454888:454889
@@ -39,6 +39,7 @@
 #include "kstavector.h"
 #include "kstvcurve.h"
 #include "kstrmatrix.h"
+#include "kstimage.h"
 #include "plugincollection.h"
 
 
@@ -680,8 +681,26 @@
                   // xStart, yStart, xNumSteps, yNumSteps, 
                   //doAve, doSkip, skip);
               KST::addMatrixToList(KstMatrixPtr(matrix));
-
               
+              // Time to create the image from the matrix
+              tag_name = KST::suggestImageName(matrix->tagName());
+              QStringList palList = KPalette::getPaletteList();
+              QString pal;
+              if (palList.contains("Kst Grayscale 256")) {
+                pal = QString("Kst Grayscale 256");
+              } else {
+                pal = QString(*palList.at(0));
+              }
+              
+              KPalette* newPal = new KPalette(pal);
+              KstImagePtr image = new KstImage(tag_name, KstMatrixPtr(matrix), 0.0, 1.0,
+                                   true, newPal);
+              plot->addCurve(KstBaseCurvePtr(image));
+              KST::dataObjectList.lock().writeLock();
+              KST::dataObjectList.append(image.data());
+              KST::dataObjectList.lock().writeUnlock();
+              image = 0L; // drop the reference
+              
               if (in.sep_plots) {
                 plot->setTagName(matrix->tagName());
                 i_plot++;


More information about the Kst mailing list