File indexing completed on 2025-01-05 03:35:38
0001 /* 0002 File : AddSubtractDialog.h 0003 Project : LabPlot 0004 Description : Dialog for adding/subtracting a value from column values 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2018-2023 Alexander Semke <alexander.semke@web.de> 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #ifndef ADDSUBTRACTVALUEDIALOG_H 0011 #define ADDSUBTRACTVALUEDIALOG_H 0012 0013 #include "ui_addsubtractvaluewidget.h" 0014 #include <QDialog> 0015 0016 class Column; 0017 class Spreadsheet; 0018 class Matrix; 0019 class Project; 0020 class TextLabel; 0021 class XYCurve; 0022 0023 class QSpacerItem; 0024 class QPushButton; 0025 0026 class AddSubtractValueDialog : public QDialog { 0027 Q_OBJECT 0028 0029 public: 0030 enum Operation { Add, Subtract, Multiply, Divide, SubtractBaseline }; 0031 0032 explicit AddSubtractValueDialog(Spreadsheet*, const QVector<Column*>&, Operation, QWidget* parent = nullptr); 0033 explicit AddSubtractValueDialog(Matrix*, Operation, QWidget* parent = nullptr); 0034 ~AddSubtractValueDialog() override; 0035 0036 private: 0037 void init(); 0038 void processColumns(); 0039 void generateForColumns(); 0040 void generateForColumn(Column* col, int colIndex); 0041 void generateForMatrices(); 0042 void subtractBaseline(QVector<double>&); 0043 QString getMessage(const QString&); 0044 void updateSpacer(bool); 0045 0046 bool setIntValue(int& value, int columnIndex = 0) const; 0047 bool setBigIntValue(qint64& value, int columnIndex = 0) const; 0048 bool setDoubleValue(double& value, int columnIndex = 0) const; 0049 bool setDateTimeValue(qint64& value, int columnIndex = 0) const; 0050 0051 Ui::AddSubtractValueWidget ui; 0052 QSpacerItem* m_verticalSpacer{nullptr}; 0053 Spreadsheet* m_spreadsheet{nullptr}; 0054 QVector<Column*> m_columns; 0055 Matrix* m_matrix{nullptr}; 0056 QPushButton* m_okButton{nullptr}; 0057 Operation m_operation; 0058 bool m_numeric{false}; 0059 0060 // preview related members 0061 bool m_previewDirty{true}; 0062 bool m_xColumnBaselineDirty{true}; 0063 Project* m_project{nullptr}; 0064 XYCurve* m_curveOrigin{nullptr}; 0065 XYCurve* m_curveBaseline{nullptr}; 0066 XYCurve* m_curveResult{nullptr}; 0067 Column* m_xColumnBaseline{nullptr}; 0068 Column* m_yColumnBaseline{nullptr}; 0069 Column* m_yColumnResult{nullptr}; 0070 TextLabel* m_previewPlotTitle{nullptr}; 0071 double m_arplsRatio{0.0}; 0072 0073 private Q_SLOTS: 0074 void generate(); 0075 void typeChanged(int); 0076 void previewChanged(bool); 0077 void initPreview(); 0078 void invalidatePreview(); 0079 void updatePreview(); 0080 }; 0081 0082 #endif