DiscussionsIssue archiveOCCT:Visualization

Archived issue #0021985

Vista/WIndows 7 compatibility issues reported by the community

CommunityOCCT:Visualizationclosed14 public notes

Search issues

Description

There are several compatibility issues reported by the community for OCCT
visualization component.

1. OCC 6.3.1 Windows7 bug

*************************************************
In order to be able to load one of our OCC based DLL’s in Windows 7, we needed
to modify src\Graphic3d\Graphic3d_WNTGraphicDevice.cxx.

Around line 51 we changed:

  Standard_CString TheShr = getenv("CSF_GraphicShr");
  if ( ! TheShr )
    TheShr = "TKOpenGl.dll";

Into:

  Standard_CString TheShr = getenv("CSF_GraphicShr");
  if ( ! TheShr || (strcmp(TheShr,"")==0) )
    TheShr = "TKOpenGl.dll";

*************************************************

SAN: I believe strlen(TheShr) == 0 is a more natural way to check for an empty
string.

2. About compatibility with Windows 7

*************************************************

I have now compiled under Windows 7, using OpenCascade 6.3.0
I have noticed the following problem:

The function WNT_Window:: Dump does not work correctly.
This function is used in the MFC standard example 01_Geometry, where it
is called from menu option File>>Export>>Image...
The problem is that instead of the correct image of the drawing window
it produces an empty grey image.

The same problem exists in Windows Vista.
There is no problem for Windows XP.

*************************************************

SAN: In order to approach the problem, it is necessary to revise all OCCT API
methods related to 2D/3D scene dump creation and eliminate duplicated
functionality (if any) in WNT/Xw/OpenGl packages, keeping e.g. only the
following imlementations (to be discussed):
- Reading window pixels directly.
- Redrawing window contents to an off-screen bitmap (suitable for non-OpenGL
scene only!).
- Redrawing OpenGL scene contents to a framebuffer object (FBO) and reading its
data.

Public activity

14 archived notes

Participants are labeled by their role within this record.

01Commenter 1
As of OCCT 6.5.2: point 1 is fixed, point 2 is still there
02Commenter 2
Dear aba,

Could you, please, review OCCT samples and replace all occurrences of WNT_Window::Dump() with V3d_View::ToPixMap() calls?
03Commenter 3
In OCCT samples with 3d visualization all WNT_Window::Dump method calls were replaced with V3dView::Dump method calls.

In 2d visualization OCCT sample Viewer2d in OCC_2dView.cpp WNT_Window::Dump method call wasn't replaced.

The methods WNT_Window::Dump and V3dView::Dump were checked:
OnFileExportImage() message handlers provide possibility to export models in files with .bmp, .gif and .xwd extensions, but during image saving (in Image_AlienPixMap::Save method) FreeImage_GetFIFFromFilename method recognizes .xwd extension as FIF_UNKNOWN and therefore it isn't possible to export in .xwd file.

The Git branch CR21985 is ready to be reviewed.
Dear san. please review.
04Commenter 4
Branch CR21985 reviewed with the following remark.

Modified files:

samples/mfc/standard/01_Geometry/src/GeometryView.cpp
samples/mfc/standard/09_Animation/src/AnimationView3D.cpp
samples/mfc/standard/Common/OCC_3dView.cpp

now contain the same line:

myView->Dump((Standard_CString)(LPCTSTR)filename);

C-style casting to Standard_CString from LPCTSTR that can point to a Unicode string if UNICODE is defined is unsafe.
KGV suggests removing both casts:

myView->Dump(filename);

In such a case compiler will inform a developer if an attempt to pass a Unicode string to non-Unicode function is being made.
Otherwise, corrupted Unicode data will be passed as a regular C-style string to V3d_View::Dump() method.
05Commenter 5
The Git branch CR21985 was updated.
Casts to LPCTSTR and Standard_CString were removed.

Dear san, please review.
06Commenter 1
Dear aba,

In file OCC_3dView.cpp, 155-182:
> filter = _T("BMP Files (*.BMP)|*.bmp|GIF Files (*.GIF)|*.gif|XWD Files
>(*.XWD)|*.xwd|PS Files (*.PS)|*.ps|EPS Files (*.EPS)|*.eps|TEX Files
>(*.TEX)|*.tex|PDF Files (*.PDF)|*.pdf|SVG Files (*.SVG)|*.svg|PGF Files
>(*.PGF)|*.pgf||");
> ...
> char* theFile = new char[filename.GetLength()+1];
> //_tcscpy(theFile,filename);
> strcpy_s(theFile,filename.GetLength()+1,filename);
> CString ext = dlg.GetFileExt();
> if (ext == "ps" || ext == "emf")
> {
It seems that this extension detection is incomplete:
- SetCursor() is not called within Export() scenario.
- Export function should be used for extensions PS, EPS, TEX, PDF, SVG, PGF, EMF.
- String comparison should be case-insensitive.
- theFile variable looks redundant here.
Also:
- Please rename "filename" variable to "aFileName".

File AnimationView3D.cpp, 241-244 and GeometryView.cpp, 80-83, OCC_3dView.cpp:
>void CAnimationView3D::OnFileExportImage()
>{
> CFileDialog dlg(FALSE,_T("*.BMP"),NULL,OFN_HIDEREADONLY |
> OFN_OVERWRITEPROMPT, _T("BMP Files (*.BMP)|*.bmp |GIF Files (*.GIF)|*.gif
>| XWD Files (*.XWD)|*.xwd||"), NULL );
Please extend list of supported extensions (based on FreeImage).
07Commenter 7
Just a question to everybody: is the list of supported export image file formats documented anywhere?
Or should one check vdump DRAW command of FreeImage headers each time?
Is not it worth adding this information to Image_AlienPixMap.hxx?
08Commenter 1
Dear aba,

please add information about following supported formats to Image_AlienPixMap documentation and use it in the samples (notice that there are no XWD format):
*.bmp - bitmap image, lossless format without compression.
*.ppm - PPM (Portable Pixmap Format), lossless format without compression.
*.png - PNG (Portable Network Graphics) lossless format with compression.
*.jpg, *.jpe, *.jpeg - JPEG/JIFF (Joint Photographic Experts Group) lossy format (compressed with quality losses). YUV color space used (automatically converted from/to RGB).
*.tif, *.tiff - TIFF (Tagged Image File Format).
*.tga - TGA (Truevision Targa Graphic), lossless format.
*.gif - GIF (Graphical Interchange Format), lossy format. Color stored using pallete (up to 256 distinct colors).
*.exr - OpenEXR high dynamic-range format (supports float pixel formats).
09Commenter 9
The Git granch CR21985 was modified.

In files OCC_3dView.cpp, AnimationView3D.cpp and GeometryView.cpp:
  1)in OnFileExportImage() methods lists of supported extensions were extended according to FreeImage supported image formats.
  2)'filename' variable was renamed to 'aFileName'


In OCC_3dView.cpp:
1)In Export() function is used for PS, EPS, TEX, PDF, SVG, PGF and EMF extensions.
2)In condition checking supported for Export() function formats case-insensitive string comparison was added.
3) 'theFile' variable was removed, and the only 'aFileName' variable is used for both Export() and Dump() methods

Please review.
10Commenter 10
Branch CR21985 reviewed without remarks, ready for testing.
11Commenter 11
Dear Commenter 2,

Why this issue is suspended?
Note that it has been waiting for testing for two weeks.
12Commenter 12
Dear aba,

Could you please update the supported image file types and file filters for 2D viewer samples, too?
13Commenter 13
The supported image file filter for 2d samples in OCC_2dView::OnFileExportImage() method was extended with formats supported by FreeImage (bmp, gif, png, jpeg, ppm, tiff, tga, exr).

The Git branch CR21985 was updated.
Dear san, please review.
14Commenter 14
Branch CR21985 reviewed without remarks, ready for testing.