1 /** -*- mode: c++ ; c-basic-offset: 2 -*-
2  * @file   PointParameter.h
3  * @author Sebastien Fourey
4  * @date   June 2018
5  *
6  * @brief  Declaration of the class PointParameter
7  *
8  * This file is part of the ZArt software's source code.
9  *
10  * Copyright Sebastien Fourey / GREYC Ensicaen (2010-...)
11  *
12  *                    https://foureys.users.greyc.fr/
13  *
14  * This software is a computer program whose purpose is to demonstrate
15  * the possibilities of the GMIC image processing language by offering the
16  * choice of several manipulations on a video stream acquired from a webcam. In
17  * other words, ZArt is a GUI for G'MIC real-time manipulations on the output
18  * of a webcam.
19  *
20  * This software is governed by the CeCILL  license under French law and
21  * abiding by the rules of distribution of free software.  You can  use,
22  * modify and/ or redistribute the software under the terms of the CeCILL
23  * license as circulated by CEA, CNRS and INRIA at the following URL
24  * "http://www.cecill.info". See also the directory "Licence" which comes
25  * with this source code for the full text of the CeCILL license.
26  *
27  * As a counterpart to the access to the source code and  rights to copy,
28  * modify and redistribute granted by the license, users are provided only
29  * with a limited warranty  and the software's author,  the holder of the
30  * economic rights,  and the successive licensors  have only  limited
31  * liability.
32  *
33  * In this respect, the user's attention is drawn to the risks associated
34  * with loading,  using,  modifying and/or developing or reproducing the
35  * software by the user in light of its specific status of free software,
36  * that may mean  that it is complicated to manipulate,  and  that  also
37  * therefore means  that it is reserved for developers  and  experienced
38  * professionals having in-depth computer knowledge. Users are therefore
39  * encouraged to load and test the software's suitability as regards their
40  * requirements in conditions enabling the security of their systems and/or
41  * data to be ensured and,  more generally, to use and operate it in the
42  * same conditions as regards security.
43  *
44  * The fact that you are presently reading this means that you have had
45  * knowledge of the CeCILL license and that you accept its terms.
46  */
47 #ifndef ZART_POINTPARAMETER_H
48 #define ZART_POINTPARAMETER_H
49 
50 #include <QColor>
51 #include <QColorDialog>
52 #include <QDomNode>
53 #include <QDoubleSpinBox>
54 #include <QPixmap>
55 #include <QPointF>
56 #include <QString>
57 #include <QToolButton>
58 #include "AbstractParameter.h"
59 class QSpinBox;
60 class QSlider;
61 class QLabel;
62 class QPushButton;
63 class KeypointList;
64 
65 class PointParameter : public AbstractParameter {
66   Q_OBJECT
67 public:
68   PointParameter(QDomNode node, QObject * parent = 0);
69   ~PointParameter();
70   bool isVisible() const override;
71   void addTo(QWidget *, int row) override;
72   void addToKeypointList(KeypointList &) const override;
73   void extractPositionFromKeypointList(KeypointList &) override;
74   QString textValue() const override;
75   void setValue(const QString & value) override;
76   void reset() override;
77   void setRemoved(bool on);
78   void saveValueInDOM() override;
79 
80   static void resetDefaultColorIndex();
81 
82 public slots:
83   void enableNotifications(bool);
84 
85 private slots:
86   void onSpinBoxChanged();
87   void onRemoveButtonToggled(bool);
88 
89 private:
90   QDomNode _node;
91   bool initFromNode(QDomNode node);
92   static int randomChannel();
93   void connectSpinboxes();
94   void disconnectSpinboxes();
95   void pickColorFromDefaultColormap();
96   QString _name;
97   QPointF _defaultPosition;
98   bool _defaultRemovedStatus;
99   QPointF _position;
100   QColor _color;
101   bool _removable;
102   int _radius;
103   bool _visible;
104   bool _keepOpacityWhenSelected;
105 
106   QLabel * _label;
107   QLabel * _colorLabel;
108   QLabel * _labelX;
109   QLabel * _labelY;
110   QDoubleSpinBox * _spinBoxX;
111   QDoubleSpinBox * _spinBoxY;
112   QToolButton * _removeButton;
113   bool _connected;
114   bool _removed;
115   QWidget * _rowCell;
116   bool _notificationEnabled;
117   static int _defaultColorNextIndex;
118   static unsigned long _randomSeed;
119 };
120 
121 #endif // ZART_POINTPARAMETER_H
122