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

Compare commits

..

31 Commits

Author SHA1 Message Date
nds
3a8ba84200 0030791: Visualization - possibility to display materials by different hatching style for clipping
# move capping style from presentation into drawer
# crash in capping by setting projection as
# several hatch templates
2019-09-04 00:49:54 +03:00
nds
4d6db8fb0c 0030857: Visualization - using one implementation of Text in graphic group - warnings correction - merge correction
#issue remarks correction
2019-08-16 13:01:41 +03:00
nds
cbf87d0753 Revert "0030901: Visualization - OSD_MemInfo moving memory computation out of the constructor" 2019-08-15 11:48:32 +03:00
nds
f834363dc3 0030901: Visualization - OSD_MemInfo moving memory computation out of the constructor 2019-08-15 08:48:14 +03:00
nds
a8959620a2 0030901: Visualization - OSD_MemInfo moving memory computation out of the constructor 2019-08-15 08:40:14 +03:00
nds
b7949b1dca 0030857: Visualization - using one implementation of Text in graphic group - warnings correction 2019-08-05 07:46:57 +03:00
nds
87c7ff6548 0030857: Visualization - using one implementation of Text in graphic group 2019-08-05 07:42:47 +03:00
nds
b416dd9bb6 0029451: Information Message Alert to debug an algorithm or object functionality
Dump/Init implementation in OCCT object and parsing it in VInspector (partially)
2019-08-02 08:07:13 +03:00
nds
9e7172d372 0030537: Visualization - wrapping text in font text formatter - correction after review 2019-08-02 07:11:31 +03:00
nds
79db594820 0029451: Information Message Alert to debug an algorithm or object functionality
Dump/Init implementation in OCCT object and parsing it in MessageView (VInspector later)
2019-07-17 13:54:31 +03:00
nds
fafcc26452 0030791: Visualization - possibility to display materials by different hatching style for clipping 2019-06-18 15:44:43 +03:00
nds
120f8788ff 0030728: Visualization - using one implementation of highlight/unhighlight in context - compilation correction
# check of NULL global selection owner (e.g. AIS_RubberBand has no global owner)
2019-06-17 13:45:49 +03:00
nds
9e58a20735 0030784: Visualization - check if selectable of owner in internal container in AIS_InteractiveContext before using
# todo - add similar check for other places where needed
2019-06-17 13:12:38 +03:00
nds
cafd762c93 0030268: Inspectors - improvements in VInspector plugin,
0029451: Information Message Alert to debug an algorithm or object functionality
2019-06-14 10:39:35 +03:00
nds
c9d8f1a93a 0029451: Information Message Alert to debug an algorithm or object functionality
Modifications:
 - Message_AlertExtended to store additional parameters (attributes, composite alert container, performance meter)
 - Message_Attribute and inherited classes to store custom information about alert
 - Message_CompositeAlerts to have hierarchical structure of alerts
 - Message_PerfMeter to automatically calculate time between alerts adding into report
 - Message_ReportCall back to be able to react to message report filling.
 - Import/Export message report report. Currently it is implemented using XmlDrivers_MessageReportStorage
 - MessageView/MessageModel - Inspector plugin for GUI presentation of Message_Report

(cherry picked from commit e4529dcf83b12759e47efb89ded8207f802556a7)

Conflicts:
	tools/ViewControl/FILES
	tools/ViewControl/ViewControl_PropertyView.cxx
	tools/ViewControl/ViewControl_PropertyView.hxx
	tools/ViewControl/ViewControl_Table.cxx
	tools/ViewControl/ViewControl_Table.hxx
	tools/ViewControl/ViewControl_TableModel.hxx
	tools/ViewControl/ViewControl_TableModelFilter.cxx
	tools/ViewControl/ViewControl_TableModelFilter.hxx
	tools/ViewControl/ViewControl_TableModelValues.hxx
	tools/ViewControl/ViewControl_TableProperty.cxx
	tools/ViewControl/ViewControl_TableProperty.hxx
	tools/ViewControl/ViewControl_Tools.cxx
	tools/ViewControl/ViewControl_Tools.hxx
(cherry picked from commit 68876fcc5a)
(cherry picked from commit 9a3d03bedb29dbf0124f5d53478d331d7ba877ff)
2019-06-13 01:21:48 +03:00
nds
f9778348a4 0030728: Visualization - using one implementation of highlight/unhighlight in context - compilation correction 2019-06-11 14:24:23 +03:00
nds
b65ce1439c 0030725: Visualization - remove Display calling from SetSelected methods of context
AIS_InteractiveContext::Load/ClearGlobal is modified for correct processing SetSelected for child objects.
As Display/Erase of object with children displays/erases these children, then the children status inside context should also be updated.

(cherry picked from commit 26b44c42ba1c2d999edf10d8dab4c02eae2c5ff7)

# Conflicts:
#	src/AIS/AIS_InteractiveContext.hxx
2019-06-11 13:50:37 +03:00
nds
184a20c4fa 0030737: Visualization - implementing new selection schemes in context
#apply selection scheme to container of owners

(cherry picked from commit 91ed0554e0c7d8b8cca6f86b8fe1a0891e55c3ed)

# Conflicts:
#	src/AIS/AIS_InteractiveContext_1.cxx
2019-06-11 13:48:25 +03:00
nds
73794e88be 0030737: Visualization - implementing new selection schemes in context
(cherry picked from commit f9d4ea66dbba0c6fb70d0232d9fd326722e83fbc)
(cherry picked from commit 1c7d53e55a)
(cherry picked from commit e2b319869af281f741ad97595c23de6d3128bce2)

# Conflicts:
#	src/AIS/AIS_InteractiveContext_1.cxx
2019-06-11 13:46:58 +03:00
nds
9e9c9c84bd 0030728: Visualization - using one implementation of highlight/unhighlight in context
(cherry picked from commit 36b87936acf5a89d573663b5e8d086a4a4a084d3)

# Conflicts:
#	src/AIS/AIS_InteractiveContext_1.cxx
(cherry picked from commit 7fc133f086611b4f4e36b658f99c29012da921d1)

# Conflicts:
#	src/AIS/AIS_InteractiveContext_1.cxx
(cherry picked from commit a06b8e8308)
(cherry picked from commit 0d5a72ab1638e4ed3d3eb72b15430ee7337f69bc)

# Conflicts:
#	src/AIS/AIS_InteractiveContext.cxx
2019-06-11 13:45:22 +03:00
nds
eb4bec0547 0030695: Visualization - selection by box should use clipping planes set for viewer - moving check on touching the clipping plane in selection only.
(cherry picked from commit 2fb3ed87a5)
(cherry picked from commit 618238791bf6f511e36455e89a780c62c401da50)

# Conflicts:
#	src/SelectMgr/SelectMgr_ViewerSelector.cxx
2019-06-11 13:44:34 +03:00
nds
ba793f42f8 0030537: Visualization - wrapping text in font text formatter
(cherry picked from commit 8016b09836)

# Conflicts:
#	src/Graphic3d/Graphic3d_Group.hxx
#	src/OpenGl/OpenGl_Text.hxx
(cherry picked from commit c0a38f3a5294cc0f168bc592f17f4ec9837d5a48)
2019-06-11 13:41:41 +03:00
nds
8fe265bf96 0030484: Visualization - 2d persistent: order of detection doesn't coincide with order of objects creation
(cherry picked from commit a151681f49)
(cherry picked from commit 555748a0d1583c1951fe4d85530c14a87edfdec8)
2019-06-11 13:41:13 +03:00
nds
b412a87c5c 0030425: Visualization - possibility to redefine AIS_Selection
(cherry picked from commit 672fb1a467)
(cherry picked from commit 28ab6a20977f69318559db4f2bd3dd8f49ac3b28)
2019-06-11 13:40:54 +03:00
snn
b7fb7db6ae 0030392: XCAFDoc_GraphNode doesn't copy backward links
(cherry picked from commit 6131065fae)
(cherry picked from commit 713624228050b8f7db4d8b2e22c7edfd8c832471)
2019-06-11 13:40:22 +03:00
nds
8688b82341 0030352: DRAW - Extending interface of ViewerTest_EventManager to process mouse button event
(cherry picked from commit 41e01634af5fccd37fc86931dac6f5c5569a63da)
(cherry picked from commit 7660866377)
(cherry picked from commit a2cd3c1905a3a3c2fb96ceb8eaec1cc982a64c97)
2019-06-11 13:39:54 +03:00
nds
89d8a85dd8 refs 474:Possibility to create and play animations
(cherry picked from commit d9a231a9ce2499615952944cae1a0db6552db2e4)
(cherry picked from commit ab078490cd)
(cherry picked from commit 277ea0a15e589efd7128f915959a18a59ebdfd1c)
2019-06-11 13:39:13 +03:00
nds
72e4a10556 refs #355: Add possibility to hide clipping plane
(cherry picked from commit ca1f82f6c6860a2e1995d7d9a66ce8c152e9d3cc)
(cherry picked from commit 61f39b4dc7)
(cherry picked from commit 7b08ab936a5f6091651fc0311c5c255bd0dc9cb0)

# Conflicts:
#	src/XCAFDoc/XCAFDoc.hxx
2019-06-11 13:38:53 +03:00
nds
503d5141aa Fix reading name of shape from subtype of PRODUCT_DEFINITION STEP entity
(cherry picked from commit 87fc89a8b83565eba0616eebba1f6ce655777461)
(cherry picked from commit 7526e6c9e4)

# Conflicts:
#	src/STEPCAFControl/STEPCAFControl_Reader.cxx
(cherry picked from commit f4608bc37035abbcbe5233fbcafc79bf4ad02b94)
2019-06-11 13:36:36 +03:00
nds
a22653eb86 XCAFDoc/View fixes to store in the view: image, parts transparency, notes, notes positions
(cherry picked from commit b050e0a15c06403adfa545ad793555491a0b6b9f)
(cherry picked from commit 7099619e5d)
(cherry picked from commit ccd4b101f5ab18ab3518b9779e88d687e2db6ff1)

# Conflicts:
#	src/XCAFDoc/XCAFDoc.cxx
#	src/XCAFDoc/XCAFDoc.hxx
2019-06-11 13:35:56 +03:00
aba
11a53a3503 0028954: Visualization - implement interactive object for camera manipulations 2019-06-11 13:22:00 +03:00
498 changed files with 42950 additions and 8146 deletions

View File

@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

BIN
data/images/hatch_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

BIN
data/images/hatch_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

BIN
data/images/hatch_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 B

BIN
data/images/hatch_5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 887 B

BIN
data/images/hatch_6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

BIN
data/images/hatch_7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

BIN
data/images/hatch_8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -82,6 +82,19 @@
const Standard_Real SquareTolerance = Precision::SquareConfusion();
namespace
{
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 :
@@ -1538,3 +1551,63 @@ void AIS::ComputeProjVertexPresentation (const Handle( Prs3d_Presentation )& aPr
StdPrs_WFShape::Add (aPresentation, MakEd.Edge(), aDrawer);
}
}
//=======================================================================
//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;
}

View File

@@ -17,6 +17,8 @@
#ifndef _AIS_HeaderFile
#define _AIS_HeaderFile
#include <AIS_DisplayStatus.hxx>
#include <AIS_KindOfInteractive.hxx>
#include <AIS_KindOfSurface.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <Aspect_TypeOfMarker.hxx>
@@ -203,6 +205,50 @@ 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 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

View File

@@ -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>
@@ -796,16 +797,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) aTextParams = new Graphic3d_Text (anAspect->Height());
aTextParams->SetText (theText.ToExtString());
aTextParams->SetOrientation (gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()));
aTextParams->SetOwnAnchorPoint (Standard_False);
aTextParams->SetVAlignment (theVertAlignment);
theGroup->AddText (aTextParams);
}
//=======================================================================

View File

@@ -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);

View File

@@ -161,7 +161,6 @@ myIsAutoActivateSelMode(Standard_True)
aStyle->SetMethod(Aspect_TOHM_COLOR);
aStyle->SetColor (Quantity_NOC_GRAY40);
}
InitAttributes();
}
@@ -1945,7 +1944,11 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t
}
const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
unhighlightOwners (theIObj);
AIS_NListOfEntityOwner anOwners;
const Handle(SelectMgr_EntityOwner)& aGlobOwner = theIObj->GlobalSelOwner();
if (!aGlobOwner.IsNull())
anOwners.Append(aGlobOwner);
unhighlightOwners (anOwners);
myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False);
if (!myLastPicked.IsNull()
@@ -1977,10 +1980,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())
@@ -2014,7 +2017,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
@@ -2522,15 +2525,6 @@ void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_Interacti
anActiveViewIter.Value()->View()->InvalidateZLayerBoundingBox (aLayerId);
}
}
//=======================================================================
//function : GravityPoint
//purpose :
//=======================================================================
gp_Pnt AIS_InteractiveContext::GravityPoint (const Handle(V3d_View)& theView) const
{
return theView->GravityPoint();
}
//=======================================================================
//function : setObjectStatus
//purpose :

View File

@@ -25,6 +25,8 @@
#include <AIS_ListOfInteractive.hxx>
#include <AIS_Selection.hxx>
#include <AIS_SelectionModesConcurrency.hxx>
#include <AIS_SelectionScheme.hxx>
#include <AIS_SelectionType.hxx>
#include <AIS_StatusOfDetection.hxx>
#include <AIS_StatusOfPick.hxx>
#include <AIS_TypeOfIso.hxx>
@@ -467,6 +469,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,
@@ -505,6 +525,13 @@ public: //! @name Selection management
const Handle(V3d_View)& theView,
const Standard_Boolean theToUpdateViewer);
//! 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,
@@ -557,14 +584,6 @@ public: //! @name Selection management
Standard_EXPORT void AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
const Standard_Boolean theToUpdateViewer);
//! Updates Selected state of specified owner without calling HilightSelected().
//! Has no effect if Selected state is not changed, and redirects to AddOrRemoveSelected() otherwise.
//! @param theOwner owner object to set selected state
//! @param theIsSelected new selected state
//! @return TRUE if Selected state has been changed
Standard_EXPORT Standard_Boolean SetSelectedState (const Handle(SelectMgr_EntityOwner)& theOwner,
const Standard_Boolean theIsSelected);
//! Highlights selected objects.
Standard_EXPORT void HilightSelected (const Standard_Boolean theToUpdateViewer);
@@ -824,9 +843,6 @@ public: //! @name common properties
//! returns the number of removed structures from the viewers.
Standard_EXPORT Standard_Integer PurgeDisplay();
//! Return rotation gravity point.
Standard_EXPORT virtual gp_Pnt GravityPoint (const Handle(V3d_View)& theView) const;
public: //! @name debug visualization
//! Visualization of sensitives - for debugging purposes!
@@ -1203,6 +1219,13 @@ public: //! @name sub-intensity management (deprecated)
Standard_EXPORT void SubIntensityOff (const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Boolean theToUpdateViewer);
//! Sets selection instance to manipulate a container of selected owners
//! \param theSelection an instance of the selection
void SetSelection (const Handle(AIS_Selection)& theSelection) { mySelection = theSelection; }
//! Returns selection instance
const Handle(AIS_Selection)& Selection() const { return mySelection; }
protected: //! @name internal methods
Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const;
@@ -1222,7 +1245,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.
@@ -1233,12 +1256,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.
@@ -1246,9 +1274,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
@@ -1391,7 +1424,6 @@ protected: //! @name internal fields
SelectMgr_PickingStrategy myPickingStrategy; //!< picking strategy to be applied within MoveTo()
Standard_Boolean myAutoHilight;
Standard_Boolean myIsAutoActivateSelMode;
};
DEFINE_STANDARD_HANDLE(AIS_InteractiveContext, Standard_Transient)

View File

@@ -85,30 +85,9 @@ void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOw
//=======================================================================
void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner)
{
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
if (anObj.IsNull())
{
return;
}
if (!theOwner->IsAutoHilight())
{
SelectMgr_SequenceOfOwner aSeq;
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
if (aSelIter.Value()->IsSameSelectable (anObj))
{
aSeq.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);
}
AIS_NListOfEntityOwner anOwners;
anOwners.Append (theOwner);
highlightOwners (anOwners, Standard_False/*check if it is really important*/);
}
//=======================================================================
@@ -117,14 +96,15 @@ 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);
const Handle(AIS_GlobalStatus)& aStatus = myObjects (theObj);
const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, aStatus->DisplayMode());
const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
if (aGlobOwner.IsNull())
@@ -133,22 +113,9 @@ void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject
return;
}
if (!aGlobOwner->IsAutoHilight())
{
SelectMgr_SequenceOfOwner aSeq;
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
if (aSelIter.Value()->IsSameSelectable (theObj))
{
aSeq.Append (aSelIter.Value());
}
}
theObj->HilightSelected (myMainPM, aSeq);
}
else
{
aGlobOwner->HilightWithColor (myMainPM, theStyle, aHiMode);
}
AIS_NListOfEntityOwner anOwners;
anOwners.Append (aGlobOwner);
highlightOwners (anOwners, Standard_True);
}
//=======================================================================
@@ -156,24 +123,30 @@ 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)& aStatus = myObjects.ChangeFind (anInteractive);
if (anOwner->IsAutoHilight())
{
anOwner->Unhilight (myMainPM);
if (theIsToHilightSubIntensity)
{
if (aStatus->IsSubIntensityOn())
if (!aStatus.IsNull() && aStatus->IsSubIntensityOn())
{
const Standard_Integer aHiMode = getHilightMode (anInteractive, aStatus->HilightStyle(), aStatus->DisplayMode());
highlightWithSubintensity (anOwner, aHiMode);
@@ -184,9 +157,9 @@ void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsTo
{
anObjToClear.Add (anInteractive);
}
if (anOwner == anInteractive->GlobalSelOwner())
if (!aStatus.IsNull() && anOwner == anInteractive->GlobalSelOwner())
{
myObjects.ChangeFind (anInteractive)->SetHilightStatus (Standard_False);
aStatus->SetHilightStatus (Standard_False);
}
}
for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
@@ -201,7 +174,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 +188,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);
}
//=======================================================================
@@ -485,37 +452,22 @@ 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);
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
AIS_NListOfEntityOwner aPickedOwners;
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);
aPickedOwners.Append (myMainSel->Picked (aPickIter));
}
if (myAutoHilight)
{
HilightSelected (toUpdateViewer);
}
Standard_Integer aSelNum = NbSelected();
return (aSelNum == 0) ? AIS_SOP_NothingSelected
: (aSelNum == 1) ? AIS_SOP_OneSelected
: AIS_SOP_SeveralSelected;
return Select (aPickedOwners, theSelScheme);
}
//=======================================================================
@@ -524,94 +476,87 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
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);
myMainSel->Pick (thePolyline, theView);
AIS_NListOfEntityOwner aPickedOwners;
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);
aPickedOwners.Append (myMainSel->Picked (aPickIter));
}
if (myAutoHilight)
{
HilightSelected (toUpdateViewer);
}
Standard_Integer aSelNum = NbSelected();
return (aSelNum == 0) ? AIS_SOP_NothingSelected
: (aSelNum == 1) ? AIS_SOP_OneSelected
: AIS_SOP_SeveralSelected;
return Select (aPickedOwners, theSelScheme);
}
//=======================================================================
//function : Select
//purpose :
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_SelectionScheme theSelScheme)
{
if (!myLastPicked.IsNull())
// special case: single selection of detected owner - is it necessary ?
/*if (myWasLastMain && !myLastPicked.IsNull() && !myAutoHilight &&
(myLastPicked->IsSelected()
&& !myLastPicked->IsForcedHilight()
&& NbSelected() <= 1))
{
if (myAutoHilight)
{
clearDynamicHighlight();
}
if (!myLastPicked->IsSelected()
|| myLastPicked->IsForcedHilight()
|| NbSelected() > 1)
{
SetSelected (myLastPicked, Standard_False);
if(toUpdateViewer)
{
UpdateCurrentViewer();
}
}
}
else
{
ClearSelected (toUpdateViewer);
}
mySelection->selectOwner(myLastPicked, aPrevSelected, SelectionScheme (AIS_SelectionType_Select));
return getStatusOfPick (NbSelected());
}*/
Standard_Integer aSelNum = NbSelected();
AIS_NListOfEntityOwner aPickedOwners;
aPickedOwners.Append (myLastPicked);
return (aSelNum == 0) ? AIS_SOP_NothingSelected
: (aSelNum == 1) ? AIS_SOP_OneSelected
: AIS_SOP_SeveralSelected;
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);
}
//=======================================================================
@@ -623,38 +568,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");
}
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);
}
//=======================================================================
@@ -663,30 +579,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);
}
//=======================================================================
//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();
@@ -704,14 +621,31 @@ 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())
if (theToUseObjectDisplayMode && anOwner == anObj->GlobalSelOwner())
{
aState->SetHilightStatus (Standard_True);
aState->SetHilightStyle (anObjSelStyle);
@@ -732,7 +666,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 ? aState->DisplayMode() : -1);
anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
}
}
@@ -745,9 +679,6 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
}
anObjOwnerMap.Clear();
}
if (theToUpdateViewer)
UpdateCurrentViewer();
}
//=======================================================================
@@ -756,17 +687,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();
@@ -921,13 +842,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();
}
@@ -974,28 +888,19 @@ 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)& aStatus = myObjects.ChangeFind (anObj);
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);
AIS_NListOfEntityOwner anOwners;
anOwners.Append (theOwner);
unhighlightOwners (anOwners);
aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
}
}
@@ -1004,43 +909,6 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO
UpdateCurrentViewer();
}
// =======================================================================
// function : SetSelectedState
// purpose :
// =======================================================================
Standard_Boolean AIS_InteractiveContext::SetSelectedState (const Handle(SelectMgr_EntityOwner)& theEntity,
const Standard_Boolean theIsSelected)
{
if (theEntity.IsNull())
{
throw Standard_ProgramError ("Internal error: AIS_InteractiveContext::SetSelectedState() called with NO object");
}
if (!theEntity->HasSelectable()
|| mySelection->IsSelected (theEntity) == theIsSelected)
{
return false;
}
if (theEntity->IsAutoHilight())
{
AddOrRemoveSelected (theEntity, false);
return true;
}
if (theIsSelected)
{
const AIS_SelectStatus aSelStatus = mySelection->AddSelect (theEntity);
theEntity->SetSelected (true);
return aSelStatus == AIS_SS_Added;
}
else
{
const AIS_SelectStatus aSelStatus = mySelection->Select (theEntity);
theEntity->SetSelected (false);
return aSelStatus == AIS_SS_Removed;
}
}
//=======================================================================
//function : IsSelected

View File

@@ -84,37 +84,6 @@ void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& th
}
}
//=======================================================================
//function : SetCappingStyle
//purpose :
//=======================================================================
void AIS_InteractiveObject::SetCappingStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
{
myCappingStyle = theStyle;
// Modify existing presentations
for (Standard_Integer aPrsIter = 1, n = myPresentations.Length(); aPrsIter <= n; ++aPrsIter)
{
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);
}
}
}
}
}
//=======================================================================
//function : HasPresentation
//purpose :
@@ -175,3 +144,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);
}

View File

@@ -104,12 +104,6 @@ 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;
@@ -124,6 +118,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 +131,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;
};

View File

@@ -1,36 +0,0 @@
// 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_MouseGesture_HeaderFile
#define _AIS_MouseGesture_HeaderFile
#include <NCollection_DataMap.hxx>
//! Mouse gesture - only one can be active at one moment.
enum AIS_MouseGesture
{
AIS_MouseGesture_NONE, //!< no active gesture
//
AIS_MouseGesture_SelectRectangle, //!< rectangular selection
AIS_MouseGesture_SelectLasso, //!< polygonal selection
//
AIS_MouseGesture_Zoom, //!< view zoom gesture
AIS_MouseGesture_Pan, //!< view panning gesture
AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture
AIS_MouseGesture_RotateView, //!< view rotation gesture
};
//! Map defining mouse gestures.
typedef NCollection_DataMap<unsigned int, AIS_MouseGesture> AIS_MouseGestureMap;
#endif // _AIS_MouseGesture_HeaderFile

View File

@@ -1,33 +0,0 @@
// 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_RotationMode_HeaderFile
#define _AIS_RotationMode_HeaderFile
//! Camera rotation mode.
enum AIS_RotationMode
{
AIS_RotationMode_BndBoxActive, //!< default OCCT rotation
AIS_RotationMode_PickLast, //!< rotate around last picked point
AIS_RotationMode_PickCenter, //!< rotate around point at the center of window
AIS_RotationMode_CameraAt, //!< rotate around camera center
AIS_RotationMode_BndBoxScene, //!< rotate around scene center
};
enum
{
AIS_RotationMode_LOWER = 0,
AIS_RotationMode_UPPER = AIS_RotationMode_BndBoxScene,
};
#endif // _AIS_RotationMode_HeaderFile

View File

@@ -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;
}

View File

@@ -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
{
@@ -32,18 +34,18 @@ public:
Standard_EXPORT AIS_Selection();
//! removes all the object of the selection.
Standard_EXPORT void Clear();
Standard_EXPORT virtual void Clear();
//! if the object is not yet in the selection, it will be added.
//! if the object is already in the selection, it will be removed.
Standard_EXPORT AIS_SelectStatus Select (const Handle(SelectMgr_EntityOwner)& theObject);
Standard_EXPORT virtual AIS_SelectStatus Select (const Handle(SelectMgr_EntityOwner)& theObject);
//! the object is always add int the selection.
//! faster when the number of objects selected is great.
Standard_EXPORT AIS_SelectStatus AddSelect (const Handle(SelectMgr_EntityOwner)& theObject);
Standard_EXPORT virtual AIS_SelectStatus AddSelect (const Handle(SelectMgr_EntityOwner)& theObject);
//! clears the selection and adds the object in the selection.
void ClearAndSelect (const Handle(SelectMgr_EntityOwner)& theObject)
virtual void ClearAndSelect (const Handle(SelectMgr_EntityOwner)& theObject)
{
Clear();
Select (theObject);
@@ -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;

View 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

View File

@@ -11,21 +11,21 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_NavigationMode_HeaderFile
#define _AIS_NavigationMode_HeaderFile
//! Camera navigation mode.
enum AIS_NavigationMode
#ifndef _AIS_SelectionType_HeaderFile
#define _AIS_SelectionType_HeaderFile
//! Sets selection schemes for interactive contexts.
//! It is possible to use combination of schemes.
enum AIS_SelectionType
{
AIS_NavigationMode_Orbit, //!< orbit rotation
AIS_NavigationMode_FirstPersonFlight, //!< flight rotation (first person)
AIS_NavigationMode_FirstPersonWalk, //!< walking mode (first person)
AIS_SelectionType_Select,
AIS_SelectionType_SelectInRect,
AIS_SelectionType_SelectInPoly,
AIS_SelectionType_ShiftSelect,
AIS_SelectionType_ShiftSelectInRect,
AIS_SelectionType_ShiftSelectInPoly
};
enum
{
AIS_NavigationMode_LOWER = 0,
AIS_NavigationMode_UPPER = AIS_NavigationMode_FirstPersonWalk
};
#endif // _V3d_NavigationMode_HeaderFile
#endif // _AIS_SelectionType_HeaderFile

View File

@@ -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)
{

File diff suppressed because it is too large Load Diff

View File

@@ -1,658 +0,0 @@
// Copyright (c) 2016-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_ViewController_HeaderFile
#define _AIS_ViewController_HeaderFile
#include <Aspect_VKeySet.hxx>
#include <Aspect_TouchMap.hxx>
#include <AIS_DragAction.hxx>
#include <AIS_MouseGesture.hxx>
#include <AIS_NavigationMode.hxx>
#include <AIS_ViewInputBuffer.hxx>
#include <AIS_RotationMode.hxx>
#include <AIS_WalkDelta.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_Vec3.hxx>
#include <NCollection_Array1.hxx>
#include <OSD_Timer.hxx>
#include <Precision.hxx>
#include <Standard_Mutex.hxx>
class AIS_InteractiveObject;
class AIS_InteractiveContext;
class AIS_Point;
class AIS_RubberBand;
class V3d_View;
//! Auxiliary structure for handling viewer events between GUI and Rendering threads.
//!
//! Class implements the following features:
//! - Buffers storing the state of user input (mouse, touches and keyboard).
//! - Mapping mouse/multi-touch input to View camera manipulations (panning/rotating/zooming).
//! - Input events are not applied immediately but queued for separate processing from two working threads
//! UI thread receiving user input and Rendering thread for OCCT 3D Viewer drawing.
class AIS_ViewController
{
public:
//! Empty constructor.
Standard_EXPORT AIS_ViewController();
//! Return input buffer.
const AIS_ViewInputBuffer& InputBuffer (AIS_ViewInputBufferType theType) const { return theType == AIS_ViewInputBufferType_UI ? myUI : myGL; }
//! Return input buffer.
AIS_ViewInputBuffer& ChangeInputBuffer (AIS_ViewInputBufferType theType) { return theType == AIS_ViewInputBufferType_UI ? myUI : myGL; }
public: //! @name global parameters
//! Return camera rotation mode, AIS_RotationMode_BndBoxActive by default.
AIS_RotationMode RotationMode() const { return myRotationMode; }
//! Set camera rotation mode.
void SetRotationMode (AIS_RotationMode theMode) { myRotationMode = theMode; }
//! Return camera navigation mode; AIS_NavigationMode_Orbit by default.
AIS_NavigationMode NavigationMode() const { return myNavigationMode; }
//! Set camera navigation mode.
Standard_EXPORT void SetNavigationMode (AIS_NavigationMode theMode);
//! Return mouse input acceleration ratio in First Person mode; 1.0 by default.
float MouseAcceleration() const { return myMouseAccel; }
//! Set mouse input acceleration ratio.
void SetMouseAcceleration (float theRatio) { myMouseAccel = theRatio; }
//! Return orbit rotation acceleration ratio; 1.0 by default.
float OrbitAcceleration() const { return myOrbitAccel; }
//! Set orbit rotation acceleration ratio.
void SetOrbitAcceleration (float theRatio) { myOrbitAccel = theRatio; }
//! Return TRUE if panning anchor point within perspective projection should be displayed in 3D Viewer; TRUE by default.
bool ToShowPanAnchorPoint() const { return myToShowPanAnchorPoint; }
//! Set if panning anchor point within perspective projection should be displayed in 3D Viewer.
void SetShowPanAnchorPoint (bool theToShow) { myToShowPanAnchorPoint = theToShow; }
//! Return TRUE if rotation point should be displayed in 3D Viewer; TRUE by default.
bool ToShowRotateCenter() const { return myToShowRotateCenter; }
//! Set if rotation point should be displayed in 3D Viewer.
void SetShowRotateCenter (bool theToShow) { myToShowRotateCenter = theToShow; }
//! Return TRUE if camera up orientation within AIS_NavigationMode_Orbit rotation mode should be forced Z up; FALSE by default.
bool ToLockOrbitZUp() const { return myToLockOrbitZUp; }
//! Set if camera up orientation within AIS_NavigationMode_Orbit rotation mode should be forced Z up.
void SetLockOrbitZUp (bool theToForceUp) { myToLockOrbitZUp = theToForceUp; }
//! Return TRUE if z-rotation via two-touches gesture is enabled; FALSE by default.
bool ToAllowTouchZRotation() const { return myToAllowTouchZRotation; }
//! Set if z-rotation via two-touches gesture is enabled.
void SetAllowTouchZRotation (bool theToEnable) { myToAllowTouchZRotation = theToEnable; }
//! Return TRUE if camera rotation is allowed; TRUE by default.
bool ToAllowRotation() const { return myToAllowRotation; }
//! Set if camera rotation is allowed.
void SetAllowRotation (bool theToEnable) { myToAllowRotation = theToEnable; }
//! Return TRUE if panning is allowed; TRUE by default.
bool ToAllowPanning() const { return myToAllowPanning; }
//! Set if panning is allowed.
void SetAllowPanning (bool theToEnable) { myToAllowPanning = theToEnable; }
//! Return TRUE if zooming is allowed; TRUE by default.
bool ToAllowZooming() const { return myToAllowZooming; }
//! Set if zooming is allowed.
void SetAllowZooming (bool theToEnable) { myToAllowZooming = theToEnable; }
//! Return TRUE if ZFocus change is allowed; TRUE by default.
bool ToAllowZFocus() const { return myToAllowZFocus; }
//! Set if ZFocus change is allowed.
void SetAllowZFocus (bool theToEnable) { myToAllowZFocus = theToEnable; }
//! Return TRUE if dynamic highlight on mouse move is allowed; TRUE by default.
bool ToAllowHighlight() const { return myToAllowHighlight; }
//! Set if dragging object is allowed.
void SetAllowHighlight (bool theToEnable) { myToAllowHighlight = theToEnable; }
//! Return TRUE if dragging object is allowed; TRUE by default.
bool ToAllowDragging() const { return myToAllowDragging; }
//! Set if dynamic highlight on mouse move is allowed.
void SetAllowDragging (bool theToEnable) { myToAllowDragging = theToEnable; }
//! Return TRUE if pitch direction should be inverted while processing Aspect_VKey_NavLookUp/Aspect_VKey_NavLookDown; FALSE by default.
bool ToInvertPitch() const { return myToInvertPitch; }
//! Set flag inverting pitch direction.
void SetInvertPitch (bool theToInvert) { myToInvertPitch = theToInvert; }
//! Return normal walking speed, in m/s; 1.5 by default.
float WalkSpeedAbsolute() const { return myWalkSpeedAbsolute; }
//! Set normal walking speed, in m/s; 1.5 by default.
void SetWalkSpeedAbsolute (float theSpeed) { myWalkSpeedAbsolute = theSpeed; }
//! Return walking speed relative to scene bounding box; 0.1 by default.
float WalkSpeedRelative() const { return myWalkSpeedRelative; }
//! Set walking speed relative to scene bounding box.
void SetWalkSpeedRelative (float theFactor) { myWalkSpeedRelative = theFactor; }
//! Return active thrust value; 0.0f by default.
float ThrustSpeed() const { return myThrustSpeed; }
//! Set active thrust value.
void SetThrustSpeed (float theSpeed) { myThrustSpeed = theSpeed; }
//! Return TRUE if previous position of MoveTo has been defined.
bool HasPreviousMoveTo() const { return myPrevMoveTo != Graphic3d_Vec2i (-1); }
//! Return previous position of MoveTo event in 3D viewer.
const Graphic3d_Vec2i& PreviousMoveTo() const { return myPrevMoveTo; }
//! Reset previous position of MoveTo.
void ResetPreviousMoveTo() { myPrevMoveTo = Graphic3d_Vec2i (-1); }
public: //! @name keyboard input
//! Return keyboard state.
const Aspect_VKeySet& Keys() const { return myKeys; }
//! Return keyboard state.
Aspect_VKeySet& ChangeKeys() { return myKeys; }
//! Press key.
//! @param theKey key pressed
//! @param theTime event timestamp
Standard_EXPORT virtual void KeyDown (Aspect_VKey theKey,
double theTime,
double thePressure = 1.0);
//! Release key.
//! @param theKey key pressed
//! @param theTime event timestamp
Standard_EXPORT virtual void KeyUp (Aspect_VKey theKey,
double theTime);
//! Simulate key up/down events from axis value.
Standard_EXPORT virtual void KeyFromAxis (Aspect_VKey theNegative,
Aspect_VKey thePositive,
double theTime,
double thePressure);
//! Fetch active navigation actions.
Standard_EXPORT AIS_WalkDelta FetchNavigationKeys (Standard_Real theCrouchRatio,
Standard_Real theRunRatio);
public: //! @name mouse input
//! Return map defining mouse gestures.
const AIS_MouseGestureMap& MouseGestureMap() const { return myMouseGestureMap; }
//! Return map defining mouse gestures.
AIS_MouseGestureMap& ChangeMouseGestureMap() { return myMouseGestureMap; }
//! Return double click interval in seconds; 0.4 by default.
double MouseDoubleClickInterval() const { return myMouseDoubleClickInt; }
//! Set double click interval in seconds.
void SetMouseDoubleClickInterval (double theSeconds) { myMouseDoubleClickInt = theSeconds; }
//! Perform selection in 3D viewer.
//! This method is expected to be called from UI thread.
//! @param thePnt picking point
//! @param theIsXOR XOR selection flag
Standard_EXPORT virtual void SelectInViewer (const Graphic3d_Vec2i& thePnt,
const bool theIsXOR = false);
//! Perform selection in 3D viewer.
//! This method is expected to be called from UI thread.
//! @param thePnts picking point
//! @param theIsXOR XOR selection flag
Standard_EXPORT virtual void SelectInViewer (const NCollection_Sequence<Graphic3d_Vec2i>& thePnts,
const bool theIsXOR = false);
//! Update rectangle selection tool.
//! This method is expected to be called from UI thread.
//! @param thePntFrom rectangle first corner
//! @param thePntTo rectangle another corner
//! @param theIsXOR XOR selection flag
Standard_EXPORT virtual void UpdateRubberBand (const Graphic3d_Vec2i& thePntFrom,
const Graphic3d_Vec2i& thePntTo,
const bool theIsXOR = false);
//! Update polygonal selection tool.
//! This method is expected to be called from UI thread.
//! @param thePnt new point to add to polygon
//! @param theToAppend append new point or update the last point
Standard_EXPORT virtual void UpdatePolySelection (const Graphic3d_Vec2i& thePnt,
bool theToAppend);
//! Update zoom event (e.g. from mouse scroll).
//! This method is expected to be called from UI thread.
//! @param theDelta mouse cursor position to zoom at and zoom delta
//! @return TRUE if new zoom event has been created or FALSE if existing one has been updated
Standard_EXPORT virtual bool UpdateZoom (const Aspect_ScrollDelta& theDelta);
//! Update Z rotation event.
//! @param theAngle rotation angle, in radians.
//! @return TRUE if new zoom event has been created or FALSE if existing one has been updated
Standard_EXPORT virtual bool UpdateZRotation (double theAngle);
//! Update mouse scroll event; redirects to UpdateZoom by default.
//! This method is expected to be called from UI thread.
//! @param theDelta mouse cursor position and delta
//! @return TRUE if new event has been created or FALSE if existing one has been updated
Standard_EXPORT virtual bool UpdateMouseScroll (const Aspect_ScrollDelta& theDelta);
//! Handle mouse button press/release event.
//! This method is expected to be called from UI thread.
//! @param thePoint mouse cursor position
//! @param theButtons pressed buttons
//! @param theModifiers key modifiers
//! @param theIsEmulated if TRUE then mouse event comes NOT from real mouse
//! but emulated from non-precise input like touch on screen
//! @return TRUE if View should be redrawn
Standard_EXPORT virtual bool UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButtons,
Aspect_VKeyFlags theModifiers,
bool theIsEmulated);
//! Handle mouse cursor movement event.
//! This method is expected to be called from UI thread.
//! @param thePoint mouse cursor position
//! @param theButtons pressed buttons
//! @param theModifiers key modifiers
//! @param theIsEmulated if TRUE then mouse event comes NOT from real mouse
//! but emulated from non-precise input like touch on screen
//! @return TRUE if View should be redrawn
Standard_EXPORT virtual bool UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButtons,
Aspect_VKeyFlags theModifiers,
bool theIsEmulated);
//! Handle mouse button press event.
//! This method is expected to be called from UI thread.
//! @param thePoint mouse cursor position
//! @param theButton pressed button
//! @param theModifiers key modifiers
//! @param theIsEmulated if TRUE then mouse event comes NOT from real mouse
//! but emulated from non-precise input like touch on screen
//! @return TRUE if View should be redrawn
bool PressMouseButton (const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButton,
Aspect_VKeyFlags theModifiers,
bool theIsEmulated)
{
return UpdateMouseButtons (thePoint, myMousePressed | theButton, theModifiers, theIsEmulated);
}
//! Handle mouse button release event.
//! This method is expected to be called from UI thread.
//! @param thePoint mouse cursor position
//! @param theButton released button
//! @param theModifiers key modifiers
//! @param theIsEmulated if TRUE then mouse event comes NOT from real mouse
//! but emulated from non-precise input like touch on screen
//! @return TRUE if View should be redrawn
bool ReleaseMouseButton (const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButton,
Aspect_VKeyFlags theModifiers,
bool theIsEmulated)
{
Aspect_VKeyMouse aButtons = myMousePressed & (~theButton);
return UpdateMouseButtons (thePoint, aButtons, theModifiers, theIsEmulated);
}
//! Handle mouse button click event (emulated by UpdateMouseButtons() while releasing single button).
//! Note that as this method is called by UpdateMouseButtons(), it should be executed from UI thread.
//! Default implementation redirects to SelectInViewer().
//! This method is expected to be called from UI thread.
//! @param thePoint mouse cursor position
//! @param theButton clicked button
//! @param theModifiers key modifiers
//! @param theIsDoubleClick flag indicating double mouse click
//! @return TRUE if View should be redrawn
Standard_EXPORT virtual bool UpdateMouseClick (const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButton,
Aspect_VKeyFlags theModifiers,
bool theIsDoubleClick);
//! Return currently pressed mouse buttons.
Aspect_VKeyMouse PressedMouseButtons() const { return myMousePressed; }
//! Return active key modifiers passed with last mouse event.
Aspect_VKeyFlags LastMouseFlags() const { return myMouseModifiers; }
//! Return last mouse position.
const Graphic3d_Vec2i& LastMousePosition() const { return myMousePositionLast; }
public: //! @name multi-touch input
//! Return scale factor for adjusting tolerances for starting multi-touch gestures; 1.0 by default
//! This scale factor is expected to be computed from touch screen resolution.
float TouchToleranceScale() const { return myTouchToleranceScale; }
//! Set scale factor for adjusting tolerances for starting multi-touch gestures.
void SetTouchToleranceScale (float theTolerance) { myTouchToleranceScale = theTolerance; }
//! Return TRUE if touches map is not empty.
bool HasTouchPoints() const { return !myTouchPoints.IsEmpty(); }
//! Add touch point with the given ID.
//! This method is expected to be called from UI thread.
//! @param theId touch unique identifier
//! @param thePnt touch coordinates
//! @param theClearBefore if TRUE previously registered touches will be removed
Standard_EXPORT virtual void AddTouchPoint (Standard_Size theId,
const Graphic3d_Vec2d& thePnt,
Standard_Boolean theClearBefore = false);
//! Remove touch point with the given ID.
//! This method is expected to be called from UI thread.
//! @param theId touch unique identifier
//! @param theClearSelectPnts if TRUE will initiate clearing of selection points
//! @return TRUE if point has been removed
Standard_EXPORT virtual bool RemoveTouchPoint (Standard_Size theId,
Standard_Boolean theClearSelectPnts = false);
//! Update touch point with the given ID.
//! If point with specified ID was not registered before, it will be added.
//! This method is expected to be called from UI thread.
//! @param theId touch unique identifier
//! @param thePnt touch coordinates
Standard_EXPORT virtual void UpdateTouchPoint (Standard_Size theId,
const Graphic3d_Vec2d& thePnt);
public:
//! Return event time (e.g. current time).
double EventTime() const { return myEventTimer.ElapsedTime(); }
//! Reset input state (pressed keys, mouse buttons, etc.) e.g. on window focus loss.
//! This method is expected to be called from UI thread.
Standard_EXPORT virtual void ResetViewInput();
//! Reset view orientation.
//! This method is expected to be called from UI thread.
Standard_EXPORT virtual void UpdateViewOrientation (V3d_TypeOfOrientation theOrientation,
bool theToFitAll);
//! Update buffer for rendering thread.
//! This method is expected to be called within synchronization barrier between GUI
//! and Rendering threads (e.g. GUI thread should be locked beforehand to avoid data races).
//! @param theCtx interactive context
//! @param theView active view
//! @param theToHandle if TRUE, the HandleViewEvents() will be called
Standard_EXPORT virtual void FlushViewEvents (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
Standard_Boolean theToHandle = Standard_False);
//! Process events within rendering thread.
Standard_EXPORT virtual void HandleViewEvents (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
public:
//! Callback called by handleMoveTo() on Selection in 3D Viewer.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void OnSelectionChanged (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
//! Callback called by handleMoveTo() on dragging object in 3D Viewer.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void OnObjectDragged (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
AIS_DragAction theAction);
//! Pick closest point under mouse cursor.
//! This method is expected to be called from rendering thread.
//! @param thePnt [out] result point
//! @param theCtx [in] interactive context
//! @param theView [in] active view
//! @param theCursor [in] mouse cursor
//! @param theToStickToPickRay [in] when TRUE, the result point will lie on picking ray
//! @return TRUE if result has been found
Standard_EXPORT virtual bool PickPoint (gp_Pnt& thePnt,
const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const Graphic3d_Vec2i& theCursor,
bool theToStickToPickRay);
//! Compute rotation gravity center point depending on rotation mode.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual gp_Pnt GravityPoint (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
public:
//! Perform camera actions.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void handleCameraActions (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const AIS_WalkDelta& theWalk);
//! Perform moveto/selection/dragging.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void handleMoveTo (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
//! Return TRUE if another frame should be drawn right after this one.
bool toAskNextFrame() const { return myToAskNextFrame; }
//! Set if another frame should be drawn right after this one.
void setAskNextFrame (bool theToDraw = true) { myToAskNextFrame = theToDraw; }
//! Return if panning anchor point has been defined.
bool hasPanningAnchorPoint() const { return !Precision::IsInfinite (myPanPnt3d.X()); }
//! Return active panning anchor point.
const gp_Pnt& panningAnchorPoint() const { return myPanPnt3d; }
//! Set active panning anchor point.
void setPanningAnchorPoint (const gp_Pnt& thePnt) { myPanPnt3d = thePnt; }
//! Handle panning event myGL.Panning.
Standard_EXPORT virtual void handlePanning (const Handle(V3d_View)& theView);
//! Handle Z rotation event myGL.ZRotate.
Standard_EXPORT virtual void handleZRotate (const Handle(V3d_View)& theView);
//! Return minimal camera distance for zoom operation.
double MinZoomDistance() const { return myMinCamDistance; }
//! Set minimal camera distance for zoom operation.
void SetMinZoomDistance (double theDist) { myMinCamDistance = theDist; }
//! Handle zoom event myGL.ZoomActions.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void handleZoom (const Handle(V3d_View)& theView,
const Aspect_ScrollDelta& theParams,
const gp_Pnt* thePnt);
//! Handle ZScroll event myGL.ZoomActions.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void handleZFocusScroll (const Handle(V3d_View)& theView,
const Aspect_ScrollDelta& theParams);
//! Handle orbital rotation events myGL.OrbitRotation.
//! @param theView view to modify
//! @param thePnt 3D point to rotate around
//! @param theToLockZUp amend camera to exclude roll angle (put camera Up vector to plane containing global Z and view direction)
Standard_EXPORT virtual void handleOrbitRotation (const Handle(V3d_View)& theView,
const gp_Pnt& thePnt,
bool theToLockZUp);
//! Handle view direction rotation events myGL.ViewRotation.
//! This method is expected to be called from rendering thread.
//! @param theView camera to modify
//! @param theYawExtra extra yaw increment
//! @param thePitchExtra extra pitch increment
//! @param theRoll roll value
//! @param theToRestartOnIncrement flag indicating flight mode
Standard_EXPORT virtual void handleViewRotation (const Handle(V3d_View)& theView,
double theYawExtra,
double thePitchExtra,
double theRoll,
bool theToRestartOnIncrement);
//! Handle view redraw.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
protected:
//! Flush buffers.
Standard_EXPORT virtual void flushBuffers (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
//! Flush touch gestures.
Standard_EXPORT virtual void flushGestures (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
//! Return current and previously fetched event times.
//! This callback is intended to compute delta between sequentially processed events.
//! @param thePrevTime [out] events time fetched previous time by this method
//! @param theCurrTime [out] actual events time
void updateEventsTime (double& thePrevTime,
double& theCurrTime)
{
thePrevTime = myLastEventsTime;
myLastEventsTime = EventTime();
theCurrTime = myLastEventsTime;
}
//! Perform selection via mouse click.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void handleSelectionPick (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
//! Perform dynamic highlight on mouse move.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void handleDynamicHighlight (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
//! Perform rubber-band selection.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void handleSelectionPoly (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
//! Lazy AIS_InteractiveContext::MoveTo() with myPrevMoveTo check.
Standard_EXPORT virtual void contextLazyMoveTo (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const Graphic3d_Vec2i& thePnt);
protected:
AIS_ViewInputBuffer myUI; //!< buffer for UI thread
AIS_ViewInputBuffer myGL; //!< buffer for rendering thread
OSD_Timer myEventTimer; //!< timer for timestamping events
Standard_Real myLastEventsTime; //!< last fetched events timer value for computing delta/progress
Standard_Boolean myToAskNextFrame; //!< flag indicating that another frame should be drawn right after this one
Standard_Real myMinCamDistance; //!< minimal camera distance for zoom operation
AIS_RotationMode myRotationMode; //!< rotation mode
AIS_NavigationMode myNavigationMode; //!< navigation mode (orbit rotation / first person)
Standard_ShortReal myMouseAccel; //!< mouse input acceleration ratio in First Person mode
Standard_ShortReal myOrbitAccel; //!< Orbit rotation acceleration ratio
Standard_Boolean myToShowPanAnchorPoint; //!< option displaying panning anchor point
Standard_Boolean myToShowRotateCenter; //!< option displaying rotation center point
Standard_Boolean myToLockOrbitZUp; //!< force camera up orientation within AIS_NavigationMode_Orbit rotation mode
Standard_Boolean myToInvertPitch; //!< flag inverting pitch direction while processing Aspect_VKey_NavLookUp/Aspect_VKey_NavLookDown
Standard_Boolean myToAllowTouchZRotation; //!< enable z-rotation two-touches gesture; FALSE by default
Standard_Boolean myToAllowRotation; //!< enable rotation; TRUE by default
Standard_Boolean myToAllowPanning; //!< enable panning; TRUE by default
Standard_Boolean myToAllowZooming; //!< enable zooming; TRUE by default
Standard_Boolean myToAllowZFocus; //!< enable ZFocus change; TRUE by default
Standard_Boolean myToAllowHighlight; //!< enable dynamic highlight on mouse move; TRUE by default
Standard_Boolean myToAllowDragging; //!< enable dragging object; TRUE by default
Standard_ShortReal myWalkSpeedAbsolute; //!< normal walking speed, in m/s; 1.5 by default
Standard_ShortReal myWalkSpeedRelative; //!< walking speed relative to scene bounding box; 0.1 by default
Standard_ShortReal myThrustSpeed; //!< active thrust value
Standard_Boolean myHasThrust; //!< flag indicating active thrust
Handle(AIS_RubberBand) myRubberBand; //!< Rubber-band presentation
Handle(AIS_InteractiveObject) myDragObject; //!< currently dragged object
Graphic3d_Vec2i myPrevMoveTo; //!< previous position of MoveTo event in 3D viewer
Standard_Boolean myHasHlrOnBeforeRotation; //!< flag for restoring Computed mode after rotation
protected: //! @name keyboard input variables
Aspect_VKeySet myKeys; //!< keyboard state
protected: //! @name mouse input variables
Standard_Real myMouseClickThreshold; //!< mouse click threshold in pixels; 3 by default
Standard_Real myMouseDoubleClickInt; //!< double click interval in seconds; 0.4 by default
Standard_ShortReal myScrollZoomRatio; //!< distance ratio for mapping mouse scroll event to zoom; 15.0 by default
AIS_MouseGestureMap myMouseGestureMap; //!< map defining mouse gestures
AIS_MouseGesture myMouseActiveGesture; //!< initiated mouse gesture (by pressing mouse button)
Standard_Boolean myMouseActiveIdleRotation; //!< flag indicating view idle rotation state
Graphic3d_Vec2i myMousePositionLast; //!< last mouse position
Graphic3d_Vec2i myMousePressPoint; //!< mouse position where active gesture was been initiated
Graphic3d_Vec2i myMouseProgressPoint; //!< gesture progress
OSD_Timer myMouseClickTimer; //!< timer for handling double-click event
Standard_Integer myMouseClickCounter; //!< counter for handling double-click event
Aspect_VKeyMouse myMousePressed; //!< active mouse buttons
Aspect_VKeyFlags myMouseModifiers; //!< active key modifiers passed with last mouse event
Standard_Integer myMouseSingleButton; //!< index of mouse button pressed alone (>0)
protected: //! @name multi-touch input variables
Standard_ShortReal myTouchToleranceScale; //!< tolerance scale factor; 1.0 by default
Standard_ShortReal myTouchRotationThresholdPx; //!< threshold for starting one-touch rotation gesture in pixels; 6 by default
Standard_ShortReal myTouchZRotationThreshold; //!< threshold for starting two-touch Z-rotation gesture in radians; 2 degrees by default
Standard_ShortReal myTouchPanThresholdPx; //!< threshold for starting two-touch panning gesture in pixels; 4 by default
Standard_ShortReal myTouchZoomThresholdPx; //!< threshold for starting two-touch zoom (pitch) gesture in pixels; 6 by default
Standard_ShortReal myTouchZoomRatio; //!< distance ratio for mapping two-touch zoom (pitch) gesture from pixels to zoom; 0.13 by default
Aspect_TouchMap myTouchPoints; //!< map of active touches
Graphic3d_Vec2d myStartPanCoord; //!< touch coordinates at the moment of starting panning gesture
Graphic3d_Vec2d myStartRotCoord; //!< touch coordinates at the moment of starting rotating gesture
Standard_Integer myNbTouchesLast; //!< number of touches within previous gesture flush to track gesture changes
Standard_Boolean myUpdateStartPointPan; //!< flag indicating that new anchor point should be picked for starting panning gesture
Standard_Boolean myUpdateStartPointRot; //!< flag indicating that new gravity point should be picked for starting rotation gesture
Standard_Boolean myUpdateStartPointZRot; //!< flag indicating that new gravity point should be picked for starting Z-rotation gesture
protected: //! @name rotation/panning transient state variables
Handle(AIS_Point) myAnchorPointPrs1; //!< anchor point presentation (Graphic3d_ZLayerId_Top)
Handle(AIS_Point) myAnchorPointPrs2; //!< anchor point presentation (Graphic3d_ZLayerId_Topmost)
gp_Pnt myPanPnt3d; //!< active panning anchor point
gp_Pnt myRotatePnt3d; //!< active rotation center of gravity
gp_Dir myCamStartOpUp; //!< camera Up direction at the beginning of rotation
gp_Pnt myCamStartOpEye; //!< camera Eye position at the beginning of rotation
gp_Pnt myCamStartOpCenter; //!< camera Center position at the beginning of rotation
gp_Vec myCamStartOpToCenter; //!< vector from rotation gravity point to camera Center at the beginning of rotation
gp_Vec myCamStartOpToEye; //!< vector from rotation gravity point to camera Eye at the beginning of rotation
Graphic3d_Vec3d myRotateStartYawPitchRoll; //!< camera yaw pitch roll at the beginning of rotation
};
#endif // _AIS_ViewController_HeaderFile

2106
src/AIS/AIS_ViewCube.cxx Normal file

File diff suppressed because it is too large Load Diff

1060
src/AIS/AIS_ViewCube.hxx Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,153 +0,0 @@
// Copyright (c) 2016-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_ViewInputBuffer_HeaderFile
#define _AIS_ViewInputBuffer_HeaderFile
#include <Aspect_ScrollDelta.hxx>
#include <Graphic3d_Vec2.hxx>
#include <NCollection_Sequence.hxx>
#include <V3d_TypeOfOrientation.hxx>
//! Selection mode
enum AIS_ViewSelectionTool
{
AIS_ViewSelectionTool_Picking, //!< pick to select
AIS_ViewSelectionTool_RubberBand, //!< rubber-band to select
AIS_ViewSelectionTool_Polygon //!< polyline to select
};
//! Input buffer type.
enum AIS_ViewInputBufferType
{
AIS_ViewInputBufferType_UI, //!< input buffer for filling from UI thread
AIS_ViewInputBufferType_GL, //!< input buffer accessible from GL thread
};
//! Auxiliary structure defining viewer events
class AIS_ViewInputBuffer
{
public:
bool IsNewGesture; //!< transition from one action to another
NCollection_Sequence<Aspect_ScrollDelta> ZoomActions; //!< the queue with zoom actions
struct _orientation
{
bool ToFitAll; //!< perform FitAll operation
bool ToSetViewOrient; //!< set new view orientation
V3d_TypeOfOrientation ViewOrient; //!< new view orientation
_orientation() : ToFitAll (false), ToSetViewOrient (false), ViewOrient (V3d_Xpos) {}
} Orientation;
struct _highlighting
{
bool ToHilight; //!< perform dynamic highlighting at specified point
Graphic3d_Vec2i Point; //!< the new point for dynamic highlighting
_highlighting() : ToHilight (false) {}
} MoveTo;
struct _selection
{
AIS_ViewSelectionTool Tool; //!< perform selection
bool IsXOR; //!< perform shift selection
NCollection_Sequence<Graphic3d_Vec2i>
Points; //!< the points for selection
bool ToApplyTool; //!< apply rubber-band selection tool
_selection() : Tool (AIS_ViewSelectionTool_Picking), IsXOR (false), ToApplyTool (false) {}
} Selection;
struct _panningParams
{
bool ToStart; //!< start panning
Graphic3d_Vec2i PointStart; //!< panning start point
bool ToPan; //!< perform panning
Graphic3d_Vec2i Delta; //!< panning delta
_panningParams() : ToStart (false), ToPan (false) {}
} Panning;
struct _draggingParams
{
bool ToStart; //!< start dragging
bool ToStop; //!< stop dragging
bool ToAbort; //!< abort dragging (restore previous position)
Graphic3d_Vec2i PointStart; //!< drag start point
Graphic3d_Vec2i PointTo; //!< drag end point
_draggingParams() : ToStart (false), ToStop (false), ToAbort (false) {}
} Dragging;
struct _orbitRotation
{
bool ToStart; //!< start orbit rotation
Graphic3d_Vec2d PointStart; //!< orbit rotation start point
bool ToRotate; //!< perform orbit rotation
Graphic3d_Vec2d PointTo; //!< orbit rotation end point
_orbitRotation() : ToStart (false), ToRotate (false) {}
} OrbitRotation;
struct _viewRotation
{
bool ToStart; //!< start view rotation
Graphic3d_Vec2d PointStart; //!< view rotation start point
bool ToRotate; //!< perform view rotation
Graphic3d_Vec2d PointTo; //!< view rotation end point
_viewRotation() : ToStart (false), ToRotate (false) {}
} ViewRotation;
struct _zrotateParams
{
Graphic3d_Vec2i Point; //!< Z rotation start point
double Angle; //!< Z rotation angle
bool ToRotate; //!< start Z rotation
_zrotateParams() : Angle (0.0), ToRotate (false) {}
} ZRotate;
public:
AIS_ViewInputBuffer()
: IsNewGesture (false) {}
//! Reset events buffer.
void Reset()
{
Orientation.ToFitAll = false;
Orientation.ToSetViewOrient = false;
MoveTo.ToHilight = false;
Selection.ToApplyTool = false;
IsNewGesture = false;
ZoomActions.Clear();
Panning.ToStart = false;
Panning.ToPan = false;
Dragging.ToStart = false;
Dragging.ToStop = false;
Dragging.ToAbort = false;
OrbitRotation.ToStart = false;
OrbitRotation.ToRotate = false;
ViewRotation.ToStart = false;
ViewRotation.ToRotate = false;
ZRotate.ToRotate = false;
}
};
#endif // _AIS_ViewInputBuffer_HeaderFile

View File

@@ -1,115 +0,0 @@
// 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_WalkDelta_HeaderFile
#define _AIS_WalkDelta_HeaderFile
#include <Standard_Real.hxx>
//! Walking translation components.
enum AIS_WalkTranslation
{
AIS_WalkTranslation_Forward = 0, //!< translation delta, Forward walk
AIS_WalkTranslation_Side, //!< translation delta, Side walk
AIS_WalkTranslation_Up, //!< translation delta, Up walk
};
//! Walking rotation components.
enum AIS_WalkRotation
{
AIS_WalkRotation_Yaw = 0, //!< yaw rotation angle
AIS_WalkRotation_Pitch, //!< pitch rotation angle
AIS_WalkRotation_Roll, //!< roll rotation angle
};
//! Walking value.
struct AIS_WalkPart
{
Standard_Real Value; //!< value
Standard_Real Pressure; //!< key pressure
Standard_Real Duration; //!< duration
//! Return TRUE if delta is empty.
bool IsEmpty() const { return Abs (Value) <= RealSmall(); }
//! Empty constructor.
AIS_WalkPart() : Value (0.0), Pressure (1.0), Duration (0.0) {}
};
//! Walking values.
struct AIS_WalkDelta
{
//! Empty constructor.
AIS_WalkDelta()
: myIsJumping (false), myIsCrouching (false), myIsRunning (false) {}
//! Return translation component.
const AIS_WalkPart& operator[] (AIS_WalkTranslation thePart) const { return myTranslation[thePart]; }
//! Return translation component.
AIS_WalkPart& operator[] (AIS_WalkTranslation thePart) { return myTranslation[thePart]; }
//! Return rotation component.
const AIS_WalkPart& operator[] (AIS_WalkRotation thePart) const { return myRotation[thePart]; }
//! Return rotation component.
AIS_WalkPart& operator[] (AIS_WalkRotation thePart) { return myRotation[thePart]; }
//! Return jumping state.
bool IsJumping() const { return myIsJumping; }
//! Set jumping state.
void SetJumping (bool theIsJumping) { myIsJumping = theIsJumping; }
//! Return crouching state.
bool IsCrouching() const { return myIsCrouching; }
//! Set crouching state.
void SetCrouching (bool theIsCrouching) { myIsCrouching = theIsCrouching; }
//! Return running state.
bool IsRunning() const { return myIsRunning; }
//! Set running state.
void SetRunning (bool theIsRunning) { myIsRunning = theIsRunning; }
//! Return TRUE when both Rotation and Translation deltas are empty.
bool IsEmpty() const { return !ToMove() && !ToRotate(); }
//! Return TRUE if translation delta is defined.
bool ToMove() const
{
return !myTranslation[AIS_WalkTranslation_Forward].IsEmpty()
|| !myTranslation[AIS_WalkTranslation_Side].IsEmpty()
|| !myTranslation[AIS_WalkTranslation_Up].IsEmpty();
}
//! Return TRUE if rotation delta is defined.
bool ToRotate() const
{
return !myRotation[AIS_WalkRotation_Yaw].IsEmpty()
|| !myRotation[AIS_WalkRotation_Pitch].IsEmpty()
|| !myRotation[AIS_WalkRotation_Roll].IsEmpty();
}
private:
AIS_WalkPart myTranslation[3];
AIS_WalkPart myRotation[3];
bool myIsJumping;
bool myIsCrouching;
bool myIsRunning;
};
#endif // _AIS_WalkDelta_HeaderFile

View File

@@ -56,7 +56,6 @@ AIS_DimensionSelectionMode.hxx
AIS_DisplayMode.hxx
AIS_DisplaySpecialSymbol.hxx
AIS_DisplayStatus.hxx
AIS_DragAction.hxx
AIS_EllipseRadiusDimension.cxx
AIS_EllipseRadiusDimension.hxx
AIS_EqualDistanceRelation.cxx
@@ -107,7 +106,6 @@ AIS_MaxRadiusDimension.cxx
AIS_MaxRadiusDimension.hxx
AIS_MediaPlayer.cxx
AIS_MediaPlayer.hxx
AIS_MouseGesture.hxx
AIS_MidPointRelation.cxx
AIS_MidPointRelation.hxx
AIS_MidPointRelation.lxx
@@ -116,7 +114,6 @@ AIS_MinRadiusDimension.hxx
AIS_MultipleConnectedInteractive.cxx
AIS_MultipleConnectedInteractive.hxx
AIS_MultipleConnectedInteractive.lxx
AIS_NavigationMode.hxx
AIS_NListOfEntityOwner.hxx
AIS_OffsetDimension.cxx
AIS_OffsetDimension.hxx
@@ -138,13 +135,14 @@ AIS_RadiusDimension.cxx
AIS_RadiusDimension.hxx
AIS_Relation.cxx
AIS_Relation.hxx
AIS_RotationMode.hxx
AIS_RubberBand.hxx
AIS_RubberBand.cxx
AIS_Selection.cxx
AIS_Selection.hxx
AIS_SelectStatus.hxx
AIS_SelectionModesConcurrency.hxx
AIS_SelectionScheme.hxx
AIS_SelectionType.hxx
AIS_SequenceOfDimension.hxx
AIS_SequenceOfInteractive.hxx
AIS_Shape.cxx
@@ -179,7 +177,5 @@ AIS_TypeOfAxis.hxx
AIS_TypeOfDist.hxx
AIS_TypeOfIso.hxx
AIS_TypeOfPlane.hxx
AIS_ViewController.cxx
AIS_ViewController.hxx
AIS_ViewInputBuffer.hxx
AIS_WalkDelta.hxx
AIS_ViewCube.hxx
AIS_ViewCube.cxx

452
src/Aspect/Aspect.cxx Normal file
View 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
View 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

View File

@@ -1,59 +0,0 @@
// 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 _Aspect_ScrollDelta_HeaderFile
#define _Aspect_ScrollDelta_HeaderFile
#include <Aspect_VKeyFlags.hxx>
#include <NCollection_Vec2.hxx>
#include <Standard_Real.hxx>
//! Parameters for mouse scroll action.
struct Aspect_ScrollDelta
{
NCollection_Vec2<int> Point; //!< scale position
Standard_Real Delta; //!< delta in pixels
Aspect_VKeyFlags Flags; //!< key flags
//! Return true if action has point defined.
bool HasPoint() const
{
return Point.x() >= 0
&& Point.y() >= 0;
}
//! Reset at point.
void ResetPoint()
{
Point.SetValues (-1, -1);
}
//! Empty constructor.
Aspect_ScrollDelta()
: Point (-1, -1), Delta (0.0), Flags (Aspect_VKeyFlags_NONE) {}
//! Constructor.
Aspect_ScrollDelta (const NCollection_Vec2<int>& thePnt,
Standard_Real theValue,
Aspect_VKeyFlags theFlags = Aspect_VKeyFlags_NONE)
: Point (thePnt), Delta (theValue), Flags (theFlags) {}
//! Constructor with undefined point.
Aspect_ScrollDelta (Standard_Real theValue,
Aspect_VKeyFlags theFlags = Aspect_VKeyFlags_NONE)
: Point (-1, -1), Delta (theValue), Flags (theFlags) {}
};
#endif // _Aspect_ScrollDelta_HeaderFile

View File

@@ -1,49 +0,0 @@
// Copyright (c) 2016-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 _Aspect_Touch_HeaderFile
#define _Aspect_Touch_HeaderFile
#include <NCollection_Vec2.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
//! Structure holding touch position - original and current location.
class Aspect_Touch
{
public:
NCollection_Vec2<Standard_Real> From; //!< original touch position
NCollection_Vec2<Standard_Real> To; //!< current touch position
Standard_Boolean IsPreciseDevice; //!< precise device input (e.g. mouse cursor, NOT emulated from touch screen)
//! Return values delta.
NCollection_Vec2<Standard_Real> Delta() const { return To - From; }
//! Empty constructor
Aspect_Touch()
: From (0.0, 0.0), To (0.0, 0.0), IsPreciseDevice (false) {}
//! Constructor with initialization.
Aspect_Touch (const NCollection_Vec2<Standard_Real>& thePnt,
Standard_Boolean theIsPreciseDevice)
: From (thePnt), To (thePnt), IsPreciseDevice (theIsPreciseDevice) {}
//! Constructor with initialization.
Aspect_Touch (Standard_Real theX, Standard_Real theY,
Standard_Boolean theIsPreciseDevice)
: From (theX, theY), To (theX, theY), IsPreciseDevice (theIsPreciseDevice) {}
};
#endif // _Aspect_Touch_HeaderFile

View File

@@ -1,199 +0,0 @@
// Copyright (c) 2016-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 _Aspect_VKey_HeaderFile
#define _Aspect_VKey_HeaderFile
#include <Aspect_VKeyFlags.hxx>
//! Define virtual key as integer number to allow extensions.
typedef unsigned int Aspect_VKey;
//! Enumeration defining virtual keys irrelevant to current keyboard layout for simplified hot-keys management logic.
enum Aspect_VKeyBasic
{
Aspect_VKey_UNKNOWN = 0,
// main latin alphabet keys
Aspect_VKey_A = 1,
Aspect_VKey_B,
Aspect_VKey_C,
Aspect_VKey_D,
Aspect_VKey_E,
Aspect_VKey_F,
Aspect_VKey_G,
Aspect_VKey_H,
Aspect_VKey_I,
Aspect_VKey_J,
Aspect_VKey_K,
Aspect_VKey_L,
Aspect_VKey_M,
Aspect_VKey_N,
Aspect_VKey_O,
Aspect_VKey_P,
Aspect_VKey_Q,
Aspect_VKey_R,
Aspect_VKey_S,
Aspect_VKey_T,
Aspect_VKey_U,
Aspect_VKey_V,
Aspect_VKey_W,
Aspect_VKey_X,
Aspect_VKey_Y,
Aspect_VKey_Z,
Aspect_VKey_0,
Aspect_VKey_1,
Aspect_VKey_2,
Aspect_VKey_3,
Aspect_VKey_4,
Aspect_VKey_5,
Aspect_VKey_6,
Aspect_VKey_7,
Aspect_VKey_8,
Aspect_VKey_9,
Aspect_VKey_F1,
Aspect_VKey_F2,
Aspect_VKey_F3,
Aspect_VKey_F4,
Aspect_VKey_F5,
Aspect_VKey_F6,
Aspect_VKey_F7,
Aspect_VKey_F8,
Aspect_VKey_F9,
Aspect_VKey_F10,
Aspect_VKey_F11,
Aspect_VKey_F12,
// standard keys
Aspect_VKey_Up,
Aspect_VKey_Down,
Aspect_VKey_Left,
Aspect_VKey_Right,
Aspect_VKey_Plus, //!< '+'
Aspect_VKey_Minus, //!< '-'
Aspect_VKey_Equal, //!< '=+'
Aspect_VKey_PageUp,
Aspect_VKey_PageDown,
Aspect_VKey_Home,
Aspect_VKey_End,
Aspect_VKey_Escape,
Aspect_VKey_Back,
Aspect_VKey_Enter,
Aspect_VKey_Backspace,
Aspect_VKey_Space,
Aspect_VKey_Delete,
Aspect_VKey_Tilde,
Aspect_VKey_Tab,
Aspect_VKey_Comma, //!< ','
Aspect_VKey_Period, //!< '.'
Aspect_VKey_Semicolon, //!< ';:'
Aspect_VKey_Slash, //!< '/?'
Aspect_VKey_BracketLeft, //!< '[{'
Aspect_VKey_Backslash, //!< '\|'
Aspect_VKey_BracketRight, //!< ']}'
Aspect_VKey_Apostrophe, //!< ''"'
Aspect_VKey_Numlock, //!< Num Lock key
Aspect_VKey_Scroll, //!< Scroll Lock key
// numpad keys
Aspect_VKey_Numpad0,
Aspect_VKey_Numpad1,
Aspect_VKey_Numpad2,
Aspect_VKey_Numpad3,
Aspect_VKey_Numpad4,
Aspect_VKey_Numpad5,
Aspect_VKey_Numpad6,
Aspect_VKey_Numpad7,
Aspect_VKey_Numpad8,
Aspect_VKey_Numpad9,
Aspect_VKey_NumpadMultiply, //!< numpad '*'
Aspect_VKey_NumpadAdd, //!< numpad '+'
Aspect_VKey_NumpadSubtract, //!< numpad '-'
Aspect_VKey_NumpadDivide, //!< numpad '/'
// Multimedia keys
Aspect_VKey_MediaNextTrack,
Aspect_VKey_MediaPreviousTrack,
Aspect_VKey_MediaStop,
Aspect_VKey_MediaPlayPause,
Aspect_VKey_VolumeMute,
Aspect_VKey_VolumeDown,
Aspect_VKey_VolumeUp,
Aspect_VKey_BrowserBack,
Aspect_VKey_BrowserForward,
Aspect_VKey_BrowserRefresh,
Aspect_VKey_BrowserStop,
Aspect_VKey_BrowserSearch,
Aspect_VKey_BrowserFavorites,
Aspect_VKey_BrowserHome,
// modifier keys, @sa Aspect_VKey_ModifiersLower and Aspect_VKey_ModifiersUpper below
Aspect_VKey_Shift,
Aspect_VKey_Control,
Aspect_VKey_Alt,
Aspect_VKey_Menu,
Aspect_VKey_Meta,
// virtual navigation keys, @sa Aspect_VKey_NavigationKeysLower and Aspect_VKey_NavigationKeysUpper below
Aspect_VKey_NavInteract, //!< interact
Aspect_VKey_NavForward, //!< go forward
Aspect_VKey_NavBackward, //!< go backward
Aspect_VKey_NavSlideLeft, //!< sidewalk, left
Aspect_VKey_NavSlideRight, //!< sidewalk, right
Aspect_VKey_NavSlideUp, //!< lift up
Aspect_VKey_NavSlideDown, //!< fall down
Aspect_VKey_NavRollCCW, //!< bank left (roll counter-clockwise)
Aspect_VKey_NavRollCW, //!< bank right (roll clockwise)
Aspect_VKey_NavLookLeft, //!< look left (yaw counter-clockwise)
Aspect_VKey_NavLookRight, //!< look right (yaw clockwise)
Aspect_VKey_NavLookUp, //!< look up (pitch clockwise)
Aspect_VKey_NavLookDown, //!< look down (pitch counter-clockwise)
Aspect_VKey_NavCrouch, //!< crouch walking
Aspect_VKey_NavJump, //!< jump
Aspect_VKey_NavThrustForward, //!< increase continuous velocity in forward direction
Aspect_VKey_NavThrustBackward, //!< increase continuous velocity in reversed direction
Aspect_VKey_NavThrustStop, //!< reset continuous velocity
Aspect_VKey_NavSpeedIncrease, //!< increase navigation speed
Aspect_VKey_NavSpeedDecrease, //!< decrease navigation speed
};
//! Auxiliary ranges.
enum
{
Aspect_VKey_Lower = 0,
Aspect_VKey_ModifiersLower = Aspect_VKey_Shift,
Aspect_VKey_ModifiersUpper = Aspect_VKey_Meta,
Aspect_VKey_NavigationKeysLower = Aspect_VKey_NavInteract,
Aspect_VKey_NavigationKeysUpper = Aspect_VKey_NavSpeedDecrease,
Aspect_VKey_Upper = Aspect_VKey_NavSpeedDecrease,
Aspect_VKey_NB = Aspect_VKey_Upper - Aspect_VKey_Lower + 1,
Aspect_VKey_MAX = 255
};
//! Return modifier flags for specified modifier key.
inline Aspect_VKeyFlags Aspect_VKey2Modifier (Aspect_VKey theKey)
{
switch (theKey)
{
case Aspect_VKey_Shift: return Aspect_VKeyFlags_SHIFT;
case Aspect_VKey_Control: return Aspect_VKeyFlags_CTRL;
case Aspect_VKey_Alt: return Aspect_VKeyFlags_ALT;
case Aspect_VKey_Menu: return Aspect_VKeyFlags_MENU;
case Aspect_VKey_Meta: return Aspect_VKeyFlags_META;
default: return 0;
}
}
#endif // _Aspect_VKey_HeaderFile

View File

@@ -1,49 +0,0 @@
// Copyright (c) 2016-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 _Aspect_VKeyFlags_HeaderFile
#define _Aspect_VKeyFlags_HeaderFile
//! Key modifier, for combining with general key from Aspect_VKey.
typedef unsigned int Aspect_VKeyFlags;
//! Key modifier, for combining with general key from Aspect_VKey.
enum
{
Aspect_VKeyFlags_NONE = 0,
// reserve first 8 bits to combine value with Aspect_VKey
Aspect_VKeyFlags_SHIFT = 1 << 8, //!< Aspect_VKey_Shift
Aspect_VKeyFlags_CTRL = 1 << 9, //!< Aspect_VKey_Control
Aspect_VKeyFlags_ALT = 1 << 10, //!< Aspect_VKey_Alt
Aspect_VKeyFlags_MENU = 1 << 11, //!< Aspect_VKey_Menu
Aspect_VKeyFlags_META = 1 << 12, //!< Aspect_VKey_Meta
Aspect_VKeyFlags_ALL = Aspect_VKeyFlags_SHIFT | Aspect_VKeyFlags_CTRL | Aspect_VKeyFlags_ALT | Aspect_VKeyFlags_MENU | Aspect_VKeyFlags_META
};
//! Mouse buttons, for combining with Aspect_VKey and Aspect_VKeyFlags.
typedef unsigned int Aspect_VKeyMouse;
//! Mouse button bitmask
enum
{
Aspect_VKeyMouse_NONE = 0, //!< no buttons
Aspect_VKeyMouse_LeftButton = 1 << 13, //!< mouse left button
Aspect_VKeyMouse_MiddleButton = 1 << 14, //!< mouse middle button (scroll)
Aspect_VKeyMouse_RightButton = 1 << 15, //!< mouse right button
Aspect_VKeyMouse_MainButtons = Aspect_VKeyMouse_LeftButton | Aspect_VKeyMouse_MiddleButton | Aspect_VKeyMouse_RightButton
};
#endif // _Aspect_VKeyFlags_HeaderFile

View File

@@ -1,150 +0,0 @@
// Copyright (c) 2016-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 "Aspect_VKeySet.hxx"
IMPLEMENT_STANDARD_RTTIEXT(Aspect_VKeySet, Standard_Transient)
// ================================================================
// Function : As1pect_VKeySet
// Purpose :
// ================================================================
Aspect_VKeySet::Aspect_VKeySet()
: myKeys (0, Aspect_VKey_MAX),
myModifiers (Aspect_VKeyFlags_NONE)
{
//
}
// ================================================================
// Function : Reset
// Purpose :
// ================================================================
void Aspect_VKeySet::Reset()
{
Standard_Mutex::Sentry aLock (myLock);
myModifiers = 0;
for (NCollection_Array1<KeyState>::Iterator aKeyIter (myKeys); aKeyIter.More(); aKeyIter.Next())
{
aKeyIter.ChangeValue().Reset();
}
}
// ================================================================
// Function : KeyDown
// Purpose :
// ================================================================
void Aspect_VKeySet::KeyDown (Aspect_VKey theKey,
double theTime,
double thePressure)
{
Standard_Mutex::Sentry aLock (myLock);
if (myKeys[theKey].Status != KeyStatus_Pressed)
{
myKeys[theKey].Status = KeyStatus_Pressed;
myKeys[theKey].TimeDown = theTime;
}
myKeys[theKey].Pressure = thePressure;
const unsigned int aModif = Aspect_VKey2Modifier (theKey);
myModifiers = myModifiers | aModif;
}
// ================================================================
// Function : KeyUp
// Purpose :
// ================================================================
void Aspect_VKeySet::KeyUp (Aspect_VKey theKey,
double theTime)
{
Standard_Mutex::Sentry aLock (myLock);
if (myKeys[theKey].Status == KeyStatus_Pressed)
{
myKeys[theKey].Status = KeyStatus_Released;
myKeys[theKey].TimeUp = theTime;
}
const unsigned int aModif = Aspect_VKey2Modifier (theKey);
if (aModif != 0)
{
myModifiers = myModifiers & ~aModif;
}
}
// ================================================================
// Function : KeyFromAxis
// Purpose :
// ================================================================
void Aspect_VKeySet::KeyFromAxis (Aspect_VKey theNegative,
Aspect_VKey thePositive,
double theTime,
double thePressure)
{
Standard_Mutex::Sentry aLock (myLock);
if (thePressure != 0)
{
const Aspect_VKey aKeyDown = thePressure > 0 ? thePositive : theNegative;
const Aspect_VKey aKeyUp = thePressure < 0 ? thePositive : theNegative;
KeyDown (aKeyDown, theTime, Abs (thePressure));
if (myKeys[aKeyUp].Status == KeyStatus_Pressed)
{
KeyUp (aKeyUp, theTime);
}
}
else
{
if (myKeys[theNegative].Status == KeyStatus_Pressed)
{
KeyUp (theNegative, theTime);
}
if (myKeys[thePositive].Status == KeyStatus_Pressed)
{
KeyUp (thePositive, theTime);
}
}
}
// ================================================================
// Function : HoldDuration
// Purpose :
// ================================================================
bool Aspect_VKeySet::HoldDuration (Aspect_VKey theKey,
double theTime,
double& theDuration,
double& thePressure)
{
Standard_Mutex::Sentry aLock (myLock);
switch (myKeys[theKey].Status)
{
case KeyStatus_Free:
{
theDuration = 0.0;
return false;
}
case KeyStatus_Released:
{
myKeys[theKey].Status = KeyStatus_Free;
theDuration = myKeys[theKey].TimeUp - myKeys[theKey].TimeDown;
thePressure = myKeys[theKey].Pressure;
return true;
}
case KeyStatus_Pressed:
{
theDuration = theTime - myKeys[theKey].TimeDown;
thePressure = myKeys[theKey].Pressure;
return true;
}
}
return false;
}

View File

@@ -1,152 +0,0 @@
// Copyright (c) 2016-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 _Aspect_VKeySet_HeaderFile
#define _Aspect_VKeySet_HeaderFile
#include <Aspect_VKey.hxx>
#include <NCollection_Array1.hxx>
#include <OSD_Timer.hxx>
#include <Standard_Mutex.hxx>
#include <Standard_Transient.hxx>
//! Structure defining key state.
class Aspect_VKeySet : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Aspect_VKeySet, Standard_Transient)
public:
//! Main constructor.
Standard_EXPORT Aspect_VKeySet();
//! Return active modifiers.
Aspect_VKeyFlags Modifiers() const
{
Standard_Mutex::Sentry aLock (myLock);
return myModifiers;
}
//! Return timestamp of press event.
double DownTime (Aspect_VKey theKey) const
{
Standard_Mutex::Sentry aLock (myLock);
return myKeys[theKey].TimeDown;
}
//! Return timestamp of release event.
double TimeUp (Aspect_VKey theKey) const
{
Standard_Mutex::Sentry aLock (myLock);
return myKeys[theKey].TimeUp;
}
//! Return TRUE if key is in Free state.
bool IsFreeKey (Aspect_VKey theKey) const
{
Standard_Mutex::Sentry aLock (myLock);
return myKeys[theKey].Status == KeyStatus_Free;
}
//! Return TRUE if key is in Pressed state.
bool IsKeyDown (Aspect_VKey theKey) const
{
Standard_Mutex::Sentry aLock (myLock);
return myKeys[theKey].Status == KeyStatus_Pressed;
}
public:
//! Reset the key state into unpressed state.
Standard_EXPORT void Reset();
//! Press key.
//! @param theKey key pressed
//! @param theTime event timestamp
Standard_EXPORT void KeyDown (Aspect_VKey theKey,
double theTime,
double thePressure = 1.0);
//! Release key.
//! @param theKey key pressed
//! @param theTime event timestamp
Standard_EXPORT void KeyUp (Aspect_VKey theKey,
double theTime);
//! Simulate key up/down events from axis value.
Standard_EXPORT void KeyFromAxis (Aspect_VKey theNegative,
Aspect_VKey thePositive,
double theTime,
double thePressure);
//! Return duration of the button in pressed state.
//! @param theKey key to check
//! @param theTime current time (for computing duration from key down time)
//! @param theDuration key press duration
//! @return TRUE if key was in pressed state
bool HoldDuration (Aspect_VKey theKey,
double theTime,
double& theDuration)
{
double aPressure = -1.0;
return HoldDuration (theKey, theTime, theDuration, aPressure);
}
//! Return duration of the button in pressed state.
//! @param theKey key to check
//! @param theTime current time (for computing duration from key down time)
//! @param theDuration key press duration
//! @param thePressure key pressure
//! @return TRUE if key was in pressed state
Standard_EXPORT bool HoldDuration (Aspect_VKey theKey,
double theTime,
double& theDuration,
double& thePressure);
private:
//! Key state.
enum KeyStatus
{
KeyStatus_Free, //!< free status
KeyStatus_Pressed, //!< key is in pressed state
KeyStatus_Released, //!< key has been just released (transient state before KeyStatus_Free)
};
//! Structure defining key state.
struct KeyState
{
KeyState() : TimeDown (0.0), TimeUp (0.0), Pressure (1.0), Status (KeyStatus_Free) {}
void Reset()
{
Status = KeyStatus_Free;
TimeDown = 0.0;
TimeUp = 0.0;
Pressure = 1.0;
}
double TimeDown; //!< time of key press event
double TimeUp; //!< time of key release event
double Pressure; //!< key pressure
KeyStatus Status; //!< key status
};
private:
NCollection_Array1<KeyState> myKeys; //!< keys state
mutable Standard_Mutex myLock; //!< mutex for thread-safe updates
Aspect_VKeyFlags myModifiers; //!< active modifiers
};
#endif // _Aspect_VKeySet_HeaderFile

View File

@@ -16,21 +16,28 @@
#ifndef _Aspect_Window_HeaderFile
#define _Aspect_Window_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Aspect_Background.hxx>
#include <Aspect_GradientBackground.hxx>
#include <Aspect_FBConfig.hxx>
#include <Aspect_FillMethod.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Transient.hxx>
#include <Quantity_Color.hxx>
#include <Aspect_GradientFillMethod.hxx>
#include <Aspect_TypeOfResize.hxx>
#include <Standard_Integer.hxx>
#include <Aspect_Drawable.hxx>
#include <Standard.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
class Aspect_DisplayConnection;
class Aspect_WindowDefinitionError;
class Aspect_WindowError;
class Aspect_Background;
class Aspect_GradientBackground;
class Aspect_Window;
DEFINE_STANDARD_HANDLE(Aspect_Window, Standard_Transient)
//! Defines a window.
@@ -102,9 +109,6 @@ public:
//! Returns native Window FB config (GLXFBConfig on Xlib)
Standard_EXPORT virtual Aspect_FBConfig NativeFBConfig() const = 0;
//! Sets window title.
virtual void SetTitle (const TCollection_AsciiString& theTitle) { (void )theTitle; }
//! Invalidate entire window content.
//!
//! Implementation is expected to allow calling this method from non-GUI thread,

View File

@@ -1,3 +1,5 @@
Aspect.cxx
Aspect.hxx
Aspect_AspectFillAreaDefinitionError.hxx
Aspect_AspectLineDefinitionError.hxx
Aspect_AspectMarkerDefinitionError.hxx
@@ -34,9 +36,6 @@ Aspect_RectangularGrid.cxx
Aspect_RectangularGrid.hxx
Aspect_RenderingContext.hxx
Aspect_SequenceOfColor.hxx
Aspect_ScrollDelta.hxx
Aspect_Touch.hxx
Aspect_TouchMap.hxx
Aspect_TypeOfColorScaleData.hxx
Aspect_TypeOfColorScaleOrientation.hxx
Aspect_TypeOfColorScalePosition.hxx
@@ -50,10 +49,6 @@ Aspect_TypeOfResize.hxx
Aspect_TypeOfStyleText.hxx
Aspect_TypeOfTriedronPosition.hxx
Aspect_Units.hxx
Aspect_VKey.hxx
Aspect_VKeyFlags.hxx
Aspect_VKeySet.cxx
Aspect_VKeySet.hxx
Aspect_WidthOfLine.hxx
Aspect_Window.cxx
Aspect_Window.hxx

View File

@@ -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.

View File

@@ -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.

View File

@@ -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;

View File

@@ -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;
};

View 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());
}

View 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

View 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 {
}

View 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

View File

@@ -53,3 +53,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

View File

@@ -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
cout << "\n Gap : " << Gap;
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;
}

View File

@@ -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.

View File

@@ -17,6 +17,7 @@
#include <Bnd_B3d.hxx>
#include <NCollection_Array1.hxx>
#include <Precision.hxx>
#include <TCollection.hxx>
#include <TColStd_Array1OfReal.hxx>
class OBBTool
@@ -677,3 +678,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;
}

View File

@@ -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>
@@ -276,6 +277,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)

View File

@@ -175,3 +175,12 @@ 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 + "]";
}

View File

@@ -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

View File

@@ -180,7 +180,7 @@ TCollection_ExtendedString CDF_FWOSDriver::DefaultFolder()
else {
theDefaultFolder=UTL::xgetenv("TEMP");
if(theDefaultFolder.Length()==0)
theDefaultFolder = ".";
throw Standard_Failure("cannot determine default folder; HOMEDRIVE and TEMP are undefined");
}
#else
TCollection_ExtendedString home=UTL::xgetenv("HOME");

View File

@@ -46,7 +46,10 @@ void CDF_Store::Init() {
myCurrentDocument = myMainDocument;
myList = new CDF_StoreList(myCurrentDocument);
// getting the subcomponents.
myIsMainDocument = Standard_True;
FindDefault();
// getting the subcomponents.
//
myIsMainDocument = Standard_False;
myList->Init();

View File

@@ -47,7 +47,6 @@
#include <Aspect_GradientFillMethod.hxx>
#include <Aspect_Handle.hxx>
#include <Aspect_TypeOfResize.hxx>
#include <Aspect_VKey.hxx>
#include <Quantity_NameOfColor.hxx>
class Aspect_WindowDefinitionError;
@@ -59,10 +58,6 @@ class Aspect_GradientBackground;
//! This class defines Cocoa window
class Cocoa_Window : public Aspect_Window
{
public:
//! Convert Carbon virtual key into Aspect_VKey.
Standard_EXPORT static Aspect_VKey VirtualKeyFromNative (Standard_Integer theKey);
public:
@@ -141,9 +136,6 @@ public:
//! Returns nothing on OS X
virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return NULL; }
//! Sets window title.
Standard_EXPORT virtual void SetTitle (const TCollection_AsciiString& theTitle) Standard_OVERRIDE;
//! Invalidate entire window content by setting NSView::setNeedsDisplay property.
//! Call will be implicitly redirected to the main thread when called from non-GUI thread.
Standard_EXPORT virtual void InvalidateContent (const Handle(Aspect_DisplayConnection)& theDisp = NULL) Standard_OVERRIDE;

View File

@@ -403,27 +403,6 @@ void Cocoa_Window::Size (Standard_Integer& theWidth,
theHeight = (Standard_Integer )aBounds.size.height;
}
// =======================================================================
// function : SetTitle
// purpose :
// =======================================================================
void Cocoa_Window::SetTitle (const TCollection_AsciiString& theTitle)
{
if (myHView == NULL)
{
return;
}
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
(void )theTitle;
#else
NSWindow* aWindow = [myHView window];
NSString* aTitleNS = [[NSString alloc] initWithUTF8String: theTitle.ToCString()];
[aWindow setTitle: aTitleNS];
[aTitleNS release];
#endif
}
// =======================================================================
// function : InvalidateContent
// purpose :
@@ -450,143 +429,3 @@ void Cocoa_Window::InvalidateContent (const Handle(Aspect_DisplayConnection)& )
waitUntilDone: NO];
}
}
// =======================================================================
// function : VirtualKeyFromNative
// purpose :
// =======================================================================
Aspect_VKey Cocoa_Window::VirtualKeyFromNative (Standard_Integer theKey)
{
switch (theKey)
{
case 0x00: return Aspect_VKey_A;
case 0x01: return Aspect_VKey_S;
case 0x02: return Aspect_VKey_D;
case 0x03: return Aspect_VKey_F;
case 0x04: return Aspect_VKey_H;
case 0x05: return Aspect_VKey_G;
case 0x06: return Aspect_VKey_Z;
case 0x07: return Aspect_VKey_X;
case 0x08: return Aspect_VKey_C;
case 0x09: return Aspect_VKey_V;
case 0x0A: return Aspect_VKey_UNKNOWN;
case 0x0B: return Aspect_VKey_B;
case 0x0C: return Aspect_VKey_Q;
case 0x0D: return Aspect_VKey_W;
case 0x0E: return Aspect_VKey_E;
case 0x0F: return Aspect_VKey_R;
case 0x10: return Aspect_VKey_Y;
case 0x11: return Aspect_VKey_T;
case 0x12: return Aspect_VKey_1;
case 0x13: return Aspect_VKey_2;
case 0x14: return Aspect_VKey_3;
case 0x15: return Aspect_VKey_4;
case 0x16: return Aspect_VKey_6;
case 0x17: return Aspect_VKey_5;
case 0x18: return Aspect_VKey_Plus;
case 0x19: return Aspect_VKey_9;
case 0x1A: return Aspect_VKey_7;
case 0x1B: return Aspect_VKey_Minus;
case 0x1C: return Aspect_VKey_8;
case 0x1D: return Aspect_VKey_0;
case 0x1E: return Aspect_VKey_BracketRight;
case 0x1F: return Aspect_VKey_O;
case 0x20: return Aspect_VKey_U;
case 0x21: return Aspect_VKey_BracketLeft;
case 0x22: return Aspect_VKey_I;
case 0x23: return Aspect_VKey_P;
case 0x24: return Aspect_VKey_Enter;
case 0x25: return Aspect_VKey_L;
case 0x26: return Aspect_VKey_J;
case 0x27: return Aspect_VKey_Apostrophe;
case 0x28: return Aspect_VKey_K;
case 0x29: return Aspect_VKey_Semicolon;
case 0x2A: return Aspect_VKey_Backslash;
case 0x2B: return Aspect_VKey_Comma; // 43, ',<'
case 0x2C: return Aspect_VKey_Slash; //ST_VK_OEM_2, // 44, '?/'
case 0x2D: return Aspect_VKey_N;
case 0x2E: return Aspect_VKey_M;
case 0x2F: return Aspect_VKey_Period; // 47, '.>'
case 0x30: return Aspect_VKey_Tab;
case 0x31: return Aspect_VKey_Space;
case 0x32: return Aspect_VKey_Tilde; // '~`'
case 0x33: return Aspect_VKey_Backspace;
case 0x34: return Aspect_VKey_UNKNOWN;
case 0x35: return Aspect_VKey_Escape;
case 0x36: return Aspect_VKey_UNKNOWN; // Aspect_VKey_Cmd, right Command
case 0x37: return Aspect_VKey_UNKNOWN; // Aspect_VKey_Cmd, left Command
case 0x38: return Aspect_VKey_Shift; // left shift
case 0x39: return Aspect_VKey_UNKNOWN;
case 0x3A: return Aspect_VKey_Alt; // left alt/option
case 0x3B: return Aspect_VKey_Control;
case 0x3C: return Aspect_VKey_Shift; // right shift
case 0x3D: return Aspect_VKey_Alt; // right alt/option
case 0x3E: return Aspect_VKey_UNKNOWN;
case 0x3F: return Aspect_VKey_UNKNOWN; // Aspect_VKey_Func, fn
case 0x40:
case 0x41:
case 0x42:
case 0x43:
case 0x44:
case 0x45:
case 0x46:
case 0x47:
case 0x48:
case 0x49:
case 0x4A:
case 0x4B: return Aspect_VKey_UNKNOWN;
case 0x4C: return Aspect_VKey_Enter; // fn + return
case 0x4D:
case 0x4E:
case 0x4F:
case 0x50:
case 0x51:
case 0x52:
case 0x53:
case 0x54:
case 0x55:
case 0x56:
case 0x57:
case 0x58:
case 0x59:
case 0x5A:
case 0x5B:
case 0x5C:
case 0x5D:
case 0x5E:
case 0x5F: return Aspect_VKey_UNKNOWN;
case 0x60: return Aspect_VKey_F5;
case 0x61: return Aspect_VKey_F6;
case 0x62: return Aspect_VKey_F7;
case 0x63: return Aspect_VKey_F3;
case 0x64: return Aspect_VKey_F8;
case 0x65: return Aspect_VKey_F9;
//case 0x66: return Aspect_VKey_UNKNOWN;
case 0x67: return Aspect_VKey_F11;
//case 0x68: return Aspect_VKey_UNKNOWN;
//case 0x69: return Aspect_VKey_UNKNOWN;
//case 0x6A: return Aspect_VKey_UNKNOWN;
//case 0x6B: return Aspect_VKey_UNKNOWN;
//case 0x6C: return Aspect_VKey_UNKNOWN;
case 0x6D: return Aspect_VKey_F10;
//case 0x6E: return Aspect_VKey_UNKNOWN;
case 0x6F: return Aspect_VKey_F12;
//case 0x70: return Aspect_VKey_UNKNOWN;
//case 0x71: return Aspect_VKey_UNKNOWN;
//case 0x72: return Aspect_VKey_UNKNOWN;
case 0x73: return Aspect_VKey_Home;
case 0x74: return Aspect_VKey_PageUp;
case 0x75: return Aspect_VKey_Delete;
case 0x76: return Aspect_VKey_F4;
case 0x77: return Aspect_VKey_End;
case 0x78: return Aspect_VKey_F2;
case 0x79: return Aspect_VKey_PageDown;
case 0x7A: return Aspect_VKey_F1;
case 0x7B: return Aspect_VKey_Left;
case 0x7C: return Aspect_VKey_Right;
case 0x7D: return Aspect_VKey_Down;
case 0x7E: return Aspect_VKey_Up;
case 0x7F: return Aspect_VKey_UNKNOWN;
}
return Aspect_VKey_UNKNOWN;
}

View File

@@ -0,0 +1,54 @@
# Install script for directory: F:/Projects/DMUReviewer/3rd-parties_prepared/occt_CR0_DMUReviewer_5/src/DRAWEXE
# Set the install prefix
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "F:/Projects/DMUReviewer/Deps/3rd-parties_2019-06-18_Rina/occt-vc12-64")
endif()
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
# Set the install configuration name.
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
if(BUILD_TYPE)
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
else()
set(CMAKE_INSTALL_CONFIG_NAME "Release")
endif()
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
endif()
# Set the component getting installed.
if(NOT CMAKE_INSTALL_COMPONENT)
if(COMPONENT)
message(STATUS "Install component: \"${COMPONENT}\"")
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
else()
set(CMAKE_INSTALL_COMPONENT)
endif()
endif()
# Is this installation the result of a crosscompile?
if(NOT DEFINED CMAKE_CROSSCOMPILING)
set(CMAKE_CROSSCOMPILING "FALSE")
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
if ("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
set (OCCT_INSTALL_BIN_LETTER "")
elseif ("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$")
set (OCCT_INSTALL_BIN_LETTER "i")
elseif ("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
set (OCCT_INSTALL_BIN_LETTER "d")
endif()
endif()
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
if("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/win64/vc12/bin${OCCT_INSTALL_BIN_LETTER}" TYPE EXECUTABLE FILES "F:/Projects/DMUReviewer/3rd-parties_prepared/occt_CR0_DMUReviewer_5/win64/vc12/bin/DRAWEXE.exe")
elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/win64/vc12/bin${OCCT_INSTALL_BIN_LETTER}" TYPE EXECUTABLE FILES "F:/Projects/DMUReviewer/3rd-parties_prepared/occt_CR0_DMUReviewer_5/win64/vc12/bind/DRAWEXE.exe")
elseif("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$")
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/win64/vc12/bin${OCCT_INSTALL_BIN_LETTER}" TYPE EXECUTABLE FILES "F:/Projects/DMUReviewer/3rd-parties_prepared/occt_CR0_DMUReviewer_5/win64/vc12/bini/DRAWEXE.exe")
endif()
endif()

View File

@@ -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>
@@ -52,8 +53,10 @@ void DsgPrs_XYZAxisPresentation::Add(
if (*aText != '\0')
{
Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (1./81.);
aTextParams->SetText (aText);
aTextParams->SetPosition (gp_Pnt (aPlast.X(),aPlast.Y(),aPlast.Z()));
Prs3d_Root::CurrentGroup(aPresentation)->AddText (aTextParams);
}
}
@@ -83,7 +86,9 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta
if (*aText != '\0')
{
Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z());
Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.);
Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (1./81.);
aTextParams->SetText (aText);
aTextParams->SetPosition (gp_Pnt (aPlast.X(),aPlast.Y(),aPlast.Z()));
Prs3d_Root::CurrentGroup(aPresentation)->AddText(aTextParams);
}
}

View File

@@ -1,3 +1,5 @@
Font.cxx
Font.hxx
Font_BRepFont.cxx
Font_BRepFont.hxx
Font_BRepTextBuilder.cxx

56
src/Font/Font.cxx Normal file
View 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
View 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

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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

View File

@@ -81,17 +81,20 @@ static void CheckCurveData
throw Standard_ConstructionError("BSpline curve: # Poles and degree mismatch");
}
//! Check rationality of an array of weights
static Standard_Boolean Rational (const TColStd_Array1OfReal& theWeights)
//=======================================================================
//function : Rational
//purpose : check rationality of an array of weights
//=======================================================================
static Standard_Boolean Rational(const TColStd_Array1OfReal& W)
{
for (Standard_Integer i = theWeights.Lower(); i < theWeights.Upper(); i++)
{
if (Abs (theWeights[i] - theWeights[i + 1]) > gp::Resolution())
{
return Standard_True;
}
Standard_Integer i, n = W.Length();
Standard_Boolean rat = Standard_False;
for (i = 1; i < n; i++) {
rat = Abs(W(i) - W(i+1)) > gp::Resolution();
if (rat) break;
}
return Standard_False;
return rat;
}
//=======================================================================

View File

@@ -79,17 +79,20 @@ static void CheckCurveData
throw Standard_ConstructionError("BSpline curve: # Poles and degree mismatch");
}
//! Check rationality of an array of weights
static Standard_Boolean Rational (const TColStd_Array1OfReal& theWeights)
//=======================================================================
//function : Rational
//purpose : check rationality of an array of weights
//=======================================================================
static Standard_Boolean Rational(const TColStd_Array1OfReal& W)
{
for (Standard_Integer i = theWeights.Lower(); i < theWeights.Upper(); i++)
{
if (Abs (theWeights[i] - theWeights[i + 1]) > gp::Resolution())
{
return Standard_True;
}
Standard_Integer i, n = W.Length();
Standard_Boolean rat = Standard_False;
for (i = 1; i < n; i++) {
rat = Abs(W(i) - W(i+1)) > gp::Resolution();
if (rat) break;
}
return Standard_False;
return rat;
}
//=======================================================================

View File

@@ -1,3 +1,5 @@
Graphic3d.cxx
Graphic3d.hxx
Graphic3d_AlphaMode.hxx
Graphic3d_ArrayFlags.hxx
Graphic3d_ArrayOfPoints.hxx
@@ -103,6 +105,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 +132,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
View 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
View 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

View File

@@ -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,61 @@ 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;
Quantity_ColorRGBA myInteriorColor;
Quantity_ColorRGBA myBackInteriorColor;
Quantity_ColorRGBA myEdgeColor;
*/
{
Standard_SStream aTmpStream;
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);
}

View File

@@ -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;

View File

@@ -233,6 +233,31 @@ public:
return aState;
}
//! Check if the given bounding box is In and touch the clipping planes
Standard_Boolean ProbeBoxTouch (const Graphic3d_BndBox3d& theBox) const
{
Graphic3d_ClipState aState = Graphic3d_ClipState_Out;
for (const Graphic3d_ClipPlane* aPlaneIter = this; aPlaneIter != NULL; aPlaneIter = aPlaneIter->myNextInChain.get())
{
if (aPlaneIter->IsBoxFullInHalfspace (theBox))
{
// within union operation, if box is entirely inside at least one half-space, others can be ignored
return Standard_False;
}
else if (!aPlaneIter->IsBoxFullOutHalfspace (theBox))
{
// the box is not fully out, and not fully in, check is it on (but not intersect)
if (ProbeBoxMaxPointHalfspace (theBox) != Graphic3d_ClipState_Out)
{
return Standard_True;
}
// if at least one full out test fail, clipping state is inconclusive (partially clipped)
aState = Graphic3d_ClipState_On;
}
}
return Standard_False;
}
public:
//! Check if the given point is outside of the half-space (e.g. should be discarded by clipping plane).
@@ -271,6 +296,16 @@ public:
return IsPointOutHalfspace (aMaxPnt);
}
//! Check if the given bounding box is fully outside of the half-space (e.g. should be discarded by clipping plane).
Graphic3d_ClipState ProbeBoxMaxPointHalfspace (const Graphic3d_BndBox3d& theBox) const
{
const Graphic3d_Vec4d aMaxPnt (myEquation.x() > 0.0 ? theBox.CornerMax().x() : theBox.CornerMin().x(),
myEquation.y() > 0.0 ? theBox.CornerMax().y() : theBox.CornerMin().y(),
myEquation.z() > 0.0 ? theBox.CornerMax().z() : theBox.CornerMin().z(),
1.0);
return ProbePointHalfspace (aMaxPnt);
}
//! Check if the given bounding box is fully inside (or touches from inside) the half-space (e.g. NOT discarded by clipping plane).
bool IsBoxFullInHalfspace (const Graphic3d_BndBox3d& theBox) const
{

View File

@@ -17,6 +17,7 @@
#include <gp_Ax2.hxx>
#include <gp_Pnt.hxx>
#include <Font_TextFormatter.hxx>
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
@@ -29,6 +30,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 +312,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) aTextParams = new Graphic3d_Text (theHeight);
aTextParams->SetText (theText);
aTextParams->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
aTextParams->SetHAlignment (theHta);
aTextParams->SetVAlignment (theVta);
AddText (aTextParams, theToEvalMinMax);
}
// =======================================================================
@@ -346,8 +338,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) aTextParams = new Graphic3d_Text (theHeight);
aTextParams->SetText (theText);
aTextParams->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
AddText (aTextParams, theToEvalMinMax);
}
// =======================================================================
@@ -357,15 +351,20 @@ 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) aTextParams = new Graphic3d_Text (theHeight);
aTextParams->SetText (aText);
aTextParams->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
aTextParams->SetHAlignment (theHta);
aTextParams->SetVAlignment (theVta);
AddText (aTextParams, theToEvalMinMax);
}
// =======================================================================
@@ -375,53 +374,64 @@ 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) aTextParams = new Graphic3d_Text (theHeight);
aTextParams->SetText (aText);
aTextParams->SetOrientation (theOrientation);
aTextParams->SetOwnAnchorPoint (theHasOwnAnchor);
aTextParams->SetHAlignment (theHta);
aTextParams->SetVAlignment (theVta);
AddText (aTextParams, 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;
}
Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (theHeight);
aTextParams->SetText (theText);
aTextParams->SetOrientation (theOrientation);
aTextParams->SetOwnAnchorPoint (theHasOwnAnchor);
aTextParams->SetHAlignment (theHta);
aTextParams->SetVAlignment (theVta);
AddText (aTextParams, theToEvalMinMax);
}
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();
// =======================================================================
// function : Text
// purpose :
// =======================================================================
void Graphic3d_Group::Text (const Handle(Font_TextFormatter)& theTextFormatter,
const gp_Ax2& theOrientation,
const Standard_Real theHeight,
const Standard_Real /*theAngle*/,
const Graphic3d_TextPath /*theTp*/,
const Standard_Boolean theToEvalMinMax,
const Standard_Boolean theHasOwnAnchor)
{
Handle(Graphic3d_Text) aTextParams = new Graphic3d_Text (theHeight);
aTextParams->SetTextFormatter (theTextFormatter);
aTextParams->SetOrientation (theOrientation);
aTextParams->SetOwnAnchorPoint (theHasOwnAnchor);
AddText (aTextParams, theToEvalMinMax);
}
// =======================================================================
@@ -434,6 +444,32 @@ void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
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) aTextParams = new Graphic3d_Text (theHeight);
aTextParams->SetText (aText);
aTextParams->SetPosition (gp_Pnt (thePoint.X(), thePoint.Y(), thePoint.Z()));
AddText (aTextParams, 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 (aPosition.X(), aPosition.Y(), aPosition.Z(), 1.0f));
}
Update();
}

View File

@@ -35,9 +35,11 @@
#include <gp_Ax2.hxx>
#include <TCollection_ExtendedString.hxx>
class Font_TextFormatter;
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,84 +116,9 @@ 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);
@@ -244,6 +171,121 @@ 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);
//! Add text element in 3D space.
Standard_DEPRECATED("Deprecated method Text() with obsolete arguments, use AddText() instead of it")
Standard_EXPORT virtual void Text (const Handle(Font_TextFormatter)& theTextFormatter,
const gp_Ax2& theOrientation,
const Standard_Real theHeight,
const Standard_Real theAngle,
const Graphic3d_TextPath theTp,
const Standard_Boolean theToEvalMinMax,
const Standard_Boolean theHasOwnAnchor = Standard_True);
protected:
//! Creates a group in the structure <AStructure>.

View 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);
}

View File

@@ -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

View File

@@ -0,0 +1,29 @@
// Copyright (c) 2013-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_Text.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
// =======================================================================
// function : Graphic3d_Text
// purpose :
// =======================================================================
Graphic3d_Text::Graphic3d_Text (const Standard_Real theHeight)
: myHeight (theHeight),
myHasPlane (Standard_False),
myHasOwnAnchor (Standard_True),
myHAlign (Graphic3d_HTA_LEFT),
myVAlign (Graphic3d_VTA_BOTTOM)
{
}

View File

@@ -0,0 +1,112 @@
// 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_TextParams_HeaderFile
#define _Graphic3d_TextParams_HeaderFile
#include <gp_Ax2.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_TextPath.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
#include <Font_TextFormatter.hxx>
//! This class with text parameters.
//! The text might be defined in some plane and has own attached point.
//! In case if text formatter is used, the text value is store in the formatter.
class Graphic3d_Text : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
public:
Standard_EXPORT Graphic3d_Text (const Standard_Real theHeight);
//! Destructor.
Standard_EXPORT virtual ~Graphic3d_Text() {}
//! Sets text value.
const NCollection_String& Text() const { return myText; }
//! Returns text value.
void SetText (const NCollection_String& theText) { myText = theText; }
//! 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.
void SetOrientation (const gp_Ax2& theOrientation) { myOrientation = theOrientation; myHasPlane = Standard_True; }
//! Reset text orientation in 3D space.
void ResetOrientation() { myOrientation = gp_Ax2(); myHasPlane = Standard_False; }
//! 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_Real Height() const { return myHeight; }
//! Returns height of text
void SetHeight (const Standard_Real theHeight) { myHeight = theHeight; }
//! Returns horizontal alignment of text.
Graphic3d_HorizontalTextAlignment HAlignment() const { return myHAlign; }
//! Sets horizontal alignment of text.
void SetHAlignment (const Graphic3d_HorizontalTextAlignment theJustification) { myHAlign = theJustification; }
//! Returns vertical alignment of text.
Graphic3d_VerticalTextAlignment VAlignment() const { return myVAlign; }
//! Sets vertical alignment of text.
void SetVAlignment (const Graphic3d_VerticalTextAlignment theJustification) { myVAlign = theJustification; }
//! Returns text formatter
const Handle(Font_TextFormatter)& TextFormatter() const { return myTextFormatter; }
//! Sets text formatter
void SetTextFormatter (const Handle(Font_TextFormatter)& theTextFormatter) { myTextFormatter = theTextFormatter; }
private:
NCollection_String myText; //!< text value
Handle(Font_TextFormatter) myTextFormatter; //!< text formatter collect information about text letter positions
bool myHasPlane; //!< Check if text have orientation in 3D space.
gp_Ax2 myOrientation; //!< Text orientation in 3D space.
Standard_Real myHeight; //!< height of text
Graphic3d_HorizontalTextAlignment myHAlign; //!< horizontal alignment
Graphic3d_VerticalTextAlignment myVAlign; //!< vertical alignment
Standard_Boolean myHasOwnAnchor; //!< flag if text uses position as point of attach
};
DEFINE_STANDARD_HANDLE(Graphic3d_Text, Standard_Transient)
#endif // _Graphic3d_TextParams_HeaderFile

View File

@@ -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) aTextParams = new Graphic3d_Text (aHeight);
aTextParams->SetText (aStr.ToCString());
aTextParams->SetPosition (gp_Pnt (X, Y, Z));
aTextGroup->AddText(aTextParams);
}
}
}

View File

@@ -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,8 @@ Message_Msg.hxx
Message_Msg.lxx
Message_MsgFile.cxx
Message_MsgFile.hxx
Message_PerfMeter.cxx
Message_PerfMeter.hxx
Message_Printer.cxx
Message_Printer.hxx
Message_PrinterOStream.cxx
@@ -32,8 +47,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

View File

@@ -49,3 +49,304 @@ 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"
};
}
//=======================================================================
//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 : 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;
}

View File

@@ -17,14 +17,18 @@
#ifndef _Message_HeaderFile
#define _Message_HeaderFile
#include <Message_Gravity.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 +63,106 @@ 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 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:

View File

@@ -0,0 +1,69 @@
// 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 <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 : 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;
}

View File

@@ -0,0 +1,123 @@
// 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
//! 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(), myCumulativeTime (GetUndefinedTime()) {}
//! 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 the alert cumulative time. It includes times of sub alerts
//! @return value
Standard_Real GetCumulativeTime() const { return myCumulativeTime; }
//! Sets cumulative time of alert
//! \param theCumulativeTime time of the alert
void SetCumulativeTime (const Standard_Real theCumulativeTime) { myCumulativeTime = theCumulativeTime; }
//! 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 when it is not defined
//! \return integer value
static Standard_Integer GetUndefinedTime() { return -1; }
//! 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 myCumulativeTime; //!< alert cumulative time
friend Message_PerfMeter;
};
#endif // _Message_Alert_HeaderFile

View 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

View 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() : "";
}

View File

@@ -0,0 +1,67 @@
// 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_Attribute_HeaderFile
#define _Message_Attribute_HeaderFile
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
DEFINE_STANDARD_HANDLE(Message_Attribute, Standard_Transient)
//! Additional information of extended alert attribute
//! To provide other custom attribute container, it might be redefined.
class Message_Attribute : public Standard_Transient
{
public:
//! Empty constructor
Standard_EXPORT Message_Attribute (const TCollection_AsciiString& theName = TCollection_AsciiString(),
const TCollection_AsciiString& theDescription = TCollection_AsciiString())
: myName (theName), myDescription (theDescription) {}
//! 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;
//! Returns custom name of alert if it is set
//! @return alert name
const TCollection_AsciiString& GetName() const { return myName; }
//! Sets the custom name of alert
//! @param theName a name for the alert
void SetName (const TCollection_AsciiString& theName) { myName = theName; }
//! Sets desription of alert
//! @param theName a name for the alert
void SetDescription (const TCollection_AsciiString& theDescription) { myDescription = theDescription; }
//! Returns description of alert if it is set
//! @return alert description
virtual const TCollection_AsciiString& GetDescription() const { return myDescription; }
// OCCT RTTI
DEFINE_STANDARD_RTTIEXT(Message_Attribute, Standard_Transient)
private:
TCollection_AsciiString myName; //!< alert name, if defined is used in GetMessageKey
TCollection_AsciiString myDescription; //!< alert description if defined
};
#endif // _Message_Attribute_HeaderFile

View File

@@ -0,0 +1,32 @@
// 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_AttributeObject.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeObject, Message_AttributeStream)
//=======================================================================
//function : Message_AttributeObject
//purpose :
//=======================================================================
Message_AttributeObject::Message_AttributeObject (const Handle(Standard_Transient)& theObject,
const Standard_SStream& theStream,
const TCollection_AsciiString& theName,
const TCollection_AsciiString& theDescription)
: Message_AttributeStream (theStream, theName, theDescription)
{
myObject = theObject;
}

View File

@@ -0,0 +1,46 @@
// 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_AttributeObject_HeaderFile
#define _Message_AttributeObject_HeaderFile
#include <Message_AttributeStream.hxx>
#include <TCollection_AsciiString.hxx>
//! Alert object storing Transient object in its field
class Message_AttributeObject : public Message_AttributeStream
{
public:
//! Constructor with string argument
Standard_EXPORT Message_AttributeObject (const Handle(Standard_Transient)& theObject,
const Standard_SStream& theStream,
const TCollection_AsciiString& theName = TCollection_AsciiString(),
const TCollection_AsciiString& theDescription = TCollection_AsciiString());
//! Sets the object
//! @param theObject an instance
void SetObject (const Handle(Standard_Transient)& theObject) { myObject = theObject; }
//! Returns object
Handle(Standard_Transient) GetObject() const { return myObject; }
// OCCT RTTI
DEFINE_STANDARD_RTTIEXT(Message_AttributeObject, Message_AttributeStream)
private:
Handle(Standard_Transient) myObject;
};
#endif // _Message_AttributeObject_HeaderFile

View File

@@ -0,0 +1,47 @@
// 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_AttributeStream.hxx>
#include <Message.hxx>
#include <Message_Msg.hxx>
#include <Message_PerfMeter.hxx>
#include <Message_Report.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute)
//=======================================================================
//function : SetValues
//purpose :
//=======================================================================
Message_AttributeStream::Message_AttributeStream (const Standard_SStream& theStream,
const TCollection_AsciiString& theName,
const TCollection_AsciiString& theDescription)
: Message_Attribute(theName, theDescription)
{
SetStream (theStream);
}
//=======================================================================
//function : SetStream
//purpose :
//=======================================================================
void Message_AttributeStream::SetStream (const Standard_SStream& theStream)
{
TCollection_AsciiString aStreamStr (theStream.str().c_str());
myStream << aStreamStr;
}

View File

@@ -0,0 +1,50 @@
// 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_AttributeStream_HeaderFile
#define _Message_AttributeStream_HeaderFile
#include <Message_Attribute.hxx>
#include <TCollection_AsciiString.hxx>
#include <NCollection_Vector.hxx>
class Message_PerfMeter;
class Message_Report;
//! Alert object storing container of Standard_Real values in its field
class Message_AttributeStream : public Message_Attribute
{
public:
//! Constructor with string argument
Standard_EXPORT Message_AttributeStream (const Standard_SStream& theStream,
const TCollection_AsciiString& theName = TCollection_AsciiString(),
const TCollection_AsciiString& theDescription = TCollection_AsciiString());
//! Sets stream value
Standard_EXPORT void SetStream (const Standard_SStream& theStream);
//! Returns stream value
const Standard_SStream& GetStream() const { return myStream; }
// OCCT RTTI
DEFINE_STANDARD_RTTIEXT(Message_AttributeStream, Message_Attribute)
private:
Standard_SStream myStream; //!< container of values
};
#endif // _Message_AttributeStream_HeaderFile

View File

@@ -0,0 +1,69 @@
// 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_CompositeAlerts.hxx>
#include <Message_AlertExtended.hxx>
#include <Standard_Assert.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Message_CompositeAlerts, Standard_Transient)
//=======================================================================
//function : Merge
//purpose :
//=======================================================================
Standard_Boolean Message_CompositeAlerts::Merge (const Handle(Message_Alert)& theTarget)
{
Handle(Message_AlertExtended) anExtAlert = Handle(Message_AlertExtended)::DownCast (theTarget);
if (!anExtAlert.IsNull() && !anExtAlert->GetCompositeAlerts().IsNull())
{
Handle(Message_CompositeAlerts) anExtCompositeAlert = anExtAlert->GetCompositeAlerts();
// hierarchical alerts can not be merged
for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity)
{
if (!GetAlerts ((Message_Gravity)iGravity).IsEmpty() ||
!anExtCompositeAlert->GetAlerts ((Message_Gravity)iGravity).IsEmpty())
return Standard_False;
}
}
// by default, merge trivially
return Standard_True;
}
//=======================================================================
//function : GetAlerts
//purpose :
//=======================================================================
Message_ListOfAlert& Message_CompositeAlerts::GetAlerts (const Message_Gravity theGravity)
{
return myChildAlerts[theGravity];
}
//=======================================================================
//function : HasAlerts
//purpose :
//=======================================================================
Standard_Boolean Message_CompositeAlerts::HasAlert (const Handle(Message_Alert)& theAlert)
{
for (int iGravity = Message_Trace; iGravity <= Message_Fail; ++iGravity)
{
Message_ListOfAlert& anAlerts = GetAlerts ((Message_Gravity)iGravity);
if (anAlerts.Contains (theAlert))
return Standard_True;
}
return Standard_False;
}

View File

@@ -0,0 +1,67 @@
// 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_CompositeAlerts_HeaderFile
#define _Message_CompositeAlerts_HeaderFile
#include <Message_Alert.hxx>
#include <Message_Gravity.hxx>
#include <Message_ListOfAlert.hxx>
#include <Standard_Transient.hxx>
class Message_CompositeAlerts;
DEFINE_STANDARD_HANDLE(Message_CompositeAlerts, Standard_Transient)
//! Base class of the hierarchy of classes describing various situations
//! occurring during execution of some algorithm or procedure.
//!
//! Alert should provide unique text identifier that can be used to distinguish
//! particular type of alerts, e.g. to get text message string describing it.
//! See method GetMessageKey(); by default, dynamic type name is used.
//!
//! Alert can contain some data. To avoid duplication of data, new alert
//! can be merged with another one of the same type. Method SupportsMerge()
//! should return true if merge is supported; method Merge() should do the
//! merge if possible and return true in that case and false otherwise.
//!
class Message_CompositeAlerts : public Standard_Transient
{
public:
//! Empty constructor
Standard_EXPORT Message_CompositeAlerts () {}
//! If possible, merge data contained in this alert to theTarget.
//! @return True if merged.
//! Base implementation always returns true.
virtual Standard_EXPORT Standard_Boolean Merge (const Handle(Message_Alert)& theTarget);
//! Returns list of collected alerts with specified gravity
Standard_EXPORT Message_ListOfAlert& GetAlerts (const Message_Gravity theGravity);
//! Returns true if the alert belong the list of the child alerts.
//! \param theAlert an alert to be checked as a child alert
//! \return true if the alert is found in a container of children
Standard_EXPORT Standard_Boolean HasAlert (const Handle(Message_Alert)& theAlert);
// OCCT RTTI
DEFINE_STANDARD_RTTIEXT(Message_CompositeAlerts,Standard_Transient)
protected:
// store messages in a lists sorted by gravity;
// here we rely on knowledge that Message_Fail is the last element of the enum
Message_ListOfAlert myChildAlerts[Message_Fail + 1];
};
#endif // _Message_CompositeAlerts_HeaderFile

View File

@@ -0,0 +1,168 @@
// 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_PerfMeter.hxx>
#include <Message_AlertExtended.hxx>
#include <Message_CompositeAlerts.hxx>
#include <OSD_Chronometer.hxx>
//=======================================================================
//function : Destructor
//purpose :
//=======================================================================
Message_PerfMeter::~Message_PerfMeter()
{
releaseAlert (0);
}
//=======================================================================
//function : GetAlert
//purpose :
//=======================================================================
Handle(Message_AlertExtended) Message_PerfMeter::GetAlert (const Standard_Integer theLevelId) const
{
if (!myActiveAlerts.IsBound (theLevelId))
return Handle(Message_AlertExtended)();
return myActiveAlerts.Find (theLevelId).myAlert;
}
//=======================================================================
//function : AddAlert
//purpose :
//=======================================================================
void Message_PerfMeter::AddAlert (const Handle(Message_Alert)& theAlert)
{
Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (theAlert);
if (anExtendedAlert.IsNull())
return;
if (myActiveAlerts.IsEmpty())
{
setAlert (0, theAlert);
return;
}
Standard_Integer aSize = myActiveAlerts.Size();
// looking for the parent of the parameter alert to release the previous alert
for (Standard_Integer aLevelId = 0; aLevelId < aSize; aLevelId++)
{
Handle(Message_AlertExtended) anAlert = GetAlert (aLevelId);
Handle(Message_CompositeAlerts) aCompositeAlert = anAlert->GetCompositeAlerts();
Standard_ASSERT_RETURN (! aCompositeAlert.IsNull(), "Any alert of the performance meter has composite and children",);
if (!aCompositeAlert->HasAlert (theAlert))
continue;
// parent alert is found
if (myActiveAlerts.IsBound (aLevelId + 1))
releaseAlert (aLevelId + 1);
setAlert (aLevelId + 1, theAlert);
return;
}
Standard_Boolean isDone = Standard_True;
Standard_ASSERT_RETURN (!isDone, "Alert should be processed above",);
}
//=======================================================================
//function : setAlert
//purpose :
//=======================================================================
Standard_Boolean Message_PerfMeter::setAlert (const Standard_Integer theLevelId,
const Handle(Message_Alert)& theAlert)
{
if (!GetAlert (theLevelId).IsNull())
return Standard_False;
Handle(Message_AlertExtended) anAlertExtended = Handle(Message_AlertExtended)::DownCast (theAlert);
if (anAlertExtended.IsNull())
return Standard_False;
myActiveAlerts.Bind (theLevelId, AlertInfo (anAlertExtended, getCurrentTime()));
anAlertExtended->SetPerfMeter (this);
return Standard_True;
}
//=======================================================================
//function : releaseAlert
//purpose :
//=======================================================================
Standard_Boolean Message_PerfMeter::releaseAlert (const Standard_Integer theLevelId)
{
// release alerts from the tail till the given alert
for (Standard_Integer aLevelId = myActiveAlerts.Extent() - 1; aLevelId >= theLevelId; aLevelId--)
{
if (!myActiveAlerts.IsBound (aLevelId))
continue;
stopAlert (aLevelId);
}
return Standard_True;
}
//=======================================================================
//function : stopAlert
//purpose :
//=======================================================================
Standard_Boolean Message_PerfMeter::stopAlert (const Standard_Integer theLevelId)
{
if (!myActiveAlerts.IsBound (theLevelId))
return Standard_False;
AlertInfo anAlertInfo = myActiveAlerts.Find (theLevelId);
Handle(Message_AlertExtended) anExtendedAlert = anAlertInfo.myAlert;
anExtendedAlert->SetCumulativeTime (getCurrentTime() - anAlertInfo.myStartTime);
anExtendedAlert->SetPerfMeter (0);
myActiveAlerts.UnBind (theLevelId);
return Standard_True;
}
//=======================================================================
//function : getLevel
//purpose :
//=======================================================================
Standard_Integer Message_PerfMeter::getLevel (const Handle(Message_Alert)& theAlert)
{
for (NCollection_DataMap<Standard_Integer, AlertInfo>::Iterator anIterator (myActiveAlerts);
anIterator.More(); anIterator.Next())
{
if (anIterator.Value().myAlert == theAlert)
return anIterator.Key();
}
return -1;
}
//=======================================================================
//function : getCurrentTime
//purpose :
//=======================================================================
Standard_Real Message_PerfMeter::getCurrentTime()
{
Standard_Real aSystemSeconds, aCurrentSeconds;
OSD_Chronometer::GetThreadCPU (aCurrentSeconds, aSystemSeconds);
return aCurrentSeconds;
}

Some files were not shown because too many files have changed in this diff Show More