File: rfx_colorbox.h

package info (click to toggle)
meshlab 1.3.2+dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 21,096 kB
  • ctags: 33,630
  • sloc: cpp: 224,813; ansic: 8,170; xml: 119; makefile: 80
file content (134 lines) | stat: -rw-r--r-- 4,448 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/****************************************************************************
* MeshLab                                                           o o     *
* A versatile mesh processing toolbox                             o     o   *
*                                                                _   O  _   *
* Copyright(C) 2005-2008                                           \/)\/    *
* Visual Computing Lab                                            /\/|      *
* ISTI - Italian National Research Council                           |      *
*                                                                    \      *
* All rights reserved.                                                      *
*                                                                           *
* This program is free software; you can redistribute it and/or modify      *
* it under the terms of the GNU General Public License as published by      *
* the Free Software Foundation; either version 2 of the License, or         *
* (at your option) any later version.                                       *
*                                                                           *
* This program is distributed in the hope that it will be useful,           *
* but WITHOUT ANY WARRANTY; without even the implied warranty of            *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
* for more details.                                                         *
*                                                                           *
****************************************************************************/

#ifndef RFX_COLORBOX_H_
#define RFX_COLORBOX_H_

#include <cassert>
#include <climits>
#include <cfloat>
#include <QSignalMapper>
#include <QWidget>
#include <QFrame>
#include <QPushButton>
#include <QColor>
#include <QColorDialog>
#include <QGridLayout>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QSlider>
#include <vcg/space/color4.h>
#include "rfx_dialog.h"

class RfxColorBox : public QWidget
{
	Q_OBJECT

public:
     explicit RfxColorBox(const int&, const int&, const QColor&, QWidget *parent = 0);
	virtual ~RfxColorBox();

	/*
		Returns the current color as an array of float value between 0 and 1.
		@return the current color as float array.
	*/
	inline vcg::Color4f getColorf(){
		vcg::Color4f c(_redS->value() / 255.0f,_greenS->value() / 255.0f,_blueS->value() / 255.0f,_alphaS->value() / 255.0f);
		return c;
	}

public slots:
	void setR(int);
	void setR();
	void setG(int);
	void setG();
	void setB(int);
	void setB();
	void setA(int);
	void setA();

private slots:
     void setBoxColorFromDialog();
     
signals:
     void colorChanged();
     /*
	 Unused at the moment...maybe for further usages.

	 void redChanged();
     void greenChanged();
     void blueChanged();
     void alphaChanged();*/

private:
	QFrame* _scacchiera;
	/*Colored box without alpha channel*/
	QFrame* _rgbBox;
	/*Colored box with alpha channel*/
	QPushButton* _rgbaBox;

	/* The sliders */
	QSlider* _redS;
	QSlider* _greenS;
	QSlider* _blueS;
	QSlider* _alphaS;

	/* The text boxes */
	QLineEdit* _redT;
	QLineEdit* _greenT;
	QLineEdit* _blueT;
	QLineEdit* _alphaT;

	 enum Channels{
		 CHANNEL_R, CHANNEL_G, CHANNEL_B, CHANNEL_A, CHANNEL_ALL
	 };

     /*Returns a string rapresenting a new stylesheet(without alpha channel)*/
	 QString getNewRGBStylesheet(const QString&, RfxColorBox::Channels, int*[]);
     /*Returns a string rapresenting a new stylesheet(with alpha channel)*/
     QString getNewRGBAStylesheet(const QString&, RfxColorBox::Channels, int*[]);

     /* default basic style for the rgb box */
     static const QString _BASE_RGB_BOX_STYLE;

     /* default basic style for the rgba box */
     static const QString _BASE_RGBA_BOX_STYLE;

	 /* Initialize a slider.
	 @param slider the slider to initialize
	 @param value the initial value
	 */
	 void initSlider(QSlider*, int);

	 /* Initialize a text box.
	 @param box the text box to initialize
	 */
	 void initTextBox(QLineEdit*);

	 /* Connects all the slider to the color box. */
	 void connectSliders();

	 /* Disconnects all the slider to the color box. */
	 void disconnectSliders();
};
#endif /* RFX_COLORBOX_H_*/