[Kst] branches/work/kst/portto4/kst/src/datasources/fitsimage

Peter Kümmel syntheticpp at gmx.net
Wed Feb 2 19:29:06 CET 2011


SVN commit 1218520 by kuemmel:

add strings to fitsimage

 M  +60 -1     fitsimage.cpp  
 M  +6 -0      fitsimage.h  


--- branches/work/kst/portto4/kst/src/datasources/fitsimage/fitsimage.cpp #1218519:1218520
@@ -44,7 +44,61 @@
     }
 };
 
+
+
 //
+// String interface
+//
+
+class DataInterfaceFitsImageString : public DataSource::DataInterface<DataString>
+{
+public:
+  DataInterfaceFitsImageString(FitsImageSource& s) : source(s) {}
+
+  // read one element
+  int read(const QString&, DataString::ReadInfo&);
+
+  // named elements
+  QStringList list() const { return source._strings.keys(); }
+  bool isListComplete() const { return true; }
+  bool isValid(const QString&) const;
+
+  // T specific
+  const DataString::DataInfo dataInfo(const QString&) const { return DataString::DataInfo(); }
+  void setDataInfo(const QString&, const DataString::DataInfo&) {}
+
+  // meta data
+  QMap<QString, double> metaScalars(const QString&) { return QMap<QString, double>(); }
+  QMap<QString, QString> metaStrings(const QString&) { return QMap<QString, QString>(); }
+
+
+private:
+  FitsImageSource& source;
+};
+
+
+//-------------------------------------------------------------------------------------------
+int DataInterfaceFitsImageString::read(const QString& string, DataString::ReadInfo& p)
+{
+  // TODO read strings from file
+  if (isValid(string) && p.value) {
+    *p.value = source._strings[string];
+    return 1;
+  }
+  return 0;
+}
+
+
+//-------------------------------------------------------------------------------------------
+bool DataInterfaceFitsImageString::isValid(const QString& string) const
+{
+  // TODO read strings from file
+  return  source._strings.contains( string );
+}
+
+
+
+//
 // Matrix interface
 //
 
@@ -324,9 +378,12 @@
 
 
 FitsImageSource::FitsImageSource(Kst::ObjectStore *store, QSettings *cfg, const QString& filename, const QString& type, const QDomElement& e)
-: Kst::DataSource(store, cfg, filename, type), _config(0L),
+: Kst::DataSource(store, cfg, filename, type),
+  _config(0L),
+  is(new DataInterfaceFitsImageString(*this)),
   im(new DataInterfaceFitsImageMatrix(&_fptr))
 {
+  setInterface(is);
   setInterface(im);
 
   setUpdateType(None);
@@ -389,6 +446,8 @@
     _fptr = 0L;
     return false;
   }
+
+  _strings = fileMetas();
 }
 
 
--- branches/work/kst/portto4/kst/src/datasources/fitsimage/fitsimage.h #1218519:1218520
@@ -21,7 +21,9 @@
 #include <fitsio.h>
 
 class DataInterfaceFitsImageMatrix;
+class DataInterfaceFitsImageString;
 
+
 class FitsImageSource : public Kst::DataSource {
   Q_OBJECT
 
@@ -49,8 +51,12 @@
     fitsfile *_fptr;
     mutable Config *_config;
 
+    QMap<QString, QString> _strings;
+
+    DataInterfaceFitsImageString* is;
     DataInterfaceFitsImageMatrix* im;
 
+    friend class DataInterfaceFitsImageString;
 };
 
 


More information about the Kst mailing list