Compare commits
39 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
df3644aa35 | ||
|
0252a0a4fb | ||
|
b4baade508 | ||
|
460abf4e0f | ||
|
a9db047e5d | ||
|
9640291ff0 | ||
|
7b296f0230 | ||
|
bf82385599 | ||
|
41a2c46b21 | ||
|
fd448091bf | ||
|
280e1f1b27 | ||
|
fd8fbd466b | ||
|
cdfdde3191 | ||
|
2147f85a35 | ||
|
502194e4fc | ||
|
d5c557436d | ||
|
52cc62eee8 | ||
|
7d4472c752 | ||
|
3ca159f3ca | ||
|
f25bebd7b3 | ||
|
68be9e7b9c | ||
|
7bc6dba60c | ||
|
37d575793d | ||
|
9f13057096 | ||
|
a22151d83c | ||
|
990d032c90 | ||
|
b383a61fbd | ||
|
07f2064617 | ||
|
fb64d0f4a2 | ||
|
115d350e09 | ||
|
3dd193aa6d | ||
|
87018b452a | ||
|
61f73653ba | ||
|
8ed0708507 | ||
|
077a220c51 | ||
|
c5cee3222f | ||
|
e837b3a26c | ||
|
846245d4b2 | ||
|
d7fa57a7a3 |
@@ -1,4 +1,4 @@
|
||||
TModelingData TKShapeView
|
||||
TModelingData TKShapeView TKMessageModel TKMessageView
|
||||
TVisualization TKView TKVInspector
|
||||
TApplicationFramework TKTreeModel TKTInspectorAPI TKDFBrowser
|
||||
TTool TKTInspector TKToolsDraw TInspectorEXE
|
BIN
data/images/hatch_1_.png
Normal file
After Width: | Height: | Size: 670 B |
BIN
data/images/hatch_2.png
Normal file
After Width: | Height: | Size: 679 B |
BIN
data/images/hatch_3.png
Normal file
After Width: | Height: | Size: 761 B |
BIN
data/images/hatch_4.png
Normal file
After Width: | Height: | Size: 674 B |
BIN
data/images/hatch_5.png
Normal file
After Width: | Height: | Size: 887 B |
BIN
data/images/hatch_6.png
Normal file
After Width: | Height: | Size: 933 B |
BIN
data/images/hatch_7.png
Normal file
After Width: | Height: | Size: 633 B |
BIN
data/images/hatch_8.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
@@ -1716,6 +1716,41 @@ aGroup->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect()); //!< next array
|
||||
aGroup->AddPrimitiveArray (aLines);
|
||||
~~~~
|
||||
|
||||
@subsection upgrade_740_text Changes in Graphic3d_Text and OpenGl_Text API
|
||||
|
||||
Parameters of *Text* in *Graphic3d_Group* are moved into a new *Graphic3d_Text* class. *AddText* of *Graphic3d_Group* should be used instead of the previous *Text*.
|
||||
|
||||
The previous code:
|
||||
~~~~
|
||||
Standard_Real x, y, z;
|
||||
theAttachmentPoint.Coord(x,y,z);
|
||||
theGroup->Text (theText,
|
||||
Graphic3d_Vertex(x,y,z),
|
||||
theAspect->Height(),
|
||||
theAspect->Angle(),
|
||||
theAspect->Orientation(),
|
||||
theAspect->HorizontalJustification(),
|
||||
theAspect->VerticalJustification());
|
||||
~~~~
|
||||
should be replaced by the new code:
|
||||
~~~~
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text (theAspect->Height());
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetPosition (theAttachmentPoint);
|
||||
aText->SetHorizontalAlignment (theAspect->HorizontalJustification());
|
||||
aText->SetVerticalAlignment (theAspect->VerticalJustification());
|
||||
theGroup->AddText (aText);
|
||||
~~~~
|
||||
|
||||
*OpenGl_Text* contains *Graphic3d_Text* field.
|
||||
|
||||
*OpenGl_TextParam* struct is removed. Constructor and *Init* of *OpenGl_Text* with *OpenGl_TextParam* are also removed.
|
||||
Instead of using them, change *OpenGl_Text*.
|
||||
|
||||
Please, note, that after modifying *OpenGl_Text*, *Reset* of *OpenGl_Text* should be called.
|
||||
|
||||
*FormatParams* of *OpenGl_Text* is replaced by *Text*.
|
||||
|
||||
@subsection upgrade_740_prsupdate Presentation invalidation
|
||||
|
||||
Historically AIS_InteractiveObject provided two independent mechanisms invalidating presentation (asking presentation manager to recompute specific display mode or all modes):
|
||||
|
108
src/AIS/AIS.cxx
@@ -82,6 +82,24 @@
|
||||
|
||||
const Standard_Real SquareTolerance = Precision::SquareConfusion();
|
||||
|
||||
namespace
|
||||
{
|
||||
static Standard_CString AIS_Table_PrintDisplayMode[2] =
|
||||
{
|
||||
"WIREFRAME", "SHADING"
|
||||
};
|
||||
|
||||
static Standard_CString AIS_Table_PrintDisplayStatus[3] =
|
||||
{
|
||||
"DISPLAYED", "ERASED", "NONE"
|
||||
};
|
||||
|
||||
static Standard_CString AIS_Table_PrintKindOfInteractive[6] =
|
||||
{
|
||||
"NONE", "DATUM", "SHAPE", "OBJECT", "RELATION", "DIMENSION"
|
||||
};
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Nearest
|
||||
//purpose :
|
||||
@@ -1533,3 +1551,93 @@ void AIS::ComputeProjVertexPresentation (const Handle( Prs3d_Presentation )& aPr
|
||||
StdPrs_WFShape::Add (aPresentation, MakEd.Edge(), aDrawer);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DisplayModeToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString AIS::DisplayModeToString (AIS_DisplayMode theType)
|
||||
{
|
||||
return AIS_Table_PrintDisplayMode[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DisplayModeFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS::DisplayModeFromString (Standard_CString theTypeString,
|
||||
AIS_DisplayMode& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = 0; aTypeIter <= AIS_Shaded; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = AIS_Table_PrintDisplayMode[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = AIS_DisplayMode (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DisplayStatusToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString AIS::DisplayStatusToString (AIS_DisplayStatus theType)
|
||||
{
|
||||
return AIS_Table_PrintDisplayStatus[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DisplayStatusFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS::DisplayStatusFromString (Standard_CString theTypeString,
|
||||
AIS_DisplayStatus& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = 0; aTypeIter <= AIS_DS_None; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = AIS_Table_PrintDisplayStatus[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = AIS_DisplayStatus (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : KindOfInteractiveToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString AIS::KindOfInteractiveToString (AIS_KindOfInteractive theType)
|
||||
{
|
||||
return AIS_Table_PrintKindOfInteractive[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : KindOfInteractiveFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean AIS::KindOfInteractiveFromString (Standard_CString theTypeString,
|
||||
AIS_KindOfInteractive& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = 0; aTypeIter <= AIS_KOI_Dimension; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = AIS_Table_PrintKindOfInteractive[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = AIS_KindOfInteractive (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
@@ -17,6 +17,9 @@
|
||||
#ifndef _AIS_HeaderFile
|
||||
#define _AIS_HeaderFile
|
||||
|
||||
#include <AIS_DisplayStatus.hxx>
|
||||
#include <AIS_DisplayMode.hxx>
|
||||
#include <AIS_KindOfInteractive.hxx>
|
||||
#include <AIS_KindOfSurface.hxx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
@@ -203,6 +206,72 @@ public:
|
||||
|
||||
Standard_EXPORT static void ComputeProjVertexPresentation (const Handle(Prs3d_Presentation)& aPres, const Handle(Prs3d_Drawer)& aDrawer, const TopoDS_Vertex& aVertex, const gp_Pnt& ProjPoint, const Quantity_NameOfColor aColor = Quantity_NOC_PURPLE, const Standard_Real aWidth = 2, const Aspect_TypeOfMarker aProjTOM = Aspect_TOM_PLUS, const Aspect_TypeOfLine aCallTOL = Aspect_TOL_DOT);
|
||||
|
||||
//! Returns the string name for a given enum type.
|
||||
//! @param theType display mode
|
||||
//! @return string identifier
|
||||
Standard_EXPORT static Standard_CString DisplayModeToString (AIS_DisplayMode theType);
|
||||
|
||||
//! Returns the display mode from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return status type or AIS_WireFrame if string identifier is invalid
|
||||
static AIS_DisplayMode DisplayModeFromString (Standard_CString theTypeString)
|
||||
{
|
||||
AIS_DisplayMode aType = AIS_WireFrame;
|
||||
DisplayModeFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the display mode from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected display status
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean DisplayModeFromString (const Standard_CString theTypeString,
|
||||
AIS_DisplayMode& theType);
|
||||
|
||||
//! Returns the string name for a given enum type.
|
||||
//! @param theType display status
|
||||
//! @return string identifier
|
||||
Standard_EXPORT static Standard_CString DisplayStatusToString (AIS_DisplayStatus theType);
|
||||
|
||||
//! Returns the display status from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return status type or AIS_DS_None if string identifier is invalid
|
||||
static AIS_DisplayStatus DisplayStatusFromString (Standard_CString theTypeString)
|
||||
{
|
||||
AIS_DisplayStatus aType = AIS_DS_None;
|
||||
DisplayStatusFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the shape type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected display status
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean DisplayStatusFromString (const Standard_CString theTypeString,
|
||||
AIS_DisplayStatus& theType);
|
||||
|
||||
//! Returns the string name for a given enum type.
|
||||
//! @param theType display status
|
||||
//! @return string identifier
|
||||
Standard_EXPORT static Standard_CString KindOfInteractiveToString (AIS_KindOfInteractive theType);
|
||||
|
||||
//! Returns the display status from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return status type or AIS_KOI_None if string identifier is invalid
|
||||
static AIS_KindOfInteractive KindOfInteractiveFromString (Standard_CString theTypeString)
|
||||
{
|
||||
AIS_KindOfInteractive aType = AIS_KOI_None;
|
||||
KindOfInteractiveFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the shape type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected display status
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean KindOfInteractiveFromString (const Standard_CString theTypeString,
|
||||
AIS_KindOfInteractive& theType);
|
||||
|
||||
};
|
||||
|
||||
#endif // _AIS_HeaderFile
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include <Graphic3d_AspectText3d.hxx>
|
||||
#include <Graphic3d_GraphicDriver.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
@@ -78,6 +79,31 @@ namespace
|
||||
Standard_Real aSaturation = NCollection_Lerp<Standard_Real>::Interpolate (theHlsMin[2], theHlsMax[2], aValue);
|
||||
return Quantity_Color (AIS_ColorScale::hueToValidRange (aHue), aLightness, aSaturation, Quantity_TOC_HLS);
|
||||
}
|
||||
|
||||
//! Return the index of discrete interval for specified value.
|
||||
//! Note that when value lies exactly on the border between two intervals,
|
||||
//! determining which interval to return is undefined operation;
|
||||
//! Current implementation returns the following interval in this case.
|
||||
//! @param theValue [in] value to map
|
||||
//! @param theMin [in] values range, lower value
|
||||
//! @param theMax [in] values range, upper value
|
||||
//! @param theNbIntervals [in] number of discrete intervals
|
||||
//! @return index of interval within [1, theNbIntervals] range
|
||||
static Standard_Integer colorDiscreteInterval (Standard_Real theValue,
|
||||
Standard_Real theMin,
|
||||
Standard_Real theMax,
|
||||
Standard_Integer theNbIntervals)
|
||||
{
|
||||
if (Abs (theMax - theMin) <= Precision::Approximation())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Integer anInterval = 1 + (Standard_Integer )Floor (Standard_Real (theNbIntervals) * (theValue - theMin) / (theMax - theMin));
|
||||
// map the very upper value (theValue==theMax) to the largest color interval
|
||||
anInterval = Min (anInterval, theNbIntervals);
|
||||
return anInterval;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -347,21 +373,14 @@ Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
|
||||
|
||||
if (myColorType == Aspect_TOCSD_USER)
|
||||
{
|
||||
Standard_Integer anIndex = 0;
|
||||
if (Abs (myMax - myMin) > Precision::Approximation())
|
||||
{
|
||||
anIndex = (theValue - myMin < Precision::Confusion())
|
||||
? 1
|
||||
: Standard_Integer (Ceiling (( theValue - myMin ) / ( (myMax - myMin) / myNbIntervals)));
|
||||
}
|
||||
|
||||
if (anIndex <= 0 || anIndex > myColors.Length())
|
||||
const Standard_Integer anInterval = colorDiscreteInterval (theValue, myMin, myMax, myNbIntervals);
|
||||
if (anInterval < myColors.Lower() || anInterval > myColors.Upper())
|
||||
{
|
||||
theColor = Quantity_Color();
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theColor = myColors.Value (anIndex);
|
||||
theColor = myColors.Value (anInterval);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -385,13 +404,8 @@ Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_Real anInterval = 0.0;
|
||||
if (Abs (theMax - theMin) > Precision::Approximation())
|
||||
{
|
||||
anInterval = Floor (Standard_Real (theColorsCount) * (theValue - theMin) / (theMax - theMin));
|
||||
}
|
||||
|
||||
theColor = colorFromValueEx (anInterval, 0, theColorsCount - 1, theColorHlsMin, theColorHlsMax);
|
||||
const Standard_Integer anInterval = colorDiscreteInterval (theValue, theMin, theMax, theColorsCount);
|
||||
theColor = colorFromValueEx (anInterval - 1, 0, theColorsCount - 1, theColorHlsMin, theColorHlsMax);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -796,16 +810,14 @@ void AIS_ColorScale::drawText (const Handle(Graphic3d_Group)& theGroup,
|
||||
const Graphic3d_VerticalTextAlignment theVertAlignment)
|
||||
{
|
||||
const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
|
||||
theGroup->Text (theText,
|
||||
gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()),
|
||||
anAspect->Height(),
|
||||
anAspect->Angle(),
|
||||
anAspect->Orientation(),
|
||||
Graphic3d_HTA_LEFT,
|
||||
theVertAlignment,
|
||||
Standard_True,
|
||||
Standard_False); // has own anchor
|
||||
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)anAspect->Height());
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetOrientation (gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()));
|
||||
aText->SetOwnAnchorPoint (Standard_False);
|
||||
aText->SetVerticalAlignment (theVertAlignment);
|
||||
|
||||
theGroup->AddText (aText);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -633,9 +633,11 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
|
||||
{
|
||||
aShadedGroup = thePrs->NewGroup();
|
||||
aShadedGroup->SetClosed (isClosed);
|
||||
if (isClosed
|
||||
&& !myCappingStyle.IsNull())
|
||||
aShadedGroup->SetGroupPrimitivesAspect (myCappingStyle);
|
||||
if (isClosed)
|
||||
{
|
||||
if (aDrawer->HasOwnFillCappingAspect())
|
||||
aShadedGroup->SetGroupPrimitivesAspect (aDrawer->FillCappingAspect());
|
||||
}
|
||||
}
|
||||
aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect());
|
||||
aShadedGroup->AddPrimitiveArray (aTriangles);
|
||||
|
@@ -1968,7 +1968,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t
|
||||
}
|
||||
|
||||
const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
|
||||
unhighlightOwners (theIObj);
|
||||
unselectOwners (theIObj);
|
||||
myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False);
|
||||
|
||||
if (!myLastPicked.IsNull()
|
||||
@@ -2000,10 +2000,10 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : unhighlightOwners
|
||||
//function : unselectOwners
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject)
|
||||
void AIS_InteractiveContext::unselectOwners (const Handle(AIS_InteractiveObject)& theObject)
|
||||
{
|
||||
SelectMgr_SequenceOfOwner aSeq;
|
||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
||||
@@ -2037,7 +2037,7 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
|
||||
return;
|
||||
}
|
||||
|
||||
unhighlightOwners (theIObj);
|
||||
unselectOwners (theIObj);
|
||||
|
||||
myMainPM->Erase (theIObj, -1);
|
||||
theIObj->ErasePresentations (true); // make sure highlighting presentations are properly erased
|
||||
@@ -2538,6 +2538,15 @@ void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_Interacti
|
||||
const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
||||
{
|
||||
theObject->SetTransformPersistence (theTrsfPers);
|
||||
UpdateOnTransformPersistence (theObject);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UpdateOnTransformPersistence
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::UpdateOnTransformPersistence (const Handle(AIS_InteractiveObject)& theObject)
|
||||
{
|
||||
if (!myObjects.IsBound (theObject))
|
||||
{
|
||||
return;
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <AIS_Selection.hxx>
|
||||
#include <AIS_SelectionModesConcurrency.hxx>
|
||||
#include <AIS_SelectionScheme.hxx>
|
||||
#include <AIS_StatusOfDetection.hxx>
|
||||
#include <AIS_StatusOfPick.hxx>
|
||||
#include <AIS_TypeOfIso.hxx>
|
||||
@@ -344,6 +345,11 @@ public: //! @name object local transformation management
|
||||
Standard_EXPORT void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject,
|
||||
const Handle(Graphic3d_TransformPers)& theTrsfPers);
|
||||
|
||||
//! Updates displayed interactive object by checking and recomputing its flagged as "to be recomputed" presentation and selection structures.
|
||||
//! This method does not force any recomputation on its own.
|
||||
//! The method recomputes selections even if they are loaded without activation in particular selector.
|
||||
Standard_EXPORT void UpdateOnTransformPersistence (const Handle(AIS_InteractiveObject)& theIObj);
|
||||
|
||||
Standard_DEPRECATED("This method is deprecated - SetTransformPersistence() taking Graphic3d_TransformPers should be called instead")
|
||||
void SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObj,
|
||||
const Graphic3d_TransModeFlags& theFlag,
|
||||
@@ -470,6 +476,24 @@ public: //! @name Selection management
|
||||
return AddSelect (theObject->GlobalSelOwner());
|
||||
}
|
||||
|
||||
//! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
|
||||
//! The objects detected are passed to the main viewer, which is then updated.
|
||||
Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
|
||||
const Standard_Integer theYPMin,
|
||||
const Standard_Integer theXPMax,
|
||||
const Standard_Integer theYPMax,
|
||||
const Handle(V3d_View)& theView,
|
||||
const AIS_SelectionScheme theSelScheme);
|
||||
|
||||
//! polyline selection; clears the previous picked list
|
||||
Standard_EXPORT AIS_StatusOfPick Select (const TColgp_Array1OfPnt2d& thePolyline,
|
||||
const Handle(V3d_View)& theView,
|
||||
const AIS_SelectionScheme theSelScheme);
|
||||
|
||||
//! Stores and hilights the previous detected; Unhilights the previous picked.
|
||||
//! @sa MoveTo().
|
||||
Standard_EXPORT AIS_StatusOfPick Select (const AIS_SelectionScheme theSelScheme);
|
||||
|
||||
//! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
|
||||
//! The objects detected are passed to the main viewer, which is then updated.
|
||||
Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
|
||||
@@ -511,6 +535,13 @@ public: //! @name Selection management
|
||||
//! Returns bounding box of selected objects.
|
||||
Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const;
|
||||
|
||||
//! Sets list of owner selected/deselected using selection scheme
|
||||
//! It is possible that selection of other objects is changed relatively selection scheme .
|
||||
//! \param theOwner owners to change selection state
|
||||
//! \param theSelScheme selection scheme
|
||||
Standard_EXPORT AIS_StatusOfPick Select (const AIS_NListOfEntityOwner& theOwners,
|
||||
const AIS_SelectionScheme theSelScheme);
|
||||
|
||||
//! Fits the view correspondingly to the bounds of selected objects.
|
||||
//! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
|
||||
Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
|
||||
@@ -1235,7 +1266,7 @@ protected: //! @name internal methods
|
||||
Standard_EXPORT Standard_Integer PurgeViewer (const Handle(V3d_Viewer)& Vwr);
|
||||
|
||||
//! Helper function to unhighlight all entity owners currently highlighted with seleciton color.
|
||||
Standard_EXPORT void unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject);
|
||||
Standard_EXPORT void unselectOwners (const Handle(AIS_InteractiveObject)& theObject);
|
||||
|
||||
//! Helper function that highlights the owner given with <theStyle> without
|
||||
//! performing AutoHighlight checks, e.g. is used for dynamic highlight.
|
||||
@@ -1246,12 +1277,17 @@ protected: //! @name internal methods
|
||||
//! for AutoHighlight, e.g. is used for selection.
|
||||
Standard_EXPORT void highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner);
|
||||
|
||||
//! Helper function that highlights the owners given with <theStyle> with check
|
||||
//! for AutoHighlight, e.g. is used for selection.
|
||||
Standard_EXPORT void highlightOwners (const AIS_NListOfEntityOwner& theOwners,
|
||||
const Standard_Boolean& theToUseObjectDisplayMode);
|
||||
|
||||
//! Helper function that highlights global owner of the object given with <theStyle> with check
|
||||
//! for AutoHighlight, e.g. is used for selection.
|
||||
//! If global owner is null, it simply highlights the whole object
|
||||
Standard_EXPORT void highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theDispMode) const;
|
||||
const Standard_Integer theDispMode);
|
||||
|
||||
//! Helper function that unhighlights all owners that are stored in current AIS_Selection.
|
||||
//! The function updates global status and selection state of owner and interactive object.
|
||||
@@ -1259,9 +1295,14 @@ protected: //! @name internal methods
|
||||
//! switched on in AIS_GlobalStatus will be highlighted with context's sub-intensity color.
|
||||
Standard_EXPORT void unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
|
||||
|
||||
//! Helper function that highlights the owners given with <theStyle> with check
|
||||
//! for AutoHighlight, e.g. is used for selection.
|
||||
Standard_EXPORT void unhighlightOwners (const AIS_NListOfEntityOwner& theOwners,
|
||||
const Standard_Boolean theIsToHilightSubIntensity = Standard_False);
|
||||
|
||||
//! Helper function that unhighlights global selection owner of given interactive.
|
||||
//! The function does not perform any updates of global or owner status
|
||||
Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const;
|
||||
Standard_EXPORT void unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj);
|
||||
|
||||
//! Helper function that turns on sub-intensity in global status and highlights
|
||||
//! given objects with sub-intensity color
|
||||
|
@@ -85,6 +85,7 @@ void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOw
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner)
|
||||
{
|
||||
AIS_NListOfEntityOwner anOwners;
|
||||
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
|
||||
if (anObj.IsNull())
|
||||
{
|
||||
@@ -98,17 +99,15 @@ void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwn
|
||||
{
|
||||
if (aSelIter.Value()->IsSameSelectable (anObj))
|
||||
{
|
||||
aSeq.Append (aSelIter.Value());
|
||||
anOwners.Append (aSelIter.Value());
|
||||
}
|
||||
}
|
||||
anObj->HilightSelected (myMainPM, aSeq);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Handle(Prs3d_Drawer)& aStyle = getSelStyle (anObj, theOwner);
|
||||
const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
|
||||
theOwner->HilightWithColor (myMainPM, aStyle, aHiMode);
|
||||
anOwners.Append (theOwner);
|
||||
}
|
||||
highlightOwners (anOwners, Standard_False/*check if it is really important*/);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -117,14 +116,19 @@ void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwn
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
|
||||
const Handle(Prs3d_Drawer)& theStyle,
|
||||
const Standard_Integer theDispMode) const
|
||||
const Standard_Integer /*theDispMode*/)
|
||||
{
|
||||
if (theObj.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, theDispMode);
|
||||
Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (theObj);
|
||||
if (!aStatusPtr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, (*aStatusPtr)->DisplayMode());
|
||||
const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
|
||||
|
||||
if (aGlobOwner.IsNull())
|
||||
@@ -133,6 +137,7 @@ void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject
|
||||
return;
|
||||
}
|
||||
|
||||
AIS_NListOfEntityOwner anOwners;
|
||||
if (!aGlobOwner->IsAutoHilight())
|
||||
{
|
||||
SelectMgr_SequenceOfOwner aSeq;
|
||||
@@ -140,15 +145,15 @@ void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject
|
||||
{
|
||||
if (aSelIter.Value()->IsSameSelectable (theObj))
|
||||
{
|
||||
aSeq.Append (aSelIter.Value());
|
||||
anOwners.Append (aSelIter.Value());
|
||||
}
|
||||
}
|
||||
theObj->HilightSelected (myMainPM, aSeq);
|
||||
}
|
||||
else
|
||||
{
|
||||
aGlobOwner->HilightWithColor (myMainPM, theStyle, aHiMode);
|
||||
anOwners.Append (aGlobOwner);
|
||||
}
|
||||
highlightOwners (anOwners, Standard_True);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -156,26 +161,32 @@ void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity)
|
||||
{
|
||||
unhighlightOwners (mySelection->Objects(), theIsToHilightSubIntensity);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : unhighlightOwners
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::unhighlightOwners (const AIS_NListOfEntityOwner& theOwners,
|
||||
const Standard_Boolean theIsToHilightSubIntensity)
|
||||
{
|
||||
NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
|
||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (theOwners); aSelIter.More(); aSelIter.Next())
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
|
||||
const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
|
||||
Handle(AIS_GlobalStatus) aStatus;
|
||||
if (!myObjects.Find (anInteractive, aStatus))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anInteractive);
|
||||
|
||||
if (anOwner->IsAutoHilight())
|
||||
{
|
||||
anOwner->Unhilight (myMainPM);
|
||||
if (theIsToHilightSubIntensity)
|
||||
{
|
||||
if (aStatus->IsSubIntensityOn())
|
||||
if (aStatusPtr && (*aStatusPtr)->IsSubIntensityOn())
|
||||
{
|
||||
const Standard_Integer aHiMode = getHilightMode (anInteractive, aStatus->HilightStyle(), aStatus->DisplayMode());
|
||||
const Standard_Integer aHiMode = getHilightMode (anInteractive, (*aStatusPtr)->HilightStyle(), (*aStatusPtr)->DisplayMode());
|
||||
highlightWithSubintensity (anOwner, aHiMode);
|
||||
}
|
||||
}
|
||||
@@ -184,9 +195,9 @@ void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsTo
|
||||
{
|
||||
anObjToClear.Add (anInteractive);
|
||||
}
|
||||
if (anOwner == anInteractive->GlobalSelOwner())
|
||||
if (aStatusPtr && anOwner == anInteractive->GlobalSelOwner())
|
||||
{
|
||||
myObjects.ChangeFind (anInteractive)->SetHilightStatus (Standard_False);
|
||||
(*aStatusPtr)->SetHilightStatus (Standard_False);
|
||||
}
|
||||
}
|
||||
for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
|
||||
@@ -201,7 +212,7 @@ void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsTo
|
||||
//function : unhighlightGlobal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const
|
||||
void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj)
|
||||
{
|
||||
if (theObj.IsNull())
|
||||
{
|
||||
@@ -215,15 +226,9 @@ void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObje
|
||||
return;
|
||||
}
|
||||
|
||||
if (aGlobOwner->IsAutoHilight())
|
||||
{
|
||||
aGlobOwner->Unhilight (myMainPM);
|
||||
}
|
||||
else
|
||||
{
|
||||
myMainPM->Unhighlight (theObj);
|
||||
theObj->ClearSelected();
|
||||
}
|
||||
AIS_NListOfEntityOwner anOwners;
|
||||
anOwners.Append (aGlobOwner);
|
||||
unhighlightOwners (anOwners);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -486,86 +491,14 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi
|
||||
const Standard_Integer theXPMax,
|
||||
const Standard_Integer theYPMax,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean toUpdateViewer)
|
||||
const AIS_SelectionScheme theSelScheme)
|
||||
{
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
|
||||
}
|
||||
|
||||
// all objects detected by the selector are taken, previous current objects are emptied,
|
||||
// new objects are put...
|
||||
ClearSelected (Standard_False);
|
||||
myLastActiveView = theView.get();
|
||||
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner)& aCurOwner = myMainSel->Picked (aPickIter);
|
||||
if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
|
||||
continue;
|
||||
|
||||
mySelection->Select (aCurOwner);
|
||||
}
|
||||
|
||||
if (myAutoHilight)
|
||||
{
|
||||
HilightSelected (toUpdateViewer);
|
||||
}
|
||||
|
||||
Standard_Integer aSelNum = NbSelected();
|
||||
|
||||
return (aSelNum == 0) ? AIS_SOP_NothingSelected
|
||||
: (aSelNum == 1) ? AIS_SOP_OneSelected
|
||||
: AIS_SOP_SeveralSelected;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose : Selection by polyline
|
||||
//=======================================================================
|
||||
AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean toUpdateViewer)
|
||||
{
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
|
||||
}
|
||||
|
||||
// all objects detected by the selector are taken, previous current objects are emptied,
|
||||
// new objects are put...
|
||||
ClearSelected (Standard_False);
|
||||
myLastActiveView = theView.get();
|
||||
myMainSel->Pick (thePolyline, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
|
||||
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
|
||||
continue;
|
||||
|
||||
mySelection->Select (anOwner);
|
||||
}
|
||||
|
||||
if (myAutoHilight)
|
||||
{
|
||||
HilightSelected (toUpdateViewer);
|
||||
}
|
||||
|
||||
Standard_Integer aSelNum = NbSelected();
|
||||
|
||||
return (aSelNum == 0) ? AIS_SOP_NothingSelected
|
||||
: (aSelNum == 1) ? AIS_SOP_OneSelected
|
||||
: AIS_SOP_SeveralSelected;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
|
||||
{
|
||||
if (!myLastPicked.IsNull())
|
||||
{
|
||||
Graphic3d_Vec2i aMousePos (-1, -1);
|
||||
@@ -578,54 +511,126 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate
|
||||
{
|
||||
return AIS_SOP_NothingSelected;
|
||||
}
|
||||
|
||||
if (myAutoHilight)
|
||||
{
|
||||
clearDynamicHighlight();
|
||||
}
|
||||
if (!myLastPicked->IsSelected()
|
||||
|| myLastPicked->IsForcedHilight()
|
||||
|| NbSelected() > 1)
|
||||
{
|
||||
SetSelected (myLastPicked, Standard_False);
|
||||
if(toUpdateViewer)
|
||||
{
|
||||
UpdateCurrentViewer();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
|
||||
|
||||
AIS_NListOfEntityOwner aPickedOwners;
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
ClearSelected (toUpdateViewer);
|
||||
aPickedOwners.Append (myMainSel->Picked (aPickIter));
|
||||
}
|
||||
|
||||
Standard_Integer aSelNum = NbSelected();
|
||||
return Select (aPickedOwners, theSelScheme);
|
||||
}
|
||||
|
||||
return (aSelNum == 0) ? AIS_SOP_NothingSelected
|
||||
: (aSelNum == 1) ? AIS_SOP_OneSelected
|
||||
: AIS_SOP_SeveralSelected;
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose : Selection by polyline
|
||||
//=======================================================================
|
||||
AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
|
||||
const Handle(V3d_View)& theView,
|
||||
const AIS_SelectionScheme theSelScheme)
|
||||
{
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
|
||||
}
|
||||
|
||||
myMainSel->Pick (thePolyline, theView);
|
||||
|
||||
AIS_NListOfEntityOwner aPickedOwners;
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
aPickedOwners.Append (myMainSel->Picked (aPickIter));
|
||||
}
|
||||
|
||||
return Select (aPickedOwners, theSelScheme);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_SelectionScheme theSelScheme)
|
||||
{
|
||||
// special case: single selection of detected owner - is it necessary ?
|
||||
/*if (myWasLastMain && !myLastinMain.IsNull() && !myAutoHilight &&
|
||||
(myLastinMain->IsSelected()
|
||||
&& !myLastinMain->IsForcedHilight()
|
||||
&& NbSelected() <= 1))
|
||||
{
|
||||
mySelection->selectOwner(myLastinMain, aPrevSelected, theSelScheme);
|
||||
|
||||
Graphic3d_Vec2i aMousePos (-1, -1);
|
||||
if (myMainSel->GetManager().GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Point)
|
||||
{
|
||||
aMousePos.SetValues ((Standard_Integer )myMainSel->GetManager().GetMousePosition().X(),
|
||||
(Standard_Integer )myMainSel->GetManager().GetMousePosition().Y());
|
||||
}
|
||||
if (myLastPicked->HandleMouseClick (aMousePos, Aspect_VKeyMouse_LeftButton, Aspect_VKeyFlags_NONE, false))
|
||||
{
|
||||
return AIS_SOP_NothingSelected;
|
||||
}
|
||||
return getStatusOfPick (NbSelected());
|
||||
}*/
|
||||
|
||||
AIS_NListOfEntityOwner aPickedOwners;
|
||||
if (!myLastPicked.IsNull() &&
|
||||
myLastPicked->HasSelectable())
|
||||
{
|
||||
Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(myLastPicked->Selectable());
|
||||
if (!anIO.IsNull() &&
|
||||
myObjects.IsBound(anIO))
|
||||
{
|
||||
aPickedOwners.Append (myLastPicked);
|
||||
}
|
||||
}
|
||||
|
||||
return Select (aPickedOwners, theSelScheme);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
|
||||
const Standard_Integer theYPMin,
|
||||
const Standard_Integer theXPMax,
|
||||
const Standard_Integer theYPMax,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean)
|
||||
{
|
||||
return Select (theXPMin, theYPMin, theXPMax, theYPMax, theView, AIS_SelectionScheme_ClearAndAdd);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose : Selection by polyline
|
||||
//=======================================================================
|
||||
AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean)
|
||||
{
|
||||
return Select (thePolyline, theView, AIS_SelectionScheme_ClearAndAdd);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean)
|
||||
{
|
||||
return Select (AIS_SelectionScheme_ClearAndAdd);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShiftSelect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
|
||||
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean)
|
||||
{
|
||||
if (myAutoHilight)
|
||||
{
|
||||
clearDynamicHighlight();
|
||||
}
|
||||
if (!myLastPicked.IsNull())
|
||||
{
|
||||
AddOrRemoveSelected (myLastPicked, toUpdateViewer);
|
||||
}
|
||||
|
||||
Standard_Integer aSelNum = NbSelected();
|
||||
|
||||
return (aSelNum == 0) ? AIS_SOP_NothingSelected
|
||||
: (aSelNum == 1) ? AIS_SOP_OneSelected
|
||||
: AIS_SOP_SeveralSelected;
|
||||
return Select (AIS_SelectionScheme_Switch);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -637,39 +642,9 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
|
||||
const Standard_Integer theXPMax,
|
||||
const Standard_Integer theYPMax,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean toUpdateViewer)
|
||||
const Standard_Boolean)
|
||||
{
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
|
||||
}
|
||||
|
||||
myLastActiveView = theView.get();
|
||||
if (myAutoHilight)
|
||||
{
|
||||
UnhilightSelected (Standard_False);
|
||||
}
|
||||
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
|
||||
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
|
||||
continue;
|
||||
|
||||
mySelection->Select (anOwner);
|
||||
}
|
||||
|
||||
if (myAutoHilight)
|
||||
{
|
||||
HilightSelected (toUpdateViewer);
|
||||
}
|
||||
|
||||
Standard_Integer aSelNum = NbSelected();
|
||||
|
||||
return (aSelNum == 0) ? AIS_SOP_NothingSelected
|
||||
: (aSelNum == 1) ? AIS_SOP_OneSelected
|
||||
: AIS_SOP_SeveralSelected;
|
||||
|
||||
return Select (theXPMin, theYPMin, theXPMax, theYPMax, theView, AIS_SelectionScheme_Switch);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -678,31 +653,31 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
|
||||
//=======================================================================
|
||||
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
|
||||
const Handle(V3d_View)& theView,
|
||||
const Standard_Boolean toUpdateViewer)
|
||||
const Standard_Boolean)
|
||||
{
|
||||
if (theView->Viewer() != myMainVwr)
|
||||
{
|
||||
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
|
||||
}
|
||||
return Select (thePolyline, theView, AIS_SelectionScheme_Switch);
|
||||
}
|
||||
|
||||
myLastActiveView = theView.get();
|
||||
//=======================================================================
|
||||
//function : Select
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_NListOfEntityOwner& theOwners,
|
||||
const AIS_SelectionScheme theSelScheme)
|
||||
{
|
||||
// all objects detected by the selector are taken, previous current objects are emptied,
|
||||
// new objects are put...
|
||||
if (myAutoHilight)
|
||||
{
|
||||
clearDynamicHighlight();
|
||||
UnhilightSelected (Standard_False);
|
||||
}
|
||||
myMainSel->Pick (thePolyline, theView);
|
||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
|
||||
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
|
||||
continue;
|
||||
|
||||
mySelection->Select (anOwner);
|
||||
}
|
||||
mySelection->SelectOwners (theOwners, theSelScheme, myFilters);
|
||||
|
||||
if (myAutoHilight)
|
||||
{
|
||||
HilightSelected (toUpdateViewer);
|
||||
HilightSelected (Standard_False);
|
||||
}
|
||||
|
||||
Standard_Integer aSelNum = NbSelected();
|
||||
@@ -720,17 +695,36 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
|
||||
{
|
||||
// In case of selection without using local context
|
||||
clearDynamicHighlight();
|
||||
|
||||
highlightOwners (mySelection->Objects(), Standard_True);
|
||||
|
||||
if (theToUpdateViewer)
|
||||
UpdateCurrentViewer();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : highlightOwners
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theOwners,
|
||||
const Standard_Boolean& theToUseObjectDisplayMode)
|
||||
{
|
||||
AIS_MapOfObjSelectedOwners anObjOwnerMap;
|
||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (theOwners); aSelIter.More(); aSelIter.Next())
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
|
||||
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
|
||||
if (anObj.IsNull())
|
||||
continue;
|
||||
|
||||
const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner);
|
||||
Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind(anObj);
|
||||
if (anOwner == anObj->GlobalSelOwner())
|
||||
Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj);
|
||||
if (!aStatusPtr)
|
||||
continue;
|
||||
if (theToUseObjectDisplayMode && anOwner == anObj->GlobalSelOwner())
|
||||
{
|
||||
aState->SetHilightStatus (Standard_True);
|
||||
aState->SetHilightStyle (anObjSelStyle);
|
||||
(*aStatusPtr)->SetHilightStatus (Standard_True);
|
||||
(*aStatusPtr)->SetHilightStyle (anObjSelStyle);
|
||||
}
|
||||
if (!anOwner->IsAutoHilight())
|
||||
{
|
||||
@@ -748,7 +742,7 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
|
||||
}
|
||||
else
|
||||
{
|
||||
const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, aState->DisplayMode());
|
||||
const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, theToUseObjectDisplayMode ? (*aStatusPtr)->DisplayMode() : -1);
|
||||
anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
|
||||
}
|
||||
}
|
||||
@@ -761,9 +755,6 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
|
||||
}
|
||||
anObjOwnerMap.Clear();
|
||||
}
|
||||
|
||||
if (theToUpdateViewer)
|
||||
UpdateCurrentViewer();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -772,17 +763,7 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
|
||||
//=======================================================================
|
||||
void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
|
||||
{
|
||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
|
||||
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
|
||||
if (anOwner == anObj->GlobalSelOwner())
|
||||
{
|
||||
myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
|
||||
}
|
||||
|
||||
anOwner->Unhilight (myMainPM);
|
||||
}
|
||||
unhighlightSelected();
|
||||
|
||||
if (theToUpdateViewer)
|
||||
UpdateCurrentViewer();
|
||||
@@ -865,7 +846,9 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t
|
||||
}
|
||||
if (aSelOwner == aSelectable->GlobalSelOwner())
|
||||
{
|
||||
myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
|
||||
Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (aSelectable);
|
||||
if (aStatusPtr)
|
||||
(*aStatusPtr)->SetHilightStatus (Standard_False);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -937,13 +920,6 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t
|
||||
}
|
||||
}
|
||||
|
||||
if (myAutoHilight && theOwner == anObject->GlobalSelOwner())
|
||||
{
|
||||
Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
|
||||
aState->SetHilightStatus (Standard_True);
|
||||
aState->SetHilightStyle (anObjSelStyle);
|
||||
}
|
||||
|
||||
if (theToUpdateViewer)
|
||||
UpdateCurrentViewer();
|
||||
}
|
||||
@@ -990,29 +966,24 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO
|
||||
if (myAutoHilight)
|
||||
{
|
||||
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
|
||||
const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
|
||||
Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
|
||||
if (!myObjects.IsBound(anObj)) // e.g. AIS_ViewCubeFlat is not displayed
|
||||
return;
|
||||
|
||||
Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj);
|
||||
if (!aStatusPtr)
|
||||
return;
|
||||
|
||||
if (theOwner->IsSelected())
|
||||
{
|
||||
highlightSelected (theOwner);
|
||||
if (isGlobal)
|
||||
{
|
||||
aStatus->SetHilightStatus (Standard_True);
|
||||
aStatus->SetHilightStyle (getSelStyle (anObj, theOwner));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (theOwner->IsAutoHilight())
|
||||
{
|
||||
theOwner->Unhilight (myMainPM);
|
||||
}
|
||||
else
|
||||
{
|
||||
anObj->ClearSelected();
|
||||
}
|
||||
aStatus->SetHilightStatus (Standard_False);
|
||||
aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
|
||||
AIS_NListOfEntityOwner anOwners;
|
||||
anOwners.Append (theOwner);
|
||||
unhighlightOwners (anOwners);
|
||||
|
||||
(*aStatusPtr)->SetHilightStyle (Handle(Prs3d_Drawer)());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -84,34 +84,14 @@ void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& th
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCappingStyle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_InteractiveObject::SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
|
||||
//-----------------------------------------------------------------------------
|
||||
void AIS_InteractiveObject::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
|
||||
{
|
||||
myCappingStyle = theStyle;
|
||||
SelectMgr_SelectableObject::SetTransformPersistence (theTrsfPers);
|
||||
|
||||
// Modify existing presentations
|
||||
for (Standard_Integer aPrsIter = 1, n = myPresentations.Length(); aPrsIter <= n; ++aPrsIter)
|
||||
if (!GetContext().IsNull())
|
||||
{
|
||||
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter);
|
||||
if (!aPrs3d.IsNull())
|
||||
{
|
||||
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
|
||||
if (!aStruct.IsNull())
|
||||
{
|
||||
const Graphic3d_SequenceOfGroup& aGroups = aStruct->Groups();
|
||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
|
||||
{
|
||||
Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
|
||||
if (aGrp.IsNull())
|
||||
continue;
|
||||
|
||||
aGrp->SetGroupPrimitivesAspect (theStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
GetContext()->UpdateOnTransformPersistence (this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,3 +155,26 @@ void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect
|
||||
aGroup->SetGroupPrimitivesAspect (aTextAspect->Aspect());
|
||||
}
|
||||
}
|
||||
|
||||
const TCollection_AsciiString AIS_InteractiveObject_ClassName = "AIS_InteractiveObject";
|
||||
|
||||
// =======================================================================
|
||||
// function : Dump
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void AIS_InteractiveObject::Dump (Standard_OStream& OS) const
|
||||
{
|
||||
DUMP_START_KEY (OS, AIS_InteractiveObject_ClassName);
|
||||
|
||||
{
|
||||
Standard_SStream aTmpStream;
|
||||
SelectMgr_SelectableObject::Dump (aTmpStream);
|
||||
DUMP_VALUES (OS, "SelectMgr_SelectableObject", TCollection::ToDumpString (aTmpStream));
|
||||
}
|
||||
|
||||
DUMP_VALUES (OS, "InteractiveContext", TCollection::GetPointerInfo (myCTXPtr));
|
||||
DUMP_VALUES (OS, "Owner", TCollection::GetPointerInfo (myOwner));
|
||||
|
||||
DUMP_STOP_KEY (OS, AIS_InteractiveObject_ClassName);
|
||||
|
||||
}
|
||||
|
@@ -104,16 +104,15 @@ public:
|
||||
void ClearOwner() { myOwner.Nullify(); }
|
||||
|
||||
public:
|
||||
//! Set style of filling capping section created by clipping planes.
|
||||
Standard_EXPORT virtual void SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
|
||||
|
||||
//! Returns style for filling capping section created by clipping planes.
|
||||
const Handle(Graphic3d_AspectFillCapping)& CappingStyle() const { return myCappingStyle; }
|
||||
|
||||
|
||||
//! Returns the context pointer to the interactive context.
|
||||
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
|
||||
|
||||
//! Sets up Transform Persistence defining a special Local Coordinate system where this object should be located.
|
||||
//! Updates the presentation in context if it is not NULL
|
||||
//! @sa Graphic3d_TransformPers class description
|
||||
Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
|
||||
|
||||
//! Returns TRUE when this object has a presentation in the current DisplayMode()
|
||||
Standard_EXPORT Standard_Boolean HasPresentation() const;
|
||||
|
||||
@@ -124,6 +123,9 @@ public:
|
||||
Standard_DEPRECATED("Deprecated method, results might be undefined")
|
||||
Standard_EXPORT void SetAspect (const Handle(Prs3d_BasicAspect)& anAspect);
|
||||
|
||||
//! Dumps the content of me on the stream <OS>.
|
||||
Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
||||
//! The TypeOfPresention3d means that the interactive object
|
||||
@@ -134,7 +136,6 @@ protected:
|
||||
|
||||
AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext()
|
||||
Handle(Standard_Transient) myOwner; //!< application-specific owner object
|
||||
Handle(Graphic3d_AspectFillCapping) myCappingStyle;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -15,6 +15,8 @@
|
||||
#include <AIS_Selection.hxx>
|
||||
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <AIS_SelectionScheme.hxx>
|
||||
#include <SelectMgr_Filter.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
|
||||
|
||||
@@ -130,3 +132,71 @@ AIS_SelectStatus AIS_Selection::AddSelect (const Handle(SelectMgr_EntityOwner)&
|
||||
theObject->SetSelected (Standard_True);
|
||||
return AIS_SS_Added;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SelectOwners
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Selection::SelectOwners (const AIS_NListOfEntityOwner& thePickedOwners,
|
||||
const int theSelScheme,
|
||||
const Handle(SelectMgr_Filter)& theFilter)
|
||||
{
|
||||
int aSelScheme = theSelScheme;
|
||||
AIS_NListOfEntityOwner aPrevSelected = Objects();
|
||||
if (theSelScheme & AIS_SelectionScheme_Clear)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (theSelScheme & AIS_SelectionScheme_Switch &&
|
||||
theSelScheme & AIS_SelectionScheme_PickedIfEmpty &&
|
||||
thePickedOwners.Size() < aPrevSelected.Size())
|
||||
{
|
||||
// check if all picked objects are in previous selected list, if so, all objects will be deselected,
|
||||
// but in mode AIS_SelectionScheme_PickedIfEmpty new picked objects should be selected, here, after Clear, Add
|
||||
Standard_Boolean anOtherFound = Standard_False;
|
||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
|
||||
{
|
||||
anOtherFound = !aPrevSelected.Contains (aSelIter.Value());
|
||||
if (anOtherFound)
|
||||
break;
|
||||
}
|
||||
if (!anOtherFound)
|
||||
aSelScheme = AIS_SelectionScheme_Add;
|
||||
}
|
||||
}
|
||||
|
||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
|
||||
{
|
||||
selectOwner(aSelIter.Value(), aPrevSelected, aSelScheme, theFilter);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : selectOwner
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AIS_SelectStatus AIS_Selection::selectOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const AIS_NListOfEntityOwner& thePreviousSelected,
|
||||
const int theSelScheme,
|
||||
const Handle(SelectMgr_Filter)& theFilter)
|
||||
{
|
||||
if (theOwner.IsNull() || !theOwner->HasSelectable() || !theFilter->IsOk (theOwner))
|
||||
return AIS_SS_NotDone;
|
||||
|
||||
if (theSelScheme & AIS_SelectionScheme_Add)
|
||||
{
|
||||
return AddSelect (theOwner);
|
||||
}
|
||||
else if (theSelScheme & AIS_SelectionScheme_Switch)
|
||||
{
|
||||
if (thePreviousSelected.Contains (theOwner)) // was selected, should not be now
|
||||
{
|
||||
if (theOwner->IsSelected())
|
||||
return Select (theOwner); // deselect
|
||||
}
|
||||
else
|
||||
return AddSelect (theOwner); // was not selected, should be now
|
||||
}
|
||||
|
||||
return AIS_SS_NotDone;
|
||||
}
|
||||
|
@@ -22,6 +22,8 @@
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
class SelectMgr_Filter;
|
||||
|
||||
//! Class holding the list of selected owners.
|
||||
class AIS_Selection : public Standard_Transient
|
||||
{
|
||||
@@ -75,6 +77,28 @@ public:
|
||||
//! Return selected object at iterator position.
|
||||
const Handle(SelectMgr_EntityOwner)& Value() const { return myIterator.Value(); }
|
||||
|
||||
//! Select or deselect owners depending on the selection scheme
|
||||
//! \param theOwners elements to change selection state
|
||||
//! \param theSelScheme selection scheme, defines how owner is selected
|
||||
//! \param theFilter context filter to skip not acceptable owners
|
||||
//! \return result of selection
|
||||
Standard_EXPORT virtual void SelectOwners (const AIS_NListOfEntityOwner& thePickedOwners,
|
||||
const int theSelScheme,
|
||||
const Handle(SelectMgr_Filter)& theFilter);
|
||||
|
||||
protected:
|
||||
//! Select or deselect owner depending on the selection scheme
|
||||
//! \param theOwner element to change selection state
|
||||
//! \param thePreviousSelected previous selected objects
|
||||
//! \param theSelScheme selection scheme, defines how owner is selected
|
||||
//! \param theFilter context filter to skip not acceptable owners
|
||||
//! \return result of selection
|
||||
Standard_EXPORT virtual AIS_SelectStatus selectOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||
const AIS_NListOfEntityOwner& thePreviousSelected,
|
||||
const int theSelScheme,
|
||||
const Handle(SelectMgr_Filter)& theFilter);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
AIS_NListOfEntityOwner myresult;
|
||||
|
34
src/AIS/AIS_SelectionScheme.hxx
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2019 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 _AIS_SelectionScheme_HeaderFile
|
||||
#define _AIS_SelectionScheme_HeaderFile
|
||||
|
||||
|
||||
//! Sets selection schemes for interactive contexts.
|
||||
//! It is possible to use combination of schemes.
|
||||
enum AIS_SelectionScheme
|
||||
{
|
||||
AIS_SelectionScheme_Empty = 0x0000, // do nothing
|
||||
AIS_SelectionScheme_Clear = 0x0001, // clears current selection
|
||||
AIS_SelectionScheme_Add = 0x0002, // add detected object to current selection
|
||||
AIS_SelectionScheme_Switch = 0x0004, // switch selection state in values selected/deselected
|
||||
AIS_SelectionScheme_PickedIfEmpty = 0x0008, // if after switch, result selection is empty, select picked objects
|
||||
AIS_SelectionScheme_ClearAndSwitch = AIS_SelectionScheme_Clear | AIS_SelectionScheme_Switch,
|
||||
AIS_SelectionScheme_ClearAndAdd = AIS_SelectionScheme_Clear | AIS_SelectionScheme_Add,
|
||||
AIS_SelectionScheme_ClearAndSwitchAndPicked = AIS_SelectionScheme_ClearAndSwitch | AIS_SelectionScheme_PickedIfEmpty,
|
||||
AIS_SelectionScheme_Custom // reserved item for custom selection scheme
|
||||
};
|
||||
|
||||
#endif // _AIS_SelectionScheme_HeaderFile
|
@@ -180,7 +180,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myCappingStyle);
|
||||
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myDrawer->FillCappingAspect());
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <Graphic3d_ViewAffinity.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <NCollection_Lerp.hxx>
|
||||
#include <Prs3d.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
@@ -193,6 +194,7 @@ void AIS_ViewCube::setDefaultAttributes()
|
||||
myDrawer->TextAspect()->SetColor (Quantity_NOC_BLACK);
|
||||
myDrawer->TextAspect()->SetFont (Font_NOF_SANS_SERIF);
|
||||
myDrawer->TextAspect()->SetHeight (16.0);
|
||||
myDrawer->TextAspect()->Aspect()->SetTextZoomable (true); // the whole object is drawn within transformation-persistence
|
||||
// this should be forced back-face culling regardless Closed flag
|
||||
myDrawer->TextAspect()->Aspect()->SetSuppressBackFaces (true);
|
||||
|
||||
@@ -717,7 +719,14 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
||||
const Standard_Real anOffset = 2.0; // extra offset to avoid overlapping with triangulation
|
||||
const gp_Pnt aPos = aDir.XYZ() * (mySize * 0.5 + myBoxFacetExtension + anOffset);
|
||||
const gp_Ax2 aPosition (aPos, aDir, anUp.Crossed (aDir));
|
||||
Prs3d_Text::Draw (aTextGroup, myDrawer->TextAspect(), aLabel, aPosition);
|
||||
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)myDrawer->TextAspect()->Height());
|
||||
aText->SetText (aLabel);
|
||||
aText->SetOrientation (aPosition);
|
||||
aText->SetOwnAnchorPoint (false);
|
||||
aText->SetHorizontalAlignment(myDrawer->TextAspect()->HorizontalJustification());
|
||||
aText->SetVerticalAlignment (myDrawer->TextAspect()->VerticalJustification());
|
||||
aTextGroup->AddText (aText);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -145,6 +145,7 @@ AIS_Selection.cxx
|
||||
AIS_Selection.hxx
|
||||
AIS_SelectStatus.hxx
|
||||
AIS_SelectionModesConcurrency.hxx
|
||||
AIS_SelectionScheme.hxx
|
||||
AIS_SequenceOfDimension.hxx
|
||||
AIS_SequenceOfInteractive.hxx
|
||||
AIS_Shape.cxx
|
||||
|
452
src/Aspect/Aspect.cxx
Normal file
@@ -0,0 +1,452 @@
|
||||
// Copyright (c) 2018 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 <Aspect.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
static Standard_CString Aspect_Table_PrintTypeOfDeflection[2] =
|
||||
{
|
||||
"RELATIVE", "ABSOLUTE"
|
||||
};
|
||||
|
||||
static Standard_CString Aspect_Table_PrintTypeOfFacingModel[3] =
|
||||
{
|
||||
"BOTH", "BACK", "FRONT"
|
||||
};
|
||||
|
||||
static Standard_CString Aspect_Table_PrintTypeOfHighlightMethod[2] =
|
||||
{
|
||||
"COLOR", "BOUNDBOX"
|
||||
};
|
||||
|
||||
static Standard_CString Aspect_Table_PrintTypeOfLine[6] =
|
||||
{
|
||||
"EMPTY", "SOLID", "DASH", "DOT", "DOT_DASH", "USER_DEFINED"
|
||||
};
|
||||
|
||||
static Standard_CString Aspect_Table_PrintTypeOfMarker[15] =
|
||||
{
|
||||
"EMPTY", "POINT", "PLUS", "STAR", "X", "O", "O_POINT", "O_PLUS", "O_STAR", "O_X",
|
||||
"RING1", "RING2", "RING3", "BALL", "USER_DEFINED"
|
||||
};
|
||||
|
||||
static Standard_CString Aspect_Table_PrintTypeOfDisplayText[6] =
|
||||
{
|
||||
"NORMAL", "SUBTITLE", "DEKALE", "BLEND", "DIMENSION", "SHADOW"
|
||||
};
|
||||
|
||||
static Standard_CString Aspect_Table_PrintTypeOfStyleText[2] =
|
||||
{
|
||||
"NORMAL", "ANNOTATION"
|
||||
};
|
||||
|
||||
static Standard_CString Aspect_Table_PrintInteriorStyle[6] =
|
||||
{
|
||||
"EMPTY", "HOLLOW", "HATCH", "SOLID", "HIDDEN_LINE", "POINT"
|
||||
};
|
||||
|
||||
static Standard_CString Aspect_Table_PrintPolygonOffsetMode[7] =
|
||||
{
|
||||
"OFF", "FILL", "LINE", "POINT", "ALL", "NONE", "MASK"
|
||||
};
|
||||
|
||||
static Standard_CString Aspect_Table_PrintHatchStyle[14] =
|
||||
{
|
||||
"SOLID", "HORIZONTAL", "HORIZONTAL_WIDE", "VERTICAL", "VERTICAL_WIDE",
|
||||
"DIAGONAL_45", "DIAGONAL_45_WIDE", "DIAGONAL_135", "DIAGONAL_135_WIDE",
|
||||
"GRID", "GRID_WIDE", "GRID_DIAGONAL", "GRID_DIAGONAL_WIDE", "NB"
|
||||
};
|
||||
|
||||
static Standard_CString Aspect_Table_PrintTypeOfTriedronPosition[9] =
|
||||
{
|
||||
"CENTER", "TOP", "BOTTOM", "LEFT", "RIGHT", "LEFT_LOWER", "LEFT_UPPER", "RIGHT_LOWER", "RIGHT_UPPER"
|
||||
};
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfDeflectionToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Aspect::TypeOfDeflectionToString (Aspect_TypeOfDeflection theType)
|
||||
{
|
||||
return Aspect_Table_PrintTypeOfDeflection[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfDeflectionFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Aspect::TypeOfDeflectionFromString (Standard_CString theTypeString,
|
||||
Aspect_TypeOfDeflection& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = 0; aTypeIter <= Aspect_TOD_ABSOLUTE; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Aspect_Table_PrintTypeOfDeflection[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Aspect_TypeOfDeflection (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfFacingModelToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Aspect::TypeOfFacingModelToString (Aspect_TypeOfFacingModel theType)
|
||||
{
|
||||
return Aspect_Table_PrintTypeOfFacingModel[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfFacingModelFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Aspect::TypeOfFacingModelFromString (Standard_CString theTypeString,
|
||||
Aspect_TypeOfFacingModel& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = 0; aTypeIter <= Aspect_TOFM_FRONT_SIDE; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Aspect_Table_PrintTypeOfFacingModel[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Aspect_TypeOfFacingModel (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfHighlightMethodToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Aspect::TypeOfHighlightMethodToString (Aspect_TypeOfHighlightMethod theType)
|
||||
{
|
||||
return Aspect_Table_PrintTypeOfHighlightMethod[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfHighlightMethodFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Aspect::TypeOfHighlightMethodFromString (Standard_CString theTypeString,
|
||||
Aspect_TypeOfHighlightMethod& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = 0; aTypeIter <= Aspect_TOHM_BOUNDBOX; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Aspect_Table_PrintTypeOfHighlightMethod[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Aspect_TypeOfHighlightMethod (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfLineToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Aspect::TypeOfLineToString (Aspect_TypeOfLine theType)
|
||||
{
|
||||
return Aspect_Table_PrintTypeOfLine[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfLineFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Aspect::TypeOfLineFromString (Standard_CString theTypeString,
|
||||
Aspect_TypeOfLine& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Aspect_TOL_EMPTY; aTypeIter <= Aspect_TOL_USERDEFINED; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Aspect_Table_PrintTypeOfLine[aTypeIter + 1];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Aspect_TypeOfLine (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfMarkerToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Aspect::TypeOfMarkerToString (Aspect_TypeOfMarker theType)
|
||||
{
|
||||
return Aspect_Table_PrintTypeOfMarker[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfMarkerFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Aspect::TypeOfMarkerFromString (Standard_CString theTypeString,
|
||||
Aspect_TypeOfMarker& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Aspect_TOM_EMPTY; aTypeIter <= Aspect_TOM_USERDEFINED; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Aspect_Table_PrintTypeOfMarker[aTypeIter + 1];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Aspect_TypeOfMarker (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfDisplayTextToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Aspect::TypeOfDisplayTextToString (Aspect_TypeOfDisplayText theType)
|
||||
{
|
||||
return Aspect_Table_PrintTypeOfDisplayText[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfDisplayTextFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Aspect::TypeOfDisplayTextFromString (Standard_CString theTypeString,
|
||||
Aspect_TypeOfDisplayText& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Aspect_TODT_NORMAL; aTypeIter <= Aspect_TODT_SHADOW; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Aspect_Table_PrintTypeOfDisplayText[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Aspect_TypeOfDisplayText (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfStyleTextToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Aspect::TypeOfStyleTextToString (Aspect_TypeOfStyleText theType)
|
||||
{
|
||||
return Aspect_Table_PrintTypeOfStyleText[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfStyleTextFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Aspect::TypeOfStyleTextFromString (Standard_CString theTypeString,
|
||||
Aspect_TypeOfStyleText& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Aspect_TOST_NORMAL; aTypeIter <= Aspect_TOST_ANNOTATION; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Aspect_Table_PrintTypeOfStyleText[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Aspect_TypeOfStyleText (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InteriorStyleToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Aspect::InteriorStyleToString (Aspect_InteriorStyle theType)
|
||||
{
|
||||
return Aspect_Table_PrintInteriorStyle[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InteriorStyleFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Aspect::InteriorStyleFromString (Standard_CString theTypeString,
|
||||
Aspect_InteriorStyle& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Aspect_IS_EMPTY; aTypeIter <= Aspect_IS_POINT; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Aspect_Table_PrintInteriorStyle[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Aspect_InteriorStyle (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PolygonOffsetModeToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Aspect::PolygonOffsetModeToString (Aspect_PolygonOffsetMode theType)
|
||||
{
|
||||
switch (theType)
|
||||
{
|
||||
case Aspect_POM_Off: return Aspect_Table_PrintPolygonOffsetMode[0];
|
||||
case Aspect_POM_Fill: return Aspect_Table_PrintPolygonOffsetMode[1];
|
||||
case Aspect_POM_Line: return Aspect_Table_PrintPolygonOffsetMode[2];
|
||||
case Aspect_POM_Point: return Aspect_Table_PrintPolygonOffsetMode[3];
|
||||
case Aspect_POM_All: return Aspect_Table_PrintPolygonOffsetMode[4];
|
||||
case Aspect_POM_None: return Aspect_Table_PrintPolygonOffsetMode[5];
|
||||
case Aspect_POM_Mask: return Aspect_Table_PrintPolygonOffsetMode[6];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PolygonOffsetModeFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Aspect::PolygonOffsetModeFromString (Standard_CString theTypeString,
|
||||
Aspect_PolygonOffsetMode& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
if (aName == Aspect_Table_PrintPolygonOffsetMode[0]) { theType = Aspect_POM_Off; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintPolygonOffsetMode[1]) { theType = Aspect_POM_Fill; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintPolygonOffsetMode[2]) { theType = Aspect_POM_Line; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintPolygonOffsetMode[3]) { theType = Aspect_POM_Point; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintPolygonOffsetMode[4]) { theType = Aspect_POM_All; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintPolygonOffsetMode[5]) { theType = Aspect_POM_None; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintPolygonOffsetMode[6]) { theType = Aspect_POM_Mask; return Standard_True; }
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HatchStyleToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Aspect::HatchStyleToString (Aspect_HatchStyle theType)
|
||||
{
|
||||
return Aspect_Table_PrintHatchStyle[theType];
|
||||
switch (theType)
|
||||
{
|
||||
case Aspect_HS_SOLID: return Aspect_Table_PrintHatchStyle[0];
|
||||
case Aspect_HS_HORIZONTAL: return Aspect_Table_PrintHatchStyle[1];
|
||||
case Aspect_HS_HORIZONTAL_WIDE: return Aspect_Table_PrintHatchStyle[2];
|
||||
case Aspect_HS_VERTICAL: return Aspect_Table_PrintHatchStyle[3];
|
||||
case Aspect_HS_VERTICAL_WIDE: return Aspect_Table_PrintHatchStyle[4];
|
||||
case Aspect_HS_DIAGONAL_45: return Aspect_Table_PrintHatchStyle[5];
|
||||
case Aspect_HS_DIAGONAL_45_WIDE: return Aspect_Table_PrintHatchStyle[6];
|
||||
case Aspect_HS_DIAGONAL_135: return Aspect_Table_PrintHatchStyle[7];
|
||||
case Aspect_HS_DIAGONAL_135_WIDE: return Aspect_Table_PrintHatchStyle[8];
|
||||
case Aspect_HS_GRID: return Aspect_Table_PrintHatchStyle[9];
|
||||
case Aspect_HS_GRID_WIDE: return Aspect_Table_PrintHatchStyle[10];
|
||||
case Aspect_HS_GRID_DIAGONAL: return Aspect_Table_PrintHatchStyle[11];
|
||||
case Aspect_HS_GRID_DIAGONAL_WIDE: return Aspect_Table_PrintHatchStyle[12];
|
||||
case Aspect_HS_NB: return Aspect_Table_PrintHatchStyle[13];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HatchStyleFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Aspect::HatchStyleFromString (Standard_CString theTypeString,
|
||||
Aspect_HatchStyle& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
if (aName == Aspect_Table_PrintHatchStyle[0]) { theType = Aspect_HS_SOLID; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[1]) { theType = Aspect_HS_HORIZONTAL; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[2]) { theType = Aspect_HS_HORIZONTAL_WIDE; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[3]) { theType = Aspect_HS_VERTICAL; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[4]) { theType = Aspect_HS_VERTICAL_WIDE; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[5]) { theType = Aspect_HS_DIAGONAL_45; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[6]) { theType = Aspect_HS_DIAGONAL_45_WIDE; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[7]) { theType = Aspect_HS_DIAGONAL_135; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[8]) { theType = Aspect_HS_DIAGONAL_135_WIDE; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[9]) { theType = Aspect_HS_GRID; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[10]) { theType = Aspect_HS_GRID_WIDE; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[11]) { theType = Aspect_HS_GRID_DIAGONAL; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[12]) { theType = Aspect_HS_GRID_DIAGONAL_WIDE; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintHatchStyle[13]) { theType = Aspect_HS_NB; return Standard_True; }
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfTriedronPositionToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Aspect::TypeOfTriedronPositionToString (Aspect_TypeOfTriedronPosition theType)
|
||||
{
|
||||
return Aspect_Table_PrintTypeOfTriedronPosition[theType];
|
||||
switch (theType)
|
||||
{
|
||||
case Aspect_TOTP_CENTER: return Aspect_Table_PrintTypeOfTriedronPosition[0];
|
||||
case Aspect_TOTP_TOP: return Aspect_Table_PrintTypeOfTriedronPosition[1];
|
||||
case Aspect_TOTP_BOTTOM: return Aspect_Table_PrintTypeOfTriedronPosition[2];
|
||||
case Aspect_TOTP_LEFT: return Aspect_Table_PrintTypeOfTriedronPosition[3];
|
||||
case Aspect_TOTP_RIGHT: return Aspect_Table_PrintTypeOfTriedronPosition[4];
|
||||
case Aspect_TOTP_LEFT_LOWER: return Aspect_Table_PrintTypeOfTriedronPosition[5];
|
||||
case Aspect_TOTP_LEFT_UPPER: return Aspect_Table_PrintTypeOfTriedronPosition[6];
|
||||
case Aspect_TOTP_RIGHT_LOWER: return Aspect_Table_PrintTypeOfTriedronPosition[7];
|
||||
case Aspect_TOTP_RIGHT_UPPER: return Aspect_Table_PrintTypeOfTriedronPosition[8];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfTriedronPositionFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Aspect::TypeOfTriedronPositionFromString (Standard_CString theTypeString,
|
||||
Aspect_TypeOfTriedronPosition& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
if (aName == Aspect_Table_PrintTypeOfTriedronPosition[0]) { theType = Aspect_TOTP_CENTER; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[1]) { theType = Aspect_TOTP_TOP; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[2]) { theType = Aspect_TOTP_BOTTOM; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[3]) { theType = Aspect_TOTP_LEFT; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[4]) { theType = Aspect_TOTP_RIGHT; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[5]) { theType = Aspect_TOTP_LEFT_LOWER; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[6]) { theType = Aspect_TOTP_LEFT_UPPER; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[7]) { theType = Aspect_TOTP_RIGHT_LOWER; return Standard_True; }
|
||||
else if (aName == Aspect_Table_PrintTypeOfTriedronPosition[8]) { theType = Aspect_TOTP_RIGHT_UPPER; return Standard_True; }
|
||||
return Standard_False;
|
||||
}
|
284
src/Aspect/Aspect.hxx
Normal file
@@ -0,0 +1,284 @@
|
||||
// Copyright (c) 2018 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 _Aspect_HeaderFile
|
||||
#define _Aspect_HeaderFile
|
||||
|
||||
#include <Aspect_HatchStyle.hxx>
|
||||
#include <Aspect_InteriorStyle.hxx>
|
||||
#include <Aspect_PolygonOffsetMode.hxx>
|
||||
#include <Aspect_TypeOfDeflection.hxx>
|
||||
#include <Aspect_TypeOfDisplayText.hxx>
|
||||
#include <Aspect_TypeOfFacingModel.hxx>
|
||||
#include <Aspect_TypeOfHighlightMethod.hxx>
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Aspect_TypeOfStyleText.hxx>
|
||||
#include <Aspect_TypeOfTriedronPosition.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
//! Provides methods to cast enumerations of package to string value
|
||||
class Aspect
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TypeOfDeflectionToString (Aspect_TypeOfDeflection theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_TOFM_BOTH_SIDE if string identifier is invalid
|
||||
static Aspect_TypeOfDeflection TypeOfDeflectionFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Aspect_TypeOfDeflection aType = Aspect_TOD_RELATIVE;
|
||||
TypeOfDeflectionFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TypeOfDeflectionFromString (const Standard_CString theTypeString,
|
||||
Aspect_TypeOfDeflection& theType);
|
||||
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TypeOfFacingModelToString (Aspect_TypeOfFacingModel theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_TOFM_BOTH_SIDE if string identifier is invalid
|
||||
static Aspect_TypeOfFacingModel TypeOfFacingModelFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Aspect_TypeOfFacingModel aType = Aspect_TOFM_BOTH_SIDE;
|
||||
TypeOfFacingModelFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TypeOfFacingModelFromString (const Standard_CString theTypeString,
|
||||
Aspect_TypeOfFacingModel& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TypeOfHighlightMethodToString (Aspect_TypeOfHighlightMethod theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_TOHM_COLOR if string identifier is invalid
|
||||
static Aspect_TypeOfHighlightMethod TypeOfHighlightMethodFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Aspect_TypeOfHighlightMethod aType = Aspect_TOHM_COLOR;
|
||||
TypeOfHighlightMethodFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TypeOfHighlightMethodFromString (const Standard_CString theTypeString,
|
||||
Aspect_TypeOfHighlightMethod& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TypeOfLineToString (Aspect_TypeOfLine theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_TOL_EMPTY if string identifier is invalid
|
||||
static Aspect_TypeOfLine TypeOfLineFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Aspect_TypeOfLine aType = Aspect_TOL_EMPTY;
|
||||
TypeOfLineFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TypeOfLineFromString (const Standard_CString theTypeString,
|
||||
Aspect_TypeOfLine& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TypeOfMarkerToString (Aspect_TypeOfMarker theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_TOM_EMPTY if string identifier is invalid
|
||||
static Aspect_TypeOfMarker TypeOfMarkerFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Aspect_TypeOfMarker aType = Aspect_TOM_EMPTY;
|
||||
TypeOfMarkerFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TypeOfMarkerFromString (const Standard_CString theTypeString,
|
||||
Aspect_TypeOfMarker& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TypeOfDisplayTextToString (Aspect_TypeOfDisplayText theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_TODT_NORMAL if string identifier is invalid
|
||||
static Aspect_TypeOfDisplayText TypeOfDisplayTextFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Aspect_TypeOfDisplayText aType = Aspect_TODT_NORMAL;
|
||||
TypeOfDisplayTextFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TypeOfDisplayTextFromString (const Standard_CString theTypeString,
|
||||
Aspect_TypeOfDisplayText& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TypeOfStyleTextToString (Aspect_TypeOfStyleText theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_TODT_NORMAL if string identifier is invalid
|
||||
static Aspect_TypeOfStyleText TypeOfStyleTextFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Aspect_TypeOfStyleText aType = Aspect_TOST_NORMAL;
|
||||
TypeOfStyleTextFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TypeOfStyleTextFromString (const Standard_CString theTypeString,
|
||||
Aspect_TypeOfStyleText& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString InteriorStyleToString (Aspect_InteriorStyle theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_IS_EMPTY if string identifier is invalid
|
||||
static Aspect_InteriorStyle InteriorStyleFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Aspect_InteriorStyle aType = Aspect_IS_EMPTY;
|
||||
InteriorStyleFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean InteriorStyleFromString (const Standard_CString theTypeString,
|
||||
Aspect_InteriorStyle& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString PolygonOffsetModeToString (Aspect_PolygonOffsetMode theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_POM_Off if string identifier is invalid
|
||||
static Aspect_PolygonOffsetMode PolygonOffsetModeFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Aspect_PolygonOffsetMode aType = Aspect_POM_Off;
|
||||
PolygonOffsetModeFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean PolygonOffsetModeFromString (const Standard_CString theTypeString,
|
||||
Aspect_PolygonOffsetMode& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString HatchStyleToString (Aspect_HatchStyle theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_POM_Off if string identifier is invalid
|
||||
static Aspect_HatchStyle HatchStyleFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Aspect_HatchStyle aType = Aspect_HS_SOLID;
|
||||
HatchStyleFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean HatchStyleFromString (const Standard_CString theTypeString,
|
||||
Aspect_HatchStyle& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TypeOfTriedronPositionToString (Aspect_TypeOfTriedronPosition theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_TOTP_CENTER if string identifier is invalid
|
||||
static Aspect_TypeOfTriedronPosition TypeOfTriedronPositionFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Aspect_TypeOfTriedronPosition aType = Aspect_TOTP_CENTER;
|
||||
TypeOfTriedronPositionFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TypeOfTriedronPositionFromString (const Standard_CString theTypeString,
|
||||
Aspect_TypeOfTriedronPosition& theType);
|
||||
|
||||
};
|
||||
|
||||
#endif // _Aspect_HeaderFile
|
@@ -1,3 +1,5 @@
|
||||
Aspect.cxx
|
||||
Aspect.hxx
|
||||
Aspect_AspectFillAreaDefinitionError.hxx
|
||||
Aspect_AspectLineDefinitionError.hxx
|
||||
Aspect_AspectMarkerDefinitionError.hxx
|
||||
|
@@ -1395,7 +1395,7 @@ BRepCheck_Status BRepCheck_Wire::SelfIntersect(const TopoDS_Face& F,
|
||||
if (aCT1==GeomAbs_Line && aCT2==GeomAbs_Line) {
|
||||
// check for the two lines coincidence
|
||||
Standard_Real aPAR_T, aT11, aT12, aT21, aT22, aT1m, aT2m;
|
||||
Standard_Real aD2, aTolE1, aTolE2, aTol2, aDot;
|
||||
Standard_Real aD2, aTolE1, aTolE2, aTol2;
|
||||
gp_Lin2d aL1, aL2;
|
||||
gp_Pnt2d aP1m;
|
||||
//
|
||||
@@ -1423,14 +1423,10 @@ BRepCheck_Status BRepCheck_Wire::SelfIntersect(const TopoDS_Face& F,
|
||||
if (aT2m>aT21 && aT2m<aT22) {
|
||||
const gp_Dir2d& aDir1=aL1.Direction();
|
||||
const gp_Dir2d& aDir2=aL2.Direction();
|
||||
aDot=aDir1*aDir2;
|
||||
if (aDot<0.) {
|
||||
aDot=-aDot;
|
||||
}
|
||||
//
|
||||
if ((1.-aDot)<5.e-11){//0.00001 rad
|
||||
localok = Standard_False;
|
||||
break;// from for (k = 0; k < 2; ++k){...
|
||||
if (aDir1.IsParallel (aDir2, Precision::Angular()))
|
||||
{
|
||||
localok = Standard_False;
|
||||
break;// from for (k = 0; k < 2; ++k){...
|
||||
}
|
||||
}//if (aT2m>aT21 && aT2m<aT22) {
|
||||
}//if (aD2<aTol2) {
|
||||
|
@@ -1,25 +1,26 @@
|
||||
// Copyright (c) 2018 OPEN CASCADE SAS
|
||||
// This file is part of commercial software by OPEN CASCADE SAS,
|
||||
// furnished in accordance with the terms and conditions of the contract
|
||||
// and with the inclusion of this copyright notice.
|
||||
// This file or any part thereof may not be provided or otherwise
|
||||
// made available to any third party.
|
||||
//
|
||||
// No ownership title to the software is transferred hereby.
|
||||
//
|
||||
// OPEN CASCADE SAS makes no representation or warranties with respect to the
|
||||
// performance of this software, and specifically disclaims any responsibility
|
||||
// for any damages, special or consequential, connected with its use.
|
||||
//
|
||||
// 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 <BRepGProp_MeshProps.hxx>
|
||||
|
||||
#include <BRepGProp.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <GProp.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Poly_Triangle.hxx>
|
||||
#include<ElSLib.hxx>
|
||||
#include<gp_Ax3.hxx>
|
||||
#include <BRepGProp.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <GProp.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : CalculateElSProps
|
||||
|
@@ -1,23 +1,19 @@
|
||||
// Copyright (c) 2018 OPEN CASCADE SAS
|
||||
// This file is part of commercial software by OPEN CASCADE SAS,
|
||||
// furnished in accordance with the terms and conditions of the contract
|
||||
// and with the inclusion of this copyright notice.
|
||||
// This file or any part thereof may not be provided or otherwise
|
||||
// made available to any third party.
|
||||
//
|
||||
// No ownership title to the software is transferred hereby.
|
||||
//
|
||||
// OPEN CASCADE SAS makes no representation or warranties with respect to the
|
||||
// performance of this software, and specifically disclaims any responsibility
|
||||
// for any damages, special or consequential, connected with its use.
|
||||
//
|
||||
// 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 _BRepGProp_MeshProps_HeaderFile
|
||||
#define _BRepGProp_MeshProps_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <GProp_GProps.hxx>
|
||||
#include <TopAbs_Orientation.hxx>
|
||||
#include <Poly_Array1OfTriangle.hxx>
|
||||
@@ -36,11 +32,11 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Describes types of geometric objects.
|
||||
//! - Vinert is 3D closed region of space delimited with
|
||||
//! Point and surface mesh;
|
||||
//! - Sinert is surface mesh in 3D space.
|
||||
typedef enum { Vinert = 0, Sinert } BRepGProp_MeshObjType;
|
||||
//! Describes types of geometric objects.
|
||||
//! - Vinert is 3D closed region of space delimited with
|
||||
//! Point and surface mesh;
|
||||
//! - Sinert is surface mesh in 3D space.
|
||||
typedef enum { Vinert = 0, Sinert } BRepGProp_MeshObjType;
|
||||
|
||||
//! Constructor takes the type of object.
|
||||
BRepGProp_MeshProps(const BRepGProp_MeshObjType theType) :
|
||||
|
@@ -25,14 +25,14 @@
|
||||
//! Class implements functionality of model healer tool.
|
||||
//! Iterates over model's faces and checks consistency of their wires,
|
||||
//! i.e.whether wires are closed and do not contain self - intersections.
|
||||
//! In case if wire contains disconnected parts, ends of adjacent edges
|
||||
//! forming the gaps are connected in parametric space forcibly. The notion
|
||||
//! of this operation is to create correct discrete model defined relatively
|
||||
//! In case if wire contains disconnected parts, ends of adjacent edges
|
||||
//! forming the gaps are connected in parametric space forcibly. The notion
|
||||
//! of this operation is to create correct discrete model defined relatively
|
||||
//! parametric space of target face taking into account connectivity and
|
||||
//! tolerances of 3D space only. This means that there are no specific
|
||||
//! computations are made for the sake of determination of U and V tolerance.
|
||||
//! Registers intersections on edges forming the face<EFBFBD>s shape and tries to
|
||||
//! amplify discrete represenation by decreasing of deflection for the target edge.
|
||||
//! Registers intersections on edges forming the face's shape and tries to
|
||||
//! amplify discrete represenation by decreasing of deflection for the target edge.
|
||||
//! Checks can be performed in parallel mode.
|
||||
class BRepMesh_ModelHealer : public IMeshTools_ModelAlgo
|
||||
{
|
||||
|
@@ -363,8 +363,8 @@ TopoDS_Shape BRepTools_ReShape::Apply (const TopoDS_Shape& shape,
|
||||
return res;
|
||||
}
|
||||
|
||||
TopAbs_ShapeEnum st = shape.ShapeType(); //, subt;
|
||||
if ( st >= until ) return newsh; // critere d arret
|
||||
TopAbs_ShapeEnum st = shape.ShapeType();
|
||||
if (st > until || (st == until && until > TopAbs_COMPOUND)) return newsh; // stopping criteria
|
||||
if(st == TopAbs_VERTEX || st == TopAbs_SHAPE)
|
||||
return shape;
|
||||
// define allowed types of components
|
||||
|
@@ -18,7 +18,9 @@
|
||||
|
||||
#include <BVH_Constants.hxx>
|
||||
#include <BVH_Types.hxx>
|
||||
#include <Message_Alerts.hxx>
|
||||
#include <Standard_ShortReal.hxx>
|
||||
#include <TCollection.hxx>
|
||||
|
||||
#include <limits>
|
||||
|
||||
@@ -108,6 +110,17 @@ public:
|
||||
//! Returns center of bounding box along the given axis.
|
||||
T Center (const Standard_Integer theAxis) const;
|
||||
|
||||
//! Dumps the content of me on the stream <OS>.
|
||||
void Dump (Standard_OStream& OS) const
|
||||
{
|
||||
DUMP_VALUES (OS, "BVH_Box", 2);
|
||||
DUMP_VALUES (OS, "IsValid", IsValid());
|
||||
|
||||
OS << "Bnd_Box" << TCollection::DumpSeparator();
|
||||
BVH::ToBndBox (CornerMin(), CornerMax()).Dump (OS);
|
||||
OS << TCollection::DumpSeparator();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//! Checks if the Box is out of the other box.
|
||||
|
@@ -18,6 +18,11 @@
|
||||
|
||||
#include <BVH_Box.hxx>
|
||||
|
||||
#include <Message_Alerts.hxx>
|
||||
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
|
||||
template<class T, int N> class BVH_Builder;
|
||||
|
||||
//! A non-template class for using as base for BVH_TreeBase
|
||||
@@ -27,6 +32,13 @@ class BVH_TreeBaseTransient : public Standard_Transient
|
||||
DEFINE_STANDARD_RTTIEXT(BVH_TreeBaseTransient, Standard_Transient)
|
||||
protected:
|
||||
BVH_TreeBaseTransient() {}
|
||||
|
||||
//! Dumps the content of me on the stream <OS>.
|
||||
virtual void Dump (Standard_OStream& OS) const { (void)OS; }
|
||||
|
||||
//! Dumps the content of the given node on the stream <OS>.
|
||||
virtual void DumpNode (const int theNodeIndex, Standard_OStream& OS) const
|
||||
{ (void)theNodeIndex; (void)OS; }
|
||||
};
|
||||
|
||||
//! Stores parameters of bounding volume hierarchy (BVH).
|
||||
@@ -178,6 +190,37 @@ public: //! @name methods for accessing serialized tree data
|
||||
return myMaxPointBuffer;
|
||||
}
|
||||
|
||||
|
||||
//! Dumps the content of me on the stream <OS>.
|
||||
Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE
|
||||
{
|
||||
DUMP_VALUES (OS, "BVH_Tree", 2);
|
||||
|
||||
DUMP_VALUES (OS, "Depth", Depth());
|
||||
DUMP_VALUES (OS, "Length", Length());
|
||||
|
||||
for (Standard_Integer aNodeIdx = 0; aNodeIdx < Length(); ++aNodeIdx)
|
||||
{
|
||||
DumpNode (aNodeIdx, OS);
|
||||
}
|
||||
}
|
||||
|
||||
//! Dumps the content of the given node on the stream <OS>.
|
||||
Standard_EXPORT virtual void DumpNode (const int theNodeIndex, Standard_OStream& OS) const Standard_OVERRIDE
|
||||
{
|
||||
DUMP_VALUES (OS, "BVH_TreeNode", 2);
|
||||
DUMP_VALUES (OS, "NodeIndex", theNodeIndex);
|
||||
|
||||
OS << "Bnd_Box" << TCollection::DumpSeparator();
|
||||
BVH::ToBndBox (MinPoint (theNodeIndex), MaxPoint (theNodeIndex)).Dump (OS);
|
||||
OS << TCollection::DumpSeparator();
|
||||
|
||||
DUMP_VALUES (OS, "BegPrimitive", BegPrimitive (theNodeIndex));
|
||||
DUMP_VALUES (OS, "EndPrimitive", EndPrimitive (theNodeIndex));
|
||||
DUMP_VALUES (OS, "Level", Level (theNodeIndex));
|
||||
DUMP_VALUES (OS, "IsOuter", IsOuter (theNodeIndex));
|
||||
}
|
||||
|
||||
public: //! @name protected fields
|
||||
|
||||
//! Array of node data records.
|
||||
|
@@ -21,10 +21,12 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <NCollection_Mat4.hxx>
|
||||
#include <NCollection_Vec2.hxx>
|
||||
#include <NCollection_Vec3.hxx>
|
||||
#include <NCollection_Vector.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
// GCC supports shrink function only in C++11 mode
|
||||
@@ -57,6 +59,32 @@ namespace BVH
|
||||
typedef NCollection_Vec3<T> Type;
|
||||
};
|
||||
|
||||
template<class T> Bnd_Box ToBndBox (const T& theType1, const T& theType2)
|
||||
{
|
||||
return Bnd_Box (theType1, 0., 0., theType2, 0., 0.);
|
||||
}
|
||||
|
||||
template<class T> Bnd_Box ToBndBox (const NCollection_Vec2<T>& theType1,
|
||||
const NCollection_Vec2<T>& theType2)
|
||||
{
|
||||
return Bnd_Box (theType1.x(), theType1.y(), 0.,
|
||||
theType2.x(), theType2.y(), 0.);
|
||||
}
|
||||
|
||||
template<class T> Bnd_Box ToBndBox (const NCollection_Vec3<T>& theType1,
|
||||
const NCollection_Vec3<T>& theType2)
|
||||
{
|
||||
return Bnd_Box (theType1.x(), theType1.y(), theType1.z(),
|
||||
theType2.x(), theType2.y(), theType2.z());
|
||||
}
|
||||
|
||||
template<class T> Bnd_Box ToBndBox (const NCollection_Vec4<T>& theType1,
|
||||
const NCollection_Vec4<T>& theType2)
|
||||
{
|
||||
return Bnd_Box (theType1.x(), theType1.y(), theType1.z(),
|
||||
theType2.x(), theType2.y(), theType2.z());
|
||||
}
|
||||
|
||||
template<class T> struct VectorType<T, 4>
|
||||
{
|
||||
typedef NCollection_Vec4<T> Type;
|
||||
|
@@ -35,8 +35,6 @@
|
||||
#include <BinMXCAFDoc_MaterialToolDriver.hxx>
|
||||
#include <BinMXCAFDoc_NoteDriver.hxx>
|
||||
#include <BinMXCAFDoc_NoteBalloonDriver.hxx>
|
||||
#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
|
||||
#include <BinMXCAFDoc_NoteCommentDriver.hxx>
|
||||
#include <BinMXCAFDoc_NotesToolDriver.hxx>
|
||||
#include <BinMXCAFDoc_ShapeToolDriver.hxx>
|
||||
#include <BinMXCAFDoc_ViewDriver.hxx>
|
||||
@@ -78,8 +76,7 @@ void BinMXCAFDoc::AddDrivers(const Handle(BinMDF_ADriverTable)& theDriverTable,
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_DimTolDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_MaterialDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_NoteBalloonDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_NoteBinDataDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_NoteCommentDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_NoteDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_ViewDriver (theMsgDrv));
|
||||
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_ColorToolDriver (theMsgDrv));
|
||||
|
@@ -42,6 +42,9 @@ class BinMXCAFDoc_DimTolToolDriver;
|
||||
class BinMXCAFDoc_MaterialToolDriver;
|
||||
class BinMXCAFDoc_ViewDriver;
|
||||
class BinMXCAFDoc_ViewToolDriver;
|
||||
class BinMXCAFDoc_AnimationDriver;
|
||||
class BinMXCAFDoc_AnimationToolDriver;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -89,6 +92,9 @@ friend class BinMXCAFDoc_DimTolToolDriver;
|
||||
friend class BinMXCAFDoc_MaterialToolDriver;
|
||||
friend class BinMXCAFDoc_ViewDriver;
|
||||
friend class BinMXCAFDoc_ViewToolDriver;
|
||||
friend class BinMXCAFDoc_AnimationDriver;
|
||||
friend class BinMXCAFDoc_AnimationToolDriver;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
112
src/BinMXCAFDoc/BinMXCAFDoc_AnimationDriver.cxx
Normal file
@@ -0,0 +1,112 @@
|
||||
// Created on: 2017-10-02
|
||||
// Created by: Elena MOZOKHINA
|
||||
// Copyright (c) 2016 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 <BinMXCAFDoc_AnimationDriver.hxx>
|
||||
#include <BinObjMgt_Persistent.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <XCAFDoc_Animation.hxx>
|
||||
# include <TColStd_HArray1OfByte.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_AnimationDriver,BinMDF_ADriver)
|
||||
|
||||
static Standard_Boolean getByteArray(const BinObjMgt_Persistent& theSource, Handle(TColStd_HArray1OfByte)& theArray)
|
||||
{
|
||||
Standard_Integer aFirstInd, aLastInd;
|
||||
if (!(theSource >> aFirstInd >> aLastInd))
|
||||
return Standard_False;
|
||||
if (aLastInd < aFirstInd)
|
||||
return Standard_False;
|
||||
|
||||
theArray.reset(new TColStd_HArray1OfByte(aFirstInd, aLastInd - aFirstInd + 1));
|
||||
theSource.GetByteArray(&theArray->ChangeFirst(), aLastInd - aFirstInd + 1);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
static void putByteArray(BinObjMgt_Persistent& theTarget, const Handle(TColStd_HArray1OfByte)& theArray)
|
||||
{
|
||||
if (theArray.IsNull())
|
||||
return;
|
||||
const Standard_Integer aFirstInd = theArray->Lower();
|
||||
const Standard_Integer aLastInd = theArray->Upper();
|
||||
if (aLastInd < aFirstInd)
|
||||
return;
|
||||
|
||||
theTarget << aFirstInd << aLastInd;
|
||||
theTarget.PutByteArray(&theArray->ChangeFirst(), aLastInd - aFirstInd + 1);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BinMXCAFDoc_AnimationDriver::BinMXCAFDoc_AnimationDriver
|
||||
(const Handle(Message_Messenger)& theMsgDriver)
|
||||
: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_Animation)->Name())
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) BinMXCAFDoc_AnimationDriver::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_Animation();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BinMXCAFDoc_AnimationDriver::Paste(const BinObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
BinObjMgt_RRelocationTable& /*theRelocTable*/) const
|
||||
{
|
||||
Handle(XCAFDoc_Animation) anAtt = Handle(XCAFDoc_Animation)::DownCast(theTarget);
|
||||
Standard_Real aDensity;
|
||||
TCollection_AsciiString aName;
|
||||
|
||||
if (!(theSource >> aName))
|
||||
return Standard_False;
|
||||
Handle(TColStd_HArray1OfByte) anImage, anAnimation;
|
||||
if (!getByteArray(theSource, anImage) || anImage.IsNull())
|
||||
return Standard_False;
|
||||
if (!getByteArray(theSource, anAnimation) || anAnimation.IsNull())
|
||||
return Standard_False;
|
||||
anAtt->Set(new TCollection_HAsciiString(aName), anImage, anAnimation);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinMXCAFDoc_AnimationDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
BinObjMgt_Persistent& theTarget,
|
||||
BinObjMgt_SRelocationTable& /*theRelocTable*/) const
|
||||
{
|
||||
Handle(XCAFDoc_Animation) anAtt = Handle(XCAFDoc_Animation)::DownCast(theSource);
|
||||
Handle(TCollection_HAsciiString) aName = anAtt->GetName();
|
||||
if (!aName.IsNull())
|
||||
theTarget << aName->String();
|
||||
|
||||
putByteArray(theTarget, anAtt->GetImage());
|
||||
putByteArray(theTarget, anAtt->GetAnimation());
|
||||
}
|
72
src/BinMXCAFDoc/BinMXCAFDoc_AnimationDriver.hxx
Normal file
@@ -0,0 +1,72 @@
|
||||
// Created on: 2017-10-02
|
||||
// Created by: Elena MOZOKHINA
|
||||
// Copyright (c) 2016 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 _BinMXCAFDoc_AnimationDriver_HeaderFile
|
||||
#define _BinMXCAFDoc_AnimationDriver_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <BinMDF_ADriver.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <BinObjMgt_RRelocationTable.hxx>
|
||||
#include <BinObjMgt_SRelocationTable.hxx>
|
||||
class Message_Messenger;
|
||||
class TDF_Attribute;
|
||||
class BinObjMgt_Persistent;
|
||||
|
||||
|
||||
class BinMXCAFDoc_AnimationDriver;
|
||||
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_AnimationDriver, BinMDF_ADriver)
|
||||
|
||||
|
||||
class BinMXCAFDoc_AnimationDriver : public BinMDF_ADriver
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Standard_EXPORT BinMXCAFDoc_AnimationDriver(const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean Paste (const BinObjMgt_Persistent& theSource, const Handle(TDF_Attribute)& theTarget, BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource, BinObjMgt_Persistent& theTarget, BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_AnimationDriver,BinMDF_ADriver)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _BinMXCAFDoc_AnimationDriver_HeaderFile
|
65
src/BinMXCAFDoc/BinMXCAFDoc_AnimationToolDriver.cxx
Normal file
@@ -0,0 +1,65 @@
|
||||
// Created on: 2017-10-02
|
||||
// Created by: Elena MOZOKHINA
|
||||
// Copyright (c) 2016 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 <BinMXCAFDoc_AnimationToolDriver.hxx>
|
||||
#include <BinObjMgt_Persistent.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <XCAFDoc_AnimationTool.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_AnimationToolDriver, BinMDF_ADriver)
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BinMXCAFDoc_AnimationToolDriver::BinMXCAFDoc_AnimationToolDriver
|
||||
(const Handle(Message_Messenger)& theMsgDriver)
|
||||
: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_AnimationTool)->Name())
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) BinMXCAFDoc_AnimationToolDriver::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_AnimationTool();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BinMXCAFDoc_AnimationToolDriver::Paste
|
||||
(const BinObjMgt_Persistent& /*theSource*/,
|
||||
const Handle(TDF_Attribute)& /*theTarget*/,
|
||||
BinObjMgt_RRelocationTable& /*theRelocTable*/) const
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinMXCAFDoc_AnimationToolDriver::Paste
|
||||
(const Handle(TDF_Attribute)& /*theSource*/,
|
||||
BinObjMgt_Persistent& /*theTarget*/,
|
||||
BinObjMgt_SRelocationTable& /*theRelocTable*/) const {
|
||||
}
|
50
src/BinMXCAFDoc/BinMXCAFDoc_AnimationToolDriver.hxx
Normal file
@@ -0,0 +1,50 @@
|
||||
// Created on: 2017-10-02
|
||||
// Created by: Elena MOZOKHINA
|
||||
// Copyright (c) 2016 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 _BinMXCAFDoc_AnimationToolDriver_HeaderFile
|
||||
#define _BinMXCAFDoc_AnimationToolDriver_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <BinMDF_ADriver.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <BinObjMgt_RRelocationTable.hxx>
|
||||
#include <BinObjMgt_SRelocationTable.hxx>
|
||||
class Message_Messenger;
|
||||
class TDF_Attribute;
|
||||
class BinObjMgt_Persistent;
|
||||
|
||||
|
||||
class BinMXCAFDoc_AnimationToolDriver;
|
||||
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_AnimationToolDriver, BinMDF_ADriver)
|
||||
|
||||
|
||||
class BinMXCAFDoc_AnimationToolDriver : public BinMDF_ADriver
|
||||
{
|
||||
public:
|
||||
|
||||
Standard_EXPORT BinMXCAFDoc_AnimationToolDriver(const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean Paste(const BinObjMgt_Persistent& theSource, const Handle(TDF_Attribute)& theTarget, BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void Paste(const Handle(TDF_Attribute)& theSource, BinObjMgt_Persistent& theTarget, BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_AnimationToolDriver, BinMDF_ADriver)
|
||||
|
||||
};
|
||||
#endif // _BinMXCAFDoc_AnimationToolDriver_HeaderFile
|
@@ -20,14 +20,14 @@
|
||||
#include <BinMXCAFDoc_NoteBalloonDriver.hxx>
|
||||
#include <XCAFDoc_NoteBalloon.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BinMXCAFDoc_NoteBalloonDriver::BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver)
|
||||
: BinMXCAFDoc_NoteCommentDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
|
||||
: BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -40,13 +40,52 @@ Handle(TDF_Attribute) BinMXCAFDoc_NoteBalloonDriver::NewEmpty() const
|
||||
return new XCAFDoc_NoteBalloon();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BinMXCAFDoc_NoteBalloonDriver::Paste(const BinObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
BinObjMgt_RRelocationTable& theRelocTable) const
|
||||
{
|
||||
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
|
||||
return Standard_False;
|
||||
|
||||
Handle(XCAFDoc_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::DownCast(theTarget);
|
||||
if (aNote.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
TCollection_ExtendedString aComment;
|
||||
if (!(theSource >> aComment))
|
||||
return Standard_False;
|
||||
|
||||
aNote->Set(aComment);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinMXCAFDoc_NoteBalloonDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
BinObjMgt_Persistent& theTarget,
|
||||
BinObjMgt_SRelocationTable& theRelocTable) const
|
||||
{
|
||||
BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
|
||||
|
||||
Handle(XCAFDoc_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::DownCast(theSource);
|
||||
if (!aNote.IsNull())
|
||||
theTarget << aNote->Get();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BinMXCAFDoc_NoteBalloonDriver::BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver,
|
||||
Standard_CString theName)
|
||||
: BinMXCAFDoc_NoteCommentDriver(theMsgDriver, theName)
|
||||
: BinMXCAFDoc_NoteDriver(theMsgDriver, theName)
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -16,20 +16,28 @@
|
||||
#ifndef _BinMXCAFDoc_NoteBalloonDriver_HeaderFile
|
||||
#define _BinMXCAFDoc_NoteBalloonDriver_HeaderFile
|
||||
|
||||
#include <BinMXCAFDoc_NoteCommentDriver.hxx>
|
||||
#include <BinMXCAFDoc_NoteDriver.hxx>
|
||||
|
||||
class BinMXCAFDoc_NoteBalloonDriver;
|
||||
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
|
||||
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
|
||||
|
||||
class BinMXCAFDoc_NoteBalloonDriver : public BinMXCAFDoc_NoteCommentDriver
|
||||
class BinMXCAFDoc_NoteBalloonDriver : public BinMXCAFDoc_NoteDriver
|
||||
{
|
||||
public:
|
||||
|
||||
Standard_EXPORT BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
|
||||
|
||||
Standard_EXPORT Standard_Boolean Paste(const BinObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theSource,
|
||||
BinObjMgt_Persistent& theTarget,
|
||||
BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
|
||||
|
||||
|
||||
protected:
|
||||
|
@@ -1,96 +0,0 @@
|
||||
// Created on: 2017-02-13
|
||||
// Created by: Eugeny NIKONOV
|
||||
// Copyright (c) 2005-2017 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 <BinObjMgt_Persistent.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <TColStd_HArray1OfByte.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
|
||||
#include <XCAFDoc_NoteBinData.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BinMXCAFDoc_NoteBinDataDriver::BinMXCAFDoc_NoteBinDataDriver(const Handle(Message_Messenger)& theMsgDriver)
|
||||
: BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBinData)->Name())
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) BinMXCAFDoc_NoteBinDataDriver::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_NoteBinData();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BinMXCAFDoc_NoteBinDataDriver::Paste(const BinObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
BinObjMgt_RRelocationTable& theRelocTable) const
|
||||
{
|
||||
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
|
||||
return Standard_False;
|
||||
|
||||
Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
|
||||
if (aNote.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
TCollection_ExtendedString aTitle;
|
||||
TCollection_AsciiString aMIMEtype;
|
||||
Standard_Integer nbSize;
|
||||
if (!(theSource >> aTitle >> aMIMEtype >> nbSize))
|
||||
return Standard_False;
|
||||
|
||||
Handle(TColStd_HArray1OfByte) aData;
|
||||
if (nbSize > 0)
|
||||
{
|
||||
aData.reset(new TColStd_HArray1OfByte(1, nbSize));
|
||||
theSource.GetByteArray(&aData->ChangeFirst(), nbSize);
|
||||
}
|
||||
|
||||
aNote->Set(aTitle, aMIMEtype, aData);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinMXCAFDoc_NoteBinDataDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
BinObjMgt_Persistent& theTarget,
|
||||
BinObjMgt_SRelocationTable& theRelocTable) const
|
||||
{
|
||||
BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
|
||||
|
||||
Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theSource);
|
||||
if (!aNote.IsNull())
|
||||
{
|
||||
theTarget << aNote->Title() << aNote->MIMEtype() << aNote->Size();
|
||||
if (aNote->Size() > 0)
|
||||
theTarget.PutByteArray(&aNote->Data()->ChangeFirst(), aNote->Size());
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
// Created on: 2017-02-13
|
||||
// Created by: Sergey NIKONOV
|
||||
// Copyright (c) 2005-2017 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 _BinMXCAFDoc_NoteBinDataDriver_HeaderFile
|
||||
#define _BinMXCAFDoc_NoteBinDataDriver_HeaderFile
|
||||
|
||||
#include <BinMXCAFDoc_NoteDriver.hxx>
|
||||
|
||||
class BinMXCAFDoc_NoteBinDataDriver;
|
||||
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
|
||||
|
||||
class BinMXCAFDoc_NoteBinDataDriver : public BinMXCAFDoc_NoteDriver
|
||||
{
|
||||
public:
|
||||
|
||||
Standard_EXPORT BinMXCAFDoc_NoteBinDataDriver(const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theSource,
|
||||
BinObjMgt_Persistent& theTarget,
|
||||
BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
|
||||
|
||||
};
|
||||
|
||||
#endif // _BinMXCAFDoc_NoteBinDataDriver_HeaderFile
|
@@ -1,91 +0,0 @@
|
||||
// Created on: 2017-02-13
|
||||
// Created by: Eugeny NIKONOV
|
||||
// Copyright (c) 2005-2017 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 <BinObjMgt_Persistent.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <BinMXCAFDoc_NoteCommentDriver.hxx>
|
||||
#include <XCAFDoc_NoteComment.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BinMXCAFDoc_NoteCommentDriver::BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver)
|
||||
: BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteComment)->Name())
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) BinMXCAFDoc_NoteCommentDriver::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_NoteComment();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BinMXCAFDoc_NoteCommentDriver::Paste(const BinObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
BinObjMgt_RRelocationTable& theRelocTable) const
|
||||
{
|
||||
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
|
||||
return Standard_False;
|
||||
|
||||
Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theTarget);
|
||||
if (aNote.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
TCollection_ExtendedString aComment;
|
||||
if (!(theSource >> aComment))
|
||||
return Standard_False;
|
||||
|
||||
aNote->Set(aComment);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinMXCAFDoc_NoteCommentDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
BinObjMgt_Persistent& theTarget,
|
||||
BinObjMgt_SRelocationTable& theRelocTable) const
|
||||
{
|
||||
BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
|
||||
|
||||
Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theSource);
|
||||
if (!aNote.IsNull())
|
||||
theTarget << aNote->Comment();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BinMXCAFDoc_NoteCommentDriver::BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
|
||||
Standard_CString theName)
|
||||
: BinMXCAFDoc_NoteDriver(theMsgDriver, theName)
|
||||
{
|
||||
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
// Created on: 2017-02-13
|
||||
// Created by: Sergey NIKONOV
|
||||
// Copyright (c) 2005-2017 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 _BinMXCAFDoc_NoteCommentDriver_HeaderFile
|
||||
#define _BinMXCAFDoc_NoteCommentDriver_HeaderFile
|
||||
|
||||
#include <BinMXCAFDoc_NoteDriver.hxx>
|
||||
|
||||
class BinMXCAFDoc_NoteCommentDriver;
|
||||
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
|
||||
|
||||
class BinMXCAFDoc_NoteCommentDriver : public BinMXCAFDoc_NoteDriver
|
||||
{
|
||||
public:
|
||||
|
||||
Standard_EXPORT BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theSource,
|
||||
BinObjMgt_Persistent& theTarget,
|
||||
BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
|
||||
|
||||
protected:
|
||||
|
||||
BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
|
||||
Standard_CString theName);
|
||||
|
||||
};
|
||||
|
||||
#endif // _BinMXCAFDoc_NoteCommentDriver_HeaderFile
|
@@ -22,6 +22,24 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteDriver, BinMDF_ADriver)
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BinMXCAFDoc_NoteDriver::BinMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& theMsgDriver)
|
||||
: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_Note)->Name())
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) BinMXCAFDoc_NoteDriver::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_Note();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
|
@@ -35,6 +35,10 @@ class BinMXCAFDoc_NoteDriver : public BinMDF_ADriver
|
||||
{
|
||||
public:
|
||||
|
||||
Standard_EXPORT BinMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
@@ -39,10 +39,6 @@ BinMXCAFDoc_NoteDriver.cxx
|
||||
BinMXCAFDoc_NoteDriver.hxx
|
||||
BinMXCAFDoc_NoteBalloonDriver.cxx
|
||||
BinMXCAFDoc_NoteBalloonDriver.hxx
|
||||
BinMXCAFDoc_NoteCommentDriver.cxx
|
||||
BinMXCAFDoc_NoteCommentDriver.hxx
|
||||
BinMXCAFDoc_NoteBinDataDriver.cxx
|
||||
BinMXCAFDoc_NoteBinDataDriver.hxx
|
||||
BinMXCAFDoc_NotesToolDriver.cxx
|
||||
BinMXCAFDoc_NotesToolDriver.hxx
|
||||
BinMXCAFDoc_ShapeToolDriver.cxx
|
||||
@@ -53,3 +49,7 @@ BinMXCAFDoc_ViewToolDriver.cxx
|
||||
BinMXCAFDoc_ViewToolDriver.hxx
|
||||
BinMXCAFDoc_VolumeDriver.cxx
|
||||
BinMXCAFDoc_VolumeDriver.hxx
|
||||
BinMXCAFDoc_AnimationDriver.cxx
|
||||
BinMXCAFDoc_AnimationDriver.hxx
|
||||
BinMXCAFDoc_AnimationToolDriver.cxx
|
||||
BinMXCAFDoc_AnimationToolDriver.hxx
|
||||
|
@@ -20,7 +20,10 @@
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <NCollection_List.hxx>
|
||||
#include <Standard_ConstructionError.hxx>
|
||||
#include <TCollection.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
// set the flag to one
|
||||
#define ClearVoidFlag() ( Flags &= ~VoidMask )
|
||||
@@ -43,6 +46,19 @@ Bnd_Box::Bnd_Box()
|
||||
SetVoid();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Bnd_Box
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Bnd_Box::Bnd_Box (const Standard_Real theXmin, const Standard_Real theYmin, const Standard_Real theZmin,
|
||||
const Standard_Real theXmax, const Standard_Real theYmax, const Standard_Real theZmax)
|
||||
: Gap (0.0)
|
||||
{
|
||||
SetVoid();
|
||||
Update (theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
@@ -957,3 +973,71 @@ void Bnd_Box::Dump () const
|
||||
std::cout << "\n Gap : " << Gap;
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PointsSeparator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString PointsSeparator()
|
||||
{
|
||||
return " - ";
|
||||
}
|
||||
|
||||
|
||||
const TCollection_AsciiString Bnd_Box_ClassName = "Bnd_Box";
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Bnd_Box::Dump (Standard_OStream& OS) const
|
||||
{
|
||||
DUMP_START_KEY (OS, Bnd_Box_ClassName);
|
||||
|
||||
DUMP_VALUES (OS, "Xmin", Xmin);
|
||||
DUMP_VALUES (OS, "Ymin", Ymin);
|
||||
DUMP_VALUES (OS, "Zmin", Zmin);
|
||||
DUMP_VALUES (OS, "Xmax", Xmax);
|
||||
DUMP_VALUES (OS, "Ymax", Ymax);
|
||||
DUMP_VALUES (OS, "Zmax", Zmax);
|
||||
DUMP_VALUES (OS, "Gap", Gap);
|
||||
DUMP_VALUES (OS, "Flags", Flags);
|
||||
|
||||
DUMP_STOP_KEY (OS, Bnd_Box_ClassName);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Bnd_Box::Init (const Standard_SStream& OS)
|
||||
{
|
||||
NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> aStreamValues;
|
||||
TCollection_AsciiString aKey;
|
||||
TCollection::Split (OS, aStreamValues, aKey);
|
||||
|
||||
TCollection_AsciiString aXmin, anYmin, aZmin, aXmax, anYmax, aZmax, aGap, aFlags;
|
||||
if (!aStreamValues.FindFromKey ("Xmin", aXmin) ||
|
||||
!aStreamValues.FindFromKey ("Ymin", anYmin) ||
|
||||
!aStreamValues.FindFromKey ("Zmin", aZmin) ||
|
||||
!aStreamValues.FindFromKey ("Xmax", aXmax) ||
|
||||
!aStreamValues.FindFromKey ("Ymax", anYmax) ||
|
||||
!aStreamValues.FindFromKey ("Zmax", aZmax) ||
|
||||
!aStreamValues.FindFromKey ("Gap", aGap) ||
|
||||
!aStreamValues.FindFromKey ("Flags", aFlags))
|
||||
return Standard_False;
|
||||
|
||||
Xmin = aXmin.RealValue();
|
||||
Ymin = anYmin.RealValue();
|
||||
Zmin = aZmin.RealValue();
|
||||
Xmax = aXmax.RealValue();
|
||||
Ymax = anYmax.RealValue();
|
||||
Zmax = aZmax.RealValue();
|
||||
|
||||
Gap = aGap.RealValue();
|
||||
Flags = aFlags.IntegerValue();
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
@@ -24,6 +24,10 @@
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
|
||||
class Standard_ConstructionError;
|
||||
class gp_Pnt;
|
||||
class gp_Dir;
|
||||
@@ -69,6 +73,14 @@ public:
|
||||
//! The constructed box is qualified Void. Its gap is null.
|
||||
Standard_EXPORT Bnd_Box();
|
||||
|
||||
//! Creates a bounding box, it contains:
|
||||
//! - interval [ aXmin,aXmax ] in the "X Direction",
|
||||
//! - interval [ aYmin,aYmax ] in the "Y Direction",
|
||||
//! - interval [ aZmin,aZmax ] in the "Z Direction";
|
||||
//! The constructed box is qualified Void. Its gap is null.
|
||||
Standard_EXPORT Bnd_Box (const Standard_Real aXmin, const Standard_Real aYmin, const Standard_Real aZmin,
|
||||
const Standard_Real aXmax, const Standard_Real aYmax, const Standard_Real aZmax);
|
||||
|
||||
//! Sets this bounding box so that it covers the whole of 3D space.
|
||||
//! It is infinitely long in all directions.
|
||||
void SetWhole() { Flags = WholeMask; }
|
||||
@@ -296,6 +308,20 @@ public:
|
||||
&& Xmax >= Xmin;
|
||||
}
|
||||
|
||||
//! Dumps the content of me on the stream <OS>.
|
||||
Standard_EXPORT void Dump (Standard_OStream& OS) const;
|
||||
|
||||
//! Dumps the content of me on the stream <OS>.
|
||||
Standard_EXPORT Standard_Boolean Init (const Standard_SStream& OS);
|
||||
|
||||
//! Covers bounding box into string in format: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax)
|
||||
//! \return the string value
|
||||
Standard_EXPORT TCollection_AsciiString ToString() const { return ""; }
|
||||
|
||||
//! Converts text value into parameters if possible, the string format is: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax)
|
||||
//! \return true if conversion is done
|
||||
Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue) { (void)theValue; return Standard_False; }
|
||||
|
||||
protected:
|
||||
|
||||
//! Bit flags.
|
||||
|
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <NCollection_Array1.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TCollection.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
|
||||
//! Auxiliary class to select from the points stored in
|
||||
@@ -992,3 +993,78 @@ void Bnd_OBB::Add(const Bnd_OBB& theOther)
|
||||
ReBuild(TColgp_Array1OfPnt(aList[0], 0, 15));
|
||||
}
|
||||
|
||||
const TCollection_AsciiString Bnd_OBB_ClassName = "Bnd_OBB";
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Bnd_OBB::Dump (Standard_OStream& OS) const
|
||||
{
|
||||
DUMP_START_KEY (OS, Bnd_OBB_ClassName);
|
||||
{
|
||||
Standard_SStream aTmpStream;
|
||||
myCenter.Dump (aTmpStream);
|
||||
DUMP_VALUES (OS, "Center", TCollection::ToDumpString (aTmpStream));
|
||||
}
|
||||
{
|
||||
Standard_SStream aTmpStream;
|
||||
myAxes[0].Dump (aTmpStream);
|
||||
DUMP_VALUES (OS, "XAxis", TCollection::ToDumpString (aTmpStream));
|
||||
}
|
||||
{
|
||||
Standard_SStream aTmpStream;
|
||||
myAxes[1].Dump (aTmpStream);
|
||||
DUMP_VALUES (OS, "YAxis", TCollection::ToDumpString (aTmpStream));
|
||||
}
|
||||
{
|
||||
Standard_SStream aTmpStream;
|
||||
myAxes[2].Dump (aTmpStream);
|
||||
DUMP_VALUES (OS, "ZAxis", TCollection::ToDumpString (aTmpStream));
|
||||
}
|
||||
|
||||
DUMP_VALUES (OS, "XHSize", XHSize());
|
||||
DUMP_VALUES (OS, "YHSize", YHSize());
|
||||
DUMP_VALUES (OS, "ZHSize", ZHSize());
|
||||
DUMP_VALUES (OS, "IsAABox", myIsAABox);
|
||||
|
||||
DUMP_STOP_KEY (OS, Bnd_OBB_ClassName);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Bnd_OBB::Init (const Standard_SStream& /*OS*/)
|
||||
{
|
||||
//NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> aStreamValues;
|
||||
//TCollection::Split (OS, aStreamValues, aKey);
|
||||
|
||||
//TCollection_AsciiString anXYZValue;
|
||||
//if (aStreamValues.Size() == 1)
|
||||
//{
|
||||
// NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString>::Iterator anIterator (aStreamValues);
|
||||
// TCollection_AsciiString aValueStr = anIterator.Value();
|
||||
// Standard_Integer aPosition = aValueStr.Search (Bnd_Box_ClassName + TCollection::ClassNameSeparator());
|
||||
// if (aPosition < 1)
|
||||
// return Standard_False;
|
||||
// anXYZValue = aValueStr.Split (aPosition);
|
||||
//}
|
||||
|
||||
//NCollection_Vector<Standard_Real> aValues;
|
||||
//if (!TCollection::SplitReal (anXYZValue, TCollection::VectorSeparator(), aValues))
|
||||
// return Standard_False;
|
||||
|
||||
//if (aValues.Size() != 8)
|
||||
// return Standard_False;
|
||||
|
||||
//Update (aValues.Value (1), aValues.Value (2), aValues.Value (3), aValues.Value (4), aValues.Value (5), aValues.Value (6));
|
||||
//Gap = aValues.Value (7);
|
||||
//Flags = (Standard_Integer)aValues.Value (8);
|
||||
|
||||
//return Standard_True;
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
@@ -281,6 +282,20 @@ public:
|
||||
//! (which it was created from) and theP.
|
||||
Standard_EXPORT void Add(const gp_Pnt& theP);
|
||||
|
||||
//! Dumps the content of me on the stream <OS>.
|
||||
Standard_EXPORT Standard_Boolean Init (const Standard_SStream& OS);
|
||||
|
||||
//! Dumps the content of me on the stream <OS>.
|
||||
Standard_EXPORT void Dump (Standard_OStream& OS) const;
|
||||
|
||||
//! Covers bounding box into string in format: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax)
|
||||
//! \return the string value
|
||||
Standard_EXPORT TCollection_AsciiString ToString() const { return ""; }
|
||||
|
||||
//! Converts text value into parameters if possible, the string format is: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax)
|
||||
//! \return true if conversion is done
|
||||
Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue) { (void)theValue; return Standard_False; }
|
||||
|
||||
protected:
|
||||
|
||||
void ProcessOnePoint(const gp_Pnt& theP)
|
||||
|
@@ -174,4 +174,13 @@ void Bnd_Range::Split(const Standard_Real theVal,
|
||||
{
|
||||
theList.Append(Bnd_Range(aValPrev, myLast));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString Bnd_Range::ToString() const
|
||||
{
|
||||
return TCollection_AsciiString ("[") + myFirst + ", " + myLast + "]";
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_ConstructionError.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
#include <NCollection_List.hxx>
|
||||
|
||||
@@ -256,6 +257,10 @@ public:
|
||||
return ((myFirst == theOther.myFirst) && (myLast == theOther.myLast));
|
||||
}
|
||||
|
||||
//! Covers point into string in format: [myFirst, myLast]
|
||||
//! \return the string value
|
||||
Standard_EXPORT TCollection_AsciiString ToString() const;
|
||||
|
||||
private:
|
||||
|
||||
Standard_Real myFirst; //!< Start of range
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
@@ -36,7 +37,7 @@ void DsgPrs_XYZAxisPresentation::Add(
|
||||
const Handle(Prs3d_LineAspect)& aLineAspect,
|
||||
const gp_Dir & aDir,
|
||||
const Standard_Real aVal,
|
||||
const Standard_CString aText,
|
||||
const Standard_CString theText,
|
||||
const gp_Pnt& aPfirst,
|
||||
const gp_Pnt& aPlast)
|
||||
{
|
||||
@@ -50,10 +51,12 @@ void DsgPrs_XYZAxisPresentation::Add(
|
||||
|
||||
Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), aPlast,aDir, M_PI/180.*10., aVal/10.);
|
||||
|
||||
if (*aText != '\0')
|
||||
if (*theText != '\0')
|
||||
{
|
||||
Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f/81.0f);
|
||||
aText->SetText (theText);
|
||||
aText->SetPosition (aPlast);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->AddText (aText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +67,7 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta
|
||||
const Handle(Prs3d_TextAspect)& aTextAspect,
|
||||
const gp_Dir & aDir,
|
||||
const Standard_Real aVal,
|
||||
const Standard_CString aText,
|
||||
const Standard_CString theText,
|
||||
const gp_Pnt& aPfirst,
|
||||
const gp_Pnt& aPlast)
|
||||
{
|
||||
@@ -81,9 +84,11 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta
|
||||
|
||||
G->SetPrimitivesAspect(aTextAspect->Aspect());
|
||||
|
||||
if (*aText != '\0')
|
||||
if (*theText != '\0')
|
||||
{
|
||||
Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f/81.0f);
|
||||
aText->SetText (theText);
|
||||
aText->SetPosition (aPlast);
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->AddText(aText);
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
Font.cxx
|
||||
Font.hxx
|
||||
Font_BRepFont.cxx
|
||||
Font_BRepFont.hxx
|
||||
Font_BRepTextBuilder.cxx
|
||||
|
56
src/Font/Font.cxx
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright (c) 2018 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.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
static Standard_CString Font_Table_PrintFontAspect[5] =
|
||||
{
|
||||
"UNDEFINED", "REGULAR", "BOLD", "ITALIC", "BOLD_ITALIC"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FontAspectToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Font::FontAspectToString (Font_FontAspect theType)
|
||||
{
|
||||
return Font_Table_PrintFontAspect[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FontAspectFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Font::FontAspectFromString (Standard_CString theTypeString,
|
||||
Font_FontAspect& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = 0; aTypeIter <= Font_FA_BoldItalic; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Font_Table_PrintFontAspect[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Font_FontAspect (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
54
src/Font/Font.hxx
Normal file
@@ -0,0 +1,54 @@
|
||||
// Copyright (c) 2018 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _Font_HeaderFile
|
||||
#define _Font_HeaderFile
|
||||
|
||||
#include <Font_FontAspect.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
//! Provides methods to cast enumerations of package to string value
|
||||
class Font
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString FontAspectToString (Font_FontAspect theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Aspect_TOFM_BOTH_SIDE if string identifier is invalid
|
||||
static Font_FontAspect FontAspectFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Font_FontAspect aType = Font_FA_Undefined;
|
||||
FontAspectFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean FontAspectFromString (const Standard_CString theTypeString,
|
||||
Font_FontAspect& theType);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // _Font_HeaderFile
|
@@ -15,12 +15,14 @@
|
||||
|
||||
#include <Font_BRepTextBuilder.hxx>
|
||||
|
||||
#include <Font_TextFormatter.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// Function : Perfrom
|
||||
// Purpose :
|
||||
// =======================================================================
|
||||
TopoDS_Shape Font_BRepTextBuilder::Perform (Font_BRepFont& theFont,
|
||||
const Font_TextFormatter& theFormatter,
|
||||
const Handle(Font_TextFormatter)& theFormatter,
|
||||
const gp_Ax3& thePenLoc)
|
||||
{
|
||||
gp_Trsf aTrsf;
|
||||
@@ -31,34 +33,20 @@ TopoDS_Shape Font_BRepTextBuilder::Perform (Font_BRepFont& theFont,
|
||||
|
||||
myBuilder.MakeCompound (aResult);
|
||||
|
||||
Standard_Integer aSymbolCounter = 0;
|
||||
Standard_Real aScaleUnits = theFont.Scale();
|
||||
for (NCollection_Utf8Iter anIter = theFormatter.String().Iterator(); *anIter != 0; ++anIter)
|
||||
Standard_Real aScaleUnits = theFont.Scale();
|
||||
for (Font_TextFormatter::Iterator aFormatterIt (*theFormatter, Font_TextFormatter::IterationFilter_ExcludeInvisible);
|
||||
aFormatterIt .More(); aFormatterIt .Next())
|
||||
{
|
||||
const Standard_Utf32Char aCharCurr = *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)
|
||||
|| aCharCurr == ' '
|
||||
|| aCharCurr == '\t'
|
||||
|| aCharCurr == '\n')
|
||||
{
|
||||
continue; // skip unsupported carriage control codes
|
||||
}
|
||||
const NCollection_Vec2<Standard_ShortReal>& aCorner = theFormatter->BottomLeft (aFormatterIt.SymbolPosition());
|
||||
|
||||
const NCollection_Vec2<Standard_ShortReal>& aCorner = theFormatter.TopLeft (aSymbolCounter);
|
||||
aPen.SetCoord (aCorner.x() * aScaleUnits, aCorner.y() * aScaleUnits, 0.0);
|
||||
aGlyphShape = theFont.RenderGlyph (aCharCurr);
|
||||
aGlyphShape = theFont.RenderGlyph (aFormatterIt.Symbol());
|
||||
if (!aGlyphShape.IsNull())
|
||||
{
|
||||
aTrsf.SetTranslation (gp_Vec (aPen));
|
||||
aGlyphShape.Move (aTrsf);
|
||||
myBuilder.Add (aResult, aGlyphShape);
|
||||
}
|
||||
|
||||
++aSymbolCounter;
|
||||
}
|
||||
|
||||
aTrsf.SetTransformation (thePenLoc, gp_Ax3 (gp::XOY()));
|
||||
@@ -77,13 +65,13 @@ TopoDS_Shape Font_BRepTextBuilder::Perform (Font_BRepFont&
|
||||
const Graphic3d_HorizontalTextAlignment theHAlign,
|
||||
const Graphic3d_VerticalTextAlignment theVAlign)
|
||||
{
|
||||
Font_TextFormatter aFormatter;
|
||||
Handle(Font_TextFormatter) aFormatter = new Font_TextFormatter();
|
||||
|
||||
aFormatter.Reset();
|
||||
aFormatter.SetupAlignment (theHAlign, theVAlign);
|
||||
aFormatter->Reset();
|
||||
aFormatter->SetupAlignment (theHAlign, theVAlign);
|
||||
|
||||
aFormatter.Append (theString, *(reinterpret_cast<Font_FTFont*> (&theFont)));
|
||||
aFormatter.Format();
|
||||
aFormatter->Append (theString, *(reinterpret_cast<Font_FTFont*> (&theFont)));
|
||||
aFormatter->Format();
|
||||
|
||||
return Perform (theFont, aFormatter, thePenLoc);
|
||||
}
|
||||
|
@@ -17,9 +17,10 @@
|
||||
#define Font_BRepTextBuilder_Header
|
||||
|
||||
#include <Font_BRepFont.hxx>
|
||||
#include <Font_TextFormatter.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
|
||||
class Font_TextFormatter;
|
||||
|
||||
//! Represents class for applying text formatting.
|
||||
class Font_BRepTextBuilder
|
||||
{
|
||||
@@ -30,7 +31,7 @@ public:
|
||||
//! @param theFormatter formatter which defines alignment for the text
|
||||
//! @return result shape with pen transformation applied as shape location
|
||||
Standard_EXPORT TopoDS_Shape Perform (Font_BRepFont& theFont,
|
||||
const Font_TextFormatter& theFormatter,
|
||||
const Handle(Font_TextFormatter)& theFormatter,
|
||||
const gp_Ax3& thePenLoc = gp_Ax3());
|
||||
//! Render text as BRep shape.
|
||||
//! @param theString text in UTF-8 encoding
|
||||
|
@@ -17,6 +17,10 @@
|
||||
|
||||
#include <Font_FTFont.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT (Font_TextFormatter, Standard_Transient)
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef NCollection_Vec2<Standard_ShortReal> Vec2f;
|
||||
@@ -55,16 +59,17 @@ Font_TextFormatter::Font_TextFormatter()
|
||||
: myAlignX (Graphic3d_HTA_LEFT),
|
||||
myAlignY (Graphic3d_VTA_TOP),
|
||||
myTabSize (8),
|
||||
myWrappingWidth (0.0f),
|
||||
myLastSymbolWidth (0.0f),
|
||||
myMaxSymbolWidth (0.0f),
|
||||
//
|
||||
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),
|
||||
@@ -94,10 +99,12 @@ void Font_TextFormatter::Reset()
|
||||
myIsFormatted = false;
|
||||
myString.Clear();
|
||||
myPen.x() = myPen.y() = 0.0f;
|
||||
myRectsNb = 0;
|
||||
myLineSpacing = myAscender = 0.0f;
|
||||
myCorners.Clear();
|
||||
myNewLines.Clear();
|
||||
|
||||
myLastSymbolWidth = 0.0f;
|
||||
myMaxSymbolWidth = 0.0f;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -119,16 +126,14 @@ void Font_TextFormatter::Append (const NCollection_String& 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;)
|
||||
Standard_Utf32Char aCharThis;
|
||||
for (Font_TextFormatter::Iterator aFormatterIt (*this); aFormatterIt .More(); aFormatterIt .Next())
|
||||
{
|
||||
const Standard_Utf32Char aCharThis = *anIter;
|
||||
const Standard_Utf32Char aCharNext = *++anIter;
|
||||
aCharThis = aFormatterIt.Symbol();
|
||||
const Standard_Utf32Char aCharNext = aFormatterIt.SymbolNext();
|
||||
|
||||
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)
|
||||
Standard_ShortReal anAdvanceX = 0;
|
||||
if (IsCommandSymbol (aCharThis))
|
||||
{
|
||||
continue; // skip unsupported carriage control codes
|
||||
}
|
||||
@@ -136,79 +141,66 @@ void Font_TextFormatter::Append (const NCollection_String& theString,
|
||||
{
|
||||
aSymbolsCounter = 0;
|
||||
myNewLines.Append (myPen.x());
|
||||
continue; // will be processed on second pass
|
||||
anAdvanceX = 0; // the symbol has null width
|
||||
}
|
||||
else if (aCharThis == ' ')
|
||||
{
|
||||
++aSymbolsCounter;
|
||||
myPen.x() += theFont.AdvanceX (' ', aCharNext);
|
||||
continue;
|
||||
anAdvanceX = theFont.AdvanceX (' ', aCharNext);
|
||||
}
|
||||
else if (aCharThis == '\t')
|
||||
{
|
||||
const Standard_Integer aSpacesNum = (myTabSize - (aSymbolsCounter - 1) % myTabSize);
|
||||
myPen.x() += theFont.AdvanceX (' ', aCharNext) * Standard_ShortReal(aSpacesNum);
|
||||
anAdvanceX = theFont.AdvanceX (' ', aCharNext) * Standard_ShortReal(aSpacesNum);
|
||||
aSymbolsCounter += aSpacesNum;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
anAdvanceX = theFont.AdvanceX (aCharThis, aCharNext);
|
||||
|
||||
++aSymbolsCounter;
|
||||
|
||||
myCorners.Append (myPen);
|
||||
|
||||
myPen.x() += theFont.AdvanceX (aCharThis, aCharNext);
|
||||
|
||||
++myRectsNb;
|
||||
myPen.x() += anAdvanceX;
|
||||
myMaxSymbolWidth = Max (myMaxSymbolWidth, anAdvanceX);
|
||||
}
|
||||
myLastSymbolWidth = myPen.x() - myCorners.Last().x();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : newLine
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Font_TextFormatter::newLine (const Standard_Integer theLastRect)
|
||||
void Font_TextFormatter::newLine (const Standard_Integer theLastRect,
|
||||
const Standard_ShortReal theMaxLineWidth)
|
||||
{
|
||||
if (myRectLineStart >= myRectsNb)
|
||||
Standard_Integer aFirstCornerId = myRectLineStart;
|
||||
Standard_Integer aLastCornerId = theLastRect;
|
||||
|
||||
if (aFirstCornerId >= myCorners.Length())
|
||||
{
|
||||
++myLinesNb;
|
||||
myPenCurrLine -= myLineSpacing;
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_ShortReal aXMin = BottomLeft (aFirstCornerId).x();
|
||||
Font_Rect aBndBox;
|
||||
BndBox (aLastCornerId, aBndBox);
|
||||
Standard_ShortReal aXMax = aBndBox.Right;
|
||||
|
||||
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;
|
||||
}
|
||||
case Graphic3d_HTA_LEFT: myMoveVec.x() = -aXMin; break;
|
||||
case Graphic3d_HTA_RIGHT: myMoveVec.x() = -aXMin + (theMaxLineWidth - (aXMax - aXMin)) - theMaxLineWidth; break;
|
||||
case Graphic3d_HTA_CENTER: myMoveVec.x() = -aXMin + 0.5f * (theMaxLineWidth - (aXMax - aXMin)) - 0.5f * theMaxLineWidth; break;
|
||||
}
|
||||
|
||||
move (myCorners, myMoveVec, myRectLineStart, theLastRect);
|
||||
|
||||
++myLinesNb;
|
||||
myPenCurrLine -= myLineSpacing;
|
||||
myRectLineStart = myRectWordStart = theLastRect + 1;
|
||||
myRectLineStart = theLastRect + 1;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -217,13 +209,13 @@ void Font_TextFormatter::newLine (const Standard_Integer theLastRect)
|
||||
// =======================================================================
|
||||
void Font_TextFormatter::Format()
|
||||
{
|
||||
if (myRectsNb == 0 || myIsFormatted)
|
||||
if (myCorners.Length() == 0 || myIsFormatted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myIsFormatted = true;
|
||||
myLinesNb = myRectLineStart = myRectWordStart = 0;
|
||||
myLinesNb = myRectLineStart = 0;
|
||||
myBndTop = 0.0f;
|
||||
myBndWidth = 0.0f;
|
||||
myMoveVec.x() = myMoveVec.y() = 0.0f;
|
||||
@@ -232,59 +224,56 @@ void Font_TextFormatter::Format()
|
||||
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);
|
||||
Standard_ShortReal aMaxLineWidth = Wrapping();
|
||||
if (HasWrapping())
|
||||
{
|
||||
aMaxLineWidth = Max (aMaxLineWidth, MaximumSymbolWidth()); // it is not possible to wrap less than symbol width
|
||||
}
|
||||
else
|
||||
{
|
||||
if (myNewLines.IsEmpty()) // If only one line
|
||||
aMaxLineWidth = myPen.x();
|
||||
else
|
||||
{
|
||||
for (int aLineIt = 0; aLineIt < myNewLines.Size(); aLineIt++)
|
||||
aMaxLineWidth = Max (aMaxLineWidth, LineWidth (aLineIt));
|
||||
aMaxLineWidth = Max (aMaxLineWidth, LineWidth (myNewLines.Size())); // processing the last line also
|
||||
}
|
||||
}
|
||||
|
||||
for (Font_TextFormatter::Iterator aFormatterIt (*this);
|
||||
aFormatterIt .More(); aFormatterIt .Next())
|
||||
{
|
||||
const Standard_Utf32Char aCharThis = aFormatterIt.Symbol();
|
||||
aRectIter = aFormatterIt.SymbolPosition();
|
||||
|
||||
if (aCharThis == '\x0A') // LF (line feed, new line)
|
||||
{
|
||||
const Standard_Integer aLastRect = aRectIter; // last rect on current line
|
||||
newLine (aLastRect, aMaxLineWidth);
|
||||
++myNewLineNb;
|
||||
continue;
|
||||
}
|
||||
else if (aCharThis == ' '
|
||||
|| aCharThis == '\t')
|
||||
else if (HasWrapping()) // wrap lines longer than maximum width
|
||||
{
|
||||
myRectWordStart = aRectIter;
|
||||
continue;
|
||||
Standard_Integer aFirstCornerId = myRectLineStart;
|
||||
|
||||
Font_Rect aBndBox;
|
||||
BndBox (aRectIter, aBndBox);
|
||||
const Standard_ShortReal aNextXPos = aBndBox.Right - BottomLeft (aFirstCornerId).x();
|
||||
if (aNextXPos > aMaxLineWidth) // wrap the line and do processing of the symbol
|
||||
{
|
||||
const Standard_Integer aLastRect = aRectIter - 1; // last rect on current line
|
||||
newLine (aLastRect, aMaxLineWidth);
|
||||
}
|
||||
}
|
||||
|
||||
++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);
|
||||
newLine (myCorners.Length() - 1, aMaxLineWidth);
|
||||
|
||||
// apply vertical alignment style
|
||||
if (myAlignY == Graphic3d_VTA_BOTTOM)
|
||||
@@ -302,6 +291,126 @@ void Font_TextFormatter::Format()
|
||||
|
||||
if (myAlignY != Graphic3d_VTA_TOP)
|
||||
{
|
||||
moveY (myCorners, myBndTop, 0, myRectsNb - 1);
|
||||
moveY (myCorners, myBndTop, 0, myCorners.Length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : BndBox
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Font_TextFormatter::BndBox (const Standard_Integer theIndex, Font_Rect& theBndBox) const
|
||||
{
|
||||
if (theIndex < 0 || theIndex >= Corners().Size())
|
||||
return Standard_False;
|
||||
|
||||
const NCollection_Vec2<Standard_ShortReal>& aLeftCorner = BottomLeft (theIndex);
|
||||
if (theIndex + 1 < myCorners.Length()) // not the last symbol
|
||||
{
|
||||
const NCollection_Vec2<Standard_ShortReal>& aNextLeftCorner = BottomLeft (theIndex + 1);
|
||||
theBndBox.Left = aLeftCorner.x();
|
||||
theBndBox.Bottom = aLeftCorner.y();
|
||||
theBndBox.Top = theBndBox.Bottom + myLineSpacing;
|
||||
if (Abs (aLeftCorner.y() - aNextLeftCorner.y()) < Precision::Confusion()) // in the same row
|
||||
{
|
||||
theBndBox.Right = aNextLeftCorner.x();
|
||||
}
|
||||
else
|
||||
{
|
||||
// the next symbol is on the next row either by '\n' or by wrapping
|
||||
Standard_ShortReal aLineWidth = LineWidth (LineIndex (theIndex));
|
||||
theBndBox.Left = aLeftCorner.x();
|
||||
switch (myAlignX)
|
||||
{
|
||||
case Graphic3d_HTA_LEFT: theBndBox.Right = aLineWidth; break;
|
||||
case Graphic3d_HTA_RIGHT: theBndBox.Right = myBndWidth; break;
|
||||
case Graphic3d_HTA_CENTER: theBndBox.Right = 0.5f * (myBndWidth + aLineWidth); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // the last symbol
|
||||
{
|
||||
theBndBox.Left = aLeftCorner.x();
|
||||
theBndBox.Right = aLeftCorner.x() + myLastSymbolWidth;
|
||||
theBndBox.Bottom = aLeftCorner.y();
|
||||
theBndBox.Top = theBndBox.Bottom + myLineSpacing;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// function : IsLFSymbol
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Font_TextFormatter::IsLFSymbol (const Standard_Integer theIndex) const
|
||||
{
|
||||
Font_Rect aBndBox;
|
||||
if (!BndBox (theIndex, aBndBox))
|
||||
return Standard_False;
|
||||
|
||||
return Abs (aBndBox.Right - aBndBox.Left) < Precision::Confusion();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FirstPosition
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_ShortReal Font_TextFormatter::FirstPosition() const
|
||||
{
|
||||
switch (myAlignX)
|
||||
{
|
||||
default:
|
||||
case Graphic3d_HTA_LEFT: return 0; break;
|
||||
case Graphic3d_HTA_RIGHT: return myBndWidth; break;
|
||||
case Graphic3d_HTA_CENTER: return 0.5f * myBndWidth; break;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : LinePositionIndex
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Font_TextFormatter::LinePositionIndex (const Standard_Integer theIndex) const
|
||||
{
|
||||
Standard_Integer anIndex = 0;
|
||||
|
||||
Standard_ShortReal anIndexHeight = BottomLeft (theIndex).y();
|
||||
for (Standard_Integer aPrevIndex = theIndex-1; aPrevIndex >= 0; aPrevIndex--)
|
||||
{
|
||||
if (BottomLeft (aPrevIndex).y() > anIndexHeight)
|
||||
break;
|
||||
anIndex++;
|
||||
}
|
||||
return anIndex;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : LineIndex
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Integer Font_TextFormatter::LineIndex (const Standard_Integer theIndex) const
|
||||
{
|
||||
if (myLineSpacing < 0.0f)
|
||||
return 0;
|
||||
|
||||
return (Standard_Integer)Abs((BottomLeft (theIndex).y() + myAscender) / myLineSpacing);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : LineWidth
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_ShortReal Font_TextFormatter::LineWidth (const Standard_Integer theIndex) const
|
||||
{
|
||||
if (theIndex < 0)
|
||||
return 0;
|
||||
|
||||
if (theIndex < myNewLines.Length())
|
||||
return theIndex == 0 ? myNewLines[0] : myNewLines[theIndex] - myNewLines[theIndex -1];
|
||||
|
||||
if (theIndex == myNewLines.Length()) // the last line
|
||||
return theIndex == 0 ? myPen.x() : myPen.x() - myNewLines[theIndex -1];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -25,10 +25,111 @@
|
||||
|
||||
class Font_FTFont;
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Font_TextFormatter, Standard_Transient)
|
||||
|
||||
//! This class intended to prepare formatted text.
|
||||
class Font_TextFormatter
|
||||
//! Case of the formatter using:
|
||||
//! Handle(Font_TextFormatter) aFormatter = new Font_TextFormatter();
|
||||
//! aFormatter->Append(text_1, aFont1);
|
||||
//! aFormatter->Append(text_2, aFont2);
|
||||
//! aFormatter->Format();
|
||||
//!
|
||||
//! Example of corners indices for the text:
|
||||
//! "row_1\n" - 0-5
|
||||
//! "\n" - 6
|
||||
//! "\n" - 7
|
||||
//! "row_2\n" - 8-13
|
||||
//! Processing of \n symbol:
|
||||
//! - it is placed on the row where it appears
|
||||
//! - BndBox for \n has zero width
|
||||
//! - if the last symbol is \n, use LastBndBox() to get position on the next row
|
||||
//!
|
||||
//! Pay attention that fonts should have the same LineSpacing value
|
||||
//!
|
||||
class Font_TextFormatter : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
//! Iteration filter flags. Command symbols are skipped with any filter.
|
||||
enum IterationFilter
|
||||
{
|
||||
IterationFilter_None = 0x0000, //!< no filter
|
||||
IterationFilter_ExcludeInvisible = 0x0002, //!< exclude ' ', '\t', '\n'
|
||||
};
|
||||
|
||||
//! Iterator through light sources.
|
||||
class Iterator
|
||||
{
|
||||
public:
|
||||
//! Constructor with initialization.
|
||||
Iterator (const Font_TextFormatter& theFormatter,
|
||||
IterationFilter theFilter = IterationFilter_None)
|
||||
: myFilter (theFilter), myIter (theFormatter.myString.Iterator())
|
||||
{
|
||||
mySymbolPosition = readNextSymbol (-1, mySymbolChar);
|
||||
mySymbolNext = readNextSymbol (mySymbolPosition, mySymbolCharNext);
|
||||
}
|
||||
|
||||
//! Returns TRUE if iterator points to a valid item.
|
||||
Standard_Boolean More() const { return mySymbolPosition >= 0; }
|
||||
|
||||
//! Returns TRUE if next item exists
|
||||
Standard_Boolean HasNext() const { return mySymbolNext >= 0; }
|
||||
|
||||
//! Returns current symbol.
|
||||
Standard_Utf32Char Symbol() const { return mySymbolChar; }
|
||||
|
||||
//! Returns the next symbol if exists.
|
||||
Standard_Utf32Char SymbolNext() const { return mySymbolCharNext; }
|
||||
|
||||
//! Returns current symbol position.
|
||||
Standard_Integer SymbolPosition() const { return mySymbolPosition; }
|
||||
|
||||
//! Returns the next symbol position.
|
||||
Standard_Integer SymbolPositionNext() const { return mySymbolNext; }
|
||||
|
||||
//! Moves to the next item.
|
||||
void Next()
|
||||
{
|
||||
mySymbolPosition = mySymbolNext;
|
||||
mySymbolChar = mySymbolCharNext;
|
||||
mySymbolNext = readNextSymbol (mySymbolPosition, mySymbolCharNext);
|
||||
}
|
||||
|
||||
protected:
|
||||
Standard_Integer readNextSymbol (const Standard_Integer aSymbolStartingFrom, Standard_Utf32Char& theSymbolChar)
|
||||
{
|
||||
Standard_Integer aNextSymbol = aSymbolStartingFrom;
|
||||
for (; *myIter != 0; ++myIter)
|
||||
{
|
||||
const Standard_Utf32Char aCharCurr = *myIter;
|
||||
if (Font_TextFormatter::IsCommandSymbol (aCharCurr))
|
||||
{
|
||||
continue; // skip unsupported carriage control codes
|
||||
}
|
||||
aNextSymbol++;
|
||||
if ((myFilter & IterationFilter_ExcludeInvisible) != 0)
|
||||
{
|
||||
if (aCharCurr == '\x0A'|| // LF (line feed, new line)
|
||||
aCharCurr == ' ' ||
|
||||
aCharCurr == '\t')
|
||||
continue;
|
||||
}
|
||||
++myIter;
|
||||
theSymbolChar = aCharCurr;
|
||||
return aNextSymbol; // found the first next, not command and not filtered symbol
|
||||
}
|
||||
return -1; // the next symbol is not found
|
||||
}
|
||||
|
||||
protected:
|
||||
IterationFilter myFilter; //!< possibility to filter not-necessary symbols
|
||||
|
||||
NCollection_Utf8Iter myIter; //!< the next symbol iterator value over the text formatter string
|
||||
Standard_Integer mySymbolPosition; //!< the current position
|
||||
Standard_Utf32Char mySymbolChar; //!< the current symbol
|
||||
Standard_Integer mySymbolNext; //!< position of the next symbol in iterator, if zero, the iterator is finished
|
||||
Standard_Utf32Char mySymbolCharNext; //!< the current symbol
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
Standard_EXPORT Font_TextFormatter();
|
||||
@@ -49,16 +150,32 @@ public:
|
||||
Standard_EXPORT void Format();
|
||||
|
||||
//! Returns specific glyph rectangle.
|
||||
inline const NCollection_Vec2<Standard_ShortReal>& TopLeft (const Standard_Integer theIndex) const
|
||||
{
|
||||
return myCorners.Value (theIndex);
|
||||
}
|
||||
inline const NCollection_Vec2<Standard_ShortReal>& BottomLeft (const Standard_Integer theIndex) const
|
||||
{ return myCorners.Value (theIndex); }
|
||||
|
||||
//! Returns current rendering string.
|
||||
inline const NCollection_String& String() const
|
||||
{
|
||||
return myString;
|
||||
}
|
||||
//! Returns symbol bounding box
|
||||
//! @param bounding box.
|
||||
Standard_EXPORT Standard_Boolean BndBox (const Standard_Integer theIndex, Font_Rect& theBndBox) const;
|
||||
|
||||
//! Returns the line height
|
||||
//! \param theIndex a line index, obtained by LineIndex()
|
||||
Standard_ShortReal LineHeight (const Standard_Integer theIndex) const
|
||||
{ return theIndex == 0 ? myAscender : myLineSpacing; }
|
||||
|
||||
//!< Returns width of a line
|
||||
Standard_EXPORT Standard_ShortReal LineWidth (const Standard_Integer theIndex) const;
|
||||
|
||||
//! Returns true if the symbol by the index is '\n'. The width of the symbol is zero.
|
||||
Standard_EXPORT Standard_Boolean IsLFSymbol (const Standard_Integer theIndex) const;
|
||||
|
||||
//! Returns position of the first symbol in a line using alignment
|
||||
Standard_EXPORT Standard_ShortReal FirstPosition() const;
|
||||
|
||||
//! Returns column index of the corner index in the current line
|
||||
Standard_EXPORT Standard_Integer LinePositionIndex (const Standard_Integer theIndex) const;
|
||||
|
||||
//! Returns row index of the corner index among text lines
|
||||
Standard_EXPORT Standard_Integer LineIndex (const Standard_Integer theIndex) const;
|
||||
|
||||
//! Returns tab size.
|
||||
inline Standard_Integer TabSize() const
|
||||
@@ -66,6 +183,21 @@ public:
|
||||
return myTabSize;
|
||||
}
|
||||
|
||||
//!< Returns horizontal alignment style
|
||||
Graphic3d_HorizontalTextAlignment HorizontalTextAlignment() const { return myAlignX; }
|
||||
|
||||
//!< Returns vertical alignment style
|
||||
Graphic3d_VerticalTextAlignment VerticalTextAlignment() const { return myAlignY; }
|
||||
|
||||
//!< Sets text wrapping width, zero means that the text is not bounded by width
|
||||
void SetWrapping (const Standard_ShortReal theWidth) { myWrappingWidth = theWidth; }
|
||||
|
||||
//!< Returns text maximum width, zero means that the text is not bounded by width
|
||||
Standard_Boolean HasWrapping() const { return myWrappingWidth > 0; }
|
||||
|
||||
//!< Returns text maximum width, zero means that the text is not bounded by width
|
||||
Standard_ShortReal Wrapping() const { return myWrappingWidth; }
|
||||
|
||||
//! @return width of formatted text.
|
||||
inline Standard_ShortReal ResultWidth() const
|
||||
{
|
||||
@@ -78,6 +210,9 @@ public:
|
||||
return myLineSpacing * Standard_ShortReal(myLinesNb);
|
||||
}
|
||||
|
||||
//!< @return maximum width of the text symbol
|
||||
inline Standard_ShortReal MaximumSymbolWidth() const { return myMaxSymbolWidth; }
|
||||
|
||||
//! @param bounding box.
|
||||
inline void BndBox (Font_Rect& theBndBox) const
|
||||
{
|
||||
@@ -98,16 +233,40 @@ public:
|
||||
theBndBox.Bottom = theBndBox.Top - myLineSpacing * Standard_ShortReal(myLinesNb);
|
||||
}
|
||||
|
||||
//!< Returns internal container of the top left corners of a formatted rectangles.
|
||||
const NCollection_Vector < NCollection_Vec2<Standard_ShortReal> >& Corners() const { return myCorners; }
|
||||
|
||||
const NCollection_Vector<Standard_ShortReal>& NewLines() const { return myNewLines; }
|
||||
|
||||
//!< Returns true if the symbol is CR, BEL, FF, NP, BS or VT
|
||||
static inline Standard_Boolean IsCommandSymbol (const Standard_Utf32Char& theSymbol)
|
||||
{
|
||||
if (theSymbol == '\x0D' // CR (carriage return)
|
||||
|| theSymbol == '\a' // BEL (alarm)
|
||||
|| theSymbol == '\f' // FF (form feed) NP (new page)
|
||||
|| theSymbol == '\b' // BS (backspace)
|
||||
|| theSymbol == '\v') // VT (vertical tab)
|
||||
return Standard_True;
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT (Font_TextFormatter, Standard_Transient)
|
||||
|
||||
protected: //! @name class auxiliary methods
|
||||
|
||||
//! Move glyphs on the current line to correct position.
|
||||
Standard_EXPORT void newLine (const Standard_Integer theLastRect);
|
||||
Standard_EXPORT void newLine (const Standard_Integer theLastRect,
|
||||
const Standard_ShortReal theMaxLineWidth);
|
||||
|
||||
protected: //! @name configuration
|
||||
|
||||
Graphic3d_HorizontalTextAlignment myAlignX; //!< horizontal alignment style
|
||||
Graphic3d_VerticalTextAlignment myAlignY; //!< vertical alignment style
|
||||
Standard_Integer myTabSize; //!< horizontal tabulation width (number of space symbols)
|
||||
Standard_ShortReal myWrappingWidth; //!< text is wrapped by the width if it is defined (more 0)
|
||||
Standard_ShortReal myLastSymbolWidth; //!< width of the last symbol
|
||||
Standard_ShortReal myMaxSymbolWidth; //!< maximum symbol width of the formatter string
|
||||
|
||||
protected: //! @name input data
|
||||
|
||||
@@ -116,18 +275,16 @@ protected: //! @name input data
|
||||
myPen; //!< current pen position
|
||||
NCollection_Vector < NCollection_Vec2<Standard_ShortReal> >
|
||||
myCorners; //!< The top left corners of a formatted rectangles.
|
||||
Standard_Integer myRectsNb; //!< rectangles number
|
||||
NCollection_Vector<Standard_ShortReal>
|
||||
myNewLines; //!< position at LF
|
||||
Standard_ShortReal myLineSpacing; //!< line spacing (computed as maximum of all fonts involved in text formatting)
|
||||
Standard_ShortReal myAscender; //!<
|
||||
Standard_ShortReal myAscender; //!< line spacing for the first line
|
||||
bool myIsFormatted; //!< formatting state
|
||||
|
||||
protected: //! @name temporary variables for formatting routines
|
||||
|
||||
Standard_Integer myLinesNb; //!< overall (new)lines number (including splitting by width limit)
|
||||
Standard_Integer myRectLineStart; //!< id of first rectangle on the current line
|
||||
Standard_Integer myRectWordStart; //!< id of first rectangle in the current word
|
||||
Standard_Integer myNewLineNb;
|
||||
|
||||
Standard_ShortReal myPenCurrLine; //!< current baseline position
|
||||
@@ -135,6 +292,8 @@ protected: //! @name temporary variables for formatting routines
|
||||
Standard_ShortReal myBndWidth;
|
||||
NCollection_Vec2<Standard_ShortReal>
|
||||
myMoveVec; //!< local variable
|
||||
|
||||
friend Iterator;
|
||||
};
|
||||
|
||||
#endif // Font_TextFormatter_Header
|
||||
|
@@ -593,6 +593,12 @@ void GCPnts_TangentialDeflection::PerformCurve (const TheCurve& C)
|
||||
{
|
||||
U1 = parameters(i);
|
||||
U2 = parameters(i + 1);
|
||||
|
||||
if (U2 - U1 <= uTol)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check maximal deflection on interval;
|
||||
Standard_Real dmax = 0.;
|
||||
Standard_Real umax = 0.;
|
||||
|
@@ -1,3 +1,5 @@
|
||||
Graphic3d.cxx
|
||||
Graphic3d.hxx
|
||||
Graphic3d_AlphaMode.hxx
|
||||
Graphic3d_ArrayFlags.hxx
|
||||
Graphic3d_ArrayOfPoints.hxx
|
||||
@@ -50,6 +52,15 @@ Graphic3d_ClipPlane.hxx
|
||||
Graphic3d_CStructure.cxx
|
||||
Graphic3d_CStructure.hxx
|
||||
Graphic3d_CTexture.hxx
|
||||
Graphic3d_CubeMap.cxx
|
||||
Graphic3d_CubeMap.hxx
|
||||
Graphic3d_CubeMapOrder.cxx
|
||||
Graphic3d_CubeMapOrder.hxx
|
||||
Graphic3d_CubeMapPacked.cxx
|
||||
Graphic3d_CubeMapPacked.hxx
|
||||
Graphic3d_CubeMapSeparate.cxx
|
||||
Graphic3d_CubeMapSeparate.hxx
|
||||
Graphic3d_CubeMapSide.hxx
|
||||
Graphic3d_CullingTool.cxx
|
||||
Graphic3d_CullingTool.hxx
|
||||
Graphic3d_CView.cxx
|
||||
@@ -103,6 +114,7 @@ Graphic3d_NameOfTexture2D.hxx
|
||||
Graphic3d_NameOfTextureEnv.hxx
|
||||
Graphic3d_NameOfTexturePlane.hxx
|
||||
Graphic3d_NMapOfTransient.hxx
|
||||
Graphic3d_PolygonOffset.cxx
|
||||
Graphic3d_PolygonOffset.hxx
|
||||
Graphic3d_PriorityDefinitionError.hxx
|
||||
Graphic3d_RenderingMode.hxx
|
||||
@@ -129,6 +141,8 @@ Graphic3d_StructureDefinitionError.hxx
|
||||
Graphic3d_StructureManager.cxx
|
||||
Graphic3d_StructureManager.hxx
|
||||
Graphic3d_TextPath.hxx
|
||||
Graphic3d_Text.cxx
|
||||
Graphic3d_Text.hxx
|
||||
Graphic3d_Texture1D.cxx
|
||||
Graphic3d_Texture1D.hxx
|
||||
Graphic3d_Texture1Dmanual.cxx
|
||||
|
521
src/Graphic3d/Graphic3d.cxx
Normal file
@@ -0,0 +1,521 @@
|
||||
// Copyright (c) 2018 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 <Graphic3d.hxx>
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
static Standard_CString Graphic3d_Table_PrintZLayerId[6] =
|
||||
{
|
||||
"UNKNOWN", "DEFAULT", "TOP", "TOPMOST", "TOP_OSD", "BOT_OSD"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintHorizontalTextAlignment[3] =
|
||||
{
|
||||
"LEFT", "CENTER", "RIGHT"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintVerticalTextAlignment[4] =
|
||||
{
|
||||
"BOTTOM", "CENTER", "TOP", "TOP_FIRST_LINE"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintTextPath[4] =
|
||||
{
|
||||
"UP", "DOWN", "LEFT", "RIGHT"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintAlphaMode[4] =
|
||||
{
|
||||
"BLEND_AUTO", "OPAQUE", "MASK", "BLEND"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintTypeOfShadingModel[5] =
|
||||
{
|
||||
"DEFAULT", "UNLIT", "FACET", "VERTEX", "FRAGMENT"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintTypeOfAttribute[5] =
|
||||
{
|
||||
"POS", "NORM", "UV", "COLOR", "CUSTOM"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintTypeOfData[7] =
|
||||
{
|
||||
"USHORT", "UINT", "VEC2", "VEC3", "VEC4", "VEC4UB", "FLOAT"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintTransModeFlags[6] =
|
||||
{
|
||||
"NONE", "ZOOM_PERS", "ROTATE_PERS", "TRIEDRON_PERS", "2d", "ZOOM_ROTATE_PERS"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintCameraProjection[5] =
|
||||
{
|
||||
"ORTHOGRAPHIC", "PERSPECTIVE", "STEREO", "MONOLEFTEYE", "MONORIGHTEYE"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintFocusType[2] =
|
||||
{
|
||||
"ABSOLUTE", "RELATIVE"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintIODType[2] =
|
||||
{
|
||||
"ABSOLUTE", "RELATIVE"
|
||||
};
|
||||
|
||||
static Standard_CString Graphic3d_Table_PrintNameOfMaterial[26] =
|
||||
{
|
||||
"BRASS", "BRONZE", "COPPER", "GOLD", "PEWTER", "PLASTER", "PLASTIC", "SILVER", // 8
|
||||
"STEEL", "STONE", "SHINY_PLASTIC", "SATIN", "METALIZED", "NEON_GNC", "CHROME", // 7
|
||||
"ALUMINIUM", "OBSIDIAN", "NEON_PHC", "JADE", "CHARCOAL", "WATER", "GLASS", // 7
|
||||
"DIAMOND", "TRANSPARENT", "DEFAULT", "UserDefined" // 4
|
||||
};
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ZLayerIdToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId theType)
|
||||
{
|
||||
switch (theType)
|
||||
{
|
||||
case Graphic3d_ZLayerId_UNKNOWN: return Graphic3d_Table_PrintZLayerId[0]; break;
|
||||
case Graphic3d_ZLayerId_Default: return Graphic3d_Table_PrintZLayerId[1]; break;
|
||||
case Graphic3d_ZLayerId_Top: return Graphic3d_Table_PrintZLayerId[2]; break;
|
||||
case Graphic3d_ZLayerId_Topmost: return Graphic3d_Table_PrintZLayerId[3]; break;
|
||||
case Graphic3d_ZLayerId_TopOSD: return Graphic3d_Table_PrintZLayerId[4]; break;
|
||||
case Graphic3d_ZLayerId_BotOSD: return Graphic3d_Table_PrintZLayerId[5]; break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ZLayerIdFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::ZLayerIdFromString (Standard_CString theTypeString,
|
||||
Graphic3d_ZLayerId& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = 0; aTypeIter <= 5; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintZLayerId[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
switch (aTypeIter)
|
||||
{
|
||||
case 0: theType = Graphic3d_ZLayerId_UNKNOWN; break;
|
||||
case 1: theType = Graphic3d_ZLayerId_Default; break;
|
||||
case 2: theType = Graphic3d_ZLayerId_Top; break;
|
||||
case 3: theType = Graphic3d_ZLayerId_Topmost; break;
|
||||
case 4: theType = Graphic3d_ZLayerId_TopOSD; break;
|
||||
case 5: theType = Graphic3d_ZLayerId_BotOSD; break;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
if (aName.IsIntegerValue())
|
||||
{
|
||||
theType = aName.IntegerValue();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HorizontalTextAlignmentToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::HorizontalTextAlignmentToString (Graphic3d_HorizontalTextAlignment theType)
|
||||
{
|
||||
return Graphic3d_Table_PrintHorizontalTextAlignment[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HorizontalTextAlignmentFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::HorizontalTextAlignmentFromString (Standard_CString theTypeString,
|
||||
Graphic3d_HorizontalTextAlignment& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Graphic3d_HTA_LEFT; aTypeIter <= Graphic3d_HTA_RIGHT; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintHorizontalTextAlignment[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Graphic3d_HorizontalTextAlignment (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VerticalTextAlignmentToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::VerticalTextAlignmentToString (Graphic3d_VerticalTextAlignment theType)
|
||||
{
|
||||
return Graphic3d_Table_PrintVerticalTextAlignment[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VerticalTextAlignmentFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::VerticalTextAlignmentFromString (Standard_CString theTypeString,
|
||||
Graphic3d_VerticalTextAlignment& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Graphic3d_VTA_BOTTOM; aTypeIter <= Graphic3d_VTA_TOPFIRSTLINE; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintVerticalTextAlignment[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Graphic3d_VerticalTextAlignment (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TextPathToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::TextPathToString (Graphic3d_TextPath theType)
|
||||
{
|
||||
return Graphic3d_Table_PrintTextPath[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TextPathFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::TextPathFromString (Standard_CString theTypeString,
|
||||
Graphic3d_TextPath& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Graphic3d_TP_UP; aTypeIter <= Graphic3d_TP_RIGHT; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintTextPath[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Graphic3d_TextPath (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AlphaModeToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::AlphaModeToString (Graphic3d_AlphaMode theType)
|
||||
{
|
||||
return Graphic3d_Table_PrintAlphaMode[theType + 1];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AlphaModeFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::AlphaModeFromString (Standard_CString theTypeString,
|
||||
Graphic3d_AlphaMode& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Graphic3d_AlphaMode_BlendAuto; aTypeIter <= Graphic3d_AlphaMode_Blend; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintAlphaMode[aTypeIter + 1];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Graphic3d_AlphaMode (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfShadingModelToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::TypeOfShadingModelToString (Graphic3d_TypeOfShadingModel theType)
|
||||
{
|
||||
return Graphic3d_Table_PrintTypeOfShadingModel[theType + 1];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfShadingModelFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::TypeOfShadingModelFromString (Standard_CString theTypeString,
|
||||
Graphic3d_TypeOfShadingModel& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Graphic3d_TOSM_DEFAULT; aTypeIter <= Graphic3d_TOSM_FRAGMENT; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintTypeOfShadingModel[aTypeIter + 1];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Graphic3d_TypeOfShadingModel (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfAttributeToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::TypeOfAttributeToString (Graphic3d_TypeOfAttribute theType)
|
||||
{
|
||||
return Graphic3d_Table_PrintTypeOfAttribute[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfAttributeFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::TypeOfAttributeFromString (Standard_CString theTypeString,
|
||||
Graphic3d_TypeOfAttribute& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Graphic3d_TOA_POS; aTypeIter <= Graphic3d_TOA_CUSTOM; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintTypeOfAttribute[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Graphic3d_TypeOfAttribute (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfDataToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::TypeOfDataToString (Graphic3d_TypeOfData theType)
|
||||
{
|
||||
return Graphic3d_Table_PrintTypeOfData[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TypeOfDataFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::TypeOfDataFromString (Standard_CString theTypeString,
|
||||
Graphic3d_TypeOfData& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Graphic3d_TOD_USHORT; aTypeIter <= Graphic3d_TOD_FLOAT; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintTypeOfData[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Graphic3d_TypeOfData (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TransModeFlagsToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::TransModeFlagsToString (Graphic3d_TransModeFlags theType)
|
||||
{
|
||||
switch (theType)
|
||||
{
|
||||
case Graphic3d_TMF_None: return Graphic3d_Table_PrintTransModeFlags[0]; break;
|
||||
case Graphic3d_TMF_ZoomPers: return Graphic3d_Table_PrintTransModeFlags[1]; break;
|
||||
case Graphic3d_TMF_RotatePers: return Graphic3d_Table_PrintTransModeFlags[2]; break;
|
||||
case Graphic3d_TMF_TriedronPers: return Graphic3d_Table_PrintTransModeFlags[3]; break;
|
||||
case Graphic3d_TMF_2d: return Graphic3d_Table_PrintTransModeFlags[4]; break;
|
||||
case Graphic3d_TMF_ZoomRotatePers: return Graphic3d_Table_PrintTransModeFlags[5]; break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ZLayerIdFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::TransModeFlagsFromString (Standard_CString theTypeString,
|
||||
Graphic3d_TransModeFlags& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = 0; aTypeIter <= 5; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintTransModeFlags[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
switch (aTypeIter)
|
||||
{
|
||||
case 0: theType = Graphic3d_TMF_None; break;
|
||||
case 1: theType = Graphic3d_TMF_ZoomPers; break;
|
||||
case 2: theType = Graphic3d_TMF_RotatePers; break;
|
||||
case 3: theType = Graphic3d_TMF_TriedronPers; break;
|
||||
case 4: theType = Graphic3d_TMF_2d; break;
|
||||
case 5: theType = Graphic3d_TMF_ZoomRotatePers; break;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CameraProjectionToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::CameraProjectionToString (Graphic3d_Camera::Projection theType)
|
||||
{
|
||||
return Graphic3d_Table_PrintCameraProjection[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CameraProjectionFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::CameraProjectionFromString (Standard_CString theTypeString,
|
||||
Graphic3d_Camera::Projection& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Graphic3d_Camera::Projection_Orthographic;
|
||||
aTypeIter <= Graphic3d_Camera::Projection_MonoRightEye; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintCameraProjection[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Graphic3d_Camera::Projection (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CameraFocusTypeToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::CameraFocusTypeToString (Graphic3d_Camera::FocusType theType)
|
||||
{
|
||||
return Graphic3d_Table_PrintFocusType[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FocusTypeFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::CameraFocusTypeFromString (Standard_CString theTypeString,
|
||||
Graphic3d_Camera::FocusType& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Graphic3d_Camera::FocusType_Absolute;
|
||||
aTypeIter <= Graphic3d_Camera::FocusType_Relative; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintFocusType[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Graphic3d_Camera::FocusType (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CameraIODTypeToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::CameraIODTypeToString (Graphic3d_Camera::IODType theType)
|
||||
{
|
||||
return Graphic3d_Table_PrintIODType[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IODTypeFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::CameraIODTypeFromString (Standard_CString theTypeString,
|
||||
Graphic3d_Camera::IODType& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Graphic3d_Camera::IODType_Absolute;
|
||||
aTypeIter <= Graphic3d_Camera::IODType_Relative; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintIODType[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Graphic3d_Camera::IODType (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NameOfMaterialToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Graphic3d::NameOfMaterialToString (Graphic3d_NameOfMaterial theType)
|
||||
{
|
||||
return Graphic3d_Table_PrintNameOfMaterial[theType];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NameOfMaterialFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean Graphic3d::NameOfMaterialFromString (Standard_CString theTypeString,
|
||||
Graphic3d_NameOfMaterial& theType)
|
||||
{
|
||||
TCollection_AsciiString aName (theTypeString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aTypeIter = Graphic3d_TOD_USHORT; aTypeIter <= Graphic3d_TOD_FLOAT; ++aTypeIter)
|
||||
{
|
||||
Standard_CString aTypeName = Graphic3d_Table_PrintNameOfMaterial[aTypeIter];
|
||||
if (aName == aTypeName)
|
||||
{
|
||||
theType = Graphic3d_NameOfMaterial (aTypeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
327
src/Graphic3d/Graphic3d.hxx
Normal file
@@ -0,0 +1,327 @@
|
||||
// Copyright (c) 2018 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 _Graphic3d_HeaderFile
|
||||
#define _Graphic3d_HeaderFile
|
||||
|
||||
#include <Graphic3d_AlphaMode.hxx>
|
||||
#include <Graphic3d_Buffer.hxx>
|
||||
#include <Graphic3d_Camera.hxx>
|
||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||
#include <Graphic3d_TextPath.hxx>
|
||||
#include <Graphic3d_TransModeFlags.hxx>
|
||||
#include <Graphic3d_TypeOfShadingModel.hxx>
|
||||
#include <Graphic3d_NameOfMaterial.hxx>
|
||||
|
||||
#include <Graphic3d_ZLayerId.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
//! Provides methods to cast enumerations of package to string value
|
||||
class Graphic3d
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString ZLayerIdToString (Graphic3d_ZLayerId theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Graphic3d_ZLayerId_UNKNOWN if string identifier is invalid
|
||||
static Graphic3d_ZLayerId ZLayerIdFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_ZLayerId aType = Graphic3d_ZLayerId_UNKNOWN;
|
||||
ZLayerIdFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean ZLayerIdFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_ZLayerId& theType);
|
||||
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString HorizontalTextAlignmentToString (Graphic3d_HorizontalTextAlignment theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Graphic3d_HTA_LEFT if string identifier is invalid
|
||||
static Graphic3d_HorizontalTextAlignment HorizontalTextAlignmentFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_HorizontalTextAlignment aType = Graphic3d_HTA_LEFT;
|
||||
HorizontalTextAlignmentFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean HorizontalTextAlignmentFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_HorizontalTextAlignment& theType);
|
||||
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString VerticalTextAlignmentToString (Graphic3d_VerticalTextAlignment theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Graphic3d_VTA_BOTTOM if string identifier is invalid
|
||||
static Graphic3d_VerticalTextAlignment VerticalTextAlignmentFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_VerticalTextAlignment aType = Graphic3d_VTA_BOTTOM;
|
||||
VerticalTextAlignmentFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean VerticalTextAlignmentFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_VerticalTextAlignment& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TextPathToString (Graphic3d_TextPath theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Graphic3d_TP_UP if string identifier is invalid
|
||||
static Graphic3d_TextPath TextPathFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_TextPath aType = Graphic3d_TP_UP;
|
||||
TextPathFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TextPathFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_TextPath& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString AlphaModeToString (Graphic3d_AlphaMode theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Graphic3d_AlphaMode_Opaque if string identifier is invalid
|
||||
static Graphic3d_AlphaMode AlphaModeFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_AlphaMode aType = Graphic3d_AlphaMode_Opaque;
|
||||
AlphaModeFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean AlphaModeFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_AlphaMode& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TypeOfShadingModelToString (Graphic3d_TypeOfShadingModel theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Graphic3d_TOSM_DEFAULT if string identifier is invalid
|
||||
static Graphic3d_TypeOfShadingModel TypeOfShadingModelFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_TypeOfShadingModel aType = Graphic3d_TOSM_DEFAULT;
|
||||
TypeOfShadingModelFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TypeOfShadingModelFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_TypeOfShadingModel& theType);
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TypeOfAttributeToString (Graphic3d_TypeOfAttribute theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Graphic3d_TOA_POS if string identifier is invalid
|
||||
static Graphic3d_TypeOfAttribute TypeOfAttributeFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_TypeOfAttribute aType = Graphic3d_TOA_POS;
|
||||
TypeOfAttributeFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TypeOfAttributeFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_TypeOfAttribute& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TypeOfDataToString (Graphic3d_TypeOfData theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Graphic3d_TOSM_DEFAULT if string identifier is invalid
|
||||
static Graphic3d_TypeOfData TypeOfDataFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_TypeOfData aType = Graphic3d_TOD_USHORT;
|
||||
TypeOfDataFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TypeOfDataFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_TypeOfData& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString TransModeFlagsToString (Graphic3d_TransModeFlags theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Graphic3d_TOSM_DEFAULT if string identifier is invalid
|
||||
static Graphic3d_TransModeFlags TransModeFlagsFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_TransModeFlags aType = Graphic3d_TMF_None;
|
||||
TransModeFlagsFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean TransModeFlagsFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_TransModeFlags& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString CameraProjectionToString (Graphic3d_Camera::Projection theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or Projection_Orthographic if string identifier is invalid
|
||||
static Graphic3d_Camera::Projection CameraProjectionFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_Camera::Projection aType = Graphic3d_Camera::Projection_Orthographic;
|
||||
CameraProjectionFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean CameraProjectionFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_Camera::Projection& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString CameraFocusTypeToString (Graphic3d_Camera::FocusType theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or FocusType_Absolute if string identifier is invalid
|
||||
static Graphic3d_Camera::FocusType CameraFocusTypeFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_Camera::FocusType aType = Graphic3d_Camera::FocusType_Absolute;
|
||||
CameraFocusTypeFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean CameraFocusTypeFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_Camera::FocusType& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString CameraIODTypeToString (Graphic3d_Camera::IODType theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or IODType_Absolute if string identifier is invalid
|
||||
static Graphic3d_Camera::IODType CameraIODTypeFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_Camera::IODType aType = Graphic3d_Camera::IODType_Absolute;
|
||||
CameraIODTypeFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean CameraIODTypeFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_Camera::IODType& theType);
|
||||
|
||||
//! Returns the string name for a given type.
|
||||
//! @param theType an enumeration type
|
||||
//! @return string identifier from the enumeration list
|
||||
Standard_EXPORT static Standard_CString NameOfMaterialToString (Graphic3d_NameOfMaterial theType);
|
||||
|
||||
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @return enumeration type or IODType_Absolute if string identifier is invalid
|
||||
static Graphic3d_NameOfMaterial NameOfMaterialFromString (Standard_CString theTypeString)
|
||||
{
|
||||
Graphic3d_NameOfMaterial aType = Graphic3d_NOM_BRASS;
|
||||
NameOfMaterialFromString (theTypeString, aType);
|
||||
return aType;
|
||||
}
|
||||
|
||||
//! Determines the type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theTypeString string identifier
|
||||
//! @param theType detected type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean NameOfMaterialFromString (const Standard_CString theTypeString,
|
||||
Graphic3d_NameOfMaterial& theType);
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_HeaderFile
|
@@ -12,6 +12,7 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Graphic3d_Aspects.hxx>
|
||||
#include <TCollection.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Aspects, Standard_Transient)
|
||||
|
||||
@@ -60,3 +61,69 @@ void Graphic3d_Aspects::SetTextureMap (const Handle(Graphic3d_TextureMap)& theTe
|
||||
|
||||
myTextureSet = new Graphic3d_TextureSet (theTexture);
|
||||
}
|
||||
|
||||
const TCollection_AsciiString Graphic3d_Aspects_ClassName = "Graphic3d_Aspects";
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Graphic3d_Aspects::Dump (Standard_OStream& OS) const
|
||||
{
|
||||
DUMP_START_KEY (OS, Graphic3d_Aspects_ClassName);
|
||||
|
||||
/*Handle(Graphic3d_ShaderProgram) myProgram;
|
||||
Handle(Graphic3d_TextureSet) myTextureSet;
|
||||
Handle(Graphic3d_MarkerImage) myMarkerImage;
|
||||
Handle(Graphic3d_HatchStyle) myHatchStyle;
|
||||
Handle(TCollection_HAsciiString) myTextFont;
|
||||
Graphic3d_MaterialAspect myFrontMaterial;
|
||||
Graphic3d_MaterialAspect myBackMaterial;
|
||||
*/
|
||||
|
||||
Standard_SStream aTmpStream;
|
||||
myInteriorColor.Dump (aTmpStream);
|
||||
DUMP_VALUES (OS, "InteriorColor", TCollection::ToDumpString (aTmpStream));
|
||||
|
||||
aTmpStream.str ("");
|
||||
myBackInteriorColor.Dump (aTmpStream);
|
||||
DUMP_VALUES (OS, "BackInteriorColor", TCollection::ToDumpString (aTmpStream));
|
||||
|
||||
aTmpStream.str ("");
|
||||
myEdgeColor.Dump (aTmpStream);
|
||||
DUMP_VALUES (OS, "EdgeColor", TCollection::ToDumpString (aTmpStream));
|
||||
|
||||
aTmpStream.str ("");
|
||||
myPolygonOffset.Dump (aTmpStream);
|
||||
DUMP_VALUES (OS, "PolygonOffset", TCollection::ToDumpString (aTmpStream));
|
||||
|
||||
|
||||
/*Aspect_InteriorStyle myInteriorStyle;
|
||||
Graphic3d_TypeOfShadingModel myShadingModel;
|
||||
Graphic3d_AlphaMode myAlphaMode;
|
||||
Standard_ShortReal myAlphaCutoff;
|
||||
|
||||
Aspect_TypeOfLine myLineType;
|
||||
Standard_ShortReal myLineWidth;
|
||||
|
||||
Aspect_TypeOfMarker myMarkerType;
|
||||
Standard_ShortReal myMarkerScale;
|
||||
|
||||
Aspect_TypeOfStyleText myTextStyle;
|
||||
Aspect_TypeOfDisplayText myTextDisplayType;
|
||||
Font_FontAspect myTextFontAspect;
|
||||
Standard_ShortReal myTextAngle;
|
||||
*/
|
||||
|
||||
DUMP_VALUES (OS, "ToSkipFirstEdge", myToSkipFirstEdge);
|
||||
DUMP_VALUES (OS, "ToDistinguishMaterials", myToDistinguishMaterials);
|
||||
DUMP_VALUES (OS, "ToDrawEdges", myToDrawEdges);
|
||||
DUMP_VALUES (OS, "ToDrawSilhouette", myToDrawSilhouette);
|
||||
DUMP_VALUES (OS, "ToSuppressBackFaces", myToSuppressBackFaces);
|
||||
DUMP_VALUES (OS, "ToMapTexture", myToMapTexture);
|
||||
DUMP_VALUES (OS, "IsTextZoomable", myIsTextZoomable);
|
||||
|
||||
|
||||
DUMP_STOP_KEY (OS, Graphic3d_Aspects_ClassName);
|
||||
}
|
||||
|
@@ -477,6 +477,9 @@ public:
|
||||
&& myIsTextZoomable == theOther.myIsTextZoomable;
|
||||
}
|
||||
|
||||
//! Dumps the content of me on the stream <OS>.
|
||||
Standard_EXPORT void Dump (Standard_OStream& OS) const;
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Graphic3d_ShaderProgram) myProgram;
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <Aspect_Window.hxx>
|
||||
#include <Graphic3d_BufferType.hxx>
|
||||
#include <Graphic3d_Camera.hxx>
|
||||
#include <Graphic3d_CubeMap.hxx>
|
||||
#include <Graphic3d_CLight.hxx>
|
||||
#include <Graphic3d_CStructure.hxx>
|
||||
#include <Graphic3d_DataStructureManager.hxx>
|
||||
@@ -373,6 +374,12 @@ public:
|
||||
//! Sets background image fill style.
|
||||
virtual void SetBackgroundImageStyle (const Aspect_FillMethod theFillStyle) = 0;
|
||||
|
||||
//! Returns cubemap being setted last time on background.
|
||||
virtual Handle(Graphic3d_CubeMap) BackgroundCubeMap() const = 0;
|
||||
|
||||
//! Sets environment cubemap as background.
|
||||
virtual void SetBackgroundCubeMap (const Handle(Graphic3d_CubeMap)& theCubeMap) = 0;
|
||||
|
||||
//! Returns environment texture set for the view.
|
||||
virtual Handle(Graphic3d_TextureEnv) TextureEnv() const = 0;
|
||||
|
||||
|
17
src/Graphic3d/Graphic3d_CubeMap.cxx
Normal file
@@ -0,0 +1,17 @@
|
||||
// Author: Ilya Khramov
|
||||
// Copyright (c) 2019 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 <Graphic3d_CubeMap.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CubeMap, Graphic3d_TextureMap)
|
110
src/Graphic3d/Graphic3d_CubeMap.hxx
Normal file
@@ -0,0 +1,110 @@
|
||||
// Author: Ilya Khramov
|
||||
// Copyright (c) 2019 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 _Graphic3d_CubeMap_HeaderFile
|
||||
#define _Graphic3d_CubeMap_HeaderFile
|
||||
|
||||
#include <Graphic3d_CubeMapOrder.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
|
||||
//! Base class for cubemaps.
|
||||
//! It is iterator over cubemap sides.
|
||||
class Graphic3d_CubeMap : public Graphic3d_TextureMap
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_CubeMap, Graphic3d_TextureMap)
|
||||
public:
|
||||
|
||||
//! Constructor defining loading cubemap from file.
|
||||
Graphic3d_CubeMap (const TCollection_AsciiString& theFileName) :
|
||||
Graphic3d_TextureMap (theFileName, Graphic3d_TOT_CUBEMAP),
|
||||
myCurrentSide (Graphic3d_CMS_POS_X),
|
||||
myEndIsReached (false),
|
||||
myIsTopDown (true),
|
||||
myZIsInverted (false)
|
||||
{}
|
||||
|
||||
//! Constructor defining direct cubemap initialization from PixMap.
|
||||
Graphic3d_CubeMap (const Handle(Image_PixMap)& thePixmap = Handle(Image_PixMap)()) :
|
||||
Graphic3d_TextureMap (thePixmap, Graphic3d_TOT_CUBEMAP),
|
||||
myCurrentSide (Graphic3d_CMS_POS_X),
|
||||
myEndIsReached (false),
|
||||
myIsTopDown (true),
|
||||
myZIsInverted (false)
|
||||
{}
|
||||
|
||||
//! Returns whether the iterator has reached the end (true if it hasn't).
|
||||
Standard_Boolean More() const { return !myEndIsReached; }
|
||||
|
||||
//! Returns current cubemap side (iterator state).
|
||||
Graphic3d_CubeMapSide CurrentSide() const { return myCurrentSide; }
|
||||
|
||||
//! Moves iterator to the next cubemap side.
|
||||
//! Uses OpenGL cubemap sides order +X -> -X -> +Y -> -Y -> +Z -> -Z.
|
||||
void Next()
|
||||
{
|
||||
if (!myEndIsReached && myCurrentSide == Graphic3d_CMS_NEG_Z)
|
||||
{
|
||||
myEndIsReached = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
myCurrentSide = Graphic3d_CubeMapSide (myCurrentSide + 1);
|
||||
}
|
||||
}
|
||||
|
||||
//! Returns whether row's memory layout is top-down.
|
||||
Standard_Boolean IsTopDown() const
|
||||
{
|
||||
return myIsTopDown;
|
||||
}
|
||||
|
||||
//! Sets Z axis inversion (vertical flipping).
|
||||
void SetZInversion (Standard_Boolean theZIsInverted)
|
||||
{
|
||||
myZIsInverted = theZIsInverted;
|
||||
}
|
||||
|
||||
//! Returns whether Z axis is inverted.
|
||||
Standard_Boolean ZIsInverted() const
|
||||
{
|
||||
return myZIsInverted;
|
||||
}
|
||||
|
||||
//! Returns PixMap containing current side of cubemap.
|
||||
//! Returns null handle if current side is invalid.
|
||||
virtual Handle(Image_PixMap) Value() = 0;
|
||||
|
||||
//! Sets iterator state to +X cubemap side.
|
||||
Graphic3d_CubeMap& Reset()
|
||||
{
|
||||
myCurrentSide = Graphic3d_CMS_POS_X;
|
||||
myEndIsReached = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Empty destructor.
|
||||
~Graphic3d_CubeMap() {}
|
||||
|
||||
protected:
|
||||
|
||||
Graphic3d_CubeMapSide myCurrentSide; //!< Iterator state
|
||||
Standard_Boolean myEndIsReached; //!< Indicates whether end of iteration has been reached or hasn't
|
||||
Standard_Boolean myIsTopDown; //!< Stores rows's memory layout
|
||||
Standard_Boolean myZIsInverted; //!< Indicates whether Z axis is inverted that allows to synchronize vertical flip of cubemap
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_CubeMap, Graphic3d_TextureMap)
|
||||
|
||||
#endif // _Graphic3d_CubeMap_HeaderFile
|
278
src/Graphic3d/Graphic3d_CubeMapOrder.cxx
Normal file
@@ -0,0 +1,278 @@
|
||||
// Author: Ilya Khramov
|
||||
// Copyright (c) 2019 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 <Graphic3d_CubeMapOrder.hxx>
|
||||
|
||||
#include <Standard_Failure.hxx>
|
||||
|
||||
#include <bitset>
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapOrder
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder::Graphic3d_CubeMapOrder()
|
||||
:
|
||||
myConvolution (0),
|
||||
myHasOverflows (false)
|
||||
{}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapOrder
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder::Graphic3d_CubeMapOrder (unsigned char thePosXLocation,
|
||||
unsigned char theNegXLocation,
|
||||
unsigned char thePosYLocation,
|
||||
unsigned char theNegYLocation,
|
||||
unsigned char thePosZLocation,
|
||||
unsigned char theNegZLocation)
|
||||
:
|
||||
myConvolution (0),
|
||||
myHasOverflows (false)
|
||||
{
|
||||
Set (Graphic3d_CMS_POS_X, thePosXLocation);
|
||||
Set (Graphic3d_CMS_NEG_X, theNegXLocation);
|
||||
Set (Graphic3d_CMS_POS_Y, thePosYLocation);
|
||||
Set (Graphic3d_CMS_NEG_Y, theNegYLocation);
|
||||
Set (Graphic3d_CMS_POS_Z, thePosZLocation);
|
||||
Set (Graphic3d_CMS_NEG_Z, theNegZLocation);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapOrder
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder::Graphic3d_CubeMapOrder (const Graphic3d_ValidatedCubeMapOrder theOrder)
|
||||
:
|
||||
myConvolution (theOrder.Order.myConvolution),
|
||||
myHasOverflows (theOrder.Order.myHasOverflows)
|
||||
{}
|
||||
|
||||
// =======================================================================
|
||||
// function : Set
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::Set (const Graphic3d_CubeMapOrder& theOrder)
|
||||
{
|
||||
myConvolution = theOrder.myConvolution;
|
||||
myHasOverflows = theOrder.myHasOverflows;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : operator=
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ValidatedCubeMapOrder Graphic3d_CubeMapOrder::Validated() const
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
throw Standard_Failure("Try of Graphic3d_ValidatedCubeMapOrder creation using invalid Graphic3d_CubeMapOrder");
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Set
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::Set (Graphic3d_CubeMapSide theCubeMapSide, unsigned char theValue)
|
||||
{
|
||||
if (theValue > 5)
|
||||
{
|
||||
myHasOverflows = true;
|
||||
return *this;
|
||||
}
|
||||
set (theCubeMapSide, theValue);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Get
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
unsigned char Graphic3d_CubeMapOrder::Get (Graphic3d_CubeMapSide theCubeMapSide) const
|
||||
{
|
||||
return get (static_cast<unsigned char> (theCubeMapSide));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : operator[]
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
unsigned char Graphic3d_CubeMapOrder::operator[] (Graphic3d_CubeMapSide theCubeMapSide) const
|
||||
{
|
||||
return Get (theCubeMapSide);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetDefault
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::SetDefault()
|
||||
{
|
||||
for (unsigned char i = 0; i < 6; ++i)
|
||||
{
|
||||
set (Graphic3d_CubeMapSide (i), i);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Permute
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::Permute (Graphic3d_ValidatedCubeMapOrder thePermutation)
|
||||
{
|
||||
for (unsigned char i = 0; i < 6; ++i)
|
||||
{
|
||||
set (i, thePermutation->get (get (i)));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Permuted
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder Graphic3d_CubeMapOrder::Permuted (Graphic3d_ValidatedCubeMapOrder thePermutation) const
|
||||
{
|
||||
Graphic3d_CubeMapOrder anOrder = *this;
|
||||
anOrder.Permute (thePermutation);
|
||||
return anOrder;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Swap
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::Swap (Graphic3d_CubeMapSide theFirstSide,
|
||||
Graphic3d_CubeMapSide theSecondSide)
|
||||
{
|
||||
unsigned char aTmp = Get (theFirstSide);
|
||||
set (theFirstSide, Get(theSecondSide));
|
||||
set (theSecondSide, aTmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Swapped
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder Graphic3d_CubeMapOrder::Swapped (Graphic3d_CubeMapSide theFirstSide,
|
||||
Graphic3d_CubeMapSide theSecondSide) const
|
||||
{
|
||||
Graphic3d_CubeMapOrder anOrder = *this;
|
||||
anOrder.Swap (theFirstSide, theSecondSide);
|
||||
return anOrder;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Clear
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapOrder& Graphic3d_CubeMapOrder::Clear()
|
||||
{
|
||||
myConvolution = 0;
|
||||
myHasOverflows = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsEmpty
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Graphic3d_CubeMapOrder::IsEmpty() const
|
||||
{
|
||||
return myConvolution == 0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HasRepetitions
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Graphic3d_CubeMapOrder::HasRepetitions() const
|
||||
{
|
||||
std::bitset<6> aBitSet;
|
||||
for (unsigned char i = 0; i < 6; ++i)
|
||||
{
|
||||
std::bitset<6>::reference aFlag = aBitSet[get (i)];
|
||||
if (aFlag)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
aFlag = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : HasOverflows
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Graphic3d_CubeMapOrder::HasOverflows() const
|
||||
{
|
||||
return myHasOverflows;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsValid
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Graphic3d_CubeMapOrder::IsValid() const
|
||||
{
|
||||
return !HasRepetitions() && !HasOverflows();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : get
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
unsigned char Graphic3d_CubeMapOrder::get (unsigned char theCubeMapSide) const
|
||||
{
|
||||
return (myConvolution / (1 << (theCubeMapSide * 3))) % (1 << 3);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : set
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_CubeMapOrder::set (unsigned char theCubeMapSide, unsigned char theValue)
|
||||
{
|
||||
unsigned int aValuePlace = 1 << (theCubeMapSide * 3);
|
||||
myConvolution -= aValuePlace * get (theCubeMapSide);
|
||||
myConvolution += aValuePlace * theValue;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : set
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_CubeMapOrder::set (Graphic3d_CubeMapSide theCubeMapSide, unsigned char theValue)
|
||||
{
|
||||
set (static_cast<unsigned char> (theCubeMapSide), theValue);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Default
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
const Graphic3d_ValidatedCubeMapOrder& Graphic3d_CubeMapOrder::Default()
|
||||
{
|
||||
static const Graphic3d_ValidatedCubeMapOrder aCubeMapOrder = Graphic3d_CubeMapOrder().SetDefault().Validated();
|
||||
return aCubeMapOrder;
|
||||
}
|
158
src/Graphic3d/Graphic3d_CubeMapOrder.hxx
Normal file
@@ -0,0 +1,158 @@
|
||||
// Author: Ilya Khramov
|
||||
// Copyright (c) 2019 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 _Graphic3d_CubeMapOrder_HeaderFile
|
||||
#define _Graphic3d_CubeMapOrder_HeaderFile
|
||||
|
||||
#include <Graphic3d_CubeMapSide.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
|
||||
class Graphic3d_ValidatedCubeMapOrder;
|
||||
|
||||
//! Graphic3d_CubeMapOrder maps sides of cubemap on tiles in packed cubemap image
|
||||
//! to support different tiles order in such images.
|
||||
//! Also it can be considered as permutation of numbers from 0 to 5.
|
||||
//! It stores permutation in one integer as convolution.
|
||||
class Graphic3d_CubeMapOrder
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
//! Creates empty order with zero convolution.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder();
|
||||
|
||||
//! Initializes order with values.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder (unsigned char thePosXLocation,
|
||||
unsigned char theNegXLocation,
|
||||
unsigned char thePosYLocation,
|
||||
unsigned char theNegYLocation,
|
||||
unsigned char thePosZLocation,
|
||||
unsigned char theNegZLocation);
|
||||
|
||||
//! Creates Graphic3d_CubeMapOrder using Graphic3d_ValidatedCubeMapOrder.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder (const Graphic3d_ValidatedCubeMapOrder theOrder);
|
||||
|
||||
//! Alias of 'operator='.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& Set (const Graphic3d_CubeMapOrder& theOrder);
|
||||
|
||||
//! Checks whether order is valid and returns object containing it.
|
||||
//! If order is invalid then exception will be thrown.
|
||||
//! This method is only way to create Graphic3d_ValidatedCubeMapOrder except copy constructor.
|
||||
Standard_EXPORT Graphic3d_ValidatedCubeMapOrder Validated() const;
|
||||
|
||||
public:
|
||||
|
||||
//! Sets number of tile in packed cubemap image according passed cubemap side.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& Set (Graphic3d_CubeMapSide theCubeMapSide, unsigned char theValue);
|
||||
|
||||
//! Sets default order (just from 0 to 5)
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& SetDefault();
|
||||
|
||||
//! Applies another cubemap order as permutation for the current one.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& Permute (Graphic3d_ValidatedCubeMapOrder anOrder);
|
||||
|
||||
//! Returns permuted by other cubemap order copy of current one.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder Permuted (Graphic3d_ValidatedCubeMapOrder anOrder) const;
|
||||
|
||||
//! Swaps values of two cubemap sides.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& Swap (Graphic3d_CubeMapSide theFirstSide,
|
||||
Graphic3d_CubeMapSide theSecondSide);
|
||||
|
||||
//! Returns copy of current order with swapped values of two cubemap sides.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder Swapped (Graphic3d_CubeMapSide theFirstSide,
|
||||
Graphic3d_CubeMapSide theSecondSide) const;
|
||||
|
||||
//! Returns value of passed cubemap side.
|
||||
Standard_EXPORT unsigned char Get (Graphic3d_CubeMapSide theCubeMapSide) const;
|
||||
|
||||
//! Alias of 'Get'.
|
||||
Standard_EXPORT unsigned char operator[] (Graphic3d_CubeMapSide theCubeMapSide) const;
|
||||
|
||||
//! Makes order empty.
|
||||
Standard_EXPORT Graphic3d_CubeMapOrder& Clear();
|
||||
|
||||
//! Checks whether order is empty.
|
||||
Standard_EXPORT bool IsEmpty() const;
|
||||
|
||||
//! Checks whether order has repetitions.
|
||||
Standard_EXPORT bool HasRepetitions() const;
|
||||
|
||||
//! Checks whether attempts to assign index greater than 5 to any side happed.
|
||||
Standard_EXPORT bool HasOverflows() const;
|
||||
|
||||
//! Checks whether order is valid.
|
||||
//! Order is valid when it doesn't have repetitions
|
||||
//! and there were not attempts to assign indexes greater than 5.
|
||||
Standard_EXPORT bool IsValid() const;
|
||||
|
||||
public:
|
||||
|
||||
//! Returns default order in protector container class.
|
||||
//! It is guaranteed to be valid.
|
||||
Standard_EXPORT static const Graphic3d_ValidatedCubeMapOrder& Default();
|
||||
|
||||
private:
|
||||
|
||||
//! Alias of 'Get' with other parameter's type for more handful iteration.
|
||||
unsigned char get (unsigned char theCubeMapSide) const;
|
||||
|
||||
//! Alias of 'set' with other parameter's type for more handful iteration and applying permutations.
|
||||
void set (unsigned char theCubeMapSide, unsigned char theValue);
|
||||
|
||||
//! 'Set' without overflow's checking.
|
||||
void set (Graphic3d_CubeMapSide theCubeMapSide, unsigned char theValue);
|
||||
|
||||
private:
|
||||
|
||||
unsigned int myConvolution; //!< Contains all values of permutation as power convolution
|
||||
bool myHasOverflows; //!< Indicates if there are attempts to assign index greater than 5
|
||||
};
|
||||
|
||||
//! Graphic3d_ValidatedCubeMapOrder contains completely valid order object.
|
||||
//! The only way to create this class except copy constructor is 'Validated' method of Graphic3d_CubeMapOrder.
|
||||
//! This class can initialize Graphic3d_CubeMapOrder.
|
||||
//! It is supposed to be used in case of necessity of completely valid order (in function argument as example).
|
||||
//! It helps to automate order's valid checks.
|
||||
class Graphic3d_ValidatedCubeMapOrder
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
friend class Graphic3d_CubeMapOrder;
|
||||
|
||||
//! Allows skip access to 'Order' field and work directly.
|
||||
const Graphic3d_CubeMapOrder* operator->() const
|
||||
{
|
||||
return &Order;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
const Graphic3d_CubeMapOrder Order; //!< Completely valid order
|
||||
|
||||
private:
|
||||
|
||||
//! Only Graphic3d_CubeMapOrder can generate Graphic3d_ValidatedCubeMapOrder in 'Validated' method.
|
||||
Graphic3d_ValidatedCubeMapOrder(const Graphic3d_CubeMapOrder theOrder)
|
||||
:
|
||||
Order(theOrder)
|
||||
{}
|
||||
|
||||
//! Deleted 'operator='
|
||||
Graphic3d_ValidatedCubeMapOrder& operator= (const Graphic3d_ValidatedCubeMapOrder&);
|
||||
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_CubeMapOrder_HeaderFile
|
196
src/Graphic3d/Graphic3d_CubeMapPacked.cxx
Normal file
@@ -0,0 +1,196 @@
|
||||
// Author: Ilya Khramov
|
||||
// Copyright (c) 2019 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 <Graphic3d_CubeMapPacked.hxx>
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapPacked
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapPacked::Graphic3d_CubeMapPacked (const TCollection_AsciiString& theFilePath,
|
||||
const Graphic3d_ValidatedCubeMapOrder theOrder)
|
||||
:
|
||||
Graphic3d_CubeMap (theFilePath),
|
||||
myOrder (theOrder),
|
||||
myTileNumberX (1)
|
||||
{}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapPacked
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapPacked::Graphic3d_CubeMapPacked (const Handle(Image_PixMap)& theImage,
|
||||
const Graphic3d_ValidatedCubeMapOrder theOrder)
|
||||
:
|
||||
Graphic3d_CubeMap (Handle(Image_PixMap)()),
|
||||
myOrder (theOrder),
|
||||
myTileNumberX (1)
|
||||
{
|
||||
if (checkImage (theImage, myTileNumberX))
|
||||
{
|
||||
myPixMap = theImage;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Value
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Image_PixMap) Graphic3d_CubeMapPacked::Value()
|
||||
{
|
||||
if (myTileNumberX != 0)
|
||||
{
|
||||
if (myPixMap.IsNull())
|
||||
{
|
||||
TCollection_AsciiString aFilePath;
|
||||
myPath.SystemName (aFilePath);
|
||||
if (!aFilePath.IsEmpty())
|
||||
{
|
||||
tryLoadImage (aFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!myPixMap.IsNull())
|
||||
{
|
||||
Handle(Image_PixMap) aWrapper = new Image_PixMap();
|
||||
|
||||
Standard_Size aTileSize = myPixMap->SizeX() / myTileNumberX;
|
||||
|
||||
myIsTopDown = myPixMap->IsTopDown();
|
||||
|
||||
Graphic3d_CubeMapOrder anOrder = myOrder;
|
||||
|
||||
if (!myIsTopDown)
|
||||
{
|
||||
myPixMap->SetTopDown (true);
|
||||
anOrder.Swap (Graphic3d_CMS_POS_Y, Graphic3d_CMS_NEG_Y);
|
||||
}
|
||||
|
||||
unsigned int aTileIndexX = anOrder[myCurrentSide] % myTileNumberX;
|
||||
unsigned int aTileIndexY = anOrder[myCurrentSide] / myTileNumberX;
|
||||
|
||||
aTileIndexY = myIsTopDown ? aTileIndexY : (6 / myTileNumberX - 1 - aTileIndexY);
|
||||
|
||||
if (aWrapper->InitWrapper (myPixMap->Format(),
|
||||
myPixMap->ChangeRawValue(aTileIndexY * aTileSize, aTileIndexX * aTileSize),
|
||||
aTileSize,
|
||||
aTileSize,
|
||||
myPixMap->SizeRowBytes()))
|
||||
{
|
||||
myPixMap->SetTopDown (myIsTopDown);
|
||||
return aWrapper;
|
||||
}
|
||||
else
|
||||
{
|
||||
myPixMap->SetTopDown(myIsTopDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Handle(Image_PixMap)();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : checkOrder
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_CubeMapPacked::checkOrder (const NCollection_Array1<unsigned int>& theOrder)
|
||||
{
|
||||
Standard_Boolean anOrderIsValid = Standard_True;
|
||||
|
||||
if (theOrder.Size() != 6)
|
||||
{
|
||||
anOrderIsValid = Standard_False;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < 6 && anOrderIsValid; ++i)
|
||||
{
|
||||
if (theOrder[i] > 5)
|
||||
{
|
||||
anOrderIsValid = Standard_False;
|
||||
break;
|
||||
}
|
||||
|
||||
for (unsigned int j = i + 1; j < 6; ++j)
|
||||
{
|
||||
if (theOrder[i] == theOrder[j])
|
||||
{
|
||||
anOrderIsValid = Standard_False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!anOrderIsValid)
|
||||
{
|
||||
throw Standard_Failure ("Ivalid order format in tiles of Graphic3d_CubeMapPacked");
|
||||
}
|
||||
|
||||
return anOrderIsValid;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : checkImage
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_CubeMapPacked::checkImage (const Handle(Image_PixMap)& theImage,
|
||||
unsigned int& theTileNumberX)
|
||||
{
|
||||
Standard_Size aSizeX = theImage->SizeX();
|
||||
Standard_Size aSizeY = theImage->SizeY();
|
||||
|
||||
if ((aSizeY % aSizeX == 0) && (aSizeY / aSizeX == 6))
|
||||
{
|
||||
theTileNumberX = 1;
|
||||
}
|
||||
else if ((aSizeX % aSizeY == 0) && (aSizeX / aSizeY == 6))
|
||||
{
|
||||
theTileNumberX = 6;
|
||||
}
|
||||
else if ((aSizeX % 2 == 0) && (aSizeY % 3 == 0) && (aSizeX / 2 == aSizeY / 3))
|
||||
{
|
||||
theTileNumberX = 2;
|
||||
}
|
||||
else if ((aSizeX % 3 == 0) && (aSizeY % 2 == 0) && (aSizeX / 3 == aSizeY / 2))
|
||||
{
|
||||
theTileNumberX = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : tryLoadImage
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_CubeMapPacked::tryLoadImage (const TCollection_AsciiString& theFilePath)
|
||||
{
|
||||
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap;
|
||||
if (anImage->Load (theFilePath))
|
||||
{
|
||||
if (checkImage (anImage, myTileNumberX))
|
||||
{
|
||||
myPixMap = anImage;
|
||||
}
|
||||
}
|
||||
}
|
71
src/Graphic3d/Graphic3d_CubeMapPacked.hxx
Normal file
@@ -0,0 +1,71 @@
|
||||
// Author: Ilya Khramov
|
||||
// Copyright (c) 2019 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 _Graphic3d_CubeMapPacked_HeaderFile
|
||||
#define _Graphic3d_CubeMapPacked_HeaderFile
|
||||
|
||||
#include <Graphic3d_CubeMap.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
|
||||
//! Class is intended to process cubemap packed into single image plane.
|
||||
class Graphic3d_CubeMapPacked : public Graphic3d_CubeMap
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
|
||||
public:
|
||||
|
||||
//! Initialization to load cubemef from file.
|
||||
//! @theFileName - path to the cubemap image
|
||||
//! @theOrder - array conaining six different indexes of cubemap sides which maps tile grid to cubemap sides
|
||||
Standard_EXPORT Graphic3d_CubeMapPacked (const TCollection_AsciiString& theFileName,
|
||||
const Graphic3d_ValidatedCubeMapOrder theOrder = Graphic3d_CubeMapOrder::Default());
|
||||
|
||||
//! Initialization to set cubemap directly by PixMap.
|
||||
//! @thePixMap - origin PixMap
|
||||
//! @theOrder - array conaining six different indexes of cubemap sides which maps tile grid to cubemap sides
|
||||
Standard_EXPORT Graphic3d_CubeMapPacked (const Handle(Image_PixMap)& theImage,
|
||||
const Graphic3d_ValidatedCubeMapOrder theOrder = Graphic3d_CubeMapOrder::Default());
|
||||
|
||||
//! Returns current cubemap side as PixMap.
|
||||
//! Resulting PixMap is memory wrapper over original image.
|
||||
//! Returns null handle if current side or whole cubemap is invalid.
|
||||
//! Origin image has to contain six quad tiles having one sizes without any gaps to be valid.
|
||||
Standard_EXPORT Handle(Image_PixMap) Value() Standard_OVERRIDE;
|
||||
|
||||
//! Empty destructor.
|
||||
~Graphic3d_CubeMapPacked() {}
|
||||
|
||||
private:
|
||||
|
||||
//! Checks whether given tiles order is valid.
|
||||
static Standard_Boolean checkOrder (const NCollection_Array1<unsigned int>& theOrder);
|
||||
|
||||
//! Checks whether given pixmap is valid to contain six tiles.
|
||||
static Standard_Boolean checkImage (const Handle(Image_PixMap)& theImage,
|
||||
unsigned int& theTileNumberX);
|
||||
|
||||
//! Tries to load image from file and checks it after that.
|
||||
//! Does nothing in case of fail.
|
||||
void tryLoadImage (const TCollection_AsciiString &theFilePath);
|
||||
|
||||
protected:
|
||||
|
||||
Graphic3d_CubeMapOrder myOrder; //!< order mapping tile grit to cubemap sides
|
||||
unsigned int myTileNumberX; //!< width of tile grid
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_CubeMapPacked, Graphic3d_CubeMap)
|
||||
|
||||
#endif // _Graphic3d_CubeMapPacked_HeaderFile
|
185
src/Graphic3d/Graphic3d_CubeMapSeparate.cxx
Normal file
@@ -0,0 +1,185 @@
|
||||
// Author: Ilya Khramov
|
||||
// Copyright (c) 2019 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 <Graphic3d_CubeMapSeparate.hxx>
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CubeMapSeparate, Graphic3d_CubeMap)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapSeparate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapSeparate::Graphic3d_CubeMapSeparate (const NCollection_Array1<TCollection_AsciiString>& thePaths)
|
||||
{
|
||||
if (thePaths.Size() == 6)
|
||||
{
|
||||
for (unsigned int i = 0; i < 6; ++i)
|
||||
{
|
||||
myPaths[i] = thePaths[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Standard_Failure("Invalid number of paths to load Graphic3d_CubeMapSeparate");
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_CubeMapSeparate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_CubeMapSeparate::Graphic3d_CubeMapSeparate (const NCollection_Array1<Handle(Image_PixMap)>& theImages)
|
||||
{
|
||||
if (theImages.Size() == 6)
|
||||
{
|
||||
if (theImages[0].IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theImages[0]->SizeX() != theImages[0]->SizeY())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myImages[0] = theImages[0];
|
||||
myIsTopDown = myImages[0]->IsTopDown();
|
||||
|
||||
for (unsigned int i = 1; i < 6; ++i)
|
||||
{
|
||||
if (!theImages[i].IsNull())
|
||||
{
|
||||
if (theImages[i]->SizeX() == myImages[0]->SizeX()
|
||||
&& theImages[i]->SizeY() == myImages[0]->SizeY()
|
||||
&& theImages[i]->Format() == myImages[0]->Format()
|
||||
&& theImages[i]->IsTopDown() == myImages[0]->IsTopDown())
|
||||
{
|
||||
myImages[i] = theImages[i];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
resetImages();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Standard_Failure("Invalid number of images in Graphic3d_CubeMapSeparate initialization");
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Value
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Handle(Image_PixMap) Graphic3d_CubeMapSeparate::Value()
|
||||
{
|
||||
Graphic3d_CubeMapOrder anOrder = Graphic3d_CubeMapOrder::Default();
|
||||
if (!myIsTopDown)
|
||||
{
|
||||
anOrder.Swap(Graphic3d_CMS_POS_Y, Graphic3d_CMS_NEG_Y);
|
||||
}
|
||||
|
||||
if (!myImages[anOrder[myCurrentSide]].IsNull())
|
||||
{
|
||||
return myImages[anOrder[myCurrentSide]];
|
||||
}
|
||||
else
|
||||
{
|
||||
TCollection_AsciiString aFilePath;
|
||||
myPaths[anOrder[myCurrentSide]].SystemName(aFilePath);
|
||||
if (!aFilePath.IsEmpty())
|
||||
{
|
||||
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap;
|
||||
if (anImage->Load(aFilePath))
|
||||
{
|
||||
if (anImage->SizeX() == anImage->SizeY())
|
||||
{
|
||||
if (myCurrentSide == 0)
|
||||
{
|
||||
mySize = anImage->SizeX();
|
||||
myFormat = anImage->Format();
|
||||
myIsTopDown = anImage->IsTopDown();
|
||||
return anImage;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (anImage->Format() == myFormat
|
||||
&& anImage->SizeX() == mySize
|
||||
&& anImage->IsTopDown() == myIsTopDown)
|
||||
{
|
||||
return anImage;
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::DefaultMessenger()->Send(TCollection_AsciiString() +
|
||||
"'" + aFilePath + "' inconsistent image format or dimension in Graphic3d_CubeMapSeparate");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::DefaultMessenger()->Send(TCollection_AsciiString() +
|
||||
"Unable to load '" + aFilePath + "' image of Graphic3d_CubeMapSeparate");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::DefaultMessenger()->Send(TCollection_AsciiString() +
|
||||
"[" + myCurrentSide + "] path of Graphic3d_CubeMapSeparate is invalid");
|
||||
}
|
||||
}
|
||||
|
||||
return Handle(Image_PixMap)();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : IsDone
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Graphic3d_CubeMapSeparate::IsDone() const
|
||||
{
|
||||
if (!myImages[0].IsNull())
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < 6; ++i)
|
||||
{
|
||||
OSD_File aCubeMapFile(myPaths[i]);
|
||||
if (!aCubeMapFile.Exists())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : resetImages
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_CubeMapSeparate::resetImages()
|
||||
{
|
||||
for (unsigned int i = 0; i < 6; ++i)
|
||||
{
|
||||
myImages[i].Nullify();
|
||||
}
|
||||
}
|
71
src/Graphic3d/Graphic3d_CubeMapSeparate.hxx
Normal file
@@ -0,0 +1,71 @@
|
||||
// Author: Ilya Khramov
|
||||
// Copyright (c) 2019 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 _Graphic3d_CubeMapSeparate_HeaderFile
|
||||
#define _Graphic3d_CubeMapSeparate_HeaderFile
|
||||
|
||||
#include <Graphic3d_CubeMap.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
|
||||
//! Class to manage cubemap located in six different images.
|
||||
class Graphic3d_CubeMapSeparate : public Graphic3d_CubeMap
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_CubeMapSeparate, Graphic3d_CubeMap)
|
||||
public:
|
||||
|
||||
//! Initializes cubemap to be loaded from file.
|
||||
//! @thePaths - array of paths to separate image files (has to have size equal 6).
|
||||
Standard_EXPORT Graphic3d_CubeMapSeparate (const NCollection_Array1<TCollection_AsciiString>& thePaths);
|
||||
|
||||
//! Initializes cubemap to be setted directly from PixMaps.
|
||||
//! @theImages - array if PixMaps (has to have size equal 6).
|
||||
Standard_EXPORT Graphic3d_CubeMapSeparate(const NCollection_Array1<Handle(Image_PixMap)>& theImages);
|
||||
|
||||
//! Returns current side of cubemap as PixMap.
|
||||
//! Returns null handle if current side or whole cubemap is invalid.
|
||||
//! All origin images have to have the same sizes, format and quad shapes to form valid cubemap.
|
||||
Standard_EXPORT Handle(Image_PixMap) Value() Standard_OVERRIDE;
|
||||
|
||||
//! Returns NULL.
|
||||
virtual Handle(Image_PixMap) GetImage() const Standard_OVERRIDE
|
||||
{
|
||||
return Handle(Image_PixMap)();
|
||||
}
|
||||
|
||||
//! Checks if a texture class is valid or not.
|
||||
//! Returns true if the construction of the class is correct.
|
||||
Standard_EXPORT Standard_Boolean IsDone() const Standard_OVERRIDE;
|
||||
|
||||
//! Empty destructor.
|
||||
~Graphic3d_CubeMapSeparate() {}
|
||||
|
||||
protected:
|
||||
|
||||
OSD_Path myPaths[6]; //!< array of paths to cubemap images
|
||||
Handle(Image_PixMap) myImages[6]; //!< array of cubemap images
|
||||
|
||||
Standard_Size mySize; //!< size of each side of cubemap
|
||||
Image_Format myFormat; //!< format each side of cubemap
|
||||
|
||||
private:
|
||||
|
||||
//! Nulifies whole images array.
|
||||
void resetImages();
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_CubeMapSeparate, Graphic3d_CubeMap)
|
||||
|
||||
#endif // _Graphic3d_CubeMapSeparate_HeaderFile
|
29
src/Graphic3d/Graphic3d_CubeMapSide.hxx
Normal file
@@ -0,0 +1,29 @@
|
||||
// Author: Ilya Khramov
|
||||
// Copyright (c) 2019 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 _Graphic3d_CubeMapSide_HeaderFile
|
||||
#define _Graphic3d_CubeMapSide_HeaderFile
|
||||
|
||||
//! Sides of cubemap in order of OpenGL rules
|
||||
enum Graphic3d_CubeMapSide
|
||||
{
|
||||
Graphic3d_CMS_POS_X, //!< X axis positive direction side
|
||||
Graphic3d_CMS_NEG_X, //!< X axis negative direction side
|
||||
Graphic3d_CMS_POS_Y, //!< Y axis positive direction side
|
||||
Graphic3d_CMS_NEG_Y, //!< Y axis negative direction side
|
||||
Graphic3d_CMS_POS_Z, //!< Z axis positive direction side
|
||||
Graphic3d_CMS_NEG_Z, //!< Z axis negative direction side
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_CubeMapSide_HeaderFile
|
@@ -29,6 +29,7 @@
|
||||
#include <Graphic3d_Structure.hxx>
|
||||
#include "Graphic3d_Structure.pxx"
|
||||
#include <Graphic3d_StructureManager.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <Graphic3d_TransModeFlags.hxx>
|
||||
#include <Message.hxx>
|
||||
@@ -310,31 +311,21 @@ void Graphic3d_Group::Marker (const Graphic3d_Vertex& thePoint,
|
||||
// function : Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Group::Text (const Standard_CString /*theText*/,
|
||||
void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
const Graphic3d_Vertex& thePoint,
|
||||
const Standard_Real /*theHeight*/,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTp*/,
|
||||
const Graphic3d_HorizontalTextAlignment /*theHta*/,
|
||||
const Graphic3d_VerticalTextAlignment /*theVta*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
if (IsDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theToEvalMinMax)
|
||||
{
|
||||
Standard_ShortReal x, y, z;
|
||||
thePoint.Coord (x, y, z);
|
||||
myStructure->CStructure()->Is2dText = Standard_True;
|
||||
myBounds.Add (Graphic3d_Vec4 (static_cast<Standard_ShortReal> (x),
|
||||
static_cast<Standard_ShortReal> (y),
|
||||
static_cast<Standard_ShortReal> (z),
|
||||
1.0f));
|
||||
}
|
||||
Update();
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText);
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -346,8 +337,10 @@ void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
Text (theText, thePoint, theHeight, 0.0,
|
||||
Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText);
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -357,15 +350,18 @@ void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
const Graphic3d_Vertex& thePoint,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTp*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
const NCollection_String aText (theText.ToExtString());
|
||||
Text (aText.ToCString(), thePoint, theHeight, theAngle,
|
||||
theTp, theHta, theVta, theToEvalMinMax);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -375,53 +371,43 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTP,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTP*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax,
|
||||
const Standard_Boolean theHasOwnAnchor)
|
||||
{
|
||||
const NCollection_String aText (theText.ToExtString());
|
||||
Text (aText.ToCString(),
|
||||
theOrientation,
|
||||
theHeight,
|
||||
theAngle,
|
||||
theTP,
|
||||
theHTA,
|
||||
theVTA,
|
||||
theToEvalMinMax,
|
||||
theHasOwnAnchor);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetOrientation (theOrientation);
|
||||
aText->SetOwnAnchorPoint (theHasOwnAnchor);
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Group::Text (const Standard_CString /*theText*/,
|
||||
void Graphic3d_Group::Text (const Standard_CString theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real /*theHeight*/,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real /*theAngle*/,
|
||||
const Graphic3d_TextPath /*theTp*/,
|
||||
const Graphic3d_HorizontalTextAlignment /*theHta*/,
|
||||
const Graphic3d_VerticalTextAlignment /*theVta*/,
|
||||
const Graphic3d_HorizontalTextAlignment theHta,
|
||||
const Graphic3d_VerticalTextAlignment theVta,
|
||||
const Standard_Boolean theToEvalMinMax,
|
||||
const Standard_Boolean /*theHasOwnAnchor*/)
|
||||
const Standard_Boolean theHasOwnAnchor)
|
||||
{
|
||||
if (IsDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theToEvalMinMax)
|
||||
{
|
||||
myStructure->CStructure()->Is2dText = Standard_False;
|
||||
myBounds.Add (Graphic3d_Vec4 (static_cast<Standard_ShortReal> (theOrientation.Location().X()),
|
||||
static_cast<Standard_ShortReal> (theOrientation.Location().Y()),
|
||||
static_cast<Standard_ShortReal> (theOrientation.Location().Z()),
|
||||
1.0f));
|
||||
}
|
||||
Update();
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText);
|
||||
aText->SetOrientation (theOrientation);
|
||||
aText->SetOwnAnchorPoint (theHasOwnAnchor);
|
||||
aText->SetHorizontalAlignment (theHta);
|
||||
aText->SetVerticalAlignment (theVta);
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -433,7 +419,50 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
const NCollection_String aText (theText.ToExtString());
|
||||
Text (aText.ToCString(), thePoint, theHeight, 0.0,
|
||||
Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)theHeight);
|
||||
aText->SetText (theText.ToExtString());
|
||||
aText->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
|
||||
AddText (aText, theToEvalMinMax);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : AddText
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Group::AddText (const Handle(Graphic3d_Text)& theTextParams,
|
||||
const Standard_Boolean theToEvalMinMax)
|
||||
{
|
||||
if (IsDeleted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theToEvalMinMax)
|
||||
{
|
||||
myStructure->CStructure()->Is2dText = !theTextParams->HasPlane();
|
||||
|
||||
gp_Pnt aPosition = theTextParams->Position();
|
||||
myBounds.Add (Graphic3d_Vec4 ((Standard_ShortReal)aPosition.X(), (Standard_ShortReal)aPosition.Y(), (Standard_ShortReal)aPosition.Z(), 1.0f));
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
const TCollection_AsciiString Graphic3d_Group_ClassName = "Graphic3d_Group";
|
||||
|
||||
// =======================================================================
|
||||
// function : Dump
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Group::Dump (Standard_OStream& OS) const
|
||||
{
|
||||
DUMP_START_KEY (OS, Graphic3d_Group_ClassName);
|
||||
|
||||
//Graphic3d_Structure* myStructure; //!< pointer to the parent structure
|
||||
//Graphic3d_BndBox4f myBounds; //!< bounding box
|
||||
|
||||
DUMP_VALUES (OS, "IsClosed", myIsClosed);
|
||||
DUMP_VALUES (OS, "ContainsFacet", myContainsFacet);
|
||||
|
||||
DUMP_STOP_KEY (OS, Graphic3d_Group_ClassName);
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@
|
||||
class Graphic3d_Structure;
|
||||
class Graphic3d_ArrayOfPrimitives;
|
||||
class Graphic3d_AspectFillCapping;
|
||||
class Graphic3d_Text;
|
||||
|
||||
//! This class allows the definition of groups
|
||||
//! of primitives inside of graphic objects (presentations).
|
||||
@@ -114,87 +115,16 @@ public:
|
||||
//! Replace aspects specified in the replacement map.
|
||||
virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) = 0;
|
||||
|
||||
public:
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_EXPORT virtual void Text (const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Real AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_EXPORT void Text (const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Real AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_EXPORT virtual void Text (const TCollection_ExtendedString& theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
//! Adds a text for display
|
||||
Standard_EXPORT virtual void AddText (const Handle(Graphic3d_Text)& theTextParams,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
|
||||
//! Adds an array of primitives for display
|
||||
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType, const Handle(Graphic3d_IndexBuffer)& theIndices, const Handle(Graphic3d_Buffer)& theAttribs, const Handle(Graphic3d_BoundBuffer)& theBounds, const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
|
||||
const Handle(Graphic3d_IndexBuffer)& theIndices,
|
||||
const Handle(Graphic3d_Buffer)& theAttribs,
|
||||
const Handle(Graphic3d_BoundBuffer)& theBounds,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
|
||||
//! Adds an array of primitives for display
|
||||
Standard_EXPORT void AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim, const Standard_Boolean theToEvalMinMax = Standard_True);
|
||||
@@ -244,6 +174,115 @@ public:
|
||||
//! Return true if primitive arrays within this graphic group form closed volume (do no contain open shells).
|
||||
bool IsClosed() const { return myIsClosed; }
|
||||
|
||||
//! @name obsolete methods
|
||||
public:
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT virtual void Text (const Standard_CString AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Real AAngle,
|
||||
const Graphic3d_TextPath ATp,
|
||||
const Graphic3d_HorizontalTextAlignment AHta,
|
||||
const Graphic3d_VerticalTextAlignment AVta,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT void Text (const Standard_CString AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! AAngle : Orientation of the text
|
||||
//! (with respect to the horizontal).
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Real AAngle,
|
||||
const Graphic3d_TextPath ATp,
|
||||
const Graphic3d_HorizontalTextAlignment AHta,
|
||||
const Graphic3d_VerticalTextAlignment AVta,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <AText> at position <APoint>.
|
||||
//! The 3D point of attachment is projected. The text is
|
||||
//! written in the plane of projection.
|
||||
//! The attributes are given with respect to the plane of
|
||||
//! projection.
|
||||
//! AHeight : Height of text.
|
||||
//! (Relative to the Normalized Projection
|
||||
//! Coordinates (NPC) Space).
|
||||
//! The other attributes have the following default values:
|
||||
//! AAngle : PI / 2.
|
||||
//! ATp : TP_RIGHT
|
||||
//! AHta : HTA_LEFT
|
||||
//! AVta : VTA_BOTTOM
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT void Text (const TCollection_ExtendedString& AText,
|
||||
const Graphic3d_Vertex& APoint,
|
||||
const Standard_Real AHeight,
|
||||
const Standard_Boolean EvalMinMax = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT virtual void Text (const Standard_CString theTextUtf,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
//! Creates the string <theText> at orientation <theOrientation> in 3D space.
|
||||
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
|
||||
Standard_EXPORT virtual void Text (const TCollection_ExtendedString& theText,
|
||||
const gp_Ax2& theOrientation,
|
||||
const Standard_Real theHeight,
|
||||
const Standard_Real theAngle,
|
||||
const Graphic3d_TextPath theTp,
|
||||
const Graphic3d_HorizontalTextAlignment theHTA,
|
||||
const Graphic3d_VerticalTextAlignment theVTA,
|
||||
const Standard_Boolean theToEvalMinMax = Standard_True,
|
||||
const Standard_Boolean theHasOwnAnchor = Standard_True);
|
||||
|
||||
|
||||
//! Dumps the content of me on the stream <OS>.
|
||||
Standard_EXPORT virtual void Dump (Standard_OStream& OS) const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Creates a group in the structure <AStructure>.
|
||||
|
35
src/Graphic3d/Graphic3d_PolygonOffset.cxx
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) 2016 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 <Graphic3d_PolygonOffset.hxx>
|
||||
|
||||
#include <Aspect.hxx>
|
||||
#include <TCollection.hxx>
|
||||
|
||||
const TCollection_AsciiString Graphic3d_PolygonOffset_ClassName = "Graphic3d_PolygonOffset";
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Graphic3d_PolygonOffset::Dump (Standard_OStream& OS) const
|
||||
{
|
||||
DUMP_START_KEY (OS, Graphic3d_PolygonOffset_ClassName);
|
||||
|
||||
DUMP_VALUES (OS, "Mode", Aspect::PolygonOffsetModeToString (Mode));
|
||||
DUMP_VALUES (OS, "Factor", Factor);
|
||||
DUMP_VALUES (OS, "Units", Units);
|
||||
|
||||
DUMP_STOP_KEY (OS, Graphic3d_PolygonOffset_ClassName);
|
||||
}
|
@@ -15,6 +15,7 @@
|
||||
#define _Graphic3d_PolygonOffset_HeaderFile
|
||||
|
||||
#include <Aspect_PolygonOffsetMode.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
|
||||
//! Polygon offset parameters.
|
||||
struct Graphic3d_PolygonOffset
|
||||
@@ -33,6 +34,10 @@ struct Graphic3d_PolygonOffset
|
||||
&& Factor == theOther.Factor
|
||||
&& Units == theOther.Units;
|
||||
}
|
||||
|
||||
//! Dumps the content of me on the stream <OS>.
|
||||
Standard_EXPORT void Dump (Standard_OStream& OS) const;
|
||||
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_PolygonOffset_HeaderFile
|
||||
|
49
src/Graphic3d/Graphic3d_Text.cxx
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) 2019 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 <Graphic3d_Text.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_Text
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_Text::Graphic3d_Text (const Standard_ShortReal theHeight)
|
||||
: myHeight (theHeight),
|
||||
myHAlign (Graphic3d_HTA_LEFT),
|
||||
myVAlign (Graphic3d_VTA_BOTTOM),
|
||||
myHasPlane (Standard_False),
|
||||
myHasOwnAnchor (Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetOrientation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Text::SetOrientation (const gp_Ax2& theOrientation)
|
||||
{
|
||||
myOrientation = theOrientation;
|
||||
myHasPlane = Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ResetOrientation
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_Text::ResetOrientation()
|
||||
{
|
||||
myOrientation = gp_Ax2();
|
||||
myHasPlane = Standard_False;
|
||||
}
|
125
src/Graphic3d/Graphic3d_Text.hxx
Normal file
@@ -0,0 +1,125 @@
|
||||
// Copyright (c) 2019 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 _Graphic3d_Text_HeaderFile
|
||||
#define _Graphic3d_Text_HeaderFile
|
||||
|
||||
#include <gp_Ax2.hxx>
|
||||
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Font_TextFormatter.hxx>
|
||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||
#include <NCollection_String.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
//! This class allows the definition of a text object for display.
|
||||
//! The text might be defined in one of ways, using:
|
||||
//! - text value and position,
|
||||
//! - text value, orientation and the state whether the text uses position as point of attach.
|
||||
//! - text formatter. Formatter contains text, height and alignment parameter.
|
||||
//!
|
||||
//! This class also has parameters of the text height and H/V alignments.
|
||||
//! More compilated formatting is available using Font_TextFormatter.
|
||||
class Graphic3d_Text : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
|
||||
|
||||
public:
|
||||
|
||||
//! Creates default text parameters.
|
||||
Standard_EXPORT Graphic3d_Text (const Standard_ShortReal theHeight);
|
||||
|
||||
//! Destructor.
|
||||
virtual ~Graphic3d_Text() {}
|
||||
|
||||
//! Returns text value.
|
||||
const NCollection_String& Text() const { return myText; }
|
||||
|
||||
//! Sets text value.
|
||||
void SetText (const NCollection_String& theText) { myText = theText; }
|
||||
|
||||
//! Sets text value.
|
||||
void SetText (const TCollection_AsciiString& theText) { myText = theText.ToCString(); }
|
||||
|
||||
//! Sets text value.
|
||||
void SetText (Standard_CString theText) { myText = theText; }
|
||||
|
||||
//! @return text formatter
|
||||
const Handle(Font_TextFormatter)& TextFormatter() const { return myFormatter; }
|
||||
|
||||
//! @return default formatter of text withing this context
|
||||
void SetTextFormatter (const Handle(Font_TextFormatter)& theFormatter) { myFormatter = theFormatter; }
|
||||
|
||||
//! The 3D point of attachment is projected.
|
||||
//! If the orientation is defined, the text is written in the plane of projection.
|
||||
const gp_Pnt& Position() const { return myOrientation.Location(); }
|
||||
|
||||
//! Sets text point.
|
||||
void SetPosition (const gp_Pnt& thePoint) { myOrientation.SetLocation (thePoint); }
|
||||
|
||||
//! Returns text orientation in 3D space.
|
||||
const gp_Ax2& Orientation() const { return myOrientation; }
|
||||
|
||||
//! Returns true if the text is filled by a point
|
||||
Standard_Boolean HasPlane() const { return myHasPlane; }
|
||||
|
||||
//! Sets text orientation in 3D space.
|
||||
Standard_EXPORT void SetOrientation (const gp_Ax2& theOrientation);
|
||||
|
||||
//! Reset text orientation in 3D space.
|
||||
Standard_EXPORT void ResetOrientation();
|
||||
|
||||
//! Returns true if the text has an anchor point
|
||||
Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchor; }
|
||||
|
||||
//! Returns true if the text has an anchor point
|
||||
void SetOwnAnchorPoint (const Standard_Boolean theHasOwnAnchor) { myHasOwnAnchor = theHasOwnAnchor; }
|
||||
|
||||
//! Sets height of text. (Relative to the Normalized Projection Coordinates (NPC) Space).
|
||||
Standard_ShortReal Height() const { return myHeight; }
|
||||
|
||||
//! Returns height of text
|
||||
void SetHeight (const Standard_ShortReal theHeight) { myHeight = theHeight; }
|
||||
|
||||
//! Returns horizontal alignment of text.
|
||||
Graphic3d_HorizontalTextAlignment HorizontalAlignment() const { return myHAlign; }
|
||||
|
||||
//! Sets horizontal alignment of text.
|
||||
void SetHorizontalAlignment (const Graphic3d_HorizontalTextAlignment theJustification) { myHAlign = theJustification; }
|
||||
|
||||
//! Returns vertical alignment of text.
|
||||
Graphic3d_VerticalTextAlignment VerticalAlignment() const { return myVAlign; }
|
||||
|
||||
//! Sets vertical alignment of text.
|
||||
void SetVerticalAlignment (const Graphic3d_VerticalTextAlignment theJustification) { myVAlign = theJustification; }
|
||||
|
||||
protected:
|
||||
Handle(Font_TextFormatter) myFormatter; //!< text formatter
|
||||
|
||||
NCollection_String myText; //!< text value
|
||||
gp_Ax2 myOrientation; //!< Text orientation in 3D space.
|
||||
|
||||
Standard_ShortReal myHeight; //!< height of text
|
||||
Graphic3d_HorizontalTextAlignment myHAlign; //!< horizontal alignment
|
||||
Graphic3d_VerticalTextAlignment myVAlign; //!< vertical alignment
|
||||
|
||||
Standard_Boolean myHasPlane; //!< Check if text have orientation in 3D space.
|
||||
Standard_Boolean myHasOwnAnchor; //!< flag if text uses position as point of attach
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Graphic3d_Text, Standard_Transient)
|
||||
|
||||
#endif // _Graphic3d_Text_HeaderFile
|
@@ -40,6 +40,8 @@ enum Graphic3d_TextureUnit
|
||||
//Graphic3d_TextureUnit_MetallicRoughness = Graphic3d_TextureUnit_2, //!< metalness+roughness of the material
|
||||
//Graphic3d_TextureUnit_Emissive = Graphic3d_TextureUnit_3, //!< emissive map controls the color and intensity of the light being emitted by the material
|
||||
//Graphic3d_TextureUnit_Occlusion = Graphic3d_TextureUnit_4, //!< occlusion map indicating areas of indirect lighting
|
||||
|
||||
Graphic3d_TextureUnit_EnvMap = Graphic3d_TextureUnit_0 //!< environment cubemap for background
|
||||
};
|
||||
enum
|
||||
{
|
||||
|
@@ -20,9 +20,15 @@
|
||||
//! Describes type of view background.
|
||||
enum Graphic3d_TypeOfBackground
|
||||
{
|
||||
Graphic3d_TOB_NONE,
|
||||
Graphic3d_TOB_NONE = -1,
|
||||
Graphic3d_TOB_GRADIENT,
|
||||
Graphic3d_TOB_TEXTURE
|
||||
Graphic3d_TOB_TEXTURE,
|
||||
Graphic3d_TOB_CUBEMAP
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
Graphic3d_TypeOfBackground_NB = Graphic3d_TOB_CUBEMAP + 1
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_TypeOfBackground_HeaderFile
|
||||
|
@@ -22,7 +22,8 @@ enum Graphic3d_TypeOfTexture
|
||||
{
|
||||
Graphic3d_TOT_1D,
|
||||
Graphic3d_TOT_2D,
|
||||
Graphic3d_TOT_2D_MIPMAP
|
||||
Graphic3d_TOT_2D_MIPMAP,
|
||||
Graphic3d_TOT_CUBEMAP
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_TypeOfTexture_HeaderFile
|
||||
|
@@ -42,7 +42,7 @@
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
|
||||
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||
//
|
||||
static void ComputeSamplePars(const Handle(Adaptor3d_HSurface)& Hsurface,
|
||||
const Standard_Integer nbsu,
|
||||
@@ -259,16 +259,12 @@ void IntCurvesFace_Intersector::InternalCall(const IntCurveSurface_HInter &HICS,
|
||||
for(; anExp.More(); anExp.Next())
|
||||
{
|
||||
TopoDS_Edge anE = TopoDS::Edge(anExp.Current());
|
||||
Standard_Real curtol = BRep_Tool::Tolerance(anE);
|
||||
Standard_Real tol2d = Max(Hsurface->UResolution(curtol), Hsurface->VResolution(curtol));
|
||||
tol2d = Max(tol2d, Tol);
|
||||
Standard_Real f, l;
|
||||
Handle(Geom2d_Curve) aPC = BRep_Tool::CurveOnSurface(anE, face, f, l);
|
||||
Geom2dAPI_ProjectPointOnCurve aProj(Puv, aPC, f, l);
|
||||
if(aProj.NbPoints() > 0)
|
||||
Handle(Geom_Curve) aPC = BRep_Tool::Curve (anE, f, l);
|
||||
GeomAPI_ProjectPointOnCurve aProj (HICSPointindex.Pnt(), aPC, f, l);
|
||||
if (aProj.NbPoints() > 0)
|
||||
{
|
||||
Standard_Real d = aProj.LowerDistance();
|
||||
if(d <= tol2d)
|
||||
if (aProj.LowerDistance() <= maxtol3d)
|
||||
{
|
||||
//Nearest edge is found, state is really ON
|
||||
currentstate = TopAbs_ON;
|
||||
|
@@ -837,141 +837,139 @@ void IntTools_EdgeEdge::FindBestSolution(const Standard_Real aT11,
|
||||
//=======================================================================
|
||||
void IntTools_EdgeEdge::ComputeLineLine()
|
||||
{
|
||||
Standard_Boolean IsParallel, IsCoincide;
|
||||
Standard_Real aSin, aCos, aAng, aTol;
|
||||
Standard_Real aT1, aT2, aT11, aT12, aT21, aT22;
|
||||
gp_Pnt aP11, aP12;
|
||||
gp_Lin aL1, aL2;
|
||||
gp_Dir aD1, aD2;
|
||||
IntTools_CommonPrt aCommonPrt;
|
||||
//
|
||||
IsParallel = Standard_False;
|
||||
IsCoincide = Standard_False;
|
||||
aTol = myTol*myTol;
|
||||
aL1 = myCurve1.Line();
|
||||
aL2 = myCurve2.Line();
|
||||
aD1 = aL1.Position().Direction();
|
||||
aD2 = aL2.Position().Direction();
|
||||
myRange1.Range(aT11, aT12);
|
||||
myRange2.Range(aT21, aT22);
|
||||
//
|
||||
aCommonPrt.SetEdge1(myEdge1);
|
||||
aCommonPrt.SetEdge2(myEdge2);
|
||||
//
|
||||
aCos = aD1.Dot(aD2);
|
||||
aAng = (aCos >= 0.) ? 2.*(1. - aCos) : 2.*(1. + aCos);
|
||||
//
|
||||
if(aAng <= Precision::Angular()) {
|
||||
IsParallel = Standard_True;
|
||||
if(aL1.SquareDistance(aL2.Location()) <= aTol) {
|
||||
IsCoincide = Standard_True;
|
||||
aP11 = ElCLib::Value(aT11, aL1);
|
||||
aP12 = ElCLib::Value(aT12, aL1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
aP11 = ElCLib::Value(aT11, aL1);
|
||||
aP12 = ElCLib::Value(aT12, aL1);
|
||||
if(aL2.SquareDistance(aP11) <= aTol && aL2.SquareDistance(aP12) <= aTol) {
|
||||
IsCoincide = Standard_True;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (IsCoincide) {
|
||||
Standard_Real t21, t22;
|
||||
//
|
||||
t21 = ElCLib::Parameter(aL2, aP11);
|
||||
t22 = ElCLib::Parameter(aL2, aP12);
|
||||
if((t21 > aT22 && t22 > aT22) || (t21 < aT21 && t22 < aT21)) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
Standard_Real temp;
|
||||
if(t21 > t22) {
|
||||
temp = t21;
|
||||
t21 = t22;
|
||||
t22 = temp;
|
||||
}
|
||||
//
|
||||
if(t21 >= aT21) {
|
||||
if(t22 <= aT22) {
|
||||
aCommonPrt.SetRange1(aT11, aT12);
|
||||
aCommonPrt.SetAllNullFlag(Standard_True);
|
||||
aCommonPrt.AppendRange2(t21, t22);
|
||||
}
|
||||
else {
|
||||
aCommonPrt.SetRange1(aT11, aT12 - (t22 - aT22));
|
||||
aCommonPrt.AppendRange2(t21, aT22);
|
||||
}
|
||||
}
|
||||
else {
|
||||
aCommonPrt.SetRange1(aT11 + (aT21 - t21), aT12);
|
||||
aCommonPrt.AppendRange2(aT21, t22);
|
||||
}
|
||||
aCommonPrt.SetType(TopAbs_EDGE);
|
||||
myCommonParts.Append(aCommonPrt);
|
||||
return;
|
||||
}
|
||||
//
|
||||
if (IsParallel) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
Standard_Real aTol = myTol * myTol;
|
||||
|
||||
gp_Lin aL1 = myCurve1.Line();
|
||||
gp_Lin aL2 = myCurve2.Line();
|
||||
|
||||
gp_Dir aD1 = aL1.Direction();
|
||||
gp_Dir aD2 = aL2.Direction();
|
||||
|
||||
Standard_Real anAngle = aD1.Angle (aD2);
|
||||
Standard_Boolean IsCoincide = anAngle < Precision::Angular();
|
||||
if (IsCoincide)
|
||||
{
|
||||
TopoDS_Iterator aIt1, aIt2;
|
||||
aIt1.Initialize(myEdge1);
|
||||
for (; aIt1.More(); aIt1.Next()) {
|
||||
const TopoDS_Shape& aV1 = aIt1.Value();
|
||||
aIt2.Initialize(myEdge2);
|
||||
for (; aIt2.More(); aIt2.Next()) {
|
||||
const TopoDS_Shape& aV2 = aIt2.Value();
|
||||
if (aV2.IsSame(aV1)) {
|
||||
if (aL1.SquareDistance (aL2.Location()) > aTol)
|
||||
return;
|
||||
}
|
||||
|
||||
Standard_Real aT11, aT12, aT21, aT22;
|
||||
myRange1.Range (aT11, aT12);
|
||||
myRange2.Range (aT21, aT22);
|
||||
|
||||
gp_Pnt aP11 = ElCLib::Value (aT11, aL1);
|
||||
gp_Pnt aP12 = ElCLib::Value (aT12, aL1);
|
||||
|
||||
if (!IsCoincide)
|
||||
{
|
||||
gp_Pnt O2 (aL2.Location());
|
||||
if (!Precision::IsInfinite (aT21) && !Precision::IsInfinite (aT22))
|
||||
O2 = ElCLib::Value ((aT21 + aT22) / 2., aL2);
|
||||
|
||||
gp_Vec aVec1 = gp_Vec (O2, aP11).Crossed (aD2);
|
||||
gp_Vec aVec2 = gp_Vec (O2, aP12).Crossed (aD2);
|
||||
|
||||
Standard_Real aSqDist1 = aVec1.SquareMagnitude();
|
||||
Standard_Real aSqDist2 = aVec2.SquareMagnitude();
|
||||
|
||||
IsCoincide = (aSqDist1 <= aTol && aSqDist2 <= aTol);
|
||||
|
||||
if (!IsCoincide && aVec1.Dot (aVec2) > 0)
|
||||
// the lines do not intersect
|
||||
return;
|
||||
}
|
||||
|
||||
IntTools_CommonPrt aCommonPrt;
|
||||
aCommonPrt.SetEdge1 (myEdge1);
|
||||
aCommonPrt.SetEdge2 (myEdge2);
|
||||
|
||||
if (IsCoincide)
|
||||
{
|
||||
Standard_Real t21 = ElCLib::Parameter (aL2, aP11);
|
||||
Standard_Real t22 = ElCLib::Parameter (aL2, aP12);
|
||||
|
||||
if ((t21 > aT22 && t22 > aT22) || (t21 < aT21 && t22 < aT21))
|
||||
// projections are out of range
|
||||
return;
|
||||
|
||||
if (t21 > t22)
|
||||
std::swap (t21, t22);
|
||||
|
||||
if (t21 >= aT21)
|
||||
{
|
||||
if (t22 <= aT22)
|
||||
{
|
||||
aCommonPrt.SetRange1 (aT11, aT12);
|
||||
aCommonPrt.SetAllNullFlag (Standard_True);
|
||||
aCommonPrt.AppendRange2 (t21, t22);
|
||||
}
|
||||
else
|
||||
{
|
||||
aCommonPrt.SetRange1 (aT11, aT12 - (t22 - aT22));
|
||||
aCommonPrt.AppendRange2 (t21, aT22);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aCommonPrt.SetRange1 (aT11 + (aT21 - t21), aT12);
|
||||
aCommonPrt.AppendRange2 (aT21, t22);
|
||||
}
|
||||
aCommonPrt.SetType (TopAbs_EDGE);
|
||||
myCommonParts.Append (aCommonPrt);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
gp_Vec O1O2 (aL1.Location(), aL2.Location());
|
||||
gp_XYZ aCross = aD1.XYZ().Crossed (aD2.XYZ());
|
||||
Standard_Real aDistLL = O1O2.Dot (gp_Vec (aCross.Normalized()));
|
||||
if (Abs (aDistLL) > myTol)
|
||||
return;
|
||||
|
||||
{
|
||||
// Fast check that no intersection needs to be added
|
||||
for (TopoDS_Iterator it1 (myEdge1); it1.More(); it1.Next())
|
||||
{
|
||||
for (TopoDS_Iterator it2 (myEdge2); it2.More(); it2.Next())
|
||||
{
|
||||
if (it1.Value().IsSame (it2.Value()))
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
aSin = 1. - aCos*aCos;
|
||||
gp_Pnt O1 = aL1.Location();
|
||||
gp_Pnt O2 = aL2.Location();
|
||||
gp_Vec O1O2 (O1, O2);
|
||||
//
|
||||
aT2 = (aD1.XYZ()*(O1O2.Dot(aD1))-(O1O2.XYZ())).Dot(aD2.XYZ());
|
||||
aT2 /= aSin;
|
||||
//
|
||||
if(aT2 < aT21 || aT2 > aT22) {
|
||||
|
||||
Standard_Real aSqSin = aCross.SquareModulus();
|
||||
Standard_Real aT2 = (aD1.XYZ() * (O1O2.Dot (aD1)) - (O1O2.XYZ())).Dot (aD2.XYZ());
|
||||
aT2 /= aSqSin;
|
||||
|
||||
if (aT2 < aT21 || aT2 > aT22)
|
||||
// out of range
|
||||
return;
|
||||
}
|
||||
//
|
||||
gp_Pnt aP2(ElCLib::Value(aT2, aL2));
|
||||
aT1 = (gp_Vec(O1, aP2)).Dot(aD1);
|
||||
//
|
||||
if(aT1 < aT11 || aT1 > aT12) {
|
||||
|
||||
gp_Pnt aP2 = ElCLib::Value (aT2, aL2);
|
||||
Standard_Real aT1 = gp_Vec (aL1.Location(), aP2).Dot (aD1);
|
||||
|
||||
if (aT1 < aT11 || aT1 > aT12)
|
||||
// out of range
|
||||
return;
|
||||
}
|
||||
//
|
||||
gp_Pnt aP1(ElCLib::Value(aT1, aL1));
|
||||
Standard_Real aDist = aP1.SquareDistance(aP2);
|
||||
//
|
||||
if (aDist > aTol) {
|
||||
|
||||
gp_Pnt aP1 = ElCLib::Value (aT1, aL1);
|
||||
Standard_Real aDist = aP1.SquareDistance (aP2);
|
||||
|
||||
if (aDist > aTol)
|
||||
// no intersection
|
||||
return;
|
||||
}
|
||||
//
|
||||
|
||||
// compute correct range on the edges
|
||||
Standard_Real anAngle, aDt1, aDt2;
|
||||
//
|
||||
anAngle = aD1.Angle(aD2);
|
||||
//
|
||||
aDt1 = IntTools_Tools::ComputeIntRange(myTol1, myTol2, anAngle);
|
||||
aDt2 = IntTools_Tools::ComputeIntRange(myTol2, myTol1, anAngle);
|
||||
//
|
||||
aCommonPrt.SetRange1(aT1 - aDt1, aT1 + aDt1);
|
||||
aCommonPrt.AppendRange2(aT2 - aDt2, aT2 + aDt2);
|
||||
aCommonPrt.SetType(TopAbs_VERTEX);
|
||||
aCommonPrt.SetVertexParameter1(aT1);
|
||||
aCommonPrt.SetVertexParameter2(aT2);
|
||||
myCommonParts.Append(aCommonPrt);
|
||||
Standard_Real aDt1 = IntTools_Tools::ComputeIntRange (myTol1, myTol2, anAngle);
|
||||
Standard_Real aDt2 = IntTools_Tools::ComputeIntRange (myTol2, myTol1, anAngle);
|
||||
|
||||
aCommonPrt.SetRange1 (aT1 - aDt1, aT1 + aDt1);
|
||||
aCommonPrt.AppendRange2 (aT2 - aDt2, aT2 + aDt2);
|
||||
aCommonPrt.SetType (TopAbs_VERTEX);
|
||||
aCommonPrt.SetVertexParameter1 (aT1);
|
||||
aCommonPrt.SetVertexParameter2 (aT2);
|
||||
myCommonParts.Append (aCommonPrt);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <Graphic3d_ArrayOfPoints.hxx>
|
||||
#include <Graphic3d_AspectMarker3d.hxx>
|
||||
#include <Graphic3d_AspectText3d.hxx>
|
||||
#include <Graphic3d_Text.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <MeshVS_Buffer.hxx>
|
||||
@@ -251,8 +252,11 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
|
||||
}
|
||||
|
||||
aPnts.Append (Graphic3d_Vec3 ((float )X, (float )Y, (float )Z));
|
||||
Graphic3d_Vertex aPoint (X, Y, Z);
|
||||
aTextGroup->Text (aStr.ToCString(), aPoint, aHeight);
|
||||
|
||||
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)aHeight);
|
||||
aText->SetText (aStr);
|
||||
aText->SetPosition (gp_Pnt (X, Y, Z));
|
||||
aTextGroup->AddText(aText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,21 @@
|
||||
Message.cxx
|
||||
Message.hxx
|
||||
Message_Alert.cxx
|
||||
Message_Alert.hxx
|
||||
Message_AlertExtended.cxx
|
||||
Message_AlertExtended.hxx
|
||||
Message_Alerts.hxx
|
||||
Message_Algorithm.cxx
|
||||
Message_Algorithm.hxx
|
||||
Message_Algorithm.lxx
|
||||
Message_Attribute.cxx
|
||||
Message_Attribute.hxx
|
||||
Message_AttributeObject.cxx
|
||||
Message_AttributeObject.hxx
|
||||
Message_AttributeStream.cxx
|
||||
Message_AttributeStream.hxx
|
||||
Message_CompositeAlerts.cxx
|
||||
Message_CompositeAlerts.hxx
|
||||
Message_ExecStatus.hxx
|
||||
Message_Gravity.hxx
|
||||
Message_HArrayOfMsg.hxx
|
||||
@@ -15,6 +28,9 @@ Message_Msg.hxx
|
||||
Message_Msg.lxx
|
||||
Message_MsgFile.cxx
|
||||
Message_MsgFile.hxx
|
||||
Message_PerfMeter.cxx
|
||||
Message_PerfMeter.hxx
|
||||
Message_PerfMeterMode.hxx
|
||||
Message_Printer.cxx
|
||||
Message_Printer.hxx
|
||||
Message_PrinterOStream.cxx
|
||||
@@ -32,8 +48,8 @@ Message_SequenceOfPrinters.hxx
|
||||
Message_SequenceOfProgressScale.hxx
|
||||
Message_Status.hxx
|
||||
Message_StatusType.hxx
|
||||
Message_Alert.cxx
|
||||
Message_Alert.hxx
|
||||
Message_ListOfAlert.hxx
|
||||
Message_Report.cxx
|
||||
Message_Report.hxx
|
||||
Message_ReportCallBack.cxx
|
||||
Message_ReportCallBack.hxx
|
||||
|
@@ -49,3 +49,342 @@ TCollection_AsciiString Message::FillTime (const Standard_Integer hour,
|
||||
Sprintf (t, "%.2fs", second);
|
||||
return TCollection_AsciiString (t);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
static Standard_CString Message_Table_PrintGravityEnum[5] =
|
||||
{
|
||||
"TRACE", "INFO", "WARNING", "ALARM", "FAIL"
|
||||
};
|
||||
|
||||
static Standard_CString Message_Table_PrintPerfMeterModeEnum[10] =
|
||||
{
|
||||
"NONE", "USER_TIME_CPU", "SYSTEM_TIME_CPU", "MEM_PRIVATE", "MEM_VIRTUAL",
|
||||
"MEM_WORKING_SET", "MEM_WORKING_SET_PEAK", "MEM_SWAP_USAGE", "MEM_SWAP_USAGE_PEAK", "MEM_HEAP_USAGE"
|
||||
};
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GravityToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_CString Message::GravityToString (const Message_Gravity theGravity)
|
||||
{
|
||||
return Message_Table_PrintGravityEnum[theGravity];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GravityFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Message::GravityFromString (const Standard_CString theGravityString,
|
||||
Message_Gravity& theGravity)
|
||||
{
|
||||
TCollection_AsciiString aName (theGravityString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aGravityIter = 0; aGravityIter <= Message_Fail; ++aGravityIter)
|
||||
{
|
||||
Standard_CString aGravityName = Message_Table_PrintGravityEnum[aGravityIter];
|
||||
if (aName == aGravityName)
|
||||
{
|
||||
theGravity = Message_Gravity (aGravityIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PerfMeterModeToString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_CString Message::PerfMeterModeToString (const Message_PerfMeterMode theValue)
|
||||
{
|
||||
return Message_Table_PrintPerfMeterModeEnum[theValue];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PerfMeterModeFromString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Message::PerfMeterModeFromString (const Standard_CString theString,
|
||||
Message_PerfMeterMode& theValue)
|
||||
{
|
||||
TCollection_AsciiString aName (theString);
|
||||
aName.UpperCase();
|
||||
for (Standard_Integer aModeIter = 0; aModeIter <= Message_PerfMeterMode_MemHeapUsage; ++aModeIter)
|
||||
{
|
||||
Standard_CString aModeName = Message_Table_PrintPerfMeterModeEnum[aModeIter];
|
||||
if (aName == aModeName)
|
||||
{
|
||||
theValue = Message_PerfMeterMode (aModeIter);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetPointerInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Message::TransientToString (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
|
||||
{
|
||||
if (thePointer.IsNull())
|
||||
return TCollection_AsciiString();
|
||||
|
||||
return PointerToString(thePointer.operator->(), isShortInfo);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetPointerInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Message::PointerToString (const void* thePointer, const bool isShortInfo)
|
||||
{
|
||||
std::ostringstream aPtrStr;
|
||||
aPtrStr << thePointer;
|
||||
if (!isShortInfo)
|
||||
return aPtrStr.str().c_str();
|
||||
|
||||
TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
|
||||
for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
|
||||
{
|
||||
if (anInfoPtr.Value(aSymbolId) != '0')
|
||||
{
|
||||
anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
|
||||
anInfoPtr.Prepend("0x");
|
||||
return anInfoPtr;
|
||||
}
|
||||
}
|
||||
return aPtrStr.str().c_str();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : StrVectorToString
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Message::StrVectorToString
|
||||
(const NCollection_Vector<TCollection_AsciiString>& theValues)
|
||||
{
|
||||
TCollection_AsciiString aValue;
|
||||
for (NCollection_Vector<TCollection_AsciiString>::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next())
|
||||
{
|
||||
aValue += aValuesIt.Value();
|
||||
if (aValuesIt.More())
|
||||
aValue += VectorSeparator();
|
||||
}
|
||||
return aValue;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : StrVectorFromString
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Message::StrVectorFromString
|
||||
(const TCollection_AsciiString& theValue,
|
||||
NCollection_Vector<TCollection_AsciiString>& theValues)
|
||||
{
|
||||
TCollection_AsciiString aCurrentString = theValue, aValueString;
|
||||
|
||||
while (!aCurrentString.IsEmpty())
|
||||
{
|
||||
Standard_Integer aPosition = aCurrentString.Search (", ");
|
||||
aValueString = aCurrentString;
|
||||
if (aPosition > 0)
|
||||
aCurrentString = aValueString.Split (aPosition - 1);
|
||||
theValues.Append (aValueString.RealValue());
|
||||
if (aPosition > 0)
|
||||
aCurrentString = aCurrentString.Split (2);
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : RealVectorToString
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Message::RealVectorToString
|
||||
(const NCollection_Vector<Standard_Real>& theValues)
|
||||
{
|
||||
TCollection_AsciiString aValue = ("(");
|
||||
|
||||
for (NCollection_Vector<Standard_Real>::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next())
|
||||
{
|
||||
aValue += aValuesIt.Value();
|
||||
if (aValuesIt.More())
|
||||
aValue += VectorSeparator();
|
||||
}
|
||||
aValue += ")";
|
||||
|
||||
return aValue;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : RealVectorFromString
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Message::RealVectorFromString
|
||||
(const TCollection_AsciiString& theValue,
|
||||
NCollection_Vector<Standard_Real>& theValues)
|
||||
{
|
||||
TCollection_AsciiString aCurrentString = theValue, aValueString;
|
||||
|
||||
Standard_Integer aPosition = aCurrentString.Search ("(");
|
||||
if (aPosition != 1)
|
||||
return Standard_False;
|
||||
aCurrentString = aCurrentString.Split (aPosition);
|
||||
|
||||
aPosition = aCurrentString.Search (")");
|
||||
if (aPosition != 1)
|
||||
return Standard_False;
|
||||
aValueString = aCurrentString.Split (aPosition);
|
||||
|
||||
|
||||
while (!aCurrentString.IsEmpty())
|
||||
{
|
||||
// x value
|
||||
aPosition = aCurrentString.Search (", ");
|
||||
aValueString = aCurrentString;
|
||||
if (aPosition > 0)
|
||||
aCurrentString = aValueString.Split (aPosition - 1);
|
||||
theValues.Append (aValueString.RealValue());
|
||||
if (aPosition > 0)
|
||||
aCurrentString = aCurrentString.Split (2);
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : CoordVectorToString
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Message::CoordVectorToString
|
||||
(const NCollection_Vector<Standard_Real>& theValues)
|
||||
{
|
||||
TCollection_AsciiString aValue = ("(");
|
||||
aValue += RealVectorToString (theValues);
|
||||
aValue += ")";
|
||||
|
||||
return aValue;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : CoordVectorFromString
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Message::CoordVectorFromString
|
||||
(const TCollection_AsciiString& theValue,
|
||||
NCollection_Vector<Standard_Real>& theValues)
|
||||
{
|
||||
TCollection_AsciiString aCurrentString = theValue, aValueString;
|
||||
|
||||
Standard_Integer aPosition = aCurrentString.Search ("(");
|
||||
if (aPosition != 1)
|
||||
return Standard_False;
|
||||
aCurrentString = aCurrentString.Split (aPosition);
|
||||
|
||||
aPosition = aCurrentString.Search (")");
|
||||
if (aPosition != 1)
|
||||
return Standard_False;
|
||||
aValueString = aCurrentString.Split (aPosition);
|
||||
|
||||
return RealVectorFromString (aCurrentString, theValues);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ColorVectorToString
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TCollection_AsciiString Message::ColorVectorToString
|
||||
(const NCollection_Vector<Standard_Real>& theValues)
|
||||
{
|
||||
TCollection_AsciiString aValue = ("[");
|
||||
aValue += RealVectorToString (theValues);
|
||||
aValue += "]";
|
||||
|
||||
return aValue;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ColorVectorFromString
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean Message::ColorVectorFromString
|
||||
(const TCollection_AsciiString& theValue,
|
||||
NCollection_Vector<Standard_Real>& theValues)
|
||||
{
|
||||
TCollection_AsciiString aCurrentString = theValue, aValueString;
|
||||
|
||||
Standard_Integer aPosition = aCurrentString.Search ("[");
|
||||
if (aPosition != 1)
|
||||
return Standard_False;
|
||||
aCurrentString = aCurrentString.Split (aPosition);
|
||||
|
||||
aPosition = aCurrentString.Search ("]");
|
||||
if (aPosition != 1)
|
||||
return Standard_False;
|
||||
aValueString = aCurrentString.Split (aPosition);
|
||||
|
||||
return RealVectorFromString (aCurrentString, theValues);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ConvertStream
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Message::ConvertStream (const Standard_SStream& theStream,
|
||||
Standard_Integer& theColumnCount,
|
||||
NCollection_Vector<TCollection_AsciiString>& theValues)
|
||||
{
|
||||
TCollection_AsciiString aStream (theStream.str().c_str());
|
||||
Standard_Character aSeparator = Message::DumpSeparator();
|
||||
Standard_Integer aColumnCount = 0;
|
||||
|
||||
TCollection_AsciiString aCurrentString = aStream;
|
||||
Standard_Integer aPosition = aCurrentString.Search (aSeparator);
|
||||
if (aPosition >= 1)
|
||||
{
|
||||
TCollection_AsciiString aTailString = aCurrentString.Split (aPosition);
|
||||
Standard_Boolean aClassNameFound = Standard_False;
|
||||
while (!aCurrentString.IsEmpty())
|
||||
{
|
||||
TCollection_AsciiString aValueString = aCurrentString;
|
||||
aPosition = aValueString.Search (aSeparator);
|
||||
if (aPosition < 0 )
|
||||
break;
|
||||
aCurrentString = aValueString.Split (aPosition - 1);
|
||||
|
||||
if (!aColumnCount)
|
||||
{
|
||||
if (!aClassNameFound)
|
||||
aClassNameFound = Standard_True;
|
||||
else
|
||||
{
|
||||
if (!aValueString.IsIntegerValue())
|
||||
break; // not correct Dump, in correct the first value is number of property columns
|
||||
aColumnCount = aValueString.IntegerValue();
|
||||
}
|
||||
}
|
||||
else
|
||||
theValues.Append (aValueString);
|
||||
|
||||
if (aTailString.IsEmpty())
|
||||
break;
|
||||
aCurrentString = aTailString;
|
||||
aPosition = aCurrentString.Search (aSeparator);
|
||||
if (aPosition < 0 )
|
||||
{
|
||||
aCurrentString = aTailString;
|
||||
aTailString = TCollection_AsciiString();
|
||||
}
|
||||
else
|
||||
aTailString = aCurrentString.Split (aPosition);
|
||||
}
|
||||
}
|
||||
theColumnCount = aColumnCount;
|
||||
}
|
||||
|
@@ -17,14 +17,19 @@
|
||||
#ifndef _Message_HeaderFile
|
||||
#define _Message_HeaderFile
|
||||
|
||||
#include <Message_Gravity.hxx>
|
||||
#include <Message_PerfMeterMode.hxx>
|
||||
#include <NCollection_Vector.hxx>
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
class Message_Messenger;
|
||||
class TCollection_AsciiString;
|
||||
class Message_Msg;
|
||||
class Message_MsgFile;
|
||||
class Message_Messenger;
|
||||
@@ -59,8 +64,129 @@ public:
|
||||
//! 3. (0, 0, 4.5 ) returns "4.50s"
|
||||
Standard_EXPORT static TCollection_AsciiString FillTime (const Standard_Integer Hour, const Standard_Integer Minute, const Standard_Real Second);
|
||||
|
||||
//! Returns the string name for a given gravity.
|
||||
//! @param Gravity gravity type
|
||||
//! @return string identifier from the list Message_Trace, Message_Info, Message_Warning, Message_Alarm and Message_Fail
|
||||
Standard_EXPORT static Standard_CString GravityToString (const Message_Gravity theGravity);
|
||||
|
||||
//! Returns the gravity type from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theGravityString string identifier
|
||||
//! @return gravity or Message_Trace if string identifier is invalid
|
||||
static Message_Gravity GravityFromString (const Standard_CString theGravityString)
|
||||
{
|
||||
Message_Gravity aGravity = Message_Trace;
|
||||
GravityFromString (theGravityString, aGravity);
|
||||
return aGravity;
|
||||
}
|
||||
|
||||
//! Determines the gravity from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theGravityString string identifier
|
||||
//! @param theGravity detected shape type
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean GravityFromString (const Standard_CString theGravityString,
|
||||
Message_Gravity& theGravity);
|
||||
|
||||
//! Returns the string name for a perf meter mode.
|
||||
//! @param theValue mode
|
||||
//! @return string identifier
|
||||
Standard_EXPORT static Standard_CString PerfMeterModeToString (const Message_PerfMeterMode theValue);
|
||||
|
||||
//! Returns the enum value from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theString string identifier
|
||||
//! @return enum or Message_PerfMeterMode_None if string identifier is invalid
|
||||
static Message_PerfMeterMode PerfMeterModeFromString (const Standard_CString theString)
|
||||
{
|
||||
Message_PerfMeterMode aValue = Message_PerfMeterMode_None;
|
||||
PerfMeterModeFromString (theString, aValue);
|
||||
return aValue;
|
||||
}
|
||||
|
||||
//! Returns the enum value from the given string identifier (using case-insensitive comparison).
|
||||
//! @param theString string identifier
|
||||
//! @return enum or Message_PerfMeterMode_None if string identifier is invalid
|
||||
//! @return TRUE if string identifier is known
|
||||
Standard_EXPORT static Standard_Boolean PerfMeterModeFromString (const Standard_CString theString,
|
||||
Message_PerfMeterMode& theValue);
|
||||
|
||||
|
||||
//! Returns separator symbol of Dump information
|
||||
static Standard_Character DumpSeparator() { return '\\'; }
|
||||
|
||||
//! Returns separator symbol of values vector union
|
||||
static TCollection_AsciiString VectorSeparator() { return " ,"; }
|
||||
|
||||
//! Convert handle pointer to string value
|
||||
//! \param thePointer a pointer
|
||||
//! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
|
||||
//! \return the string value
|
||||
Standard_EXPORT static TCollection_AsciiString TransientToString (const Handle(Standard_Transient)& thePointer,
|
||||
const bool isShortInfo = true);
|
||||
|
||||
//! Convert pointer to string value
|
||||
//! \param thePointer a pointer
|
||||
//! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
|
||||
//! \return the string value
|
||||
Standard_EXPORT static TCollection_AsciiString PointerToString (const void* thePointer,
|
||||
const bool isShortInfo = true);
|
||||
//! Convert vector of real values to string, separator is vector separator
|
||||
//! \param thePointer a container of real values
|
||||
//! \return the string value
|
||||
Standard_EXPORT static TCollection_AsciiString StrVectorToString
|
||||
(const NCollection_Vector<TCollection_AsciiString>& theValues);
|
||||
|
||||
//! Convert string to vector of real values, separator is vector separator
|
||||
//! \param thePointer a container of real values
|
||||
//! \return the string value
|
||||
Standard_EXPORT static Standard_Boolean StrVectorFromString
|
||||
(const TCollection_AsciiString& theValue,
|
||||
NCollection_Vector<TCollection_AsciiString>& theValues);
|
||||
|
||||
//! Convert vector of real values to string, separator is vector separator
|
||||
//! \param thePointer a container of real values
|
||||
//! \return the string value
|
||||
Standard_EXPORT static TCollection_AsciiString RealVectorToString
|
||||
(const NCollection_Vector<Standard_Real>& theValues);
|
||||
|
||||
//! Convert string to vector of real values, separator is vector separator
|
||||
//! \param thePointer a container of real values
|
||||
//! \return the string value
|
||||
Standard_EXPORT static Standard_Boolean RealVectorFromString
|
||||
(const TCollection_AsciiString& theValue,
|
||||
NCollection_Vector<Standard_Real>& theValues);
|
||||
|
||||
//! Convert vector of real values to string, separator is vector separator
|
||||
//! \param thePointer a container of real values
|
||||
//! \return the string value
|
||||
Standard_EXPORT static TCollection_AsciiString CoordVectorToString
|
||||
(const NCollection_Vector<Standard_Real>& theValues);
|
||||
|
||||
//! Convert string to vector of real values, separator is vector separator
|
||||
//! \param thePointer a container of real values
|
||||
//! \return the string value
|
||||
Standard_EXPORT static Standard_Boolean CoordVectorFromString
|
||||
(const TCollection_AsciiString& theValue,
|
||||
NCollection_Vector<Standard_Real>& theValues);
|
||||
|
||||
//! Convert vector of real values to string, separator is vector separator
|
||||
//! \param thePointer a container of real values
|
||||
//! \return the string value
|
||||
Standard_EXPORT static TCollection_AsciiString ColorVectorToString
|
||||
(const NCollection_Vector<Standard_Real>& theValues);
|
||||
|
||||
//! Convert string to vector of real values, separator is vector separator
|
||||
//! \param thePointer a container of real values
|
||||
//! \return the string value
|
||||
Standard_EXPORT static Standard_Boolean ColorVectorFromString
|
||||
(const TCollection_AsciiString& theValue,
|
||||
NCollection_Vector<Standard_Real>& theValues);
|
||||
|
||||
//! Converts stream to vector of values and column count
|
||||
//! \param theStream stream value
|
||||
//! \param theColumnCount [out] number of columns
|
||||
//! \param theValues [out] container of split values
|
||||
static Standard_EXPORT void ConvertStream (const Standard_SStream& theStream,
|
||||
Standard_Integer& theColumnCount,
|
||||
NCollection_Vector<TCollection_AsciiString>& theValues);
|
||||
|
||||
protected:
|
||||
|
||||
|
81
src/Message/Message_AlertExtended.cxx
Normal file
@@ -0,0 +1,81 @@
|
||||
// Created on: 2018-06-10
|
||||
// Created by: Natalia Ermolaeva
|
||||
// Copyright (c) 2017 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 <Message_AlertExtended.hxx>
|
||||
#include <Message_Attribute.hxx>
|
||||
#include <Message_CompositeAlerts.hxx>
|
||||
#include <Message_Report.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
#include <Standard_Assert.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Message_AlertExtended,Message_Alert)
|
||||
|
||||
//=======================================================================
|
||||
//function : GetMessageKey
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_CString Message_AlertExtended::GetMessageKey () const
|
||||
{
|
||||
if (myAttribute.IsNull())
|
||||
return Message_Alert::GetMessageKey();
|
||||
|
||||
return myAttribute->GetMessageKey();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetCompositeAlerts
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle (Message_CompositeAlerts) Message_AlertExtended::GetCompositeAlerts (const Standard_Boolean isCreate)
|
||||
{
|
||||
if (myCompositAlerts.IsNull() && isCreate)
|
||||
myCompositAlerts = new Message_CompositeAlerts();
|
||||
|
||||
return myCompositAlerts;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsMetricValid
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean Message_AlertExtended::IsMetricValid() const
|
||||
{
|
||||
return fabs (myMetricStart - GetUndefinedMetric()) > Precision::Confusion() &&
|
||||
fabs (myMetricStop - GetUndefinedMetric()) > Precision::Confusion();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddAlert
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Message_Alert) Message_AlertExtended::AddAlert (const Handle(Message_Report)& theReport,
|
||||
const Handle(Message_Attribute)& theAttribute,
|
||||
Message_PerfMeter* thePerfMeter,
|
||||
const Handle(Message_Alert)& theParentAlert)
|
||||
{
|
||||
if (!theReport->IsActive (Message_Info))
|
||||
return Handle(Message_Alert)();
|
||||
|
||||
Handle(Message_AlertExtended) anAlert = new Message_AlertExtended();
|
||||
anAlert->SetAttribute (theAttribute);
|
||||
theReport->AddAlert (Message_Info, anAlert, thePerfMeter, theParentAlert);
|
||||
|
||||
return anAlert;
|
||||
}
|
133
src/Message/Message_AlertExtended.hxx
Normal file
@@ -0,0 +1,133 @@
|
||||
// Created on: 2018-06-10
|
||||
// Created by: Natalia Ermolaeva
|
||||
// Copyright (c) 2017 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 _Message_AlertExtended_HeaderFile
|
||||
#define _Message_AlertExtended_HeaderFile
|
||||
|
||||
#include <Message_Alert.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
class Message_Attribute;
|
||||
class Message_PerfMeter;
|
||||
class Message_Report;
|
||||
|
||||
DEFINE_STANDARD_HANDLE(Message_AlertExtended, Message_Alert)
|
||||
|
||||
class Message_CompositeAlerts;
|
||||
|
||||
//! Inherited class of Message_Alert with some additional information.
|
||||
//!
|
||||
//! It has Message_Attributes to provide the alert name, description and
|
||||
//! other custom information
|
||||
//!
|
||||
//! It is possible to set performance meter into alert to store time/memory metric information
|
||||
//! spent between the next alert adding. Also time of child alerts are collected
|
||||
//!
|
||||
//! It has a container of composite alerts, if the alert might provide
|
||||
//! sub-alerts collecting.
|
||||
//!
|
||||
|
||||
class Message_AlertExtended : public Message_Alert
|
||||
{
|
||||
public:
|
||||
//! Empty constructor
|
||||
Standard_EXPORT Message_AlertExtended()
|
||||
: Message_Alert(), myMetricStart (GetUndefinedMetric()), myMetricStop (GetUndefinedMetric()) {}
|
||||
|
||||
//! Return a C string to be used as a key for generating text user
|
||||
//! messages describing this alert.
|
||||
//! The messages are generated with help of Message_Msg class, in
|
||||
//! Message_Report::Dump().
|
||||
//! Base implementation returns dynamic type name of the instance.
|
||||
virtual Standard_EXPORT Standard_CString GetMessageKey () const;
|
||||
|
||||
//! Sets container of the alert attributes
|
||||
//! \param theAttributes an attribute values
|
||||
void SetAttribute (const Handle(Message_Attribute)& theAttribute) { myAttribute = theAttribute; }
|
||||
|
||||
//! Returns container of the alert attributes
|
||||
//! \param theAttributes an attribute values
|
||||
const Handle(Message_Attribute)& Attribute () const { return myAttribute; }
|
||||
|
||||
//! Returns class provided hierarchy of alerts if created or create if the parameter is true
|
||||
//! \param isCreate if composite alert has not been created for this alert, it should be created
|
||||
//! \return instance or NULL
|
||||
Standard_EXPORT Handle (Message_CompositeAlerts) GetCompositeAlerts (const Standard_Boolean isCreate = Standard_False);
|
||||
|
||||
//! Returns performance meter
|
||||
//! \return instance or NULL
|
||||
Message_PerfMeter* GetPerfMeter() { return myPerfMeter; }
|
||||
|
||||
//! Returns true if metric is computed
|
||||
//! @return value
|
||||
Standard_EXPORT Standard_Boolean IsMetricValid() const;
|
||||
|
||||
//! Returns the alert cumulative metric. It includes time/mem of sub alerts
|
||||
//! @return value
|
||||
Standard_Real MetricStart() const { return myMetricStart; }
|
||||
|
||||
//! Returns the alert cumulative metric. It includes time/mem of sub alerts
|
||||
//! @return value
|
||||
Standard_Real MetricStop() const { return myMetricStop; }
|
||||
|
||||
//! Sets cumulative time/mem of alert
|
||||
//! \param theCumulativeMetric time/mem of the alert
|
||||
void SetMetricValues (const Standard_Real theStartValue, const Standard_Real theStopValue)
|
||||
{ myMetricStart = theStartValue; myMetricStop = theStopValue; }
|
||||
|
||||
//! Return true if this type of alert can be merged with other
|
||||
//! of the same type to avoid duplication.
|
||||
//! Basis implementation returns true.
|
||||
virtual Standard_EXPORT Standard_Boolean SupportsMerge () const { return Standard_False; }
|
||||
|
||||
//! Returns default value of the time/mem when it is not defined
|
||||
//! \return integer value
|
||||
static Standard_Real GetUndefinedMetric() { return -1.0; }
|
||||
|
||||
//! Creates new instance of the alert and put it into report with Message_Info gravity.
|
||||
//! It does nothing if such kind of gravity is not active in the report
|
||||
//! @param theReport the message report where new alert is placed
|
||||
//! @param theAttribute container of additional values of the alert
|
||||
//! @param thePerfMeter performance meter calculates the alert spent time and participate in searching the last alert if needed
|
||||
//! @param theParentAlert parent for the new alert, or alert is placed under the report
|
||||
//! @return created alert or NULL if Message_Info is not active in report
|
||||
static Standard_EXPORT Handle(Message_Alert) AddAlert (const Handle(Message_Report)& theReport,
|
||||
const Handle(Message_Attribute)& theAttribute,
|
||||
Message_PerfMeter* thePerfMeter,
|
||||
const Handle(Message_Alert)& theParentAlert = Handle(Message_Alert)());
|
||||
|
||||
// OCCT RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(Message_AlertExtended, Message_Alert)
|
||||
|
||||
protected:
|
||||
//! Sets performance meter
|
||||
//! \param theMeter instance pointer or NULL
|
||||
void SetPerfMeter (Message_PerfMeter* theMeter) { myPerfMeter = theMeter; }
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Message_CompositeAlerts) myCompositAlerts; //!< class provided hierarchical structure of alerts
|
||||
//!< It should be created by an attempt of a child alert creation
|
||||
|
||||
Handle(Message_Attribute) myAttribute; //!< container of the alert attributes
|
||||
|
||||
Message_PerfMeter* myPerfMeter; //!< performance meter
|
||||
Standard_Real myMetricStart; //!< value on start metric computation
|
||||
Standard_Real myMetricStop; //!< value on stop metric computation
|
||||
|
||||
friend Message_PerfMeter;
|
||||
};
|
||||
|
||||
#endif // _Message_Alert_HeaderFile
|
102
src/Message/Message_Alerts.hxx
Normal file
@@ -0,0 +1,102 @@
|
||||
// Created on: 2018-06-10
|
||||
// Created by: Natalia Ermolaeva
|
||||
// Copyright (c) 2017 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 _Message_Alerts_HeaderFile
|
||||
#define _Message_Alerts_HeaderFile
|
||||
|
||||
#include <Message.hxx>
|
||||
#include <Message_AlertExtended.hxx>
|
||||
#include <Message_AttributeObject.hxx>
|
||||
#include <Message_AttributeStream.hxx>
|
||||
#include <Message_Gravity.hxx>
|
||||
#include <Message_Report.hxx>
|
||||
|
||||
#include <NCollection_Vector.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
static Handle(Message_Alert) OCCT_Message_Alert;
|
||||
|
||||
#define MESSAGE_INFO(Name, Description, PerfMeter, ParentAlert) \
|
||||
{ \
|
||||
if (!Message_Report::CurrentReport().IsNull() && \
|
||||
Message_Report::CurrentReport()->IsActive (Message_Info)) \
|
||||
{ \
|
||||
OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \
|
||||
new Message_Attribute (Name, Description), PerfMeter, ParentAlert); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define MESSAGE_INFO_OBJECT(Object, StreamValues, Name, Description, PerfMeter, ParentAlert) \
|
||||
{ \
|
||||
if (!Message_Report::CurrentReport().IsNull() && \
|
||||
Message_Report::CurrentReport()->IsActive (Message_Info)) \
|
||||
{ \
|
||||
OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \
|
||||
new Message_AttributeObject (Object, StreamValues, Name, Description), PerfMeter, ParentAlert ); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define MESSAGE_INFO_STREAM(StreamValues, Name, Description, PerfMeter, ParentAlert) \
|
||||
{ \
|
||||
if (!Message_Report::CurrentReport().IsNull() && \
|
||||
Message_Report::CurrentReport()->IsActive (Message_Info)) \
|
||||
{ \
|
||||
OCCT_Message_Alert = Message_AlertExtended::AddAlert (Message_Report::CurrentReport(), \
|
||||
new Message_AttributeStream (StreamValues, Name, Description), PerfMeter, ParentAlert ); \
|
||||
} \
|
||||
}
|
||||
|
||||
//#define DUMP_VALUE(OS, Value) \
|
||||
// { \
|
||||
// OS << Value << Message::DumpSeparator(); \
|
||||
// }
|
||||
//
|
||||
//#define DUMP_VALUES_COLUMNS(OS, ObjectName, ColumnCount) \
|
||||
// { \
|
||||
// OS << ObjectName << Message::DumpSeparator() << ColumnCount << Message::DumpSeparator(); \
|
||||
// }
|
||||
//
|
||||
//#define DUMP_VALUES(OS, Value1, Value2) \
|
||||
// { \
|
||||
// OS << Value1 << Message::DumpSeparator() << Value2 << Message::DumpSeparator(); \
|
||||
// }
|
||||
//
|
||||
//#define DUMP_VEC_COLOR(Values, Value) \
|
||||
// { \
|
||||
// Value = Message::ColorVectorToString (aValues); \
|
||||
// }
|
||||
//
|
||||
//#define DUMP_VEC_COLOR_SPLIT(Value, Values) \
|
||||
// { \
|
||||
// Message::ColorVectorFromString (Value, Values); \
|
||||
// }
|
||||
//
|
||||
//#define DUMP_VEC_COORD(Values, Value) \
|
||||
// { \
|
||||
// Value = Message::CoordVectorToString (aValues); \
|
||||
// }
|
||||
//
|
||||
//#define DUMP_VEC_COORD_SPLIT(Value, Values) \
|
||||
// { \
|
||||
// Message::CoordVectorFromString (Value, Values); \
|
||||
// }
|
||||
//
|
||||
//
|
||||
//#define DUMP_VALUES_SPLIT(OS, ColumnCount, Values) \
|
||||
// { \
|
||||
// Message::ConvertStream (OS, aColumnCount, aValues); \
|
||||
// }
|
||||
|
||||
#endif // _Message_Alerts_HeaderFile
|
30
src/Message/Message_Attribute.cxx
Normal file
@@ -0,0 +1,30 @@
|
||||
// Created on: 2018-06-10
|
||||
// Created by: Natalia Ermolaeva
|
||||
// Copyright (c) 2017 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 <Message_Attribute.hxx>
|
||||
|
||||
#include <Standard_Assert.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Message_Attribute, Standard_Transient)
|
||||
|
||||
//=======================================================================
|
||||
//function : GetMessageKey
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_CString Message_Attribute::GetMessageKey () const
|
||||
{
|
||||
return !myName.IsEmpty() ? myName.ToCString() : "";
|
||||
}
|