#include <Iguana/GLBrowsers/interface/Ig3DAxisRotationControl.h>
Public Member Functions | |
Ig3DAxisRotationControl (IgControlCategory *pane, QString label, Ig3DPlaneControl *planeControl) | |
Create a new axis rotation controller with three thumbwheels. | |
IgSoQtThumbWheel * | xWidget () const |
IgSoQtThumbWheel * | yWidget () const |
IgSoQtThumbWheel * | zWidget () const |
Protected Member Functions | |
virtual void | applyValue (void) |
virtual void | updateValue (void) |
Private Slots | |
void | alignToAxis () |
void | setXAxisDirty (float change) |
void | setYAxisDirty (float change) |
void | setZAxisDirty (float change) |
Private Member Functions | |
void | makeWheelControl (IgControlCategory *pane, QWidget *parent, int axis, bool horizontal) |
SbVec3f | rotateAboutAxis (float x, float y, float z, float angle) |
Rotates a 3D vector given by its components and the angle. | |
Private Attributes | |
IgQtAxisAlignment * | m_alignment |
float | m_oldAngle [3] |
Ig3DPlaneControl * | m_planeControl |
IgSoQtThumbWheel * | m_thumbWheels [3] |
Definition at line 25 of file Ig3DAxisRotationControl.h.
Ig3DAxisRotationControl::Ig3DAxisRotationControl | ( | IgControlCategory * | pane, | |
QString | label, | |||
Ig3DPlaneControl * | planeControl | |||
) |
Create a new axis rotation controller with three thumbwheels.
Definition at line 20 of file Ig3DAxisRotationControl.cc.
References reco::fitHelper::add(), IgControlBase::addGridWidget(), alignToAxis(), ASSERT, IgControlCategory::bodyArea(), IgControlCategory::bodyLayout(), HLT_VtxMuL3::connect, IgControlItem::dirty(), IgQtRangeControlCommon::getSettingItem(), IgControlBase::gridRows(), i, hlt_scaler_cfg::labels, m_alignment, IgControlBase::makeIndentedLabel(), IgControlItem::makeSpacedBox(), makeWheelControl(), IgControlCategory::popIndent(), IgControlCategory::pushIndent(), IgQtAxisAlignment::widget(), X_Axis, and Z_Axis.
00022 : IgControlBase (pane), m_planeControl(planeControl) 00023 { 00024 ASSERT (pane); 00025 ASSERT (pane->bodyArea ()); 00026 ASSERT (pane->bodyLayout ()); 00027 00028 std::vector<QString> labels; 00029 QString tmpLabels ("X:Y:Z"); 00030 00031 for(unsigned int i = 0; i < 3; i++) 00032 { 00033 labels.push_back (IgQtRangeControlCommon::getSettingItem (tmpLabels)); 00034 } 00035 00036 QWidget *area = pane->bodyArea (); 00037 00038 // Add label to the grid 00039 QWidget *vlab = makeIndentedLabel (label, area); 00040 addGridWidget (vlab, gridRows (), 0); 00041 00042 QString tips ("Set the \""); 00043 tips += label + "\" of the item"; 00044 QWhatsThis::add (vlab, tips.latin1 ()); 00045 00046 pane->pushIndent (); 00047 00048 // create three thumbWheel controls for rotating around the axes 00049 for (int axis = X_Axis; axis <= Z_Axis; axis++) 00050 { 00051 makeWheelControl(pane, vlab, axis, true);// und so weiter... 00052 } 00053 00054 // Add alignment button group if requested 00055 m_alignment = new IgQtAxisAlignment (area); 00056 addGridWidget (makeSpacedBox (area, m_alignment->widget ()), gridRows (), 1); 00057 00058 connect (m_alignment, SIGNAL (dirty ()), this, SLOT (alignToAxis ())); 00059 00060 pane->popIndent (); 00061 }
void Ig3DAxisRotationControl::alignToAxis | ( | ) | [private, slot] |
Definition at line 102 of file Ig3DAxisRotationControl.cc.
References m_alignment, m_planeControl, IgControlItem::setClean(), Ig3DPlaneControl::setDirection(), and IgQtAxisAlignment::value().
Referenced by Ig3DAxisRotationControl().
00103 { 00104 // gets the alignment vector on a signal event and sets the cutting plane 00105 // accordingly. After that, the alignment buttons have to be cleaned again 00106 // to be able to use them again. 00107 m_planeControl->setDirection (m_alignment->value ().getValue ()); 00108 m_alignment->setClean(); 00109 }
Implements IgControlBase.
Definition at line 203 of file Ig3DAxisRotationControl.cc.
00204 { 00205 // We don't have a field for this control, so this method does 00206 // nothing. 00207 }
void Ig3DAxisRotationControl::makeWheelControl | ( | IgControlCategory * | pane, | |
QWidget * | parent, | |||
int | axis, | |||
bool | horizontal | |||
) | [private] |
Definition at line 112 of file Ig3DAxisRotationControl.cc.
References IgControlBase::addGridWidget(), IgControlCategory::bodyArea(), HLT_VtxMuL3::connect, IgControlBase::gridRows(), IgSoQtThumbWheel::Horizontal, label, m_thumbWheels, IgControlBase::makeIndentedLabel(), IgControlItem::makeSpacedBox(), row, setXAxisDirty(), setYAxisDirty(), setZAxisDirty(), IgSoQtThumbWheel::Vertical, X_Axis, and Y_Axis.
Referenced by Ig3DAxisRotationControl().
00113 { 00114 // get index of the last row 00115 int row = gridRows (); 00116 00117 QWidget *area = pane->bodyArea (); 00118 00119 // determine the orientation based on the passed boolean 00120 IgSoQtThumbWheel::Orientation orientation; 00121 orientation = (horizontal ? IgSoQtThumbWheel::Horizontal : IgSoQtThumbWheel::Vertical); 00122 00123 // create the thumbwheel and its label 00124 QString label; 00125 switch (axis) 00126 { 00127 case X_Axis: 00128 label = "X Axis"; 00129 break; 00130 case Y_Axis: 00131 label = "Y Axis"; 00132 break; 00133 default: 00134 label = "Z Axis"; 00135 break; 00136 } 00137 m_thumbWheels[axis] = new IgSoQtThumbWheel (orientation, parent, label); 00138 00139 // create a label inside an area 00140 QWidget* vlab = makeIndentedLabel (label, area); 00141 00142 // add label and thumbwheel control to the gridded widget 00143 addGridWidget (vlab, row, 0); 00144 addGridWidget (makeSpacedBox (area, m_thumbWheels[axis]), row, 1); 00145 00146 // connect wheels 00147 switch (axis) 00148 { 00149 case X_Axis: 00150 connect (m_thumbWheels[axis], SIGNAL( wheelMoved (float) ), this, SLOT( setXAxisDirty (float) )); 00151 break; 00152 case Y_Axis: 00153 connect (m_thumbWheels[axis], SIGNAL( wheelMoved (float) ), this, SLOT( setYAxisDirty (float) )); 00154 break; 00155 default: 00156 connect (m_thumbWheels[axis], SIGNAL( wheelMoved (float) ), this, SLOT( setZAxisDirty (float) )); 00157 break; 00158 } 00159 }
SbVec3f Ig3DAxisRotationControl::rotateAboutAxis | ( | float | x, | |
float | y, | |||
float | z, | |||
float | angle | |||
) | [private] |
Rotates a 3D vector given by its components and the angle.
To rotate about the x-Axis pass the vector components as follows: rotateAboutAxis(y,z,x,angle) About y-Axis: rotateAboutAxis(z,x,y,angle) About z-Axis: rotateAboutAxis(x,y,z,angle)
Definition at line 185 of file Ig3DAxisRotationControl.cc.
References funct::cos(), and funct::sin().
Referenced by setXAxisDirty(), setYAxisDirty(), and setZAxisDirty().
00186 { 00187 float new_x = x*cos(angle) - y*sin(angle); 00188 float new_y = x*sin(angle) + y*cos(angle); 00189 return SbVec3f(new_x, new_y, z); 00190 }
void Ig3DAxisRotationControl::setXAxisDirty | ( | float | change | ) | [private, slot] |
Definition at line 64 of file Ig3DAxisRotationControl.cc.
References change(), Ig3DPlaneControl::direction(), m_oldAngle, m_planeControl, rotateAboutAxis(), and Ig3DPlaneControl::setDirection().
Referenced by makeWheelControl().
00065 { 00066 // calculate the difference between the old and the new angle 00067 // and remember the new angle for the next call 00068 float change = angle - m_oldAngle[0]; 00069 m_oldAngle[0] = angle; 00070 00071 // get the plane's normal direction and rotate it by 'change' 00072 // degrees (radians) around the X axis. Finally set the plane's 00073 // new calculated direction. 00074 SbVec3f old_dir (m_planeControl->direction ()); 00075 SbVec3f new_dir = rotateAboutAxis (old_dir[1], old_dir[2], old_dir[0], change); 00076 m_planeControl->setDirection (SbVec3f(new_dir[2], new_dir[0], new_dir[1])); 00077 }
void Ig3DAxisRotationControl::setYAxisDirty | ( | float | change | ) | [private, slot] |
Definition at line 80 of file Ig3DAxisRotationControl.cc.
References change(), Ig3DPlaneControl::direction(), m_oldAngle, m_planeControl, rotateAboutAxis(), and Ig3DPlaneControl::setDirection().
Referenced by makeWheelControl().
00081 { 00082 float change = angle - m_oldAngle[1]; 00083 m_oldAngle[1] = angle; 00084 00085 SbVec3f old_dir (m_planeControl->direction ()); 00086 SbVec3f new_dir = rotateAboutAxis (old_dir[2], old_dir[0], old_dir[1], change); 00087 m_planeControl->setDirection (SbVec3f(new_dir[1], new_dir[2], new_dir[0])); 00088 }
void Ig3DAxisRotationControl::setZAxisDirty | ( | float | change | ) | [private, slot] |
Definition at line 91 of file Ig3DAxisRotationControl.cc.
References change(), Ig3DPlaneControl::direction(), m_oldAngle, m_planeControl, rotateAboutAxis(), and Ig3DPlaneControl::setDirection().
Referenced by makeWheelControl().
00092 { 00093 float change = angle - m_oldAngle[2]; 00094 m_oldAngle[2] = angle; 00095 00096 SbVec3f old_dir (m_planeControl->direction ()); 00097 SbVec3f new_dir = rotateAboutAxis (old_dir[0], old_dir[1], old_dir[2], change); 00098 m_planeControl->setDirection (new_dir); 00099 }
Implements IgControlBase.
Definition at line 196 of file Ig3DAxisRotationControl.cc.
00197 { 00198 // We don't have a field for this control, so this method does 00199 // nothing. 00200 }
IgSoQtThumbWheel * Ig3DAxisRotationControl::xWidget | ( | ) | const |
Definition at line 162 of file Ig3DAxisRotationControl.cc.
References m_thumbWheels, and X_Axis.
Referenced by Ig3DGridCategory::addTips(), Ig3DClipsCategory::Ig3DClipsCategory(), Ig3DFieldPlanesCategory::Ig3DFieldPlanesCategory(), and Ig3DSlicersCategory::Ig3DSlicersCategory().
00163 { 00164 return m_thumbWheels[X_Axis]; 00165 }
IgSoQtThumbWheel * Ig3DAxisRotationControl::yWidget | ( | ) | const |
Definition at line 168 of file Ig3DAxisRotationControl.cc.
References m_thumbWheels, and Y_Axis.
Referenced by Ig3DGridCategory::addTips(), Ig3DClipsCategory::Ig3DClipsCategory(), Ig3DFieldPlanesCategory::Ig3DFieldPlanesCategory(), and Ig3DSlicersCategory::Ig3DSlicersCategory().
00169 { 00170 return m_thumbWheels[Y_Axis]; 00171 }
IgSoQtThumbWheel * Ig3DAxisRotationControl::zWidget | ( | ) | const |
Definition at line 174 of file Ig3DAxisRotationControl.cc.
References m_thumbWheels, and Z_Axis.
Referenced by Ig3DGridCategory::addTips(), Ig3DClipsCategory::Ig3DClipsCategory(), Ig3DFieldPlanesCategory::Ig3DFieldPlanesCategory(), and Ig3DSlicersCategory::Ig3DSlicersCategory().
00175 { 00176 return m_thumbWheels[Z_Axis]; 00177 }
Definition at line 54 of file Ig3DAxisRotationControl.h.
Referenced by alignToAxis(), and Ig3DAxisRotationControl().
float Ig3DAxisRotationControl::m_oldAngle[3] [private] |
Definition at line 53 of file Ig3DAxisRotationControl.h.
Referenced by setXAxisDirty(), setYAxisDirty(), and setZAxisDirty().
Definition at line 52 of file Ig3DAxisRotationControl.h.
Referenced by alignToAxis(), setXAxisDirty(), setYAxisDirty(), and setZAxisDirty().
IgSoQtThumbWheel* Ig3DAxisRotationControl::m_thumbWheels[3] [private] |
Definition at line 55 of file Ig3DAxisRotationControl.h.
Referenced by makeWheelControl(), xWidget(), yWidget(), and zWidget().