1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0027880: Samples - fix handling of Unicode paths within MFC import/export sample

This commit is contained in:
kgv 2016-09-19 11:46:27 +03:00 committed by bugmaster
parent b357dcc225
commit e620e2857f
8 changed files with 34 additions and 45 deletions

View File

@ -4388,7 +4388,7 @@ Standard_Real Length = System.Mass();\n\
gp_Mat I = System.MatrixOfInertia();\n\ gp_Mat I = System.MatrixOfInertia();\n\
\n"); \n");
PocessTextInDialog("Linear Properties", Message); PocessTextInDialog("Linear Properties", Message);
MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, (const wchar_t* )string.ToExtString(), L"Linear Properties", MB_OK); MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, string.ToWideString(), L"Linear Properties", MB_OK);
} }
void CModelingDoc::OnSurface() void CModelingDoc::OnSurface()
@ -4503,7 +4503,7 @@ Standard_Real Area = System.Mass();\n\
gp_Mat I = System.MatrixOfInertia();\n\ gp_Mat I = System.MatrixOfInertia();\n\
\n"); \n");
PocessTextInDialog("Surface Properties", Message); PocessTextInDialog("Surface Properties", Message);
MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, (const wchar_t* )string.ToExtString(), L"Surface Properties", MB_OK); MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, string.ToWideString(), L"Surface Properties", MB_OK);
} }
@ -4585,7 +4585,7 @@ Standard_Real Volume = System.Mass();\n\
gp_Mat I = System.MatrixOfInertia();\n\ gp_Mat I = System.MatrixOfInertia();\n\
\n"); \n");
PocessTextInDialog("Volume Properties", Message); PocessTextInDialog("Volume Properties", Message);
MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, (const wchar_t* )string.ToExtString(), L"Volume Properties", MB_OK); MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, string.ToWideString(), L"Volume Properties", MB_OK);
} }

View File

@ -321,7 +321,7 @@ void CViewer2dDoc::OnBUTTONTestImage()
NULL, NULL,
NULL, NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
SupportedImageFormats() + "| all files (*.*)|*.*;||", SupportedImageFormats() + L"| all files (*.*)|*.*;||",
NULL); NULL);
CString anInitDir (((OCC_App*) AfxGetApp())->GetInitDataDir()); CString anInitDir (((OCC_App*) AfxGetApp())->GetInitDataDir());
@ -332,8 +332,7 @@ void CViewer2dDoc::OnBUTTONTestImage()
{ {
SetCursor(AfxGetApp()->LoadStandardCursor (IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor (IDC_WAIT));
CString aFilePath = anOpenImageDlg.GetPathName(); CString aFilePath = anOpenImageDlg.GetPathName();
TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )aFilePath); TCollection_AsciiString aFileName ((const wchar_t* )aFilePath);
TCollection_AsciiString aFileName (aFileNameW, '?');
//erase viewer //erase viewer
if(myAISContext->HasOpenedContext()) if(myAISContext->HasOpenedContext())
@ -355,7 +354,7 @@ void CViewer2dDoc::OnBUTTONMultipleImage()
NULL, NULL,
NULL, NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
SupportedImageFormats() + "| all files (*.*)|*.*;||", SupportedImageFormats() + L"| all files (*.*)|*.*;||",
NULL); NULL);
CString anInitDir (((OCC_App*) AfxGetApp())->GetInitDataDir()); CString anInitDir (((OCC_App*) AfxGetApp())->GetInitDataDir());
@ -367,8 +366,7 @@ void CViewer2dDoc::OnBUTTONMultipleImage()
{ {
SetCursor(AfxGetApp()->LoadStandardCursor (IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor (IDC_WAIT));
CString aFilePath = anOpenImageDlg.GetPathName(); CString aFilePath = anOpenImageDlg.GetPathName();
TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )aFilePath); TCollection_AsciiString aFileName ((const wchar_t* )aFilePath);
TCollection_AsciiString aFileName (aFileNameW, '?');
//erase viewer //erase viewer
if(myAISContext->HasOpenedContext()) if(myAISContext->HasOpenedContext())

View File

@ -143,8 +143,7 @@ Handle(AIS_TexturedShape) TexturesExt_Presentation::Texturize(const TopoDS_Shape
initfile += aTFileName.ToCString(); initfile += aTFileName.ToCString();
} }
TCollection_ExtendedString aFileName ((Standard_ExtString )(const wchar_t* )initfile); aTShape->SetTextureFileName (TCollection_AsciiString ((const wchar_t* )initfile));
aTShape->SetTextureFileName (TCollection_AsciiString (aFileName, '?'));
// do other initialization of AIS_TexturedShape // do other initialization of AIS_TexturedShape
aTShape->SetTextureMapOn(); aTShape->SetTextureMapOn();

View File

@ -134,19 +134,19 @@ void CImportExportApp::OnFileOpen()
// add to filter // add to filter
strFilter += strFilterName; strFilter += strFilterName;
ASSERT(!strFilter.IsEmpty()); // must have a file type name ASSERT(!strFilter.IsEmpty()); // must have a file type name
strFilter += (TCHAR)'\0'; // next string please strFilter += L'\0'; // next string please
strFilter += (TCHAR)'*'; strFilter += L'*';
strFilter += strFilterExt; strFilter += strFilterExt;
strFilter += (TCHAR)'\0'; // next string please strFilter += L'\0'; // next string please
dlg.m_ofn.nMaxCustFilter++; dlg.m_ofn.nMaxCustFilter++;
} }
// append the "*.*" all files filter // append the "*.*" all files filter
CString allFilter; CString allFilter;
VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER)); VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
strFilter += allFilter; strFilter += allFilter;
strFilter += (TCHAR)'\0'; // next string please strFilter += L'\0'; // next string please
strFilter += _T("*.*"); strFilter += L"*.*";
strFilter += (TCHAR)'\0'; // last string strFilter += L'\0'; // last string
dlg.m_ofn.nMaxCustFilter++; dlg.m_ofn.nMaxCustFilter++;
dlg.m_ofn.lpstrFilter = strFilter; dlg.m_ofn.lpstrFilter = strFilter;

View File

@ -213,7 +213,7 @@ void COcafDoc::OnCreatebox()
// Create a new box using the CNewBoxDlg Dialog parameters as attributes // Create a new box using the CNewBoxDlg Dialog parameters as attributes
TDF_Label L = TSC.CreateBox (Dlg.m_x, Dlg.m_y, Dlg.m_z, Dlg.m_w, Dlg.m_l, Dlg.m_h, TDF_Label L = TSC.CreateBox (Dlg.m_x, Dlg.m_y, Dlg.m_z, Dlg.m_w, Dlg.m_l, Dlg.m_h,
TCollection_ExtendedString ((Standard_ExtString )(const wchar_t* )Dlg.m_Name)); TCollection_ExtendedString ((const wchar_t* )Dlg.m_Name));
// Get the TPrsStd_AISPresentation of the new box TNaming_NamedShape // Get the TPrsStd_AISPresentation of the new box TNaming_NamedShape
Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(L, TNaming_NamedShape::GetID()); Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(L, TNaming_NamedShape::GetID());
@ -270,7 +270,7 @@ void COcafDoc::OnCreatecyl()
// Create a new box using the CNewCylDlg Dialog parameters as attributes // Create a new box using the CNewCylDlg Dialog parameters as attributes
TDF_Label L = TSC.CreateCyl (Dlg.m_x, Dlg.m_y, Dlg.m_z, Dlg.m_r, Dlg.m_h, TDF_Label L = TSC.CreateCyl (Dlg.m_x, Dlg.m_y, Dlg.m_z, Dlg.m_r, Dlg.m_h,
TCollection_ExtendedString ((Standard_ExtString )(const wchar_t* )Dlg.m_Name)); TCollection_ExtendedString ((const wchar_t* )Dlg.m_Name));
// Get the TPrsStd_AISPresentation of the new cylinder TNaming_NamedShape // Get the TPrsStd_AISPresentation of the new cylinder TNaming_NamedShape
Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(L, TNaming_NamedShape::GetID()); Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(L, TNaming_NamedShape::GetID());
@ -389,7 +389,7 @@ Handle(TFunction_Function) TFF; \n\
// Modify the box // Modify the box
TOcaf_Commands TSC(LabObject); TOcaf_Commands TSC(LabObject);
TSC.ModifyBox (Dlg.m_x, Dlg.m_y, Dlg.m_z, Dlg.m_w, Dlg.m_l, Dlg.m_h, TSC.ModifyBox (Dlg.m_x, Dlg.m_y, Dlg.m_z, Dlg.m_w, Dlg.m_l, Dlg.m_h,
TCollection_ExtendedString ((Standard_ExtString )(const wchar_t* )Dlg.m_Name), log); TCollection_ExtendedString ((const wchar_t* )Dlg.m_Name), log);
// Get the presentation of the box, display it and set it selected // Get the presentation of the box, display it and set it selected
Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(LabObject, TNaming_NamedShape::GetID()); Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(LabObject, TNaming_NamedShape::GetID());
@ -474,7 +474,7 @@ D->CommitCommand(); \n\
// Modify the cylinder // Modify the cylinder
TOcaf_Commands TSC(LabObject); TOcaf_Commands TSC(LabObject);
TSC.ModifyCyl (Dlg.m_x, Dlg.m_y, Dlg.m_z, Dlg.m_r, Dlg.m_h, TSC.ModifyCyl (Dlg.m_x, Dlg.m_y, Dlg.m_z, Dlg.m_r, Dlg.m_h,
TCollection_ExtendedString ((Standard_ExtString )(const wchar_t* )Dlg.m_Name), log); TCollection_ExtendedString ((const wchar_t* )Dlg.m_Name), log);
// Get the presentation of the cylinder, display it and set it selected // Get the presentation of the cylinder, display it and set it selected
Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(LabObject, TNaming_NamedShape::GetID()); Handle(TPrsStd_AISPresentation) prs= TPrsStd_AISPresentation::Set(LabObject, TNaming_NamedShape::GetID());
@ -591,7 +591,7 @@ D->CommitCommand(); \n\
// Modify the cylinder // Modify the cylinder
TOcaf_Commands ToolTSC(ToolLab); TOcaf_Commands ToolTSC(ToolLab);
ToolTSC.ModifyCyl (Dlg.m_x, Dlg.m_y, Dlg.m_z, Dlg.m_r, Dlg.m_h, ToolTSC.ModifyCyl (Dlg.m_x, Dlg.m_y, Dlg.m_z, Dlg.m_r, Dlg.m_h,
TCollection_ExtendedString ((Standard_ExtString )(const wchar_t* )Dlg.m_Name), log); TCollection_ExtendedString ((const wchar_t* )Dlg.m_Name), log);
// Redisplay the modified Tool object // Redisplay the modified Tool object
TDataStd_Integer::Set(ToolLab, 1); TDataStd_Integer::Set(ToolLab, 1);
@ -899,7 +899,7 @@ void COcafDoc::OnCloseDocument()
void COcafDoc::OnFileSaveAs() void COcafDoc::OnFileSaveAs()
{ {
const wchar_t* SPathName = PathName; const wchar_t* SPathName = PathName;
TCollection_ExtendedString TPathName ((Standard_ExtString )SPathName); TCollection_ExtendedString TPathName (SPathName);
CString Filter; CString Filter;
@ -928,7 +928,7 @@ void COcafDoc::OnFileSaveAs()
cout << "Save As " << CSPath << endl; cout << "Save As " << CSPath << endl;
PathName=CSPath; PathName=CSPath;
const wchar_t* SPath = CSPath; const wchar_t* SPath = CSPath;
TCollection_ExtendedString TPath ((Standard_ExtString )SPath); TCollection_ExtendedString TPath (SPath);
if (TPath.SearchFromEnd(".xml") > 0) if (TPath.SearchFromEnd(".xml") > 0)
{ {
@ -984,7 +984,7 @@ void COcafDoc::OnFileSave()
if(PathName!="") if(PathName!="")
{ {
const wchar_t* SPath = PathName; const wchar_t* SPath = PathName;
TCollection_ExtendedString TPath ((Standard_ExtString )SPath); TCollection_ExtendedString TPath (SPath);
if (TPath.SearchFromEnd(".xml") > 0) if (TPath.SearchFromEnd(".xml") > 0)
{ {
@ -1038,7 +1038,7 @@ m_App->SaveAs(myOcafDoc,(TCollection_ExtendedString) TPath); \n\
CString CSPath = dlg.GetPathName(); CString CSPath = dlg.GetPathName();
const wchar_t* SPath = CSPath; const wchar_t* SPath = CSPath;
TCollection_ExtendedString TPath ((Standard_ExtString )SPath); TCollection_ExtendedString TPath (SPath);
// Choose storage format // Choose storage format
if (TPath.SearchFromEnd(".xml") > 0) if (TPath.SearchFromEnd(".xml") > 0)
@ -1094,7 +1094,7 @@ BOOL COcafDoc::OnOpenDocument(LPCTSTR lpszPathName)
PathName = lpszPathName; PathName = lpszPathName;
const wchar_t* aPathName = lpszPathName; const wchar_t* aPathName = lpszPathName;
TCollection_ExtendedString anOccPathName ((Standard_ExtString)aPathName); TCollection_ExtendedString anOccPathName (aPathName);
// Open the document in the current application // Open the document in the current application
//PCDM_ReaderStatus RS = m_App->Open(TPath,myOcafDoc); //PCDM_ReaderStatus RS = m_App->Open(TPath,myOcafDoc);

View File

@ -715,8 +715,7 @@ const TCollection_AsciiString CDimensionDlg::GetUnits() const
return TCollection_AsciiString(); return TCollection_AsciiString();
CString aStr; CString aStr;
GetDlgItem (IDC_DisplayUnits)->GetWindowText (aStr); GetDlgItem (IDC_DisplayUnits)->GetWindowText (aStr);
TCollection_ExtendedString aCharsW ((Standard_ExtString )(const wchar_t* )aStr); return TCollection_AsciiString ((const wchar_t* )aStr);
return TCollection_AsciiString (aCharsW, '?');
} }
//======================================================================= //=======================================================================

View File

@ -273,8 +273,7 @@ dlg.m_ofn.lpstrInitialDir = initdir;
if (dlg.DoModal() == IDOK) if (dlg.DoModal() == IDOK)
{ {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )dlg.GetPathName()); TCollection_AsciiString aFileName ((const wchar_t* )dlg.GetPathName());
TCollection_AsciiString aFileName (aFileNameW, '?');
Standard_Integer status = ReadIGES (aFileName.ToCString(), aSequence); Standard_Integer status = ReadIGES (aFileName.ToCString(), aSequence);
if (status != IFSelect_RetDone) if (status != IFSelect_RetDone)
{ {
@ -338,8 +337,7 @@ dlg.m_ofn.lpstrInitialDir = initdir;
{ {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )dlg.GetPathName()); TCollection_AsciiString aFileName ((const wchar_t* )dlg.GetPathName());
TCollection_AsciiString aFileName (aFileNameW, '?');
result = SaveIGES (aFileName.ToCString(), aHSequenceOfShape); result = SaveIGES (aFileName.ToCString(), aHSequenceOfShape);
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
@ -400,8 +398,7 @@ dlg.m_ofn.lpstrInitialDir = initdir;
if (dlg.DoModal() == IDOK) if (dlg.DoModal() == IDOK)
{ {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )dlg.GetPathName()); TCollection_AsciiString aFileName ((const wchar_t* )dlg.GetPathName());
TCollection_AsciiString aFileName (aFileNameW, '?');
IFSelect_ReturnStatus ReturnStatus = ReadSTEP (aFileName.ToCString(), aSequence); IFSelect_ReturnStatus ReturnStatus = ReadSTEP (aFileName.ToCString(), aSequence);
switch (ReturnStatus) switch (ReturnStatus)
{ {
@ -518,8 +515,7 @@ IFSelect_ReturnStatus CImportExport::SaveSTEP(const Handle(TopTools_HSequenceOfS
if (aDlg.DoModal() == IDOK) { if (aDlg.DoModal() == IDOK) {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )aDlg.GetPathName()); TCollection_AsciiString aFileName ((const wchar_t* )aDlg.GetPathName());
TCollection_AsciiString aFileName (aFileNameW, '?');
STEPControl_StepModelType selection = aDlg.m_Cc1ModelType; STEPControl_StepModelType selection = aDlg.m_Cc1ModelType;
@ -605,11 +601,10 @@ dlg.m_ofn.lpstrInitialDir = initdir;
if (dlg.DoModal() == IDOK) { if (dlg.DoModal() == IDOK) {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )dlg.GetPathName()); TCollection_AsciiString aFileName ((const wchar_t* )dlg.GetPathName());
TCollection_AsciiString aFileName (aFileNameW, '?');
TCollection_AsciiString Message; TCollection_AsciiString Message;
result = SaveSTL (aFileName.ToCString(), aHSequenceOfShape, Message); result = SaveSTL (aFileName.ToCString(), aHSequenceOfShape, Message);
CString aMsg (Message.ToCString()); CString aMsg (TCollection_ExtendedString (Message).ToWideString());
MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, aMsg, result ? L"CasCade" : L"CasCade Error", result ? MB_OK : MB_ICONERROR); MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, aMsg, result ? L"CasCade" : L"CasCade Error", result ? MB_OK : MB_ICONERROR);
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }
@ -696,11 +691,10 @@ dlg.m_ofn.lpstrInitialDir = initdir;
if (dlg.DoModal() == IDOK) { if (dlg.DoModal() == IDOK) {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )dlg.GetPathName()); TCollection_AsciiString aFileName ((const wchar_t* )dlg.GetPathName());
TCollection_AsciiString aFileName (aFileNameW, '?');
TCollection_AsciiString Message; TCollection_AsciiString Message;
result = SaveVRML (aFileName.ToCString(), aHSequenceOfShape, anArrayOfColors, anArrayOfTransparencies, Message); result = SaveVRML (aFileName.ToCString(), aHSequenceOfShape, anArrayOfColors, anArrayOfTransparencies, Message);
CString aMsg (Message.ToCString()); CString aMsg (TCollection_ExtendedString(Message).ToWideString());
MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, aMsg, result ? L"CasCade" : L"CasCade Error", result ? MB_OK : MB_ICONERROR); MessageBoxW (AfxGetApp()->m_pMainWnd->m_hWnd, aMsg, result ? L"CasCade" : L"CasCade Error", result ? MB_OK : MB_ICONERROR);
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }

View File

@ -25,8 +25,7 @@ void OCC_BaseDoc::ExportView (const Handle(V3d_View)& theView) const
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
CString aFileExt = anExportDlg.GetFileExt(); CString aFileExt = anExportDlg.GetFileExt();
TCollection_ExtendedString aFileNameW ((Standard_ExtString )(const wchar_t* )anExportDlg.GetPathName()); TCollection_AsciiString aFileName ((const wchar_t* )anExportDlg.GetPathName());
TCollection_AsciiString aFileName (aFileNameW, '?');
// For vector formats use V3d_View::Export() method // For vector formats use V3d_View::Export() method
if (!(aFileExt.CompareNoCase (L"ps")) || !(aFileExt.CompareNoCase (L"pdf")) if (!(aFileExt.CompareNoCase (L"ps")) || !(aFileExt.CompareNoCase (L"pdf"))