輸出精度控制

【小數位數】、【小數精度】

小數位的顯示長度控制需要兩步設置,其實比較簡單,比如:

#include <sstream>

osgText::Text* text = dynamic_cast<osgText::Text*>(textNode->getDrawable(0));
std::wstringstream ss;
osg::Vec3d pos = _osgView->getCursorPickPoint();

//設置小數位數只保留3位,整數部分不限制
ss.setf(std::ios::fixed, std::ios::floatfield);
ss.precision(3);

ss << L"X:" << pos.x() << L", Y:"  << pos.y() << L", Z:" << pos.z() ;
text->setText(ss.str().c_str()); 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章