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

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】establishing the active database (http://www.dimcax.com/hust/showthread.php?t=16132)

yang686526 2009-05-05 09:53 AM

【转帖】establishing the active database
 
establishing the active database.
establishing the active database.
hello,
this code is copied from the one you use in oninitialupdate in odamfcapp.
my target is to change the file that is shown on the view.
apparently it works fine although if i want the view showing the new file immediately with his correct size, i need a call to onsize or another method that redraws the window.
縒hy this call is not needed in oninitialupdate?.
縄s it safe deleting the old database like i do?
縄s it safe deleting the old device like i do?
void cdwgviewer::onchangedatabase()
{
m_pdevice = null;
pdb = null;
//strfilename is obtained from a dialog box.
pdb = theapp.readfile(strfilename, false, false, oda::ksharedenyno );
odgicontextfordbdatabase::setdatabase(pdb);
if (!pdb.isnull())
{
// begin rendering
odgsdcrect screenrect(odgsdcpoint(0, 0), odgsdcpoint(100, 100));
// create the custom rendering device
odgsdeviceptr pdevice = new odrxobjectimpl<exgssimpledevice>();
exgssimpledevice* pexdevice = (exgssimpledevice*)pdevice.get();
// set the output stream and database for the device.
pexdevice->setattribs(stdout);
pexdevice->setdatabase(pdb);
// prepare the device to render the active layout in this database.
pdevice = oddbgsmanager::setupactivelayoutviews(pdevice, pexdevice);
onoptionsrenderingdevicechanged();
//crect rc;
//getclientrect(rc);
//odgsdcrect outputrect( odgsdcpoint(rc.left, rc.bottom),
// odgsdcpoint(rc.right, rc.top) );
// m_pdevice->onsize(outputrect);
// initiate rendering.
pdevice->update(&screenrect);
// end rendering
redrawwindow();
}
}
best regards.
i believe its safe to
m_pdevice = null;
pdb = null;
since pdb is a smarpointer oddbdatabaseptr which should release and delete.
however, i can't fully answer your questions because i do know know how your classes are defined/derived, where pdb and m_pdevice are defined ect.
i assume that if it works with no leaks or crashing then all is fine


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