几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-06, 08:55 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】odgsdeviceonsize problem

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)
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】oda 1.06 vs new 1.08 and 1.09 nls problem yang686526 DirectDWG 0 2009-05-06 06:50 PM
【转帖】dimentions problem in import export using dwgdirec yang686526 DirectDWG 0 2009-05-04 07:43 PM
【转帖】color conversion problem dd 1.14.01 yang686526 DirectDWG 0 2009-05-04 05:53 PM
【转帖】cannot open a dwg file in autocad - random problem yang686526 DirectDWG 0 2009-05-04 05:28 PM
【转帖】vista and addin dll problem yang686526 SolidWorks二次开发 0 2009-04-13 03:19 PM


所有的时间均为北京时间。 现在的时间是 05:07 AM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多