2017-08-11 06:56:27 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
|
|
|
//
|
|
|
|
// ResInsight 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.
|
|
|
|
//
|
|
|
|
// ResInsight 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicPasteAsciiDataToSummaryPlotFeatureUi.h"
|
|
|
|
|
2017-11-21 03:01:43 -06:00
|
|
|
#include "cafPdmUiTextEditor.h"
|
|
|
|
|
2017-08-11 06:56:27 -05:00
|
|
|
namespace caf {
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void RicPasteAsciiDataToSummaryPlotFeatureUi::DecimalSeparatorEnum::setUp()
|
|
|
|
{
|
|
|
|
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_DOT, "DOT", "Dot: .");
|
|
|
|
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_COMMA, "COMMA", "Comma: ,");
|
|
|
|
setDefault(RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_DOT);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void RicPasteAsciiDataToSummaryPlotFeatureUi::DateFormatEnum::setUp()
|
|
|
|
{
|
|
|
|
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_DDMMYYYY_DOT_SEPARATED, "dd.MM.yyyy", "Day.Month.Year (dd.MM.yyyy)");
|
|
|
|
setDefault(RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_DDMMYYYY_DOT_SEPARATED);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void RicPasteAsciiDataToSummaryPlotFeatureUi::TimeFormatEnum::setUp()
|
|
|
|
{
|
|
|
|
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_NONE, "NONE", "None");
|
|
|
|
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_HHMM, "hh:mm", "Hour:Minute (hh:mm)");
|
|
|
|
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_HHMMSS, "hh:mm:ss", "Hour:Minute:Second (hh:mm:ss)");
|
|
|
|
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_HHMMSSZZZ, "hh:mm:ss.zzz", "Hour:Minute:Second.Millisecond (hh:mm:ss.zzz)");
|
|
|
|
setDefault(RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void RicPasteAsciiDataToSummaryPlotFeatureUi::CellSeparatorEnum::setUp()
|
|
|
|
{
|
2017-11-21 03:01:43 -06:00
|
|
|
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_TAB, "TAB", "Tab");
|
|
|
|
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_COMMA, "COMMA", "Comma");
|
|
|
|
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_SEMICOLON, "SEMICOLON", "Semicolon");
|
2017-08-11 06:56:27 -05:00
|
|
|
setDefault(RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_TAB);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-21 04:18:21 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RicPasteAsciiDataToSummaryPlotFeatureUi, "RicPasteAsciiDataToSummaryPlotFeatureUi");
|
2017-08-11 06:56:27 -05:00
|
|
|
|
2017-11-22 13:34:18 -06:00
|
|
|
|
2017-08-11 06:56:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-08-18 02:42:04 -05:00
|
|
|
RicPasteAsciiDataToSummaryPlotFeatureUi::RicPasteAsciiDataToSummaryPlotFeatureUi() : m_createNewPlot(false)
|
2017-08-11 06:56:27 -05:00
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("RicPasteAsciiDataToSummaryPlotFeatureUi", "", "", "");
|
|
|
|
|
2017-08-18 02:42:04 -05:00
|
|
|
CAF_PDM_InitField(&m_plotTitle, "PlotTitle", QString(), "Plot Title", "", "", "");
|
2017-08-18 02:59:00 -05:00
|
|
|
CAF_PDM_InitField(&m_curvePrefix, "CurvePrefix", QString(), "Curve Prefix", "", "", "");
|
2017-08-18 02:42:04 -05:00
|
|
|
|
2017-08-11 06:56:27 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_decimalSeparator, "DecimalSeparator", "Decimal Separator", "", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_dateFormat, "DateFormat", "Date Format", "", "", "");
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_timeFormat, "TimeFormat", "Time Format", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_useCustomDateFormat, "UseCustomDateFormat", false, "Use Custom Date Format", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_customDateFormat, "CustomDateFormat", QString(), "Custom Date Format", "", "", "");
|
|
|
|
|
2017-08-21 03:11:15 -05:00
|
|
|
CAF_PDM_InitField(&m_curveLineStyle, "LineStyle", caf::AppEnum<RimPlotCurve::LineStyleEnum>(RimPlotCurve::STYLE_NONE), "Line Style", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_curveSymbol, "Symbol", caf::AppEnum<RimPlotCurve::PointSymbolEnum>(RimPlotCurve::SYMBOL_ELLIPSE), "Symbol", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_curveSymbolSkipDistance, "SymbolSkipDinstance", 0.0f, "Symbol Skip Distance", "", "", "");
|
|
|
|
|
2017-08-11 06:56:27 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_cellSeparator, "CellSeparator", "Cell Separator", "", "", "");
|
2017-11-21 03:01:43 -06:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_previewText, "PreviewText", "Preview Text", "", "", "");
|
|
|
|
m_previewText.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName());
|
|
|
|
m_previewText.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
|
|
|
m_previewText.uiCapability()->setUiReadOnly(true);
|
2017-08-11 06:56:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-11-22 13:34:18 -06:00
|
|
|
const AsciiDataParseOptions RicPasteAsciiDataToSummaryPlotFeatureUi::parseOptions() const
|
2017-08-11 06:56:27 -05:00
|
|
|
{
|
2017-11-22 13:34:18 -06:00
|
|
|
AsciiDataParseOptions parseOptions;
|
|
|
|
|
|
|
|
parseOptions.plotTitle = m_plotTitle();
|
|
|
|
parseOptions.curvePrefix = m_curvePrefix();
|
|
|
|
|
2017-08-11 06:56:27 -05:00
|
|
|
{
|
2017-11-22 13:34:18 -06:00
|
|
|
QString separator;
|
|
|
|
switch (m_decimalSeparator())
|
2017-08-11 06:56:27 -05:00
|
|
|
{
|
2017-11-22 13:34:18 -06:00
|
|
|
case DECIMAL_COMMA:
|
|
|
|
separator = ",";
|
|
|
|
break;
|
|
|
|
case DECIMAL_DOT:
|
|
|
|
default:
|
|
|
|
separator = ".";
|
|
|
|
break;
|
2017-08-11 06:56:27 -05:00
|
|
|
}
|
|
|
|
|
2017-11-22 13:34:18 -06:00
|
|
|
parseOptions.decimalSeparator = separator;
|
2017-08-11 06:56:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2017-11-22 13:34:18 -06:00
|
|
|
QString dateFormat;
|
|
|
|
|
|
|
|
if (m_useCustomDateFormat())
|
|
|
|
{
|
|
|
|
dateFormat = m_customDateFormat;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dateFormat = m_dateFormat().text();
|
|
|
|
}
|
|
|
|
|
2017-11-23 02:52:33 -06:00
|
|
|
parseOptions.dateFormat = dateFormat;
|
2017-08-11 06:56:27 -05:00
|
|
|
}
|
|
|
|
|
2017-11-22 13:34:18 -06:00
|
|
|
parseOptions.timeFormat = m_timeFormat() != TIME_NONE ? m_timeFormat().text() : QString("");
|
2017-08-18 02:42:04 -05:00
|
|
|
|
2017-11-22 13:34:18 -06:00
|
|
|
{
|
|
|
|
QString separator;
|
2017-08-18 02:59:00 -05:00
|
|
|
|
2017-11-22 13:34:18 -06:00
|
|
|
switch (m_cellSeparator())
|
|
|
|
{
|
|
|
|
case CELL_COMMA:
|
|
|
|
separator = ",";
|
|
|
|
break;
|
|
|
|
case CELL_SEMICOLON:
|
|
|
|
separator = ";";
|
|
|
|
break;
|
|
|
|
case CELL_TAB:
|
|
|
|
default:
|
|
|
|
separator = "\t";
|
|
|
|
break;
|
|
|
|
}
|
2017-08-21 03:11:15 -05:00
|
|
|
|
2017-11-22 13:34:18 -06:00
|
|
|
parseOptions.cellSeparator = separator;
|
|
|
|
}
|
2017-08-21 03:11:15 -05:00
|
|
|
|
2017-11-22 13:34:18 -06:00
|
|
|
parseOptions.curveLineStyle = m_curveLineStyle();
|
|
|
|
parseOptions.curveSymbol = m_curveSymbol();
|
|
|
|
parseOptions.curveSymbolSkipDistance = m_curveSymbolSkipDistance();
|
|
|
|
|
|
|
|
return parseOptions;
|
2017-08-21 03:11:15 -05:00
|
|
|
}
|
|
|
|
|
2017-08-18 02:42:04 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicPasteAsciiDataToSummaryPlotFeatureUi::createNewPlot()
|
|
|
|
{
|
|
|
|
m_createNewPlot = true;
|
|
|
|
}
|
|
|
|
|
2017-11-21 03:01:43 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicPasteAsciiDataToSummaryPlotFeatureUi::setPreviewText(const QString& previewText)
|
|
|
|
{
|
|
|
|
m_previewText = previewText;
|
|
|
|
}
|
|
|
|
|
2017-08-11 06:56:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicPasteAsciiDataToSummaryPlotFeatureUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
2017-08-18 02:42:04 -05:00
|
|
|
{
|
2017-08-18 02:59:00 -05:00
|
|
|
caf::PdmUiGroup* namingGroup = uiOrdering.addNewGroup("Naming");
|
|
|
|
if (m_createNewPlot)
|
|
|
|
{
|
|
|
|
namingGroup->add(&m_plotTitle);
|
|
|
|
}
|
|
|
|
namingGroup->add(&m_curvePrefix);
|
2017-08-18 02:42:04 -05:00
|
|
|
}
|
|
|
|
|
2017-08-11 06:56:27 -05:00
|
|
|
{
|
|
|
|
caf::PdmUiGroup* valuesGroup = uiOrdering.addNewGroup("Values");
|
|
|
|
valuesGroup->add(&m_decimalSeparator);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
caf::PdmUiGroup* dateGroup = uiOrdering.addNewGroup("Dates");
|
|
|
|
dateGroup->add(&m_useCustomDateFormat);
|
|
|
|
if (m_useCustomDateFormat())
|
|
|
|
{
|
|
|
|
dateGroup->add(&m_customDateFormat);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dateGroup->add(&m_dateFormat);
|
|
|
|
dateGroup->add(&m_timeFormat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
caf::PdmUiGroup* cellGroup = uiOrdering.addNewGroup("Cells");
|
|
|
|
|
|
|
|
cellGroup->add(&m_cellSeparator);
|
|
|
|
}
|
|
|
|
|
2017-08-21 03:11:15 -05:00
|
|
|
{
|
|
|
|
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance");
|
|
|
|
|
|
|
|
appearanceGroup->add(&m_curveLineStyle);
|
|
|
|
appearanceGroup->add(&m_curveSymbol);
|
|
|
|
appearanceGroup->add(&m_curveSymbolSkipDistance);
|
|
|
|
}
|
|
|
|
|
2017-11-21 03:01:43 -06:00
|
|
|
{
|
|
|
|
caf::PdmUiGroup* previewGroup = uiOrdering.addNewGroup("Preview");
|
|
|
|
|
|
|
|
previewGroup->add(&m_previewText);
|
|
|
|
}
|
|
|
|
|
2017-08-11 06:56:27 -05:00
|
|
|
uiOrdering.skipRemainingFields();
|
|
|
|
}
|
2017-11-21 03:01:43 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicPasteAsciiDataToSummaryPlotFeatureUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
|
|
|
{
|
|
|
|
if (field == &m_previewText)
|
|
|
|
{
|
|
|
|
caf::PdmUiTextEditorAttribute* attrib = dynamic_cast<caf::PdmUiTextEditorAttribute*> (attribute);
|
|
|
|
if (attrib)
|
|
|
|
{
|
|
|
|
attrib->wrapMode = caf::PdmUiTextEditorAttribute::NoWrap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|