File: PivotCalibrationFLTKWidgetExample.h

package info (click to toggle)
igstk 4.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 36,940 kB
  • ctags: 6,895
  • sloc: cpp: 70,958; makefile: 99; xml: 70
file content (136 lines) | stat: -rw-r--r-- 4,870 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*=========================================================================

  Program:   Image Guided Surgery Software Toolkit
  Module:    $RCSfile: PivotCalibrationFLTKWidgetExample.h,v $
  Language:  C++
  Date:      $Date: 2009-06-08 20:56:31 $
  Version:   $Revision: 1.1 $

  Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#ifndef __PivotCalibrationFLTKWidgetExample_h
#define __PivotCalibrationFLTKWidgetExample_h

#include "itkCommand.h"
#include "igstkPolarisTracker.h"
#include "igstkPolarisTrackerTool.h"
#include "igstkSerialCommunication.h"
#include "PivotCalibrationFLTKWidgetExampleUI.h"


class PivotCalibrationFLTKWidgetExample :
  public PivotCalibrationFLTKWidgetExampleUI
{
public:
  PivotCalibrationFLTKWidgetExample();
  virtual void InitializeTrackingAndCalibration();
  virtual void SaveCalibration();

private:
                   //pivot calibration get transform observer
  igstkObserverMacro( TransformTo, 
                      igstk::CoordinateSystemTransformToEvent, 
                      igstk::CoordinateSystemTransformToResult )
  TransformToObserver::Pointer m_TransformToObserver;

                 //pivot calibration get RMSE observer
  igstkObserverMacro( RMSE, 
                      igstk::DoubleTypeEvent, 
                      igstk::EventHelperType::DoubleType )
  RMSEObserver::Pointer m_RMSEObserver;

                   //pivot calibration success/failure observer
  typedef itk::MemberCommand<PivotCalibrationFLTKWidgetExample>   
    CalibrationSuccessFailureObserverType;
  void OnCalibrationSuccessFailureEvent( itk::Object *caller, 
                              const itk::EventObject & event );
  CalibrationSuccessFailureObserverType::Pointer m_CalibrationSuccessFailureObserver;  

              //observer for write failure event
  typedef itk::MemberCommand<PivotCalibrationFLTKWidgetExample>   
    WriteFailureObserverType;
  void OnWriteFailureEvent( itk::Object *caller, 
                              const itk::EventObject & event );
  


  /* Observe all tracking related errors, those generated by the tracker and
     the serial communication*/
  class TrackingErrorObserver : public itk::Command
    {
    public:
      typedef TrackingErrorObserver            Self;
      typedef ::itk::Command                   Superclass;
      typedef ::itk::SmartPointer<Self>        Pointer;
      typedef ::itk::SmartPointer<const Self>  ConstPointer;

      igstkNewMacro(Self)
      igstkTypeMacro(IGSTKErrorObserver, itk::Command)

      /*
       * When an error occurs in the tracker or serial communicaiton component 
       * it will invoke this method with the appropriate error event object as 
       * a parameter. */
      void Execute(itk::Object *caller, const itk::EventObject & event);

      /*
       * When an error occurs in the tracker or serial communicaiton component 
       * it will invoke this method with the appropriate error event object as 
       * a parameter. */
      void Execute(const itk::Object *caller, const itk::EventObject & event);

      /**
       * Clear the current error. */
      void ClearError();

      /**
      * If an error occured in the tracker or serial communication this method
      * will return true. */
      bool Error();

    protected:

      /**
       * Construct an error observer for all the possible errors that occur in
       * the tracker and serial communication classes. */
      TrackingErrorObserver();

      virtual ~TrackingErrorObserver(){}

    private:

      /**
       *  member variables
       */
      bool                                m_ErrorOccured;
      std::map<std::string,std::string>   m_ErrorEvent2ErrorMessage;

      //purposely not implemented
      TrackingErrorObserver(const Self&);
      void operator=(const Self&);
    };

                         //constant settings for the serial communication
  static const igstk::SerialCommunication::ParityType PARITY;
  static const igstk::SerialCommunication::BaudRateType BAUD_RATE;
  static const igstk::SerialCommunication::DataBitsType DATA_BITS;
  static const igstk::SerialCommunication::StopBitsType STOP_BITS;
  static const igstk::SerialCommunication::HandshakeType HAND_SHAKE;


  igstk::PolarisTracker::Pointer m_tracker;
  igstk::PolarisTrackerTool::Pointer m_tool;
  igstk::SerialCommunication::Pointer m_serialCommunication;
  TrackingErrorObserver::Pointer m_errorObserver;
  bool m_initialized;

};

#endif //_PIVOT_CALIBRATION_FLTK_WIDGET_EXAMPLE_H_