CFx SDK Documentation  2022 SP0
EditorImpl.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 
25 
26 
27 #ifndef _ODEDITORIMPL_H_INCLUDED_
28 #define _ODEDITORIMPL_H_INCLUDED_
29 
30 #include "TD_PackPush.h"
31 
32 #include "Editor.h"
33 
39 //FELIX_CHANGE_BEGIN
40 
41 #ifdef XENON
42 TOOLKIT_EXPORT void fxReportReactorExceptionImpl( unsigned iReactorIdx, OdRxObject* pReactor, const char * szMethod, const OdError& err);
43 #define FX_SAFE_CALL_REACTOR_EVENT_IMPL(reactor, method, params, index) \
44 try { \
45  reactor->method params; \
46 } catch (const OdError& err ) { \
47  fxReportReactorExceptionImpl( index, reactor.get(), #method, err ); \
48 }
49 #else
50 #define FX_SAFE_CALL_REACTOR_EVENT_IMPL(reactor, method, params, index) { reactor->method params; }
51 #endif
52 
53 #include "FxDbExtension.h"
54 
55 #ifdef XENON
56 #define FX_BEGIN_MAIN_THREAD()
57 #define FX_END_MAIN_THREAD()
58 #else
59 #define FX_BEGIN_MAIN_THREAD() \
60  CFxDbExtension::StaticExecuteInMainThread( [&]() {
61 #define FX_END_MAIN_THREAD() \
62  } );
63 #endif
64 
65 #define RXEVENT_FIRE(method, inparams, params) \
66 inline void fire_##method inparams \
67 { \
68  FX_BEGIN_MAIN_THREAD(); \
69  TD_AUTOLOCK( m_mutex ); \
70  ++m_EventCounter; \
71  try \
72  { \
73  unsigned i, size = m_reactors.size(); \
74  for (i = 0; i < size; ++i) \
75  { \
76  if (!m_reactors[i].isNull()) \
77  { \
78  FX_SAFE_CALL_REACTOR_EVENT_IMPL( m_reactors[i], method, params, i ) \
79  } \
80  } \
81  } \
82  catch( ... ) \
83  { \
84  --m_EventCounter; \
85  throw; \
86  } \
87  if (!(--m_EventCounter))\
88  while( m_reactors.remove(OdRxEventReactorPtr()) );\
89  FX_END_MAIN_THREAD(); \
90 }
91 
92 #define EDEVENT_FIRE(method, inparams, params) \
93 inline void fire_##method inparams \
94 { \
95  FX_BEGIN_MAIN_THREAD(); \
96  TD_AUTOLOCK( m_mutex ); \
97  ++m_EventCounter; \
98  try \
99  { \
100  unsigned i, size = m_reactors.size(); \
101  for (i = 0; i < size; ++i) \
102  { \
103  if (!m_reactors[i].isNull())\
104  {\
105  OdEditorReactorPtr pReactor = OdEditorReactor::cast(m_reactors[i]); \
106  if (pReactor.get()) \
107  { \
108  FX_SAFE_CALL_REACTOR_EVENT_IMPL( pReactor, method, params, i ) \
109  } \
110  }\
111  } \
112  } \
113  catch( ... ) \
114  { \
115  --m_EventCounter; \
116  throw; \
117  } \
118  if (!(--m_EventCounter))\
119  while( m_reactors.remove(OdRxEventReactorPtr()) );\
120  FX_END_MAIN_THREAD(); \
121 }
122 //FELIX_CHANGE_END
123 
130 {
131 //FELIX_CHANGE_BEGIN
132 protected:
134 public:
137 public:
138  OdRxEventImpl() : m_EventCounter(0) {}
139 //FELIX_CHANGE_END
141 
142  void addReactor(OdRxEventReactor* pReactor);
144 
145  // notifiers
146  RXEVENT_FIRE(dwgFileOpened, (OdDbDatabase* db, const OdString& filename),(db, filename))
147  RXEVENT_FIRE(initialDwgFileOpenComplete, (OdDbDatabase* db), (db))
148  RXEVENT_FIRE(databaseConstructed, (OdDbDatabase* db), (db))
149  RXEVENT_FIRE(databaseToBeDestroyed, (OdDbDatabase* db), (db))
150  RXEVENT_FIRE(beginSave, (OdDbDatabase* db, const OdString& pIntendedName), (db, pIntendedName))
151  RXEVENT_FIRE(saveComplete, (OdDbDatabase* db, const OdString& pActualName), (db, pActualName))
152  RXEVENT_FIRE(abortSave, (OdDbDatabase* db), (db))
153  // DXF In/Out Events.
154  RXEVENT_FIRE(beginDxfIn, (OdDbDatabase* db), (db))
155  RXEVENT_FIRE(abortDxfIn, (OdDbDatabase* db), (db))
156  RXEVENT_FIRE(dxfInComplete, (OdDbDatabase* db), (db))
157  //
158  RXEVENT_FIRE(beginDxfOut, (OdDbDatabase* db), (db))
159  RXEVENT_FIRE(abortDxfOut, (OdDbDatabase* db), (db))
160  RXEVENT_FIRE(dxfOutComplete, (OdDbDatabase* db), (db))
161  // Insert Events.
162  RXEVENT_FIRE(beginInsert, (OdDbDatabase* pTo, const OdString& pBlockName, OdDbDatabase* pFrom), (pTo, pBlockName, pFrom))
163  RXEVENT_FIRE(beginInsert, (OdDbDatabase* pTo, const OdGeMatrix3d& xform, OdDbDatabase* pFrom), (pTo, xform, pFrom))
164  RXEVENT_FIRE(otherInsert, (OdDbDatabase* pTo, OdDbIdMapping& idMap, OdDbDatabase* pFrom), (pTo, idMap, pFrom))
165  RXEVENT_FIRE(abortInsert, (OdDbDatabase* pTo), (pTo))
166  RXEVENT_FIRE(endInsert, (OdDbDatabase* pTo), (pTo))
167 
168  // Wblock Events.
169  RXEVENT_FIRE(wblockNotice, (OdDbDatabase* pDb), (pDb))
170  RXEVENT_FIRE(beginWblock, (OdDbDatabase* pTo, OdDbDatabase* pFrom, const OdGePoint3d& insertionPoint), (pTo, pFrom, insertionPoint))
171  RXEVENT_FIRE(beginWblock, (OdDbDatabase* pTo, OdDbDatabase* pFrom, OdDbObjectId blockId), (pTo, pFrom, blockId))
172  RXEVENT_FIRE(beginWblock, (OdDbDatabase* pTo, OdDbDatabase* pFrom), (pTo, pFrom))
173  RXEVENT_FIRE(otherWblock, (OdDbDatabase* pTo, OdDbIdMapping& m, OdDbDatabase* pFrom), (pTo, m, pFrom))
174  RXEVENT_FIRE(abortWblock, (OdDbDatabase* pTo), (pTo))
175  RXEVENT_FIRE(endWblock, (OdDbDatabase* pTo), (pTo))
176  RXEVENT_FIRE(beginWblockObjects, (OdDbDatabase* pDb, OdDbIdMapping& m), (pDb, m))
177 
178  // Deep Clone Events.
179  RXEVENT_FIRE(beginDeepClone, (OdDbDatabase* pTo, OdDbIdMapping& m), (pTo, m))
180  RXEVENT_FIRE(beginDeepCloneXlation, (OdDbIdMapping& m), (m))
181  RXEVENT_FIRE(abortDeepClone, (OdDbIdMapping& m), (m))
182  RXEVENT_FIRE(endDeepClone, (OdDbIdMapping& m), (m))
183 
184  // Partial Open Events.
185  RXEVENT_FIRE(partialOpenNotice, (OdDbDatabase* pDb), (pDb))
186 
187  //
188  // OdEditorReactor events.
189  //
190  // file events
191  EDEVENT_FIRE(beginDwgOpen, (const OdString& filename), (filename))
192  EDEVENT_FIRE(endDwgOpen, (const OdString& filename), (filename))
193  EDEVENT_FIRE(beginClose, (OdDbDatabase* pDb), (pDb))
194 
195  // xref events
196  EDEVENT_FIRE(beginAttach, (OdDbDatabase* pToDb, const OdString& filename, OdDbDatabase* pFromDb), (pToDb, filename, pFromDb))
197  EDEVENT_FIRE(otherAttach, (OdDbDatabase* pToDb, OdDbDatabase* pFromDb), (pToDb, pFromDb))
198  EDEVENT_FIRE(abortAttach, (OdDbDatabase* pFromDb), (pFromDb))
199  EDEVENT_FIRE(endAttach, (OdDbDatabase* pToDb), (pToDb))
200  EDEVENT_FIRE(redirected, (OdDbObjectId newId, OdDbObjectId oldId), (newId, oldId))
201  EDEVENT_FIRE(comandeered, (OdDbDatabase* pToDb, OdDbObjectId id, OdDbDatabase* pFromDb), (pToDb, id, pFromDb))
202  EDEVENT_FIRE(beginRestore, (OdDbDatabase* pToDb, const OdString& filename, OdDbDatabase* pFromDb), (pToDb, filename, pFromDb))
203  EDEVENT_FIRE(abortRestore, (OdDbDatabase* pToDb), (pToDb))
204  EDEVENT_FIRE(endRestore, (OdDbDatabase* pToDb), (pToDb))
205 
206  // xref subcommand events
207  EDEVENT_FIRE(xrefSubcommandBindItem, (int activity, OdDbObjectId blockId), (activity, blockId))
208  EDEVENT_FIRE(xrefSubcommandAttachItem, (int activity, const OdString& xrefPath), (activity, xrefPath))
209  EDEVENT_FIRE(xrefSubcommandOverlayItem, (int activity, const OdString& xrefPath), (activity, xrefPath))
210  EDEVENT_FIRE(xrefSubcommandDetachItem, (int activity, OdDbObjectId blockId), (activity, blockId))
211  EDEVENT_FIRE(xrefSubcommandPathItem, (int activity, OdDbObjectId blockId, const OdString& newPath), (activity, blockId, newPath))
212  EDEVENT_FIRE(xrefSubcommandReloadItem, (int activity, OdDbObjectId blockId), (activity, blockId))
213  EDEVENT_FIRE(xrefSubcommandUnloadItem, (int activity, OdDbObjectId blockId), (activity, blockId))
214 
215  // command undo events
216  EDEVENT_FIRE(undoSubcommandAuto, (int activity, bool state), (activity, state))
217  EDEVENT_FIRE(undoSubcommandControl,(int activity, int option), (activity, option))
218  EDEVENT_FIRE(undoSubcommandBegin, (int activity), (activity))
219  EDEVENT_FIRE(undoSubcommandEnd, (int activity), (activity))
220  EDEVENT_FIRE(undoSubcommandMark, (int activity), (activity))
221  EDEVENT_FIRE(undoSubcommandBack, (int activity), (activity))
222  EDEVENT_FIRE(undoSubcommandNumber, (int activity, int num), (activity, num))
223 
224  // pickfirst selection event
225  EDEVENT_FIRE(pickfirstModified, (), ())
226 
227  // layout event
228  EDEVENT_FIRE(layoutSwitched, (const OdString& newLayoutName), (newLayoutName))
229 
230  // window events
231  EDEVENT_FIRE(docFrameMovedOrResized, (OdHWnd hwndDocFrame, bool moved), (hwndDocFrame, moved))
232  EDEVENT_FIRE(mainFrameMovedOrResized, (OdHWnd hwndMainFrame, bool moved), (hwndMainFrame, moved))
233 
234  // mouse events
235  EDEVENT_FIRE(beginDoubleClick, (const OdGePoint3d& clickPoint), (clickPoint))
236  EDEVENT_FIRE(beginRightClick, (const OdGePoint3d& clickPoint), (clickPoint))
237 
238  // toolbar events
239  EDEVENT_FIRE(toolbarBitmapSizeWillChange, (bool largeBitmaps), (largeBitmaps))
240  EDEVENT_FIRE(toolbarBitmapSizeChanged, (bool largeBitmaps), (largeBitmaps))
241 
242  // partial open events
243  EDEVENT_FIRE(objectsLazyLoaded, (const OdDbObjectIdArray& objectIds), (objectIds))
244 
245  // quit events
246  EDEVENT_FIRE(beginQuit, (), ())
247  EDEVENT_FIRE(quitAborted, (), ())
248  EDEVENT_FIRE(quitWillStart, (), ())
249 
250  // modeless operation events
251  EDEVENT_FIRE(modelessOperationWillStart, (const OdString& contextString), (contextString))
252  EDEVENT_FIRE(modelessOperationEnded, (const OdString& contextString), (contextString))
253 
254  // SysVar events
255  EDEVENT_FIRE( sysVarChanged, (OdDbDatabase* pDb, const OdString& varName),(pDb, varName))
256  EDEVENT_FIRE( sysVarWillChange, (OdDbDatabase* pDb, const OdString& varName), (pDb, varName))
257 };
258 
260 
266 {
267 public:
270 };
271 
273 
274 #include "TD_PackPop.h"
275 
276 #endif // _ODEDITORIMPL_H_INCLUDED_
277 
#define TOOLKIT_EXPORT
Definition: DbExport.h:40
OdSmartPtr< OdEditorImpl > OdEditorImplPtr
Definition: EditorImpl.h:272
#define RXEVENT_FIRE(method, inparams, params)
Definition: EditorImpl.h:65
#define EDEVENT_FIRE(method, inparams, params)
Definition: EditorImpl.h:92
int OdRefCounter
Definition: OdMutex.h:436
ptrdiff_t OdHWnd
ODRX_DECLARE_MEMBERS(OdEditorImpl)
OdArray< OdRxEventReactorPtr > m_reactors
Definition: EditorImpl.h:135
void addReactor(OdRxEventReactor *pReactor)
RXEVENT_FIRE(dwgFileOpened,(OdDbDatabase *db, const OdString &filename),(db, filename)) RXEVENT_FIRE(initialDwgFileOpenComplete
ODRX_DECLARE_MEMBERS(OdRxEventImpl)
OdRefCounter m_EventCounter
Definition: EditorImpl.h:133
OdMutex m_mutex
Definition: EditorImpl.h:136
void removeReactor(OdRxEventReactor *pReactor)