Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for Recording to a file. Also did some file clean up an…

…d renaming.
  • Loading branch information...
commit baec84fa4a11fa54c14dc285860f46e5b3722cb1 1 parent 2870ca0
Michael Feist authored
1  BlinkAnalysis.sln
View
@@ -22,6 +22,7 @@ Global
{7439C959-92E0-4299-A67C-FC9E32D38AEB}.Release|Win32.Build.0 = Release|Win32
{48428683-A37D-4FFB-94A4-2F11F3419F2E}.Debug|Win32.ActiveCfg = Debug
{48428683-A37D-4FFB-94A4-2F11F3419F2E}.Release|Win32.ActiveCfg = Release
+ {48428683-A37D-4FFB-94A4-2F11F3419F2E}.Release|Win32.Build.0 = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
13 BlinkAnalysis/AppData.cpp
View
@@ -91,19 +91,6 @@ bool AppData::openFile(char* filePath) {
return true;
}
-pugi::xml_node AppData::getNewRecording() {
- // Get Project
- pugi::xml_node project = doc.child("Project");
-
- // If no Project create new Project node
- if (!project) {
- project = doc.append_child();
- project.set_name("Project");
- }
-
- return project.append_child();
-}
-
bool AppData::saveFile() {
MainFormController::getInstance()->getInfo();
2  BlinkAnalysis/AppData.h
View
@@ -32,8 +32,6 @@ public class AppData
char* getLastError() { return this->error; }
- pugi::xml_node getNewRecording();
-
bool openFile(char* filePath);
bool saveFile();
bool isSaveNeeded() { return this->needSaveFlag; }
7 BlinkAnalysis/BlinkAnalysis.vcxproj
View
@@ -111,16 +111,19 @@
</ItemGroup>
<ItemGroup>
<None Include="app.ico" />
- <Content Include="DikablisHelpDocs\DikablisHelp.htm">
+ <Content Include="docs\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <None Include="DikablisHelpDocs\DikablisHelp.rtf" />
+ <None Include="docs\DikablisHelp.rtf" />
<Content Include="NatNetLib.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images/*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+<Content Include="Settings/*">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<None Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
4 BlinkAnalysis/DikablisHelp.h
View
@@ -14,7 +14,6 @@ namespace BlinkAnalysis {
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
- using namespace System::Diagnostics;
using namespace System::IO;
using namespace System::Reflection;
@@ -113,9 +112,8 @@ namespace BlinkAnalysis {
}
#pragma endregion
private: System::Void Form_Load(System::Object^ sender, System::EventArgs^ e) {
- String^ path = Path::GetFullPath( "DikablisHelpDocs/DikablisHelp.htm");
+ String^ path = Path::GetFullPath( "docs/DikablisHelp.htm");
webBrowser->Navigate("file:///" + path);
- Debug::WriteLine(path);
}
};
}
23 BlinkAnalysis/MainFormController.cpp
View
@@ -3,6 +3,8 @@
#include "AppData.h"
+#include <msclr\marshal_cppstd.h>
+
void MainFormController::dikablisOutputLog(std::string msg) {
this->form->dikablisOutputLog(gcnew String(msg.c_str()));
}
@@ -39,3 +41,24 @@ void MainFormController::optiTrackOutputLog(std::string msg) {
this->form->optiTrackOutputLog(gcnew String(msg.c_str()));
}
+void MainFormController::showError(LPCTSTR msg) {
+ MessageBox::Show(gcnew String(msg), "Error",
+ MessageBoxButtons::OK, MessageBoxIcon::Warning);
+}
+
+void MainFormController::getFilePath(std::string& pathBuffer) {
+ SaveFileDialog^ dialog = gcnew SaveFileDialog;
+
+ dialog->Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
+ dialog->FilterIndex = 2;
+ dialog->RestoreDirectory = true;
+
+ if ( dialog->ShowDialog() == ::DialogResult::OK )
+ {
+ MessageBox::Show(dialog->FileName);
+
+ msclr::interop::marshal_context context;
+ pathBuffer = context.marshal_as<std::string>(dialog->FileName);
+ }
+}
+
3  BlinkAnalysis/MainFormController.h
View
@@ -40,5 +40,8 @@ public ref class MainFormController sealed :
void worldUpdateGridView(int id) { this->form->worldUpdateGridView(id); }
void objectUpdateList() { this->form->objectUpdateList(); }
void objectUpdateGridView(int id) { this->form->objectUpdateGridView(id); }
+
+ void showError(LPCTSTR msg);
+ void getFilePath(std::string& pathBuffer);
};
116 BlinkAnalysis/Recording.cpp
View
@@ -2,6 +2,7 @@
#include "Recording.h"
#include "AppData.h"
+#include "MainFormController.h"
#include "RecordingManager.h"
typedef std::map<int, RigidBody*>::iterator RigidBody_iterator;
@@ -10,8 +11,6 @@ Recording::Recording(void)
{
this->readyForRecording = false;
this->id = RecordingManager::getInstance()->getNewID();
-
- this->recording = AppData::getInstance()->getNewRecording();
}
@@ -32,7 +31,7 @@ bool Recording::loadRecording(pugi::xml_node recording) {
}
// Get Static Objects
- pugi::xml_node static_objects = recording.child("Static");
+ pugi::xml_node static_objects = recording.child("StaticData");
for (pugi::xml_node rigidBody = static_objects.child("RigidBody"); rigidBody; rigidBody = static_objects.next_sibling("RigidBody")) {
pugi::xml_attribute id = rigidBody.attribute("id");
@@ -49,34 +48,72 @@ bool Recording::loadRecording(pugi::xml_node recording) {
return true;
}
+void XTrace(LPCTSTR lpszFormat, ...)
+{
+ va_list args;
+ va_start(args, lpszFormat);
+ int nBuf;
+ TCHAR szBuffer[512]; // get rid of this hard-coded buffer
+ nBuf = _vsntprintf_s(szBuffer, 511, lpszFormat, args);
+ ::OutputDebugString(szBuffer);
+ va_end(args);
+}
+
+
void Recording::initializeRecording() {
ClientHandler* client = AppData::getInstance()->getClient();
if (client) {
- recording.set_name("Recording");
-
- pugi::xml_node static_objects = recording.child("Static");
-
- if (!static_objects) {
- static_objects = recording.append_child();
- static_objects.set_name("Static");
+ UINT uRetVal = 0;
+ DWORD dwRetVal = 0;
+ // Get the temp path.
+ dwRetVal = GetTempPath(MAX_PATH, // length of the buffer
+ lpTempPathBuffer); // buffer for path
+
+ if (dwRetVal > MAX_PATH) {
+ MainFormController::getInstance()->showError(L"Failed to find temporary directory.\n");
+ RecordingManager::getInstance()->stopRecording();
+ return;
}
- for (pugi::xml_node rigidBody = static_objects.child("RigidBody"); rigidBody; rigidBody = static_objects.next_sibling("RigidBody")) {
- static_objects.remove_child(rigidBody);
+ // Create a temporary file.
+ uRetVal = GetTempFileName(lpTempPathBuffer, // directory for tmp files
+ L"BlinkAnalysisRecording", // temp file name prefix
+ 0, // create unique name
+ szTempFileName); // buffer for the name
+
+ if (uRetVal == 0)
+ {
+ MainFormController::getInstance()->showError(L"Failed to create temporary file.\n");
+ RecordingManager::getInstance()->stopRecording();
+ return;
}
- std::map<int, RigidBody*>* rigidBodies = client->getRigidBodyMap();
+ std::string filePath;
+ MainFormController::getInstance()->getFilePath(filePath);
- for (RigidBody_iterator it = rigidBodies->begin(); it != rigidBodies->end(); ++it) {
- pugi::xml_node rigidBody = static_objects.append_child();
- rigidBody.set_name("RigidBody");
- rigidBody.append_attribute("id") = it->second->getID();
- rigidBody.append_attribute("name") = it->second->getName();
+ //tempFileStream.open(szTempFileName);
+ tempFileStream.open(filePath);
+
+ if (tempFileStream.is_open()) {
+
+ tempFileStream << "<Recording>\n";
+ tempFileStream << "\t<StaticData>\n";
+ std::map<int, RigidBody*>* rigidBodies = client->getRigidBodyMap();
+
+ for (RigidBody_iterator it = rigidBodies->begin(); it != rigidBodies->end(); ++it) {
+ tempFileStream << "\t\t<RigidBody ";
+ tempFileStream << "id=\"" << it->second->getID() << "\" ";
+ tempFileStream << "name=\"" << it->second->getName() << "\" ";
+ tempFileStream << "/>\n";
+ }
+
+ tempFileStream << "\t</StaticData>\n";
+ tempFileStream << "\t<Frames>\n";
}
}
-
+
this->readyForRecording = true;
}
@@ -84,28 +121,41 @@ void Recording:: addFrame() {
if (!this->readyForRecording)
initializeRecording();
+ if (!tempFileStream.is_open())
+ return;
+
ClientHandler* client = AppData::getInstance()->getClient();
if (client) {
- pugi::xml_node frame = recording.append_child();
- frame.set_name("Frame");
+ tempFileStream << "\t\t<Frame>\n";
std::map<int, RigidBody*>* rigidBodies = client->getRigidBodyMap();
for (RigidBody_iterator it = rigidBodies->begin(); it != rigidBodies->end(); ++it) {
- pugi::xml_node rigidBody = frame.append_child();
- rigidBody.set_name("RigidBody");
+ tempFileStream << "\t\t\t<RigidBody \n";
- rigidBody.append_attribute("id") = it->second->getID();
-
- rigidBody.append_attribute("x") = it->second->getPosition().x();
- rigidBody.append_attribute("y") = it->second->getPosition().y();
- rigidBody.append_attribute("z") = it->second->getPosition().z();
-
- rigidBody.append_attribute("qx") = it->second->getRotation().x();
- rigidBody.append_attribute("qy") = it->second->getRotation().y();
- rigidBody.append_attribute("qz") = it->second->getRotation().z();
- rigidBody.append_attribute("qw") = it->second->getRotation().w();
+ tempFileStream << "id=\"" << it->second->getID() << "\" ";
+
+ tempFileStream << "x=\"" << it->second->getPosition().x() << "\" ";
+ tempFileStream << "y=\"" << it->second->getPosition().y() << "\" ";
+ tempFileStream << "z=\"" << it->second->getPosition().z() << "\" ";
+
+ tempFileStream << "qx=\"" << it->second->getRotation().x() << "\" ";
+ tempFileStream << "qy=\"" << it->second->getRotation().y() << "\" ";
+ tempFileStream << "qz=\"" << it->second->getRotation().z() << "\" ";
+ tempFileStream << "qw=\"" << it->second->getRotation().w() << "\" ";
+
+ tempFileStream << "/>\n";
}
+
+ tempFileStream << "\t\t</Frame>\n";
+ }
+}
+
+void Recording::closeRecording() {
+ if (tempFileStream.is_open()) {
+ tempFileStream << "\t</Frames>\n";
+ tempFileStream << "</Recording>\n";
+ tempFileStream.close();
}
}
16 BlinkAnalysis/Recording.h
View
@@ -1,4 +1,11 @@
#pragma once
+#include <windows.h>
+#include <tchar.h>
+#include <stdio.h>
+
+#include <iostream>
+#include <fstream>
+
#include <string.h>
#include <map>
#include <vector>
@@ -110,9 +117,13 @@ class Recording
bool readyForRecording;
std::vector<Frame> frames;
- pugi::xml_node recording;
void initializeRecording();
+
+ std::ofstream tempFileStream;
+
+ TCHAR szTempFileName[MAX_PATH];
+ TCHAR lpTempPathBuffer[MAX_PATH];
public:
Recording(void);
~Recording(void);
@@ -120,11 +131,10 @@ class Recording
void setName(std::string name) { this->name = name; }
std::string getName() { return this->name; }
+ void closeRecording();
void addFrame();
int numberOfFrames() { return this->frames.size(); }
bool loadRecording(pugi::xml_node recording);
-
- pugi::xml_node& getXML() { return this->recording; }
};
8 BlinkAnalysis/RecordingManager.cpp
View
@@ -7,6 +7,8 @@
RecordingManager* RecordingManager::m_pInstance = NULL;
+#define RECORDING_FPS 24
+
RecordingManager::RecordingManager(void)
{
this->recording = false;
@@ -24,7 +26,7 @@ RecordingManager::~RecordingManager(void)
void recordingThread(void *) {
while (RecordingManager::getInstance()->isRecording()) {
RecordingManager::getInstance()->addFrame();
- Sleep(1000/60);
+ Sleep(1000/RECORDING_FPS);
}
// Terminate thread
@@ -34,6 +36,7 @@ void recordingThread(void *) {
void RecordingManager::addRecording() {
if (this->currentRecording != NULL) {
this->recordings.push_back(this->currentRecording);
+ this->currentRecording->closeRecording();
this->currentRecording = 0;
}
}
@@ -53,8 +56,9 @@ void RecordingManager::startRecording() {
void RecordingManager::stopRecording() {
if (this->recording) {
- addRecording();
this->recording = false;
+
+ addRecording();
}
}
BIN  BlinkAnalysis/app.rc
View
Binary file not shown
0  BlinkAnalysis/DikablisHelpDocs/DikablisHelp.htm → BlinkAnalysis/docs/DikablisHelp.htm
View
File renamed without changes
0  BlinkAnalysis/DikablisHelpDocs/DikablisHelp.rtf → BlinkAnalysis/docs/DikablisHelp.rtf
View
File renamed without changes
43 Setup/Setup.vdproj
View
@@ -33,13 +33,7 @@
}
"Entry"
{
- "MsmKey" = "8:_488106BC5BC74D4789E6A4D8C144DE2A"
- "OwnerKey" = "8:_8E8513CA16D445B3958A033AAAAF13A3"
- "MsmSig" = "8:_UNDEFINED"
- }
- "Entry"
- {
- "MsmKey" = "8:_7B2EE1D6DB6D8F01DFF3993CC147A9C5"
+ "MsmKey" = "8:_7165D838F5D94FE28A9A11A80D805D7C"
"OwnerKey" = "8:_8E8513CA16D445B3958A033AAAAF13A3"
"MsmSig" = "8:_UNDEFINED"
}
@@ -116,6 +110,19 @@
"PrerequisitesLocation" = "2:1"
"Url" = "8:"
"ComponentsUrl" = "8:"
+ "Items"
+ {
+ "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:.NETFramework,Version=v4.0,Profile=Client"
+ {
+ "Name" = "8:Microsoft .NET Framework 4 Client Profile (x86 and x64)"
+ "ProductCode" = "8:.NETFramework,Version=v4.0,Profile=Client"
+ }
+ "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.Windows.Installer.3.1"
+ {
+ "Name" = "8:Windows Installer 3.1"
+ "ProductCode" = "8:Microsoft.Windows.Installer.3.1"
+ }
+ }
}
}
"Release"
@@ -243,26 +250,6 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
- "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_7B2EE1D6DB6D8F01DFF3993CC147A9C5"
- {
- "SourcePath" = "8:NatNetLib.dll"
- "TargetName" = "8:NatNetLib.dll"
- "Tag" = "8:"
- "Folder" = "8:_5B2E1B03F1B9421C82AC522697881248"
- "Condition" = "8:"
- "Transitive" = "11:FALSE"
- "Vital" = "11:TRUE"
- "ReadOnly" = "11:FALSE"
- "Hidden" = "11:FALSE"
- "System" = "11:FALSE"
- "Permanent" = "11:FALSE"
- "SharedLegacy" = "11:FALSE"
- "PackageAs" = "3:1"
- "Register" = "3:1"
- "Exclude" = "11:FALSE"
- "IsDependency" = "11:TRUE"
- "IsolateTo" = "8:"
- }
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_9CD5E06F8EB168CEF724CDEC5447627E"
{
"SourcePath" = "8:osg80-osg.dll"
@@ -1002,7 +989,7 @@
}
"MergeModule"
{
- "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_488106BC5BC74D4789E6A4D8C144DE2A"
+ "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_7165D838F5D94FE28A9A11A80D805D7C"
{
"UseDynamicProperties" = "11:TRUE"
"IsDependency" = "11:TRUE"
Please sign in to comment.
Something went wrong with that request. Please try again.