1.unicode编码字符转 utf-8中文汉字:
#include <atlstr.h>
bool UnicodeToChinese(string str, CString& cstr)
{
int i = 0;
int j = 0;
int len = 0;
len = str.length();
if (len <= 0)
{
return false;
}
int nValue = 0;
WCHAR * pWchar;
wchar_t* szHex;
char strchar[6] = { '0','x','\0' };
for (i = 0; i < len; i++)
{
if (str[i] == 'u')
{
for (j = 2; j < 6; j++)
{
i++;
strchar[j] = str[i];
}
USES_CONVERSION;
szHex = A2W(strchar);
StrToIntExW(szHex, STIF_SUPPORT_HEX, &nValue);
pWchar = (WCHAR*)& nValue;
cstr = cstr + pWchar;
}
}
return true;
}
void test3() {
//待雪初平和望断秋高
string m_Unicode = "\\u5f85\\u96ea\\u521d\\u5e73\\u548c\\u671b\\u65ad\\u79cb\\u9ad8";
CString m_UnicodeToChinese;
UnicodeToChinese(m_Unicode, m_UnicodeToChinese);
cout << m_Unicode << "\n" << "UnicodeToChinese:" << "\n";
wcout << m_UnicodeToChinese.GetString() << endl;
//CString c_name = _T("li");
//所以CT2A其实就是CW2A就是将Unicode转换为多字符集ASCII,也可写成CW2A
std::string str = CT2A(m_UnicodeToChinese.GetString());
}
###################################################
occ动画:
TopoDS_Shape aTopoBox1 = BRepPrimAPI_MakeBox(10,20,30).Shape();
Handle(AIS_Shape) hBox1 = new AIS_Shape(aTopoBox1);
hBox1->SetColor(Quantity_NOC_RED);
myOccView->getContext()->Display(hBox1,Standard_True);
//animation
TCollection_AsciiString name("anim");
Handle(AIS_Animation) anim = new AIS_Animation(name);
double durationTime =20;
anim->SetOwnDuration(durationTime);
//anim->StartTimer(0,1.0,true);
gp_Trsf start_pnt, end_pnt;
start_pnt.SetValues(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0);
end_pnt.SetValues(5, 0, 0, 800,
0, 5, 0, 0,
0, 0, 5, 0);
Handle(AIS_AnimationObject) aisObj = new AIS_AnimationObject("boxObj", myOccView->getContext(), hBox1, start_pnt, end_pnt);
aisObj->SetOwnDuration(durationTime);
aisObj->SetStartPts(0);//?
anim->Add(aisObj);
anim->StartTimer(0, 1.0, true);
//anim->Start(true);
aisObj->Start(true);
int i=1;
while (!anim->IsStopped())
{
qDebug() << i++ << " " << aisObj->ElapsedTime() << endl;
anim->UpdateTimer();
anim->UpdateTotalDuration();
//anim->
//myOccView->getContext()->SetLocation();
//aisObj->Update(0.01*i);
myOccView->getContext()->UpdateCurrentViewer();
if(myOccView->myView->IsInvalidated()){
myOccView->myView->Redraw();
qDebug() << " IsInvalidated ";
}
else{
myOccView->myView->RedrawImmediate();
}
//myOccView->getContext()->DisplayAll(true);
}
版权声明:本文为qq_46582938原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。