File indexing completed on 2024-12-22 04:17:16
0001 /*************************************************************************** 0002 netcdf.cpp - netCDF file data source reader 0003 ------------------- 0004 begin : 17/06/2004 0005 copyright : (C) 2004 Nicolas Brisset <nicodev@users.sourceforge.net> 0006 email : kst@kde.org 0007 modified : 03/14/05 by K. Scott 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * * 0012 * This program is free software; you can redistribute it and/or modify * 0013 * it under the terms of the GNU General Public License as published by * 0014 * the Free Software Foundation; either version 2 of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 ***************************************************************************/ 0018 0019 0020 #include "netcdfplugin.h" 0021 #include "netcdfsource.h" 0022 0023 #include <QFile> 0024 0025 // 0026 // NetCdfPlugin 0027 // 0028 0029 QString NetCdfPlugin::pluginName() const { return tr("netCDF Reader"); } 0030 QString NetCdfPlugin::pluginDescription() const { return tr("netCDF Reader"); } 0031 0032 0033 Kst::DataSource *NetCdfPlugin::create(Kst::ObjectStore *store, 0034 QSettings *cfg, 0035 const QString &filename, 0036 const QString &type, 0037 const QDomElement &element) const 0038 { 0039 return new NetcdfSource(store, cfg, filename, type, element); 0040 } 0041 0042 0043 QStringList NetCdfPlugin::matrixList(QSettings *cfg, 0044 const QString& filename, 0045 const QString& type, 0046 QString *typeSuggestion, 0047 bool *complete) const 0048 { 0049 return QStringList(); 0050 } 0051 0052 0053 QStringList NetCdfPlugin::scalarList(QSettings *cfg, 0054 const QString& filename, 0055 const QString& type, 0056 QString *typeSuggestion, 0057 bool *complete) const 0058 { 0059 0060 Q_UNUSED(cfg); 0061 Q_UNUSED(type) 0062 QStringList scalarList; 0063 return scalarList; 0064 } 0065 0066 0067 QStringList NetCdfPlugin::stringList(QSettings *cfg, 0068 const QString& filename, 0069 const QString& type, 0070 QString *typeSuggestion, 0071 bool *complete) const { 0072 Q_UNUSED(cfg); 0073 Q_UNUSED(type) 0074 QStringList stringList; 0075 0076 return stringList; 0077 } 0078 0079 0080 QStringList NetCdfPlugin::fieldList(QSettings *cfg, 0081 const QString& filename, 0082 const QString& type, 0083 QString *typeSuggestion, 0084 bool *complete) const { 0085 Q_UNUSED(cfg); 0086 Q_UNUSED(type) 0087 0088 QStringList fieldList; 0089 0090 return fieldList; 0091 } 0092 0093 0094 bool NetCdfPlugin::supportsTime(QSettings *cfg, const QString& filename) const { 0095 //FIXME 0096 Q_UNUSED(cfg) 0097 Q_UNUSED(filename) 0098 return true; 0099 } 0100 0101 0102 QStringList NetCdfPlugin::provides() const 0103 { 0104 return QStringList() << NetcdfSource::netcdfTypeKey(); 0105 } 0106 0107 0108 Kst::DataSourceConfigWidget *NetCdfPlugin::configWidget(QSettings *cfg, const QString& filename) const { 0109 0110 Q_UNUSED(cfg) 0111 Q_UNUSED(filename) 0112 return 0;; 0113 0114 } 0115 0116 0117 /** understands_netcdf: returns true if: 0118 - the file is readable (!) 0119 - the file can be opened by the netcdf library **/ 0120 int NetCdfPlugin::understands(QSettings *cfg, const QString& filename) const 0121 { 0122 QFile f(filename); 0123 0124 if (!f.open(QFile::ReadOnly)) { 0125 KST_DBG qDebug() << "Unable to read file !" << endl; 0126 return 0; 0127 } 0128 0129 NcFile *ncfile = new NcFile(filename.toUtf8().data()); 0130 if (ncfile->is_valid()) { 0131 KST_DBG qDebug() << filename << " looks like netCDF !" << endl; 0132 delete ncfile; 0133 return 80; 0134 } else { 0135 delete ncfile; 0136 return 0; 0137 } 0138 } 0139 0140 0141 #ifndef QT5 0142 Q_EXPORT_PLUGIN2(kstdata_netcdfsource, NetCdfPlugin) 0143 #endif