1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0026862: Configuration - avoid usage of 3rd-party headers within OpenGl_View and D3DHost_View

Move Font_FTFont::Rect structure into dedicated header Font_FTFont.
D3DHost_View, OpenGl_Font, Font_TextFormatter - use forward declarations.

Fix regressions after #0024776

OpenGl_View::IsInvalidated() - fix misprint.
D3DHost_View::Redraw() - assign myFBO before rendering.
D3DHost_FrameBuffer::Init() - fix always zero viewport.
This commit is contained in:
kgv
2015-11-12 12:47:26 +03:00
committed by bugmaster
parent 2651bfde07
commit d2eddacc8f
16 changed files with 179 additions and 136 deletions

View File

@@ -11,6 +11,7 @@ Font_FTLibrary.cxx
Font_FTLibrary.hxx
Font_NameOfFont.hxx
Font_NListOfSystemFont.hxx
Font_Rect.hxx
Font_SystemFont.cxx
Font_SystemFont.hxx
Font_NameOfFont.hxx

View File

@@ -262,9 +262,9 @@ float Font_FTFont::AdvanceY (const Standard_Utf32Char theUCharNext)
// function : BoundingBox
// purpose :
// =======================================================================
Font_FTFont::Rect Font_FTFont::BoundingBox (const NCollection_String& theString,
const Graphic3d_HorizontalTextAlignment theAlignX,
const Graphic3d_VerticalTextAlignment theAlignY)
Font_Rect Font_FTFont::BoundingBox (const NCollection_String& theString,
const Graphic3d_HorizontalTextAlignment theAlignX,
const Graphic3d_VerticalTextAlignment theAlignY)
{
Font_TextFormatter aFormatter;
aFormatter.SetupAlignment (theAlignX, theAlignY);
@@ -273,9 +273,7 @@ Font_FTFont::Rect Font_FTFont::BoundingBox (const NCollection_String&
aFormatter.Append (theString, *this);
aFormatter.Format();
Rect aBndBox;
Font_Rect aBndBox;
aFormatter.BndBox (aBndBox);
return aBndBox;
}

View File

@@ -18,73 +18,17 @@
#include <Font_FontAspect.hxx>
#include <Font_FTLibrary.hxx>
#include <Font_Rect.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <Image_PixMap.hxx>
#include <NCollection_String.hxx>
#include <NCollection_Vec2.hxx>
//! Wrapper over FreeType font.
//! Notice that this class uses internal buffers for loaded glyphs
//! and it is absolutely UNSAFE to load/read glyph from concurrent threads!
class Font_FTFont : public Standard_Transient
{
public:
//! Auxiliary structure - rectangle definition
struct Rect
{
float Left;
float Right;
float Top;
float Bottom;
NCollection_Vec2<float> TopLeft() const
{
return NCollection_Vec2<float> (Left, Top);
}
NCollection_Vec2<float>& TopLeft (NCollection_Vec2<float>& theVec) const
{
theVec.x() = Left;
theVec.y() = Top;
return theVec;
}
NCollection_Vec2<float>& TopRight (NCollection_Vec2<float>& theVec) const
{
theVec.x() = Right;
theVec.y() = Top;
return theVec;
}
NCollection_Vec2<float>& BottomLeft (NCollection_Vec2<float>& theVec) const
{
theVec.x() = Left;
theVec.y() = Bottom;
return theVec;
}
NCollection_Vec2<float>& BottomRight (NCollection_Vec2<float>& theVec) const
{
theVec.x() = Right;
theVec.y() = Bottom;
return theVec;
}
float Width () const
{
return Right - Left;
}
float Height () const
{
return Top - Bottom;
}
};
public:
//! Create uninitialized instance.
@@ -186,7 +130,7 @@ public:
}
//! Retrieve glyph bitmap rectangle
inline void GlyphRect (Font_FTFont::Rect& theRect) const
inline void GlyphRect (Font_Rect& theRect) const
{
const FT_Bitmap& aBitmap = myFTFace->glyph->bitmap;
theRect.Left = float(myFTFace->glyph->bitmap_left);
@@ -198,9 +142,9 @@ public:
//! Computes bounding box of the given text using plain-text formatter (Font_TextFormatter).
//! Note that bounding box takes into account the text alignment options.
//! Its corners are relative to the text alignment anchor point, their coordinates can be negative.
Standard_EXPORT Rect BoundingBox (const NCollection_String& theString,
const Graphic3d_HorizontalTextAlignment theAlignX,
const Graphic3d_VerticalTextAlignment theAlignY);
Standard_EXPORT Font_Rect BoundingBox (const NCollection_String& theString,
const Graphic3d_HorizontalTextAlignment theAlignX,
const Graphic3d_VerticalTextAlignment theAlignY);
protected:

81
src/Font/Font_Rect.hxx Normal file
View File

@@ -0,0 +1,81 @@
// Created by: Kirill GAVRILOV
// Copyright (c) 2013-2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Font_Rect_H__
#define _Font_Rect_H__
#include <NCollection_Vec2.hxx>
//! Auxiliary POD structure - 2D rectangle definition.
struct Font_Rect
{
float Left; //!< left position
float Right; //!< right position
float Top; //!< top position
float Bottom; //!< bottom position
//! Top-left corner as vec2.
NCollection_Vec2<float> TopLeft() const
{
return NCollection_Vec2<float> (Left, Top);
}
//! Top-left corner as vec2.
NCollection_Vec2<float>& TopLeft (NCollection_Vec2<float>& theVec) const
{
theVec.x() = Left;
theVec.y() = Top;
return theVec;
}
//! Top-right corner as vec2.
NCollection_Vec2<float>& TopRight (NCollection_Vec2<float>& theVec) const
{
theVec.x() = Right;
theVec.y() = Top;
return theVec;
}
//! Bottom-left corner as vec2.
NCollection_Vec2<float>& BottomLeft (NCollection_Vec2<float>& theVec) const
{
theVec.x() = Left;
theVec.y() = Bottom;
return theVec;
}
//! Bottom-right corner as vec2.
NCollection_Vec2<float>& BottomRight (NCollection_Vec2<float>& theVec) const
{
theVec.x() = Right;
theVec.y() = Bottom;
return theVec;
}
//! Rectangle width.
float Width() const
{
return Right - Left;
}
//! Rectangle height.
float Height() const
{
return Top - Bottom;
}
};
#endif // _Font_Rect_H__

View File

@@ -15,6 +15,8 @@
#include <Font_TextFormatter.hxx>
#include <Font_FTFont.hxx>
namespace
{
typedef NCollection_Vec2<Standard_ShortReal> Vec2f;

View File

@@ -16,9 +16,14 @@
#ifndef Font_TextFormatter_Header
#define Font_TextFormatter_Header
#include <Font_FTFont.hxx>
#include <Font_Rect.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_Vector.hxx>
#include <NCollection_String.hxx>
class Font_FTFont;
//! This class intended to prepare formatted text.
class Font_TextFormatter
@@ -74,7 +79,7 @@ public:
}
//! @param bounding box.
inline void BndBox (Font_FTFont::Rect& theBndBox) const
inline void BndBox (Font_Rect& theBndBox) const
{
theBndBox.Left = 0.0f;
switch (myAlignX)