CMS 3D CMS Logo

Ig3DRotationFControl.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "Iguana/GLBrowsers/interface/Ig3DRotationFControl.h"
00004 #include "Iguana/GLBrowsers/interface/Ig3DUnitVec3fControl.h"
00005 #include "Iguana/GLBrowsers/interface/Ig3DRotationControl.h"
00006 #include "Iguana/GLBrowsers/interface/Ig3DFloatControl.h"
00007 #include "Iguana/GLBrowsers/interface/IgQtRangeControl.h"
00008 #include <classlib/utils/DebugAids.h>
00009 
00010 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00011 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00012 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00013 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00014 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00015 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00016 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00017 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00018 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00019 
00020 Ig3DRotationFControl::Ig3DRotationFControl (IgControlCategory *pane,
00021                                             QString           label)
00022     : Ig3DFieldControl (pane)
00023 {
00024     ASSERT (pane);
00025     ASSERT (pane->bodyArea ());
00026     ASSERT (pane->bodyLayout ());
00027 
00028     QWidget *area = pane->bodyArea ();
00029 
00030     // Add a new row to the grid: just the label for this category
00031     QWidget     *vlab = makeIndentedLabel (label, area);
00032     addGridWidget (vlab, gridRows (), 0);
00033 
00034     // Now add subitems for direction and distance
00035     pane->pushIndent ();
00036     m_axis = new Ig3DUnitVec3fControl (pane, "Axis");
00037     
00038     m_angle = new Ig3DFloatControl (pane, "Angle",
00039                                     IgQtRangeControl::StepperPart
00040                                     | IgQtRangeControl::ValuePart
00041                                     | IgQtRangeControl::SliderPart);    
00042     m_angle->control ()->setSmallStep (1); 
00043     m_angle->control ()->setLongStep (5); 
00044     m_angle->control ()->setRange (-180.,180.);
00045     
00046     pane->popIndent ();
00047 
00048     // Always reflect the state of the real value controls and vice versa.
00049     connect (m_axis,   SIGNAL(dirty()), this, SLOT(setDirty()));
00050     connect (m_axis,   SIGNAL(settingsChanged (void)),
00051              this,     SLOT  (emitSettingsChanged (void)));
00052     connect (m_angle,  SIGNAL(dirty()), this, SLOT(setDirty()));
00053     connect (m_angle,  SIGNAL(settingsChanged (void)),
00054              this,     SLOT  (emitSettingsChanged (void)));
00055     connect (this, SIGNAL(clean()), m_axis, SLOT(setClean()));
00056     connect (this, SIGNAL(clean()), m_angle,  SLOT(setClean()));
00057     connect (this, SIGNAL(editable(bool)),m_axis,SLOT(setEditable(bool)));
00058     connect (this, SIGNAL(editable(bool)),m_angle, SLOT(setEditable(bool)));
00059     connect (this, SIGNAL(editable(bool)),vlab,       SLOT(setEnabled(bool)));
00060 }
00061 
00063 SoSFRotation *
00064 Ig3DRotationFControl::field (void) const
00065 { return static_cast<SoSFRotation *> (Ig3DFieldControl::field ()); }
00066 
00067 void
00068 Ig3DRotationFControl::setField (SoSFRotation *field)
00069 { Ig3DFieldControl::setField (field); }
00070 
00071 SbRotation
00072 Ig3DRotationFControl::fieldValue (void) const
00073 { ASSERT (field ()); return field ()->getValue (); }
00074 
00076 SbRotation
00077 Ig3DRotationFControl::value (void) const
00078 { return SbRotation (axis (), angle ()); }
00079 
00080 SbVec3f
00081 Ig3DRotationFControl::axis (void) const
00082 { return m_axis->value (); }
00083 
00084 float
00085 Ig3DRotationFControl::angle (void) const
00086 { return Ig3DRotationControl::deg2rad(m_angle->value ()); }
00087 
00088 void
00089 Ig3DRotationFControl::setValue (const SbRotation &newval)
00090 {
00091     SbVec3f axis;
00092     float angle;
00093     newval.getValue (axis, angle);
00094     setValue (axis, Ig3DRotationControl::rad2deg(angle));
00095 }
00096 
00097 void
00098 Ig3DRotationFControl::setValue (const SbVec3f &axis, float angle)
00099 { setAxis (axis); setAngle (angle); }
00100 
00101 void
00102 Ig3DRotationFControl::setAxis (const SbVec3f &newval)
00103 { m_axis->setValue (newval); }
00104 
00105 void
00106 Ig3DRotationFControl::setAngle (float newval)
00107 { m_angle->setValue (newval); }
00108 
00109 void
00110 Ig3DRotationFControl::updateValue (void)
00111 { setValue (fieldValue ()); }
00112 
00113 void
00114 Ig3DRotationFControl::applyValue (void)
00115 { field ()->setValue (value ()); }
00116 
00118 Ig3DVectorControl*
00119 Ig3DRotationFControl::axisControl (void) const
00120 { return m_axis; }
00121 
00122 Ig3DFloatControl*
00123 Ig3DRotationFControl::angleControl  (void) const
00124 { return m_angle; }
00125 
00126 QString
00127 Ig3DRotationFControl::getSettingString (void) const
00128 {
00129 
00130   QString setting (m_axis->control ()->getSettingString ());
00131   IgQtRangeControlCommon::addSettingItem (m_angle->control ()->
00132                                           getSettingString (),
00133                                           setting);
00134   return setting;
00135 }
00136     
00137 void
00138 Ig3DRotationFControl::setSettingString (QString &setting)
00139 {
00140   m_axis->control ()->setSettingString (setting);
00141   m_angle->control ()->setSettingString (setting);
00142 }
00143 
00144 void
00145 Ig3DRotationFControl::emitSettingsChanged (void)
00146 { fieldSettingsChanged (); }

Generated on Tue Jun 9 17:38:36 2009 for CMSSW by  doxygen 1.5.4