<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css"></style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi,<br>
<br>
Thanks for the great help from Ionut Iorgovan and Andreas Lasso, I can now use the Polaris tracker and display correctly the view with IGSTK.<br>
<br>
I past here the code (below), which is an example of how to use a Polaris tracker with QT 4 and IGSTK 5.2. I hope this might help someone else.<br>
<br>
Best,<br>
Steve<br>
<br>
<br>
MAIN.CPP<br>
--------------------------------------------------------<br>
<br>
#include <QApplication><br>
#include <QtTest/QTest><br>
#include <QMainWindow><br>
#include <iostream><br>
#include "igstkView3D.h"<br>
#include "igstkAxesObject.h"<br>
#include "igstkAxesObjectRepresentation.h"<br>
#include "igstkCylinderObject.h"<br>
#include "igstkCylinderObjectRepresentation.h"<br>
#include "igstkTransformObserver.h"<br>
#include "igstkLogger.h"<br>
#include "itkStdStreamLogOutput.h"<br>
#include "igstkPolarisTracker.h"<br>
#include "igstkPolarisTrackerTool.h"<br>
#include "igstkSerialCommunication.h"<br>
#include "igstkQTWidget.h"<br>
<br>
<br>
int main( int argc, char * argv[])<br>
{<br>
    igstk::RealTimeClock::Initialize();<br>
<br>
<br>
<br>
    // *******************************<br>
    //      INSTANCES<br>
    //********************************<br>
<br>
    // logger<br>
    igstk::Object::LoggerType::Pointer   m_Logger        = igstk::Object::LoggerType::New();<br>
    itk::StdStreamLogOutput::Pointer     m_LogOutput     = itk::StdStreamLogOutput::New();<br>
<br>
    // tracker<br>
    igstk::PolarisTracker::Pointer       m_Tracker       = igstk::PolarisTracker::New();<br>
    igstk::PolarisTrackerTool::Pointer   m_TrackerTool   = igstk::PolarisTrackerTool::New();<br>
    igstk::SerialCommunication::Pointer  m_Communication = igstk::SerialCommunication::New();<br>
<br>
    //observer<br>
    igstk::TransformObserver::Pointer    coordSystemAObserver = igstk::TransformObserver::New();<br>
<br>
    //transformation<br>
    const double longestValidityTime = igstk::TimeStamp::GetLongestPossibleTime();<br>
    igstk::Transform identityTransform;<br>
    identityTransform.SetToIdentity(longestValidityTime);<br>
<br>
    //objects<br>
    igstk::AxesObject::Pointer                    worldReference  = igstk::AxesObject::New();<br>
    igstk::AxesObjectRepresentation::Pointer      worldReferenceR = igstk::AxesObjectRepresentation::New();<br>
    igstk::CylinderObject::Pointer                cylinder        = igstk::CylinderObject::New();<br>
    igstk::CylinderObjectRepresentation::Pointer  cylinderR       = igstk::CylinderObjectRepresentation::New();<br>
<br>
    //views<br>
    igstk::View3D::Pointer View3D = igstk::View3D::New();<br>
<br>
    //QT<br>
    QApplication myApp(argc, argv);<br>
    QMainWindow myMainWindow;<br>
    igstk::QTWidget* qtWidget3D  = new igstk::QTWidget();<br>
<br>
<br>
<br>
<br>
    // *******************************<br>
    //     LOGGER<br>
    //********************************<br>
    m_LogOutput->SetStream(std::cout);<br>
    m_Logger->AddLogOutput(m_LogOutput);<br>
    //m_Logger->SetPriorityLevel( itk::Logger::DEBUG);<br>
<br>
<br>
<br>
<br>
    // *******************************<br>
    //      OBJECTS<br>
    //********************************<br>
<br>
    // world reference<br>
    worldReference  -> SetSize(200.0,200.0,200.0);<br>
    worldReferenceR -> RequestSetAxesObject(worldReference);<br>
    worldReferenceR -> SetOpacity(1.0);<br>
<br>
    // cylinder<br>
    //cylinder->SetLogger(m_Logger);<br>
    cylinder  -> SetRadius(20.0);<br>
    cylinder  -> SetHeight(300.0);<br>
    cylinderR -> RequestSetCylinderObject( cylinder );<br>
    cylinderR -> SetColor(1.0,0.0,0.0);<br>
    cylinderR -> SetOpacity(1.0);<br>
<br>
<br>
<br>
<br>
<br>
<br>
    // *******************************<br>
    //     TRACKER<br>
    //********************************<br>
<br>
    //serial communication<br>
    //m_Communication->SetLogger( m_Logger );<br>
    m_Communication->SetPortNumber(       igstk::SerialCommunication::PortNumber0 );<br>
    m_Communication->SetParity(           igstk::SerialCommunication::NoParity );<br>
    m_Communication->SetBaudRate(         igstk::SerialCommunication::BaudRate115200 );<br>
    m_Communication->SetDataBits(         igstk::SerialCommunication::DataBits8 );<br>
    m_Communication->SetStopBits(         igstk::SerialCommunication::StopBits1 );<br>
    m_Communication->SetHardwareHandshake(igstk::SerialCommunication::HandshakeOff );<br>
    m_Communication->SetCapture( true );<br>
<br>
    igstk::Communication::ResultType openCommOutput = m_Communication->OpenCommunication();<br>
    if( openCommOutput == igstk::Communication::SUCCESS)<br>
        std::cout<<"SerialComm: OpenCommunication OK"<<std::endl;<br>
    else if(openCommOutput == igstk::Communication::TIMEOUT)<br>
        std::cout<<"SerialComm: OpenCommunication TIMEOUT"<<std::endl;<br>
    else if(openCommOutput == igstk::Communication::FAILURE)<br>
        std::cout<<"SerialComm: OpenCommunication FAILED"<<std::endl;<br>
<br>
<br>
    // tracker<br>
    //m_Tracker->SetLogger(m_Logger);<br>
    m_Tracker->SetCommunication(m_Communication);<br>
    m_Tracker->RequestOpen();<br>
<br>
<br>
    // tool<br>
    m_TrackerTool->SetLogger(m_Logger);<br>
    m_TrackerTool->RequestSelectWirelessTrackerTool();<br>
    m_TrackerTool->RequestSetSROMFileName("../Resources/TrackerROMfiles/ISTB0050.rom");<br>
    m_TrackerTool->RequestConfigure();<br>
    m_TrackerTool->RequestAttachToTracker(m_Tracker);<br>
<br>
<br>
    //observer<br>
    coordSystemAObserver->ObserveTransformEventsFrom(m_TrackerTool);<br>
<br>
<br>
    //start tracking<br>
    m_Tracker->RequestStartTracking();<br>
<br>
<br>
<br>
<br>
    // *******************************<br>
    //      TRANSFORM AND PARENTS<br>
    //********************************<br>
<br>
    View3D->RequestSetTransformAndParent(identityTransform, worldReference);<br>
    cylinder->RequestSetTransformAndParent(identityTransform, worldReference);<br>
<br>
<br>
<br>
<br>
<br>
<br>
    // *******************************<br>
    //      3DView<br>
    //********************************<br>
    //View3D->SetLogger(m_Logger);<br>
    View3D->RequestAddObject(worldReferenceR->Copy());<br>
    View3D->RequestAddObject(cylinderR->Copy());<br>
    View3D->SetRefreshRate( 30 ); // Hz<br>
<br>
<br>
<br>
<br>
<br>
<br>
    // *******************************<br>
    //      QT<br>
    //********************************<br>
    qtWidget3D->RequestSetView( View3D );<br>
    qtWidget3D->RequestEnableInteractions();<br>
    myMainWindow.setCentralWidget(qtWidget3D);<br>
    myMainWindow.setFixedSize(720,576);<br>
    myMainWindow.show();<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
    // *******************************<br>
    //     MAIN LOOP<br>
    //********************************<br>
    View3D->RequestStart();<br>
    View3D->RequestResetCamera();<br>
<br>
    while(1)<br>
    {<br>
        std::cout<<"\n\n"<<std::endl;<br>
        QTest::qWait(25);<br>
        igstk::PulseGenerator::CheckTimeouts();<br>
<br>
        //print tracker position<br>
        igstk::Transform trackerToolTransform;<br>
        ::itk::Vector<double, 3> trackerToolTranslation;<br>
        coordSystemAObserver->Clear();<br>
        m_TrackerTool->RequestGetTransformToParent();<br>
        if (coordSystemAObserver->GotTransform())<br>
        {<br>
            trackerToolTransform = coordSystemAObserver->GetTransform();<br>
            if ( trackerToolTransform.IsValidNow() )<br>
            {<br>
                trackerToolTranslation = trackerToolTransform.GetTranslation();<br>
                std::cout << "Trackertool :"<br>
                          << m_TrackerTool->GetTrackerToolIdentifier()<br>
                          << "\t\t  Position = ("<br>
                          << trackerToolTranslation[0]<br>
                          << ","<br>
                          << trackerToolTranslation[1]<br>
                          << ","<br>
                          << trackerToolTranslation[2]<br>
                          << ")" << std::endl<br>
                          << "\tExp Time = " << trackerToolTransform.GetExpirationTime() <<std::endl;<br>
                cylinder->RequestUpdateTransformToParent(trackerToolTransform);<br>
            }<br>
        }<br>
    }<br>
<br>
<br>
    return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
QT PRO FILE<br>
-------------------------------------------------<br>
<br>
QT       += core gui network \<br>
            widgets printsupport<br>
<br>
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets<br>
<br>
QT += testlib #to be able to use the QtTest library<br>
DESTDIR = $$PWD #to say that we are working from this project directory (to easily set up relative filepath)<br>
<br>
HEADERS +=<br>
<br>
<br>
SOURCES += \<br>
    src/main.cpp \<br>
<br>
<br>
<br>
#include the geometry library<br>
INCLUDEPATH += /usr/local/include/Geometry<br>
<br>
<br>
#include IGSTK<br>
INCLUDEPATH += /usr/local/include/IGSTK<br>
INCLUDEPATH += /home/berger/SpineBot/kitware/igstk/IGSTK-5.2/bin/Testing/<br>
<br>
#include ITK<br>
INCLUDEPATH += /usr/local/include/ITK-4.4<br>
INCLUDEPATH += /usr/local/include/ITK-4.4/vnl<br>
<br>
<br>
#include VTK<br>
INCLUDEPATH += /usr/local/include/vtk-5.10<br>
<br>
<br>
#lib igstk<br>
LIBS += -L/usr/local/lib/IGSTK<br>
LIBS += -lIGSTK<br>
LIBS += -lSceneGraphVisualization<br>
<br>
<br>
#lib ITK<br>
LIBS += -L/usr/local/lib/<br>
LIBS += -lITKBiasCorrection-4.4<br>
LIBS += -lITKBioCell-4.4<br>
LIBS += -lITKCommon-4.4<br>
LIBS += -lITKDICOMParser-4.4<br>
LIBS += -litkdouble-conversion-4.4<br>
LIBS += -lITKEXPAT-4.4<br>
LIBS += -lITKFEM-4.4<br>
LIBS += -litkgdcmCommon-4.4<br>
LIBS += -litkgdcmDICT-4.4<br>
LIBS += -litkgdcmDSED-4.4<br>
LIBS += -litkgdcmIOD-4.4<br>
LIBS += -litkgdcmjpeg12-4.4<br>
LIBS += -litkgdcmjpeg16-4.4<br>
LIBS += -litkgdcmjpeg8-4.4<br>
LIBS += -litkgdcmMSFF-4.4<br>
LIBS += -litkgdcmuuid-4.4<br>
LIBS += -lITKgiftiio-4.4<br>
LIBS += -litkhdf5-4.4<br>
LIBS += -litkhdf5_cpp-4.4<br>
LIBS += -lITKIOBioRad-4.4<br>
LIBS += -lITKIOBMP-4.4<br>
LIBS += -lITKIOCSV-4.4<br>
LIBS += -lITKIOGDCM-4.4<br>
LIBS += -lITKIOGE-4.4<br>
LIBS += -lITKIOGIPL-4.4<br>
LIBS += -lITKIOHDF5-4.4<br>
LIBS += -lITKIOImageBase-4.4<br>
LIBS += -lITKIOIPL-4.4<br>
LIBS += -lITKIOJPEG-4.4<br>
LIBS += -lITKIOLSM-4.4<br>
LIBS += -lITKIOMesh-4.4<br>
LIBS += -lITKIOMeta-4.4<br>
LIBS += -lITKIONIFTI-4.4<br>
LIBS += -lITKIONRRD-4.4<br>
LIBS += -lITKIOPNG-4.4<br>
LIBS += -lITKIOSiemens-4.4<br>
LIBS += -lITKIOSpatialObjects-4.4<br>
LIBS += -lITKIOStimulate-4.4<br>
LIBS += -lITKIOTIFF-4.4<br>
LIBS += -lITKIOTransformBase-4.4<br>
LIBS += -lITKIOTransformHDF5-4.4<br>
LIBS += -lITKIOTransformInsightLegacy-4.4<br>
LIBS += -lITKIOTransformMatlab-4.4<br>
LIBS += -lITKIOVTK-4.4<br>
LIBS += -lITKIOXML-4.4<br>
LIBS += -litkjpeg-4.4<br>
LIBS += -lITKKLMRegionGrowing-4.4<br>
LIBS += -lITKLabelMap-4.4<br>
LIBS += -lITKMesh-4.4<br>
LIBS += -lITKMetaIO-4.4<br>
LIBS += -litkNetlibSlatec-4.4<br>
LIBS += -lITKniftiio-4.4<br>
LIBS += -lITKNrrdIO-4.4<br>
LIBS += -litkopenjpeg-4.4<br>
LIBS += -lITKOptimizers-4.4<br>
LIBS += -lITKOptimizersv4-4.4<br>
LIBS += -lITKPath-4.4<br>
LIBS += -litkpng-4.4<br>
LIBS += -lITKPolynomials-4.4<br>
LIBS += -lITKQuadEdgeMesh-4.4<br>
LIBS += -lITKReview-4.4<br>
LIBS += -lITKSpatialObjects-4.4<br>
LIBS += -lITKStatistics-4.4<br>
LIBS += -litksys-4.4<br>
LIBS += -litktiff-4.4<br>
LIBS += -litkv3p_lsqr-4.4<br>
LIBS += -litkv3p_netlib-4.4<br>
LIBS += -litkvcl-4.4<br>
LIBS += -lITKVideoCore-4.4<br>
LIBS += -lITKVideoIO-4.4<br>
LIBS += -litkvnl-4.4<br>
LIBS += -litkvnl_algo-4.4<br>
LIBS += -lITKVNLInstantiation-4.4<br>
LIBS += -lITKVTK-4.4<br>
LIBS += -lITKWatersheds-4.4<br>
LIBS += -litkzlib-4.4<br>
LIBS += -lITKznz-4.4<br>
<br>
<br>
<br>
#lib VTK<br>
LIBS += -L/usr/local/lib/vtk-5.10<br>
LIBS += -lLSDyna<br>
LIBS += -lMapReduceMPI<br>
LIBS += -lmpistubs<br>
LIBS += -lQVTK<br>
LIBS += -lvtkalglib<br>
LIBS += -lvtkCharts<br>
LIBS += -lvtkCommon<br>
LIBS += -lvtkDICOMParser<br>
LIBS += -lvtkexoIIc<br>
LIBS += -lvtkexpat<br>
LIBS += -lvtkFiltering<br>
LIBS += -lvtkfreetype<br>
LIBS += -lvtkftgl<br>
LIBS += -lvtkGenericFiltering<br>
LIBS += -lvtkGeovis<br>
LIBS += -lvtkGraphics<br>
LIBS += -lvtkhdf5<br>
LIBS += -lvtkhdf5_hl<br>
LIBS += -lvtkHybrid<br>
LIBS += -lvtkImaging<br>
LIBS += -lvtkInfovis<br>
LIBS += -lvtkIO<br>
LIBS += -lvtkjpeg<br>
LIBS += -lvtklibxml2<br>
LIBS += -lvtkmetaio<br>
LIBS += -lvtkNetCDF<br>
LIBS += -lvtkNetCDF_cxx<br>
LIBS += -lvtkpng<br>
LIBS += -lvtkproj4<br>
LIBS += -lvtkQtChart<br>
LIBS += -lvtkRendering<br>
LIBS += -lvtksqlite<br>
LIBS += -lvtksys<br>
LIBS += -lvtktiff<br>
LIBS += -lvtkverdict<br>
LIBS += -lvtkViews<br>
LIBS += -lvtkVolumeRendering<br>
LIBS += -lvtkWidgets<br>
LIBS += -lvtkzlib<br>
<br>
<br>
<br>
<br>
<br>
<br>
</div>
</body>
</html>