~ubuntu-branches/ubuntu/lucid/igstk/lucid

« back to all changes in this revision

Viewing changes to Examples/TrackerConfiguration/igstkMedSafeTrackerConfiguration.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Dominique Belhachemi
  • Date: 2009-10-07 17:35:43 UTC
  • mfrom: (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091007173543-69eyhyjrh0bfoqe5
Tags: 4.2.0-2
* Fixed link issue (Closes: #549799)
* switch to quilt

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=========================================================================
 
2
 
 
3
  Program:   Image Guided Surgery Software Toolkit
 
4
  Module:    $RCSfile: igstkMedSafeTrackerConfiguration.cxx,v $
 
5
  Language:  C++
 
6
  Date:      $Date: 2009-01-30 20:48:01 $
 
7
  Version:   $Revision: 1.1 $
 
8
 
 
9
  Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
 
10
  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
 
11
 
 
12
     This software is distributed WITHOUT ANY WARRANTY; without even
 
13
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 
14
     PURPOSE.  See the above copyright notices for more information.
 
15
 
 
16
=========================================================================*/
 
17
 
 
18
#include "igstkMedSafeTrackerConfiguration.h"
 
19
 
 
20
namespace igstk
 
21
{
 
22
               //maximal refresh rate for the 3D Guidance MedSafe system possible
 
23
               //with the short/mid range transmitters
 
24
const double MedSafeTrackerConfiguration::MAXIMAL_REFERESH_RATE = 350;
 
25
 
 
26
const unsigned MedSafeTrackerConfiguration::MAXIMAL_PORT_NUMBER = 4;
 
27
 
 
28
MedSafeTrackerConfiguration::MedSafeTrackerConfiguration()  
 
29
{
 
30
  this->m_Frequency = this->MAXIMAL_REFERESH_RATE;
 
31
}
 
32
 
 
33
 
 
34
MedSafeTrackerConfiguration::~MedSafeTrackerConfiguration()
 
35
{
 
36
}
 
37
 
 
38
 
 
39
double
 
40
MedSafeTrackerConfiguration::GetMaximalRefreshRate()
 
41
{
 
42
  return this->MAXIMAL_REFERESH_RATE;
 
43
}
 
44
 
 
45
 
 
46
void 
 
47
MedSafeTrackerConfiguration::InternalAddTool( 
 
48
  const TrackerToolConfiguration *tool, bool isReference )
 
49
{
 
50
  AddToolFailureEvent fe;
 
51
  const MedSafeToolConfiguration *wiredTool = 
 
52
    dynamic_cast<const MedSafeToolConfiguration *>( tool );
 
53
  
 
54
 
 
55
  if( wiredTool == NULL )
 
56
  {
 
57
    fe.Set( "Given tool configuration type not compatible with tracker type." );
 
58
    this->InvokeEvent( fe );
 
59
    return;
 
60
  }
 
61
   //check for valid bird name???
 
62
 
 
63
  if( wiredTool->GetPortNumber()==0 ||
 
64
      wiredTool->GetPortNumber()> this->MAXIMAL_PORT_NUMBER )
 
65
  {
 
66
    fe.Set( "Specified physical port number is invalid." );
 
67
    this->InvokeEvent( fe );
 
68
    return;
 
69
  }
 
70
  
 
71
        //copy the tool and add it as a standard or dynamic reference tool
 
72
  MedSafeToolConfiguration *newTool = 
 
73
    new MedSafeToolConfiguration( *wiredTool );
 
74
  
 
75
  if( !isReference )
 
76
  {
 
77
    this->m_TrackerToolList.insert(std::pair<std::string, TrackerToolConfiguration *>
 
78
      (newTool->GetToolName(), newTool) );
 
79
  }
 
80
  else
 
81
  {
 
82
    delete this->m_ReferenceTool;
 
83
    this->m_ReferenceTool = newTool; 
 
84
  }
 
85
  this->InvokeEvent( AddToolSuccessEvent() );
 
86
}
 
87
 
 
88
 
 
89
MedSafeToolConfiguration::MedSafeToolConfiguration() : m_PortNumber( 1 )
 
90
{
 
91
}                                                                
 
92
 
 
93
 
 
94
MedSafeToolConfiguration::MedSafeToolConfiguration( const 
 
95
  MedSafeToolConfiguration &other ) : TrackerToolConfiguration( other ) 
 
96
{
 
97
  this->m_PortNumber = other.m_PortNumber;
 
98
}                                                                
 
99
 
 
100
 
 
101
MedSafeToolConfiguration::~MedSafeToolConfiguration()
 
102
{
 
103
}
 
104
 
 
105
 
 
106
std::string 
 
107
MedSafeToolConfiguration::GetToolTypeAsString()
 
108
{
 
109
  return "MedSafeToolConfiguration";
 
110
}
 
111
 
 
112
} // end of name space