查看单个帖子
旧 2009-05-06, 06:32 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】newbie question trying to extend singledoc with with zoom-w

newbie question: trying to extend singledoc with with zoom_w
newbie question: trying to extend singledoc with with zoom_window func.
hi,
i looked at the zoom_window example in odamfcapp, but it is sooo complicated and there is lots of stuff that i don't need in my simple case.. i tried to simplify/adjust the zoom_window example, but i can't get it to work.
pls help
here's what i have:
i have a simple dxf file with just 1 polyline in it. attached file.
i have a user selected area - rectangle.
i have pt1 (upper left corner)and pt2 (bottom right corner) in some device coordinates. model space.
now i do the following:
////////////////////////////////////////////////////////
oddbobjectptr pvpobj = getdocument()->m_pdb->activeviewportid().safeopenobject(oddb::kforread) ;
oddbabstractviewportdataptr pavd(pvpobj);
odgsview* pview = m_pdevice->viewat(0);
//skip the xworldtoeye transformation, because my dxf is not in wcs but in ucs
odgevector3d eyevec = pt2 - pt1;
if(odnonzero(eyevec.x) && odnonzero(eyevec.y))
(odnonzero(eyevec.x) && odnonzero(eyevec.y))
{
odgepoint3d newpos = pt1 + eyevec / 2.;
eyevec.x = fabs(eyevec.x);
eyevec.y = fabs(eyevec.y);
pview->dolly( newpos.asvector() );
double wf = pview->fieldwidth() / eyevec.x;
double hf = pview->fieldheight() / eyevec.y;
pview->zoom(odmin(wf, hf));
}
pavd->setview(pvpobj, pview);
m_pdevice->update();
/////////////////////////////////////////////////////////
this code does zoom, but not corectly and not the selected area.
please help - i really need to get it to work.
also, i couldn't find the tranformation from device coordinates to ucs?!? i wanted to check device coordinates converted to ucs give me result similar to my polyline coordinates...but i couldn't find the transformation formula??
p.s. i also tried this code with dwg file and used the worldtoeye transformation - same thing! - it does zoom, but not the selected area.
thank you in advance
//nora
attached files

hi,
quote:
i have pt1 (upper left corner)and pt2 (bottom right corner) in some device coordinates. model space.
what you mean as "some device coordinates"? you should know what coordinate system you are use - to determine correct transformation. in odamfcapp example, input coordinates is in wcs, but in dolly() and zoom() methods you should use eye coordinate space.
quote:
also, i couldn't find the tranformation from device coordinates to ucs?!? i wanted to check device coordinates converted to ucs give me result similar to my polyline coordinates...but i couldn't find the transformation formula??
see odamfcapp example. following methods in [editorobject.cpp] file:
void odexeditorobject::ucsplane(odgeplane& plane) const
bool odexeditorobject::toucstoworld(odgepoint3d& wcspt) const
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)