zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
/////////////////////////////////////////////////////////////////////////////// 
// Copyright (C) 2002-2016, Open Design Alliance (the "Alliance"). 
// All rights reserved. 
// 
// This software and its documentation and related materials are owned by 
// the Alliance. The software may only be incorporated into application 
// programs owned by members of the Alliance, subject to a signed 
// Membership Agreement and Supplemental Software License Agreement with the
// Alliance. The structure and organization of this software are the valuable  
// trade secrets of the Alliance and its suppliers. The software is also 
// protected by copyright law and international treaty provisions. Application  
// programs incorporating this software must include the following statement 
// with their copyright notices:
//   
//   This application incorporates Teigha(R) software pursuant to a license 
//   agreement with Open Design Alliance.
//   Teigha(R) Copyright (C) 2002-2016 by Open Design Alliance. 
//   All rights reserved.
//
// By use of this software, its documentation or related materials, you 
// acknowledge and accept the above terms.
///////////////////////////////////////////////////////////////////////////////
 
 
 
 
#ifndef _ODDB_BASEHOSTAPPSERVICES_INCLUDED_
#define _ODDB_BASEHOSTAPPSERVICES_INCLUDED_
 
 
#include "TD_PackPush.h"
 
 
#include "DbRootExport.h"
#include "DbBaseDatabase.h"
#include "DbHostAppProgressMeter.h"
#include "RxObject.h"
#include "SmartPtr.h"
#include "OdFont.h"
 
class OdGsDevice;
/** \details
  This template class is a specialization of the OdSmartPtr class for OdGsDevice object pointers.
*/
typedef OdSmartPtr<OdGsDevice> OdGsDevicePtr;
 
class OdDbUndoController;
/** \details
  This template class is a specialization of the OdSmartPtr class for OdDbUndoController object pointers.
*/
typedef OdSmartPtr<OdDbUndoController> OdDbUndoControllerPtr;
 
class OdAuditInfo;
class OdTtfDescriptor;
 
 
typedef unsigned long LCID;
 
enum OdSDIValues
{
  kMDIEnabled             = 0,
  kSDIUserEnforced        = 1,
  kSDIAppEnforced         = 2,
  kSDIUserAndAppEnforced  = 3
};
 
enum ProdIdCode
{
  kProd_ACAD = 1, // Plain
  kProd_LT   = 2, // Lite
  kProd_OEM  = 3, // OEM
  kProd_OdDb = 4  // ..
};
 
 
/** \details
    This class is the base class for platform specific operations within Teigha.
 
    Library: TD_Db
 
    <group OdDb_Classes>
*/
class ODRX_ABSTRACT DBROOT_EXPORT OdDbBaseHostAppServices : public OdRxObject
{
public:
  ODRX_DECLARE_MEMBERS(OdDbBaseHostAppServices);
 
  OdDbBaseHostAppServices();
 
  enum RemapFileContext
  {
    kDrawingOpen        = 0,
    kXrefResolution     = 1,
    kRasterResolution   = 2
  };
 
  enum FindFileHint
  {
    kDefault              = 0,  // Any file.
    kFontFile             = 1,  // Can be either SHX or TTF file.
    kCompiledShapeFile    = 2,  // SHX file.
    kTrueTypeFontFile     = 3,  // TTF file.
    kEmbeddedImageFile    = 4,  // Image file (ISM).
    kXRefDrawing          = 5,  // Drawing template file (DWT).
    kPatternFile          = 6,  // Pattern file (PAT).
    kTXApplication        = 7,  // Teigha(R) Xtension file (TX).
    kFontMapFile          = 8,  // FontMap file (FMP).
    kUnderlayFile         = 9,  // Underlay file.
    kTextureMapFile       = 10, // Material texture file.
    kPhotometricWebFile   = 11  // Photometric web file (IES).
  };
 
  enum GsBitmapDeviceFlags
  {
    kUseSoftwareHLR       = (1 << 0), // Enable use of SoftwareHLR on device
    kFor2dExportRender    = (1 << 1), // Device for shaded viewport export
    kFor2dExportRenderHLR = (1 << 2), // Device for HiddenLine viewport export
    kForThumbnail         = (1 << 3)  // Device for thumbnail image generation
  };
 
  /** \details
    Returns the fully qualified path to the specified file.
 
    \param filename [in]  Name of the file to find.
    \param pDb [in]  Pointer to the database context.
    \param hint [in]  Hint that indicates the type of file that is required.
 
    \remarks
    Returns an empty string if the file is not found.
 
    This function is called by Teigha when access is needed to a
    file, such as a font file, a template file, etc.
 
    pDb == 0 specifies that this file search is not related to a database.
 
    If pDb != 0, call pDb->getFilename() to determine the path to the DWG
    file associated with the database.
 
    The typical search order is as follows:
 
    1.  The filename itself.
    2.  The current directory.
    3.  The drawing directory (for shx font, image, and xref files).
    4.  The directories listed in the ACAD environment variable.
    5.  The Windows fonts directory (only for TTF fonts on Windows).
 
    hint must be one of the following:
 
    <table>
    Name                    Value     Description Extension
    kDefault                0         Any file.                         any
    kFontFile               1         Can be either SHX or TTF file.    SHX or TTF
    kCompiledShapeFile      2         SHX file.                         SHX
    kTrueTypeFontFile       3         TTF file.                         TTF
    kEmbeddedImageFile      4         Image file.                       ISM
    kXRefDrawing            5         Drawing template file.            DWT
    kPatternFile            6         Pattern file (PAT)                PAT
    kTXApplication          7         Teigha(R) Xtension file.            TX
    kFontMapFile            8         FontMap file                      FMP
    kUnderlayFile           9         Underlay file
    kTextureMapFile        10
    </table>
 
    \note
    The client application can, in fact return any non-null string, so long as
    the application can handle that string in OdDbSystemServices::createFile.
  */
  virtual OdString findFile(
    const OdString& filename,
    OdDbBaseDatabase* pDb = 0,
    FindFileHint hint = kDefault) = 0;
 
  /** \details
    Returns an instance of an OdDbHostAppProgressMeter.
  */
  virtual OdDbHostAppProgressMeter* newProgressMeter();
 
  /** \details
    Notification function called whenever Teigha no longer needs the specified
    ProgressMeter object.
 
    \param pProgressMeter [in]  Pointer to the ProgressMeter object no longer needed by Teigha.
 
    \note
    The default implementation of this function does nothing but return.
  */
  virtual void releaseProgressMeter(
    OdDbHostAppProgressMeter* pProgressMeter);
 
  /** \details
    Returns the name of the client program.
 
    \remarks
    This function is typically used for populating "About" information.
 
    \note
    The default implementation of this function returns oddbGetLibraryInfo()->getLibName()
  */
  virtual const OdString program() = 0;
 
  /** \details
    Returns the name of the client product.
 
    \remarks
    This function is typically used for populating "About" information.
 
    \note
    The default implementation of this function returns program().
  */
  virtual const OdString product() = 0;
 
  /** \details
    Returns the name of the client company.
 
    \remarks
    This function is typically used for populating "About" information.
 
    \note
    The default implementation of this function returns oddbGetLibraryInfo()->getCompanyName().
  */
  virtual const OdString companyName() = 0;
 
  /** \details
    Returns the name of the client product code.
 
    \remarks
    This function is typically used for populating "About" information.
 
    prodcode() returns one of the following:
 
    <table>
    Name          Value   Description
    kProd_ACAD    1       Plain
    kProd_LT      2       Lite
    kProd_OEM     3       OEM
    kProd_OdDb    4       ..
    </table>
 
    \note
    The default implementation of this function returns kProd_OEM, and should not be overridden.
  */
  virtual ProdIdCode prodcode();
 
  /** \details
    Returns the release major and minor version string of the client application.
 
    \note
    The default implementation of this function returns oddbGetLibraryInfo()->getLibVersion().
  */
  virtual const OdString releaseMajorMinorString();
 
  /** \details
    Returns the release major version of the client application.
 
    \note
    The default implementation of this function returns TD_MAJOR_VERSION.
  */
  virtual int releaseMajorVersion();
 
  /** \details
    Returns the release minor version of the client application.
 
    \note
    The default implementation of this function returns TD_MINOR_VERSION.
  */
  virtual int releaseMinorVersion();
 
  /** \details
    Returns the release version string of the client application.
 
    \note
    The default implementation of this function returns oddbGetLibraryInfo()->getLibVersion().
  */
  virtual const OdString versionString();
 
  /** \details
    Displays the specified warning message.
 
    \param warnVisGroup [in]  Group of warning message visibility (always visible if empty).
    \param message [in]  Warning message.
    \param warningOb [in]  Warning object.
    \param objectId [in]  Object ID of the object associated with the warning.
 
    \note
    These functions call odSystemServices()->warning(message) to display the warning.
  */
  virtual void warning(
    const OdString& message);
  virtual void warning(
    const char* warnVisGroup,
    const OdString& message);
  virtual void warning(
    OdWarning warningOb);
  virtual void warning(
    const char* warnVisGroup,
    OdWarning warningOb);
 
  //virtual void warning(
  //  OdWarning warningOb,
  //  OdDbObjectId objectId);
 
  /** \details
    Returns the error description associated with the specified error code.
    \param errorCode [in]  Error code.
 
    \note
    The default implementation of this function returns formatMessage(errorCode).
  */
  virtual OdString getErrorDescription(
    unsigned int errorCode);
 
  /** \details
    Returns a formatted message corresponding to the specified error code(s).
    \param errorCode [in]  Error code.
  */
  virtual OdString formatMessage(
    unsigned int errorCode,...);
#ifdef ODA_FORMAT
  virtual OdString formatMessage(unsigned int errorCode, long i, const OdString& str) { return formatMessage(errorCode, i, (void*)str.c_str()); }
#endif
 
  /** \details
    Returns an alternate UndoController object for Teigha.
 
    \remarks
    The default implementation of this function always returns a null SmartPointer.
 
    Each database requires at most 2 undo controllers (for undo and redo).
  */
  virtual OdDbUndoControllerPtr newUndoController();
 
  /** \details
  Returns an alternate stream object for undo/redo operations.
 
  \remarks
  The default implementation of this function always returns a null SmartPointer.
  It may return null in the user application. In this case the default memory based stream will be used.
  In fact this stream will be used for the current undo/redo step. Other steps can be controlled by
  OdDbUndoController.
  */
  virtual OdStreamBufPtr newUndoStream();
 
  /** \details
    Print the audit report for the specified AuditInfo object.
 
    \param pAuditInfo [in]  Pointer to an OdDbAuditInfo object.
    \param strLine [in]  The string to print.
    \param printDest [in]  Print destination.
 
    \remarks
    The default implementation of this function does nothing but return.
  */
  virtual void auditPrintReport(
    OdAuditInfo* pAuditInfo,
    const OdString& strLine,
    int printDest) const;
 
  /** \details
    Locates the TTF or TTC file containing the specified font description.
 
    \param description [in]  Font description.
    \param filename [out]  Receives the name of the TrueType font file.
 
    \remarks
    Returns true and the filename if and only if the font file was found.
 
    \note
    The non-Windows builds of this function do nothing but return.
  */
  virtual bool ttfFileNameByDescriptor(
    const OdTtfDescriptor& description,
    OdString& filename) = 0;
 
  /** \details
    Returns the font file to be used when a given font file is
    not found by Teigha.
 
    \sa
    Font Handling
  */
  virtual OdString getAlternateFontName() const = 0;
 
  /** \details
    Returns the name of the font mapping file used by the getPreferableFont function.
 
    \sa
    Font Handling
 
    \note
    The default implementation of this function does nothing but return an empty string.
    It will be fully implemented in a future release.
  */
  virtual OdString getFontMapFileName() const = 0;
 
  /** \details
    Returns the preferable font name for the specified font name and type.
 
 
    \param fontName [in]  Font name.
    \param fontType [in]  Font type.
 
    \remarks
    This function is called as the first step in the process of resolving a font file.
    The default implementation tries to locate a font mapping file by calling
    getFontMapFileName, and substitutes the font name based on the contents of this
    file.
 
    fontType must be one of the following:
 
    <table>
    Name                    Value    Description
    kFontTypeUnknown        0        Unknown.
    kFontTypeShx            1        SHX font.
    kFontTypeTrueType       2        TrueType font.
    kFontTypeShape          3        Shape file.
    kFontTypeBig            4        BigFont file.
    </table>
 
    \sa
    Font Handling
  */
  virtual OdString getPreferableFont(
    const OdString& fontName,
    OdFontType fontType) = 0;
 
  /** \details
    Returns the font to be used when the specified font is not found.
 
    \param fontName [in]  Font name.
    \param fontType [in]  Font type.
 
    \remarks
    fontType must be one of the following:
 
    <table>
    Name                    Value    Description
    kFontTypeUnknown        0        Unknown.
    kFontTypeShx            1        SHX font.
    kFontTypeTrueType       2        TrueType font.
    kFontTypeShape          3        Shape file.
    kFontTypeBig            4        BigFont file.
    </table>
 
    The default implementation of this function calls getAlternateFontName for
    fonts that are not of type kFontTypeShape or kFontTypeBig. When they are,
    and empty string is returned.
 
    Client code could override this function to perform custom substitution
    for these types of fonts.
 
    \sa
    Font Handling
  */
  virtual OdString getSubstituteFont(
    const OdString& fontName,
    OdFontType fontType) = 0;
 
  /** \details
    Collects folders with TrueType fonts.
 
    \param aDirs [out]   Array names of folders.
 
    \sa
    Font Handling
  */
  virtual bool getSystemFontFolders(
    OdStringArray& aDirs) {return false; }
 
  /** \details
    Collects TrueType font paths.
 
    \param res [out]      Array of full file names of TrueType fonts.
    \param sPath [in]    Array of folders paths with TrueType files.
    \param sFilter [in]  File name filter.
 
    \sa
    Font Handling
  */
  virtual void collectFilePathsInDirectory(OdStringArray& res, // out
    const OdString& sPath, // in
    const OdString& sFilter = L"*.*") { return; }
 
  /** \details
    Prompts the user for a filename, and returns their response.
 
    \param flags [in]  Dialog behavior.
    \param dialogCaption [in]  Dialog caption.
    \param defExt [in]  Default file extension without "."
    \param defFilename [in]  Default filename.
    \param filter [in]  Filter pattern.
 
    \remarks
    flags must be one of the following:
 
    <table>
    Name                  Value   Description
    kGfpForOpen           0       For Open.
    kGfpForSave           1       For Save.
    kGfpOverwritePrompt   2       Enable overwrite prompt displaying when exist file selected for saving.
    </table>
 
    This function is intended for the selection of filenames via dialog boxes,
    although other methods may be used.
 
    *  Returns "canceled" if the user cancels the request.
    *  Returns "unsupported" if the application does not support this user input.
 
    \note
    The default implementation of this function does nothing but return "unsupported".
  */
  virtual OdString fileDialog(
    int flags,
    const OdString& dialogCaption = OdString::kEmpty,
    const OdString& defExt = OdString::kEmpty,
    const OdString& defFilename = OdString::kEmpty,
    const OdString& filter = OdString::kEmpty);
 
  /** \details
    Returns a the gsBitmapDevice associated with this HostAppServices object.
 
    \param pViewObj [in]  OdAbstractViewPE compatible object (OdGsView, OdDbViewport or etc.).
    \param pDb [in]  Pointer to the database context.
    \param flags [in]  Bitmap device flags.
  */
  virtual OdGsDevicePtr gsBitmapDevice(
    OdRxObject* pViewObj = NULL,
    OdDbBaseDatabase* pDb = NULL,
    OdUInt32 flags = 0);
 
  /** \details
    Returns the path to the temporary files folder.
  */
  virtual OdString getTempPath() const;
 
// ODA_MT_DBIO_BEGIN
  /** \details
    MtMode controls if multi-threading is used (bit-coded)
  */
  virtual OdInt16 getMtMode() const;
 
  /** \details
    Returns the number of threads for required multi-threaded mode.
  */
  virtual int numThreads(OdDb::MultiThreadedMode mtMode);
// ODA_MT_DBIO_END
};
 
 
#include "TD_PackPop.h"
 
#endif // _ODDB_BASEHOSTAPPSERVICES_INCLUDED_