Salome HOME
Copyright update 2022
[modules/paravis.git] / src / Plugins / MEDReader / plugin / ParaViewPlugin / VectBoolWidget.h
1 // Copyright (C) 2010-2022  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay
20
21 #ifndef __VECTBOOLWIDGET_H__
22 #define __VECTBOOLWIDGET_H__
23
24 #include <QFrame>
25 #include <QLabel>
26 #include <QMap>
27
28 class QSlider;
29 class QGroupBox;
30 class QHBoxLayout;
31 class QVBoxLayout;
32 class QGridLayout;
33 class QPushButton;
34 class VectBoolModel;
35 class VectBoolSpreadSheet;
36
37 class NbOfActiveTSDisplay : public QLabel
38 {
39 Q_OBJECT
40 public:
41   NbOfActiveTSDisplay(QWidget *parent=0);
42 public slots:
43   void display(int nbOfItemsOn, int totalNbOfItems);
44   void totalNbOfItemsChanged(int totalNbOfItems);
45 private:
46   int _nb_of_items_on;
47   int _total_nb_of_items;
48 };
49
50 class VectBoolItem : public QObject
51 {
52 Q_OBJECT
53 Q_PROPERTY(bool activated READ isActivated WRITE activated)
54 public:
55   VectBoolItem(QObject *parent, int pos, VectBoolModel *model);
56   bool isActivated() const;
57   void activated(bool val);
58 public slots:
59   void theModelHasChanged();
60 signals:
61   void changed();
62 private:
63   int _pos;
64   mutable bool _old_status;
65   VectBoolModel *_model;
66 };
67
68 class VectBoolWidget : public QFrame
69 {
70 public:
71   VectBoolWidget(QWidget *parent, int nbOfItems);
72   ~VectBoolWidget();
73   int getNumberOfBoolItems() const;
74   void setItems(const QStringList& dts, const QStringList& its, const QStringList& tts);
75   const QMap<QString, VectBoolItem *>& getItems() const { return _items; }
76 private:
77   static int GetMaxTickValueOfSlider(int val);
78 private:
79   QMap<QString, VectBoolItem *> _items;
80   QHBoxLayout *_horizontal_layout;
81   QFrame *_spreadsheet_container;
82   QGridLayout *_grid_layout;
83   QGroupBox *_group_box;
84   QVBoxLayout *_vertical_layout;
85   NbOfActiveTSDisplay *_nb_of_time_steps_on;
86   QSlider *_nb_of_rows_selecter;
87   QPushButton *_sel_unsel_all;
88   VectBoolSpreadSheet *_vbw;
89   VectBoolModel *_vbm;
90 };
91
92 #endif