mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-03 14:10:33 +03:00
Compare commits
3 Commits
CR26507
...
CR690-MONT
Author | SHA1 | Date | |
---|---|---|---|
|
94e2d0be0f | ||
|
1ed0e5502e | ||
|
a5416a8c8c |
@@ -597,13 +597,9 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
|
|||||||
|
|
||||||
Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
|
Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
|
||||||
|
|
||||||
TCollection_ExtendedString aLabelString = GetTextLabel();
|
// prepare label string and compute its geometrical width
|
||||||
// Text sizes
|
Standard_Real aLabelWidth;
|
||||||
Standard_Real aLabelWidth = 0.0;
|
TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
|
||||||
Standard_Real aLabelHeight = 0.0;
|
|
||||||
Standard_Real aSymbolWidth = 0.0;
|
|
||||||
Standard_Real aSymbolHeight = 0.0;
|
|
||||||
getLabelSizes (aLabelString, aLabelWidth, aLabelHeight, aSymbolWidth, aSymbolHeight);
|
|
||||||
|
|
||||||
// add margins to label width
|
// add margins to label width
|
||||||
if (aDimensionAspect->IsText3d())
|
if (aDimensionAspect->IsText3d())
|
||||||
@@ -1163,14 +1159,8 @@ const gp_Pnt AIS_AngleDimension::GetTextPosition() const
|
|||||||
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
|
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
|
||||||
|
|
||||||
// Prepare label string and compute its geometrical width
|
// Prepare label string and compute its geometrical width
|
||||||
TCollection_ExtendedString aLabelString = GetTextLabel();
|
Standard_Real aLabelWidth;
|
||||||
// Text sizes
|
TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
|
||||||
Standard_Real aLabelWidth = 0.0;
|
|
||||||
Standard_Real aLabelHeight = 0.0;
|
|
||||||
Standard_Real aSymbolWidth = 0.0;
|
|
||||||
Standard_Real aSymbolHeight = 0.0;
|
|
||||||
getLabelSizes (aLabelString, aLabelWidth, aLabelHeight, aSymbolWidth, aSymbolHeight);
|
|
||||||
|
|
||||||
|
|
||||||
gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, myFirstPoint).Normalized() * GetFlyout());
|
gp_Pnt aFirstAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, myFirstPoint).Normalized() * GetFlyout());
|
||||||
gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, mySecondPoint).Normalized() * GetFlyout());
|
gp_Pnt aSecondAttach = myCenterPoint.Translated (gp_Vec(myCenterPoint, mySecondPoint).Normalized() * GetFlyout());
|
||||||
@@ -1349,14 +1339,8 @@ void AIS_AngleDimension::FitTextAlignment (const Prs3d_DimensionTextHorizontalPo
|
|||||||
Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
|
Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
|
||||||
|
|
||||||
// Prepare label string and compute its geometrical width
|
// Prepare label string and compute its geometrical width
|
||||||
TCollection_ExtendedString aLabelString = GetTextLabel();
|
Standard_Real aLabelWidth;
|
||||||
// Text sizes
|
TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
|
||||||
Standard_Real aLabelWidth = 0.0;
|
|
||||||
Standard_Real aLabelHeight = 0.0;
|
|
||||||
Standard_Real aSymbolWidth = 0.0;
|
|
||||||
Standard_Real aSymbolHeight = 0.0;
|
|
||||||
getLabelSizes (aLabelString, aLabelWidth, aLabelHeight, aSymbolWidth, aSymbolHeight);
|
|
||||||
|
|
||||||
|
|
||||||
// add margins to label width
|
// add margins to label width
|
||||||
if (aDimensionAspect->IsText3d())
|
if (aDimensionAspect->IsText3d())
|
||||||
|
@@ -37,11 +37,10 @@ namespace
|
|||||||
//function : Constructor
|
//function : Constructor
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle,
|
AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle)
|
||||||
const Standard_Real theParameter)
|
|
||||||
: AIS_Dimension (AIS_KOD_DIAMETER)
|
: AIS_Dimension (AIS_KOD_DIAMETER)
|
||||||
{
|
{
|
||||||
SetMeasuredGeometry (theCircle, theParameter);
|
SetMeasuredGeometry (theCircle);
|
||||||
SetSpecialSymbol (THE_DIAMETER_SYMBOL);
|
SetSpecialSymbol (THE_DIAMETER_SYMBOL);
|
||||||
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||||
SetFlyout (0.0);
|
SetFlyout (0.0);
|
||||||
@@ -108,8 +107,7 @@ gp_Pnt AIS_DiameterDimension::AnchorPoint()
|
|||||||
//function : SetMeasuredGeometry
|
//function : SetMeasuredGeometry
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_DiameterDimension::SetMeasuredGeometry (const gp_Circ& theCircle,
|
void AIS_DiameterDimension::SetMeasuredGeometry (const gp_Circ& theCircle)
|
||||||
const Standard_Real theParameter)
|
|
||||||
{
|
{
|
||||||
myCircle = theCircle;
|
myCircle = theCircle;
|
||||||
myGeometryType = GeometryType_Edge;
|
myGeometryType = GeometryType_Edge;
|
||||||
@@ -124,7 +122,7 @@ void AIS_DiameterDimension::SetMeasuredGeometry (const gp_Circ& theCircle,
|
|||||||
else if (!myIsPlaneCustom)
|
else if (!myIsPlaneCustom)
|
||||||
{
|
{
|
||||||
ComputePlane();
|
ComputePlane();
|
||||||
myAnchorPoint = ElCLib::Value (theParameter, myCircle);
|
myAnchorPoint = ElCLib::Value (0.0, myCircle);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetToUpdate();
|
SetToUpdate();
|
||||||
@@ -296,7 +294,7 @@ void AIS_DiameterDimension::Compute (const Handle(PrsMgr_PresentationManager3d)&
|
|||||||
gp_Pnt aSecondPnt (gp::Origin());
|
gp_Pnt aSecondPnt (gp::Origin());
|
||||||
ComputeSidePoints (myCircle, aFirstPnt, aSecondPnt);
|
ComputeSidePoints (myCircle, aFirstPnt, aSecondPnt);
|
||||||
|
|
||||||
DrawLinearDimension (thePresentation, theMode, aFirstPnt, aSecondPnt, Standard_False, myToDrawDimensionLine);
|
DrawLinearDimension (thePresentation, theMode, aFirstPnt, aSecondPnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -58,7 +58,7 @@ public:
|
|||||||
|
|
||||||
//! Construct diameter dimension for the circle.
|
//! Construct diameter dimension for the circle.
|
||||||
//! @param theCircle [in] the circle to measure.
|
//! @param theCircle [in] the circle to measure.
|
||||||
Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle, const Standard_Real theParameter = 0);
|
Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle);
|
||||||
|
|
||||||
//! Construct diameter dimension for the circle and orient it correspondingly
|
//! Construct diameter dimension for the circle and orient it correspondingly
|
||||||
//! to the passed plane.
|
//! to the passed plane.
|
||||||
@@ -105,7 +105,7 @@ public:
|
|||||||
//! The dimension will become invalid if the diameter of the circle
|
//! The dimension will become invalid if the diameter of the circle
|
||||||
//! is less than Precision::Confusion().
|
//! is less than Precision::Confusion().
|
||||||
//! @param theCircle [in] the circle to measure.
|
//! @param theCircle [in] the circle to measure.
|
||||||
Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle, const Standard_Real theParameter = 0);
|
Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle);
|
||||||
|
|
||||||
//! Measure diameter on the passed shape, if applicable.
|
//! Measure diameter on the passed shape, if applicable.
|
||||||
//! The dimension will become invalid if the passed shape is not
|
//! The dimension will become invalid if the passed shape is not
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
#include <Bnd_Box.hxx>
|
#include <Bnd_Box.hxx>
|
||||||
#include <ElCLib.hxx>
|
#include <ElCLib.hxx>
|
||||||
#include <Font_BRepFont.hxx>
|
#include <Font_BRepFont.hxx>
|
||||||
#include <Font_FTFont.hxx>
|
|
||||||
#include <GC_MakeCircle.hxx>
|
#include <GC_MakeCircle.hxx>
|
||||||
#include <Geom_Line.hxx>
|
#include <Geom_Line.hxx>
|
||||||
#include <GeomAdaptor_Curve.hxx>
|
#include <GeomAdaptor_Curve.hxx>
|
||||||
@@ -84,8 +83,8 @@ namespace
|
|||||||
static const TCollection_AsciiString THE_UNDEFINED_UNITS;
|
static const TCollection_AsciiString THE_UNDEFINED_UNITS;
|
||||||
|
|
||||||
// default text margin and resolution
|
// default text margin and resolution
|
||||||
static const Standard_Real THE_3D_TEXT_MARGIN = 0.1;
|
static const Standard_Real THE_3D_TEXT_MARGIN = 0.1;
|
||||||
static const unsigned int THE_FONT_RESOLUTION = 96;
|
static const unsigned int THE_2D_TEXT_RESOLUTION = 72;
|
||||||
|
|
||||||
// default selection priorities
|
// default selection priorities
|
||||||
static const Standard_Integer THE_NEUTRAL_SEL_PRIORITY = 5;
|
static const Standard_Integer THE_NEUTRAL_SEL_PRIORITY = 5;
|
||||||
@@ -99,102 +98,37 @@ namespace
|
|||||||
AIS_Dimension::AIS_Dimension (const AIS_KindOfDimension theType)
|
AIS_Dimension::AIS_Dimension (const AIS_KindOfDimension theType)
|
||||||
: AIS_InteractiveObject (),
|
: AIS_InteractiveObject (),
|
||||||
mySelToleranceForText2d(0.0),
|
mySelToleranceForText2d(0.0),
|
||||||
myTypeOfLabel (TOL_Computed),
|
myCustomValue (0.0),
|
||||||
myLabel (""),
|
myIsValueCustom (Standard_False),
|
||||||
myIsTextPositionFixed (Standard_False),
|
myIsTextPositionFixed (Standard_False),
|
||||||
mySpecialSymbol (' '),
|
mySpecialSymbol (' '),
|
||||||
myDisplaySpecialSymbol (AIS_DSS_No),
|
myDisplaySpecialSymbol (AIS_DSS_No),
|
||||||
myToDrawDimensionLine (Standard_True),
|
|
||||||
myGeometryType (GeometryType_UndefShapes),
|
myGeometryType (GeometryType_UndefShapes),
|
||||||
myIsPlaneCustom (Standard_False),
|
myIsPlaneCustom (Standard_False),
|
||||||
myFlyout (0.0),
|
myFlyout (0.0),
|
||||||
myIsTextAligned (Standard_False),
|
|
||||||
myTextDir (1.0, 0.0, 0.0),
|
|
||||||
myLeaderSegmentLength (0.0),
|
|
||||||
myIsGeometryValid (Standard_False),
|
myIsGeometryValid (Standard_False),
|
||||||
myKindOfDimension (theType)
|
myKindOfDimension (theType)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : GetValue
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
Standard_Real AIS_Dimension::GetValue() const
|
|
||||||
{
|
|
||||||
switch (myTypeOfLabel)
|
|
||||||
{
|
|
||||||
case TOL_Computed:
|
|
||||||
return ComputeValue();
|
|
||||||
case TOL_Value:
|
|
||||||
{
|
|
||||||
return myCustomValue;
|
|
||||||
}
|
|
||||||
case TOL_Text:
|
|
||||||
default:
|
|
||||||
return 0.0;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : SetCustomValue
|
//function : SetCustomValue
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_Dimension::SetCustomValue (const Standard_Real theValue)
|
void AIS_Dimension::SetCustomValue (const Standard_Real theValue)
|
||||||
{
|
{
|
||||||
if (myTypeOfLabel == TOL_Value && GetValue() == theValue)
|
if (myIsValueCustom && myCustomValue == theValue)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
myTypeOfLabel = TOL_Value;
|
myIsValueCustom = Standard_True;
|
||||||
|
|
||||||
myCustomValue = theValue;
|
myCustomValue = theValue;
|
||||||
|
|
||||||
SetToUpdate();
|
SetToUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetTextLabel
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void AIS_Dimension::SetTextLabel (const TCollection_ExtendedString& theValue)
|
|
||||||
{
|
|
||||||
myTypeOfLabel = TOL_Text;
|
|
||||||
myLabel = theValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : GetTextLabel
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
TCollection_ExtendedString AIS_Dimension::GetTextLabel() const
|
|
||||||
{
|
|
||||||
if (myTypeOfLabel == TOL_Text)
|
|
||||||
{
|
|
||||||
return myLabel;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TCollection_ExtendedString aString;
|
|
||||||
|
|
||||||
// Format value string using "sprintf"
|
|
||||||
TCollection_AsciiString aFormatStr = myDrawer->DimensionAspect()->ValueStringFormat();
|
|
||||||
|
|
||||||
char aFmtBuffer[256];
|
|
||||||
sprintf (aFmtBuffer, aFormatStr.ToCString(), ValueToDisplayUnits());
|
|
||||||
aString = TCollection_ExtendedString (aFmtBuffer);
|
|
||||||
|
|
||||||
// Add units to values string
|
|
||||||
if (myDrawer->DimensionAspect()->IsUnitsDisplayed())
|
|
||||||
{
|
|
||||||
aString += " ";
|
|
||||||
aString += TCollection_ExtendedString (GetDisplayUnits());
|
|
||||||
}
|
|
||||||
return aString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : GetPlane
|
//function : GetPlane
|
||||||
//purpose :
|
//purpose :
|
||||||
@@ -208,7 +142,7 @@ const gp_Pln& AIS_Dimension::GetPlane() const
|
|||||||
//function : GetGeometryType
|
//function : GetGeometryType
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
const Standard_Integer AIS_Dimension::GetGeometryType() const
|
const Standard_Integer AIS_Dimension::GetGeometryType () const
|
||||||
{
|
{
|
||||||
return myGeometryType;
|
return myGeometryType;
|
||||||
}
|
}
|
||||||
@@ -310,75 +244,6 @@ void AIS_Dimension::SetFlyout (const Standard_Real theFlyout)
|
|||||||
SetToUpdate();
|
SetToUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : ToDrawDimensionLine
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
const Standard_Boolean AIS_Dimension::ToDrawDimensionLine() const
|
|
||||||
{
|
|
||||||
return myToDrawDimensionLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetToDrawDimensionLine
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void AIS_Dimension::SetToDrawDimensionLine (const Standard_Boolean theToDraw)
|
|
||||||
{
|
|
||||||
myToDrawDimensionLine = theToDraw;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetToAlignText
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void AIS_Dimension::SetToAlignText (const Standard_Boolean theToAlign,
|
|
||||||
const gp_Dir& theAlignmentDir)
|
|
||||||
{
|
|
||||||
myIsTextAligned = theToAlign;
|
|
||||||
myTextDir = theAlignmentDir;
|
|
||||||
if (theToAlign && !myTextDir.IsNormal (myPlane.Axis().Direction(), Precision::Angular() ) )
|
|
||||||
{
|
|
||||||
myIsTextAligned = Standard_False;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : IsTextAligned
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
const Standard_Boolean AIS_Dimension::IsTextAligned() const
|
|
||||||
{
|
|
||||||
return myIsTextAligned;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : TextAlignmentDir
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
const gp_Dir& AIS_Dimension::TextAlignmentDir() const
|
|
||||||
{
|
|
||||||
return myTextDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : SetLeaderSegment
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void AIS_Dimension::SetLeaderSegment (const Standard_Real& theLength)
|
|
||||||
{
|
|
||||||
myLeaderSegmentLength = theLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : UnsetLeaderSegment
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void AIS_Dimension::UnsetLeaderSegment()
|
|
||||||
{
|
|
||||||
myLeaderSegmentLength = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : GetDisplayUnits
|
//function : GetDisplayUnits
|
||||||
//purpose :
|
//purpose :
|
||||||
@@ -408,62 +273,73 @@ Standard_Real AIS_Dimension::ValueToDisplayUnits() const
|
|||||||
GetDisplayUnits().ToCString());
|
GetDisplayUnits().ToCString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
//=======================================================================
|
||||||
// function : getLabelSizes
|
//function : GetValueString
|
||||||
// purpose :
|
//purpose :
|
||||||
// =======================================================================
|
//=======================================================================
|
||||||
void AIS_Dimension::getLabelSizes (const TCollection_ExtendedString& theLabel,
|
TCollection_ExtendedString AIS_Dimension::GetValueString (Standard_Real& theWidth) const
|
||||||
Standard_Real& theWidth,
|
|
||||||
Standard_Real& theHeight,
|
|
||||||
Standard_Real& theSymbolWidth,
|
|
||||||
Standard_Real& theSymbolHeight) const
|
|
||||||
{
|
{
|
||||||
Handle(Prs3d_DimensionAspect) anAspect = myDrawer->DimensionAspect();
|
// format value string using "sprintf"
|
||||||
Handle(Prs3d_TextAspect) aTextAspect = myDrawer->DimensionAspect()->TextAspect();
|
TCollection_AsciiString aFormatStr = myDrawer->DimensionAspect()->ValueStringFormat();
|
||||||
Standard_Real aFontHeight = aTextAspect->Height();
|
|
||||||
|
|
||||||
Quantity_Color aColor;
|
char aFmtBuffer[256];
|
||||||
Standard_CString aFontName;
|
sprintf (aFmtBuffer, aFormatStr.ToCString(), ValueToDisplayUnits());
|
||||||
Standard_Real anExpFactor, aSpace;
|
TCollection_ExtendedString aValueStr = TCollection_ExtendedString (aFmtBuffer);
|
||||||
aTextAspect->Aspect()->Values (aColor, aFontName, anExpFactor, aSpace);
|
|
||||||
|
|
||||||
NCollection_String aText ((Standard_Utf16Char*) theLabel.ToExtString());
|
// add units to values string
|
||||||
NCollection_String aSymbol;
|
if (myDrawer->DimensionAspect()->IsUnitsDisplayed())
|
||||||
if (DisplaySpecialSymbol() != AIS_DSS_No)
|
|
||||||
{
|
{
|
||||||
aSymbol.FromUnicode ((Standard_Utf16Char*) TCollection_ExtendedString (mySpecialSymbol).ToExtString());
|
aValueStr += " ";
|
||||||
|
aValueStr += TCollection_ExtendedString (GetDisplayUnits());
|
||||||
}
|
}
|
||||||
|
|
||||||
Font_FTFont::Rect aTextBox;
|
switch (myDisplaySpecialSymbol)
|
||||||
Font_FTFont::Rect aSymbolBox;
|
|
||||||
|
|
||||||
if (!anAspect->IsText3d())
|
|
||||||
{
|
{
|
||||||
Font_FTFont aFont;
|
case AIS_DSS_Before : aValueStr.Insert (1, mySpecialSymbol); break;
|
||||||
aFont.Init (aFontName,
|
case AIS_DSS_After : aValueStr.Insert (aValueStr.Length() + 1, mySpecialSymbol); break;
|
||||||
aTextAspect->Aspect()->GetTextFontAspect(),
|
case AIS_DSS_No : break;
|
||||||
static_cast<Standard_Integer> (aFontHeight),
|
}
|
||||||
THE_FONT_RESOLUTION);
|
|
||||||
aTextBox = aFont.BoundingBox (aText, Graphic3d_HTA_LEFT, Graphic3d_VTA_TOP);
|
// Get text style parameters
|
||||||
if (!aSymbol.IsEmpty())
|
Quantity_Color aColor;
|
||||||
|
Standard_CString aFontName;
|
||||||
|
Standard_Real aFactor;
|
||||||
|
Standard_Real aSpace;
|
||||||
|
myDrawer->DimensionAspect()->TextAspect()->Aspect()->Values (aColor, aFontName, aFactor, aSpace);
|
||||||
|
Font_FontAspect aFontAspect = myDrawer->DimensionAspect()->TextAspect()->Aspect()->GetTextFontAspect();
|
||||||
|
Standard_Real aFontHeight = myDrawer->DimensionAspect()->TextAspect()->Height();
|
||||||
|
|
||||||
|
NCollection_Utf8String anUTFString = (Standard_Utf16Char* )aValueStr.ToExtString();
|
||||||
|
|
||||||
|
theWidth = 0.0;
|
||||||
|
|
||||||
|
if (myDrawer->DimensionAspect()->IsText3d())
|
||||||
|
{
|
||||||
|
// text width produced by BRepFont
|
||||||
|
Font_BRepFont aFont (aFontName, aFontAspect, aFontHeight);
|
||||||
|
|
||||||
|
for (NCollection_Utf8Iter anIter = anUTFString.Iterator(); *anIter != 0; )
|
||||||
{
|
{
|
||||||
aSymbolBox = aFont.BoundingBox (aSymbol, Graphic3d_HTA_LEFT, Graphic3d_VTA_TOP);
|
Standard_Utf32Char aCurrChar = *anIter;
|
||||||
|
Standard_Utf32Char aNextChar = *(++anIter);
|
||||||
|
theWidth += aFont.AdvanceX (aCurrChar, aNextChar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Font_BRepFont aFont (aFontName, aTextAspect->Aspect()->GetTextFontAspect(), aFontHeight);
|
// Text width for 1:1 scale 2D case
|
||||||
aTextBox = aFont.BoundingBox (aText);
|
Handle(Font_FTFont) aFont = new Font_FTFont();
|
||||||
if (!aSymbol.IsEmpty())
|
aFont->Init (aFontName, aFontAspect, (const unsigned int)aFontHeight, THE_2D_TEXT_RESOLUTION);
|
||||||
|
|
||||||
|
for (NCollection_Utf8Iter anIter = anUTFString.Iterator(); *anIter != 0; )
|
||||||
{
|
{
|
||||||
aSymbolBox = aFont.BoundingBox (aSymbol);
|
Standard_Utf32Char aCurrChar = *anIter;
|
||||||
|
Standard_Utf32Char aNextChar = *(++anIter);
|
||||||
|
theWidth += (Standard_Real) aFont->AdvanceX (aCurrChar, aNextChar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
theWidth = aTextBox.Width();
|
return aValueStr;
|
||||||
theHeight = aTextBox.Height();
|
|
||||||
theSymbolWidth = aSymbolBox.Width();
|
|
||||||
theSymbolHeight = aSymbolBox.Height();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -534,176 +410,87 @@ void AIS_Dimension::DrawText (const Handle(Prs3d_Presentation)& thePresentation,
|
|||||||
const TCollection_ExtendedString& theText,
|
const TCollection_ExtendedString& theText,
|
||||||
const Standard_Integer theLabelPosition)
|
const Standard_Integer theLabelPosition)
|
||||||
{
|
{
|
||||||
// Prepare font
|
|
||||||
const Handle(Prs3d_TextAspect)& aTextAspect = myDrawer->DimensionAspect()->TextAspect();
|
|
||||||
Handle(Graphic3d_AspectText3d) anAspectText3d = aTextAspect->Aspect();
|
|
||||||
Quantity_Color aColor;
|
|
||||||
Standard_CString aFontName;
|
|
||||||
Standard_Real anExpFactor, aSpace;
|
|
||||||
anAspectText3d->Values (aColor, aFontName, anExpFactor, aSpace);
|
|
||||||
Font_FontAspect aFontAspect = anAspectText3d->GetTextFontAspect();
|
|
||||||
const Standard_Real aFontHeight = aTextAspect->Height();
|
|
||||||
|
|
||||||
Standard_Real aWidth = 0.0;
|
|
||||||
Standard_Real aHeight = 0.0;
|
|
||||||
Standard_Real aSymbolWidth = 0.0;
|
|
||||||
Standard_Real aSymbolHeight = 0.0;
|
|
||||||
getLabelSizes (theText, aWidth, aHeight, aSymbolWidth, aSymbolHeight);
|
|
||||||
|
|
||||||
// Compute label offsets
|
|
||||||
Standard_Real aMarginSize = aFontHeight * THE_3D_TEXT_MARGIN;
|
|
||||||
Standard_Real aCenterHOffset = 0.0;
|
|
||||||
Standard_Real aCenterVOffset = 0.0;
|
|
||||||
Standard_Real aSymbolVOffset = 0.0; //< Offset of symbol relative to the main text
|
|
||||||
Standard_Real aSymbolHOffset = 0.0;
|
|
||||||
Standard_Real aShapeHOffset = 0.0;
|
|
||||||
Standard_Real aShapeVOffset = 0.0;
|
|
||||||
|
|
||||||
Standard_Integer aVLabelPos = theLabelPosition & LabelPosition_VMask;
|
|
||||||
Standard_Integer aHLabelPos = theLabelPosition & LabelPosition_HMask;
|
|
||||||
|
|
||||||
if (myDrawer->DimensionAspect()->IsText3d())
|
if (myDrawer->DimensionAspect()->IsText3d())
|
||||||
{
|
{
|
||||||
// Creating TopoDS_Shape for text
|
// getting font parameters
|
||||||
|
Quantity_Color aColor;
|
||||||
|
Standard_CString aFontName;
|
||||||
|
Standard_Real anExpansionFactor;
|
||||||
|
Standard_Real aSpace;
|
||||||
|
myDrawer->DimensionAspect()->TextAspect()->Aspect()->Values (aColor, aFontName, anExpansionFactor, aSpace);
|
||||||
|
Font_FontAspect aFontAspect = myDrawer->DimensionAspect()->TextAspect()->Aspect()->GetTextFontAspect();
|
||||||
|
Standard_Real aFontHeight = myDrawer->DimensionAspect()->TextAspect()->Height();
|
||||||
|
|
||||||
|
// creating TopoDS_Shape for text
|
||||||
Font_BRepFont aFont (aFontName, aFontAspect, aFontHeight);
|
Font_BRepFont aFont (aFontName, aFontAspect, aFontHeight);
|
||||||
NCollection_Utf8String anUTFString = (Standard_Utf16Char* )theText.ToExtString();
|
NCollection_Utf8String anUTFString = (Standard_Utf16Char* )theText.ToExtString();
|
||||||
TopoDS_Shape aTextShape = aFont.RenderText (anUTFString);
|
TopoDS_Shape aTextShape = aFont.RenderText (anUTFString);
|
||||||
const Standard_Real aHeightOfLine = aFont.LineSpacing();
|
|
||||||
|
|
||||||
// Add special symbol
|
// compute text width with kerning
|
||||||
TopoDS_Shape aSymbolShape;
|
Standard_Real aTextWidth = 0.0;
|
||||||
if (myDisplaySpecialSymbol != AIS_DSS_No)
|
Standard_Real aTextHeight = aFont.Ascender() + aFont.Descender();
|
||||||
|
|
||||||
|
for (NCollection_Utf8Iter anIter = anUTFString.Iterator(); *anIter != 0; )
|
||||||
{
|
{
|
||||||
NCollection_Utf8String anUTFSymbol = (Standard_Utf16Char* )TCollection_ExtendedString (mySpecialSymbol).ToExtString();
|
Standard_Utf32Char aCurrChar = *anIter;
|
||||||
aSymbolShape = aFont.RenderText (anUTFSymbol);
|
Standard_Utf32Char aNextChar = *(++anIter);
|
||||||
|
aTextWidth += aFont.AdvanceX (aCurrChar, aNextChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Formating text position in XOY plane
|
// formating text position in XOY plane
|
||||||
|
Standard_Integer aHLabelPos = theLabelPosition & LabelPosition_HMask;
|
||||||
|
Standard_Integer aVLabelPos = theLabelPosition & LabelPosition_VMask;
|
||||||
|
|
||||||
|
gp_Dir aTextDir (aHLabelPos == LabelPosition_Left ? -theTextDir : theTextDir);
|
||||||
|
|
||||||
|
// compute label offsets
|
||||||
|
Standard_Real aMarginSize = aFontHeight * THE_3D_TEXT_MARGIN;
|
||||||
|
Standard_Real aCenterHOffset = 0.0;
|
||||||
|
Standard_Real aCenterVOffset = 0.0;
|
||||||
switch (aHLabelPos)
|
switch (aHLabelPos)
|
||||||
{
|
{
|
||||||
case LabelPosition_HCenter : aCenterHOffset = 0.0; break;
|
case LabelPosition_HCenter : aCenterHOffset = 0.0; break;
|
||||||
case LabelPosition_Right : aCenterHOffset = (aWidth + aSymbolWidth) / 2.0 + aMarginSize; break;
|
case LabelPosition_Right : aCenterHOffset = aTextWidth / 2.0 + aMarginSize; break;
|
||||||
case LabelPosition_Left : aCenterHOffset = -(aWidth + aSymbolWidth) / 2.0 - aMarginSize; break;
|
case LabelPosition_Left : aCenterHOffset = -aTextWidth / 2.0 - aMarginSize; break;
|
||||||
|
}
|
||||||
|
switch (aVLabelPos)
|
||||||
|
{
|
||||||
|
case LabelPosition_VCenter : aCenterVOffset = 0.0; break;
|
||||||
|
case LabelPosition_Above : aCenterVOffset = aTextHeight / 2.0 + aMarginSize; break;
|
||||||
|
case LabelPosition_Below : aCenterVOffset = -aTextHeight / 2.0 - aMarginSize; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Correct text direction
|
// compute shape offset transformation
|
||||||
gp_Dir aTextDir = (aHLabelPos == LabelPosition_Left ? -theTextDir : theTextDir);
|
Standard_Real aShapeHOffset = aCenterHOffset - aTextWidth / 2.0;
|
||||||
|
Standard_Real aShapeVOffset = aCenterVOffset - aTextHeight / 2.0;
|
||||||
|
|
||||||
// Transform text to myWorkingPlane coordinate system
|
// center shape in its bounding box (suppress border spacing added by FT_Font)
|
||||||
|
Bnd_Box aShapeBnd;
|
||||||
|
BRepBndLib::AddClose (aTextShape, aShapeBnd);
|
||||||
|
|
||||||
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
|
aShapeBnd.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
|
|
||||||
|
Standard_Real aXalign = aTextWidth * 0.5 - (aXmax + aXmin) * 0.5;
|
||||||
|
Standard_Real aYalign = aTextHeight * 0.5 - (aYmax + aYmin) * 0.5;
|
||||||
|
aShapeHOffset += aXalign;
|
||||||
|
aShapeVOffset += aYalign;
|
||||||
|
|
||||||
|
gp_Trsf anOffsetTrsf;
|
||||||
|
anOffsetTrsf.SetTranslation (gp::Origin(), gp_Pnt (aShapeHOffset, aShapeVOffset, 0.0));
|
||||||
|
aTextShape.Move (anOffsetTrsf);
|
||||||
|
|
||||||
|
// transform text to myWorkingPlane coordinate system
|
||||||
gp_Ax3 aTextCoordSystem (theTextPos, GetPlane().Axis().Direction(), aTextDir);
|
gp_Ax3 aTextCoordSystem (theTextPos, GetPlane().Axis().Direction(), aTextDir);
|
||||||
gp_Trsf aTextPlaneTrsf;
|
gp_Trsf aTextPlaneTrsf;
|
||||||
aTextPlaneTrsf.SetTransformation (aTextCoordSystem, gp_Ax3 (gp::XOY()));
|
aTextPlaneTrsf.SetTransformation (aTextCoordSystem, gp_Ax3 (gp::XOY()));
|
||||||
|
|
||||||
// ALIGNMENT: Vertical
|
|
||||||
|
|
||||||
switch (aVLabelPos)
|
|
||||||
{
|
|
||||||
case LabelPosition_FirstLine:
|
|
||||||
{
|
|
||||||
if (myTypeOfLabel == TOL_Text && aHeight > aHeightOfLine)
|
|
||||||
{
|
|
||||||
aShapeVOffset = aHeightOfLine - aHeight / 2.0 ;
|
|
||||||
aSymbolVOffset = aShapeVOffset - aHeightOfLine / 2.0 + aMarginSize;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LabelPosition_LastLine:
|
|
||||||
{
|
|
||||||
if (myTypeOfLabel == TOL_Text && aHeight > aHeightOfLine)
|
|
||||||
{
|
|
||||||
aShapeVOffset = aHeight / 2.0 - aHeightOfLine;
|
|
||||||
aSymbolVOffset = aShapeVOffset - aHeight / 2.0 - aMarginSize;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LabelPosition_VCenter :
|
|
||||||
{
|
|
||||||
if (myTypeOfLabel == TOL_Text && aHeight > aHeightOfLine)
|
|
||||||
{
|
|
||||||
aSymbolVOffset = aCenterVOffset - aHeight / 2.0 + aHeightOfLine / 2.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case LabelPosition_Above:
|
|
||||||
{
|
|
||||||
aCenterVOffset = aHeight / 2.0 + aMarginSize;
|
|
||||||
if (myTypeOfLabel == TOL_Text)
|
|
||||||
{
|
|
||||||
aSymbolVOffset = aCenterVOffset / 2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LabelPosition_Below:
|
|
||||||
{
|
|
||||||
aCenterVOffset = - aHeight / 2.0 - aMarginSize;
|
|
||||||
if (myTypeOfLabel == TOL_Text)
|
|
||||||
{
|
|
||||||
aSymbolVOffset = aCenterVOffset / 2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ALIGNMENT: Horisontal
|
|
||||||
|
|
||||||
// Center shape in its bounding box (suppress border spacing added by FT_Font)
|
|
||||||
Bnd_Box aShapeBnd;
|
|
||||||
BRepBndLib::AddClose (aTextShape, aShapeBnd);
|
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
|
||||||
aShapeBnd.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
|
||||||
Standard_Real aXalign = aWidth * 0.5 - (aXmax + aXmin) * 0.5;
|
|
||||||
Standard_Real aYalign = aHeight * 0.5 - (aYmax + aYmin) * 0.5;
|
|
||||||
|
|
||||||
// Compute where to place main part of label (without special symbol) relative to the input text position
|
|
||||||
aShapeHOffset = aCenterHOffset - aWidth / 2.0 + aXalign;
|
|
||||||
aShapeVOffset += aCenterVOffset - aHeight / 2.0 + aYalign;
|
|
||||||
|
|
||||||
gp_Trsf anOffsetTrsf;
|
|
||||||
if (!aSymbolShape.IsNull())
|
|
||||||
{
|
|
||||||
Bnd_Box aSymbolBnd;
|
|
||||||
BRepBndLib::AddClose (aSymbolShape, aSymbolBnd);
|
|
||||||
aSymbolBnd.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
|
||||||
aXalign = aSymbolWidth * 0.5 - (aXmax + aXmin) * 0.5;
|
|
||||||
|
|
||||||
aSymbolHOffset = aCenterHOffset + aXalign;
|
|
||||||
aSymbolVOffset += aYalign - aHeight / 2.0;
|
|
||||||
|
|
||||||
switch (myDisplaySpecialSymbol)
|
|
||||||
{
|
|
||||||
case AIS_DSS_After:
|
|
||||||
{
|
|
||||||
aSymbolHOffset += aWidth * 0.5;
|
|
||||||
aShapeHOffset -= aSymbolWidth * 0.5;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case AIS_DSS_Before:
|
|
||||||
{
|
|
||||||
aSymbolHOffset -= (aWidth + aSymbolWidth) * 0.5;
|
|
||||||
aShapeHOffset += aSymbolWidth * 0.5;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case AIS_DSS_No:
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modify transformation for a special symbol relative! to the main text
|
|
||||||
anOffsetTrsf.SetTranslation (gp::Origin(), gp_Pnt (aSymbolHOffset, aSymbolVOffset, 0.0));
|
|
||||||
aSymbolShape.Move (anOffsetTrsf);
|
|
||||||
aSymbolShape.Move (aTextPlaneTrsf);
|
|
||||||
}
|
|
||||||
|
|
||||||
anOffsetTrsf.SetTranslation (gp::Origin(), gp_Pnt (aShapeHOffset, aShapeVOffset, 0.0));
|
|
||||||
aTextShape.Move (anOffsetTrsf);
|
|
||||||
aTextShape.Move (aTextPlaneTrsf);
|
aTextShape.Move (aTextPlaneTrsf);
|
||||||
|
|
||||||
// Compute anchor point for flipping options
|
// set text flipping anchors
|
||||||
gp_Trsf aCenterOffsetTrsf;
|
gp_Trsf aCenterOffsetTrsf;
|
||||||
gp_Pnt aCenterOffset (aCenterHOffset, aCenterVOffset, 0.0);
|
gp_Pnt aCenterOffset (aCenterHOffset, aCenterVOffset, 0.0);
|
||||||
aCenterOffsetTrsf.SetTranslation (gp::Origin(), aCenterOffset);
|
aCenterOffsetTrsf.SetTranslation (gp::Origin(), aCenterOffset);
|
||||||
|
|
||||||
gp_Pnt aCenterOfLabel (gp::Origin());
|
gp_Pnt aCenterOfLabel (gp::Origin());
|
||||||
aCenterOfLabel.Transform (aCenterOffsetTrsf);
|
aCenterOfLabel.Transform (aCenterOffsetTrsf);
|
||||||
aCenterOfLabel.Transform (aTextPlaneTrsf);
|
aCenterOfLabel.Transform (aTextPlaneTrsf);
|
||||||
@@ -711,7 +498,7 @@ void AIS_Dimension::DrawText (const Handle(Prs3d_Presentation)& thePresentation,
|
|||||||
gp_Ax2 aFlippingAxes (aCenterOfLabel, GetPlane().Axis().Direction(), aTextDir);
|
gp_Ax2 aFlippingAxes (aCenterOfLabel, GetPlane().Axis().Direction(), aTextDir);
|
||||||
Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_True, aFlippingAxes);
|
Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_True, aFlippingAxes);
|
||||||
|
|
||||||
// Draw text
|
// draw text
|
||||||
if (myDrawer->DimensionAspect()->IsTextShaded())
|
if (myDrawer->DimensionAspect()->IsTextShaded())
|
||||||
{
|
{
|
||||||
// Setting text shading and color parameters
|
// Setting text shading and color parameters
|
||||||
@@ -723,84 +510,33 @@ void AIS_Dimension::DrawText (const Handle(Prs3d_Presentation)& thePresentation,
|
|||||||
myDrawer->ShadingAspect()->Aspect()->SetBackInteriorColor (aColor);
|
myDrawer->ShadingAspect()->Aspect()->SetBackInteriorColor (aColor);
|
||||||
myDrawer->ShadingAspect()->SetMaterial (aShadeMat);
|
myDrawer->ShadingAspect()->SetMaterial (aShadeMat);
|
||||||
|
|
||||||
|
// drawing text
|
||||||
StdPrs_ShadedShape::Add (thePresentation, aTextShape, myDrawer);
|
StdPrs_ShadedShape::Add (thePresentation, aTextShape, myDrawer);
|
||||||
StdPrs_ShadedShape::Add (thePresentation, aSymbolShape, myDrawer);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Setting color for text
|
// setting color for text
|
||||||
myDrawer->FreeBoundaryAspect()->Aspect()->SetColor (aColor);
|
myDrawer->FreeBoundaryAspect()->Aspect()->SetColor (aColor);
|
||||||
|
// drawing text
|
||||||
StdPrs_WFShape::Add (thePresentation, aTextShape, myDrawer);
|
StdPrs_WFShape::Add (thePresentation, aTextShape, myDrawer);
|
||||||
StdPrs_WFShape::Add (thePresentation, aSymbolShape, myDrawer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_False, gp_Ax2());
|
Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_False, gp_Ax2());
|
||||||
|
|
||||||
mySelectionGeom.TextPos = aCenterOfLabel;
|
mySelectionGeom.TextPos = aCenterOfLabel;
|
||||||
mySelectionGeom.TextDir = aTextDir;
|
mySelectionGeom.TextDir = aTextDir;
|
||||||
mySelectionGeom.TextWidth = aWidth + aMarginSize * 2.0;
|
mySelectionGeom.TextWidth = aTextWidth + aMarginSize * 2.0;
|
||||||
mySelectionGeom.TextHeight = aHeight + aSymbolHeight;
|
mySelectionGeom.TextHeight = aTextHeight;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2D text
|
// generate primitives for 2D text
|
||||||
|
|
||||||
myDrawer->DimensionAspect()->TextAspect()->Aspect()->SetDisplayType (Aspect_TODT_DIMENSION);
|
myDrawer->DimensionAspect()->TextAspect()->Aspect()->SetDisplayType (Aspect_TODT_DIMENSION);
|
||||||
|
|
||||||
gp_Pnt aTextPos = theTextPos;
|
Prs3d_Text::Draw (thePresentation,
|
||||||
|
myDrawer->DimensionAspect()->TextAspect(),
|
||||||
Font_FTFont aFont;
|
theText,
|
||||||
aFont.Init (aFontName,
|
theTextPos);
|
||||||
anAspectText3d->GetTextFontAspect(),
|
|
||||||
static_cast<Standard_Integer>(aFontHeight),
|
|
||||||
THE_FONT_RESOLUTION);
|
|
||||||
const Standard_Real aHeightOfLine = aFont.LineSpacing();
|
|
||||||
|
|
||||||
switch (aVLabelPos)
|
|
||||||
{
|
|
||||||
case LabelPosition_FirstLine: break;
|
|
||||||
case LabelPosition_LastLine : break;
|
|
||||||
case LabelPosition_VCenter : break;
|
|
||||||
case LabelPosition_Above:
|
|
||||||
{
|
|
||||||
if (myTypeOfLabel == TOL_Text && aHeight > aHeightOfLine)
|
|
||||||
{
|
|
||||||
aSymbolVOffset = -aHeight / 2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case LabelPosition_Below:
|
|
||||||
{
|
|
||||||
if (myTypeOfLabel == TOL_Text && aHeight > aHeightOfLine)
|
|
||||||
{
|
|
||||||
aSymbolVOffset = aHeight / 2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: for 2d text that is always parallel to view plane,
|
|
||||||
// multiline text alignment with special symbol does not applied.
|
|
||||||
TCollection_ExtendedString aText = theText;
|
|
||||||
switch (myDisplaySpecialSymbol)
|
|
||||||
{
|
|
||||||
case AIS_DSS_Before:
|
|
||||||
{
|
|
||||||
aText.Insert (1, mySpecialSymbol);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case AIS_DSS_After:
|
|
||||||
{
|
|
||||||
aText += mySpecialSymbol;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case AIS_DSS_No: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Prs3d_Text::Draw (thePresentation, aTextAspect, aText, aTextPos);
|
|
||||||
|
|
||||||
mySelectionGeom.TextPos = theTextPos;
|
mySelectionGeom.TextPos = theTextPos;
|
||||||
mySelectionGeom.TextDir = theTextDir;
|
mySelectionGeom.TextDir = theTextDir;
|
||||||
@@ -825,33 +561,11 @@ void AIS_Dimension::DrawExtension (const Handle(Prs3d_Presentation)& thePresenta
|
|||||||
gp_Lin anExtensionLine (theExtensionStart, theExtensionDir);
|
gp_Lin anExtensionLine (theExtensionStart, theExtensionDir);
|
||||||
|
|
||||||
Standard_Boolean hasLabel = theLabelString.Length() > 0;
|
Standard_Boolean hasLabel = theLabelString.Length() > 0;
|
||||||
|
|
||||||
gp_Dir aTextDir = myIsTextAligned
|
|
||||||
? (myTextDir * theExtensionDir < 0 ? -myTextDir : myTextDir)
|
|
||||||
: theExtensionDir;
|
|
||||||
|
|
||||||
// Compute graphical primitives and sensitives for extension line
|
|
||||||
gp_Pnt anExtStart = theExtensionStart;
|
|
||||||
gp_Pnt anExtEnd = !hasLabel || !(theLabelPosition & LabelPosition_Above || theLabelPosition & LabelPosition_Below)
|
|
||||||
? ElCLib::Value (theExtensionSize, anExtensionLine)
|
|
||||||
: ElCLib::Value (theExtensionSize + theLabelWidth, anExtensionLine);
|
|
||||||
|
|
||||||
gp_Pnt aSegmentPoint;
|
|
||||||
|
|
||||||
if (hasLabel && (theMode == ComputeMode_All || theMode == ComputeMode_Text))
|
if (hasLabel && (theMode == ComputeMode_All || theMode == ComputeMode_Text))
|
||||||
{
|
{
|
||||||
// compute text primitives; get its model width
|
// compute text primitives; get its model width
|
||||||
gp_Pnt aTextPos = ElCLib::Value (theExtensionSize, anExtensionLine);
|
gp_Pnt aTextPos = ElCLib::Value (theExtensionSize, anExtensionLine);
|
||||||
|
gp_Dir aTextDir = theExtensionDir;
|
||||||
if (hasLabel && myLeaderSegmentLength > 0 && myIsTextAligned)
|
|
||||||
{
|
|
||||||
gp_Lin aSegmentLine (anExtEnd, aTextDir);
|
|
||||||
Standard_Real aSegmentLength = !(theLabelPosition & LabelPosition_Above || theLabelPosition & LabelPosition_Below)
|
|
||||||
? myLeaderSegmentLength : theLabelWidth + myLeaderSegmentLength;
|
|
||||||
aSegmentPoint = ElCLib::Value (aSegmentLength, aSegmentLine);
|
|
||||||
aTextPos = !(theLabelPosition & LabelPosition_Above || theLabelPosition & LabelPosition_Below)
|
|
||||||
? aSegmentPoint : ElCLib::Value (myLeaderSegmentLength, aSegmentLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawText (thePresentation,
|
DrawText (thePresentation,
|
||||||
aTextPos,
|
aTextPos,
|
||||||
@@ -865,18 +579,21 @@ void AIS_Dimension::DrawExtension (const Handle(Prs3d_Presentation)& thePresenta
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add graphical primitives
|
Standard_Boolean isShortLine = !myDrawer->DimensionAspect()->IsText3d()
|
||||||
Handle(Graphic3d_ArrayOfSegments) anExtPrimitive = new Graphic3d_ArrayOfSegments ((hasLabel && myLeaderSegmentLength > 0 && myIsTextAligned) ? 4 : 2);
|
|| theLabelPosition & LabelPosition_VCenter;
|
||||||
|
|
||||||
|
// compute graphical primitives and sensitives for extension line
|
||||||
|
gp_Pnt anExtStart = theExtensionStart;
|
||||||
|
gp_Pnt anExtEnd = !hasLabel || isShortLine
|
||||||
|
? ElCLib::Value (theExtensionSize, anExtensionLine)
|
||||||
|
: ElCLib::Value (theExtensionSize + theLabelWidth, anExtensionLine);
|
||||||
|
|
||||||
|
// add graphical primitives
|
||||||
|
Handle(Graphic3d_ArrayOfSegments) anExtPrimitive = new Graphic3d_ArrayOfSegments (2);
|
||||||
anExtPrimitive->AddVertex (anExtStart);
|
anExtPrimitive->AddVertex (anExtStart);
|
||||||
anExtPrimitive->AddVertex (anExtEnd);
|
anExtPrimitive->AddVertex (anExtEnd);
|
||||||
// Draw segment
|
|
||||||
if (hasLabel && myLeaderSegmentLength > 0 && myIsTextAligned)
|
|
||||||
{
|
|
||||||
anExtPrimitive->AddVertex (anExtEnd);
|
|
||||||
anExtPrimitive->AddVertex (aSegmentPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add selection primitives
|
// add selection primitives
|
||||||
SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
|
SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
|
||||||
aSensitiveCurve.Append (anExtStart);
|
aSensitiveCurve.Append (anExtStart);
|
||||||
aSensitiveCurve.Append (anExtEnd);
|
aSensitiveCurve.Append (anExtEnd);
|
||||||
@@ -902,8 +619,7 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
const Standard_Integer theMode,
|
const Standard_Integer theMode,
|
||||||
const gp_Pnt& theFirstPoint,
|
const gp_Pnt& theFirstPoint,
|
||||||
const gp_Pnt& theSecondPoint,
|
const gp_Pnt& theSecondPoint,
|
||||||
const Standard_Boolean theIsOneSide,
|
const Standard_Boolean theIsOneSide)
|
||||||
const Standard_Boolean theToDrawDimensionLine)
|
|
||||||
{
|
{
|
||||||
// do not build any dimension for equal points
|
// do not build any dimension for equal points
|
||||||
if (theFirstPoint.IsEqual (theSecondPoint, Precision::Confusion()))
|
if (theFirstPoint.IsEqual (theSecondPoint, Precision::Confusion()))
|
||||||
@@ -916,14 +632,9 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
// For extensions we need to know arrow size, text size and extension size: get it from aspect
|
// For extensions we need to know arrow size, text size and extension size: get it from aspect
|
||||||
Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
|
Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
|
||||||
Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
|
Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
|
||||||
|
// prepare label string and compute its geometrical width
|
||||||
// Prepare label string and compute its geometrical sizes
|
Standard_Real aLabelWidth;
|
||||||
Standard_Real aLabelWidth, aLabelHeight;
|
TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
|
||||||
Standard_Real aSymbolWidth, aSymbolHeight;
|
|
||||||
TCollection_ExtendedString aLabel = GetTextLabel();
|
|
||||||
getLabelSizes (aLabel, aLabelWidth, aLabelHeight, aSymbolWidth, aSymbolHeight);
|
|
||||||
aLabelHeight += aSymbolHeight;
|
|
||||||
aLabelWidth += aSymbolWidth;
|
|
||||||
|
|
||||||
// add margins to cut dimension lines for 3d text
|
// add margins to cut dimension lines for 3d text
|
||||||
if (aDimensionAspect->IsText3d())
|
if (aDimensionAspect->IsText3d())
|
||||||
@@ -948,7 +659,7 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide, aHorisontalTextPos,
|
FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide, aHorisontalTextPos,
|
||||||
aLabelPosition, isArrowsExternal);
|
aLabelPosition, isArrowsExternal);
|
||||||
|
|
||||||
// compute dimension line points
|
// compute dimension line points
|
||||||
gp_Ax1 aPlaneNormal = GetPlane().Axis();
|
gp_Ax1 aPlaneNormal = GetPlane().Axis();
|
||||||
gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint);
|
gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint);
|
||||||
|
|
||||||
@@ -1006,11 +717,7 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
|
|
||||||
gp_Pnt aTextPos = IsTextPositionCustom() ? myFixedTextPosition
|
gp_Pnt aTextPos = IsTextPositionCustom() ? myFixedTextPosition
|
||||||
: (aCenterLineBegin.XYZ() + aCenterLineEnd.XYZ()) * 0.5;
|
: (aCenterLineBegin.XYZ() + aCenterLineEnd.XYZ()) * 0.5;
|
||||||
|
gp_Dir aTextDir = aDimensionLine.Direction();
|
||||||
// Choose a text direction
|
|
||||||
gp_Dir aTextDir = myIsTextAligned
|
|
||||||
? myTextDir
|
|
||||||
: aDimensionLine.Direction();
|
|
||||||
|
|
||||||
// add text primitives
|
// add text primitives
|
||||||
if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
|
if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
|
||||||
@@ -1018,18 +725,15 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
DrawText (thePresentation,
|
DrawText (thePresentation,
|
||||||
aTextPos,
|
aTextPos,
|
||||||
aTextDir,
|
aTextDir,
|
||||||
aLabel,
|
aLabelString,
|
||||||
aLabelPosition);
|
aLabelPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add dimension line primitives
|
// add dimension line primitives
|
||||||
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
|
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
|
||||||
{
|
{
|
||||||
// Line break is made only for 3d text (for 2d text it is managed with stensil test)
|
Standard_Boolean isLineBreak = aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center
|
||||||
// and for special alignment for multi-line text
|
&& aDimensionAspect->IsText3d();
|
||||||
Standard_Boolean isLineBreak = aDimensionAspect->IsText3d() &&
|
|
||||||
(aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center || (myTypeOfLabel == TOL_Text &&
|
|
||||||
(aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_FirstLine || aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_LastLine) ) );
|
|
||||||
|
|
||||||
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (isLineBreak ? 4 : 2);
|
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (isLineBreak ? 4 : 2);
|
||||||
|
|
||||||
@@ -1066,15 +770,11 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
|
|
||||||
// set text label justification
|
// set text label justification
|
||||||
Graphic3d_VerticalTextAlignment aTextJustificaton = Graphic3d_VTA_BOTTOM;
|
Graphic3d_VerticalTextAlignment aTextJustificaton = Graphic3d_VTA_BOTTOM;
|
||||||
|
|
||||||
// TODO check it!
|
|
||||||
switch (aLabelPosition & LabelPosition_VMask)
|
switch (aLabelPosition & LabelPosition_VMask)
|
||||||
{
|
{
|
||||||
case LabelPosition_Above :
|
case LabelPosition_Above :
|
||||||
case LabelPosition_LastLine :
|
case LabelPosition_VCenter : aTextJustificaton = Graphic3d_VTA_BOTTOM; break;
|
||||||
case LabelPosition_VCenter : aTextJustificaton = Graphic3d_VTA_BOTTOM; break;
|
case LabelPosition_Below : aTextJustificaton = Graphic3d_VTA_TOP; break;
|
||||||
case LabelPosition_FirstLine :
|
|
||||||
case LabelPosition_Below : aTextJustificaton = Graphic3d_VTA_TOP; break;
|
|
||||||
}
|
}
|
||||||
aDimensionAspect->TextAspect()->SetVerticalJustification (aTextJustificaton);
|
aDimensionAspect->TextAspect()->SetVerticalJustification (aTextJustificaton);
|
||||||
|
|
||||||
@@ -1135,7 +835,7 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
? aFirstArrowEnd
|
? aFirstArrowEnd
|
||||||
: aFirstArrowBegin,
|
: aFirstArrowBegin,
|
||||||
aFirstExtensionDir,
|
aFirstExtensionDir,
|
||||||
aLabel,
|
aLabelString,
|
||||||
aLabelWidth,
|
aLabelWidth,
|
||||||
theMode,
|
theMode,
|
||||||
aLabelPosition);
|
aLabelPosition);
|
||||||
@@ -1143,30 +843,27 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
// add dimension line primitives
|
// add dimension line primitives
|
||||||
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
|
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
|
||||||
{
|
{
|
||||||
if (theToDrawDimensionLine || !isArrowsExternal || abs(myFlyout) > Precision::Confusion() )
|
// add central dimension line
|
||||||
{
|
Prs3d_Root::NewGroup (thePresentation);
|
||||||
// add central dimension line
|
|
||||||
Prs3d_Root::NewGroup (thePresentation);
|
|
||||||
|
|
||||||
// add graphical primitives
|
// add graphical primitives
|
||||||
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
|
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
|
||||||
aPrimSegments->AddVertex (aCenterLineBegin);
|
aPrimSegments->AddVertex (aCenterLineBegin);
|
||||||
aPrimSegments->AddVertex (aCenterLineEnd);
|
aPrimSegments->AddVertex (aCenterLineEnd);
|
||||||
|
|
||||||
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
|
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
|
||||||
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
|
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
|
||||||
|
|
||||||
// add selection primitives
|
// add selection primitives
|
||||||
SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
|
SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
|
||||||
aSensitiveCurve.Append (aCenterLineBegin);
|
aSensitiveCurve.Append (aCenterLineBegin);
|
||||||
aSensitiveCurve.Append (aCenterLineEnd);
|
aSensitiveCurve.Append (aCenterLineEnd);
|
||||||
}
|
|
||||||
|
|
||||||
// add arrows to presentation
|
// add arrows to presentation
|
||||||
Prs3d_Root::NewGroup (thePresentation);
|
Prs3d_Root::NewGroup (thePresentation);
|
||||||
|
|
||||||
DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
|
DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
|
||||||
if (!theIsOneSide && (theToDrawDimensionLine || (!isArrowsExternal && !theToDrawDimensionLine) ))
|
if (!theIsOneSide)
|
||||||
{
|
{
|
||||||
DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
|
DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
|
||||||
}
|
}
|
||||||
@@ -1179,12 +876,9 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
// add extension lines for external arrows
|
// add extension lines for external arrows
|
||||||
Prs3d_Root::NewGroup (thePresentation);
|
Prs3d_Root::NewGroup (thePresentation);
|
||||||
|
|
||||||
if (theToDrawDimensionLine)
|
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
|
||||||
{
|
aSecondArrowEnd, aSecondExtensionDir,
|
||||||
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
|
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
|
||||||
aSecondArrowEnd, aSecondExtensionDir,
|
|
||||||
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -1204,35 +898,32 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
? aSecondArrowEnd
|
? aSecondArrowEnd
|
||||||
: aSecondArrowBegin,
|
: aSecondArrowBegin,
|
||||||
aSecondExtensionDir,
|
aSecondExtensionDir,
|
||||||
aLabel, aLabelWidth,
|
aLabelString, aLabelWidth,
|
||||||
theMode,
|
theMode,
|
||||||
aLabelPosition);
|
aLabelPosition);
|
||||||
|
|
||||||
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
|
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
|
||||||
{
|
{
|
||||||
if (theToDrawDimensionLine || !isArrowsExternal || abs(myFlyout) > Precision::Confusion())
|
// add central dimension line
|
||||||
{
|
Prs3d_Root::NewGroup (thePresentation);
|
||||||
// add central dimension line
|
|
||||||
Prs3d_Root::NewGroup (thePresentation);
|
|
||||||
|
|
||||||
// add graphical primitives
|
// add graphical primitives
|
||||||
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
|
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
|
||||||
aPrimSegments->AddVertex (aCenterLineBegin);
|
aPrimSegments->AddVertex (aCenterLineBegin);
|
||||||
aPrimSegments->AddVertex (aCenterLineEnd);
|
aPrimSegments->AddVertex (aCenterLineEnd);
|
||||||
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
|
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
|
||||||
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
|
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
|
||||||
|
|
||||||
// add selection primitives
|
// add selection primitives
|
||||||
SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
|
SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
|
||||||
aSensitiveCurve.Append (aCenterLineBegin);
|
aSensitiveCurve.Append (aCenterLineBegin);
|
||||||
aSensitiveCurve.Append (aCenterLineEnd);
|
aSensitiveCurve.Append (aCenterLineEnd);
|
||||||
}
|
|
||||||
|
|
||||||
// add arrows to presentation
|
// add arrows to presentation
|
||||||
Prs3d_Root::NewGroup (thePresentation);
|
Prs3d_Root::NewGroup (thePresentation);
|
||||||
|
|
||||||
DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
|
DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
|
||||||
if (!theIsOneSide && (theToDrawDimensionLine || (!theToDrawDimensionLine && !isArrowsExternal) ))
|
if (!theIsOneSide)
|
||||||
{
|
{
|
||||||
DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
|
DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
|
||||||
}
|
}
|
||||||
@@ -1245,12 +936,9 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
// add extension lines for external arrows
|
// add extension lines for external arrows
|
||||||
Prs3d_Root::NewGroup (thePresentation);
|
Prs3d_Root::NewGroup (thePresentation);
|
||||||
|
|
||||||
if (theToDrawDimensionLine)
|
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
|
||||||
{
|
aFirstArrowEnd, aFirstExtensionDir,
|
||||||
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
|
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
|
||||||
aFirstArrowEnd, aFirstExtensionDir,
|
|
||||||
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -1894,15 +1582,8 @@ void AIS_Dimension::FitTextAlignmentForLinear (const gp_Pnt& theFirstPoint,
|
|||||||
Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
|
Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
|
||||||
|
|
||||||
// prepare label string and compute its geometrical width
|
// prepare label string and compute its geometrical width
|
||||||
TCollection_ExtendedString aLabelString = GetTextLabel();
|
Standard_Real aLabelWidth;
|
||||||
|
TCollection_ExtendedString aLabelString = GetValueString (aLabelWidth);
|
||||||
// Text sizes
|
|
||||||
Standard_Real aLabelWidth = 0.0;
|
|
||||||
Standard_Real aLabelHeight = 0.0;
|
|
||||||
Standard_Real aSymbolWidth = 0.0;
|
|
||||||
Standard_Real aSymbolHeight = 0.0;
|
|
||||||
getLabelSizes (aLabelString, aLabelWidth, aLabelHeight, aSymbolWidth, aSymbolHeight);
|
|
||||||
|
|
||||||
|
|
||||||
// Add margins to cut dimension lines for 3d text
|
// Add margins to cut dimension lines for 3d text
|
||||||
if (aDimensionAspect->IsText3d())
|
if (aDimensionAspect->IsText3d())
|
||||||
@@ -1936,7 +1617,7 @@ void AIS_Dimension::FitTextAlignmentForLinear (const gp_Pnt& theFirstPoint,
|
|||||||
switch (theHorizontalTextPos)
|
switch (theHorizontalTextPos)
|
||||||
{
|
{
|
||||||
case Prs3d_DTHP_Left : theLabelPosition |= LabelPosition_Left; break;
|
case Prs3d_DTHP_Left : theLabelPosition |= LabelPosition_Left; break;
|
||||||
case Prs3d_DTHP_Right : theLabelPosition |= theIsOneSide ? LabelPosition_Left : LabelPosition_Right; break;
|
case Prs3d_DTHP_Right : theLabelPosition |= LabelPosition_Right; break;
|
||||||
case Prs3d_DTHP_Center: theLabelPosition |= LabelPosition_HCenter; break;
|
case Prs3d_DTHP_Center: theLabelPosition |= LabelPosition_HCenter; break;
|
||||||
case Prs3d_DTHP_Fit:
|
case Prs3d_DTHP_Fit:
|
||||||
{
|
{
|
||||||
@@ -1953,9 +1634,7 @@ void AIS_Dimension::FitTextAlignmentForLinear (const gp_Pnt& theFirstPoint,
|
|||||||
switch (aDimensionAspect->TextVerticalPosition())
|
switch (aDimensionAspect->TextVerticalPosition())
|
||||||
{
|
{
|
||||||
case Prs3d_DTVP_Above : theLabelPosition |= LabelPosition_Above; break;
|
case Prs3d_DTVP_Above : theLabelPosition |= LabelPosition_Above; break;
|
||||||
case Prs3d_DTVP_FirstLine : theLabelPosition |= LabelPosition_FirstLine; break;
|
|
||||||
case Prs3d_DTVP_Below : theLabelPosition |= LabelPosition_Below; break;
|
case Prs3d_DTVP_Below : theLabelPosition |= LabelPosition_Below; break;
|
||||||
case Prs3d_DTVP_LastLine : theLabelPosition |= LabelPosition_LastLine; break;
|
|
||||||
case Prs3d_DTVP_Center : theLabelPosition |= LabelPosition_VCenter; break;
|
case Prs3d_DTVP_Center : theLabelPosition |= LabelPosition_VCenter; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -195,12 +195,10 @@ protected:
|
|||||||
LabelPosition_HCenter = 0x04,
|
LabelPosition_HCenter = 0x04,
|
||||||
LabelPosition_HMask = LabelPosition_Left | LabelPosition_Right | LabelPosition_HCenter,
|
LabelPosition_HMask = LabelPosition_Left | LabelPosition_Right | LabelPosition_HCenter,
|
||||||
|
|
||||||
LabelPosition_Above = 0x0010,
|
LabelPosition_Above = 0x10,
|
||||||
LabelPosition_FirstLine = 0x0020,
|
LabelPosition_Below = 0x20,
|
||||||
LabelPosition_Below = 0x0040,
|
LabelPosition_VCenter = 0x40,
|
||||||
LabelPosition_LastLine = 0x0080,
|
LabelPosition_VMask = LabelPosition_Above | LabelPosition_Below | LabelPosition_VCenter
|
||||||
LabelPosition_VCenter = 0x0100,
|
|
||||||
LabelPosition_VMask = LabelPosition_Above | LabelPosition_Below | LabelPosition_VCenter | LabelPosition_FirstLine | LabelPosition_LastLine
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -226,7 +224,10 @@ public:
|
|||||||
//! compute it on its own in model space coordinates.
|
//! compute it on its own in model space coordinates.
|
||||||
//! @return the dimension value (in model units) which is used
|
//! @return the dimension value (in model units) which is used
|
||||||
//! during display of the presentation.
|
//! during display of the presentation.
|
||||||
Standard_EXPORT Standard_Real GetValue() const;
|
Standard_Real GetValue() const
|
||||||
|
{
|
||||||
|
return myIsValueCustom ? myCustomValue : ComputeValue();
|
||||||
|
}
|
||||||
|
|
||||||
//! Sets user-defined dimension value.
|
//! Sets user-defined dimension value.
|
||||||
//! The user-defined dimension value is specified in model space,
|
//! The user-defined dimension value is specified in model space,
|
||||||
@@ -234,14 +235,6 @@ public:
|
|||||||
//! @param theValue [in] the user-defined value to display.
|
//! @param theValue [in] the user-defined value to display.
|
||||||
Standard_EXPORT void SetCustomValue (const Standard_Real theValue);
|
Standard_EXPORT void SetCustomValue (const Standard_Real theValue);
|
||||||
|
|
||||||
//! Sets nultiline text for dimension label.
|
|
||||||
//! @param theValue [in] multiline string of Unicode symbols.
|
|
||||||
//! Can be used along with spectial symbol (like radius and diameter symbol)
|
|
||||||
Standard_EXPORT void SetTextLabel (const TCollection_ExtendedString& theValue);
|
|
||||||
|
|
||||||
//! @return the text for text label.
|
|
||||||
Standard_EXPORT TCollection_ExtendedString GetTextLabel() const;
|
|
||||||
|
|
||||||
//! Get the dimension plane in which the 2D dimension presentation is computed.
|
//! Get the dimension plane in which the 2D dimension presentation is computed.
|
||||||
//! By default, if plane is not defined by user, it is computed automatically
|
//! By default, if plane is not defined by user, it is computed automatically
|
||||||
//! after dimension geometry is computed.
|
//! after dimension geometry is computed.
|
||||||
@@ -382,26 +375,6 @@ public:
|
|||||||
return myIsGeometryValid && CheckPlane (GetPlane());
|
return myIsGeometryValid && CheckPlane (GetPlane());
|
||||||
}
|
}
|
||||||
|
|
||||||
//! @return state that shows if the radius inner segment
|
|
||||||
//! is to be displayed.
|
|
||||||
Standard_EXPORT const Standard_Boolean ToDrawDimensionLine() const;
|
|
||||||
|
|
||||||
//! Sets the flag that defines whether the dimenion line segment is displayed
|
|
||||||
//! @warning Dimension line won't be displayed only if arrows and label are moved
|
|
||||||
//! outside on dimension line extensions
|
|
||||||
Standard_EXPORT void SetToDrawDimensionLine (const Standard_Boolean theToDrawInnerSegment);
|
|
||||||
|
|
||||||
Standard_EXPORT void SetToAlignText (const Standard_Boolean theToAlign,
|
|
||||||
const gp_Dir& theAlignmentDir = gp_Dir (1.0, 0.0, 0.0));
|
|
||||||
|
|
||||||
Standard_EXPORT const Standard_Boolean IsTextAligned() const;
|
|
||||||
|
|
||||||
Standard_EXPORT const gp_Dir& TextAlignmentDir() const;
|
|
||||||
|
|
||||||
Standard_EXPORT void SetLeaderSegment (const Standard_Real& theLength);
|
|
||||||
|
|
||||||
Standard_EXPORT void UnsetLeaderSegment();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTI(AIS_Dimension)
|
DEFINE_STANDARD_RTTI(AIS_Dimension)
|
||||||
@@ -410,9 +383,10 @@ protected:
|
|||||||
|
|
||||||
Standard_EXPORT Standard_Real ValueToDisplayUnits() const;
|
Standard_EXPORT Standard_Real ValueToDisplayUnits() const;
|
||||||
|
|
||||||
Standard_EXPORT void getLabelSizes (const TCollection_ExtendedString& theLabel,
|
//! Get formatted value string and its model space width.
|
||||||
Standard_Real& theWidth, Standard_Real& theHeight,
|
//! @param theWidth [out] the model space with of the string.
|
||||||
Standard_Real& theSymbolWidth, Standard_Real& theSymbolHeight) const;
|
//! @return formatted dimension value string.
|
||||||
|
Standard_EXPORT TCollection_ExtendedString GetValueString (Standard_Real& theWidth) const;
|
||||||
|
|
||||||
//! Performs drawing of 2d or 3d arrows on the working plane
|
//! Performs drawing of 2d or 3d arrows on the working plane
|
||||||
//! @param theLocation [in] the location of the arrow tip.
|
//! @param theLocation [in] the location of the arrow tip.
|
||||||
@@ -460,15 +434,11 @@ protected:
|
|||||||
//! @param theFirstPoint [in] the first attach point of linear dimension.
|
//! @param theFirstPoint [in] the first attach point of linear dimension.
|
||||||
//! @param theSecondPoint [in] the second attach point of linear dimension.
|
//! @param theSecondPoint [in] the second attach point of linear dimension.
|
||||||
//! @param theIsOneSide [in] specifies whether the dimension has only one flyout line.
|
//! @param theIsOneSide [in] specifies whether the dimension has only one flyout line.
|
||||||
//! @param theToDrawDimensionLine [in] specifies whether the dimension line is to be displayed.
|
|
||||||
//! @warning Dimension line won't be displayed only if arrows and label are moved
|
|
||||||
//! outside on dimension line extensions
|
|
||||||
Standard_EXPORT void DrawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation,
|
Standard_EXPORT void DrawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation,
|
||||||
const Standard_Integer theMode,
|
const Standard_Integer theMode,
|
||||||
const gp_Pnt& theFirstPoint,
|
const gp_Pnt& theFirstPoint,
|
||||||
const gp_Pnt& theSecondPoint,
|
const gp_Pnt& theSecondPoint,
|
||||||
const Standard_Boolean theIsOneSide = Standard_False,
|
const Standard_Boolean theIsOneSide = Standard_False);
|
||||||
const Standard_Boolean theToDrawDimensionLine = Standard_True);
|
|
||||||
|
|
||||||
//! Compute selection sensitives for linear dimension flyout lines (length, diameter, radius).
|
//! Compute selection sensitives for linear dimension flyout lines (length, diameter, radius).
|
||||||
//! Please note that this method uses base dimension properties: working plane and flyout length.
|
//! Please note that this method uses base dimension properties: working plane and flyout length.
|
||||||
@@ -680,57 +650,29 @@ protected: //! @name Selection geometry
|
|||||||
|
|
||||||
Standard_Real mySelToleranceForText2d; //!< Sensitive point tolerance for 2d text selection.
|
Standard_Real mySelToleranceForText2d; //!< Sensitive point tolerance for 2d text selection.
|
||||||
|
|
||||||
protected:
|
protected: //! @name Value properties
|
||||||
|
|
||||||
enum TypeOfLabel
|
Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined).
|
||||||
{
|
Standard_Boolean myIsValueCustom; //!< Is user-defined value.
|
||||||
TOL_Computed = 0, //< is default
|
|
||||||
TOL_Value = 1,
|
|
||||||
TOL_Text
|
|
||||||
};
|
|
||||||
|
|
||||||
protected: //! @name Label properties
|
|
||||||
|
|
||||||
TypeOfLabel myTypeOfLabel;
|
|
||||||
|
|
||||||
Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined).
|
|
||||||
TCollection_ExtendedString myLabel; //!< Label text. Sets the user defined multiline text
|
|
||||||
|
|
||||||
protected: //! @name Fixed text position properties
|
protected: //! @name Fixed text position properties
|
||||||
|
|
||||||
gp_Pnt myFixedTextPosition; //!< Stores text position fixed by user.
|
gp_Pnt myFixedTextPosition; //!< Stores text position fixed by user.
|
||||||
Standard_Boolean myIsTextPositionFixed; //!< Is the text label position fixed by user.
|
Standard_Boolean myIsTextPositionFixed; //!< Is the text label position fixed by user.
|
||||||
|
|
||||||
protected: //! @name Units properties
|
protected: //! @name Units properties
|
||||||
|
|
||||||
Standard_ExtCharacter mySpecialSymbol; //!< Special symbol.
|
Standard_ExtCharacter mySpecialSymbol; //!< Special symbol.
|
||||||
AIS_DisplaySpecialSymbol myDisplaySpecialSymbol; //!< Special symbol display options.
|
AIS_DisplaySpecialSymbol myDisplaySpecialSymbol; //!< Special symbol display options.
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
//! Shows if the dimension line is to be drawn
|
|
||||||
//! It is used only if the text is placed on the one of the dimension line extensions.
|
|
||||||
//! By default it is TRUE
|
|
||||||
//! @warning Dimension line won't be displayed only if arrows and label are moved
|
|
||||||
//! outside on dimension line extensions
|
|
||||||
Standard_Boolean myToDrawDimensionLine;
|
|
||||||
|
|
||||||
protected: //! @name Geometrical properties
|
protected: //! @name Geometrical properties
|
||||||
|
|
||||||
GeometryType myGeometryType; //!< defines type of shapes on which the dimension is to be built.
|
GeometryType myGeometryType; //!< defines type of shapes on which the dimension is to be built.
|
||||||
|
|
||||||
gp_Pln myPlane; //!< Plane where dimension will be built (computed or user defined).
|
gp_Pln myPlane; //!< Plane where dimension will be built (computed or user defined).
|
||||||
Standard_Boolean myIsPlaneCustom; //!< Is plane defined by user (otherwise it will be computed automatically).
|
Standard_Boolean myIsPlaneCustom; //!< Is plane defined by user (otherwise it will be computed automatically).
|
||||||
Standard_Real myFlyout; //!< Flyout distance.
|
Standard_Real myFlyout; //!< Flyout distance.
|
||||||
|
Standard_Boolean myIsGeometryValid; //!< Is dimension geometry properly defined.
|
||||||
//! Shows if the text label is aligned to user-defined direction myTextDir
|
|
||||||
//! Otherwise it is alligned to the dimension line extension direction
|
|
||||||
//! @warning Only for text placed outside of the dimension line
|
|
||||||
Standard_Boolean myIsTextAligned;
|
|
||||||
gp_Dir myTextDir; //!< Alignment direction for the text
|
|
||||||
Standard_Real myLeaderSegmentLength; //!< Length of leader line segment aligned with text to myTextDir direction
|
|
||||||
|
|
||||||
Standard_Boolean myIsGeometryValid; //!< Is dimension geometry properly defined.
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@@ -33,25 +33,15 @@ namespace
|
|||||||
//function : Constructor
|
//function : Constructor
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_RadiusDimension::init()
|
AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle)
|
||||||
|
: AIS_Dimension (AIS_KOD_RADIUS)
|
||||||
{
|
{
|
||||||
|
SetMeasuredGeometry (theCircle);
|
||||||
SetSpecialSymbol (THE_RADIUS_SYMBOL);
|
SetSpecialSymbol (THE_RADIUS_SYMBOL);
|
||||||
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||||
SetFlyout (0.0);
|
SetFlyout (0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Constructor
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
|
|
||||||
const Standard_Real theParameter)
|
|
||||||
: AIS_Dimension (AIS_KOD_RADIUS)
|
|
||||||
{
|
|
||||||
init();
|
|
||||||
SetMeasuredGeometry (theCircle, theParameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Constructor
|
//function : Constructor
|
||||||
//purpose :
|
//purpose :
|
||||||
@@ -60,8 +50,10 @@ AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
|
|||||||
const gp_Pnt& theAttachPoint)
|
const gp_Pnt& theAttachPoint)
|
||||||
: AIS_Dimension (AIS_KOD_RADIUS)
|
: AIS_Dimension (AIS_KOD_RADIUS)
|
||||||
{
|
{
|
||||||
init();
|
|
||||||
SetMeasuredGeometry (theCircle, theAttachPoint);
|
SetMeasuredGeometry (theCircle, theAttachPoint);
|
||||||
|
SetSpecialSymbol (THE_RADIUS_SYMBOL);
|
||||||
|
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||||
|
SetFlyout (0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -71,21 +63,22 @@ AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
|
|||||||
AIS_RadiusDimension::AIS_RadiusDimension (const TopoDS_Shape& theShape)
|
AIS_RadiusDimension::AIS_RadiusDimension (const TopoDS_Shape& theShape)
|
||||||
: AIS_Dimension (AIS_KOD_RADIUS)
|
: AIS_Dimension (AIS_KOD_RADIUS)
|
||||||
{
|
{
|
||||||
init();
|
|
||||||
SetMeasuredGeometry (theShape);
|
SetMeasuredGeometry (theShape);
|
||||||
|
SetSpecialSymbol (THE_RADIUS_SYMBOL);
|
||||||
|
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||||
|
SetFlyout (0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : SetMeasuredGeometry
|
//function : SetMeasuredGeometry
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_RadiusDimension::SetMeasuredGeometry (const gp_Circ& theCircle,
|
void AIS_RadiusDimension::SetMeasuredGeometry (const gp_Circ& theCircle)
|
||||||
const Standard_Real theParameter)
|
|
||||||
{
|
{
|
||||||
myCircle = theCircle;
|
myCircle = theCircle;
|
||||||
myGeometryType = GeometryType_Edge;
|
myGeometryType = GeometryType_Edge;
|
||||||
myShape = BRepLib_MakeEdge (theCircle);
|
myShape = BRepLib_MakeEdge (theCircle);
|
||||||
myAnchorPoint = ElCLib::Value (theParameter, myCircle);
|
myAnchorPoint = ElCLib::Value (0, myCircle);
|
||||||
myIsGeometryValid = IsValidCircle (myCircle);
|
myIsGeometryValid = IsValidCircle (myCircle);
|
||||||
|
|
||||||
if (myIsGeometryValid)
|
if (myIsGeometryValid)
|
||||||
@@ -137,33 +130,6 @@ void AIS_RadiusDimension::SetMeasuredGeometry (const TopoDS_Shape& theShape)
|
|||||||
SetToUpdate();
|
SetToUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Circle
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
const gp_Circ& AIS_RadiusDimension::Circle() const
|
|
||||||
{
|
|
||||||
return myCircle;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : AnchorPoint
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
const gp_Pnt& AIS_RadiusDimension::AnchorPoint() const
|
|
||||||
{
|
|
||||||
return myAnchorPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Shape
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
const TopoDS_Shape& AIS_RadiusDimension::Shape() const
|
|
||||||
{
|
|
||||||
return myShape;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : CheckPlane
|
//function : CheckPlane
|
||||||
//purpose :
|
//purpose :
|
||||||
@@ -264,7 +230,7 @@ void AIS_RadiusDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawLinearDimension (thePresentation, theMode, myAnchorPoint, myCircle.Location(), Standard_True, myToDrawDimensionLine);
|
DrawLinearDimension (thePresentation, theMode, myAnchorPoint, myCircle.Location(), Standard_True);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -38,19 +38,13 @@ DEFINE_STANDARD_HANDLE (AIS_RadiusDimension,AIS_Dimension)
|
|||||||
//! In case if the dimension is built on the arbitrary shape,
|
//! In case if the dimension is built on the arbitrary shape,
|
||||||
//! it can be considered as invalid if the shape does not contain
|
//! it can be considered as invalid if the shape does not contain
|
||||||
//! circle geometry.
|
//! circle geometry.
|
||||||
//! Use IsValid() method to check that created dimension is valid.
|
|
||||||
class AIS_RadiusDimension : public AIS_Dimension
|
class AIS_RadiusDimension : public AIS_Dimension
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
|
|
||||||
//! Setting of default construction paramters
|
|
||||||
void init();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Create radius dimension for the circle geometry.
|
//! Create radius dimension for the circle geometry.
|
||||||
//! @param theCircle [in] the circle to measure.
|
//! @param theCircle [in] the circle to measure.
|
||||||
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle, const Standard_Real theParameter = 0);
|
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle);
|
||||||
|
|
||||||
//! Create radius dimension for the circle geometry and define its
|
//! Create radius dimension for the circle geometry and define its
|
||||||
//! orientation by location of the first point on that circle.
|
//! orientation by location of the first point on that circle.
|
||||||
@@ -67,13 +61,22 @@ public:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//! @return measured geometry circle.
|
//! @return measured geometry circle.
|
||||||
Standard_EXPORT const gp_Circ& Circle() const;
|
const gp_Circ& Circle() const
|
||||||
|
{
|
||||||
|
return myCircle;
|
||||||
|
}
|
||||||
|
|
||||||
//! @return anchor point on circle for radius dimension.
|
//! @return anchor point on circle for radius dimension.
|
||||||
Standard_EXPORT const gp_Pnt& AnchorPoint() const;
|
const gp_Pnt& AnchorPoint() const
|
||||||
|
{
|
||||||
|
return myAnchorPoint;
|
||||||
|
}
|
||||||
|
|
||||||
//! @return the measured shape.
|
//! @return the measured shape.
|
||||||
Standard_EXPORT const TopoDS_Shape& Shape() const;
|
const TopoDS_Shape& Shape() const
|
||||||
|
{
|
||||||
|
return myShape;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -81,7 +84,7 @@ public:
|
|||||||
//! The dimension will become invalid if the radius of the circle
|
//! The dimension will become invalid if the radius of the circle
|
||||||
//! is less than Precision::Confusion().
|
//! is less than Precision::Confusion().
|
||||||
//! @param theCircle [in] the circle to measure.
|
//! @param theCircle [in] the circle to measure.
|
||||||
Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle, const Standard_Real theParameter = 0);
|
Standard_EXPORT void SetMeasuredGeometry (const gp_Circ& theCircle);
|
||||||
|
|
||||||
//! Measure radius of the circle and orient the dimension so
|
//! Measure radius of the circle and orient the dimension so
|
||||||
//! the dimension lines attaches to anchor point on the circle.
|
//! the dimension lines attaches to anchor point on the circle.
|
||||||
@@ -118,16 +121,16 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Standard_EXPORT virtual void ComputePlane() Standard_OVERRIDE;
|
Standard_EXPORT virtual void ComputePlane();
|
||||||
|
|
||||||
//! Checks if anchor point and the center of the circle are on the plane.
|
//! Checks if anchor point and the center of the circle are on the plane.
|
||||||
Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const Standard_OVERRIDE;
|
Standard_EXPORT virtual Standard_Boolean CheckPlane (const gp_Pln& thePlane) const;
|
||||||
|
|
||||||
Standard_EXPORT virtual Standard_Real ComputeValue() const Standard_OVERRIDE;
|
Standard_EXPORT virtual Standard_Real ComputeValue() const;
|
||||||
|
|
||||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
|
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
|
||||||
const Handle(Prs3d_Presentation)& thePresentation,
|
const Handle(Prs3d_Presentation)& thePresentation,
|
||||||
const Standard_Integer theMode = 0) Standard_OVERRIDE;
|
const Standard_Integer theMode = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@@ -74,6 +74,8 @@ void AppCont_LeastSquare::FixSingleBorderPoint(const AppCont_Function& the
|
|||||||
aPrevP = aTabP;
|
aPrevP = aTabP;
|
||||||
aPrevP2d = aTabP2d;
|
aPrevP2d = aTabP2d;
|
||||||
aPrevDist = aCurrDist;
|
aPrevDist = aCurrDist;
|
||||||
|
if(aCurrDist == 0.0)//protection of the division by 0 in the next iteration.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
theFix2d = aPrevP2d;
|
theFix2d = aPrevP2d;
|
||||||
theFix = aPrevP;
|
theFix = aPrevP;
|
||||||
|
@@ -240,7 +240,7 @@ is
|
|||||||
theF2: Face from TopoDS;
|
theF2: Face from TopoDS;
|
||||||
theTolR3D:Real from Standard;
|
theTolR3D:Real from Standard;
|
||||||
theNC:out Curve from BOPDS;
|
theNC:out Curve from BOPDS;
|
||||||
theMVB:out MapOfInteger from BOPCol)
|
theLBV:out ListOfInteger from BOPCol)
|
||||||
is protected;
|
is protected;
|
||||||
|
|
||||||
IsExistingPaveBlock(me:out;
|
IsExistingPaveBlock(me:out;
|
||||||
@@ -367,9 +367,9 @@ is
|
|||||||
ProcessExistingPaveBlocks(me:out;
|
ProcessExistingPaveBlocks(me:out;
|
||||||
theInt : Integer from Standard;
|
theInt : Integer from Standard;
|
||||||
theMPBOnIn : IndexedMapOfPaveBlock from BOPDS;
|
theMPBOnIn : IndexedMapOfPaveBlock from BOPDS;
|
||||||
|
theDMBV : DataMapOfIntegerListOfInteger from BOPCol;
|
||||||
theMSCPB : out IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS;
|
theMSCPB : out IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS;
|
||||||
theMVI : out DataMapOfShapeInteger from BOPCol;
|
theMVI : out DataMapOfShapeInteger from BOPCol;
|
||||||
theMVB : MapOfInteger from BOPCol;
|
|
||||||
theMPB : out MapOfPaveBlock from BOPDS)
|
theMPB : out MapOfPaveBlock from BOPDS)
|
||||||
is protected;
|
is protected;
|
||||||
---Purpose:
|
---Purpose:
|
||||||
@@ -403,10 +403,11 @@ is
|
|||||||
|
|
||||||
PreparePostTreatFF(me:out;
|
PreparePostTreatFF(me:out;
|
||||||
aInt : Integer from Standard;
|
aInt : Integer from Standard;
|
||||||
|
aCur : Integer from Standard;
|
||||||
aPB : PaveBlock from BOPDS;
|
aPB : PaveBlock from BOPDS;
|
||||||
aMSCPB : out IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS;
|
aMSCPB : out IndexedDataMapOfShapeCoupleOfPaveBlocks from BOPDS;
|
||||||
aMVI : out DataMapOfShapeInteger from BOPCol;
|
aMVI : out DataMapOfShapeInteger from BOPCol;
|
||||||
aVC : out VectorOfCurve from BOPDS)
|
aLPB : out ListOfPaveBlock from BOPDS)
|
||||||
is protected;
|
is protected;
|
||||||
---Purpose:
|
---Purpose:
|
||||||
-- Keeps data for post treatment
|
-- Keeps data for post treatment
|
||||||
|
@@ -374,10 +374,10 @@ void BOPAlgo_PaveFiller::MakeBlocks()
|
|||||||
//-----------------------------------------------------scope f
|
//-----------------------------------------------------scope f
|
||||||
aAllocator=new NCollection_IncAllocator();
|
aAllocator=new NCollection_IncAllocator();
|
||||||
//
|
//
|
||||||
BOPCol_ListOfInteger aLSE(aAllocator);
|
BOPCol_ListOfInteger aLSE(aAllocator), aLBV(aAllocator);
|
||||||
BOPCol_MapOfInteger aMVOnIn(100, aAllocator), aMF(100, aAllocator),
|
BOPCol_MapOfInteger aMVOnIn(100, aAllocator), aMF(100, aAllocator),
|
||||||
aMVStick(100,aAllocator), aMVEF(100, aAllocator),
|
aMVStick(100,aAllocator), aMVEF(100, aAllocator),
|
||||||
aMVB(100, aAllocator), aMI(100, aAllocator);
|
aMI(100, aAllocator);
|
||||||
BOPDS_IndexedMapOfPaveBlock aMPBOnIn(100, aAllocator);
|
BOPDS_IndexedMapOfPaveBlock aMPBOnIn(100, aAllocator);
|
||||||
BOPDS_MapOfPaveBlock aMPBAdd(100, aAllocator);
|
BOPDS_MapOfPaveBlock aMPBAdd(100, aAllocator);
|
||||||
BOPDS_ListOfPaveBlock aLPB(aAllocator);
|
BOPDS_ListOfPaveBlock aLPB(aAllocator);
|
||||||
@@ -385,8 +385,9 @@ void BOPAlgo_PaveFiller::MakeBlocks()
|
|||||||
BOPCol_DataMapOfShapeInteger aMVI(100, aAllocator);
|
BOPCol_DataMapOfShapeInteger aMVI(100, aAllocator);
|
||||||
BOPDS_DataMapOfPaveBlockListOfPaveBlock aDMExEdges(100, aAllocator);
|
BOPDS_DataMapOfPaveBlockListOfPaveBlock aDMExEdges(100, aAllocator);
|
||||||
BOPCol_DataMapOfIntegerReal aMVTol(100, aAllocator);
|
BOPCol_DataMapOfIntegerReal aMVTol(100, aAllocator);
|
||||||
BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItMV;
|
|
||||||
BOPCol_DataMapOfIntegerInteger aDMI(100, aAllocator);
|
BOPCol_DataMapOfIntegerInteger aDMI(100, aAllocator);
|
||||||
|
BOPCol_DataMapOfIntegerListOfInteger aDMBV(100, aAllocator);
|
||||||
|
BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItMV;
|
||||||
//
|
//
|
||||||
for (i=0; i<aNbFF; ++i) {
|
for (i=0; i<aNbFF; ++i) {
|
||||||
//
|
//
|
||||||
@@ -411,17 +412,19 @@ void BOPAlgo_PaveFiller::MakeBlocks()
|
|||||||
// Update face info
|
// Update face info
|
||||||
if (aMF.Add(nF1)) {
|
if (aMF.Add(nF1)) {
|
||||||
myDS->UpdateFaceInfoOn(nF1);
|
myDS->UpdateFaceInfoOn(nF1);
|
||||||
|
myDS->UpdateFaceInfoIn(nF1);
|
||||||
}
|
}
|
||||||
if (aMF.Add(nF2)) {
|
if (aMF.Add(nF2)) {
|
||||||
myDS->UpdateFaceInfoOn(nF2);
|
myDS->UpdateFaceInfoOn(nF2);
|
||||||
|
myDS->UpdateFaceInfoIn(nF2);
|
||||||
}
|
}
|
||||||
|
//
|
||||||
BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
|
BOPDS_FaceInfo& aFI1=myDS->ChangeFaceInfo(nF1);
|
||||||
BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
|
BOPDS_FaceInfo& aFI2=myDS->ChangeFaceInfo(nF2);
|
||||||
//
|
//
|
||||||
aMVOnIn.Clear();
|
aMVOnIn.Clear();
|
||||||
aMPBOnIn.Clear();
|
aMPBOnIn.Clear();
|
||||||
aMVB.Clear();
|
aDMBV.Clear();
|
||||||
aMVTol.Clear();
|
aMVTol.Clear();
|
||||||
//
|
//
|
||||||
myDS->VerticesOnIn(nF1, nF2, aMVOnIn, aMPBOnIn);
|
myDS->VerticesOnIn(nF1, nF2, aMVOnIn, aMPBOnIn);
|
||||||
@@ -465,7 +468,13 @@ void BOPAlgo_PaveFiller::MakeBlocks()
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (aIC.HasBounds()) {
|
if (aIC.HasBounds()) {
|
||||||
PutBoundPaveOnCurve(aF1, aF2, aTolR3D, aNC, aMVB);
|
aLBV.Clear();
|
||||||
|
//
|
||||||
|
PutBoundPaveOnCurve(aF1, aF2, aTolR3D, aNC, aLBV);
|
||||||
|
//
|
||||||
|
if (!aLBV.IsEmpty()) {
|
||||||
|
aDMBV.Bind(j, aLBV);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}//for (j=0; j<aNbC; ++j) {
|
}//for (j=0; j<aNbC; ++j) {
|
||||||
//
|
//
|
||||||
@@ -529,7 +538,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
|
|||||||
aFI2.PaveBlocksIn().Contains(aPBOut));
|
aFI2.PaveBlocksIn().Contains(aPBOut));
|
||||||
}
|
}
|
||||||
if (!bInBothFaces) {
|
if (!bInBothFaces) {
|
||||||
PreparePostTreatFF(i, aPBOut, aMSCPB, aMVI, aVC);
|
PreparePostTreatFF(i, j, aPBOut, aMSCPB, aMVI, aLPBC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@@ -580,7 +589,7 @@ void BOPAlgo_PaveFiller::MakeBlocks()
|
|||||||
TV->Tolerance(aTol);
|
TV->Tolerance(aTol);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
ProcessExistingPaveBlocks(i, aMPBOnIn, aMSCPB, aMVI, aMVB, aMPBAdd);
|
ProcessExistingPaveBlocks(i, aMPBOnIn, aDMBV, aMSCPB, aMVI, aMPBAdd);
|
||||||
}//for (i=0; i<aNbFF; ++i) {
|
}//for (i=0; i<aNbFF; ++i) {
|
||||||
//
|
//
|
||||||
// post treatment
|
// post treatment
|
||||||
@@ -913,22 +922,23 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo
|
|||||||
for (j=0; j<aNbC; ++j) {
|
for (j=0; j<aNbC; ++j) {
|
||||||
BOPDS_Curve& aNC=aVNC(j);
|
BOPDS_Curve& aNC=aVNC(j);
|
||||||
BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
|
BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
|
||||||
aItLPB.Initialize(aLPBC);
|
|
||||||
//
|
|
||||||
// Treat existing pave blocks
|
|
||||||
if (aItLPB.More() && theDME.IsBound(aLPBC.First())) {
|
|
||||||
const Handle(BOPDS_PaveBlock)& aPB=aLPBC.First();
|
|
||||||
BOPDS_ListOfPaveBlock& aLPB=theDME.ChangeFind(aPB);
|
|
||||||
UpdateExistingPaveBlocks(aPB, aLPB, nF1, nF2);
|
|
||||||
aLPBC.Clear();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
// Add section edges to face info
|
// Add section edges to face info
|
||||||
for (; aItLPB.More(); aItLPB.Next()) {
|
aItLPB.Initialize(aLPBC);
|
||||||
|
for (; aItLPB.More(); ) {
|
||||||
const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
|
const Handle(BOPDS_PaveBlock)& aPB=aItLPB.Value();
|
||||||
|
//
|
||||||
|
// Treat existing pave blocks
|
||||||
|
if (theDME.IsBound(aPB)) {
|
||||||
|
BOPDS_ListOfPaveBlock& aLPB=theDME.ChangeFind(aPB);
|
||||||
|
UpdateExistingPaveBlocks(aPB, aLPB, nF1, nF2);
|
||||||
|
aLPBC.Remove(aItLPB);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
aFI1.ChangePaveBlocksSc().Add(aPB);
|
aFI1.ChangePaveBlocksSc().Add(aPB);
|
||||||
aFI2.ChangePaveBlocksSc().Add(aPB);
|
aFI2.ChangePaveBlocksSc().Add(aPB);
|
||||||
|
aItLPB.Next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@@ -1006,6 +1016,11 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo
|
|||||||
const Handle(BOPDS_PaveBlock)& aPB = aMPBCopy(j);
|
const Handle(BOPDS_PaveBlock)& aPB = aMPBCopy(j);
|
||||||
if (theDME.IsBound(aPB)) {
|
if (theDME.IsBound(aPB)) {
|
||||||
const BOPDS_ListOfPaveBlock& aLPB = theDME.Find(aPB);
|
const BOPDS_ListOfPaveBlock& aLPB = theDME.Find(aPB);
|
||||||
|
if (aLPB.IsEmpty()) {
|
||||||
|
aMPBOnIn.Add(aPB);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
aItLPB.Initialize(aLPB);
|
aItLPB.Initialize(aLPB);
|
||||||
for (; aItLPB.More(); aItLPB.Next()) {
|
for (; aItLPB.More(); aItLPB.Next()) {
|
||||||
const Handle(BOPDS_PaveBlock)& aPB1 = aItLPB.Value();
|
const Handle(BOPDS_PaveBlock)& aPB1 = aItLPB.Value();
|
||||||
@@ -1189,7 +1204,7 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo
|
|||||||
const TopoDS_Face& aF2,
|
const TopoDS_Face& aF2,
|
||||||
const Standard_Real aTolR3D,
|
const Standard_Real aTolR3D,
|
||||||
BOPDS_Curve& aNC,
|
BOPDS_Curve& aNC,
|
||||||
BOPCol_MapOfInteger& aMVB)
|
BOPCol_ListOfInteger& aLVB)
|
||||||
{
|
{
|
||||||
Standard_Boolean bVF;
|
Standard_Boolean bVF;
|
||||||
Standard_Integer nV, iFlag, nVn, j, aNbEP;
|
Standard_Integer nV, iFlag, nVn, j, aNbEP;
|
||||||
@@ -1277,7 +1292,8 @@ void BOPAlgo_PaveFiller::UpdateFaceInfo
|
|||||||
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVn);
|
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nVn);
|
||||||
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
|
Bnd_Box& aBoxDS=aSIDS.ChangeBox();
|
||||||
BRepBndLib::Add(aVn, aBoxDS);
|
BRepBndLib::Add(aVn, aBoxDS);
|
||||||
aMVB.Add(nVn);
|
//
|
||||||
|
aLVB.Append(nVn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1769,51 +1785,68 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
|
|||||||
void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks
|
void BOPAlgo_PaveFiller::ProcessExistingPaveBlocks
|
||||||
(const Standard_Integer theInt,
|
(const Standard_Integer theInt,
|
||||||
const BOPDS_IndexedMapOfPaveBlock& aMPBOnIn,
|
const BOPDS_IndexedMapOfPaveBlock& aMPBOnIn,
|
||||||
|
const BOPCol_DataMapOfIntegerListOfInteger& aDMBV,
|
||||||
BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
|
BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
|
||||||
BOPCol_DataMapOfShapeInteger& aMVI,
|
BOPCol_DataMapOfShapeInteger& aMVI,
|
||||||
const BOPCol_MapOfInteger& aMVB,
|
|
||||||
BOPDS_MapOfPaveBlock& aMPB)
|
BOPDS_MapOfPaveBlock& aMPB)
|
||||||
{
|
{
|
||||||
Standard_Integer nV, nE, iFlag, i, aNbPB;
|
if (aDMBV.IsEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
Standard_Real aT;
|
Standard_Real aT;
|
||||||
BOPCol_MapIteratorOfMapOfInteger aItB;
|
Standard_Integer i, nV, nE, iC, aNbPB, iFlag;
|
||||||
|
BOPCol_ListIteratorOfListOfInteger aItLI;
|
||||||
|
BOPCol_DataMapIteratorOfDataMapOfIntegerListOfInteger aItBV;
|
||||||
//
|
//
|
||||||
BOPDS_VectorOfInterfFF& aFFs=myDS->InterfFF();
|
BOPDS_VectorOfInterfFF& aFFs = myDS->InterfFF();
|
||||||
BOPDS_InterfFF& aFF = aFFs(theInt);
|
BOPDS_InterfFF& aFF = aFFs(theInt);
|
||||||
BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves();
|
BOPDS_VectorOfCurve& aVC = aFF.ChangeCurves();
|
||||||
//
|
//
|
||||||
aItB.Initialize(aMVB);
|
aNbPB = aMPBOnIn.Extent();
|
||||||
for (; aItB.More(); aItB.Next()) {
|
//
|
||||||
nV = aItB.Value();
|
aItBV.Initialize(aDMBV);
|
||||||
const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
|
for (; aItBV.More(); aItBV.Next()) {
|
||||||
const Bnd_Box& aBoxV=aSIV.Box();
|
iC = aItBV.Key();
|
||||||
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aSIV.Shape();
|
const BOPCol_ListOfInteger& aLBV = aItBV.Value();
|
||||||
if (!aMVI.IsBound(aV)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
aNbPB = aMPBOnIn.Extent();
|
BOPDS_Curve& aNC = aVC.ChangeValue(iC);
|
||||||
for (i = 1; i <= aNbPB; ++i) {
|
BOPDS_ListOfPaveBlock& aLPBC = aNC.ChangePaveBlocks();
|
||||||
const Handle(BOPDS_PaveBlock)& aPB = aMPBOnIn(i);
|
//
|
||||||
if (aPB->Pave1().Index() == nV || aPB->Pave2().Index() == nV) {
|
aItLI.Initialize(aLBV);
|
||||||
|
for (; aItLI.More(); aItLI.Next()) {
|
||||||
|
nV = aItLI.Value();
|
||||||
|
const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV);
|
||||||
|
const Bnd_Box& aBoxV=aSIV.Box();
|
||||||
|
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aSIV.Shape();
|
||||||
|
if (!aMVI.IsBound(aV)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (aMPB.Contains(aPB)) {
|
for (i = 1; i <= aNbPB; ++i) {
|
||||||
continue;
|
const Handle(BOPDS_PaveBlock)& aPB = aMPBOnIn(i);
|
||||||
}
|
if (aPB->Pave1().Index() == nV || aPB->Pave2().Index() == nV) {
|
||||||
nE=aPB->Edge();
|
continue;
|
||||||
const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
|
}
|
||||||
const Bnd_Box& aBoxE=aSIE.Box();
|
//
|
||||||
//
|
if (aMPB.Contains(aPB)) {
|
||||||
if (!aBoxV.IsOut(aBoxE)) {
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
nE = aPB->Edge();
|
||||||
|
const BOPDS_ShapeInfo& aSIE = myDS->ShapeInfo(nE);
|
||||||
|
const Bnd_Box& aBoxE = aSIE.Box();
|
||||||
|
//
|
||||||
|
if (aBoxV.IsOut(aBoxE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//
|
||||||
const TopoDS_Edge& aE = *(TopoDS_Edge*)&aSIE.Shape();
|
const TopoDS_Edge& aE = *(TopoDS_Edge*)&aSIE.Shape();
|
||||||
//
|
//
|
||||||
iFlag=myContext->ComputeVE (aV, aE, aT);
|
iFlag = myContext->ComputeVE(aV, aE, aT);
|
||||||
if (!iFlag) {
|
if (!iFlag) {
|
||||||
aMPB.Add(aPB);
|
aMPB.Add(aPB);
|
||||||
//
|
PreparePostTreatFF(theInt, iC, aPB, aMSCPB, aMVI, aLPBC);
|
||||||
PreparePostTreatFF(theInt, aPB, aMSCPB, aMVI, aVC);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1888,10 +1921,11 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
|
|||||||
// 3. Update pave blocks
|
// 3. Update pave blocks
|
||||||
if (bCB) {
|
if (bCB) {
|
||||||
//create new common blocks
|
//create new common blocks
|
||||||
|
BOPDS_ListOfPaveBlock aLPBNew;
|
||||||
const BOPCol_ListOfInteger& aFaces = aCB1->Faces();
|
const BOPCol_ListOfInteger& aFaces = aCB1->Faces();
|
||||||
aIt.Initialize(aLPB);
|
aIt.Initialize(aLPB);
|
||||||
for (; aIt.More(); aIt.Next()) {
|
for (; aIt.More(); aIt.Next()) {
|
||||||
Handle(BOPDS_PaveBlock)& aPB = aIt.ChangeValue();
|
const Handle(BOPDS_PaveBlock)& aPB = aIt.Value();
|
||||||
//
|
//
|
||||||
aCB = new BOPDS_CommonBlock;
|
aCB = new BOPDS_CommonBlock;
|
||||||
aIt1.Initialize(aLPB1);
|
aIt1.Initialize(aLPB1);
|
||||||
@@ -1911,8 +1945,11 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
|
|||||||
aCB->AddFaces(aFaces);
|
aCB->AddFaces(aFaces);
|
||||||
myDS->SortPaveBlocks(aCB);
|
myDS->SortPaveBlocks(aCB);
|
||||||
//
|
//
|
||||||
aPB=aCB->PaveBlocks().First();
|
const Handle(BOPDS_PaveBlock)& aPBNew = aCB->PaveBlocks().First();
|
||||||
|
aLPBNew.Append(aPBNew);
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
aLPB = aLPBNew;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nE = aPBf->OriginalEdge();
|
nE = aPBf->OriginalEdge();
|
||||||
@@ -2038,16 +2075,14 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void BOPAlgo_PaveFiller::PreparePostTreatFF
|
void BOPAlgo_PaveFiller::PreparePostTreatFF
|
||||||
(const Standard_Integer aInt,
|
(const Standard_Integer aInt,
|
||||||
|
const Standard_Integer aCur,
|
||||||
const Handle(BOPDS_PaveBlock)& aPB,
|
const Handle(BOPDS_PaveBlock)& aPB,
|
||||||
BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
|
BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& aMSCPB,
|
||||||
BOPCol_DataMapOfShapeInteger& aMVI,
|
BOPCol_DataMapOfShapeInteger& aMVI,
|
||||||
BOPDS_VectorOfCurve& aVC)
|
BOPDS_ListOfPaveBlock& aLPBC)
|
||||||
{
|
{
|
||||||
Standard_Integer nV1, nV2, iC;
|
Standard_Integer nV1, nV2;
|
||||||
//
|
//
|
||||||
aVC.Append1();
|
|
||||||
iC=aVC.Extent()-1;
|
|
||||||
BOPDS_ListOfPaveBlock& aLPBC = aVC(iC).ChangePaveBlocks();
|
|
||||||
aLPBC.Append(aPB);
|
aLPBC.Append(aPB);
|
||||||
//
|
//
|
||||||
aPB->Indices(nV1, nV2);
|
aPB->Indices(nV1, nV2);
|
||||||
@@ -2057,7 +2092,7 @@ void BOPAlgo_PaveFiller::RemoveUsedVertices(BOPDS_Curve& aNC,
|
|||||||
// Keep info for post treatment
|
// Keep info for post treatment
|
||||||
BOPDS_CoupleOfPaveBlocks aCPB;
|
BOPDS_CoupleOfPaveBlocks aCPB;
|
||||||
aCPB.SetIndexInterf(aInt);
|
aCPB.SetIndexInterf(aInt);
|
||||||
aCPB.SetIndex(iC);
|
aCPB.SetIndex(aCur);
|
||||||
aCPB.SetPaveBlock1(aPB);
|
aCPB.SetPaveBlock1(aPB);
|
||||||
//
|
//
|
||||||
aMSCPB.Add(aE, aCPB);
|
aMSCPB.Add(aE, aCPB);
|
||||||
|
@@ -54,6 +54,12 @@ static
|
|||||||
static
|
static
|
||||||
Standard_Boolean IsClosed(const TopoDS_Edge& ,
|
Standard_Boolean IsClosed(const TopoDS_Edge& ,
|
||||||
const TopoDS_Face& );
|
const TopoDS_Face& );
|
||||||
|
static
|
||||||
|
Standard_Real ComputeTol(const TopoDS_Edge& theE,
|
||||||
|
const Standard_Real theFirst,
|
||||||
|
const Standard_Real theLast,
|
||||||
|
const Handle(Geom2d_Curve)& theC,
|
||||||
|
const TopoDS_Face& theF);
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -68,7 +74,7 @@ Standard_Integer BOPTools_AlgoTools2D::AttachExistingPCurve
|
|||||||
{
|
{
|
||||||
Standard_Boolean bIsToReverse, bIsClosed;
|
Standard_Boolean bIsToReverse, bIsClosed;
|
||||||
Standard_Integer iRet;
|
Standard_Integer iRet;
|
||||||
Standard_Real aTol, aT11, aT12, aT21, aT22, aTolPPC;
|
Standard_Real aTol, aTolSP, aT11, aT12, aT21, aT22, aTolPPC;
|
||||||
Handle(Geom2d_Curve) aC2Dold, aC2DoldC;
|
Handle(Geom2d_Curve) aC2Dold, aC2DoldC;
|
||||||
Handle(Geom2d_TrimmedCurve) aC2DT;
|
Handle(Geom2d_TrimmedCurve) aC2DT;
|
||||||
BRep_Builder aBB;
|
BRep_Builder aBB;
|
||||||
@@ -85,24 +91,22 @@ Standard_Integer BOPTools_AlgoTools2D::AttachExistingPCurve
|
|||||||
//
|
//
|
||||||
bIsToReverse=IsToReverse(aE2, aE1, aCtx);
|
bIsToReverse=IsToReverse(aE2, aE1, aCtx);
|
||||||
if (bIsToReverse) {
|
if (bIsToReverse) {
|
||||||
|
Standard_Real aT21r, aT22r;
|
||||||
|
//
|
||||||
aC2DoldC->Reverse();
|
aC2DoldC->Reverse();
|
||||||
//
|
//
|
||||||
gp_Pnt2d aP1, aP2;
|
aT21r=aC2DoldC->ReversedParameter(aT21);
|
||||||
//
|
aT22r=aC2DoldC->ReversedParameter(aT22);
|
||||||
aC2Dold->D0(aT22, aP2);
|
aT21=aT22r;
|
||||||
aC2DoldC->D0(aT21, aP1);
|
aT22=aT21r;
|
||||||
aC2DoldC->Translate(aP1, aP2);
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
aC2DT=new Geom2d_TrimmedCurve(aC2DoldC, aT21, aT22);
|
aC2DT=new Geom2d_TrimmedCurve(aC2DoldC, aT21, aT22);
|
||||||
//
|
//
|
||||||
aTol=BRep_Tool::Tolerance(aE1);
|
|
||||||
BRep_Tool::Range (aE1, aT11, aT12);
|
|
||||||
aBB.SameRange(aE1, Standard_False);
|
|
||||||
aBB.SameParameter(aE1, Standard_False);
|
|
||||||
|
|
||||||
aTolPPC=Precision::PConfusion();
|
aTolPPC=Precision::PConfusion();
|
||||||
//
|
//
|
||||||
|
BRep_Tool::Range (aE1, aT11, aT12);
|
||||||
|
//
|
||||||
GeomLib::SameRange(aTolPPC, aC2DT, aT21, aT22, aT11, aT12, aC2DT);
|
GeomLib::SameRange(aTolPPC, aC2DT, aT21, aT22, aT11, aT12, aC2DT);
|
||||||
//
|
//
|
||||||
if (aC2DT.IsNull()){
|
if (aC2DT.IsNull()){
|
||||||
@@ -110,6 +114,19 @@ Standard_Integer BOPTools_AlgoTools2D::AttachExistingPCurve
|
|||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
// check the curves on same parameter to prevent
|
||||||
|
// big tolerance increasing
|
||||||
|
aTol = BRep_Tool::Tolerance(aE1);
|
||||||
|
aTolSP = ComputeTol(aE1, aT11, aT12, aC2DT, aF);
|
||||||
|
//
|
||||||
|
if ((aTolSP > 10.*aTol) && aTolSP > 0.1) {
|
||||||
|
iRet = 3;
|
||||||
|
return iRet;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aBB.SameRange(aE1, Standard_False);
|
||||||
|
aBB.SameParameter(aE1, Standard_False);
|
||||||
|
//
|
||||||
aBB.UpdateEdge(aE1, aC2DT, aF, aTol);
|
aBB.UpdateEdge(aE1, aC2DT, aF, aTol);
|
||||||
BRepLib::SameParameter(aE1);
|
BRepLib::SameParameter(aE1);
|
||||||
BRepLib::SameRange(aE1);
|
BRepLib::SameRange(aE1);
|
||||||
@@ -118,7 +135,7 @@ Standard_Integer BOPTools_AlgoTools2D::AttachExistingPCurve
|
|||||||
if (bIsClosed) {
|
if (bIsClosed) {
|
||||||
iRet=UpdateClosedPCurve(aE2, aE1, aF, aCtx);
|
iRet=UpdateClosedPCurve(aE2, aE1, aF, aCtx);
|
||||||
if(iRet) {
|
if(iRet) {
|
||||||
iRet=3;
|
iRet=4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@@ -308,4 +325,40 @@ Standard_Boolean IsClosed(const TopoDS_Edge& aE,
|
|||||||
}
|
}
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : ComputeTol
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Real ComputeTol(const TopoDS_Edge& theE,
|
||||||
|
const Standard_Real theFirst,
|
||||||
|
const Standard_Real theLast,
|
||||||
|
const Handle(Geom2d_Curve)& theC,
|
||||||
|
const TopoDS_Face& theF)
|
||||||
|
{
|
||||||
|
Standard_Real f, l, aD, aDMax, aT, aDt;
|
||||||
|
gp_Pnt aP1, aP2;
|
||||||
|
gp_Pnt2d aP2d;
|
||||||
|
//
|
||||||
|
const Standard_Integer NCONTROL = 22;
|
||||||
|
//
|
||||||
|
const Handle(Geom_Curve)& aC = BRep_Tool::Curve(theE, f, l);
|
||||||
|
const Handle(Geom_Surface)& aS = BRep_Tool::Surface(theF);
|
||||||
|
//
|
||||||
|
aDMax = 0.;
|
||||||
|
aDt = (theLast - theFirst) / NCONTROL;
|
||||||
|
//
|
||||||
|
for (aT = theFirst; aT <= theLast; aT += aDt) {
|
||||||
|
theC->D0(aT, aP2d);
|
||||||
|
aS->D0(aP2d.X(), aP2d.Y(), aP1);
|
||||||
|
//
|
||||||
|
aC->D0(aT, aP2);
|
||||||
|
//
|
||||||
|
aD = aP1.SquareDistance(aP2);
|
||||||
|
if (aD > aDMax) {
|
||||||
|
aDMax = aD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
aDMax = sqrt(aDMax);
|
||||||
|
return aDMax;
|
||||||
|
}
|
||||||
|
@@ -7,5 +7,3 @@ Font_FTLibrary.hxx
|
|||||||
Font_FTLibrary.cxx
|
Font_FTLibrary.cxx
|
||||||
Font_NListOfSystemFont.hxx
|
Font_NListOfSystemFont.hxx
|
||||||
Font_NameOfFont.hxx
|
Font_NameOfFont.hxx
|
||||||
Font_TextFormatter.hxx
|
|
||||||
Font_TextFormatter.cxx
|
|
@@ -516,51 +516,3 @@ TopoDS_Shape Font_BRepFont::RenderText (const NCollection_String& theString)
|
|||||||
}
|
}
|
||||||
return aResult;
|
return aResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : BoundingBox
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
Font_FTFont::Rect Font_BRepFont::BoundingBox (const NCollection_String& theString)
|
|
||||||
{
|
|
||||||
Rect aBox;
|
|
||||||
aBox.Left = 0.f;
|
|
||||||
aBox.Right = 0.f;
|
|
||||||
aBox.Bottom = 0.f;
|
|
||||||
aBox.Top = static_cast<float> (Ascender());
|
|
||||||
|
|
||||||
Standard_Integer aLine = 0;
|
|
||||||
Standard_Real aCurrWidth = 0.;
|
|
||||||
for (NCollection_Utf8Iter anIter = theString.Iterator(); *anIter != 0;)
|
|
||||||
{
|
|
||||||
const Standard_Utf32Char aCharCurr = *anIter;
|
|
||||||
const Standard_Utf32Char aCharNext = *++anIter;
|
|
||||||
if (aCharCurr == '\x0D' // CR (carriage return)
|
|
||||||
|| aCharCurr == '\a' // BEL (alarm)
|
|
||||||
|| aCharCurr == '\f' // FF (form feed) NP (new page)
|
|
||||||
|| aCharCurr == '\b' // BS (backspace)
|
|
||||||
|| aCharCurr == '\v') // VT (vertical tab)
|
|
||||||
{
|
|
||||||
continue; // skip unsupported carriage control codes
|
|
||||||
}
|
|
||||||
else if (aCharCurr == ' ' || aCharCurr == '\t')
|
|
||||||
{
|
|
||||||
aCurrWidth += AdvanceX (aCharCurr, aCharNext);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (aCharCurr == '\n')
|
|
||||||
{
|
|
||||||
aBox.Right = Max (aBox.Right, static_cast<float> (aCurrWidth));
|
|
||||||
aCurrWidth = 0;
|
|
||||||
++aLine;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
aCurrWidth += AdvanceX (aCharCurr, aCharNext);
|
|
||||||
}
|
|
||||||
|
|
||||||
aBox.Right = Max (aBox.Right, static_cast<float> (aCurrWidth));
|
|
||||||
aBox.Bottom = aBox.Top - static_cast<float> (LineSpacing() * Standard_Real (aLine + 1));
|
|
||||||
|
|
||||||
return aBox;
|
|
||||||
}
|
|
||||||
|
@@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
#include <Font_FTFont.hxx>
|
#include <Font_FTFont.hxx>
|
||||||
#include <Font_FontMgr.hxx>
|
#include <Font_FontMgr.hxx>
|
||||||
#include <Font_TextFormatter.hxx>
|
|
||||||
|
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
#include <TCollection_HAsciiString.hxx>
|
#include <TCollection_HAsciiString.hxx>
|
||||||
|
|
||||||
@@ -259,25 +257,3 @@ float Font_FTFont::AdvanceY (const Standard_Utf32Char theUCharNext)
|
|||||||
}
|
}
|
||||||
return fromFTPoints<float> (myKernAdvance.y + myFTFace->glyph->advance.y);
|
return fromFTPoints<float> (myKernAdvance.y + myFTFace->glyph->advance.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : BoundingBox
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
Font_FTFont::Rect Font_FTFont::BoundingBox (const NCollection_String& theString,
|
|
||||||
const Graphic3d_HorizontalTextAlignment theAlignX,
|
|
||||||
const Graphic3d_VerticalTextAlignment theAlignY)
|
|
||||||
{
|
|
||||||
Font_TextFormatter aFormatter;
|
|
||||||
aFormatter.SetupAlignment (theAlignX, theAlignY);
|
|
||||||
aFormatter.Reset();
|
|
||||||
|
|
||||||
aFormatter.Append (theString, *this);
|
|
||||||
aFormatter.Format();
|
|
||||||
|
|
||||||
Rect aBndBox;
|
|
||||||
|
|
||||||
aFormatter.BndBox (aBndBox);
|
|
||||||
|
|
||||||
return aBndBox;
|
|
||||||
}
|
|
||||||
|
@@ -16,13 +16,11 @@
|
|||||||
#ifndef _Font_FTFont_H__
|
#ifndef _Font_FTFont_H__
|
||||||
#define _Font_FTFont_H__
|
#define _Font_FTFont_H__
|
||||||
|
|
||||||
#include <Font_FontAspect.hxx>
|
|
||||||
#include <Font_FTLibrary.hxx>
|
|
||||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
|
||||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
|
||||||
#include <Image_PixMap.hxx>
|
|
||||||
#include <NCollection_String.hxx>
|
|
||||||
#include <NCollection_Vec2.hxx>
|
#include <NCollection_Vec2.hxx>
|
||||||
|
#include <NCollection_String.hxx>
|
||||||
|
#include <Font_FTLibrary.hxx>
|
||||||
|
#include <Image_PixMap.hxx>
|
||||||
|
#include <Font_FontAspect.hxx>
|
||||||
|
|
||||||
//! Wrapper over FreeType font.
|
//! Wrapper over FreeType font.
|
||||||
//! Notice that this class uses internal buffers for loaded glyphs
|
//! Notice that this class uses internal buffers for loaded glyphs
|
||||||
@@ -40,11 +38,6 @@ public:
|
|||||||
float Top;
|
float Top;
|
||||||
float Bottom;
|
float Bottom;
|
||||||
|
|
||||||
NCollection_Vec2<float> TopLeft() const
|
|
||||||
{
|
|
||||||
return NCollection_Vec2<float> (Left, Top);
|
|
||||||
}
|
|
||||||
|
|
||||||
NCollection_Vec2<float>& TopLeft (NCollection_Vec2<float>& theVec) const
|
NCollection_Vec2<float>& TopLeft (NCollection_Vec2<float>& theVec) const
|
||||||
{
|
{
|
||||||
theVec.x() = Left;
|
theVec.x() = Left;
|
||||||
@@ -73,16 +66,6 @@ public:
|
|||||||
return theVec;
|
return theVec;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Width () const
|
|
||||||
{
|
|
||||||
return Right - Left;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Height () const
|
|
||||||
{
|
|
||||||
return Top - Bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -195,13 +178,6 @@ public:
|
|||||||
theRect.Bottom = float(myFTFace->glyph->bitmap_top - (int )aBitmap.rows);
|
theRect.Bottom = float(myFTFace->glyph->bitmap_top - (int )aBitmap.rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! 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);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//! Convert value to 26.6 fixed-point format for FT library API.
|
//! Convert value to 26.6 fixed-point format for FT library API.
|
||||||
|
@@ -1,312 +0,0 @@
|
|||||||
// Created on: 2013-01-29
|
|
||||||
// Created by: Kirill GAVRILOV
|
|
||||||
// Copyright (c) 2013-2014 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.
|
|
||||||
|
|
||||||
#include <Font_TextFormatter.hxx>
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
typedef NCollection_Vec2<Standard_ShortReal> Vec2f;
|
|
||||||
|
|
||||||
//! Auxiliary function to translate corners by the vector.
|
|
||||||
inline void move (NCollection_Vector< Vec2f >& theCorners,
|
|
||||||
const Vec2f& theMoveVec,
|
|
||||||
Standard_Integer theCharLower,
|
|
||||||
const Standard_Integer theCharUpper)
|
|
||||||
{
|
|
||||||
for(; theCharLower <= theCharUpper; ++theCharLower)
|
|
||||||
{
|
|
||||||
theCorners.ChangeValue (theCharLower) += theMoveVec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Auxiliary function to translate corners in vertical direction.
|
|
||||||
inline void moveY (NCollection_Vector<Vec2f>& theCorners,
|
|
||||||
const Standard_ShortReal theMoveVec,
|
|
||||||
Standard_Integer theCharLower,
|
|
||||||
const Standard_Integer theCharUpper)
|
|
||||||
{
|
|
||||||
for(; theCharLower <= theCharUpper; ++theCharLower)
|
|
||||||
{
|
|
||||||
theCorners.ChangeValue (theCharLower).y() += theMoveVec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Apply floor to vector components.
|
|
||||||
//! @param theVec - vector to change (by reference!)
|
|
||||||
//! @return modified vector
|
|
||||||
inline Vec2f& floor (Vec2f& theVec)
|
|
||||||
{
|
|
||||||
theVec.x() = std::floor (theVec.x());
|
|
||||||
theVec.y() = std::floor (theVec.y());
|
|
||||||
return theVec;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_HANDLE (Font_TextFormatter, Standard_Transient)
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(Font_TextFormatter, Standard_Transient)
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : Font_TextFormatter
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
Font_TextFormatter::Font_TextFormatter()
|
|
||||||
: myAlignX (Graphic3d_HTA_LEFT),
|
|
||||||
myAlignY (Graphic3d_VTA_TOP),
|
|
||||||
myTabSize (8),
|
|
||||||
//
|
|
||||||
myPen (0.0f, 0.0f),
|
|
||||||
myRectsNb (0),
|
|
||||||
myLineSpacing (0.0f),
|
|
||||||
myAscender (0.0f),
|
|
||||||
myIsFormatted (false),
|
|
||||||
//
|
|
||||||
myLinesNb (0),
|
|
||||||
myRectLineStart (0),
|
|
||||||
myRectWordStart (0),
|
|
||||||
myNewLineNb(0),
|
|
||||||
myPenCurrLine (0.0f),
|
|
||||||
myBndTop (0.0f),
|
|
||||||
myBndWidth (0.0f),
|
|
||||||
myMoveVec (0.0f, 0.0f)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : SetupAlignment
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
void Font_TextFormatter::SetupAlignment (const Graphic3d_HorizontalTextAlignment theAlignX,
|
|
||||||
const Graphic3d_VerticalTextAlignment theAlignY)
|
|
||||||
{
|
|
||||||
myAlignX = theAlignX;
|
|
||||||
myAlignY = theAlignY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : Reset
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
void Font_TextFormatter::Reset()
|
|
||||||
{
|
|
||||||
myIsFormatted = false;
|
|
||||||
myString.Clear();
|
|
||||||
myPen.x() = myPen.y() = 0.0f;
|
|
||||||
myRectsNb = 0;
|
|
||||||
myLineSpacing = myAscender = 0.0f;
|
|
||||||
myCorners.Clear();
|
|
||||||
myNewLines.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : Append
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
void Font_TextFormatter::Append (const NCollection_String& theString,
|
|
||||||
Font_FTFont& theFont)
|
|
||||||
{
|
|
||||||
if (theString.IsEmpty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
myAscender = Max (myAscender, theFont.Ascender());
|
|
||||||
myLineSpacing = Max (myLineSpacing, theFont.LineSpacing());
|
|
||||||
myString += theString;
|
|
||||||
|
|
||||||
int aSymbolsCounter = 0; // special counter to process tabulation symbols
|
|
||||||
|
|
||||||
// first pass - render all symbols using associated font on single ZERO baseline
|
|
||||||
for (NCollection_Utf8Iter anIter = theString.Iterator(); *anIter != 0;)
|
|
||||||
{
|
|
||||||
const Standard_Utf32Char aCharThis = *anIter;
|
|
||||||
const Standard_Utf32Char aCharNext = *++anIter;
|
|
||||||
|
|
||||||
if (aCharThis == '\x0D' // CR (carriage return)
|
|
||||||
|| aCharThis == '\a' // BEL (alarm)
|
|
||||||
|| aCharThis == '\f' // FF (form feed) NP (new page)
|
|
||||||
|| aCharThis == '\b' // BS (backspace)
|
|
||||||
|| aCharThis == '\v') // VT (vertical tab)
|
|
||||||
{
|
|
||||||
continue; // skip unsupported carriage control codes
|
|
||||||
}
|
|
||||||
else if (aCharThis == '\x0A') // LF (line feed, new line)
|
|
||||||
{
|
|
||||||
aSymbolsCounter = 0;
|
|
||||||
myNewLines.Append (myPen.x());
|
|
||||||
continue; // will be processed on second pass
|
|
||||||
}
|
|
||||||
else if (aCharThis == ' ')
|
|
||||||
{
|
|
||||||
++aSymbolsCounter;
|
|
||||||
myPen.x() += theFont.AdvanceX (' ', aCharNext);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (aCharThis == '\t')
|
|
||||||
{
|
|
||||||
const Standard_Integer aSpacesNum = (myTabSize - (aSymbolsCounter - 1) % myTabSize);
|
|
||||||
myPen.x() += theFont.AdvanceX (' ', aCharNext) * Standard_ShortReal(aSpacesNum);
|
|
||||||
aSymbolsCounter += aSpacesNum;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
++aSymbolsCounter;
|
|
||||||
|
|
||||||
myCorners.Append (myPen);
|
|
||||||
|
|
||||||
myPen.x() += theFont.AdvanceX (aCharThis, aCharNext);
|
|
||||||
|
|
||||||
++myRectsNb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : newLine
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
void Font_TextFormatter::newLine (const Standard_Integer theLastRect)
|
|
||||||
{
|
|
||||||
if (myRectLineStart >= myRectsNb)
|
|
||||||
{
|
|
||||||
++myLinesNb;
|
|
||||||
myPenCurrLine -= myLineSpacing;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
myMoveVec.y() = myPenCurrLine;
|
|
||||||
switch (myAlignX)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case Graphic3d_HTA_LEFT:
|
|
||||||
{
|
|
||||||
myMoveVec.x() = (myNewLineNb > 0) ? -myNewLines.Value (myNewLineNb - 1) : 0.0f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Graphic3d_HTA_RIGHT:
|
|
||||||
{
|
|
||||||
myMoveVec.x() = (myNewLineNb < myNewLines.Length())
|
|
||||||
? -myNewLines.Value (myNewLineNb)
|
|
||||||
: -myPen.x();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Graphic3d_HTA_CENTER:
|
|
||||||
{
|
|
||||||
const Standard_ShortReal aFrom = (myNewLineNb > 0)
|
|
||||||
? myNewLines.Value (myNewLineNb - 1)
|
|
||||||
: 0.0f;
|
|
||||||
const Standard_ShortReal aTo = (myNewLineNb < myNewLines.Length())
|
|
||||||
? myNewLines.Value (myNewLineNb)
|
|
||||||
: myPen.x();
|
|
||||||
myMoveVec.x() = -0.5f * (aFrom + aTo);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
move (myCorners, myMoveVec, myRectLineStart, theLastRect);
|
|
||||||
|
|
||||||
++myLinesNb;
|
|
||||||
myPenCurrLine -= myLineSpacing;
|
|
||||||
myRectLineStart = myRectWordStart = theLastRect + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : Format
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
void Font_TextFormatter::Format()
|
|
||||||
{
|
|
||||||
if (myRectsNb == 0 || myIsFormatted)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
myIsFormatted = true;
|
|
||||||
myLinesNb = myRectLineStart = myRectWordStart = 0;
|
|
||||||
myBndTop = 0.0f;
|
|
||||||
myBndWidth = 0.0f;
|
|
||||||
myMoveVec.x() = myMoveVec.y() = 0.0f;
|
|
||||||
|
|
||||||
// split text into lines and apply horizontal alignment
|
|
||||||
myPenCurrLine = -myAscender;
|
|
||||||
Standard_Integer aRectIter = 0;
|
|
||||||
myNewLineNb = 0;
|
|
||||||
Standard_ShortReal aMaxLineWidth = -1.0f;
|
|
||||||
for (NCollection_Utf8Iter anIter = myString.Iterator(); *anIter != 0; ++anIter)
|
|
||||||
{
|
|
||||||
const Standard_Utf32Char aCharThis = *anIter;
|
|
||||||
if (aCharThis == '\x0D' // CR (carriage return)
|
|
||||||
|| aCharThis == '\a' // BEL (alarm)
|
|
||||||
|| aCharThis == '\f' // FF (form feed) NP (new page)
|
|
||||||
|| aCharThis == '\b' // BS (backspace)
|
|
||||||
|| aCharThis == '\v') // VT (vertical tab)
|
|
||||||
{
|
|
||||||
continue; // skip unsupported carriage control codes
|
|
||||||
}
|
|
||||||
else if (aCharThis == '\x0A') // LF (line feed, new line)
|
|
||||||
{
|
|
||||||
// calculate max line width
|
|
||||||
if (myNewLineNb == 0)
|
|
||||||
{
|
|
||||||
aMaxLineWidth = myNewLines.Value(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aMaxLineWidth = Max (aMaxLineWidth, myNewLines.Value (myNewLineNb) - myNewLines.Value (myNewLineNb - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
const Standard_Integer aLastRect = aRectIter - 1; // last rect on current line
|
|
||||||
newLine (aLastRect);
|
|
||||||
++myNewLineNb;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (aCharThis == ' '
|
|
||||||
|| aCharThis == '\t')
|
|
||||||
{
|
|
||||||
myRectWordStart = aRectIter;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
++aRectIter;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If only one line
|
|
||||||
if (aMaxLineWidth < 0.0f)
|
|
||||||
{
|
|
||||||
aMaxLineWidth = myPen.x();
|
|
||||||
}
|
|
||||||
else // Consider last line
|
|
||||||
{
|
|
||||||
aMaxLineWidth = Max (aMaxLineWidth, myPen.x() - myNewLines.Value (myNewLineNb - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
myBndWidth = aMaxLineWidth;
|
|
||||||
|
|
||||||
// move last line
|
|
||||||
newLine (myRectsNb - 1);
|
|
||||||
|
|
||||||
// apply vertical alignment style
|
|
||||||
if (myAlignY == Graphic3d_VTA_BOTTOM)
|
|
||||||
{
|
|
||||||
myBndTop = -myLineSpacing - myPenCurrLine;
|
|
||||||
moveY (myCorners, myBndTop, 0, myRectsNb - 1);
|
|
||||||
}
|
|
||||||
else if (myAlignY == Graphic3d_VTA_CENTER)
|
|
||||||
{
|
|
||||||
myBndTop = 0.5f * (myLineSpacing * Standard_ShortReal(myLinesNb));
|
|
||||||
moveY (myCorners, myBndTop, 0, myRectsNb - 1);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -26,6 +26,8 @@ OpenGl_Element.hxx
|
|||||||
OpenGl_Element.cxx
|
OpenGl_Element.cxx
|
||||||
OpenGl_Text.hxx
|
OpenGl_Text.hxx
|
||||||
OpenGl_Text.cxx
|
OpenGl_Text.cxx
|
||||||
|
OpenGl_TextFormatter.hxx
|
||||||
|
OpenGl_TextFormatter.cxx
|
||||||
OpenGl_PointSprite.hxx
|
OpenGl_PointSprite.hxx
|
||||||
OpenGl_PointSprite.cxx
|
OpenGl_PointSprite.cxx
|
||||||
Handle_OpenGl_PointSprite.hxx
|
Handle_OpenGl_PointSprite.hxx
|
||||||
@@ -167,5 +169,3 @@ OpenGl_Sphere.hxx
|
|||||||
OpenGl_Sphere.cxx
|
OpenGl_Sphere.cxx
|
||||||
OpenGl_BackgroundArray.hxx
|
OpenGl_BackgroundArray.hxx
|
||||||
OpenGl_BackgroundArray.cxx
|
OpenGl_BackgroundArray.cxx
|
||||||
OpenGl_TextBuilder.hxx
|
|
||||||
OpenGl_TextBuilder.cxx
|
|
||||||
|
@@ -203,12 +203,14 @@ bool OpenGl_Font::renderGlyph (const Handle(OpenGl_Context)& theCtx,
|
|||||||
// function : RenderGlyph
|
// function : RenderGlyph
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
bool OpenGl_Font::RenderGlyph (const Handle(OpenGl_Context)& theCtx,
|
void OpenGl_Font::RenderGlyph (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Standard_Utf32Char theUChar,
|
const Standard_Utf32Char theUChar,
|
||||||
Tile& theGlyph)
|
const Standard_Utf32Char theUCharNext,
|
||||||
|
OpenGl_Font::Tile& theGlyph,
|
||||||
|
OpenGl_Vec2& thePen)
|
||||||
{
|
{
|
||||||
Standard_Integer aTileId = 0;
|
Standard_Integer aTileId = 0;
|
||||||
if (!myGlyphMap.Find (theUChar,aTileId))
|
if (!myGlyphMap.Find (theUChar, aTileId))
|
||||||
{
|
{
|
||||||
if (renderGlyph (theCtx, theUChar))
|
if (renderGlyph (theCtx, theUChar))
|
||||||
{
|
{
|
||||||
@@ -216,16 +218,19 @@ bool OpenGl_Font::RenderGlyph (const Handle(OpenGl_Context)& theCtx,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
thePen.x() += myFont->AdvanceX (theUChar, theUCharNext);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
myGlyphMap.Bind (theUChar, aTileId);
|
myGlyphMap.Bind (theUChar, aTileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const OpenGl_Font::Tile& aTile = myTiles.Value (aTileId);
|
const OpenGl_Font::Tile& aTile = myTiles.Value (aTileId);
|
||||||
theGlyph.px = aTile.px;
|
theGlyph.px.Top = thePen.y() + aTile.px.Top;
|
||||||
theGlyph.uv = aTile.uv;
|
theGlyph.px.Bottom = thePen.y() + aTile.px.Bottom;
|
||||||
theGlyph.texture = aTile.texture;
|
theGlyph.px.Left = thePen.x() + aTile.px.Left;
|
||||||
|
theGlyph.px.Right = thePen.x() + aTile.px.Right;
|
||||||
|
theGlyph.uv = aTile.uv;
|
||||||
|
theGlyph.texture = aTile.texture;
|
||||||
|
|
||||||
return true;
|
thePen.x() += myFont->AdvanceX (theUChar, theUCharNext);
|
||||||
}
|
}
|
||||||
|
@@ -115,13 +115,18 @@ public:
|
|||||||
return myLineSpacing;
|
return myLineSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Render glyph to texture if not already.
|
//! Compute glyph rectangle at specified pen position (on baseline)
|
||||||
|
//! and render it to texture if not already.
|
||||||
//! @param theCtx active context
|
//! @param theCtx active context
|
||||||
//! @param theUChar unicode symbol to render
|
//! @param theUChar unicode symbol to render
|
||||||
|
//! @param theUCharNext next symbol to compute advance with kerning when available
|
||||||
//! @param theGlyph computed glyph position rectangle, texture ID and UV coordinates
|
//! @param theGlyph computed glyph position rectangle, texture ID and UV coordinates
|
||||||
Standard_EXPORT bool RenderGlyph (const Handle(OpenGl_Context)& theCtx,
|
//! @param thePen pen position on baseline to place new glyph
|
||||||
|
Standard_EXPORT void RenderGlyph (const Handle(OpenGl_Context)& theCtx,
|
||||||
const Standard_Utf32Char theUChar,
|
const Standard_Utf32Char theUChar,
|
||||||
Tile& theGlyph);
|
const Standard_Utf32Char theUCharNext,
|
||||||
|
Tile& theGlyph,
|
||||||
|
OpenGl_Vec2& thePen);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@@ -464,7 +464,8 @@ void OpenGl_Text::setupMatrix (const Handle(OpenGl_PrinterContext)& thePrintCtx,
|
|||||||
anObjZ);
|
anObjZ);
|
||||||
|
|
||||||
OpenGl_Utils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
|
OpenGl_Utils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
|
||||||
OpenGl_Utils::Rotate<GLdouble> (aModViewMat, theTextAspect.Angle(), 0.0, 0.0, 1.0);
|
OpenGl_Utils::Rotate<GLdouble> (aModViewMat, theTextAspect.Angle(), 0.0, 0.0, 1.0);
|
||||||
|
|
||||||
if (!theTextAspect.IsZoomable())
|
if (!theTextAspect.IsZoomable())
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -579,7 +580,6 @@ Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
|
|||||||
if (!aRequestedFont.IsNull())
|
if (!aRequestedFont.IsNull())
|
||||||
{
|
{
|
||||||
aFontFt = new Font_FTFont (NULL);
|
aFontFt = new Font_FTFont (NULL);
|
||||||
|
|
||||||
if (aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight))
|
if (aFontFt->Init (aRequestedFont->FontPath()->ToCString(), theHeight))
|
||||||
{
|
{
|
||||||
aFont = new OpenGl_Font (aFontFt, theKey);
|
aFont = new OpenGl_Font (aFontFt, theKey);
|
||||||
@@ -655,21 +655,13 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
|
|||||||
|
|
||||||
if (myTextures.IsEmpty())
|
if (myTextures.IsEmpty())
|
||||||
{
|
{
|
||||||
Font_TextFormatter aFormatter;
|
OpenGl_TextFormatter aFormatter;
|
||||||
aFormatter.SetupAlignment (myParams.HAlign, myParams.VAlign);
|
aFormatter.SetupAlignment (myParams.HAlign, myParams.VAlign);
|
||||||
aFormatter.Reset();
|
aFormatter.Reset();
|
||||||
|
aFormatter.Append (theCtx, myString, *myFont.operator->());
|
||||||
aFormatter.Append (myString, *myFont->FTFont());
|
|
||||||
aFormatter.Format();
|
aFormatter.Format();
|
||||||
|
|
||||||
OpenGl_TextBuilder aBuilder;
|
aFormatter.Result (theCtx, myTextures, myVertsVbo, myTCrdsVbo);
|
||||||
aBuilder.Perform (aFormatter,
|
|
||||||
theCtx,
|
|
||||||
*myFont.operator->(),
|
|
||||||
myTextures,
|
|
||||||
myVertsVbo,
|
|
||||||
myTCrdsVbo);
|
|
||||||
|
|
||||||
aFormatter.BndBox (myBndBox);
|
aFormatter.BndBox (myBndBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <OpenGl_AspectText.hxx>
|
#include <OpenGl_AspectText.hxx>
|
||||||
#include <OpenGl_TextParam.hxx>
|
#include <OpenGl_TextParam.hxx>
|
||||||
#include <OpenGl_TextBuilder.hxx>
|
#include <OpenGl_TextFormatter.hxx>
|
||||||
|
|
||||||
#include <TCollection_ExtendedString.hxx>
|
#include <TCollection_ExtendedString.hxx>
|
||||||
#include <Graphic3d_Vertex.hxx>
|
#include <Graphic3d_Vertex.hxx>
|
||||||
|
@@ -1,221 +0,0 @@
|
|||||||
// Created on: 2015-06-18
|
|
||||||
// Created by: Ilya SEVRIKOV
|
|
||||||
// Copyright (c) 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.
|
|
||||||
|
|
||||||
#include <OpenGl_TextBuilder.hxx>
|
|
||||||
#include <OpenGl_VertexBufferCompat.hxx>
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
//! Apply floor to vector components.
|
|
||||||
//! @param theVec - vector to change (by reference!)
|
|
||||||
//! @return modified vector
|
|
||||||
inline OpenGl_Vec2& floor (OpenGl_Vec2& theVec)
|
|
||||||
{
|
|
||||||
theVec.x() = std::floor (theVec.x());
|
|
||||||
theVec.y() = std::floor (theVec.y());
|
|
||||||
return theVec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : OpenGl_TextBuilder
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
OpenGl_TextBuilder::OpenGl_TextBuilder()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : createGlyphs
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
void OpenGl_TextBuilder::createGlyphs (const Font_TextFormatter& theFormatter,
|
|
||||||
const Handle(OpenGl_Context)& theCtx,
|
|
||||||
OpenGl_Font& theFont,
|
|
||||||
NCollection_Vector<GLuint>& theTextures,
|
|
||||||
NCollection_Vector<NCollection_Handle<NCollection_Vector<OpenGl_Vec2> > >& theVertsPerTexture,
|
|
||||||
NCollection_Vector<NCollection_Handle<NCollection_Vector<OpenGl_Vec2> > >& theTCrdsPerTexture)
|
|
||||||
{
|
|
||||||
OpenGl_Vec2 aVec (0.0f, 0.0f);
|
|
||||||
|
|
||||||
theTextures.Clear();
|
|
||||||
theVertsPerTexture.Clear();
|
|
||||||
theTCrdsPerTexture.Clear();
|
|
||||||
|
|
||||||
OpenGl_Font::Tile aTile = {};
|
|
||||||
OpenGl_Vec2 aPen (0.0f, 0.0f);
|
|
||||||
Standard_Integer aRectsNb = 0;
|
|
||||||
Standard_Integer aSymbolsCounter = 0;
|
|
||||||
|
|
||||||
for (NCollection_Utf8Iter anIter = theFormatter.String().Iterator(); *anIter != 0;)
|
|
||||||
{
|
|
||||||
const Standard_Utf32Char aCharThis = *anIter;
|
|
||||||
const Standard_Utf32Char aCharNext = *++anIter;
|
|
||||||
|
|
||||||
if (aCharThis == '\x0D' // CR (carriage return)
|
|
||||||
|| aCharThis == '\a' // BEL (alarm)
|
|
||||||
|| aCharThis == '\f' // FF (form feed) NP (new page)
|
|
||||||
|| aCharThis == '\b' // BS (backspace)
|
|
||||||
|| aCharThis == '\v') // VT (vertical tab)
|
|
||||||
{
|
|
||||||
continue; // skip unsupported carriage control codes
|
|
||||||
}
|
|
||||||
else if (aCharThis == '\x0A') // LF (line feed, new line)
|
|
||||||
{
|
|
||||||
aSymbolsCounter = 0;
|
|
||||||
continue; // will be processed on second pass
|
|
||||||
}
|
|
||||||
else if (aCharThis == ' ')
|
|
||||||
{
|
|
||||||
++aSymbolsCounter;
|
|
||||||
aPen.x() += theFont.AdvanceX (' ', aCharNext);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (aCharThis == '\t')
|
|
||||||
{
|
|
||||||
const Standard_Integer aSpacesNum = (theFormatter.TabSize() - (aSymbolsCounter - 1) % theFormatter.TabSize());
|
|
||||||
aPen.x() += theFont.AdvanceX (' ', aCharNext) * Standard_ShortReal(aSpacesNum);
|
|
||||||
aSymbolsCounter += aSpacesNum;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
++aSymbolsCounter;
|
|
||||||
|
|
||||||
theFont.RenderGlyph (theCtx, aCharThis, aTile);
|
|
||||||
|
|
||||||
const OpenGl_Vec2& aTopLeft = theFormatter.TopLeft (aRectsNb);
|
|
||||||
aTile.px.Right += aTopLeft.x();
|
|
||||||
aTile.px.Left += aTopLeft.x();
|
|
||||||
aTile.px.Bottom += aTopLeft.y();
|
|
||||||
aTile.px.Top += aTopLeft.y();
|
|
||||||
const Font_FTFont::Rect& aRectUV = aTile.uv;
|
|
||||||
const GLuint aTexture = aTile.texture;
|
|
||||||
|
|
||||||
Standard_Integer aListId = 0;
|
|
||||||
for (aListId = 0; aListId < theTextures.Length(); ++aListId)
|
|
||||||
{
|
|
||||||
if (theTextures.Value (aListId) == aTexture)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (aListId >= theTextures.Length())
|
|
||||||
{
|
|
||||||
theTextures.Append (aTexture);
|
|
||||||
theVertsPerTexture.Append (new NCollection_Vector<OpenGl_Vec2>());
|
|
||||||
theTCrdsPerTexture.Append (new NCollection_Vector<OpenGl_Vec2>());
|
|
||||||
}
|
|
||||||
|
|
||||||
NCollection_Vector<OpenGl_Vec2>& aVerts = *theVertsPerTexture.ChangeValue (aListId);
|
|
||||||
NCollection_Vector<OpenGl_Vec2>& aTCrds = *theTCrdsPerTexture.ChangeValue (aListId);
|
|
||||||
|
|
||||||
// apply floor on position to avoid blurring issues
|
|
||||||
// due to cross-pixel coordinates
|
|
||||||
aVerts.Append (floor(aTile.px.TopRight (aVec)));
|
|
||||||
aVerts.Append (floor(aTile.px.TopLeft (aVec)));
|
|
||||||
aVerts.Append (floor(aTile.px.BottomLeft (aVec)));
|
|
||||||
aTCrds.Append (aRectUV.TopRight (aVec));
|
|
||||||
aTCrds.Append (aRectUV.TopLeft (aVec));
|
|
||||||
aTCrds.Append (aRectUV.BottomLeft (aVec));
|
|
||||||
|
|
||||||
aVerts.Append (floor(aTile.px.BottomRight (aVec)));
|
|
||||||
aVerts.Append (floor(aTile.px.TopRight (aVec)));
|
|
||||||
aVerts.Append (floor(aTile.px.BottomLeft (aVec)));
|
|
||||||
aTCrds.Append (aRectUV.BottomRight (aVec));
|
|
||||||
aTCrds.Append (aRectUV.TopRight (aVec));
|
|
||||||
aTCrds.Append (aRectUV.BottomLeft (aVec));
|
|
||||||
|
|
||||||
++aRectsNb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// =======================================================================
|
|
||||||
// function : CreateTextures
|
|
||||||
// purpose :
|
|
||||||
// =======================================================================
|
|
||||||
void OpenGl_TextBuilder::Perform (const Font_TextFormatter& theFormatter,
|
|
||||||
const Handle(OpenGl_Context)& theCtx,
|
|
||||||
OpenGl_Font& theFont,
|
|
||||||
NCollection_Vector<GLuint>& theTextures,
|
|
||||||
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theVertsPerTexture,
|
|
||||||
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theTCrdsPerTexture)
|
|
||||||
{
|
|
||||||
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > > aVertsPerTexture;
|
|
||||||
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > > aTCrdsPerTexture;
|
|
||||||
|
|
||||||
createGlyphs (theFormatter, theCtx, theFont, theTextures, aVertsPerTexture, aTCrdsPerTexture);
|
|
||||||
|
|
||||||
if (theVertsPerTexture.Length() != theTextures.Length())
|
|
||||||
{
|
|
||||||
for (Standard_Integer aTextureIter = 0; aTextureIter < theVertsPerTexture.Length(); ++aTextureIter)
|
|
||||||
{
|
|
||||||
theVertsPerTexture.Value (aTextureIter)->Release (theCtx.operator->());
|
|
||||||
theTCrdsPerTexture.Value (aTextureIter)->Release (theCtx.operator->());
|
|
||||||
}
|
|
||||||
theVertsPerTexture.Clear();
|
|
||||||
theTCrdsPerTexture.Clear();
|
|
||||||
|
|
||||||
const bool isNormalMode = theCtx->ToUseVbo();
|
|
||||||
Handle(OpenGl_VertexBuffer) aVertsVbo, aTcrdsVbo;
|
|
||||||
while (theVertsPerTexture.Length() < theTextures.Length())
|
|
||||||
{
|
|
||||||
if (isNormalMode)
|
|
||||||
{
|
|
||||||
aVertsVbo = new OpenGl_VertexBuffer();
|
|
||||||
aTcrdsVbo = new OpenGl_VertexBuffer();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aVertsVbo = new OpenGl_VertexBufferCompat();
|
|
||||||
aTcrdsVbo = new OpenGl_VertexBufferCompat();
|
|
||||||
}
|
|
||||||
theVertsPerTexture.Append (aVertsVbo);
|
|
||||||
theTCrdsPerTexture.Append (aTcrdsVbo);
|
|
||||||
aVertsVbo->Create (theCtx);
|
|
||||||
aTcrdsVbo->Create (theCtx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Standard_Integer aTextureIter = 0; aTextureIter < theTextures.Length(); ++aTextureIter)
|
|
||||||
{
|
|
||||||
const NCollection_Vector<OpenGl_Vec2>& aVerts = *aVertsPerTexture.Value (aTextureIter);
|
|
||||||
Handle(OpenGl_VertexBuffer)& aVertsVbo = theVertsPerTexture.ChangeValue (aTextureIter);
|
|
||||||
if (!aVertsVbo->Init (theCtx, 2, aVerts.Length(), (GLfloat* )NULL)
|
|
||||||
|| !myVboEditor.Init (theCtx, aVertsVbo))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (Standard_Integer aVertIter = 0; aVertIter < aVerts.Length(); ++aVertIter, myVboEditor.Next())
|
|
||||||
{
|
|
||||||
myVboEditor.Value() = aVerts.Value (aVertIter);
|
|
||||||
}
|
|
||||||
myVboEditor.Flush();
|
|
||||||
|
|
||||||
const NCollection_Vector<OpenGl_Vec2>& aTCrds = *aTCrdsPerTexture.Value (aTextureIter);
|
|
||||||
Handle(OpenGl_VertexBuffer)& aTCrdsVbo = theTCrdsPerTexture.ChangeValue (aTextureIter);
|
|
||||||
if (!aTCrdsVbo->Init (theCtx, 2, aVerts.Length(), (GLfloat* )NULL)
|
|
||||||
|| !myVboEditor.Init (theCtx, aTCrdsVbo))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (Standard_Integer aVertIter = 0; aVertIter < aVerts.Length(); ++aVertIter, myVboEditor.Next())
|
|
||||||
{
|
|
||||||
myVboEditor.Value() = aTCrds.Value (aVertIter);
|
|
||||||
}
|
|
||||||
myVboEditor.Flush();
|
|
||||||
}
|
|
||||||
myVboEditor.Init (NULL, NULL);
|
|
||||||
}
|
|
@@ -1,62 +0,0 @@
|
|||||||
// Created on: 2015-06-18
|
|
||||||
// Created by: Ilya SEVRIKOV
|
|
||||||
// Copyright (c) 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 OpenGl_TextBuilder_Header
|
|
||||||
#define OpenGl_TextBuilder_Header
|
|
||||||
|
|
||||||
#include <Font_TextFormatter.hxx>
|
|
||||||
|
|
||||||
#include <OpenGl_Context.hxx>
|
|
||||||
#include <OpenGl_Font.hxx>
|
|
||||||
#include <OpenGl_VertexBuffer.hxx>
|
|
||||||
#include <OpenGl_VertexBufferEditor.hxx>
|
|
||||||
#include <OpenGl_Vec.hxx>
|
|
||||||
|
|
||||||
#include <NCollection_Vector.hxx>
|
|
||||||
#include <NCollection_Handle.hxx>
|
|
||||||
|
|
||||||
|
|
||||||
//! This class generates primitive array required for rendering textured text using OpenGl_Font instance.
|
|
||||||
class OpenGl_TextBuilder
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
//! Creates empty object.
|
|
||||||
OpenGl_TextBuilder();
|
|
||||||
|
|
||||||
//! Creates texture quads for the given text.
|
|
||||||
Standard_EXPORT void Perform (const Font_TextFormatter& theFormatter,
|
|
||||||
const Handle(OpenGl_Context)& theContext,
|
|
||||||
OpenGl_Font& theFont,
|
|
||||||
NCollection_Vector<GLuint>& theTextures,
|
|
||||||
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theVertsPerTexture,
|
|
||||||
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theTCrdsPerTexture);
|
|
||||||
|
|
||||||
protected: //! @name class auxillary methods
|
|
||||||
|
|
||||||
Standard_EXPORT void createGlyphs (const Font_TextFormatter& theFormatter,
|
|
||||||
const Handle(OpenGl_Context)& theCtx,
|
|
||||||
OpenGl_Font& theFont,
|
|
||||||
NCollection_Vector<GLuint>& theTextures,
|
|
||||||
NCollection_Vector< NCollection_Handle < NCollection_Vector <OpenGl_Vec2> > >& theVertsPerTexture,
|
|
||||||
NCollection_Vector< NCollection_Handle < NCollection_Vector <OpenGl_Vec2> > >& theTCrdsPerTexture);
|
|
||||||
|
|
||||||
protected: //! @name class auxillary fields
|
|
||||||
|
|
||||||
NCollection_Vector<OpenGl_Font::Tile> myTileRects;
|
|
||||||
OpenGl_VertexBufferEditor<OpenGl_Vec2> myVboEditor;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // OpenGl_TextBuilder_Header
|
|
461
src/OpenGl/OpenGl_TextFormatter.cxx
Executable file
461
src/OpenGl/OpenGl_TextFormatter.cxx
Executable file
@@ -0,0 +1,461 @@
|
|||||||
|
// Created on: 2013-01-29
|
||||||
|
// Created by: Kirill GAVRILOV
|
||||||
|
// Copyright (c) 2013-2014 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.
|
||||||
|
|
||||||
|
#include <OpenGl_TextFormatter.hxx>
|
||||||
|
|
||||||
|
#include <OpenGl_VertexBufferCompat.hxx>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
//! Auxiliary function to translate rectangle by the vector.
|
||||||
|
inline void move (Font_FTFont::Rect& theRect,
|
||||||
|
const OpenGl_Vec2& theVec)
|
||||||
|
{
|
||||||
|
theRect.Left += theVec.x();
|
||||||
|
theRect.Right += theVec.x();
|
||||||
|
theRect.Top += theVec.y();
|
||||||
|
theRect.Bottom += theVec.y();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Auxiliary function to translate rectangles by the vector.
|
||||||
|
inline void move (NCollection_Vector<OpenGl_Font::Tile>& theRects,
|
||||||
|
const OpenGl_Vec2& theMoveVec,
|
||||||
|
Standard_Integer theCharLower,
|
||||||
|
const Standard_Integer theCharUpper)
|
||||||
|
{
|
||||||
|
for(; theCharLower <= theCharUpper; ++theCharLower)
|
||||||
|
{
|
||||||
|
Font_FTFont::Rect& aRect = theRects.ChangeValue (theCharLower).px;
|
||||||
|
move (aRect, theMoveVec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Auxiliary function to translate rectangles in horizontal direction.
|
||||||
|
/*inline void moveX (NCollection_Vector<OpenGl_Font::Tile>& theRects,
|
||||||
|
const Standard_ShortReal theMoveVec,
|
||||||
|
Standard_Integer theCharLower,
|
||||||
|
const Standard_Integer theCharUpper)
|
||||||
|
{
|
||||||
|
for (; theCharLower <= theCharUpper; ++theCharLower)
|
||||||
|
{
|
||||||
|
Font_FTFont::Rect& aRect = theRects.ChangeValue (theCharLower).px;
|
||||||
|
aRect.Left += theMoveVec;
|
||||||
|
aRect.Right += theMoveVec;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
//! Auxiliary function to translate rectangles in vertical direction.
|
||||||
|
inline void moveY (NCollection_Vector<OpenGl_Font::Tile>& theRects,
|
||||||
|
const Standard_ShortReal theMoveVec,
|
||||||
|
Standard_Integer theCharLower,
|
||||||
|
const Standard_Integer theCharUpper)
|
||||||
|
{
|
||||||
|
for(; theCharLower <= theCharUpper; ++theCharLower)
|
||||||
|
{
|
||||||
|
Font_FTFont::Rect& aRect = theRects.ChangeValue (theCharLower).px;
|
||||||
|
aRect.Top += theMoveVec;
|
||||||
|
aRect.Bottom += theMoveVec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Apply floor to vector components.
|
||||||
|
//! @param theVec - vector to change (by reference!)
|
||||||
|
//! @return modified vector
|
||||||
|
inline OpenGl_Vec2& floor (OpenGl_Vec2& theVec)
|
||||||
|
{
|
||||||
|
theVec.x() = std::floor (theVec.x());
|
||||||
|
theVec.y() = std::floor (theVec.y());
|
||||||
|
return theVec;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_STANDARD_HANDLE (OpenGl_TextFormatter, Standard_Transient)
|
||||||
|
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_TextFormatter, Standard_Transient)
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : OpenGl_TextFormatter
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
OpenGl_TextFormatter::OpenGl_TextFormatter()
|
||||||
|
: myAlignX (Graphic3d_HTA_LEFT),
|
||||||
|
myAlignY (Graphic3d_VTA_TOP),
|
||||||
|
myTabSize (8),
|
||||||
|
//
|
||||||
|
myPen (0.0f, 0.0f),
|
||||||
|
myRectsNb (0),
|
||||||
|
myLineSpacing (0.0f),
|
||||||
|
myAscender (0.0f),
|
||||||
|
myIsFormatted (false),
|
||||||
|
//
|
||||||
|
myLinesNb (0),
|
||||||
|
myRectLineStart (0),
|
||||||
|
myRectWordStart (0),
|
||||||
|
myNewLineNb(0),
|
||||||
|
myPenCurrLine (0.0f),
|
||||||
|
myLineLeft (0.0f),
|
||||||
|
myLineTail (0.0f),
|
||||||
|
myBndTop (0.0f),
|
||||||
|
myBndWidth (0.0f),
|
||||||
|
myMoveVec (0.0f, 0.0f)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : SetupAlignment
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
void OpenGl_TextFormatter::SetupAlignment (const Graphic3d_HorizontalTextAlignment theAlignX,
|
||||||
|
const Graphic3d_VerticalTextAlignment theAlignY)
|
||||||
|
{
|
||||||
|
myAlignX = theAlignX;
|
||||||
|
myAlignY = theAlignY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : Reset
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
void OpenGl_TextFormatter::Reset()
|
||||||
|
{
|
||||||
|
myIsFormatted = false;
|
||||||
|
myString.Clear();
|
||||||
|
myPen.x() = myPen.y() = 0.0f;
|
||||||
|
myRectsNb = 0;
|
||||||
|
myLineSpacing = myAscender = 0.0f;
|
||||||
|
myRects.Clear();
|
||||||
|
myNewLines.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : Result
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
void OpenGl_TextFormatter::Result (NCollection_Vector<GLuint>& theTextures,
|
||||||
|
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > >& theVertsPerTexture,
|
||||||
|
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > >& theTCrdsPerTexture) const
|
||||||
|
{
|
||||||
|
OpenGl_Vec2 aVec (0.0f, 0.0f);
|
||||||
|
theTextures.Clear();
|
||||||
|
theVertsPerTexture.Clear();
|
||||||
|
theTCrdsPerTexture.Clear();
|
||||||
|
for (Standard_Integer aRectIter = 0; aRectIter < myRectsNb; ++aRectIter)
|
||||||
|
{
|
||||||
|
const Font_FTFont::Rect& aRect = myRects.Value (aRectIter).px;
|
||||||
|
const Font_FTFont::Rect& aRectUV = myRects.Value (aRectIter).uv;
|
||||||
|
const GLuint aTexture = myRects.Value (aRectIter).texture;
|
||||||
|
|
||||||
|
Standard_Integer aListId = 0;
|
||||||
|
for (aListId = 0; aListId < theTextures.Length(); ++aListId)
|
||||||
|
{
|
||||||
|
if (theTextures.Value (aListId) == aTexture)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (aListId >= theTextures.Length())
|
||||||
|
{
|
||||||
|
theTextures.Append (aTexture);
|
||||||
|
theVertsPerTexture.Append (new NCollection_Vector<OpenGl_Vec2>());
|
||||||
|
theTCrdsPerTexture.Append (new NCollection_Vector<OpenGl_Vec2>());
|
||||||
|
}
|
||||||
|
|
||||||
|
NCollection_Vector<OpenGl_Vec2>& aVerts = *theVertsPerTexture.ChangeValue (aListId);
|
||||||
|
NCollection_Vector<OpenGl_Vec2>& aTCrds = *theTCrdsPerTexture.ChangeValue (aListId);
|
||||||
|
|
||||||
|
// apply floor on position to avoid blurring issues
|
||||||
|
// due to cross-pixel coordinates
|
||||||
|
aVerts.Append (floor(aRect.TopRight (aVec)));
|
||||||
|
aVerts.Append (floor(aRect.TopLeft (aVec)));
|
||||||
|
aVerts.Append (floor(aRect.BottomLeft (aVec)));
|
||||||
|
aTCrds.Append (aRectUV.TopRight (aVec));
|
||||||
|
aTCrds.Append (aRectUV.TopLeft (aVec));
|
||||||
|
aTCrds.Append (aRectUV.BottomLeft (aVec));
|
||||||
|
|
||||||
|
aVerts.Append (floor(aRect.BottomRight (aVec)));
|
||||||
|
aVerts.Append (floor(aRect.TopRight (aVec)));
|
||||||
|
aVerts.Append (floor(aRect.BottomLeft (aVec)));
|
||||||
|
aTCrds.Append (aRectUV.BottomRight (aVec));
|
||||||
|
aTCrds.Append (aRectUV.TopRight (aVec));
|
||||||
|
aTCrds.Append (aRectUV.BottomLeft (aVec));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : Result
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
void OpenGl_TextFormatter::Result (const Handle(OpenGl_Context)& theCtx,
|
||||||
|
NCollection_Vector<GLuint>& theTextures,
|
||||||
|
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theVertsPerTexture,
|
||||||
|
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theTCrdsPerTexture) const
|
||||||
|
{
|
||||||
|
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > > aVertsPerTexture;
|
||||||
|
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > > aTCrdsPerTexture;
|
||||||
|
Result (theTextures, aVertsPerTexture, aTCrdsPerTexture);
|
||||||
|
|
||||||
|
if (theVertsPerTexture.Length() != theTextures.Length())
|
||||||
|
{
|
||||||
|
for (Standard_Integer aTextureIter = 0; aTextureIter < theVertsPerTexture.Length(); ++aTextureIter)
|
||||||
|
{
|
||||||
|
theVertsPerTexture.Value (aTextureIter)->Release (theCtx.operator->());
|
||||||
|
theTCrdsPerTexture.Value (aTextureIter)->Release (theCtx.operator->());
|
||||||
|
}
|
||||||
|
theVertsPerTexture.Clear();
|
||||||
|
theTCrdsPerTexture.Clear();
|
||||||
|
|
||||||
|
const bool isNormalMode = theCtx->ToUseVbo();
|
||||||
|
Handle(OpenGl_VertexBuffer) aVertsVbo, aTcrdsVbo;
|
||||||
|
while (theVertsPerTexture.Length() < theTextures.Length())
|
||||||
|
{
|
||||||
|
if (isNormalMode)
|
||||||
|
{
|
||||||
|
aVertsVbo = new OpenGl_VertexBuffer();
|
||||||
|
aTcrdsVbo = new OpenGl_VertexBuffer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aVertsVbo = new OpenGl_VertexBufferCompat();
|
||||||
|
aTcrdsVbo = new OpenGl_VertexBufferCompat();
|
||||||
|
}
|
||||||
|
theVertsPerTexture.Append (aVertsVbo);
|
||||||
|
theTCrdsPerTexture.Append (aTcrdsVbo);
|
||||||
|
aVertsVbo->Create (theCtx);
|
||||||
|
aTcrdsVbo->Create (theCtx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Standard_Integer aTextureIter = 0; aTextureIter < theTextures.Length(); ++aTextureIter)
|
||||||
|
{
|
||||||
|
const NCollection_Vector<OpenGl_Vec2>& aVerts = *aVertsPerTexture.Value (aTextureIter);
|
||||||
|
Handle(OpenGl_VertexBuffer)& aVertsVbo = theVertsPerTexture.ChangeValue (aTextureIter);
|
||||||
|
if (!aVertsVbo->Init (theCtx, 2, aVerts.Length(), (GLfloat* )NULL)
|
||||||
|
|| !myVboEditor.Init (theCtx, aVertsVbo))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (Standard_Integer aVertIter = 0; aVertIter < aVerts.Length(); ++aVertIter, myVboEditor.Next())
|
||||||
|
{
|
||||||
|
myVboEditor.Value() = aVerts.Value (aVertIter);
|
||||||
|
}
|
||||||
|
myVboEditor.Flush();
|
||||||
|
|
||||||
|
const NCollection_Vector<OpenGl_Vec2>& aTCrds = *aTCrdsPerTexture.Value (aTextureIter);
|
||||||
|
Handle(OpenGl_VertexBuffer)& aTCrdsVbo = theTCrdsPerTexture.ChangeValue (aTextureIter);
|
||||||
|
if (!aTCrdsVbo->Init (theCtx, 2, aVerts.Length(), (GLfloat* )NULL)
|
||||||
|
|| !myVboEditor.Init (theCtx, aTCrdsVbo))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (Standard_Integer aVertIter = 0; aVertIter < aVerts.Length(); ++aVertIter, myVboEditor.Next())
|
||||||
|
{
|
||||||
|
myVboEditor.Value() = aTCrds.Value (aVertIter);
|
||||||
|
}
|
||||||
|
myVboEditor.Flush();
|
||||||
|
}
|
||||||
|
myVboEditor.Init (NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : Append
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
void OpenGl_TextFormatter::Append (const Handle(OpenGl_Context)& theCtx,
|
||||||
|
const NCollection_String& theString,
|
||||||
|
OpenGl_Font& theFont)
|
||||||
|
{
|
||||||
|
if (theString.IsEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
myAscender = Max (myAscender, theFont.Ascender());
|
||||||
|
myLineSpacing = Max (myLineSpacing, theFont.LineSpacing());
|
||||||
|
myString += theString;
|
||||||
|
|
||||||
|
int aSymbolsCounter = 0; // special counter to process tabulation symbols
|
||||||
|
|
||||||
|
// first pass - render all symbols using associated font on single ZERO baseline
|
||||||
|
OpenGl_Font::Tile aTile;
|
||||||
|
memset (&aTile, 0, sizeof(aTile));
|
||||||
|
for (NCollection_Utf8Iter anIter = theString.Iterator(); *anIter != 0;)
|
||||||
|
{
|
||||||
|
const Standard_Utf32Char aCharThis = *anIter;
|
||||||
|
const Standard_Utf32Char aCharNext = *++anIter;
|
||||||
|
|
||||||
|
if (aCharThis == '\x0D' // CR (carriage return)
|
||||||
|
|| aCharThis == '\a' // BEL (alarm)
|
||||||
|
|| aCharThis == '\f' // FF (form feed) NP (new page)
|
||||||
|
|| aCharThis == '\b' // BS (backspace)
|
||||||
|
|| aCharThis == '\v') // VT (vertical tab)
|
||||||
|
{
|
||||||
|
continue; // skip unsupported carriage control codes
|
||||||
|
}
|
||||||
|
else if (aCharThis == '\x0A') // LF (line feed, new line)
|
||||||
|
{
|
||||||
|
aSymbolsCounter = 0;
|
||||||
|
myNewLines.Append (myPen.x());
|
||||||
|
continue; // will be processed on second pass
|
||||||
|
}
|
||||||
|
else if (aCharThis == ' ')
|
||||||
|
{
|
||||||
|
++aSymbolsCounter;
|
||||||
|
myPen.x() += theFont.AdvanceX (' ', aCharNext);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (aCharThis == '\t')
|
||||||
|
{
|
||||||
|
const Standard_Integer aSpacesNum = (myTabSize - (aSymbolsCounter - 1) % myTabSize);
|
||||||
|
myPen.x() += theFont.AdvanceX (' ', aCharNext) * Standard_ShortReal(aSpacesNum);
|
||||||
|
aSymbolsCounter += aSpacesNum;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
++aSymbolsCounter;
|
||||||
|
theFont.RenderGlyph (theCtx,
|
||||||
|
aCharThis, aCharNext,
|
||||||
|
aTile, myPen);
|
||||||
|
myRects.Append (aTile);
|
||||||
|
|
||||||
|
++myRectsNb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : newLine
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
void OpenGl_TextFormatter::newLine (const Standard_Integer theLastRect)
|
||||||
|
{
|
||||||
|
if (myRectLineStart >= myRectsNb)
|
||||||
|
{
|
||||||
|
++myLinesNb;
|
||||||
|
myPenCurrLine -= myLineSpacing;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
myMoveVec.y() = myPenCurrLine;
|
||||||
|
switch (myAlignX)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case Graphic3d_HTA_LEFT:
|
||||||
|
{
|
||||||
|
myMoveVec.x() = (myNewLineNb > 0) ? -myNewLines.Value (myNewLineNb - 1) : 0.0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Graphic3d_HTA_RIGHT:
|
||||||
|
{
|
||||||
|
myMoveVec.x() = (myNewLineNb < myNewLines.Length())
|
||||||
|
? -myNewLines.Value (myNewLineNb)
|
||||||
|
: -myPen.x();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Graphic3d_HTA_CENTER:
|
||||||
|
{
|
||||||
|
const Standard_ShortReal aFrom = (myNewLineNb > 0)
|
||||||
|
? myNewLines.Value (myNewLineNb - 1)
|
||||||
|
: 0.0f;
|
||||||
|
const Standard_ShortReal aTo = (myNewLineNb < myNewLines.Length())
|
||||||
|
? myNewLines.Value (myNewLineNb)
|
||||||
|
: myPen.x();
|
||||||
|
myMoveVec.x() = -0.5f * (aFrom + aTo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
move (myRects, myMoveVec, myRectLineStart, theLastRect);
|
||||||
|
|
||||||
|
++myLinesNb;
|
||||||
|
myPenCurrLine -= myLineSpacing;
|
||||||
|
myRectLineStart = myRectWordStart = theLastRect + 1;
|
||||||
|
if (myRectLineStart < myRectsNb)
|
||||||
|
{
|
||||||
|
myLineLeft = myRects.Value (myRectLineStart).px.Left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : Format
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
void OpenGl_TextFormatter::Format()
|
||||||
|
{
|
||||||
|
if (myRectsNb == 0 || myIsFormatted)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
myIsFormatted = true;
|
||||||
|
myLinesNb = myRectLineStart = myRectWordStart = 0;
|
||||||
|
myLineLeft = 0.0f;
|
||||||
|
myLineTail = 0.0f;
|
||||||
|
myBndTop = 0.0f;
|
||||||
|
myBndWidth = 0.0f;
|
||||||
|
myMoveVec.x() = myMoveVec.y() = 0.0f;
|
||||||
|
|
||||||
|
// split text into lines and apply horizontal alignment
|
||||||
|
myPenCurrLine = -myAscender;
|
||||||
|
Standard_Integer aRectIter = 0;
|
||||||
|
myNewLineNb = 0;
|
||||||
|
for (NCollection_Utf8Iter anIter = myString.Iterator(); *anIter != 0; ++anIter)
|
||||||
|
{
|
||||||
|
const Standard_Utf32Char aCharThis = *anIter;
|
||||||
|
if (aCharThis == '\x0D' // CR (carriage return)
|
||||||
|
|| aCharThis == '\a' // BEL (alarm)
|
||||||
|
|| aCharThis == '\f' // FF (form feed) NP (new page)
|
||||||
|
|| aCharThis == '\b' // BS (backspace)
|
||||||
|
|| aCharThis == '\v') // VT (vertical tab)
|
||||||
|
{
|
||||||
|
continue; // skip unsupported carriage control codes
|
||||||
|
}
|
||||||
|
else if (aCharThis == '\x0A') // LF (line feed, new line)
|
||||||
|
{
|
||||||
|
const Standard_Integer aLastRect = aRectIter - 1; // last rect on current line
|
||||||
|
newLine (aLastRect);
|
||||||
|
++myNewLineNb;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (aCharThis == ' '
|
||||||
|
|| aCharThis == '\t')
|
||||||
|
{
|
||||||
|
myRectWordStart = aRectIter;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_ShortReal aWidth = myRects.Value (aRectIter).px.Right - myLineLeft;
|
||||||
|
myBndWidth = Max (myBndWidth, aWidth);
|
||||||
|
|
||||||
|
++aRectIter;
|
||||||
|
}
|
||||||
|
|
||||||
|
// move last line
|
||||||
|
newLine (myRectsNb - 1);
|
||||||
|
|
||||||
|
// apply vertical alignment style
|
||||||
|
if (myAlignY == Graphic3d_VTA_BOTTOM)
|
||||||
|
{
|
||||||
|
myBndTop = -myLineSpacing - myPenCurrLine;
|
||||||
|
moveY (myRects, myBndTop, 0, myRectsNb - 1);
|
||||||
|
}
|
||||||
|
else if (myAlignY == Graphic3d_VTA_CENTER)
|
||||||
|
{
|
||||||
|
myBndTop = 0.5f * (myLineSpacing * Standard_ShortReal(myLinesNb));
|
||||||
|
moveY (myRects, myBndTop, 0, myRectsNb - 1);
|
||||||
|
}
|
||||||
|
}
|
71
src/Font/Font_TextFormatter.hxx → src/OpenGl/OpenGl_TextFormatter.hxx
Normal file → Executable file
71
src/Font/Font_TextFormatter.hxx → src/OpenGl/OpenGl_TextFormatter.hxx
Normal file → Executable file
@@ -13,20 +13,25 @@
|
|||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
#ifndef Font_TextFormatter_Header
|
#ifndef _OpenGl_TextFormatter_H__
|
||||||
#define Font_TextFormatter_Header
|
#define _OpenGl_TextFormatter_H__
|
||||||
|
|
||||||
#include <Font_FTFont.hxx>
|
#include <OpenGl_Font.hxx>
|
||||||
#include <NCollection_DataMap.hxx>
|
#include <OpenGl_VertexBufferEditor.hxx>
|
||||||
#include <NCollection_Vector.hxx>
|
|
||||||
|
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||||
|
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||||
|
|
||||||
|
#include <NCollection_String.hxx>
|
||||||
|
|
||||||
//! This class intended to prepare formatted text.
|
//! This class intended to prepare formatted text.
|
||||||
class Font_TextFormatter : public Standard_Transient
|
class OpenGl_TextFormatter : public Standard_Transient
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Default constructor.
|
//! Default constructor.
|
||||||
Standard_EXPORT Font_TextFormatter();
|
Standard_EXPORT OpenGl_TextFormatter();
|
||||||
|
|
||||||
//! Setup alignment style.
|
//! Setup alignment style.
|
||||||
Standard_EXPORT void SetupAlignment (const Graphic3d_HorizontalTextAlignment theAlignX,
|
Standard_EXPORT void SetupAlignment (const Graphic3d_HorizontalTextAlignment theAlignX,
|
||||||
@@ -36,30 +41,24 @@ public:
|
|||||||
Standard_EXPORT void Reset();
|
Standard_EXPORT void Reset();
|
||||||
|
|
||||||
//! Render specified text to inner buffer.
|
//! Render specified text to inner buffer.
|
||||||
Standard_EXPORT void Append (const NCollection_String& theString,
|
Standard_EXPORT void Append (const Handle(OpenGl_Context)& theCtx,
|
||||||
Font_FTFont& theFont);
|
const NCollection_String& theString,
|
||||||
|
OpenGl_Font& theFont);
|
||||||
|
|
||||||
//! Perform formatting on the buffered text.
|
//! Perform formatting on the buffered text.
|
||||||
//! Should not be called more than once after initialization!
|
//! Should not be called more than once after initialization!
|
||||||
Standard_EXPORT void Format();
|
Standard_EXPORT void Format();
|
||||||
|
|
||||||
//! Returns specific glyph rectangle.
|
//! Retrieve formatting results.
|
||||||
inline const NCollection_Vec2<Standard_ShortReal>& TopLeft (const Standard_Integer theIndex) const
|
Standard_EXPORT void Result (NCollection_Vector<GLuint>& theTextures,
|
||||||
{
|
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > >& theVertsPerTexture,
|
||||||
return myCorners.Value (theIndex);
|
NCollection_Vector< NCollection_Handle <NCollection_Vector <OpenGl_Vec2> > >& theTCrdsPerTexture) const;
|
||||||
}
|
|
||||||
|
|
||||||
//! Returns current rendering string.
|
//! Retrieve formatting results.
|
||||||
inline const NCollection_String& String() const
|
Standard_EXPORT void Result (const Handle(OpenGl_Context)& theCtx,
|
||||||
{
|
NCollection_Vector<GLuint>& theTextures,
|
||||||
return myString;
|
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theVertsPerTexture,
|
||||||
}
|
NCollection_Vector<Handle(OpenGl_VertexBuffer)>& theTCrdsPerTexture) const;
|
||||||
|
|
||||||
//! Returns tab size.
|
|
||||||
inline Standard_Integer TabSize() const
|
|
||||||
{
|
|
||||||
return myTabSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! @return width of formatted text.
|
//! @return width of formatted text.
|
||||||
inline Standard_ShortReal ResultWidth() const
|
inline Standard_ShortReal ResultWidth() const
|
||||||
@@ -107,10 +106,9 @@ protected: //! @name configuration
|
|||||||
protected: //! @name input data
|
protected: //! @name input data
|
||||||
|
|
||||||
NCollection_String myString; //!< currently rendered text
|
NCollection_String myString; //!< currently rendered text
|
||||||
NCollection_Vec2<Standard_ShortReal>
|
OpenGl_Vec2 myPen; //!< current pen position
|
||||||
myPen; //!< current pen position
|
NCollection_Vector<OpenGl_Font::Tile>
|
||||||
NCollection_Vector < NCollection_Vec2<Standard_ShortReal> >
|
myRects; //!< glyphs rectangles
|
||||||
myCorners; //!< The top left corners of a formatted rectangles.
|
|
||||||
Standard_Integer myRectsNb; //!< rectangles number
|
Standard_Integer myRectsNb; //!< rectangles number
|
||||||
NCollection_Vector<Standard_ShortReal>
|
NCollection_Vector<Standard_ShortReal>
|
||||||
myNewLines; //!< position at LF
|
myNewLines; //!< position at LF
|
||||||
@@ -118,6 +116,10 @@ protected: //! @name input data
|
|||||||
Standard_ShortReal myAscender; //!<
|
Standard_ShortReal myAscender; //!<
|
||||||
bool myIsFormatted; //!< formatting state
|
bool myIsFormatted; //!< formatting state
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
mutable OpenGl_VertexBufferEditor<OpenGl_Vec2> myVboEditor;
|
||||||
|
|
||||||
protected: //! @name temporary variables for formatting routines
|
protected: //! @name temporary variables for formatting routines
|
||||||
|
|
||||||
Standard_Integer myLinesNb; //!< overall (new)lines number (including splitting by width limit)
|
Standard_Integer myLinesNb; //!< overall (new)lines number (including splitting by width limit)
|
||||||
@@ -126,17 +128,18 @@ protected: //! @name temporary variables for formatting routines
|
|||||||
Standard_Integer myNewLineNb;
|
Standard_Integer myNewLineNb;
|
||||||
|
|
||||||
Standard_ShortReal myPenCurrLine; //!< current baseline position
|
Standard_ShortReal myPenCurrLine; //!< current baseline position
|
||||||
|
Standard_ShortReal myLineLeft; //!< left x position of first glyph on line before formatting applied
|
||||||
|
Standard_ShortReal myLineTail;
|
||||||
Standard_ShortReal myBndTop;
|
Standard_ShortReal myBndTop;
|
||||||
Standard_ShortReal myBndWidth;
|
Standard_ShortReal myBndWidth;
|
||||||
NCollection_Vec2<Standard_ShortReal>
|
OpenGl_Vec2 myMoveVec; //!< local variable
|
||||||
myMoveVec; //!< local variable
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTI(Font_TextFormatter) // Type definition
|
DEFINE_STANDARD_RTTI(OpenGl_TextFormatter) // Type definition
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_STANDARD_HANDLE(Font_TextFormatter, Standard_Transient)
|
DEFINE_STANDARD_HANDLE(OpenGl_TextFormatter, Standard_Transient)
|
||||||
|
|
||||||
#endif // Font_TextFormatter_Header
|
#endif // _OpenGl_TextFormatter_H__
|
@@ -78,13 +78,11 @@ is
|
|||||||
-- DTHP_Fit - value label located automatically at left side if does not fits
|
-- DTHP_Fit - value label located automatically at left side if does not fits
|
||||||
-- the dimension space, otherwise the value label is placed at center.
|
-- the dimension space, otherwise the value label is placed at center.
|
||||||
|
|
||||||
enumeration DimensionTextVerticalPosition is DTVP_Above, DTVP_FirstLine, DTVP_Below, DTVP_LastLine, DTVP_Center;
|
enumeration DimensionTextVerticalPosition is DTVP_Above, DTVP_Below, DTVP_Center;
|
||||||
---Purpose: Specifies options for positioning dimension value label in vertical direction
|
---Purpose: Specifies options for positioning dimension value label in vertical direction
|
||||||
-- with respect to dimension (extension) line.
|
-- with respect to dimension (extension) line.
|
||||||
-- DTVP_Above - text label is located above the dimension or extension line.
|
-- DTVP_Above - text label is located above the dimension or extension line.
|
||||||
-- DTVP_FirstLine - for multi-line text: first line alignment (is by default for multi-line label)
|
|
||||||
-- DTVP_Below - text label is located below the dimension or extension line.
|
-- DTVP_Below - text label is located below the dimension or extension line.
|
||||||
-- DTVP_LastLine - for multi-line text: last line alignment (is by default for multi-line label)
|
|
||||||
-- DTVP_Center - the text label middle-point is in line with dimension or extension line.
|
-- DTVP_Center - the text label middle-point is in line with dimension or extension line.
|
||||||
|
|
||||||
enumeration DimensionArrowOrientation is DAO_Internal, DAO_External, DAO_Fit;
|
enumeration DimensionArrowOrientation is DAO_Internal, DAO_External, DAO_Fit;
|
||||||
|
@@ -38,7 +38,6 @@
|
|||||||
#include <Draw_Appli.hxx>
|
#include <Draw_Appli.hxx>
|
||||||
#include <Draw_Window.hxx>
|
#include <Draw_Window.hxx>
|
||||||
#include <DBRep.hxx>
|
#include <DBRep.hxx>
|
||||||
#include <ElCLib.hxx>
|
|
||||||
#include <ElSLib.hxx>
|
#include <ElSLib.hxx>
|
||||||
#include <GC_MakePlane.hxx>
|
#include <GC_MakePlane.hxx>
|
||||||
#include <Geom_CartesianPoint.hxx>
|
#include <Geom_CartesianPoint.hxx>
|
||||||
@@ -169,21 +168,16 @@ static Standard_Boolean Get3DPointAtMousePosition (const gp_Pnt& theFirstPoint,
|
|||||||
// length, angle, radius and diameter dimension.
|
// length, angle, radius and diameter dimension.
|
||||||
//
|
//
|
||||||
//draw args: -text [3d|2d] [wf|sh|wireframe|shading] [Size]
|
//draw args: -text [3d|2d] [wf|sh|wireframe|shading] [Size]
|
||||||
// -label [left|right|hcenter|hfit] [top|bottom|vcenter|firstline|lastline|vfit]
|
// -label [left|right|hcenter|hfit] [top|bottom|vcenter|vfit]
|
||||||
// -arrow [external|internal|fit] [Length(int)]
|
// -arrow [external|internal|fit] [Length(int)]
|
||||||
// -arrowangle ArrowAngle(degrees)
|
// -arrowangle ArrowAngle(degrees)
|
||||||
// -plane xoy|yoz|zox
|
// -plane xoy|yoz|zox
|
||||||
// -flyout FloatValue -extension FloatValue
|
// -flyout FloatValue -extension FloatValue
|
||||||
// -value CustomNumberValue
|
// -value CustomNumberValue
|
||||||
// -valuetext CustomText
|
|
||||||
// -dispunits DisplayUnitsString
|
// -dispunits DisplayUnitsString
|
||||||
// -modelunits ModelUnitsString
|
// -modelunits ModelUnitsString
|
||||||
// -showunits (DEFAULT)
|
// -showunits
|
||||||
// -hideunits
|
// -hideunits
|
||||||
// -drawdimline (DEFAULT)
|
|
||||||
// -hidedimline
|
|
||||||
// -aligntext DirX DirY DirZ
|
|
||||||
// -segment Length
|
|
||||||
//
|
//
|
||||||
// Warning! flyout is not an aspect value, it is for dimension parameter
|
// Warning! flyout is not an aspect value, it is for dimension parameter
|
||||||
// likewise text position, but text position override other paramaters.
|
// likewise text position, but text position override other paramaters.
|
||||||
@@ -196,8 +190,6 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
Standard_Boolean& theIsCustomPlane, gp_Pln& thePlane,
|
Standard_Boolean& theIsCustomPlane, gp_Pln& thePlane,
|
||||||
NCollection_DataMap<TCollection_AsciiString, Standard_Real>& theRealParams,
|
NCollection_DataMap<TCollection_AsciiString, Standard_Real>& theRealParams,
|
||||||
NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theStringParams,
|
NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theStringParams,
|
||||||
NCollection_DataMap<TCollection_AsciiString, Standard_Boolean>& theBooleanParams,
|
|
||||||
Standard_Boolean& theIsTextAligned, gp_Dir& theTextDir,
|
|
||||||
NCollection_List<Handle(AIS_InteractiveObject)>* theShapeList = NULL)
|
NCollection_List<Handle(AIS_InteractiveObject)>* theShapeList = NULL)
|
||||||
{
|
{
|
||||||
theRealParams.Clear();
|
theRealParams.Clear();
|
||||||
@@ -216,7 +208,7 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOOLEAN flags
|
// Boolean flags
|
||||||
if (aParam.IsEqual ("-showunits"))
|
if (aParam.IsEqual ("-showunits"))
|
||||||
{
|
{
|
||||||
theAspect->MakeUnitsDisplayed (Standard_True);
|
theAspect->MakeUnitsDisplayed (Standard_True);
|
||||||
@@ -228,25 +220,14 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aParam.IsEqual ("-drawdimline"))
|
// Before all non-boolean flags parsing check if a flag have at least one value.
|
||||||
{
|
|
||||||
theBooleanParams.Bind ("drawdimline", Standard_True);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (aParam.IsEqual ("-hidedimline"))
|
|
||||||
{
|
|
||||||
theBooleanParams.Bind ("drawdimline", Standard_False);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Before all NON-BOOLEAN flags parsing check if a flag have at least one value.
|
|
||||||
if (anIt + 1 >= theArgNum)
|
if (anIt + 1 >= theArgNum)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: "<< aParam <<" flag should have value.\n";
|
std::cerr << "Error: "<< aParam <<" flag should have value.\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NON-BOOLEAN flags
|
// Non-boolean flags
|
||||||
if (aParam.IsEqual ("-shape")
|
if (aParam.IsEqual ("-shape")
|
||||||
|| aParam.IsEqual ("-shapes"))
|
|| aParam.IsEqual ("-shapes"))
|
||||||
{
|
{
|
||||||
@@ -324,15 +305,13 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
TCollection_AsciiString aParamValue (theArgVec[anIt]);
|
TCollection_AsciiString aParamValue (theArgVec[anIt]);
|
||||||
aParamValue.LowerCase();
|
aParamValue.LowerCase();
|
||||||
|
|
||||||
if (aParamValue == "left") { theAspect->SetTextHorizontalPosition (Prs3d_DTHP_Left); }
|
if (aParamValue == "left") { theAspect->SetTextHorizontalPosition (Prs3d_DTHP_Left); }
|
||||||
else if (aParamValue == "right") { theAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right); }
|
else if (aParamValue == "right") { theAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right); }
|
||||||
else if (aParamValue == "hcenter") { theAspect->SetTextHorizontalPosition (Prs3d_DTHP_Center); }
|
else if (aParamValue == "hcenter") { theAspect->SetTextHorizontalPosition (Prs3d_DTHP_Center);}
|
||||||
else if (aParamValue == "hfit") { theAspect->SetTextHorizontalPosition (Prs3d_DTHP_Fit); }
|
else if (aParamValue == "hfit") { theAspect->SetTextHorizontalPosition (Prs3d_DTHP_Fit); }
|
||||||
else if (aParamValue == "above") { theAspect->SetTextVerticalPosition (Prs3d_DTVP_Above); }
|
else if (aParamValue == "above") { theAspect->SetTextVerticalPosition (Prs3d_DTVP_Above); }
|
||||||
else if (aParamValue == "below") { theAspect->SetTextVerticalPosition (Prs3d_DTVP_Below); }
|
else if (aParamValue == "below") { theAspect->SetTextVerticalPosition (Prs3d_DTVP_Below); }
|
||||||
else if (aParamValue == "vcenter") { theAspect->SetTextVerticalPosition (Prs3d_DTVP_Center); }
|
else if (aParamValue == "vcenter") { theAspect->SetTextVerticalPosition (Prs3d_DTVP_Center);}
|
||||||
else if (aParamValue == "firstline") { theAspect->SetTextVerticalPosition (Prs3d_DTVP_FirstLine); }
|
|
||||||
else if (aParamValue == "lastline") { theAspect->SetTextVerticalPosition (Prs3d_DTVP_LastLine); }
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "Error: invalid label position: '" << aParamValue << "'.\n";
|
std::cerr << "Error: invalid label position: '" << aParamValue << "'.\n";
|
||||||
@@ -355,7 +334,7 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
TCollection_AsciiString aValue (theArgVec[++anIt]);
|
TCollection_AsciiString aValue (theArgVec[++anIt]);
|
||||||
if (!aValue.IsRealValue())
|
if (!aValue.IsRealValue())
|
||||||
{
|
{
|
||||||
std::cerr << "Error: arrow length should be float degree value.\n";
|
std::cerr << "Error: arrow lenght should be float degree value.\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
theAspect->ArrowAspect()->SetLength (Draw::Atof (aValue.ToCString()));
|
theAspect->ArrowAspect()->SetLength (Draw::Atof (aValue.ToCString()));
|
||||||
@@ -409,20 +388,6 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (aParam.IsEqual ("-aligntext"))
|
|
||||||
{
|
|
||||||
theIsTextAligned = Standard_True;
|
|
||||||
TCollection_AsciiString aParam1 (theArgVec[++anIt]);
|
|
||||||
TCollection_AsciiString aParam2 (theArgVec[++anIt]);
|
|
||||||
TCollection_AsciiString aParam3 (theArgVec[++anIt]);
|
|
||||||
if (!aParam1.IsRealValue() || !aParam2.IsRealValue() || !aParam3.IsRealValue())
|
|
||||||
{
|
|
||||||
std::cerr << "Error: direction coordinate should be real value.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
theTextDir.SetCoord (aParam1.RealValue(), aParam2.RealValue(), aParam3.RealValue());
|
|
||||||
}
|
|
||||||
// REAL parameters
|
|
||||||
else if (aParam.IsEqual ("-flyout"))
|
else if (aParam.IsEqual ("-flyout"))
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aParam (theArgVec[++anIt]);
|
TCollection_AsciiString aParam (theArgVec[++anIt]);
|
||||||
@@ -437,43 +402,13 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
else if (aParam.IsEqual ("-value"))
|
else if (aParam.IsEqual ("-value"))
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aParam (theArgVec[++anIt]);
|
TCollection_AsciiString aParam (theArgVec[++anIt]);
|
||||||
|
|
||||||
// Custom real value
|
|
||||||
if (!aParam.IsRealValue())
|
if (!aParam.IsRealValue())
|
||||||
{
|
{
|
||||||
std::cerr << "Error: custom value should be real value.\n";
|
std::cerr << "Error: dimension value for dimension should be real value.\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
theRealParams.Bind ("value", Draw::Atof (aParam.ToCString()));
|
theRealParams.Bind ("value", Draw::Atof (aParam.ToCString()));
|
||||||
|
|
||||||
}
|
|
||||||
else if (aParam.IsEqual ("-circleparam"))
|
|
||||||
{
|
|
||||||
TCollection_AsciiString aParam (theArgVec[++anIt]);
|
|
||||||
if (!aParam.IsRealValue())
|
|
||||||
{
|
|
||||||
std::cerr << "Error: circle parameter should be real value.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
theRealParams.Bind ("circleparam", aParam.RealValue());
|
|
||||||
}
|
|
||||||
else if (aParam.IsEqual ("-segment"))
|
|
||||||
{
|
|
||||||
TCollection_AsciiString aParam (theArgVec[++anIt]);
|
|
||||||
if (!aParam.IsRealValue() || aParam.RealValue() < 0.0)
|
|
||||||
{
|
|
||||||
std::cerr << "Error: segment length should be positive real value.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
theRealParams.Bind ("segment", aParam.RealValue());
|
|
||||||
}
|
|
||||||
// STRING parameters
|
|
||||||
else if (aParam.IsEqual ("-valuetext"))
|
|
||||||
{
|
|
||||||
TCollection_AsciiString aParam (theArgVec[++anIt]);
|
|
||||||
theStringParams.Bind ("valuetext", aParam);
|
|
||||||
}
|
}
|
||||||
else if (aParam.IsEqual ("-modelunits"))
|
else if (aParam.IsEqual ("-modelunits"))
|
||||||
{
|
{
|
||||||
@@ -503,8 +438,7 @@ static int ParseDimensionParams (Standard_Integer theArgNum,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
static void SetDimensionParams (const Handle(AIS_Dimension)& theDim,
|
static void SetDimensionParams (const Handle(AIS_Dimension)& theDim,
|
||||||
const NCollection_DataMap<TCollection_AsciiString, Standard_Real>& theRealParams,
|
const NCollection_DataMap<TCollection_AsciiString, Standard_Real>& theRealParams,
|
||||||
const NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theStringParams,
|
const NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>& theStringParams)
|
||||||
const NCollection_DataMap<TCollection_AsciiString, Standard_Boolean>& theBooleanParams)
|
|
||||||
{
|
{
|
||||||
if (theRealParams.IsBound ("flyout"))
|
if (theRealParams.IsBound ("flyout"))
|
||||||
{
|
{
|
||||||
@@ -515,10 +449,6 @@ static void SetDimensionParams (const Handle(AIS_Dimension)& theDim,
|
|||||||
{
|
{
|
||||||
theDim->SetCustomValue (theRealParams.Find ("value"));
|
theDim->SetCustomValue (theRealParams.Find ("value"));
|
||||||
}
|
}
|
||||||
else if (theStringParams.IsBound ("valuetext"))
|
|
||||||
{
|
|
||||||
theDim->SetTextLabel (theStringParams.Find ("valuetext"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theStringParams.IsBound ("modelunits"))
|
if (theStringParams.IsBound ("modelunits"))
|
||||||
{
|
{
|
||||||
@@ -529,16 +459,6 @@ static void SetDimensionParams (const Handle(AIS_Dimension)& theDim,
|
|||||||
{
|
{
|
||||||
theDim->SetDisplayUnits (theStringParams.Find ("dispunits"));
|
theDim->SetDisplayUnits (theStringParams.Find ("dispunits"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theBooleanParams.IsBound ("drawdimline"))
|
|
||||||
{
|
|
||||||
theDim->SetToDrawDimensionLine (theBooleanParams.Find ("drawdimline"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theRealParams.IsBound ("segment"))
|
|
||||||
{
|
|
||||||
theDim->SetLeaderSegment (theRealParams.Find ("segment"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -563,12 +483,9 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
|
|||||||
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
|
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
|
||||||
Standard_Boolean isPlaneCustom = Standard_False;
|
Standard_Boolean isPlaneCustom = Standard_False;
|
||||||
gp_Pln aWorkingPlane;
|
gp_Pln aWorkingPlane;
|
||||||
Standard_Boolean isTextAligned = Standard_False;
|
|
||||||
gp_Dir aTextDir (1.0, 0.0, 0.0);
|
|
||||||
|
|
||||||
NCollection_DataMap<TCollection_AsciiString, Standard_Real> aRealParams;
|
NCollection_DataMap<TCollection_AsciiString, Standard_Real> aRealParams;
|
||||||
NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> aStringParams;
|
NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> aStringParams;
|
||||||
NCollection_DataMap<TCollection_AsciiString, Standard_Boolean> aBoolParams;
|
|
||||||
|
|
||||||
TCollection_AsciiString aDimType(theArgs[2]);
|
TCollection_AsciiString aDimType(theArgs[2]);
|
||||||
aDimType.LowerCase();
|
aDimType.LowerCase();
|
||||||
@@ -598,7 +515,7 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
|
|||||||
|
|
||||||
if (ParseDimensionParams (theArgsNb, theArgs, 3,
|
if (ParseDimensionParams (theArgsNb, theArgs, 3,
|
||||||
anAspect,isPlaneCustom,aWorkingPlane,
|
anAspect,isPlaneCustom,aWorkingPlane,
|
||||||
aRealParams, aStringParams, aBoolParams, isTextAligned, aTextDir, &aShapes))
|
aRealParams, aStringParams, &aShapes))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -739,15 +656,7 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
|
|||||||
{
|
{
|
||||||
Handle(AIS_Circle) aShape = Handle(AIS_Circle)::DownCast (aShapes.First());
|
Handle(AIS_Circle) aShape = Handle(AIS_Circle)::DownCast (aShapes.First());
|
||||||
gp_Circ aCircle = aShape->Circle()->Circ();
|
gp_Circ aCircle = aShape->Circle()->Circ();
|
||||||
Standard_Real aParam = 0;
|
aDim = new AIS_RadiusDimension (aCircle);
|
||||||
|
|
||||||
// Check if circle parameter is set
|
|
||||||
if (aRealParams.IsBound ("circleparam"))
|
|
||||||
{
|
|
||||||
aParam = aRealParams.Find ("circleparam");
|
|
||||||
}
|
|
||||||
|
|
||||||
aDim = new AIS_RadiusDimension (aCircle, aParam);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -776,16 +685,7 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
|
|||||||
{
|
{
|
||||||
Handle(AIS_Circle) aShape = Handle(AIS_Circle)::DownCast (aShapes.First());
|
Handle(AIS_Circle) aShape = Handle(AIS_Circle)::DownCast (aShapes.First());
|
||||||
gp_Circ aCircle = aShape->Circle()->Circ();
|
gp_Circ aCircle = aShape->Circle()->Circ();
|
||||||
|
aDim = new AIS_DiameterDimension (aCircle);
|
||||||
Standard_Real aParam = 0;
|
|
||||||
|
|
||||||
// Check if circle parameter is set
|
|
||||||
if (aRealParams.IsBound ("circleparam"))
|
|
||||||
{
|
|
||||||
aParam = aRealParams.Find ("circleparam");
|
|
||||||
}
|
|
||||||
|
|
||||||
aDim = new AIS_DiameterDimension (aCircle, aParam);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -813,11 +713,6 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTextAligned)
|
|
||||||
{
|
|
||||||
aDim->SetToAlignText (isTextAligned, aTextDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check dimension geometry
|
// Check dimension geometry
|
||||||
if (!aDim->IsValid())
|
if (!aDim->IsValid())
|
||||||
{
|
{
|
||||||
@@ -828,7 +723,7 @@ static int VDimBuilder (Draw_Interpretor& /*theDi*/,
|
|||||||
|
|
||||||
aDim->SetDimensionAspect (anAspect);
|
aDim->SetDimensionAspect (anAspect);
|
||||||
|
|
||||||
SetDimensionParams (aDim, aRealParams, aStringParams, aBoolParams);
|
SetDimensionParams (aDim, aRealParams, aStringParams);
|
||||||
|
|
||||||
VDisplayAISObject (aName,aDim);
|
VDisplayAISObject (aName,aDim);
|
||||||
|
|
||||||
@@ -2649,13 +2544,10 @@ static int VDimParam (Draw_Interpretor& theDi, Standard_Integer theArgNum, const
|
|||||||
TCollection_AsciiString aName (theArgVec[1]);
|
TCollection_AsciiString aName (theArgVec[1]);
|
||||||
gp_Pln aWorkingPlane;
|
gp_Pln aWorkingPlane;
|
||||||
Standard_Boolean isCustomPlane = Standard_False;
|
Standard_Boolean isCustomPlane = Standard_False;
|
||||||
Standard_Boolean isTextAligned = Standard_False;
|
|
||||||
gp_Dir aTextDir (1.0, 0.0, 0.0);
|
|
||||||
Standard_Boolean toUpdate = Standard_True;
|
Standard_Boolean toUpdate = Standard_True;
|
||||||
|
|
||||||
NCollection_DataMap<TCollection_AsciiString, Standard_Real> aRealParams;
|
NCollection_DataMap<TCollection_AsciiString, Standard_Real> aRealParams;
|
||||||
NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> aStringParams;
|
NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> aStringParams;
|
||||||
NCollection_DataMap<TCollection_AsciiString, Standard_Boolean> aBoolParams;
|
|
||||||
|
|
||||||
if (!GetMapOfAIS().IsBound2 (aName))
|
if (!GetMapOfAIS().IsBound2 (aName))
|
||||||
{
|
{
|
||||||
@@ -2666,7 +2558,7 @@ static int VDimParam (Draw_Interpretor& theDi, Standard_Integer theArgNum, const
|
|||||||
Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2 (aName));
|
Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2 (aName));
|
||||||
if (anObject->Type() != AIS_KOI_Dimension)
|
if (anObject->Type() != AIS_KOI_Dimension)
|
||||||
{
|
{
|
||||||
theDi << theArgVec[0] << "error: no dimension with the name: " << aName.ToCString() << ".\n";
|
theDi << theArgVec[0] << "error: no dimension with this name.\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2675,7 +2567,7 @@ static int VDimParam (Draw_Interpretor& theDi, Standard_Integer theArgNum, const
|
|||||||
|
|
||||||
if (ParseDimensionParams (theArgNum, theArgVec, 2, anAspect,
|
if (ParseDimensionParams (theArgNum, theArgVec, 2, anAspect,
|
||||||
isCustomPlane, aWorkingPlane,
|
isCustomPlane, aWorkingPlane,
|
||||||
aRealParams, aStringParams, aBoolParams, isTextAligned, aTextDir))
|
aRealParams, aStringParams))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -2685,12 +2577,7 @@ static int VDimParam (Draw_Interpretor& theDi, Standard_Integer theArgNum, const
|
|||||||
aDim->SetCustomPlane (aWorkingPlane);
|
aDim->SetCustomPlane (aWorkingPlane);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTextAligned)
|
SetDimensionParams (aDim, aRealParams, aStringParams);
|
||||||
{
|
|
||||||
aDim->SetToAlignText (isTextAligned, aTextDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetDimensionParams (aDim, aRealParams, aStringParams, aBoolParams);
|
|
||||||
|
|
||||||
if (!aDim->IsValid())
|
if (!aDim->IsValid())
|
||||||
{
|
{
|
||||||
@@ -2886,20 +2773,16 @@ void ViewerTest::RelationCommands(Draw_Interpretor& theCommands)
|
|||||||
theCommands.Add("vdimension",
|
theCommands.Add("vdimension",
|
||||||
"vdimension name {-angle|-length|-radius|-diameter} -shapes shape1 [shape2 [shape3]]\n"
|
"vdimension name {-angle|-length|-radius|-diameter} -shapes shape1 [shape2 [shape3]]\n"
|
||||||
"[-text 3d|2d wf|sh|wireframe|shading IntegerSize]\n"
|
"[-text 3d|2d wf|sh|wireframe|shading IntegerSize]\n"
|
||||||
"[-label left|right|hcenter|hfit above|below|vcenter|vfit]\n"
|
"[-label left|right|hcenter|hfit top|bottom|vcenter|vfit]\n"
|
||||||
"[-arrow external|internal|fit]\n"
|
"[-arrow external|internal|fit]\n"
|
||||||
"[{-arrowlength|-arlen} RealArrowLength]\n"
|
"[{-arrowlength|-arlen} RealArrowLength]\n"
|
||||||
"[{-arrowangle|-arangle} ArrowAngle(degrees)]\n"
|
"[{-arrowangle|-arangle} ArrowAngle(degrees)]\n"
|
||||||
"[-plane xoy|yoz|zox]\n"
|
"[-plane xoy|yoz|zox]\n"
|
||||||
"[-flyout FloatValue -extension FloatValue]\n"
|
"[-flyout FloatValue -extension FloatValue]\n"
|
||||||
"[-value CustomNumberValue] OR [-valuetext CustomMultilineLabel]\n"
|
"[-value CustomNumberValue]\n"
|
||||||
"[-dispunits DisplayUnitsString]\n"
|
"[-dispunits DisplayUnitsString]\n"
|
||||||
"[-modelunits ModelUnitsString]\n"
|
"[-modelunits ModelUnitsString]\n"
|
||||||
"[-showunits | -hideunits]\n"
|
"[-showunits | -hideunits]\n"
|
||||||
"[-drawdimline] <- dimension line is displayed by default\n"
|
|
||||||
"[-hidedimline]/n"
|
|
||||||
"[-aligntext DirX DirY DirZ]\n"
|
|
||||||
"[-segment Length\n"
|
|
||||||
" -Builds angle, length, radius and diameter dimensions.\n"
|
" -Builds angle, length, radius and diameter dimensions.\n"
|
||||||
" -See also: vdimparam, vmovedim.\n",
|
" -See also: vdimparam, vmovedim.\n",
|
||||||
__FILE__,VDimBuilder,group);
|
__FILE__,VDimBuilder,group);
|
||||||
@@ -2917,11 +2800,6 @@ void ViewerTest::RelationCommands(Draw_Interpretor& theCommands)
|
|||||||
"[-dispunits DisplayUnitsString]\n"
|
"[-dispunits DisplayUnitsString]\n"
|
||||||
"[-modelunits ModelUnitsString]\n"
|
"[-modelunits ModelUnitsString]\n"
|
||||||
"[-showunits | -hideunits]\n"
|
"[-showunits | -hideunits]\n"
|
||||||
"[-drawdimline] <- dimension line is displayed by default\n"
|
|
||||||
"[-hidedimline]/n"
|
|
||||||
"[-aligntext DirX DirY DirZ]\n"
|
|
||||||
"[-segment Length\n"
|
|
||||||
" -Builds angle, length, radius and diameter dimensions.\n"
|
|
||||||
" -Sets parameters for angle, length, radius and diameter dimensions.\n"
|
" -Sets parameters for angle, length, radius and diameter dimensions.\n"
|
||||||
" -See also: vmovedim, vdimension.\n",
|
" -See also: vmovedim, vdimension.\n",
|
||||||
__FILE__,VDimParam,group);
|
__FILE__,VDimParam,group);
|
||||||
|
36
tests/bugs/modalg_6/bug26218
Executable file
36
tests/bugs/modalg_6/bug26218
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "OCC26218"
|
||||||
|
puts "============"
|
||||||
|
puts ""
|
||||||
|
###############################
|
||||||
|
## Wrong result done by General Fuse algorithm
|
||||||
|
###############################
|
||||||
|
|
||||||
|
restore [locate_data_file bug26218_b11.brep] b1
|
||||||
|
restore [locate_data_file bug26218_b21.brep] b2
|
||||||
|
|
||||||
|
bclearobjects
|
||||||
|
bcleartools
|
||||||
|
baddobjects b1
|
||||||
|
baddcompound b2
|
||||||
|
|
||||||
|
bfillds
|
||||||
|
bbuild result
|
||||||
|
|
||||||
|
set square 2728.77
|
||||||
|
|
||||||
|
set nbshapes_expected "
|
||||||
|
Number of shapes in shape
|
||||||
|
VERTEX : 31
|
||||||
|
EDGE : 52
|
||||||
|
WIRE : 25
|
||||||
|
FACE : 25
|
||||||
|
SHELL : 4
|
||||||
|
SOLID : 4
|
||||||
|
COMPSOLID : 0
|
||||||
|
COMPOUND : 1
|
||||||
|
SHAPE : 142
|
||||||
|
"
|
||||||
|
checknbshapes result -ref ${nbshapes_expected} -t -m "result done by General Fuse algorithm"
|
||||||
|
|
||||||
|
set 3dviewer 1
|
37
tests/bugs/modalg_6/bug26224
Executable file
37
tests/bugs/modalg_6/bug26224
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "OCC26224"
|
||||||
|
puts "============"
|
||||||
|
puts ""
|
||||||
|
###############################
|
||||||
|
## Wrong result obtained by Common operator.
|
||||||
|
###############################
|
||||||
|
|
||||||
|
restore [locate_data_file bug26224_b1.brep] b1
|
||||||
|
restore [locate_data_file bug26224_b2.brep] b2
|
||||||
|
|
||||||
|
bclearobjects
|
||||||
|
bcleartools
|
||||||
|
baddobjects b1
|
||||||
|
baddtools b2
|
||||||
|
|
||||||
|
bfillds
|
||||||
|
bbop result 0
|
||||||
|
|
||||||
|
set square 35006.6
|
||||||
|
|
||||||
|
set nbshapes_expected "
|
||||||
|
Number of shapes in shape
|
||||||
|
VERTEX : 9
|
||||||
|
EDGE : 9
|
||||||
|
WIRE : 1
|
||||||
|
FACE : 1
|
||||||
|
SHELL : 1
|
||||||
|
SOLID : 0
|
||||||
|
COMPSOLID : 0
|
||||||
|
COMPOUND : 1
|
||||||
|
SHAPE : 22
|
||||||
|
|
||||||
|
"
|
||||||
|
checknbshapes result -ref ${nbshapes_expected} -t -m "result obtained by Common operator"
|
||||||
|
|
||||||
|
set 3dviewer 1
|
@@ -1,28 +0,0 @@
|
|||||||
puts "================================================================"
|
|
||||||
puts "CR26507"
|
|
||||||
puts "Visualization - Improved presentations of dimensions"
|
|
||||||
puts "================================================================"
|
|
||||||
puts ""
|
|
||||||
puts "Radius dimension line not continued to the center of a circle"
|
|
||||||
|
|
||||||
#set anImage1 $imagedir/${casename}_1.png
|
|
||||||
|
|
||||||
vinit Viewer1/View
|
|
||||||
vright
|
|
||||||
|
|
||||||
vpoint aCircleP1 0 0 60
|
|
||||||
vpoint aCircleP2 60 0 0
|
|
||||||
vpoint aCircleP3 120 0 60
|
|
||||||
vcircle aCircle aCircleP1 aCircleP2 aCircleP3 0
|
|
||||||
|
|
||||||
#Check all text and arrow positions
|
|
||||||
vdimension aDim1 -radius -shapes aCircle -text 3d -plane zox -label hfit -arrow external -hidedimline
|
|
||||||
vdimension aDim2 -radius -shapes aCircle -circleparam 20 -text 3d -plane zox -label right -arrow external -hidedimline
|
|
||||||
vdimension aDim3 -radius -shapes aCircle -circleparam 40 -text 3d -plane zox -label hfit -arrow internal -hidedimline
|
|
||||||
|
|
||||||
vdimension aDim4 -radius -shapes aCircle -circleparam 60 -text 2d -flyout 30 -plane zox -label right -arrow external -hidedimline
|
|
||||||
vdimparam aDim4 -text 20
|
|
||||||
vfit
|
|
||||||
|
|
||||||
#finalize and dump
|
|
||||||
set only_screen 1
|
|
@@ -1,34 +0,0 @@
|
|||||||
puts "================================================================"
|
|
||||||
puts "CR26507"
|
|
||||||
puts "Visualization - Improved presentations of dimensions"
|
|
||||||
puts "================================================================"
|
|
||||||
puts ""
|
|
||||||
puts "User-defined orientation of text label"
|
|
||||||
puts "Line segment aligned with text"
|
|
||||||
|
|
||||||
#set anImage1 $imagedir/${casename}_1.png
|
|
||||||
|
|
||||||
vinit Viewer1/View
|
|
||||||
vbottom
|
|
||||||
|
|
||||||
vpoint lengthP1 0 0 0
|
|
||||||
vpoint lengthP2 50 100 0
|
|
||||||
vpoint lengthP3 -50 100 0
|
|
||||||
vpoint lengthP4 0 200 0
|
|
||||||
# Text in center - custom aligment does not taken into account
|
|
||||||
vdimension dim1 -length -plane xoy -shapes lengthP1 lengthP2 -text 3d -aligntext 1.0 0.0 0.0 -flyout -10
|
|
||||||
|
|
||||||
# Text on the right side - it is aligned
|
|
||||||
vdimension dim2 -length -plane xoy -shapes lengthP1 lengthP3 -text 3d -aligntext 1.0 0.0 0.0 -segment 0 -label right
|
|
||||||
|
|
||||||
# Text on the left side - it is aligned
|
|
||||||
vdimension dim3 -length -plane xoy -shapes lengthP2 lengthP3 -text 3d -flyout -10 -aligntext 1.0 0.0 0.0 -segment 5 -label left
|
|
||||||
|
|
||||||
# Text on the left side - it is aligned
|
|
||||||
vdimension dim4 -length -plane xoy -shapes lengthP2 lengthP4 -text 3d -flyout -10 -aligntext 1.0 0.0 0.0 -segment 25 -label right
|
|
||||||
|
|
||||||
# Text on the left side - it is aligned
|
|
||||||
vdimension dim5 -length -plane xoy -shapes lengthP4 lengthP3 -text 3d -flyout -10 -aligntext 1.0 0.0 0.0 -label left above -segment 10
|
|
||||||
vfit
|
|
||||||
#finalize and dump
|
|
||||||
set only_screen 1
|
|
@@ -1,28 +0,0 @@
|
|||||||
puts "================================================================"
|
|
||||||
puts "CR26507"
|
|
||||||
puts "Visualization - Improved presentations of dimensions"
|
|
||||||
puts "================================================================"
|
|
||||||
puts ""
|
|
||||||
puts "Multi-line custom text label"
|
|
||||||
|
|
||||||
#set anImage1 $imagedir/${casename}_1.png
|
|
||||||
|
|
||||||
vinit Viewer1/View
|
|
||||||
vbottom
|
|
||||||
|
|
||||||
vpoint lengthP1 0 0 0
|
|
||||||
vpoint lengthP2 50 100 0
|
|
||||||
vpoint lengthP3 -50 100 0
|
|
||||||
# Text in center - custom aligment does not taken into account
|
|
||||||
vdimension dim1 -length -plane xoy -shapes lengthP1 lengthP2 -valuetext "+2.0\n-3.0\nThickness" -text 2d -aligntext 1.0 0.0 0.0 -segment 15 -flyout -10 -label left firstline
|
|
||||||
|
|
||||||
# Text on the right side - it is aligned
|
|
||||||
vdimension dim2 -length -plane xoy -shapes lengthP1 lengthP3 -valuetext "+3.0\n-15.0\nThickness" -text 2d -aligntext 1.0 0.0 0.0 -segment 15 -label right
|
|
||||||
|
|
||||||
# Text on the left side - it is aligned
|
|
||||||
vdimension dim3 -length -plane xoy -shapes lengthP2 lengthP3 -text 2d -valuetext "+3.0\n-15.0" -flyout -10 -aligntext 1.0 0.0 0.0 -segment 10
|
|
||||||
|
|
||||||
|
|
||||||
vfit
|
|
||||||
#finalize and dump
|
|
||||||
set only_screen 1
|
|
@@ -1,32 +0,0 @@
|
|||||||
puts "================================================================"
|
|
||||||
puts "CR26507"
|
|
||||||
puts "Visualization - Improved presentations of dimensions"
|
|
||||||
puts "================================================================"
|
|
||||||
puts ""
|
|
||||||
puts "Radius dimension with multiline custom text"
|
|
||||||
|
|
||||||
#set anImage1 $imagedir/${casename}_1.png
|
|
||||||
|
|
||||||
vinit Viewer1/View
|
|
||||||
vright
|
|
||||||
|
|
||||||
vpoint aCircleP1 0 0 60
|
|
||||||
vpoint aCircleP2 60 0 0
|
|
||||||
vpoint aCircleP3 120 0 60
|
|
||||||
vcircle aCircle aCircleP1 aCircleP2 aCircleP3 0
|
|
||||||
|
|
||||||
#Check all text and arrow positions
|
|
||||||
vdimension aDim1 -radius -shapes aCircle -circleparam 10 -text 3d -label right -arrow external -hidedimline -valuetext "+2.0\n -3.0\nThickness" -aligntext 1.0 0.0 0.0 -segment 15 -label left firstline
|
|
||||||
vdimension aDim2 -diameter -shapes aCircle -circleparam 5 -text 3d -label left -arrow external -hidedimline -valuetext "+4.0\n -6.0" -aligntext 1.0 0.0 0.0 -segment 15 -label left firstline
|
|
||||||
vdimension aDim3 -radius -shapes aCircle -circleparam 20 -text 3d -plane zox -label right -arrow external -hidedimline
|
|
||||||
vdimension aDim4 -radius -shapes aCircle -circleparam 30 -text 3d -plane zox -label vcenter -arrow internal -hidedimline
|
|
||||||
|
|
||||||
vdimension aDim5 -radius -shapes aCircle -circleparam 40 -text 2d -label right -arrow external -hidedimline -valuetext "+2.0\n -3.0\nThickness" -aligntext 1.0 0.0 0.0 -segment 15 -label left firstline
|
|
||||||
|
|
||||||
vdimparam aDim1 -text 6
|
|
||||||
vdimparam aDim3 -text 6
|
|
||||||
|
|
||||||
vfit
|
|
||||||
|
|
||||||
#finalize and dump
|
|
||||||
set only_screen 1
|
|
@@ -1,34 +0,0 @@
|
|||||||
puts "================================================================"
|
|
||||||
puts "CR26507"
|
|
||||||
puts "Visualization - Improved presentations of dimensions"
|
|
||||||
puts "================================================================"
|
|
||||||
puts ""
|
|
||||||
puts "User-defined orientation of text label"
|
|
||||||
puts "Line segment aligned with text"
|
|
||||||
|
|
||||||
#set anImage1 $imagedir/${casename}_1.png
|
|
||||||
|
|
||||||
vinit Viewer1/View
|
|
||||||
vbottom
|
|
||||||
|
|
||||||
vpoint lengthP1 0 0 0
|
|
||||||
vpoint lengthP2 100 0 0
|
|
||||||
vpoint lengthP3 100 100 0
|
|
||||||
vpoint lengthP4 0 100 0
|
|
||||||
# Text in center - custom aligment does not taken into account
|
|
||||||
#vdimension dim1 -length -plane xoy -shapes lengthP1 lengthP2 -text 3d -aligntext 1.0 0.0 0.0 -flyout -10
|
|
||||||
|
|
||||||
# Text on the right side - it is aligned
|
|
||||||
vdimension dim2 -length -plane xoy -shapes lengthP1 lengthP3 -text 3d -aligntext 1.0 0.0 0.0 -segment 0 -label right
|
|
||||||
|
|
||||||
# Text on the left side - it is aligned
|
|
||||||
vdimension dim3 -length -plane xoy -shapes lengthP2 lengthP3 -text 3d -flyout -10 -aligntext 1.0 0.0 0.0 -segment 5 -label left
|
|
||||||
|
|
||||||
# Text on the left side - it is aligned
|
|
||||||
vdimension dim4 -length -plane xoy -shapes lengthP4 lengthP1 -text 3d -valuetext "0.6\n1.58\nTHICKNESS" -flyout -10 -aligntext 1.0 0.0 0.0 -segment 10 -label right vcenter
|
|
||||||
|
|
||||||
# Text on the left side - it is aligned
|
|
||||||
vdimension dim5 -length -plane xoy -shapes lengthP4 lengthP3 -text 3d -flyout -10 -aligntext 1.0 0.0 0.0 -label left above -segment 10
|
|
||||||
vfit
|
|
||||||
#finalize and dump
|
|
||||||
set only_screen 1
|
|
@@ -1,25 +0,0 @@
|
|||||||
puts "================================================================"
|
|
||||||
puts "CR26507"
|
|
||||||
puts "Visualization - Improved presentations of dimensions"
|
|
||||||
puts "================================================================"
|
|
||||||
puts ""
|
|
||||||
puts "Radius dimension vertical alignment with multiline custom text"
|
|
||||||
|
|
||||||
#set anImage1 $imagedir/${casename}_1.png
|
|
||||||
|
|
||||||
vinit Viewer1/View
|
|
||||||
vright
|
|
||||||
|
|
||||||
vpoint aCircleP1 0 0 60
|
|
||||||
vpoint aCircleP2 60 0 0
|
|
||||||
vpoint aCircleP3 120 0 60
|
|
||||||
vcircle aCircle aCircleP1 aCircleP2 aCircleP3 0
|
|
||||||
|
|
||||||
#Check all text and arrow positions
|
|
||||||
vdimension aDim1 -radius -shapes aCircle -circleparam 10 -text 3d -label right -arrow external -hidedimline -valuetext "+2.0\n -3.0\nThickness" -aligntext 1.0 0.0 0.0 -segment 15 -label left firstline
|
|
||||||
vdimension aDim2 -radius -shapes aCircle -circleparam 20 -text 3d -label right -arrow external -hidedimline -valuetext "+3.0\n -4.0\nThickness" -aligntext 1.0 0.0 0.0 -segment 15 -label left lastline
|
|
||||||
vdimension aDim3 -radius -shapes aCircle -circleparam 30 -text 3d -label right -arrow external -hidedimline -valuetext "+4.0\n -5.0\nThickness" -aligntext 1.0 0.0 0.0 -flyout -70 -segment 15 -label left vcenter
|
|
||||||
vfit
|
|
||||||
|
|
||||||
#finalize and dump
|
|
||||||
set only_screen 1
|
|
Reference in New Issue
Block a user