odgsdevice:

nsize problem
odgsdevice:

nsize problem
hi,
i am writing my first application with the library and i have run into a problem with odgsdevice:: onsize. i am using vc6/mfc to write a basic dwg viewer that can be used as a control in a dialog. the viewer is working fine but i wanted to add a toolbar so i tried to make a gap at the top of the window by moving the top edge of the device rectangle. to do this i passed a non-zero "top" value (e.g. 20) to the onsize function. the top edge did move down, but a black band also appeared at the top of the drawing (see screen shot).
odgsdcrect outputrect(odgsdcpoint(rc.left, rc.bottom), odgsdcpoint(rc.right, rc.top + 20));
m_pdevice->onsize(outputrect);
is there a way around this problem, or am i misunderstanding how onsize works?
stuart
attached images
the way around is substitute this function (exgsgdivectorizedevice.cpp)
code:
void exgsgdivectorizedevice::beginpaint()
{
hdc hdc = createdrawdc();
exgigdigeometry::draw_color(m_background);
exgigdigeometry::beginpaint(hdc);
exgigdigeometry::setselection(exgswin32device::isdrawselection());
exgigdigeometry::setdragging(exgswin32device::isdrawdragging());
if(m_bclearscreen)
::rectangle(hdc, m_outputrect.m_min.x, m_outputrect.m_max.y, m_outputrect.m_max.x, m_outputrect.m_min.y);
}
by this one
code:
void exgsgdivectorizedevice::beginpaint()
{
hdc hdc = createdrawdc();
exgigdigeometry::draw_color(m_background);
exgigdigeometry::beginpaint(hdc);
exgigdigeometry::setselection(exgswin32device::isdrawselection());
exgigdigeometry::setdragging(exgswin32device::isdrawdragging());
if(m_bclearscreen)
::rectangle(hdc, 0, 0, m_outputrect.m_max.x, m_outputrect.m_min.y);
}
we'll look into the problem - thank you.
sincerely yours,
george udov
onsize problem
george,
thank you for this information. could i just ask a couple of questions about using the exgsgdivectorizedevice class. this is my first project with the library, so i'm a little unsure how to substitute exgsgdivectorizedevice for the odgsdevice i'm using at the moment.
i have based my code heavily on the singledoc sample, which creates a device like this...
odgsmoduleptr pgs = :drxdynamiclinker()->loadmodule("wingdi.gs");
m_pdevice = pgs->createdevice();
i've also had a look at the odvectorizeex sample, which creates its device like this...
odgsdeviceptr pdevice = exgssimpledevice::createobject(output, exgssimpledevice::k3ddevice);
the exgsgdivectorizedevice class doesn't appear to have a createobject function, so i tried to write one like this...
odgsdeviceptr exgsgdivectorizedevice::createobject()
{
return odrxobjectimpl<exgsgdivectorizedevice, odgsdevice>::createobject();
}
however, i find that my project now crashes at this line...
m_pdevice = oddbgsmanager::setupactivelayoutviews(m_pdevice, this);
i noticed in the help file that it says, "client apps must override the odgsdevice::createview function in their device class". the exgsgdivectorizedevice class doesn't appear to have a createview function either.
do i need to write a createview function too, or am i on the wrong track?!
stuart
all our gsdevices are inherited from odgsbasevectorizedevice class. odgsbasevectorizedevice::createview member is implemented in this way:
code:
odgsviewptr odgsbasevectorizedevice::createview(const odgsclientviewinfo* pinfo, bool benablelayervisibilityperview)
{
odsmartptr<odgsviewimpl> pres = m_pmodule->createview();
pres->init(this, pinfo, benablelayervisibilityperview);
return pres;
}
if device is created by gsmodule instance, it holds m_pmodule pointer to module, so default createview works successfully. but if you create device on your own (using createobject, like in odvectorizeex), it doesn't know m_pmodule pointer, so default implementation throws exception. so if you create device using your createobject, you must implement createview override (like odvectorizeex).
in this particular case it is better to fix this bug (substitute function) manually directly in exgsgdivectorizedevice.cpp and recompile appropriate module. it is needn't to inherit from exgsgdivectorizedevice only for fixing this bug - in 1.14 it will be fixed in exgsgdivectorizedevice.
sincerely yours,
george udov
george,
thank you once again for your help. this makes things a lot clearer. if i understand correctly, this is what i need to do if i want to use the exgsgdivectorizedevice class instead of the odgsdevice class...
- make your changes in the beginpaint function
- write a createobject function for exgsgdivectorizedevice
- write a createview function for exgsgdivectorizedevice
just one thing i'm unsure of. you say i need createview because i don't have a module pointer. is it possible to create an instance of exgsgdivectorizedevice through a call to odgsmodule::createdevice, like i do for odgsdevice...
odgsmoduleptr pgs = :: odrxdynamiclinker()->loadmodule("wingdi.gs");
m_pdevice = pgs->createdevice();
can i somehow make createdevice return an exgsgdivectorizedevice? would this then mean that i don't need a createobject or createview function?
stuart
quote:
originally posted by george udov
the way around is substitute this function (exgsgdivectorizedevice.cpp)
code:
void exgsgdivectorizedevice::beginpaint()
{
...
if(m_bclearscreen)
::rectangle(hdc, m_outputrect.m_min.x, m_outputrect.m_max.y, m_outputrect.m_max.x, m_outputrect.m_min.y);
}
by this one
code:
void exgsgdivectorizedevice::beginpaint()
{
...
if(m_bclearscreen)
::rectangle(hdc, 0, 0, m_outputrect.m_max.x, m_outputrect.m_min.y);
}
we'll look into the problem - thank you.
i tried this work around in my application but found that the drawing extents still appear to be vertically offset by 20 pixels (see screen shot attached). the black band has now disappeared, but does anyone know if there is also a way to correct the drawing extents?
regards,
stuart
attached images (84.5 kb, 26 views)