-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPowerPointControl.cpp
More file actions
322 lines (261 loc) · 6.77 KB
/
Copy pathPowerPointControl.cpp
File metadata and controls
322 lines (261 loc) · 6.77 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
// -*- C++ -*-
/*!
* @file PowerPointControl.cpp
* @brief PowerPoint Control Component
* @date $Date$
*
* $Id$
*/
#include "PowerPointControl.h"
// Module specification
// <rtc-template block="module_spec">
static const char* powerpointcontrol_spec[] =
{
"implementation_id", "PowerPointControl",
"type_name", "PowerPointControl",
"description", "PowerPoint Control Component",
"version", "1.0.0",
"vendor", "Miyamoto Nobuhiko",
"category", "Office",
"activity_type", "PERIODIC",
"kind", "DataFlowComponent",
"max_instance", "1",
"language", "C++",
"lang_type", "compile",
"conf.default.file_path", "NewFile",
"conf.default.SlideFileInitialNumber", "1",
"conf.default.SlideNumberInRelative", "1",
"conf.__widget__.file_path", "text",
"conf.__widget__.SlideFileInitialNumber", "spin",
"conf.__widget__.SlideNumberInRelative", "radio",
"conf.__constraints__.SlideFileInitialNumber", "1<=x<=100",
"conf.__constraints__.SlideNumberInRelative", "(0,1)",
""
};
// </rtc-template>
/*!
* @brief PowerPointControlComponentのコンストラクタ
* @param manager マネージャオブジェクト
*/
PowerPointControl::PowerPointControl(RTC::Manager* manager)
// <rtc-template block="initializer">
: RTC::DataFlowComponentBase(manager),
m_SlideNumberInIn("SlideNumberIn", m_SlideNumberIn),
m_EffectNumberInIn("EffectNumberIn", m_EffectNumberIn),
m_PenIn("Pen", m_Pen),
m_SlideNumberOutOut("SlideNumberOut", m_SlideNumberOut)
// </rtc-template>
{
}
/*!
* @brief PowerPointControlComponentのデストラクタ
* @param manager マネージャオブジェクト
*/
PowerPointControl::~PowerPointControl()
{
}
/**
*@brief ファイル名のコンフィギュレーションパラメータ変更の関数
* @param FP ファイル名
*/
void PowerPointControl::SetFilePath(std::string FP)
{
coil::Properties file_confSet("default");
file_confSet.setProperty("file_path", FP.c_str());
this->m_configsets.setConfigurationSetValues(file_confSet);
this->m_configsets.activateConfigurationSet("default");
this->m_configsets.update("default", "file_path");
}
/**
* @brief コンフィギュレーションパラメータが更新されたときにファイルを再読み込みする関数
*/
void PowerPointControl::ConfigUpdate()
{
this->m_configsets.update("default","file_path");
//std::string sfn = Replace(file_path, "/", "\\");
coil::replaceString(file_path, "/", "\\");
System::String ^tfn = gcnew System::String(file_path.c_str());
//System::Console::WriteLine(tfn);
if (file_path == "NewFile")
{
PowerPointObject::Obj->Open("");
}
else if(PowerPointObject::Obj->filename != tfn)
{
PowerPointObject::Obj->Open(tfn);
}
}
/**
*@brief ファイル名の取得の関数
* @return ファイル名
*/
std::string PowerPointControl::getFileName()
{
return file_path;
}
/**
*@brief 初期化処理用コールバック関数
* @return RTC::ReturnCode_t
*/
RTC::ReturnCode_t PowerPointControl::onInitialize()
{
// Registration: InPort/OutPort/Service
// <rtc-template block="registration">
// Set InPort buffers
addInPort("SlideNumberIn", m_SlideNumberInIn);
addInPort("EffectNumberIn", m_EffectNumberInIn);
addInPort("Pen", m_PenIn);
// Set OutPort buffer
addOutPort("SlideNumberOut", m_SlideNumberOutOut);
// Set service provider to Ports
// Set service consumers to Ports
// Set CORBA Service Ports
// </rtc-template>
bindParameter("file_path", file_path, "NewFile");
bindParameter("SlideFileInitialNumber", SlideFileInitialNumber, "1");
bindParameter("SlideNumberInRelative", SlideNumberInRelative, "1");
/*std::string filePath = "";
coil::Properties& prop(::RTC::Manager::instance().getConfig());
getProperty(prop, "powerpoint.filename", filePath);
SetFilePath(filePath);*/
this->m_configsets.update("default", "file_path");
pt = new PowerPointTask(this);
pt->activate();
this->addConfigurationSetListener(ON_SET_CONFIG_SET, new PowerPointConfigUpdateParam(this));
return RTC::RTC_OK;
}
/*
RTC::ReturnCode_t PowerPointControl::onFinalize()
{
return RTC::RTC_OK;
}
*/
/*
RTC::ReturnCode_t PowerPointControl::onStartup(RTC::UniqueId ec_id)
{
return RTC::RTC_OK;
}
*/
/*
RTC::ReturnCode_t PowerPointControl::onShutdown(RTC::UniqueId ec_id)
{
return RTC::RTC_OK;
}
*/
/**
*@brief 活性化時のコールバック関数
* @param ec_id
* @return
*/
RTC::ReturnCode_t PowerPointControl::onActivated(RTC::UniqueId ec_id)
{
PowerPointObject::Obj->run();
PowerPointObject::Obj->gotoSlide(SlideFileInitialNumber);
slidenum = SlideFileInitialNumber;
return RTC::RTC_OK;
}
/**
*@brief 不活性化時のコールバック関数
* @param ec_id target ExecutionContext Id
* @return RTC::ReturnCode_t
*/
RTC::ReturnCode_t PowerPointControl::onDeactivated(RTC::UniqueId ec_id)
{
PowerPointObject::Obj->end();
return RTC::RTC_OK;
}
/**
*@brief 周期処理用コールバック関数
* @param ec_id target ExecutionContext Id
* @return RTC::ReturnCode_t
*/
RTC::ReturnCode_t PowerPointControl::onExecute(RTC::UniqueId ec_id)
{
if(m_SlideNumberInIn.isNew())
{
m_SlideNumberInIn.read();
if(SlideNumberInRelative == 0)
{
if(PowerPointObject::Obj->gotoSlide(m_SlideNumberIn.data))
slidenum = m_SlideNumberIn.data;
}
else
{
if(PowerPointObject::Obj->gotoSlide(slidenum+m_SlideNumberIn.data))
slidenum += m_SlideNumberIn.data;
}
m_SlideNumberOut.data = slidenum;
m_SlideNumberOutOut.write();
}
if(m_EffectNumberInIn.isNew())
{
m_EffectNumberInIn.read();
if(m_SlideNumberIn.data > 0)
{
for(int i=0;i < m_EffectNumberIn.data;i++)
{
PowerPointObject::Obj->next();
}
}
else
{
for(int i=0;i < -m_EffectNumberIn.data;i++)
{
PowerPointObject::Obj->previous();
}
}
}
if(m_PenIn.isNew())
{
m_PenIn.read();
int len = m_Pen.data.length();
for(int i=0;i < len/2;i++)
{
if(i == 0)
PowerPointObject::Obj->drawLine(m_Pen.data[i*2],m_Pen.data[i*2+1],m_Pen.data[i*2],m_Pen.data[i*2+1]);
else
PowerPointObject::Obj->drawLine(m_Pen.data[i*2-2],m_Pen.data[i*2-1],m_Pen.data[i*2],m_Pen.data[i*2+1]);
}
}
return RTC::RTC_OK;
}
/*
RTC::ReturnCode_t PowerPointControl::onAborting(RTC::UniqueId ec_id)
{
return RTC::RTC_OK;
}
*/
/*
RTC::ReturnCode_t PowerPointControl::onError(RTC::UniqueId ec_id)
{
return RTC::RTC_OK;
}
*/
/*
RTC::ReturnCode_t PowerPointControl::onReset(RTC::UniqueId ec_id)
{
return RTC::RTC_OK;
}
*/
/*
RTC::ReturnCode_t PowerPointControl::onStateUpdate(RTC::UniqueId ec_id)
{
return RTC::RTC_OK;
}
*/
/*
RTC::ReturnCode_t PowerPointControl::onRateChanged(RTC::UniqueId ec_id)
{
return RTC::RTC_OK;
}
*/
extern "C"
{
void PowerPointControlInit(RTC::Manager* manager)
{
coil::Properties profile(powerpointcontrol_spec);
manager->registerFactory(profile,
RTC::Create<PowerPointControl>,
RTC::Delete<PowerPointControl>);
}
};