aced.h 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. //
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Copyright 2015 Autodesk, Inc. All rights reserved.
  5. //
  6. // Use of this software is subject to the terms of the Autodesk license
  7. // agreement provided at the time of installation or download, or which
  8. // otherwise accompanies this software in either electronic or hard copy form.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. //
  12. // DESCRIPTION: Header for Rx application definitions and C
  13. // access to AutoCAD Editor-specific services.
  14. //
  15. #ifndef _ACED_H
  16. #define _ACED_H
  17. #include "adesk.h"
  18. #include "rxevent.h" // AcRxEventReactor
  19. #include "acedinpt.h" //for ACAD_PORT
  20. #pragma pack (push, 8)
  21. struct IDispatch;
  22. /* Name of Registered Service Object for constructing AutoCAD-specific
  23. instances.
  24. */
  25. #define ACED_SERVICES ACRX_T("AcEdServices")
  26. #define ACED_EDITOR_OBJ ACRX_T("AcEditor")
  27. // The various modes for context menus.
  28. enum AcadContextMenuMode {
  29. kDefault = 0, // No selection set, no command active.
  30. kEdit, // Select set, no command active.
  31. kCommand, // Command active.
  32. kHotGrip, // Hot grip exists.
  33. kOsnap, // Shift key down.
  34. #ifdef _ADESK_MAC_
  35. kCMPaperSpace // In paper space.
  36. #endif
  37. };
  38. enum xrefSubcommandActivities
  39. {
  40. kStart = 0,
  41. kStartItem = 2,
  42. kEndItem = 3,
  43. kEnd = 4,
  44. kWillAbort = 5,
  45. kAborted = 6,
  46. kStartXBindBlock = 7,
  47. kStartXBindSymbol = 8
  48. };
  49. enum undoSubcommandActivities
  50. {
  51. kNone = 0,
  52. kOne = 1,
  53. kAll = 2
  54. };
  55. #pragma pack (pop)
  56. #include "accmd.h" // ACRX_CMD_DEFUN
  57. #pragma pack (push, 8)
  58. #if defined(__cplusplus)
  59. struct AcEdCommandStruc;
  60. class AcString;
  61. class AcRxVariable;
  62. class AcGiImageBGRA32;
  63. class AcEdImpSysVarIterator;
  64. extern "C" {
  65. #endif
  66. /* Given a string representing a command name, looks through stack of
  67. * registered command dictionaries and returns status indicating whether
  68. * a command of that name is registered. If a command is found, its
  69. * elements are returned in retStruc.
  70. * Returns TRUE if a command named <cmdStr> was found, FALSE if not.
  71. */
  72. int acedCmdLookup(const ACHAR* cmdStr, int globalLookup,
  73. AcEdCommandStruc* retStruc,
  74. int skipUndef = FALSE);
  75. int acedCmdLookup2(const ACHAR* cmdStr, int globalLookup,
  76. AcEdCommandStruc* retStruc,
  77. int sf = ACRX_CMD_DEFUN);
  78. /* Given a string representing a command name, looks throught stack of
  79. * registered command dictionaries and if found, changes the undefine
  80. * bit in the command flags.
  81. */
  82. int acedCmdUndefine(const ACHAR* cmdStr, int undefIt);
  83. /* Takes the input string and puts the command directory of that name
  84. * first in the search path for command name resolution by AutoCAD.
  85. * Returns TRUE if a dictionary named <cmdDirName> was found, FALSE if
  86. * not.
  87. */
  88. int acedPopCommandDirectory(const ACHAR* cmdDirName);
  89. /* Return the innermost current command for the given document */
  90. class AcApDocument;
  91. Acad::ErrorStatus acedGetCommandForDocument(AcApDocument* pDoc,
  92. ACHAR*& pGlobalCmdName);
  93. /* acedSetOLELock
  94. * Takes an integer argument as the lock code which must be used to
  95. * unlock the interface. This sets a soft lock meaning that people
  96. * can choose to ignore it, but only if they don't care about clobbering
  97. * the user or another app, or AutoCAD. If you call this function and
  98. * you get Adesk::kFalse, then you should not attempt to call AutoCAD
  99. * functions. If you get Adesk::kTrue, it means no other app or user
  100. * is active and it's okay for the caller to access the AutoCAD functions.
  101. * The second integer argument specifies the mode in which it is acceptable
  102. * to grab the lock. The mode bits are the same as those outlined in the
  103. * addCommand member for defining ARX commands. */
  104. Adesk::Boolean acedSetOLELock(int handle, int flags=0);
  105. /* acedClearOLELock
  106. * Takes an integer argument as the lock code which was used to set the
  107. * lock orriginally. If the lock codes don't match, then the operation
  108. * will fail and return Adesk::kFalse; If they match, it will return
  109. * Adesk::kTrue. Once the lock is cleared, another OLE application is
  110. * free to set the lock, so don't attempt to use the AutoCAD ADS functions
  111. * outside of a acedSetOLELock/acedClearOLELock section.
  112. */
  113. Adesk::Boolean acedClearOLELock(int handle);
  114. /* acedPostCommandPrompt
  115. * Causes AutoCAD to repost the last command prompt message. This is
  116. * used from OLE applications that are invoked without going through
  117. * the normal AutoCAD user interface. Call this function just prior
  118. * to exit from OLE app.
  119. */
  120. void acedPostCommandPrompt();
  121. #if defined(__cplusplus)
  122. }
  123. /* acedSyncFileOpen
  124. * Causes the file specified by pszFileToOpen to be synchronously opened
  125. * within the AutoCAD editor.
  126. */
  127. Acad::ErrorStatus acedSyncFileOpen(const ACHAR *pszFileToOpen,
  128. const wchar_t* wszPassword = NULL);
  129. /* Perform the SetColor dialog. Return TRUE on OK else FALSE
  130. * nColor : On entry the default color on exit of OK user chosen color
  131. * bAllowMetaColor : if TRUE the pseudo-colours "BYLAYER" and "BYBLOCK"
  132. * will be allowed
  133. * nCurLayerColor : is the color of the current layer, For use in the
  134. * color swatch if the color is set to "BYLAYER"
  135. */
  136. Adesk::Boolean acedSetColorDialog(int& nColor, Adesk::Boolean bAllowMetaColor,
  137. int nCurLayerColor);
  138. /* Perform the SetColor dialog. Return TRUE on OK else FALSE.
  139. * Similar to acedSetColorDialog, but capable of returning true colors.
  140. * color : On entry the default color on exit of OK user chosen color
  141. * bAllowMetaColor : if TRUE the pseudo-colours "BYLAYER" and "BYBLOCK"
  142. * will be allowed
  143. * curLayerColor : is the color of the current layer, For use in the
  144. * color swatch if the color is set to "BYLAYER"
  145. * tabs: specifies which selection method tabs to display to the user
  146. */
  147. Adesk::Boolean acedSetColorDialogTrueColor( AcCmColor& color, Adesk::Boolean bAllowMetaColor,
  148. const AcCmColor& curLayerColor, AcCm::DialogTabs tabs = (AcCm::DialogTabs)(AcCm::kACITab | AcCm::kTrueColorTab | AcCm::kColorBookTab) );
  149. #if defined(_ADESK_WINDOWS_)
  150. // We don't needs these for the OSX/GCC port.
  151. /* Defines a callback prototype to be used with the callback version of the
  152. * set color dialog.
  153. */
  154. typedef void (WINAPI* AcEdColorDialogCallbackFunction)(void *pCallbackData, const AcCmColor& newColor);
  155. /* Perform the SetColor dialog but with a callback. Return TRUE on OK else FALSE.
  156. * Similar to acedSetColorDialogTrueColor, but the caller receives callbacks on
  157. * each intermediate color selection.
  158. * color : On entry the default color on exit of OK user chosen color
  159. * bAllowMetaColor : if TRUE the pseudo-colours "BYLAYER" and "BYBLOCK"
  160. * will be allowed
  161. * curLayerColor : is the color of the current layer, For use in the
  162. * color swatch if the color is set to "BYLAYER"
  163. * tabs: specifies which selection method tabs to display to the user
  164. * callback: a method called for intermediate color selections
  165. * pCallbackData: context data for the callback method
  166. */
  167. Adesk::Boolean acedSetColorDialogTrueColorWithCallback( AcCmColor& color,
  168. Adesk::Boolean bAllowMetaColor,
  169. const AcCmColor& curLayerColor,
  170. AcCm::DialogTabs tabs = (AcCm::DialogTabs)(AcCm::kACITab | AcCm::kTrueColorTab | AcCm::kColorBookTab),
  171. AcEdColorDialogCallbackFunction callback = NULL,
  172. void * pCallbackData = NULL);
  173. #endif
  174. /* Prompt the user for a color on the command line. Return TRUE on OK else FALSE.
  175. * promptString : Part of the string for prompting the user for a true color. It
  176. * mesh into the form of "promptString [Truecolor/COlorbook]<byLayer>: ".
  177. * If it is NULL, it will default to "New Color".
  178. * color : On entry the default color on exit of OK user chosen color
  179. * If it is set to kNone, then it will default to the current color.
  180. * bAllowMetaColor : if TRUE the pseudo-colours "BYLAYER" and "BYBLOCK" will be allowed
  181. */
  182. Adesk::Boolean acedSetColorPrompt( ACHAR* promptString,
  183. AcCmColor& color,
  184. Adesk::Boolean bAllowMetaColor);
  185. /* Query if a specific menugroup is loaded in the current session
  186. * Return True if it is else False.
  187. */
  188. Adesk::Boolean acedIsMenuGroupLoaded(const ACHAR *pszGroupName);
  189. /* Loads a partial menu file.
  190. * Returns true if partial menu is successfully loaded.
  191. */
  192. bool acedLoadPartialMenu(const TCHAR* pszMenuFile);
  193. /* Unloads a partial menu file.
  194. * Returns true if partial menu is successfully unloaded.
  195. */
  196. bool acedUnloadPartialMenu(const TCHAR* pszMenuFile);
  197. /* Forces a reload of the currently loaded menus.
  198. * bIncrementalReloading : if true, menus will be reloaded incrementally.
  199. */
  200. void acedReloadMenus(bool bIncrementalReloading);
  201. /* Informs AutoCAD when a modeless application is starting and completing
  202. * some significant operation identified by strContext.
  203. */
  204. void acedSendModelessOperationStart(const ACHAR* strContext);
  205. void acedSendModelessOperationEnded(const ACHAR* strContext);
  206. /* acedUpdateDisplay
  207. * Asks AutoCAD to update its display screen immediately.
  208. * AutoCAD manages its display area in the most efficient way by
  209. * keeping track of which portions of screen get affected as you make
  210. * various call to AutoCAD. In general the calls you make will not
  211. * immediately be reflected in screen changes because AutoCAD will
  212. * conglomerate the calls and make them apparent at times that minimize
  213. * disturbances to the screen. When AutoCAD is not active or has no focus,
  214. * it will not update its display at all. If you're in a modeless dialog
  215. * and adding or updating an entity, the display won't show the changes
  216. * immediatley. Use this function to force AutoCAD to update its display.
  217. * While it might initially appear to be a good idea to call acedUpdateDisplay
  218. * frequently, there are two possible drawbacks.
  219. * First, it might incur undue processing overhead.
  220. * Secondly, frequent calls to correct the display might result in screen
  221. * flashing disturbing to the user.
  222. */
  223. void acedUpdateDisplay();
  224. /* acedUpdateDisplayPause
  225. * This function allows turning off display updates in order to hide
  226. * automated tasks from the user. All documents are affected by this
  227. * call. This call should not be enabled if any kind of drawing area
  228. * input is expected from the user. There are no additional
  229. * restrictions on what can be done in this paused state then there
  230. * would be if the display were not paused. Callers of this function
  231. * should first save the return value from acedUpdateDisplayPaused(),
  232. * then restore that value when finished pausing the display.
  233. */
  234. void acedUpdateDisplayPause (bool bEnable);
  235. /* acedIsUpdateDisplayPaused
  236. * Returns true if display updates are paused, false otherwise. This
  237. * function should be used before calling acedUpdateDisplayPause, to
  238. * record the current update display pause state and restore that when
  239. * finished pausing the display. This way, other users of
  240. * acedUpdateDisplayPause will not have the display re-enabled
  241. * prematurely.
  242. */
  243. bool acedIsUpdateDisplayPaused (void);
  244. /* This function sets an internal flag in AutoCAD so that when a command
  245. * that has a dialog that is normally not activated by LISP (such as
  246. * the PLOT command) is run, the dialog will be activated rather than
  247. * using the command line interface.
  248. *
  249. * Returns the value that the internal flag was set to before this function
  250. * was called.
  251. */
  252. Adesk::Boolean acedInitDialog(Adesk::Boolean useDialog = Adesk::kTrue);
  253. /////////////////////////////////////////////////////////////////////////////
  254. // This function sets a int variable in the current document establishing the
  255. // version of the command that will be run next. The return value is the
  256. // old version value. Calling this method will no argument will initialize the
  257. // value to 0, which indicates that no version has been established.
  258. /////////////////////////////////////////////////////////////////////////////
  259. //
  260. Adesk::UInt8 acedInitCommandVersion(Adesk::UInt8 nVersion = 0);
  261. /////////////////////////////////////////////////////////////////////////////
  262. // This function is used to query the requested version of the command currently
  263. // in progress. It does this by querying the version set at this depth of
  264. // the command version stack.
  265. /////////////////////////////////////////////////////////////////////////////
  266. //
  267. Adesk::UInt8 acedGetCommandVersion();
  268. void
  269. acedDisableDefaultARXExceptionHandler(Adesk::Boolean disable = Adesk::kTrue);
  270. Acad::ErrorStatus acedVportTableRecords2Vports();
  271. Acad::ErrorStatus acedVports2VportTableRecords();
  272. Acad::ErrorStatus
  273. acedVPLayer(const AcDbObjectId& vpId, const AcDbObjectIdArray& layerIds,
  274. AcDb::VpFreezeOps operation);
  275. #define acedServices \
  276. AcEdServices::cast(acrxServiceDictionary->at(ACED_SERVICES))
  277. class AcEdServices: public AcRxService
  278. {
  279. public:
  280. ACRX_DECLARE_MEMBERS(AcEdServices);
  281. virtual AcEdCommand* newAcEdCommand(AcRxFunctionPtr cmdFcnAddr,
  282. Adesk::Int32 cmdFlags) const = 0;
  283. };
  284. class AcDbDatabase;
  285. class AcEditorReactor: public AcRxEventReactor
  286. {
  287. public:
  288. ACRX_DECLARE_MEMBERS(AcEditorReactor);
  289. AcEditorReactor() : mVeto(0) {}
  290. // Command Events
  291. //
  292. virtual void unknownCommand (const ACHAR* cmdStr, AcDbVoidPtrArray *al);
  293. virtual void commandWillStart(const ACHAR* cmdStr);
  294. virtual void commandEnded (const ACHAR* cmdStr);
  295. virtual void commandCancelled(const ACHAR* cmdStr);
  296. virtual void commandFailed (const ACHAR* cmdStr);
  297. // Lisp Events
  298. //
  299. virtual void lispWillStart (const ACHAR* firstLine);
  300. virtual void lispEnded ();
  301. virtual void lispCancelled ();
  302. ADESK_DEPRECATED virtual void beginClose(AcDbDatabase* pDwg);
  303. // DXF In/Out Events.
  304. //
  305. virtual void beginDxfIn (AcDbDatabase*);
  306. virtual void abortDxfIn (AcDbDatabase*);
  307. virtual void dxfInComplete (AcDbDatabase*);
  308. //
  309. virtual void beginDxfOut (AcDbDatabase*);
  310. virtual void abortDxfOut (AcDbDatabase*);
  311. virtual void dxfOutComplete (AcDbDatabase*);
  312. // DWG Open Events.
  313. //
  314. virtual void beginDwgOpen (ACHAR* filename);
  315. virtual void endDwgOpen (const ACHAR* filename, AcDbDatabase* pDb);
  316. virtual void initialDwgFileOpenComplete(AcDbDatabase* pDwg);
  317. // DWG/Save Events.
  318. //
  319. virtual void dwgFileOpened(AcDbDatabase*, ACHAR* fileName);
  320. virtual void databaseConstructed(AcDbDatabase*);
  321. virtual void databaseToBeDestroyed(AcDbDatabase*);
  322. virtual void beginSave (AcDbDatabase*, const ACHAR* pIntendedName);
  323. virtual void saveComplete (AcDbDatabase*, const ACHAR* pActualName);
  324. virtual void abortSave (AcDbDatabase*);
  325. // Insert Events.
  326. //
  327. virtual void beginInsert(AcDbDatabase* pTo, const ACHAR* pBlockName,
  328. AcDbDatabase* pFrom);
  329. virtual void beginInsert(AcDbDatabase* pTo, const AcGeMatrix3d& xform,
  330. AcDbDatabase* pFrom);
  331. virtual void otherInsert(AcDbDatabase* pTo, AcDbIdMapping& idMap,
  332. AcDbDatabase* pFrom);
  333. virtual void abortInsert(AcDbDatabase* pTo);
  334. virtual void endInsert (AcDbDatabase* pTo);
  335. // Wblock Events.
  336. //
  337. virtual void wblockNotice(AcDbDatabase* pDb);
  338. virtual void beginWblock(AcDbDatabase* pTo, AcDbDatabase* pFrom,
  339. const AcGePoint3d*& insertionPoint);
  340. virtual void beginWblock(AcDbDatabase* pTo, AcDbDatabase* pFrom,
  341. AcDbObjectId blockId);
  342. virtual void beginWblock(AcDbDatabase* pTo, AcDbDatabase* pFrom);
  343. virtual void otherWblock(AcDbDatabase* pTo, AcDbIdMapping&,
  344. AcDbDatabase* pFrom);
  345. virtual void abortWblock(AcDbDatabase* pTo);
  346. virtual void endWblock (AcDbDatabase* pTo);
  347. // Deep Clone Events.
  348. //
  349. virtual void beginDeepClone (AcDbDatabase* pTo, AcDbIdMapping&);
  350. virtual void beginDeepCloneXlation(AcDbIdMapping&, Acad::ErrorStatus*);
  351. virtual void abortDeepClone (AcDbIdMapping&);
  352. virtual void endDeepClone (AcDbIdMapping&);
  353. // Sys Var Events.
  354. //
  355. virtual void sysVarChanged (const ACHAR* varName, Adesk::Boolean success);
  356. virtual void sysVarWillChange (const ACHAR* varName);
  357. // XREF-related Events
  358. //
  359. virtual void beginAttach (AcDbDatabase* pTo, const ACHAR*,
  360. AcDbDatabase* pFrom);
  361. virtual void otherAttach (AcDbDatabase* pTo, AcDbDatabase* pFrom);
  362. virtual void abortAttach (AcDbDatabase* pFrom);
  363. virtual void endAttach (AcDbDatabase* pTo);
  364. virtual void redirected (AcDbObjectId newId, AcDbObjectId oldId);
  365. virtual void comandeered (AcDbDatabase* pTo, AcDbObjectId id,
  366. AcDbDatabase* pFrom);
  367. virtual void beginRestore(AcDbDatabase* pTo, const ACHAR*,
  368. AcDbDatabase* pFrom);
  369. virtual void abortRestore(AcDbDatabase* pTo);
  370. virtual void endRestore (AcDbDatabase* pTo);
  371. // More XREF related Events
  372. //
  373. virtual void xrefSubcommandBindItem (AcDbDatabase* pHost, int activity, AcDbObjectId blockId);
  374. virtual void xrefSubcommandAttachItem (AcDbDatabase* pHost, int activity, const ACHAR* pPath);
  375. virtual void xrefSubcommandOverlayItem(AcDbDatabase* pHost, int activity, const ACHAR* pPath);
  376. virtual void xrefSubcommandDetachItem (AcDbDatabase* pHost, int activity, AcDbObjectId blockId);
  377. virtual void xrefSubcommandPathItem (int activity, AcDbObjectId blockId,
  378. const ACHAR* pNewPath);
  379. virtual void xrefSubcommandReloadItem (AcDbDatabase* pHost, int activity, AcDbObjectId blockId);
  380. virtual void xrefSubcommandUnloadItem (AcDbDatabase* pHost, int activity, AcDbObjectId blockId);
  381. // UNDO Events
  382. //
  383. virtual void undoSubcommandAuto (int activity, Adesk::Boolean state);
  384. virtual void undoSubcommandControl (int activity, int option);
  385. virtual void undoSubcommandBegin (int activity);
  386. virtual void undoSubcommandEnd (int activity);
  387. virtual void undoSubcommandMark (int activity);
  388. virtual void undoSubcommandBack (int activity);
  389. virtual void undoSubcommandNumber (int activity, int num);
  390. virtual void pickfirstModified();
  391. virtual void layoutSwitched(const ACHAR* newLayoutName);
  392. //window messages
  393. virtual void docFrameMovedOrResized(Adesk::LongPtr hwndDocFrame, bool bMoved);
  394. virtual void mainFrameMovedOrResized(Adesk::LongPtr hwndMainFrame, bool bMoved);
  395. //Mouse events
  396. virtual void beginDoubleClick(const AcGePoint3d& clickPoint);
  397. virtual void beginRightClick(const AcGePoint3d& clickPoint);
  398. // Toolbar Size changes
  399. virtual void toolbarBitmapSizeWillChange(Adesk::Boolean bLarge);
  400. virtual void toolbarBitmapSizeChanged(Adesk::Boolean bLarge);
  401. // WblockObjects - begin new pFrom database
  402. virtual void beginWblockObjects (AcDbDatabase* pFrom, AcDbIdMapping& );
  403. // Partial Open Events
  404. //
  405. virtual void partialOpenNotice(AcDbDatabase* pDb);
  406. virtual void objectsLazyLoaded(const AcDbObjectIdArray& idArray);
  407. // Quit Events
  408. virtual void beginQuit();
  409. virtual void quitAborted();
  410. virtual void quitWillStart();
  411. virtual void modelessOperationWillStart(const ACHAR* contextStr);
  412. virtual void modelessOperationEnded(const ACHAR* contextStr);
  413. virtual void cmdIUnkModified(const ACHAR* strCommand);
  414. /// <summary>
  415. ///
  416. /// Sends notification on the start of an xref subcommand. The xref
  417. /// subcommands are the ones in the following enum (aced.h):
  418. ///
  419. /// enum AcXrefSubCommand {
  420. /// kAttach,
  421. /// kBind,
  422. /// kDetach,
  423. /// kOverlay,
  424. /// kPath,
  425. /// kReload,
  426. /// kResolve,
  427. /// kUnload,
  428. /// kXBind
  429. /// };
  430. ///
  431. /// An application can veto the operation by returning a bad status,
  432. /// e.g. Acad::eVetoed.
  433. ///
  434. /// There are multiple output arguments, based on the subcommand.
  435. /// Subcommands like attach have all the arguments provided.
  436. /// Subcommands like Bind only supply the btrids.
  437. ///
  438. /// The rule for checking the output arguments is: Use the BtrIds first.
  439. /// The other two arguments may be empty.
  440. /// In subcommands like Path - the path in the Block Table Record could
  441. /// differ from the one in the paths argument - in which case - both
  442. /// could be used.
  443. ///
  444. /// </summary>
  445. ///
  446. /// <param name="subcmd">
  447. /// The subcommand which is about to start.
  448. /// </param>
  449. ///
  450. /// <param name="btrIds">
  451. /// The xref block table record ids. The primary output argument.
  452. /// </param>
  453. ///
  454. /// <param name="btrNames">
  455. /// Xref Block Table Record names.
  456. /// </param>
  457. ///
  458. /// <param name="paths">
  459. /// The path strings for the subcommand, if applicable.
  460. /// </param>
  461. ///
  462. /// <returns>
  463. /// Returns Acad::eOk if successful. If the application return an
  464. /// error status, the subcommand will be vetoed.
  465. /// </returns>
  466. ///
  467. /// <remarks>
  468. /// Though the btr names and path arguments seem redundant at times,
  469. /// they can help applications avoid open for write/open for read conflicts
  470. /// in case the subcommand already has the Block Table Record open.
  471. /// </remarks>
  472. ///
  473. virtual Acad::ErrorStatus xrefSubCommandStart(
  474. AcXrefSubCommand subcmd,
  475. const AcDbObjectIdArray& btrIds,
  476. const ACHAR* const * btrNames,
  477. const ACHAR* const * paths);
  478. /// <summary>
  479. /// Notification just before an Xref is locked via
  480. /// AcEdXrefFileLock::lockFile().
  481. /// </summary>
  482. ///
  483. /// <param name = "btrId">
  484. /// The xref block table record id that is to be locked.
  485. /// </param>
  486. ///
  487. virtual void preXrefLockFile(AcDbObjectId btrId);
  488. virtual void viewChanged();
  489. protected:
  490. Acad::ErrorStatus veto();
  491. private:
  492. Adesk::UInt8 mVeto;
  493. friend class AcEditorImp;
  494. };
  495. class AcEditorReactor2 : public AcEditorReactor
  496. {
  497. public:
  498. ACRX_DECLARE_MEMBERS(AcEditorReactor2);
  499. // One can call veto() during this notifcation to stop
  500. // AutoCAD from shutting down the document
  501. // This notification is fired *before* the legacy beginClose event
  502. virtual void beginDocClose(AcDbDatabase* /*pDwg*/) {}
  503. // docCloseAborted is fired to all reactors that received
  504. // the beginDocClose event when the last reactor vetos the close
  505. virtual void docCloseAborted(AcDbDatabase* /*pDwg*/) {}
  506. // This notification is fired at the same time as the legacy beginClose event
  507. virtual void docCloseWillStart(AcDbDatabase* /*pDwg*/) {}
  508. // Layout switch is about to occur
  509. virtual void layoutToBeSwitched (const ACHAR * /*oldLayoutName*/, const ACHAR * /*newLayoutName*/) {}
  510. // Drawing area has moved or resized
  511. virtual void dwgViewResized (Adesk::LongPtr /*hwndDwgView*/) {}
  512. };
  513. class CAdUiPathname;
  514. class AcEditorReactor3 : public AcEditorReactor2
  515. {
  516. public:
  517. ACRX_DECLARE_MEMBERS(AcEditorReactor3);
  518. // triggered at the end of drsubs.cpp, fullregen()
  519. virtual void fullRegenEnded(AcDbDatabase* /*pDb*/,
  520. const AcDbIntArray & /*regenedViewports*/) {}
  521. // Notify about upgrade and downgrade open. Currently upublished
  522. // apis.
  523. virtual void curDocOpenUpgraded(AcDbDatabase* /*pDb*/,
  524. const CAdUiPathname& /*filename*/)
  525. {}
  526. virtual void curDocOpenDowngraded(AcDbDatabase* /*pDb*/,
  527. const CAdUiPathname& /*filename*/)
  528. {}
  529. };
  530. #define acedEditor AcEditor::cast(acrxSysRegistry()->at(ACED_EDITOR_OBJ))
  531. class AcEditor: public AcRxEvent
  532. {
  533. public:
  534. ACRX_DECLARE_MEMBERS(AcEditor);
  535. virtual void addReactor (AcRxEventReactor * newObj) = 0;
  536. virtual void removeReactor(AcRxEventReactor * delObj) = 0;
  537. };
  538. class AcEdUIContext : public AcRxObject
  539. {
  540. public:
  541. ACRX_DECLARE_MEMBERS(AcEdUIContext);
  542. virtual void* getMenuContext(const AcRxClass *,
  543. const AcDbObjectIdArray&)=0;
  544. virtual void* getMenuContext(const AcRxClass*,
  545. const AcDbObjectIdArray&,
  546. const AcArray<AcDbFullSubentPathArray,
  547. AcArrayObjectCopyReallocator<AcDbFullSubentPathArray> >& subentIds);
  548. virtual void onCommand(Adesk::UInt32 ) =0;
  549. virtual void OnUpdateMenu();
  550. };
  551. Adesk::Boolean acedAddObjectContextMenu(AcRxClass *pClass,
  552. AcEdUIContext *pContext,
  553. const void *appId);
  554. Adesk::Boolean acedRemoveObjectContextMenu(AcRxClass *pClass,
  555. AcEdUIContext *pContext);
  556. Adesk::Boolean acedAddDefaultContextMenu(AcEdUIContext *pContext,
  557. const void *appId,
  558. const ACHAR* appName=NULL);
  559. Adesk::Boolean acedRemoveDefaultContextMenu(AcEdUIContext *pContext);
  560. bool acedSetCMBaseAlias(LPCTSTR strAlias, AcadContextMenuMode mode);
  561. LPCTSTR acedGetCMBaseAlias(AcadContextMenuMode mode);
  562. Acad::ErrorStatus acedMspace(); // in a layout, switch to mspace
  563. Acad::ErrorStatus acedPspace(); // in a layout, switch to pspace
  564. Acad::ErrorStatus acedSetCurrentVPort(int vpnumber);
  565. Acad::ErrorStatus acedSetCurrentVPort(const AcDbViewport* pVp);
  566. /* acedIsDragging
  567. * Indicates whether dragging is occurring in AutoCAD's editor.
  568. */
  569. int acedIsDragging(void);
  570. // Set the current view from an AcDbViewTableRecord.
  571. Acad::ErrorStatus
  572. acedSetCurrentView(AcDbViewTableRecord *pVwRec, AcDbViewport *pVP);
  573. // Restore a named view into current active viewport
  574. Acad::ErrorStatus acedRestoreCurrentView(const AcDbObjectId& namedViewId);
  575. short acedGetCurVportCircleSides();
  576. Acad::ErrorStatus acedSetCurVportCircleSides(short value);
  577. void acedGetCurVportPixelToDisplay(double& xFactor, double& yFactor);
  578. void acedGetCurVportScreenToDisplay(double& xFactor, double& yFactor);
  579. Acad::ErrorStatus acedSetCurrentUCS(const AcGeMatrix3d & mat);
  580. Acad::ErrorStatus acedGetCurrentUCS(AcGeMatrix3d& mat);
  581. Acad::ErrorStatus acedRestorePreviousUCS();
  582. class AcDbFcf;
  583. class AcDbMText;
  584. // Replaces the AcDbFcf::edit() method
  585. // pTol must be open for Write
  586. //
  587. void acedEditToleranceInteractive(AcDbFcf* pTol);
  588. // Replaces the AcDbMText::edit() method
  589. // pMText must be open at least for Read, preferably for Write
  590. int acedEditMTextInteractive(AcDbMText* pMText, bool useNewUI = false, bool allowTabs = false);
  591. enum DimstyleTabSuppressed {
  592. kSymbolsArrowsTabSuppressed = 0x01,
  593. kTextTabSuppressed = 0x02,
  594. kFitTabSuppressed = 0x04,
  595. kPrimaryTabSuppressed = 0x08,
  596. kAlternateTabSuppressed = 0x10,
  597. kToleranceTabSuppressed = 0x20
  598. };
  599. int acedEditDimstyleInteractiveEx(AcDbDatabase * pDb,
  600. AcDbDimStyleTableRecord * pRec,
  601. int familyType,
  602. const ACHAR* title = NULL,
  603. int tabCtrlFlags = 0);
  604. // AutoCAD color to RGB conversion function
  605. //
  606. Adesk::UInt32 acedGetRGB(int color);
  607. Acad::ErrorStatus acedGetCurrentSelectionSet(AcDbObjectIdArray& sset);
  608. // acedGetFullSubentPatsForCurrentSelection
  609. // Obtains the selected sub-entities on the entity specified in the current
  610. // selection set.
  611. // selectedObject - The AcDbObjectId (returned by a prior call to
  612. // acedGetCurrentSelectionSet) that may have selected
  613. // sub-entities.
  614. // selectedSubentities - The sub-entities, if any, currently selected
  615. // on the object.
  616. //
  617. // Returns Acad::eOk if successful and sub-entities are selected. Returns
  618. // Acad::eSubSelectionSetEmpty if the entity is in the current selection set
  619. // but has no sub-entities selected. Returns Acad::eKeyNotFound if the entity
  620. // is not in the current selection set.
  621. //
  622. Acad::ErrorStatus acedGetFullSubentPathsForCurrentSelection(
  623. const AcDbObjectId& selectedObject,
  624. AcDbFullSubentPathArray& selectedSubentities);
  625. class AcDbHatch;
  626. class AcDbEntity;
  627. // AutoCAD's IDispatch pointer
  628. #define acedGetIDispatch AcadGetIDispatch
  629. extern "C" IDispatch *acedGetIDispatch (BOOL bAddRef);
  630. // Get the current viewport id. Returns null id if no vports open.
  631. // The id returned will refer to a viewport entity (AcDbViewport) if
  632. // the editor is in layout mode. Otherwise, in tilemode, it will
  633. // refer to an AcDbViewportTableRecord object.
  634. //
  635. AcDbObjectId acedActiveViewportId();
  636. // Converts viewport number into an id. The id refers to a Viewport
  637. // entity (in layout mode) or to a ViewportTableRecord (in tile mode).
  638. // The int number is one returned by the CVPORT sysvar or by the
  639. // AcDbViewport::number() method.
  640. //
  641. AcDbObjectId acedViewportIdFromNumber(int nVpNum);
  642. // Returns the number of viewports in the current editor window.
  643. // Includes the paperspace viewport, when we're in layout mode.
  644. //
  645. int acedNumberOfViewports();
  646. // Get the current viewport ObjectId for the current layout's viewport.
  647. // Returns null id in tile mode. Note that acedActiveViewportId()
  648. // has the same functionality as this when in layout mode.
  649. AcDbObjectId acedGetCurViewportObjectId();
  650. // Replaces AcDbHatch::convertFrom()
  651. // pHatch must be a newly created, and open for write.
  652. // pEnt must be an AcDbBlockReference or AcDbSolid
  653. // If transferId is kTrue, the calling AcDbHatch will assume the
  654. // AcDbObjectId, handle, any extended entity data, extension dictionaries,
  655. // or reactors, as well as any hatch associativity of pEnt. This is the only
  656. // way the associativity with the boundary objects can be transferred. pEnt
  657. // will then be deleted and set to NULL. If transferId is kFalse, pEnt will
  658. // remain in the database as is and the caller is responsible for closing it.
  659. // The resulting AcDbHatch will not be database-resident, and as such, cannot
  660. // assume any of the associativity with pEnt's boundary objects. The caller
  661. // can later call pEnt->handOverTo() to exchange the new AcDbHatch for pEnt in
  662. // the database, but the associativity cannot be re-established.
  663. Acad::ErrorStatus
  664. acedConvertEntityToHatch(AcDbHatch* pHatch, AcDbEntity*& pEnt, bool transferId);
  665. enum AcHatchNotifier {
  666. kNobody = 0x00,
  667. kImpHatch = 0x01,
  668. kBoundary = 0x02,
  669. kHatchAndBoundary = (kImpHatch | kBoundary),
  670. kAddScale = 0x04
  671. };
  672. enum AcHatchEdReact
  673. {
  674. kStartHatchWatcher = 1,
  675. kSwapHatchId,
  676. kUpRootHatchWatcher,
  677. kDestroyHatchWatcher,
  678. kDisableNextStart,
  679. kRecomputeBoundary
  680. };
  681. Acad::ErrorStatus
  682. acedManageHatchEditorReactor(AcDbObjectId hatchId,
  683. AcHatchEdReact action,
  684. AcDbObjectId boundaryId = AcDbObjectId::kNull,
  685. AcHatchNotifier notifyType = kNobody,
  686. bool transformed = false);
  687. // DrawOrder Inheritance command type
  688. enum AcEdDrawOrderCmdType {
  689. kDrawOrderNone = 0,
  690. kDrawOrderBottom,
  691. kDrawOrderTop,
  692. kDrawOrderBelow,
  693. kDrawOrderAbove
  694. };
  695. // acedDrawOrderInherit() is called to set DrawOrder on the new childArray object(s).
  696. // It should be called after the childArray objects are added to the space/db, but before
  697. // they are regen'ed, so that they are regen'ed to the proper location the first time.
  698. // If "cmd" arg is kDrawOrderBelow or kDrawOrderAbove, then a valid parent id must be supplied, and
  699. // children objects are place either just below or just above the parent entity, visually.
  700. // If cmdtype passed in is Top or Bottom, parent entity can be NULL (and any value is ignored, since
  701. // the entity is being moving to the very top or bottom of DrawOrder.)
  702. // The parent and all child entities must all be in the same space (Model, Paper, or a given block).
  703. Acad::ErrorStatus acedDrawOrderInherit(AcDbObjectId parent,
  704. AcDbObjectIdArray &childArray,
  705. AcEdDrawOrderCmdType cmd);
  706. // acedCreateViewportByView
  707. //
  708. // This function creates a viewport for the given model view at the desired
  709. // location. It bases the size of the viewport on the scale factor and the
  710. // size of the model view, e.g. a model view 20 feet across and a scale of
  711. // 1 foot to 1/4 inch would yield a viewport that was 5 inches across on the
  712. // paper of the layout.
  713. //
  714. // This call assumes that the viewport is being created in the current
  715. // layout.
  716. Acad::ErrorStatus
  717. acedCreateViewportByView(AcDbDatabase *pDb,
  718. const AcDbObjectId& view,
  719. const AcGePoint2d& location,
  720. double scale,
  721. AcDbObjectId& viewportId);
  722. // acedCreateEnhancedViewportOnDrop
  723. //
  724. // This function creates an AcDbViewport in the current layout of the
  725. // current drawing database. It takes the referred to file, XREF's it in,
  726. // creates a viewport at the specified location at a size determined from
  727. // the view's model size combined with the scale factor, and sets the
  728. // viewports viewing parameters to those of the view, including the views
  729. // layer state. This method provides no user interaction.
  730. Acad::ErrorStatus
  731. acedCreateEnhancedViewportOnDrop(const ACHAR *filename,
  732. const ACHAR *viewName,
  733. const AcGePoint2d location,
  734. double scale,
  735. AcDbObjectId labelBlockId,
  736. AcDbObjectId& sheetViewId,
  737. AcDbObjectId& viewportId);
  738. Acad::ErrorStatus
  739. acedCreateEnhancedViewportOnDropDWG(const ACHAR *filename,
  740. AcDbExtents *extents,
  741. const AcGePoint2d location,
  742. double scale,
  743. AcDbObjectId labelBlockId,
  744. AcDbObjectId& sheetViewId,
  745. AcDbObjectId& viewportId);
  746. // acedGetUnitsValueString
  747. //
  748. // Returns the localized string used to represent an AcDb::UnitsValue to the
  749. // user.
  750. // The units parameter specifies the string to obtain the localized string for.
  751. // The method returns NULL if the units value provided is invalid.
  752. //
  753. const AcString* acedGetUnitsValueString (AcDb::UnitsValue units);
  754. /// <summary>
  755. /// This function computes the conversion factor that blocks and xrefs
  756. /// need to be scaled duing insertion to retain their size. So for example,
  757. /// if a block that is created using feet as its units is inserted into a drawing
  758. /// with inches as its units, the conversion will be 12.
  759. /// </summary>
  760. /// <param name="blkInsunits">Input units that the block is created with.</param>
  761. /// <param name="conversionFactor">Return the conversion factor between the block's
  762. /// units and the current drawing's units.</param>
  763. /// <returns>Returns true if a conversion factor was computed.</returns>
  764. bool acedGetUnitsConversion(AcDb::UnitsValue blkInsunits, double& conversionFactor);
  765. // acdbCanonicalToSystemRange
  766. //
  767. // Outputs a string to display a range of doubles, conforming to current editor settings.
  768. // The method returns false if the input string is empty or cannot be parsed.
  769. //
  770. bool acdbCanonicalToSystemRange(int eUnits, const AcString& strIn, AcString& strOut);
  771. // acdbSystemRangeToCanonical
  772. //
  773. // Outputs a canonical string representing a range of doubles, given a string which
  774. // represents that range using numbers conforming to current editor settings.
  775. // The method returns false if the input string is empty or cannot be parsed.
  776. //
  777. bool acdbSystemRangeToCanonical(int eUnits, const AcString& strIn, AcString& strOut);
  778. void acedEnableUsrbrk();
  779. void acedDisableUsrbrk();
  780. bool acedIsUsrbrkDisabled();
  781. bool acedIsInBackgroundMode();
  782. enum BlockEditModeFlags {
  783. kBlkEditModeNone = 0x0,
  784. kBlkEditModeActive = 0x01,
  785. kBlkEditModeOpen = 0x02,
  786. kBlkEditModeDirty = 0x04
  787. };
  788. unsigned int acedGetBlockEditMode();
  789. void acedOpenDocWindowsMinimized( bool bMinimized );
  790. bool acedCompareToCurrentViewport(const AcDbViewTableRecord *pVwRec);
  791. /// <summary>
  792. /// Provides the id of the last frame rendered in animations invoked from the
  793. /// ANIPATH command
  794. /// </summary>
  795. /// <returns>
  796. /// Returns 0 when ANIPATH animation is inactive. The first frame of an
  797. /// an ANIPATH animation returns 1, and subsequent frames increment by 1
  798. /// from the previous frame.
  799. /// </returns>
  800. Adesk::UInt32 acedGetAnimationFrameId(void);
  801. /// <summary>This function is used to show the constraint bars for a given
  802. /// set of constrained entities.</summary>
  803. /// <param name="subentPaths">Full sub-entity paths of entities for which
  804. /// constraint bars are to be shown.</param>
  805. /// <returns>Returns true if successful, or false otherwise.</returns>
  806. ACAD_PORT bool acedShowConstraintBar(AcDbFullSubentPathArray &subentPaths);
  807. /// <summary>This function is used to hide the constraint bars for a given
  808. /// set of constrained entities.</summary>
  809. /// <param name="subentPaths">Full sub-entity paths of entities for which
  810. /// constraint bars are to be hidden.</param>
  811. /// <returns>Returns true if successful, or false otherwise.</returns>
  812. ACAD_PORT bool acedHideConstraintBar(AcDbFullSubentPathArray &subentPaths);
  813. /// <summary>This function is used to show or hide the constraint bars for
  814. /// all constrained entities in the active document.</summary>
  815. /// <param name="bToShow">Set this to true to show constraint bars,
  816. /// set to false to hide constraint bars. </param>
  817. /// <returns>Returns true if successful, or false otherwise.</returns>
  818. ACAD_PORT bool acedShowConstraintBarForAll(bool bToShow);
  819. Acad::ErrorStatus acedTraceBoundary(const AcGePoint3d& seedPoint,
  820. bool detectIslands,
  821. AcDbVoidPtrArray& resultingBoundarySet);
  822. void acedSetDrawComplexShape (int val);
  823. int acedGetDrawComplexShape ();
  824. void acedSetRecursingLinetypeVectorGeneration (int val);
  825. int acedGetRecursingLinetypeVectorGeneration ();
  826. struct flagmat * acedGetComplexLineTypeTransformPtr();
  827. ACAD_PORT Acad::ErrorStatus acedAudit(AcDbDatabase* pDb, bool bFixErrors, bool bCmdLnEcho = false);
  828. /// <summary>
  829. /// Adds a supplemental cursor image. Only one cursor badge image can be shown at a time.
  830. /// If multiple features supply badges the last badge with the highest priorityOrder will
  831. /// be the badge shown.
  832. /// </summary>
  833. /// <param name="pSuppCursorImage">Input image</param>
  834. /// <param name="priorityOrder">Stacking order badge should appear in. Higher numbers win.</param>
  835. /// <returns>Returns true if successful.</returns>
  836. ACAD_PORT bool acedAddSupplementalCursorImage(const AcGiImageBGRA32* pSuppCursorImage, int priorityOrder = 0);
  837. /// <summary>
  838. /// Removes a previously added supplemental cursor badge.
  839. /// </summary>
  840. /// <param name="pSuppCursorImage">Input image</param>
  841. /// <returns>Returns true if successful.</returns>
  842. ACAD_PORT bool acedRemoveSupplementalCursorImage(const AcGiImageBGRA32* pSuppCursorImage);
  843. /// <summary>
  844. /// Checks if the current supplemental cursor badge is set.
  845. /// </summary>
  846. /// <returns>Returns true if there is supplemental cursor badge; otherwise false.</returns>
  847. ACAD_PORT bool acedHasSupplementalCursorImage();
  848. /// <summary>
  849. /// Sets <x, y> to be the cursor offset to the top right corner of the pickbox.
  850. /// </summary>
  851. /// <param name="x">Input X offset</param>
  852. /// <param name="y">Input Y offset</param>
  853. ACAD_PORT void acedSetSupplementalCursorOffset(int x, int y);
  854. /// <summary>
  855. /// Gets the cursor offset <x, y>, which is to the top right corner of the pickbox.
  856. /// </summary>
  857. /// <param name="x">X offset</param>
  858. /// <param name="y">Y offset</param>
  859. ACAD_PORT void acedGetSupplementalCursorOffset(int& x, int& y);
  860. class AcEdSysVarIterator
  861. {
  862. public:
  863. ACAD_PORT AcEdSysVarIterator();
  864. ACAD_PORT ~AcEdSysVarIterator();
  865. ACAD_PORT void step();
  866. ACAD_PORT const AcRxVariable* getSysVar();
  867. ACAD_PORT void reset();
  868. ACAD_PORT bool done() const;
  869. private:
  870. AcEdImpSysVarIterator* m_pImp;
  871. };
  872. #endif // cplusplus
  873. #pragma pack (pop)
  874. #endif