高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】plotstyle 9ctb0 not being applied
plotstyle (ctb) not being applied
plotstyle (ctb) not being applied
hi,
i have taken the odamfcapp example and stripped it down to create a simple viewer. i have created an exe for the app and a dll containing the view for display (aka cdwgviewer). i am able to open and view a drawing and even plot.
some differences include the structure of the cdocument of the view which is external to the dll containing the view.
i used the view switching technique.
mainfrm()
typedef uint ( * lpdllfunc)(cruntimeclass**);
lpdllfunc lpfndllfunc = null;
lpfndllfunc = (lpdllfunc)::getprocaddress(theapp.m_hplotcontrold ll,"initdwg");
cruntimeclass* pnewviewclass;
lpfndllfunc(&pnewviewclass);
.....
pdoc->switchtoview(pnewviewclass, null);
cdocument()
switchtoview(cruntimeclass* pnewviewclass, cview* pnewview)
....
however, the ".ctb" that is used in the drawing and actually found and loaded does not seem to be applied - but does in the original sample. is there something that needs to initialized in the doc that i may not be doing? a sample showing only the initialization of plotstyle using a ctb for a known m_pdb would be appreciated.
the following is some of the code used which is not much different from the sample.
void oninitialupdate()
odinitialize(&m_svcs);
m_pdb = m_svcs.readfile( filename, /*false*/true, false, oda::ksharedenyno );
odgicontextfordbdatabase::setdatabase(m_pdb);
m_hwindowdc = ::getdc(m_hwnd);
const odcolorref* palette = curpalette();
odgspalette ppalcpy;
ppalcpy.insert(ppalcpy.begin(), palette, palette+256);
ppalcpy[0] = activebackground();
createdevice();
if(m_pdevice.isnull())
{
getparent()->postmessage(wm_close);
return;
}
m_pdevice->update();
m_hthreadreadyevent = ::createevent(0, true, false, 0);
m_hdrawerthread = ::createthread(null, 0, _drawerthread, this, create_suspended, &m_drawerthreadid);
::setthreadpriority(m_hdrawerthread, thread_priority_below_normal);
::resumethread(m_hdrawerthread);
::waitforsingleobject(m_hthreadreadyevent, infinite);
void createdevice()
odgsmoduleptr pgs = :drxdynamiclinker()->loadmodule("wingdi");
// odgsmoduleptr pgs = :drxdynamiclinker()->loadapp("genericopenglmodule");
odgsdeviceptr pdevice = pgs->createdevice();
odrxdictionaryptr pproperties = pdevice->properties();
if(pproperties.get())
{
pproperties->putat("windowhdc", odrxvariantvalue((long)m_hwindowdc));
pproperties->putat("windowhwnd", odrxvariantvalue((long)m_hwnd)); // hwnd necessary for directx device
if(pproperties->has("doublebufferenabled")) // check if property is supported
{
pproperties->putat("doublebufferenabled", odrxvariantvalue(doublebufferenabled()));
}
// this is for temporary illustration of using gl lists:
if(pproperties->has("enablecaching")) // check if property is supported
{
pproperties->putat("enablecaching", odrxvariantvalue(usegsmodel()));
}
}
enablegsmodel(usegsmodel());
m_pdevice = oddbgsmanager::setupactivelayoutviews(pdevice, this);
m_layoutid = m_pdevice->layoutid();
const odcolorref* palette = curpalette();
odgspalette ppalcpy;
ppalcpy.insert(ppalcpy.begin(), palette, palette+256);
ppalcpy[0] = activebackground();
m_pdevice->setlogicalpalette(ppalcpy.asarrayptr(), 256);
if(m_pdevice->iskindof(odgsmodellayouthelper::desc()))
{
m_bpsoverall = false;
m_pdevice->setbackgroundcolor(activebackground());
}
else
{
m_bpsoverall = true;
m_pdevice->setbackgroundcolor(odrgb(173,174,173)); // acad's color for paper bg
}
setpalettebackground(activebackground());
if (rc.left == 0 && rc.right == 0 && rc.bottom == 0 && rc.top == 0)
rc.right = rc.bottom = 100;
odgsdcrect gsrect(rc.left, rc.right, rc.bottom, rc.top);
m_pdevice->onsize(gsrect);
// adding plotstyletable info
prepareplotstyles();
i have narrowed it down to:
loadplotstyletable(pfilebuf);
resulting in
m_pplotstyletable == 0 of class odgicontextfordbdatabase
any clues?
look at your oddbhostappservices... it may not be finding the .ctb or mishandling it... or not even called.
tyler
dwg export dll
i am writing a dwg export dll for our cad program. but i cannot use plotstyle services because when i add codes above, my dll will not be loaded. i guess that afxloadlibrary function dont load because of g_odrx_static_module_map.
the macros above are required only for static build but they should not damage configuration using dwgdirect dlls because _toolkit_in_dll_ must be defined if and only if dll configuration of dwgdirect is used.
in dll configuatation modules (.drx) are loaded dynamically. the only requirement is their presence in application folder.
in static configuration the macros above must be used and application must be linked with modules mentioned in macros.
btw, client dll may fail to load if it is linked with some .dll or .drx which is absent in application folder.
sergey slezkin
|