-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmdCPPObjectWatcher.cpp
More file actions
105 lines (85 loc) · 3.44 KB
/
cmdCPPObjectWatcher.cpp
File metadata and controls
105 lines (85 loc) · 3.44 KB
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
/////////////////////////////////////////////////////////////////////////////
// cmdCPPObjectWatcher.cpp : command file
//
#include "StdAfx.h"
#include "CPPObjectWatcherPlugIn.h"
#include "CustomEventWatcher.h"
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//
// BEGIN CPPObjectWatcher command
//
#pragma region CPPObjectWatcher command
// Do NOT put the definition of class CCommandCPPObjectWatcher in a header
// file. There is only ONE instance of a CCommandCPPObjectWatcher class
// and that instance is the static theCPPObjectWatcherCommand that appears
// immediately below the class definition.
class CCommandCPPObjectWatcher : public CRhinoCommand
{
public:
// The one and only instance of CCommandCPPObjectWatcher is created below.
// No copy constructor or operator= is required. Values of
// member variables persist for the duration of the application.
// CCommandCPPObjectWatcher::CCommandCPPObjectWatcher()
// is called exactly once when static theCPPObjectWatcherCommand is created.
CCommandCPPObjectWatcher() {}
// CCommandCPPObjectWatcher::~CCommandCPPObjectWatcher()
// is called exactly once when static theCPPObjectWatcherCommand is
// destroyed. The destructor should not make any calls to
// the Rhino SDK. If your command has persistent settings,
// then override CRhinoCommand::SaveProfile and CRhinoCommand::LoadProfile.
~CCommandCPPObjectWatcher() {}
// Returns a unique UUID for this command.
// If you try to use an id that is already being used, then
// your command will not work. Use GUIDGEN.EXE to make unique UUID.
UUID CommandUUID()
{
// {E326F0E7-A772-4F5C-AC7E-C9A49FC33469}
static const GUID CPPObjectWatcherCommand_UUID =
{ 0xE326F0E7, 0xA772, 0x4F5C, { 0xAC, 0x7E, 0xC9, 0xA4, 0x9F, 0xC3, 0x34, 0x69 } };
return CPPObjectWatcherCommand_UUID;
}
// Returns the English command name.
const wchar_t* EnglishCommandName() { return L"CPPObjectWatcher"; }
// Returns the localized command name.
const wchar_t* LocalCommandName() { return L"CPPObjectWatcher"; }
// Rhino calls RunCommand to run the command.
CRhinoCommand::result RunCommand( const CRhinoCommandContext& );
// Declare event watcher as member variable
CCustomEventWatcher m_watcher;
bool m_bRegistered;
};
// The one and only CCommandCPPObjectWatcher object.
// Do NOT create any other instance of a CCommandCPPObjectWatcher class.
static class CCommandCPPObjectWatcher theCPPObjectWatcherCommand;
CRhinoCommand::result CCommandCPPObjectWatcher::RunCommand( const CRhinoCommandContext& context )
{
// CCommandCPPObjectWatcher::RunCommand() is called when the user runs the "CPPObjectWatcher"
// command or the "CPPObjectWatcher" command is run by a history operation.
//Register the event watcher
if( IDYES == RhinoMessageBox( L"Watch object events?",
L"Object Watcher",
MB_YESNO | MB_ICONQUESTION)
)
{
if( !m_bRegistered )
{
m_bRegistered = true;
m_watcher.Register();
}
//Enable the event watcher
m_watcher.Enable( true );
}
else
{
//Disable the event watcher
m_watcher.Enable( false );
}
return CRhinoCommand::success;
}
#pragma endregion
//
// END CPPObjectWatcher command
//
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////