1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
/* Copyright (c) 2020, Dyssol Development Team.
* Copyright (c) 2023, DyssolTEC GmbH.
* All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */
#pragma once
#include "ui_BasicStreamsViewer.h"
#include "DyssolDefines.h"
#include "QtDialog.h"
#define PLOT_LINE_WIDTH 3
class CMaterialsDatabase;
class CFlowsheet;
class CBaseStream;
class CTimeDependentValue;
class CMDMatrix;
class CMultidimensionalGrid;
class CBasicStreamsViewer
: public QWidget
, public CDyssolBaseWidget
{
Q_OBJECT
private:
enum class EPropertyType : int { Mass, Temperatue, Pressure, PhaseFraction, Phase1, Phase2, Phase3, Phase4, SolidDistr, SauterDiameter };
enum class EDimType : int { Row, Col };
enum class EDistrCombination : int { Empty, Compounds, TwoDimensional, OneDimensionalVertical, OneDimensionalHorizontal };
enum class ETabType : int { Table, Plot };
CFlowsheet* m_pFlowsheet; /// Pointer to the flowsheet.
CMaterialsDatabase* m_materialsDB; // Pointer to materials database.
std::vector<const CBaseStream*> m_vSelectedStreams; /// Currently selected streams.
std::vector<const CTimeDependentValue*> m_vSelected2D; /// Currently selected 2D distributions from all selected streams.
std::vector<const CMDMatrix*> m_vSelectedMD; /// Currently selected MD distributions from all selected streams.
std::vector<double> m_vSelectedTP; /// Union of time points in all selected streams.
double m_dCurrentTime; /// Currently chosen time point.
public:
CBasicStreamsViewer(CFlowsheet* _pFlowsheet, CMaterialsDatabase* _materialsDB, QWidget* parent = nullptr);
void InitializeConnections() const;
/// Sets list of streams to visualize.
void SetStreams(const std::vector<const CBaseStream*>& _vStreams);
public slots:
void UpdateWholeView();
void setVisible(bool _bVisible) override;
private:
Ui::CBasicStreamsViewer ui;
/// Creates combo boxes for properties, dimensions and compounds.
void SetupComboBoxes() const;
/// Creates main combo box with the list of stream properties.
void SetupComboBoxProperties() const;
/// Creates combo box for a dimension, and selects the item with _defaultPos if nothing has been selected yet.
void SetupComboBoxDims(QComboBox* _combo, int _defaultPos) const;
/// Creates combo box for compounds.
void SetupComboBoxCompounds() const;
/// Creates combo box with PSD types.
void SetupComboBoxPSDType() const;
/// Creates combo box with PSD grid types.
void SetupComboBoxPSDGrid() const;
/// Creates time slider.
void SetupTimeSlider() const;
/// Updates the list of all time points m_vSelectedTP according to selected streams.
void GetSelectedTimePoints();
/// Updates the lists of all distributions m_vSelected2D and m_vSelectedMD according to selected streams.
void GetSelectedDistributions();
/// Sets position of time slider according to the current time m_dCurrentTime.
void UpdateSliderPosition();
/// Sets text to the time editor according to the current time m_dCurrentTime.
void UpdateTimeLabel() const;
/// Sets number of time points to the info label.
void UpdateTPNumberLabel() const;
/// Update main tab.
void UpdateTabView();
/// Update table view.
void UpdateTableTab();
/// Update plot view.
void UpdatePlotTab();
/// Sets enabled all controls according to the selection of streams.
void UpdateWidgetsEnable() const;
/// Sets visible all controls used for multidimensional stuff.
void UpdateWidgetsVisible() const;
/// Returns currently chosen property.
EPropertyType ChosenProperty() const;
/// Returns currently chosen distribution type for rows or columns.
EDistrTypes ChosenDim(EDimType _dim) const;
/// Returns currently chosen PSD type.
EPSDTypes ChosenPSDType() const;
/// Returns currently chosen PSD grid type.
EPSDGridType ChosenPSDGridType() const;
/// Returns the key of currently chosen compound.
std::string ChosenCompound() const;
/// Returns currently chosen tab.
ETabType ChosenTab() const;
/// Returns headers for the current table view according to provided distribution type _distr.
std::vector<std::string> TableHeaders(EDistrTypes _distr) const;
/// Return the name of the chosen PSD type if _distr is chosen.
std::string PSDSymbolicName(EDistrTypes _distr) const;
/// Return the name of the chosen distribution type _distr.
QString DistrSymbolicName(EDistrTypes _distr) const;
/// Sets selected mass/temperature/pressure to the table.
void SetMTPToTable(int _type);
/// Sets selected phase fractions to the table.
void SetPhaseFractionsToTable();
/// Sets selected compounds distribution to the table.
void SetPhaseCompoundsToTable();
/// Sets Sauter diameter of the selected distribution to the table.
void SetSauterDiameterToTable();
/// Sets selected distribution to the table.
void SetSolidDistrsToTable();
/// Configures the table according to the selected combination of settings _type.
void SetSolidDistrsToTableHeaders(EDistrCombination _type);
/// Sets data to the table according to the selected combination of settings _type.
void SetSolidDistrsToTableData(EDistrCombination _type);
/// Sets selected mass/temperature/pressure to the plot.
void SetMTPToPlot(int _type);
/// Sets selected phase fractions to the plot.
void SetPhaseFractionsToPlot();
/// Sets selected compounds distribution to the plot.
void SetPhaseCompoundsToPlot();
/// Sets Sauter diameter of the selected distribution to the plot.
void SetSauterDiameterToPlot();
/// Sets selected distribution to the plot.
void SetSolidDistrsToPlot();
/// Restores previous selected position if possible.
static void RestorePosition(QComboBox* _combo, int _position, int _defaultPosition = 0);
/// Exports selected data to a csv-file.
void ExportToFile();
/// Create and show context menu on right-click.
void contextMenuEvent(QContextMenuEvent* _event) override;
// Returns grid dimensions, either from the single selected stream or from the flowsheet.
const CMultidimensionalGrid& ActiveGrid() const;
private slots:
void PropertyChanged();
void SliderMoved();
void TimeEdited();
void PrevTimeClicked();
void NextTimeClicked();
void ComboRowsChanged();
void ComboColsChanged();
void ComboCompoundsChanged();
void ComboPSDTypeChanged();
void ComboPSDGridTypeChanged();
void TabChanged();
};
|