File indexing completed on 2024-04-21 03:41:39

0001 /*
0002     SPDX-FileCopyrightText: 2011 Rebetez Etienne <etienne.rebetez@oberwallis.ch>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef PERIODICTABLESTATES_H
0008 #define PERIODICTABLESTATES_H
0009 
0010 #include <QParallelAnimationGroup>
0011 #include <QStateMachine>
0012 
0013 
0014 #include "elementitem.h"
0015 #include "numerationitem.h"
0016 #include "statemachine.h"
0017 
0018 /**
0019  * @class PeriodicTableStates
0020  * In this class all states of element items and numeration items are defined.
0021  * The position and animations of the items are set.
0022  *
0023  * @short Setting up the pse states
0024  * @author Etienne Rebetez
0025  *
0026  */
0027 
0028 class PeriodicTableStates
0029 {
0030 public:
0031     /**
0032      * Constructor need list of Items.
0033      * @param elementItemList List of the Element items in the table.
0034      * @param numerationItemList List of the Numeration items in the table.
0035      */
0036     PeriodicTableStates(const QList<ElementItem *> &elementItemList, const QList<NumerationItem *> &numerationItemList);
0037 
0038     virtual ~PeriodicTableStates();
0039 
0040     /**
0041      * Get the rectangle of the given periodic table.
0042      * @param tableIndex Index of the table @see pseTables.
0043      * @return Rectangle in floating point precision.
0044      */
0045     QRectF pseRect(int tableIndex) const;
0046 
0047     /**
0048      * Set the table index
0049      * @param tableIndex Index of the table @see pseTables..
0050      */
0051     void setTableState(int tableIndex);
0052 
0053 private:
0054     void setNumerationItemPositions(int tableIndex);
0055     void hideAllNumerationItems(int tableIndex);
0056     int maxNumerationItemXCoordinate(int tableIndex);
0057 
0058     void addElementAnimation(QGraphicsObject *object, int factor = 1);
0059 
0060     void setElementItemPositions(int tableIndex);
0061 
0062     QPoint hiddenPoint() const;
0063 
0064     QStateMachine m_states;
0065     QParallelAnimationGroup *m_group;
0066     StateSwitcher *m_stateSwitcher;
0067 
0068     QList<ElementItem *> m_elementItemList;
0069     QList<NumerationItem *> m_numerationItemList;
0070 
0071     int m_width;
0072     int m_height;
0073 
0074     QList<QState *> m_tableStatesList;
0075 };
0076 
0077 #endif // PERIODICTABLESTATES_H