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

Coding - Apply .clang-format formatting #286

Update empty method guards to new style with regex (see PR).
Used clang-format 18.1.8.
New actions to validate code formatting is added.
Update .clang-format with disabling of include sorting.
  It is temporary changes, then include will be sorted.
Apply formatting for /src and /tools folder.
The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
dpasukhi
2025-01-25 20:15:22 +00:00
parent dbba6f1289
commit a5a7b3185b
14005 changed files with 1273539 additions and 1195567 deletions

View File

@@ -11,7 +11,7 @@
// 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.
// commercial license or contractual agreement.
#include <inspector/View_Displayer.hxx>
@@ -34,7 +34,9 @@
// purpose :
// =======================================================================
View_Displayer::View_Displayer()
: myIsKeepPresentations (false), myFitAllActive (false), myDisplayMode (0)
: myIsKeepPresentations(false),
myFitAllActive(false),
myDisplayMode(0)
{
myDisplayPreview = new View_DisplayPreview();
}
@@ -43,21 +45,26 @@ View_Displayer::View_Displayer()
// function : SetContext
// purpose :
// =======================================================================
void View_Displayer::SetContext (const Handle(AIS_InteractiveContext)& theContext)
void View_Displayer::SetContext(const Handle(AIS_InteractiveContext)& theContext)
{
NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive> > aDisplayed = myDisplayed;
EraseAllPresentations (true);
NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive>> aDisplayed =
myDisplayed;
EraseAllPresentations(true);
myContext = theContext;
for (NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive> >::Iterator aDisplayedIt(aDisplayed);
aDisplayedIt.More(); aDisplayedIt.Next())
for (NCollection_DataMap<View_PresentationType,
NCollection_Shared<AIS_ListOfInteractive>>::Iterator
aDisplayedIt(aDisplayed);
aDisplayedIt.More();
aDisplayedIt.Next())
{
View_PresentationType aType = aDisplayedIt.Key();
for (AIS_ListIteratorOfListOfInteractive aPresentationsIt (aDisplayedIt.Value());
aPresentationsIt.More(); aPresentationsIt.Next())
DisplayPresentation (aPresentationsIt.Value(), aType, false);
for (AIS_ListIteratorOfListOfInteractive aPresentationsIt(aDisplayedIt.Value());
aPresentationsIt.More();
aPresentationsIt.Next())
DisplayPresentation(aPresentationsIt.Value(), aType, false);
}
myDisplayPreview->SetContext (theContext);
myDisplayPreview->SetContext(theContext);
UpdateViewer();
}
@@ -65,19 +72,20 @@ void View_Displayer::SetContext (const Handle(AIS_InteractiveContext)& theContex
// function : SetDisplayMode
// purpose :
// =======================================================================
void View_Displayer::SetDisplayMode (const int theDisplayMode,
const View_PresentationType theType,
const bool theToUpdateViewer)
void View_Displayer::SetDisplayMode(const int theDisplayMode,
const View_PresentationType theType,
const bool theToUpdateViewer)
{
myDisplayMode = theDisplayMode;
if (GetContext().IsNull())
return;
NCollection_Shared<AIS_ListOfInteractive> aDisplayed;
DisplayedPresentations (aDisplayed, theType);
DisplayedPresentations(aDisplayed, theType);
for (AIS_ListIteratorOfListOfInteractive aDisplayedIt (aDisplayed); aDisplayedIt.More(); aDisplayedIt.Next())
GetContext()->SetDisplayMode (aDisplayedIt.Value(), theDisplayMode, Standard_False);
for (AIS_ListIteratorOfListOfInteractive aDisplayedIt(aDisplayed); aDisplayedIt.More();
aDisplayedIt.Next())
GetContext()->SetDisplayMode(aDisplayedIt.Value(), theDisplayMode, Standard_False);
if (theToUpdateViewer)
UpdateViewer();
@@ -87,38 +95,39 @@ void View_Displayer::SetDisplayMode (const int theDisplayMode,
// function : DisplayPresentation
// purpose :
// =======================================================================
void View_Displayer::DisplayPresentation (const Handle(Standard_Transient)& thePresentation,
const View_PresentationType theType,
const bool theToUpdateViewer)
void View_Displayer::DisplayPresentation(const Handle(Standard_Transient)& thePresentation,
const View_PresentationType theType,
const bool theToUpdateViewer)
{
if (GetContext().IsNull())
return;
NCollection_Shared<AIS_ListOfInteractive> aDisplayed;
DisplayedPresentations (aDisplayed, theType);
DisplayedPresentations(aDisplayed, theType);
if (!myIsKeepPresentations)
ErasePresentations (theType, false);
ErasePresentations(theType, false);
Handle(AIS_InteractiveObject) aPresentation = Handle(AIS_InteractiveObject)::DownCast (thePresentation);
Handle(AIS_InteractiveObject) aPresentation =
Handle(AIS_InteractiveObject)::DownCast(thePresentation);
if (!aPresentation.IsNull() && aPresentation->GetContext().IsNull())
{
// one presentation can not be shown in several contexts
if (theType == View_PresentationType_Additional)
{
Quantity_Color aColor;
if (myColorAttributes.Find (View_PresentationType_Additional, aColor))
aPresentation->SetColor (aColor);
if (myColorAttributes.Find(View_PresentationType_Additional, aColor))
aPresentation->SetColor(aColor);
}
GetContext()->Display (aPresentation, false);
GetContext()->Display(aPresentation, false);
if (myDisplayMode != -1)
GetContext()->SetDisplayMode (aPresentation, myDisplayMode, false);
aDisplayed.Append (aPresentation);
GetContext()->SetDisplayMode(aPresentation, myDisplayMode, false);
aDisplayed.Append(aPresentation);
}
if (myFitAllActive)
fitAllView();
myDisplayed.Bind (theType, aDisplayed);
myDisplayed.Bind(theType, aDisplayed);
if (theToUpdateViewer)
UpdateViewer();
@@ -128,14 +137,15 @@ void View_Displayer::DisplayPresentation (const Handle(Standard_Transient)& theP
// function : RedisplayPresentation
// purpose :
// =======================================================================
void View_Displayer::RedisplayPresentation (const Handle(Standard_Transient)& thePresentation,
const bool theToUpdateViewer)
void View_Displayer::RedisplayPresentation(const Handle(Standard_Transient)& thePresentation,
const bool theToUpdateViewer)
{
Handle(AIS_InteractiveObject) aPresentation = Handle(AIS_InteractiveObject)::DownCast (thePresentation);
Handle(AIS_InteractiveObject) aPresentation =
Handle(AIS_InteractiveObject)::DownCast(thePresentation);
if (aPresentation.IsNull() || aPresentation->GetContext().IsNull())
return;
GetContext()->Redisplay (aPresentation, false);
GetContext()->Redisplay(aPresentation, false);
if (myFitAllActive)
fitAllView();
@@ -148,11 +158,14 @@ void View_Displayer::RedisplayPresentation (const Handle(Standard_Transient)& th
// function : EraseAllPresentations
// purpose :
// =======================================================================
void View_Displayer::EraseAllPresentations (const bool theToUpdateViewer)
void View_Displayer::EraseAllPresentations(const bool theToUpdateViewer)
{
for (NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive> >::Iterator aDisplayedIt(myDisplayed);
aDisplayedIt.More(); aDisplayedIt.Next())
ErasePresentations (aDisplayedIt.Key(), false);
for (NCollection_DataMap<View_PresentationType,
NCollection_Shared<AIS_ListOfInteractive>>::Iterator
aDisplayedIt(myDisplayed);
aDisplayedIt.More();
aDisplayedIt.Next())
ErasePresentations(aDisplayedIt.Key(), false);
if (theToUpdateViewer)
UpdateViewer();
@@ -162,24 +175,26 @@ void View_Displayer::EraseAllPresentations (const bool theToUpdateViewer)
// function : ErasePresentations
// purpose :
// =======================================================================
void View_Displayer::ErasePresentations (const View_PresentationType theType, const bool theToUpdateViewer)
void View_Displayer::ErasePresentations(const View_PresentationType theType,
const bool theToUpdateViewer)
{
if (GetContext().IsNull())
return;
NCollection_Shared<AIS_ListOfInteractive> aDisplayed;
DisplayedPresentations (aDisplayed, theType);
DisplayedPresentations(aDisplayed, theType);
for (AIS_ListIteratorOfListOfInteractive aDisplayedIt (aDisplayed); aDisplayedIt.More(); aDisplayedIt.Next())
for (AIS_ListIteratorOfListOfInteractive aDisplayedIt(aDisplayed); aDisplayedIt.More();
aDisplayedIt.Next())
{
if (aDisplayedIt.Value()->IsKind(STANDARD_TYPE (AIS_Trihedron)))
if (aDisplayedIt.Value()->IsKind(STANDARD_TYPE(AIS_Trihedron)))
continue;
GetContext()->Remove (aDisplayedIt.Value(), Standard_False);
GetContext()->Remove(aDisplayedIt.Value(), Standard_False);
}
aDisplayed.Clear();
myDisplayed.Bind (theType, aDisplayed);
myDisplayed.Bind(theType, aDisplayed);
if (theToUpdateViewer)
UpdateViewer();
@@ -189,23 +204,24 @@ void View_Displayer::ErasePresentations (const View_PresentationType theType, co
// function : ErasePresentation
// purpose :
// =======================================================================
void View_Displayer::ErasePresentation (const Handle(Standard_Transient)& thePresentation,
const View_PresentationType theType,
const bool theToUpdateViewer)
void View_Displayer::ErasePresentation(const Handle(Standard_Transient)& thePresentation,
const View_PresentationType theType,
const bool theToUpdateViewer)
{
if (GetContext().IsNull())
return;
Handle(AIS_InteractiveObject) aPresentation = Handle(AIS_InteractiveObject)::DownCast (thePresentation);
Handle(AIS_InteractiveObject) aPresentation =
Handle(AIS_InteractiveObject)::DownCast(thePresentation);
if (aPresentation.IsNull())
return;
GetContext()->Remove (aPresentation, Standard_False);
GetContext()->Remove(aPresentation, Standard_False);
NCollection_Shared<AIS_ListOfInteractive> aDisplayed;
DisplayedPresentations (aDisplayed, theType);
aDisplayed.Remove (aPresentation);
myDisplayed.Bind (theType, aDisplayed);
DisplayedPresentations(aDisplayed, theType);
aDisplayed.Remove(aPresentation);
myDisplayed.Bind(theType, aDisplayed);
if (myFitAllActive)
fitAllView();
@@ -218,56 +234,59 @@ void View_Displayer::ErasePresentation (const Handle(Standard_Transient)& thePre
// function : DisplayDefaultTrihedron
// purpose :
// =======================================================================
void View_Displayer::DisplayDefaultTrihedron (const Standard_Boolean toDisplay, const bool theToUpdateViewer)
void View_Displayer::DisplayDefaultTrihedron(const Standard_Boolean toDisplay,
const bool theToUpdateViewer)
{
const Handle(AIS_Trihedron)& aTrihedron = defaultTrihedron (toDisplay);
const Handle(AIS_Trihedron)& aTrihedron = defaultTrihedron(toDisplay);
if (aTrihedron.IsNull())
return;
if (toDisplay)
GetContext()->Display (aTrihedron, theToUpdateViewer);
GetContext()->Display(aTrihedron, theToUpdateViewer);
else
GetContext()->Erase (aTrihedron, theToUpdateViewer);
GetContext()->Erase(aTrihedron, theToUpdateViewer);
}
// =======================================================================
// function : DisplayViewCube
// purpose :
// =======================================================================
void View_Displayer::DisplayViewCube (const Standard_Boolean toDisplay, const bool theToUpdateViewer)
void View_Displayer::DisplayViewCube(const Standard_Boolean toDisplay, const bool theToUpdateViewer)
{
if (myViewCube.IsNull() && toDisplay)
{
myViewCube = new AIS_ViewCube();
myViewCube->SetSize (35.0);
myViewCube->SetBoxColor (Quantity_NOC_GRAY50);
myViewCube->SetSize(35.0);
myViewCube->SetBoxColor(Quantity_NOC_GRAY50);
}
if (myViewCube.IsNull())
return;
if (toDisplay)
GetContext()->Display (myViewCube, theToUpdateViewer);
GetContext()->Display(myViewCube, theToUpdateViewer);
else
GetContext()->Erase (myViewCube, theToUpdateViewer);
GetContext()->Erase(myViewCube, theToUpdateViewer);
}
// =======================================================================
// function : SetVisible
// purpose :
// =======================================================================
void View_Displayer::SetVisible (const TopoDS_Shape& theShape, const bool theState, const View_PresentationType theType)
void View_Displayer::SetVisible(const TopoDS_Shape& theShape,
const bool theState,
const View_PresentationType theType)
{
if (theShape.IsNull())
return;
if (theState)
DisplayPresentation (CreatePresentation (theShape), View_PresentationType_Main, Standard_False);
DisplayPresentation(CreatePresentation(theShape), View_PresentationType_Main, Standard_False);
else
{
Handle(AIS_InteractiveObject) aPresentation = FindPresentation (theShape, theType);
Handle(AIS_InteractiveObject) aPresentation = FindPresentation(theShape, theType);
if (!aPresentation.IsNull())
ErasePresentation (aPresentation, theType, Standard_False);
ErasePresentation(aPresentation, theType, Standard_False);
}
UpdateViewer();
@@ -277,9 +296,10 @@ void View_Displayer::SetVisible (const TopoDS_Shape& theShape, const bool theSta
// function : IsVisible
// purpose :
// =======================================================================
bool View_Displayer::IsVisible (const TopoDS_Shape& theShape, const View_PresentationType theType) const
bool View_Displayer::IsVisible(const TopoDS_Shape& theShape,
const View_PresentationType theType) const
{
Handle(AIS_InteractiveObject) aPresentation = FindPresentation (theShape, theType);
Handle(AIS_InteractiveObject) aPresentation = FindPresentation(theShape, theType);
return !aPresentation.IsNull();
}
@@ -287,10 +307,11 @@ bool View_Displayer::IsVisible (const TopoDS_Shape& theShape, const View_Present
// function : UpdatePreview
// purpose :
// =======================================================================
void View_Displayer::UpdatePreview (const View_DisplayActionType theType,
const NCollection_List<Handle(Standard_Transient)>& thePresentations)
void View_Displayer::UpdatePreview(
const View_DisplayActionType theType,
const NCollection_List<Handle(Standard_Transient)>& thePresentations)
{
myDisplayPreview->UpdatePreview (theType, thePresentations);
myDisplayPreview->UpdatePreview(theType, thePresentations);
if (myFitAllActive)
fitAllView();
}
@@ -311,19 +332,21 @@ void View_Displayer::UpdateViewer()
// function : SetAttributeColor
// purpose :
// =======================================================================
void View_Displayer::SetAttributeColor (const Quantity_Color& theColor, const View_PresentationType theType)
void View_Displayer::SetAttributeColor(const Quantity_Color& theColor,
const View_PresentationType theType)
{
myColorAttributes.Bind (theType, theColor);
myColorAttributes.Bind(theType, theColor);
}
// =======================================================================
// function : DisplayedPresentations
// purpose :
// =======================================================================
void View_Displayer::DisplayedPresentations (NCollection_Shared<AIS_ListOfInteractive>& thePresentations,
const View_PresentationType theType) const
void View_Displayer::DisplayedPresentations(
NCollection_Shared<AIS_ListOfInteractive>& thePresentations,
const View_PresentationType theType) const
{
myDisplayed.Find (theType, thePresentations);
myDisplayed.Find(theType, thePresentations);
}
// =======================================================================
@@ -351,19 +374,21 @@ Handle(V3d_View) View_Displayer::GetView() const
// function : FindPresentation
// purpose :
// =======================================================================
Handle(AIS_InteractiveObject) View_Displayer::FindPresentation (const TopoDS_Shape& theShape,
const View_PresentationType theType) const
Handle(AIS_InteractiveObject) View_Displayer::FindPresentation(
const TopoDS_Shape& theShape,
const View_PresentationType theType) const
{
if (theShape.IsNull())
return Handle(AIS_InteractiveObject)();
NCollection_Shared<AIS_ListOfInteractive> aDisplayed;
DisplayedPresentations (aDisplayed, theType);
DisplayedPresentations(aDisplayed, theType);
for (AIS_ListIteratorOfListOfInteractive aDisplayedIt (aDisplayed); aDisplayedIt.More(); aDisplayedIt.Next())
for (AIS_ListIteratorOfListOfInteractive aDisplayedIt(aDisplayed); aDisplayedIt.More();
aDisplayedIt.Next())
{
Handle(AIS_Shape) aPresentation = Handle(AIS_Shape)::DownCast (aDisplayedIt.Value());
if (aPresentation->Shape().IsEqual (theShape))
Handle(AIS_Shape) aPresentation = Handle(AIS_Shape)::DownCast(aDisplayedIt.Value());
if (aPresentation->Shape().IsEqual(theShape))
return aPresentation;
}
@@ -374,10 +399,10 @@ Handle(AIS_InteractiveObject) View_Displayer::FindPresentation (const TopoDS_Sha
// function : CreatePresentation
// purpose :
// =======================================================================
Handle(Standard_Transient) View_Displayer::CreatePresentation (const TopoDS_Shape& theShape)
Handle(Standard_Transient) View_Displayer::CreatePresentation(const TopoDS_Shape& theShape)
{
Handle(AIS_Shape) aPresentation = new AIS_Shape (theShape);
aPresentation->Attributes()->SetAutoTriangulation (Standard_False);
Handle(AIS_Shape) aPresentation = new AIS_Shape(theShape);
aPresentation->Attributes()->SetAutoTriangulation(Standard_False);
return aPresentation;
}
@@ -386,7 +411,7 @@ Handle(Standard_Transient) View_Displayer::CreatePresentation (const TopoDS_Shap
// function : fitAllView
// purpose :
// =======================================================================
void View_Displayer::fitAllView()
void View_Displayer::fitAllView()
{
Handle(V3d_View) aView = GetView();
if (!aView.IsNull())
@@ -400,12 +425,12 @@ void View_Displayer::fitAllView()
// function : defaultTrihedron
// purpose :
// =======================================================================
const Handle(AIS_Trihedron)& View_Displayer::defaultTrihedron (const bool toCreate)
const Handle(AIS_Trihedron)& View_Displayer::defaultTrihedron(const bool toCreate)
{
if (myDefaultTrihedron.IsNull() && toCreate)
{
myDefaultTrihedron = new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY()));
myDefaultTrihedron->SetSize (1);
myDefaultTrihedron = new AIS_Trihedron(new Geom_Axis2Placement(gp::XOY()));
myDefaultTrihedron->SetSize(1);
}
return myDefaultTrihedron;
}