-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRpcDocument.cpp
93 lines (73 loc) · 1.89 KB
/
RpcDocument.cpp
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
#include "StdAfx.h"
#include "RpcDocument.h"
#include "RpcMains.h"
#include "RpcEventMachine.h"
#include "RpcUtilities.h"
CRpcDocument::CRpcDocument(void)
{
Defaults();
}
CRpcDocument::~CRpcDocument(void)
{
}
void CRpcDocument::Defaults(void)
{
m_iAnimationFrame = 0;
}
int CRpcDocument::Version(void)
{
return 1;
}
int CRpcDocument::AnimationFrame(void) const
{
return m_iAnimationFrame;
}
void CRpcDocument::SetAnimationFrame(CRhinoDoc& doc, int iFrame)
{
if (m_iAnimationFrame == iFrame)
return;
const int iOldFrame = m_iAnimationFrame;
m_iAnimationFrame = iFrame;
Mains().EventMachine().OnAnimationFrameChanged(doc, iOldFrame, iFrame);
}
bool CRpcDocument::ReadFromArchive(CRhinoDoc& doc, ON_BinaryArchive& archive, const CRhinoFileReadOptions& options)
{
int major_version = 0;
int minor_version = 0;
if (!archive.BeginRead3dmChunk(TCODE_USER, &major_version, &minor_version))
return false;
int iVersion = 0;
if (!archive.ReadInt(&iVersion))
{
archive.EndRead3dmChunk();
return false;
}
if (iVersion > Version())
{
const CLBPString sMsg = _RhLocalizeString( L"This model was created with a more recent version of the RPC Plugin.", 36076);
::MessageBox(RhinoApp().MainWnd(), sMsg, L"RPC", MB_OK|MB_ICONINFORMATION);
archive.EndRead3dmChunk();
return false;
}
bool bRet = true;
if (bRet) {bRet = archive.ReadInt(&m_iAnimationFrame);}
if (!archive.EndRead3dmChunk())
return false;
return bRet;
}
bool CRpcDocument::WriteToArchive(CRhinoDoc& doc, ON_BinaryArchive& archive, const CRhinoFileWriteOptions& options)
{
const int major_version = 1;
const int minor_version = 0;
archive.BeginWrite3dmChunk(TCODE_USER, major_version, minor_version);
if (!archive.WriteInt(Version()))
{
archive.EndWrite3dmChunk();
return false;
}
bool bRet = true;
if (bRet) {bRet = archive.WriteInt(m_iAnimationFrame);}
if (!archive.EndWrite3dmChunk())
return false;
return bRet;
}