File size: 4,931 Bytes
68ce2fc | 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 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
/*
Author(s): Balazs Vagvolgyi, Simon DiMaio, Anton Deguet
Created on: 2008-05-23
(C) Copyright 2008-2009 Johns Hopkins University (JHU), All Rights
Reserved.
--- begin cisst license - do not edit ---
This software is provided "as is" under an open source license, with
no warranty. The complete license can be found in license.txt and
http://www.cisst.org/cisst/license.txt.
--- end cisst license ---
*/
#include <cisstOSAbstraction/osaThreadedLogFile.h>
#include <cisstOSAbstraction/osaSleep.h>
#include <cisstMultiTask/mtsTaskManager.h>
#include <cisst3DUserInterface/ui3CursorSphere.h>
#include <sawSensablePhantom/mtsSensableHD.h>
#include <sawKeyboard/mtsKeyboard.h>
#include <SimpleBehavior.h>
#include <ImageViewer.h>
#include <RegistrationBehavior.h>
int main()
{
// log configuration
cmnLogger::SetMask(CMN_LOG_ALLOW_ALL);
cmnLogger::SetMaskFunction(CMN_LOG_ALLOW_ALL);
cmnLogger::SetMaskDefaultLog(CMN_LOG_ALLOW_ALL);
cmnLogger::AddChannel(std::cout, CMN_LOG_ALLOW_ERRORS_AND_WARNINGS);
// specify a higher, more verbose log level for these classes
cmnLogger::SetMaskClassMatching("ui3", CMN_LOG_ALLOW_ALL);
cmnLogger::SetMaskClassMatching("mts", CMN_LOG_ALLOW_ALL);
mtsTaskManager * componentManager = mtsTaskManager::GetInstance();
mtsSensableHD * sensable = new mtsSensableHD("Omni", "Omni1"); //, "Omni2" /* name in driver, see Preferences in Sensable Driver */);
componentManager->AddComponent(sensable);
ui3Manager guiManager;
SimpleBehavior simpleBehavior("SimpleBehavior1");
guiManager.AddBehavior(&simpleBehavior, // behavior reference
0, // position in the menu bar: default
"circle.png"); // icon file: no texture
ImageViewer imageViewer("ImageViewer1");
guiManager.AddBehavior(&imageViewer,
1,
"square.png");
/*
RegistrationBehavior registrationBehavior("RegistrationBehavior1");
guiManager.AddBehavior(®istrationBehavior, // behavior reference
2, // position in the menu bar: default
"cube.png"); // icon file: no texture
*/
svlCameraGeometry camera_geometry;
camera_geometry.SetPerspective(1000.0, 400, 300);
camera_geometry.RotateWorldAboutY(180.0);
guiManager.AddRenderer(400, 300, // render width & height
1.0, // virtual camera zoom
false, // borderless flag
0, 0, // window position
camera_geometry, 2, // camera parameters
"ThirdEyeView"); // name of renderer
vctFrm3 transform;
transform.Translation().Assign(+30.0, 0.0, +150.0); // recenter Omni's depth (right)
ui3MasterArm * rightMaster = new ui3MasterArm("Omni1");
guiManager.AddMasterArm(rightMaster);
rightMaster->SetInput(sensable, "Omni1",
sensable, "Omni1Button1",
sensable, "Omni1Button2",
ui3MasterArm::PRIMARY);
rightMaster->SetTransformation(transform, 0.5 /* scale factor */);
ui3CursorBase * rightCursor = new ui3CursorSphere();
rightCursor->SetAnchor(ui3CursorBase::CENTER_RIGHT);
rightMaster->SetCursor(rightCursor);
#if 0
transform.Translation().Assign(+30.0, 0.0, -150.0); // recenter Omni's depth (right)
ui3MasterArm * leftMaster = new ui3MasterArm("Omni2");
guiManager.AddMasterArm(leftMaster);
leftMaster->SetInput(sensable, "Omni2",
sensable, "Omni2Button1",
sensable, "Omni2Button2",
ui3MasterArm::SECONDARY);
leftMaster->SetTransformation(transform, 0.5 /* scale factor */);
ui3CursorBase * leftCursor = new ui3CursorSphere();
leftCursor->SetAnchor(ui3CursorBase::CENTER_LEFT);
leftMaster->SetCursor(leftCursor);
#endif
// connect keyboard to ui3 and Omnis
mtsKeyboard * keyboard = new mtsKeyboard();
componentManager->AddComponent(keyboard);
keyboard->SetQuitKey('q');
// MaM
keyboard->AddKeyButtonEvent('m', "MaM", true);
guiManager.SetupMaM(keyboard, "MaM");
guiManager.ConnectAll();
// following should be replaced by a utility function or method of ui3Manager
componentManager->CreateAll();
osaSleep(3.0 * cmn_s);
componentManager->StartAll();
osaSleep(1.0 * cmn_s);
do {
osaSleep(10.0 * cmn_ms);
} while (!keyboard->Done());
componentManager->KillAll();
componentManager->Cleanup();
cmnLogger::SetMask(CMN_LOG_ALLOW_NONE);
return 0;
}
|