00001 #ifndef IGUANA_GL_BROWSERS_IG_3DRANGE_MCONTROL_H
00002 # define IGUANA_GL_BROWSERS_IG_3DRANGE_MCONTROL_H
00003
00004
00005
00006 # include "Iguana/GLBrowsers/interface/Ig3DFieldControl.h"
00007 # include "Iguana/GLBrowsers/interface/IgControlCategory.h"
00008 # include <classlib/utils/DebugAids.h>
00009 # include <qlayout.h>
00010 # include <qlabel.h>
00011 # include <qwhatsthis.h>
00012 # include <qtooltip.h>
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 template <class C1, class C2, class C3>
00023 class IGUANA_GL_BROWSERS_API Ig3DRangeMControl : public Ig3DFieldControl
00024 {
00025 public:
00026 typedef Ig3DRangeMControl<C1, C2, C3> inherited;
00027
00028 Ig3DRangeMControl (IgControlCategory *pane, QString label,
00029 int parts = IgQtRangeMControl::ValuePart);
00030
00031
00032
00033
00034 C1 * field (void) const
00035 { return static_cast<C1 *> (Ig3DFieldControl::field ()); }
00036
00037 void setField (C1 *field)
00038 {
00039 Ig3DFieldControl::setField (field);
00040 if (field){
00041 m_value->resize (field->getNum ());
00042 m_value->setDirty (false);
00043 }
00044 }
00045
00046 virtual const C2* fieldValue (void) const
00047 { ASSERT (field ()); return field ()->getValues (0); }
00048
00049 C3 * control (void) const
00050 { return m_value; }
00051
00052 virtual const C2* value (void) const
00053 { return &(m_value->value ()[0]); }
00054
00055 virtual void setValue (unsigned int size, const C2* newval)
00056 { m_value->setValue (size, newval); setDirty (true); }
00057
00058 virtual void setValue (const std::vector<C2>& newval)
00059 { m_value->setValue (newval); setDirty (true); }
00060
00061 QString getSettingString (void) const
00062 { return control ()->getSettingString (); }
00063
00064 void setSettingString (QString &setting)
00065 { control ()->setSettingString (setting); }
00066
00067 protected:
00068 virtual void updateValue (void)
00069 { setValue (m_value->size (), fieldValue ()); }
00070
00071 virtual void applyValue (void)
00072 { field ()->setValues (0, m_value->size (), value ()); }
00073
00074 private:
00075 C3 *m_value;
00076 };
00077
00078 template <class C1, class C2, class C3>
00079 Ig3DRangeMControl<C1, C2, C3>::Ig3DRangeMControl (IgControlCategory *pane,
00080 QString label,
00081 int parts )
00082 : Ig3DFieldControl (pane)
00083 {
00084 ASSERT (pane);
00085 ASSERT (pane->bodyArea ());
00086 ASSERT (pane->bodyLayout ());
00087
00088 QWidget *area = pane->bodyArea ();
00089 int row = gridRows ();
00090
00091 ASSERT (row >= 0);
00092
00093
00094 QWidget *vlab = makeIndentedLabel (label, area);
00095 addGridWidget (vlab, row, 0);
00096 QString tips ("Set the \"");
00097 tips += label + "\" of the item";
00098 QToolTip::add (vlab, tips.latin1 ());
00099 QWhatsThis::add (vlab, tips.latin1 ());
00100
00101 m_value = new C3 (area, parts);
00102 addGridWidget (makeSpacedBox (area, m_value->widget ()), row, 1);
00103
00104
00105 connect (m_value, SIGNAL (dirty ()),
00106 this, SLOT (setDirty ()));
00107 connect (this, SIGNAL (editable (bool)),
00108 m_value->widget (), SLOT (setEnabled (bool)));
00109 connect (this, SIGNAL (editable (bool)),
00110 vlab, SLOT (setEnabled (bool)));
00111 connect (this, SIGNAL (clean ()),
00112 m_value, SLOT (setClean ()));
00113 connect (pane, SIGNAL (tracking (bool)),
00114 m_value, SLOT (resetChangedValue (bool)));
00115 connect (m_value, SIGNAL (settingsChanged (void)),
00116 this, SLOT (fieldSettingsChanged (void)));
00117 }
00118
00119
00120
00121 #endif // IGUANA_GL_BROWSERS_IG_3DRANGE_MCONTROL_H