Archived issue #0022879
Possible bug in Opengl_togl_begin_layer_mode.cxx
Description
Post from the Forum (Massimo Del Fedele) - http://www.opencascade.org/org/forum/thread_22425/.
"The code here :
/*
* On gere le type de font (ASCII !)
*/
if ( strcmp( (char*)FTGLLayerFontName, (char*)font ) != 0 &&
FTGLLayerFontAspect == aspect &&
FTGLLayerFontHeight == height
)
{
makes no sense to me.... it's re-setting font data ONLY if font NAME is different AND font aspect and height are equal... I think it should be like this :
if ( strcmp( (char*)FTGLLayerFontName, (char*)font ) != 0 ||
FTGLLayerFontAspect != aspect ||
FTGLLayerFontHeight != height
)
Anyways, even after pathcing code as whown, font size bug in layer remains... so there must be some other problem.
BTW, the coding style is quite weird... why, for example :
FTGLLayerFontName[0] = '\0';
strcat( (char*)FTGLLayerFontName, (char*)font );
instead of a more simple
strcpy(.....) ??
"
The issue is confirmed as a bug by SAN.
"The code here :
/*
* On gere le type de font (ASCII !)
*/
if ( strcmp( (char*)FTGLLayerFontName, (char*)font ) != 0 &&
FTGLLayerFontAspect == aspect &&
FTGLLayerFontHeight == height
)
{
makes no sense to me.... it's re-setting font data ONLY if font NAME is different AND font aspect and height are equal... I think it should be like this :
if ( strcmp( (char*)FTGLLayerFontName, (char*)font ) != 0 ||
FTGLLayerFontAspect != aspect ||
FTGLLayerFontHeight != height
)
Anyways, even after pathcing code as whown, font size bug in layer remains... so there must be some other problem.
BTW, the coding style is quite weird... why, for example :
FTGLLayerFontName[0] = '\0';
strcat( (char*)FTGLLayerFontName, (char*)font );
instead of a more simple
strcpy(.....) ??
"
The issue is confirmed as a bug by SAN.
Additional information
SetTextAttributes method has been fixed in OpenGl_GraphicDriver.
This method now sets font name, type of display text and color of background for subtitle or decal text display for overlayer or underlayer text.
Without this fix, only font name argument has an effect.
There are four different type of display text available:
- Aspect_TODT_NORMAL, display text as usual,
- Aspect_TODT_SUBTITLE, display text on colored background,
- Aspect_TODT_DEKALE, display text with colored outlines,
- Aspect_TODT_BLEND, display text with blended colors.
The color of the font itself can be set with method SetColor in OpenGl_GraphicDriver.
Changes in packages:
OpenGl package:
1) OpenGl_GraphicDriver - method SetTextAttributes now correctly processes the Font, Type, R, G, B parameters.
V3d package:
1) V3d_ColorScale - text attributes changed from Aspect_TODT_SUBTITLE to Aspect_TODT_NORMAL.
2) V3d_LayerMgr - text attributes on beginnig of redraw of the layers in method V3d_LayerMgr::Begin() changed from Aspect_TODT_SUBTITLE to Aspect_TODT_NORMAL.
ViewerTest package:
1) Text attributes testing command "voverlaytext" implemented.
This method now sets font name, type of display text and color of background for subtitle or decal text display for overlayer or underlayer text.
Without this fix, only font name argument has an effect.
There are four different type of display text available:
- Aspect_TODT_NORMAL, display text as usual,
- Aspect_TODT_SUBTITLE, display text on colored background,
- Aspect_TODT_DEKALE, display text with colored outlines,
- Aspect_TODT_BLEND, display text with blended colors.
The color of the font itself can be set with method SetColor in OpenGl_GraphicDriver.
Changes in packages:
OpenGl package:
1) OpenGl_GraphicDriver - method SetTextAttributes now correctly processes the Font, Type, R, G, B parameters.
V3d package:
1) V3d_ColorScale - text attributes changed from Aspect_TODT_SUBTITLE to Aspect_TODT_NORMAL.
2) V3d_LayerMgr - text attributes on beginnig of redraw of the layers in method V3d_LayerMgr::Begin() changed from Aspect_TODT_SUBTITLE to Aspect_TODT_NORMAL.
ViewerTest package:
1) Text attributes testing command "voverlaytext" implemented.
Public activity
8 archived notes
Participants are labeled by their role within this record.
To be processed after integration of #0022819
The following issues has been fixed:
- SetTextAttributes method now affects the type of display text: it is defined on Visual3d_Layer level in accordance with Aspect_TypeOfDisplayText enumeration; this allows to display text in 4 modes: normal, subtitle (with colored background), decal (with colored outlines), blend (mixing colors). The R, G, B values defines the color of the background for subtitle and blend display types.
- The problems with text height and text font are no longer exist in updated OpenGl_GraphicDriver.
- Draw command for overlay text testing purposes "voverlaytext" added
=============================================================================
Dear San,
Could you please review the modification in branch:
http://svn/svn/occt/branches/OCC22879
- SetTextAttributes method now affects the type of display text: it is defined on Visual3d_Layer level in accordance with Aspect_TypeOfDisplayText enumeration; this allows to display text in 4 modes: normal, subtitle (with colored background), decal (with colored outlines), blend (mixing colors). The R, G, B values defines the color of the background for subtitle and blend display types.
- The problems with text height and text font are no longer exist in updated OpenGl_GraphicDriver.
- Draw command for overlay text testing purposes "voverlaytext" added
=============================================================================
Dear San,
Could you please review the modification in branch:
http://svn/svn/occt/branches/OCC22879
"voverlaytext" testing command added with the following syntax:
voverlaytext TextString X Y [TextHeight] [FontName] [R G B(TextColor)] [DisplayType] [R G B (BackgroundColor)]
TextString - the string with text;
X, Y - where to display the text;
TextHeight - height of the displayed text (default 10.0)
FontName - name of the font to be used (default Courier);
TextColor - Three real values that define the color of the text (default 1.0 1.0 1.0)
DisplayType - display type of the text, might be {normal/subtitle/decal/blend}
BackgroundColor - Three real values that define the color of the subtitle or decal background (default 1.0 1.0 1.0)
The example scenario to test the overlay text parameters:
pload AISV
vinit
# check text height
voverlaytext "Text Height=14" 10.0 10.0 14.0
voverlaytext "Text Height=25" 10.0 40.0 25.0
# check text text font and color
voverlaytext "Arial" 10.0 60.0 18.0 "Arial" 1.0 0.0 0.0
voverlaytext "Times New Roman" 10.0 80.0 20.0 "Times New Roman" 0.0 0.0 1.0
# check display type
voverlaytext "Type1" 10.0 110.0 20.0 "Arial" 1.0 0.0 0.0 subtitle 0.3 0.3 0.3
voverlaytext "Type2" 10.0 130.0 20.0 "Arial" 0.5 0.5 0.3 decal 0.8 0.8 0.8
voverlaytext "Type3" 10.0 150.0 20.0 "Arial" 0.5 0.5 0.3 blend
# check blend:
pload MODELING
box b 10 10 10
vdisplay b
vsetdispmode b 1 ... and move the box under the text to see blended colors.
voverlaytext TextString X Y [TextHeight] [FontName] [R G B(TextColor)] [DisplayType] [R G B (BackgroundColor)]
TextString - the string with text;
X, Y - where to display the text;
TextHeight - height of the displayed text (default 10.0)
FontName - name of the font to be used (default Courier);
TextColor - Three real values that define the color of the text (default 1.0 1.0 1.0)
DisplayType - display type of the text, might be {normal/subtitle/decal/blend}
BackgroundColor - Three real values that define the color of the subtitle or decal background (default 1.0 1.0 1.0)
The example scenario to test the overlay text parameters:
pload AISV
vinit
# check text height
voverlaytext "Text Height=14" 10.0 10.0 14.0
voverlaytext "Text Height=25" 10.0 40.0 25.0
# check text text font and color
voverlaytext "Arial" 10.0 60.0 18.0 "Arial" 1.0 0.0 0.0
voverlaytext "Times New Roman" 10.0 80.0 20.0 "Times New Roman" 0.0 0.0 1.0
# check display type
voverlaytext "Type1" 10.0 110.0 20.0 "Arial" 1.0 0.0 0.0 subtitle 0.3 0.3 0.3
voverlaytext "Type2" 10.0 130.0 20.0 "Arial" 0.5 0.5 0.3 decal 0.8 0.8 0.8
voverlaytext "Type3" 10.0 150.0 20.0 "Arial" 0.5 0.5 0.3 blend
# check blend:
pload MODELING
box b 10 10 10
vdisplay b
vsetdispmode b 1 ... and move the box under the text to see blended colors.
The SVN branch reviewed with the following remarks.
OpenGl_GraphicDriver_Layer.cxx
===========================================
Is it really correct to enable blending by the code below without specifying the blend function??? Is blending really needed here at all?
switch (aDispType)
301 {
302 // blend type
303 case Aspect_TODT_BLEND:
304 {
305 isBlend = glIsEnabled(GL_BLEND);
306 if (!isBlend)
307 glEnable(GL_BLEND);
308
309 glEnable(GL_COLOR_LOGIC_OP);
310 glLogicOp(GL_XOR);
311 }
312 break;
and here:
if (aDispType == Aspect_TODT_BLEND)
415 {
416 if (!isBlend)
417 glDisable(GL_BLEND);
418
419 glDisable(GL_COLOR_LOGIC_OP);
420 }
OpenGl_GraphicDriver_Layer.cxx
===========================================
Is it really correct to enable blending by the code below without specifying the blend function??? Is blending really needed here at all?
switch (aDispType)
301 {
302 // blend type
303 case Aspect_TODT_BLEND:
304 {
305 isBlend = glIsEnabled(GL_BLEND);
306 if (!isBlend)
307 glEnable(GL_BLEND);
308
309 glEnable(GL_COLOR_LOGIC_OP);
310 glLogicOp(GL_XOR);
311 }
312 break;
and here:
if (aDispType == Aspect_TODT_BLEND)
415 {
416 if (!isBlend)
417 glDisable(GL_BLEND);
418
419 glDisable(GL_COLOR_LOGIC_OP);
420 }
Dear San,
The redundant code blocks were removed, also the draw command was slightly corrected: color values R G B can be ranged from 0 to 255.
Please review the changes in branch:
http://svn/svn/occt/branches/OCC22879
The redundant code blocks were removed, also the draw command was slightly corrected: color values R G B can be ranged from 0 to 255.
Please review the changes in branch:
http://svn/svn/occt/branches/OCC22879
The SVN branch reviewed without remarks, ready for testing.
Dear Commenter 1,
SVN branch http://svn/svn/occt/branches/OCC22879 hes been moved to GIT CR22879 one.
Workbench KAS:dev:mkv-22879-occt was created from git branch CR22879
(and mkv-22879-products from svn trunk) and compiled on Linux platform.
There are not regressions in mkv-22879-products regarding to KAS:dev:products-20120306-opt
Test case for this fix is chl 934 V3. It's OK.
See results in /QADisk/occttests/results/KAS/dev/mkv-22879-products_13032012/lin
See reference results in /QADisk/occttests/results/KAS/dev/products-20120306-opt_07032012/lin
See test cases in /QADisk/occttests/tests/ED
SVN branch http://svn/svn/occt/branches/OCC22879 hes been moved to GIT CR22879 one.
Workbench KAS:dev:mkv-22879-occt was created from git branch CR22879
(and mkv-22879-products from svn trunk) and compiled on Linux platform.
There are not regressions in mkv-22879-products regarding to KAS:dev:products-20120306-opt
Test case for this fix is chl 934 V3. It's OK.
See results in /QADisk/occttests/results/KAS/dev/mkv-22879-products_13032012/lin
See reference results in /QADisk/occttests/results/KAS/dev/products-20120306-opt_07032012/lin
See test cases in /QADisk/occttests/tests/ED
Integrated into master
Related records