Exemplo n.º 1
0
//=======================================================
// StartTracking
//=======================================================
bool mitk::OptitrackTrackingDevice::StartTracking()
{
  MITK_DEBUG << "StartTracking";
  bool resultIsTrackableTracked;

  if (this->GetState() != mitk::TrackingDevice::Ready)
  {
    MITK_INFO << "System is not in State Ready -> Cannot StartTracking";
    mitkThrowException(mitk::IGTException) << "System is not in State Ready -> Cannot StartTracking";
    return false;
  }

  this->SetState(mitk::TrackingDevice::Tracking);

  // Change the m_StopTracking Variable to false
  this->m_StopTrackingMutex->Lock();
  this->m_StopTracking = false;
  this->m_StopTrackingMutex->Unlock();

  m_TrackingFinishedMutex->Unlock(); // transfer the execution rights to tracking thread

  /******************************************************************************
  ###############################################################################
  TODO: check the timestamp from the Optitrack API
  ###############################################################################
  ******************************************************************************/
  mitk::IGTTimeStamp::GetInstance()->Start(this);

  // Launch multiThreader using the Function ThreadStartTracking that executes the TrackTools() method
  m_ThreadID = m_MultiThreader->SpawnThread(this->ThreadStartTracking, this);    // start a new thread that executes the TrackTools() method

  // Information for the user
  if(GetToolCount() == 0) MITK_INFO << "No tools are defined";

  for (  int i = 0; i < GetToolCount(); ++i)  // use mutexed methods to access tool container
  {
    resultIsTrackableTracked = TT_IsTrackableTracked(i);
    if(resultIsTrackableTracked)
    {
      MITK_DEBUG << "Trackable " << i << " is inside the Tracking Volume and it is Tracked";
    }
    else
    {
      MITK_DEBUG << "Trackable " << i << " is not been tracked. Check if it is inside the  Tracking volume";
    }

  }

  return true;
}
Exemplo n.º 2
0
wxRibbonToolBarToolBase* wxRibbonToolBar::AddTool(
            int tool_id,
            const wxBitmap& bitmap,
            const wxBitmap& bitmap_disabled,
            const wxString& help_string,
            wxRibbonButtonKind kind,
            wxObject* client_data)
{
    return InsertTool(GetToolCount(), tool_id, bitmap, bitmap_disabled,
        help_string, kind, client_data);
}
Exemplo n.º 3
0
//=======================================================
// TrackTools
//=======================================================
void mitk::OptitrackTrackingDevice::TrackTools()
{
  MITK_DEBUG << "TrackTools";

  Point3D position;
  ScalarType t = 0.0;

  try
  {
    bool localStopTracking;       // Because m_StopTracking is used by two threads, access has to be guarded by a mutex. To minimize thread locking, a local copy is used here
    this->m_StopTrackingMutex->Lock();  // update the local copy of m_StopTracking
    localStopTracking = this->m_StopTracking;

    /* lock the TrackingFinishedMutex to signal that the execution rights are now transfered to the tracking thread */
    if (!localStopTracking)
    {
    m_TrackingFinishedMutex->Lock();
    }

  this->m_StopTrackingMutex->Unlock();
    while ((this->GetState() == mitk::TrackingDevice::Tracking) && (localStopTracking == false))
    {
      // For each Tracked Tool update the position and orientation
      for (  int i = 0; i < GetToolCount(); ++i)  // use mutexed methods to access tool container
      {
        OptitrackTrackingTool* currentTool = this->GetOptitrackTool(i);
        if(currentTool != nullptr)
        {
          currentTool->updateTool();
          MITK_DEBUG << "Tool number " << i << " updated position";
        }
        else
        {
          MITK_DEBUG << "Get data from tool number " << i << " failed";
          mitkThrowException(mitk::IGTException) << "Get data from tool number " << i << " failed";
        }
      }

      /* Update the local copy of m_StopTracking */
      this->m_StopTrackingMutex->Lock();
      localStopTracking = m_StopTracking;
      this->m_StopTrackingMutex->Unlock();
      Sleep(OPTITRACK_FRAME_RATE);
    } // tracking ends if we pass this line

    m_TrackingFinishedMutex->Unlock(); // transfer control back to main thread
  }
  catch(...)
  {
    m_TrackingFinishedMutex->Unlock();
    this->StopTracking();
    mitkThrowException(mitk::IGTException) << "Error while trying to track tools. Thread stopped.";
  }
}
Exemplo n.º 4
0
//-----------------------------------------------------------------------------
// Switches to a named tool
//-----------------------------------------------------------------------------
IToolSystem *CToolFrameworkInternal::SwitchToTool( const char* pToolName )
{
	int nCount = GetToolCount();
	for ( int i = 0; i < nCount; ++i )
	{
		if ( !Q_stricmp( pToolName, GetToolName(i) ) )
		{
			SwitchToTool( i );
			return m_ToolSystems[i];
		}
	}

	return NULL;
}
Exemplo n.º 5
0
//-----------------------------------------------------------------------------
// Purpose: Returns a tool pointer for a given tool ID, NULL if there is no
//			corresponding tool.
//-----------------------------------------------------------------------------
CBaseTool *CToolManager::GetToolForID(ToolID_t eToolID)
{
	int nToolCount = GetToolCount();
	for (int i = 0; i < nToolCount; i++)
	{
		CBaseTool *pTool = GetTool(i);
		if (pTool->GetToolID() == eToolID)
		{
			return pTool;
		}
	}

	return NULL;
}
Exemplo n.º 6
0
CCustomToolTipCtrl::CCustomToolTipCtrl(CWnd* pParentWnd)
  {
  ASSERT(pParentWnd);
  pParentWnd->EnableToolTips(TRUE);
  VERIFY(Create(pParentWnd));
  CWnd* w = pParentWnd->GetWindow(GW_CHILD);
  while (w)
    {
    AddTool(w);
    w = w->GetWindow(GW_HWNDNEXT);
    }
  if (GetToolCount()>0)
    Activate(TRUE);
  }
Exemplo n.º 7
0
IMaterialProxy *CToolFrameworkInternal::LookupProxy( const char *proxyName )
{
	int toolCount = GetToolCount();
	for ( int i = 0; i < toolCount; ++i )
	{
		IToolSystem *tool = m_ToolSystems[ i ];
		Assert( tool );

		IMaterialProxy *matProxy = tool->LookupProxy( proxyName );
		if ( matProxy )
		{
			return matProxy;
		}
	}
	return NULL;
}
Exemplo n.º 8
0
mitk::NavigationTool::Pointer mitk::NavigationToolStorage::GetToolByName(std::string name)
  {
  for (int i=0; i<GetToolCount(); i++) if ((GetTool(i)->GetToolName())==name) return GetTool(i);
  return NULL;
  }
Exemplo n.º 9
0
mitk::NavigationTool::Pointer mitk::NavigationToolStorage::GetTool(std::string identifier)
  {
  for (int i=0; i<GetToolCount(); i++) if ((GetTool(i)->GetIdentifier())==identifier) return GetTool(i);
  return NULL;
  }