mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
* #2082 Support custom date time format * Clang-format
This commit is contained in:
parent
824ec5cef6
commit
e58da136e3
@ -22,6 +22,7 @@
|
|||||||
#include "RiaPreferences.h"
|
#include "RiaPreferences.h"
|
||||||
|
|
||||||
#include "RiaColorTables.h"
|
#include "RiaColorTables.h"
|
||||||
|
#include "RiaQDateTimeTools.h"
|
||||||
#include "RifReaderSettings.h"
|
#include "RifReaderSettings.h"
|
||||||
|
|
||||||
#include "cafPdmFieldCvfColor.h"
|
#include "cafPdmFieldCvfColor.h"
|
||||||
@ -30,6 +31,9 @@
|
|||||||
#include "cafPdmUiFieldHandle.h"
|
#include "cafPdmUiFieldHandle.h"
|
||||||
#include "cafPdmUiFilePathEditor.h"
|
#include "cafPdmUiFilePathEditor.h"
|
||||||
|
|
||||||
|
#include <QDate>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#endif
|
#endif
|
||||||
@ -167,6 +171,13 @@ RiaPreferences::RiaPreferences(void)
|
|||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&m_readerSettings, "readerSettings", "Reader Settings", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&m_readerSettings, "readerSettings", "Reader Settings", "", "", "");
|
||||||
m_readerSettings = new RifReaderSettings;
|
m_readerSettings = new RifReaderSettings;
|
||||||
|
CAF_PDM_InitFieldNoDefault(&m_dateFormat, "dateFormat", "Date Format", "", "", "");
|
||||||
|
m_dateFormat.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
|
||||||
|
m_dateFormat = RiaQDateTimeTools::supportedDateFormats().front();
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault(&m_timeFormat, "timeFormat", "Time Format", "", "", "");
|
||||||
|
m_timeFormat.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
|
||||||
|
m_timeFormat = RiaQDateTimeTools::supportedTimeFormats().front();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -257,6 +268,8 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
|||||||
viewsGroup->add(&showHud);
|
viewsGroup->add(&showHud);
|
||||||
|
|
||||||
caf::PdmUiGroup* otherGroup = uiOrdering.addNewGroup("Other");
|
caf::PdmUiGroup* otherGroup = uiOrdering.addNewGroup("Other");
|
||||||
|
otherGroup->add(&m_dateFormat);
|
||||||
|
otherGroup->add(&m_timeFormat);
|
||||||
otherGroup->add(&ssihubAddress);
|
otherGroup->add(&ssihubAddress);
|
||||||
otherGroup->add(&showLasCurveWithoutTvdWarning);
|
otherGroup->add(&showLasCurveWithoutTvdWarning);
|
||||||
otherGroup->add(&holoLensDisableCertificateVerification);
|
otherGroup->add(&holoLensDisableCertificateVerification);
|
||||||
@ -353,6 +366,30 @@ QList<caf::PdmOptionItemInfo> RiaPreferences::calculateValueOptions(const caf::P
|
|||||||
options.push_back(caf::PdmOptionItemInfo(skip.uiText(), RiaPreferences::NOT_IMPORT));
|
options.push_back(caf::PdmOptionItemInfo(skip.uiText(), RiaPreferences::NOT_IMPORT));
|
||||||
options.push_back(caf::PdmOptionItemInfo(allowImport.uiText(), RiaPreferences::IMPORT));
|
options.push_back(caf::PdmOptionItemInfo(allowImport.uiText(), RiaPreferences::IMPORT));
|
||||||
}
|
}
|
||||||
|
else if (fieldNeedingOptions == &m_dateFormat)
|
||||||
|
{
|
||||||
|
for (auto dateFormat : RiaQDateTimeTools::supportedDateFormats())
|
||||||
|
{
|
||||||
|
QDate exampleDate = QDate(2019, 8, 16);
|
||||||
|
QString fullDateFormat =
|
||||||
|
RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
|
||||||
|
QString uiText = QString("%1 (%2)").arg(fullDateFormat).arg(exampleDate.toString(fullDateFormat));
|
||||||
|
uiText.replace("AP", "AM/PM");
|
||||||
|
options.push_back(caf::PdmOptionItemInfo(uiText, QVariant::fromValue(dateFormat)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (fieldNeedingOptions == &m_timeFormat)
|
||||||
|
{
|
||||||
|
for (auto timeFormat : RiaQDateTimeTools::supportedTimeFormats())
|
||||||
|
{
|
||||||
|
QTime exampleTime = QTime(15, 48, 22);
|
||||||
|
QString timeFormatString =
|
||||||
|
RiaQDateTimeTools::timeFormatString(timeFormat, RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE_SECOND);
|
||||||
|
QString uiText = QString("%1 (%2)").arg(timeFormatString).arg(exampleTime.toString(timeFormatString));
|
||||||
|
uiText.replace("AP", "AM/PM");
|
||||||
|
options.push_back(caf::PdmOptionItemInfo(uiText, QVariant::fromValue(timeFormat)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
@ -500,6 +537,22 @@ QString RiaPreferences::holoLensExportFolder() const
|
|||||||
return m_holoLensExportFolder();
|
return m_holoLensExportFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
const QString& RiaPreferences::dateFormat() const
|
||||||
|
{
|
||||||
|
return m_dateFormat();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
const QString& RiaPreferences::timeFormat() const
|
||||||
|
{
|
||||||
|
return m_timeFormat();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "RiaGuiApplication.h"
|
#include "RiaGuiApplication.h"
|
||||||
#include "RiaDefines.h"
|
#include "RiaDefines.h"
|
||||||
#include "RiaFontCache.h"
|
#include "RiaFontCache.h"
|
||||||
|
#include "RiaQDateTimeTools.h"
|
||||||
|
|
||||||
#include "cafAppEnum.h"
|
#include "cafAppEnum.h"
|
||||||
#include "cafPdmChildField.h"
|
#include "cafPdmChildField.h"
|
||||||
@ -71,6 +71,9 @@ public:
|
|||||||
bool showProjectChangedDialog() const;
|
bool showProjectChangedDialog() const;
|
||||||
QString holoLensExportFolder() const;
|
QString holoLensExportFolder() const;
|
||||||
|
|
||||||
|
const QString& dateFormat() const;
|
||||||
|
const QString& timeFormat() const;
|
||||||
|
|
||||||
std::map<RiaDefines::FontSettingType, RiaFontCache::FontSize> defaultFontSizes() const;
|
std::map<RiaDefines::FontSettingType, RiaFontCache::FontSize> defaultFontSizes() const;
|
||||||
|
|
||||||
public: // Pdm Fields
|
public: // Pdm Fields
|
||||||
@ -129,7 +132,6 @@ protected:
|
|||||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||||
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||||
void initAfterRead() override;
|
void initAfterRead() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString tabNameGeneral();
|
static QString tabNameGeneral();
|
||||||
static QString tabNameEclipse();
|
static QString tabNameEclipse();
|
||||||
@ -148,4 +150,7 @@ private:
|
|||||||
caf::PdmField<bool> m_showTestToolbar;
|
caf::PdmField<bool> m_showTestToolbar;
|
||||||
caf::PdmField<bool> m_includeFractureDebugInfoFile;
|
caf::PdmField<bool> m_includeFractureDebugInfoFile;
|
||||||
caf::PdmField<QString> m_holoLensExportFolder;
|
caf::PdmField<QString> m_holoLensExportFolder;
|
||||||
|
caf::PdmField<QString> m_dateFormat;
|
||||||
|
caf::PdmField<QString> m_timeFormat;
|
||||||
|
QStringList m_tabNames;
|
||||||
};
|
};
|
||||||
|
@ -393,3 +393,79 @@ QString RiaQDateTimeTools::dateFormatString()
|
|||||||
{
|
{
|
||||||
return "dd.MMM yyyy";
|
return "dd.MMM yyyy";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<QString> RiaQDateTimeTools::supportedDateFormats()
|
||||||
|
{
|
||||||
|
std::vector<QString> dateFormats;
|
||||||
|
|
||||||
|
// See enum DateFormatComponents in header
|
||||||
|
// The semi-colon separated components are:
|
||||||
|
// DATE_FORMAT_YEAR, ..YEAR_MONTH, ..YEAR_MONTH_DAY
|
||||||
|
dateFormats.push_back("yyyy;yyyy-MM;yyyy-MM-dd");
|
||||||
|
dateFormats.push_back("yyyy;MMM yyyy;dd. MMM yyyy");
|
||||||
|
dateFormats.push_back("yyyy;MMM yyyy;MMM dd. yyyy");
|
||||||
|
dateFormats.push_back("yyyy;MM/yyyy;dd/MM/yyyy");
|
||||||
|
dateFormats.push_back("yyyy;M/yyyy;d/M/yyyy");
|
||||||
|
dateFormats.push_back("yyyy;M/yyyy;M/d/yyyy");
|
||||||
|
dateFormats.push_back("yy;M/yy;d/M/yy");
|
||||||
|
dateFormats.push_back("yy;M/yy;M/d/yy");
|
||||||
|
dateFormats.push_back("yyyy;MM-yyyy;dd-MM-yyyy");
|
||||||
|
dateFormats.push_back("yyyy;MM-yyyy;MM-dd-yyyy");
|
||||||
|
dateFormats.push_back("yy;MM-yy;dd-MM-yy");
|
||||||
|
dateFormats.push_back("yy;MM-yy;MM-dd-yy");
|
||||||
|
|
||||||
|
return dateFormats;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<QString> RiaQDateTimeTools::supportedTimeFormats()
|
||||||
|
{
|
||||||
|
std::vector<QString> timeFormats;
|
||||||
|
|
||||||
|
// See enum TimeFormatComponents in header
|
||||||
|
// The semi-colon separated components are:
|
||||||
|
// TIME_FORMAT_HOUR, ..HOUR_MINUTE, ..HOUR_MINUTE_SECOND and ..HOUR_MINUTE_MILLISECOND
|
||||||
|
timeFormats.push_back("HH;HH:mm;HH:mm:ss;HH:mm:ss.zzz");
|
||||||
|
timeFormats.push_back("H;H:mm;H:mm:ss;H:mm:ss.zzz");
|
||||||
|
timeFormats.push_back("hh AP;hh:mm AP;hh:mm:ss AP;hh:mm:ss.zzz AP");
|
||||||
|
timeFormats.push_back("h AP;h:mm AP;h:mm:ss AP;h:mm:ss.zzz AP");
|
||||||
|
|
||||||
|
return timeFormats;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RiaQDateTimeTools::dateFormatString(const QString& fullDateFormat, DateFormatComponents dateComponents)
|
||||||
|
{
|
||||||
|
if (dateComponents == DATE_FORMAT_NONE) return "";
|
||||||
|
|
||||||
|
QStringList allVariants = fullDateFormat.split(";");
|
||||||
|
if (static_cast<int>(dateComponents) < allVariants.size())
|
||||||
|
{
|
||||||
|
return allVariants[dateComponents];
|
||||||
|
}
|
||||||
|
CVF_ASSERT(false && "Date format string is malformed");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RiaQDateTimeTools::timeFormatString(const QString& fullTimeFormat, TimeFormatComponents timeComponents)
|
||||||
|
{
|
||||||
|
if (timeComponents == TIME_FORMAT_NONE) return "";
|
||||||
|
|
||||||
|
QStringList allVariants = fullTimeFormat.split(";");
|
||||||
|
if (static_cast<int>(timeComponents) < allVariants.size())
|
||||||
|
{
|
||||||
|
return allVariants[timeComponents];
|
||||||
|
}
|
||||||
|
CVF_ASSERT(false && "Time format string is malformed");
|
||||||
|
return "";
|
||||||
|
}
|
@ -22,7 +22,11 @@
|
|||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -60,6 +64,25 @@ class RiaQDateTimeTools
|
|||||||
static const DateTimeSpan TIMESPAN_DECADE;
|
static const DateTimeSpan TIMESPAN_DECADE;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum DateFormatComponents
|
||||||
|
{
|
||||||
|
DATE_FORMAT_NONE = -1,
|
||||||
|
DATE_FORMAT_YEAR = 0,
|
||||||
|
DATE_FORMAT_YEAR_MONTH,
|
||||||
|
DATE_FORMAT_YEAR_MONTH_DAY,
|
||||||
|
DATE_FORMAT_SIZE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum TimeFormatComponents
|
||||||
|
{
|
||||||
|
TIME_FORMAT_NONE = -1,
|
||||||
|
TIME_FORMAT_HOUR,
|
||||||
|
TIME_FORMAT_HOUR_MINUTE,
|
||||||
|
TIME_FORMAT_HOUR_MINUTE_SECOND,
|
||||||
|
TIME_FORMAT_HOUR_MINUTE_SECOND_MILLISECOND,
|
||||||
|
TIME_FORMAT_SIZE
|
||||||
|
};
|
||||||
|
|
||||||
static const QString TIMESPAN_DAY_NAME;
|
static const QString TIMESPAN_DAY_NAME;
|
||||||
static const QString TIMESPAN_WEEK_NAME;
|
static const QString TIMESPAN_WEEK_NAME;
|
||||||
static const QString TIMESPAN_MONTH_NAME;
|
static const QString TIMESPAN_MONTH_NAME;
|
||||||
@ -104,9 +127,16 @@ public:
|
|||||||
static QString createTimeFormatStringFromDates(const std::vector<QDateTime>& dates);
|
static QString createTimeFormatStringFromDates(const std::vector<QDateTime>& dates);
|
||||||
static QString dateFormatString();
|
static QString dateFormatString();
|
||||||
|
|
||||||
|
static std::vector<QString> supportedDateFormats();
|
||||||
|
static std::vector<QString> supportedTimeFormats();
|
||||||
|
|
||||||
|
static QString dateFormatString(const QString& fullDateFormat, DateFormatComponents dateComponents);
|
||||||
|
static QString timeFormatString(const QString& fullTimeFormat, TimeFormatComponents timeComponents);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static quint64 secondsInDay();
|
static quint64 secondsInDay();
|
||||||
static quint64 secondsInYear();
|
static quint64 secondsInYear();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
@ -926,7 +926,10 @@ void RimSummaryPlot::updateTimeAxis()
|
|||||||
|
|
||||||
if (m_timeAxisProperties->timeMode() == RimSummaryTimeAxisProperties::DATE)
|
if (m_timeAxisProperties->timeMode() == RimSummaryTimeAxisProperties::DATE)
|
||||||
{
|
{
|
||||||
m_qwtPlot->useDateBasedTimeAxis();
|
QString dateFormat = m_timeAxisProperties->dateFormat();
|
||||||
|
QString timeFormat = m_timeAxisProperties->timeFormat();
|
||||||
|
|
||||||
|
m_qwtPlot->useDateBasedTimeAxis(dateFormat, timeFormat);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -24,11 +24,12 @@
|
|||||||
|
|
||||||
#include "RimSummaryPlot.h"
|
#include "RimSummaryPlot.h"
|
||||||
|
|
||||||
|
#include "cafPdmUiComboBoxEditor.h"
|
||||||
|
#include "cafPdmUiDateEditor.h"
|
||||||
#include "cafPdmUiLineEditor.h"
|
#include "cafPdmUiLineEditor.h"
|
||||||
|
#include "cafPdmUiTimeEditor.h"
|
||||||
#include "qwt_date.h"
|
|
||||||
#include "cvfAssert.h"
|
#include "cvfAssert.h"
|
||||||
|
#include "qwt_date.h"
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
@ -53,13 +54,10 @@ void caf::AppEnum< RimSummaryTimeAxisProperties::TimeUnitType >::setUp()
|
|||||||
setDefault(RimSummaryTimeAxisProperties::YEARS);
|
setDefault(RimSummaryTimeAxisProperties::YEARS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace caf
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RimSummaryTimeAxisProperties, "SummaryTimeAxisProperties");
|
CAF_PDM_SOURCE_INIT(RimSummaryTimeAxisProperties, "SummaryTimeAxisProperties");
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -77,17 +75,24 @@ RimSummaryTimeAxisProperties::RimSummaryTimeAxisProperties()
|
|||||||
CAF_PDM_InitFieldNoDefault(&m_timeMode, "TimeMode", "Time Mode", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&m_timeMode, "TimeMode", "Time Mode", "", "", "");
|
||||||
CAF_PDM_InitFieldNoDefault(&m_timeUnit, "TimeUnit", "Time Unit", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&m_timeUnit, "TimeUnit", "Time Unit", "", "", "");
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&m_visibleDateRangeMax, "VisibleRangeMax", "Max", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&m_visibleDateRangeMax, "VisibleDateRangeMax", "Max Date", "", "", "");
|
||||||
m_visibleDateRangeMax.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
m_visibleDateRangeMax.uiCapability()->setUiEditorTypeName(caf::PdmUiDateEditor::uiEditorTypeName());
|
||||||
|
CAF_PDM_InitFieldNoDefault(&m_visibleDateRangeMin, "VisibleDateRangeMin", "Min Date", "", "", "");
|
||||||
|
m_visibleDateRangeMin.uiCapability()->setUiEditorTypeName(caf::PdmUiDateEditor::uiEditorTypeName());
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&m_visibleDateRangeMin, "VisibleRangeMin", "Min", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&m_visibleTimeRangeMax, "VisibleTimeRangeMax", "MaxTime", "", "", "");
|
||||||
m_visibleDateRangeMin.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
m_visibleTimeRangeMax.uiCapability()->setUiEditorTypeName(caf::PdmUiTimeEditor::uiEditorTypeName());
|
||||||
|
m_visibleTimeRangeMax.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&m_visibleTimeRangeMax, "VisibleTimeModeRangeMax", "Max", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&m_visibleTimeRangeMin, "VisibleTimeRangeMin", "Min Time", "", "", "");
|
||||||
m_visibleDateRangeMax.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
m_visibleTimeRangeMin.uiCapability()->setUiEditorTypeName(caf::PdmUiTimeEditor::uiEditorTypeName());
|
||||||
|
m_visibleTimeRangeMin.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&m_visibleTimeRangeMin, "VisibleTimeModeRangeMin", "Min", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&m_visibleTimeSinceStartRangeMax, "VisibleTimeModeRangeMax", "Max", "", "", "");
|
||||||
m_visibleDateRangeMin.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
m_visibleTimeSinceStartRangeMax.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault(&m_visibleTimeSinceStartRangeMin, "VisibleTimeModeRangeMin", "Min", "", "", "");
|
||||||
|
m_visibleTimeSinceStartRangeMin.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(&m_titlePositionEnum, "TitlePosition", "Title Position", "", "", "");
|
CAF_PDM_InitFieldNoDefault(&m_titlePositionEnum, "TitlePosition", "Title Position", "", "", "");
|
||||||
CAF_PDM_InitField(&m_titleFontSize, "FontSize", 10, "Font Size", "", "", "");
|
CAF_PDM_InitField(&m_titleFontSize, "FontSize", 10, "Font Size", "", "", "");
|
||||||
@ -95,6 +100,19 @@ RimSummaryTimeAxisProperties::RimSummaryTimeAxisProperties()
|
|||||||
CAF_PDM_InitField(&m_valuesFontSize, "ValuesFontSize", 10, "Font Size", "", "", "");
|
CAF_PDM_InitField(&m_valuesFontSize, "ValuesFontSize", 10, "Font Size", "", "", "");
|
||||||
m_valuesFontSize = RiaFontCache::pointSizeFromFontSizeEnum(RiaApplication::instance()->preferences()->defaultPlotFontSize());
|
m_valuesFontSize = RiaFontCache::pointSizeFromFontSizeEnum(RiaApplication::instance()->preferences()->defaultPlotFontSize());
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault(&m_dateFormat, "DateFormat", "Date Format", "", "", "");
|
||||||
|
m_dateFormat.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
|
||||||
|
m_dateFormat = RiaApplication::instance()->preferences()->dateFormat();
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault(&m_timeFormat, "TimeFormat", "Time Format", "", "", "");
|
||||||
|
m_timeFormat.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
|
||||||
|
m_timeFormat = RiaApplication::instance()->preferences()->timeFormat();
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault(&m_visibleDateTimeRangeMax_OBSOLETE, "VisibleRangeMax", "Max", "", "", "");
|
||||||
|
m_visibleDateTimeRangeMax_OBSOLETE.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault(&m_visibleDateTimeRangeMin_OBSOLETE, "VisibleRangeMin", "Min", "", "", "");
|
||||||
|
m_visibleDateTimeRangeMin_OBSOLETE.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -143,9 +161,11 @@ void RimSummaryTimeAxisProperties::setValuesFontSize(int fontSize)
|
|||||||
double RimSummaryTimeAxisProperties::visibleRangeMin() const
|
double RimSummaryTimeAxisProperties::visibleRangeMin() const
|
||||||
{
|
{
|
||||||
if (m_timeMode() == DATE)
|
if (m_timeMode() == DATE)
|
||||||
return QwtDate::toDouble(m_visibleDateRangeMin());
|
{
|
||||||
|
return QwtDate::toDouble(visibleDateTimeMin());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return m_visibleTimeRangeMin();
|
return m_visibleTimeSinceStartRangeMin();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -154,9 +174,11 @@ double RimSummaryTimeAxisProperties::visibleRangeMin() const
|
|||||||
double RimSummaryTimeAxisProperties::visibleRangeMax() const
|
double RimSummaryTimeAxisProperties::visibleRangeMax() const
|
||||||
{
|
{
|
||||||
if (m_timeMode() == DATE)
|
if (m_timeMode() == DATE)
|
||||||
return QwtDate::toDouble(m_visibleDateRangeMax());
|
{
|
||||||
|
return QwtDate::toDouble(visibleDateTimeMax());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return m_visibleTimeRangeMax();
|
return m_visibleTimeSinceStartRangeMax();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -166,15 +188,16 @@ void RimSummaryTimeAxisProperties::setVisibleRangeMin(double value)
|
|||||||
{
|
{
|
||||||
if (m_timeMode() == DATE)
|
if (m_timeMode() == DATE)
|
||||||
{
|
{
|
||||||
m_visibleDateRangeMin = QwtDate::toDateTime(value);
|
QDateTime dateTime = QwtDate::toDateTime(value);
|
||||||
m_visibleTimeRangeMin = fromDateToDisplayTime(m_visibleDateRangeMin());
|
m_visibleTimeSinceStartRangeMin = fromDateToDisplayTime(dateTime);
|
||||||
|
setVisibleDateTimeMin(dateTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_visibleTimeRangeMin = value;
|
m_visibleTimeSinceStartRangeMin = value;
|
||||||
m_visibleDateRangeMin = fromDisplayTimeToDate(value);
|
QDateTime dateTime = fromDisplayTimeToDate(value);
|
||||||
|
setVisibleDateTimeMin(dateTime);
|
||||||
}
|
}
|
||||||
auto s = m_visibleDateRangeMin().toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -184,16 +207,16 @@ void RimSummaryTimeAxisProperties::setVisibleRangeMax(double value)
|
|||||||
{
|
{
|
||||||
if (m_timeMode() == DATE)
|
if (m_timeMode() == DATE)
|
||||||
{
|
{
|
||||||
m_visibleDateRangeMax = QwtDate::toDateTime(value);
|
QDateTime dateTime = QwtDate::toDateTime(value);
|
||||||
m_visibleTimeRangeMax = fromDateToDisplayTime(m_visibleDateRangeMax());
|
m_visibleTimeSinceStartRangeMax = fromDateToDisplayTime(dateTime);
|
||||||
|
setVisibleDateTimeMax(dateTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_visibleTimeRangeMax = value;
|
m_visibleTimeSinceStartRangeMax = value;
|
||||||
m_visibleDateRangeMax = fromDisplayTimeToDate(value);
|
QDateTime dateTime = fromDisplayTimeToDate(value);
|
||||||
|
setVisibleDateTimeMax(dateTime);
|
||||||
}
|
}
|
||||||
auto s = m_visibleDateRangeMax().toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -217,8 +240,8 @@ void RimSummaryTimeAxisProperties::setAutoZoom(bool enableAutoZoom)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryTimeAxisProperties::updateTimeVisibleRange()
|
void RimSummaryTimeAxisProperties::updateTimeVisibleRange()
|
||||||
{
|
{
|
||||||
m_visibleTimeRangeMax = fromDateToDisplayTime(m_visibleDateRangeMax());
|
m_visibleTimeSinceStartRangeMax = fromDateToDisplayTime(visibleDateTimeMax());
|
||||||
m_visibleTimeRangeMin = fromDateToDisplayTime(m_visibleDateRangeMin());
|
m_visibleTimeSinceStartRangeMin = fromDateToDisplayTime(visibleDateTimeMin());
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -226,8 +249,8 @@ void RimSummaryTimeAxisProperties::updateTimeVisibleRange()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryTimeAxisProperties::updateDateVisibleRange()
|
void RimSummaryTimeAxisProperties::updateDateVisibleRange()
|
||||||
{
|
{
|
||||||
m_visibleDateRangeMin = fromDisplayTimeToDate(m_visibleTimeRangeMin());
|
setVisibleDateTimeMin(fromDisplayTimeToDate(m_visibleTimeSinceStartRangeMin()));
|
||||||
m_visibleDateRangeMax = fromDisplayTimeToDate(m_visibleTimeRangeMax());
|
setVisibleDateTimeMax(fromDisplayTimeToDate(m_visibleTimeSinceStartRangeMax()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -260,7 +283,6 @@ double RimSummaryTimeAxisProperties::fromDateToDisplayTime(const QDateTime& disp
|
|||||||
return fromTimeTToDisplayUnitScale() * (secsSinceEpoc - startOfSimulation);
|
return fromTimeTToDisplayUnitScale() * (secsSinceEpoc - startOfSimulation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -272,13 +294,49 @@ bool RimSummaryTimeAxisProperties::isActive() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QList<caf::PdmOptionItemInfo> RimSummaryTimeAxisProperties::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
QDateTime RimSummaryTimeAxisProperties::visibleDateTimeMin() const
|
||||||
|
{
|
||||||
|
QDateTime fullMin(m_visibleDateRangeMin(), m_visibleTimeRangeMin());
|
||||||
|
return fullMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QDateTime RimSummaryTimeAxisProperties::visibleDateTimeMax() const
|
||||||
|
{
|
||||||
|
QDateTime fullMax(m_visibleDateRangeMax(), m_visibleTimeRangeMax());
|
||||||
|
return fullMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryTimeAxisProperties::setVisibleDateTimeMin(const QDateTime& dateTime)
|
||||||
|
{
|
||||||
|
m_visibleDateRangeMin = dateTime.date();
|
||||||
|
m_visibleTimeRangeMin = dateTime.time();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryTimeAxisProperties::setVisibleDateTimeMax(const QDateTime& dateTime)
|
||||||
|
{
|
||||||
|
m_visibleDateRangeMax = dateTime.date();
|
||||||
|
m_visibleTimeRangeMax = dateTime.time();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QList<caf::PdmOptionItemInfo> RimSummaryTimeAxisProperties::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||||
|
bool* useOptionsOnly)
|
||||||
{
|
{
|
||||||
QList<caf::PdmOptionItemInfo> options;
|
QList<caf::PdmOptionItemInfo> options;
|
||||||
*useOptionsOnly = true;
|
*useOptionsOnly = true;
|
||||||
|
|
||||||
if (&m_titleFontSize == fieldNeedingOptions ||
|
if (&m_titleFontSize == fieldNeedingOptions || &m_valuesFontSize == fieldNeedingOptions)
|
||||||
&m_valuesFontSize == fieldNeedingOptions)
|
|
||||||
{
|
{
|
||||||
std::vector<int> fontSizes;
|
std::vector<int> fontSizes;
|
||||||
fontSizes.push_back(8);
|
fontSizes.push_back(8);
|
||||||
@ -297,7 +355,30 @@ QList<caf::PdmOptionItemInfo> RimSummaryTimeAxisProperties::calculateValueOption
|
|||||||
options.push_back(caf::PdmOptionItemInfo(text, value));
|
options.push_back(caf::PdmOptionItemInfo(text, value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (fieldNeedingOptions == &m_dateFormat)
|
||||||
|
{
|
||||||
|
for (auto dateFormat : RiaQDateTimeTools::supportedDateFormats())
|
||||||
|
{
|
||||||
|
QDate exampleDate = QDate(2019, 8, 16);
|
||||||
|
QString fullDateFormat =
|
||||||
|
RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
|
||||||
|
QString uiText = QString("%1 (%2)").arg(fullDateFormat).arg(exampleDate.toString(fullDateFormat));
|
||||||
|
uiText.replace("AP", "AM/PM");
|
||||||
|
options.push_back(caf::PdmOptionItemInfo(uiText, QVariant::fromValue(dateFormat)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (fieldNeedingOptions == &m_timeFormat)
|
||||||
|
{
|
||||||
|
for (auto timeFormat : RiaQDateTimeTools::supportedTimeFormats())
|
||||||
|
{
|
||||||
|
QTime exampleTime = QTime(15, 48, 22);
|
||||||
|
QString timeFormatString =
|
||||||
|
RiaQDateTimeTools::timeFormatString(timeFormat, RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE_SECOND);
|
||||||
|
QString uiText = QString("%1 (%2)").arg(timeFormatString).arg(exampleTime.toString(timeFormatString));
|
||||||
|
uiText.replace("AP", "AM/PM");
|
||||||
|
options.push_back(caf::PdmOptionItemInfo(uiText, QVariant::fromValue(timeFormat)));
|
||||||
|
}
|
||||||
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,6 +466,22 @@ double RimSummaryTimeAxisProperties::fromDaysToDisplayUnitScale()
|
|||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
const QString& RimSummaryTimeAxisProperties::dateFormat() const
|
||||||
|
{
|
||||||
|
return m_dateFormat();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
const QString& RimSummaryTimeAxisProperties::timeFormat() const
|
||||||
|
{
|
||||||
|
return m_timeFormat();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -400,14 +497,18 @@ void RimSummaryTimeAxisProperties::defineUiOrdering(QString uiConfigName, caf::P
|
|||||||
timeGroup->add(&m_timeMode);
|
timeGroup->add(&m_timeMode);
|
||||||
if (m_timeMode() == DATE)
|
if (m_timeMode() == DATE)
|
||||||
{
|
{
|
||||||
timeGroup->add( &m_visibleDateRangeMax);
|
timeGroup->add(&m_visibleDateRangeMax, true);
|
||||||
timeGroup->add(&m_visibleDateRangeMin);
|
timeGroup->add(&m_visibleTimeRangeMax, false);
|
||||||
|
timeGroup->add(&m_visibleDateRangeMin, true);
|
||||||
|
timeGroup->add(&m_visibleTimeRangeMin, false);
|
||||||
|
timeGroup->add(&m_dateFormat);
|
||||||
|
timeGroup->add(&m_timeFormat);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
timeGroup->add(&m_timeUnit);
|
timeGroup->add(&m_timeUnit);
|
||||||
timeGroup->add(&m_visibleTimeRangeMax);
|
timeGroup->add(&m_visibleTimeSinceStartRangeMax);
|
||||||
timeGroup->add(&m_visibleTimeRangeMin);
|
timeGroup->add(&m_visibleTimeSinceStartRangeMin);
|
||||||
}
|
}
|
||||||
timeGroup->add(&m_valuesFontSize);
|
timeGroup->add(&m_valuesFontSize);
|
||||||
|
|
||||||
@ -417,7 +518,9 @@ void RimSummaryTimeAxisProperties::defineUiOrdering(QString uiConfigName, caf::P
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimSummaryTimeAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
void RimSummaryTimeAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||||
|
const QVariant& oldValue,
|
||||||
|
const QVariant& newValue)
|
||||||
{
|
{
|
||||||
RimSummaryPlot* rimSummaryPlot = nullptr;
|
RimSummaryPlot* rimSummaryPlot = nullptr;
|
||||||
this->firstAncestorOrThisOfType(rimSummaryPlot);
|
this->firstAncestorOrThisOfType(rimSummaryPlot);
|
||||||
@ -425,10 +528,21 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* c
|
|||||||
|
|
||||||
if (changedField == &m_visibleDateRangeMax)
|
if (changedField == &m_visibleDateRangeMax)
|
||||||
{
|
{
|
||||||
QDateTime test = newValue.toDateTime();
|
QDate test = newValue.toDate();
|
||||||
if (!test.isValid())
|
if (!test.isValid())
|
||||||
{
|
{
|
||||||
m_visibleDateRangeMax = oldValue.toDateTime();
|
m_visibleDateRangeMax = oldValue.toDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTimeVisibleRange();
|
||||||
|
m_isAutoZoom = false;
|
||||||
|
}
|
||||||
|
else if (changedField == &m_visibleTimeRangeMax)
|
||||||
|
{
|
||||||
|
QTime test = newValue.toTime();
|
||||||
|
if (!test.isValid())
|
||||||
|
{
|
||||||
|
m_visibleTimeRangeMax = oldValue.toTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTimeVisibleRange();
|
updateTimeVisibleRange();
|
||||||
@ -436,16 +550,27 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* c
|
|||||||
}
|
}
|
||||||
else if (changedField == &m_visibleDateRangeMin)
|
else if (changedField == &m_visibleDateRangeMin)
|
||||||
{
|
{
|
||||||
QDateTime test = newValue.toDateTime();
|
QDate test = newValue.toDate();
|
||||||
if (!test.isValid())
|
if (!test.isValid())
|
||||||
{
|
{
|
||||||
m_visibleDateRangeMin = oldValue.toDateTime();
|
m_visibleDateRangeMin = oldValue.toDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTimeVisibleRange();
|
updateTimeVisibleRange();
|
||||||
m_isAutoZoom = false;
|
m_isAutoZoom = false;
|
||||||
}
|
}
|
||||||
else if (changedField == &m_visibleTimeRangeMin || changedField == &m_visibleTimeRangeMax)
|
else if (changedField == &m_visibleTimeRangeMin)
|
||||||
|
{
|
||||||
|
QTime test = newValue.toTime();
|
||||||
|
if (!test.isValid())
|
||||||
|
{
|
||||||
|
m_visibleTimeRangeMin = oldValue.toTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTimeVisibleRange();
|
||||||
|
m_isAutoZoom = false;
|
||||||
|
}
|
||||||
|
else if (changedField == &m_visibleTimeSinceStartRangeMin || changedField == &m_visibleTimeSinceStartRangeMax)
|
||||||
{
|
{
|
||||||
updateDateVisibleRange();
|
updateDateVisibleRange();
|
||||||
m_isAutoZoom = false;
|
m_isAutoZoom = false;
|
||||||
@ -460,7 +585,58 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* c
|
|||||||
rimSummaryPlot->loadDataAndUpdate();
|
rimSummaryPlot->loadDataAndUpdate();
|
||||||
updateDateVisibleRange();
|
updateDateVisibleRange();
|
||||||
}
|
}
|
||||||
|
else if (changedField == &m_dateFormat || changedField == &m_timeFormat)
|
||||||
|
{
|
||||||
|
updateTimeVisibleRange(); // Use the stored max min dates to update the visible time range to new unit
|
||||||
|
rimSummaryPlot->loadDataAndUpdate();
|
||||||
|
updateDateVisibleRange();
|
||||||
|
}
|
||||||
|
|
||||||
rimSummaryPlot->updateAxes();
|
rimSummaryPlot->updateAxes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryTimeAxisProperties::initAfterRead()
|
||||||
|
{
|
||||||
|
QDateTime maxDateTime = m_visibleDateTimeRangeMax_OBSOLETE();
|
||||||
|
QDateTime minDateTime = m_visibleDateTimeRangeMin_OBSOLETE();
|
||||||
|
if (maxDateTime.isValid())
|
||||||
|
{
|
||||||
|
m_visibleDateRangeMax = maxDateTime.date();
|
||||||
|
m_visibleTimeRangeMax = maxDateTime.time();
|
||||||
|
}
|
||||||
|
if (minDateTime.isValid())
|
||||||
|
{
|
||||||
|
m_visibleDateRangeMin = minDateTime.date();
|
||||||
|
m_visibleTimeRangeMin = minDateTime.time();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryTimeAxisProperties::defineEditorAttribute(const caf::PdmFieldHandle* field,
|
||||||
|
QString uiConfigName,
|
||||||
|
caf::PdmUiEditorAttribute* attribute)
|
||||||
|
{
|
||||||
|
if (field == &m_visibleDateRangeMin || field == &m_visibleDateRangeMax)
|
||||||
|
{
|
||||||
|
auto dateAttrib = dynamic_cast<caf::PdmUiDateEditorAttribute*>(attribute);
|
||||||
|
if (dateAttrib)
|
||||||
|
{
|
||||||
|
dateAttrib->dateFormat =
|
||||||
|
RiaQDateTimeTools::dateFormatString(m_dateFormat(), RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (field == &m_visibleTimeRangeMin || field == &m_visibleTimeRangeMax)
|
||||||
|
{
|
||||||
|
auto timeAttrib = dynamic_cast<caf::PdmUiTimeEditorAttribute*>(attribute);
|
||||||
|
if (timeAttrib)
|
||||||
|
{
|
||||||
|
timeAttrib->timeFormat =
|
||||||
|
RiaQDateTimeTools::timeFormatString(m_timeFormat(), RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE_SECOND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "RiaQDateTimeTools.h"
|
||||||
#include "RimPlotAxisPropertiesInterface.h"
|
#include "RimPlotAxisPropertiesInterface.h"
|
||||||
|
|
||||||
#include "cafPdmObject.h"
|
#include "cafPdmObject.h"
|
||||||
@ -70,6 +71,9 @@ public:
|
|||||||
double fromTimeTToDisplayUnitScale();
|
double fromTimeTToDisplayUnitScale();
|
||||||
double fromDaysToDisplayUnitScale();
|
double fromDaysToDisplayUnitScale();
|
||||||
|
|
||||||
|
const QString& dateFormat() const;
|
||||||
|
const QString& timeFormat() const;
|
||||||
|
|
||||||
double visibleRangeMin() const;
|
double visibleRangeMin() const;
|
||||||
double visibleRangeMax() const;
|
double visibleRangeMax() const;
|
||||||
|
|
||||||
@ -81,30 +85,49 @@ public:
|
|||||||
|
|
||||||
bool isActive() const;
|
bool isActive() const;
|
||||||
|
|
||||||
|
QDateTime visibleDateTimeMin() const;
|
||||||
|
QDateTime visibleDateTimeMax() const;
|
||||||
|
|
||||||
|
void setVisibleDateTimeMin(const QDateTime& dateTime);
|
||||||
|
void setVisibleDateTimeMax(const QDateTime& dateTime);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||||
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||||
caf::PdmFieldHandle* objectToggleField() override;
|
caf::PdmFieldHandle* objectToggleField() override;
|
||||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||||
|
void initAfterRead() override;
|
||||||
|
void defineEditorAttribute(const caf::PdmFieldHandle* field,
|
||||||
|
QString uiConfigName,
|
||||||
|
caf::PdmUiEditorAttribute* attribute) override;
|
||||||
|
|
||||||
double fromDateToDisplayTime(const QDateTime& displayTime);
|
double fromDateToDisplayTime(const QDateTime& displayTime);
|
||||||
QDateTime fromDisplayTimeToDate(double displayTime);
|
QDateTime fromDisplayTimeToDate(double displayTime);
|
||||||
void updateTimeVisibleRange();
|
void updateTimeVisibleRange();
|
||||||
void updateDateVisibleRange();
|
void updateDateVisibleRange();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmField< caf::AppEnum< TimeModeType > > m_timeMode;
|
caf::PdmField< caf::AppEnum< TimeModeType > > m_timeMode;
|
||||||
caf::PdmField< caf::AppEnum< TimeUnitType > > m_timeUnit;
|
caf::PdmField< caf::AppEnum< TimeUnitType > > m_timeUnit;
|
||||||
|
|
||||||
caf::PdmField<bool> m_isActive;
|
caf::PdmField<bool> m_isActive;
|
||||||
caf::PdmField<QDateTime> m_visibleDateRangeMin;
|
caf::PdmField<QDate> m_visibleDateRangeMin;
|
||||||
caf::PdmField<QDateTime> m_visibleDateRangeMax;
|
caf::PdmField<QDate> m_visibleDateRangeMax;
|
||||||
caf::PdmField<double> m_visibleTimeRangeMin;
|
caf::PdmField<QTime> m_visibleTimeRangeMin;
|
||||||
caf::PdmField<double> m_visibleTimeRangeMax;
|
caf::PdmField<QTime> m_visibleTimeRangeMax;
|
||||||
|
|
||||||
|
caf::PdmField<double> m_visibleTimeSinceStartRangeMin;
|
||||||
|
caf::PdmField<double> m_visibleTimeSinceStartRangeMax;
|
||||||
caf::PdmField<bool> m_isAutoZoom;
|
caf::PdmField<bool> m_isAutoZoom;
|
||||||
|
|
||||||
caf::PdmField<int> m_titleFontSize;
|
caf::PdmField<int> m_titleFontSize;
|
||||||
caf::PdmField<caf::AppEnum<AxisTitlePositionType>> m_titlePositionEnum;
|
caf::PdmField<caf::AppEnum<AxisTitlePositionType>> m_titlePositionEnum;
|
||||||
caf::PdmField<int> m_valuesFontSize;
|
caf::PdmField<int> m_valuesFontSize;
|
||||||
|
caf::PdmField<QString> m_dateFormat;
|
||||||
|
caf::PdmField<QString> m_timeFormat;
|
||||||
|
|
||||||
|
caf::PdmField<QDateTime> m_visibleDateTimeRangeMin_OBSOLETE;
|
||||||
|
caf::PdmField<QDateTime> m_visibleDateTimeRangeMax_OBSOLETE;
|
||||||
};
|
};
|
||||||
|
@ -82,7 +82,11 @@ RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlo
|
|||||||
RiuQwtPlotTools::setCommonPlotBehaviour(m_lorenzPlot);
|
RiuQwtPlotTools::setCommonPlotBehaviour(m_lorenzPlot);
|
||||||
new RiuQwtPlotWheelZoomer(m_lorenzPlot);
|
new RiuQwtPlotWheelZoomer(m_lorenzPlot);
|
||||||
addWindowZoom(m_lorenzPlot);
|
addWindowZoom(m_lorenzPlot);
|
||||||
RiuQwtPlotTools::enableDateBasedBottomXAxis(m_lorenzPlot);
|
|
||||||
|
QString dateFormat = RiaApplication::instance()->preferences()->dateFormat();
|
||||||
|
QString timeFormat = RiaApplication::instance()->preferences()->timeFormat();
|
||||||
|
|
||||||
|
RiuQwtPlotTools::enableDateBasedBottomXAxis(m_lorenzPlot, dateFormat, timeFormat);
|
||||||
m_lorenzPlot->setTitle("Lorenz Coefficient");
|
m_lorenzPlot->setTitle("Lorenz Coefficient");
|
||||||
|
|
||||||
RiuQwtPlotTools::setCommonPlotBehaviour(m_sweepEffPlot);
|
RiuQwtPlotTools::setCommonPlotBehaviour(m_sweepEffPlot);
|
||||||
|
@ -17,12 +17,16 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
#include "RiuQwtPlotTools.h"
|
#include "RiuQwtPlotTools.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaPreferences.h"
|
||||||
|
|
||||||
#include "qwt_date_scale_draw.h"
|
#include "qwt_date_scale_draw.h"
|
||||||
#include "qwt_date_scale_engine.h"
|
#include "qwt_date_scale_engine.h"
|
||||||
#include "qwt_plot.h"
|
#include "qwt_plot.h"
|
||||||
#include "qwt_plot_grid.h"
|
#include "qwt_plot_grid.h"
|
||||||
#include "qwt_plot_layout.h"
|
#include "qwt_plot_layout.h"
|
||||||
|
|
||||||
|
#include <QRegExp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -108,12 +112,69 @@ void RiuQwtPlotTools::setDefaultAxes(QwtPlot* plot)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuQwtPlotTools::enableDateBasedBottomXAxis(QwtPlot* plot)
|
void RiuQwtPlotTools::enableDateBasedBottomXAxis(QwtPlot* plot,
|
||||||
|
const QString& dateFormat,
|
||||||
|
const QString& timeFormat)
|
||||||
{
|
{
|
||||||
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw(Qt::UTC);
|
QwtDateScaleDraw* scaleDraw = new QwtDateScaleDraw(Qt::UTC);
|
||||||
scaleDraw->setDateFormat(QwtDate::Year, QString("dd-MM-yyyy"));
|
|
||||||
|
std::set<QwtDate::IntervalType> intervals = {QwtDate::Year,
|
||||||
|
QwtDate::Month,
|
||||||
|
QwtDate::Week,
|
||||||
|
QwtDate::Day,
|
||||||
|
QwtDate::Hour,
|
||||||
|
QwtDate::Minute,
|
||||||
|
QwtDate::Second,
|
||||||
|
QwtDate::Millisecond};
|
||||||
|
|
||||||
|
for (QwtDate::IntervalType interval : intervals)
|
||||||
|
{
|
||||||
|
scaleDraw->setDateFormat(interval, dateTimeFormatForInterval(interval, dateFormat, timeFormat));
|
||||||
|
}
|
||||||
|
|
||||||
QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine(Qt::UTC);
|
QwtDateScaleEngine* scaleEngine = new QwtDateScaleEngine(Qt::UTC);
|
||||||
plot->setAxisScaleEngine(QwtPlot::xBottom, scaleEngine);
|
plot->setAxisScaleEngine(QwtPlot::xBottom, scaleEngine);
|
||||||
plot->setAxisScaleDraw(QwtPlot::xBottom, scaleDraw);
|
plot->setAxisScaleDraw(QwtPlot::xBottom, scaleDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RiuQwtPlotTools::dateTimeFormatForInterval(QwtDate::IntervalType interval,
|
||||||
|
const QString& dateFormat,
|
||||||
|
const QString& timeFormat)
|
||||||
|
{
|
||||||
|
switch (interval)
|
||||||
|
{
|
||||||
|
case QwtDate::Millisecond:
|
||||||
|
return RiaQDateTimeTools::timeFormatString(timeFormat, RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE_SECOND_MILLISECOND);
|
||||||
|
case QwtDate::Second:
|
||||||
|
return RiaQDateTimeTools::timeFormatString(timeFormat, RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE_SECOND);
|
||||||
|
case QwtDate::Minute: {
|
||||||
|
QString fullFormat = RiaQDateTimeTools::timeFormatString(timeFormat, RiaQDateTimeTools::TIME_FORMAT_HOUR_MINUTE);
|
||||||
|
fullFormat += "\n";
|
||||||
|
fullFormat += RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
|
||||||
|
return fullFormat;
|
||||||
|
}
|
||||||
|
case QwtDate::Hour: {
|
||||||
|
QString fullFormat = RiaQDateTimeTools::timeFormatString(timeFormat, RiaQDateTimeTools::TIME_FORMAT_HOUR);
|
||||||
|
if (!fullFormat.endsWith("AP"))
|
||||||
|
{
|
||||||
|
fullFormat += ":00";
|
||||||
|
}
|
||||||
|
fullFormat += "\n";
|
||||||
|
fullFormat += RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
|
||||||
|
return fullFormat;
|
||||||
|
}
|
||||||
|
case QwtDate::Day:
|
||||||
|
return RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
|
||||||
|
case QwtDate::Week:
|
||||||
|
return RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH);
|
||||||
|
case QwtDate::Month:
|
||||||
|
return RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH);
|
||||||
|
case QwtDate::Year:
|
||||||
|
return RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR);
|
||||||
|
default:
|
||||||
|
return RiaQDateTimeTools::dateFormatString(dateFormat, RiaQDateTimeTools::DATE_FORMAT_YEAR_MONTH_DAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "RiaQDateTimeTools.h"
|
||||||
|
#include <qwt_date.h>
|
||||||
|
|
||||||
class QwtPlot;
|
class QwtPlot;
|
||||||
|
|
||||||
class RiuQwtPlotTools
|
class RiuQwtPlotTools
|
||||||
@ -24,6 +27,8 @@ class RiuQwtPlotTools
|
|||||||
public:
|
public:
|
||||||
static void setCommonPlotBehaviour(QwtPlot* plot);
|
static void setCommonPlotBehaviour(QwtPlot* plot);
|
||||||
static void setDefaultAxes(QwtPlot* plot);
|
static void setDefaultAxes(QwtPlot* plot);
|
||||||
static void enableDateBasedBottomXAxis(QwtPlot* plot);
|
static void enableDateBasedBottomXAxis(QwtPlot* plot, const QString& dateFormat, const QString& timeFormat);
|
||||||
};
|
|
||||||
|
|
||||||
|
static QString
|
||||||
|
dateTimeFormatForInterval(QwtDate::IntervalType interval, const QString& dateFormat, const QString& timeFormat);
|
||||||
|
};
|
||||||
|
@ -183,7 +183,10 @@ void RiuResultQwtPlot::setDefaults()
|
|||||||
enableAxis(QwtPlot::xTop, false);
|
enableAxis(QwtPlot::xTop, false);
|
||||||
enableAxis(QwtPlot::yRight, false);
|
enableAxis(QwtPlot::yRight, false);
|
||||||
|
|
||||||
RiuQwtPlotTools::enableDateBasedBottomXAxis(this);
|
QString dateFormat = RiaApplication::instance()->preferences()->dateFormat();
|
||||||
|
QString timeFormat = RiaApplication::instance()->preferences()->timeFormat();
|
||||||
|
|
||||||
|
RiuQwtPlotTools::enableDateBasedBottomXAxis(this, dateFormat, timeFormat);
|
||||||
|
|
||||||
setAxisMaxMinor(QwtPlot::xBottom, 2);
|
setAxisMaxMinor(QwtPlot::xBottom, 2);
|
||||||
setAxisMaxMinor(QwtPlot::yLeft, 3);
|
setAxisMaxMinor(QwtPlot::yLeft, 3);
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
#include "RiuSummaryQwtPlot.h"
|
#include "RiuSummaryQwtPlot.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaPreferences.h"
|
||||||
|
|
||||||
#include "RimEnsembleCurveSet.h"
|
#include "RimEnsembleCurveSet.h"
|
||||||
#include "RimEnsembleCurveSetCollection.h"
|
#include "RimEnsembleCurveSetCollection.h"
|
||||||
#include "RimMainPlotCollection.h"
|
#include "RimMainPlotCollection.h"
|
||||||
@ -98,9 +101,10 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot(RimViewWindow* viewWindow, QWidget* parent
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuSummaryQwtPlot::useDateBasedTimeAxis()
|
void RiuSummaryQwtPlot::useDateBasedTimeAxis(const QString& dateFormat,
|
||||||
|
const QString& timeFormat)
|
||||||
{
|
{
|
||||||
RiuQwtPlotTools::enableDateBasedBottomXAxis(this);
|
RiuQwtPlotTools::enableDateBasedBottomXAxis(this, dateFormat, timeFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -198,7 +202,10 @@ void RiuSummaryQwtPlot::contextMenuEvent(QContextMenuEvent* event)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuSummaryQwtPlot::setDefaults()
|
void RiuSummaryQwtPlot::setDefaults()
|
||||||
{
|
{
|
||||||
useDateBasedTimeAxis();
|
QString dateFormat = RiaApplication::instance()->preferences()->dateFormat();
|
||||||
|
QString timeFormat = RiaApplication::instance()->preferences()->timeFormat();
|
||||||
|
|
||||||
|
useDateBasedTimeAxis(dateFormat, timeFormat);
|
||||||
|
|
||||||
// The legend will be deleted in the destructor of the plot or when
|
// The legend will be deleted in the destructor of the plot or when
|
||||||
// another legend is inserted.
|
// another legend is inserted.
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "RiaQDateTimeTools.h"
|
||||||
#include "RiuInterfaceToViewWindow.h"
|
#include "RiuInterfaceToViewWindow.h"
|
||||||
#include "RiuQwtPlot.h"
|
#include "RiuQwtPlot.h"
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ class RiuSummaryQwtPlot : public RiuQwtPlot
|
|||||||
public:
|
public:
|
||||||
RiuSummaryQwtPlot(RimViewWindow* ownerViewWindow, QWidget* parent = nullptr);
|
RiuSummaryQwtPlot(RimViewWindow* ownerViewWindow, QWidget* parent = nullptr);
|
||||||
|
|
||||||
void useDateBasedTimeAxis();
|
void useDateBasedTimeAxis(const QString& dateFormat, const QString& timeFormat);
|
||||||
void useTimeBasedTimeAxis();
|
void useTimeBasedTimeAxis();
|
||||||
|
|
||||||
void addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet* curveSetToShowLegendFor);
|
void addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet* curveSetToShowLegendFor);
|
||||||
|
@ -41,3 +41,41 @@ QTextStream& operator << (QTextStream& str, const QDateTime& value)
|
|||||||
str << text;
|
str << text;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Specialized read operation for QDates
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
#include <QDate>
|
||||||
|
QTextStream& operator >> (QTextStream& str, QDate& value)
|
||||||
|
{
|
||||||
|
QString text;
|
||||||
|
str >> text;
|
||||||
|
value = QDate::fromString(text, "yyyy_MM_dd");
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream& operator << (QTextStream& str, const QDate& value)
|
||||||
|
{
|
||||||
|
QString text = value.toString("yyyy_MM_dd");
|
||||||
|
str << text;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Specialized read operation for QTimes
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
#include <QTime>
|
||||||
|
QTextStream& operator >> (QTextStream& str, QTime& value)
|
||||||
|
{
|
||||||
|
QString text;
|
||||||
|
str >> text;
|
||||||
|
value = QTime::fromString(text, "HH:mm:ss");
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream& operator << (QTextStream& str, const QTime& value)
|
||||||
|
{
|
||||||
|
QString text = value.toString("HH:mm:ss");
|
||||||
|
str << text;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
@ -19,6 +19,22 @@ QTextStream& operator << (QTextStream& str, const bool& value);
|
|||||||
QTextStream& operator >> (QTextStream& str, QDateTime& value);
|
QTextStream& operator >> (QTextStream& str, QDateTime& value);
|
||||||
QTextStream& operator << (QTextStream& str, const QDateTime& value);
|
QTextStream& operator << (QTextStream& str, const QDateTime& value);
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
/// QTextStream Stream operator overloading for QDates
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
//class QDate;
|
||||||
|
QTextStream& operator >> (QTextStream& str, QDate& value);
|
||||||
|
QTextStream& operator << (QTextStream& str, const QDate& value);
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
/// QTextStream Stream operator overloading for QTimes
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
//class QTime;
|
||||||
|
QTextStream& operator >> (QTextStream& str, QTime& value);
|
||||||
|
QTextStream& operator << (QTextStream& str, const QTime& value);
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// QTextStream Stream operator overloading for std::vector of things.
|
/// QTextStream Stream operator overloading for std::vector of things.
|
||||||
|
@ -15,6 +15,7 @@ set (MOC_HEADER_FILES
|
|||||||
cafPdmUiColorEditor.h
|
cafPdmUiColorEditor.h
|
||||||
cafPdmUiComboBoxEditor.h
|
cafPdmUiComboBoxEditor.h
|
||||||
cafPdmUiDateEditor.h
|
cafPdmUiDateEditor.h
|
||||||
|
cafPdmUiTimeEditor.h
|
||||||
cafPdmUiDefaultObjectEditor.h
|
cafPdmUiDefaultObjectEditor.h
|
||||||
cafPdmUiDoubleSliderEditor.h
|
cafPdmUiDoubleSliderEditor.h
|
||||||
cafPdmUiFilePathEditor.h
|
cafPdmUiFilePathEditor.h
|
||||||
@ -71,6 +72,8 @@ set( PROJECT_FILES
|
|||||||
cafPdmUiComboBoxEditor.h
|
cafPdmUiComboBoxEditor.h
|
||||||
cafPdmUiDateEditor.cpp
|
cafPdmUiDateEditor.cpp
|
||||||
cafPdmUiDateEditor.h
|
cafPdmUiDateEditor.h
|
||||||
|
cafPdmUiTimeEditor.cpp
|
||||||
|
cafPdmUiTimeEditor.h
|
||||||
cafPdmUiDoubleSliderEditor.cpp
|
cafPdmUiDoubleSliderEditor.cpp
|
||||||
cafPdmUiDoubleSliderEditor.h
|
cafPdmUiDoubleSliderEditor.h
|
||||||
cafPdmUiDragDropInterface.h
|
cafPdmUiDragDropInterface.h
|
||||||
|
@ -88,6 +88,7 @@ void PdmUiDateEditor::configureAndUpdateUi(const QString& uiConfigName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_dateEdit->setDate(uiField()->uiValue().toDate());
|
m_dateEdit->setDate(uiField()->uiValue().toDate());
|
||||||
|
m_dateEdit->setTime(uiField()->uiValue().toTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ void PdmUiDateEditor::configureAndUpdateUi(const QString& uiConfigName)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QWidget* PdmUiDateEditor::createEditorWidget(QWidget* parent)
|
QWidget* PdmUiDateEditor::createEditorWidget(QWidget* parent)
|
||||||
{
|
{
|
||||||
m_dateEdit = new QDateEdit(parent);
|
m_dateEdit = new QDateTimeEdit(parent);
|
||||||
m_dateEdit->setCalendarPopup(true);
|
m_dateEdit->setCalendarPopup(true);
|
||||||
connect(m_dateEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
|
connect(m_dateEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
|
||||||
return m_dateEdit;
|
return m_dateEdit;
|
||||||
@ -116,7 +117,7 @@ QWidget* PdmUiDateEditor::createLabelWidget(QWidget* parent)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void PdmUiDateEditor::slotEditingFinished()
|
void PdmUiDateEditor::slotEditingFinished()
|
||||||
{
|
{
|
||||||
this->setValueToField(m_dateEdit->date());
|
this->setValueToField(m_dateEdit->dateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace caf
|
} // end namespace caf
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
#include "cafPdmUiFieldEditorHandle.h"
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
|
|
||||||
#include <QDateEdit>
|
#include <QDateTimeEdit>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -83,7 +83,7 @@ protected slots:
|
|||||||
void slotEditingFinished();
|
void slotEditingFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<QDateEdit> m_dateEdit;
|
QPointer<QDateTimeEdit> m_dateEdit;
|
||||||
QPointer<QShortenedLabel> m_label;
|
QPointer<QShortenedLabel> m_label;
|
||||||
|
|
||||||
PdmUiDateEditorAttribute m_attributes;
|
PdmUiDateEditorAttribute m_attributes;
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "cafPdmProxyValueField.h"
|
#include "cafPdmProxyValueField.h"
|
||||||
#include "cafPdmUiCheckBoxEditor.h"
|
#include "cafPdmUiCheckBoxEditor.h"
|
||||||
#include "cafPdmUiDateEditor.h"
|
#include "cafPdmUiDateEditor.h"
|
||||||
|
#include "cafPdmUiTimeEditor.h"
|
||||||
#include "cafPdmUiFieldEditorHandle.h"
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
#include "cafPdmUiFilePathEditor.h"
|
#include "cafPdmUiFilePathEditor.h"
|
||||||
#include "cafPdmUiLineEditor.h"
|
#include "cafPdmUiLineEditor.h"
|
||||||
@ -57,6 +58,7 @@ CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiCheckBoxEditor, bool);
|
|||||||
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, QString);
|
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, QString);
|
||||||
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiDateEditor, QDate);
|
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiDateEditor, QDate);
|
||||||
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiDateEditor, QDateTime);
|
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiDateEditor, QDateTime);
|
||||||
|
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiTimeEditor, QTime);
|
||||||
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, int);
|
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, int);
|
||||||
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, double);
|
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, double);
|
||||||
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, float);
|
CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiLineEditor, float);
|
||||||
|
121
Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.cpp
Normal file
121
Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.cpp
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
//##################################################################################################
|
||||||
|
//
|
||||||
|
// Custom Visualization Core library
|
||||||
|
// Copyright (C) 2017 Ceetron Solutions AS
|
||||||
|
//
|
||||||
|
// This library may be used under the terms of either the GNU General Public License or
|
||||||
|
// the GNU Lesser General Public License as follows:
|
||||||
|
//
|
||||||
|
// GNU General Public License Usage
|
||||||
|
// This library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
// GNU Lesser General Public License Usage
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
#include "cafPdmUiTimeEditor.h"
|
||||||
|
|
||||||
|
#include "cafFactory.h"
|
||||||
|
#include "cafPdmField.h"
|
||||||
|
#include "cafPdmObject.h"
|
||||||
|
#include "cafPdmUiDefaultObjectEditor.h"
|
||||||
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
|
#include "cafPdmUiOrdering.h"
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
#include "cafQShortenedLabel.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDate>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QIntValidator>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QPalette>
|
||||||
|
#include <QStatusBar>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
|
||||||
|
CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(PdmUiTimeEditor);
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiTimeEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||||
|
{
|
||||||
|
CAF_ASSERT(!m_timeEdit.isNull());
|
||||||
|
|
||||||
|
PdmUiFieldEditorHandle::updateLabelFromField(m_label, uiConfigName);
|
||||||
|
|
||||||
|
m_timeEdit->setEnabled(!uiField()->isUiReadOnly(uiConfigName));
|
||||||
|
|
||||||
|
caf::PdmUiObjectHandle* uiObject = uiObj(uiField()->fieldHandle()->ownerObject());
|
||||||
|
if (uiObject)
|
||||||
|
{
|
||||||
|
uiObject->editorAttribute(uiField()->fieldHandle(), uiConfigName, &m_attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_attributes.timeFormat.isEmpty())
|
||||||
|
{
|
||||||
|
m_timeEdit->setDisplayFormat(m_attributes.timeFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_timeEdit->setDate(uiField()->uiValue().toDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QWidget* PdmUiTimeEditor::createEditorWidget(QWidget* parent)
|
||||||
|
{
|
||||||
|
m_timeEdit = new QTimeEdit(parent);
|
||||||
|
connect(m_timeEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
|
||||||
|
return m_timeEdit;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QWidget* PdmUiTimeEditor::createLabelWidget(QWidget* parent)
|
||||||
|
{
|
||||||
|
m_label = new QShortenedLabel(parent);
|
||||||
|
return m_label;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void PdmUiTimeEditor::slotEditingFinished()
|
||||||
|
{
|
||||||
|
this->setValueToField(m_timeEdit->date());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end namespace caf
|
93
Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.h
Normal file
93
Fwk/AppFwk/cafUserInterface/cafPdmUiTimeEditor.h
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
//##################################################################################################
|
||||||
|
//
|
||||||
|
// Custom Visualization Core library
|
||||||
|
// Copyright (C) 2019- Ceetron Solutions AS
|
||||||
|
//
|
||||||
|
// This library may be used under the terms of either the GNU General Public License or
|
||||||
|
// the GNU Lesser General Public License as follows:
|
||||||
|
//
|
||||||
|
// GNU General Public License Usage
|
||||||
|
// This library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
// GNU Lesser General Public License Usage
|
||||||
|
// This library is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//##################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cafPdmUiFieldEditorHandle.h"
|
||||||
|
|
||||||
|
#include <QTimeEdit>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPointer>
|
||||||
|
#include <QString>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class PdmUiTimeEditorAttribute : public PdmUiEditorAttribute
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString timeFormat;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PdmUiTimeEditorAttribute()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
class PdmUiTimeEditor : public PdmUiFieldEditorHandle
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PdmUiTimeEditor() {}
|
||||||
|
~PdmUiTimeEditor() override {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QWidget* createEditorWidget(QWidget * parent) override;
|
||||||
|
QWidget* createLabelWidget(QWidget * parent) override;
|
||||||
|
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void slotEditingFinished();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<QTimeEdit> m_timeEdit;
|
||||||
|
QPointer<QShortenedLabel> m_label;
|
||||||
|
|
||||||
|
PdmUiTimeEditorAttribute m_attributes;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // end namespace caf
|
Loading…
Reference in New Issue
Block a user