From: Michal MalĂ˝ Date: Fri, 1 Aug 2014 17:08:06 +0000 (+0200) Subject: Fix build on VC11 X-Git-Tag: 0.3a~2 X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=c8585cc5e93504e6e257249773e77566b062039d;p=anyanka.git Fix build on VC11 --- diff --git a/datafileexporter.cpp b/datafileexporter.cpp index 54513f5..7a84d22 100644 --- a/datafileexporter.cpp +++ b/datafileexporter.cpp @@ -30,7 +30,7 @@ #include -const std::vector DataFileExporter::SUPPORTED_FORMATS = { OutputFormat("Comma separated values", "csv") }; +const OutputFormat DataFileExporter::SUPPORTED_FORMATS[] = { OutputFormat("Comma separated values", "csv") }; /* Static methods */ QStringList DataFileExporter::supportedFormats() @@ -61,7 +61,7 @@ exportData(const WriteList& list, const QString& path, const int formatIdx) DataFileExporter::ReturnCode ret; DataWriterBackend* backend; - if (formatIdx < 0 || formatIdx >= SUPPORTED_FORMATS.size()) { + if (formatIdx < 0 || formatIdx >= sizeof(SUPPORTED_FORMATS)) { return ReturnCode::E_INVAL_FORMAT; } @@ -133,6 +133,8 @@ DataFileExporter::OutputFormats DataFileExporter::formatIdxToFormat(const int id switch (idx) { case 0: return OutputFormats::CSV; + default: + return OutputFormats::INVALID; } } @@ -168,8 +170,8 @@ void DataFileExporter::guessFormatFromSuffix(const QString& name) if (suffix.length() == 0) return; - for (size_t i = 0; i < SUPPORTED_FORMATS.size(); i++) { - const OutputFormat& of = SUPPORTED_FORMATS.at(i); + for (size_t i = 0; i < sizeof(SUPPORTED_FORMATS); i++) { + const OutputFormat& of = SUPPORTED_FORMATS[i]; if (suffix.compare(of.second) == 0) { emit formatChanged(i); return; diff --git a/datafileexporter.h b/datafileexporter.h index c766577..136000e 100644 --- a/datafileexporter.h +++ b/datafileexporter.h @@ -53,14 +53,15 @@ public: static QStringList supportedFormats(); private: enum class OutputFormats { - CSV + CSV, + INVALID }; OutputFormats formatIdxToFormat(const int idx); QString toCSVLine(double time, double value); ReturnCode writeToFile(QFile& file, const DataWriterBackend* writer, const std::pair>& data); - static const std::vector SUPPORTED_FORMATS; + static const OutputFormat SUPPORTED_FORMATS[]; signals: void formatChanged(const int idx); diff --git a/datafilesloader.h b/datafilesloader.h index 19261a1..9f4852b 100644 --- a/datafilesloader.h +++ b/datafilesloader.h @@ -27,6 +27,7 @@ #include "libHPCS/libhpcs.h" #include #include +#include class DataFilesLoader : public QObject { diff --git a/datamanager.cpp b/datamanager.cpp index 5f3e4f5..aa95588 100644 --- a/datamanager.cpp +++ b/datamanager.cpp @@ -28,15 +28,15 @@ #include const QString DataManager::ME_SENDER_STR("DataManager"); -const QString DataManager::UNIT_DEGREES_CELSIUS_TEXT = QString::fromLatin1((const char[]){static_cast(0xB0), 0x43, 0x00}); -const QString DataManager::UNIT_KILOVOLTS_TEXT = QString::fromLatin1((const char[]){0x4B, 0x56, 0x00}); -const QString DataManager::UNIT_KILOVOLTS_ALT1_TEXT = QString::fromLatin1((const char[]){0x6B, 0x56, 0x00}); -const QString DataManager::UNIT_MICROAMPERES_TEXT = QString::fromLatin1((const char[]){static_cast(0xB5), 0x41, 0x00}); -const QString DataManager::UNIT_MICROAMPERES_ALT1_TEXT = QString::fromLatin1((const char[]){0x75, 0x41, 0x00}); -const QString DataManager::UNIT_MILLIAU_TEXT = QString::fromLatin1((const char[]){0x6D, 0x41, 0x55, 0x00}); -const QString DataManager::UNIT_MILLIBARS_TEXT = QString::fromLatin1((const char[]){0x6D, 0x62, 0x61, 0x72, 0x00}); -const QString DataManager::UNIT_MILLIVOLTS_TEXT = QString::fromLatin1((const char[]){0x6D, 0x56, 0x00}); -const QString DataManager::UNIT_WATTS_TEXT = QString::fromLatin1((const char[]){0x57, 0x00}); +const char DataManager::UNIT_DEGREES_CELSIUS_TEXT[] = {static_cast(0xB0), 0x43, 0x00}; +const char DataManager::UNIT_KILOVOLTS_TEXT[] = {0x4B, 0x56, 0x00}; +const char DataManager::UNIT_KILOVOLTS_ALT1_TEXT[] = {0x6B, 0x56, 0x00}; +const char DataManager::UNIT_MICROAMPERES_TEXT[] = {static_cast(0xB5), 0x41, 0x00}; +const char DataManager::UNIT_MICROAMPERES_ALT1_TEXT[] = {0x75, 0x41, 0x00}; +const char DataManager::UNIT_MILLIAU_TEXT[] = {0x6D, 0x41, 0x55, 0x00}; +const char DataManager::UNIT_MILLIBARS_TEXT[] = {0x6D, 0x62, 0x61, 0x72, 0x00}; +const char DataManager::UNIT_MILLIVOLTS_TEXT[] = {0x6D, 0x56, 0x00}; +const char DataManager::UNIT_WATTS_TEXT[] = {0x57, 0x00}; const QStringList DataManager::DATA_DIR_SUFFIX = QStringList() << "*.D"; const QString DataManager::S_RES_DATAEXPORT("Error while exporting data to file"); const QString DataManager::S_RES_IMGEXPORT("Error while exporting graph to image"); @@ -270,28 +270,26 @@ std::string DataManager::signalControllerKey(const QString& main, const QString& return std::string(main.toStdString() + "_" + resource.toStdString()); } -Signal::YUnit DataManager::yunitFromUnitStr(const char* unit_str) +Signal::YUnit DataManager::yunitFromUnitStr(const char* str) { - QString str = m_sigNameCodec->toUnicode(unit_str); - - if (QString::compare(str, UNIT_DEGREES_CELSIUS_TEXT) == 0) + if (strcmp(str, UNIT_DEGREES_CELSIUS_TEXT) == 0) return Signal::YUnit::DEGREES_CELSIUS; - else if (QString::compare(str, UNIT_KILOVOLTS_TEXT) == 0 || - QString::compare(str, UNIT_KILOVOLTS_ALT1_TEXT) == 0) + else if (strcmp(str, UNIT_KILOVOLTS_TEXT) == 0 || + strcmp(str, UNIT_KILOVOLTS_ALT1_TEXT) == 0) return Signal::YUnit::KILOVOLTS; - else if (QString::compare(str, UNIT_MICROAMPERES_TEXT) == 0 || - QString::compare(str, UNIT_MICROAMPERES_ALT1_TEXT) == 0) + else if (strcmp(str, UNIT_MICROAMPERES_TEXT) == 0 || + strcmp(str, UNIT_MICROAMPERES_ALT1_TEXT) == 0) return Signal::YUnit::MICROAMPERES; - else if (QString::compare(str, UNIT_MILLIAU_TEXT) == 0) + else if (strcmp(str, UNIT_MILLIAU_TEXT) == 0) return Signal::YUnit::MILLIAU; - else if (QString::compare(str, UNIT_MILLIBARS_TEXT) == 0) + else if (strcmp(str, UNIT_MILLIBARS_TEXT) == 0) return Signal::YUnit::MILLIBARS; - else if (QString::compare(str, UNIT_MILLIVOLTS_TEXT) == 0) + else if (strcmp(str, UNIT_MILLIVOLTS_TEXT) == 0) return Signal::YUnit::MILLIVOLTS; - else if (QString::compare(str, UNIT_WATTS_TEXT) == 0) + else if (strcmp(str, UNIT_WATTS_TEXT) == 0) return Signal::YUnit::WATTS; else - throw std::invalid_argument(str.toStdString()); + throw std::invalid_argument(std::string(str)); } std::shared_ptr DataManager::loadSingleRun(QDir& dir) diff --git a/datamanager.h b/datamanager.h index 020f858..250acea 100644 --- a/datamanager.h +++ b/datamanager.h @@ -62,7 +62,7 @@ private: bool saveSingleRunUserData(std::shared_ptr sr); std::string signalControllerKey(const QString& main, const QString& resource); void showOneSignal(std::shared_ptr ctrl); - Signal::YUnit yunitFromUnitStr(const char* unit_str); + Signal::YUnit yunitFromUnitStr(const char* str); std::shared_ptr m_activeSequence; QString m_prevSequenceKey; @@ -77,15 +77,15 @@ private: ExportGraphToImageDialog m_graphToImageExportDialog; static const QString ME_SENDER_STR; - static const QString UNIT_DEGREES_CELSIUS_TEXT; - static const QString UNIT_KILOVOLTS_TEXT; - static const QString UNIT_KILOVOLTS_ALT1_TEXT; - static const QString UNIT_MICROAMPERES_TEXT; - static const QString UNIT_MICROAMPERES_ALT1_TEXT; - static const QString UNIT_MILLIAU_TEXT; - static const QString UNIT_MILLIBARS_TEXT; - static const QString UNIT_MILLIVOLTS_TEXT; - static const QString UNIT_WATTS_TEXT; + static const char UNIT_DEGREES_CELSIUS_TEXT[]; + static const char UNIT_KILOVOLTS_TEXT[]; + static const char UNIT_KILOVOLTS_ALT1_TEXT[]; + static const char UNIT_MICROAMPERES_TEXT[]; + static const char UNIT_MICROAMPERES_ALT1_TEXT[]; + static const char UNIT_MILLIAU_TEXT[]; + static const char UNIT_MILLIBARS_TEXT[]; + static const char UNIT_MILLIVOLTS_TEXT[]; + static const char UNIT_WATTS_TEXT[]; static const QStringList DATA_DIR_SUFFIX; diff --git a/gui/exportgraphtoimagedialog.cpp b/gui/exportgraphtoimagedialog.cpp index 58e7f25..35f5452 100644 --- a/gui/exportgraphtoimagedialog.cpp +++ b/gui/exportgraphtoimagedialog.cpp @@ -25,6 +25,7 @@ #include "ui_exportgraphtoimagedialog.h" #include #include +#include /* Public functions */ diff --git a/integratedpeak.cpp b/integratedpeak.cpp index d4b1756..66b684b 100644 --- a/integratedpeak.cpp +++ b/integratedpeak.cpp @@ -21,6 +21,7 @@ */ #include "integratedpeak.h" +#include #include const QString IntegratedPeak::KEY_AUC("auc"); @@ -129,6 +130,11 @@ bool IntegratedPeak::deserialize(const QJsonValue& value) return true; } +template QJsonValue IntegratedPeak::fromQVariant(T value) const +{ + return QJsonValue::fromVariant(QVariant(value)); +} + double IntegratedPeak::height() const { return fabs(m_peakY - (baselineSlope() * (m_peakIdx - m_fromIdx) + m_fromY)); @@ -140,14 +146,14 @@ QJsonValue IntegratedPeak::serialize() const QString type = (m_type == Type::PEAK) ? "PEAK" : "VALLEY"; jso.insert(KEY_AUC, QJsonValue(m_auc)); - jso.insert(KEY_FROMIDX, QJsonValue(static_cast(m_fromIdx))); + jso.insert(KEY_FROMIDX, QJsonValue(fromQVariant(static_cast(m_fromIdx)))); jso.insert(KEY_FROMTIME, QJsonValue(m_fromTime)); jso.insert(KEY_FROMY, QJsonValue(m_fromY)); jso.insert(KEY_ITYPE, QJsonValue( (m_itype == IntegrationType::BASELINE) ? true : false) ); - jso.insert(KEY_PEAKIDX, QJsonValue(static_cast(m_peakIdx))); + jso.insert(KEY_PEAKIDX, QJsonValue(fromQVariant(static_cast(m_peakIdx)))); jso.insert(KEY_PEAKTIME, QJsonValue(m_peakTime)); jso.insert(KEY_PEAKY, QJsonValue(m_peakY)); - jso.insert(KEY_TOIDX, QJsonValue(static_cast(m_toIdx))); + jso.insert(KEY_TOIDX, QJsonValue(fromQVariant(static_cast(m_toIdx)))); jso.insert(KEY_TOTIME, QJsonValue(m_toTime)); jso.insert(KEY_TOY, QJsonValue(m_toY)); jso.insert(KEY_TYPE, QJsonValue(type)); diff --git a/integratedpeak.h b/integratedpeak.h index 1e1e2db..60e31d8 100644 --- a/integratedpeak.h +++ b/integratedpeak.h @@ -68,6 +68,8 @@ public: virtual QJsonValue serialize() const; private: + template QJsonValue fromQVariant(T val) const; + double m_auc; size_t m_fromIdx; double m_fromTime; diff --git a/logger.h b/logger.h index c9e3bf0..2f308b8 100644 --- a/logger.h +++ b/logger.h @@ -30,6 +30,10 @@ #include #include +#ifdef WIN32 +#define __func__ __FUNCTION__ +#endif + #define __QFUNC__ QString(__func__) + QString("()") class LocalLogger; diff --git a/signalcontroller.cpp b/signalcontroller.cpp index ed1ebbc..c2a1942 100644 --- a/signalcontroller.cpp +++ b/signalcontroller.cpp @@ -176,14 +176,16 @@ RulerDrawData SignalController::getRulerDrawData(const double from, const double diffRel = to - from; switch (axis) { - case Axis::TIME: - fromAbs = m_signal->timeAt(relToIdx(from)); - toAbs = m_signal->timeAt(relToIdx(to)); - break; - case Axis::VALUE: - fromAbs = relToValue(from); - toAbs = relToValue(to); - break; + case Axis::TIME: + fromAbs = m_signal->timeAt(relToIdx(from)); + toAbs = m_signal->timeAt(relToIdx(to)); + break; + case Axis::VALUE: + fromAbs = relToValue(from); + toAbs = relToValue(to); + break; + default: + return RulerDrawData(); } /* Calculate step */