first version of the track-saver

This commit is contained in:
Erik Faye-Lund 2008-02-17 15:31:29 +00:00
parent 896abe5c0a
commit 63d7e1f67c
5 changed files with 38 additions and 9 deletions

View File

@ -734,7 +734,7 @@ void TrackView::editToggleInterpolationType()
SyncEditData::Command *cmd = syncData->getSetKeyFrameCommand(editTrack, int(lower->first), newKey);
syncData->exec(cmd);
invalidateRange(editTrack, editTrack, lower->first, upper->first);
invalidateRange(editTrack, editTrack, int(lower->first), int(upper->first));
}
else MessageBeep(0);
}

View File

@ -170,13 +170,38 @@ std::string ClientDevice::getTrackFileName(std::string trackName)
return fileName;
}
static bool saveTrack(const sync::Track &track, std::string fileName)
{
FILE *fp = fopen(fileName.c_str(), "wb");
if (NULL == fp) return false;
size_t keyFrameCount = track.getKeyFrameCount();
fwrite(&keyFrameCount, sizeof(size_t), 1, fp);
sync::Track::KeyFrameContainer::const_iterator it;
for (it = track.keyFrames.begin(); it != track.keyFrames.end(); ++it)
{
size_t row = it->first;
float value = it->second.value;
char interpolationType = char(it->second.interpolationType);
// write key
fwrite(&row, sizeof(size_t), 1, fp);
fwrite(&value, sizeof(float), 1, fp);
fwrite(&interpolationType, sizeof(char), 1, fp);
}
fclose(fp);
fp = NULL;
return true;
}
void ClientDevice::saveTracks()
{
sync::Data::TrackContainer::iterator iter;
for (iter = syncData.tracks.begin(); iter != syncData.tracks.end(); ++iter)
{
std::string fileName = getTrackFileName(iter->first);
printf("\"%s\"\n", fileName.c_str());
saveTrack(syncData.getTrack(iter->second), getTrackFileName(iter->first));
}
}

View File

@ -103,7 +103,7 @@ void Track::setKeyFrame(size_t row, const KeyFrame &keyFrame)
keyFrames[row] = keyFrame;
}
size_t Track::getFrameCount() const
size_t Track::getKeyFrameCount() const
{
if (keyFrames.empty()) return 0;
KeyFrameContainer::const_iterator iter = keyFrames.end();

View File

@ -38,7 +38,7 @@ namespace sync
bool isKeyFrame(size_t row) const;
const KeyFrame *getKeyFrame(size_t row) const;
size_t getFrameCount() const;
size_t getKeyFrameCount() const;
void deleteKeyFrame(size_t row);
void setKeyFrame(size_t row, const KeyFrame &keyFrame);

View File

@ -40,7 +40,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@ -102,7 +102,7 @@
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@ -162,7 +162,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@ -225,7 +225,7 @@
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@ -345,6 +345,10 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\sync\data.h"
>
</File>
<File
RelativePath=".\sync\device.h"
>
</File>