几何尺寸与公差论坛------致力于产品几何量公差标准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, 11:00 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】problem setting layout and extensions of the layou

problem setting layout and extensions of the layout
problem setting layout and extensions of the layout
with some dwg files i have a serious problem when i try to set some of the layouts and their extensions.
i use the following class to save all the informations of the dwg:
class cinstancedata
{
public:
oddbdatabaseptr pdb;
odgicontextfordbdatabaseptr pdwgcontext; // vectorization context.
odgsdeviceptr pdevice; // rendering device and set the output stream for the device.
oddblayertableptr players; // layer table
oddbsymboltableiteratorptr playeriterator;
odarray<odstring> layouts;
uint ncurrlayout;
uint nlayoutpos;
colorref nbackgroundcolor;
double minx;
double miny;
double maxx;
double maxy;
bool bdrawenabled;
};
every time the user chooses the layout to set, i call the following methods (handle is a reference to the class
cinstancedata illustrated above, and szlayout is the name of the layout).
with this method i can set and see all the layouts correctly but with the layout named "model" i cannot see the drawing,
while with odamfcapp application i can see the layout "model" correctly.
can anyone tell me how to solve the problem or where is the mistake in my code?
void winapi setactivelayout(long handle, lpctstr szlayout)
{
afx_manage_state(afxgetstaticmodulestate());
assert(handle);
if (!handle)
return;
cinstancedata *pdata = (cinstancedata *)handle;
// create device using gdi graphic engine
pdata->pdevice = null;
pdata->pdevice = theapp.m_pgswingdi->createdevice();
// search for layout
for (uint i = 0; i < pdata->layouts.size(); i++)
{
if (pdata->layouts[i].icompare(szlayout) == 0)
break;
}
// if non found, load first layout
if (i == pdata->layouts.size())
pdata->ncurrlayout = 0;
else
pdata->ncurrlayout = i;
pdata->pdb->setcurrentlayout(pdata->layouts[pdata->ncurrlayout]);
pdata->pdevice = oddbgsmanager::setupactivelayoutviews(pdata->pdevice, pdata->pdwgcontext);
odgsview *pview = pdata->pdevice->viewat(0);
odabstractviewpeptr pviewabs(pview);
odgeboundblock3d boxext;
odgepoint3d gmin;
odgepoint3d gmax;
bool bbboxvalid;
try
{
bbboxvalid = pviewabs->viewextents(pview,boxext);
}
catch (...)
{
bbboxvalid = false;
}
odgspaperlayouthelperptr ppaperlayouthelper = odgspaperlayouthelper::cast(pdata->pdevice);
if(ppaperlayouthelper.get() && ppaperlayouthelper->overallview().get() == pview)
{
if(!bbboxvalid || !(boxext.minpoint().x < boxext.maxpoint().x && boxext.minpoint().y < boxext.maxpoint().y))
{
bbboxvalid = ::getlayoutextents(ppaperlayouthelper->layoutid(), pview, boxext);
}
}
else if(!bbboxvalid) // model space viewport
{
odgslayouthelperptr playouthelper = odgslayouthelper::cast(pdata->pdevice);
if(playouthelper.get())
{
bbboxvalid = ::getlayoutextents(playouthelper->layoutid(), pview, boxext);
}
}
if(!bbboxvalid)
{
// set to somewhat reasonable (e.g. paper size)
if(pdata->pdb->getmeasurement()==oddb::kmetric)
{
boxext.set(odgepoint3d::korigin, odgepoint3d(297., 210., 0.)); // set to papersize iso a4 (portrait)
}
else
{
boxext.set(odgepoint3d::korigin, odgepoint3d(11., 8.5, 0.)); // ansi a (8.50 x 11.00) (landscape)
}
boxext.transformby(pview->viewingmatrix());
}
odgematrix3d word2eye= pview->viewingmatrix().inverse();
boxext.transformby(word2eye);
boxext.getminmaxpoints(gmin, gmax);
pdata->minx = gmin.x;
pdata->miny = gmin.y;
pdata->maxx = gmax.x;
pdata->maxy = gmax.y;
pview->setviewportbordervisibility(false);
pview->orbit(3.1415926535897932384626433, 0.0);
setbackgroundcolor(handle, pdata->nbackgroundcolor);
setupextents(handle);
return;
}
void setupextents(long handle)
{
if (((cinstancedata *)handle)->minx == ((cinstancedata *)handle)->maxx)
return;
if (((cinstancedata *)handle)->miny == ((cinstancedata *)handle)->maxy)
return;
odgepoint3d min(((cinstancedata *)handle)->minx, ((cinstancedata *)handle)->miny, 0.0);
odgepoint3d max(((cinstancedata *)handle)->maxx, ((cinstancedata *)handle)->maxy, 0.0);
odgeextents3d ext(min, max);
if (ext.isvalidextents() == false)
return;
odgsview* pview = ((cinstancedata *)handle)->pdevice->viewat(0);
odgepoint3d targ = pview->target();
odgevector3d dirfromtarg = pview->position() - targ;
// set target to center of the scene, keep view direction:
targ = ext.minpoint() + (ext.maxpoint() - ext.minpoint()) / 2.0;
if(pview->isfrontclipped() || pview->isbackclipped())
{
// keep distance from target to front & back planes
targ = targ.orthoproject(odgeplane(pview->target(), dirfromtarg));
}
// world extents to view cs:
ext.transformby(pview->viewingmatrix());
double fw = ext.maxpoint().x - ext.minpoint().x;
double fh = ext.maxpoint().y - ext.minpoint().y;
pview->setview(targ + dirfromtarg, targ, pview->upvector(), fw, fh);
}
thank you
attached files
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


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

高级搜索
显示模式

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

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

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】dwg without layout extension information yang686526 DirectDWG 0 2009-05-05 08:11 AM


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


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