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

« back to all changes in this revision

Viewing changes to Source/igstkWebcamWinVideoImagerTool.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: igstkWebcamWinVideoImagerTool.cxx,v $
 
5
  Language:  C++
 
6
  Date:      $Date: 2009-06-18 18:40:55 $
 
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
#if defined(_MSC_VER)
 
19
//  Warning about: identifier was truncated to '255' characters
 
20
// in the debug information (MVC6.0 Debug)
 
21
#pragma warning( disable : 4786 )
 
22
#endif
 
23
 
 
24
#include "igstkWebcamWinVideoImagerTool.h"
 
25
#include "igstkWebcamWinVideoImager.h"
 
26
 
 
27
namespace igstk
 
28
{
 
29
 
 
30
/** Constructor */
 
31
WebcamWinVideoImagerTool::WebcamWinVideoImagerTool():m_StateMachine(this)
 
32
{
 
33
  m_VideoImagerToolConfigured = false;
 
34
 
 
35
  // States
 
36
  igstkAddStateMacro( Idle );
 
37
  igstkAddStateMacro( VideoImagerToolNameSpecified );
 
38
 
 
39
  // Set the input descriptors
 
40
  igstkAddInputMacro( ValidVideoImagerToolName );
 
41
  igstkAddInputMacro( InValidVideoImagerToolName );
 
42
 
 
43
  // Add transitions
 
44
  // Transitions from idle state
 
45
  igstkAddTransitionMacro( Idle,
 
46
                           ValidVideoImagerToolName,
 
47
                           VideoImagerToolNameSpecified,
 
48
                           SetVideoImagerToolName );
 
49
 
 
50
  igstkAddTransitionMacro( Idle,
 
51
                           InValidVideoImagerToolName,
 
52
                           Idle,
 
53
                           ReportInvalidVideoImagerToolNameSpecified );
 
54
 
 
55
  // Transitions from VideoImagerToolName specified
 
56
  igstkAddTransitionMacro( VideoImagerToolNameSpecified,
 
57
                           ValidVideoImagerToolName,
 
58
                           VideoImagerToolNameSpecified,
 
59
                           ReportInvalidRequest );
 
60
  igstkAddTransitionMacro( VideoImagerToolNameSpecified,
 
61
                           InValidVideoImagerToolName,
 
62
                           VideoImagerToolNameSpecified,
 
63
                           ReportInvalidRequest );
 
64
 
 
65
  igstkSetInitialStateMacro( Idle );
 
66
 
 
67
  m_StateMachine.SetReadyToRun();
 
68
}
 
69
 
 
70
/** Destructor */
 
71
WebcamWinVideoImagerTool::~WebcamWinVideoImagerTool()
 
72
{
 
73
}
 
74
 
 
75
/** Request set VideoImagerTool name */
 
76
void WebcamWinVideoImagerTool::RequestSetVideoImagerToolName( 
 
77
                                           const std::string& clientDeviceName )
 
78
{
 
79
  igstkLogMacro( DEBUG, "igstk::WebcamWinVideoImagerTool::"
 
80
                               << "RequestSetVideoImagerToolName called ...\n");
 
81
  if ( clientDeviceName == "" )
 
82
    {
 
83
    m_StateMachine.PushInput( m_InValidVideoImagerToolNameInput );
 
84
    m_StateMachine.ProcessInputs();
 
85
    }
 
86
  else
 
87
    {
 
88
    m_VideoImagerToolNameToBeSet = clientDeviceName;
 
89
    m_StateMachine.PushInput( m_ValidVideoImagerToolNameInput );
 
90
    m_StateMachine.ProcessInputs();
 
91
    }
 
92
}
 
93
 
 
94
/** Set valid VideoImagerTool name */
 
95
void WebcamWinVideoImagerTool::SetVideoImagerToolNameProcessing( )
 
96
{
 
97
  igstkLogMacro( DEBUG, "igstk::WebcamWinVideoImagerTool"
 
98
                          << "::SetVideoImagerToolNameProcessing called ...\n");
 
99
 
 
100
  this->m_VideoImagerToolName = m_VideoImagerToolNameToBeSet;
 
101
 
 
102
  m_VideoImagerToolConfigured = true;
 
103
 
 
104
  // VideoImagerTool name is used as a unique identifier
 
105
  this->SetVideoImagerToolIdentifier( this->m_VideoImagerToolName );
 
106
}
 
107
 
 
108
/** Report Invalid VideoImagerTool name*/
 
109
void WebcamWinVideoImagerTool
 
110
::ReportInvalidVideoImagerToolNameSpecifiedProcessing( )
 
111
{
 
112
  igstkLogMacro( DEBUG, "igstk::WebcamWinVideoImagerTool"
 
113
       << "::ReportInvalidVideoImagerToolNameSpecifiedProcessing called ...\n");
 
114
 
 
115
  igstkLogMacro( CRITICAL, "Invalid VideoImagerTool name specified ");
 
116
}
 
117
 
 
118
void WebcamWinVideoImagerTool::ReportInvalidRequestProcessing()
 
119
{
 
120
  igstkLogMacro( WARNING, "ReportInvalidRequestProcessing() called ...\n");
 
121
}
 
122
 
 
123
/** The "CheckIfVideoImagerToolIsConfigured" method returns true if the imager
 
124
 * tool is configured */
 
125
bool
 
126
WebcamWinVideoImagerTool::CheckIfVideoImagerToolIsConfigured( ) const
 
127
{
 
128
  igstkLogMacro( DEBUG, "igstk::WebcamWinVideoImagerTool"
 
129
                         << "::CheckIfVideoImagerToolIsConfigured called...\n");
 
130
  return m_VideoImagerToolConfigured;
 
131
}
 
132
 
 
133
/** Print Self function */
 
134
void WebcamWinVideoImagerTool::PrintSelf( 
 
135
                                    std::ostream& os, itk::Indent indent ) const
 
136
{
 
137
  Superclass::PrintSelf(os, indent);
 
138
 
 
139
  os << indent << "VideoImagerTool name : "
 
140
    << m_VideoImagerToolName << std::endl;
 
141
  os << indent << "VideoImagerToolConfigured:"
 
142
    << m_VideoImagerToolConfigured << std::endl;
 
143
}
 
144
 
 
145
}  // namespace igstk