You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
192 lines
5.4 KiB
C++
192 lines
5.4 KiB
C++
#ifndef NMWXSENSITIVE_H
|
|
#define NMWXSENSITIVE_H
|
|
|
|
#include "iDlgBase.h"
|
|
#include "nmSubWxs_global.h"
|
|
|
|
#include "nmDataSensitive.h"
|
|
|
|
class QTreeWidget;
|
|
class QTreeWidgetItem;
|
|
class QComboBox;
|
|
class QPushButton;
|
|
class QStackedWidget;
|
|
class QCheckBox;
|
|
class QSpinBox;
|
|
class QLineEdit;
|
|
class nmDataAnalyzeManager;
|
|
class QTableWidget;
|
|
class QTableView;
|
|
class QLabel;
|
|
class QIcon;
|
|
class SensitivityRunsView;
|
|
class nmCalculationDllPebiSolverTask;
|
|
class QCloseEvent;
|
|
class SensitivityDistributionPlot;
|
|
class SensitivityResultsModel;
|
|
class iGuiPlot;
|
|
class QMenu;
|
|
class QAction;
|
|
struct nmSensitivityFitSettings;
|
|
|
|
class NM_SUB_WXS_EXPORT nmWxSensitivityHistogramOptions : public iDlgBase
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
nmWxSensitivityHistogramOptions(const QSharedPointer<nmDataSensitive::BatchResult>& results,
|
|
int bins, QWidget* parent);
|
|
signals:
|
|
void settingsChanged(int bins, int variable);
|
|
private slots:
|
|
void onApply();
|
|
void onAccept();
|
|
private:
|
|
QSpinBox* m_bins;
|
|
QComboBox* m_variable;
|
|
};
|
|
|
|
class NM_SUB_WXS_EXPORT nmWxSensitivityScatter : public iDlgBase
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
nmWxSensitivityScatter(const QSharedPointer<nmDataSensitive::BatchResult>& results,
|
|
double baseError, QWidget* parent = nullptr);
|
|
signals:
|
|
void filterChanged();
|
|
protected:
|
|
bool eventFilter(QObject* object, QEvent* event) override;
|
|
private slots:
|
|
void updateParameter();
|
|
void updateThreshold();
|
|
void resetThreshold();
|
|
void adjustContextMenu(QMenu* menu);
|
|
void updateLegend();
|
|
private:
|
|
QSharedPointer<nmDataSensitive::BatchResult> m_results;
|
|
double m_baseError;
|
|
double m_defaultThreshold;
|
|
bool m_draggingThreshold;
|
|
QComboBox* m_parameter;
|
|
QComboBox* m_ordinate;
|
|
double m_threshold;
|
|
QLabel* m_legend;
|
|
QAction* m_resultsInPlot;
|
|
iGuiPlot* m_plot;
|
|
QVector<QPointF> m_points;
|
|
QVector<int> m_runRows;
|
|
};
|
|
|
|
// 复用原结果表格,每个 Show 窗口只控制所属图中的采样曲线。
|
|
class NM_SUB_WXS_EXPORT nmWxSensitivityShow : public iDlgBase
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
nmWxSensitivityShow(const QSharedPointer<nmDataSensitive::BatchResult>& results,
|
|
iGuiPlot* plot, QWidget* parent);
|
|
void done(int result) override;
|
|
|
|
private slots:
|
|
void onApply();
|
|
void onAccept();
|
|
void updateHighlight();
|
|
|
|
private:
|
|
SensitivityResultsModel* m_model;
|
|
QTableView* m_table;
|
|
QPushButton* m_highlight;
|
|
};
|
|
|
|
class NM_SUB_WXS_EXPORT nmWxSensitive : public iDlgBase
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit nmWxSensitive(QWidget *parent = 0, nmDataAnalyzeManager* manager = nullptr);
|
|
~nmWxSensitive();
|
|
// 主窗口接管普通求解进度框后,才隐藏参数窗口并启动批量任务。
|
|
void startSensitivityCalculation();
|
|
|
|
signals:
|
|
void sigSensitivityTaskReady(nmWxSensitive* dialog, nmCalculationDllPebiSolverTask* task);
|
|
void sigSensitivityCancelRequested();
|
|
|
|
public slots:
|
|
void reject() override;
|
|
|
|
protected:
|
|
void closeEvent(QCloseEvent* event) override;
|
|
|
|
private slots:
|
|
void onGenerateClicked();
|
|
void onCancelClicked();
|
|
void onCalculationTypeChanged(int index);
|
|
void onImproveSettingsClicked();
|
|
void onTreeItemClicked(QTreeWidgetItem *item, int column);
|
|
void onVariableParamChanged();
|
|
void onSamplingEditingFinished();
|
|
void onTableCellClicked(int row, int column);
|
|
void onTreeItemChanged(QTreeWidgetItem *item, int column);
|
|
void onPreviewClicked();
|
|
void onPreviewScrollAction(int action);
|
|
void onSensitivityFinished();
|
|
void onResultsChanged();
|
|
void onModelResultChanged();
|
|
|
|
private:
|
|
void setupUI();
|
|
void createConnections();
|
|
void populateTreeWidget();
|
|
void createDetailPages();
|
|
QWidget *createVariablePage(const QString &varName);
|
|
void updateValuesForPage(int idx);
|
|
void updateDistributionPage(int idx);
|
|
bool readDistributionPage(int idx, nmDataSensitive::VariableSampling& variable) const;
|
|
QIcon createTriangleIcon(); // 创建三角箭头图标
|
|
|
|
void loadDataToUI(bool refreshRangesOnly = false); // 从数据加载到界面
|
|
bool saveDataFromUI(); // 校验并从界面保存到数据
|
|
void refreshModelValues();
|
|
void updateModelCount();
|
|
void setCalculationRunning(bool running);
|
|
int findVariableIndex(const QString& varName); // 查找变量索引
|
|
|
|
// UI 控件
|
|
QComboBox *calculationTypeCombo;
|
|
QPushButton *m_improveSettingsButton;
|
|
QSharedPointer<nmSensitivityFitSettings> m_improveSettings;
|
|
QTreeWidget *variablesTree;
|
|
QStackedWidget *detailStack;
|
|
QLabel *modelCountLabel;
|
|
QSpinBox *m_monteCarloCount;
|
|
QPushButton *generateButton;
|
|
QPushButton *cancelButton;
|
|
QPushButton *previewButton;
|
|
|
|
// 各个变量页面的控件列表
|
|
QList<QComboBox*> m_modeCombos;
|
|
QList<QCheckBox*> m_logChecks;
|
|
QList<QSpinBox*> m_numSpins;
|
|
QList<QLineEdit*> m_modelSpins;
|
|
QList<QLineEdit*> m_minSpins;
|
|
QList<QLineEdit*> m_maxSpins;
|
|
QList<QTableWidget*> m_valueTables;
|
|
QList<QLabel*> m_unitLabels;
|
|
QList<QLabel*> m_numLabels, m_minLabels, m_maxLabels;
|
|
QList<QComboBox*> m_distributionCombos;
|
|
QList<QWidget*> m_distributionPanels;
|
|
QList<SensitivityDistributionPlot*> m_distributionPlots;
|
|
|
|
// 跟踪当前选中的值索引
|
|
int m_selectedValueIndex;
|
|
bool m_loading;
|
|
nmDataAnalyzeManager* m_pDataManager;
|
|
SensitivityRunsView* m_previewView;
|
|
nmCalculationDllPebiSolverTask* m_pSensitivityTask;
|
|
bool m_calculationRunning;
|
|
|
|
// 敏感分析数据
|
|
nmDataSensitive m_sensitiveData;
|
|
};
|
|
|
|
#endif // NMWXSENSITIVE_H
|