~ubuntu-branches/ubuntu/oneiric/soqt/oneiric

« back to all changes in this revision

Viewing changes to build/msvc8/src/Inventor/Qt/engines/RadioGroup.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2009-03-01 11:41:00 UTC
  • mfrom: (1.1.4 upstream) (5.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090301114100-f4zz3n1oasa52fgk
Tags: 1.4.2~svn20090224-2
* Upload upstream SVN head version containing fixes to build with Coin 3
  (Closes: #515729, #515736, #515742).  Upstream indicated to me that
  SVN is stable enough to release.

* control: Update Standards-Version to 3.8.0; no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**************************************************************************\
2
 
 *
3
 
 *  This file is part of the Coin 3D visualization library.
4
 
 *  Copyright (C) 1998-2005 by Systems in Motion.  All rights reserved.
5
 
 *
6
 
 *  This library is free software; you can redistribute it and/or
7
 
 *  modify it under the terms of the GNU General Public License
8
 
 *  ("GPL") version 2 as published by the Free Software Foundation.
9
 
 *  See the file LICENSE.GPL at the root directory of this source
10
 
 *  distribution for additional information about the GNU GPL.
11
 
 *
12
 
 *  For using Coin with software that can not be combined with the GNU
13
 
 *  GPL, and for taking advantage of the additional benefits of our
14
 
 *  support services, please contact Systems in Motion about acquiring
15
 
 *  a Coin Professional Edition License.
16
 
 *
17
 
 *  See <URL:http://www.coin3d.org/> for more information.
18
 
 *
19
 
 *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
20
 
 *  <URL:http://www.sim.no/>.
21
 
 *
22
 
\**************************************************************************/
23
 
 
24
 
#include <Inventor/Qt/engines/SoGuiRadioGroup.h>
25
 
#include <assert.h>
26
 
 
27
 
SO_ENGINE_SOURCE(SoGuiRadioGroup);
28
 
 
29
 
void
30
 
SoGuiRadioGroup::initClass(void)
31
 
{
32
 
  SO_ENGINE_INIT_CLASS(SoGuiRadioGroup, SoEngine, "Engine");
33
 
}
34
 
 
35
 
SoGuiRadioGroup::SoGuiRadioGroup(void)
36
 
{
37
 
  this->index = -1;
38
 
 
39
 
  SO_ENGINE_CONSTRUCTOR(SoGuiRadioGroup);
40
 
 
41
 
  SO_ENGINE_ADD_INPUT(in0, (FALSE));
42
 
  SO_ENGINE_ADD_INPUT(in1, (FALSE));
43
 
  SO_ENGINE_ADD_INPUT(in2, (FALSE));
44
 
  SO_ENGINE_ADD_INPUT(in3, (FALSE));
45
 
  SO_ENGINE_ADD_INPUT(in4, (FALSE));
46
 
  SO_ENGINE_ADD_INPUT(in5, (FALSE));
47
 
  SO_ENGINE_ADD_INPUT(in6, (FALSE));
48
 
  SO_ENGINE_ADD_INPUT(in7, (FALSE));
49
 
 
50
 
  SO_ENGINE_ADD_OUTPUT(out0, SoSFBool);
51
 
  SO_ENGINE_ADD_OUTPUT(out1, SoSFBool);
52
 
  SO_ENGINE_ADD_OUTPUT(out2, SoSFBool);
53
 
  SO_ENGINE_ADD_OUTPUT(out3, SoSFBool);
54
 
  SO_ENGINE_ADD_OUTPUT(out4, SoSFBool);
55
 
  SO_ENGINE_ADD_OUTPUT(out5, SoSFBool);
56
 
  SO_ENGINE_ADD_OUTPUT(out6, SoSFBool);
57
 
  SO_ENGINE_ADD_OUTPUT(out7, SoSFBool);
58
 
}
59
 
 
60
 
SoGuiRadioGroup::~SoGuiRadioGroup(void)
61
 
{
62
 
}
63
 
 
64
 
void
65
 
SoGuiRadioGroup::inputChanged(SoField * which)
66
 
{
67
 
  SoSFBool * fields[] = {
68
 
    &(this->in0),
69
 
    &(this->in1),
70
 
    &(this->in2),
71
 
    &(this->in3),
72
 
    &(this->in4),
73
 
    &(this->in5),
74
 
    &(this->in6),
75
 
    &(this->in7),
76
 
    NULL
77
 
  };
78
 
  int i;
79
 
  for ( i = 0; which != fields[i] && fields[i] != NULL; i++ ) { }
80
 
  assert(fields[i] != NULL );
81
 
  if ( ((SoSFBool *)which)->getValue() != FALSE ) {
82
 
    this->index = i;
83
 
  } else {
84
 
    if ( this->index == i ) this->index = -1;
85
 
  }
86
 
}
87
 
 
88
 
void
89
 
SoGuiRadioGroup::evaluate(void)
90
 
{
91
 
  if ( this->index == -1 ) return; // avoid update
92
 
  SoSFBool * fields[] = {
93
 
    &(this->in0), &(this->in1), &(this->in2), &(this->in3),
94
 
    &(this->in4), &(this->in5), &(this->in6), &(this->in7),
95
 
    NULL
96
 
  };
97
 
  SoEngineOutput * outputs[] = {
98
 
    &(this->out0), &(this->out1), &(this->out2), &(this->out3),
99
 
    &(this->out4), &(this->out5), &(this->out6), &(this->out7),
100
 
    NULL
101
 
  };
102
 
  int i;
103
 
  for ( i = 0; i < 8; i++ ) {
104
 
    if ( i == this->index ) {
105
 
      SO_ENGINE_OUTPUT((*outputs[i]), SoSFBool, setValue(TRUE));
106
 
    } else {
107
 
      SO_ENGINE_OUTPUT((*outputs[i]), SoSFBool, setValue(FALSE));
108
 
    }
109
 
  }
110
 
}
111