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

Compare commits

...

30 Commits

Author SHA1 Message Date
nds
9785e5939b 0031150: Visualization - provide interface to change selection entities sensitivity factor 2019-11-11 14:52:52 +03:00
nds
60d61bea5e 0031149: Visualization - using clipping planes for FitAll of V3d_View 2019-11-11 14:04:39 +03:00
nds
0d1b52780b 0030268: Inspectors - improvements in VInspector plugin
# Dump for OCCT objects
2019-11-09 07:12:06 +03:00
nds
5a60253c55 0030268: Inspectors - improvements in VInspector plugin
# Dump for OCCT objects
2019-11-01 08:06:34 +03:00
nds
98d49da76f 0029451: Information Message Alert to debug an algorithm or object functionality
(cherry picked from commit 1f64bcf7813ab6bad61310ae6f19539d133f1ac4)

#compilation correction is ammended
2019-10-15 12:59:39 +03:00
nds
0e965f544e 0030268: Inspectors - improvements in VInspector plugin
# Dump for OCCT objects

(cherry picked from commit bf166a4f8908aae1d259a962c4deedbcd9063fcc)
2019-10-15 11:10:36 +03:00
nds
62e59942c9 Revert "0030268: Inspectors - improvements in VInspector plugin"
This reverts commit 22f35b2166.

# Conflicts:
#	src/Graphic3d/Graphic3d_ClipPlane.cxx
2019-10-15 11:06:54 +03:00
nds
47329f0adf Revert "0029451: Information Message Alert to debug an algorithm or object functionality"
This reverts commit 64c52c0521.
2019-10-15 11:05:53 +03:00
snn
41114c82f0 0031068: Data Exchange - A parent node shall be created for imported notes 2019-10-15 11:00:57 +03:00
nds
d7272de6a6 Revert "groups of notes added to XCAFDoc_NotesTool"
This reverts commit 92fe90c559.
2019-10-15 10:59:10 +03:00
nds
63c48876e4 Revert "groups of notes added to XCAFDoc_NotesTool"
This reverts commit bf2a25e092.
2019-10-15 10:58:56 +03:00
nds
bf2a25e092 groups of notes added to XCAFDoc_NotesTool 2019-10-14 18:42:29 +03:00
snn
92fe90c559 groups of notes added to XCAFDoc_NotesTool
# Conflicts:
#	src/XCAFDoc/XCAFDoc_NotesTool.cxx

(cherry picked from commit a9db047e5d)
2019-10-14 18:38:52 +03:00
nds
c0b0919b8c 0030791: Visualization - possibility to display materials by different hatching style for clipping
#compilation corrections
2019-10-05 17:02:39 +03:00
nds
64c52c0521 0029451: Information Message Alert to debug an algorithm or object functionality
(cherry picked from commit 4c6cbbf845945848cc2cb730d58ac07734ae5440)
2019-10-04 19:01:19 +03:00
nds
9cbf89af71 0031014: Inspectors - variables for Qt in CMake
(cherry picked from commit f3dd41854b0f1af6181c61d4d06ed813c7c342fb)
2019-10-04 19:00:50 +03:00
nds
22f35b2166 0030268: Inspectors - improvements in VInspector plugin
# Dump for OCCT objects

(cherry picked from commit ac3d1e7de29f5ffed15e6445ef0694b63524b3dd)
2019-10-04 19:00:31 +03:00
nds
6ad25e3a28 0030922: Visualization - OpenGl_Text wrong local transformation if text has not own attach point
(cherry picked from commit d149bbcbaf7d237425b574a1977acb07db299bea)
(cherry picked from commit 95a4927b5b2b9310de6ebe36f0fe6523cebe52c6)
(cherry picked from commit f414985732fb8084363d543e65fc4d7232e22488)
(cherry picked from commit 976a69be5faf878072d4b93006493a5fd5ae422f)
2019-10-04 18:59:03 +03:00
snn
ea4a8b2ba1 0030988: Add possibility to attach multiple files to notes
Implemented

(cherry picked from commit 9640291ff0)
2019-10-04 18:58:35 +03:00
nds
9ef696f23e 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

(cherry picked from commit 3a8ba84200)
(cherry picked from commit 280e1f1b27)

# Conflicts:
#	src/AIS/AIS_InteractiveObject.cxx
#	src/ViewerTest/ViewerTest_ViewerCommands.cxx
2019-10-04 18:57:03 +03:00
vro
c39cf33aeb 0030784: Visualization - check if selectable of owner in internal container in AIS_InteractiveContext before using
# Issue #1140: Click on interactive cube crashes the application.

(cherry picked from commit fd8fbd466b)
2019-10-04 18:56:16 +03:00
nds
aef350836f 0030791: Visualization - possibility to display materials by different hatching style for clipping
#compilation correction for VS2017, Debian

(cherry picked from commit 2147f85a35)
2019-10-04 18:56:06 +03:00
nds
9dfef0dba8 0030737: Visualization - implementing new selection schemes in context
(cherry picked from commit 951d93f193cdc00724586df1903ad39fc487cecd)
(cherry picked from commit 502194e4fc)
2019-10-04 18:55:53 +03:00
nds
04f32ec6a6 0030537: Visualization - wrapping text in font text formatter
Font_TextFormatter inherits Standard_Transient, now it is given as a handle in functions.
Graphic3d_Text - extended with Font_TextFormatter to be able to have it filled out of text render. If it is not defined here, the default text formatter of context is used.
OpenGl_Context - has default Font_TextFormatter for rendering OpenGl_Text.

(cherry picked from commit d5c557436d)
2019-10-04 18:55:18 +03:00
nds
f7d176b4c9 0030791: Visualization - possibility to display materials by different hatching style for clipping
(cherry picked from commit fafcc26452)

# Conflicts:
#	src/Graphic3d/Graphic3d_Group.hxx
(cherry picked from commit 7d4472c752)

# Conflicts:
#	src/Graphic3d/Graphic3d_ClipPlane.cxx
#	src/Graphic3d/Graphic3d_ClipPlane.hxx
#	src/OpenGl/OpenGl_Group.hxx
#	src/ViewerTest/ViewerTest_ViewerCommands.cxx
2019-10-04 18:55:02 +03:00
nds
68175994e7 0030784: Visualization - check if selectable of owner in internal container in AIS_InteractiveContext before using
# todo - add similar check for other places where needed

(cherry picked from commit 9e58a20735)
(cherry picked from commit 3ca159f3ca)
2019-10-04 18:49:37 +03:00
snn
36939d056a 0030392: XCAFDoc_GraphNode doesn't copy backward links
(cherry picked from commit 6131065fae)
(cherry picked from commit 713624228050b8f7db4d8b2e22c7edfd8c832471)
(cherry picked from commit b7fb7db6ae)
(cherry picked from commit 68be9e7b9c)
2019-10-04 18:48:43 +03:00
nds
fc0dfabf9f refs 474:Possibility to create and play animations
(cherry picked from commit d9a231a9ce2499615952944cae1a0db6552db2e4)
(cherry picked from commit ab078490cd)
(cherry picked from commit 277ea0a15e589efd7128f915959a18a59ebdfd1c)
(cherry picked from commit 89d8a85dd8)
(cherry picked from commit 7bc6dba60c)
2019-10-04 18:48:01 +03:00
nds
8dfef072d0 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
(cherry picked from commit 72e4a10556)
(cherry picked from commit 37d575793d)
2019-10-04 18:47:47 +03:00
nds
bbe059fc76 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
(cherry picked from commit a22653eb86)
(cherry picked from commit 9f13057096)
2019-10-04 18:47:07 +03:00
495 changed files with 29767 additions and 2958 deletions

View File

@@ -1,4 +1,4 @@
TModelingData TKShapeView
TModelingData TKShapeView TKMessageModel TKMessageView
TVisualization TKView TKVInspector
TApplicationFramework TKTreeModel TKTInspectorAPI TKDFBrowser
TTool TKTInspector TKToolsDraw TInspectorEXE

View File

@@ -31,4 +31,10 @@ if (NOT ${Qt5_FOUND})
#message (STATUS "Qt4 cmake configuration")
else()
#message (STATUS "Qt5 cmake configuration")
endif()
endif()
if (3RDPARTY_QT_DIR OR EXISTS "${3RDPARTY_QT_DIR}")
list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_QT_DIR}/bin")
else()
list (APPEND 3RDPARTY_NO_DLLS 3RDPARTY_QT_DLL_DIR)
endif()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 11 KiB

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

@@ -633,6 +633,11 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
{
aShadedGroup = thePrs->NewGroup();
aShadedGroup->SetClosed (isClosed);
if (isClosed)
{
if (aDrawer->HasOwnFillCappingAspect())
aShadedGroup->SetGroupPrimitivesAspect (aDrawer->FillCappingAspect());
}
}
aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect());
aShadedGroup->AddPrimitiveArray (aTriangles);

View File

@@ -25,6 +25,7 @@
#include <AIS_ListOfInteractive.hxx>
#include <AIS_Selection.hxx>
#include <AIS_SelectionModesConcurrency.hxx>
#include <AIS_SelectionScheme.hxx>
#include <AIS_StatusOfDetection.hxx>
#include <AIS_StatusOfPick.hxx>
#include <AIS_TypeOfIso.hxx>
@@ -470,6 +471,24 @@ public: //! @name Selection management
return AddSelect (theObject->GlobalSelOwner());
}
//! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
//! The objects detected are passed to the main viewer, which is then updated.
Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
const Standard_Integer theYPMin,
const Standard_Integer theXPMax,
const Standard_Integer theYPMax,
const Handle(V3d_View)& theView,
const AIS_SelectionScheme theSelScheme);
//! polyline selection; clears the previous picked list
Standard_EXPORT AIS_StatusOfPick Select (const TColgp_Array1OfPnt2d& thePolyline,
const Handle(V3d_View)& theView,
const AIS_SelectionScheme theSelScheme);
//! Stores and hilights the previous detected; Unhilights the previous picked.
//! @sa MoveTo().
Standard_EXPORT AIS_StatusOfPick Select (const AIS_SelectionScheme theSelScheme);
//! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
//! The objects detected are passed to the main viewer, which is then updated.
Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
@@ -511,6 +530,13 @@ public: //! @name Selection management
//! Returns bounding box of selected objects.
Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const;
//! Sets list of owner selected/deselected using selection scheme
//! It is possible that selection of other objects is changed relatively selection scheme .
//! \param theOwner owners to change selection state
//! \param theSelScheme selection scheme
Standard_EXPORT AIS_StatusOfPick Select (const AIS_NListOfEntityOwner& theOwners,
const AIS_SelectionScheme theSelScheme);
//! Fits the view correspondingly to the bounds of selected objects.
//! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
@@ -675,6 +701,9 @@ public: //! @name immediate mode rendering
//! Redraws immediate structures in all views of the viewer given taking into account its visibility.
void RedrawImmediate (const Handle(V3d_Viewer)& theViewer) { myMainPM->RedrawImmediate (theViewer); }
//! Change state to reset V3d_View bounding boxes. It should be used after a clipping plane was changed
Standard_EXPORT void InvalidateBoundingBox();
public: //! @name management of active Selection Modes
//! Activates or deactivates the selection mode for specified object.
@@ -1216,6 +1245,9 @@ public: //! @name sub-intensity management (deprecated)
//! @param theSelection an instance of the selection
void SetSelection (const Handle(AIS_Selection)& theSelection) { mySelection = theSelection; }
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
protected: //! @name internal methods
Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const;

View File

@@ -490,86 +490,14 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi
const Standard_Integer theXPMax,
const Standard_Integer theYPMax,
const Handle(V3d_View)& theView,
const Standard_Boolean toUpdateViewer)
const AIS_SelectionScheme theSelScheme)
{
if (theView->Viewer() != myMainVwr)
{
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
}
// all objects detected by the selector are taken, previous current objects are emptied,
// new objects are put...
ClearSelected (Standard_False);
myLastActiveView = theView.get();
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
const Handle(SelectMgr_EntityOwner)& aCurOwner = myMainSel->Picked (aPickIter);
if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
continue;
mySelection->Select (aCurOwner);
}
if (myAutoHilight)
{
HilightSelected (toUpdateViewer);
}
Standard_Integer aSelNum = NbSelected();
return (aSelNum == 0) ? AIS_SOP_NothingSelected
: (aSelNum == 1) ? AIS_SOP_OneSelected
: AIS_SOP_SeveralSelected;
}
//=======================================================================
//function : Select
//purpose : Selection by polyline
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
const Handle(V3d_View)& theView,
const Standard_Boolean toUpdateViewer)
{
if (theView->Viewer() != myMainVwr)
{
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
}
// all objects detected by the selector are taken, previous current objects are emptied,
// new objects are put...
ClearSelected (Standard_False);
myLastActiveView = theView.get();
myMainSel->Pick (thePolyline, theView);
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
continue;
mySelection->Select (anOwner);
}
if (myAutoHilight)
{
HilightSelected (toUpdateViewer);
}
Standard_Integer aSelNum = NbSelected();
return (aSelNum == 0) ? AIS_SOP_NothingSelected
: (aSelNum == 1) ? AIS_SOP_OneSelected
: AIS_SOP_SeveralSelected;
}
//=======================================================================
//function : Select
//purpose :
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
{
if (!myLastPicked.IsNull())
{
Graphic3d_Vec2i aMousePos (-1, -1);
@@ -582,54 +510,126 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate
{
return AIS_SOP_NothingSelected;
}
if (myAutoHilight)
{
clearDynamicHighlight();
}
if (!myLastPicked->IsSelected()
|| myLastPicked->IsForcedHilight()
|| NbSelected() > 1)
{
SetSelected (myLastPicked, Standard_False);
if(toUpdateViewer)
{
UpdateCurrentViewer();
}
}
}
else
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
AIS_NListOfEntityOwner aPickedOwners;
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
ClearSelected (toUpdateViewer);
aPickedOwners.Append (myMainSel->Picked (aPickIter));
}
Standard_Integer aSelNum = NbSelected();
return Select (aPickedOwners, theSelScheme);
}
return (aSelNum == 0) ? AIS_SOP_NothingSelected
: (aSelNum == 1) ? AIS_SOP_OneSelected
: AIS_SOP_SeveralSelected;
//=======================================================================
//function : Select
//purpose : Selection by polyline
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
const Handle(V3d_View)& theView,
const AIS_SelectionScheme theSelScheme)
{
if (theView->Viewer() != myMainVwr)
{
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
}
myMainSel->Pick (thePolyline, theView);
AIS_NListOfEntityOwner aPickedOwners;
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
aPickedOwners.Append (myMainSel->Picked (aPickIter));
}
return Select (aPickedOwners, theSelScheme);
}
//=======================================================================
//function : Select
//purpose :
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_SelectionScheme theSelScheme)
{
// special case: single selection of detected owner - is it necessary ?
/*if (myWasLastMain && !myLastinMain.IsNull() && !myAutoHilight &&
(myLastinMain->IsSelected()
&& !myLastinMain->IsForcedHilight()
&& NbSelected() <= 1))
{
mySelection->selectOwner(myLastinMain, aPrevSelected, theSelScheme);
Graphic3d_Vec2i aMousePos (-1, -1);
if (myMainSel->GetManager().GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Point)
{
aMousePos.SetValues ((Standard_Integer )myMainSel->GetManager().GetMousePosition().X(),
(Standard_Integer )myMainSel->GetManager().GetMousePosition().Y());
}
if (myLastPicked->HandleMouseClick (aMousePos, Aspect_VKeyMouse_LeftButton, Aspect_VKeyFlags_NONE, false))
{
return AIS_SOP_NothingSelected;
}
return getStatusOfPick (NbSelected());
}*/
AIS_NListOfEntityOwner aPickedOwners;
if (!myLastPicked.IsNull() &&
myLastPicked->HasSelectable())
{
Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(myLastPicked->Selectable());
if (!anIO.IsNull() &&
myObjects.IsBound(anIO))
{
aPickedOwners.Append (myLastPicked);
}
}
return Select (aPickedOwners, theSelScheme);
}
//=======================================================================
//function : Select
//purpose :
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
const Standard_Integer theYPMin,
const Standard_Integer theXPMax,
const Standard_Integer theYPMax,
const Handle(V3d_View)& theView,
const Standard_Boolean)
{
return Select (theXPMin, theYPMin, theXPMax, theYPMax, theView, AIS_SelectionScheme_ClearAndAdd);
}
//=======================================================================
//function : Select
//purpose : Selection by polyline
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
const Handle(V3d_View)& theView,
const Standard_Boolean)
{
return Select (thePolyline, theView, AIS_SelectionScheme_ClearAndAdd);
}
//=======================================================================
//function : Select
//purpose :
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean)
{
return Select (AIS_SelectionScheme_ClearAndAdd);
}
//=======================================================================
//function : ShiftSelect
//purpose :
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean)
{
if (myAutoHilight)
{
clearDynamicHighlight();
}
if (!myLastPicked.IsNull())
{
AddOrRemoveSelected (myLastPicked, toUpdateViewer);
}
Standard_Integer aSelNum = NbSelected();
return (aSelNum == 0) ? AIS_SOP_NothingSelected
: (aSelNum == 1) ? AIS_SOP_OneSelected
: AIS_SOP_SeveralSelected;
return Select (AIS_SelectionScheme_Switch);
}
//=======================================================================
@@ -641,39 +641,9 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
const Standard_Integer theXPMax,
const Standard_Integer theYPMax,
const Handle(V3d_View)& theView,
const Standard_Boolean toUpdateViewer)
const Standard_Boolean)
{
if (theView->Viewer() != myMainVwr)
{
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
}
myLastActiveView = theView.get();
if (myAutoHilight)
{
UnhilightSelected (Standard_False);
}
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
continue;
mySelection->Select (anOwner);
}
if (myAutoHilight)
{
HilightSelected (toUpdateViewer);
}
Standard_Integer aSelNum = NbSelected();
return (aSelNum == 0) ? AIS_SOP_NothingSelected
: (aSelNum == 1) ? AIS_SOP_OneSelected
: AIS_SOP_SeveralSelected;
return Select (theXPMin, theYPMin, theXPMax, theYPMax, theView, AIS_SelectionScheme_Switch);
}
//=======================================================================
@@ -682,31 +652,31 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
const Handle(V3d_View)& theView,
const Standard_Boolean toUpdateViewer)
const Standard_Boolean)
{
if (theView->Viewer() != myMainVwr)
{
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
}
return Select (thePolyline, theView, AIS_SelectionScheme_Switch);
}
myLastActiveView = theView.get();
//=======================================================================
//function : Select
//purpose :
//=======================================================================
AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_NListOfEntityOwner& theOwners,
const AIS_SelectionScheme theSelScheme)
{
// all objects detected by the selector are taken, previous current objects are emptied,
// new objects are put...
if (myAutoHilight)
{
clearDynamicHighlight();
UnhilightSelected (Standard_False);
}
myMainSel->Pick (thePolyline, theView);
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
{
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
continue;
mySelection->Select (anOwner);
}
mySelection->SelectOwners (theOwners, theSelScheme, myFilters);
if (myAutoHilight)
{
HilightSelected (toUpdateViewer);
HilightSelected (Standard_False);
}
Standard_Integer aSelNum = NbSelected();
@@ -990,7 +960,9 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO
if (myAutoHilight)
{
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
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);

View File

@@ -454,3 +454,17 @@ Standard_Boolean AIS_InteractiveContext::EndImmediateDraw()
myMainPM->EndImmediateDraw (myMainVwr);
return Standard_True;
}
//=======================================================================
//function : InvalidateBoundingBox
//purpose :
//=======================================================================
void AIS_InteractiveContext::InvalidateBoundingBox()
{
const Handle(V3d_Viewer)& aCurViewer = CurrentViewer();
for (V3d_ListOfViewIterator anActiveViewIter (aCurViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
{
anActiveViewIter.Value()->View()->InvalidateAllLayerBoundingBox();
}
}

View File

@@ -86,3 +86,42 @@ void AIS_InteractiveContext::PolygonOffsets(
anObj->PolygonOffsets( aMode, aFactor, aUnits );
}
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void AIS_InteractiveContext::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, AIS_InteractiveContext);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myObjects.Size());
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mgrSelector.get());
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainPM.get());
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainVwr.get());
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainSel.get());
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastActiveView);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastPicked.get());
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToHilightSelected);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mySelection.get());
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myFilters.get());
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myDefaultDrawer.get());
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Selected]);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Dynamic]);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalSelected]);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalDynamic]);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_SubIntensity]);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDetectedSeq.Size());
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurDetected);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurHighlighted);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPickingStrategy);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoHilight);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsAutoActivateSelMode);
}

View File

@@ -18,6 +18,7 @@
#include <AIS_InteractiveContext.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectFillCapping.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>

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

@@ -180,10 +180,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
try
{
OCC_CATCH_SIGNALS
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer,
myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
&& !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
myUVOrigin, myUVRepeat, myUVScale);
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myDrawer->FillCappingAspect());
}
catch (Standard_Failure const& anException)
{
@@ -990,3 +987,23 @@ Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real & anAngle,
aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
return myDrawer->HasOwnHLRDeviationAngle();
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void AIS_Shape::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, AIS_Shape);
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, AIS_InteractiveObject);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myshape);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBB);
//OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUVOrigin);
//OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUVRepeat);
//OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUVScale);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myInitAng);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCompBB);
}

View File

@@ -325,6 +325,9 @@ public:
const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer);
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
protected:
TopoDS_Shape myshape; //!< shape to display

View File

@@ -41,6 +41,7 @@ AIS_TextLabel::AIS_TextLabel()
myFont ("Courier"),
myFontAspect (Font_FA_Regular),
myHasOrientation3D (Standard_False),
myHasOwnAnchorPoint (Standard_True),
myHasFlipping (Standard_False)
{
myDrawer->SetTextAspect (new Prs3d_TextAspect());
@@ -308,7 +309,12 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePr
gp_Ax2 anOrientation = myOrientation3D;
anOrientation.SetLocation (aPosition);
Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePrs), anAsp, myText, myOrientation3D, !myHasFlipping);
Standard_Boolean aHasOwnAnchor = HasOwnAnchorPoint();
if (myHasFlipping)
aHasOwnAnchor = Standard_False; // always not using own anchor if flipping
Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePrs), anAsp, myText, myOrientation3D, aHasOwnAnchor);
if (myHasFlipping && isInit)
{
Prs3d_Root::CurrentGroup (thePrs)->SetFlippingOptions (Standard_False, gp_Ax2());

View File

@@ -90,6 +90,12 @@ public:
Standard_EXPORT Standard_Boolean HasFlipping() const;
//! Returns flag if text uses position as point of attach
Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; }
//! Set flag if text uses position as point of attach
void SetOwnAnchorPoint (const Standard_Boolean theOwnAnchorPoint) { myHasOwnAnchorPoint = theOwnAnchorPoint; }
//! Define the display type of the text.
//!
//! TODT_NORMAL Default display. Text only.
@@ -121,6 +127,7 @@ protected:
Font_FontAspect myFontAspect;
gp_Ax2 myOrientation3D;
Standard_Boolean myHasOrientation3D;
Standard_Boolean myHasOwnAnchorPoint;
Standard_Boolean myHasFlipping;
public:

View File

@@ -995,3 +995,33 @@ Handle(Prs3d_PointAspect) AIS_Trihedron::getHighlightPointAspect()
return myHighlightPointAspect;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void AIS_Trihedron::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, AIS_Trihedron);
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, AIS_InteractiveObject);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnSize);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnTextColor);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnArrowColor);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnDatumAspect);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTrihDispMode);
//Handle(Geom_Axis2Placement) myComponent;
//NCollection_DataMap<Prs3d_DatumParts, Standard_Integer> mySelectionPriority;
//NCollection_DataMap<Prs3d_DatumParts, TCollection_ExtendedString> myLabel;
//NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_Group)> myPartToGroup;
//NCollection_List<Prs3d_DatumParts> mySelectedParts;
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myHighlightAspect.get());
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myHighlightLineAspect.get());
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myHighlightPointAspect.get());
//NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_ArrayOfPrimitives)> myPrimitives;
}

View File

@@ -222,6 +222,9 @@ protected:
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
protected:
//! Creates a sensitive entity for the datum part that will be used in selection owner creation.

View File

@@ -145,6 +145,7 @@ AIS_Selection.cxx
AIS_Selection.hxx
AIS_SelectStatus.hxx
AIS_SelectionModesConcurrency.hxx
AIS_SelectionScheme.hxx
AIS_SequenceOfDimension.hxx
AIS_SequenceOfInteractive.hxx
AIS_Shape.cxx

View File

@@ -114,7 +114,24 @@ public:
{
(void)theDepth;
OCCT_DUMP_CLASS_BEGIN (theOStream, BVH_Box);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsValid());
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsInited);
int n = Min (N, 3);
if (n == 1)
{
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMinPoint[0]);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMinPoint[0]);
}
if (n == 2)
{
OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "MinPoint", n, myMinPoint[0], myMinPoint[1]);
OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "MaxPoint", n, myMaxPoint[0], myMaxPoint[1]);
}
if (n == 3)
{
OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "MinPoint", n, myMinPoint[0], myMinPoint[1], myMinPoint[2]);
OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "MaxPoint", n, myMaxPoint[0], myMaxPoint[1], myMaxPoint[2]);
}
}
public:

View File

@@ -35,8 +35,6 @@
#include <BinMXCAFDoc_MaterialToolDriver.hxx>
#include <BinMXCAFDoc_NoteDriver.hxx>
#include <BinMXCAFDoc_NoteBalloonDriver.hxx>
#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
#include <BinMXCAFDoc_NoteCommentDriver.hxx>
#include <BinMXCAFDoc_NotesToolDriver.hxx>
#include <BinMXCAFDoc_ShapeToolDriver.hxx>
#include <BinMXCAFDoc_ViewDriver.hxx>
@@ -78,8 +76,7 @@ void BinMXCAFDoc::AddDrivers(const Handle(BinMDF_ADriverTable)& theDriverTable,
theDriverTable->AddDriver( new BinMXCAFDoc_DimTolDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_MaterialDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteBalloonDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteBinDataDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteCommentDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_ViewDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_ColorToolDriver (theMsgDrv));

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

@@ -20,14 +20,14 @@
#include <BinMXCAFDoc_NoteBalloonDriver.hxx>
#include <XCAFDoc_NoteBalloon.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteBalloonDriver::BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver)
: BinMXCAFDoc_NoteCommentDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
: BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBalloon)->Name())
{
}
@@ -40,13 +40,52 @@ Handle(TDF_Attribute) BinMXCAFDoc_NoteBalloonDriver::NewEmpty() const
return new XCAFDoc_NoteBalloon();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean BinMXCAFDoc_NoteBalloonDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const
{
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
return Standard_False;
Handle(XCAFDoc_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
TCollection_ExtendedString aComment;
if (!(theSource >> aComment))
return Standard_False;
aNote->Set(aComment);
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void BinMXCAFDoc_NoteBalloonDriver::Paste(const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const
{
BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
Handle(XCAFDoc_NoteBalloon) aNote = Handle(XCAFDoc_NoteBalloon)::DownCast(theSource);
if (!aNote.IsNull())
theTarget << aNote->Get();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteBalloonDriver::BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver,
Standard_CString theName)
: BinMXCAFDoc_NoteCommentDriver(theMsgDriver, theName)
: BinMXCAFDoc_NoteDriver(theMsgDriver, theName)
{
}

View File

@@ -16,20 +16,28 @@
#ifndef _BinMXCAFDoc_NoteBalloonDriver_HeaderFile
#define _BinMXCAFDoc_NoteBalloonDriver_HeaderFile
#include <BinMXCAFDoc_NoteCommentDriver.hxx>
#include <BinMXCAFDoc_NoteDriver.hxx>
class BinMXCAFDoc_NoteBalloonDriver;
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
class BinMXCAFDoc_NoteBalloonDriver : public BinMXCAFDoc_NoteCommentDriver
class BinMXCAFDoc_NoteBalloonDriver : public BinMXCAFDoc_NoteDriver
{
public:
Standard_EXPORT BinMXCAFDoc_NoteBalloonDriver(const Handle(Message_Messenger)& theMsgDriver);
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteCommentDriver)
Standard_EXPORT Standard_Boolean Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBalloonDriver, BinMXCAFDoc_NoteDriver)
protected:

View File

@@ -1,96 +0,0 @@
// Created on: 2017-02-13
// Created by: Eugeny NIKONOV
// Copyright (c) 2005-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BinObjMgt_Persistent.hxx>
#include <Message_Messenger.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <TColStd_HArray1OfByte.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <BinMXCAFDoc_NoteBinDataDriver.hxx>
#include <XCAFDoc_NoteBinData.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteBinDataDriver::BinMXCAFDoc_NoteBinDataDriver(const Handle(Message_Messenger)& theMsgDriver)
: BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteBinData)->Name())
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) BinMXCAFDoc_NoteBinDataDriver::NewEmpty() const
{
return new XCAFDoc_NoteBinData();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean BinMXCAFDoc_NoteBinDataDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const
{
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
return Standard_False;
Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
TCollection_ExtendedString aTitle;
TCollection_AsciiString aMIMEtype;
Standard_Integer nbSize;
if (!(theSource >> aTitle >> aMIMEtype >> nbSize))
return Standard_False;
Handle(TColStd_HArray1OfByte) aData;
if (nbSize > 0)
{
aData.reset(new TColStd_HArray1OfByte(1, nbSize));
theSource.GetByteArray(&aData->ChangeFirst(), nbSize);
}
aNote->Set(aTitle, aMIMEtype, aData);
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void BinMXCAFDoc_NoteBinDataDriver::Paste(const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const
{
BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
Handle(XCAFDoc_NoteBinData) aNote = Handle(XCAFDoc_NoteBinData)::DownCast(theSource);
if (!aNote.IsNull())
{
theTarget << aNote->Title() << aNote->MIMEtype() << aNote->Size();
if (aNote->Size() > 0)
theTarget.PutByteArray(&aNote->Data()->ChangeFirst(), aNote->Size());
}
}

View File

@@ -1,44 +0,0 @@
// Created on: 2017-02-13
// Created by: Sergey NIKONOV
// Copyright (c) 2005-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BinMXCAFDoc_NoteBinDataDriver_HeaderFile
#define _BinMXCAFDoc_NoteBinDataDriver_HeaderFile
#include <BinMXCAFDoc_NoteDriver.hxx>
class BinMXCAFDoc_NoteBinDataDriver;
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
class BinMXCAFDoc_NoteBinDataDriver : public BinMXCAFDoc_NoteDriver
{
public:
Standard_EXPORT BinMXCAFDoc_NoteBinDataDriver(const Handle(Message_Messenger)& theMsgDriver);
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteBinDataDriver, BinMXCAFDoc_NoteDriver)
};
#endif // _BinMXCAFDoc_NoteBinDataDriver_HeaderFile

View File

@@ -1,91 +0,0 @@
// Created on: 2017-02-13
// Created by: Eugeny NIKONOV
// Copyright (c) 2005-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BinObjMgt_Persistent.hxx>
#include <Message_Messenger.hxx>
#include <Standard_Type.hxx>
#include <TDF_Attribute.hxx>
#include <BinMXCAFDoc_NoteCommentDriver.hxx>
#include <XCAFDoc_NoteComment.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteCommentDriver::BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver)
: BinMXCAFDoc_NoteDriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_NoteComment)->Name())
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) BinMXCAFDoc_NoteCommentDriver::NewEmpty() const
{
return new XCAFDoc_NoteComment();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean BinMXCAFDoc_NoteCommentDriver::Paste(const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const
{
if (!BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable))
return Standard_False;
Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theTarget);
if (aNote.IsNull())
return Standard_False;
TCollection_ExtendedString aComment;
if (!(theSource >> aComment))
return Standard_False;
aNote->Set(aComment);
return Standard_True;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
void BinMXCAFDoc_NoteCommentDriver::Paste(const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const
{
BinMXCAFDoc_NoteDriver::Paste(theSource, theTarget, theRelocTable);
Handle(XCAFDoc_NoteComment) aNote = Handle(XCAFDoc_NoteComment)::DownCast(theSource);
if (!aNote.IsNull())
theTarget << aNote->Comment();
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteCommentDriver::BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
Standard_CString theName)
: BinMXCAFDoc_NoteDriver(theMsgDriver, theName)
{
}

View File

@@ -1,49 +0,0 @@
// Created on: 2017-02-13
// Created by: Sergey NIKONOV
// Copyright (c) 2005-2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BinMXCAFDoc_NoteCommentDriver_HeaderFile
#define _BinMXCAFDoc_NoteCommentDriver_HeaderFile
#include <BinMXCAFDoc_NoteDriver.hxx>
class BinMXCAFDoc_NoteCommentDriver;
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
class BinMXCAFDoc_NoteCommentDriver : public BinMXCAFDoc_NoteDriver
{
public:
Standard_EXPORT BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver);
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theSource,
BinObjMgt_Persistent& theTarget,
BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_NoteCommentDriver, BinMXCAFDoc_NoteDriver)
protected:
BinMXCAFDoc_NoteCommentDriver(const Handle(Message_Messenger)& theMsgDriver,
Standard_CString theName);
};
#endif // _BinMXCAFDoc_NoteCommentDriver_HeaderFile

View File

@@ -22,6 +22,24 @@
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_NoteDriver, BinMDF_ADriver)
//=======================================================================
//function :
//purpose :
//=======================================================================
BinMXCAFDoc_NoteDriver::BinMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& theMsgDriver)
: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_Note)->Name())
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Handle(TDF_Attribute) BinMXCAFDoc_NoteDriver::NewEmpty() const
{
return new XCAFDoc_Note();
}
//=======================================================================
//function :
//purpose :

View File

@@ -35,6 +35,10 @@ class BinMXCAFDoc_NoteDriver : public BinMDF_ADriver
{
public:
Standard_EXPORT BinMXCAFDoc_NoteDriver(const Handle(Message_Messenger)& theMsgDriver);
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
const Handle(TDF_Attribute)& theTarget,
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;

View File

@@ -39,10 +39,6 @@ BinMXCAFDoc_NoteDriver.cxx
BinMXCAFDoc_NoteDriver.hxx
BinMXCAFDoc_NoteBalloonDriver.cxx
BinMXCAFDoc_NoteBalloonDriver.hxx
BinMXCAFDoc_NoteCommentDriver.cxx
BinMXCAFDoc_NoteCommentDriver.hxx
BinMXCAFDoc_NoteBinDataDriver.cxx
BinMXCAFDoc_NoteBinDataDriver.hxx
BinMXCAFDoc_NotesToolDriver.cxx
BinMXCAFDoc_NotesToolDriver.hxx
BinMXCAFDoc_ShapeToolDriver.cxx
@@ -53,3 +49,7 @@ BinMXCAFDoc_ViewToolDriver.cxx
BinMXCAFDoc_ViewToolDriver.hxx
BinMXCAFDoc_VolumeDriver.cxx
BinMXCAFDoc_VolumeDriver.hxx
BinMXCAFDoc_AnimationDriver.cxx
BinMXCAFDoc_AnimationDriver.hxx
BinMXCAFDoc_AnimationToolDriver.cxx
BinMXCAFDoc_AnimationToolDriver.hxx

View File

@@ -985,3 +985,12 @@ void Bnd_Box::DumpJson (Standard_OStream& theOStream, const Standard_Integer) co
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Gap);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Flags);
}
//=======================================================================
//function : InitJson
//purpose :
//=======================================================================
Standard_Boolean Bnd_Box::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
{
return Standard_False;
}

View File

@@ -305,6 +305,9 @@ public:
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
//! Inits the content of me into the stream
Standard_EXPORT Standard_Boolean InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
protected:
//! Bit flags.

View File

@@ -1041,3 +1041,12 @@ void Bnd_OBB::DumpJson (Standard_OStream& theOStream, const Standard_Integer the
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHDims[2]);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsAABox);
}
//=======================================================================
//function : InitJson
//purpose :
//=======================================================================
Standard_Boolean Bnd_OBB::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
{
return Standard_False;
}

View File

@@ -285,6 +285,9 @@ public:
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
//! Inits the content of me into the stream
Standard_EXPORT Standard_Boolean InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos);
protected:
void ProcessOnePoint(const gp_Pnt& theP)

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

@@ -16,6 +16,8 @@
#include <Geom_Transformation.hxx>
#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Geom_Transformation, Standard_Transient)
Geom_Transformation::Geom_Transformation () { }
@@ -56,3 +58,8 @@ void Geom_Transformation::PreMultiply (const Handle(Geom_Transformation)& Other)
gpTrsf.PreMultiply (Other->Trsf());
}
void Geom_Transformation::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &gpTrsf);
}

View File

@@ -192,6 +192,9 @@ public:
//! Creates a new object which is a copy of this transformation.
Standard_EXPORT Handle(Geom_Transformation) Copy() const;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
private:
gp_Trsf gpTrsf;

View File

@@ -15,6 +15,8 @@ Graphic3d_Aspects.cxx
Graphic3d_Aspects.hxx
Graphic3d_AspectFillArea3d.cxx
Graphic3d_AspectFillArea3d.hxx
Graphic3d_AspectFillCapping.cxx
Graphic3d_AspectFillCapping.hxx
Graphic3d_AspectLine3d.cxx
Graphic3d_AspectLine3d.hxx
Graphic3d_AspectMarker3d.cxx

View File

@@ -0,0 +1,134 @@
// Created on: 2017-04-14
// Created by: Anton POLETAEV
// 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 <Graphic3d_AspectFillCapping.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Standard_Transient)
// =======================================================================
// function : Graphic3d_AspectFillCapping
// purpose :
// =======================================================================
Graphic3d_AspectFillCapping::Graphic3d_AspectFillCapping()
: myFlags (Flags_None),
myHatchingState (0)
{
Graphic3d_MaterialAspect aMaterial;
aMaterial.SetColor (Quantity_NOC_BLACK);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
aMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
aMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
SetHatchStyle (Aspect_HS_HORIZONTAL);
SetHatchMaterial (aMaterial);
}
// =======================================================================
// function : SetHatchStyle
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchStyle (const Aspect_HatchStyle theStyle)
{
myStippleHatch = new Graphic3d_HatchStyle (theStyle);
myTextureHatch.Nullify();
myHatchingState++;
}
// =======================================================================
// function : SetHatchStyle
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle)
{
myStippleHatch = theStyle;
myTextureHatch.Nullify();
myHatchingState++;
}
// =======================================================================
// function : SetHatchStyle
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture)
{
myStippleHatch.Nullify();
myTextureHatch = theTexture;
myHatchingState++;
}
// =======================================================================
// function : SetHatchMaterial
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial)
{
myHatchMaterial = theMaterial;
myHatchingState++;
}
// =======================================================================
// function : SetToDrawHatch
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetToDrawHatch (const Standard_Boolean theToDraw)
{
setFlag (theToDraw, Flags_DrawHatching);
myHatchingState++;
}
// =======================================================================
// function : SetHatchZoomPeristent
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchZoomPeristent (const Standard_Boolean theToSet)
{
setFlag (theToSet, Flags_HatchZoomPersistent);
myHatchingState++;
}
// =======================================================================
// function : SetHatchRotationPeristent
// purpose :
// =======================================================================
void Graphic3d_AspectFillCapping::SetHatchRotationPeristent (const Standard_Boolean theToSet)
{
setFlag (theToSet, Flags_HatchRotationPersistent);
myHatchingState++;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void Graphic3d_AspectFillCapping::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_AspectFillCapping);
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Graphic3d_Aspects);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myMaterial);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myMaterial);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myTexture);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myShader);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStippleHatch);
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myTextureHatch);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myHatchMaterial);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFlags);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHatchingState);
}

View File

@@ -0,0 +1,167 @@
// Created on: 2017-04-14
// Created by: Anton POLETAEV
// 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 _Graphic3d_AspectFillCapping_HeaderFile
#define _Graphic3d_AspectFillCapping_HeaderFile
#include <Aspect_HatchStyle.hxx>
#include <Graphic3d_Aspects.hxx>
#include <Graphic3d_HatchStyle.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Standard_Transient.hxx>
//! Defines graphical attributes for drawing section planes on solids resulted from clipping (cutting) planes.
class Graphic3d_AspectFillCapping : public Graphic3d_Aspects
{
public:
//! Default constructor.
Standard_EXPORT Graphic3d_AspectFillCapping();
public:
//! Sets material for filling section created by clipping.
void SetMaterial (const Graphic3d_MaterialAspect& theMaterial) { myMaterial = theMaterial; }
//! Returns material for filling section created by clipping.
const Graphic3d_MaterialAspect& Material() const { return myMaterial; }
//! Sets flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
void SetUseObjectMaterial (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectMaterial); }
//! Returns flag indicating whether object's material (instead of defined by this aspect) should be used for filling section.
Standard_Boolean ToUseObjectMaterial() const { return (myFlags & Flags_UseObjectMaterial) != 0; }
//! Sets texture for filling section created by clipping.
void SetTexture (const Handle(Graphic3d_TextureMap)& theTexture) { myTexture = theTexture; }
//! Returns texture for filling section created by clipping.
const Handle(Graphic3d_TextureMap)& Texture() const { return myTexture; }
//! Sets flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
void SetUseObjectTexture (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectTexture); }
//! Returns flag indicating whether object's texture (instead of defined by this aspect) should be used for filling section.
Standard_Boolean ToUseObjectTexture() const { return (myFlags & Flags_UseObjectTexture) != 0; }
//! Sets OpenGL/GLSL shader program.
void SetShader (const Handle(Graphic3d_ShaderProgram)& theShader) { myShader = theShader; }
//! Returns OpenGL/GLSL shader program.
const Handle(Graphic3d_ShaderProgram)& Shader() const { return myShader; }
//! Sets flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
void SetUseObjectShader (const Standard_Boolean theToUse) { setFlag (theToUse, Flags_UseObjectShader); }
//! Returns flag indicating whether object's shader (instead of defined by this aspect) should be used for filling section.
Standard_Boolean ToUseObjectShader() const { return (myFlags & Flags_UseObjectShader) != 0; }
public:
//! Sets style of hatch defined by predefined stipple mask.
Standard_EXPORT void SetHatchStyle (const Aspect_HatchStyle theStyle);
//! Sets style of hatch defined by custom stipple mask.
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle);
//! Sets style of hatch defined by texture map (decal texture with alpha channel should be used).
Standard_EXPORT void SetHatchStyle (const Handle(Graphic3d_TextureMap)& theTexture);
//! Sets material style for hatch lines (texture).
Standard_EXPORT void SetHatchMaterial (const Graphic3d_MaterialAspect& theMaterial);
//! Returns material style for hatch lines (texture).
const Graphic3d_MaterialAspect& HatchMaterial() const { return myHatchMaterial; }
//! Sets boolean flag indicating whether the hatch layer should be drawn or not.
Standard_EXPORT void SetToDrawHatch (const Standard_Boolean theToDraw);
//! Returns boolean flag indicating whether the hatch layer should be drawn or not.
Standard_Boolean ToDrawHatch() const { return (myFlags & Flags_DrawHatching) != 0; }
//! Sets flag controlling behavior of hatch texture mapping on zooming.
//! @param theToSet [in] if passed TRUE the texture will keep constant screen-scale independent of zooming.
Standard_EXPORT void SetHatchZoomPeristent (const Standard_Boolean theToSet);
//! Returns value of flag controlling behavior of hatch texture mapping on zooming.
Standard_Boolean IsHatchZoomPersistent() { return (myFlags & Flags_HatchZoomPersistent) != 0; }
//! Sets flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
Standard_EXPORT void SetHatchRotationPeristent (const Standard_Boolean theToSet);
//! Returns value of flag controlling behavior of hatch texture mapping on camera rotation around heading vector.
Standard_Boolean IsHatchRotationPersistent() { return (myFlags & Flags_HatchRotationPersistent) != 0; }
//! Returns true if hatch is defined by texture.
Standard_Boolean IsTextureHatch() const { return !myTextureHatch.IsNull(); }
//! Returns texture map defining the hatch.
const Handle(Graphic3d_TextureMap)& TextureHatch() const { return myTextureHatch; }
//! Returns true if hatch is defined by stipple mask.
Standard_Boolean IsStippleHatch() const { return !myStippleHatch.IsNull(); }
//! Returns the stipple mask.
const Handle(Graphic3d_HatchStyle)& StippleHatch() const { return myStippleHatch; }
//! Returns modification counter for hatching state.
Standard_Size HatchingState() const { return myHatchingState; }
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
private:
enum Flags
{
Flags_None = 0x00, //!< no flags
Flags_UseObjectMaterial = 0x01, //!< use object material
Flags_UseObjectTexture = 0x02, //!< use object texture
Flags_UseObjectShader = 0x04, //!< use object GLSL program
Flags_HatchZoomPersistent = 0x08, //!< zoom-persistent texturing
Flags_HatchRotationPersistent = 0x10, //!< rotation-persistent texturing
Flags_DrawHatching = 0x20, //!< draw hatching
Flags_UseObjectProperties = //!< use entire fill area aspect from object
Flags_UseObjectMaterial
| Flags_UseObjectTexture
| Flags_UseObjectShader
};
void setFlag (const Standard_Boolean theToUse, const unsigned int theFlag)
{
myFlags = theToUse ? myFlags | theFlag : myFlags & ~theFlag;
}
private:
Graphic3d_MaterialAspect myMaterial;
Handle(Graphic3d_TextureMap) myTexture;
Handle(Graphic3d_ShaderProgram) myShader;
Handle(Graphic3d_HatchStyle) myStippleHatch;
Handle(Graphic3d_TextureMap) myTextureHatch;
Graphic3d_MaterialAspect myHatchMaterial;
unsigned int myFlags;
Standard_Size myHatchingState;
public:
DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillCapping, Graphic3d_Aspects)
};
DEFINE_STANDARD_HANDLE (Graphic3d_AspectFillCapping, Graphic3d_Aspects)
#endif // _Graphic3d_AspectFillCapping_HeaderFile

View File

@@ -70,6 +70,14 @@ void Graphic3d_Aspects::DumpJson (Standard_OStream& theOStream, const Standard_I
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_Aspects);
/*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;*/
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myInteriorColor);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBackInteriorColor);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myEdgeColor);
@@ -82,4 +90,23 @@ void Graphic3d_Aspects::DumpJson (Standard_OStream& theOStream, const Standard_I
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToSuppressBackFaces);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToMapTexture);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsTextZoomable);
/*Aspect_InteriorStyle myInteriorStyle;
Graphic3d_TypeOfShadingModel myShadingModel;
Graphic3d_AlphaMode myAlphaMode;
Standard_ShortReal myAlphaCutoff;
Aspect_TypeOfLine myLineType;
Standard_ShortReal myLineWidth;
Aspect_TypeOfMarker myMarkerType;
Standard_ShortReal myMarkerScale;*/
if (!myTextFont.IsNull())
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myTextFont->String());
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextStyle);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextDisplayType);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextFontAspect);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextAngle);
}

View File

@@ -58,6 +58,18 @@ Graphic3d_Fresnel Graphic3d_Fresnel::CreateConductor (const Graphic3d_Vec3& theR
return Graphic3d_Fresnel (Graphic3d_FM_SCHLICK, aFresnel);
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void Graphic3d_Fresnel::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_Fresnel);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFresnelType);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myFresnelData);
}
// =======================================================================
// function : Graphic3d_BSDF
// purpose :
@@ -189,4 +201,23 @@ Graphic3d_BSDF Graphic3d_BSDF::CreateGlass (const Graphic3d_Vec3& theWeight,
theAbsorptionCoeff);
return aBSDF;
}
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void Graphic3d_BSDF::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_BSDF);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Kc);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Kd);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Ks);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Kt);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Le);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Absorption);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &FresnelCoat);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &FresnelBase);
}

View File

@@ -87,6 +87,9 @@ public:
return myFresnelType;
}
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
protected:
//! Creates new Fresnel reflectance factor.
@@ -180,6 +183,9 @@ public:
//! Performs comparison of two BSDFs.
Standard_EXPORT bool operator== (const Graphic3d_BSDF& theOther) const;
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
};
#endif // _Graphic3d_BSDF_HeaderFile

View File

@@ -18,6 +18,7 @@
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_TransModeFlags.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CStructure,Standard_Transient)
@@ -44,3 +45,46 @@ Graphic3d_CStructure::Graphic3d_CStructure (const Handle(Graphic3d_StructureMana
{
Id = myGraphicDriver->NewIdentification();
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void Graphic3d_CStructure::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_CStructure);
for (Graphic3d_SequenceOfGroup::Iterator anIterator (myGroups); anIterator.More(); anIterator.Next())
{
Handle(Graphic3d_Group) aGroup = anIterator.Value();
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aGroup.get());
}
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Id);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myZLayer);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Priority);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, PreviousPriority);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, ContainsFacet);
//OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &ViewAffinity);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsInfinite);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, stick);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, highlight);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, visible);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, HLRValidation);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsForHighlight);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsMutable);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Is2dText);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBndBox);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTrsf.get());
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTrsfPers.get());
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myClipPlanes.get());
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myHighlightStyle.get());
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsCulled);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myBndBoxClipCheck);
}

View File

@@ -133,6 +133,9 @@ public:
//! highlight flag is set to true
const Handle(Graphic3d_PresentationAttributes)& HighlightStyle() const { return myHighlightStyle; }
//! Returns true if the structure is clipped with set planes
virtual Standard_Boolean IsClipped (const Handle(Graphic3d_SequenceOfHClipPlane)& theClipPlane) const = 0;
public:
//! Returns FALSE if the structure hits the current view volume, otherwise returns TRUE.
@@ -194,6 +197,9 @@ public:
//! Update render transformation matrix.
virtual void updateLayerTransformation() {}
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
public:
int Id;

View File

@@ -369,6 +369,18 @@ void Graphic3d_CView::InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theL
}
}
}
// =======================================================================
// function : InvalidateAllLayerBoundingBox
// purpose :
// =======================================================================
void Graphic3d_CView::InvalidateAllLayerBoundingBox()
{
for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
{
const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
aLayer->InvalidateBoundingBox();
}
}
// =======================================================================
// function : ContainsFacet
@@ -436,7 +448,8 @@ Bnd_Box Graphic3d_CView::MinMaxValues (const Standard_Boolean theToIncludeAuxili
Bnd_Box aBox = aLayer->BoundingBox (Identification(),
aCamera,
aWinSize.x(), aWinSize.y(),
theToIncludeAuxiliary);
theToIncludeAuxiliary,
ClipPlanes());
aResult.Add (aBox);
}
return aResult;

View File

@@ -298,6 +298,9 @@ public:
//! Returns the bounding box of all structures displayed in the Z layer.
Standard_EXPORT virtual void InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId);
//! Returns the bounding box of all structures displayed in the Z layer.
Standard_EXPORT virtual void InvalidateAllLayerBoundingBox();
//! Remove Z layer from the specified view. All structures
//! displayed at the moment in layer will be displayed in default layer
//! ( the bottom-level z layer ). To unset layer ID from associated

View File

@@ -1546,3 +1546,41 @@ void Graphic3d_Camera::FrustumPoints (NCollection_Array1<Graphic3d_Vec3d>& thePo
aTmpPnt = anInvWorldView * aLeftBottomFar;
thePoints.SetValue (FrustumVert_LeftBottomFar, aTmpPnt.xyz() / aTmpPnt.w());
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void Graphic3d_Camera::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_Camera);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUp);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDirection);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myEye);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDistance);
/*gp_XYZ myAxialScale; //!< World axial scale.
Projection myProjType; //!< Projection type used for rendering.
Standard_Real myFOVy; //!< Field Of View in y axis.
Standard_Real myFOVyTan; //!< Field Of View as Tan(DTR_HALF * myFOVy)
Standard_Real myZNear; //!< Distance to near clipping plane.
Standard_Real myZFar; //!< Distance to far clipping plane.
Standard_Real myAspect; //!< Width to height display ratio.
Standard_Real myScale; //!< Specifies parallel scale for orthographic projection.
Standard_Real myZFocus; //!< Stereographic focus value.
FocusType myZFocusType; //!< Stereographic focus definition type.
Standard_Real myIOD; //!< Intraocular distance value.
IODType myIODType; //!< Intraocular distance definition type.
Graphic3d_CameraTile myTile;//!< Tile defining sub-area for drawing
mutable TransformMatrices<Standard_Real> myMatricesD;
mutable TransformMatrices<Standard_ShortReal> myMatricesF;
mutable Graphic3d_WorldViewProjState myWorldViewProjState;*/
}

View File

@@ -552,6 +552,9 @@ public:
//! The matrix will be updated on request.
Standard_EXPORT void InvalidateOrientation();
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
//! @name Managing projection and orientation cache
private:

View File

@@ -24,19 +24,6 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ClipPlane,Standard_Transient)
namespace
{
static volatile Standard_Integer THE_CLIP_PLANE_COUNTER = 0;
static Handle(Graphic3d_AspectFillArea3d) defaultAspect()
{
Graphic3d_MaterialAspect aMaterial (Graphic3d_NOM_DEFAULT);
Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
anAspect->SetDistinguishOff();
anAspect->SetFrontMaterial (aMaterial);
anAspect->SetHatchStyle (Aspect_HS_HORIZONTAL);
anAspect->SetInteriorStyle (Aspect_IS_SOLID);
anAspect->SetInteriorColor (Quantity_NOC_GRAY20);
anAspect->SetSuppressBackFaces (false);
return anAspect;
}
}
// =======================================================================
@@ -44,19 +31,8 @@ namespace
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane()
: myAspect (defaultAspect()),
myPrevInChain(NULL),
myPlane (0.0, 0.0, 1.0, 0.0),
myEquation (0.0, 0.0, 1.0, 0.0),
myEquationRev(0.0, 0.0,-1.0, 0.0),
myChainLenFwd(1),
myFlags (Graphic3d_CappingFlags_None),
myEquationMod(0),
myAspectMod (0),
myIsOn (Standard_True),
myIsCapping (Standard_False)
{
makeId();
init();
}
// =======================================================================
@@ -64,19 +40,8 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane()
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_Vec4d& theEquation)
: myAspect (defaultAspect()),
myPrevInChain(NULL),
myPlane (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w()),
myEquation (theEquation),
myEquationRev(0.0, 0.0,-1.0, 0.0),
myChainLenFwd(1),
myFlags (Graphic3d_CappingFlags_None),
myEquationMod(0),
myAspectMod (0),
myIsOn (Standard_True),
myIsCapping (Standard_False)
{
makeId();
init (gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.a()));
updateInversedPlane();
}
@@ -84,42 +49,27 @@ Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_Vec4d& theEquation)
// function : Graphic3d_ClipPlane
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const Graphic3d_ClipPlane& theOther)
: Standard_Transient(theOther),
myAspect (defaultAspect()),
myPrevInChain(NULL),
myPlane (theOther.myPlane),
myEquation (theOther.myEquation),
myEquationRev(theOther.myEquationRev),
myChainLenFwd(1),
myFlags (theOther.myFlags),
myEquationMod(0),
myAspectMod (0),
myIsOn (theOther.myIsOn),
myIsCapping (theOther.myIsCapping)
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Graphic3d_ClipPlane& theOther)
: Standard_Transient (theOther)
{
makeId();
*myAspect = *theOther.CappingAspect();
*mySectionStyle = *theOther.CappingSectionStyle();
init (theOther.myPlane,
theOther.myEquationRev,
theOther.myIsOn,
theOther.myIsCapping,
theOther.ToOverrideCappingAspect(),
theOther.CappingSectionStyle());
updateInversedPlane();
}
// =======================================================================
// function : Graphic3d_ClipPlane
// purpose :
// =======================================================================
Graphic3d_ClipPlane::Graphic3d_ClipPlane(const gp_Pln& thePlane)
: myAspect (defaultAspect()),
myPrevInChain(NULL),
myPlane (thePlane),
myChainLenFwd(1),
myFlags (Graphic3d_CappingFlags_None),
myEquationMod(0),
myAspectMod (0),
myIsOn (Standard_True),
myIsCapping (Standard_False)
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const gp_Pln& thePlane)
{
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
init (thePlane);
updateInversedPlane();
makeId();
}
// =======================================================================
@@ -131,7 +81,7 @@ void Graphic3d_ClipPlane::SetEquation (const Graphic3d_Vec4d& theEquation)
myPlane = gp_Pln (theEquation.x(), theEquation.y(), theEquation.z(), theEquation.w());
myEquation = theEquation;
updateInversedPlane();
myEquationMod++;
myOrientationDirty = Standard_True;
}
// =======================================================================
@@ -143,7 +93,7 @@ void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
myPlane = thePlane;
thePlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
updateInversedPlane();
myEquationMod++;
myOrientationDirty = Standard_True;
}
// =======================================================================
@@ -183,128 +133,114 @@ Handle(Graphic3d_ClipPlane) Graphic3d_ClipPlane::Clone() const
// =======================================================================
void Graphic3d_ClipPlane::SetCappingColor (const Quantity_Color& theColor)
{
myAspect->SetInteriorColor (theColor);
myAspect->ChangeFrontMaterial().SetColor (theColor);
mySectionStyle->SetInteriorColor (theColor);
mySectionStyle->ChangeFrontMaterial().SetColor (theColor);
++myAspectMod;
}
// =======================================================================
// function : SetCappingMaterial
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& theMat)
void Graphic3d_ClipPlane::SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle)
{
myAspect->SetFrontMaterial (theMat);
if (myAspect->FrontMaterial().MaterialType() != Graphic3d_MATERIAL_ASPECT)
mySectionStyle = theStyle;
if (mySectionStyle->FrontMaterial().MaterialType() != Graphic3d_MATERIAL_ASPECT)
{
myAspect->SetInteriorColor (theMat.Color());
}
++myAspectMod;
}
// =======================================================================
// function : SetCappingTexture
// function : OrientationMatrix
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
const Graphic3d_Mat4& Graphic3d_ClipPlane::OrientationMatrix() const
{
if (!theTexture.IsNull())
if (myOrientationDirty)
{
myAspect->SetTextureMapOn();
Handle(Graphic3d_TextureSet) aTextureSet = myAspect->TextureSet();
if (aTextureSet.IsNull() || aTextureSet->Size() != 1)
const Standard_ShortReal aDirection[] = {
static_cast<Standard_ShortReal> (myEquation[0]),
static_cast<Standard_ShortReal> (myEquation[1]),
static_cast<Standard_ShortReal> (myEquation[2])
};
const Standard_ShortReal aTranslate[] = {
static_cast<Standard_ShortReal> (myEquation[0] * -myEquation[3]),
static_cast<Standard_ShortReal> (myEquation[1] * -myEquation[3]),
static_cast<Standard_ShortReal> (myEquation[2] * -myEquation[3])
};
Standard_ShortReal aSide1[] = { 0.0f, 0.0f, 0.0f };
Standard_ShortReal aSide2[] = { 0.0f, 0.0f, 0.0f };
const Standard_ShortReal aMagintude = static_cast<Standard_ShortReal> (Sqrt (myEquation[0] * myEquation[0] + myEquation[2] * myEquation[2]));
if (aMagintude < ShortRealSmall())
{
aTextureSet = new Graphic3d_TextureSet (theTexture);
aSide1[0] = 1.0f;
}
else
{
aTextureSet->SetFirst (theTexture);
aSide1[0] = aDirection[2] / aMagintude;
aSide1[2] = -aDirection[0] / aMagintude;
}
myAspect->SetTextureSet (aTextureSet);
aSide2[0] = (-aSide1[1] * aDirection[2]) - (-aSide1[2] * aDirection[1]);
aSide2[1] = (-aSide1[2] * aDirection[0]) - (-aSide1[0] * aDirection[2]);
aSide2[2] = (-aSide1[0] * aDirection[1]) - (-aSide1[1] * aDirection[0]);
myOrientationMat.SetValue (0, 0, aSide1[0]);
myOrientationMat.SetValue (1, 0, aSide1[1]);
myOrientationMat.SetValue (2, 0, aSide1[2]);
myOrientationMat.SetValue (3, 0, 0.0F);
myOrientationMat.SetValue (0, 1, aDirection[0]);
myOrientationMat.SetValue (1, 1, aDirection[1]);
myOrientationMat.SetValue (2, 1, aDirection[2]);
myOrientationMat.SetValue (3, 1, 0.0F);
myOrientationMat.SetValue (0, 2, aSide2[0]);
myOrientationMat.SetValue (1, 2, aSide2[1]);
myOrientationMat.SetValue (2, 2, aSide2[2]);
myOrientationMat.SetValue (3, 2, 0.0F);
myOrientationMat.SetValue (0, 3, aTranslate[0]);
myOrientationMat.SetValue (1, 3, aTranslate[1]);
myOrientationMat.SetValue (2, 3, aTranslate[2]);
myOrientationMat.SetValue (3, 3, 1.0F);
myOrientationDirty = Standard_False;
}
else
return myOrientationMat;
}
// =======================================================================
// function : init
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::init (const gp_Pln& thePlane,
const Graphic3d_Vec4d& theEquationRev,
const Standard_Boolean theIsOn,
const Standard_Boolean theIsCapping,
const Standard_Boolean theOverrideStyle,
const Handle(Graphic3d_AspectFillCapping)& theStyle)
{
if (myEntityUID.IsEmpty())
{
myAspect->SetTextureMapOff();
myAspect->SetTextureSet (Handle(Graphic3d_TextureSet)());
myEntityUID = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
}
++myAspectMod;
}
// =======================================================================
// function : SetCappingHatch
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatch (const Aspect_HatchStyle theStyle)
{
myAspect->SetHatchStyle (theStyle);
++myAspectMod;
}
// =======================================================================
// function : SetCappingCustomHatch
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle)
{
myAspect->SetHatchStyle (theStyle);
++myAspectMod;
}
// =======================================================================
// function : SetCappingHatchOn
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatchOn()
{
myAspect->SetInteriorStyle (Aspect_IS_HATCH);
++myAspectMod;
}
// =======================================================================
// function : SetCappingHatchOff
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingHatchOff()
{
myAspect->SetInteriorStyle (Aspect_IS_SOLID);
++myAspectMod;
}
// =======================================================================
// function : SetCappingAspect
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
{
myAspect = theAspect;
++myAspectMod;
}
// =======================================================================
// function : setCappingFlag
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::setCappingFlag (bool theToUse, int theFlag)
{
if (theToUse)
{
myFlags |= theFlag;
}
else
{
myFlags &= ~(theFlag);
}
++myAspectMod;
}
// =======================================================================
// function : makeId
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::makeId()
{
myId = TCollection_AsciiString ("Graphic3d_ClipPlane_") //DynamicType()->Name()
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_CLIP_PLANE_COUNTER));
myPrevInChain = NULL;
myEquationRev = theEquationRev;
myChainLenFwd = 1;
myPlane = thePlane;
myPlane.Coefficients (myEquation[0], myEquation[1], myEquation[2], myEquation[3]);
myIsOn = theIsOn;
myIsCapping = theIsCapping;
myOverrideObjectStyle = theOverrideStyle;
mySectionStyle = theStyle.IsNull() ? new Graphic3d_AspectFillCapping() : theStyle;
myOrientationDirty = Standard_True;
}
// =======================================================================
@@ -326,7 +262,7 @@ void Graphic3d_ClipPlane::updateChainLen()
// =======================================================================
void Graphic3d_ClipPlane::SetChainNextPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
{
++myEquationMod;
myOrientationDirty = Standard_True;
if (!myNextInChain.IsNull())
{
myNextInChain->myPrevInChain = NULL;
@@ -338,3 +274,28 @@ void Graphic3d_ClipPlane::SetChainNextPlane (const Handle(Graphic3d_ClipPlane)&
}
updateChainLen();
}
// =======================================================================
// function : DumpJson
// purpose :
// =======================================================================
void Graphic3d_ClipPlane::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_ClipPlane);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, mySectionStyle.get());
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myEntityUID);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPlane);
OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "Equation", 4, myEquation.x(), myEquation.y(), myEquation.z(), myEquation.w())
OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "EquationRev", 4, myEquationRev.x(), myEquationRev.y(), myEquationRev.z(), myEquationRev.w())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myChainLenFwd);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFlags);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myEquationMod);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAspectMod);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsOn);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsCapping);
}

View File

@@ -19,9 +19,12 @@
#include <Aspect_HatchStyle.hxx>
#include <gp_Pln.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectFillCapping.hxx>
#include <Graphic3d_BndBox3d.hxx>
#include <Graphic3d_CappingFlags.hxx>
#include <Graphic3d_Mat4.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <NCollection_Handle.hxx>
#include <NCollection_Vec4.hxx>
#include <Standard_Macro.hxx>
#include <Standard_TypeDef.hxx>
@@ -167,49 +170,11 @@ public:
public: // @name user-defined graphical attributes
//! Return color for rendering capping surface.
Quantity_Color CappingColor() const { return myAspect->FrontMaterial().MaterialType() == Graphic3d_MATERIAL_ASPECT ? myAspect->FrontMaterial().Color() : myAspect->InteriorColor(); }
Quantity_Color CappingColor() const { return mySectionStyle->FrontMaterial().MaterialType() == Graphic3d_MATERIAL_ASPECT ? mySectionStyle->FrontMaterial().Color() : mySectionStyle->InteriorColor(); }
//! Set color for rendering capping surface.
Standard_EXPORT void SetCappingColor (const Quantity_Color& theColor);
//! Set material for rendering capping surface.
//! @param theMat [in] the material.
Standard_EXPORT void SetCappingMaterial (const Graphic3d_MaterialAspect& theMat);
//! @return capping material.
const Graphic3d_MaterialAspect& CappingMaterial() const { return myAspect->FrontMaterial(); }
//! Set texture to be applied on capping surface.
//! @param theTexture [in] the texture.
Standard_EXPORT void SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture);
//! @return capping texture map.
Handle(Graphic3d_TextureMap) CappingTexture() const { return !myAspect->TextureSet().IsNull() && !myAspect->TextureSet()->IsEmpty()
? myAspect->TextureSet()->First()
: Handle(Graphic3d_TextureMap)(); }
//! Set hatch style (stipple) and turn hatching on.
//! @param theStyle [in] the hatch style.
Standard_EXPORT void SetCappingHatch (const Aspect_HatchStyle theStyle);
//! @return hatching style.
Aspect_HatchStyle CappingHatch() const { return (Aspect_HatchStyle)myAspect->HatchStyle()->HatchType(); }
//! Set custom hatch style (stipple) and turn hatching on.
//! @param theStyle [in] the hatch pattern.
Standard_EXPORT void SetCappingCustomHatch (const Handle(Graphic3d_HatchStyle)& theStyle);
//! @return hatching style.
const Handle(Graphic3d_HatchStyle)& CappingCustomHatch() const { return myAspect->HatchStyle(); }
//! Turn on hatching.
Standard_EXPORT void SetCappingHatchOn();
//! Turn off hatching.
Standard_EXPORT void SetCappingHatchOff();
//! @return True if hatching mask is turned on.
Standard_Boolean IsHatchOn() const { return myAspect->InteriorStyle() == Aspect_IS_HATCH; }
//! This ID is used for managing associated resources in graphical driver.
//! The clip plane can be assigned within a range of IO which can be
@@ -220,41 +185,18 @@ public: // @name user-defined graphical attributes
//! @return clip plane resource identifier string.
const TCollection_AsciiString& GetId() const
{
return myId;
return myEntityUID;
}
public:
//! Return capping aspect.
//! Returns style used for drawing capping section.
//! @return capping surface rendering aspect.
const Handle(Graphic3d_AspectFillArea3d)& CappingAspect() const { return myAspect; }
const Handle(Graphic3d_AspectFillCapping)& CappingSectionStyle() const { return mySectionStyle; }
//! Assign capping aspect.
Standard_EXPORT void SetCappingAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
//! Sets clipping section filling aspect.
Standard_EXPORT void SetCappingSectionStyle (const Handle(Graphic3d_AspectFillCapping)& theStyle);
//! Flag indicating whether material for capping plane should be taken from object.
//! Default value: FALSE (use dedicated capping plane material).
bool ToUseObjectMaterial() const { return (myFlags & Graphic3d_CappingFlags_ObjectMaterial) != 0; }
//! Set flag for controlling the source of capping plane material.
void SetUseObjectMaterial (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectMaterial); }
//! Flag indicating whether texture for capping plane should be taken from object.
//! Default value: FALSE.
bool ToUseObjectTexture() const { return (myFlags & Graphic3d_CappingFlags_ObjectTexture) != 0; }
//! Set flag for controlling the source of capping plane texture.
void SetUseObjectTexture (bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectTexture); }
//! Flag indicating whether shader program for capping plane should be taken from object.
//! Default value: FALSE.
bool ToUseObjectShader() const { return (myFlags & Graphic3d_CappingFlags_ObjectShader) != 0; }
//! Set flag for controlling the source of capping plane shader program.
void SetUseObjectShader(bool theToUse) { setCappingFlag (theToUse, Graphic3d_CappingFlags_ObjectShader); }
//! Return true if some fill area aspect properties should be taken from object.
bool ToUseObjectProperties() const { return myFlags != Graphic3d_CappingFlags_None; }
public:
@@ -377,6 +319,9 @@ public:
return !IsPointOutHalfspace (aMinPnt);
}
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
public: // @name modification counters
//! @return modification counter for equation.
@@ -390,14 +335,25 @@ public: // @name modification counters
{
return myAspectMod;
}
//! Flag indicating whether section style of the plane should overrides similar property of object presentation.
//! Default value: FALSE (use dedicated presentation aspect style).
bool ToOverrideCappingAspect() const { return myOverrideObjectStyle; }
//! Sets flag for controlling the preference of using section style between clip plane and object.
void SetToOverrideCappingAspect (const bool theToOverride) { myOverrideObjectStyle = theToOverride; }
//! Returns plane's orientation matrix.
Standard_EXPORT const Graphic3d_Mat4& OrientationMatrix() const;
private:
//! Generate unique object id for OpenGL graphic resource manager.
void makeId();
//! Set capping flag.
Standard_EXPORT void setCappingFlag (bool theToUse, int theFlag);
//! Initializes plane and makes unique identifier (UID) to differentiate clipping plane entities.
void init (const gp_Pln& thePlane = gp_Pln(),
const Graphic3d_Vec4d& theEquationRev = Graphic3d_Vec4d(0.0, 0.0,-1.0, 0.0),
const Standard_Boolean theIsOn = Standard_True,
const Standard_Boolean theIsCapping = Standard_False,
const Standard_Boolean theOverrideStyle = Standard_False,
const Handle(Graphic3d_AspectFillCapping)& theStyle = Handle(Graphic3d_AspectFillCapping)());
//! Update chain length in backward direction.
void updateChainLen();
@@ -412,10 +368,10 @@ private:
private:
Handle(Graphic3d_AspectFillArea3d) myAspect; //!< fill area aspect
Handle(Graphic3d_AspectFillCapping) mySectionStyle; //!< Style set for drawing capped solid section.
Handle(Graphic3d_ClipPlane) myNextInChain; //!< next plane in a chain of planes defining logical AND operation
Graphic3d_ClipPlane* myPrevInChain; //!< previous plane in a chain of planes defining logical AND operation
TCollection_AsciiString myId; //!< resource id
TCollection_AsciiString myEntityUID; //!< Unique identifier for the plane
gp_Pln myPlane; //!< plane definition
Graphic3d_Vec4d myEquation; //!< plane equation vector
Graphic3d_Vec4d myEquationRev; //!< reversed plane equation
@@ -425,6 +381,9 @@ private:
unsigned int myAspectMod; //!< modification counter of aspect
Standard_Boolean myIsOn; //!< state of the clipping plane
Standard_Boolean myIsCapping; //!< state of graphic driver capping
Standard_Boolean myOverrideObjectStyle; //!< Flag forcing to use plane's section style rather than section style defined for object
mutable Standard_Boolean myOrientationDirty; //!< Boolean flag indicating whether orientation matrix is dirty or not.
mutable Graphic3d_Mat4 myOrientationMat; //!< Plane orientation matrix (for visualization purposes).
};

View File

@@ -37,6 +37,7 @@
class Graphic3d_Structure;
class Graphic3d_ArrayOfPrimitives;
class Graphic3d_AspectFillCapping;
class Graphic3d_Text;
//! This class allows the definition of groups
@@ -105,6 +106,9 @@ public:
//! Modifies the current context of the group to give another aspect for all the primitives created after this call in the group.
virtual void SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) = 0;
//! Returns style of filling clipping sections on closed shell primitives.
virtual Handle(Graphic3d_AspectFillCapping) FillCappingAspect() const = 0;
//! Update presentation aspects after their modification.
virtual void SynchronizeAspects() = 0;

View File

@@ -21,13 +21,15 @@
//! - ASPECT_LINE: aspect for line primitives;
//! - ASPECT_TEXT: aspect for text primitives;
//! - ASPECT_MARKER: aspect for marker primitives;
//! - ASPECT_FILL_AREA: aspect for face primitives.
//! - ASPECT_FILL_AREA: aspect for face primitives;
//! - Graphic3d_ASPECT_FILL_CAPPING: aspect for filling clipping sections.
enum Graphic3d_GroupAspect
{
Graphic3d_ASPECT_LINE,
Graphic3d_ASPECT_TEXT,
Graphic3d_ASPECT_MARKER,
Graphic3d_ASPECT_FILL_AREA
Graphic3d_ASPECT_FILL_AREA,
Graphic3d_ASPECT_FILL_CAPPING
};
#endif // _Graphic3d_GroupAspect_HeaderFile

View File

@@ -516,3 +516,15 @@ const Standard_Byte* Graphic3d_HatchStyle::Pattern() const
? (const Standard_Byte*)myPredefinedPatterns[myHatchType]
: NULL);
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void Graphic3d_HatchStyle::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_HatchStyle);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPattern.get());
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHatchType);
}

View File

@@ -49,6 +49,9 @@ public:
return myHatchType;
}
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
private:
Handle(NCollection_Buffer) myPattern; //!< Image bitmap with custom hatch pattern

View File

@@ -179,7 +179,8 @@ Bnd_Box Graphic3d_Layer::BoundingBox (Standard_Integer theViewId,
const Handle(Graphic3d_Camera)& theCamera,
Standard_Integer theWindowWidth,
Standard_Integer theWindowHeight,
Standard_Boolean theToIncludeAuxiliary) const
Standard_Boolean theToIncludeAuxiliary,
const Handle(Graphic3d_SequenceOfHClipPlane)& theClipPlanes) const
{
updateBVH();
@@ -202,6 +203,11 @@ Bnd_Box Graphic3d_Layer::BoundingBox (Standard_Integer theViewId,
continue;
}
if (aStructure->IsClipped (theClipPlanes) || aStructure->IsClipped (aStructure->ClipPlanes()))
{
continue;
}
// "FitAll" operation ignores object with transform persistence parameter
// but adds transform persistence point in a bounding box of layer (only zoom pers. objects).
if (!aStructure->TransformPersistence().IsNull())
@@ -626,3 +632,41 @@ void Graphic3d_Layer::SetLayerSettings (const Graphic3d_ZLayerSettings& theSetti
}
}
}
// =======================================================================
// function : DumpJson
// purpose :
// =======================================================================
void Graphic3d_Layer::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_Layer);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLayerId);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNbStructures);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNbStructuresNotCulled);
const Standard_Integer aNbPriorities = myArray.Length();
for (Standard_Integer aPriorityIter = 0; aPriorityIter < aNbPriorities; ++aPriorityIter)
{
const Graphic3d_IndexedMapOfStructure& aStructures = myArray (aPriorityIter);
for (Graphic3d_IndexedMapOfStructure::Iterator aStructIter (aStructures); aStructIter.More(); aStructIter.Next())
{
const Graphic3d_CStructure* aStructure = aStructIter.Value();
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, aStructure);
}
}
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myLayerSettings);
//mutable Graphic3d_BvhCStructureSet myBVHPrimitives;
//mutable Graphic3d_BvhCStructureSetTrsfPers myBVHPrimitivesTrsfPers;
//mutable NCollection_IndexedMap<const Graphic3d_CStructure*> myAlwaysRenderedMap;
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myBVHIsLeftChildQueuedFirst);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsBVHPrimitivesNeedsReset);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsBoundingBoxNeedsReset[0]);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsBoundingBoxNeedsReset[1]);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBoundingBox[0]);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBoundingBox[1]);
}

View File

@@ -24,6 +24,8 @@
#include <NCollection_IndexedMap.hxx>
#include <NCollection_Sequence.hxx>
class Graphic3d_SequenceOfHClipPlane;
//! Defines index map of structures.
typedef NCollection_IndexedMap<const Graphic3d_CStructure*> Graphic3d_IndexedMapOfStructure;
@@ -110,7 +112,8 @@ public:
const Handle(Graphic3d_Camera)& theCamera,
Standard_Integer theWindowWidth,
Standard_Integer theWindowHeight,
Standard_Boolean theToIncludeAuxiliary) const;
Standard_Boolean theToIncludeAuxiliary,
const Handle(Graphic3d_SequenceOfHClipPlane)& theClipPlanes = Handle(Graphic3d_SequenceOfHClipPlane)()) const;
//! Returns zoom-scale factor.
Standard_EXPORT Standard_Real considerZoomPersistenceObjects (Standard_Integer theViewId,
@@ -144,6 +147,9 @@ public:
//! Returns indexed map of always rendered structures.
const NCollection_IndexedMap<const Graphic3d_CStructure*>& NonCullableStructures() const { return myAlwaysRenderedMap; }
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
protected:
//! Updates BVH trees if their state has been invalidated.

View File

@@ -702,3 +702,28 @@ Graphic3d_TypeOfMaterial Graphic3d_MaterialAspect::MaterialType (const Standard_
const RawMaterial& aMat = THE_MATERIALS[theRank - 1];
return aMat.MaterialType;
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void Graphic3d_MaterialAspect::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_MaterialAspect);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBSDF);
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myStringName);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColors[Graphic3d_TOR_AMBIENT]);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColors[Graphic3d_TOR_DIFFUSE]);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColors[Graphic3d_TOR_SPECULAR]);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColors[Graphic3d_TOR_EMISSION]);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTransparencyCoef);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRefractionIndex);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myShininess);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaterialType);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaterialName);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRequestedMaterialName);
}

View File

@@ -227,6 +227,9 @@ public:
}
}
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
private:
//! Initialize the standard material.

View File

@@ -15,4 +15,21 @@
#include <Graphic3d_PresentationAttributes.hxx>
#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT (Graphic3d_PresentationAttributes, Standard_Transient)
// =======================================================================
// function : DumpJson
// purpose :
// =======================================================================
void Graphic3d_PresentationAttributes::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myBasicFillAreaAspect.get());
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBasicColor);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHiMethod);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myZLayer);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDispMode);
}

View File

@@ -90,6 +90,9 @@ public:
//! Sets basic presentation fill area aspect.
virtual void SetBasicFillAreaAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) { myBasicFillAreaAspect = theAspect; }
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
protected:
Handle(Graphic3d_AspectFillArea3d) myBasicFillAreaAspect; //!< presentation fill area aspect

View File

@@ -58,3 +58,18 @@ bool Graphic3d_SequenceOfHClipPlane::Remove (const Handle(Graphic3d_ClipPlane)&
}
return false;
}
// =======================================================================
// function : DumpJson
// purpose :
// =======================================================================
void Graphic3d_SequenceOfHClipPlane::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToOverrideGlobal);
for (NCollection_Sequence<Handle(Graphic3d_ClipPlane)>::Iterator anIterator (myItems); anIterator.More(); anIterator.Next())
{
Handle(Graphic3d_ClipPlane) aClipPlane = anIterator.Value();
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aClipPlane.get());
}
}

View File

@@ -94,6 +94,9 @@ public:
//! Return the first item in sequence.
const Handle(Graphic3d_ClipPlane)& First() const { return myItems.First(); }
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
protected:
NCollection_Sequence<Handle(Graphic3d_ClipPlane)> myItems;

View File

@@ -30,6 +30,8 @@
#include "Graphic3d_Structure.pxx"
#include <Standard_Dump.hxx>
#include <stdio.h>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Structure,Standard_Transient)
@@ -1027,3 +1029,22 @@ void Graphic3d_Structure::SetZLayer (const Graphic3d_ZLayerId theLayerId)
myStructureManager->ChangeZLayer (this, theLayerId);
myCStructure->SetZLayer (theLayerId);
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
void Graphic3d_Structure::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_Structure);
//Graphic3d_StructureManager* myStructureManager;
//NCollection_IndexedMap<Graphic3d_Structure*> myAncestors;
//NCollection_IndexedMap<Graphic3d_Structure*> myDescendants;
//Standard_Address myOwner;
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCStructure.get());
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVisual);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComputeVisual);
}

View File

@@ -432,6 +432,9 @@ public:
//! Returns the low-level structure
const Handle(Graphic3d_CStructure)& CStructure() const { return myCStructure; }
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
protected:
//! Transforms boundaries with <theTrsf> transformation.

View File

@@ -17,6 +17,7 @@
#include <gp_Ax2.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Font_TextFormatter.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <NCollection_String.hxx>
@@ -31,6 +32,7 @@
//! - text formatter. Formatter contains text, height and alignment parameter.
//!
//! This class also has parameters of the text height and H/V alignments.
//! More compilated formatting is available using Font_TextFormatter.
class Graphic3d_Text : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
@@ -55,6 +57,12 @@ public:
//! Sets text value.
void SetText (Standard_CString theText) { myText = theText; }
//! @return text formatter
const Handle(Font_TextFormatter)& TextFormatter() const { return myFormatter; }
//! @return default formatter of text withing this context
void SetTextFormatter (const Handle(Font_TextFormatter)& theFormatter) { myFormatter = theFormatter; }
//! The 3D point of attachment is projected.
//! If the orientation is defined, the text is written in the plane of projection.
const gp_Pnt& Position() const { return myOrientation.Location(); }
@@ -99,6 +107,8 @@ public:
void SetVerticalAlignment (const Graphic3d_VerticalTextAlignment theJustification) { myVAlign = theJustification; }
protected:
Handle(Font_TextFormatter) myFormatter; //!< text formatter
NCollection_String myText; //!< text value
gp_Ax2 myOrientation; //!< Text orientation in 3D space.

View File

@@ -51,3 +51,17 @@ Handle(Graphic3d_TransformPers) Graphic3d_TransformPers::FromDeprecatedParams (G
}
return aTrsfPers;
}
// =======================================================================
// function : DumpJson
// purpose :
// =======================================================================
void Graphic3d_TransformPers::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_TransformPers);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMode)
OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "Params3d", 3, myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ)
OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "Params2d", 3, myParams.Params2d.OffsetX, myParams.Params2d.OffsetY, myParams.Params2d.Corner)
}

View File

@@ -283,6 +283,9 @@ public:
const Standard_Integer theViewportWidth,
const Standard_Integer theViewportHeight) const;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
private:
//! 3D anchor point for zoom/rotate transformation persistence.

View File

@@ -19,6 +19,7 @@
#include <Graphic3d_LightSet.hxx>
#include <Graphic3d_PolygonOffset.hxx>
#include <Precision.hxx>
#include <Standard_Dump.hxx>
#include <TCollection_AsciiString.hxx>
enum Graphic3d_ZLayerSetting
@@ -208,6 +209,31 @@ struct Graphic3d_ZLayerSettings
myPolygonOffset.Units =-1.0f;
}
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_ZLayerSettings);
OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myName);
//OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myLights.get());
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myOriginTrsf.get());
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myOrigin);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCullingDistance);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCullingSize);
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPolygonOffset);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsImmediate);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToRaytrace);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUseEnvironmentTexture);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToEnableDepthTest);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToEnableDepthWrite);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToClearDepth);
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToRenderInDepthPrepass);
}
protected:
TCollection_AsciiString myName; //!< user-provided name

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,9 @@ Message_Msg.hxx
Message_Msg.lxx
Message_MsgFile.cxx
Message_MsgFile.hxx
Message_PerfMeter.cxx
Message_PerfMeter.hxx
Message_PerfMeterMode.hxx
Message_Printer.cxx
Message_Printer.hxx
Message_PrinterOStream.cxx
@@ -32,8 +48,8 @@ Message_SequenceOfPrinters.hxx
Message_SequenceOfProgressScale.hxx
Message_Status.hxx
Message_StatusType.hxx
Message_Alert.cxx
Message_Alert.hxx
Message_ListOfAlert.hxx
Message_Report.cxx
Message_Report.hxx
Message_ReportCallBack.cxx
Message_ReportCallBack.hxx

View File

@@ -49,3 +49,342 @@ TCollection_AsciiString Message::FillTime (const Standard_Integer hour,
Sprintf (t, "%.2fs", second);
return TCollection_AsciiString (t);
}
namespace
{
static Standard_CString Message_Table_PrintGravityEnum[5] =
{
"TRACE", "INFO", "WARNING", "ALARM", "FAIL"
};
static Standard_CString Message_Table_PrintPerfMeterModeEnum[10] =
{
"NONE", "USER_TIME_CPU", "SYSTEM_TIME_CPU", "MEM_PRIVATE", "MEM_VIRTUAL",
"MEM_WORKING_SET", "MEM_WORKING_SET_PEAK", "MEM_SWAP_USAGE", "MEM_SWAP_USAGE_PEAK", "MEM_HEAP_USAGE"
};
}
//=======================================================================
//function : GravityToString
//purpose :
//=======================================================================
Standard_CString Message::GravityToString (const Message_Gravity theGravity)
{
return Message_Table_PrintGravityEnum[theGravity];
}
//=======================================================================
//function : GravityFromString
//purpose :
//=======================================================================
Standard_Boolean Message::GravityFromString (const Standard_CString theGravityString,
Message_Gravity& theGravity)
{
TCollection_AsciiString aName (theGravityString);
aName.UpperCase();
for (Standard_Integer aGravityIter = 0; aGravityIter <= Message_Fail; ++aGravityIter)
{
Standard_CString aGravityName = Message_Table_PrintGravityEnum[aGravityIter];
if (aName == aGravityName)
{
theGravity = Message_Gravity (aGravityIter);
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : PerfMeterModeToString
//purpose :
//=======================================================================
Standard_CString Message::PerfMeterModeToString (const Message_PerfMeterMode theValue)
{
return Message_Table_PrintPerfMeterModeEnum[theValue];
}
//=======================================================================
//function : PerfMeterModeFromString
//purpose :
//=======================================================================
Standard_Boolean Message::PerfMeterModeFromString (const Standard_CString theString,
Message_PerfMeterMode& theValue)
{
TCollection_AsciiString aName (theString);
aName.UpperCase();
for (Standard_Integer aModeIter = 0; aModeIter <= Message_PerfMeterMode_MemHeapUsage; ++aModeIter)
{
Standard_CString aModeName = Message_Table_PrintPerfMeterModeEnum[aModeIter];
if (aName == aModeName)
{
theValue = Message_PerfMeterMode (aModeIter);
return Standard_True;
}
}
return Standard_False;
}
// =======================================================================
// function : GetPointerInfo
// purpose :
// =======================================================================
TCollection_AsciiString Message::TransientToString (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
{
if (thePointer.IsNull())
return TCollection_AsciiString();
return PointerToString(thePointer.operator->(), isShortInfo);
}
// =======================================================================
// function : GetPointerInfo
// purpose :
// =======================================================================
TCollection_AsciiString Message::PointerToString (const void* thePointer, const bool isShortInfo)
{
std::ostringstream aPtrStr;
aPtrStr << thePointer;
if (!isShortInfo)
return aPtrStr.str().c_str();
TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
{
if (anInfoPtr.Value(aSymbolId) != '0')
{
anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
anInfoPtr.Prepend("0x");
return anInfoPtr;
}
}
return aPtrStr.str().c_str();
}
// =======================================================================
// function : StrVectorToString
// purpose :
// =======================================================================
TCollection_AsciiString Message::StrVectorToString
(const NCollection_Vector<TCollection_AsciiString>& theValues)
{
TCollection_AsciiString aValue;
for (NCollection_Vector<TCollection_AsciiString>::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next())
{
aValue += aValuesIt.Value();
if (aValuesIt.More())
aValue += VectorSeparator();
}
return aValue;
}
// =======================================================================
// function : StrVectorFromString
// purpose :
// =======================================================================
Standard_Boolean Message::StrVectorFromString
(const TCollection_AsciiString& theValue,
NCollection_Vector<TCollection_AsciiString>& theValues)
{
TCollection_AsciiString aCurrentString = theValue, aValueString;
while (!aCurrentString.IsEmpty())
{
Standard_Integer aPosition = aCurrentString.Search (", ");
aValueString = aCurrentString;
if (aPosition > 0)
aCurrentString = aValueString.Split (aPosition - 1);
theValues.Append (aValueString.RealValue());
if (aPosition > 0)
aCurrentString = aCurrentString.Split (2);
}
return Standard_True;
}
// =======================================================================
// function : RealVectorToString
// purpose :
// =======================================================================
TCollection_AsciiString Message::RealVectorToString
(const NCollection_Vector<Standard_Real>& theValues)
{
TCollection_AsciiString aValue = ("(");
for (NCollection_Vector<Standard_Real>::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next())
{
aValue += aValuesIt.Value();
if (aValuesIt.More())
aValue += VectorSeparator();
}
aValue += ")";
return aValue;
}
// =======================================================================
// function : RealVectorFromString
// purpose :
// =======================================================================
Standard_Boolean Message::RealVectorFromString
(const TCollection_AsciiString& theValue,
NCollection_Vector<Standard_Real>& theValues)
{
TCollection_AsciiString aCurrentString = theValue, aValueString;
Standard_Integer aPosition = aCurrentString.Search ("(");
if (aPosition != 1)
return Standard_False;
aCurrentString = aCurrentString.Split (aPosition);
aPosition = aCurrentString.Search (")");
if (aPosition != 1)
return Standard_False;
aValueString = aCurrentString.Split (aPosition);
while (!aCurrentString.IsEmpty())
{
// x value
aPosition = aCurrentString.Search (", ");
aValueString = aCurrentString;
if (aPosition > 0)
aCurrentString = aValueString.Split (aPosition - 1);
theValues.Append (aValueString.RealValue());
if (aPosition > 0)
aCurrentString = aCurrentString.Split (2);
}
return Standard_True;
}
// =======================================================================
// function : CoordVectorToString
// purpose :
// =======================================================================
TCollection_AsciiString Message::CoordVectorToString
(const NCollection_Vector<Standard_Real>& theValues)
{
TCollection_AsciiString aValue = ("(");
aValue += RealVectorToString (theValues);
aValue += ")";
return aValue;
}
// =======================================================================
// function : CoordVectorFromString
// purpose :
// =======================================================================
Standard_Boolean Message::CoordVectorFromString
(const TCollection_AsciiString& theValue,
NCollection_Vector<Standard_Real>& theValues)
{
TCollection_AsciiString aCurrentString = theValue, aValueString;
Standard_Integer aPosition = aCurrentString.Search ("(");
if (aPosition != 1)
return Standard_False;
aCurrentString = aCurrentString.Split (aPosition);
aPosition = aCurrentString.Search (")");
if (aPosition != 1)
return Standard_False;
aValueString = aCurrentString.Split (aPosition);
return RealVectorFromString (aCurrentString, theValues);
}
// =======================================================================
// function : ColorVectorToString
// purpose :
// =======================================================================
TCollection_AsciiString Message::ColorVectorToString
(const NCollection_Vector<Standard_Real>& theValues)
{
TCollection_AsciiString aValue = ("[");
aValue += RealVectorToString (theValues);
aValue += "]";
return aValue;
}
// =======================================================================
// function : ColorVectorFromString
// purpose :
// =======================================================================
Standard_Boolean Message::ColorVectorFromString
(const TCollection_AsciiString& theValue,
NCollection_Vector<Standard_Real>& theValues)
{
TCollection_AsciiString aCurrentString = theValue, aValueString;
Standard_Integer aPosition = aCurrentString.Search ("[");
if (aPosition != 1)
return Standard_False;
aCurrentString = aCurrentString.Split (aPosition);
aPosition = aCurrentString.Search ("]");
if (aPosition != 1)
return Standard_False;
aValueString = aCurrentString.Split (aPosition);
return RealVectorFromString (aCurrentString, theValues);
}
// =======================================================================
// function : ConvertStream
// purpose :
// =======================================================================
void Message::ConvertStream (const Standard_SStream& theStream,
Standard_Integer& theColumnCount,
NCollection_Vector<TCollection_AsciiString>& theValues)
{
TCollection_AsciiString aStream (theStream.str().c_str());
Standard_Character aSeparator = Message::DumpSeparator();
Standard_Integer aColumnCount = 0;
TCollection_AsciiString aCurrentString = aStream;
Standard_Integer aPosition = aCurrentString.Search (aSeparator);
if (aPosition >= 1)
{
TCollection_AsciiString aTailString = aCurrentString.Split (aPosition);
Standard_Boolean aClassNameFound = Standard_False;
while (!aCurrentString.IsEmpty())
{
TCollection_AsciiString aValueString = aCurrentString;
aPosition = aValueString.Search (aSeparator);
if (aPosition < 0 )
break;
aCurrentString = aValueString.Split (aPosition - 1);
if (!aColumnCount)
{
if (!aClassNameFound)
aClassNameFound = Standard_True;
else
{
if (!aValueString.IsIntegerValue())
break; // not correct Dump, in correct the first value is number of property columns
aColumnCount = aValueString.IntegerValue();
}
}
else
theValues.Append (aValueString);
if (aTailString.IsEmpty())
break;
aCurrentString = aTailString;
aPosition = aCurrentString.Search (aSeparator);
if (aPosition < 0 )
{
aCurrentString = aTailString;
aTailString = TCollection_AsciiString();
}
else
aTailString = aCurrentString.Split (aPosition);
}
}
theColumnCount = aColumnCount;
}

View File

@@ -17,14 +17,19 @@
#ifndef _Message_HeaderFile
#define _Message_HeaderFile
#include <Message_Gravity.hxx>
#include <Message_PerfMeterMode.hxx>
#include <NCollection_Vector.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
#include <TCollection_AsciiString.hxx>
class Message_Messenger;
class TCollection_AsciiString;
class Message_Msg;
class Message_MsgFile;
class Message_Messenger;
@@ -59,8 +64,129 @@ public:
//! 3. (0, 0, 4.5 ) returns "4.50s"
Standard_EXPORT static TCollection_AsciiString FillTime (const Standard_Integer Hour, const Standard_Integer Minute, const Standard_Real Second);
//! Returns the string name for a given gravity.
//! @param Gravity gravity type
//! @return string identifier from the list Message_Trace, Message_Info, Message_Warning, Message_Alarm and Message_Fail
Standard_EXPORT static Standard_CString GravityToString (const Message_Gravity theGravity);
//! Returns the gravity type from the given string identifier (using case-insensitive comparison).
//! @param theGravityString string identifier
//! @return gravity or Message_Trace if string identifier is invalid
static Message_Gravity GravityFromString (const Standard_CString theGravityString)
{
Message_Gravity aGravity = Message_Trace;
GravityFromString (theGravityString, aGravity);
return aGravity;
}
//! Determines the gravity from the given string identifier (using case-insensitive comparison).
//! @param theGravityString string identifier
//! @param theGravity detected shape type
//! @return TRUE if string identifier is known
Standard_EXPORT static Standard_Boolean GravityFromString (const Standard_CString theGravityString,
Message_Gravity& theGravity);
//! Returns the string name for a perf meter mode.
//! @param theValue mode
//! @return string identifier
Standard_EXPORT static Standard_CString PerfMeterModeToString (const Message_PerfMeterMode theValue);
//! Returns the enum value from the given string identifier (using case-insensitive comparison).
//! @param theString string identifier
//! @return enum or Message_PerfMeterMode_None if string identifier is invalid
static Message_PerfMeterMode PerfMeterModeFromString (const Standard_CString theString)
{
Message_PerfMeterMode aValue = Message_PerfMeterMode_None;
PerfMeterModeFromString (theString, aValue);
return aValue;
}
//! Returns the enum value from the given string identifier (using case-insensitive comparison).
//! @param theString string identifier
//! @return enum or Message_PerfMeterMode_None if string identifier is invalid
//! @return TRUE if string identifier is known
Standard_EXPORT static Standard_Boolean PerfMeterModeFromString (const Standard_CString theString,
Message_PerfMeterMode& theValue);
//! Returns separator symbol of Dump information
static Standard_Character DumpSeparator() { return '\\'; }
//! Returns separator symbol of values vector union
static TCollection_AsciiString VectorSeparator() { return " ,"; }
//! Convert handle pointer to string value
//! \param thePointer a pointer
//! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
//! \return the string value
Standard_EXPORT static TCollection_AsciiString TransientToString (const Handle(Standard_Transient)& thePointer,
const bool isShortInfo = true);
//! Convert pointer to string value
//! \param thePointer a pointer
//! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
//! \return the string value
Standard_EXPORT static TCollection_AsciiString PointerToString (const void* thePointer,
const bool isShortInfo = true);
//! Convert vector of real values to string, separator is vector separator
//! \param thePointer a container of real values
//! \return the string value
Standard_EXPORT static TCollection_AsciiString StrVectorToString
(const NCollection_Vector<TCollection_AsciiString>& theValues);
//! Convert string to vector of real values, separator is vector separator
//! \param thePointer a container of real values
//! \return the string value
Standard_EXPORT static Standard_Boolean StrVectorFromString
(const TCollection_AsciiString& theValue,
NCollection_Vector<TCollection_AsciiString>& theValues);
//! Convert vector of real values to string, separator is vector separator
//! \param thePointer a container of real values
//! \return the string value
Standard_EXPORT static TCollection_AsciiString RealVectorToString
(const NCollection_Vector<Standard_Real>& theValues);
//! Convert string to vector of real values, separator is vector separator
//! \param thePointer a container of real values
//! \return the string value
Standard_EXPORT static Standard_Boolean RealVectorFromString
(const TCollection_AsciiString& theValue,
NCollection_Vector<Standard_Real>& theValues);
//! Convert vector of real values to string, separator is vector separator
//! \param thePointer a container of real values
//! \return the string value
Standard_EXPORT static TCollection_AsciiString CoordVectorToString
(const NCollection_Vector<Standard_Real>& theValues);
//! Convert string to vector of real values, separator is vector separator
//! \param thePointer a container of real values
//! \return the string value
Standard_EXPORT static Standard_Boolean CoordVectorFromString
(const TCollection_AsciiString& theValue,
NCollection_Vector<Standard_Real>& theValues);
//! Convert vector of real values to string, separator is vector separator
//! \param thePointer a container of real values
//! \return the string value
Standard_EXPORT static TCollection_AsciiString ColorVectorToString
(const NCollection_Vector<Standard_Real>& theValues);
//! Convert string to vector of real values, separator is vector separator
//! \param thePointer a container of real values
//! \return the string value
Standard_EXPORT static Standard_Boolean ColorVectorFromString
(const TCollection_AsciiString& theValue,
NCollection_Vector<Standard_Real>& theValues);
//! Converts stream to vector of values and column count
//! \param theStream stream value
//! \param theColumnCount [out] number of columns
//! \param theValues [out] container of split values
static Standard_EXPORT void ConvertStream (const Standard_SStream& theStream,
Standard_Integer& theColumnCount,
NCollection_Vector<TCollection_AsciiString>& theValues);
protected:

View File

@@ -0,0 +1,81 @@
// Created on: 2018-06-10
// Created by: Natalia Ermolaeva
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Message_AlertExtended.hxx>
#include <Message_Attribute.hxx>
#include <Message_CompositeAlerts.hxx>
#include <Message_Report.hxx>
#include <Precision.hxx>
#include <Standard_Assert.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Message_AlertExtended,Message_Alert)
//=======================================================================
//function : GetMessageKey
//purpose :
//=======================================================================
Standard_CString Message_AlertExtended::GetMessageKey () const
{
if (myAttribute.IsNull())
return Message_Alert::GetMessageKey();
return myAttribute->GetMessageKey();
}
//=======================================================================
//function : GetCompositeAlerts
//purpose :
//=======================================================================
Handle (Message_CompositeAlerts) Message_AlertExtended::GetCompositeAlerts (const Standard_Boolean isCreate)
{
if (myCompositAlerts.IsNull() && isCreate)
myCompositAlerts = new Message_CompositeAlerts();
return myCompositAlerts;
}
//=======================================================================
//function : IsMetricValid
//purpose :
//=======================================================================
Standard_Boolean Message_AlertExtended::IsMetricValid() const
{
return fabs (myMetricStart - GetUndefinedMetric()) > Precision::Confusion() &&
fabs (myMetricStop - GetUndefinedMetric()) > Precision::Confusion();
}
//=======================================================================
//function : AddAlert
//purpose :
//=======================================================================
Handle(Message_Alert) Message_AlertExtended::AddAlert (const Handle(Message_Report)& theReport,
const Handle(Message_Attribute)& theAttribute,
Message_PerfMeter* thePerfMeter,
const Handle(Message_Alert)& theParentAlert)
{
if (!theReport->IsActive (Message_Info))
return Handle(Message_Alert)();
Handle(Message_AlertExtended) anAlert = new Message_AlertExtended();
anAlert->SetAttribute (theAttribute);
theReport->AddAlert (Message_Info, anAlert, thePerfMeter, theParentAlert);
return anAlert;
}

View File

@@ -0,0 +1,133 @@
// Created on: 2018-06-10
// Created by: Natalia Ermolaeva
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Message_AlertExtended_HeaderFile
#define _Message_AlertExtended_HeaderFile
#include <Message_Alert.hxx>
#include <TCollection_AsciiString.hxx>
class Message_Attribute;
class Message_PerfMeter;
class Message_Report;
DEFINE_STANDARD_HANDLE(Message_AlertExtended, Message_Alert)
class Message_CompositeAlerts;
//! Inherited class of Message_Alert with some additional information.
//!
//! It has Message_Attributes to provide the alert name, description and
//! other custom information
//!
//! It is possible to set performance meter into alert to store time/memory metric information
//! spent between the next alert adding. Also time of child alerts are collected
//!
//! It has a container of composite alerts, if the alert might provide
//! sub-alerts collecting.
//!
class Message_AlertExtended : public Message_Alert
{
public:
//! Empty constructor
Standard_EXPORT Message_AlertExtended()
: Message_Alert(), myMetricStart (GetUndefinedMetric()), myMetricStop (GetUndefinedMetric()) {}
//! Return a C string to be used as a key for generating text user
//! messages describing this alert.
//! The messages are generated with help of Message_Msg class, in
//! Message_Report::Dump().
//! Base implementation returns dynamic type name of the instance.
virtual Standard_EXPORT Standard_CString GetMessageKey () const;
//! Sets container of the alert attributes
//! \param theAttributes an attribute values
void SetAttribute (const Handle(Message_Attribute)& theAttribute) { myAttribute = theAttribute; }
//! Returns container of the alert attributes
//! \param theAttributes an attribute values
const Handle(Message_Attribute)& Attribute () const { return myAttribute; }
//! Returns class provided hierarchy of alerts if created or create if the parameter is true
//! \param isCreate if composite alert has not been created for this alert, it should be created
//! \return instance or NULL
Standard_EXPORT Handle (Message_CompositeAlerts) GetCompositeAlerts (const Standard_Boolean isCreate = Standard_False);
//! Returns performance meter
//! \return instance or NULL
Message_PerfMeter* GetPerfMeter() { return myPerfMeter; }
//! Returns true if metric is computed
//! @return value
Standard_EXPORT Standard_Boolean IsMetricValid() const;
//! Returns the alert cumulative metric. It includes time/mem of sub alerts
//! @return value
Standard_Real MetricStart() const { return myMetricStart; }
//! Returns the alert cumulative metric. It includes time/mem of sub alerts
//! @return value
Standard_Real MetricStop() const { return myMetricStop; }
//! Sets cumulative time/mem of alert
//! \param theCumulativeMetric time/mem of the alert
void SetMetricValues (const Standard_Real theStartValue, const Standard_Real theStopValue)
{ myMetricStart = theStartValue; myMetricStop = theStopValue; }
//! Return true if this type of alert can be merged with other
//! of the same type to avoid duplication.
//! Basis implementation returns true.
virtual Standard_EXPORT Standard_Boolean SupportsMerge () const { return Standard_False; }
//! Returns default value of the time/mem when it is not defined
//! \return integer value
static Standard_Real GetUndefinedMetric() { return -1.0; }
//! Creates new instance of the alert and put it into report with Message_Info gravity.
//! It does nothing if such kind of gravity is not active in the report
//! @param theReport the message report where new alert is placed
//! @param theAttribute container of additional values of the alert
//! @param thePerfMeter performance meter calculates the alert spent time and participate in searching the last alert if needed
//! @param theParentAlert parent for the new alert, or alert is placed under the report
//! @return created alert or NULL if Message_Info is not active in report
static Standard_EXPORT Handle(Message_Alert) AddAlert (const Handle(Message_Report)& theReport,
const Handle(Message_Attribute)& theAttribute,
Message_PerfMeter* thePerfMeter,
const Handle(Message_Alert)& theParentAlert = Handle(Message_Alert)());
// OCCT RTTI
DEFINE_STANDARD_RTTIEXT(Message_AlertExtended, Message_Alert)
protected:
//! Sets performance meter
//! \param theMeter instance pointer or NULL
void SetPerfMeter (Message_PerfMeter* theMeter) { myPerfMeter = theMeter; }
protected:
Handle(Message_CompositeAlerts) myCompositAlerts; //!< class provided hierarchical structure of alerts
//!< It should be created by an attempt of a child alert creation
Handle(Message_Attribute) myAttribute; //!< container of the alert attributes
Message_PerfMeter* myPerfMeter; //!< performance meter
Standard_Real myMetricStart; //!< value on start metric computation
Standard_Real myMetricStop; //!< value on stop metric computation
friend Message_PerfMeter;
};
#endif // _Message_Alert_HeaderFile

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,192 @@
// 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>
#include <OSD_MemInfo.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,
const Message_PerfMeterMode theMode)
{
Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (theAlert);
if (anExtendedAlert.IsNull())
return;
if (myActiveAlerts.IsEmpty())
{
setAlert (0, theAlert, theMode);
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, theMode);
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,
const Message_PerfMeterMode theMode)
{
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, getCurrentInfo (theMode)));
anAlertExtended->SetPerfMeter (this);
myMode = theMode;
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->SetMetricValues (anAlertInfo.myStartValue, getCurrentInfo(myMode));
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 : getCurrentInfo
//purpose :
//=======================================================================
Standard_Real Message_PerfMeter::getCurrentInfo (const Message_PerfMeterMode theMode)
{
if (theMode == Message_PerfMeterMode_UserTimeCPU ||
theMode == Message_PerfMeterMode_SystemTimeInfo)
{
Standard_Real aUserSeconds, aSystemSeconds;
OSD_Chronometer::GetThreadCPU (aUserSeconds, aSystemSeconds);
return theMode == Message_PerfMeterMode_UserTimeCPU ? aUserSeconds : aSystemSeconds;
}
OSD_MemInfo::Counter aType;
switch (theMode)
{
case Message_PerfMeterMode_MemPrivate: aType = OSD_MemInfo::MemPrivate; break;
case Message_PerfMeterMode_MemVirtual: aType = OSD_MemInfo::MemVirtual; break;
case Message_PerfMeterMode_MemWorkingSet: aType = OSD_MemInfo::MemWorkingSet; break;
case Message_PerfMeterMode_MemWorkingSetPeak: aType = OSD_MemInfo::MemWorkingSetPeak; break;
case Message_PerfMeterMode_MemSwapUsage: aType = OSD_MemInfo::MemSwapUsage; break;
case Message_PerfMeterMode_MemSwapUsagePeak: aType = OSD_MemInfo::MemSwapUsagePeak; break;
case Message_PerfMeterMode_MemHeapUsage: aType = OSD_MemInfo::MemHeapUsage; break;
default: return Message_AlertExtended::GetUndefinedMetric(); break;
}
OSD_MemInfo aMemInfo (Standard_False);
aMemInfo.Update (aType);
return (Standard_Real)aMemInfo.ValuePreciseMiB (aType);
}

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