Skip to content
Snippets Groups Projects
Commit 75eb3f8c authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

Merge branch 'enh-changes-from-cameranavigation' into 'master'

Enh changes from cameranavigation

See merge request !174
parents ecaa6316 0972a9e6
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ namespace imstk
{
Logger::Logger(std::string filename)
{
m_filename = filename + this->getCurrentTimeFormatted() + ".log";
m_filename = filename + "_" + this->getCurrentTimeFormatted() + ".log";
m_mutex = new std::mutex();
m_thread = new std::thread(Logger::eventLoop, this);
}
......@@ -83,9 +83,7 @@ void
Logger::eventLoop(Logger * logger)
{
std::ofstream file(logger->m_filename);
char buffer[1024];
std::fill_n(buffer, 1024, '\0');
std::string buffer;
while (logger->m_running) {
std::unique_lock<std::mutex> ul(*logger->m_mutex);
......@@ -98,13 +96,13 @@ Logger::eventLoop(Logger * logger)
break;
}
std::strcpy(buffer, logger->m_message.c_str());
buffer = logger->m_message;
logger->m_changed = false;
ul.unlock();
logger->m_condition.notify_one();
file << buffer << "\n";
file << buffer;
}
file.close();
logger->m_condition.notify_one();
......@@ -113,6 +111,7 @@ Logger::eventLoop(Logger * logger)
void
Logger::log(std::string message, bool prependTime /* = false */)
{
m_message = "";
if (prependTime)
{
m_message = this->getCurrentTimeFormatted() + " ";
......
......@@ -49,7 +49,7 @@ public:
/// \params filename this name will be used in the file name of the log file
///
Logger(std::string filename);
~Logger();
virtual ~Logger();
///
/// \brief Log one line.
......@@ -94,6 +94,11 @@ public:
///
void shutdown();
///
/// \brief Get the file name
///
inline std::string getFileName() const { return m_filename; }
private:
static std::string getCurrentTimeFormatted();
......
......@@ -49,6 +49,11 @@ SceneObjectController::updateControlledObjects()
}
}
if (m_updateCallback)
{
m_updateCallback(this);
}
// Update colliding geometry
m_sceneObject->getMasterGeometry()->setTranslation(m_trackingController->getPosition());
m_sceneObject->getMasterGeometry()->setRotation(m_trackingController->getRotation());
......
......@@ -37,6 +37,7 @@ namespace imstk
///
class SceneObjectController : public SceneObjectControllerBase
{
using ControllerCallbackFunction = std::function<void(SceneObjectController* hdapiClient)>;
public:
///
/// \brief Constructor
......@@ -83,9 +84,16 @@ public:
inline std::shared_ptr<DeviceTracker> getTrackingController() const { return m_trackingController; }
inline void setTrackingController(std::shared_ptr<DeviceTracker> controller) { m_trackingController = controller; }
///
/// \brief Setting custom behavior functions
///
inline void setUpdateCallback(ControllerCallbackFunction foo) { m_updateCallback = foo; }
protected:
std::shared_ptr<DeviceTracker> m_trackingController; ///< Device tracker
std::shared_ptr<SceneObject> m_sceneObject; ///< SceneObject controlled by the Tracker
//Callback functions
ControllerCallbackFunction m_updateCallback; ///> function callback preceding module update
};
} // imstk
#endif // ifndef imstkSceneObjectController_h
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment