CFx SDK Documentation  2023 SP0
GfxSrvOps.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 GFXSRV_OPS_H
25 #define GFXSRV_OPS_H
26 
27 
28 #include "OdaCommon.h"
29 #include "Ed/EdCommandStack.h"
30 #include "Ed/EdCommandContext.h"
31 #include "Ed/EdUserIO.h"
32 #include "DynamicLinker.h"
33 #include "DbBaseDatabase.h"
34 #include "TxDefs.h"
35 #include "DbGsManager.h"
36 #include "Gs/GsModel.h"
37 #include "DbLayout.h"
38 #include "DbBlockTableRecord.h"
39 #include "RxObjectImpl.h"
40 #include "Tf/TFSQL.h"
41 #include "MemoryStream.h"
42 
44 
45 using namespace Oda;
46 using namespace OdEd;
47 
49  return !ctx->arbitraryData("AutoUpdateReactor").isNull();
50 }
51 
52 inline void UpdateGs(OdEdCommandContext* ctx) {
54  gsDev->update();
55 }
56 
57 inline OdGsDevicePtr setupDevice(OdRxObject* rxDb, OdGsDevice* gsDev, bool bEnableGsModel, ODCOLORREF palBg, OdGiDefaultContextPtr giCtx) {
58  OdDbBaseDatabasePEPtr dbPx = rxDb;
59  if (giCtx.isNull()) {
60  giCtx = dbPx->createGiContext(rxDb);
61  giCtx->enableGsModel(bEnableGsModel);
62  }
63 
64  OdGsDevicePtr gsHelper = dbPx->setupActiveLayoutViews(gsDev, giCtx);
65  dbPx->setupPalette(gsDev, giCtx, 0, palBg);
66 
67  return gsHelper;
68 }
69 
73  OdRxObjectPtr db = ctx->baseDatabase();
74  BaseDbPxPtr dbpx = BaseDbPxPtr(db);
75  OdRxObjectPtr curLayout = dbpx->currentLayout(db);
76  if (curLayout)
77  return BaseLytPxPtr(curLayout)->name(curLayout);
78  return OdString(L"Model");
79 }
80 
82 public:
84  sewtol = simpltol = 0.0;
85  sortByWeight = false;
86  dataLimit = 0xFFFFFFFF;
87  chunkSz = 0xFFFFFFFF;
88  }
89 
90  const OdString& outFileName() const { return outFName; }
91  void setOutFileName(const OdString& val) { outFName = val; }
92  OdUInt32 chunkSize() const { return chunkSz; }
93  void setChunkSize(OdUInt32 val) { chunkSz = val; }
94  OdUInt32 outputDataLimit() const { return dataLimit; }
96  dataLimit = val;
97  if(val<0xFFFFFFFF)
98  enableSorting(true);
99  }
100 
101  double simplTol() const { return simpltol; }
102  double sewTol() const { return sewtol; }
103  void setSimplificationTolerances(double sewTol, double simplTol) {
104  simpltol = simplTol; sewtol = sewTol;
105  }
106 
107  OdString layoutName() const { return layout; }
108  void setLayoutName(const OdString& name) { layout = name; }
109 
110  bool isSortingEnabled() const { return sortByWeight; }
111  void enableSorting(bool val) { sortByWeight = val; }
112  OdString cachePath() const { return pathToCache; }
113  void setCachePath(const OdString& val) { pathToCache = val; }
114 private:
115  OdString outFName;
116  OdString pathToCache;
117  OdUInt32 chunkSz;
118  OdUInt32 dataLimit;
119  double sewtol;
120  double simpltol;
121  OdString layout;
122  bool sortByWeight;
123 };
124 
125 OdGsDevicePtr newGfxSrv(const OdString& fmtCtx, OdEdCommandContext* ctx, OdGsDCRect& rect, bool autoupdate, GfxSrvcParams& params);
126 
127 
128 
129 using namespace Oda;
132 
133 
135  return strg->prepare(
136  "SELECT layouts.rowid,settings.var,settings.val"
137  " FROM layouts,settings WHERE settings.var='layout' AND layouts.name=settings.val")
138  ->exe()->row().int32(0);
139 }
140 inline void cacheDeviceState(CMDCTX* ctx) {
142  OD::TFSQLP strg = OD::TFSQL::cast(ctx->arbitraryData("stateStorage"));
143  if (helper.get() && strg.get()) {
144  OdUInt32 layoutRow = layoutCacheRowId(strg);
145  OD::TFSQL::BlobP buf = strg->openR("layouts", "state", layoutRow);
146  helper->storeLayoutGsState(buf);
147  }
148 }
149 #endif //GFXSRV_OPS_H
OdDbBaseDatabasePEPtr BaseDbPxPtr
Definition: GfxSrvOps.h:130
OdUInt32 layoutCacheRowId(OD::TFSQL *strg)
Definition: GfxSrvOps.h:134
OdGsDevicePtr setupDevice(OdRxObject *rxDb, OdGsDevice *gsDev, bool bEnableGsModel, ODCOLORREF palBg, OdGiDefaultContextPtr giCtx)
Definition: GfxSrvOps.h:57
OdString getCurrentLayoutName(OdEdCommandContext *ctx)
Definition: GfxSrvOps.h:70
void UpdateGs(OdEdCommandContext *ctx)
Definition: GfxSrvOps.h:52
OdGsDevicePtr newGfxSrv(const OdString &fmtCtx, OdEdCommandContext *ctx, OdGsDCRect &rect, bool autoupdate, GfxSrvcParams &params)
void cacheDeviceState(CMDCTX *ctx)
Definition: GfxSrvOps.h:140
OdDbBaseLayoutPEPtr BaseLytPxPtr
Definition: GfxSrvOps.h:131
OdString sInitializedGs
bool isAutoUpdateReactorAttached(OdEdCommandContext *ctx)
Definition: GfxSrvOps.h:48
#define ODCOLORREF
Definition: OdPlatform.h:883
unsigned int OdUInt32
OdString OdString
Definition: OdString.h:1224
void setLayoutName(const OdString &name)
Definition: GfxSrvOps.h:108
double simplTol() const
Definition: GfxSrvOps.h:101
void setOutputDataLimit(OdUInt32 val)
Definition: GfxSrvOps.h:95
OdUInt32 outputDataLimit() const
Definition: GfxSrvOps.h:94
void setCachePath(const OdString &val)
Definition: GfxSrvOps.h:113
bool isSortingEnabled() const
Definition: GfxSrvOps.h:110
void setSimplificationTolerances(double sewTol, double simplTol)
Definition: GfxSrvOps.h:103
const OdString & outFileName() const
Definition: GfxSrvOps.h:90
void setChunkSize(OdUInt32 val)
Definition: GfxSrvOps.h:93
OdString cachePath() const
Definition: GfxSrvOps.h:112
OdUInt32 chunkSize() const
Definition: GfxSrvOps.h:92
OdString layoutName() const
Definition: GfxSrvOps.h:107
void enableSorting(bool val)
Definition: GfxSrvOps.h:111
void setOutFileName(const OdString &val)
Definition: GfxSrvOps.h:91
double sewTol() const
Definition: GfxSrvOps.h:102
virtual Statement::ParamsP prepare(const char *sql, int at=-1, StatementP *stmt=0)=0
bool isNull() const
Definition: BaseObjectPtr.h:70
virtual OdRxObject * baseDatabase()=0
virtual OdRxObjectPtr arbitraryData(const OdString &szPathName) const =0
static OdRxObjectPtr cast(const OdRxObject *pointer)
Definition: RxObject.h:659
const T * get() const
Definition: SmartPtr.h:326
GLenum GLint * params
Definition: gles2_ext.h:184
GLuint const GLchar * name
Definition: gles2_ext.h:265
Definition: EdUserIO.h:44
Definition: TxDefs.h:48
RXPTR arbVarSafe(OdEdCommandContext *ctx, const WSTR &varName)
Definition: TxDefs.h:165