void GraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item)
{
    //use attached properties
    if (GridLayoutAttached *obj = attachedProperties.value(item)) {
        int row = obj->row();
        int column = obj->column();
        int rowSpan = obj->rowSpan();
        int columnSpan = obj->columnSpan();
        Qt::Alignment alignment = obj->alignment();

        if (row == -1 || column == -1) {
            qWarning() << "Must set row and column for an item in a grid layout";
            return;
        }

        if (obj->rowSpacing() != -1)
            setRowSpacing(row, obj->rowSpacing());
        if (obj->columnSpacing() != -1)
            setColumnSpacing(column, obj->columnSpacing());
        if (obj->rowStretchFactor() != -1)
            setRowStretchFactor(row, obj->rowStretchFactor());
        if (obj->columnStretchFactor() != -1)
            setColumnStretchFactor(column, obj->columnStretchFactor());
        if (obj->rowPreferredHeight() != -1)
            setRowPreferredHeight(row, obj->rowPreferredHeight());
        if (obj->rowMaximumHeight() != -1)
            setRowMaximumHeight(row, obj->rowMaximumHeight());
        if (obj->rowMinimumHeight() != -1)
            setRowMinimumHeight(row, obj->rowMinimumHeight());
        if (obj->rowFixedHeight() != -1)
            setRowFixedHeight(row, obj->rowFixedHeight());
        if (obj->columnPreferredWidth() != -1)
            setColumnPreferredWidth(row, obj->columnPreferredWidth());
        if (obj->columnMaximumWidth() != -1)
            setColumnMaximumWidth(row, obj->columnMaximumWidth());
        if (obj->columnMinimumWidth() != -1)
            setColumnMinimumWidth(row, obj->columnMinimumWidth());
        if (obj->columnFixedWidth() != -1)
            setColumnFixedWidth(row, obj->columnFixedWidth());

        addItem(item, row, column, rowSpan, columnSpan);

        if (alignment != -1)
            setAlignment(item, alignment);
        QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*, Qt::Alignment)),
                         this, SLOT(updateAlignment(QGraphicsLayoutItem*, Qt::Alignment)));
    }
Esempio n. 2
0
DlRawfileDescTab::DlRawfileDescTab(QWidget* parent, DlProject* dlProject) :
    QWidget(parent),
    dlProject_(dlProject),
    rawSettingsDialog(nullptr),
    fieldSepTOB1Flag_(false)
{
    DEBUG_FUNC_NAME

    variableView_ = new VariableView(this);
    variableModel_ = new VariableModel(variableView_, dlProject_->variables());
    variableDelegate_ = new VariableDelegate(variableView_);

    variableView_->setModel(variableModel_);
    variableView_->setItemDelegate(variableDelegate_);
    variableView_->setSelectionMode(QAbstractItemView::SingleSelection);
    variableView_->setSelectionBehavior(QAbstractItemView::SelectColumns);
    variableView_->setCornerButtonEnabled(false);
    variableView_->setWordWrap(false);

    QHeaderView *hHeaderView = variableView_->horizontalHeader();
    hHeaderView->setDefaultSectionSize(175);
    hHeaderView->setSectionResizeMode(QHeaderView::Fixed);
    hHeaderView->setSectionsClickable(true);
    hHeaderView->setHighlightSections(true);
    hHeaderView->setSectionsMovable(false);

    variableView_->setMinimumHeight(298);
    variableView_->resizeRowsToContents();
    variableView_->resizeColumnsToContents();
    for (int i = 0; i < variableModel_->rowCount(); i++)
    {
        variableView_->verticalHeader()->resizeSection(i, 20);
    }

    auto addButton = new QToolButton;
    addButton->setObjectName(QStringLiteral("plusButton"));
    addButton->setToolTip(tr("<b>+</b> Add a variable."));

    auto removeButton = new QToolButton;
    removeButton->setObjectName(QStringLiteral("minusButton"));
    removeButton->setToolTip(tr("<b>-</b> Remove a variable."));

    auto buttonsLayout = new QVBoxLayout;
    buttonsLayout->addWidget(addButton);
    buttonsLayout->addWidget(removeButton);
    buttonsLayout->addStretch();

    rawSettingsButton = new QPushButton(tr("Raw File Settings..."));
    rawSettingsButton->setProperty("mdButton", true);
    rawSettingsButton->setStyleSheet(QStringLiteral("QPushButton {margin-top: 15px}"));

    clearCustomVarsButton = new QPushButton(tr("Clear Custom Variables"));
    clearCustomVarsButton->setProperty("mdButton", true);
    clearCustomVarsButton->setStyleSheet(QStringLiteral("QPushButton {margin-top: 15px}"));

    auto varLayout = new QGridLayout;
    varLayout->addWidget(variableView_, 0, 0, -1, 1);
    varLayout->addLayout(buttonsLayout, 0, 1, 1, 1);
    varLayout->setColumnStretch(0, 1);
    varLayout->setColumnStretch(1, 0);
    varLayout->setRowStretch(2, 0);
    varLayout->setSizeConstraint(QLayout::SetNoConstraint);

    auto varGroup = new QGroupBox(tr("Data Columns Info"));
    varGroup->setObjectName(QStringLiteral("simpleGroupBox"));
    varGroup->setFlat(true);
    varGroup->setLayout(varLayout);

    auto varScrollArea = new QScrollArea;
    varScrollArea->setWidget(varGroup);
    varScrollArea->setWidgetResizable(true);

    auto mainlayout = new QGridLayout(this);
    mainlayout->setRowMinimumHeight(0, 18);
    mainlayout->addWidget(rawSettingsButton, 1, 0, 1, 1, Qt::AlignTop);
    mainlayout->addWidget(clearCustomVarsButton, 2, 0, 1, 1, Qt::AlignTop);
    mainlayout->addWidget(varScrollArea, 0, 1, -1, -1);
    mainlayout->setRowStretch(3, 1);
    mainlayout->setColumnStretch(1, 1);
    mainlayout->setSizeConstraint(QLayout::SetNoConstraint);
    setLayout(mainlayout);

    connect(variableModel_, &VariableModel::modified, [=]()
            { dlProject_->setModified(true); });

    connect(dlProject, &DlProject::projectModified,
            this, &DlRawfileDescTab::updateModels);

    connect(dlProject, &DlProject::projectChanged,
            this, &DlRawfileDescTab::updateModels);

    connect(addButton, &QToolButton::clicked,
            variableView_, &VariableView::addVar);
    connect(removeButton, &QToolButton::clicked,
            variableView_, &VariableView::removeVar);

    connect(rawSettingsButton, &QPushButton::clicked,
            this, &DlRawfileDescTab::showRawSettingsDialog);

    connect(clearCustomVarsButton, &QPushButton::clicked,[=]()
            { variableDelegate_->clearCustomVariableBuffer(); });

    // to trigger table editing with single click without altering the
    // editTriggers property, because that way the column selection
    // clicking on the header trigger the first cell editor
    connect(variableView_, SIGNAL(clicked(const QModelIndex &)),
            variableView_, SLOT(edit(const QModelIndex &)));
}
TimeLagSettingsDialog::TimeLagSettingsDialog(QWidget *parent, EcProject *ecProject, ConfigState* config) :
    QDialog(parent),
    ecProject_(ecProject),
    configState_(config)
{
    setWindowModality(Qt::WindowModal);
    setWindowTitle(tr("Time Lag Optimization Settings"));
    WidgetUtils::removeContextHelpButton(this);

    auto groupTitle = new QLabel;
    groupTitle->setText(tr("Configure smart time lag detection, "
                           "providing quality selection criteria and initial "
                           "time lag windows"));

    auto hrLabel = new QLabel;
    hrLabel->setObjectName(QStringLiteral("hrLabel"));

    existingRadio = new QRadioButton(tr("Time lag file available : "));
    existingRadio->setToolTip(tr("<b>Time lag file available:</b> If you have a satisfactory time lag assessment from a previous run and it applies to the current dataset, you can use it by providing the path to the file 'eddypro_timelag_opt_ID.txt' that was generated by EddyPro in the previous run and contains the results of the assessment. This will shorten program execution time and assure full comparability between the current and previous results."));

    nonExistingRadio = new QRadioButton(tr("Time lag file not available :"));
    nonExistingRadio->setToolTip(tr("<b>Time lag file not available:</b> Choose this option and provide the following information if you need to optimize time lags for your dataset. EddyPro will complete the time lag optimization first and then complete the raw data processing and flux computation procedures."));

    subsetCheckBox = new QCheckBox;
    subsetCheckBox->setProperty("subperiod", true);
    subsetCheckBox->setText(tr("Select a different period"));
    subsetCheckBox->setToolTip(tr("<b>Select a different period:</b> Select this option and set the corresponding dates, to identify the time period EddyPro will use for the Time lag optimization. This subperiod must fall within the time period defined by the available raw data."));

    startDateLabel = new ClickLabel(this);
    startDateLabel->setText(tr("Start :"));
    startDateLabel->setToolTip(tr("<b>Start:</b> Starting date of the time period to be used for time lag optimization. This time should not be shorter than about 1-2 months. As a general recommendation, select a time period during which the instrument setup did not undergo major modifications. Results obtained using a given time period (e.g., 2 months) can be used for processing a longer time period, in which major modifications did not occur in the setup. The stricter the threshold setup in this dialogue, the longer the period should be in order to get robust results."));
    startDateEdit = new QDateEdit;
    startDateEdit->setToolTip(startDateLabel->toolTip());
    startDateEdit->setCalendarPopup(true);
    WidgetUtils::customizeCalendar(startDateEdit->calendarWidget());

    startTimeEdit = new QTimeEdit;
    startTimeEdit->setDisplayFormat(QStringLiteral("hh:mm"));
    startTimeEdit->setAccelerated(true);

    lockedIcon = new QLabel;
    auto pixmap = QPixmap(QStringLiteral(":/icons/vlink-locked"));
#if defined(Q_OS_MAC)
    pixmap.setDevicePixelRatio(2.0);
#endif
    lockedIcon->setPixmap(pixmap);

    endDateLabel = new ClickLabel(this);
    endDateLabel->setText(tr("End :"));
    endDateLabel->setToolTip(tr("<b>End:</b> End date of the time period to be used for time lag optimization. This time should not be shorter than about 1-2 months As a general recommendation, select a time period during which the instrumental setup did not undergo major modifications. Results obtained using a given time period (e.g., 2 months) can be used for processing a longer time period, in which major modifications did not occur in the setup. The stricter the threshold setup in this dialogue, the longer the period should be in order to get robust results."));
    endDateEdit = new QDateEdit;
    endDateEdit->setToolTip(endDateLabel->toolTip());
    endDateEdit->setCalendarPopup(true);
    WidgetUtils::customizeCalendar(endDateEdit->calendarWidget());

    endTimeEdit = new QTimeEdit;
    endTimeEdit->setDisplayFormat(QStringLiteral("hh:mm"));
    endTimeEdit->setAccelerated(true);

    auto dateTimeContainer = new QGridLayout;
    dateTimeContainer->addWidget(startDateEdit, 0, 1);
    dateTimeContainer->addWidget(startTimeEdit, 0, 2);
    dateTimeContainer->addWidget(lockedIcon, 0, 0, 2, 1);
    dateTimeContainer->addWidget(endDateEdit, 1, 1);
    dateTimeContainer->addWidget(endTimeEdit, 1, 2);
    dateTimeContainer->setColumnStretch(1, 1);
    dateTimeContainer->setColumnStretch(2, 1);
    dateTimeContainer->setColumnStretch(3, 2);
    dateTimeContainer->setContentsMargins(0, 0, 0, 0);
    dateTimeContainer->setVerticalSpacing(3);

    fileBrowse = new FileBrowseWidget;
    fileBrowse->setToolTip(tr("<b>Load:</b> Load an existing time lag file"));
    fileBrowse->setDialogTitle(tr("Select the Time Lag Optimization File"));
    fileBrowse->setDialogWorkingDir(WidgetUtils::getSearchPathHint());
    fileBrowse->setDialogFilter(tr("All Files (*.*)"));

    auto existingFileLayout = new QHBoxLayout;
    existingFileLayout->addWidget(existingRadio);
    existingFileLayout->addWidget(fileBrowse);
    existingFileLayout->setStretch(2, 1);
    existingFileLayout->setContentsMargins(0, 0, 0, 0);
    existingFileLayout->setSpacing(0);

    radioGroup = new QButtonGroup(this);
    radioGroup->addButton(existingRadio, 0);
    radioGroup->addButton(nonExistingRadio, 1);

    h2oTitleLabel = WidgetUtils::createBlueLabel(this, tr("Water vapor time lag as a function of relative humidity"));

    pgRangeLabel = new ClickLabel(tr("Plausibility range around median value :"));
    pgRangeLabel->setToolTip(tr("<b>Plausibility range around median value:</b> The plausibility range is defined as the median time lag, %1 <i>n</i> times the MAD (median of the absolute deviations from the median time lag). Specify <i>n</i> here. The value of 1.5 was heuristically found to be optimal.").arg(Defs::PLUSMINUS));
    pgRangeSpin = new QDoubleSpinBox;
    pgRangeSpin->setDecimals(1);
    pgRangeSpin->setRange(0.1, 100.0);
    pgRangeSpin->setSingleStep(0.1);
    pgRangeSpin->setAccelerated(true);
    pgRangeSpin->setSuffix(tr("  [mad]"));
    pgRangeSpin->setToolTip(pgRangeLabel->toolTip());
    pgRangeLabel_2 = new QLabel(tr("(<tt>%1%2n%3mad</tt>, where you set <tt>n</tt>)").arg(Defs::MICRO, Defs::PLUSMINUS, Defs::MID_DOT));

    rhClassLabel = new ClickLabel(tr("Number of RH classes :"));
    rhClassLabel->setToolTip(tr("<b>Number of RH classes:</b> Select the number or relative humidity classes, to assess water vapor time lag as a function of RH. The whole range or RH variation (0-100%) will be evenly divided according to the selected number of classes. For example, selecting 10 classes causes EddyPro to assess water vapor time lags for the classes 0-10%, 10-20%,..., 90-100%. Selecting 1 class, the label <b><i>Do not sort in RH classes</i></b> appears and will cause EddyPro to treat water vapor exactly like other passive gases. This option is only suitable for open path systems, or closed path systems with short and heated sampling lines."));

    rhClassSpin = new QSpinBox;
    rhClassSpin->setRange(1, 20);
    rhClassSpin->setSingleStep(1);
    rhClassSpin->setAccelerated(true);
    rhClassSpin->setSpecialValueText(tr("Do not sort in RH classes"));
    rhClassSpin->setToolTip(rhClassLabel->toolTip());

    gasTitleLabel = WidgetUtils::createBlueLabel(this, tr("Passive gases"));

    co2MinFluxLabel = new ClickLabel(tr("Minimum (absolute) %1 flux :").arg(Defs::CO2_STRING));
    co2MinFluxLabel->setToolTip(tr("<b>Minimum (absolute) %1 flux:</b> %1 time lags corresponding to fluxes smaller (in module) than this value will not be considered in the time lag optimization. Selecting high-enough fluxes assures that well developed turbulent conditions are met and the correlation function is well characterized.").arg(Defs::CO2_STRING));
    co2MinFluxSpin = new QDoubleSpinBox;
    co2MinFluxSpin->setDecimals(3);
    co2MinFluxSpin->setRange(0.0, 100.0);
    co2MinFluxSpin->setSingleStep(0.001);
    co2MinFluxSpin->setAccelerated(true);
    co2MinFluxSpin->setSuffix(tr("  [%1]").arg(Defs::UMOL_M2S_STRING));
    co2MinFluxSpin->setToolTip(co2MinFluxLabel->toolTip());

    ch4MinFluxLabel = new ClickLabel(tr("Minimum (absolute) %1 flux :").arg(Defs::CH4_STRING));
    ch4MinFluxLabel->setToolTip(tr("<b>Minimum (absolute) %1 flux:</b> %1 time lags corresponding to fluxes smaller (in module) than this value will not be considered in the time lag optimization. Selecting high-enough fluxes assures that well developed turbulent conditions are met and the correlation function is well characterized.").arg(Defs::CH4_STRING));
    ch4MinFluxSpin = new QDoubleSpinBox;
    ch4MinFluxSpin->setDecimals(3);
    ch4MinFluxSpin->setRange(0.0, 100.0);
    ch4MinFluxSpin->setSingleStep(0.001);
    ch4MinFluxSpin->setAccelerated(true);
    ch4MinFluxSpin->setSuffix(tr("  [%1]").arg(Defs::UMOL_M2S_STRING));
    ch4MinFluxSpin->setToolTip(ch4MinFluxLabel->toolTip());

    gas4MinFluxLabel = new ClickLabel(tr("Minimum (absolute) %1 gas flux :").arg(Defs::GAS4_STRING));
    gas4MinFluxLabel->setToolTip(tr("<b>Minimum (absolute) %1 gas flux:</b> %1 gas time lags corresponding to fluxes smaller (in module) than this value will not be considered in the time lag optimization. Selecting high-enough fluxes assures that well developed turbulent conditions are met and the correlation function is well characterized.").arg(Defs::GAS4_STRING));
    gas4MinFluxSpin = new QDoubleSpinBox;
    gas4MinFluxSpin->setDecimals(3);
    gas4MinFluxSpin->setRange(0.0, 100.0);
    gas4MinFluxSpin->setSingleStep(0.001);
    gas4MinFluxSpin->setAccelerated(true);
    gas4MinFluxSpin->setSuffix(tr("  [%1]").arg(Defs::UMOL_M2S_STRING));
    gas4MinFluxSpin->setToolTip(gas4MinFluxLabel->toolTip());

    leMinFluxLabel = new ClickLabel(tr("Minimum latent heat flux :"));
    leMinFluxLabel->setToolTip(tr("<b>Minimum latent heat flux:</b> Minimum latent heat flux: H<sub>2</sub>O time lags corresponding to latent heat fluxes smaller than this value will not be considered in the time lag optimization. Selecting high-enough fluxes assures that well developed turbulent conditions are met and the correlation function is well characterized."));
    leMinFluxSpin = new QDoubleSpinBox;
    leMinFluxSpin->setDecimals(1);
    leMinFluxSpin->setRange(0.0, 1000.0);
    leMinFluxSpin->setSingleStep(0.1);
    leMinFluxSpin->setAccelerated(true);
    leMinFluxSpin->setSuffix(tr("  [%1]").arg(Defs::W_M2_STRING));
    leMinFluxSpin->setToolTip(leMinFluxLabel->toolTip());

    searchWindowLabel = WidgetUtils::createBlueLabel(this, tr("Time lag searching windows"));

    minLabel = WidgetUtils::createBlueLabel(this, tr("Minimum"));
    minLabel->setToolTip(tr("<b>Minimum:</b> Minimum time lag for each gas, for initializing the time lag optimization procedure. The searching window defined by Minimum and Maximum should be large enough to accommodate all possible time lags. Leave as <i>Not set</i> if in doubt, EddyPro will initialize it automatically."));

    maxLabel = WidgetUtils::createBlueLabel(this, tr("Maximum"));
    maxLabel->setToolTip(tr("<b>Maximum:</b> Maximum time lag for each gas, for initializing the time lag optimization procedure. The searching window defined by Minimum and Maximum should be large enough to accommodate all possible time lags. In particular, maximum time lags of water vapor in closed path systems can up to ten times higher than its nominal value, or even higher. Leave as <i>Not set</i> if in doubt, EddyPro will initialize it automatically."));

    co2Label = new ClickLabel(tr("%1 :").arg(Defs::CO2_STRING));

    minCo2TlSpin = new QDoubleSpinBox;
    minCo2TlSpin->setDecimals(1);
    minCo2TlSpin->setRange(-1000.1, 1000.0);
    minCo2TlSpin->setSingleStep(0.1);
    minCo2TlSpin->setSpecialValueText(tr("Detect automatically"));
    minCo2TlSpin->setAccelerated(true);
    minCo2TlSpin->setSuffix(tr("  [s]"));
    minCo2TlSpin->setToolTip(minLabel->toolTip());

    maxCo2TlSpin = new QDoubleSpinBox;
    maxCo2TlSpin->setDecimals(1);
    maxCo2TlSpin->setRange(-1000.1, 1000.0);
    maxCo2TlSpin->setSingleStep(0.1);
    maxCo2TlSpin->setSpecialValueText(tr("Detect automatically"));
    maxCo2TlSpin->setAccelerated(true);
    maxCo2TlSpin->setSuffix(tr("  [s]"));
    maxCo2TlSpin->setToolTip(maxLabel->toolTip());

    h2oLabel = new ClickLabel(tr("%1 :").arg(Defs::H2O_STRING));

    minH2oTlSpin = new QDoubleSpinBox;
    minH2oTlSpin->setDecimals(1);
    minH2oTlSpin->setRange(-1000.1, 1000.0);
    minH2oTlSpin->setSingleStep(0.1);
    minH2oTlSpin->setSpecialValueText(tr("Detect automatically"));
    minH2oTlSpin->setAccelerated(true);
    minH2oTlSpin->setSuffix(tr("  [s]"));
    minH2oTlSpin->setToolTip(minLabel->toolTip());

    maxH2oTlSpin = new QDoubleSpinBox;
    maxH2oTlSpin->setDecimals(1);
    maxH2oTlSpin->setRange(-1000.1, 1000.0);
    maxH2oTlSpin->setSingleStep(0.1);
    maxH2oTlSpin->setSpecialValueText(tr("Detect automatically"));
    maxH2oTlSpin->setAccelerated(true);
    maxH2oTlSpin->setSuffix(tr("  [s]"));
    maxH2oTlSpin->setToolTip(maxLabel->toolTip());

    ch4Label = new ClickLabel(tr("%1 :").arg(Defs::CH4_STRING));

    minCh4TlSpin = new QDoubleSpinBox;
    minCh4TlSpin->setDecimals(1);
    minCh4TlSpin->setRange(-1000.1, 1000.0);
    minCh4TlSpin->setSingleStep(0.1);
    minCh4TlSpin->setSpecialValueText(tr("Detect automatically"));
    minCh4TlSpin->setAccelerated(true);
    minCh4TlSpin->setSuffix(tr("  [s]"));
    minCh4TlSpin->setToolTip(minLabel->toolTip());

    maxCh4TlSpin = new QDoubleSpinBox;
    maxCh4TlSpin->setDecimals(1);
    maxCh4TlSpin->setRange(-1000.1, 1000.0);
    maxCh4TlSpin->setSingleStep(0.1);
    maxCh4TlSpin->setSpecialValueText(tr("Detect automatically"));
    maxCh4TlSpin->setAccelerated(true);
    maxCh4TlSpin->setSuffix(tr("  [s]"));
    maxCh4TlSpin->setToolTip(maxLabel->toolTip());

    gas4Label = new ClickLabel(tr("%1 gas :").arg(Defs::GAS4_STRING));

    minGas4TlSpin = new QDoubleSpinBox;
    minGas4TlSpin->setDecimals(1);
    minGas4TlSpin->setRange(-1000.1, 1000.0);
    minGas4TlSpin->setSingleStep(0.1);
    minGas4TlSpin->setSpecialValueText(tr("Detect automatically"));
    minGas4TlSpin->setAccelerated(true);
    minGas4TlSpin->setSuffix(tr("  [s]"));
    minGas4TlSpin->setToolTip(minLabel->toolTip());

    maxGas4TlSpin = new QDoubleSpinBox;
    maxGas4TlSpin->setDecimals(1);
    maxGas4TlSpin->setRange(-1000.1, 1000.0);
    maxGas4TlSpin->setSingleStep(0.1);
    maxGas4TlSpin->setSpecialValueText(tr("Detect automatically"));
    maxGas4TlSpin->setAccelerated(true);
    maxGas4TlSpin->setSuffix(tr("  [s]"));
    maxGas4TlSpin->setToolTip(maxLabel->toolTip());

    auto propertiesLayout = new QGridLayout;
    propertiesLayout->addLayout(existingFileLayout, 0, 0, 1, -1);
    propertiesLayout->addWidget(nonExistingRadio, 1, 0);
    propertiesLayout->addWidget(subsetCheckBox, 1, 1, 1, 1, Qt::AlignLeft);
    propertiesLayout->addWidget(startDateLabel, 1, 1, Qt::AlignRight);
    propertiesLayout->addLayout(dateTimeContainer, 1, 2, 2, 1);
    propertiesLayout->addWidget(endDateLabel, 2, 1, Qt::AlignRight);
    propertiesLayout->addWidget(pgRangeLabel, 3, 1, 1, 1, Qt::AlignRight);
    propertiesLayout->addWidget(pgRangeSpin, 3, 2);
    propertiesLayout->addWidget(pgRangeLabel_2, 3, 3);

    propertiesLayout->addWidget(h2oTitleLabel, 4, 0, 1, 2);

    propertiesLayout->addWidget(rhClassLabel, 5, 1, Qt::AlignRight);
    propertiesLayout->addWidget(rhClassSpin, 5, 2);
    propertiesLayout->addWidget(leMinFluxLabel, 6, 1, Qt::AlignRight);
    propertiesLayout->addWidget(leMinFluxSpin, 6, 2);

    propertiesLayout->addWidget(gasTitleLabel, 7, 0);

    propertiesLayout->addWidget(co2MinFluxLabel, 8, 1, Qt::AlignRight);
    propertiesLayout->addWidget(co2MinFluxSpin, 8, 2);
    propertiesLayout->addWidget(ch4MinFluxLabel, 9, 1, Qt::AlignRight);
    propertiesLayout->addWidget(ch4MinFluxSpin, 9, 2);
    propertiesLayout->addWidget(gas4MinFluxLabel, 10, 1, Qt::AlignRight);
    propertiesLayout->addWidget(gas4MinFluxSpin, 10, 2);

    propertiesLayout->addWidget(searchWindowLabel, 11, 0);
    propertiesLayout->addWidget(minLabel, 12, 1);
    propertiesLayout->addWidget(maxLabel, 12, 2);
    propertiesLayout->addWidget(co2Label, 13, 0, Qt::AlignRight);
    propertiesLayout->addWidget(minCo2TlSpin, 13, 1);
    propertiesLayout->addWidget(maxCo2TlSpin, 13, 2);
    propertiesLayout->addWidget(h2oLabel, 14, 0, Qt::AlignRight);
    propertiesLayout->addWidget(minH2oTlSpin, 14, 1);
    propertiesLayout->addWidget(maxH2oTlSpin, 14, 2);
    propertiesLayout->addWidget(ch4Label, 15, 0, Qt::AlignRight);
    propertiesLayout->addWidget(minCh4TlSpin, 15, 1);
    propertiesLayout->addWidget(maxCh4TlSpin, 15, 2);
    propertiesLayout->addWidget(gas4Label, 16, 0, Qt::AlignRight);
    propertiesLayout->addWidget(minGas4TlSpin, 16, 1);
    propertiesLayout->addWidget(maxGas4TlSpin, 16, 2);
    propertiesLayout->setVerticalSpacing(3);
    propertiesLayout->setRowMinimumHeight(2, 10);
    propertiesLayout->setContentsMargins(3, 3, 3, 3);

    auto propertiesFrame = new QWidget;
    propertiesFrame->setLayout(propertiesLayout);
    propertiesFrame->setMinimumWidth(propertiesFrame->sizeHint().width());

    auto okButton = WidgetUtils::createCommonButton(this, tr("Ok"));

    auto mainLayout = new QGridLayout(this);
    mainLayout->addWidget(groupTitle, 0, 0);
    mainLayout->addWidget(hrLabel, 1, 0);
    mainLayout->addWidget(propertiesFrame, 2, 0);
    mainLayout->addWidget(okButton, 3, 0, 1, 1, Qt::AlignCenter);
    mainLayout->setVerticalSpacing(10);
    mainLayout->setContentsMargins(30, 30, 30, 30);
    mainLayout->setSizeConstraint(QLayout::SetFixedSize);
    setLayout(mainLayout);

    connect(radioGroup, SIGNAL(buttonClicked(int)),
            this, SLOT(updateTlMode(int)));

    connect(radioGroup, SIGNAL(buttonClicked(int)),
            this, SLOT(radioClicked(int)));

    connect(fileBrowse, &FileBrowseWidget::pathChanged,
            this, &TimeLagSettingsDialog::updateFile);
    connect(fileBrowse, &FileBrowseWidget::pathSelected,
        this, &TimeLagSettingsDialog::testSelectedFile);

    connect(subsetCheckBox, &QCheckBox::toggled,
            this, &TimeLagSettingsDialog::updateSubsetSelection);

    connect(startDateLabel, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onStartDateLabelClicked);
    connect(startDateEdit, &QDateEdit::dateChanged,
            this, &TimeLagSettingsDialog::updateStartDate);
    connect(startTimeEdit, &QTimeEdit::timeChanged,
            this, &TimeLagSettingsDialog::updateStartTime);

    connect(endDateLabel, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onEndDateLabelClicked);
    connect(endDateEdit, &QDateEdit::dateChanged,
            this, &TimeLagSettingsDialog::updateEndDate);
    connect(endTimeEdit, &QTimeEdit::timeChanged,
            this, &TimeLagSettingsDialog::updateEndTime);

    connect(rhClassLabel, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onRhClassClicked);
    connect(rhClassSpin, SIGNAL(valueChanged(int)),
            this, SLOT(updateRhClass(int)));

    connect(co2MinFluxLabel, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onCo2MinFluxClicked);
    connect(co2MinFluxSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateCo2MinFlux(double)));

    connect(ch4MinFluxLabel, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onCh4MinFluxClicked);
    connect(ch4MinFluxSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateCh4MinFlux(double)));

    connect(gas4MinFluxLabel, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onGas4MinFluxClicked);
    connect(gas4MinFluxSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateGas4MinFlux(double)));

    connect(leMinFluxLabel, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onLeMinFluxClicked);
    connect(leMinFluxSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateLeMinFlux(double)));

    connect(pgRangeLabel, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onPgRangeLabelClicked);
    connect(pgRangeSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updatePgRange(double)));

    connect(co2Label, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onCo2LabelClicked);
    connect(minCo2TlSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateMinCo2Tl(double)));
    connect(maxCo2TlSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateMaxCo2Tl(double)));

    connect(h2oLabel, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onH2oLabelClicked);
    connect(minH2oTlSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateMinH2oTl(double)));
    connect(maxH2oTlSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateMaxH2oTl(double)));

    connect(ch4Label, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onCh4LabelClicked);
    connect(minCh4TlSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateMinCh4Tl(double)));
    connect(maxCh4TlSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateMaxCh4Tl(double)));

    connect(gas4Label, &ClickLabel::clicked,
            this, &TimeLagSettingsDialog::onGas4LabelClicked);
    connect(minGas4TlSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateMinGas4Tl(double)));
    connect(maxGas4TlSpin, SIGNAL(valueChanged(double)),
            this, SLOT(updateMaxGas4Tl(double)));

    connect(okButton, &QPushButton::clicked,
            this, &TimeLagSettingsDialog::close);

    // init
    forceEndDatePolicy();
    forceEndTimePolicy();
}
Esempio n. 4
0
CalibrationDialog::CalibrationDialog(QWidget* parent, EcProject *ecProject, ConfigState* config) :
    QDialog(parent),
    ecProject_(ecProject),
    configState_(config)
{
    setWindowModality(Qt::WindowModal);
    setWindowTitle(tr("Calibration Values"));
    WidgetUtils::removeContextHelpButton(this);

    auto calibDateTitle = WidgetUtils::createBlueLabel(this, tr("Calibration date"));

    calibDate = new QDateTimeEdit;
    calibDate->setDisplayFormat(QStringLiteral("yyyy-MM-dd HH:mm:ss"));
    calibDate->setDate(QDate::currentDate());
    calibDate->setTime(QTime::currentTime());

    auto co2ValuesTitle = WidgetUtils::createBlueLabel(this,
                            tr("%1 calibration values").arg(Defs::CO2_STRING));

    auto co2_A_title = new QLabel;
    co2_A_title->setText(QStringLiteral("A :"));
    auto co2_B_title = new QLabel;
    co2_B_title->setText(QStringLiteral("B :"));
    auto co2_C_title = new QLabel;
    co2_C_title->setText(QStringLiteral("C :"));
    auto co2_D_title = new QLabel;
    co2_D_title->setText(QStringLiteral("D :"));
    auto co2_E_title = new QLabel;
    co2_E_title->setText(QStringLiteral("E :"));
    auto co2_XS_title = new QLabel;
    co2_XS_title->setText(QStringLiteral("XS :"));
    auto co2_Z_title = new QLabel;
    co2_Z_title->setText(QStringLiteral("Z :"));

    co2_A_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    co2_B_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    co2_C_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    co2_D_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    co2_E_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    co2_XS_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    co2_Z_spinbox = WidgetUtils::createCalibrationSpinbox(this);

    auto h2oValuesTitle = WidgetUtils::createBlueLabel(this,
                            tr("%1 calibration values").arg(Defs::H2O_STRING));

    auto h2o_A_title = new QLabel;
    h2o_A_title->setText(QStringLiteral("A :"));
    auto h2o_B_title = new QLabel;
    h2o_B_title->setText(QStringLiteral("B :"));
    auto h2o_C_title = new QLabel;
    h2o_C_title->setText(QStringLiteral("C :"));
    auto h2o_XS_title = new QLabel;
    h2o_XS_title->setText(QStringLiteral("XS :"));
    auto h2o_Z_title = new QLabel;
    h2o_Z_title->setText(QStringLiteral("Z :"));

    h2o_A_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    h2o_B_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    h2o_C_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    h2o_XS_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    h2o_Z_spinbox = WidgetUtils::createCalibrationSpinbox(this);

    auto zeroSpanDateTitle = WidgetUtils::createBlueLabel(this, tr("Zero/Span date"));

    zeroDate = new QDateTimeEdit;
    zeroDate->setDisplayFormat(QStringLiteral("yyyy-MM-dd HH:mm:ss"));
    zeroDate->setDate(QDate::currentDate());
    zeroDate->setTime(QTime::currentTime());

    auto zeroSpanValuesTitle = WidgetUtils::createBlueLabel(this, tr("Zero/Span values"));

    auto co2_Zero_title = new QLabel;
    co2_Zero_title->setText(QStringLiteral("%1 Zero :").arg(Defs::CO2_STRING));
    auto co2_Span_title = new QLabel;
    co2_Span_title->setText(QStringLiteral("%1 Span :").arg(Defs::CO2_STRING));
    auto co2_SpanTarget_title = new QLabel;
    co2_SpanTarget_title->setText(QStringLiteral("at :"));
    auto co2_Span2_title = new QLabel;
    co2_Span2_title->setText(QStringLiteral("%1 Span 2 :").arg(Defs::CO2_STRING));
    auto co2_Span2Target_title = new QLabel;
    co2_Span2Target_title->setText(QStringLiteral("at :"));
    auto co2_CX_title = new QLabel;
    co2_CX_title->setText(QStringLiteral("CX :"));

    co2_Zero_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    co2_Span_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    co2_SpanTarget_spinbox = new QDoubleSpinBox;
    co2_SpanTarget_spinbox->setSuffix(QStringLiteral(" [ppm]"));

    co2_Span2_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    co2_Span2Target_spinbox = new QDoubleSpinBox;
    co2_Span2Target_spinbox->setSuffix(QStringLiteral(" [ppm]"));
    co2_CX_spinbox = WidgetUtils::createCalibrationSpinbox(this);

    auto h2o_Zero_title = new QLabel;
    h2o_Zero_title->setText(QStringLiteral("%1 Zero :").arg(Defs::H2O_STRING));
    auto h2o_Span_title = new QLabel;
    h2o_Span_title->setText(QStringLiteral("%1 Span :").arg(Defs::H2O_STRING));
    auto h2o_SpanTarget_title = new QLabel;
    h2o_SpanTarget_title->setText(QStringLiteral("at :"));
    auto h2o_Span2_title = new QLabel;
    h2o_Span2_title->setText(QStringLiteral("%1 Span 2 :").arg(Defs::H2O_STRING));
    auto h2o_Span2Target_title = new QLabel;
    h2o_Span2Target_title->setText(QStringLiteral("at :"));
    auto h2o_WX_title = new QLabel;
    h2o_WX_title->setText(QStringLiteral("WX :"));

    h2o_Zero_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    h2o_Span_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    h2o_SpanTarget_spinbox = new QDoubleSpinBox;
    h2o_SpanTarget_spinbox->setSuffix(QStringLiteral(" [%1]").arg(Defs::DEGREE_C));
    h2o_Span2_spinbox = WidgetUtils::createCalibrationSpinbox(this);
    h2o_Span2Target_spinbox = new QDoubleSpinBox;
    h2o_Span2Target_spinbox->setSuffix(QStringLiteral(" [%1]").arg(Defs::DEGREE_C));
    h2o_WX_spinbox = WidgetUtils::createCalibrationSpinbox(this);

    auto okButton = WidgetUtils::createCommonButton(this, tr("Ok"));

    auto mainLayout = new QGridLayout(this);
    mainLayout->addWidget(calibDateTitle, 0, 0);
    mainLayout->addWidget(calibDate, 0, 1, 1, 2);

    mainLayout->addWidget(co2ValuesTitle, 1, 0, 1, 2);
    mainLayout->addWidget(co2_A_title, 2, 0, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_A_spinbox, 2, 1);
    mainLayout->addWidget(co2_B_title, 3, 0, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_B_spinbox, 3, 1);
    mainLayout->addWidget(co2_C_title, 4, 0, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_C_spinbox, 4, 1);
    mainLayout->addWidget(co2_D_title, 5, 0, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_D_spinbox, 5, 1);
    mainLayout->addWidget(co2_E_title, 6, 0, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_E_spinbox, 6, 1);
    mainLayout->addWidget(co2_XS_title, 7, 0, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_XS_spinbox, 7, 1);
    mainLayout->addWidget(co2_Z_title, 8, 0, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_Z_spinbox, 8, 1);

    mainLayout->addWidget(h2oValuesTitle, 1, 4, 1, 2);
    mainLayout->addWidget(h2o_A_title, 2, 4, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(h2o_A_spinbox, 2, 5);
    mainLayout->addWidget(h2o_B_title, 3, 4, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(h2o_B_spinbox, 3, 5);
    mainLayout->addWidget(h2o_C_title, 4, 4, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(h2o_C_spinbox, 4, 5);
    mainLayout->addWidget(h2o_XS_title, 5, 4, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(h2o_XS_spinbox, 5, 5);
    mainLayout->addWidget(h2o_Z_title, 6, 4, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(h2o_Z_spinbox, 6, 5);

    mainLayout->addWidget(zeroSpanDateTitle, 10, 0);
    mainLayout->addWidget(zeroDate, 10, 1, 1, 2);

    mainLayout->addWidget(zeroSpanValuesTitle, 12, 0);
    mainLayout->addWidget(co2_Zero_title, 13, 0, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_Zero_spinbox, 13, 1);
    mainLayout->addWidget(co2_Span_title, 14, 0, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_Span_spinbox, 14, 1);
    mainLayout->addWidget(co2_SpanTarget_title, 14, 2, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_SpanTarget_spinbox, 14, 3);
    mainLayout->addWidget(co2_Span2_title, 15, 0, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_Span2_spinbox, 15, 1);
    mainLayout->addWidget(co2_Span2Target_title, 15, 2, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_Span2Target_spinbox, 15, 3);
    mainLayout->addWidget(co2_CX_title, 16, 0, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(co2_CX_spinbox, 16, 1);

    mainLayout->addWidget(h2o_Zero_title, 13, 4, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(h2o_Zero_spinbox, 13, 5);
    mainLayout->addWidget(h2o_Span_title, 14, 4, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(h2o_Span_spinbox, 14, 5);
    mainLayout->addWidget(h2o_SpanTarget_title, 14, 6, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(h2o_SpanTarget_spinbox, 14, 7);
    mainLayout->addWidget(h2o_Span2_title, 15, 4, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(h2o_Span2_spinbox, 15, 5);
    mainLayout->addWidget(h2o_Span2Target_title, 15, 6, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(h2o_Span2Target_spinbox, 15, 7);
    mainLayout->addWidget(h2o_WX_title, 16, 4, 1, 1, Qt::AlignRight);
    mainLayout->addWidget(h2o_WX_spinbox, 16, 5);

    mainLayout->addWidget(okButton, 17, 0, 1, -1, Qt::AlignCenter);
    mainLayout->setVerticalSpacing(3);
    mainLayout->setContentsMargins(30, 30, 30, 30);
    mainLayout->setRowMinimumHeight(9, 30);
    mainLayout->setRowMinimumHeight(17, 30);
    setLayout(mainLayout);

    connect(okButton, &QPushButton::clicked,
            this, &CalibrationDialog::close);
}