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
/////////////////////////////////////////////////////////////////////////////// 
// 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 __DBRASTERIMAGEDEF_H
#define __DBRASTERIMAGEDEF_H
 
#include "TD_PackPush.h"
 
// Forward declarations
//
 
class OdDbDictionary;
 
#include "DbObjectReactor.h"
#include "DbObject.h"
#include "Gi/GiRasterImage.h"
#include "Ge/GeVector2d.h"
#include "RxObjectImpl.h"
 
/** \details
    This virtual base class defines Raster Image Definition objects in an OdDbDatabase instance.
    
    \sa
    TD_Db
 
    \remarks
    Raster Image Definitions (OdDbRasterImageDef objects) work with Raster Image (OdDbRasterImage) entities) 
    in much the same way that Block Table Records (OdDbBlockTableRecord objects) work with Block References
    (OdDbBlockReference entities).
 
    <group OdDb_Classes>
*/
class TOOLKIT_EXPORT OdDbRasterImageDef : public OdDbObject
{
public:
  ODDB_DECLARE_MEMBERS(OdDbRasterImageDef);
 
  typedef OdGiRasterImage::Units Units;
 
  OdDbRasterImageDef();
  
  OdResult subErase(
    bool erasing);
  virtual void subHandOverTo (
    OdDbObject* pNewObject);
  void subClose();
 
  OdResult dwgInFields(
    OdDbDwgFiler* pFiler);
 
  void dwgOutFields(
    OdDbDwgFiler* pFiler) const;
 
  OdResult dxfInFields(
    OdDbDxfFiler* pFiler);
 
  void dxfOutFields(
    OdDbDxfFiler* pFiler) const;
 
  /** \details
    Sets the name of the source file containing the raster image for this Raster Image Definition object (DXF 1).
    
    \param pathName [in]  Path name.
  */
  OdResult setSourceFileName(const OdString& pathName);
 
  /** \details
    Returns the name of the source file containing the raster image for this Raster Image Definition object (DXF 1).
    
    \remarks
    This function calls searchForActivePath() to determine the active path.
    
    \note
    This RasterImageDef object must be open for reading.
  */
  OdString sourceFileName() const;
 
  /** \details
    Loads the source image file for this Raster Image Definition object.
    
    \param modifyDatabase [in]  If and only if true, undo recording will be done for this object.
 
    \remarks
    This function calls searchForActivePath() to determine the active path.
    
    If the image file is currently loaded, the file will not be read.
    
    "Lazy loading" implies that the image file will not be loaded until it is required.
    
  */
  virtual OdResult load(
    bool modifyDatabase = true);
 
  /** \details
    Unloads the image for this Raster Image Definition object. 
    
    \param modifyDatabase [in]  If and only if true, undo recording will be done for this object.
 
    \remarks
 
    \note
    This RasterImageDef object must be open for writing.
 
  */
  virtual void unload(
    bool modifyDatabase = true);
 
  /** \details
    Returns true if and only if the image file for this Raster Image Definition object is loaded (DXF 280).
  */
  virtual bool isLoaded() const;
 
  /** \details
    Returns the XY pixel size of the image for this Raster Image Definition (DXF 10).
  */
  virtual OdGeVector2d size() const;
 
 
  /** \details
    Returns the default physical pixel size, in mm/pixel, of the image for this Raster Image Definition object (DXF 10).
    
    \note
    If the image has no default pixel size, 
    this function returns 1.0/(image width in pixels) for XY resolutions.
  */
  virtual OdGeVector2d resolutionMMPerPixel() const;
 
  /** \details
    Sets the default physical pixel size, in mm/pixel, of the image for this Raster Image Definition object (DXF 10).
    
    \note
    Loading the actual image file resets this value if the image has default pixel size.
  */
  virtual OdResult setResolutionMMPerPixel(const OdGeVector2d&);
 
 
  int entityCount(bool* pbLocked = NULL) const;
  void updateEntities() const;
 
  /** \details
    Returns the resolution units for the image for this Raster Image Definition object (DXF 281).
  */
  virtual OdGiRasterImage::Units resolutionUnits() const;
 
  /** \details
    Sets the resolution units for the image for this Raster Image Definition object (DXF 281).
 
    \note
    Loading the actual image file resets this value.
  */
  virtual void setResolutionUnits(enum OdGiRasterImage::Units);
 
  /** \details
    Returns the OdGiRasterImage object associated with this RasterImageDef object 
  */
  virtual OdGiRasterImagePtr image(bool load = true);
 
  /** \details
    Creates an image from the specified OdGiRasterImage object.
    \param pImage [in]  Pointer to the RasterImage object.
    \param modifyDatabase [in]  If and only if true, marks the associated OdDbDatabase instance as modified.
    
    \remarks
    isLoaded() returns false if pImage is NULL. Otherwise, it is returns true..
  */
  virtual void setImage(OdGiRasterImage* pImage, bool modifyDatabase = true);
 
  /** \details
    Creates an image dictionary, if one is not already present, in the specified OdDbDatabase instance.
 
    \param pDb [in]  Pointer to the database.
    
    \remarks
    Returns the Object ID of the image dictionary.
  */
  static OdDbObjectId createImageDictionary(OdDbDatabase* pDb);
 
  /** \details
    Returns the Object ID of the image dictionary in the specified OdDbDatabase instance.
    \param pDb [in]  Pointer to the database.  
  */
  static OdDbObjectId imageDictionary(OdDbDatabase* pDb);
 
  enum 
  { 
    kMaxSuggestNameSize = 2049 
  };
 
  /** \details
    Massages the original image filename to return a new
    image name suitable for an image dictionary.
    \param pImageDictionary [in]  Pointer to the image dictionary.
    \param strFilePath [in]  new image file name. 
    \param nMaxLength [in]  max length of the name returned
  */
  static OdString suggestName(const OdDbDictionary* pImageDictionary,
                  const OdString& strFilePath, int nMaxLength = kMaxSuggestNameSize);
 
  OdString activeFileName() const;
  OdResult setActiveFileName(const OdString& pPathName);
  /*   comment this out for a while
 
  int colorDepth() const;
  OdGiSentScanLines* makeScanLines(
    const OdGiRequestScanLines* pReq,
    const OdGeMatrix2d& pixToScreen,
    OdGePoint2dArray* pActiveClipBndy = 0, // Data will be modified!
    bool draftQuality = false,
    bool isTransparent = false,
    const double brightness = 50.0,
    const double contrast = 50.0,
    const double fade = 0.0
    ) const;
  OdString searchForActivePath();
  void embed(); // this function is not implemented in ARX
  bool isEmbedded() const;
  OdString fileType() const;
  void setUndoStoreSize(unsigned int maxImages = 10);
  unsigned int undoStoreSize() const;
  bool imageModified() const;
  void setImageModified(bool modified);
  void loadThumbnail(OdUInt16& maxWidth, OdUInt16& maxHeight,
    OdUInt8* pPalette = 0, int nPaletteEntries = 0);
  void unloadThumbnail();
  void* createThumbnailBitmap(BITMAPINFO*& pBitmapInfo,
    OdUInt8 brightness = 50, OdUInt8 contrast = 50, OdUInt8 fade = 0);
  IeFileDesc* fileDescCopy() const;
  void getScanLines(OdGiBitmap& bitmap,
    double brightness = 50.0,
    double contrast = 50.0,
    double fade = 0.0) const;
  void openImage(IeImg*& pImage);
  void closeImage();
 
  */
  static int classVersion();
};
 
 
 
 
/** \details
    This class implements Raster Image Definition Reactor objects in an OdDbDatabase instance.
    
    \sa
    TD_Db
    
    \remarks
    Raster Image Definition Reactor (OdDbRasterImageDefReactor) objects are used 
    to notify Raster Image (OdDbRasterImage) objects 
    of changes to their associated Raster Image Definition (OdDbRasterImage) objects.
    
    Modifications of Image Definition objects redraw their dependent Raster Image entities. 
    Deletion of Image Definition objects delete their dependent Raster Image entities.
 
    <group OdDb_Classes>
*/
class TOOLKIT_EXPORT OdDbRasterImageDefReactor : public OdDbObject
{
public:
  ODDB_DECLARE_MEMBERS(OdDbRasterImageDefReactor);
 
  OdDbRasterImageDefReactor();
 
  OdResult dwgInFields(
    OdDbDwgFiler* pFiler);
 
  void dwgOutFields(
    OdDbDwgFiler* pFiler) const;
 
  OdResult dxfInFields(
    OdDbDxfFiler* pFiler);
 
  void dxfOutFields(
    OdDbDxfFiler* pFiler) const;
 
  void erased(
    const OdDbObject* pObject, 
    bool erasing = true);
 
  void modified(
    const OdDbObject* pObject);
 
  enum DeleteImageEvent
  {
    kUnload = 1,
    kErase = 2
  };
  /** \details
    Controls notifications of OdDbRasterImage object events.
    
    \param enable [in]  If and only if true, enables notifications.
  */
  static void setEnable(
    bool enable);
 
  /** \details
    Notification function called whenever an OdDbRasterImageDef object is about to be unloaded or erased.
    
    \param pImageDef [in]  Pointer to the OdDbRasterImageDef object sending this notification.
    \param event [in]  Event triggering the notification.
    \param cancelAllowed [in]  True to enable user cancellation, false to disable.
    
    \remarks
    Returns true if and only if not cancelled. 
    
    event must be one of the following:
    
    <table>
    Name      Value
    kUnload   1
    kErase    2
    </table>
    
    
    \note
    Use imageModified() to determine if the Image Definition has been modified.
  */
  virtual bool onDeleteImage( 
    const OdDbRasterImageDef* pImageDef,
    DeleteImageEvent event,
    bool cancelAllowed);
 
  static int classVersion();
};
 
/** \details
  This template class is a specialization of the OdSmartPtr class for OdDbRasterImageDefReactor object pointers.
*/
typedef OdSmartPtr<OdDbRasterImageDefReactor> OdDbRasterImageDefReactorPtr;
 
/** \details
    This class implements Raster Image Definition Transient Reactor objects in an OdDbDatabase instance.
    Library: TD_Db
    <group OdDb_Classes>
*/
class TOOLKIT_EXPORT OdDbRasterImageDefTransReactor : public OdDbObjectReactor
{
protected:
  OdDbRasterImageDefTransReactor() {}
public:
  ODRX_DECLARE_MEMBERS(OdDbRasterImageDefTransReactor);
 
  /** \details
    Notification function called whenever an OdDbRasterImageDef object is about to be unloaded or erased.
    
    \param pImageDef [in]  Pointer to the OdDbRasterImageDef object sending this notification.
    \param event [in]  Event triggering the notification.
    \param cancelAllowed [in]  True to enable user cancellation, false to disable.
    
    \remarks
    Returns true if and only if not cancelled. 
    
    event must be one of the following:
    
    <table>
    Name                                 Value
    OdDbRasterImageDefReactor::kUnload   1
    OdDbRasterImageDefReactor::kErase    2
    </table>
  */
  virtual bool onDeleteImage( const OdDbRasterImageDef* pImageDef,
                              OdDbRasterImageDefReactor::DeleteImageEvent event,
                              bool cancelAllowed ) = 0;
};
 
/*   comment this for a while */
 
#if 0 /*!DOM*/
 
 
/** \details
  <group OdDb_Classes>
*/
class TOOLKIT_EXPORT OdDbRasterImageDefFileAccessReactor : public OdDbObjectReactor
{
protected:
  OdDbRasterImageDefFileAccessReactor() {}
public:
  ODRX_DECLARE_MEMBERS(OdDbRasterImageDefFileAccessReactor);
 
  virtual void onAttach(const OdDbRasterImageDef*, const OdString& pPath) = 0;
  virtual void onDetach(const OdDbRasterImageDef*, const OdString& pPath) = 0;
  virtual bool onOpen(const OdDbRasterImageDef*, const OdString& pPath,
    const OdString& pActivePath, bool& replacePath, OdString& replacementPath) = 0;
 
  virtual bool onPathChange(const OdDbRasterImageDef*,
    const OdString& pPath, const OdString& pActivePath,
    bool& replacePath, OdString& replacementPath) = 0;
 
  virtual void onClose(const OdDbRasterImageDef*, const OdString& pPath) = 0;
 
  virtual void onDialog(OdDbRasterImageDef*,
    const OdString& pCaption, const OdString& pFileExtensions) = 0;
};
 
#endif
 
/** \details
  This template class is a specialization of the OdSmartPtr class for OdDbRasterImageDef object pointers.
*/
typedef OdSmartPtr<OdDbRasterImageDef> OdDbRasterImageDefPtr;
 
#include "TD_PackPop.h"
 
#endif // __DBRASTERIMAGEDEF_H