CFx SDK Documentation  2022 SP0
DbLayerState.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 #ifndef DBLAYERSTATEMANAGER_H
25 #define DBLAYERSTATEMANAGER_H
26 
27 #include "TD_PackPush.h"
28 #include "StringArray.h"
29 
37 {
38 public:
39  enum Mask
40  {
41  kDefMask = (long)0xFFFFFFFF,
42  kNone = 0x0000,
43  kOn = 0x0001,
44  kFrozen = 0x0002,
45  kLocked = 0x0004,
46  kPlot = 0x0008,
47  kNewViewport = 0x0010,
48  kColor = 0x0020,
49  kLineType = 0x0040,
50  kLineWeight = 0x0080,
51  kPlotStyle = 0x0100,
52  kCurrentViewport = 0x0200,
53  kTransparency = 0x0400,
54 
55  kAll = kOn | kFrozen | kLocked | kPlot | kNewViewport |
56  kColor | kLineType | kLineWeight | kPlotStyle |
57  kCurrentViewport | kTransparency,
58 
59  kHidden = 0x8000,
60 //FELIX_CHANGE_BEGIN
61  kLastRestored = 0x10000
62 //FELIX_CHANGE_END
63  };
64 
65  enum
66  {
67  kUndefDoNothing = 0x00,
68  kUndefTurnOff = 0x01,
69  kUndefFreeze = 0x02,
70  kRestoreAsOverrides = 0x04
71  };
72 
78  static OdDbObjectId dictionaryId(OdDbDatabase *pDb, bool createIfNotFound = false);
79 
87  static bool has(OdDbDatabase *pDb, const OdString &layerStateName);
88 
122  static void save(OdDbDatabase *pDb, const OdString &layerStateName, int layerStateMask, const OdDbObjectId &viewportId = OdDbObjectId::kNull);
123 
169  static void restore(OdDbDatabase *pDb, const OdString &layerStateName,
170  int flags = kUndefDoNothing, const int layerStateMask = kDefMask, const OdDbObjectId& viewportId = OdDbObjectId::kNull);
203  static void setMask(OdDbDatabase *pDb, const OdString &layerStateName, int layerStateMask);
204 
237  static int mask(OdDbDatabase *pDb, const OdString &layerStateName);
238 
245  static void remove(OdDbDatabase *pDb, const OdString &layerStateName);
246 
254  static void rename(OdDbDatabase *pDb, const OdString &oldName, const OdString &newName);
255 
257  {
259  kAlreadyExists
260  };
261 
277  static ImportResult importData(OdDbDatabase *pDb, OdStreamBuf* pStreamBuf, OdString* pName = 0);
278 
286  static void exportData(OdDbDatabase *pDb, const OdString &layerStateName, OdStreamBuf* pStreamBuf);
287 
295  static void setDescription(OdDbDatabase *pDb, const OdString &layerStateName, const OdString &description);
302  static OdString description(OdDbDatabase *pDb, const OdString &layerStateName);
303 
310  static bool hasViewportData(OdDbDatabase *pDb, const OdString &layerStateName);
311 
319  static OdResult addLayerStateLayers(const OdString &sName, OdDbObjectIdArray layerIds);
320 
328  static OdResult removeLayerStateLayers(OdDbDatabase* pDb, const OdString sName, const OdStringArray& layerNames);
329 
339  static OdResult saveGroup(OdDbDatabase *pDb, const OdString &sName,
340  const OdDbObjectIdArray& pLayers, int mask = kOn,
341  int includedLayersState = kOn, int otherLayersState = kNone);
342 };
343 
345 class OdDbLayerStateManagerImpl;
346 
352 {
353 protected:
354  OdDbLayerStateManager(OdDbLayerStateManagerImpl*);
355 public:
359 
361  kNone = 0x0000,
362  kOn = 0x0001,
363  kFrozen = 0x0002,
364  kLocked = 0x0004,
365  kPlot = 0x0008,
366  kNewViewport = 0x0010,
367  kColor = 0x0020,
368  kLineType = 0x0040,
369  kLineWeight = 0x0080,
370  kPlotStyle = 0x0100,
371  kCurrentViewport = 0x0200,
372  kTransparency = 0x0400,
373  kAll = kOn | kFrozen | kLocked | kPlot | kNewViewport |
374  kColor | kLineType | kLineWeight | kPlotStyle |
375  kCurrentViewport | kTransparency,
376  kStateIsHidden = 0x8000,
377  kLastRestored = 0x10000,
378  kDecomposition = kAll | 0x20000
379  };
380 
381  enum {
382  kUndefDoNothing = 0,
383  kUndefTurnOff = 1,
384  kUndefFreeze = 2,
385  kRestoreAsOverrides = 4
386  };
387 
390 
391  OdDbObjectId layerStatesDictionaryId(bool bCreateIfNotPresent=false);
392  bool hasLayerState(const OdString& sName);
396  OdResult getLayerStateMask(const OdString& sName, LayerStateMask &returnMask);
398  OdResult renameLayerState(const OdString& sName, const OdString& sNewName);
401  OdResult exportLayerState(const OdString& sNameToExport, OdStreamBuf* pStreamBuf);
403  OdResult restoreLayerState(const OdString& sName, const OdDbObjectId& idVp, int nRestoreFlags = 0, const LayerStateMask* pClientMask = NULL);
404  OdResult setLayerStateDescription(const OdString& sName, const OdString& sDesc);
408  OdResult getLayerStateNames(OdStringArray& lsArray, bool bIncludeHidden = true, bool bIncludeXref = true);
410  OdResult getLayerStateLayers(OdStringArray& layerArray, const OdString& sName, bool bInvert = false);
411  bool compareLayerStateToDb(const OdString& sName, const OdDbObjectId& idVp);
412  OdResult addLayerStateLayers(const OdString& sName, const OdDbObjectIdArray& layerIds);
413  OdResult removeLayerStateLayers(const OdString& sName, const OdStringArray& layerNames);
414  bool isDependentLayerState(const OdString& sName);
416 protected:
417  OdDbLayerStateManagerImpl* m_pImpl;
418  friend class OdDbLayerStateManagerImpl;
419  friend class OdDbDatabase;
420 };
421 
422 //FELIX_CHANGE_BEGIN
428 {
429 public:
432 
436  virtual bool load() = 0;
437 
441  virtual bool save() = 0;
442 
446  virtual OdString getActiveLayer() const = 0;
447  virtual OdResult setActiveLayer( const OdString& layerStateName ) = 0;
448 
452  virtual bool isOn( const OdString& layerName ) const = 0;
453  virtual OdResult setOn( const OdString& layerName, const bool& bOn ) = 0;
454 
458  virtual bool isFreezed( const OdString& layerName, OdDbObjectId id = NULL ) const = 0;
459  virtual OdResult setFreeze( const OdString& layerName, const bool& bFreeze, OdDbObjectId id = NULL ) = 0;
460 
464  virtual bool isLocked( const OdString& layerName ) const = 0;
465  virtual OdResult setLocked( const OdString& layerName, const bool& bLock ) = 0;
466 
470  virtual OdCmColor getLineColor( const OdString& layerName ) const = 0;
471  virtual OdResult setLineColor( const OdString& layerName, const OdCmColor& color ) = 0;
472 
476  virtual OdDb::LineWeight getLineWeight( const OdString& layerName ) const = 0;
477  virtual OdResult setLineWeight( const OdString& layerName, const OdDb::LineWeight& lweight ) = 0;
478 
482  virtual OdDbObjectId getLineType( const OdString& layerName ) const = 0;
483  virtual OdResult setLineType( const OdString& layerName, const OdDbObjectId& ltype ) = 0;
484 
488  virtual OdString getPlotStyle( const OdString& layerName ) const = 0;
489  virtual OdResult setPlotStyle( const OdString& layerName, const OdString& plotStyle ) = 0;
490 
494  virtual OdCmTransparency getTransparency( const OdString& layerName) const = 0;
495  virtual OdResult setTransparency ( const OdString& layerName, const OdCmTransparency& transparency ) = 0;
496 
500  virtual bool isPlotable( const OdString& layerName ) const = 0;
501  virtual OdResult setPlotable( const OdString& layerName, const bool& bPlot ) = 0;
502 
506  virtual bool isNewVPFreeze( const OdString& layerName ) const = 0;
507  virtual OdResult setNewVPFreeze( const OdString& layerName, const bool& bNewVPFreeze ) = 0;
508 
512  virtual OdDbDatabase* database() const = 0;
513 
517  virtual OdString getLayerStateName() const = 0;
518  };
519 
521 
527 {
528 public:
531 
534 
535 private:
536  OdDbDatabasePtr m_pDb;
537 };
538 //FELIX_CHANGE_END
539 
545 {
546 public:
548 
549  virtual void layerStateCreated(const OdString& layerStateName,
550  const OdDbObjectId& layerStateId);
551  virtual void layerStateCompareFailed(const OdString& layerStateName,
552  const OdDbObjectId& layerStateId);
553 
554  virtual void layerStateToBeRestored(const OdString& layerStateName,
555  const OdDbObjectId& layerStateId);
556  virtual void layerStateRestored(const OdString& layerStateName,
557  const OdDbObjectId& layerStateId);
558  virtual void abortLayerStateRestore(const OdString& layerStateName,
559  const OdDbObjectId& layerStateId);
560 
561 
562  virtual void layerStateToBeDeleted(const OdString& layerStateName,
563  const OdDbObjectId& layerStateId);
564  virtual void layerStateDeleted(const OdString& layerStateName);
565  virtual void abortLayerStateDelete(const OdString& layerStateName,
566  const OdDbObjectId& layerStateId);
567 
568  virtual void layerStateToBeRenamed(const OdString& oldLayerStateName,
569  const OdString& newLayerStateName);
570  virtual void layerStateRenamed(const OdString& oldLayerStateName,
571  const OdString& newLayerStateName);
572  virtual void abortLayerStateRename(const OdString& oldLayerStateName,
573  const OdString& newLayerStateName);
574 };
575 
577 
578 #include "TD_PackPop.h"
579 
580 #endif //#ifndef DBLAYERSTATEMANAGER_H
#define TOOLKIT_EXPORT
Definition: DbExport.h:40
TOOLKIT_EXPORT OdDbLayerStateProperties * fxGetLayerStateProperties(OdDbDatabase *pDb, const OdString &layerState)
OdSmartPtr< OdDbLayerStateManagerReactor > OdDbLayerStateManagerReactorPtr
Definition: DbLayerState.h:576
ltype
Definition: DimVarDefs.h:2949
#define NULL
Definition: GsProperties.h:177
OdResult
Definition: OdResult.h:29
static OdString description(OdDbDatabase *pDb, const OdString &layerStateName)
static ImportResult importData(OdDbDatabase *pDb, OdStreamBuf *pStreamBuf, OdString *pName=0)
static void remove(OdDbDatabase *pDb, const OdString &layerStateName)
static OdResult saveGroup(OdDbDatabase *pDb, const OdString &sName, const OdDbObjectIdArray &pLayers, int mask=kOn, int includedLayersState=kOn, int otherLayersState=kNone)
static OdResult addLayerStateLayers(const OdString &sName, OdDbObjectIdArray layerIds)
static OdResult removeLayerStateLayers(OdDbDatabase *pDb, const OdString sName, const OdStringArray &layerNames)
static bool hasViewportData(OdDbDatabase *pDb, const OdString &layerStateName)
static void exportData(OdDbDatabase *pDb, const OdString &layerStateName, OdStreamBuf *pStreamBuf)
static OdDbObjectId dictionaryId(OdDbDatabase *pDb, bool createIfNotFound=false)
static void setMask(OdDbDatabase *pDb, const OdString &layerStateName, int layerStateMask)
static int mask(OdDbDatabase *pDb, const OdString &layerStateName)
static bool has(OdDbDatabase *pDb, const OdString &layerStateName)
static void restore(OdDbDatabase *pDb, const OdString &layerStateName, int flags=kUndefDoNothing, const int layerStateMask=kDefMask, const OdDbObjectId &viewportId=OdDbObjectId::kNull)
static void setDescription(OdDbDatabase *pDb, const OdString &layerStateName, const OdString &description)
static void rename(OdDbDatabase *pDb, const OdString &oldName, const OdString &newName)
static void save(OdDbDatabase *pDb, const OdString &layerStateName, int layerStateMask, const OdDbObjectId &viewportId=OdDbObjectId::kNull)
OdResult renameLayerState(const OdString &sName, const OdString &sNewName)
OdResult getLayerStateDescription(const OdString &sName, OdString &sDesc)
OdResult getLastRestoredLayerState(OdString &sName, OdDbObjectId &restoredLSId)
OdResult setLayerStateDescription(const OdString &sName, const OdString &sDesc)
OdResult saveLayerState(const OdString &sName, LayerStateMask mask)
bool compareLayerStateToDb(const OdString &sName, const OdDbObjectId &idVp)
bool addReactor(OdDbLayerStateManagerReactor *pReactor)
OdResult getLayerStateMask(const OdString &sName, LayerStateMask &returnMask)
OdResult restoreLayerState(const OdString &sName, const OdDbObjectId &idVp, int nRestoreFlags=0, const LayerStateMask *pClientMask=NULL)
OdResult importLayerStateFromDb(const OdString &pStateName, OdDbDatabase *pDb)
OdResult setLayerStateMask(const OdString &sName, LayerStateMask mask)
bool layerStateHasViewportData(const OdString &sName)
OdResult importLayerState(OdStreamBuf *pStreamBuf, OdString &sName)
OdResult removeLayerStateLayers(const OdString &sName, const OdStringArray &layerNames)
OdResult restoreLayerState(const OdString &sName)
OdResult exportLayerState(const OdString &sNameToExport, OdStreamBuf *pStreamBuf)
OdResult saveLayerState(const OdString &sName, LayerStateMask mask, const OdDbObjectId &idVp)
OdResult getLayerStateLayers(OdStringArray &layerArray, const OdString &sName, bool bInvert=false)
OdDbLayerStateManagerImpl * m_pImpl
Definition: DbLayerState.h:417
OdResult addLayerStateLayers(const OdString &sName, const OdDbObjectIdArray &layerIds)
OdDbDatabase * getDatabase() const
OdResult getLayerStateNames(OdStringArray &lsArray, bool bIncludeHidden=true, bool bIncludeXref=true)
bool isDependentLayerState(const OdString &sName)
bool hasLayerState(const OdString &sName)
OdResult importLayerState(OdStreamBuf *pStreamBuf)
OdResult deleteLayerState(const OdString &sName)
OdDbLayerStateManager(OdDbLayerStateManagerImpl *)
OdDbObjectId layerStatesDictionaryId(bool bCreateIfNotPresent=false)
ODRX_DECLARE_MEMBERS(OdDbLayerStateManager)
bool removeReactor(OdDbLayerStateManagerReactor *pReactor)
virtual void layerStateCompareFailed(const OdString &layerStateName, const OdDbObjectId &layerStateId)
virtual void abortLayerStateDelete(const OdString &layerStateName, const OdDbObjectId &layerStateId)
virtual void layerStateDeleted(const OdString &layerStateName)
virtual void layerStateRestored(const OdString &layerStateName, const OdDbObjectId &layerStateId)
virtual void layerStateToBeRenamed(const OdString &oldLayerStateName, const OdString &newLayerStateName)
virtual void layerStateToBeRestored(const OdString &layerStateName, const OdDbObjectId &layerStateId)
virtual void layerStateRenamed(const OdString &oldLayerStateName, const OdString &newLayerStateName)
virtual void layerStateToBeDeleted(const OdString &layerStateName, const OdDbObjectId &layerStateId)
virtual void abortLayerStateRename(const OdString &oldLayerStateName, const OdString &newLayerStateName)
virtual void abortLayerStateRestore(const OdString &layerStateName, const OdDbObjectId &layerStateId)
ODRX_DECLARE_MEMBERS(OdDbLayerStateManagerReactor)
virtual void layerStateCreated(const OdString &layerStateName, const OdDbObjectId &layerStateId)
virtual bool load()=0
virtual OdDbObjectId getLineType(const OdString &layerName) const =0
virtual OdResult setOn(const OdString &layerName, const bool &bOn)=0
virtual OdResult setNewVPFreeze(const OdString &layerName, const bool &bNewVPFreeze)=0
virtual OdResult setFreeze(const OdString &layerName, const bool &bFreeze, OdDbObjectId id=NULL)=0
virtual OdDbDatabase * database() const =0
virtual OdResult setLineColor(const OdString &layerName, const OdCmColor &color)=0
virtual bool isNewVPFreeze(const OdString &layerName) const =0
virtual OdCmTransparency getTransparency(const OdString &layerName) const =0
virtual OdString getActiveLayer() const =0
virtual bool isLocked(const OdString &layerName) const =0
virtual OdResult setLineWeight(const OdString &layerName, const OdDb::LineWeight &lweight)=0
virtual bool isFreezed(const OdString &layerName, OdDbObjectId id=NULL) const =0
virtual OdResult setLineType(const OdString &layerName, const OdDbObjectId &ltype)=0
virtual OdResult setPlotStyle(const OdString &layerName, const OdString &plotStyle)=0
virtual OdString getPlotStyle(const OdString &layerName) const =0
virtual OdResult setLocked(const OdString &layerName, const bool &bLock)=0
virtual bool isPlotable(const OdString &layerName) const =0
virtual ~OdDbLayerStateProperties()
Definition: DbLayerState.h:431
virtual OdResult setPlotable(const OdString &layerName, const bool &bPlot)=0
virtual OdString getLayerStateName() const =0
virtual OdDb::LineWeight getLineWeight(const OdString &layerName) const =0
virtual OdResult setTransparency(const OdString &layerName, const OdCmTransparency &transparency)=0
virtual bool save()=0
virtual OdResult setActiveLayer(const OdString &layerStateName)=0
virtual bool isOn(const OdString &layerName) const =0
virtual OdCmColor getLineColor(const OdString &layerName) const =0
OdDbLegacyLayerStateImporter(OdDbDatabasePtr pDb)
Definition: DbLayerState.h:529
static TOOLKIT_EXPORT_STATIC const OdDbObjectId kNull
Definition: DbObjectId.h:118
GLenum GLint GLuint mask
Definition: gles2_ext.h:262
LineWeight
Definition: OdaDefs.h:382
@ kNone
Light mode is inherited from the annotation.