CMS 3D CMS Logo

Ig3DEnumControl Class Reference

#include <Iguana/GLBrowsers/interface/Ig3DEnumControl.h>

Inheritance diagram for Ig3DEnumControl:

Ig3DFieldControl IgControlBase IgControlItem

List of all members.

Public Slots

void setValue (int newval)

Public Member Functions

void addValidValue (int value, const QString &name)
SoSFEnum * field (void) const
int fieldValue (void) const
 Ig3DEnumControl (IgControlCategory *pane, QString label)
void setField (SoSFEnum *field)
int value (void) const
QWidget * widget () const

Protected Member Functions

virtual void applyValue (void)
virtual void updateValue (void)

Private Slots

virtual void valueChanged (int)

Private Member Functions

int findIndex (int value)

Private Attributes

std::vector< intm_enums
QComboBox * m_value


Detailed Description

Definition at line 21 of file Ig3DEnumControl.h.


Constructor & Destructor Documentation

Ig3DEnumControl::Ig3DEnumControl ( IgControlCategory pane,
QString  label 
)

Definition at line 21 of file Ig3DEnumControl.cc.

References IgControlBase::addGridWidget(), ASSERT, IgControlCategory::bodyArea(), IgControlCategory::bodyLayout(), HLT_VtxMuL3::connect, IgControlItem::editable(), IgControlBase::gridRows(), m_value, IgControlBase::makeIndentedLabel(), IgControlItem::makeSpacedBox(), row, and valueChanged().

00022     : Ig3DFieldControl (pane)
00023 {
00024     ASSERT (pane);
00025     ASSERT (pane->bodyArea ());
00026     ASSERT (pane->bodyLayout ());
00027 
00028     QWidget     *area = pane->bodyArea ();
00029     int         row = gridRows ();
00030 
00031     ASSERT (row >= 0);
00032 
00033     // Add a new row to the grid, label on the left and the value on the right
00034     QWidget     *vlab = makeIndentedLabel (label, area);
00035     addGridWidget (vlab, row, 0);
00036 
00037     m_value = new QComboBox (area);
00038     m_value->setEditable(false);
00039     addGridWidget (makeSpacedBox (area, m_value), row, 1);
00040 
00041     // Always reflect the state of the real value control and vice versa.
00042     connect (m_value,            SIGNAL (activated    (int)), 
00043              this,               SLOT   (valueChanged (int)));
00044     connect (this,               SIGNAL (editable   (bool)), 
00045              m_value,            SLOT   (setEnabled (bool)));
00046     connect (this,               SIGNAL (editable   (bool)), 
00047              vlab,               SLOT   (setEnabled (bool)));
00048 }


Member Function Documentation

void Ig3DEnumControl::addValidValue ( int  value,
const QString &  name 
)

Definition at line 116 of file Ig3DEnumControl.cc.

References ASSERT, findIndex(), index, m_enums, and m_value.

00117 {
00118     int index = findIndex (value);
00119     ASSERT (index == -1);
00120     
00121     m_value->insertItem (name);
00122     m_enums.push_back (value);
00123 }

void Ig3DEnumControl::applyValue ( void   )  [protected, virtual]

Implements IgControlBase.

Definition at line 100 of file Ig3DEnumControl.cc.

References field(), and value().

00101 { field ()->setValue (value ()); }

SoSFEnum * Ig3DEnumControl::field ( void   )  const

Reimplemented from Ig3DFieldControl.

Definition at line 52 of file Ig3DEnumControl.cc.

References Ig3DFieldControl::field().

Referenced by applyValue(), and fieldValue().

00053 { return static_cast<SoSFEnum *> (Ig3DFieldControl::field ()); }

int Ig3DEnumControl::fieldValue ( void   )  const

Definition at line 77 of file Ig3DEnumControl.cc.

References ASSERT, and field().

Referenced by updateValue(), and valueChanged().

00078 { ASSERT (field ()); return field ()->getValue (); }

int Ig3DEnumControl::findIndex ( int  value  )  [private]

Definition at line 105 of file Ig3DEnumControl.cc.

References i, index, and m_enums.

Referenced by addValidValue(), and setValue().

00106 {
00107     int index = -1;
00108     for (unsigned int i = 0; i < m_enums.size (); i++)
00109     {
00110       if (m_enums[i] == value) { index = i ; break; }
00111     }    
00112     return index;
00113 }

void Ig3DEnumControl::setField ( SoSFEnum *  field  ) 

Definition at line 56 of file Ig3DEnumControl.cc.

References i, m_enums, m_value, name, parsecf::pyparsing::nums, and Ig3DFieldControl::setField().

Referenced by Ig3DFieldPlanesCategory::attach(), and Ig3DFieldPlanesCategory::detach().

00057 {
00058     Ig3DFieldControl::setField (field);
00059     if (field)
00060     {
00061       int nums = field->getNumEnums ();
00062       if (nums != m_enums.size ())
00063       {
00064         m_enums.clear ();
00065         m_value->clear ();
00066         SbName name;
00067         for(int i=0; i < nums; i++)
00068         {
00069           m_enums.push_back (field->getEnum(i, name));
00070           m_value->insertItem (name.getString ());
00071         }
00072       }
00073     }
00074 }

void Ig3DEnumControl::setValue ( int  newval  )  [slot]

Definition at line 86 of file Ig3DEnumControl.cc.

References ASSERT, findIndex(), index, m_value, and IgControlItem::setDirty().

Referenced by updateValue().

00087 {
00088     int index = findIndex (newval);
00089     ASSERT (index != -1);
00090     
00091     m_value->setCurrentItem (index);
00092     setDirty (true);
00093 }

void Ig3DEnumControl::updateValue ( void   )  [protected, virtual]

Implements IgControlBase.

Definition at line 96 of file Ig3DEnumControl.cc.

References fieldValue(), and setValue().

00097 { setValue (fieldValue ()); }

int Ig3DEnumControl::value ( void   )  const

Definition at line 82 of file Ig3DEnumControl.cc.

References m_enums, and m_value.

Referenced by applyValue().

00083 { return m_enums[m_value->currentItem ()]; }

void Ig3DEnumControl::valueChanged ( int  index  )  [private, virtual, slot]

Definition at line 126 of file Ig3DEnumControl.cc.

References fieldValue(), m_enums, and IgControlItem::setDirty().

Referenced by Ig3DEnumControl().

00127 {
00128     if (fieldValue () != m_enums[index])
00129       setDirty (true);
00130 }

QWidget * Ig3DEnumControl::widget ( void   )  const

Definition at line 133 of file Ig3DEnumControl.cc.

References m_value.

Referenced by Ig3DFieldPlanesCategory::Ig3DFieldPlanesCategory().

00134 { return m_value; }


Member Data Documentation

std::vector<int> Ig3DEnumControl::m_enums [private]

Definition at line 51 of file Ig3DEnumControl.h.

Referenced by addValidValue(), findIndex(), setField(), value(), and valueChanged().

QComboBox* Ig3DEnumControl::m_value [private]

Definition at line 50 of file Ig3DEnumControl.h.

Referenced by addValidValue(), Ig3DEnumControl(), setField(), setValue(), value(), and widget().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:24:57 2009 for CMSSW by  doxygen 1.5.4