Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYColorInterfaceWidget.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
23 // Added by qt3to4:
24 #include <QGridLayout>
25 #include <QLabel>
26 #include <QGroupBox>
27 
28 #include "TYColorInterfaceWidget.h"
29 
32 #include "TYToolButton.h"
33 
34 #define TR(id) OLocalizator::getString("TYColorInterfaceWidget", (id))
35 
37  : QWidget(_pParent), _pElement(pElement)
38 {
39  resize(300, 40);
40  setWindowTitle(TR("id_caption"));
41 
42  _labelColor = new QLabel("labelColor");
43  _labelColor->setText(TR("id_color_label"));
44 
45  _pushButtonColor = new TYToolButton(NULL, "pushButtonColor");
46  _pushButtonColor->setFixedSize(30, 30);
47 
48  QObject::connect(_pushButtonColor, &TYToolButton::colorAccepted, this,
50 
51  _groupBoxLayout = new QGridLayout();
52  _groupBoxLayout->setAlignment(Qt::AlignLeft);
53  _groupBoxLayout->addWidget(_labelColor, 0, 0);
54  _groupBoxLayout->addWidget(_pushButtonColor, 0, 1);
55 
56  _groupBox = new QGroupBox(this);
57  _groupBox->setTitle(TR(""));
58  _groupBox->setLayout(_groupBoxLayout);
59  //_groupBox->layout()->setSpacing( 6 );
60  //_groupBox->layout()->setContentsMargins(11, 11, 11, 11);
61 
62  QGridLayout* colorInterfaceLayout = new QGridLayout();
63  colorInterfaceLayout->addWidget(_groupBox, 0, 0);
64  colorInterfaceLayout->setContentsMargins(0, 0, 0, 0);
65  setLayout(colorInterfaceLayout);
66  updateContent();
67 }
68 
70 
72 {
73  OColor color = getElement()->getColor();
74  _pushButtonColor->setColor(QColor(color.r * 255, color.g * 255, color.b * 255));
75 }
76 
78 {
79  int color[3];
80  _pushButtonColor->getColor().getRgb(&color[0], &color[1], &color[2]);
81  getElement()->setColor(OColor(color[0] / 255.0f, color[1] / 255.0f, color[2] / 255.0f));
82 
83  // emit modified();
84 }
85 
87 
89 {
90  emit colorModified();
91 }
#define TR(id)
outil IHM pour l'objet ColorInterface (fichier header)
outil IHM pour la gestion de la couleur des ToolButton (fichier header)
Definition: color.h:31
float b
Definition: color.h:33
float r
Definition: color.h:33
float g
Definition: color.h:33
TYColorInterface * getElement()
TYColorInterfaceWidget(TYColorInterface *pElement, QWidget *_pParent=0)
OColor getColor() const
virtual void setColor(const OColor &color)
Permet de gerer la couleur des ToolButtons.
Definition: TYToolButton.h:37
void colorAccepted(QColor c)
QColor getColor()
Definition: TYToolButton.h:53
void setColor(QColor color)
Definition: TYToolButton.h:60