File indexing completed on 2022-09-27 12:24:09

0001 /*
0002     SPDX-FileCopyrightText: 2004, 2005, 2006 Carsten Niehaus <cniehaus@kde.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef ELEMENTDATAVIEWER_H
0007 #define ELEMENTDATAVIEWER_H
0008 
0009 #include "kalziumdataobject.h"
0010 #include "kalziumutils.h"
0011 #include "ui_plotsetupwidget.h"
0012 #include <QDialog>
0013 
0014 class QTimer;
0015 class KActionCollection;
0016 
0017 using DoubleList = QList<double>;
0018 
0019 /**
0020  * @short the values of an axis
0021  * @author Carsten Niehaus
0022  */
0023 class AxisData
0024 {
0025 public:
0026     /**
0027      * This represents the possible datasets.
0028      */
0029     enum PAXISDATA { NUMBER = 0, MASS, EN, MELTINGPOINT, BOILINGPOINT, ATOMICRADIUS, COVALENTRADIUS };
0030 
0031     enum AXISTYPE { X = 0, Y };
0032 
0033     explicit AxisData(AxisData::AXISTYPE);
0034 
0035     /**
0036      * @return the value of the selected dataset of element @p element
0037      */
0038     double value(int element) const;
0039 
0040     /**
0041      * the dataList contains the values off all elements
0042      * but only of the currently selected data type. This
0043      * means that it eg contains all boiling points
0044      */
0045     DoubleList dataList;
0046 
0047     QString unit;
0048 
0049     int currentDataType;
0050 
0051     ChemicalDataObject::BlueObelisk kind;
0052 
0053     AXISTYPE type() const
0054     {
0055         return m_type;
0056     }
0057 
0058 private:
0059     AXISTYPE m_type;
0060 };
0061 
0062 /**
0063  * @short This widget shows the plot and the widget
0064  * where you can setup the plot
0065  * @author Carsten Niehaus
0066  */
0067 class ElementDataViewer : public QDialog
0068 {
0069     Q_OBJECT
0070 
0071 public:
0072     explicit ElementDataViewer(QWidget *parent = nullptr);
0073 
0074     ~ElementDataViewer() override;
0075 
0076     /**
0077      * the AxixData for the y-Axis
0078      */
0079     AxisData *m_yData;
0080 
0081     /**
0082      * the AxixData for the x-Axis
0083      */
0084     AxisData *m_xData;
0085 
0086 protected:
0087     void keyPressEvent(QKeyEvent *e) override;
0088 
0089 private:
0090     Ui::PlotSetupWidget ui;
0091 
0092     void getMinMax(double &min, double &max, AxisData *data);
0093 
0094     QStringList names;
0095     QStringList symbols;
0096     QStringList elecConfig; // Electronic configuration of elements
0097     QStringList block; // Indicates the periodic table block s,p,d,f...
0098     QTimer *m_timer;
0099 
0100     KActionCollection *m_actionCollection;
0101 
0102     void initData();
0103     void setupAxisData(AxisData *data);
0104 
0105     void setLimits();
0106 
0107 protected Q_SLOTS:
0108     /**
0109      * invoke the help of the correct chapter
0110      */
0111     virtual void slotHelp();
0112 
0113 private Q_SLOTS:
0114     void rangeChanged();
0115     void fullRange();
0116     void swapXYAxis();
0117 
0118 public Q_SLOTS:
0119     void slotZoomIn();
0120     void slotZoomOut();
0121 
0122     /**
0123      * draws the plot
0124      */
0125     void drawPlot();
0126 };
0127 
0128 #endif // ELEMENTDATAVIEWER_H