IGSTK

/build/buildd/igstk-4.2.0/Source/igstkPivotCalibrationFLTKWidget.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   Image Guided Surgery Software Toolkit
00004 Module:    $RCSfile: igstkPivotCalibrationFLTKWidget.h,v $
00005 Language:  C++
00006 Date:      $Date: 2009-06-15 20:57:59 $
00007 Version:   $Revision: 1.2 $
00008 
00009 Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
00010 See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
00011 
00012 This software is distributed WITHOUT ANY WARRANTY; without even
00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014 PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __igstkPivotCalibrationFLTKWidget_h
00018 #define __igstkPivotCalibrationFLTKWidget_h
00019 
00020 #include <FL/Fl.H>
00021 #include <FL/Fl_Group.H>
00022 
00023 #include "igstkStateMachine.h"
00024 #include "igstkMacros.h"
00025 #include "igstkEvents.h"
00026 #include "igstkTracker.h"
00027 #include "igstkPivotCalibration.h"
00028 
00029 class Fl_Output;
00030 class Fl_Progress;
00031 class Fl_Button;
00032 class Fl_Multiline_Output;
00033 
00034 
00035 namespace igstk
00036 {
00071 class PivotCalibrationFLTKWidget : public Fl_Group
00072 {
00073 public:
00074   
00075   typedef PivotCalibrationFLTKWidget    Self;
00076   typedef Fl_Group                      Superclass;
00077 
00078   igstkTypeMacro( PivotCalibrationFLTKWidget, Fl_Group );
00079   
00081   igstkLoggerMacro()
00082 
00083   
00087   PivotCalibrationFLTKWidget( int x, int y, 
00088                               int w, int h, 
00089                               const char *label="" );
00091   virtual ~PivotCalibrationFLTKWidget( void );
00092 
00099   void RequestInitialize( unsigned int n, 
00100     igstk::TrackerTool::Pointer trackerTool ); 
00101 
00104   void RequestSetDelay( unsigned int delayInSeconds );  
00105 
00111   void RequestCalibrationTransform();
00112 
00117   void RequestPivotPoint();
00118 
00124   void RequestCalibrationRMSE();
00125 
00126 
00128   unsigned long AddObserver( const itk::EventObject & event, 
00129                             itk::Command *command );
00130   unsigned long AddObserver( const itk::EventObject & event, 
00131                              itk::Command *command ) const;
00132   void RemoveObserver( unsigned long observerID );
00133 
00134 private:
00135 
00136   Fl_Output *m_toolDescription;
00137   Fl_Progress *m_progress;
00138   Fl_Button *m_calibrateButton;
00139   Fl_Multiline_Output *m_output;
00140 
00141   static const double TOOL_DESCRIPTION_X_SCALE;
00142   static const double TOOL_DESCRIPTION_Y_SCALE;
00143   static const double TOOL_DESCRIPTION_W_SCALE;
00144   static const double TOOL_DESCRIPTION_H_SCALE;
00145 
00146   static const double PROGRESS_X_SCALE;
00147   static const double PROGRESS_Y_SCALE;
00148   static const double PROGRESS_W_SCALE;
00149   static const double PROGRESS_H_SCALE;
00150 
00151   static const double BUTTON_X_SCALE;
00152   static const double BUTTON_Y_SCALE;
00153   static const double BUTTON_W_SCALE;
00154   static const double BUTTON_H_SCALE;
00155 
00156   static const double OUTPUT_X_SCALE;
00157   static const double OUTPUT_Y_SCALE;
00158   static const double OUTPUT_W_SCALE;
00159   static const double OUTPUT_H_SCALE;
00160 
00162   static void RequestComputeCalibrationCB(Fl_Button *b, 
00163                                           void *v);
00164   inline void RequestComputeCalibration();
00165   //the igstk class that actually does everything
00166   PivotCalibration::Pointer m_pivotCalibration;
00167   //delay before data acquisition starts [milliseconds]
00168   unsigned int m_delay;
00169   //description of the tool we want to calibrate
00170   std::string m_currentToolInformation;
00171 
00172   //accumulate the calibration information in this stream and
00173   //then display to the user
00174   std::ostringstream m_calibrationInformationStream;
00175 
00176   //pivot calibration initialization observer
00177   typedef itk::MemberCommand<PivotCalibrationFLTKWidget>   
00178     InitializationObserverType;
00179   void OnInitializationEvent( itk::Object *caller, 
00180                               const itk::EventObject & event );
00181   InitializationObserverType::Pointer m_InitializationObserver;  
00182 
00183   //pivot calibration events (start, progress, end) 
00184   //observer
00185   typedef itk::MemberCommand<PivotCalibrationFLTKWidget>   
00186     CalibrationObserverType;
00187   void OnCalibrationEvent( itk::Object *caller, 
00188                            const itk::EventObject & event );
00189   CalibrationObserverType::Pointer m_CalibrationObserver;  
00190 
00191   //pivot calibration get transform observer
00192   igstkObserverMacro( TransformTo, 
00193                       igstk::CoordinateSystemTransformToEvent, 
00194                       igstk::CoordinateSystemTransformToResult )
00195   TransformToObserver::Pointer m_TransformToObserver;
00196 
00197   //pivot calibration get pivot point observer
00198   igstkObserverMacro( PivotPoint, 
00199                       igstk::PointEvent, 
00200                       igstk::EventHelperType::PointType )
00201   PivotPointObserver::Pointer m_PivotPointObserver;
00202 
00203   //pivot calibration get RMSE observer
00204   igstkObserverMacro( RMSE, 
00205                       igstk::DoubleTypeEvent, 
00206                       igstk::EventHelperType::DoubleType )
00207   RMSEObserver::Pointer m_RMSEObserver;
00208 
00209 };
00210 
00211 } // end namespace igstk
00212 
00213 #endif //__igstkPivotCalibrationFLTKWidget_h