-
Notifications
You must be signed in to change notification settings - Fork 0
/
Material.cxx
108 lines (91 loc) · 3.35 KB
/
Material.cxx
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
#include "Material.h"
#include <QPushButton>
#include <QLayout>
#include <QSignalMapper>
#include <Graphic3d_NameOfMaterial.hxx>
DialogMaterial::DialogMaterial(QWidget * parent,
bool modal, Qt::WindowFlags f )
: QDialog(parent, f)
{
setModal( modal );
QPushButton* b;
QVBoxLayout* vbl = new QVBoxLayout( this );
vbl->setMargin( 8 );
QSignalMapper *sm = new QSignalMapper( this );
connect( sm, SIGNAL( mapped( int ) ), this, SIGNAL( sendMaterialChanged( int ) ) );
b = new QPushButton( QObject::tr("BTN_PLASTER"), this );
sm->setMapping( b, ( int )Graphic3d_NOM_PLASTER );
connect( b, SIGNAL( clicked() ), sm, SLOT( map() ) );
b->setCheckable( true );
connect( b, SIGNAL( toggled( bool ) ), this, SLOT( updateButtons( bool ) ) );
myButtons.append( b );
vbl->addWidget( b );
b = new QPushButton( QObject::tr( "BTN_BRASS" ), this );
sm->setMapping( b, ( int )Graphic3d_NOM_BRASS );
connect( b, SIGNAL( clicked() ), sm, SLOT( map() ) );
b->setCheckable( true );
connect( b, SIGNAL( toggled( bool ) ), this, SLOT( updateButtons( bool ) ) );
myButtons.append( b );
vbl->addWidget( b );
b = new QPushButton( QObject::tr( "BTN_BRONZE" ), this );
sm->setMapping( b, ( int )Graphic3d_NOM_BRONZE );
connect( b, SIGNAL( clicked() ), sm, SLOT( map() ) );
b->setCheckable( true );
connect( b, SIGNAL( toggled( bool ) ), this, SLOT( updateButtons( bool ) ) );
myButtons.append( b );
vbl->addWidget( b );
b = new QPushButton( QObject::tr( "BTN_COPPER" ), this );
sm->setMapping( b, ( int )Graphic3d_NOM_COPPER );
connect( b, SIGNAL( clicked() ), sm, SLOT( map() ) );
b->setCheckable( true );
connect( b, SIGNAL( toggled( bool ) ), this, SLOT( updateButtons( bool ) ) );
myButtons.append( b );
vbl->addWidget( b );
b = new QPushButton( QObject::tr( "BTN_GOLD" ), this );
sm->setMapping( b, ( int )Graphic3d_NOM_GOLD );
connect( b, SIGNAL( clicked() ), sm, SLOT( map() ) );
b->setCheckable( true );
connect( b, SIGNAL( toggled( bool ) ), this, SLOT( updateButtons( bool ) ) );
myButtons.append( b );
vbl->addWidget( b );
b = new QPushButton( QObject::tr( "BTN_PEWTER" ), this );
sm->setMapping( b, ( int )Graphic3d_NOM_PEWTER );
connect( b, SIGNAL( clicked() ), sm, SLOT( map() ) );
b->setCheckable( true );
connect( b, SIGNAL( toggled( bool ) ), this, SLOT( updateButtons( bool ) ) );
myButtons.append( b );
vbl->addWidget( b );
b = new QPushButton( QObject::tr( "BTN_PLASTIC" ), this );
sm->setMapping( b, ( int )Graphic3d_NOM_PLASTIC );
connect( b, SIGNAL( clicked() ), sm, SLOT( map() ) );
b->setCheckable( true );
connect( b, SIGNAL( toggled( bool ) ), this, SLOT( updateButtons( bool ) ) );
myButtons.append( b );
vbl->addWidget( b );
b = new QPushButton( QObject::tr( "BTN_SILVER" ), this );
sm->setMapping( b, ( int )Graphic3d_NOM_SILVER );
connect( b, SIGNAL( clicked() ), sm, SLOT( map() ) );
b->setCheckable( true );
connect( b, SIGNAL( toggled( bool ) ), this, SLOT( updateButtons( bool ) ) );
myButtons.append( b );
vbl->addWidget( b );
}
DialogMaterial::~DialogMaterial()
{
}
void DialogMaterial::updateButtons( bool isOn )
{
if( !isOn )
return;
QPushButton*sentBy = ( QPushButton* )sender();
for ( int i = 0; i < myButtons.size(); i++ )
{
QPushButton* b = myButtons.at( i );
if( b != sentBy ) {
b->setEnabled( true );
b->setChecked( false );
} else {
b->setEnabled( false );
}
}
}