mqsdx 310.0.1 MQPluginSDK Extention Library / mqsdkをC++またはCLI(.Net)拡張するサポートライブラリ

- メインページ
- 関連ページ
- モジュール
- クラス
- ファイル

- ファイル一覧

全て クラス 関数 変数 型定義 プロパティ グループ ページ
MQCLI.hpp
1 /*
2 First author tiritomato 2013.
3
4 mqsdx is distributed under the GNU Lesser General Public License 3.0(LGPLv3).
5
6 support blog (Japanese only)
7 http://d.hatena.ne.jp/tiri_tomato/
8 */
9
10 #pragma once
11
12 #ifdef __cplusplus_cli
13 #include "MQ0x.hpp"
14
16 namespace MQCLI {
17
18 #pragma region Interface
19
23 public interface class IActivate {
24 public: virtual BOOL Activate(MQDocument doc, BOOL flag);
25 };
26 public interface class IEnumFileExt {
27 public: virtual const char *EnumFileExt(int index);
28 };
29 public interface class IEnumFileType {
30 public: virtual const char *EnumFileType(int index);
31 };
32 public interface class IExecute {
33 public: virtual BOOL Execute(int index, MQDocument doc);
34 };
35 public interface class IExit {
36 public: virtual void Exit();
37 };
38 public interface class IExportFile {
39 public: virtual BOOL ExportFile(int index, const char *filename, MQDocument doc);
40 };
41 public interface class IImportFile {
42 public: virtual BOOL ImportFile(int index, const char *filename, MQDocument doc);
43 };
44 public interface class IInitialize {
45 public: virtual BOOL Initialize();
46 };
47 public interface class IIsActivated {
48 public: virtual BOOL IsActivated(MQDocument doc);
49 };
50 public interface class IOnMinimize {
51 public: virtual void OnMinimize(MQDocument doc, BOOL flag);
52 };
53 public interface class IOnReceiveUserMessage {
54 public: virtual int OnReceiveUserMessage(MQDocument doc, DWORD src_product, DWORD src_id, const char *description, void *message);
55 };
56 public interface class IOnDraw {
57 public: virtual void OnDraw(MQDocument doc, MQScene scene, int Width, int Height);
58 };
59 public interface class IOnNewDocument {
60 public: virtual void OnNewDocument(MQDocument doc, const char *filename, MQStationPlugin::NEW_DOCUMENT_PARAM& param);
61 };
62 public interface class IOnEndDocument {
63 public: virtual void OnEndDocument(MQDocument doc);
64 };
65 public interface class IOnSaveDocument {
66 public: virtual void OnSaveDocument(MQDocument doc, const char *filename, MQStationPlugin::SAVE_DOCUMENT_PARAM& param);
67 };
68 public interface class IOnUndo {
69 public: virtual BOOL OnUndo(MQDocument doc, int undo_state);
70 };
71 public interface class IOnRedo {
72 public: virtual BOOL OnRedo(MQDocument doc, int redo_state);
73 };
74 public interface class IOnUpdateUndo {
75 public: virtual void OnUpdateUndo(MQDocument doc, int undo_state, int undo_size);
76 };
77 public interface class IOnObjectModified {
78 public: virtual void OnObjectModified(MQDocument doc);
79 };
80 public interface class IOnObjectSelected {
81 public: virtual void OnObjectSelected(MQDocument doc);
82 };
83 public interface class IOnUpdateObjectList {
84 public: virtual void OnUpdateObjectList(MQDocument doc);
85 };
86 public interface class IOnMaterialModified {
87 public: virtual void OnMaterialModified(MQDocument doc);
88 };
89 public interface class IOnUpdateMaterialList {
90 public: virtual void OnUpdateMaterialList(MQDocument doc);
91 };
92 public interface class IOnUpdateScene {
93 public: virtual void OnUpdateScene(MQDocument doc, MQScene scene);
94 };
95 public interface class IExecuteCallback {
96 public: virtual bool ExecuteCallback(MQDocument doc, void *option);
97 };
98 public interface class IOnLeftButtonDown {
99 public: virtual BOOL OnLeftButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
100 };
101 public interface class IOnLeftButtonMove {
102 public: virtual BOOL OnLeftButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
103 };
104 public interface class IOnLeftButtonUp {
105 public: virtual BOOL OnLeftButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
106 };
107 public interface class IOnMiddleButtonDown {
108 public: virtual BOOL OnMiddleButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
109 };
110 public interface class IOnMiddleButtonMove {
111 public: virtual BOOL OnMiddleButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
112 };
113 public interface class IOnMiddleButtonUp {
114 public: virtual BOOL OnMiddleButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
115 };
116 public interface class IOnRightButtonDown {
117 public: virtual BOOL OnRightButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
118 };
119 public interface class IOnRightButtonMove {
120 public: virtual BOOL OnRightButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
121 };
122 public interface class IOnRightButtonUp {
123 public: virtual BOOL OnRightButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
124 };
125 public interface class IOnMouseMove {
126 public: virtual BOOL OnMouseMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
127 };
128 public interface class IOnMouseWheel {
129 public: virtual BOOL OnMouseWheel(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
130 };
131 public interface class IOnKeyDown {
132 public: virtual BOOL OnKeyDown(MQDocument doc, MQScene scene, int key, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
133 };
134 public interface class IOnKeyUp {
135 public: virtual BOOL OnKeyUp(MQDocument doc, MQScene scene, int key, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
136 };
137 public interface class IBasePlugin {
138 public: property MQBasePlugin* basePlugin { virtual MQBasePlugin* get(); }
139 };
141 #pragma endregion
142
145
155 public ref struct Lock {
156 public:
157 Lock( System::Object^ pObject );
158 ~Lock() { this->!Lock(); }
159 !Lock();
160 private:
161 System::Object^ m_pObject;
162 };
163
166 public ref class MQWndHandle : System::Windows::Forms::IWin32Window
167 {
168 public:
169 MQWndHandle() { m_Handle = (System::IntPtr)MQ_GetWindowHandle(); }
170 virtual property System::IntPtr Handle { System::IntPtr get() { return m_Handle; } }
171 static operator System::IntPtr ( MQWndHandle^ src ) {
172 if ( src != nullptr ) return src->Handle;
173 return System::IntPtr();
174 }
175 private:
176 System::IntPtr m_Handle;
177 };
179
180 namespace Drawing {
183
190 void DrawTriangle( System::Drawing::Graphics^ g, array<System::Drawing::Point>^ points, array<System::Drawing::Color>^ colors, float border_radius, bool isExcludeInside = true );
191
198 void DrawTriangle( System::Drawing::Graphics^ g, array<System::Drawing::PointF>^ points, array<System::Drawing::Color>^ colors, float border_radius, bool isExcludeInside = true );
199
204 void FillTriangle( System::Drawing::Graphics^ g, array<System::Drawing::Point>^ points, array<System::Drawing::Color>^ colors );
205
210 void FillTriangle( System::Drawing::Graphics^ g, array<System::Drawing::PointF>^ points, array<System::Drawing::Color>^ colors );
212 }
213
214 namespace Plugins {
215
217
218 template <typename T> class StationPluginDefaultTemplate : public T {
219 public:
220 StationPluginDefaultTemplate(){}
221 virtual void GetPlugInID(DWORD*,DWORD*) { }
222 virtual const char *GetPlugInName(void) { return NULL; }
223 virtual const char *EnumString(void) { return NULL; }
224 virtual BOOL Initialize() { return TRUE; }
225 virtual BOOL Activate(MQDocument doc, BOOL flag) { return TRUE; }
226 virtual void Exit() {}
227 typedef typename T::DRAW_OBJECT_VIISIBILITY DRAW_OBJECT_VIISIBILITY;
228 typedef typename T::SCENE_OPTION SCENE_OPTION;
229 MQObject CreateDrawingObject(MQDocument doc, typename T::DRAW_OBJECT_VIISIBILITY visibility, BOOL instant) {
230 return T::CreateDrawingObject(doc,visibility,instant);
231 }
232 MQMaterial CreateDrawingMaterial(MQDocument doc, int& index, BOOL instant) { return T::CreateDrawingMaterial(doc,index,instant); }
233 void DeleteDrawingObject(MQDocument doc, MQObject obj) { T::DeleteDrawingObject(doc,obj); }
234 void DeleteDrawingMaterial(MQDocument doc, MQMaterial mat) { T::DeleteDrawingMaterial(doc,mat); }
235 int GetCurrentUndoState(MQDocument doc) { return T::GetCurrentUndoState(doc); }
236 void GetSceneOption(MQScene scene, typename T::SCENE_OPTION& option) { T::GetSceneOption(scene,option); }
237 };
238 template <typename T> class CommandPluginDefaultTemplate : public StationPluginDefaultTemplate<T> {
239 public:
240 CommandPluginDefaultTemplate(){}
241 void UpdateUndo() { T::UpdateUndo(); }
242 void RedrawScene(MQScene scene) { T::RedrawScene(scene); }
243 void RedrawAllScene() { T::RedrawAllScene(); }
244 void GetEditOption(typename T::EDIT_OPTION& option) { T::GetEditOption(option); }
245 MQPoint GetSnappedPos(MQScene scene, const MQPoint& p, typename T::SNAP_GRID_TYPE type) { return T::GetSnappedPos(scene,p,type); }
246 BOOL HitTest(MQScene scene, POINT p, typename T::HIT_TEST_PARAM& param) { return T::HitTest(scene,p,param); }
247 HCURSOR GetResourceCursor(typename T::MQCURSOR_TYPE cursor_type) { return T::GetResourceCursor(cursor_type); }
248 void SetMouseCursor(HCURSOR cursor) { T::SetMouseCursor(cursor); }
249 void SetStatusString(const char *str) { T::SetStatusString(str); }
250 };
252 template <typename T> class PluginDefault;
253 template <> class PluginDefault<MQStationPlugin> : public StationPluginDefaultTemplate<MQStationPlugin> { public: PluginDefault(){} };
254 template <> class PluginDefault<MQCommandPlugin> : public CommandPluginDefaultTemplate<MQCommandPlugin> { public: PluginDefault(){} };
256 typedef PluginDefault<MQCommandPlugin> CommandPluginDefault;
258
260 public ref class PluginMainHolder {
261 public:
262 static bool Regist( IBasePlugin^ pluginBody );
263 static property MQBasePlugin* pluginMain { MQBasePlugin* get(); }
264 static BOOL Activate(MQDocument doc, BOOL flag);
265 static bool ExecuteCallback(MQDocument doc, void *option);
266 static void Exit();
267 static BOOL Initialize();
268 static BOOL IsActivated(MQDocument doc);
269 static void OnMinimize(MQDocument doc, BOOL flag);
270 static int OnReceiveUserMessage(MQDocument doc, DWORD src_product, DWORD src_id, const char *description, void *message);
271 static void OnDraw(MQDocument doc, MQScene scene, int Width, int Height);
272 static void OnNewDocument(MQDocument doc, const char *filename, MQStationPlugin::NEW_DOCUMENT_PARAM& param);
273 static void OnEndDocument(MQDocument doc);
274 static void OnSaveDocument(MQDocument doc, const char *filename, MQStationPlugin::SAVE_DOCUMENT_PARAM& param);
275 static BOOL OnUndo(MQDocument doc, int undo_state);
276 static BOOL OnRedo(MQDocument doc, int redo_state);
277 static void OnUpdateUndo(MQDocument doc, int undo_state, int undo_size);
278 static void OnObjectModified(MQDocument doc);
279 static void OnObjectSelected(MQDocument doc);
280 static void OnUpdateObjectList(MQDocument doc);
281 static void OnMaterialModified(MQDocument doc);
282 static void OnUpdateMaterialList(MQDocument doc);
283 static void OnUpdateScene(MQDocument doc, MQScene scene);
284 static BOOL OnLeftButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
285 static BOOL OnLeftButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
286 static BOOL OnLeftButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
287 static BOOL OnMiddleButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
288 static BOOL OnMiddleButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
289 static BOOL OnMiddleButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
290 static BOOL OnRightButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
291 static BOOL OnRightButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
292 static BOOL OnRightButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
293 static BOOL OnMouseMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
294 static BOOL OnMouseWheel(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
295 static BOOL OnKeyDown(MQDocument doc, MQScene scene, int key, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
296 static BOOL OnKeyUp(MQDocument doc, MQScene scene, int key, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
297 private:
298 static System::Object^ m_lock = gcnew System::Object();
299 static IBasePlugin^ m_pluginMain = nullptr;
300 static bool m_firstRequestFailedFlag = false;
301 };
303
305 template <typename T> class Adapter : public T {
306 public:
307 typedef T PluginType;
308 MQObject CreateDrawingObject( MQDocument doc, MQStationPlugin::DRAW_OBJECT_VIISIBILITY visibility, BOOL instant ) {
309 return T::CreateDrawingObject(doc,visibility,instant);
310 }
311 MQMaterial CreateDrawingMaterial( MQDocument doc, int& index, BOOL instant ) {
312 return T::CreateDrawingMaterial( doc, index, instant );
313 }
314 void DeleteDrawingObject(MQDocument doc, MQObject obj) { T::DeleteDrawingObject(doc,obj); }
315 void DeleteDrawingMaterial(MQDocument doc, MQMaterial mat) { T::DeleteDrawingMaterial(doc,mat); }
316 int GetCurrentUndoState(MQDocument doc) { return T::GetCurrentUndoState(doc); }
317 void GetSceneOption(MQScene scene, MQStationPlugin::SCENE_OPTION& option) { T::GetSceneOption(scene,option); }
318 void UpdateUndo() { T::UpdateUndo(); }
319 void RedrawScene(MQScene scene){ T::RedrawScene(scene); }
320 void RedrawAllScene() { T::RedrawAllScene(); }
321 void GetEditOption(MQCommandPlugin::EDIT_OPTION& option) { T::GetEditOption(option); }
322 MQPoint GetSnappedPos(MQScene scene, const MQPoint& p, MQCommandPlugin::SNAP_GRID_TYPE type) {
323 return T::GetSnappedPos(scene,p,type);
324 }
325 BOOL HitTest(MQScene scene, POINT p, MQCommandPlugin::HIT_TEST_PARAM& param) { return T::HitTest(scene, p, param); }
326 HCURSOR GetResourceCursor(MQCommandPlugin::MQCURSOR_TYPE cursor_type) { return T::GetResourceCursor(cursor_type); }
327 void SetMouseCursor(HCURSOR cursor) { T::SetMouseCursor(cursor); }
328 void SetStatusString(const char *str) { T::SetStatusString(str); }
329 private:
330 virtual BOOL Initialize() {
331 return PluginMainHolder::Initialize();
332 }
333 virtual bool ExecuteCallback(MQDocument doc, void *option) {
334 return PluginMainHolder::ExecuteCallback(doc, option);
335 }
336 virtual void Exit() {
337 PluginMainHolder::Exit();
338 }
339 virtual BOOL Activate(MQDocument doc, BOOL flag) {
340 return PluginMainHolder::Activate(doc, flag);
341 }
342 virtual BOOL IsActivated(MQDocument doc) {
343 return PluginMainHolder::IsActivated(doc);
344 }
345 virtual void OnMinimize(MQDocument doc, BOOL flag) {
346 PluginMainHolder::OnMinimize(doc, flag);
347 }
348 virtual int OnReceiveUserMessage(MQDocument doc, DWORD src_product, DWORD src_id, const char *description, void *message) {
349 return PluginMainHolder::OnReceiveUserMessage(doc, src_product, src_id, description, message);
350 }
351 virtual void OnDraw(MQDocument doc, MQScene scene, int Width, int Height) {
352 PluginMainHolder::OnDraw(doc, scene, Width, Height);
353 }
354 virtual void OnNewDocument(MQDocument doc, const char *filename, MQStationPlugin::NEW_DOCUMENT_PARAM& param) {
355 PluginMainHolder::OnNewDocument(doc, filename, param);
356 }
357 virtual void OnEndDocument(MQDocument doc) {
358 PluginMainHolder::OnEndDocument(doc);
359 }
360 virtual void OnSaveDocument(MQDocument doc, const char *filename, MQStationPlugin::SAVE_DOCUMENT_PARAM& param) {
361 PluginMainHolder::OnSaveDocument(doc, filename, param);
362 }
363 virtual BOOL OnUndo(MQDocument doc, int undo_state) {
364 return PluginMainHolder::OnUndo(doc, undo_state);
365 }
366 virtual BOOL OnRedo(MQDocument doc, int redo_state) {
367 return PluginMainHolder::OnRedo(doc, redo_state);
368 }
369 virtual void OnUpdateUndo(MQDocument doc, int undo_state, int undo_size) {
370 PluginMainHolder::OnUpdateUndo(doc, undo_state, undo_size);
371 }
372 virtual void OnObjectModified(MQDocument doc) {
373 PluginMainHolder::OnObjectModified(doc);
374 }
375 virtual void OnObjectSelected(MQDocument doc) {
376 PluginMainHolder::OnObjectSelected(doc);
377 }
378 virtual void OnUpdateObjectList(MQDocument doc) {
379 PluginMainHolder::OnUpdateObjectList(doc);
380 }
381 virtual void OnMaterialModified(MQDocument doc) {
382 PluginMainHolder::OnMaterialModified(doc);
383 }
384 virtual void OnUpdateMaterialList(MQDocument doc) {
385 PluginMainHolder::OnUpdateMaterialList(doc);
386 }
387 virtual void OnUpdateScene(MQDocument doc, MQScene scene) {
388 PluginMainHolder::OnUpdateScene(doc, scene);
389 }
390 };
392
394 class StationPluginsUnmanaged : public MQ0x::PluginBase<Adapter<MQStationPlugin>> {
395 public:
396 StationPluginsUnmanaged( const char* productName, const char* pluginFullName, const char* displayName, const DWORD idProduct, const DWORD idPlugin )
397 : PluginBase( productName, pluginFullName, displayName, idProduct, idPlugin )
398 {
399 }
400 };
401
402 class CommandPluginsUnmanaged : public MQ0x::PluginBase<Adapter<MQCommandPlugin>> {
403 public:
404 CommandPluginsUnmanaged( const char* productName, const char* pluginFullName, const char* displayName, const DWORD idProduct, const DWORD idPlugin )
405 : PluginBase( productName, pluginFullName, displayName, idProduct, idPlugin )
406 {
407 }
408 virtual BOOL IsActivated(MQDocument doc) {
409 return PluginMainHolder::IsActivated(doc);
410 }
411 virtual BOOL OnLeftButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
412 return PluginMainHolder::OnLeftButtonDown(doc, scene, state);
413 }
414 virtual BOOL OnLeftButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
415 return PluginMainHolder::OnLeftButtonMove(doc, scene, state);
416 }
417 virtual BOOL OnLeftButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
418 return PluginMainHolder::OnLeftButtonUp(doc, scene, state);
419 }
420 virtual BOOL OnMiddleButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
421 return PluginMainHolder::OnMiddleButtonDown(doc, scene, state);
422 }
423 virtual BOOL OnMiddleButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
424 return PluginMainHolder::OnMiddleButtonMove(doc, scene, state);
425 }
426 virtual BOOL OnMiddleButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
427 return PluginMainHolder::OnMiddleButtonUp(doc, scene, state);
428 }
429 virtual BOOL OnRightButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
430 return PluginMainHolder::OnRightButtonDown(doc, scene, state);
431 }
432 virtual BOOL OnRightButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
433 return PluginMainHolder::OnRightButtonMove(doc, scene, state);
434 }
435 virtual BOOL OnRightButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
436 return PluginMainHolder::OnRightButtonUp(doc, scene, state);
437 }
438 virtual BOOL OnMouseMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
439 return PluginMainHolder::OnMouseMove(doc, scene, state);
440 }
441 virtual BOOL OnMouseWheel(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
442 return PluginMainHolder::OnMouseWheel(doc, scene, state);
443 }
444 virtual BOOL OnKeyDown(MQDocument doc, MQScene scene, int key, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
445 return PluginMainHolder::OnKeyDown(doc, scene, key, state);
446 }
447 virtual BOOL OnKeyUp(MQDocument doc, MQScene scene, int key, MQCommandPlugin::MOUSE_BUTTON_STATE& state) {
448 return PluginMainHolder::OnKeyUp(doc, scene, key, state);
449 }
450 };
452
456 public ref class StationPluginsInterfacedBase abstract :
457 IActivate,
458 IExit,
459 IInitialize,
460 IExecuteCallback,
461 IIsActivated,
462 IOnMinimize,
463 IOnReceiveUserMessage,
464 IOnDraw,
465 IOnNewDocument,
466 IOnEndDocument,
467 IOnSaveDocument,
468 IOnUndo,
469 IOnRedo,
470 IOnUpdateUndo,
471 IOnObjectModified,
472 IOnObjectSelected,
473 IOnUpdateObjectList,
474 IOnMaterialModified,
475 IOnUpdateMaterialList,
476 IOnUpdateScene,
477 IBasePlugin
478 {
479 public:
480 virtual BOOL Activate(MQDocument doc, BOOL flag) { return TRUE; }
481 virtual void Exit() {}
482 virtual BOOL Initialize() { return TRUE; }
483 virtual bool ExecuteCallback(MQDocument doc, void *option);
484 virtual BOOL IsActivated(MQDocument doc);
485 virtual void OnMinimize(MQDocument doc, BOOL flag);
486 virtual int OnReceiveUserMessage(MQDocument doc, DWORD src_product, DWORD src_id, const char *description, void *message);
487 virtual void OnDraw(MQDocument doc, MQScene scene, int Width, int Height);
488 virtual void OnNewDocument(MQDocument doc, const char *filename, MQStationPlugin::NEW_DOCUMENT_PARAM& param);
489 virtual void OnEndDocument(MQDocument doc);
490 virtual void OnSaveDocument(MQDocument doc, const char *filename, MQStationPlugin::SAVE_DOCUMENT_PARAM& param);
491 virtual BOOL OnUndo(MQDocument doc, int undo_state);
492 virtual BOOL OnRedo(MQDocument doc, int redo_state);
493 virtual void OnUpdateUndo(MQDocument doc, int undo_state, int undo_size);
494 virtual void OnObjectModified(MQDocument doc);
495 virtual void OnObjectSelected(MQDocument doc);
496 virtual void OnUpdateObjectList(MQDocument doc);
497 virtual void OnMaterialModified(MQDocument doc);
498 virtual void OnUpdateMaterialList(MQDocument doc);
499 virtual void OnUpdateScene(MQDocument doc, MQScene scene);
500 property MQBasePlugin* basePlugin { virtual MQBasePlugin* get() abstract; }
501 int SendUserMessage(MQDocument doc, DWORD target_product, DWORD target_id, const char *description, void *param);
502 void WindowClose();
503 void BeginCallback(void *option);
504 void GetPlugInID(DWORD *Product, DWORD *ID);
505 property DWORD ProductID { DWORD get(); }
506 property DWORD PluginID { DWORD get(); }
507 const char* GetPlugInName();
508 int GetPlugInType();
509 const char* EnumString();
510 protected:
511 property MQStationPlugin* stationPlugin { virtual MQStationPlugin* get() abstract; }
512 };
513
517 public ref class CommandPluginsInterfacedBase abstract : StationPluginsInterfacedBase,
518 IOnLeftButtonDown,
519 IOnLeftButtonMove,
520 IOnLeftButtonUp,
521 IOnMiddleButtonDown,
522 IOnMiddleButtonMove,
523 IOnMiddleButtonUp,
524 IOnRightButtonDown,
525 IOnRightButtonMove,
526 IOnRightButtonUp,
527 IOnMouseMove,
528 IOnMouseWheel,
529 IOnKeyDown,
530 IOnKeyUp
531 {
532 public:
533 virtual BOOL OnLeftButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
534 virtual BOOL OnLeftButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
535 virtual BOOL OnLeftButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
536 virtual BOOL OnMiddleButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
537 virtual BOOL OnMiddleButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
538 virtual BOOL OnMiddleButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
539 virtual BOOL OnRightButtonDown(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
540 virtual BOOL OnRightButtonMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
541 virtual BOOL OnRightButtonUp(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
542 virtual BOOL OnMouseMove(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
543 virtual BOOL OnMouseWheel(MQDocument doc, MQScene scene, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
544 virtual BOOL OnKeyDown(MQDocument doc, MQScene scene, int key, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
545 virtual BOOL OnKeyUp(MQDocument doc, MQScene scene, int key, MQCommandPlugin::MOUSE_BUTTON_STATE& state);
546 };
547
556 template <class T_MANAGEDBASE, class T_UNMANAGED>
557 public ref class StationPluginTemplate : T_MANAGEDBASE {
558 public:
559 StationPluginTemplate( const char* productName, const char* pluginFullName, const char* displayName ) :
560 m_pluginBody( new T_UNMANAGED( productName, pluginFullName, displayName,
561 MQ0x::CollectionHashCode<DWORD>(productName), MQ0x::CollectionHashCode<DWORD>(pluginFullName) ) ) {}
562 StationPluginTemplate( const char* productName, const char* pluginFullName, const char* displayName, const DWORD idProduct, const DWORD idPlugin ) :
563 m_pluginBody( new T_UNMANAGED( productName, pluginFullName, displayName, idProduct, idPlugin ) ) {}
564
565 property MQBasePlugin* basePlugin { virtual MQBasePlugin* get() override { return static_cast<MQBasePlugin*>(m_pluginBody); } }
579 property MQ0x::SettingProxy::Handle Setting {
580 MQ0x::SettingProxy::Handle get() {
581 if ( m_pluginBody == NULL ) return NULL;
582 return m_pluginBody->BasePlugin();
583 }
584 }
585 protected:
586 typedef PluginDefault<typename T_UNMANAGED::PluginType> PluginDefault;
587 typedef typename PluginDefault::DRAW_OBJECT_VIISIBILITY DRAW_OBJECT_VIISIBILITY;
588 typedef typename PluginDefault::SCENE_OPTION SCENE_OPTION;
589 property MQStationPlugin* stationPlugin { virtual MQStationPlugin* get() override { return m_pluginBody; } }
590 property T_UNMANAGED* pluginBody { virtual T_UNMANAGED* get() { return m_pluginBody; } }
591 MQObject CreateDrawingObject( MQDocument doc, DRAW_OBJECT_VIISIBILITY visibility, BOOL instant ) {
592 if ( m_pluginBody != NULL ) return m_pluginBody->CreateDrawingObject(doc,visibility,instant);
593 return PluginDefault().CreateDrawingObject(doc,visibility,instant);
594 }
595 MQObject CreateDrawingObject( MQDocument doc, DRAW_OBJECT_VIISIBILITY visibility ) {
596 return CreateDrawingObject(doc,visibility,TRUE);
597 }
598 MQMaterial CreateDrawingMaterial( MQDocument doc, int& index, BOOL instant ) {
599 if ( m_pluginBody != NULL ) return m_pluginBody->CreateDrawingMaterial(doc,index,instant);
600 return PluginDefault().CreateDrawingMaterial(doc,index,instant);
601 }
602 MQMaterial CreateDrawingMaterial( MQDocument doc, int& index ) { return CreateDrawingMaterial(doc,index,TRUE); }
603 void DeleteDrawingObject(MQDocument doc, MQObject obj) {
604 if ( m_pluginBody != NULL ) m_pluginBody->DeleteDrawingObject(doc,obj);
605 PluginDefault().DeleteDrawingMaterial(doc,mat);
606 }
607 void DeleteDrawingMaterial(MQDocument doc, MQMaterial mat) {
608 if ( m_pluginBody != NULL ) m_pluginBody->DeleteDrawingMaterial(doc,mat);
609 PluginDefault().DeleteDrawingMaterial(doc,mat);
610 }
611 int GetCurrentUndoState(MQDocument doc) {
612 if ( m_pluginBody != NULL ) return m_pluginBody->GetCurrentUndoState(doc);
613 return PluginDefault().GetCurrentUndoState(doc);
614 }
615 void GetSceneOption(MQScene scene, SCENE_OPTION& option) { if ( m_pluginBody != NULL ) m_pluginBody->GetSceneOption(scene,option); }
616 private:
617 T_UNMANAGED *m_pluginBody;
618 };
619
620 public ref class StationPlugin : StationPluginTemplate<StationPluginsInterfacedBase,StationPluginsUnmanaged> {
621 public:
622 StationPlugin( const char* productName, const char* pluginFullName, const char* displayName ) :
623 StationPluginTemplate( productName, pluginFullName, displayName ) {}
624 StationPlugin( const char* productName, const char* pluginFullName, const char* displayName, const DWORD idProduct, const DWORD idPlugin ) :
625 StationPluginTemplate( productName, pluginFullName, displayName, idProduct, idPlugin ) {}
626 };
627
628 public ref class CommandPlugin : StationPluginTemplate<CommandPluginsInterfacedBase,CommandPluginsUnmanaged> {
629 public:
630 CommandPlugin( const char* productName, const char* pluginFullName, const char* displayName ) :
631 StationPluginTemplate( productName, pluginFullName, displayName ) {}
632 CommandPlugin( const char* productName, const char* pluginFullName, const char* displayName, const DWORD idProduct, const DWORD idPlugin ) :
633 StationPluginTemplate( productName, pluginFullName, displayName, idProduct, idPlugin ) {}
634 protected:
635 void UpdateUndo() {
636 if ( pluginBody != NULL ) pluginBody->UpdateUndo();
637 PluginDefault().UpdateUndo();
638 }
639 void RedrawScene(MQScene scene){
640 if ( pluginBody != NULL ) pluginBody->RedrawScene(scene);
641 PluginDefault().RedrawScene(scene);
642 }
643 void RedrawAllScene() {
644 if ( pluginBody != NULL ) pluginBody->RedrawAllScene();
645 PluginDefault().RedrawAllScene();
646 }
647 void GetEditOption(MQCommandPlugin::EDIT_OPTION& option) {
648 if ( pluginBody != NULL ) pluginBody->GetEditOption(option);
649 PluginDefault().GetEditOption(option);
650 }
651 MQPoint GetSnappedPos(MQScene scene, const MQPoint& p, MQCommandPlugin::SNAP_GRID_TYPE type) {
652 if ( pluginBody != NULL ) return pluginBody->GetSnappedPos(scene,p,type);
653 return PluginDefault().GetSnappedPos(scene,p,type);
654 }
655 BOOL HitTest(MQScene scene, POINT p, MQCommandPlugin::HIT_TEST_PARAM& param) {
656 if ( pluginBody != NULL ) return pluginBody->HitTest(scene, p, param);
657 return PluginDefault().HitTest(scene,p,param);
658 }
659 HCURSOR GetResourceCursor(MQCommandPlugin::MQCURSOR_TYPE cursor_type) {
660 if ( pluginBody != NULL ) return pluginBody->GetResourceCursor(cursor_type);
661 return PluginDefault().GetResourceCursor(cursor_type);
662 }
663 void SetMouseCursor(HCURSOR cursor) {
664 if ( pluginBody != NULL ) pluginBody->SetMouseCursor(cursor);
665 PluginDefault().SetMouseCursor(cursor);
666 }
667 void SetStatusString(const char *str) {
668 if ( pluginBody != NULL ) pluginBody->SetStatusString(str);
669 PluginDefault().SetStatusString(str);
670 }
671 };
672
673 }
674 using namespace Plugins;
675
679 bool Initialize( StationPlugin^ pluginBody );
681 bool Initialize( CommandPlugin^ pluginBody );
683
684 }
685
686 #endif