1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-06-30 12:14:08 +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

@ -30,11 +30,12 @@ PackConstructorInitializers: Never
PointerAlignment: Left
ReferenceAlignment: Left
SeparateDefinitionBlocks: Always
SortIncludes: true
SortIncludes: false
UseTab: Never
#
# OCCT specific settings
StatementMacros:
- Standard_FALLTHROUGH
- Standard_DEPRECATED
TypenameMacros:
- Handle

View File

@ -0,0 +1,84 @@
# This workflow checks the code formatting of changed files in a pull request using clang-format.
# It is triggered on pull requests to the master branch.
# The workflow verifies that the clang-format version matches 18.1.8,
# checks formatting of modified files, and if formatting issues are found,
# creates a patch file that can be applied to fix the formatting.
name: Clang-Format Check
on:
pull_request:
branches:
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
format-check:
name: Check code formatting
runs-on: windows-2022
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0
- name: Check clang-format version
run: |
$version = clang-format --version
Write-Output "Detected clang-format version: $version"
$version | Select-String "18.1.8" >$null
if ($LASTEXITCODE -ne 0) {
echo "::error::Wrong clang-format version. Expected 18.1.8"
Write-Output "Error: Version mismatch - expected 18.1.8"
exit 1
}
shell: pwsh
- name: Get changed files
id: changed-files
run: |
$changedFiles = git diff --name-only origin/${{ github.base_ref }} HEAD |
Where-Object { $_ -match '^(src|tools)/' -and $_ -match '\.(cpp|hxx|cxx|lxx|h|pxx|hpp)$' }
$changedFiles | Set-Content "changed_files.txt"
if ($changedFiles.Count -gt 0) {
echo "has_files=true" >> $env:GITHUB_OUTPUT
}
shell: pwsh
- name: Check formatting
id: check
if: steps.changed-files.outputs.has_files == 'true'
run: |
$files = Get-Content "changed_files.txt"
$files | ForEach-Object -ThrottleLimit 8 -Parallel {
clang-format -i -style=file $_
}
shell: pwsh
- name: Check git status
id: git-check
if: steps.changed-files.outputs.has_files == 'true'
run: |
git diff > format.patch
if ((Get-Item format.patch).length -gt 0) {
echo "has_changes=true" >> $env:GITHUB_OUTPUT
}
shell: pwsh
- name: Upload patch
if: steps.git-check.outputs.has_changes == 'true'
uses: actions/upload-artifact@v4
with:
name: format-patch
path: format.patch
- name: Fail with instructions
if: steps.git-check.outputs.has_changes == 'true'
run: |
echo "::error::Files need formatting. To fix: 1. Download format.patch 2. "git apply format.patch" 3. Commit and push"
exit 1
shell: pwsh

View File

@ -21,58 +21,64 @@
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
//! Application Interactive Services provide the means to create links between an application GUI viewer and
//! the packages which are used to manage selection and presentation.
//! The tools AIS defined in order to do this include different sorts of entities:
//! both the selectable viewable objects themselves and the context and attribute managers to define their selection and display.
//! To orient the user as he works in a modeling environment, views and selections must be comprehensible.
//! There must be several different sorts of selectable and viewable object defined.
//! These must also be interactive, that is, connecting graphic representation and the underlying reference geometry.
//! These entities are called Interactive Objects, and are divided into four types:
//! Application Interactive Services provide the means to create links between an application GUI
//! viewer and the packages which are used to manage selection and presentation. The tools AIS
//! defined in order to do this include different sorts of entities: both the selectable viewable
//! objects themselves and the context and attribute managers to define their selection and display.
//! To orient the user as he works in a modeling environment, views and selections must be
//! comprehensible. There must be several different sorts of selectable and viewable object defined.
//! These must also be interactive, that is, connecting graphic representation and the underlying
//! reference geometry. These entities are called Interactive Objects, and are divided into four
//! types:
//! - the Datum
//! - the Relation
//! - the Object
//! - None.
//! The Datum groups together the construction elements such as lines, circles, points, trihedra, plane trihedra, planes and axes.
//! The Relation is made up of constraints on one or more interactive shapes and the corresponding reference geometry.
//! For example, you might want to constrain two edges in a parallel relation.
//! This constraint is considered as an object in its own right, and is shown as a sensitive primitive.
//! This takes the graphic form of a perpendicular arrow marked with the || symbol and lying between the two edges.
//! The Object type includes topological shapes, and connections between shapes.
//! None, in order not to eliminate the object, tells the application to look further until it finds an object definition in its generation which is accepted.
//! Inside these categories, you have the possibility of an additional characterization by means of a signature.
//! The signature provides an index to the further characterization.
//! By default, the Interactive Object has a None type and a signature of 0 (equivalent to None.)
//! If you want to give a particular type and signature to your interactive object, you must redefine the two virtual methods: Type and Signature.
//! In the C++ inheritance structure of the package, each class representing a specific Interactive Object inherits AIS_InteractiveObject.
//! Among these inheriting classes, AIS_Relation functions as the abstract mother class for tinheriting classes defining display of specific relational constraints and types of dimension.
//! Some of these include:
//! - display of constraints based on relations of symmetry, tangency, parallelism and concentricity
//! The Datum groups together the construction elements such as lines, circles, points, trihedra,
//! plane trihedra, planes and axes. The Relation is made up of constraints on one or more
//! interactive shapes and the corresponding reference geometry. For example, you might want to
//! constrain two edges in a parallel relation. This constraint is considered as an object in its
//! own right, and is shown as a sensitive primitive. This takes the graphic form of a perpendicular
//! arrow marked with the || symbol and lying between the two edges. The Object type includes
//! topological shapes, and connections between shapes. None, in order not to eliminate the object,
//! tells the application to look further until it finds an object definition in its generation
//! which is accepted. Inside these categories, you have the possibility of an additional
//! characterization by means of a signature. The signature provides an index to the further
//! characterization. By default, the Interactive Object has a None type and a signature of 0
//! (equivalent to None.) If you want to give a particular type and signature to your interactive
//! object, you must redefine the two virtual methods: Type and Signature. In the C++ inheritance
//! structure of the package, each class representing a specific Interactive Object inherits
//! AIS_InteractiveObject. Among these inheriting classes, AIS_Relation functions as the abstract
//! mother class for tinheriting classes defining display of specific relational constraints and
//! types of dimension. Some of these include:
//! - display of constraints based on relations of symmetry, tangency, parallelism and
//! concentricity
//! - display of dimensions for angles, offsets, diameters, radii and chamfers.
//! No viewer can show everything at once with any coherence or clarity.
//! Views must be managed carefully both sequentially and at any given instant.
//! Another function of the view is that of a context to carry out design in.
//! The design changes are applied to the objects in the view and then extended to the underlying reference geometry by a solver.
//! To make sense of this complicated visual data, several display and selection tools are required.
//! To facilitate management, each object and each construction element has a selection priority.
//! There are also means to modify the default priority.
//! To define an environment of dynamic detection, you can use standard filter classes or create your own.
//! A filter questions the owner of the sensitive primitive to determine if it has the desired qualities.
//! If it answers positively, it is kept. If not, it is rejected.
//! The standard filters supplied in AIS include:
//! The design changes are applied to the objects in the view and then extended to the underlying
//! reference geometry by a solver. To make sense of this complicated visual data, several display
//! and selection tools are required. To facilitate management, each object and each construction
//! element has a selection priority. There are also means to modify the default priority. To define
//! an environment of dynamic detection, you can use standard filter classes or create your own. A
//! filter questions the owner of the sensitive primitive to determine if it has the desired
//! qualities. If it answers positively, it is kept. If not, it is rejected. The standard filters
//! supplied in AIS include:
//! - AIS_AttributeFilter
//! - AIS_SignatureFilter
//! - AIS_TypeFilter.
//! A set of functions allows you to choose the interactive objects which you want to act on, the selection modes which you want to activate.
//! An interactive object can have a certain number of graphic attributes which are specific to it, such as visualization mode, color, and material.
//! By the same token, the interactive context has a set of graphic attributes, the Drawer which is valid by default for the objects it controls.
//! When an interactive object is visualized, the required graphic attributes are first taken from the object's own Drawer if one exists, or from the context drawer for the others.
//! A set of functions allows you to choose the interactive objects which you want to act on, the
//! selection modes which you want to activate. An interactive object can have a certain number of
//! graphic attributes which are specific to it, such as visualization mode, color, and material. By
//! the same token, the interactive context has a set of graphic attributes, the Drawer which is
//! valid by default for the objects it controls. When an interactive object is visualized, the
//! required graphic attributes are first taken from the object's own Drawer if one exists, or from
//! the context drawer for the others.
class AIS
{
public:
DEFINE_STANDARD_ALLOC
};
#endif // _AIS_HeaderFile

View File

@ -18,10 +18,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Animation, Standard_Transient)
//=============================================================================
//function : Constructor
//purpose :
//=============================================================================
//=================================================================================================
AIS_Animation::AIS_Animation(const TCollection_AsciiString& theAnimationName)
: myName(theAnimationName),
myState(AnimationState_Stopped),
@ -32,29 +30,23 @@ AIS_Animation::AIS_Animation (const TCollection_AsciiString& theAnimationName)
//
}
//=============================================================================
//function : ~AIS_Animation
//purpose :
//=============================================================================
//=================================================================================================
AIS_Animation::~AIS_Animation()
{
Clear();
}
//=============================================================================
//function : Clear
//purpose :
//=============================================================================
//=================================================================================================
void AIS_Animation::Clear()
{
myAnimations.Clear();
myOwnDuration = 0.0;
}
//=============================================================================
//function : Add
//purpose :
//=============================================================================
//=================================================================================================
void AIS_Animation::Add(const Handle(AIS_Animation)& theAnimation)
{
if (theAnimation.IsNull())
@ -62,7 +54,8 @@ void AIS_Animation::Add (const Handle(AIS_Animation)& theAnimation)
throw Standard_ProgramError("AIS_Animation::Add() - attempt to add a NULL animation!");
}
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{
if (anIter.Value() == theAnimation)
{
@ -75,13 +68,12 @@ void AIS_Animation::Add (const Handle(AIS_Animation)& theAnimation)
UpdateTotalDuration();
}
//=============================================================================
//function : Find
//purpose :
//=============================================================================
//=================================================================================================
Handle(AIS_Animation) AIS_Animation::Find(const TCollection_AsciiString& theAnimationName) const
{
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{
if (anIter.Value()->Name() == theAnimationName)
{
@ -91,13 +83,12 @@ Handle(AIS_Animation) AIS_Animation::Find (const TCollection_AsciiString& theAni
return Handle(AIS_Animation)();
}
//=============================================================================
//function : Remove
//purpose :
//=============================================================================
//=================================================================================================
Standard_Boolean AIS_Animation::Remove(const Handle(AIS_Animation)& theAnimation)
{
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{
if (anIter.Value() == theAnimation)
{
@ -109,14 +100,13 @@ Standard_Boolean AIS_Animation::Remove (const Handle(AIS_Animation)& theAnimatio
return Standard_False;
}
//=============================================================================
//function : Replace
//purpose :
//=============================================================================
//=================================================================================================
Standard_Boolean AIS_Animation::Replace(const Handle(AIS_Animation)& theAnimationOld,
const Handle(AIS_Animation)& theAnimationNew)
{
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{
if (anIter.Value() == theAnimationOld)
{
@ -128,14 +118,14 @@ Standard_Boolean AIS_Animation::Replace (const Handle(AIS_Animation)& theAnimati
return Standard_False;
}
//=============================================================================
//function : CopyFrom
//purpose :
//=============================================================================
//=================================================================================================
void AIS_Animation::CopyFrom(const Handle(AIS_Animation)& theOther)
{
myAnimations.Clear();
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (theOther->myAnimations); anIter.More(); anIter.Next())
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(theOther->myAnimations);
anIter.More();
anIter.Next())
{
myAnimations.Append(anIter.Value());
}
@ -144,23 +134,21 @@ void AIS_Animation::CopyFrom (const Handle(AIS_Animation)& theOther)
myOwnDuration = theOther->myOwnDuration;
}
//=============================================================================
//function : UpdateTotalDuration
//purpose :
//=============================================================================
//=================================================================================================
void AIS_Animation::UpdateTotalDuration()
{
myChildrenDuration = 0.0;
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{
myChildrenDuration = Max (myChildrenDuration, anIter.Value()->StartPts() + anIter.Value()->Duration());
myChildrenDuration =
Max(myChildrenDuration, anIter.Value()->StartPts() + anIter.Value()->Duration());
}
}
//=============================================================================
//function : StartTimer
//purpose :
//=============================================================================
//=================================================================================================
void AIS_Animation::StartTimer(const Standard_Real theStartPts,
const Standard_Real thePlaySpeed,
const Standard_Boolean theToUpdate,
@ -181,10 +169,8 @@ void AIS_Animation::StartTimer (const Standard_Real theStartPts,
}
}
//=============================================================================
//function : UpdateTimer
//purpose :
//=============================================================================
//=================================================================================================
Standard_Real AIS_Animation::UpdateTimer()
{
if (myTimer.IsNull())
@ -197,24 +183,21 @@ Standard_Real AIS_Animation::UpdateTimer()
return anElapsedTime;
}
//=============================================================================
//function : Start
//purpose :
//=============================================================================
//=================================================================================================
void AIS_Animation::Start(const Standard_Boolean theToUpdate)
{
UpdateTotalDuration();
myState = AnimationState_Started;
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{
anIter.ChangeValue()->Start(Standard_False);
}
if (theToUpdate)
{
const Standard_Real anElapsedTime = !myTimer.IsNull()
? myTimer->ElapsedTime()
: 0.0;
const Standard_Real anElapsedTime = !myTimer.IsNull() ? myTimer->ElapsedTime() : 0.0;
Update(anElapsedTime);
}
@ -224,10 +207,8 @@ void AIS_Animation::Start (const Standard_Boolean theToUpdate)
}
}
//=============================================================================
//function : Pause
//purpose :
//=============================================================================
//=================================================================================================
void AIS_Animation::Pause()
{
myState = AnimationState_Paused;
@ -236,16 +217,15 @@ void AIS_Animation::Pause()
myTimer->Pause();
}
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{
anIter.ChangeValue()->Stop();
}
}
//=============================================================================
//function : Stop
//purpose :
//=============================================================================
//=================================================================================================
void AIS_Animation::Stop()
{
myState = AnimationState_Stopped;
@ -256,50 +236,44 @@ void AIS_Animation::Stop()
myTimer->Seek(Min(Duration(), anElapsedTime));
}
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{
anIter.ChangeValue()->Stop();
}
}
//=============================================================================
//function : Update
//purpose :
//=============================================================================
//=================================================================================================
Standard_Boolean AIS_Animation::Update(const Standard_Real thePts)
{
AIS_AnimationProgress aPosition;
aPosition.Pts = thePts;
aPosition.LocalPts = thePts - myPtsStart;
aPosition.LocalNormalized = HasOwnDuration()
? (aPosition.LocalPts / myOwnDuration)
: 0.0;
aPosition.LocalNormalized = HasOwnDuration() ? (aPosition.LocalPts / myOwnDuration) : 0.0;
aPosition.LocalNormalized = Max(0.0, aPosition.LocalNormalized);
aPosition.LocalNormalized = Min(1.0, aPosition.LocalNormalized);
updateWithChildren(aPosition);
return thePts < myPtsStart + Duration();
}
//=============================================================================
//function : updateWithChildren
//purpose :
//=============================================================================
//=================================================================================================
void AIS_Animation::updateWithChildren(const AIS_AnimationProgress& thePosition)
{
if (thePosition.LocalPts < 0.0
|| IsStopped())
if (thePosition.LocalPts < 0.0 || IsStopped())
{
return;
}
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter(myAnimations); anIter.More();
anIter.Next())
{
const Handle(AIS_Animation)& anAnim = anIter.Value();
AIS_AnimationProgress aPosition = thePosition;
aPosition.LocalPts = aPosition.LocalPts - anAnim->StartPts();
aPosition.LocalNormalized = anAnim->HasOwnDuration()
? (aPosition.LocalPts / anAnim->OwnDuration())
: 0.0;
aPosition.LocalNormalized =
anAnim->HasOwnDuration() ? (aPosition.LocalPts / anAnim->OwnDuration()) : 0.0;
aPosition.LocalNormalized = Max(0.0, aPosition.LocalNormalized);
aPosition.LocalNormalized = Min(1.0, aPosition.LocalNormalized);
anAnim->updateWithChildren(aPosition);

View File

@ -28,7 +28,12 @@ struct AIS_AnimationProgress
Standard_Real LocalNormalized; //!< normalized position within current animation within 0..1 range
// clang-format on
AIS_AnimationProgress() : Pts (-1.0), LocalPts (-1.0), LocalNormalized (-1.0) {}
AIS_AnimationProgress()
: Pts(-1.0),
LocalPts(-1.0),
LocalNormalized(-1.0)
{
}
};
DEFINE_STANDARD_HANDLE(AIS_Animation, Standard_Transient)
@ -38,36 +43,41 @@ DEFINE_STANDARD_HANDLE(AIS_Animation, Standard_Transient)
//!
//! - Animation Implementor
//! Sub-classes should override method AIS_Animation::update() to perform specific animation.
//! AIS package provides limited number of such animation atoms - classes AIS_AnimationObject and AIS_AnimationCamera, which could be enough for defining a simple animation.
//! In general case, application is expected defining own AIS_Animation sub-classes implementing application-specific animation logic
//! (e.g. another interpolation or another kind of transformations - like color transition and others).
//! The basic conception of AIS_Animation::update() is defining an exact scene state for the current presentation timestamp,
//! providing a smooth and continuous animation well defined at any time step and in any direction.
//! So that a time difference between two sequential drawn Viewer frames can vary from frame to frame without visual artifacts,
//! increasing rendering framerate would not lead to animation being executed too fast
//! and low framerate (on slow hardware) would not lead to animation played longer than defined duration.
//! Hence, implementation should avoid usage of incremental step logic or should apply it very carefully.
//! AIS package provides limited number of such animation atoms - classes AIS_AnimationObject and
//! AIS_AnimationCamera, which could be enough for defining a simple animation. In general case,
//! application is expected defining own AIS_Animation sub-classes implementing
//! application-specific animation logic (e.g. another interpolation or another kind of
//! transformations - like color transition and others). The basic conception of
//! AIS_Animation::update() is defining an exact scene state for the current presentation
//! timestamp, providing a smooth and continuous animation well defined at any time step and in
//! any direction. So that a time difference between two sequential drawn Viewer frames can vary
//! from frame to frame without visual artifacts, increasing rendering framerate would not lead to
//! animation being executed too fast and low framerate (on slow hardware) would not lead to
//! animation played longer than defined duration. Hence, implementation should avoid usage of
//! incremental step logic or should apply it very carefully.
//!
//! - Animation Container
//! AIS_Animation (no sub-classing) can be used to aggregate a sequence of Animation items (children).
//! Each children should be defined with its own duration and start time (presentation timestamp).
//! It is possible defining collection of nested AIS_Animation items, so that within each container level
//! children define start playback time relative to its holder.
//! AIS_Animation (no sub-classing) can be used to aggregate a sequence of Animation items
//! (children). Each children should be defined with its own duration and start time (presentation
//! timestamp). It is possible defining collection of nested AIS_Animation items, so that within
//! each container level children define start playback time relative to its holder.
//!
//! - Animation playback Controller
//! It is suggested that application would define a single AIS_Animation instance (optional sub-classing) for controlling animation playback as whole.
//! Such controller should be filled in by other AIS_Animation as children objects,
//! and will be managed by application by calling StartTimer(), UpdateTimer() and IsStopped() methods.
//! It is suggested that application would define a single AIS_Animation instance (optional
//! sub-classing) for controlling animation playback as whole. Such controller should be filled in
//! by other AIS_Animation as children objects, and will be managed by application by calling
//! StartTimer(), UpdateTimer() and IsStopped() methods.
//!
//! Note, that AIS_Animation::StartTimer() defines a timer calculating an elapsed time, not a multimedia timer executing Viewer updates at specific intervals!
//! Application should avoid using implicit and immediate Viewer updates to ensure that AIS_Animation::UpdateTimer() is called before each redrawing of a Viewer content.
//! Redrawing logic should be also managed at application level for managing a smooth animation
//! (by defining a multimedia timer provided by used GUI framework executing updates at desired framerate, or as continuous redraws in loop).
//! Note, that AIS_Animation::StartTimer() defines a timer calculating an elapsed time, not a
//! multimedia timer executing Viewer updates at specific intervals! Application should avoid using
//! implicit and immediate Viewer updates to ensure that AIS_Animation::UpdateTimer() is called
//! before each redrawing of a Viewer content. Redrawing logic should be also managed at application
//! level for managing a smooth animation (by defining a multimedia timer provided by used GUI
//! framework executing updates at desired framerate, or as continuous redraws in loop).
class AIS_Animation : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(AIS_Animation, Standard_Transient)
public:
//! Creates empty animation.
Standard_EXPORT AIS_Animation(const TCollection_AsciiString& theAnimationName);
@ -78,7 +88,6 @@ public:
const TCollection_AsciiString& Name() const { return myName; }
public:
//! @return start time of the animation in the timeline
Standard_Real StartPts() const { return myPtsStart; }
@ -125,13 +134,14 @@ public:
const NCollection_Sequence<Handle(AIS_Animation)>& Children() const { return myAnimations; }
public:
//! Start animation with internally defined timer instance.
//! Calls ::Start() internally.
//!
//! Note, that this method initializes a timer calculating an elapsed time (presentation timestamps within AIS_Animation::UpdateTimer()),
//! not a multimedia timer executing Viewer updates at specific intervals!
//! Viewer redrawing should be managed at application level, so that AIS_Animation::UpdateTimer() is called once right before each redrawing of a Viewer content.
//! Note, that this method initializes a timer calculating an elapsed time (presentation
//! timestamps within AIS_Animation::UpdateTimer()), not a multimedia timer executing Viewer
//! updates at specific intervals! Viewer redrawing should be managed at application level, so
//! that AIS_Animation::UpdateTimer() is called once right before each redrawing of a Viewer
//! content.
//!
//! @param theStartPts starting timer position (presentation timestamp)
//! @param thePlaySpeed playback speed (1.0 means normal speed)
@ -156,7 +166,6 @@ public:
void SetTimer(const Handle(Media_Timer)& theTimer) { myTimer = theTimer; }
public:
//! Start animation. This method changes status of the animation to Started.
//! This status defines whether animation is to be performed in the timeline or not.
//! @param theToUpdate call Update() method
@ -179,16 +188,14 @@ public:
Standard_EXPORT virtual Standard_Boolean Update(const Standard_Real thePts);
protected:
//! Process one step of the animation according to the input time progress, including all children.
//! Calls also ::update() to update own animation.
//! Process one step of the animation according to the input time progress, including all
//! children. Calls also ::update() to update own animation.
Standard_EXPORT virtual void updateWithChildren(const AIS_AnimationProgress& thePosition);
//! Update the own animation to specified position - should be overridden by sub-class.
virtual void update(const AIS_AnimationProgress& theProgress) { (void)theProgress; }
protected:
//! Defines animation state.
enum AnimationState
{
@ -198,18 +205,15 @@ protected:
};
protected:
Handle(Media_Timer) myTimer;
TCollection_AsciiString myName; //!< animation name
NCollection_Sequence<Handle(AIS_Animation)>
myAnimations; //!< sequence of child animations
NCollection_Sequence<Handle(AIS_Animation)> myAnimations; //!< sequence of child animations
AnimationState myState; //!< animation state - started, stopped of paused
Standard_Real myPtsStart; //!< time of start in the timeline
Standard_Real myOwnDuration; //!< duration of animation excluding children
Standard_Real myChildrenDuration; //!< duration of animation including children
};
#endif // _AIS_Animation_HeaderFile

View File

@ -15,11 +15,10 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject)
//=============================================================================
//function : Constructor
//purpose :
//=============================================================================
AIS_AnimationAxisRotation::AIS_AnimationAxisRotation (const TCollection_AsciiString& theAnimationName,
//=================================================================================================
AIS_AnimationAxisRotation::AIS_AnimationAxisRotation(
const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject,
const gp_Ax1& theAxis,
@ -33,10 +32,8 @@ AIS_AnimationAxisRotation::AIS_AnimationAxisRotation (const TCollection_AsciiStr
//
}
//=============================================================================
//function : update
//purpose :
//=============================================================================
//=================================================================================================
void AIS_AnimationAxisRotation::update(const AIS_AnimationProgress& theProgress)
{
if (myObject.IsNull())
@ -45,7 +42,8 @@ void AIS_AnimationAxisRotation::update (const AIS_AnimationProgress& theProgress
}
gp_Trsf aTrsf;
Standard_Real aCurrentAngle = (1.0 - theProgress.LocalNormalized) * myAngleStart + theProgress.LocalNormalized * myAngleEnd;
Standard_Real aCurrentAngle =
(1.0 - theProgress.LocalNormalized) * myAngleStart + theProgress.LocalNormalized * myAngleEnd;
aTrsf.SetRotation(myRotAxis, aCurrentAngle);
updateTrsf(aTrsf);
}

View File

@ -22,7 +22,6 @@ class AIS_AnimationAxisRotation : public AIS_BaseAnimationObject
{
DEFINE_STANDARD_RTTIEXT(AIS_AnimationAxisRotation, AIS_BaseAnimationObject)
public:
//! Constructor with initialization.
//! @param[in] theAnimationName animation identifier
//! @param[in] theContext interactive context where object have been displayed
@ -38,16 +37,13 @@ public:
const Standard_Real theAngleEnd);
protected:
//! Update the progress.
Standard_EXPORT virtual void update(const AIS_AnimationProgress& theProgress) Standard_OVERRIDE;
private:
gp_Ax1 myRotAxis; //!< rotation axis
Standard_Real myAngleStart; //!< start angle for rotation
Standard_Real myAngleEnd; //!< end angle for rotation
};
#endif // _AIS_AnimationAxisRotation_HeaderFile

View File

@ -18,10 +18,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationCamera, AIS_Animation)
//=============================================================================
//function : AIS_AnimationCamera
//purpose :
//=============================================================================
//=================================================================================================
AIS_AnimationCamera::AIS_AnimationCamera(const TCollection_AsciiString& theAnimationName,
const Handle(V3d_View)& theView)
: AIS_Animation(theAnimationName),
@ -30,15 +28,11 @@ AIS_AnimationCamera::AIS_AnimationCamera (const TCollection_AsciiString& theAnim
//
}
//=============================================================================
//function : update
//purpose :
//=============================================================================
//=================================================================================================
void AIS_AnimationCamera::update(const AIS_AnimationProgress& theProgress)
{
if (myView.IsNull()
|| myCamStart.IsNull()
|| myCamEnd.IsNull())
if (myView.IsNull() || myCamStart.IsNull() || myCamEnd.IsNull())
{
return;
}

View File

@ -25,7 +25,6 @@ class AIS_AnimationCamera : public AIS_Animation
{
DEFINE_STANDARD_RTTIEXT(AIS_AnimationCamera, AIS_Animation)
public:
//! Main constructor.
Standard_EXPORT AIS_AnimationCamera(const TCollection_AsciiString& theAnimationName,
const Handle(V3d_View)& theView);
@ -40,7 +39,10 @@ public:
const Handle(Graphic3d_Camera)& CameraStart() const { return myCamStart; }
//! Define camera start position.
void SetCameraStart (const Handle(Graphic3d_Camera)& theCameraStart) { myCamStart = theCameraStart; }
void SetCameraStart(const Handle(Graphic3d_Camera)& theCameraStart)
{
myCamStart = theCameraStart;
}
//! Return camera end position.
const Handle(Graphic3d_Camera)& CameraEnd() const { return myCamEnd; }
@ -49,16 +51,13 @@ public:
void SetCameraEnd(const Handle(Graphic3d_Camera)& theCameraEnd) { myCamEnd = theCameraEnd; }
protected:
//! Update the progress.
Standard_EXPORT virtual void update(const AIS_AnimationProgress& theProgress) Standard_OVERRIDE;
protected:
Handle(V3d_View) myView; //!< view to setup camera
Handle(Graphic3d_Camera) myCamStart; //!< starting camera position
Handle(Graphic3d_Camera) myCamEnd; //!< end camera position
};
DEFINE_STANDARD_HANDLE(AIS_AnimationCamera, AIS_Animation)

View File

@ -16,10 +16,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_BaseAnimationObject)
//=============================================================================
//function : Constructor
//purpose :
//=============================================================================
//=================================================================================================
AIS_AnimationObject::AIS_AnimationObject(const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject,
@ -31,10 +29,8 @@ AIS_AnimationObject::AIS_AnimationObject (const TCollection_AsciiString& theAnim
//
}
//=============================================================================
//function : update
//purpose :
//=============================================================================
//=================================================================================================
void AIS_AnimationObject::update(const AIS_AnimationProgress& theProgress)
{
if (myObject.IsNull())

View File

@ -23,14 +23,14 @@ class AIS_AnimationObject : public AIS_BaseAnimationObject
{
DEFINE_STANDARD_RTTIEXT(AIS_AnimationObject, AIS_BaseAnimationObject)
public:
//! Constructor with initialization.
//! Note that start/end transformations specify exactly local transformation of the object,
//! not the transformation to be applied to existing local transformation.
//! @param[in] theAnimationName animation identifier
//! @param[in] theContext interactive context where object have been displayed
//! @param[in] theObject object to apply local transformation
//! @param[in] theTrsfStart local transformation at the start of animation (e.g. theObject->LocalTransformation())
//! @param[in] theTrsfStart local transformation at the start of animation (e.g.
//! theObject->LocalTransformation())
//! @param[in] theTrsfEnd local transformation at the end of animation
Standard_EXPORT AIS_AnimationObject(const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
@ -39,14 +39,11 @@ public:
const gp_Trsf& theTrsfEnd);
protected:
//! Update the progress.
Standard_EXPORT virtual void update(const AIS_AnimationProgress& theProgress) Standard_OVERRIDE;
private:
gp_TrsfNLerp myTrsfLerp; //!< interpolation tool
};
#endif // _AIS_AnimationObject_HeaderFile

View File

@ -14,7 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AIS_AttributeFilter.hxx>
#include <AIS_InteractiveObject.hxx>
#include <SelectMgr_EntityOwner.hxx>
@ -22,26 +21,30 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_AttributeFilter, SelectMgr_Filter)
AIS_AttributeFilter::AIS_AttributeFilter():
hasC(Standard_False),
hasW(Standard_False){}
AIS_AttributeFilter::AIS_AttributeFilter()
: hasC(Standard_False),
hasW(Standard_False)
{
}
AIS_AttributeFilter::AIS_AttributeFilter(const Quantity_NameOfColor aCol):
myCol(aCol),
AIS_AttributeFilter::AIS_AttributeFilter(const Quantity_NameOfColor aCol)
: myCol(aCol),
hasC(Standard_True),
hasW(Standard_False){}
hasW(Standard_False)
{
}
AIS_AttributeFilter::AIS_AttributeFilter(const Standard_Real aWid):
myWid(aWid),
AIS_AttributeFilter::AIS_AttributeFilter(const Standard_Real aWid)
: myWid(aWid),
hasC(Standard_False),
hasW(Standard_True){}
hasW(Standard_True)
{
}
Standard_Boolean AIS_AttributeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
{
Handle(AIS_InteractiveObject) aSelectable (Handle(AIS_InteractiveObject)::DownCast (anObj->Selectable()));
Handle(AIS_InteractiveObject) aSelectable(
Handle(AIS_InteractiveObject)::DownCast(anObj->Selectable()));
if (aSelectable.IsNull())
return Standard_False;

View File

@ -25,7 +25,6 @@
#include <SelectMgr_Filter.hxx>
class SelectMgr_EntityOwner;
class AIS_AttributeFilter;
DEFINE_STANDARD_HANDLE(AIS_AttributeFilter, SelectMgr_Filter)
@ -42,23 +41,19 @@ DEFINE_STANDARD_HANDLE(AIS_AttributeFilter, SelectMgr_Filter)
class AIS_AttributeFilter : public SelectMgr_Filter
{
public:
//! Constructs an empty attribute filter object.
//! This filter object determines whether selectable
//! interactive objects have a non-null owner.
Standard_EXPORT AIS_AttributeFilter();
//! Constructs an attribute filter object defined by the
//! color attribute aCol.
Standard_EXPORT AIS_AttributeFilter(const Quantity_NameOfColor aCol);
//! Constructs an attribute filter object defined by the line
//! width attribute aWidth.
Standard_EXPORT AIS_AttributeFilter(const Standard_Real aWidth);
//! Indicates that the Interactive Object has the color
//! setting specified by the argument aCol at construction time.
Standard_Boolean HasColor() const { return hasC; }
@ -96,17 +91,16 @@ public:
//! If the Interactive Object returns Standard_True
//! when detected by the Local Context selector through
//! the mouse, the object is kept; if not, it is rejected.
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anObj) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(AIS_AttributeFilter, SelectMgr_Filter)
private:
Quantity_NameOfColor myCol;
Standard_Real myWid;
Standard_Boolean hasC;
Standard_Boolean hasW;
};
#endif // _AIS_AttributeFilter_HeaderFile

View File

@ -40,59 +40,10 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Axis, AIS_InteractiveObject)
//=======================================================================
//function : AIS_Axis
//purpose :
//=======================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Line)& aComponent):
myComponent(aComponent),
myTypeOfAxis(AIS_TOAX_Unknown),
myIsXYZAxis(Standard_False)
{
myDrawer->SetLineAspect(new Prs3d_LineAspect
(Quantity_NOC_RED,Aspect_TOL_DOTDASH,1.));
SetInfiniteState();
//=================================================================================================
gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location();
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ();
}
//=======================================================================
//function : AIS_Axis
//purpose : Xaxis, YAxis, ZAxis
//=======================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType):
myAx2(aComponent),
myTypeOfAxis(anAxisType),
myIsXYZAxis(Standard_True)
{
Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
Standard_Real aLength;
try {
aLength = UnitsAPI::AnyToLS(100. ,"mm");
} catch (Standard_Failure const&) {
aLength = 0.1;
}
DA->SetAxisLength(aLength,aLength,aLength);
Quantity_Color col (Quantity_NOC_TURQUOISE);
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(col);
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(col);
DA->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(col);
myDrawer->SetDatumAspect(DA);
ComputeFields();
}
//=======================================================================
//function : AIS_Axis
//purpose :
//=======================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis)
:myComponent(new Geom_Line(anAxis->Ax1())),
AIS_Axis::AIS_Axis(const Handle(Geom_Line)& aComponent)
: myComponent(aComponent),
myTypeOfAxis(AIS_TOAX_Unknown),
myIsXYZAxis(Standard_False)
{
@ -108,8 +59,52 @@ AIS_Axis::AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis)
//=======================================================================
// function : AIS_Axis
//purpose :
// purpose : Xaxis, YAxis, ZAxis
//=======================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType)
: myAx2(aComponent),
myTypeOfAxis(anAxisType),
myIsXYZAxis(Standard_True)
{
Handle(Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
Standard_Real aLength;
try
{
aLength = UnitsAPI::AnyToLS(100., "mm");
}
catch (Standard_Failure const&)
{
aLength = 0.1;
}
DA->SetAxisLength(aLength, aLength, aLength);
Quantity_Color col(Quantity_NOC_TURQUOISE);
DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(col);
DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(col);
DA->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(col);
myDrawer->SetDatumAspect(DA);
ComputeFields();
}
//=================================================================================================
AIS_Axis::AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis)
: myComponent(new Geom_Line(anAxis->Ax1())),
myTypeOfAxis(AIS_TOAX_Unknown),
myIsXYZAxis(Standard_False)
{
myDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_DOTDASH, 1.));
SetInfiniteState();
gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location();
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
myPfirst = loc.XYZ() + aLength * thedir.XYZ();
myPlast = loc.XYZ() - aLength * thedir.XYZ();
}
//=================================================================================================
AIS_Axis::AIS_Axis(const gp_Ax1& theAxis, const Standard_Real theLength)
: myComponent(new Geom_Line(theAxis)),
myTypeOfAxis(AIS_TOAX_ZAxis),
@ -127,15 +122,13 @@ AIS_Axis::AIS_Axis (const gp_Ax1& theAxis, const Standard_Real theLength)
Handle(Prs3d_DatumAspect) aDatumAspect = new Prs3d_DatumAspect();
aDatumAspect->SetDrawLabels(Standard_False);
myDrawer->SetDatumAspect(aDatumAspect);
Handle(Prs3d_LineAspect) aDefaultLineAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
Handle(Prs3d_LineAspect) aDefaultLineAspect =
new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
myDrawer->SetLineAspect(aDefaultLineAspect);
myLineAspect = myDrawer->LineAspect();
}
//=======================================================================
//function : SetComponent
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Axis::SetComponent(const Handle(Geom_Line)& aComponent)
{
@ -151,12 +144,7 @@ void AIS_Axis::SetComponent(const Handle(Geom_Line)& aComponent)
myPlast = loc.XYZ() - aLength * thedir.XYZ();
}
//=======================================================================
//function : SetAxis2Placement
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Axis::SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType)
@ -167,20 +155,15 @@ void AIS_Axis::SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
ComputeFields();
}
//=======================================================================
//function : SetAxis1Placement
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Axis::SetAxis1Placement(const Handle(Geom_Axis1Placement)& anAxis)
{
SetComponent(new Geom_Line(anAxis->Ax1()));
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Axis::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer)
@ -193,31 +176,28 @@ void AIS_Axis::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
else
{
DsgPrs_XYZAxisPresentation::Add (thePrs, myLineAspect, myDir, myVal,
DsgPrs_XYZAxisPresentation::Add(thePrs,
myLineAspect,
myDir,
myVal,
myDrawer->DatumAspect()->ToDrawLabels() ? myText : "",
myPfirst, myPlast);
myPfirst,
myPlast);
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Axis::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer)
{
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this, 3);
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown,
myPfirst,
myPlast);
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown, myPfirst, myPlast);
aSelection->Add(seg);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Axis::SetColor(const Quantity_Color& aCol)
{
hasOwnColor = Standard_True;
@ -231,14 +211,14 @@ void AIS_Axis::SetColor(const Quantity_Color &aCol)
SynchronizeAspects();
}
//=======================================================================
//function : SetWidth
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Axis::SetWidth(const Standard_Real aValue)
{
if(aValue<0.0) return;
if(aValue==0) UnsetWidth();
if (aValue < 0.0)
return;
if (aValue == 0)
UnsetWidth();
myDrawer->LineAspect()->SetWidth(aValue);
@ -249,10 +229,8 @@ void AIS_Axis::SetWidth(const Standard_Real aValue)
SynchronizeAspects();
}
//=======================================================================
//function : SetDisplayAspect
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Axis::SetDisplayAspect(const Handle(Prs3d_LineAspect)& theNewLineAspect)
{
myDrawer->SetLineAspect(theNewLineAspect);
@ -260,13 +238,12 @@ void AIS_Axis::SetDisplayAspect (const Handle(Prs3d_LineAspect)& theNewLineAspec
SetColor(theNewLineAspect->Aspect()->Color());
}
//=======================================================================
//function : ComputeFields
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Axis::ComputeFields()
{
if (myIsXYZAxis){
if (myIsXYZAxis)
{
// calcul de myPFirst,myPlast
Handle(Prs3d_DatumAspect) DA = myDrawer->DatumAspect();
gp_Ax2 anAxis = myAx2->Ax2();
@ -278,9 +255,9 @@ void AIS_Axis::ComputeFields()
Orig.Coord(xo, yo, zo);
myPfirst.SetCoord(xo, yo, zo);
switch (myTypeOfAxis) {
case AIS_TOAX_XAxis:
switch (myTypeOfAxis)
{
case AIS_TOAX_XAxis: {
oX.Coord(x, y, z);
myVal = DA->AxisLength(Prs3d_DatumParts_XAxis);
myDir = oX;
@ -288,8 +265,7 @@ void AIS_Axis::ComputeFields()
myText = Standard_CString("X");
break;
}
case AIS_TOAX_YAxis:
{
case AIS_TOAX_YAxis: {
oY.Coord(x, y, z);
myVal = DA->AxisLength(Prs3d_DatumParts_YAxis);
myDir = oY;
@ -297,8 +273,7 @@ void AIS_Axis::ComputeFields()
myText = Standard_CString("Y");
break;
}
case AIS_TOAX_ZAxis:
{
case AIS_TOAX_ZAxis: {
oZ.Coord(x, y, z);
myVal = DA->AxisLength(Prs3d_DatumParts_ZAxis);
myDir = oZ;
@ -311,25 +286,23 @@ void AIS_Axis::ComputeFields()
}
myComponent = new Geom_Line(Orig, myDir);
x = xo + x*myVal; y = yo + y*myVal; z = zo + z*myVal;
x = xo + x * myVal;
y = yo + y * myVal;
z = zo + z * myVal;
myPlast.SetCoord(x, y, z);
SetInfiniteState();
}
}
//=======================================================================
//function : AcceptDisplayMode
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_Axis::
AcceptDisplayMode(const Standard_Integer aMode) const
{return aMode == 0;}
Standard_Boolean AIS_Axis::AcceptDisplayMode(const Standard_Integer aMode) const
{
return aMode == 0;
}
//=================================================================================================
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Axis::UnsetColor()
{
myDrawer->LineAspect()->SetColor(Quantity_NOC_RED);
@ -340,10 +313,8 @@ void AIS_Axis::UnsetColor()
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(Quantity_NOC_TURQUOISE);
SynchronizeAspects();
}
//=======================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Axis::UnsetWidth()
{

View File

@ -38,13 +38,13 @@ class AIS_Axis : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_Axis, AIS_InteractiveObject)
public:
//! Initializes the line aComponent
Standard_EXPORT AIS_Axis(const Handle(Geom_Line)& aComponent);
//! initializes the axis2 position
//! aComponent. The coordinate system used is right-handed.
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType);
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType);
//! Initializes the axis1 position anAxis.
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis);
@ -69,7 +69,8 @@ public:
//! Allows you to provide settings for aComponent:the
//! position and direction of an axis in 3D space. The
//! coordinate system used is right-handed.
Standard_EXPORT void SetAxis2Placement (const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfAxis anAxisType);
Standard_EXPORT void SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfAxis anAxisType);
//! Constructs a new line to serve as the axis anAxis in 3D space.
Standard_EXPORT void SetAxis1Placement(const Handle(Geom_Axis1Placement)& anAxis);
@ -87,11 +88,15 @@ public:
Standard_Boolean IsXYZAxis() const { return myIsXYZAxis; }
//! Returns true if the interactive object accepts the display mode aMode.
Standard_EXPORT Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean
AcceptDisplayMode(const Standard_Integer aMode) const Standard_OVERRIDE;
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 2; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
Standard_EXPORT void SetColor(const Quantity_Color& aColor) Standard_OVERRIDE;
@ -105,7 +110,6 @@ public:
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
@ -116,7 +120,6 @@ private:
Standard_EXPORT void ComputeFields();
private:
Handle(Geom_Line) myComponent;
Handle(Geom_Axis2Placement) myAx2;
gp_Pnt myPfirst;
@ -127,7 +130,6 @@ private:
Standard_Real myVal;
Standard_CString myText;
Handle(Prs3d_LineAspect) myLineAspect;
};
DEFINE_STANDARD_HANDLE(AIS_Axis, AIS_InteractiveObject)

View File

@ -24,29 +24,21 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_BadEdgeFilter, SelectMgr_Filter)
//=======================================================================
//function : AIS_BadEdgeFilter
//purpose :
//=======================================================================
//=================================================================================================
AIS_BadEdgeFilter::AIS_BadEdgeFilter()
{
myContour = 0;
}
//=======================================================================
//function : ActsOn
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_BadEdgeFilter::ActsOn(const TopAbs_ShapeEnum aType) const
{
return (aType == TopAbs_EDGE);
}
//=======================================================================
//function : IsOk
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_BadEdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{
@ -59,9 +51,11 @@ Standard_Boolean AIS_BadEdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO
const TopoDS_Shape& aShape = aBO->Shape();
if (myBadEdges.IsBound(myContour)) {
if (myBadEdges.IsBound(myContour))
{
TopTools_ListIteratorOfListOfShape it(myBadEdges.Find(myContour));
for (; it.More(); it.Next()) {
for (; it.More(); it.Next())
{
if (it.Value().IsSame(aShape))
return Standard_False;
}
@ -69,38 +63,30 @@ Standard_Boolean AIS_BadEdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO
return Standard_True;
}
//=======================================================================
//function : AddEdge
//purpose :
//=======================================================================
//=================================================================================================
void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge,
const Standard_Integer Index)
void AIS_BadEdgeFilter::AddEdge(const TopoDS_Edge& anEdge, const Standard_Integer Index)
{
if (myBadEdges.IsBound(Index))
{
if (myBadEdges.IsBound(Index)) {
myBadEdges.ChangeFind(Index).Append(anEdge);
}
else {
else
{
TopTools_ListOfShape LS;
LS.Append(anEdge);
myBadEdges.Bind(Index, LS);
}
}
//=======================================================================
//function : RemoveEdges
//purpose :
//=======================================================================
//=================================================================================================
void AIS_BadEdgeFilter::RemoveEdges(const Standard_Integer Index)
{
myBadEdges.UnBind(Index);
}
//=======================================================================
//function : RemoveEdges
//purpose :
//=======================================================================
//=================================================================================================
void AIS_BadEdgeFilter::SetContour(const Standard_Integer Index)
{

View File

@ -26,7 +26,6 @@
class SelectMgr_EntityOwner;
class TopoDS_Edge;
class AIS_BadEdgeFilter;
DEFINE_STANDARD_HANDLE(AIS_BadEdgeFilter, SelectMgr_Filter)
@ -35,14 +34,14 @@ class AIS_BadEdgeFilter : public SelectMgr_Filter
{
public:
//! Constructs an empty filter object for bad edges.
Standard_EXPORT AIS_BadEdgeFilter();
Standard_EXPORT virtual Standard_Boolean ActsOn (const TopAbs_ShapeEnum aType) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean ActsOn(const TopAbs_ShapeEnum aType) const
Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& EO) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
Standard_OVERRIDE;
//! sets <myContour> with current contour. used by
//! IsOk.
@ -56,29 +55,12 @@ public:
//! all edges in the contour <Index>.
Standard_EXPORT void RemoveEdges(const Standard_Integer Index);
DEFINE_STANDARD_RTTIEXT(AIS_BadEdgeFilter, SelectMgr_Filter)
protected:
private:
TopTools_DataMapOfIntegerListOfShape myBadEdges;
Standard_Integer myContour;
};
#endif // _AIS_BadEdgeFilter_HeaderFile

View File

@ -17,10 +17,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_BaseAnimationObject, AIS_Animation)
//=============================================================================
//function : Constructor
//purpose :
//=============================================================================
//=================================================================================================
AIS_BaseAnimationObject::AIS_BaseAnimationObject(const TCollection_AsciiString& theAnimationName,
const Handle(AIS_InteractiveContext)& theContext,
const Handle(AIS_InteractiveObject)& theObject)
@ -31,10 +29,8 @@ AIS_BaseAnimationObject::AIS_BaseAnimationObject (const TCollection_AsciiString&
//
}
//=============================================================================
//function : updateTrsf
//purpose :
//=============================================================================
//=================================================================================================
void AIS_BaseAnimationObject::updateTrsf(const gp_Trsf& theTrsf)
{
if (!myContext.IsNull())
@ -48,10 +44,8 @@ void AIS_BaseAnimationObject::updateTrsf (const gp_Trsf& theTrsf)
}
}
//=============================================================================
//function : invalidateViewer
//purpose :
//=============================================================================
//=================================================================================================
void AIS_BaseAnimationObject::invalidateViewer()
{
if (myContext.IsNull())
@ -59,7 +53,8 @@ void AIS_BaseAnimationObject::invalidateViewer()
return;
}
const Standard_Boolean isImmediate = myContext->CurrentViewer()->ZLayerSettings (myObject->ZLayer()).IsImmediate();
const Standard_Boolean isImmediate =
myContext->CurrentViewer()->ZLayerSettings(myObject->ZLayer()).IsImmediate();
if (!isImmediate)
{
myContext->CurrentViewer()->Invalidate();
@ -67,19 +62,24 @@ void AIS_BaseAnimationObject::invalidateViewer()
}
// Invalidate immediate view only if it is going out of z-fit range.
// This might be sub-optimal performing this for each animated objects in case of many animated objects.
// This might be sub-optimal performing this for each animated objects in case of many animated
// objects.
for (V3d_ListOfView::Iterator aDefViewIter = myContext->CurrentViewer()->DefinedViewIterator();
aDefViewIter.More(); aDefViewIter.Next())
aDefViewIter.More();
aDefViewIter.Next())
{
const Handle(V3d_View)& aView = aDefViewIter.Value();
const Bnd_Box aMinMaxBox = aView->View()->MinMaxValues(Standard_False);
const Bnd_Box aGraphicBox = aView->View()->MinMaxValues(Standard_True);
Standard_Real aZNear = 0.0;
Standard_Real aZFar = 0.0;
if (aView->Camera()->ZFitAll (aDefViewIter.Value()->AutoZFitScaleFactor(), aMinMaxBox, aGraphicBox, aZNear, aZFar))
if (aView->Camera()->ZFitAll(aDefViewIter.Value()->AutoZFitScaleFactor(),
aMinMaxBox,
aGraphicBox,
aZNear,
aZFar))
{
if (aZNear < aView->Camera()->ZNear()
|| aZFar > aView->Camera()->ZFar())
if (aZNear < aView->Camera()->ZNear() || aZFar > aView->Camera()->ZFar())
{
aDefViewIter.Value()->Invalidate();
}

View File

@ -22,7 +22,6 @@ class AIS_BaseAnimationObject : public AIS_Animation
{
DEFINE_STANDARD_RTTIEXT(AIS_BaseAnimationObject, AIS_Animation)
protected:
//! Constructor with initialization.
//! @param[in] theAnimationName animation identifier
//! @param[in] theContext interactive context where object have been displayed
@ -35,15 +34,12 @@ protected:
Standard_EXPORT void updateTrsf(const gp_Trsf& theTrsf);
private:
//! Invalidate the viewer for proper update.
Standard_EXPORT void invalidateViewer();
protected:
Handle(AIS_InteractiveContext) myContext; //!< context where object is displayed
Handle(AIS_InteractiveObject) myObject; //!< presentation object to set location
};
#endif // _AIS_BaseAnimationObject_HeaderFile

View File

@ -14,7 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AIS_C0RegularityFilter.hxx>
#include <BRep_Tool.hxx>
#include <GeomAbs_Shape.hxx>
@ -29,53 +28,50 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_C0RegularityFilter, SelectMgr_Filter)
//=======================================================================
//function : AIS_C0RegularityFilter
//purpose :
//=======================================================================
//=================================================================================================
AIS_C0RegularityFilter::AIS_C0RegularityFilter(const TopoDS_Shape& aShape)
{
TopTools_IndexedDataMapOfShapeListOfShape SubShapes;
TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, SubShapes);
Standard_Boolean Ok;
for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++) {
for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++)
{
Ok = Standard_False;
TopTools_ListIteratorOfListOfShape it(SubShapes(i));
TopoDS_Face Face1, Face2;
if (it.More()) {
if (it.More())
{
Face1 = TopoDS::Face(it.Value());
it.Next();
if (it.More()) {
if (it.More())
{
Face2 = TopoDS::Face(it.Value());
it.Next();
if (!it.More()) {
if (!it.More())
{
GeomAbs_Shape ShapeContinuity =
BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)), Face1, Face2);
Ok = (ShapeContinuity == GeomAbs_C0);
}
}
}
if (Ok) {
if (Ok)
{
const TopoDS_Shape& curEdge = SubShapes.FindKey(i);
myMapOfEdges.Add(curEdge);
}
}
}
//=======================================================================
//function : ActsOn
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_C0RegularityFilter::ActsOn(const TopAbs_ShapeEnum aType) const
{
return (aType == TopAbs_EDGE);
}
//=======================================================================
//function : IsOk
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_C0RegularityFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{

View File

@ -25,45 +25,26 @@
class TopoDS_Shape;
class SelectMgr_EntityOwner;
class AIS_C0RegularityFilter;
DEFINE_STANDARD_HANDLE(AIS_C0RegularityFilter, SelectMgr_Filter)
class AIS_C0RegularityFilter : public SelectMgr_Filter
{
public:
Standard_EXPORT AIS_C0RegularityFilter(const TopoDS_Shape& aShape);
Standard_EXPORT virtual Standard_Boolean ActsOn (const TopAbs_ShapeEnum aType) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& EO) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean ActsOn(const TopAbs_ShapeEnum aType) const
Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(AIS_C0RegularityFilter, SelectMgr_Filter)
protected:
private:
TopTools_MapOfShape myMapOfEdges;
};
#endif // _AIS_C0RegularityFilter_HeaderFile

View File

@ -31,12 +31,10 @@ namespace
{
static const Standard_ShortReal THE_DEFAULT_TRANSPARENCY = 0.7f;
static const Quantity_Color THE_DEFAULT_COLOR = Quantity_NOC_WHITE;
}
} // namespace
//=================================================================================================
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_CameraFrustum::AIS_CameraFrustum()
: myPoints(0, Graphic3d_Camera::FrustumVerticesNB)
{
@ -53,19 +51,15 @@ AIS_CameraFrustum::AIS_CameraFrustum()
SetDisplayMode(AIS_Shaded);
}
//=======================================================================
//function : AcceptDisplayMode
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_CameraFrustum::AcceptDisplayMode(const Standard_Integer theMode) const
{
return theMode == AIS_Shaded || theMode == AIS_WireFrame;
}
//=======================================================================
//function : SetCameraFrustum
//purpose :
//=======================================================================
//=================================================================================================
void AIS_CameraFrustum::SetCameraFrustum(const Handle(Graphic3d_Camera)& theCamera)
{
if (theCamera.IsNull())
@ -81,10 +75,8 @@ void AIS_CameraFrustum::SetCameraFrustum (const Handle(Graphic3d_Camera)& theCam
SetToUpdate();
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_CameraFrustum::SetColor(const Quantity_Color& theColor)
{
AIS_InteractiveObject::SetColor(theColor);
@ -93,10 +85,8 @@ void AIS_CameraFrustum::SetColor (const Quantity_Color& theColor)
SynchronizeAspects();
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_CameraFrustum::UnsetColor()
{
if (!HasColor())
@ -111,10 +101,8 @@ void AIS_CameraFrustum::UnsetColor()
SynchronizeAspects();
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_CameraFrustum::UnsetTransparency()
{
myDrawer->ShadingAspect()->SetTransparency(0.0f);
@ -122,10 +110,8 @@ void AIS_CameraFrustum::UnsetTransparency()
SynchronizeAspects();
}
//=======================================================================
//function : fillTriangles
//purpose :
//=======================================================================
//=================================================================================================
void AIS_CameraFrustum::fillTriangles()
{
if (myTriangles.IsNull())
@ -133,7 +119,8 @@ void AIS_CameraFrustum::fillTriangles()
const Standard_Integer aPlaneTriangleVertsNb = 2 * 3;
const Standard_Integer aPlanesNb = 3 * 2;
myTriangles = new Graphic3d_ArrayOfTriangles (Graphic3d_Camera::FrustumVerticesNB, aPlaneTriangleVertsNb * aPlanesNb);
myTriangles = new Graphic3d_ArrayOfTriangles(Graphic3d_Camera::FrustumVerticesNB,
aPlaneTriangleVertsNb * aPlanesNb);
myTriangles->SetVertice(Graphic3d_Camera::FrustumVerticesNB, gp_Pnt(0.0, 0.0, 0.0));
// Triangles go in order (clockwise vertices traversing for correct normal):
@ -173,24 +160,24 @@ void AIS_CameraFrustum::fillTriangles()
}
}
for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB; ++aPointIter)
for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB;
++aPointIter)
{
const Graphic3d_Vec3d aPnt = myPoints[aPointIter];
myTriangles->SetVertice(aPointIter + 1, gp_Pnt(aPnt.x(), aPnt.y(), aPnt.z()));
}
}
//=======================================================================
//function : fillBorders
//purpose :
//=======================================================================
//=================================================================================================
void AIS_CameraFrustum::fillBorders()
{
if (myBorders.IsNull())
{
const Standard_Integer aPlaneSegmVertsNb = 2 * 4;
const Standard_Integer aPlanesNb = 3 * 2;
myBorders = new Graphic3d_ArrayOfSegments (Graphic3d_Camera::FrustumVerticesNB, aPlaneSegmVertsNb * aPlanesNb);
myBorders = new Graphic3d_ArrayOfSegments(Graphic3d_Camera::FrustumVerticesNB,
aPlaneSegmVertsNb * aPlanesNb);
myBorders->SetVertice(Graphic3d_Camera::FrustumVerticesNB, gp_Pnt(0.0, 0.0, 0.0));
// Segments go in order:
@ -218,17 +205,16 @@ void AIS_CameraFrustum::fillBorders()
}
}
for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB; ++aPointIter)
for (Standard_Integer aPointIter = 0; aPointIter < Graphic3d_Camera::FrustumVerticesNB;
++aPointIter)
{
const Graphic3d_Vec3d aPnt = myPoints[aPointIter];
myBorders->SetVertice(aPointIter + 1, gp_Pnt(aPnt.x(), aPnt.y(), aPnt.z()));
}
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_CameraFrustum::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
@ -241,15 +227,13 @@ void AIS_CameraFrustum::Compute (const Handle(PrsMgr_PresentationManager)& ,
switch (theMode)
{
case AIS_Shaded:
{
case AIS_Shaded: {
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray(myTriangles);
}
Standard_FALLTHROUGH
case AIS_WireFrame:
{
case AIS_WireFrame: {
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect(myDrawer->LineAspect()->Aspect());
aGroup->AddPrimitiveArray(myBorders);
@ -258,30 +242,32 @@ void AIS_CameraFrustum::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_CameraFrustum::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
switch (theMode)
{
case SelectionMode_Edges:
{
case SelectionMode_Edges: {
Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup(anOwner);
for (Standard_Integer anIter = 1; anIter <= myBorders->EdgeNumber(); anIter += 2)
{
aSensitiveEntity->Add (new Select3D_SensitiveSegment (anOwner, myBorders->Vertice (myBorders->Edge (anIter)), myBorders->Vertice(myBorders->Edge (anIter + 1))));
aSensitiveEntity->Add(
new Select3D_SensitiveSegment(anOwner,
myBorders->Vertice(myBorders->Edge(anIter)),
myBorders->Vertice(myBorders->Edge(anIter + 1))));
}
theSelection->Add(aSensitiveEntity);
break;
}
case SelectionMode_Volume:
{
Handle(Select3D_SensitivePrimitiveArray) aSelArray = new Select3D_SensitivePrimitiveArray (anOwner);
aSelArray->InitTriangulation (myTriangles->Attributes(), myTriangles->Indices(), TopLoc_Location());
case SelectionMode_Volume: {
Handle(Select3D_SensitivePrimitiveArray) aSelArray =
new Select3D_SensitivePrimitiveArray(anOwner);
aSelArray->InitTriangulation(myTriangles->Attributes(),
myTriangles->Indices(),
TopLoc_Location());
theSelection->Add(aSelArray);
break;
}

View File

@ -27,7 +27,6 @@ class AIS_CameraFrustum : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_CameraFrustum, AIS_InteractiveObject)
public:
//! Selection modes supported by this object
enum SelectionMode
{
@ -36,7 +35,6 @@ public:
};
public:
//! Constructs camera frustum with default configuration.
Standard_EXPORT AIS_CameraFrustum();
@ -53,10 +51,10 @@ public:
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
//! Return true if specified display mode is supported.
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const
Standard_OVERRIDE;
protected:
//! Computes presentation of camera frustum.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
@ -67,7 +65,6 @@ protected:
const Standard_Integer theMode) Standard_OVERRIDE;
private:
//! Fills triangles primitive array for camera frustum filling.
void fillTriangles();
@ -75,11 +72,9 @@ private:
void fillBorders();
protected:
NCollection_Array1<Graphic3d_Vec3d> myPoints; //!< Array of points
Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for camera frustum filling
Handle(Graphic3d_ArrayOfSegments) myBorders; //!< Segments for camera frustum borders
};
#endif // _AIS_CameraFrustum_HeaderFile

View File

@ -35,12 +35,10 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Circle, AIS_InteractiveObject)
//=======================================================================
//function : AIS_Circle
//purpose :
//=======================================================================
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent):
AIS_InteractiveObject(PrsMgr_TOP_AllView),
//=================================================================================================
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent)
: AIS_InteractiveObject(PrsMgr_TOP_AllView),
myComponent(aComponent),
myUStart(0.0),
myUEnd(2.0 * M_PI),
@ -49,10 +47,8 @@ myIsFilledCircleSens (Standard_False)
{
}
//=======================================================================
//function : AIS_Circle
//purpose :
//=======================================================================
//=================================================================================================
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& theComponent,
const Standard_Real theUStart,
const Standard_Real theUEnd,
@ -66,36 +62,36 @@ AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& theComponent,
{
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer)
{
if (myCircleIsArc) { ComputeArc (thePrs); }
else { ComputeCircle (thePrs); }
if (myCircleIsArc)
{
ComputeArc(thePrs);
}
else
{
ComputeCircle(thePrs);
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer /*aMode*/)
{
if (myCircleIsArc) ComputeArcSelection(aSelection);
else ComputeCircleSelection(aSelection);
if (myCircleIsArc)
ComputeArcSelection(aSelection);
else
ComputeCircleSelection(aSelection);
}
//=======================================================================
//function : replaceWithNewLineAspect
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Circle::replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect)
{
if (!myDrawer->HasLink())
@ -105,7 +101,8 @@ void AIS_Circle::replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAs
}
const Handle(Graphic3d_AspectLine3d) anAspectOld = myDrawer->LineAspect()->Aspect();
const Handle(Graphic3d_AspectLine3d) anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect();
const Handle(Graphic3d_AspectLine3d) anAspectNew =
!theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect();
if (anAspectNew != anAspectOld)
{
myDrawer->SetLineAspect(theAspect);
@ -115,10 +112,7 @@ void AIS_Circle::replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAs
}
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Circle::SetColor(const Quantity_Color& aCol)
{
@ -127,10 +121,10 @@ void AIS_Circle::SetColor(const Quantity_Color &aCol)
if (!myDrawer->HasOwnLineAspect())
{
Standard_Real WW = HasWidth() ? myOwnWidth :
myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) :
1.;
Standard_Real WW = HasWidth() ? myOwnWidth
: myDrawer->HasLink()
? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
: 1.;
replaceWithNewLineAspect(new Prs3d_LineAspect(aCol, Aspect_TOL_SOLID, WW));
}
else
@ -140,10 +134,8 @@ void AIS_Circle::SetColor(const Quantity_Color &aCol)
}
}
//=======================================================================
//function : SetWidth
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Circle::SetWidth(const Standard_Real aValue)
{
myOwnWidth = (Standard_ShortReal)aValue;
@ -151,8 +143,10 @@ void AIS_Circle::SetWidth(const Standard_Real aValue)
if (!myDrawer->HasOwnLineAspect())
{
Quantity_Color CC = Quantity_NOC_YELLOW;
if( HasColor() ) CC = myDrawer->Color();
else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC);
if (HasColor())
CC = myDrawer->Color();
else if (myDrawer->HasLink())
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
replaceWithNewLineAspect(new Prs3d_LineAspect(CC, Aspect_TOL_SOLID, aValue));
}
else
@ -162,11 +156,8 @@ void AIS_Circle::SetWidth(const Standard_Real aValue)
}
}
//=================================================================================================
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Circle::UnsetColor()
{
hasOwnColor = Standard_False;
@ -178,18 +169,18 @@ void AIS_Circle::UnsetColor()
else
{
Quantity_Color CC = Quantity_NOC_YELLOW;
if( HasColor() ) CC = myDrawer->Color();
else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
if (HasColor())
CC = myDrawer->Color();
else if (myDrawer->HasLink())
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
myDrawer->LineAspect()->SetColor(CC);
myDrawer->SetColor(CC);
SynchronizeAspects();
}
}
//=======================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Circle::UnsetWidth()
{
if (!HasColor())
@ -198,16 +189,17 @@ void AIS_Circle::UnsetWidth()
}
else
{
Standard_ShortReal WW = myDrawer->HasLink() ? (Standard_ShortReal )AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line) : 1.0f;
Standard_ShortReal WW =
myDrawer->HasLink()
? (Standard_ShortReal)AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
: 1.0f;
myDrawer->LineAspect()->SetWidth(WW);
myOwnWidth = WW;
}
}
//=======================================================================
//function : ComputeCircle
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Circle::ComputeCircle(const Handle(Prs3d_Presentation)& thePresentation)
{
@ -216,14 +208,10 @@ void AIS_Circle::ComputeCircle (const Handle(Prs3d_Presentation)& thePresentatio
myDrawer->SetDeviationCoefficient(1.e-5);
StdPrs_DeflectionCurve::Add(thePresentation, curv, myDrawer);
myDrawer->SetDeviationCoefficient(prevdev);
}
//=======================================================================
//function : ComputeArc
//=================================================================================================
//purpose :
//=======================================================================
void AIS_Circle::ComputeArc(const Handle(Prs3d_Presentation)& thePresentation)
{
GeomAdaptor_Curve curv(myComponent, myUStart, myUEnd);
@ -233,30 +221,25 @@ void AIS_Circle::ComputeArc (const Handle(Prs3d_Presentation)& thePresentation)
myDrawer->SetDeviationCoefficient(prevdev);
}
//=======================================================================
//function : ComputeCircleSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& theSelection)
{
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveCircle) aCirc = new Select3D_SensitiveCircle (anOwner,
myComponent->Circ(),
myIsFilledCircleSens);
Handle(Select3D_SensitiveCircle) aCirc =
new Select3D_SensitiveCircle(anOwner, myComponent->Circ(), myIsFilledCircleSens);
theSelection->Add(aCirc);
}
//=======================================================================
//function : ComputeArcSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& theSelection)
{
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitivePoly) aSeg = new Select3D_SensitivePoly(anOwner,
myComponent->Circ(),
myUStart, myUEnd,
myUStart,
myUEnd,
myIsFilledCircleSens);
theSelection->Add(aSeg);
}

View File

@ -27,7 +27,6 @@ class AIS_Circle : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_Circle, AIS_InteractiveObject)
public:
//! Initializes this algorithm for constructing AIS circle
//! datums initializes the circle aCircle
Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& aCircle);
@ -36,13 +35,19 @@ public:
//! Initializes the circle theCircle, the arc
//! starting point theUStart, the arc ending point theUEnd,
//! and the type of sensitivity theIsFilledCircleSens.
Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& theCircle, const Standard_Real theUStart, const Standard_Real theUEnd, const Standard_Boolean theIsFilledCircleSens = Standard_False);
Standard_EXPORT AIS_Circle(const Handle(Geom_Circle)& theCircle,
const Standard_Real theUStart,
const Standard_Real theUEnd,
const Standard_Boolean theIsFilledCircleSens = Standard_False);
//! Returns index 6 by default.
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 6; }
//! Indicates that the type of Interactive Object is a datum.
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
//! Returns the circle component defined in SetCircle.
const Handle(Geom_Circle)& Circle() const { return myComponent; }
@ -88,10 +93,12 @@ public:
//! Sets the type of sensitivity for the circle. If theIsFilledCircleSens set to Standard_True
//! then the whole circle will be detectable, otherwise only the boundary of the circle.
void SetFilledCircleSens (const Standard_Boolean theIsFilledCircleSens) { myIsFilledCircleSens = theIsFilledCircleSens; }
void SetFilledCircleSens(const Standard_Boolean theIsFilledCircleSens)
{
myIsFilledCircleSens = theIsFilledCircleSens;
}
private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& theprs,
const Standard_Integer theMode) Standard_OVERRIDE;
@ -111,13 +118,11 @@ private:
void replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect);
private:
Handle(Geom_Circle) myComponent;
Standard_Real myUStart;
Standard_Real myUEnd;
Standard_Boolean myCircleIsArc;
Standard_Boolean myIsFilledCircleSens;
};
DEFINE_STANDARD_HANDLE(AIS_Circle, AIS_InteractiveObject)

View File

@ -37,8 +37,10 @@ namespace
{
//! Method to add colored quad into array of triangles.
static void addColoredQuad(const Handle(Graphic3d_ArrayOfTriangles)& theTris,
const Standard_Integer theXLeft, const Standard_Integer theYBottom,
const Standard_Integer theSizeX, const Standard_Integer theSizeY,
const Standard_Integer theXLeft,
const Standard_Integer theYBottom,
const Standard_Integer theSizeX,
const Standard_Integer theSizeY,
const Quantity_Color& theColorBottom,
const Quantity_Color& theColorTop)
{
@ -65,10 +67,16 @@ namespace
aValue = (theValue - theMin) / aValueDelta;
}
Standard_Real aHue = NCollection_Lerp<Standard_Real>::Interpolate (theHlsMin[0], theHlsMax[0], aValue);
Standard_Real aLightness = NCollection_Lerp<Standard_Real>::Interpolate (theHlsMin[1], theHlsMax[1], aValue);
Standard_Real aSaturation = NCollection_Lerp<Standard_Real>::Interpolate (theHlsMin[2], theHlsMax[2], aValue);
return Quantity_Color (AIS_ColorScale::hueToValidRange (aHue), aLightness, aSaturation, Quantity_TOC_HLS);
Standard_Real aHue =
NCollection_Lerp<Standard_Real>::Interpolate(theHlsMin[0], theHlsMax[0], aValue);
Standard_Real aLightness =
NCollection_Lerp<Standard_Real>::Interpolate(theHlsMin[1], theHlsMax[1], aValue);
Standard_Real aSaturation =
NCollection_Lerp<Standard_Real>::Interpolate(theHlsMin[2], theHlsMax[2], aValue);
return Quantity_Color(AIS_ColorScale::hueToValidRange(aHue),
aLightness,
aSaturation,
Quantity_TOC_HLS);
}
//! Return the index of discrete interval for specified value.
@ -90,17 +98,18 @@ namespace
return 1;
}
Standard_Integer anInterval = 1 + (Standard_Integer )Floor (Standard_Real (theNbIntervals) * (theValue - theMin) / (theMax - theMin));
Standard_Integer anInterval =
1
+ (Standard_Integer)Floor(Standard_Real(theNbIntervals) * (theValue - theMin)
/ (theMax - theMin));
// map the very upper value (theValue==theMax) to the largest color interval
anInterval = Min(anInterval, theNbIntervals);
return anInterval;
}
}
} // namespace
//=================================================================================================
//=======================================================================
//function : AIS_ColorScale
//purpose :
//=======================================================================
AIS_ColorScale::AIS_ColorScale()
: myMin(0.0),
myMax(1.0),
@ -130,16 +139,13 @@ AIS_ColorScale::AIS_ColorScale()
myDrawer->ShadingAspect()->Aspect()->SetInteriorColor(Quantity_NOC_WHITE);
}
//=======================================================================
//function : GetLabel
//purpose :
//=======================================================================
//=================================================================================================
TCollection_ExtendedString AIS_ColorScale::GetLabel(const Standard_Integer theIndex) const
{
if (myLabelType == Aspect_TOCSD_USER)
{
if (theIndex >= myLabels.Lower()
|| theIndex <= myLabels.Upper())
if (theIndex >= myLabels.Lower() || theIndex <= myLabels.Upper())
{
return myLabels.Value(theIndex);
}
@ -147,8 +153,8 @@ TCollection_ExtendedString AIS_ColorScale::GetLabel (const Standard_Integer theI
}
// value to be shown depends on label position
const Standard_Real aVal = myIsLabelAtBorder
? GetIntervalValue (theIndex - 1)
const Standard_Real aVal =
myIsLabelAtBorder ? GetIntervalValue(theIndex - 1)
: (0.5 * (GetIntervalValue(theIndex - 1) + GetIntervalValue(theIndex)));
char aBuf[1024];
@ -156,10 +162,8 @@ TCollection_ExtendedString AIS_ColorScale::GetLabel (const Standard_Integer theI
return TCollection_ExtendedString(aBuf);
}
//=======================================================================
//function : GetIntervalColor
//purpose :
//=======================================================================
//=================================================================================================
Quantity_Color AIS_ColorScale::GetIntervalColor(const Standard_Integer theIndex) const
{
if (myColorType == Aspect_TOCSD_USER)
@ -174,23 +178,20 @@ Quantity_Color AIS_ColorScale::GetIntervalColor (const Standard_Integer theIndex
return colorFromValue(theIndex - 1, 0, myNbIntervals - 1);
}
//=======================================================================
//function : GetLabels
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::GetLabels(TColStd_SequenceOfExtendedString& theLabels) const
{
theLabels.Clear();
for (TColStd_SequenceOfExtendedString::Iterator aLabIter (myLabels); aLabIter.More(); aLabIter.Next())
for (TColStd_SequenceOfExtendedString::Iterator aLabIter(myLabels); aLabIter.More();
aLabIter.Next())
{
theLabels.Append(aLabIter.Value());
}
}
//=======================================================================
//function : GetColors
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::GetColors(Aspect_SequenceOfColor& theColors) const
{
theColors.Clear();
@ -200,20 +201,16 @@ void AIS_ColorScale::GetColors (Aspect_SequenceOfColor& theColors) const
}
}
//=======================================================================
//function : SetRange
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::SetRange(const Standard_Real theMin, const Standard_Real theMax)
{
myMin = Min(theMin, theMax);
myMax = Max(theMin, theMax);
}
//=======================================================================
//function : SetNumberOfIntervals
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::SetNumberOfIntervals(const Standard_Integer theNum)
{
if (theNum < 1)
@ -224,10 +221,8 @@ void AIS_ColorScale::SetNumberOfIntervals (const Standard_Integer theNum)
myNbIntervals = theNum;
}
//=======================================================================
//function : SetLabel
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::SetLabel(const TCollection_ExtendedString& theLabel,
const Standard_Integer theIndex)
{
@ -239,10 +234,8 @@ void AIS_ColorScale::SetLabel (const TCollection_ExtendedString& theLabel,
myLabels.SetValue(aLabIndex, theLabel);
}
//=======================================================================
//function : SetIntervalColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::SetIntervalColor(const Quantity_Color& theColor,
const Standard_Integer theIndex)
{
@ -254,23 +247,20 @@ void AIS_ColorScale::SetIntervalColor (const Quantity_Color& theColor,
myColors.SetValue(aColorIndex, theColor);
}
//=======================================================================
//function : SetLabels
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::SetLabels(const TColStd_SequenceOfExtendedString& theSeq)
{
myLabels.Clear();
for (TColStd_SequenceOfExtendedString::Iterator aLabIter (theSeq); aLabIter.More(); aLabIter.Next())
for (TColStd_SequenceOfExtendedString::Iterator aLabIter(theSeq); aLabIter.More();
aLabIter.Next())
{
myLabels.Append(aLabIter.Value());
}
}
//=======================================================================
//function : SetColors
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::SetColors(const Aspect_SequenceOfColor& theSeq)
{
myColors.Clear();
@ -280,10 +270,8 @@ void AIS_ColorScale::SetColors (const Aspect_SequenceOfColor& theSeq)
}
}
//=======================================================================
//function : MakeUniformColors
//purpose :
//=======================================================================
//=================================================================================================
Aspect_SequenceOfColor AIS_ColorScale::MakeUniformColors(Standard_Integer theNbColors,
Standard_Real theLightness,
Standard_Real theHueFrom,
@ -370,14 +358,13 @@ Aspect_SequenceOfColor AIS_ColorScale::MakeUniformColors (Standard_Integer theNb
{
aResult.Append(aGrid.Last());
}
Standard_ASSERT_VOID (aResult.Length() == theNbColors, "Failed to generate requested nb of colors");
Standard_ASSERT_VOID(aResult.Length() == theNbColors,
"Failed to generate requested nb of colors");
return aResult;
}
//=======================================================================
//function : SizeHint
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::SizeHint(Standard_Integer& theWidth, Standard_Integer& theHeight) const
{
const Standard_Integer aTextHeight = TextHeight("");
@ -385,14 +372,16 @@ void AIS_ColorScale::SizeHint (Standard_Integer& theWidth, Standard_Integer& the
Standard_Integer aTextWidth = 0;
if (myLabelPos != Aspect_TOCSP_NONE)
{
for (Standard_Integer aLabIter = (myIsLabelAtBorder ? 0 : 1); aLabIter <= myNbIntervals; ++aLabIter)
for (Standard_Integer aLabIter = (myIsLabelAtBorder ? 0 : 1); aLabIter <= myNbIntervals;
++aLabIter)
{
aTextWidth = Max(aTextWidth, TextWidth(GetLabel(aLabIter)));
}
}
const Standard_Integer aScaleWidth = aColorWidth + aTextWidth + (aTextWidth ? 3 : 2) * mySpacing;
const Standard_Integer aScaleHeight = (Standard_Integer)(1.5 * (myNbIntervals + (myIsLabelAtBorder ? 2 : 1)) * aTextHeight);
const Standard_Integer aScaleHeight =
(Standard_Integer)(1.5 * (myNbIntervals + (myIsLabelAtBorder ? 2 : 1)) * aTextHeight);
Standard_Integer aTitleWidth = 0;
Standard_Integer aTitleHeight = 0;
@ -406,10 +395,8 @@ void AIS_ColorScale::SizeHint (Standard_Integer& theWidth, Standard_Integer& the
theHeight = aScaleHeight + aTitleHeight;
}
//=======================================================================
//function : GetIntervalValue
//purpose :
//=======================================================================
//=================================================================================================
Standard_Real AIS_ColorScale::GetIntervalValue(const Standard_Integer theIndex) const
{
if (myNbIntervals <= 0)
@ -432,10 +419,8 @@ Standard_Real AIS_ColorScale::GetIntervalValue (const Standard_Integer theIndex)
return aNum;
}
//=======================================================================
//function : colorFromValue
//purpose :
//=======================================================================
//=================================================================================================
Quantity_Color AIS_ColorScale::colorFromValue(const Standard_Real theValue,
const Standard_Real theMin,
const Standard_Real theMax) const
@ -443,10 +428,8 @@ Quantity_Color AIS_ColorScale::colorFromValue (const Standard_Real theValue,
return colorFromValueEx(theValue, theMin, theMax, myColorHlsMin, myColorHlsMax);
}
//=======================================================================
//function : FindColor
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ColorScale::FindColor(const Standard_Real theValue,
Quantity_Color& theColor) const
{
@ -458,7 +441,8 @@ Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
if (myColorType == Aspect_TOCSD_USER)
{
const Standard_Integer anInterval = colorDiscreteInterval (theValue, myMin, myMax, myNbIntervals);
const Standard_Integer anInterval =
colorDiscreteInterval(theValue, myMin, myMax, myNbIntervals);
if (anInterval < myColors.Lower() || anInterval > myColors.Upper())
{
theColor = Quantity_Color();
@ -472,10 +456,8 @@ Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
return FindColor(theValue, myMin, myMax, myNbIntervals, theColor);
}
//=======================================================================
//function : FindColor
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ColorScale::FindColor(const Standard_Real theValue,
const Standard_Real theMin,
const Standard_Real theMax,
@ -489,19 +471,21 @@ Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
return Standard_False;
}
const Standard_Integer anInterval = colorDiscreteInterval (theValue, theMin, theMax, theColorsCount);
theColor = colorFromValueEx (anInterval - 1, 0, theColorsCount - 1, theColorHlsMin, theColorHlsMax);
const Standard_Integer anInterval =
colorDiscreteInterval(theValue, theMin, theMax, theColorsCount);
theColor =
colorFromValueEx(anInterval - 1, 0, theColorsCount - 1, theColorHlsMin, theColorHlsMax);
return Standard_True;
}
//=======================================================================
//function : computeMaxLabelWidth
//purpose :
//=======================================================================
Standard_Integer AIS_ColorScale::computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const
//=================================================================================================
Standard_Integer AIS_ColorScale::computeMaxLabelWidth(
const TColStd_SequenceOfExtendedString& theLabels) const
{
Standard_Integer aWidthMax = 0;
for (TColStd_SequenceOfExtendedString::Iterator aLabIter (theLabels); aLabIter.More(); aLabIter.Next())
for (TColStd_SequenceOfExtendedString::Iterator aLabIter(theLabels); aLabIter.More();
aLabIter.Next())
{
if (!aLabIter.Value().IsEmpty())
{
@ -511,10 +495,8 @@ Standard_Integer AIS_ColorScale::computeMaxLabelWidth (const TColStd_SequenceOfE
return aWidthMax;
}
//=======================================================================
//function : updateTextAspect
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::updateTextAspect()
{
// update text aspect
@ -533,10 +515,8 @@ void AIS_ColorScale::updateTextAspect()
anAspect->Aspect()->SetTextZoomable(Standard_True);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
@ -577,25 +557,25 @@ void AIS_ColorScale::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
}
const Standard_Integer aTextWidth = myLabelPos != Aspect_TOCSP_NONE ? computeMaxLabelWidth (aLabels) : 0;
const Standard_Integer aTextWidth =
myLabelPos != Aspect_TOCSP_NONE ? computeMaxLabelWidth(aLabels) : 0;
Standard_Integer aColorBreadth = Max(5, Min(20, myBreadth - aTextWidth - 3 * mySpacing));
if (myLabelPos == Aspect_TOCSP_CENTER
|| myLabelPos == Aspect_TOCSP_NONE)
if (myLabelPos == Aspect_TOCSP_CENTER || myLabelPos == Aspect_TOCSP_NONE)
{
aColorBreadth += aTextWidth;
}
// draw title
Handle(Graphic3d_Group) aLabelsGroup;
if (!myTitle.IsEmpty()
|| !aLabels.IsEmpty())
if (!myTitle.IsEmpty() || !aLabels.IsEmpty())
{
aLabelsGroup = thePrs->NewGroup();
aLabelsGroup->SetGroupPrimitivesAspect(myDrawer->TextAspect()->Aspect());
}
if (!myTitle.IsEmpty())
{
drawText (aLabelsGroup, myTitle,
drawText(aLabelsGroup,
myTitle,
myXPos + mySpacing,
aBarTop + aBarYOffset,
Graphic3d_VTA_BOTTOM);
@ -608,10 +588,8 @@ void AIS_ColorScale::Compute (const Handle(PrsMgr_PresentationManager)& ,
drawLabels(aLabelsGroup, aLabels, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
}
//=======================================================================
//function : drawColorBar
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::drawColorBar(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theBarBottom,
const Standard_Integer theBarHeight,
@ -625,7 +603,8 @@ void AIS_ColorScale::drawColorBar (const Handle(Prs3d_Presentation)& thePrs,
}
// Draw colors
const Standard_Integer anXLeft = myLabelPos == Aspect_TOCSP_LEFT
const Standard_Integer anXLeft =
myLabelPos == Aspect_TOCSP_LEFT
? myXPos + mySpacing + theMaxLabelWidth + (theMaxLabelWidth != 0 ? 1 : 0) * mySpacing
: myXPos + mySpacing;
@ -643,12 +622,12 @@ void AIS_ColorScale::drawColorBar (const Handle(Prs3d_Presentation)& thePrs,
}
Handle(Graphic3d_ArrayOfTriangles) aTriangles;
if (myIsSmooth
&& myColorType == Aspect_TOCSD_USER)
if (myIsSmooth && myColorType == Aspect_TOCSD_USER)
{
// Smooth custom intervals, so that the color in the center of interval is equal to specified one
// (thus the halves of first and last intervals have solid color)
aTriangles = new Graphic3d_ArrayOfTriangles ((aColors.Length() + 1) * 4, // quads
// Smooth custom intervals, so that the color in the center of interval is equal to specified
// one (thus the halves of first and last intervals have solid color)
aTriangles =
new Graphic3d_ArrayOfTriangles((aColors.Length() + 1) * 4, // quads
(aColors.Length() + 1) * 2 * 3, // quads as triangles
// clang-format off
false, true); // per-vertex colors
@ -657,79 +636,80 @@ void AIS_ColorScale::drawColorBar (const Handle(Prs3d_Presentation)& thePrs,
Standard_Integer aSizeY = Standard_Integer(aStepY / 2);
const Standard_Integer anYBottom = theBarBottom + aSizeY;
Standard_Integer anYBottomIter = anYBottom;
addColoredQuad (aTriangles,
anXLeft, theBarBottom,
theColorBreadth, aSizeY,
aColor1, aColor1);
addColoredQuad(aTriangles, anXLeft, theBarBottom, theColorBreadth, aSizeY, aColor1, aColor1);
for (Standard_Integer aColorIter = 0; aColorIter < myNbIntervals - 1; ++aColorIter)
{
aColor1 = aColors.Value(aColorIter + 1);
aColor2 = aColors.Value(aColorIter + 2);
aSizeY = anYBottom + Standard_Integer((aColorIter + 1) * aStepY) - anYBottomIter;
addColoredQuad (aTriangles,
anXLeft, anYBottomIter,
theColorBreadth, aSizeY,
aColor1, aColor2);
addColoredQuad(aTriangles, anXLeft, anYBottomIter, theColorBreadth, aSizeY, aColor1, aColor2);
anYBottomIter += aSizeY;
}
aColor2 = aColors.Value(myNbIntervals);
aSizeY = theBarBottom + theBarHeight - anYBottomIter;
addColoredQuad (aTriangles,
anXLeft, anYBottomIter,
theColorBreadth, aSizeY,
aColor2, aColor2);
addColoredQuad(aTriangles, anXLeft, anYBottomIter, theColorBreadth, aSizeY, aColor2, aColor2);
}
else if (myIsSmooth)
{
// smooth transition between standard colors - without solid color regions at the beginning and end of full color range
const Quantity_Color aColorsFixed[5] =
{
colorFromValue (0, 0, 4),
// smooth transition between standard colors - without solid color regions at the beginning and
// end of full color range
const Quantity_Color aColorsFixed[5] = {colorFromValue(0, 0, 4),
colorFromValue(1, 0, 4),
colorFromValue(2, 0, 4),
colorFromValue(3, 0, 4),
colorFromValue (4, 0, 4)
};
colorFromValue(4, 0, 4)};
aTriangles = new Graphic3d_ArrayOfTriangles(4 * 4, // quads
4 * 2 * 3, // quads as triangles
false, true); // per-vertex colors
false,
true); // per-vertex colors
Standard_Integer anYBottomIter = theBarBottom;
addColoredQuad(aTriangles,
anXLeft, theBarBottom,
theColorBreadth, theBarHeight / 4,
aColorsFixed[0], aColorsFixed[1]);
anXLeft,
theBarBottom,
theColorBreadth,
theBarHeight / 4,
aColorsFixed[0],
aColorsFixed[1]);
anYBottomIter += theBarHeight / 4;
addColoredQuad(aTriangles,
anXLeft, anYBottomIter,
theColorBreadth, theBarHeight / 4,
aColorsFixed[1], aColorsFixed[2]);
anXLeft,
anYBottomIter,
theColorBreadth,
theBarHeight / 4,
aColorsFixed[1],
aColorsFixed[2]);
anYBottomIter += theBarHeight / 4;
addColoredQuad(aTriangles,
anXLeft, anYBottomIter,
theColorBreadth, theBarHeight / 4,
aColorsFixed[2], aColorsFixed[3]);
anXLeft,
anYBottomIter,
theColorBreadth,
theBarHeight / 4,
aColorsFixed[2],
aColorsFixed[3]);
anYBottomIter += theBarHeight / 4;
const Standard_Integer aLastSizeY = theBarBottom + theBarHeight - anYBottomIter;
addColoredQuad(aTriangles,
anXLeft, anYBottomIter,
theColorBreadth, aLastSizeY,
aColorsFixed[3], aColorsFixed[4]);
anXLeft,
anYBottomIter,
theColorBreadth,
aLastSizeY,
aColorsFixed[3],
aColorsFixed[4]);
}
else
{
// no color smoothing
aTriangles = new Graphic3d_ArrayOfTriangles(aColors.Length() * 4, // quads
aColors.Length() * 2 * 3, // quads as triangles
false, true); // per-vertex colors
false,
true); // per-vertex colors
Standard_Integer anYBottomIter = theBarBottom;
for (Standard_Integer aColorIter = 0; aColorIter < myNbIntervals; ++aColorIter)
{
const Quantity_Color& aColor = aColors.Value(aColorIter + 1);
const Standard_Integer aSizeY = theBarBottom + Standard_Integer((aColorIter + 1) * aStepY) - anYBottomIter;
addColoredQuad (aTriangles,
anXLeft, anYBottomIter,
theColorBreadth, aSizeY,
aColor, aColor);
const Standard_Integer aSizeY =
theBarBottom + Standard_Integer((aColorIter + 1) * aStepY) - anYBottomIter;
addColoredQuad(aTriangles, anXLeft, anYBottomIter, theColorBreadth, aSizeY, aColor, aColor);
anYBottomIter += aSizeY;
}
}
@ -739,17 +719,11 @@ void AIS_ColorScale::drawColorBar (const Handle(Prs3d_Presentation)& thePrs,
aGroup->AddPrimitiveArray(aTriangles);
const Quantity_Color aFgColor(hasOwnColor ? myDrawer->Color() : Quantity_NOC_WHITE);
drawFrame (thePrs,
anXLeft - 1, theBarBottom - 1,
theColorBreadth + 2,
theBarHeight + 2,
aFgColor);
drawFrame(thePrs, anXLeft - 1, theBarBottom - 1, theColorBreadth + 2, theBarHeight + 2, aFgColor);
}
//=======================================================================
//function : drawLabels
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::drawLabels(const Handle(Graphic3d_Group)& theGroup,
const TColStd_SequenceOfExtendedString& theLabels,
const Standard_Integer theBarBottom,
@ -757,8 +731,7 @@ void AIS_ColorScale::drawLabels (const Handle(Graphic3d_Group)& theGroup,
const Standard_Integer theMaxLabelWidth,
const Standard_Integer theColorBreadth)
{
if (myLabelPos == Aspect_TOCSP_NONE
|| theLabels.IsEmpty())
if (myLabelPos == Aspect_TOCSP_NONE || theLabels.IsEmpty())
{
return;
}
@ -773,8 +746,11 @@ void AIS_ColorScale::drawLabels (const Handle(Graphic3d_Group)& theGroup,
Standard_Integer aFilter = 0;
{
const Standard_Integer aTitleHeight = !myTitle.IsEmpty() ? (myTextHeight + 2 * mySpacing) : mySpacing;
const Standard_Integer aSpc = myHeight - aTitleHeight - ((Min (aNbLabels, 2) + Abs (aNbLabels - aNbIntervals - 1)) * myTextHeight);
const Standard_Integer aTitleHeight =
!myTitle.IsEmpty() ? (myTextHeight + 2 * mySpacing) : mySpacing;
const Standard_Integer aSpc =
myHeight - aTitleHeight
- ((Min(aNbLabels, 2) + Abs(aNbLabels - aNbIntervals - 1)) * myTextHeight);
if (aSpc <= 0)
{
return;
@ -795,17 +771,14 @@ void AIS_ColorScale::drawLabels (const Handle(Graphic3d_Group)& theGroup,
switch (myLabelPos)
{
case Aspect_TOCSP_NONE:
case Aspect_TOCSP_LEFT:
{
case Aspect_TOCSP_LEFT: {
break;
}
case Aspect_TOCSP_CENTER:
{
case Aspect_TOCSP_CENTER: {
anXLeft += (theColorBreadth - theMaxLabelWidth) / 2;
break;
}
case Aspect_TOCSP_RIGHT:
{
case Aspect_TOCSP_RIGHT: {
anXLeft += theColorBreadth + mySpacing;
break;
}
@ -815,24 +788,27 @@ void AIS_ColorScale::drawLabels (const Handle(Graphic3d_Group)& theGroup,
Standard_Integer i2 = aNbLabels - 1;
Standard_Integer aLast1 = i1;
Standard_Integer aLast2 = i2;
const Standard_Integer anYBottom = myIsLabelAtBorder
? theBarBottom
: theBarBottom + Standard_Integer(aStepY / 2);
const Standard_Integer anYBottom =
myIsLabelAtBorder ? theBarBottom : theBarBottom + Standard_Integer(aStepY / 2);
while (i2 - i1 >= aFilter || (i2 == 0 && i1 == 0))
{
Standard_Integer aPos1 = i1;
Standard_Integer aPos2 = aNbLabels - 1 - i2;
if (aFilter && !(aPos1 % aFilter))
{
drawText (theGroup, theLabels.Value (i1 + 1),
anXLeft, anYBottom + Standard_Integer(i1 * aStepY + anAscent),
drawText(theGroup,
theLabels.Value(i1 + 1),
anXLeft,
anYBottom + Standard_Integer(i1 * aStepY + anAscent),
Graphic3d_VTA_CENTER);
aLast1 = i1;
}
if (aFilter && !(aPos2 % aFilter))
{
drawText (theGroup, theLabels.Value (i2 + 1),
anXLeft, anYBottom + Standard_Integer(i2 * aStepY + anAscent),
drawText(theGroup,
theLabels.Value(i2 + 1),
anXLeft,
anYBottom + Standard_Integer(i2 * aStepY + anAscent),
Graphic3d_VTA_CENTER);
aLast2 = i2;
}
@ -843,8 +819,7 @@ void AIS_ColorScale::drawLabels (const Handle(Graphic3d_Group)& theGroup,
Standard_Integer i0 = -1;
while (aPos <= i2 && i0 == -1)
{
if (aFilter && !(aPos % aFilter)
&& Abs (aPos - aLast1) >= aFilter
if (aFilter && !(aPos % aFilter) && Abs(aPos - aLast1) >= aFilter
&& Abs(aPos - aLast2) >= aFilter)
{
i0 = aPos;
@ -854,19 +829,21 @@ void AIS_ColorScale::drawLabels (const Handle(Graphic3d_Group)& theGroup,
if (i0 != -1)
{
drawText (theGroup, theLabels.Value (i0 + 1),
anXLeft, anYBottom + Standard_Integer(i0 * aStepY + anAscent),
drawText(theGroup,
theLabels.Value(i0 + 1),
anXLeft,
anYBottom + Standard_Integer(i0 * aStepY + anAscent),
Graphic3d_VTA_CENTER);
}
}
//=======================================================================
//function : drawFrame
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::drawFrame(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theX, const Standard_Integer theY,
const Standard_Integer theWidth, const Standard_Integer theHeight,
const Standard_Integer theX,
const Standard_Integer theY,
const Standard_Integer theWidth,
const Standard_Integer theHeight,
const Quantity_Color& theColor)
{
Handle(Graphic3d_ArrayOfPolylines) aPrim = new Graphic3d_ArrayOfPolylines(5);
@ -876,19 +853,19 @@ void AIS_ColorScale::drawFrame (const Handle(Prs3d_Presentation)& thePrs,
aPrim->AddVertex(theX, theY + theHeight, 0.0);
aPrim->AddVertex(theX, theY, 0.0);
Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d (theColor, Aspect_TOL_SOLID, 1.0);
Handle(Graphic3d_AspectLine3d) anAspect =
new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 1.0);
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect(anAspect);
aGroup->AddPrimitiveArray(aPrim);
}
//=======================================================================
//function : drawText
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::drawText(const Handle(Graphic3d_Group)& theGroup,
const TCollection_ExtendedString& theText,
const Standard_Integer theX, const Standard_Integer theY,
const Standard_Integer theX,
const Standard_Integer theY,
const Graphic3d_VerticalTextAlignment theVertAlignment)
{
const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
@ -902,10 +879,8 @@ void AIS_ColorScale::drawText (const Handle(Graphic3d_Group)& theGroup,
theGroup->AddText(aText);
}
//=======================================================================
//function : TextWidth
//purpose :
//=======================================================================
//=================================================================================================
Standard_Integer AIS_ColorScale::TextWidth(const TCollection_ExtendedString& theText) const
{
Standard_Integer aWidth = 0, anAscent = 0, aDescent = 0;
@ -913,10 +888,8 @@ Standard_Integer AIS_ColorScale::TextWidth (const TCollection_ExtendedString& th
return aWidth;
}
//=======================================================================
//function : TextHeight
//purpose :
//=======================================================================
//=================================================================================================
Standard_Integer AIS_ColorScale::TextHeight(const TCollection_ExtendedString& theText) const
{
Standard_Integer aWidth = 0, anAscent = 0, aDescent = 0;
@ -924,10 +897,8 @@ Standard_Integer AIS_ColorScale::TextHeight (const TCollection_ExtendedString& t
return anAscent + aDescent;
}
//=======================================================================
//function : TextSize
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColorScale::TextSize(const TCollection_ExtendedString& theText,
const Standard_Integer theHeight,
Standard_Integer& theWidth,
@ -940,7 +911,12 @@ void AIS_ColorScale::TextSize (const TCollection_ExtendedString& theText,
const TCollection_AsciiString aText(theText);
const Handle(V3d_Viewer)& aViewer = GetContext()->CurrentViewer();
const Handle(Graphic3d_CView)& aView = aViewer->ActiveViewIterator().Value()->View();
aViewer->Driver()->TextSize (aView, aText.ToCString(), (Standard_ShortReal)theHeight, aWidth, anAscent, aDescent);
aViewer->Driver()->TextSize(aView,
aText.ToCString(),
(Standard_ShortReal)theHeight,
aWidth,
anAscent,
aDescent);
}
theWidth = (Standard_Integer)aWidth;
theAscent = (Standard_Integer)anAscent;

View File

@ -26,6 +26,7 @@
class AIS_ColorScale;
DEFINE_STANDARD_HANDLE(AIS_ColorScale, AIS_InteractiveObject)
//! Class for drawing a custom color scale.
//!
//! The color scale consists of rectangular color bar (composed of fixed
@ -39,7 +40,6 @@ class AIS_ColorScale : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_ColorScale, AIS_InteractiveObject)
public:
//! Calculate color according passed value; returns true if value is in range or false, if isn't
Standard_EXPORT static Standard_Boolean FindColor(const Standard_Real theValue,
const Standard_Real theMin,
@ -56,7 +56,10 @@ public:
const Standard_Integer theColorsCount,
Quantity_Color& theColor)
{
return FindColor (theValue, theMin, theMax, theColorsCount,
return FindColor(theValue,
theMin,
theMax,
theColorsCount,
Graphic3d_Vec3d(230.0, 1.0, 1.0),
Graphic3d_Vec3d(0.0, 1.0, 1.0),
theColor);
@ -64,22 +67,29 @@ public:
//! Shift hue into valid range.
//! Lightness and Saturation should be specified in valid range [0.0, 1.0],
//! however Hue might be given out of Quantity_Color range to specify desired range for interpolation.
//! however Hue might be given out of Quantity_Color range to specify desired range for
//! interpolation.
static Standard_Real hueToValidRange(const Standard_Real theHue)
{
Standard_Real aHue = theHue;
while (aHue < 0.0) { aHue += 360.0; }
while (aHue > 360.0) { aHue -= 360.0; }
while (aHue < 0.0)
{
aHue += 360.0;
}
while (aHue > 360.0)
{
aHue -= 360.0;
}
return aHue;
}
public:
//! Default constructor.
Standard_EXPORT AIS_ColorScale();
//! Calculate color according passed value; returns true if value is in range or false, if isn't
Standard_EXPORT Standard_Boolean FindColor (const Standard_Real theValue, Quantity_Color& theColor) const;
Standard_EXPORT Standard_Boolean FindColor(const Standard_Real theValue,
Quantity_Color& theColor) const;
//! Returns minimal value of color scale, 0.0 by default.
Standard_Real GetMin() const { return myMin; }
@ -101,7 +111,8 @@ public:
}
//! Sets the minimal and maximal value of color scale.
//! Note that values order will be ignored - the minimum and maximum values will be swapped if needed.
//! Note that values order will be ignored - the minimum and maximum values will be swapped if
//! needed.
//! ::SetReversed() should be called to swap displaying order.
Standard_EXPORT void SetRange(const Standard_Real theMin, const Standard_Real theMax);
@ -111,9 +122,9 @@ public:
//! Returns the hue angle corresponding to maximum value, 0 by default (red).
Standard_Real HueMax() const { return myColorHlsMax[0]; }
//! Returns the hue angle range corresponding to minimum and maximum values, 230 to 0 by default (blue to red).
void HueRange (Standard_Real& theMinAngle,
Standard_Real& theMaxAngle) const
//! Returns the hue angle range corresponding to minimum and maximum values, 230 to 0 by default
//! (blue to red).
void HueRange(Standard_Real& theMinAngle, Standard_Real& theMaxAngle) const
{
theMinAngle = myColorHlsMin[0];
theMaxAngle = myColorHlsMax[0];
@ -121,24 +132,27 @@ public:
//! Sets hue angle range corresponding to minimum and maximum values.
//! The valid angle range is [0, 360], see Quantity_Color and Quantity_TOC_HLS for more details.
void SetHueRange (const Standard_Real theMinAngle,
const Standard_Real theMaxAngle)
void SetHueRange(const Standard_Real theMinAngle, const Standard_Real theMaxAngle)
{
myColorHlsMin[0] = theMinAngle;
myColorHlsMax[0] = theMaxAngle;
}
//! Returns color range corresponding to minimum and maximum values, blue to red by default.
void ColorRange (Quantity_Color& theMinColor,
Quantity_Color& theMaxColor) const
void ColorRange(Quantity_Color& theMinColor, Quantity_Color& theMaxColor) const
{
theMinColor.SetValues (hueToValidRange (myColorHlsMin[0]), myColorHlsMin[1], myColorHlsMin[2], Quantity_TOC_HLS);
theMaxColor.SetValues (hueToValidRange (myColorHlsMax[0]), myColorHlsMax[1], myColorHlsMax[2], Quantity_TOC_HLS);
theMinColor.SetValues(hueToValidRange(myColorHlsMin[0]),
myColorHlsMin[1],
myColorHlsMin[2],
Quantity_TOC_HLS);
theMaxColor.SetValues(hueToValidRange(myColorHlsMax[0]),
myColorHlsMax[1],
myColorHlsMax[2],
Quantity_TOC_HLS);
}
//! Sets color range corresponding to minimum and maximum values.
void SetColorRange (const Quantity_Color& theMinColor,
const Quantity_Color& theMaxColor)
void SetColorRange(const Quantity_Color& theMinColor, const Quantity_Color& theMaxColor)
{
theMinColor.Values(myColorHlsMin[0], myColorHlsMin[1], myColorHlsMin[2], Quantity_TOC_HLS);
theMaxColor.Values(myColorHlsMax[0], myColorHlsMax[1], myColorHlsMax[2], Quantity_TOC_HLS);
@ -202,7 +216,8 @@ public:
//! @param theColor color value to set
//! @param theIndex index in range [1, GetNumberOfIntervals()];
//! appended to the end of list if -1 is specified
Standard_EXPORT void SetIntervalColor (const Quantity_Color& theColor, const Standard_Integer theIndex);
Standard_EXPORT void SetIntervalColor(const Quantity_Color& theColor,
const Standard_Integer theIndex);
//! Returns the user specified labels.
Standard_EXPORT void GetLabels(TColStd_SequenceOfExtendedString& theLabels) const;
@ -211,11 +226,11 @@ public:
const TColStd_SequenceOfExtendedString& Labels() const { return myLabels; }
//! Sets the color scale labels.
//! The length of the sequence should be equal to GetNumberOfIntervals() or to GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true.
//! If length of the sequence does not much the number of intervals,
//! then these labels will be considered as "free" and will be located
//! at the virtual intervals corresponding to the number of labels
//! (with flag IsLabelAtBorder() having the same effect as in normal case).
//! The length of the sequence should be equal to GetNumberOfIntervals() or to
//! GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true. If length of the sequence does not
//! much the number of intervals, then these labels will be considered as "free" and will be
//! located at the virtual intervals corresponding to the number of labels (with flag
//! IsLabelAtBorder() having the same effect as in normal case).
Standard_EXPORT void SetLabels(const TColStd_SequenceOfExtendedString& theSeq);
//! Returns the user specified colors.
@ -233,7 +248,8 @@ public:
//! between consequent colors.
//! See MakeUniformColors() for description of parameters.
void SetUniformColors(Standard_Real theLightness,
Standard_Real theHueFrom, Standard_Real theHueTo)
Standard_Real theHueFrom,
Standard_Real theHueTo)
{
SetColors(MakeUniformColors(myNbIntervals, theLightness, theHueFrom, theHueTo));
SetColorType(Aspect_TOCSD_USER);
@ -254,11 +270,13 @@ public:
//! Hue value can be out of the range [0, 360], interpreted as modulo 360.
//! The colors of the scale will be in the order of increasing hue if
//! theHueTo > theHueFrom, and decreasing otherwise.
Standard_EXPORT static Aspect_SequenceOfColor
MakeUniformColors (Standard_Integer theNbColors, Standard_Real theLightness,
Standard_Real theHueFrom, Standard_Real theHueTo);
Standard_EXPORT static Aspect_SequenceOfColor MakeUniformColors(Standard_Integer theNbColors,
Standard_Real theLightness,
Standard_Real theHueFrom,
Standard_Real theHueTo);
//! Returns the position of labels concerning color filled rectangles, Aspect_TOCSP_RIGHT by default.
//! Returns the position of labels concerning color filled rectangles, Aspect_TOCSP_RIGHT by
//! default.
Aspect_TypeOfColorScalePosition GetLabelPosition() const { return myLabelPos; }
//! Sets the color scale labels position relative to color bar.
@ -269,6 +287,7 @@ public:
//! Sets the color scale title position.
Standard_DEPRECATED("AIS_ColorScale::SetTitlePosition() has no effect!")
void SetTitlePosition(const Aspect_TypeOfColorScalePosition thePos) { myTitlePos = thePos; }
//! Returns TRUE if the labels and colors used in reversed order, FALSE by default.
@ -305,9 +324,11 @@ public:
//! Sets the color scale label at index.
//! Note that list is automatically resized to include specified index.
//! @param theLabel new label text
//! @param theIndex index in range [1, GetNumberOfIntervals()] or [1, GetNumberOfIntervals() + 1] if IsLabelAtBorder() is true;
//! @param theIndex index in range [1, GetNumberOfIntervals()] or [1, GetNumberOfIntervals() + 1]
//! if IsLabelAtBorder() is true;
//! label is appended to the end of list if negative index is specified
Standard_EXPORT void SetLabel (const TCollection_ExtendedString& theLabel, const Standard_Integer theIndex);
Standard_EXPORT void SetLabel(const TCollection_ExtendedString& theLabel,
const Standard_Integer theIndex);
//! Returns the size of color bar, 0 and 0 by default
//! (e.g. should be set by user explicitly before displaying).
@ -371,7 +392,6 @@ public:
void SetTextHeight(const Standard_Integer theHeight) { myTextHeight = theHeight; }
public:
//! Returns the width of text.
//! @param[in] theText the text of which to calculate width.
Standard_EXPORT Standard_Integer TextWidth(const TCollection_ExtendedString& theText) const;
@ -387,9 +407,11 @@ public:
Standard_Integer& theDescent) const;
public:
//! Return true if specified display mode is supported.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{
return theMode == 0;
}
//! Compute presentation.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
@ -398,10 +420,11 @@ public:
//! Compute selection - not implemented for color scale.
virtual void ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
const Standard_Integer /*aMode*/) Standard_OVERRIDE {}
const Standard_Integer /*aMode*/) Standard_OVERRIDE
{
}
private:
//! Returns the size of color scale.
//! @param[out] theWidth the width of color scale.
//! @param[out] theHeight the height of color scale.
@ -429,7 +452,8 @@ private:
//! @param[in] theVertAlignment text vertical alignment
void drawText(const Handle(Graphic3d_Group)& theGroup,
const TCollection_ExtendedString& theText,
const Standard_Integer theX, const Standard_Integer theY,
const Standard_Integer theX,
const Standard_Integer theY,
const Graphic3d_VerticalTextAlignment theVertAlignment);
//! Determine the maximum text label width in pixels.
@ -457,12 +481,13 @@ private:
//! @param[in] theHeight the height of frame.
//! @param[in] theColor the color of frame.
void drawFrame(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theX, const Standard_Integer theY,
const Standard_Integer theWidth, const Standard_Integer theHeight,
const Standard_Integer theX,
const Standard_Integer theY,
const Standard_Integer theWidth,
const Standard_Integer theHeight,
const Quantity_Color& theColor);
private:
Standard_Real myMin; //!< values range - minimal value
Standard_Real myMax; //!< values range - maximal value
// clang-format off
@ -488,7 +513,6 @@ private:
Standard_Integer myHeight; //!< height of the color scale
Standard_Integer mySpacing; //!< extra spacing between element
Standard_Integer myTextHeight; //!< label font height
};
#endif

View File

@ -22,7 +22,6 @@ class AIS_ColoredDrawer : public Prs3d_Drawer
{
DEFINE_STANDARD_RTTIEXT(AIS_ColoredDrawer, Prs3d_Drawer)
public:
//! Default constructor.
AIS_ColoredDrawer(const Handle(Prs3d_Drawer)& theLink)
: myIsHidden(false),
@ -35,32 +34,39 @@ public:
}
bool IsHidden() const { return myIsHidden; }
void SetHidden(const bool theToHide) { myIsHidden = theToHide; }
bool HasOwnMaterial() const { return myHasOwnMaterial; }
void UnsetOwnMaterial() { myHasOwnMaterial = false; }
void SetOwnMaterial() { myHasOwnMaterial = true; }
bool HasOwnColor() const { return myHasOwnColor; }
void UnsetOwnColor() { myHasOwnColor = false; }
void SetOwnColor(const Quantity_Color& /*theColor*/) { myHasOwnColor = true; }
bool HasOwnTransparency() const { return myHasOwnTransp; }
void UnsetOwnTransparency() { myHasOwnTransp = false; }
void SetOwnTransparency(Standard_Real /*theTransp*/) { myHasOwnTransp = true; }
bool HasOwnWidth() const { return myHasOwnWidth; }
void UnsetOwnWidth() { myHasOwnWidth = false; }
void SetOwnWidth(const Standard_Real /*theWidth*/) { myHasOwnWidth = true; }
public: //! @name list of overridden properties
bool myIsHidden;
bool myHasOwnMaterial;
bool myHasOwnColor;
bool myHasOwnTransp;
bool myHasOwnWidth;
};
DEFINE_STANDARD_HANDLE(AIS_ColoredDrawer, Prs3d_Drawer)

View File

@ -43,25 +43,21 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_ColoredDrawer,Prs3d_Drawer)
namespace
{
//! Collect all sub-compounds into map.
static void collectSubCompounds (TopTools_MapOfShape& theMap,
const TopoDS_Shape& theShape)
static void collectSubCompounds(TopTools_MapOfShape& theMap, const TopoDS_Shape& theShape)
{
for (TopoDS_Iterator aChildIter(theShape); aChildIter.More(); aChildIter.Next())
{
const TopoDS_Shape& aShape = aChildIter.Value();
if (aShape.ShapeType() == TopAbs_COMPOUND
&& theMap.Add (aShape))
if (aShape.ShapeType() == TopAbs_COMPOUND && theMap.Add(aShape))
{
collectSubCompounds(theMap, aShape);
}
}
}
}
} // namespace
//=================================================================================================
//=======================================================================
//function : AIS_ColoredShape
//purpose :
//=======================================================================
AIS_ColoredShape::AIS_ColoredShape(const TopoDS_Shape& theShape)
: AIS_Shape(theShape)
{
@ -72,10 +68,8 @@ AIS_ColoredShape::AIS_ColoredShape (const TopoDS_Shape& theShape)
myDrawer->SetFaceBoundaryAspect(myDrawer->LineAspect());
}
//=======================================================================
//function : AIS_ColoredShape
//purpose :
//=======================================================================
//=================================================================================================
AIS_ColoredShape::AIS_ColoredShape(const Handle(AIS_Shape)& theShape)
: AIS_Shape(theShape->Shape())
{
@ -104,10 +98,8 @@ AIS_ColoredShape::AIS_ColoredShape (const Handle(AIS_Shape)& theShape)
}
}
//=======================================================================
//function : CustomAspects
//purpose :
//=======================================================================
//=================================================================================================
Handle(AIS_ColoredDrawer) AIS_ColoredShape::CustomAspects(const TopoDS_Shape& theShape)
{
Handle(AIS_ColoredDrawer) aDrawer;
@ -121,10 +113,8 @@ Handle(AIS_ColoredDrawer) AIS_ColoredShape::CustomAspects (const TopoDS_Shape& t
return aDrawer;
}
//=======================================================================
//function : ClearCustomAspects
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::ClearCustomAspects()
{
if (myShapeColors.IsEmpty())
@ -135,10 +125,8 @@ void AIS_ColoredShape::ClearCustomAspects()
SetToUpdate();
}
//=======================================================================
//function : UnsetCustomAspects
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::UnsetCustomAspects(const TopoDS_Shape& theShape,
const Standard_Boolean theToUnregister)
{
@ -157,12 +145,9 @@ void AIS_ColoredShape::UnsetCustomAspects (const TopoDS_Shape& theShape,
myShapeColors.ChangeFind(theShape) = new AIS_ColoredDrawer(myDrawer);
}
//=======================================================================
//function : SetCustomColor
//purpose :
//=======================================================================
void AIS_ColoredShape::SetCustomColor (const TopoDS_Shape& theShape,
const Quantity_Color& theColor)
//=================================================================================================
void AIS_ColoredShape::SetCustomColor(const TopoDS_Shape& theShape, const Quantity_Color& theColor)
{
if (theShape.IsNull())
{
@ -174,10 +159,8 @@ void AIS_ColoredShape::SetCustomColor (const TopoDS_Shape& theShape,
aDrawer->SetOwnColor(theColor);
}
//=======================================================================
//function : SetCustomTransparency
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::SetCustomTransparency(const TopoDS_Shape& theShape,
Standard_Real theTransparency)
{
@ -191,10 +174,8 @@ void AIS_ColoredShape::SetCustomTransparency (const TopoDS_Shape& theShape,
aDrawer->SetOwnTransparency(theTransparency);
}
//=======================================================================
//function : SetCustomWidth
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::SetCustomWidth(const TopoDS_Shape& theShape,
const Standard_Real theLineWidth)
{
@ -208,10 +189,7 @@ void AIS_ColoredShape::SetCustomWidth (const TopoDS_Shape& theShape,
aDrawer->SetOwnWidth(theLineWidth);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::SetColor(const Quantity_Color& theColor)
{
@ -243,10 +221,7 @@ void AIS_ColoredShape::SetColor (const Quantity_Color& theColor)
AIS_Shape::SetColor(theColor);
}
//=======================================================================
//function : SetWidth
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::SetWidth(const Standard_Real theLineWidth)
{
@ -274,19 +249,14 @@ void AIS_ColoredShape::SetWidth (const Standard_Real theLineWidth)
AIS_Shape::SetWidth(theLineWidth);
}
//=======================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::UnsetWidth()
{
SetWidth(1.0f);
}
//=======================================================================
//function : SetTransparency
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::SetTransparency(const Standard_Real theValue)
{
@ -306,19 +276,14 @@ void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
AIS_Shape::SetTransparency(theValue);
}
//=======================================================================
//function : UnsetTransparency
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::UnsetTransparency()
{
SetTransparency(0.0f);
}
//=======================================================================
//function : SetMaterial
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::SetMaterial(const Graphic3d_MaterialAspect& theMaterial)
{
@ -338,10 +303,8 @@ void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
AIS_Shape::SetMaterial(theMaterial);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
@ -358,8 +321,7 @@ void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager)& thePrs
switch (theMode)
{
case AIS_WireFrame:
{
case AIS_WireFrame: {
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange(myshape, myDrawer, Standard_True);
// After this call if type of deflection is relative
@ -367,16 +329,17 @@ void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager)& thePrs
StdPrs_ToolTriangulatedShape::GetDeflection(myshape, myDrawer);
break;
}
case AIS_Shaded:
{
case AIS_Shaded: {
if (myDrawer->IsAutoTriangulation())
{
// compute mesh for entire shape beforehand to ensure consistency and optimizations (parallelization)
// compute mesh for entire shape beforehand to ensure consistency and optimizations
// (parallelization)
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange(myshape, myDrawer, Standard_True);
// After this call if type of deflection is relative
// computed deflection coefficient is stored as absolute.
Standard_Boolean wasRecomputed = StdPrs_ToolTriangulatedShape::Tessellate (myshape, myDrawer);
Standard_Boolean wasRecomputed =
StdPrs_ToolTriangulatedShape::Tessellate(myshape, myDrawer);
// Set to update wireframe presentation on triangulation.
if (myDrawer->IsoOnTriangulation() && wasRecomputed)
@ -386,19 +349,18 @@ void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager)& thePrs
}
break;
}
case 2:
{
case 2: {
AIS_Shape::Compute(thePrsMgr, thePrs, theMode);
return;
}
default:
{
default: {
return;
}
}
// Extract myShapeColors map (KeyshapeColored -> Color) to subshapes map (Subshape -> Color).
// This needed when colored shape is not part of BaseShape (but subshapes are) and actually container for subshapes.
// This needed when colored shape is not part of BaseShape (but subshapes are) and actually
// container for subshapes.
AIS_DataMapOfShapeDrawer aSubshapeDrawerMap;
fillSubshapeDrawerMap(aSubshapeDrawerMap);
@ -408,16 +370,18 @@ void AIS_ColoredShape::Compute (const Handle(PrsMgr_PresentationManager)& thePrs
// myShapeColors + anOpened --> array[TopAbs_ShapeEnum] of map of color-to-compound
DataMapOfDrawerCompd aDispatchedOpened[(size_t)TopAbs_SHAPE];
DataMapOfDrawerCompd aDispatchedClosed;
dispatchColors (aBaseDrawer, myshape,
aSubshapeDrawerMap, TopAbs_COMPOUND, Standard_False,
aDispatchedOpened, theMode == AIS_Shaded ? aDispatchedClosed : aDispatchedOpened[TopAbs_FACE]);
dispatchColors(aBaseDrawer,
myshape,
aSubshapeDrawerMap,
TopAbs_COMPOUND,
Standard_False,
aDispatchedOpened,
theMode == AIS_Shaded ? aDispatchedClosed : aDispatchedOpened[TopAbs_FACE]);
addShapesWithCustomProps(thePrs, aDispatchedOpened, aDispatchedClosed, theMode);
}
//=======================================================================
//function : fillSubshapeDrawerMap
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::fillSubshapeDrawerMap(AIS_DataMapOfShapeDrawer& theSubshapeDrawerMap) const
{
// unroll compounds specified for grouping sub-shapes with the same style
@ -428,12 +392,11 @@ void AIS_ColoredShape::fillSubshapeDrawerMap (AIS_DataMapOfShapeDrawer& theSubsh
aMapOfOwnCompounds.Add(myshape);
collectSubCompounds(aMapOfOwnCompounds, myshape);
}
for (AIS_DataMapOfShapeDrawer::Iterator aKeyShapeIter (myShapeColors);
aKeyShapeIter.More(); aKeyShapeIter.Next())
for (AIS_DataMapOfShapeDrawer::Iterator aKeyShapeIter(myShapeColors); aKeyShapeIter.More();
aKeyShapeIter.Next())
{
const TopoDS_Shape& aKeyShape = aKeyShapeIter.Key();
if (aKeyShape.ShapeType() != TopAbs_COMPOUND
|| aMapOfOwnCompounds.Contains (aKeyShape))
if (aKeyShape.ShapeType() != TopAbs_COMPOUND || aMapOfOwnCompounds.Contains(aKeyShape))
{
continue;
}
@ -449,13 +412,12 @@ void AIS_ColoredShape::fillSubshapeDrawerMap (AIS_DataMapOfShapeDrawer& theSubsh
}
// assign other sub-shapes with styles
for (AIS_DataMapOfShapeDrawer::Iterator aKeyShapeIter (myShapeColors);
aKeyShapeIter.More(); aKeyShapeIter.Next())
for (AIS_DataMapOfShapeDrawer::Iterator aKeyShapeIter(myShapeColors); aKeyShapeIter.More();
aKeyShapeIter.Next())
{
const TopoDS_Shape& aKeyShape = aKeyShapeIter.Key();
if (myshape == aKeyShape
|| (aKeyShape.ShapeType() == TopAbs_COMPOUND
&& !aMapOfOwnCompounds.Contains (aKeyShape)))
|| (aKeyShape.ShapeType() == TopAbs_COMPOUND && !aMapOfOwnCompounds.Contains(aKeyShape)))
{
continue;
}
@ -464,10 +426,8 @@ void AIS_ColoredShape::fillSubshapeDrawerMap (AIS_DataMapOfShapeDrawer& theSubsh
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
@ -484,9 +444,9 @@ void AIS_ColoredShape::ComputeSelection (const Handle(SelectMgr_Selection)& theS
const TopAbs_ShapeEnum aTypOfSel = AIS_Shape::SelectionType(theMode);
const Standard_Real aDeflection = StdPrs_ToolTriangulatedShape::GetDeflection(myshape, myDrawer);
const Standard_Real aDeviationAngle = myDrawer->DeviationAngle();
const Standard_Integer aPriority = StdSelect_BRepSelectionTool::GetStandardPriority (myshape, aTypOfSel);
if (myDrawer->IsAutoTriangulation()
&& !BRepTools::Triangulation (myshape, Precision::Infinite()))
const Standard_Integer aPriority =
StdSelect_BRepSelectionTool::GetStandardPriority(myshape, aTypOfSel);
if (myDrawer->IsAutoTriangulation() && !BRepTools::Triangulation(myshape, Precision::Infinite()))
{
BRepMesh_IncrementalMesh aMesher(myshape, aDeflection, Standard_False, aDeviationAngle);
}
@ -502,21 +462,29 @@ void AIS_ColoredShape::ComputeSelection (const Handle(SelectMgr_Selection)& theS
Handle(AIS_ColoredDrawer) aBaseDrawer;
myShapeColors.Find(myshape, aBaseDrawer);
computeSubshapeSelection (aBaseDrawer, aSubshapeDrawerMap, myshape, aBrepOwner, theSelection,
aTypOfSel, aPriority, aDeflection, aDeviationAngle);
computeSubshapeSelection(aBaseDrawer,
aSubshapeDrawerMap,
myshape,
aBrepOwner,
theSelection,
aTypOfSel,
aPriority,
aDeflection,
aDeviationAngle);
Handle(SelectMgr_SelectableObject) aThis(this);
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
theSelection->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
const Handle(SelectMgr_EntityOwner)& anOwner = aSelEntIter.Value()->BaseSensitive()->OwnerId();
anOwner->SetSelectable(aThis);
}
}
//=======================================================================
//function : computeSubshapeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::computeSubshapeSelection(const Handle(AIS_ColoredDrawer)& theParentDrawer,
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const TopoDS_Shape& theShape,
@ -529,44 +497,60 @@ void AIS_ColoredShape::computeSubshapeSelection (const Handle(AIS_ColoredDrawer)
{
Handle(AIS_ColoredDrawer) aDrawer = theParentDrawer;
theShapeDrawerMap.Find(theShape, aDrawer);
if (!aDrawer.IsNull()
&& aDrawer->IsHidden())
if (!aDrawer.IsNull() && aDrawer->IsHidden())
{
return;
}
const Standard_Integer aNbPOnEdge = 9;
const Standard_Real aMaximalParameter = 500.0;
if (theTypOfSel == TopAbs_SHAPE
&& theShape.ShapeType() >= TopAbs_FACE)
if (theTypOfSel == TopAbs_SHAPE && theShape.ShapeType() >= TopAbs_FACE)
{
StdSelect_BRepSelectionTool::ComputeSensitive (theShape, theOwner, theSelection,
theDeflection, theDeflAngle, aNbPOnEdge, aMaximalParameter, myDrawer->IsAutoTriangulation());
StdSelect_BRepSelectionTool::ComputeSensitive(theShape,
theOwner,
theSelection,
theDeflection,
theDeflAngle,
aNbPOnEdge,
aMaximalParameter,
myDrawer->IsAutoTriangulation());
return;
}
else if (theShape.ShapeType() == theTypOfSel)
{
const Standard_Boolean isComesFromDecomposition = !theShape.IsEqual(myshape);
Handle(StdSelect_BRepOwner) aBrepOwner = new StdSelect_BRepOwner (theShape, thePriority, isComesFromDecomposition);
StdSelect_BRepSelectionTool::ComputeSensitive (theShape, aBrepOwner, theSelection,
theDeflection, theDeflAngle, aNbPOnEdge, aMaximalParameter, myDrawer->IsAutoTriangulation());
Handle(StdSelect_BRepOwner) aBrepOwner =
new StdSelect_BRepOwner(theShape, thePriority, isComesFromDecomposition);
StdSelect_BRepSelectionTool::ComputeSensitive(theShape,
aBrepOwner,
theSelection,
theDeflection,
theDeflAngle,
aNbPOnEdge,
aMaximalParameter,
myDrawer->IsAutoTriangulation());
return;
}
for (TopoDS_Iterator aSubShapeIter(theShape); aSubShapeIter.More(); aSubShapeIter.Next())
{
const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
computeSubshapeSelection (aDrawer, theShapeDrawerMap, aSubShape,
theOwner, theSelection, theTypOfSel, thePriority,
theDeflection, theDeflAngle);
computeSubshapeSelection(aDrawer,
theShapeDrawerMap,
aSubShape,
theOwner,
theSelection,
theTypOfSel,
thePriority,
theDeflection,
theDeflAngle);
}
}
//=======================================================================
//function : addShapesWithCustomProps
//purpose :
//=======================================================================
void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation)& thePrs,
//=================================================================================================
void AIS_ColoredShape::addShapesWithCustomProps(
const Handle(Prs3d_Presentation)& thePrs,
const DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
const DataMapOfDrawerCompd& theDrawerClosedFaces,
const Standard_Integer theMode)
@ -576,11 +560,9 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
{
const Standard_Boolean isClosed = aShType == TopAbs_SHAPE;
Handle(Graphic3d_Group)& aShadedGroup = isClosed ? aClosedGroup : anOpenGroup;
const DataMapOfDrawerCompd& aDrawerShapeMap = isClosed
? theDrawerClosedFaces
: theDrawerOpenedShapePerType[aShType];
for (DataMapOfDrawerCompd::Iterator aMapIter (aDrawerShapeMap);
aMapIter.More(); aMapIter.Next())
const DataMapOfDrawerCompd& aDrawerShapeMap =
isClosed ? theDrawerClosedFaces : theDrawerOpenedShapePerType[aShType];
for (DataMapOfDrawerCompd::Iterator aMapIter(aDrawerShapeMap); aMapIter.More(); aMapIter.Next())
{
const Handle(AIS_ColoredDrawer)& aCustomDrawer = aMapIter.Key();
// clang-format off
@ -609,9 +591,7 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
// Draw each kind of subshapes and personal-colored shapes in a separate group
// since it's necessary to set transparency/material for all subshapes
// without affecting their unique colors
if (theMode == AIS_Shaded
&& aShapeDraw.ShapeType() <= TopAbs_FACE
&& !IsInfinite())
if (theMode == AIS_Shaded && aShapeDraw.ShapeType() <= TopAbs_FACE && !IsInfinite())
{
// add wireframe presentation for isolated edges and vertices
StdPrs_ShadedShape::AddWireframeForFreeElements(thePrs, aShapeDraw, aDrawer);
@ -619,10 +599,13 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
// add special wireframe presentation for faces without triangulation
StdPrs_ShadedShape::AddWireframeForFacesWithoutTriangles(thePrs, aShapeDraw, aDrawer);
Handle(Graphic3d_ArrayOfTriangles) aTriangles = StdPrs_ShadedShape::FillTriangles (aShapeDraw,
Handle(Graphic3d_ArrayOfTriangles) aTriangles = StdPrs_ShadedShape::FillTriangles(
aShapeDraw,
aDrawer->ShadingAspect()->Aspect()->ToMapTexture()
&& !aDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
myUVOrigin, myUVRepeat, myUVScale);
myUVOrigin,
myUVRepeat,
myUVScale);
if (!aTriangles.IsNull())
{
if (aShadedGroup.IsNull())
@ -636,7 +619,9 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
if (aDrawer->FaceBoundaryDraw())
{
if (Handle(Graphic3d_ArrayOfSegments) aBndSegments = StdPrs_ShadedShape::FillFaceBoundaries (aShapeDraw, aDrawer->FaceBoundaryUpperContinuity()))
if (Handle(Graphic3d_ArrayOfSegments) aBndSegments =
StdPrs_ShadedShape::FillFaceBoundaries(aShapeDraw,
aDrawer->FaceBoundaryUpperContinuity()))
{
if (anEdgesGroup.IsNull())
{
@ -657,10 +642,8 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
}
}
//=======================================================================
//function : dispatchColors
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ColoredShape::dispatchColors(const Handle(AIS_ColoredDrawer)& theParentDrawer,
const TopoDS_Shape& theShapeToParse,
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
@ -678,8 +661,7 @@ Standard_Boolean AIS_ColoredShape::dispatchColors (const Handle(AIS_ColoredDrawe
// check own setting of current shape
Handle(AIS_ColoredDrawer) aDrawer = theParentDrawer;
const Standard_Boolean isOverriden = theShapeDrawerMap.Find(theShapeToParse, aDrawer);
if (isOverriden
&& aDrawer->IsHidden())
if (isOverriden && aDrawer->IsHidden())
{
return Standard_True;
}
@ -689,8 +671,8 @@ Standard_Boolean AIS_ColoredShape::dispatchColors (const Handle(AIS_ColoredDrawe
if (aShapeType <= TopAbs_SHELL)
{
// detect parts of closed solids
Standard_Boolean isClosedShell = theParentType == TopAbs_SOLID
&& aShapeType == TopAbs_SHELL
Standard_Boolean isClosedShell =
theParentType == TopAbs_SOLID && aShapeType == TopAbs_SHELL
&& BRep_Tool::IsClosed(theShapeToParse)
&& StdPrs_ToolTriangulatedShape::IsTriangulated(theShapeToParse);
if (isClosedShell)
@ -699,8 +681,7 @@ Standard_Boolean AIS_ColoredShape::dispatchColors (const Handle(AIS_ColoredDrawe
{
const TopoDS_Shape& aFace = aFaceIter.Value();
Handle(AIS_ColoredDrawer) aFaceDrawer;
if (aFace.ShapeType() != TopAbs_FACE
|| !theShapeDrawerMap.Find (aFace, aFaceDrawer))
if (aFace.ShapeType() != TopAbs_FACE || !theShapeDrawerMap.Find(aFace, aFaceDrawer))
{
continue;
}
@ -711,7 +692,8 @@ Standard_Boolean AIS_ColoredShape::dispatchColors (const Handle(AIS_ColoredDrawe
break;
}
else if (aFaceDrawer->HasOwnShadingAspect()
&& aFaceDrawer->ShadingAspect()->Aspect()->AlphaMode() != Graphic3d_AlphaMode_Opaque)
&& aFaceDrawer->ShadingAspect()->Aspect()->AlphaMode()
!= Graphic3d_AlphaMode_Opaque)
{
if (aFaceDrawer->ShadingAspect()->Aspect()->AlphaMode() != Graphic3d_AlphaMode_BlendAuto
|| aFaceDrawer->ShadingAspect()->Aspect()->FrontMaterial().Alpha() < 1.0f
@ -728,8 +710,10 @@ Standard_Boolean AIS_ColoredShape::dispatchColors (const Handle(AIS_ColoredDrawe
for (TopoDS_Iterator aSubShapeIter(theShapeToParse); aSubShapeIter.More(); aSubShapeIter.Next())
{
const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
if (dispatchColors (aDrawer, aSubShape,
theShapeDrawerMap, aShapeType,
if (dispatchColors(aDrawer,
aSubShape,
theShapeDrawerMap,
aShapeType,
isClosedShell,
theDrawerOpenedShapePerType,
theDrawerClosedFaces))
@ -748,8 +732,10 @@ Standard_Boolean AIS_ColoredShape::dispatchColors (const Handle(AIS_ColoredDrawe
for (TopoDS_Iterator aSubShapeIter(theShapeToParse); aSubShapeIter.More(); aSubShapeIter.Next())
{
const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
if (dispatchColors (aDrawer, aSubShape,
theShapeDrawerMap, aShapeType,
if (dispatchColors(aDrawer,
aSubShape,
theShapeDrawerMap,
aShapeType,
theIsParentClosed,
theDrawerOpenedShapePerType,
theDrawerClosedFaces))
@ -773,13 +759,14 @@ Standard_Boolean AIS_ColoredShape::dispatchColors (const Handle(AIS_ColoredDrawe
// if any of styles is overridden regarding to default one, add rest to map
if (isOverriden
|| (isSubOverride && theParentType != TopAbs_WIRE // avoid drawing edges when vertex color is overridden
|| (isSubOverride
&& theParentType != TopAbs_WIRE // avoid drawing edges when vertex color is overridden
&& theParentType != TopAbs_FACE) // avoid drawing edges of the same color as face
|| (theParentType <= TopAbs_SHELL && !(isOverriden || isSubOverride))) // bind original shape to default color
|| (theParentType <= TopAbs_SHELL
&& !(isOverriden || isSubOverride))) // bind original shape to default color
{
TopoDS_Compound aCompound;
DataMapOfDrawerCompd& aDrawerShapeMap = theIsParentClosed
&& aShapeType == TopAbs_FACE
DataMapOfDrawerCompd& aDrawerShapeMap = theIsParentClosed && aShapeType == TopAbs_FACE
? theDrawerClosedFaces
: theDrawerOpenedShapePerType[(size_t)aShapeType];
if (!aDrawerShapeMap.FindFromKey(aDrawer, aCompound))
@ -792,10 +779,8 @@ Standard_Boolean AIS_ColoredShape::dispatchColors (const Handle(AIS_ColoredDrawe
return isOverriden || isSubOverride;
}
//=======================================================================
//function : isShapeEntirelyVisible
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ColoredShape::isShapeEntirelyVisible() const
{
for (AIS_DataMapOfShapeDrawer::Iterator aMapIter(myShapeColors); aMapIter.More(); aMapIter.Next())
@ -808,10 +793,8 @@ Standard_Boolean AIS_ColoredShape::isShapeEntirelyVisible() const
return Standard_True;
}
//=======================================================================
//function : bindSubShapes
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ColoredShape::bindSubShapes(AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const TopoDS_Shape& theKeyShape,
const Handle(AIS_ColoredDrawer)& theDrawer) const

View File

@ -28,7 +28,6 @@ class StdSelect_BRepOwner;
class AIS_ColoredShape : public AIS_Shape
{
public:
//! Default constructor
Standard_EXPORT AIS_ColoredShape(const TopoDS_Shape& theShape);
@ -36,7 +35,6 @@ public:
Standard_EXPORT AIS_ColoredShape(const Handle(AIS_Shape)& theShape);
public: //! @name sub-shape aspects
//! Customize properties of specified sub-shape.
//! The shape will be stored in the map but ignored, if it is not sub-shape of main Shape!
//! This method can be used to mark sub-shapes with customizable properties.
@ -51,8 +49,7 @@ public: //! @name sub-shape aspects
const Standard_Boolean theToUnregister = Standard_False);
//! Customize color of specified sub-shape
Standard_EXPORT void SetCustomColor (const TopoDS_Shape& theShape,
const Quantity_Color& theColor);
Standard_EXPORT void SetCustomColor(const TopoDS_Shape& theShape, const Quantity_Color& theColor);
//! Customize transparency of specified sub-shape
Standard_EXPORT void SetCustomTransparency(const TopoDS_Shape& theShape,
@ -69,7 +66,6 @@ public: //! @name sub-shape aspects
AIS_DataMapOfShapeDrawer& ChangeCustomAspectsMap() { return myShapeColors; }
public: //! @name global aspects
//! Setup color of entire shape.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
@ -80,10 +76,10 @@ public: //! @name global aspects
Standard_EXPORT virtual void SetTransparency(const Standard_Real theValue) Standard_OVERRIDE;
//! Sets the material aspect.
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
Standard_EXPORT virtual void SetMaterial(const Graphic3d_MaterialAspect& theAspect)
Standard_OVERRIDE;
public:
//! Removes the setting for transparency in the reconstructed compound shape.
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
@ -91,7 +87,6 @@ public:
Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE;
protected: //! @name override presentation computation
//! Compute presentation considering sub-shape color map.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
@ -102,11 +97,10 @@ protected: //! @name override presentation computation
const Standard_Integer theMode) Standard_OVERRIDE;
protected:
typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound> DataMapOfDrawerCompd;
typedef NCollection_IndexedDataMap<Handle(AIS_ColoredDrawer), TopoDS_Compound>
DataMapOfDrawerCompd;
protected:
//! Recursive function to map shapes.
//! @param theParentDrawer the drawer to be used for undetailed shapes (default colors)
//! @param theShapeToParse the subshape to be recursively parsed
@ -115,17 +109,19 @@ protected:
//! @param theIsParentClosed flag indicating that specified shape is part of closed Solid
//! @param theDrawerOpenedShapePerType the array of shape types to fill
//! @param theDrawerClosedFaces the map for closed faces
Standard_EXPORT static Standard_Boolean dispatchColors (const Handle(AIS_ColoredDrawer)& theParentDrawer,
Standard_EXPORT static Standard_Boolean dispatchColors(
const Handle(AIS_ColoredDrawer)& theParentDrawer,
const TopoDS_Shape& theShapeToParse,
const AIS_DataMapOfShapeDrawer& theShapeDrawerMap,
const TopAbs_ShapeEnum theParentType,
const Standard_Boolean theIsParentClosed,
DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
DataMapOfDrawerCompd& theDrawerClosedFaces);
protected:
protected:
//! Extract myShapeColors map (KeyshapeColored -> Color) to subshapes map (Subshape -> Color).
//! This needed when colored shape is not part of BaseShape (but subshapes are) and actually container for subshapes.
//! This needed when colored shape is not part of BaseShape (but subshapes are) and actually
//! container for subshapes.
Standard_EXPORT void fillSubshapeDrawerMap(AIS_DataMapOfShapeDrawer& theSubshapeDrawerMap) const;
//! Add shape to presentation
@ -133,7 +129,8 @@ protected:
//! @param theDrawerOpenedShapePerType the shapes map with unique attributes
//! @param theDrawerClosedFaces the map of attributes for closed faces
//! @param theMode display mode
Standard_EXPORT void addShapesWithCustomProps (const Handle(Prs3d_Presentation)& thePrs,
Standard_EXPORT void addShapesWithCustomProps(
const Handle(Prs3d_Presentation)& thePrs,
const DataMapOfDrawerCompd* theDrawerOpenedShapePerType,
const DataMapOfDrawerCompd& theDrawerClosedFaces,
const Standard_Integer theMode);
@ -143,7 +140,8 @@ protected:
//! Resolve (parse) theKeyShape into subshapes, search in they for theBaseShape,
//! bind all resolved subshapes with theOriginKeyShape and store all binds in theShapeDrawerMap
//! @param theShapeDrawerMap shapes map: resolved and found theBaseShape subshape -> theOriginKeyShape
//! @param theShapeDrawerMap shapes map: resolved and found theBaseShape subshape ->
//! theOriginKeyShape
//! @param theKeyShape a shape to be resolved (parse) into smaller (in topological sense)
//! subshapes for new bind cycle
//! @param theDrawer assigned drawer
@ -171,13 +169,10 @@ protected:
const Standard_Real theDeflAngle);
protected:
AIS_DataMapOfShapeDrawer myShapeColors;
public:
DEFINE_STANDARD_RTTIEXT(AIS_ColoredShape, AIS_Shape)
};
DEFINE_STANDARD_HANDLE(AIS_ColoredShape, AIS_Shape)

View File

@ -33,20 +33,17 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject)
//=======================================================================
//function : AIS_ConnectedInteractive
//purpose :
//=======================================================================
AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
AIS_InteractiveObject(aTypeOfPresentation3d)
//=================================================================================================
AIS_ConnectedInteractive::AIS_ConnectedInteractive(
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: AIS_InteractiveObject(aTypeOfPresentation3d)
{
//
}
//=======================================================================
//function : connect
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ConnectedInteractive::connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
const Handle(TopLoc_Datum3D)& theLocation)
{
@ -56,7 +53,8 @@ void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& the
return;
}
Handle(AIS_ConnectedInteractive) aConnected = Handle(AIS_ConnectedInteractive)::DownCast (theAnotherObj);
Handle(AIS_ConnectedInteractive) aConnected =
Handle(AIS_ConnectedInteractive)::DownCast(theAnotherObj);
if (!aConnected.IsNull())
{
myReference = aConnected->myReference;
@ -67,7 +65,8 @@ void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& the
}
else
{
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - object without own presentation can not be connected");
throw Standard_ProgramError(
"AIS_ConnectedInteractive::Connect() - object without own presentation can not be connected");
}
if (!myReference.IsNull())
@ -76,17 +75,15 @@ void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& the
&& myReference->GetContext()->DisplayStatus(myReference) != AIS_DS_None)
{
myReference.Nullify();
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - connected object should NOT be displayed in context");
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - connected object should "
"NOT be displayed in context");
}
myTypeOfPresentation3d = myReference->TypeOfPresentation3d();
}
setLocalTransformation(theLocation);
}
//=======================================================================
//function : Disconnect
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ConnectedInteractive::Disconnect()
{
@ -99,10 +96,9 @@ void AIS_ConnectedInteractive::Disconnect()
}
}
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ConnectedInteractive::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
@ -129,16 +125,13 @@ void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager)
}
}
//=======================================================================
//function : computeHLR
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ConnectedInteractive::computeHLR(const Handle(Graphic3d_Camera)& theProjector,
const Handle(TopLoc_Datum3D)& theTransformation,
const Handle(Prs3d_Presentation)& thePresentation)
{
const bool hasTrsf = !theTransformation.IsNull()
&& theTransformation->Form() != gp_Identity;
const bool hasTrsf = !theTransformation.IsNull() && theTransformation->Form() != gp_Identity;
updateShape(!hasTrsf);
if (myShape.IsNull())
{
@ -156,10 +149,8 @@ void AIS_ConnectedInteractive::computeHLR (const Handle(Graphic3d_Camera)& thePr
}
}
//=======================================================================
//function : updateShape
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ConnectedInteractive::updateShape(const Standard_Boolean isWithLocation)
{
Handle(AIS_Shape) anAisShape = Handle(AIS_Shape)::DownCast(myReference);
@ -184,10 +175,8 @@ void AIS_ConnectedInteractive::updateShape (const Standard_Boolean isWithLocatio
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
@ -218,7 +207,10 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio
myReference->RecomputePrimitives(theMode);
}
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (TheRefSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
TheRefSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
if (const Handle(Select3D_SensitiveEntity)& aSensitive = aSelEntIter.Value()->BaseSensitive())
{
@ -232,16 +224,14 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio
}
}
//=======================================================================
//function : ComputeSubShapeSelection
//purpose :
//=======================================================================
void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection,
//=================================================================================================
void AIS_ConnectedInteractive::computeSubShapeSelection(
const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
typedef NCollection_List<Handle(Select3D_SensitiveEntity)> SensitiveList;
typedef NCollection_DataMap<TopoDS_Shape, SensitiveList>
Shapes2EntitiesMap;
typedef NCollection_DataMap<TopoDS_Shape, SensitiveList> Shapes2EntitiesMap;
if (!myReference->HasSelection(theMode))
{
@ -256,11 +246,15 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_
// Fill in the map of subshapes and corresponding sensitive entities associated with aMode
Shapes2EntitiesMap aShapes2EntitiesMap;
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aRefSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
aRefSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
if (const Handle(Select3D_SensitiveEntity)& aSE = aSelEntIter.Value()->BaseSensitive())
{
if (Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (aSE->OwnerId()))
if (Handle(StdSelect_BRepOwner) anOwner =
Handle(StdSelect_BRepOwner)::DownCast(aSE->OwnerId()))
{
const TopoDS_Shape& aSubShape = anOwner->Shape();
if (!aShapes2EntitiesMap.IsBound(aSubShape))
@ -276,7 +270,11 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_
for (Shapes2EntitiesMap::Iterator aMapIt(aShapes2EntitiesMap); aMapIt.More(); aMapIt.Next())
{
const SensitiveList& aSEList = aMapIt.Value();
Handle(StdSelect_BRepOwner) anOwner = new StdSelect_BRepOwner (aMapIt.Key(), this, aSEList.First()->OwnerId()->Priority(), Standard_True);
Handle(StdSelect_BRepOwner) anOwner =
new StdSelect_BRepOwner(aMapIt.Key(),
this,
aSEList.First()->OwnerId()->Priority(),
Standard_True);
anOwner->SetLocation(Transformation());
for (SensitiveList::Iterator aListIt(aSEList); aListIt.More(); aListIt.Next())
{

View File

@ -37,34 +37,45 @@ class AIS_ConnectedInteractive : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject)
public:
//! Disconnects the previous view and sets highlight
//! mode to 0. This highlights the wireframe presentation
//! aTypeOfPresentation3d.
//! Top_AllView deactivates hidden line removal.
Standard_EXPORT AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
Standard_EXPORT AIS_ConnectedInteractive(
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
//! Returns KOI_Object
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Object; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Object;
}
//! Returns 0
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; }
//! Establishes the connection between the Connected
//! Interactive Object, anotherIobj, and its reference.
void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) { connect (theAnotherObj, Handle(TopLoc_Datum3D)()); }
void Connect(const Handle(AIS_InteractiveObject)& theAnotherObj)
{
connect(theAnotherObj, Handle(TopLoc_Datum3D)());
}
//! Establishes the connection between the Connected
//! Interactive Object, anotherIobj, and its reference.
//! Locates instance in aLocation.
void Connect(const Handle(AIS_InteractiveObject)& theAnotherObj, const gp_Trsf& theLocation)
{
connect(theAnotherObj, new TopLoc_Datum3D(theLocation));
}
//! Establishes the connection between the Connected
//! Interactive Object, anotherIobj, and its reference.
//! Locates instance in aLocation.
void Connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
const gp_Trsf& theLocation) { connect (theAnotherObj, new TopLoc_Datum3D (theLocation)); }
//! Establishes the connection between the Connected
//! Interactive Object, anotherIobj, and its reference.
//! Locates instance in aLocation.
void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
const Handle(TopLoc_Datum3D)& theLocation) { connect (theAnotherObj, theLocation); }
const Handle(TopLoc_Datum3D)& theLocation)
{
connect(theAnotherObj, theLocation);
}
//! Returns true if there is a connection established
//! between the presentation and its source reference.
@ -88,12 +99,10 @@ public:
//! Return true if reference presentation accepts specified display mode.
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{
return myReference.IsNull()
|| myReference->AcceptDisplayMode (theMode);
return myReference.IsNull() || myReference->AcceptDisplayMode(theMode);
}
protected:
//! Calculates the view aPresentation and its updates.
//! The latter are managed by aPresentationManager.
//! The display mode aMode is 0 by default.
@ -110,17 +119,20 @@ protected:
//! Computes the presentation according to a point of view.
Standard_EXPORT virtual void computeHLR(const Handle(Graphic3d_Camera)& theProjector,
const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE;
const Handle(Prs3d_Presentation)& thePrs)
Standard_OVERRIDE;
//! Generates sensitive entities by copying
//! them from myReference selection, creates and sets an entity
//! owner for this entities and adds them to theSelection
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Generates sensitive entities by copying
//! them from myReference sub shapes selection, creates and sets an entity
//! owner for this entities and adds them to theSelection
Standard_EXPORT void computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode);
Standard_EXPORT void computeSubShapeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode);
Standard_EXPORT void updateShape(const Standard_Boolean WithLocation = Standard_True);
@ -128,10 +140,8 @@ protected:
const Handle(TopLoc_Datum3D)& theLocation);
protected:
Handle(AIS_InteractiveObject) myReference;
TopoDS_Shape myShape;
};
DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject)

View File

@ -11,7 +11,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef AIS_DataMapIteratorOfDataMapOfIOStatus_HeaderFile
#define AIS_DataMapIteratorOfDataMapOfIOStatus_HeaderFile

View File

@ -21,8 +21,9 @@
#include <AIS_GlobalStatus.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<Handle(AIS_InteractiveObject),Handle(AIS_GlobalStatus)> AIS_DataMapOfIOStatus;
typedef NCollection_DataMap<Handle(AIS_InteractiveObject),Handle(AIS_GlobalStatus)>::Iterator AIS_DataMapIteratorOfDataMapOfIOStatus;
typedef NCollection_DataMap<Handle(AIS_InteractiveObject), Handle(AIS_GlobalStatus)>
AIS_DataMapOfIOStatus;
typedef NCollection_DataMap<Handle(AIS_InteractiveObject), Handle(AIS_GlobalStatus)>::Iterator
AIS_DataMapIteratorOfDataMapOfIOStatus;
#endif

View File

@ -18,6 +18,7 @@
#include <NCollection_DataMap.hxx>
#include <TopTools_ShapeMapHasher.hxx>
typedef NCollection_DataMap<TopoDS_Shape, Handle(AIS_ColoredDrawer), TopTools_ShapeMapHasher> AIS_DataMapOfShapeDrawer;
typedef NCollection_DataMap<TopoDS_Shape, Handle(AIS_ColoredDrawer), TopTools_ShapeMapHasher>
AIS_DataMapOfShapeDrawer;
#endif // _AIS_DataMapOfShapeDrawer_HeaderFile

View File

@ -17,7 +17,6 @@
#ifndef _AIS_DisplayMode_HeaderFile
#define _AIS_DisplayMode_HeaderFile
//! Sets display modes other than neutral point ones,
//! for interactive objects. The possibilities include:
//! - wireframe,

View File

@ -14,7 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AIS_ExclusionFilter.hxx>
#include <AIS_InteractiveObject.hxx>
#include <SelectMgr_EntityOwner.hxx>
@ -24,18 +23,16 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_ExclusionFilter, SelectMgr_Filter)
//=======================================================================
//function : AIS_ExclusionFilter
//purpose : Constructors
//=======================================================================
AIS_ExclusionFilter::AIS_ExclusionFilter(const Standard_Boolean ExclusionFlagOn):
myIsExclusionFlagOn(ExclusionFlagOn)
//=================================================================================================
AIS_ExclusionFilter::AIS_ExclusionFilter(const Standard_Boolean ExclusionFlagOn)
: myIsExclusionFlagOn(ExclusionFlagOn)
{
}
AIS_ExclusionFilter::AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude,
const Standard_Boolean ExclusionFlagOn):
myIsExclusionFlagOn(ExclusionFlagOn)
const Standard_Boolean ExclusionFlagOn)
: myIsExclusionFlagOn(ExclusionFlagOn)
{
TColStd_ListOfInteger L;
myStoredTypes.Bind((Standard_Integer)TypeToExclude, L);
@ -43,18 +40,16 @@ myIsExclusionFlagOn(ExclusionFlagOn)
AIS_ExclusionFilter::AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType,
const Standard_Boolean ExclusionFlagOn):
myIsExclusionFlagOn(ExclusionFlagOn)
const Standard_Boolean ExclusionFlagOn)
: myIsExclusionFlagOn(ExclusionFlagOn)
{
TColStd_ListOfInteger L;
L.Append(SignatureInType);
myStoredTypes.Bind((Standard_Integer)TypeToExclude, L);
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExclude)
{
if (IsStored(TypeToExclude))
@ -67,7 +62,8 @@ Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExcl
Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType)
{
if(!IsStored(TypeToExclude)){
if (!IsStored(TypeToExclude))
{
TColStd_ListOfInteger L;
L.Append(SignatureInType);
myStoredTypes.Bind((Standard_Integer)TypeToExclude, L);
@ -78,14 +74,12 @@ Standard_Boolean AIS_ExclusionFilter::Add(const AIS_KindOfInteractive TypeToExcl
return Standard_True;
}
//=======================================================================
//function : Remove
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToExclude)
{
if(!IsStored(TypeToExclude)) return Standard_False;
if (!IsStored(TypeToExclude))
return Standard_False;
myStoredTypes((Standard_Integer)TypeToExclude).Clear();
myStoredTypes.UnBind((Standard_Integer)TypeToExclude);
return Standard_True;
@ -94,10 +88,13 @@ Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToE
Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType)
{
if(!IsStored(TypeToExclude)) return Standard_False;
if (!IsStored(TypeToExclude))
return Standard_False;
TColStd_ListOfInteger& LL = myStoredTypes.ChangeFind((Standard_Integer)TypeToExclude);
for(TColStd_ListIteratorOfListOfInteger it(LL);it.More();it.Next()){
if(it.Value()==SignatureInType){
for (TColStd_ListIteratorOfListOfInteger it(LL); it.More(); it.Next())
{
if (it.Value() == SignatureInType)
{
LL.Remove(it);
return Standard_True;
}
@ -105,11 +102,7 @@ Standard_Boolean AIS_ExclusionFilter::Remove(const AIS_KindOfInteractive TypeToE
return Standard_False;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ExclusionFilter::Clear()
{
@ -119,37 +112,30 @@ void AIS_ExclusionFilter::Clear()
myStoredTypes.Clear();
}
//=======================================================================
//function : IsStored
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ExclusionFilter::IsStored(const AIS_KindOfInteractive aType) const
{
return myStoredTypes.IsBound(Standard_Integer(aType));
}
//=======================================================================
//function : IsSignatureIn
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ExclusionFilter::IsSignatureIn(const AIS_KindOfInteractive aType,
const Standard_Integer SignatureInType) const
{
if(!myStoredTypes.IsBound(aType)) return Standard_False;
for(TColStd_ListIteratorOfListOfInteger Lit(myStoredTypes((Standard_Integer)aType));
Lit.More();
Lit.Next()){
if (!myStoredTypes.IsBound(aType))
return Standard_False;
for (TColStd_ListIteratorOfListOfInteger Lit(myStoredTypes((Standard_Integer)aType)); Lit.More();
Lit.Next())
{
if (Lit.Value() == SignatureInType)
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : ListOfStoredTypes
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ExclusionFilter::ListOfStoredTypes(TColStd_ListOfInteger& TheList) const
{
@ -159,12 +145,10 @@ void AIS_ExclusionFilter::ListOfStoredTypes(TColStd_ListOfInteger& TheList) cons
TheList.Append(MIT.Key());
}
//=======================================================================
//function : ListOfSignature
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ExclusionFilter::ListOfSignature(const AIS_KindOfInteractive aType,TColStd_ListOfInteger& TheStoredList) const
void AIS_ExclusionFilter::ListOfSignature(const AIS_KindOfInteractive aType,
TColStd_ListOfInteger& TheStoredList) const
{
TheStoredList.Clear();
if (IsStored(aType))
@ -172,10 +156,7 @@ void AIS_ExclusionFilter::ListOfSignature(const AIS_KindOfInteractive aType,TCol
TheStoredList.Append(it.Value());
}
//=======================================================================
//function : IsOk
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ExclusionFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{
@ -200,10 +181,3 @@ Standard_Boolean AIS_ExclusionFilter::IsOk(const Handle(SelectMgr_EntityOwner)&
return myIsExclusionFlagOn;
}

View File

@ -48,8 +48,6 @@ class AIS_ExclusionFilter : public SelectMgr_Filter
{
public:
//! Constructs an empty exclusion filter object defined by
//! the flag setting ExclusionFlagOn.
//! By default, the flag is set to true.
@ -57,24 +55,30 @@ public:
//! All the AIS objects of <TypeToExclude>
//! Will be rejected by the IsOk Method.
Standard_EXPORT AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude, const Standard_Boolean ExclusionFlagOn = Standard_True);
Standard_EXPORT AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude,
const Standard_Boolean ExclusionFlagOn = Standard_True);
//! Constructs an exclusion filter object defined by the
//! enumeration value TypeToExclude, the signature
//! SignatureInType, and the flag setting ExclusionFlagOn.
//! By default, the flag is set to true.
Standard_EXPORT AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude, const Standard_Integer SignatureInType, const Standard_Boolean ExclusionFlagOn = Standard_True);
Standard_EXPORT AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType,
const Standard_Boolean ExclusionFlagOn = Standard_True);
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anObj) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
Standard_OVERRIDE;
//! Adds the type TypeToExclude to the list of types.
Standard_EXPORT Standard_Boolean Add(const AIS_KindOfInteractive TypeToExclude);
Standard_EXPORT Standard_Boolean Add (const AIS_KindOfInteractive TypeToExclude, const Standard_Integer SignatureInType);
Standard_EXPORT Standard_Boolean Add(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType);
Standard_EXPORT Standard_Boolean Remove(const AIS_KindOfInteractive TypeToExclude);
Standard_EXPORT Standard_Boolean Remove (const AIS_KindOfInteractive TypeToExclude, const Standard_Integer SignatureInType);
Standard_EXPORT Standard_Boolean Remove(const AIS_KindOfInteractive TypeToExclude,
const Standard_Integer SignatureInType);
Standard_EXPORT void Clear();
@ -86,17 +90,17 @@ public:
Standard_EXPORT void ListOfStoredTypes(TColStd_ListOfInteger& TheList) const;
Standard_EXPORT void ListOfSignature (const AIS_KindOfInteractive aType, TColStd_ListOfInteger& TheStoredList) const;
Standard_EXPORT void ListOfSignature(const AIS_KindOfInteractive aType,
TColStd_ListOfInteger& TheStoredList) const;
DEFINE_STANDARD_RTTIEXT(AIS_ExclusionFilter, SelectMgr_Filter)
private:
Standard_EXPORT Standard_Boolean IsSignatureIn (const AIS_KindOfInteractive aType, const Standard_Integer aSignature) const;
Standard_EXPORT Standard_Boolean IsSignatureIn(const AIS_KindOfInteractive aType,
const Standard_Integer aSignature) const;
Standard_Boolean myIsExclusionFlagOn;
TColStd_DataMapOfIntegerListOfInteger myStoredTypes;
};
#endif // _AIS_ExclusionFilter_HeaderFile

View File

@ -31,7 +31,6 @@ class AIS_GlobalStatus : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient)
public:
//! Default constructor.
Standard_EXPORT AIS_GlobalStatus();
@ -80,23 +79,18 @@ public:
}
//! Remove all selection modes.
void ClearSelectionModes()
{
mySelModes.Clear();
}
void ClearSelectionModes() { mySelModes.Clear(); }
Standard_Boolean IsSubIntensityOn() const { return mySubInt; }
void SetSubIntensity(Standard_Boolean theIsOn) { mySubInt = theIsOn; }
private:
TColStd_ListOfInteger mySelModes;
Handle(Prs3d_Drawer) myHiStyle;
Standard_Integer myDispMode;
Standard_Boolean myIsHilit;
Standard_Boolean mySubInt;
};
#endif // _AIS_GlobalStatus_HeaderFile

View File

@ -14,7 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AIS_GraphicTool.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_MaterialAspect.hxx>
@ -68,14 +67,17 @@ static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr,
return bid;
}
Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att)
Quantity_NameOfColor AIS_GraphicTool::GetLineColor(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att)
{
Quantity_Color color;
GetLineColor(Dr, Att, color);
return color.Name();
}
void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor)
void AIS_GraphicTool::GetLineColor(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att,
Quantity_Color& aColor)
{
aColor = GetLineAspect(Dr, Att)->Aspect()->Color();
}
@ -86,6 +88,7 @@ Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr,
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr, Att);
return LA->Aspect()->Width();
}
Aspect_TypeOfLine AIS_GraphicTool::GetLineType(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att)
{
@ -93,7 +96,6 @@ Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr,
return LA->Aspect()->Type();
}
void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att,
Quantity_NameOfColor& Col,

View File

@ -28,52 +28,41 @@
class Quantity_Color;
class Graphic3d_MaterialAspect;
class AIS_GraphicTool
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT static Quantity_NameOfColor GetLineColor(
const Handle(Prs3d_Drawer)& aDrawer,
const AIS_TypeOfAttribute TheTypeOfAttributes);
Standard_EXPORT static Quantity_NameOfColor GetLineColor (const Handle(Prs3d_Drawer)& aDrawer, const AIS_TypeOfAttribute TheTypeOfAttributes);
Standard_EXPORT static void GetLineColor(const Handle(Prs3d_Drawer)& aDrawer,
const AIS_TypeOfAttribute TheTypeOfAttributes,
Quantity_Color& TheLineColor);
Standard_EXPORT static void GetLineColor (const Handle(Prs3d_Drawer)& aDrawer, const AIS_TypeOfAttribute TheTypeOfAttributes, Quantity_Color& TheLineColor);
Standard_EXPORT static Standard_Real GetLineWidth(const Handle(Prs3d_Drawer)& aDrawer,
const AIS_TypeOfAttribute TheTypeOfAttributes);
Standard_EXPORT static Standard_Real GetLineWidth (const Handle(Prs3d_Drawer)& aDrawer, const AIS_TypeOfAttribute TheTypeOfAttributes);
Standard_EXPORT static Aspect_TypeOfLine GetLineType(
const Handle(Prs3d_Drawer)& aDrawer,
const AIS_TypeOfAttribute TheTypeOfAttributes);
Standard_EXPORT static Aspect_TypeOfLine GetLineType (const Handle(Prs3d_Drawer)& aDrawer, const AIS_TypeOfAttribute TheTypeOfAttributes);
Standard_EXPORT static void GetLineAtt (const Handle(Prs3d_Drawer)& aDrawer, const AIS_TypeOfAttribute TheTypeOfAttributes, Quantity_NameOfColor& aCol, Standard_Real& aWidth, Aspect_TypeOfLine& aTyp);
Standard_EXPORT static void GetLineAtt(const Handle(Prs3d_Drawer)& aDrawer,
const AIS_TypeOfAttribute TheTypeOfAttributes,
Quantity_NameOfColor& aCol,
Standard_Real& aWidth,
Aspect_TypeOfLine& aTyp);
Standard_EXPORT static Quantity_NameOfColor GetInteriorColor(const Handle(Prs3d_Drawer)& aDrawer);
Standard_EXPORT static void GetInteriorColor (const Handle(Prs3d_Drawer)& aDrawer, Quantity_Color& aColor);
Standard_EXPORT static void GetInteriorColor(const Handle(Prs3d_Drawer)& aDrawer,
Quantity_Color& aColor);
Standard_EXPORT static Graphic3d_MaterialAspect GetMaterial(const Handle(Prs3d_Drawer)& aDrawer);
protected:
private:
};
#endif // _AIS_GraphicTool_HeaderFile

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -29,21 +29,18 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject)
//=======================================================================
//function : AIS_InteractiveObject
//purpose :
//=======================================================================
AIS_InteractiveObject::AIS_InteractiveObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
//=================================================================================================
AIS_InteractiveObject::AIS_InteractiveObject(
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: SelectMgr_SelectableObject(aTypeOfPresentation3d),
myCTXPtr(NULL)
{
//
}
//=======================================================================
//function : Redisplay
//purpose :
//=======================================================================
//=================================================================================================
void AIS_InteractiveObject::Redisplay(const Standard_Boolean AllModes)
{
if (myCTXPtr == NULL)
@ -52,10 +49,8 @@ void AIS_InteractiveObject::Redisplay (const Standard_Boolean AllModes)
myCTXPtr->Redisplay(this, Standard_False, AllModes);
}
//=======================================================================
//function : ProcessDragging
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_InteractiveObject::ProcessDragging(const Handle(AIS_InteractiveContext)&,
const Handle(V3d_View)&,
const Handle(SelectMgr_EntityOwner)&,
@ -66,19 +61,15 @@ Standard_Boolean AIS_InteractiveObject::ProcessDragging (const Handle(AIS_Intera
return Standard_False;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
//=================================================================================================
Handle(AIS_InteractiveContext) AIS_InteractiveObject::GetContext() const
{
return myCTXPtr;
}
//=======================================================================
//function : SetContext
//purpose :
//=======================================================================
//=================================================================================================
void AIS_InteractiveObject::SetContext(const Handle(AIS_InteractiveContext)& theCtx)
{
if (myCTXPtr == theCtx.get())
@ -93,29 +84,23 @@ void AIS_InteractiveObject::SetContext (const Handle(AIS_InteractiveContext)& th
}
}
//=======================================================================
//function : SetDisplayStatus
//purpose :
//=======================================================================
//=================================================================================================
void AIS_InteractiveObject::SetDisplayStatus(PrsMgr_DisplayStatus theStatus)
{
myDisplayStatus = theStatus;
}
//=======================================================================
//function : HasPresentation
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_InteractiveObject::HasPresentation() const
{
return HasInteractiveContext()
&& myCTXPtr->MainPrsMgr()->HasPresentation(this, myDrawer->DisplayMode());
}
//=======================================================================
//function : Presentation
//purpose :
//=======================================================================
//=================================================================================================
Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
{
if (!HasInteractiveContext())
@ -123,14 +108,13 @@ Handle(Prs3d_Presentation) AIS_InteractiveObject::Presentation() const
return Handle(Prs3d_Presentation)();
}
Handle(PrsMgr_Presentation) aPrs = myCTXPtr->MainPrsMgr()->Presentation (this, myDrawer->DisplayMode(), false);
Handle(PrsMgr_Presentation) aPrs =
myCTXPtr->MainPrsMgr()->Presentation(this, myDrawer->DisplayMode(), false);
return aPrs;
}
//=======================================================================
//function : SetAspect
//purpose :
//=======================================================================
//=================================================================================================
void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect)
{
@ -163,10 +147,8 @@ void AIS_InteractiveObject::SetAspect(const Handle(Prs3d_BasicAspect)& theAspect
}
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
//=================================================================================================
void AIS_InteractiveObject::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)

View File

@ -27,24 +27,26 @@ class V3d_View;
//! Defines a class of objects with display and selection services.
//! Entities which are visualized and selected are Interactive Objects.
//! Specific attributes of entities such as arrow aspect for dimensions must be loaded in a Prs3d_Drawer.
//! Specific attributes of entities such as arrow aspect for dimensions must be loaded in a
//! Prs3d_Drawer.
//!
//! You can make use of classes of standard Interactive Objects for which all necessary methods have already been programmed,
//! or you can implement your own classes of Interactive Objects.
//! Key interface methods to be implemented by every Interactive Object:
//! You can make use of classes of standard Interactive Objects for which all necessary methods have
//! already been programmed, or you can implement your own classes of Interactive Objects. Key
//! interface methods to be implemented by every Interactive Object:
//! * Presentable Object (PrsMgr_PresentableObject)
//! Consider defining an enumeration of supported Display Mode indexes for particular Interactive Object or class of Interactive Objects.
//! Consider defining an enumeration of supported Display Mode indexes for particular Interactive
//! Object or class of Interactive Objects.
//! - AcceptDisplayMode() accepting display modes implemented by this object;
//! - Compute() computing presentation for the given display mode index;
//! * Selectable Object (SelectMgr_SelectableObject)
//! Consider defining an enumeration of supported Selection Mode indexes for particular Interactive Object or class of Interactive Objects.
//! Consider defining an enumeration of supported Selection Mode indexes for particular
//! Interactive Object or class of Interactive Objects.
//! - ComputeSelection() computing selectable entities for the given selection mode index.
class AIS_InteractiveObject : public SelectMgr_SelectableObject
{
friend class AIS_InteractiveContext;
DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject)
public:
//! Returns the kind of Interactive Object; AIS_KindOfInteractive_None by default.
virtual AIS_KindOfInteractive Type() const { return AIS_KindOfInteractive_None; }
@ -79,7 +81,8 @@ public:
Standard_EXPORT virtual void SetContext(const Handle(AIS_InteractiveContext)& aCtx);
//! Returns true if the object has an owner attributed to it.
//! The owner can be a shape for a set of sub-shapes or a sub-shape for sub-shapes which it is composed of, and takes the form of a transient.
//! The owner can be a shape for a set of sub-shapes or a sub-shape for sub-shapes which it is
//! composed of, and takes the form of a transient.
Standard_Boolean HasOwner() const { return !myOwner.IsNull(); }
//! Returns the owner of the Interactive Object.
@ -97,10 +100,13 @@ public:
//! an Interactive Object. This can be a shape for a set of
//! sub-shapes or a sub-shape for sub-shapes which it
//! is composed of. The owner takes the form of a transient.
void SetOwner (const Handle(Standard_Transient)& theApplicativeEntity) { myOwner = theApplicativeEntity; }
void SetOwner(const Handle(Standard_Transient)& theApplicativeEntity)
{
myOwner = theApplicativeEntity;
}
//! Each Interactive Object has methods which allow us to attribute an Owner to it in the form of a Transient.
//! This method removes the owner from the graphic entity.
//! Each Interactive Object has methods which allow us to attribute an Owner to it in the form of
//! a Transient. This method removes the owner from the graphic entity.
void ClearOwner() { myOwner.Nullify(); }
//! Drag object in the viewer.
@ -111,7 +117,8 @@ public:
//! @param[in] theDragTo drag end point
//! @param[in] theAction drag action
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start)
Standard_EXPORT virtual Standard_Boolean ProcessDragging (const Handle(AIS_InteractiveContext)& theCtx,
Standard_EXPORT virtual Standard_Boolean ProcessDragging(
const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragFrom,
@ -119,7 +126,6 @@ public:
const AIS_DragAction theAction);
public:
//! Returns the context pointer to the interactive context.
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
@ -134,23 +140,23 @@ public:
Standard_EXPORT void SetAspect(const Handle(Prs3d_BasicAspect)& anAspect);
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
protected:
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
protected:
//! The TypeOfPresention3d means that the interactive object
//! may have a presentation dependent on the view of Display.
Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
Standard_EXPORT AIS_InteractiveObject(
const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
//! Set presentation display status.
Standard_EXPORT void SetDisplayStatus(PrsMgr_DisplayStatus theStatus);
protected:
// clang-format off
AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext()
// clang-format on
Handle(Standard_Transient) myOwner; //!< application-specific owner object
};
DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject)

View File

@ -27,7 +27,8 @@ enum AIS_KindOfInteractive
AIS_KindOfInteractive_Shape, //!< presentation of topological shape
AIS_KindOfInteractive_Object, //!< presentation of group of topological shapes
AIS_KindOfInteractive_Relation, //!< presentation of relation (dimensions and constraints)
AIS_KindOfInteractive_Dimension, //!< presentation of dimension (length, radius, diameter and angle)
AIS_KindOfInteractive_Dimension, //!< presentation of dimension (length, radius, diameter and
//!< angle)
AIS_KindOfInteractive_LightSource, //!< presentation of light source
// old aliases

View File

@ -55,10 +55,8 @@ Standard_Boolean AIS_LightSourceOwner::HandleMouseClick (const Graphic3d_Vec2i&
bool)
{
AIS_LightSource* aLightSource = dynamic_cast<AIS_LightSource*>(mySelectable);
if (aLightSource != NULL
&& aLightSource->ToSwitchOnClick()
&& theKey == Aspect_VKeyMouse_LeftButton
&& theFlags == Aspect_VKeyFlags_NONE)
if (aLightSource != NULL && aLightSource->ToSwitchOnClick()
&& theKey == Aspect_VKeyMouse_LeftButton && theFlags == Aspect_VKeyFlags_NONE)
{
aLightSource->Light()->SetEnabled(!aLightSource->Light()->IsEnabled());
aLightSource->updateLightAspects();
@ -67,10 +65,8 @@ Standard_Boolean AIS_LightSourceOwner::HandleMouseClick (const Graphic3d_Vec2i&
return false;
}
//=======================================================================
//function : HilightWithColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_LightSourceOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode)
@ -81,10 +77,12 @@ void AIS_LightSourceOwner::HilightWithColor (const Handle(PrsMgr_PresentationMan
return;
}
if (aLightSource->Light()->Type() == Graphic3d_TypeOfLightSource_Directional && aLightSource->myIsDraggable)
if (aLightSource->Light()->Type() == Graphic3d_TypeOfLightSource_Directional
&& aLightSource->myIsDraggable)
{
Handle(Prs3d_Presentation) aPrs = aLightSource->GetHilightPresentation(thePM);
const Graphic3d_ZLayerId aZLayer = theStyle->ZLayer() != -1
const Graphic3d_ZLayerId aZLayer =
theStyle->ZLayer() != -1
? theStyle->ZLayer()
: (thePM->IsImmediateModeOn() ? Graphic3d_ZLayerId_Top : aLightSource->ZLayer());
aPrs->Clear();
@ -100,7 +98,8 @@ void AIS_LightSourceOwner::HilightWithColor (const Handle(PrsMgr_PresentationMan
}
aPoints->AddVertex(aDetPnt);
Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
const Handle(Prs3d_PointAspect) aPointAspect = new Prs3d_PointAspect (Aspect_TOM_O_POINT, theStyle->Color(), 3.0f);
const Handle(Prs3d_PointAspect) aPointAspect =
new Prs3d_PointAspect(Aspect_TOM_O_POINT, theStyle->Color(), 3.0f);
aGroup->SetGroupPrimitivesAspect(aPointAspect->Aspect());
aGroup->AddPrimitiveArray(aPoints);
@ -115,7 +114,9 @@ void AIS_LightSourceOwner::HilightWithColor (const Handle(PrsMgr_PresentationMan
}
for (Standard_Integer aStep = 0; aStep < aNbPnts; ++aStep)
{
aCircPoints.SetValue (aStep, (aDetPnt.Rotated (gp_Ax1 (gp::Origin(), aDirNormToPln), M_PI / 90 * (aStep - aNbPnts / 2))));
aCircPoints.SetValue(
aStep,
(aDetPnt.Rotated(gp_Ax1(gp::Origin(), aDirNormToPln), M_PI / 90 * (aStep - aNbPnts / 2))));
}
Handle(Graphic3d_Group) aCircGroup = aPrs->NewGroup();
@ -124,7 +125,8 @@ void AIS_LightSourceOwner::HilightWithColor (const Handle(PrsMgr_PresentationMan
for (Standard_Integer anIdx = 0; anIdx < aNbPnts; ++anIdx)
{
aPolylines->AddVertex (aCircPoints.Value (anIdx).Rotated (gp_Ax1 (gp::Origin(), aDirNorm), M_PI / 2));
aPolylines->AddVertex(
aCircPoints.Value(anIdx).Rotated(gp_Ax1(gp::Origin(), aDirNorm), M_PI / 2));
}
aPolylines->AddBound(aNbPnts);
for (Standard_Integer anIdx = 0; anIdx < aNbPnts; ++anIdx)
@ -144,14 +146,13 @@ void AIS_LightSourceOwner::HilightWithColor (const Handle(PrsMgr_PresentationMan
}
else
{
base_type::HilightWithColor (thePM, theStyle, theMode);;
base_type::HilightWithColor(thePM, theStyle, theMode);
;
}
}
//=======================================================================
//function : IsForcedHilight
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_LightSourceOwner::IsForcedHilight() const
{
Handle(AIS_LightSource) aLightSource = Handle(AIS_LightSource)::DownCast(mySelectable);
@ -203,7 +204,9 @@ AIS_LightSource::AIS_LightSource (const Handle(Graphic3d_CLight)& theLight)
myDrawer->ArrowAspect()->Aspect()->ChangeFrontMaterial() = aMat;
myDrawer->ArrowAspect()->Aspect()->SetMarkerType(Aspect_TOM_EMPTY);
myDrawer->ArrowAspect()->Aspect()->SetMarkerScale(2.0f);
myArrowLineAspectShadow = new Graphic3d_AspectLine3d (Quantity_NOC_BLACK, Aspect_TOL_SOLID,
myArrowLineAspectShadow = new Graphic3d_AspectLine3d(
Quantity_NOC_BLACK,
Aspect_TOL_SOLID,
theLight->Type() != Graphic3d_TypeOfLightSource_Ambient ? 3.0f : 1.0f);
myDrawer->SetupOwnShadingAspect();
@ -226,8 +229,7 @@ AIS_LightSource::AIS_LightSource (const Handle(Graphic3d_CLight)& theLight)
myDynHilightDrawer->SetDisplayMode(1);
myDynHilightDrawer->SetColor(Quantity_NOC_CYAN1);
if (!myTransformPersistence.IsNull()
&& myTransformPersistence->IsTrihedronOr2d())
if (!myTransformPersistence.IsNull() && myTransformPersistence->IsTrihedronOr2d())
{
myDrawer->SetZLayer(Graphic3d_ZLayerId_Topmost);
myDynHilightDrawer->SetZLayer(Graphic3d_ZLayerId_Topmost);
@ -236,10 +238,8 @@ AIS_LightSource::AIS_LightSource (const Handle(Graphic3d_CLight)& theLight)
}
}
//=======================================================================
//function : ProcessDragging
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_LightSource::ProcessDragging(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const Handle(SelectMgr_EntityOwner)& theOwner,
@ -254,17 +254,14 @@ Standard_Boolean AIS_LightSource::ProcessDragging (const Handle(AIS_InteractiveC
switch (theAction)
{
case AIS_DragAction_Start:
{
case AIS_DragAction_Start: {
myLocTrsfStart = LocalTransformation();
return Standard_True;
}
case AIS_DragAction_Confirmed:
{
case AIS_DragAction_Confirmed: {
return Standard_True;
}
case AIS_DragAction_Update:
{
case AIS_DragAction_Update: {
mySensSphere->ResetLastDetectedPoint();
SetLocalTransformation(myLocTrsfStart);
theCtx->MainSelector()->Pick(theDragFrom.x(), theDragFrom.y(), theView);
@ -277,7 +274,8 @@ Standard_Boolean AIS_LightSource::ProcessDragging (const Handle(AIS_InteractiveC
&& aStartPosition.Distance(aCurrPosition) > Precision::Confusion())
{
gp_Quaternion aQRot;
aQRot.SetRotation (gp_Vec (gp_Pnt (0, 0, 0), aStartPosition), gp_Vec (gp_Pnt (0, 0, 0), aCurrPosition));
aQRot.SetRotation(gp_Vec(gp_Pnt(0, 0, 0), aStartPosition),
gp_Vec(gp_Pnt(0, 0, 0), aCurrPosition));
gp_Trsf aTrsf;
aTrsf.SetRotation(aQRot);
SetLocalTransformation(myLocTrsfStart * aTrsf);
@ -286,12 +284,10 @@ Standard_Boolean AIS_LightSource::ProcessDragging (const Handle(AIS_InteractiveC
}
return Standard_True;
}
case AIS_DragAction_Abort:
{
case AIS_DragAction_Abort: {
return Standard_True;
}
case AIS_DragAction_Stop:
{
case AIS_DragAction_Stop: {
GetHilightPresentation(theCtx->MainPrsMgr())->Clear();
break;
}
@ -314,7 +310,8 @@ void AIS_LightSource::updateLightAspects()
myDisabledMarkerAspect->SetColor(aColor);
myDisabledMarkerAspect->SetMarkerScale(myDrawer->PointAspect()->Aspect()->MarkerScale());
myDisabledMarkerAspect->SetMarkerType (myLightSource->IsEnabled() ? Aspect_TOM_EMPTY : MarkerType (false));
myDisabledMarkerAspect->SetMarkerType(myLightSource->IsEnabled() ? Aspect_TOM_EMPTY
: MarkerType(false));
myDisabledMarkerAspect->SetMarkerImage(MarkerImage(false));
myDrawer->ShadingAspect()->SetColor(aColor);
@ -325,11 +322,11 @@ void AIS_LightSource::updateLightAspects()
{
const Standard_Real anAngleTol = 2.0 * M_PI / 180.0;
Aspect_TypeOfMarker aDirMark = Aspect_TOM_EMPTY;
if (myLightSource->IsEnabled()
&& myLightSource->IsHeadlight()
if (myLightSource->IsEnabled() && myLightSource->IsHeadlight()
&& myLightSource->Direction().IsParallel(gp::DZ(), anAngleTol))
{
aDirMark = myLightSource->Direction().IsOpposite (-gp::DZ(), anAngleTol) ? myOpposMarkerType : myCodirMarkerType;
aDirMark = myLightSource->Direction().IsOpposite(-gp::DZ(), anAngleTol) ? myOpposMarkerType
: myCodirMarkerType;
}
myDrawer->ArrowAspect()->Aspect()->SetMarkerType(aDirMark);
}
@ -345,13 +342,14 @@ void AIS_LightSource::updateLightTransformPersistence()
Handle(Graphic3d_TransformPers) aTrsfPers = myTransformPersistence;
switch (myLightSource->Type())
{
case Graphic3d_TypeOfLightSource_Ambient:
{
case Graphic3d_TypeOfLightSource_Ambient: {
if (!myIsZoomable)
{
if (aTrsfPers.IsNull() || !aTrsfPers->IsTrihedronOr2d())
{
aTrsfPers = new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_UPPER, Graphic3d_Vec2i(50));
aTrsfPers = new Graphic3d_TransformPers(Graphic3d_TMF_TriedronPers,
Aspect_TOTP_LEFT_UPPER,
Graphic3d_Vec2i(50));
}
}
else
@ -360,9 +358,9 @@ void AIS_LightSource::updateLightTransformPersistence()
}
break;
}
case Graphic3d_TypeOfLightSource_Directional:
{
Graphic3d_TransModeFlags aMode = myLightSource->IsHeadlight() ? Graphic3d_TMF_2d : Graphic3d_TMF_TriedronPers;
case Graphic3d_TypeOfLightSource_Directional: {
Graphic3d_TransModeFlags aMode =
myLightSource->IsHeadlight() ? Graphic3d_TMF_2d : Graphic3d_TMF_TriedronPers;
if (myIsZoomable)
{
aMode = myLightSource->IsHeadlight() ? Graphic3d_TMF_CameraPers : Graphic3d_TMF_None;
@ -377,7 +375,8 @@ void AIS_LightSource::updateLightTransformPersistence()
}
else
{
aTrsfPers = new Graphic3d_TransformPers (aMode, Aspect_TOTP_LEFT_UPPER, Graphic3d_Vec2i(50));
aTrsfPers =
new Graphic3d_TransformPers(aMode, Aspect_TOTP_LEFT_UPPER, Graphic3d_Vec2i(50));
}
}
}
@ -388,9 +387,9 @@ void AIS_LightSource::updateLightTransformPersistence()
break;
}
case Graphic3d_TypeOfLightSource_Positional:
case Graphic3d_TypeOfLightSource_Spot:
{
Graphic3d_TransModeFlags aMode = myLightSource->IsHeadlight()
case Graphic3d_TypeOfLightSource_Spot: {
Graphic3d_TransModeFlags aMode =
myLightSource->IsHeadlight()
? Graphic3d_TMF_CameraPers
: (!myIsZoomable ? Graphic3d_TMF_ZoomPers : Graphic3d_TMF_None);
if (aMode != Graphic3d_TMF_None)
@ -431,8 +430,7 @@ void AIS_LightSource::updateLightLocalTransformation()
myLocalTransformation.Nullify();
switch (myLightSource->Type())
{
case Graphic3d_TypeOfLightSource_Ambient:
{
case Graphic3d_TypeOfLightSource_Ambient: {
if (myIsZoomable)
{
gp_Trsf aTrsf;
@ -441,8 +439,7 @@ void AIS_LightSource::updateLightLocalTransformation()
}
break;
}
case Graphic3d_TypeOfLightSource_Directional:
{
case Graphic3d_TypeOfLightSource_Directional: {
const gp_Pnt aLightPos = (myIsZoomable && !myLightSource->IsHeadlight())
? myLightSource->DisplayPosition()
: gp::Origin();
@ -452,8 +449,7 @@ void AIS_LightSource::updateLightLocalTransformation()
myLocalTransformation = new TopLoc_Datum3D(aTrsf);
break;
}
case Graphic3d_TypeOfLightSource_Positional:
{
case Graphic3d_TypeOfLightSource_Positional: {
if (myIsZoomable)
{
gp_Trsf aTrsf;
@ -462,10 +458,10 @@ void AIS_LightSource::updateLightLocalTransformation()
}
break;
}
case Graphic3d_TypeOfLightSource_Spot:
{
case Graphic3d_TypeOfLightSource_Spot: {
gp_Trsf aTrsf;
const gp_Ax2 anAx2 (myIsZoomable ? myLightSource->Position() : gp::Origin(), -myLightSource->Direction());
const gp_Ax2 anAx2(myIsZoomable ? myLightSource->Position() : gp::Origin(),
-myLightSource->Direction());
aTrsf.SetTransformation(anAx2, gp_Ax3());
myLocalTransformation = new TopLoc_Datum3D(aTrsf);
break;
@ -483,12 +479,10 @@ void AIS_LightSource::setLocalTransformation (const Handle(TopLoc_Datum3D)& theT
const gp_Trsf aTrsf = !theTrsf.IsNull() ? theTrsf->Transformation() : gp_Trsf();
switch (myLightSource->Type())
{
case Graphic3d_TypeOfLightSource_Ambient:
{
case Graphic3d_TypeOfLightSource_Ambient: {
break;
}
case Graphic3d_TypeOfLightSource_Directional:
{
case Graphic3d_TypeOfLightSource_Directional: {
gp_Dir aNewDir = (-gp::DZ()).Transformed(aTrsf);
myLightSource->SetDirection(aNewDir);
if (myIsZoomable)
@ -498,14 +492,12 @@ void AIS_LightSource::setLocalTransformation (const Handle(TopLoc_Datum3D)& theT
}
break;
}
case Graphic3d_TypeOfLightSource_Positional:
{
case Graphic3d_TypeOfLightSource_Positional: {
gp_Pnt aNewPos = gp::Origin().Transformed(aTrsf);
myLightSource->SetPosition(aNewPos);
break;
}
case Graphic3d_TypeOfLightSource_Spot:
{
case Graphic3d_TypeOfLightSource_Spot: {
gp_Pnt aNewPos = gp::Origin().Transformed(aTrsf);
myLightSource->SetPosition(aNewPos);
@ -530,8 +522,7 @@ void AIS_LightSource::Compute (const Handle(PrsMgr_PresentationManager)& ,
const Standard_Integer theMode)
{
thePrs->SetInfiniteState(myInfiniteState);
if (theMode != 0
&& theMode != 1)
if (theMode != 0 && theMode != 1)
{
return;
}
@ -545,17 +536,24 @@ void AIS_LightSource::Compute (const Handle(PrsMgr_PresentationManager)& ,
switch (myLightSource->Type())
{
case Graphic3d_TypeOfLightSource_Ambient: computeAmbient (thePrs, theMode); break;
case Graphic3d_TypeOfLightSource_Directional: computeDirectional(thePrs, theMode); break;
case Graphic3d_TypeOfLightSource_Positional: computePositional (thePrs, theMode); break;
case Graphic3d_TypeOfLightSource_Spot: computeSpot (thePrs, theMode); break;
case Graphic3d_TypeOfLightSource_Ambient:
computeAmbient(thePrs, theMode);
break;
case Graphic3d_TypeOfLightSource_Directional:
computeDirectional(thePrs, theMode);
break;
case Graphic3d_TypeOfLightSource_Positional:
computePositional(thePrs, theMode);
break;
case Graphic3d_TypeOfLightSource_Spot:
computeSpot(thePrs, theMode);
break;
}
if (myToDisplayName)
{
TCollection_AsciiString aPrefix = !myTransformPersistence.IsNull()
&& myTransformPersistence->IsTrihedronOr2d()
? "\n" : " ";
TCollection_AsciiString aPrefix =
!myTransformPersistence.IsNull() && myTransformPersistence->IsTrihedronOr2d() ? "\n" : " ";
TCollection_AsciiString aName = aPrefix + myLightSource->Name();
Prs3d_Text::Draw(thePrs->NewGroup(), myDrawer->TextAspect(), aName, gp::Origin());
}
@ -571,21 +569,26 @@ void AIS_LightSource::computeAmbient (const Handle(Prs3d_Presentation)& thePrs,
const gp_XYZ aLightPos = gp::Origin().XYZ();
if (theMode == 0)
{
Handle(Graphic3d_ArrayOfTriangles) aSphereArray = Prs3d_ToolSphere::Create (mySize * 0.25, myNbSplitsQuadric, myNbSplitsQuadric, gp_Trsf());
Handle(Graphic3d_ArrayOfTriangles) aSphereArray =
Prs3d_ToolSphere::Create(mySize * 0.25, myNbSplitsQuadric, myNbSplitsQuadric, gp_Trsf());
Handle(Graphic3d_Group) aSphereGroup = thePrs->NewGroup();
aSphereGroup->SetClosed(true);
aSphereGroup->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
aSphereGroup->AddPrimitiveArray(aSphereArray);
}
if (theMode == 0
|| theMode == 1)
if (theMode == 0 || theMode == 1)
{
const Standard_Real aLen = mySize * 0.25;
const Standard_Integer aNbArrows = 6;
const gp_Dir aDirList[6] = {-gp::DX(), gp::DX(), -gp::DY(), gp::DY(), -gp::DZ(), gp::DZ()};
const Prs3d_ToolCylinder aCylTool (mySize * 0.1, 0.0, mySize * 0.2, myNbSplitsArrow, myNbSplitsArrow);
Handle(Graphic3d_ArrayOfTriangles) aTrisArray = new Graphic3d_ArrayOfTriangles (aNbArrows * aCylTool.VerticesNb(),
const Prs3d_ToolCylinder aCylTool(mySize * 0.1,
0.0,
mySize * 0.2,
myNbSplitsArrow,
myNbSplitsArrow);
Handle(Graphic3d_ArrayOfTriangles) aTrisArray =
new Graphic3d_ArrayOfTriangles(aNbArrows * aCylTool.VerticesNb(),
aNbArrows * aCylTool.TrianglesNb() * 3,
Graphic3d_ArrayFlags_VertexNormal);
Handle(Graphic3d_ArrayOfSegments) aLineArray = new Graphic3d_ArrayOfSegments(aNbArrows * 2);
@ -626,7 +629,8 @@ void AIS_LightSource::computeAmbient (const Handle(Prs3d_Presentation)& thePrs,
Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints(1);
aPoints->AddVertex(aLightPos);
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (theMode == 1 ? myDrawer->PointAspect()->Aspect() : myDisabledMarkerAspect);
aGroup->SetGroupPrimitivesAspect(theMode == 1 ? myDrawer->PointAspect()->Aspect()
: myDisabledMarkerAspect);
aGroup->AddPrimitiveArray(aPoints);
}
}
@ -646,9 +650,18 @@ void AIS_LightSource::computeDirectional (const Handle(Prs3d_Presentation)& theP
const gp_XYZ aLightPos = -aStep * aLightDir.XYZ();
Standard_Integer aNbArrows = 1;
if (myNbArrows >= 9) { aNbArrows = 9; }
else if (myNbArrows >= 5) { aNbArrows = 5; }
else if (myNbArrows >= 3) { aNbArrows = 3; }
if (myNbArrows >= 9)
{
aNbArrows = 9;
}
else if (myNbArrows >= 5)
{
aNbArrows = 5;
}
else if (myNbArrows >= 3)
{
aNbArrows = 3;
}
TColgp_Array1OfPnt aPoints(1, aNbArrows);
{
const gp_Ax2 anAxes(gp::Origin(), aLightDir);
@ -657,35 +670,35 @@ void AIS_LightSource::computeDirectional (const Handle(Prs3d_Presentation)& theP
const gp_XYZ aDXY = aDX + aDY;
switch (aNbArrows)
{
case 9:
{
case 9: {
aPoints.SetValue(6, aLightPos + aDY);
aPoints.SetValue(7, aLightPos + aDX);
aPoints.SetValue(8, aLightPos - aDY);
aPoints.SetValue(9, aLightPos - aDX);
}
Standard_FALLTHROUGH
case 5:
{
case 5: {
aPoints.SetValue(4, aLightPos - aDY + aDX);
aPoints.SetValue(5, aLightPos + aDY - aDX);
}
Standard_FALLTHROUGH
case 3:
{
case 3: {
aPoints.SetValue(2, aLightPos + aDXY);
aPoints.SetValue(3, aLightPos - aDXY);
}
Standard_FALLTHROUGH
case 1:
{
case 1: {
aPoints.SetValue(1, aLightPos);
break;
}
}
}
const Prs3d_ToolCylinder aCylTool (aDistance * 0.1, 0.0, aDistance * 0.2, myNbSplitsArrow, myNbSplitsArrow);
const Prs3d_ToolCylinder aCylTool(aDistance * 0.1,
0.0,
aDistance * 0.2,
myNbSplitsArrow,
myNbSplitsArrow);
Handle(Graphic3d_ArrayOfTriangles) aTrisArray;
if (theMode == 0)
{
@ -759,12 +772,12 @@ void AIS_LightSource::computePositional (const Handle(Prs3d_Presentation)& thePr
{
// light source position is set to local transformation
const gp_XYZ aLightPos = gp::Origin().XYZ();
const Standard_Real aRadius = (myIsZoomable && myLightSource->HasRange()) ? myLightSource->Range() : 0.0;
if (theMode == 0
&& aRadius > 0.0
&& myToDisplayRange)
const Standard_Real aRadius =
(myIsZoomable && myLightSource->HasRange()) ? myLightSource->Range() : 0.0;
if (theMode == 0 && aRadius > 0.0 && myToDisplayRange)
{
Handle(Graphic3d_ArrayOfTriangles) aPosRangeArray = Prs3d_ToolSphere::Create (aRadius, myNbSplitsQuadric, myNbSplitsQuadric, gp_Trsf());
Handle(Graphic3d_ArrayOfTriangles) aPosRangeArray =
Prs3d_ToolSphere::Create(aRadius, myNbSplitsQuadric, myNbSplitsQuadric, gp_Trsf());
Handle(Graphic3d_Group) aRangeGroup = thePrs->NewGroup();
aRangeGroup->SetClosed(true);
aRangeGroup->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
@ -789,7 +802,8 @@ void AIS_LightSource::computeSpot (const Handle(Prs3d_Presentation)& thePrs,
// light source position and direction are set to local transformation
const gp_Dir aLightDir = -gp::DZ();
const gp_XYZ aLightPos = gp::Origin().XYZ();
const Standard_Real aDistance = (myIsZoomable && myLightSource->HasRange()) ? myLightSource->Range() : mySize;
const Standard_Real aDistance =
(myIsZoomable && myLightSource->HasRange()) ? myLightSource->Range() : mySize;
{
Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints(1);
aPoints->AddVertex(aLightPos);
@ -815,16 +829,20 @@ void AIS_LightSource::computeSpot (const Handle(Prs3d_Presentation)& thePrs,
aDirGroup->AddPrimitiveArray(aDirArray);
}
if (theMode == 0
&& myToDisplayRange)
if (theMode == 0 && myToDisplayRange)
{
const Standard_ShortReal aHalfAngle = myLightSource->Angle() / 2.0f;
const Standard_Real aRadius = aDistance * Tan(aHalfAngle);
gp_Ax3 aSystem(aLightPos + aLightDir.XYZ() * aDistance, -aLightDir);
gp_Trsf aTrsfCone;
aTrsfCone.SetTransformation(aSystem, gp_Ax3());
Handle(Graphic3d_ArrayOfTriangles) aSpotRangeArray = Prs3d_ToolCylinder::Create (aRadius, 0.0, aDistance,
myNbSplitsQuadric, myNbSplitsQuadric, aTrsfCone);
Handle(Graphic3d_ArrayOfTriangles) aSpotRangeArray =
Prs3d_ToolCylinder::Create(aRadius,
0.0,
aDistance,
myNbSplitsQuadric,
myNbSplitsQuadric,
aTrsfCone);
Handle(Graphic3d_Group) aRangeGroup = thePrs->NewGroup();
aRangeGroup->SetClosed(true);
@ -853,10 +871,10 @@ void AIS_LightSource::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
theSel->Add(mySensSphere);
}
Handle(Select3D_SensitivePoint) aSensPosition = new Select3D_SensitivePoint (anEntityOwner, gp::Origin());
Handle(Select3D_SensitivePoint) aSensPosition =
new Select3D_SensitivePoint(anEntityOwner, gp::Origin());
aSensPosition->SetSensitivityFactor(12);
if (!myTransformPersistence.IsNull()
&& myTransformPersistence->IsTrihedronOr2d())
if (!myTransformPersistence.IsNull() && myTransformPersistence->IsTrihedronOr2d())
{
aSensPosition->SetSensitivityFactor(Max(12, Standard_Integer(mySize * 0.5)));
}

View File

@ -29,13 +29,13 @@ class Select3D_SensitiveSphere;
//! - Positional light is represented by a sphere or marker;
//! - Spot light is represented by a cone;
//! - Directional light is represented by a set of arrows at the corner of view.
//! In addition, light source name could be displayed, and clicking on presentation will enable/disable light.
//! In addition, light source name could be displayed, and clicking on presentation will
//! enable/disable light.
class AIS_LightSource : public AIS_InteractiveObject
{
friend class AIS_LightSourceOwner;
DEFINE_STANDARD_RTTIEXT(AIS_LightSource, AIS_InteractiveObject)
public:
//! Initializes the light source by copying Graphic3d_CLight settings.
Standard_EXPORT AIS_LightSource(const Handle(Graphic3d_CLight)& theLightSource);
@ -50,7 +50,6 @@ public:
}
public: //! @name Light properties
//! Returns TRUE if the light source name should be displayed; TRUE by default.
Standard_Boolean ToDisplayName() const { return myToDisplayName; }
@ -64,8 +63,8 @@ public: //! @name Light properties
}
}
//! Returns TRUE to display light source range as sphere (positional light) or cone (spot light); TRUE by default.
//! Has no effect for non-zoomable presentation.
//! Returns TRUE to display light source range as sphere (positional light) or cone (spot light);
//! TRUE by default. Has no effect for non-zoomable presentation.
Standard_Boolean ToDisplayRange() const { return myToDisplayRange; }
//! Show/hide light source range shaded presentation.
@ -149,15 +148,20 @@ public: //! @name Light properties
//! Returns light source icon.
//! @param[in] theIsEnabled marker index for enabled/disabled light source states
const Handle(Graphic3d_MarkerImage)& MarkerImage (bool theIsEnabled) const { return myMarkerImages[theIsEnabled ? 1 : 0]; }
const Handle(Graphic3d_MarkerImage)& MarkerImage(bool theIsEnabled) const
{
return myMarkerImages[theIsEnabled ? 1 : 0];
}
//! Returns light source icon.
//! @param[in] theIsEnabled marker index for enabled/disabled light source states
Aspect_TypeOfMarker MarkerType (bool theIsEnabled) const { return myMarkerTypes[theIsEnabled ? 1 : 0]; }
Aspect_TypeOfMarker MarkerType(bool theIsEnabled) const
{
return myMarkerTypes[theIsEnabled ? 1 : 0];
}
//! Sets custom icon to light source.
void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage,
bool theIsEnabled)
void SetMarkerImage(const Handle(Graphic3d_MarkerImage)& theImage, bool theIsEnabled)
{
myMarkerImages[theIsEnabled ? 1 : 0] = theImage;
myMarkerTypes[theIsEnabled ? 1 : 0] = !theImage.IsNull()
@ -166,8 +170,7 @@ public: //! @name Light properties
}
//! Sets standard icon to light source.
void SetMarkerType (Aspect_TypeOfMarker theType,
bool theIsEnabled)
void SetMarkerType(Aspect_TypeOfMarker theType, bool theIsEnabled)
{
myMarkerTypes[theIsEnabled ? 1 : 0] = theType;
}
@ -185,15 +188,17 @@ public: //! @name Light properties
void SetNbSplitsArrow(Standard_Integer theNbSplits) { myNbSplitsArrow = theNbSplits; }
//! Returns kind of the object.
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_LightSource; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_LightSource;
}
protected:
//! Return true if specified display mode is supported: 0 for main presentation and 1 for highlight.
//! Return true if specified display mode is supported: 0 for main presentation and 1 for
//! highlight.
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{
return theMode == 0
|| theMode == 1;
return theMode == 0 || theMode == 1;
}
//! Computes selection sensitive zones(triangulation) for light source presentation.
@ -213,7 +218,8 @@ protected:
//! @param[in] theDragTo drag end point
//! @param[in] theAction drag action
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start)
Standard_EXPORT virtual Standard_Boolean ProcessDragging (const Handle(AIS_InteractiveContext)& theCtx,
Standard_EXPORT virtual Standard_Boolean ProcessDragging(
const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragFrom,
@ -221,7 +227,8 @@ protected:
const AIS_DragAction theAction) Standard_OVERRIDE;
//! Sets new local transformation, which is propagated to Graphic3d_CLight instance.
Standard_EXPORT virtual void setLocalTransformation (const Handle(TopLoc_Datum3D)& theTrsf) Standard_OVERRIDE;
Standard_EXPORT virtual void setLocalTransformation(const Handle(TopLoc_Datum3D)& theTrsf)
Standard_OVERRIDE;
//! Updates local transformation basing on a type of light source.
Standard_EXPORT virtual void updateLightLocalTransformation();
@ -240,7 +247,8 @@ protected:
Standard_EXPORT virtual void computeDirectional(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode);
//! Compute positional light source presentation as a sphere of either fixed size (no range) or of size representing a maximum range.
//! Compute positional light source presentation as a sphere of either fixed size (no range) or of
//! size representing a maximum range.
Standard_EXPORT virtual void computePositional(const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode);
@ -249,7 +257,6 @@ protected:
const Standard_Integer theMode);
protected:
Handle(Graphic3d_CLight) myLightSource; //!< displayed light source
// clang-format off
@ -273,7 +280,6 @@ protected:
Standard_Boolean myToDisplayName; //!< flag to show/hide name
Standard_Boolean myToDisplayRange; //!< flag to show/hide range of positional/spot light
Standard_Boolean myToSwitchOnClick; //!< flag to handle mouse click to turn light on/off
};
//! Owner of AIS_LightSource presentation.
@ -281,7 +287,6 @@ class AIS_LightSourceOwner : public SelectMgr_EntityOwner
{
DEFINE_STANDARD_RTTIEXT(AIS_LightSourceOwner, SelectMgr_EntityOwner)
public:
//! Main constructor.
Standard_EXPORT AIS_LightSourceOwner(const Handle(AIS_LightSource)& theObject,
Standard_Integer thePriority = 5);
@ -290,18 +295,19 @@ public:
Standard_EXPORT virtual Standard_Boolean HandleMouseClick(const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButton,
Aspect_VKeyFlags theModifiers,
bool theIsDoubleClick) Standard_OVERRIDE;
bool theIsDoubleClick)
Standard_OVERRIDE;
//! Highlights selectable object's presentation with display mode in presentation manager with given highlight style.
//! Also a check for auto-highlight is performed - if selectable object manages highlighting on its own,
//! execution will be passed to SelectMgr_SelectableObject::HilightOwnerWithColor method.
//! Highlights selectable object's presentation with display mode in presentation manager with
//! given highlight style. Also a check for auto-highlight is performed - if selectable object
//! manages highlighting on its own, execution will be passed to
//! SelectMgr_SelectableObject::HilightOwnerWithColor method.
Standard_EXPORT virtual void HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Always update dynamic highlighting.
Standard_EXPORT virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE;
};
#endif // _AIS_LightSource_HeaderFile

View File

@ -36,44 +36,41 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Line, AIS_InteractiveObject)
//=======================================================================
//function : AIS_Line
//purpose :
//=======================================================================
AIS_Line::AIS_Line(const Handle(Geom_Line)& aComponent):
myComponent (aComponent),
//=================================================================================================
AIS_Line::AIS_Line(const Handle(Geom_Line)& aComponent)
: myComponent(aComponent),
myLineIsSegment(Standard_False)
{
SetInfiniteState();
}
//=======================================================================
//function : AIS_Line
//purpose :
//=======================================================================
AIS_Line::AIS_Line(const Handle(Geom_Point)& aStartPoint,
const Handle(Geom_Point)& aEndPoint):
myStartPoint(aStartPoint),
//=================================================================================================
AIS_Line::AIS_Line(const Handle(Geom_Point)& aStartPoint, const Handle(Geom_Point)& aEndPoint)
: myStartPoint(aStartPoint),
myEndPoint(aEndPoint),
myLineIsSegment(Standard_True)
{}
{
}
//=================================================================================================
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
void AIS_Line::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer)
{
if (!myLineIsSegment) { ComputeInfiniteLine (thePrs); }
else { ComputeSegmentLine (thePrs); }
if (!myLineIsSegment)
{
ComputeInfiniteLine(thePrs);
}
else
{
ComputeSegmentLine(thePrs);
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Line::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
@ -92,10 +89,8 @@ void AIS_Line::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
}
}
//=======================================================================
//function : replaceWithNewLineAspect
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Line::replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect)
{
if (!myDrawer->HasLink())
@ -105,7 +100,8 @@ void AIS_Line::replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspe
}
const Handle(Graphic3d_Aspects)& anAspectOld = myDrawer->LineAspect()->Aspect();
const Handle(Graphic3d_Aspects)& anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect();
const Handle(Graphic3d_Aspects)& anAspectNew =
!theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->LineAspect()->Aspect();
if (anAspectNew != anAspectOld)
{
myDrawer->SetLineAspect(theAspect);
@ -115,18 +111,17 @@ void AIS_Line::replaceWithNewLineAspect (const Handle(Prs3d_LineAspect)& theAspe
}
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Line::SetColor(const Quantity_Color& aCol)
{
hasOwnColor = Standard_True;
myDrawer->SetColor(aCol);
Standard_Real WW = HasWidth()? myOwnWidth:
myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.;
Standard_Real WW = HasWidth() ? myOwnWidth
: myDrawer->HasLink()
? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
: 1.;
if (!myDrawer->HasOwnLineAspect())
{
@ -139,11 +134,8 @@ void AIS_Line::SetColor(const Quantity_Color &aCol)
}
}
//=================================================================================================
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
void AIS_Line::UnsetColor()
{
hasOwnColor = Standard_False;
@ -155,18 +147,18 @@ void AIS_Line::UnsetColor()
else
{
Quantity_Color CC = Quantity_NOC_YELLOW;
if( HasColor() ) CC = myDrawer->Color();
else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC);
if (HasColor())
CC = myDrawer->Color();
else if (myDrawer->HasLink())
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
myDrawer->LineAspect()->SetColor(CC);
myDrawer->SetColor(CC);
SynchronizeAspects();
}
}
//=======================================================================
//function : SetWidth
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Line::SetWidth(const Standard_Real aValue)
{
myOwnWidth = (Standard_ShortReal)aValue;
@ -174,8 +166,10 @@ void AIS_Line::SetWidth(const Standard_Real aValue)
if (!myDrawer->HasOwnLineAspect())
{
Quantity_Color CC = Quantity_NOC_YELLOW;
if( HasColor() ) CC = myDrawer->Color();
else if(myDrawer->HasLink()) AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, CC);
if (HasColor())
CC = myDrawer->Color();
else if (myDrawer->HasLink())
AIS_GraphicTool::GetLineColor(myDrawer->Link(), AIS_TOA_Line, CC);
replaceWithNewLineAspect(new Prs3d_LineAspect(CC, Aspect_TOL_SOLID, aValue));
}
else
@ -185,11 +179,8 @@ void AIS_Line::SetWidth(const Standard_Real aValue)
}
}
//=================================================================================================
//=======================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
void AIS_Line::UnsetWidth()
{
if (!HasColor())
@ -198,17 +189,18 @@ void AIS_Line::UnsetWidth()
}
else
{
Standard_ShortReal WW = myDrawer->HasLink() ? (Standard_ShortReal )AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.0f;
Standard_ShortReal WW =
myDrawer->HasLink()
? (Standard_ShortReal)AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line)
: 1.0f;
myDrawer->LineAspect()->SetWidth(WW);
myOwnWidth = WW;
SynchronizeAspects();
}
}
//=======================================================================
//function : ComputeInfiniteLine
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Line::ComputeInfiniteLine(const Handle(Prs3d_Presentation)& aPresentation)
{
GeomAdaptor_Curve curv(myComponent);
@ -218,10 +210,8 @@ void AIS_Line::ComputeInfiniteLine( const Handle(Prs3d_Presentation)& aPresentat
aPresentation->SetInfiniteState(Standard_True);
}
//=======================================================================
//function : ComputeSegmentLine
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Line::ComputeSegmentLine(const Handle(Prs3d_Presentation)& aPresentation)
{
gp_Pnt P1 = myStartPoint->Pnt();
@ -234,11 +224,7 @@ void AIS_Line::ComputeSegmentLine( const Handle(Prs3d_Presentation)& aPresentati
StdPrs_Curve::Add(aPresentation, curv, myDrawer);
}
//=======================================================================
//function : ComputeInfiniteLineSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Line::ComputeInfiniteLineSelection(const Handle(SelectMgr_Selection)& aSelection)
{
@ -260,18 +246,14 @@ void AIS_Line::ComputeInfiniteLineSelection(const Handle(SelectMgr_Selection)& a
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown, P1, P2);
aSelection->Add(seg);
}
//=======================================================================
//function : ComputeSegmentLineSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Line::ComputeSegmentLineSelection(const Handle(SelectMgr_Selection)& aSelection)
{
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this, 5);
Handle(Select3D_SensitiveSegment) seg = new Select3D_SensitiveSegment(eown,
myStartPoint->Pnt(),
myEndPoint->Pnt());
Handle(Select3D_SensitiveSegment) seg =
new Select3D_SensitiveSegment(eown, myStartPoint->Pnt(), myEndPoint->Pnt());
aSelection->Add(seg);
}

View File

@ -29,19 +29,22 @@ class AIS_Line : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_Line, AIS_InteractiveObject)
public:
//! Initializes the line aLine.
Standard_EXPORT AIS_Line(const Handle(Geom_Line)& aLine);
//! Initializes a starting point aStartPoint
//! and a finishing point aEndPoint for the line.
Standard_EXPORT AIS_Line(const Handle(Geom_Point)& aStartPoint, const Handle(Geom_Point)& aEndPoint);
Standard_EXPORT AIS_Line(const Handle(Geom_Point)& aStartPoint,
const Handle(Geom_Point)& aEndPoint);
//! Returns the signature 5.
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 5; }
//! Returns the type Datum.
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
//! Constructs an infinite line.
const Handle(Geom_Line)& Line() const { return myComponent; }
@ -83,7 +86,6 @@ public:
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
@ -102,12 +104,10 @@ private:
void replaceWithNewLineAspect(const Handle(Prs3d_LineAspect)& theAspect);
private:
Handle(Geom_Line) myComponent;
Handle(Geom_Point) myStartPoint;
Handle(Geom_Point) myEndPoint;
Standard_Boolean myLineIsSegment;
};
DEFINE_STANDARD_HANDLE(AIS_Line, AIS_InteractiveObject)

View File

@ -11,7 +11,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef AIS_ListIteratorOfListOfInteractive_HeaderFile
#define AIS_ListIteratorOfListOfInteractive_HeaderFile

View File

@ -21,7 +21,7 @@
#include <NCollection_List.hxx>
typedef NCollection_List<Handle(AIS_InteractiveObject)> AIS_ListOfInteractive;
typedef NCollection_List<Handle(AIS_InteractiveObject)>::Iterator AIS_ListIteratorOfListOfInteractive;
typedef NCollection_List<Handle(AIS_InteractiveObject)>::Iterator
AIS_ListIteratorOfListOfInteractive;
#endif

View File

@ -43,14 +43,16 @@ IMPLEMENT_HSEQUENCE(AIS_ManipulatorObjectSequence)
namespace
{
//! Return Ax1 for specified direction of Ax2.
static gp_Ax1 getAx1FromAx2Dir (const gp_Ax2& theAx2,
int theIndex)
static gp_Ax1 getAx1FromAx2Dir(const gp_Ax2& theAx2, int theIndex)
{
switch (theIndex)
{
case 0: return gp_Ax1 (theAx2.Location(), theAx2.XDirection());
case 1: return gp_Ax1 (theAx2.Location(), theAx2.YDirection());
case 2: return theAx2.Axis();
case 0:
return gp_Ax1(theAx2.Location(), theAx2.XDirection());
case 1:
return gp_Ax1(theAx2.Location(), theAx2.YDirection());
case 2:
return theAx2.Axis();
}
throw Standard_ProgramError("AIS_Manipulator - Invalid axis index");
}
@ -60,7 +62,11 @@ namespace
{
public:
//! Main constructor.
ManipSensRotation (const gp_Dir& thePlaneNormal) : myPlaneNormal (thePlaneNormal), myAngleTol (10.0 * M_PI / 180.0) {}
ManipSensRotation(const gp_Dir& thePlaneNormal)
: myPlaneNormal(thePlaneNormal),
myAngleTol(10.0 * M_PI / 180.0)
{
}
//! Checks if picking ray can be used for detection.
Standard_Boolean isValidRay(const SelectBasics_SelectingVolumeManager& theMgr) const
@ -73,6 +79,7 @@ namespace
const gp_Dir aRay = theMgr.GetViewRayDirection();
return !aRay.IsNormal(myPlaneNormal, myAngleTol);
}
private:
gp_Dir myPlaneNormal;
Standard_Real myAngleTol;
@ -83,17 +90,17 @@ namespace
{
public:
//! Main constructor.
ManipSensCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const gp_Circ& theCircle)
ManipSensCircle(const Handle(SelectMgr_EntityOwner)& theOwnerId, const gp_Circ& theCircle)
: Select3D_SensitiveCircle(theOwnerId, theCircle, Standard_False),
ManipSensRotation (theCircle.Position().Direction()) {}
ManipSensRotation(theCircle.Position().Direction())
{
}
//! Checks whether the circle overlaps current selecting volume
virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE
{
return isValidRay (theMgr)
&& Select3D_SensitiveCircle::Matches (theMgr, thePickResult);
return isValidRay(theMgr) && Select3D_SensitiveCircle::Matches(theMgr, thePickResult);
}
};
@ -105,25 +112,25 @@ namespace
const Handle(Poly_Triangulation)& theTrg,
const gp_Dir& thePlaneNormal)
: Select3D_SensitiveTriangulation(theOwnerId, theTrg, TopLoc_Location(), Standard_True),
ManipSensRotation (thePlaneNormal) {}
ManipSensRotation(thePlaneNormal)
{
}
//! Checks whether the circle overlaps current selecting volume
virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE
{
return isValidRay (theMgr)
&& Select3D_SensitiveTriangulation::Matches (theMgr, thePickResult);
return isValidRay(theMgr) && Select3D_SensitiveTriangulation::Matches(theMgr, thePickResult);
}
};
}
} // namespace
//=================================================================================================
//=======================================================================
//function : init
//purpose :
//=======================================================================
void AIS_Manipulator::init()
{
// Create axis in the default coordinate system. The custom position is applied in local transformation.
// Create axis in the default coordinate system. The custom position is applied in local
// transformation.
myAxes[0] = Axis(gp::OX(), Quantity_NOC_RED);
myAxes[1] = Axis(gp::OY(), Quantity_NOC_GREEN);
myAxes[2] = Axis(gp::OZ(), Quantity_NOC_BLUE1);
@ -165,11 +172,10 @@ void AIS_Manipulator::init()
SetZLayer(Graphic3d_ZLayerId_Topmost);
}
//=======================================================================
//function : getHighlightPresentation
//purpose :
//=======================================================================
Handle(Prs3d_Presentation) AIS_Manipulator::getHighlightPresentation (const Handle(SelectMgr_EntityOwner)& theOwner) const
//=================================================================================================
Handle(Prs3d_Presentation) AIS_Manipulator::getHighlightPresentation(
const Handle(SelectMgr_EntityOwner)& theOwner) const
{
Handle(Prs3d_Presentation) aDummyPrs;
Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast(theOwner);
@ -180,21 +186,25 @@ Handle(Prs3d_Presentation) AIS_Manipulator::getHighlightPresentation (const Hand
switch (anOwner->Mode())
{
case AIS_MM_Translation : return myAxes[anOwner->Index()].TranslatorHighlightPrs();
case AIS_MM_Rotation : return myAxes[anOwner->Index()].RotatorHighlightPrs();
case AIS_MM_Scaling : return myAxes[anOwner->Index()].ScalerHighlightPrs();
case AIS_MM_TranslationPlane: return myAxes[anOwner->Index()].DraggerHighlightPrs();
case AIS_MM_None : break;
case AIS_MM_Translation:
return myAxes[anOwner->Index()].TranslatorHighlightPrs();
case AIS_MM_Rotation:
return myAxes[anOwner->Index()].RotatorHighlightPrs();
case AIS_MM_Scaling:
return myAxes[anOwner->Index()].ScalerHighlightPrs();
case AIS_MM_TranslationPlane:
return myAxes[anOwner->Index()].DraggerHighlightPrs();
case AIS_MM_None:
break;
}
return aDummyPrs;
}
//=======================================================================
//function : getGroup
//purpose :
//=======================================================================
Handle(Graphic3d_Group) AIS_Manipulator::getGroup (const Standard_Integer theIndex, const AIS_ManipulatorMode theMode) const
//=================================================================================================
Handle(Graphic3d_Group) AIS_Manipulator::getGroup(const Standard_Integer theIndex,
const AIS_ManipulatorMode theMode) const
{
Handle(Graphic3d_Group) aDummyGroup;
@ -205,20 +215,23 @@ Handle(Graphic3d_Group) AIS_Manipulator::getGroup (const Standard_Integer theInd
switch (theMode)
{
case AIS_MM_Translation : return myAxes[theIndex].TranslatorGroup();
case AIS_MM_Rotation : return myAxes[theIndex].RotatorGroup();
case AIS_MM_Scaling : return myAxes[theIndex].ScalerGroup();
case AIS_MM_TranslationPlane: return myAxes[theIndex].DraggerGroup();
case AIS_MM_None : break;
case AIS_MM_Translation:
return myAxes[theIndex].TranslatorGroup();
case AIS_MM_Rotation:
return myAxes[theIndex].RotatorGroup();
case AIS_MM_Scaling:
return myAxes[theIndex].ScalerGroup();
case AIS_MM_TranslationPlane:
return myAxes[theIndex].DraggerGroup();
case AIS_MM_None:
break;
}
return aDummyGroup;
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
//=================================================================================================
AIS_Manipulator::AIS_Manipulator()
: myPosition(gp::XOY()),
myCurrentIndex(-1),
@ -236,10 +249,8 @@ AIS_Manipulator::AIS_Manipulator()
init();
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
//=================================================================================================
AIS_Manipulator::AIS_Manipulator(const gp_Ax2& thePosition)
: myPosition(thePosition),
myCurrentIndex(-1),
@ -257,13 +268,15 @@ AIS_Manipulator::AIS_Manipulator (const gp_Ax2& thePosition)
init();
}
//=======================================================================
//function : SetPart
//purpose :
//=======================================================================
void AIS_Manipulator::SetPart (const Standard_Integer theAxisIndex, const AIS_ManipulatorMode theMode, const Standard_Boolean theIsEnabled)
//=================================================================================================
void AIS_Manipulator::SetPart(const Standard_Integer theAxisIndex,
const AIS_ManipulatorMode theMode,
const Standard_Boolean theIsEnabled)
{
Standard_ProgramError_Raise_if (theAxisIndex < 0 || theAxisIndex > 2, "AIS_Manipulator::SetMode(): axis index should be between 0 and 2");
Standard_ProgramError_Raise_if(
theAxisIndex < 0 || theAxisIndex > 2,
"AIS_Manipulator::SetMode(): axis index should be between 0 and 2");
switch (theMode)
{
case AIS_MM_Translation:
@ -287,11 +300,10 @@ void AIS_Manipulator::SetPart (const Standard_Integer theAxisIndex, const AIS_Ma
}
}
//=======================================================================
//function : SetPart
//purpose :
//=======================================================================
void AIS_Manipulator::SetPart (const AIS_ManipulatorMode theMode, const Standard_Boolean theIsEnabled)
//=================================================================================================
void AIS_Manipulator::SetPart(const AIS_ManipulatorMode theMode,
const Standard_Boolean theIsEnabled)
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
@ -299,10 +311,8 @@ void AIS_Manipulator::SetPart (const AIS_ManipulatorMode theMode, const Standard
}
}
//=======================================================================
//function : EnableMode
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::EnableMode(const AIS_ManipulatorMode theMode)
{
if (!IsAttached())
@ -319,10 +329,8 @@ void AIS_Manipulator::EnableMode (const AIS_ManipulatorMode theMode)
aContext->Activate(this, theMode);
}
//=======================================================================
//function : attachToBox
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::attachToBox(const Bnd_Box& theBox)
{
if (theBox.IsVoid())
@ -334,14 +342,13 @@ void AIS_Manipulator::attachToBox (const Bnd_Box& theBox)
theBox.Get(anXmin, anYmin, aZmin, anXmax, anYmax, aZmax);
gp_Ax2 aPosition = gp::XOY();
aPosition.SetLocation (gp_Pnt ((anXmin + anXmax) * 0.5, (anYmin + anYmax) * 0.5, (aZmin + aZmax) * 0.5));
aPosition.SetLocation(
gp_Pnt((anXmin + anXmax) * 0.5, (anYmin + anYmax) * 0.5, (aZmin + aZmax) * 0.5));
SetPosition(aPosition);
}
//=======================================================================
//function : adjustSize
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::adjustSize(const Bnd_Box& theBox)
{
Standard_Real aXmin = 0., aYmin = 0., aZmin = 0., aXmax = 0., aYmax = 0., aZmax = 0.0;
@ -353,11 +360,10 @@ void AIS_Manipulator::adjustSize (const Bnd_Box& theBox)
SetSize((Standard_ShortReal)(Max(aXSize, Max(aYSize, aZSize)) * 0.5));
}
//=======================================================================
//function : Attach
//purpose :
//=======================================================================
void AIS_Manipulator::Attach (const Handle(AIS_InteractiveObject)& theObject, const OptionsForAttach& theOptions)
//=================================================================================================
void AIS_Manipulator::Attach(const Handle(AIS_InteractiveObject)& theObject,
const OptionsForAttach& theOptions)
{
if (theObject->IsKind(STANDARD_TYPE(AIS_Manipulator)))
{
@ -369,11 +375,10 @@ void AIS_Manipulator::Attach (const Handle(AIS_InteractiveObject)& theObject, co
Attach(aSeq, theOptions);
}
//=======================================================================
//function : Attach
//purpose :
//=======================================================================
void AIS_Manipulator::Attach (const Handle(AIS_ManipulatorObjectSequence)& theObjects, const OptionsForAttach& theOptions)
//=================================================================================================
void AIS_Manipulator::Attach(const Handle(AIS_ManipulatorObjectSequence)& theObjects,
const OptionsForAttach& theOptions)
{
if (theObjects->Size() < 1)
{
@ -420,10 +425,8 @@ void AIS_Manipulator::Attach (const Handle(AIS_ManipulatorObjectSequence)& theOb
}
}
//=======================================================================
//function : Detach
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::Detach()
{
DeactivateCurrentMode();
@ -443,24 +446,22 @@ void AIS_Manipulator::Detach()
SetOwner(NULL);
}
//=======================================================================
//function : Objects
//purpose :
//=======================================================================
//=================================================================================================
Handle(AIS_ManipulatorObjectSequence) AIS_Manipulator::Objects() const
{
return Handle(AIS_ManipulatorObjectSequence)::DownCast(GetOwner());
}
//=======================================================================
//function : Object
//purpose :
//=======================================================================
//=================================================================================================
Handle(AIS_InteractiveObject) AIS_Manipulator::Object(const Standard_Integer theIndex) const
{
Handle(AIS_ManipulatorObjectSequence) anOwner = Handle(AIS_ManipulatorObjectSequence)::DownCast (GetOwner());
Handle(AIS_ManipulatorObjectSequence) anOwner =
Handle(AIS_ManipulatorObjectSequence)::DownCast(GetOwner());
Standard_ProgramError_Raise_if (theIndex < anOwner->Lower() || theIndex > anOwner->Upper(), "AIS_Manipulator::Object(): wrong index value");
Standard_ProgramError_Raise_if(theIndex < anOwner->Lower() || theIndex > anOwner->Upper(),
"AIS_Manipulator::Object(): wrong index value");
if (anOwner.IsNull() || anOwner->IsEmpty())
{
@ -470,28 +471,27 @@ Handle(AIS_InteractiveObject) AIS_Manipulator::Object (const Standard_Integer th
return anOwner->Value(theIndex);
}
//=======================================================================
//function : Object
//purpose :
//=======================================================================
//=================================================================================================
Handle(AIS_InteractiveObject) AIS_Manipulator::Object() const
{
return Object(1);
}
//=======================================================================
//function : ObjectTransformation
//purpose :
//=======================================================================
Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer theMaxX, const Standard_Integer theMaxY,
const Handle(V3d_View)& theView, gp_Trsf& theTrsf)
//=================================================================================================
Standard_Boolean AIS_Manipulator::ObjectTransformation(const Standard_Integer theMaxX,
const Standard_Integer theMaxY,
const Handle(V3d_View)& theView,
gp_Trsf& theTrsf)
{
// Initialize start reference data
if (!myHasStartedTransformation)
{
myStartTrsfs.Clear();
Handle(AIS_ManipulatorObjectSequence) anObjects = Objects();
for (AIS_ManipulatorObjectSequence::Iterator anObjIter (*anObjects); anObjIter.More(); anObjIter.Next())
for (AIS_ManipulatorObjectSequence::Iterator anObjIter(*anObjects); anObjIter.More();
anObjIter.Next())
{
myStartTrsfs.Append(anObjIter.Value()->LocalTransformation());
}
@ -500,18 +500,23 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
// Get 3d point with projection vector
Graphic3d_Vec3d anInputPoint, aProj;
theView->ConvertWithProj (theMaxX, theMaxY, anInputPoint.x(), anInputPoint.y(), anInputPoint.z(), aProj.x(), aProj.y(), aProj.z());
const gp_Lin anInputLine (gp_Pnt (anInputPoint.x(), anInputPoint.y(), anInputPoint.z()), gp_Dir (aProj.x(), aProj.y(), aProj.z()));
theView->ConvertWithProj(theMaxX,
theMaxY,
anInputPoint.x(),
anInputPoint.y(),
anInputPoint.z(),
aProj.x(),
aProj.y(),
aProj.z());
const gp_Lin anInputLine(gp_Pnt(anInputPoint.x(), anInputPoint.y(), anInputPoint.z()),
gp_Dir(aProj.x(), aProj.y(), aProj.z()));
switch (myCurrentMode)
{
case AIS_MM_Translation:
case AIS_MM_Scaling:
{
case AIS_MM_Scaling: {
const gp_Lin aLine(myStartPosition.Location(), myAxes[myCurrentIndex].Position().Direction());
Extrema_ExtElC anExtrema(anInputLine, aLine, Precision::Angular());
if (!anExtrema.IsDone()
|| anExtrema.IsParallel()
|| anExtrema.NbExt() != 1)
if (!anExtrema.IsDone() || anExtrema.IsParallel() || anExtrema.NbExt() != 1)
{
// translation cannot be done co-directed with camera
return Standard_False;
@ -551,14 +556,14 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
}
return Standard_True;
}
case AIS_MM_Rotation:
{
case AIS_MM_Rotation: {
const gp_Pnt aPosLoc = myStartPosition.Location();
const gp_Ax1 aCurrAxis = getAx1FromAx2Dir(myStartPosition, myCurrentIndex);
IntAna_IntConicQuad aIntersector (anInputLine, gp_Pln (aPosLoc, aCurrAxis.Direction()), Precision::Angular(), Precision::Intersection());
if (!aIntersector.IsDone()
|| aIntersector.IsParallel()
|| aIntersector.NbPoints() < 1)
IntAna_IntConicQuad aIntersector(anInputLine,
gp_Pln(aPosLoc, aCurrAxis.Direction()),
Precision::Angular(),
Precision::Intersection());
if (!aIntersector.IsDone() || aIntersector.IsParallel() || aIntersector.NbPoints() < 1)
{
return Standard_False;
}
@ -569,7 +574,8 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
myStartPick = aNewPosition;
myHasStartedTransformation = Standard_True;
gp_Dir aStartAxis = gce_MakeDir(aPosLoc, myStartPick);
myPrevState = aStartAxis.AngleWithRef (gce_MakeDir(aPosLoc, aNewPosition), aCurrAxis.Direction());
myPrevState =
aStartAxis.AngleWithRef(gce_MakeDir(aPosLoc, aNewPosition), aCurrAxis.Direction());
return Standard_True;
}
@ -578,7 +584,8 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
return Standard_False;
}
gp_Dir aStartAxis = aPosLoc.IsEqual (myStartPick, Precision::Confusion())
gp_Dir aStartAxis =
aPosLoc.IsEqual(myStartPick, Precision::Confusion())
? getAx1FromAx2Dir(myStartPosition, (myCurrentIndex + 1) % 3).Direction()
: gce_MakeDir(aPosLoc, myStartPick);
@ -603,11 +610,13 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
myPrevState = anAngle;
return Standard_True;
}
case AIS_MM_TranslationPlane:
{
case AIS_MM_TranslationPlane: {
const gp_Pnt aPosLoc = myStartPosition.Location();
const gp_Ax1 aCurrAxis = getAx1FromAx2Dir(myStartPosition, myCurrentIndex);
IntAna_IntConicQuad aIntersector(anInputLine, gp_Pln(aPosLoc, aCurrAxis.Direction()), Precision::Angular(), Precision::Intersection());
IntAna_IntConicQuad aIntersector(anInputLine,
gp_Pln(aPosLoc, aCurrAxis.Direction()),
Precision::Angular(),
Precision::Intersection());
if (!aIntersector.IsDone() || aIntersector.NbPoints() < 1)
{
return Standard_False;
@ -631,18 +640,15 @@ Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer t
theTrsf *= aNewTrsf;
return Standard_True;
}
case AIS_MM_None:
{
case AIS_MM_None: {
return Standard_False;
}
}
return Standard_False;
}
//=======================================================================
//function : ProcessDragging
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_Manipulator::ProcessDragging(const Handle(AIS_InteractiveContext)& aCtx,
const Handle(V3d_View)& theView,
const Handle(SelectMgr_EntityOwner)&,
@ -652,8 +658,7 @@ Standard_Boolean AIS_Manipulator::ProcessDragging (const Handle(AIS_InteractiveC
{
switch (theAction)
{
case AIS_DragAction_Start:
{
case AIS_DragAction_Start: {
if (HasActiveMode())
{
StartTransform(theDragFrom.x(), theDragFrom.y(), theView);
@ -661,22 +666,18 @@ Standard_Boolean AIS_Manipulator::ProcessDragging (const Handle(AIS_InteractiveC
}
break;
}
case AIS_DragAction_Confirmed:
{
case AIS_DragAction_Confirmed: {
return Standard_True;
}
case AIS_DragAction_Update:
{
case AIS_DragAction_Update: {
Transform(theDragTo.x(), theDragTo.y(), theView);
return Standard_True;
}
case AIS_DragAction_Abort:
{
case AIS_DragAction_Abort: {
StopTransform(false);
return Standard_True;
}
case AIS_DragAction_Stop:
{
case AIS_DragAction_Stop: {
// at the end of transformation redisplay for updating sensitive areas
StopTransform(true);
if (aCtx->IsDisplayed(this))
@ -690,11 +691,11 @@ Standard_Boolean AIS_Manipulator::ProcessDragging (const Handle(AIS_InteractiveC
return Standard_False;
}
//=======================================================================
//function : StartTransform
//purpose :
//=======================================================================
void AIS_Manipulator::StartTransform (const Standard_Integer theX, const Standard_Integer theY, const Handle(V3d_View)& theView)
//=================================================================================================
void AIS_Manipulator::StartTransform(const Standard_Integer theX,
const Standard_Integer theY,
const Handle(V3d_View)& theView)
{
if (myHasStartedTransformation)
{
@ -705,10 +706,8 @@ void AIS_Manipulator::StartTransform (const Standard_Integer theX, const Standar
ObjectTransformation(theX, theY, theView, aTrsf);
}
//=======================================================================
//function : StopTransform
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::StopTransform(const Standard_Boolean theToApply)
{
if (!IsAttached() || !myHasStartedTransformation)
@ -732,10 +731,8 @@ void AIS_Manipulator::StopTransform (const Standard_Boolean theToApply)
SetPosition(myStartPosition);
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::Transform(const gp_Trsf& theTrsf)
{
if (!IsAttached() || !myHasStartedTransformation)
@ -752,11 +749,11 @@ void AIS_Manipulator::Transform (const gp_Trsf& theTrsf)
const Handle(AIS_InteractiveObject)& anObj = anObjIter.ChangeValue();
const gp_Trsf& anOldTrsf = aTrsfIter.Value();
const Handle(TopLoc_Datum3D)& aParentTrsf = anObj->CombinedParentTransformation();
if (!aParentTrsf.IsNull()
&& aParentTrsf->Form() != gp_Identity)
if (!aParentTrsf.IsNull() && aParentTrsf->Form() != gp_Identity)
{
// recompute local transformation relative to parent transformation
const gp_Trsf aNewLocalTrsf = aParentTrsf->Trsf().Inverted() * theTrsf * aParentTrsf->Trsf() * anOldTrsf;
const gp_Trsf aNewLocalTrsf =
aParentTrsf->Trsf().Inverted() * theTrsf * aParentTrsf->Trsf() * anOldTrsf;
anObj->SetLocalTransformation(aNewLocalTrsf);
}
else
@ -777,11 +774,10 @@ void AIS_Manipulator::Transform (const gp_Trsf& theTrsf)
}
}
//=======================================================================
//function : Transform
//purpose :
//=======================================================================
gp_Trsf AIS_Manipulator::Transform (const Standard_Integer thePX, const Standard_Integer thePY,
//=================================================================================================
gp_Trsf AIS_Manipulator::Transform(const Standard_Integer thePX,
const Standard_Integer thePY,
const Handle(V3d_View)& theView)
{
gp_Trsf aTrsf;
@ -793,10 +789,8 @@ gp_Trsf AIS_Manipulator::Transform (const Standard_Integer thePX, const Standard
return aTrsf;
}
//=======================================================================
//function : SetPosition
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::SetPosition(const gp_Ax2& thePosition)
{
if (!myPosition.Location().IsEqual(thePosition.Location(), Precision::Confusion())
@ -846,7 +840,8 @@ void AIS_Manipulator::updateTransformation()
|| TransformPersistence()->Mode() != Graphic3d_TMF_AxialZoomPers
|| !TransformPersistence()->AnchorPoint().IsEqual(myPosition.Location(), 0.0))
{
setTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_AxialZoomPers, myPosition.Location()));
setTransformPersistence(
new Graphic3d_TransformPers(Graphic3d_TMF_AxialZoomPers, myPosition.Location()));
}
}
else
@ -854,15 +849,14 @@ void AIS_Manipulator::updateTransformation()
if (TransformPersistence().IsNull()
|| TransformPersistence()->Mode() != Graphic3d_TMF_AxialScalePers)
{
setTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_AxialScalePers, myPosition.Location()));
setTransformPersistence(
new Graphic3d_TransformPers(Graphic3d_TMF_AxialScalePers, myPosition.Location()));
}
}
}
//=======================================================================
//function : SetSize
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::SetSize(const Standard_ShortReal theSideLength)
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
@ -873,10 +867,8 @@ void AIS_Manipulator::SetSize (const Standard_ShortReal theSideLength)
SetToUpdate();
}
//=======================================================================
//function : SetGap
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::SetGap(const Standard_ShortReal theValue)
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
@ -887,10 +879,8 @@ void AIS_Manipulator::SetGap (const Standard_ShortReal theValue)
SetToUpdate();
}
//=======================================================================
//function : DeactivateCurrentMode
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::DeactivateCurrentMode()
{
if (!myIsActivationOnDetection)
@ -924,10 +914,8 @@ void AIS_Manipulator::DeactivateCurrentMode()
}
}
//=======================================================================
//function : SetZoomPersistence
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::SetZoomPersistence(const Standard_Boolean theToEnable)
{
if (myIsZoomPersistentMode != theToEnable)
@ -945,10 +933,8 @@ void AIS_Manipulator::SetZoomPersistence (const Standard_Boolean theToEnable)
updateTransformation();
}
//=======================================================================
//function : SetTransformPersistence
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::SetTransformPersistence(const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
Standard_ASSERT_RETURN(!myIsZoomPersistentMode,
@ -958,10 +944,8 @@ void AIS_Manipulator::SetTransformPersistence (const Handle(Graphic3d_TransformP
setTransformPersistence(theTrsfPers);
}
//=======================================================================
//function : setTransformPersistence
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::setTransformPersistence(const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
AIS_InteractiveObject::SetTransformPersistence(theTrsfPers);
@ -972,20 +956,16 @@ void AIS_Manipulator::setTransformPersistence (const Handle(Graphic3d_TransformP
}
}
//=======================================================================
//function : setLocalTransformation
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::setLocalTransformation(const Handle(TopLoc_Datum3D)& /*theTrsf*/)
{
Standard_ASSERT_INVOKE("AIS_Manipulator::setLocalTransformation: "
"Custom transformation is not supported by this class");
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
@ -1014,7 +994,8 @@ void AIS_Manipulator::Compute (const Handle(PrsMgr_PresentationManager)& thePrsM
// Display axes
aGroup = thePrs->NewGroup();
Handle(Prs3d_ShadingAspect) anAspectAx = new Prs3d_ShadingAspect (new Graphic3d_AspectFillArea3d(*anAspect->Aspect()));
Handle(Prs3d_ShadingAspect) anAspectAx =
new Prs3d_ShadingAspect(new Graphic3d_AspectFillArea3d(*anAspect->Aspect()));
anAspectAx->SetColor(myAxes[anIt].Color());
aGroup->SetGroupPrimitivesAspect(anAspectAx->Aspect());
myAxes[anIt].Compute(thePrsMgr, thePrs, anAspectAx);
@ -1024,10 +1005,8 @@ void AIS_Manipulator::Compute (const Handle(PrsMgr_PresentationManager)& thePrsM
updateTransformation();
}
//=======================================================================
//function : HilightSelected
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM,
const SelectMgr_SequenceOfOwner& theSeq)
{
@ -1067,19 +1046,15 @@ void AIS_Manipulator::HilightSelected (const Handle(PrsMgr_PresentationManager)&
myCurrentMode = anOwner->Mode();
}
//=======================================================================
//function : ClearSelected
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::ClearSelected()
{
DeactivateCurrentMode();
}
//=======================================================================
//function : HilightOwnerWithColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner)
@ -1105,8 +1080,8 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan
aPresentation->Highlight(theStyle);
}
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups());
aGroupIter.More(); aGroupIter.Next())
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter(aPresentation->Groups()); aGroupIter.More();
aGroupIter.Next())
{
Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
if (!aGrp.IsNull())
@ -1129,10 +1104,8 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Manipulator::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
@ -1155,8 +1128,7 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
switch (aMode)
{
case AIS_MM_Translation:
{
case AIS_MM_Translation: {
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
if (!myAxes[anIt].HasTranslation())
@ -1167,19 +1139,22 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_Translation, 9);
// define sensitivity by line
Handle(Select3D_SensitiveSegment) aLine = new Select3D_SensitiveSegment(anOwner, gp::Origin(), anAxis.TranslatorTipPosition());
Handle(Select3D_SensitiveSegment) aLine =
new Select3D_SensitiveSegment(anOwner, gp::Origin(), anAxis.TranslatorTipPosition());
aLine->SetSensitivityFactor(aHighSensitivity);
theSelection->Add(aLine);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitivePrimitiveArray) aTri = new Select3D_SensitivePrimitiveArray(anOwner);
aTri->InitTriangulation (anAxis.TriangleArray()->Attributes(), anAxis.TriangleArray()->Indices(), TopLoc_Location());
Handle(Select3D_SensitivePrimitiveArray) aTri =
new Select3D_SensitivePrimitiveArray(anOwner);
aTri->InitTriangulation(anAxis.TriangleArray()->Attributes(),
anAxis.TriangleArray()->Indices(),
TopLoc_Location());
theSelection->Add(aTri);
}
break;
}
case AIS_MM_Rotation:
{
case AIS_MM_Rotation: {
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
if (!myAxes[anIt].HasRotation())
@ -1190,18 +1165,21 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_Rotation, 9);
// define sensitivity by circle
const gp_Circ aGeomCircle (gp_Ax2(gp::Origin(), anAxis.ReferenceAxis().Direction()), anAxis.RotatorDiskRadius());
const gp_Circ aGeomCircle(gp_Ax2(gp::Origin(), anAxis.ReferenceAxis().Direction()),
anAxis.RotatorDiskRadius());
Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle(anOwner, aGeomCircle);
aCircle->SetSensitivityFactor(aLowSensitivity);
theSelection->Add(aCircle);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitiveTriangulation) aTri = new ManipSensTriangulation(anOwner, myAxes[anIt].RotatorDisk().Triangulation(), anAxis.ReferenceAxis().Direction());
Handle(Select3D_SensitiveTriangulation) aTri =
new ManipSensTriangulation(anOwner,
myAxes[anIt].RotatorDisk().Triangulation(),
anAxis.ReferenceAxis().Direction());
theSelection->Add(aTri);
}
break;
}
case AIS_MM_Scaling:
{
case AIS_MM_Scaling: {
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
if (!myAxes[anIt].HasScaling())
@ -1211,17 +1189,21 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_Scaling, 9);
// define sensitivity by point
Handle(Select3D_SensitivePoint) aPnt = new Select3D_SensitivePoint(anOwner, myAxes[anIt].ScalerCubePosition());
Handle(Select3D_SensitivePoint) aPnt =
new Select3D_SensitivePoint(anOwner, myAxes[anIt].ScalerCubePosition());
aPnt->SetSensitivityFactor(aHighSensitivity);
theSelection->Add(aPnt);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation(anOwner, myAxes[anIt].ScalerCube().Triangulation(), TopLoc_Location(), Standard_True);
Handle(Select3D_SensitiveTriangulation) aTri =
new Select3D_SensitiveTriangulation(anOwner,
myAxes[anIt].ScalerCube().Triangulation(),
TopLoc_Location(),
Standard_True);
theSelection->Add(aTri);
}
break;
}
case AIS_MM_TranslationPlane:
{
case AIS_MM_TranslationPlane: {
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
if (!myAxes[anIt].HasDragging())
@ -1231,27 +1213,34 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_TranslationPlane, 9);
// define sensitivity by two crossed lines
Standard_Real aSensitivityOffset = ZoomPersistence() ? aHighSensitivity * (0.5 + M_SQRT2) : 0.0;
gp_Pnt aP1 = myAxes[((anIt + 1) % 3)].TranslatorTipPosition().Translated (myAxes[((anIt + 2) % 3)].ReferenceAxis().Direction().XYZ() * aSensitivityOffset);
gp_Pnt aP2 = myAxes[((anIt + 2) % 3)].TranslatorTipPosition().Translated (myAxes[((anIt + 1) % 3)].ReferenceAxis().Direction().XYZ() * aSensitivityOffset);
Standard_Real aSensitivityOffset =
ZoomPersistence() ? aHighSensitivity * (0.5 + M_SQRT2) : 0.0;
gp_Pnt aP1 = myAxes[((anIt + 1) % 3)].TranslatorTipPosition().Translated(
myAxes[((anIt + 2) % 3)].ReferenceAxis().Direction().XYZ() * aSensitivityOffset);
gp_Pnt aP2 = myAxes[((anIt + 2) % 3)].TranslatorTipPosition().Translated(
myAxes[((anIt + 1) % 3)].ReferenceAxis().Direction().XYZ() * aSensitivityOffset);
gp_XYZ aMidP = (aP1.XYZ() + aP2.XYZ()) / 2.0;
gp_XYZ anOrig = aMidP.Normalized().Multiplied(aSensitivityOffset);
Handle(Select3D_SensitiveSegment) aLine1 = new Select3D_SensitiveSegment(anOwner, aP1, aP2);
aLine1->SetSensitivityFactor(aLowSensitivity);
theSelection->Add(aLine1);
Handle(Select3D_SensitiveSegment) aLine2 = new Select3D_SensitiveSegment(anOwner, anOrig, aMidP);
Handle(Select3D_SensitiveSegment) aLine2 =
new Select3D_SensitiveSegment(anOwner, anOrig, aMidP);
aLine2->SetSensitivityFactor(aLowSensitivity);
theSelection->Add(aLine2);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation(anOwner, myAxes[anIt].DraggerSector().Triangulation(), TopLoc_Location(), Standard_True);
Handle(Select3D_SensitiveTriangulation) aTri =
new Select3D_SensitiveTriangulation(anOwner,
myAxes[anIt].DraggerSector().Triangulation(),
TopLoc_Location(),
Standard_True);
theSelection->Add(aTri);
}
break;
}
default:
{
default: {
anOwner = new SelectMgr_EntityOwner(this, 5);
break;
}
@ -1316,14 +1305,18 @@ void AIS_Manipulator::Cube::Init (const gp_Ax1& thePosition, const Standard_Shor
myTriangulation = new Poly_Triangulation(aPoints, aPolyTriangles);
gp_Ax2 aPln(thePosition.Location(), thePosition.Direction());
gp_Pnt aBottomLeft = thePosition.Location().XYZ() - aPln.XDirection().XYZ() * theSize * 0.5 - aPln.YDirection().XYZ() * theSize * 0.5;
gp_Pnt aBottomLeft = thePosition.Location().XYZ() - aPln.XDirection().XYZ() * theSize * 0.5
- aPln.YDirection().XYZ() * theSize * 0.5;
gp_Pnt aV2 = aBottomLeft.XYZ() + aPln.YDirection().XYZ() * theSize;
gp_Pnt aV3 = aBottomLeft.XYZ() + aPln.YDirection().XYZ() * theSize + aPln.XDirection().XYZ() * theSize;
gp_Pnt aV3 =
aBottomLeft.XYZ() + aPln.YDirection().XYZ() * theSize + aPln.XDirection().XYZ() * theSize;
gp_Pnt aV4 = aBottomLeft.XYZ() + aPln.XDirection().XYZ() * theSize;
gp_Pnt aTopRight = thePosition.Location().XYZ() + thePosition.Direction().XYZ() * theSize
+ aPln.XDirection().XYZ() * theSize * 0.5 + aPln.YDirection().XYZ() * theSize * 0.5;
+ aPln.XDirection().XYZ() * theSize * 0.5
+ aPln.YDirection().XYZ() * theSize * 0.5;
gp_Pnt aV5 = aTopRight.XYZ() - aPln.YDirection().XYZ() * theSize;
gp_Pnt aV6 = aTopRight.XYZ() - aPln.YDirection().XYZ() * theSize - aPln.XDirection().XYZ() * theSize;
gp_Pnt aV6 =
aTopRight.XYZ() - aPln.YDirection().XYZ() * theSize - aPln.XDirection().XYZ() * theSize;
gp_Pnt aV7 = aTopRight.XYZ() - aPln.XDirection().XYZ() * theSize;
gp_Dir aRight((gp_Vec(aTopRight, aV7) ^ gp_Vec(aTopRight, aV2)).XYZ());
@ -1360,14 +1353,17 @@ void AIS_Manipulator::Cube::Init (const gp_Ax1& thePosition, const Standard_Shor
// purpose :
//=======================================================================
void AIS_Manipulator::Cube::addTriangle(const Standard_Integer theIndex,
const gp_Pnt& theP1, const gp_Pnt& theP2, const gp_Pnt& theP3,
const gp_Pnt& theP1,
const gp_Pnt& theP2,
const gp_Pnt& theP3,
const gp_Dir& theNormal)
{
myTriangulation->SetNode(theIndex * 3 + 1, theP1);
myTriangulation->SetNode(theIndex * 3 + 2, theP2);
myTriangulation->SetNode(theIndex * 3 + 3, theP3);
myTriangulation->SetTriangle (theIndex + 1, Poly_Triangle (theIndex * 3 + 1, theIndex * 3 + 2, theIndex * 3 + 3));
myTriangulation->SetTriangle(theIndex + 1,
Poly_Triangle(theIndex * 3 + 1, theIndex * 3 + 2, theIndex * 3 + 3));
myArray->AddVertex(theP1, theNormal);
myArray->AddVertex(theP2, theNormal);
myArray->AddVertex(theP3, theNormal);
@ -1433,7 +1429,8 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
{
const Standard_Real anArrowLength = 0.25 * myLength;
const Standard_Real aCylinderLength = myLength - anArrowLength;
myArrowTipPos = gp_Pnt (0.0, 0.0, 0.0).Translated (myReferenceAxis.Direction().XYZ() * aCylinderLength);
myArrowTipPos =
gp_Pnt(0.0, 0.0, 0.0).Translated(myReferenceAxis.Direction().XYZ() * aCylinderLength);
myTriangleArray = Prs3d_Arrow::DrawShaded(gp_Ax1(gp::Origin(), myReferenceAxis.Direction()),
myAxisRadius,
@ -1489,7 +1486,10 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
if (myHasRotation)
{
myCircleRadius = myInnerRadius + myIndent * 2 + myDiskThickness * 0.5f;
myCircle.Init (myInnerRadius + myIndent * 2, myInnerRadius + myDiskThickness + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), myFacettesNumber * 2);
myCircle.Init(myInnerRadius + myIndent * 2,
myInnerRadius + myDiskThickness + myIndent * 2,
gp_Ax1(gp::Origin(), myReferenceAxis.Direction()),
myFacettesNumber * 2);
myRotatorGroup = thePrs->NewGroup();
myRotatorGroup->SetGroupPrimitivesAspect(theAspect->Aspect());
myRotatorGroup->AddPrimitiveArray(myCircle.Array());
@ -1519,7 +1519,10 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
else
aXDirection = gp::DX();
mySector.Init(myInnerRadius + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), aXDirection, myFacettesNumber * 2);
mySector.Init(myInnerRadius + myIndent * 2,
gp_Ax1(gp::Origin(), myReferenceAxis.Direction()),
aXDirection,
myFacettesNumber * 2);
myDraggerGroup = thePrs->NewGroup();
Handle(Graphic3d_AspectFillArea3d) aFillArea = new Graphic3d_AspectFillArea3d();

View File

@ -93,34 +93,60 @@ DEFINE_STANDARD_HANDLE (AIS_Manipulator, AIS_InteractiveObject)
class AIS_Manipulator : public AIS_InteractiveObject
{
public:
//! Constructs a manipulator object with default placement and all parts to be displayed.
Standard_EXPORT AIS_Manipulator();
//! Constructs a manipulator object with input location and positions of axes and all parts to be displayed.
//! Constructs a manipulator object with input location and positions of axes and all parts to be
//! displayed.
Standard_EXPORT AIS_Manipulator(const gp_Ax2& thePosition);
//! Disable or enable visual parts for translation, rotation or scaling for some axis.
//! By default all parts are enabled (will be displayed).
//! @warning Enabling or disabling of visual parts of manipulator does not manage the manipulation (selection) mode.
//! @warning Enabling or disabling of visual parts of manipulator does not manage the manipulation
//! (selection) mode.
//! @warning Raises program error if axis index is < 0 or > 2.
Standard_EXPORT void SetPart (const Standard_Integer theAxisIndex, const AIS_ManipulatorMode theMode, const Standard_Boolean theIsEnabled);
Standard_EXPORT void SetPart(const Standard_Integer theAxisIndex,
const AIS_ManipulatorMode theMode,
const Standard_Boolean theIsEnabled);
//! Disable or enable visual parts for translation, rotation or scaling for ALL axes.
//! By default all parts are enabled (will be displayed).
//! @warning Enabling or disabling of visual parts of manipulator does not manage the manipulation (selection) mode.
//! @warning Enabling or disabling of visual parts of manipulator does not manage the manipulation
//! (selection) mode.
//! @warning Raises program error if axis index is < 0 or > 2.
Standard_EXPORT void SetPart (const AIS_ManipulatorMode theMode, const Standard_Boolean theIsEnabled);
Standard_EXPORT void SetPart(const AIS_ManipulatorMode theMode,
const Standard_Boolean theIsEnabled);
//! Behavior settings to be applied when performing transformation:
//! - FollowTranslation - whether the manipulator will be moved together with an object.
//! - FollowRotation - whether the manipulator will be rotated together with an object.
struct OptionsForAttach {
struct OptionsForAttach
{
OptionsForAttach() : AdjustPosition (Standard_True), AdjustSize (Standard_False), EnableModes (Standard_True) {}
OptionsForAttach& SetAdjustPosition (const Standard_Boolean theApply) { AdjustPosition = theApply; return *this; }
OptionsForAttach& SetAdjustSize (const Standard_Boolean theApply) { AdjustSize = theApply; return *this; }
OptionsForAttach& SetEnableModes (const Standard_Boolean theApply) { EnableModes = theApply; return *this; }
OptionsForAttach()
: AdjustPosition(Standard_True),
AdjustSize(Standard_False),
EnableModes(Standard_True)
{
}
OptionsForAttach& SetAdjustPosition(const Standard_Boolean theApply)
{
AdjustPosition = theApply;
return *this;
}
OptionsForAttach& SetAdjustSize(const Standard_Boolean theApply)
{
AdjustSize = theApply;
return *this;
}
OptionsForAttach& SetEnableModes(const Standard_Boolean theApply)
{
EnableModes = theApply;
return *this;
}
Standard_Boolean AdjustPosition;
Standard_Boolean AdjustSize;
@ -128,13 +154,17 @@ public:
};
//! Attaches himself to the input interactive object and become displayed in the same context.
//! It is placed in the center of object bounding box, and its size is adjusted to the object bounding box.
Standard_EXPORT void Attach (const Handle(AIS_InteractiveObject)& theObject, const OptionsForAttach& theOptions = OptionsForAttach());
//! It is placed in the center of object bounding box, and its size is adjusted to the object
//! bounding box.
Standard_EXPORT void Attach(const Handle(AIS_InteractiveObject)& theObject,
const OptionsForAttach& theOptions = OptionsForAttach());
//! Attaches himself to the input interactive object group and become displayed in the same context.
//! It become attached to the first object, baut manage manipulation of the whole group.
//! It is placed in the center of object bounding box, and its size is adjusted to the object bounding box.
Standard_EXPORT void Attach (const Handle(AIS_ManipulatorObjectSequence)& theObject, const OptionsForAttach& theOptions = OptionsForAttach());
//! Attaches himself to the input interactive object group and become displayed in the same
//! context. It become attached to the first object, baut manage manipulation of the whole group.
//! It is placed in the center of object bounding box, and its size is adjusted to the object
//! bounding box.
Standard_EXPORT void Attach(const Handle(AIS_ManipulatorObjectSequence)& theObject,
const OptionsForAttach& theOptions = OptionsForAttach());
//! Enable manipualtion mode.
//! @warning It activates selection mode in the current context.
@ -150,10 +180,7 @@ public:
}
//! @return true if manual mode activation is enabled.
Standard_Boolean IsModeActivationOnDetection() const
{
return myIsActivationOnDetection;
}
Standard_Boolean IsModeActivationOnDetection() const { return myIsActivationOnDetection; }
public:
//! Drag object in the viewer.
@ -164,7 +191,8 @@ public:
//! @param[in] theDragTo drag end point
//! @param[in] theAction drag action
//! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start)
Standard_EXPORT virtual Standard_Boolean ProcessDragging (const Handle(AIS_InteractiveContext)& theCtx,
Standard_EXPORT virtual Standard_Boolean ProcessDragging(
const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const Handle(SelectMgr_EntityOwner)& theOwner,
const Graphic3d_Vec2i& theDragFrom,
@ -173,9 +201,12 @@ public:
//! Init start (reference) transformation.
//! @warning It is used in chain with StartTransform-Transform(gp_Trsf)-StopTransform
//! and is used only for custom transform set. If Transform(const Standard_Integer, const Standard_Integer) is used,
//! initial data is set automatically, and it is reset on DeactivateCurrentMode call if it is not reset yet.
Standard_EXPORT void StartTransform (const Standard_Integer theX, const Standard_Integer theY, const Handle(V3d_View)& theView);
//! and is used only for custom transform set. If Transform(const Standard_Integer, const
//! Standard_Integer) is used, initial data is set automatically, and it is reset on
//! DeactivateCurrentMode call if it is not reset yet.
Standard_EXPORT void StartTransform(const Standard_Integer theX,
const Standard_Integer theY,
const Handle(V3d_View)& theView);
//! Apply to the owning objects the input transformation.
//! @remark The transformation is set using SetLocalTransformation for owning objects.
@ -195,18 +226,21 @@ public:
//! Apply transformation made from mouse moving from start position
//! (save on the first Transform() call and reset on DeactivateCurrentMode() call.)
//! to the in/out mouse position (theX, theY)
Standard_EXPORT gp_Trsf Transform (const Standard_Integer theX, const Standard_Integer theY,
Standard_EXPORT gp_Trsf Transform(const Standard_Integer theX,
const Standard_Integer theY,
const Handle(V3d_View)& theView);
//! Computes transformation of parent object according to the active mode and input motion vector.
//! You can use this method to get object transformation according to current mode or use own algorithm
//! to implement any other transformation for modes.
//! You can use this method to get object transformation according to current mode or use own
//! algorithm to implement any other transformation for modes.
//! @return transformation of parent object.
Standard_EXPORT Standard_Boolean ObjectTransformation (const Standard_Integer theX, const Standard_Integer theY,
const Handle(V3d_View)& theView, gp_Trsf& theTrsf);
Standard_EXPORT Standard_Boolean ObjectTransformation(const Standard_Integer theX,
const Standard_Integer theY,
const Handle(V3d_View)& theView,
gp_Trsf& theTrsf);
//! Make inactive the current selected manipulator part and reset current axis index and current mode.
//! After its call HasActiveMode() returns false.
//! Make inactive the current selected manipulator part and reset current axis index and current
//! mode. After its call HasActiveMode() returns false.
//! @sa HasActiveMode()
Standard_EXPORT void DeactivateCurrentMode();
@ -226,22 +260,26 @@ public:
//! @return true if manipulator is attached to some interactive object (has owning object).
Standard_Boolean IsAttached() const { return HasOwner(); }
//! @return true if some part of manipulator is selected (transformation mode is active, and owning object can be transformed).
//! @return true if some part of manipulator is selected (transformation mode is active, and
//! owning object can be transformed).
Standard_Boolean HasActiveMode() const { return IsAttached() && myCurrentMode != AIS_MM_None; }
Standard_Boolean HasActiveTransformation() { return myHasStartedTransformation; }
gp_Trsf StartTransformation() const { return !myStartTrsfs.IsEmpty() ? myStartTrsfs.First() : gp_Trsf(); }
gp_Trsf StartTransformation() const
{
return !myStartTrsfs.IsEmpty() ? myStartTrsfs.First() : gp_Trsf();
}
gp_Trsf StartTransformation(Standard_Integer theIndex) const
{
Standard_ProgramError_Raise_if (theIndex < 1 || theIndex > Objects()->Upper(),
Standard_ProgramError_Raise_if(
theIndex < 1 || theIndex > Objects()->Upper(),
"AIS_Manipulator::StartTransformation(): theIndex is out of bounds");
return !myStartTrsfs.IsEmpty() ? myStartTrsfs(theIndex) : gp_Trsf();
}
public: //! @name Configuration of graphical transformations
//! Enable or disable zoom persistence mode for the manipulator. With
//! this mode turned on the presentation will keep fixed screen size.
//! @warning when turned on this option overrides transform persistence
@ -253,18 +291,19 @@ public: //! @name Configuration of graphical transformations
//! Returns state of zoom persistence mode, whether it turned on or off.
Standard_Boolean ZoomPersistence() const { return myIsZoomPersistentMode; }
//! Redefines transform persistence management to setup transformation for sub-presentation of axes.
//! Redefines transform persistence management to setup transformation for sub-presentation of
//! axes.
//! @warning this interactive object does not support custom transformation persistence when
//! using \sa ZoomPersistence mode. In this mode the transformation persistence flags for
//! presentations are overridden by this class.
//! @warning Invokes debug assertion to catch incompatible usage of the method with \sa ZoomPersistence mode,
//! silently does nothing in release mode.
//! @warning Invokes debug assertion to catch incompatible usage of the method with \sa
//! ZoomPersistence mode, silently does nothing in release mode.
//! @warning revise use of AdjustSize argument of of \sa AttachToObjects method
//! when enabling zoom persistence.
Standard_EXPORT virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) Standard_OVERRIDE;
Standard_EXPORT virtual void SetTransformPersistence(
const Handle(Graphic3d_TransformPers)& theTrsfPers) Standard_OVERRIDE;
public: //! @name Setters for parameters
AIS_ManipulatorMode ActiveMode() const { return myCurrentMode; }
Standard_Integer ActiveAxisIndex() const { return myCurrentIndex; }
@ -284,16 +323,36 @@ public: //! @name Setters for parameters
Standard_EXPORT void SetGap(const Standard_ShortReal theValue);
public:
//! Behavior settings to be applied when performing transformation:
//! - FollowTranslation - whether the manipulator will be moved together with an object.
//! - FollowRotation - whether the manipulator will be rotated together with an object.
struct BehaviorOnTransform {
struct BehaviorOnTransform
{
BehaviorOnTransform() : FollowTranslation (Standard_True), FollowRotation (Standard_True), FollowDragging (Standard_True) {}
BehaviorOnTransform& SetFollowTranslation (const Standard_Boolean theApply) { FollowTranslation = theApply; return *this; }
BehaviorOnTransform& SetFollowRotation (const Standard_Boolean theApply) { FollowRotation = theApply; return *this; }
BehaviorOnTransform& SetFollowDragging (const Standard_Boolean theApply) { FollowDragging = theApply; return *this; }
BehaviorOnTransform()
: FollowTranslation(Standard_True),
FollowRotation(Standard_True),
FollowDragging(Standard_True)
{
}
BehaviorOnTransform& SetFollowTranslation(const Standard_Boolean theApply)
{
FollowTranslation = theApply;
return *this;
}
BehaviorOnTransform& SetFollowRotation(const Standard_Boolean theApply)
{
FollowRotation = theApply;
return *this;
}
BehaviorOnTransform& SetFollowDragging(const Standard_Boolean theApply)
{
FollowDragging = theApply;
return *this;
}
Standard_Boolean FollowTranslation;
Standard_Boolean FollowRotation;
@ -302,7 +361,10 @@ public:
//! Sets behavior settings for transformation action carried on the manipulator,
//! whether it translates, rotates together with the transformed object or not.
void SetTransformBehavior (const BehaviorOnTransform& theSettings) { myBehaviorOnTransform = theSettings; }
void SetTransformBehavior(const BehaviorOnTransform& theSettings)
{
myBehaviorOnTransform = theSettings;
}
//! @return behavior settings for transformation action of the manipulator.
BehaviorOnTransform& ChangeTransformBehavior() { return myBehaviorOnTransform; }
@ -311,9 +373,9 @@ public:
const BehaviorOnTransform& TransformBehavior() const { return myBehaviorOnTransform; }
public: //! @name Presentation computation
//! Fills presentation.
//! @note Manipulator presentation does not use display mode and for all modes has the same presentation.
//! @note Manipulator presentation does not use display mode and for all modes has the same
//! presentation.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode = 0) Standard_OVERRIDE;
@ -323,34 +385,36 @@ public: //! @name Presentation computation
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE
{
return Standard_False;
}
//! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden
//! methods.
virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
//! Method which clear all selected owners belonging
//! to this selectable object ( for fast presentation draw ).
Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
//! Method which draws selected owners ( for fast presentation draw ).
Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager)& thePM, const SelectMgr_SequenceOfOwner& theSeq) Standard_OVERRIDE;
Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM,
const SelectMgr_SequenceOfOwner& theSeq)
Standard_OVERRIDE;
//! Method which hilight an owner belonging to
//! this selectable object ( for fast presentation draw ).
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
Standard_EXPORT virtual void HilightOwnerWithColor(
const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
protected:
Standard_EXPORT void init();
Standard_EXPORT void updateTransformation();
Standard_EXPORT Handle(Prs3d_Presentation) getHighlightPresentation (const Handle(SelectMgr_EntityOwner)& theOwner) const;
Standard_EXPORT Handle(Prs3d_Presentation) getHighlightPresentation(
const Handle(SelectMgr_EntityOwner)& theOwner) const;
Standard_EXPORT Handle(Graphic3d_Group) getGroup (const Standard_Integer theIndex, const AIS_ManipulatorMode theMode) const;
Standard_EXPORT Handle(Graphic3d_Group) getGroup(const Standard_Integer theIndex,
const AIS_ManipulatorMode theMode) const;
Standard_EXPORT void attachToBox(const Bnd_Box& theBox);
@ -364,28 +428,25 @@ protected:
//! without need for recomputing presentation.
//! @warning Invokes debug assertion in debug to catch incompatible usage of the
//! method, silently does nothing in release mode.
Standard_EXPORT virtual void setLocalTransformation (const Handle(TopLoc_Datum3D)& theTrsf) Standard_OVERRIDE;
Standard_EXPORT virtual void setLocalTransformation(const Handle(TopLoc_Datum3D)& theTrsf)
Standard_OVERRIDE;
using AIS_InteractiveObject::SetLocalTransformation; // hide visibility
protected: //! @name Auxiliary classes to fill presentation with proper primitives
class Quadric
{
public:
virtual ~Quadric()
{
myTriangulation.Nullify();
myArray.Nullify();
}
const Handle(Poly_Triangulation)& Triangulation() const { return myTriangulation; }
const Handle(Graphic3d_ArrayOfTriangles)& Array() const { return myArray; }
protected:
Handle(Poly_Triangulation) myTriangulation;
Handle(Graphic3d_ArrayOfTriangles) myArray;
};
@ -393,12 +454,12 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
class Disk : public Quadric
{
public:
Disk()
: Quadric(),
myInnerRad(0.0f),
myOuterRad(1.0f)
{ }
{
}
~Disk() {}
@ -409,7 +470,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
const Standard_Integer theStacksNb = 20);
protected:
gp_Ax1 myPosition;
Standard_ShortReal myInnerRad;
Standard_ShortReal myOuterRad;
@ -421,7 +481,8 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Sphere()
: Quadric(),
myRadius(1.0f)
{}
{
}
void Init(const Standard_ShortReal theRadius,
const gp_Pnt& thePosition,
@ -429,7 +490,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
const Standard_Integer theStacksNb = 20);
protected:
gp_Pnt myPosition;
Standard_ShortReal myRadius;
};
@ -437,8 +497,8 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
class Cube
{
public:
Cube() {}
~Cube() {}
void Init(const gp_Ax1& thePosition, const Standard_ShortReal myBoxSize);
@ -448,12 +508,13 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
const Handle(Graphic3d_ArrayOfTriangles)& Array() const { return myArray; }
private:
void addTriangle (const Standard_Integer theIndex, const gp_Pnt& theP1, const gp_Pnt& theP2, const gp_Pnt& theP3,
void addTriangle(const Standard_Integer theIndex,
const gp_Pnt& theP1,
const gp_Pnt& theP2,
const gp_Pnt& theP3,
const gp_Dir& theNormal);
protected:
Handle(Poly_Triangulation) myTriangulation;
Handle(Graphic3d_ArrayOfTriangles) myArray;
};
@ -461,11 +522,11 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
class Sector : public Quadric
{
public:
Sector()
: Quadric(),
myRadius(0.0f)
{ }
{
}
~Sector() {}
@ -476,7 +537,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
const Standard_Integer theStacksNb = 5);
protected:
gp_Ax1 myPosition;
Standard_ShortReal myRadius;
};
@ -489,7 +549,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
class Axis
{
public:
Axis(const gp_Ax1& theAxis = gp_Ax1(),
const Quantity_Color& theColor = Quantity_Color(),
const Standard_ShortReal theLength = 10.0f);
@ -574,7 +633,10 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
void SetAxisRadius(const Standard_ShortReal theValue) { myAxisRadius = theValue; }
const Handle(Prs3d_Presentation)& TranslatorHighlightPrs() const { return myHighlightTranslator; }
const Handle(Prs3d_Presentation)& TranslatorHighlightPrs() const
{
return myHighlightTranslator;
}
const Handle(Prs3d_Presentation)& RotatorHighlightPrs() const { return myHighlightRotator; }
@ -594,9 +656,16 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
void SetIndent(const Standard_ShortReal theValue) { myIndent = theValue; }
Standard_ShortReal Size() const { return myLength + myBoxSize + myDiskThickness + myIndent * 2.0f; }
Standard_ShortReal Size() const
{
return myLength + myBoxSize + myDiskThickness + myIndent * 2.0f;
}
gp_Pnt ScalerCenter (const gp_Pnt& theLocation) const { return theLocation.XYZ() + myPosition.Direction().XYZ() * (myLength + myIndent + myBoxSize * 0.5f); }
gp_Pnt ScalerCenter(const gp_Pnt& theLocation) const
{
return theLocation.XYZ()
+ myPosition.Direction().XYZ() * (myLength + myIndent + myBoxSize * 0.5f);
}
void SetSize(const Standard_ShortReal theValue)
{
@ -621,16 +690,19 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Standard_Integer FacettesNumber() const { return myFacettesNumber; }
public:
const gp_Pnt& TranslatorTipPosition() const { return myArrowTipPos; }
const Sector& DraggerSector() const { return mySector; }
const Disk& RotatorDisk() const { return myCircle; }
float RotatorDiskRadius() const { return myCircleRadius; }
const Cube& ScalerCube() const { return myCube; }
const gp_Pnt& ScalerCubePosition() const { return myCubePos; }
protected:
gp_Ax1 myReferenceAxis; //!< Returns reference axis assignment.
gp_Ax1 myPosition; //!< Position of the axis including local transformation.
Quantity_Color myColor;
@ -650,7 +722,6 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Standard_Boolean myHasDragging;
protected:
Standard_Integer myFacettesNumber;
gp_Pnt myArrowTipPos;
@ -671,11 +742,9 @@ protected: //! @name Auxiliary classes to fill presentation with proper primitiv
Handle(Prs3d_Presentation) myHighlightDragger;
Handle(Graphic3d_ArrayOfTriangles) myTriangleArray;
};
protected:
Axis myAxes[3]; //!< Tree axes of the manipulator.
Sphere myCenter; //!< Visual part displaying the center sphere of the manipulator.
// clang-format off
@ -702,8 +771,8 @@ protected: //! @name Fields for interactive transformation. Fields only for inte
//! Aspect used to color sector part when it's selected.
Handle(Prs3d_ShadingAspect) myDraggerHighlight;
public:
public:
DEFINE_STANDARD_RTTIEXT(AIS_Manipulator, AIS_InteractiveObject)
};
#endif // _AIS_Manipulator_HeaderFile

View File

@ -16,10 +16,9 @@
#include <AIS_ManipulatorOwner.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_ManipulatorOwner, SelectMgr_EntityOwner)
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
//=================================================================================================
AIS_ManipulatorOwner::AIS_ManipulatorOwner(const Handle(SelectMgr_SelectableObject)& theSelObject,
const Standard_Integer theIndex,
const AIS_ManipulatorMode theMode,
@ -31,10 +30,8 @@ AIS_ManipulatorOwner::AIS_ManipulatorOwner (const Handle(SelectMgr_SelectableObj
//
}
//=======================================================================
//function : HilightWithColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ManipulatorOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode)
@ -48,10 +45,8 @@ void AIS_ManipulatorOwner::HilightWithColor (const Handle(PrsMgr_PresentationMan
Selectable()->HilightOwnerWithColor(thePM, theStyle, this);
}
//=======================================================================
//function : IsHilighted
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ManipulatorOwner::IsHilighted(const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer /*theMode*/) const
{
@ -63,10 +58,8 @@ Standard_Boolean AIS_ManipulatorOwner::IsHilighted (const Handle(PrsMgr_Presenta
return thePM->IsHighlighted(Selectable(), myMode);
}
//=======================================================================
//function : Unhilight
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ManipulatorOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer /*theMode*/)
{

View File

@ -27,7 +27,6 @@ DEFINE_STANDARD_HANDLE(AIS_ManipulatorOwner, SelectMgr_EntityOwner)
class AIS_ManipulatorOwner : public SelectMgr_EntityOwner
{
public:
DEFINE_STANDARD_RTTIEXT(AIS_ManipulatorOwner, SelectMgr_EntityOwner)
Standard_EXPORT AIS_ManipulatorOwner(const Handle(SelectMgr_SelectableObject)& theSelObject,
@ -39,10 +38,12 @@ public:
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
Standard_EXPORT Standard_Boolean
IsHilighted(const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer theMode) const Standard_OVERRIDE;
Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void Unhilight(const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer theMode) Standard_OVERRIDE;
AIS_ManipulatorMode Mode() const { return myMode; }
@ -50,7 +51,6 @@ public:
Standard_Integer Index() const { return myIndex; }
protected:
Standard_Integer myIndex; //!< index of manipulator axis.
AIS_ManipulatorMode myMode; //!< manipulation (highlight) mode.
};

View File

@ -39,10 +39,8 @@ static Handle(Graphic3d_ArrayOfTriangles) createRectangleArray (const Graphic3d_
return aRectTris;
}
//================================================================
// Function : AIS_MediaPlayer
// Purpose :
//================================================================
//=================================================================================================
AIS_MediaPlayer::AIS_MediaPlayer()
: myFramePair(new Graphic3d_MediaTextureSet()),
myFrameSize(1, 1),
@ -53,16 +51,20 @@ AIS_MediaPlayer::AIS_MediaPlayer()
SetInfiniteState(true);
Graphic3d_MaterialAspect aMat;
myFrameAspect = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_WHITE, Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0f, aMat, aMat);
myFrameAspect = new Graphic3d_AspectFillArea3d(Aspect_IS_SOLID,
Quantity_NOC_WHITE,
Quantity_NOC_BLACK,
Aspect_TOL_SOLID,
1.0f,
aMat,
aMat);
myFrameAspect->SetShadingModel(Graphic3d_TypeOfShadingModel_Unlit);
myFrameAspect->SetTextureMapOn(true);
myFrameAspect->SetTextureSet(myFramePair);
}
//================================================================
// Function : ~AIS_MediaPlayer
// Purpose :
//================================================================
//=================================================================================================
AIS_MediaPlayer::~AIS_MediaPlayer()
{
// stop threads
@ -73,11 +75,9 @@ AIS_MediaPlayer::~AIS_MediaPlayer()
// function : OpenInput
// purpose :
// =======================================================================
void AIS_MediaPlayer::OpenInput (const TCollection_AsciiString& thePath,
Standard_Boolean theToWait)
void AIS_MediaPlayer::OpenInput(const TCollection_AsciiString& thePath, Standard_Boolean theToWait)
{
if (myFramePair->PlayerContext().IsNull()
&& thePath.IsEmpty())
if (myFramePair->PlayerContext().IsNull() && thePath.IsEmpty())
{
return;
}
@ -138,8 +138,7 @@ bool AIS_MediaPlayer::updateSize (const Graphic3d_Vec2i& theLeftCorner,
const Graphic3d_Vec2i aFrameSize = myFramePair->FrameSize();
Graphic3d_Vec2i aNewPos = theLeftCorner;
Graphic3d_Vec2i aNewSize = myFrameSize;
if (aFrameSize.x() > 0
&& aFrameSize.y() > 0)
if (aFrameSize.x() > 0 && aFrameSize.y() > 0)
{
const double anAspect = double(theMaxSize.x()) / double(theMaxSize.y());
const double aFitAspect = double(aFrameSize.x()) / double(aFrameSize.y());
@ -165,14 +164,12 @@ bool AIS_MediaPlayer::updateSize (const Graphic3d_Vec2i& theLeftCorner,
aNewPos = theLeftCorner + theMaxSize / 2 - aNewSize / 2;
}
else if (myFrameSize.x() < 2
|| myFrameSize.y() < 2)
else if (myFrameSize.x() < 2 || myFrameSize.y() < 2)
{
aNewSize = theMaxSize;
}
if (myFrameSize == aNewSize
&& myFrameBottomLeft == aNewPos)
if (myFrameSize == aNewSize && myFrameBottomLeft == aNewPos)
{
return false;
}
@ -220,7 +217,10 @@ void AIS_MediaPlayer::Compute (const Handle(PrsMgr_PresentationManager)& ,
// main frame
{
Handle(Graphic3d_ArrayOfTriangles) aTris = createRectangleArray (myFrameBottomLeft, myFrameBottomLeft + myFrameSize, Graphic3d_ArrayFlags_VertexTexel);
Handle(Graphic3d_ArrayOfTriangles) aTris =
createRectangleArray(myFrameBottomLeft,
myFrameBottomLeft + myFrameSize,
Graphic3d_ArrayFlags_VertexTexel);
Handle(Graphic3d_Group) aMainGroup = thePrs->NewGroup();
aMainGroup->SetGroupPrimitivesAspect(myFrameAspect);
aMainGroup->AddPrimitiveArray(aTris);
@ -239,7 +239,9 @@ void AIS_MediaPlayer::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
return;
}
Handle(Graphic3d_ArrayOfTriangles) aTris = createRectangleArray (myFrameBottomLeft, myFrameBottomLeft + myFrameSize, Graphic3d_ArrayFlags_None);
Handle(Graphic3d_ArrayOfTriangles) aTris = createRectangleArray(myFrameBottomLeft,
myFrameBottomLeft + myFrameSize,
Graphic3d_ArrayFlags_None);
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this, 5);
Handle(Select3D_SensitivePrimitiveArray) aSens = new Select3D_SensitivePrimitiveArray(anOwner);

View File

@ -25,7 +25,6 @@ class AIS_MediaPlayer : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_MediaPlayer, AIS_InteractiveObject)
public:
//! Empty constructor.
Standard_EXPORT AIS_MediaPlayer();
@ -33,7 +32,8 @@ public:
Standard_EXPORT virtual ~AIS_MediaPlayer();
//! Setup callback to be called on queue progress (e.g. when new frame should be displayed).
void SetCallback (Graphic3d_MediaTextureSet::CallbackOnUpdate_t theCallbackFunction, void* theCallbackUserPtr)
void SetCallback(Graphic3d_MediaTextureSet::CallbackOnUpdate_t theCallbackFunction,
void* theCallbackUserPtr)
{
myFramePair->SetCallback(theCallbackFunction, theCallbackUserPtr);
}
@ -64,9 +64,11 @@ public:
//! @name AIS_InteractiveObject interface
protected:
//! Accept only display mode 0.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{
return theMode == 0;
}
//! Compute presentation.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
@ -78,19 +80,16 @@ protected:
const Standard_Integer theMode) Standard_OVERRIDE;
protected:
//! Update frame size.
Standard_EXPORT bool updateSize(const Graphic3d_Vec2i& theLeftCorner,
const Graphic3d_Vec2i& theMaxSize);
protected:
Handle(Graphic3d_MediaTextureSet) myFramePair;
Handle(Graphic3d_AspectFillArea3d) myFrameAspect;
Graphic3d_Vec2i myFrameBottomLeft;
Graphic3d_Vec2i myFrameSize;
bool myToClosePlayer;
};
#endif // _AIS_MediaPlayer_HeaderFile

View File

@ -23,21 +23,25 @@ enum AIS_MouseGesture
AIS_MouseGesture_NONE, //!< no active gesture
//
AIS_MouseGesture_SelectRectangle, //!< rectangular selection;
//! press button to start, move mouse to define rectangle, release to finish
//! press button to start, move mouse to define rectangle,
//! release to finish
AIS_MouseGesture_SelectLasso, //!< polygonal selection;
//! press button to start, move mouse to define polygonal path, release to finish
//! press button to start, move mouse to define polygonal path,
//! release to finish
//
AIS_MouseGesture_Zoom, //!< view zoom gesture;
//! move mouse left to zoom-out, and to the right to zoom-in
AIS_MouseGesture_ZoomVertical, //!< view zoom gesture;
//! move mouse up to zoom-out, and to the down to zoom-in
AIS_MouseGesture_ZoomWindow, //!< view zoom by window gesture;
//! press button to start, move mouse to define rectangle, release to finish
//! press button to start, move mouse to define rectangle, release
//! to finish
AIS_MouseGesture_Pan, //!< view panning gesture
AIS_MouseGesture_RotateOrbit, //!< orbit rotation gesture
AIS_MouseGesture_RotateView, //!< view rotation gesture
AIS_MouseGesture_Drag, //!< object dragging;
//! press button to start, move mouse to define rectangle, release to finish
//! press button to start, move mouse to define rectangle, release to
//! finish
};
//! Map defining mouse gestures.

View File

@ -23,10 +23,7 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive, AIS_InteractiveObject)
//=======================================================================
//function : AIS_MultipleConnectedInteractive
//purpose :
//=======================================================================
//=================================================================================================
AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive()
: AIS_InteractiveObject(PrsMgr_TOP_AllView)
@ -34,11 +31,10 @@ AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive()
myHasOwnPresentations = Standard_False;
}
//=======================================================================
//function : connect
//purpose :
//=======================================================================
Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
//=================================================================================================
Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect(
const Handle(AIS_InteractiveObject)& theAnotherObj,
const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
@ -47,17 +43,21 @@ Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const H
Handle(AIS_InteractiveObject) anObjectToAdd;
Handle(AIS_MultipleConnectedInteractive) aMultiConnected = Handle(AIS_MultipleConnectedInteractive)::DownCast (theAnotherObj);
Handle(AIS_MultipleConnectedInteractive) aMultiConnected =
Handle(AIS_MultipleConnectedInteractive)::DownCast(theAnotherObj);
if (!aMultiConnected.IsNull())
{
Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected = new AIS_MultipleConnectedInteractive();
Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected =
new AIS_MultipleConnectedInteractive();
aNewMultiConnected->myAssemblyOwner = myAssemblyOwner;
aNewMultiConnected->SetLocalTransformation(aMultiConnected->LocalTransformationGeom());
// Perform deep copy of instance tree
for (PrsMgr_ListOfPresentableObjectsIter anIter (aMultiConnected->Children()); anIter.More(); anIter.Next())
for (PrsMgr_ListOfPresentableObjectsIter anIter(aMultiConnected->Children()); anIter.More();
anIter.Next())
{
Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
Handle(AIS_InteractiveObject) anInteractive =
Handle(AIS_InteractiveObject)::DownCast(anIter.Value());
if (anInteractive.IsNull())
{
continue;
@ -85,29 +85,21 @@ Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const H
return anObjectToAdd;
}
//=======================================================================
//function : HasConnection
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const
{
return (Children().Size() != 0);
}
//=======================================================================
//function : Disconnect
//purpose :
//=======================================================================
//=================================================================================================
void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj)
{
RemoveChild(anotherIObj);
}
//=======================================================================
//function : DisconnectAll
//purpose :
//=======================================================================
//=================================================================================================
void AIS_MultipleConnectedInteractive::DisconnectAll()
{
@ -118,10 +110,8 @@ void AIS_MultipleConnectedInteractive::DisconnectAll()
}
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_MultipleConnectedInteractive::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)&,
const Standard_Integer)
@ -137,10 +127,8 @@ void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_Presentation
}
}
//=======================================================================
//function : AcceptShapeDecomposition
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_MultipleConnectedInteractive::AcceptShapeDecomposition() const
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(Children()); anIter.More(); anIter.Next())
@ -159,11 +147,10 @@ Standard_Boolean AIS_MultipleConnectedInteractive::AcceptShapeDecomposition() co
return Standard_False;
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
//=================================================================================================
void AIS_MultipleConnectedInteractive::ComputeSelection(
const Handle(SelectMgr_Selection)& /*theSelection*/,
const Standard_Integer theMode)
{
if (theMode == 0)
@ -189,10 +176,8 @@ void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_
}
}
//=======================================================================
//function : SetContext
//purpose :
//=======================================================================
//=================================================================================================
void AIS_MultipleConnectedInteractive::SetContext(const Handle(AIS_InteractiveContext)& theCtx)
{
AIS_InteractiveObject::SetContext(theCtx);

View File

@ -29,13 +29,13 @@ class AIS_MultipleConnectedInteractive : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive, AIS_InteractiveObject)
public:
//! Initializes the Interactive Object with multiple
//! connections to AIS_Interactive objects.
Standard_EXPORT AIS_MultipleConnectedInteractive();
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
//! Locates instance in theLocation and applies specified transformation persistence mode.
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its
//! reference. Locates instance in theLocation and applies specified transformation persistence
//! mode.
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
Handle(AIS_InteractiveObject) Connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
const Handle(TopLoc_Datum3D)& theLocation,
@ -44,7 +44,10 @@ public:
return connect(theAnotherObj, theLocation, theTrsfPers);
}
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Object; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Object;
}
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 1; }
@ -62,35 +65,48 @@ public:
Standard_EXPORT virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE;
//! Returns common entity owner if the object is an assembly
virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const Standard_OVERRIDE { return myAssemblyOwner; }
virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const Standard_OVERRIDE
{
return myAssemblyOwner;
}
//! Returns the owner of mode for selection of object as a whole
virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE { return myAssemblyOwner; }
virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE
{
return myAssemblyOwner;
}
//! Assigns interactive context.
Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& theCtx) Standard_OVERRIDE;
Standard_EXPORT virtual void SetContext(const Handle(AIS_InteractiveContext)& theCtx)
Standard_OVERRIDE;
public: // short aliases to Connect() method
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
//! Copies local transformation and transformation persistence mode from theInteractive.
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its
//! reference. Copies local transformation and transformation persistence mode from
//! theInteractive.
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
Handle(AIS_InteractiveObject) Connect(const Handle(AIS_InteractiveObject)& theAnotherObj)
{
return connect (theAnotherObj, theAnotherObj->LocalTransformationGeom(), theAnotherObj->TransformPersistence());
return connect(theAnotherObj,
theAnotherObj->LocalTransformationGeom(),
theAnotherObj->TransformPersistence());
}
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
//! Locates instance in theLocation and copies transformation persistence mode from theInteractive.
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its
//! reference. Locates instance in theLocation and copies transformation persistence mode from
//! theInteractive.
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
Handle(AIS_InteractiveObject) Connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
const gp_Trsf& theLocation)
{
return connect (theAnotherObj, new TopLoc_Datum3D (theLocation), theAnotherObj->TransformPersistence());
return connect(theAnotherObj,
new TopLoc_Datum3D(theLocation),
theAnotherObj->TransformPersistence());
}
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
//! Locates instance in theLocation and applies specified transformation persistence mode.
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its
//! reference. Locates instance in theLocation and applies specified transformation persistence
//! mode.
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
Handle(AIS_InteractiveObject) Connect(const Handle(AIS_InteractiveObject)& theAnotherObj,
const gp_Trsf& theLocation,
@ -100,7 +116,6 @@ public: // short aliases to Connect() method
}
protected:
//! this method is redefined virtual;
//! when the instance is connected to another
//! InteractiveObject,this method doesn't
@ -111,22 +126,22 @@ protected:
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its reference.
//! Locates instance in theLocation and applies specified transformation persistence mode.
//! Establishes the connection between the Connected Interactive Object, theInteractive, and its
//! reference. Locates instance in theLocation and applies specified transformation persistence
//! mode.
//! @return created instance object (AIS_ConnectedInteractive or AIS_MultipleConnectedInteractive)
Standard_EXPORT virtual Handle(AIS_InteractiveObject) connect (const Handle(AIS_InteractiveObject)& theInteractive,
Standard_EXPORT virtual Handle(AIS_InteractiveObject) connect(
const Handle(AIS_InteractiveObject)& theInteractive,
const Handle(TopLoc_Datum3D)& theLocation,
const Handle(Graphic3d_TransformPers)& theTrsfPers);
private:
//! Computes the selection for whole subtree in scene hierarchy.
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode) Standard_OVERRIDE;
protected:
Handle(SelectMgr_EntityOwner) myAssemblyOwner;
};
DEFINE_STANDARD_HANDLE(AIS_MultipleConnectedInteractive, AIS_InteractiveObject)

View File

@ -48,13 +48,10 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Plane, AIS_InteractiveObject)
//=======================================================================
//function : AIS_Plane
//purpose :
//=======================================================================
AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent,
const Standard_Boolean aCurrentMode):
myComponent(aComponent),
//=================================================================================================
AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent, const Standard_Boolean aCurrentMode)
: myComponent(aComponent),
myCenter(gp_Pnt(0., 0., 0.)),
myCurrentMode(aCurrentMode),
myAutomaticPosition(Standard_True),
@ -71,8 +68,8 @@ myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
//=======================================================================
AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent,
const gp_Pnt& aCenter,
const Standard_Boolean aCurrentMode):
myComponent(aComponent),
const Standard_Boolean aCurrentMode)
: myComponent(aComponent),
myCenter(aCenter),
myCurrentMode(aCurrentMode),
myAutomaticPosition(Standard_True),
@ -83,16 +80,14 @@ myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
InitDrawerAttributes();
}
//=======================================================================
//function : AIS_Plane
//purpose :
//=======================================================================
//=================================================================================================
AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent,
const gp_Pnt& aCenter,
const gp_Pnt& aPmin,
const gp_Pnt& aPmax,
const Standard_Boolean aCurrentMode):
myComponent(aComponent),
const Standard_Boolean aCurrentMode)
: myComponent(aComponent),
myCenter(aCenter),
myPmin(aPmin),
myPmax(aPmax),
@ -111,8 +106,8 @@ myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
//=======================================================================
AIS_Plane::AIS_Plane(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfPlane aPlaneType,
const Standard_Boolean aCurrentMode):
myAx2(aComponent),
const Standard_Boolean aCurrentMode)
: myAx2(aComponent),
myCurrentMode(aCurrentMode),
myAutomaticPosition(Standard_True),
myTypeOfPlane(aPlaneType),
@ -123,11 +118,7 @@ myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
ComputeFields();
}
//=======================================================================
//function : SetComponent
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::SetComponent(const Handle(Geom_Plane)& aComponent)
{
@ -138,20 +129,15 @@ void AIS_Plane::SetComponent(const Handle(Geom_Plane)& aComponent)
myAutomaticPosition = Standard_True;
}
//=======================================================================
//function : Axis2Placement
//purpose :
//=======================================================================
//=================================================================================================
Handle(Geom_Axis2Placement) AIS_Plane::Axis2Placement()
{
Handle(Geom_Axis2Placement) Bid;
return IsXYZPlane() ? myAx2 : Bid;
}
//=======================================================================
//function : SetAxis2Placement
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfPlane aPlaneType)
@ -163,17 +149,16 @@ Handle(Geom_Axis2Placement) AIS_Plane::Axis2Placement()
ComputeFields();
}
//=======================================================================
//function : PlaneAttributes
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_Plane::PlaneAttributes(Handle(Geom_Plane)& aComponent,
gp_Pnt& aCenter,
gp_Pnt& aPmin,
gp_Pnt& aPmax)
{
Standard_Boolean aStatus(Standard_False);
if (!myAutomaticPosition){
if (!myAutomaticPosition)
{
aComponent = myComponent;
aCenter = myCenter;
aPmin = myPmin;
@ -183,10 +168,8 @@ Standard_Boolean AIS_Plane::PlaneAttributes(Handle(Geom_Plane)& aComponent,
return aStatus;
}
//=======================================================================
//function : SetPlaneAttributes
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::SetPlaneAttributes(const Handle(Geom_Plane)& aComponent,
const gp_Pnt& aCenter,
const gp_Pnt& aPmin,
@ -201,10 +184,8 @@ void AIS_Plane::SetPlaneAttributes(const Handle(Geom_Plane)& aComponent,
myIsXYZPlane = Standard_False;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
@ -215,13 +196,13 @@ void AIS_Plane::Compute (const Handle(PrsMgr_PresentationManager)& ,
switch (theMode)
{
case 0:
{
case 0: {
if (!myIsXYZPlane)
{
ComputeFrame();
const Handle(Geom_Plane)& pl = myComponent;
Handle(Geom_Plane) thegoodpl (Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter)));
Handle(Geom_Plane) thegoodpl(
Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(), myCenter)));
GeomAdaptor_Surface surf(thegoodpl);
StdPrs_Plane::Add(thePrs, surf, myDrawer);
}
@ -231,8 +212,7 @@ void AIS_Plane::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
break;
}
case 1:
{
case 1: {
if (!myIsXYZPlane)
{
ComputeFrame();
@ -265,11 +245,10 @@ void AIS_Plane::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_Plane::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer /*theMode*/)
//=================================================================================================
void AIS_Plane::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer /*theMode*/)
{
theSelection->Clear();
Handle(SelectMgr_EntityOwner) aSensitiveOwner = new SelectMgr_EntityOwner(this, 10);
@ -320,17 +299,14 @@ void AIS_Plane::ComputeSelection (const Handle(SelectMgr_Selection)& theSelectio
theSelection->Add(aSensitive);
}
//=======================================================================
//function : SetSize
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::SetSize(const Standard_Real aLength)
{
SetSize(aLength, aLength);
}
void AIS_Plane::SetSize(const Standard_Real aXLength,
const Standard_Real aYLength)
void AIS_Plane::SetSize(const Standard_Real aXLength, const Standard_Real aYLength)
{
// if the plane already has a proper color or size,
// there is already a specific PlaneAspect and DatumAspect
@ -342,10 +318,13 @@ void AIS_Plane::SetSize(const Standard_Real aXLength,
DA = myDrawer->DatumAspect();
Standard_Boolean yenavaitPA(Standard_True), yenavaitDA(Standard_True);
if(myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA){
if (myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA)
{
yenavaitPA = Standard_False;
PA = new Prs3d_PlaneAspect();}
if(myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA){
PA = new Prs3d_PlaneAspect();
}
if (myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA)
{
yenavaitDA = Standard_False;
DA = new Prs3d_DatumAspect();
}
@ -358,14 +337,12 @@ void AIS_Plane::SetSize(const Standard_Real aXLength,
if (!yenavaitDA)
myDrawer->SetDatumAspect(DA);
myHasOwnSize = Standard_True;
SetToUpdate();
UpdatePresentations();
UpdateSelection();
}
//=======================================================================
// function : UnsetSize
// purpose : If there is a color, the size is restaured from the drawer of the context...
@ -373,17 +350,19 @@ void AIS_Plane::SetSize(const Standard_Real aXLength,
void AIS_Plane::UnsetSize()
{
if(!myHasOwnSize) return;
if (!myHasOwnSize)
return;
if (!hasOwnColor)
{
myDrawer->SetPlaneAspect(Handle(Prs3d_PlaneAspect)());
myDrawer->SetDatumAspect(Handle(Prs3d_DatumAspect)());
}
else{
const Handle(Prs3d_PlaneAspect) PA = myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() :
new Prs3d_PlaneAspect();
const Handle(Prs3d_DatumAspect) DA = myDrawer->HasLink() ? myDrawer->Link()->DatumAspect() :
new Prs3d_DatumAspect();
else
{
const Handle(Prs3d_PlaneAspect) PA =
myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() : new Prs3d_PlaneAspect();
const Handle(Prs3d_DatumAspect) DA =
myDrawer->HasLink() ? myDrawer->Link()->DatumAspect() : new Prs3d_DatumAspect();
myDrawer->PlaneAspect()->SetPlaneLength(PA->PlaneXLength(), PA->PlaneYLength());
myDrawer->DatumAspect()->SetAxisLength(DA->AxisLength(Prs3d_DatumParts_XAxis),
@ -395,13 +374,9 @@ void AIS_Plane::UnsetSize()
SetToUpdate();
UpdatePresentations();
UpdateSelection();
}
//=======================================================================
//function : Size
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_Plane::Size(Standard_Real& X, Standard_Real& Y) const
{
@ -410,10 +385,8 @@ Standard_Boolean AIS_Plane::Size(Standard_Real& X,Standard_Real& Y) const
return Abs(X - Y) <= Precision::Confusion();
}
//=======================================================================
//function : SetMinimumSize
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::SetMinimumSize(const Standard_Real theValue)
{
if (theValue <= 0)
@ -423,31 +396,26 @@ void AIS_Plane::SetMinimumSize (const Standard_Real theValue)
}
Standard_Real aX, anY;
Size(aX, anY);
SetTransformPersistence (new Graphic3d_TransformPersScaledAbove (Min (aX, anY) / theValue, myCenter));
SetTransformPersistence(
new Graphic3d_TransformPersScaledAbove(Min(aX, anY) / theValue, myCenter));
}
//=======================================================================
//function : UnsetMinimumSize
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::UnsetMinimumSize()
{
SetTransformPersistence(NULL);
}
//=======================================================================
//function : HasMinimumSize
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_Plane::HasMinimumSize() const
{
return !Handle(Graphic3d_TransformPersScaledAbove)::DownCast(TransformPersistence()).IsNull();
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::SetColor(const Quantity_Color& aCol)
{
// if the plane already has its proper size, there is an already created planeaspect
@ -459,10 +427,13 @@ void AIS_Plane::SetColor(const Quantity_Color &aCol)
DA = myDrawer->DatumAspect();
Standard_Boolean yenavaitPA(Standard_True), yenavaitDA(Standard_True);
if(myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA){
if (myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA)
{
yenavaitPA = Standard_False;
PA = new Prs3d_PlaneAspect();}
if(myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA){
PA = new Prs3d_PlaneAspect();
}
if (myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA)
{
yenavaitDA = Standard_False;
DA = new Prs3d_DatumAspect();
}
@ -482,21 +453,22 @@ void AIS_Plane::SetColor(const Quantity_Color &aCol)
hasOwnColor = Standard_True;
myDrawer->SetColor(aCol);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::UnsetColor()
{
if(!hasOwnColor) return;
if (!hasOwnColor)
return;
if (!myHasOwnSize)
{
myDrawer->SetPlaneAspect(Handle(Prs3d_PlaneAspect)());
myDrawer->SetDatumAspect(Handle(Prs3d_DatumAspect)());
}
else{
const Handle(Prs3d_PlaneAspect) PA = myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() :
new Prs3d_PlaneAspect();
else
{
const Handle(Prs3d_PlaneAspect) PA =
myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() : new Prs3d_PlaneAspect();
Quantity_Color Col = PA->EdgesAspect()->Aspect()->Color();
myDrawer->PlaneAspect()->EdgesAspect()->SetColor(Col);
@ -505,45 +477,45 @@ void AIS_Plane::UnsetColor()
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(Col);
}
hasOwnColor = Standard_False;
}
//=======================================================================
//function : ComputeFrame
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::ComputeFrame()
{
const Handle(Geom_Plane)& pl = myComponent;
Standard_Real U, V;
if (myAutomaticPosition) {
if (myAutomaticPosition)
{
ElSLib::Parameters(pl->Pln(), myCenter, U, V);
pl->D0(U, V, myCenter);
}
else {
Handle(Geom_Plane) thegoodpl (Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter)));
else
{
Handle(Geom_Plane) thegoodpl(
Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(), myCenter)));
ElSLib::Parameters(thegoodpl->Pln(), myPmin, U, V);
U = 2.4 * Abs(U);
V = 2.4 * Abs(V);
if (U < 10*Precision::Confusion()) U=0.1;
if (V < 10*Precision::Confusion()) V=0.1;
if (U < 10 * Precision::Confusion())
U = 0.1;
if (V < 10 * Precision::Confusion())
V = 0.1;
SetSize(U, V);
myDrawer->PlaneAspect()->SetPlaneLength(U, V);
}
}
//=======================================================================
//function : ComputeFields
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::ComputeFields()
{
if (myIsXYZPlane){
if (myIsXYZPlane)
{
Handle(Prs3d_DatumAspect) DA = myDrawer->DatumAspect();
gp_Pnt Orig = myAx2->Ax2().Location();
@ -562,29 +534,39 @@ void AIS_Plane::ComputeFields()
Standard_Real DS3 = DA->AxisLength(Prs3d_DatumParts_ZAxis);
// gp_Pnt aPt2,aPt3;
switch (myTypeOfPlane) {
case AIS_TOPL_XYPlane:
switch (myTypeOfPlane)
{
case AIS_TOPL_XYPlane: {
gp_Pln XYP(0, 0, 1, 0);
myComponent = new Geom_Plane(XYP);
x4=xo+x1*DS1; y4=yo+y1*DS1; z4=zo+z1*DS1;
x5=xo+x2*DS2; y5=yo+y2*DS2; z5=zo+z2*DS2;
x4 = xo + x1 * DS1;
y4 = yo + y1 * DS1;
z4 = zo + z1 * DS1;
x5 = xo + x2 * DS2;
y5 = yo + y2 * DS2;
z5 = zo + z2 * DS2;
break;
}
case AIS_TOPL_XZPlane:
{
case AIS_TOPL_XZPlane: {
gp_Pln XZP(0, 1, 0, 0);
myComponent = new Geom_Plane(XZP);
x4=xo+x1*DS1; y4=yo+y1*DS1; z4=zo+z1*DS1;
x5=xo+x3*DS3; y5=yo+y3*DS3; z5=zo+z3*DS3;
x4 = xo + x1 * DS1;
y4 = yo + y1 * DS1;
z4 = zo + z1 * DS1;
x5 = xo + x3 * DS3;
y5 = yo + y3 * DS3;
z5 = zo + z3 * DS3;
break;
}
case AIS_TOPL_YZPlane:
{
case AIS_TOPL_YZPlane: {
gp_Pln XZP(1, 0, 0, 0);
myComponent = new Geom_Plane(XZP);
x4=xo+x2*DS2; y4=yo+y2*DS2; z4=zo+z2*DS2;
x5=xo+x3*DS3; y5=yo+y3*DS3; z5=zo+z3*DS3;
x4 = xo + x2 * DS2;
y4 = yo + y2 * DS2;
z4 = zo + z2 * DS2;
x5 = xo + x3 * DS3;
y5 = yo + y3 * DS3;
z5 = zo + z3 * DS3;
break;
}
default:
@ -593,12 +575,9 @@ void AIS_Plane::ComputeFields()
myPmin.SetCoord(x4, y4, z4);
myPmax.SetCoord(x5, y5, z5);
}
}
//=======================================================================
//function : InitDrawerAttributes
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::InitDrawerAttributes()
{
@ -613,24 +592,17 @@ void AIS_Plane::InitDrawerAttributes()
asf->SetBackMaterial(asp);
}
//=======================================================================
//function : AcceptDisplayMode
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_Plane::
AcceptDisplayMode(const Standard_Integer aMode) const
{return aMode == 0;}
Standard_Boolean AIS_Plane::AcceptDisplayMode(const Standard_Integer aMode) const
{
return aMode == 0;
}
//=======================================================================
//function : SetContext
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Plane::SetContext(const Handle(AIS_InteractiveContext)& Ctx)
{
AIS_InteractiveObject::SetContext(Ctx);
ComputeFields();
}

View File

@ -31,26 +31,34 @@ class AIS_Plane : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_Plane, AIS_InteractiveObject)
public:
//! initializes the plane aComponent. If
//! the mode aCurrentMode equals true, the drawing
//! tool, "Drawer" is not initialized.
Standard_EXPORT AIS_Plane(const Handle(Geom_Plane)& aComponent, const Standard_Boolean aCurrentMode = Standard_False);
Standard_EXPORT AIS_Plane(const Handle(Geom_Plane)& aComponent,
const Standard_Boolean aCurrentMode = Standard_False);
//! initializes the plane aComponent and
//! the point aCenter. If the mode aCurrentMode
//! equals true, the drawing tool, "Drawer" is not
//! initialized. aCurrentMode equals true, the drawing
//! tool, "Drawer" is not initialized.
Standard_EXPORT AIS_Plane(const Handle(Geom_Plane)& aComponent, const gp_Pnt& aCenter, const Standard_Boolean aCurrentMode = Standard_False);
Standard_EXPORT AIS_Plane(const Handle(Geom_Plane)& aComponent,
const gp_Pnt& aCenter,
const Standard_Boolean aCurrentMode = Standard_False);
//! initializes the plane aComponent, the
//! point aCenter, and the minimum and maximum
//! points, aPmin and aPmax. If the mode
//! aCurrentMode equals true, the drawing tool, "Drawer" is not initialized.
Standard_EXPORT AIS_Plane(const Handle(Geom_Plane)& aComponent, const gp_Pnt& aCenter, const gp_Pnt& aPmin, const gp_Pnt& aPmax, const Standard_Boolean aCurrentMode = Standard_False);
Standard_EXPORT AIS_Plane(const Handle(Geom_Plane)& aComponent,
const gp_Pnt& aCenter,
const gp_Pnt& aPmin,
const gp_Pnt& aPmax,
const Standard_Boolean aCurrentMode = Standard_False);
Standard_EXPORT AIS_Plane(const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfPlane aPlaneType, const Standard_Boolean aCurrentMode = Standard_False);
Standard_EXPORT AIS_Plane(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfPlane aPlaneType,
const Standard_Boolean aCurrentMode = Standard_False);
//! Same value for x and y directions
Standard_EXPORT void SetSize(const Standard_Real aValue);
@ -76,7 +84,10 @@ public:
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 7; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
//! Returns the component specified in SetComponent.
const Handle(Geom_Plane)& Component() { return myComponent; }
@ -87,12 +98,18 @@ public:
//! Returns the settings for the selected plane
//! aComponent, provided in SetPlaneAttributes.
//! These include the points aCenter, aPmin, and aPmax
Standard_EXPORT Standard_Boolean PlaneAttributes (Handle(Geom_Plane)& aComponent, gp_Pnt& aCenter, gp_Pnt& aPmin, gp_Pnt& aPmax);
Standard_EXPORT Standard_Boolean PlaneAttributes(Handle(Geom_Plane)& aComponent,
gp_Pnt& aCenter,
gp_Pnt& aPmin,
gp_Pnt& aPmax);
//! Allows you to provide settings other than default ones
//! for the selected plane. These include: center point
//! aCenter, maximum aPmax and minimum aPmin.
Standard_EXPORT void SetPlaneAttributes (const Handle(Geom_Plane)& aComponent, const gp_Pnt& aCenter, const gp_Pnt& aPmin, const gp_Pnt& aPmax);
Standard_EXPORT void SetPlaneAttributes(const Handle(Geom_Plane)& aComponent,
const gp_Pnt& aCenter,
const gp_Pnt& aPmin,
const gp_Pnt& aPmax);
//! Returns the coordinates of the center point.
const gp_Pnt& Center() const { return myCenter; }
@ -108,7 +125,8 @@ public:
//! - AIS_ TOPL_XYPlane
//! - AIS_ TOPL_XZPlane
//! - AIS_ TOPL_YZPlane}.
Standard_EXPORT void SetAxis2Placement (const Handle(Geom_Axis2Placement)& aComponent, const AIS_TypeOfPlane aPlaneType);
Standard_EXPORT void SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
const AIS_TypeOfPlane aPlaneType);
//! Returns the position of the plane's axis2 system
//! identifying the x, y, or z axis and giving the plane a
@ -129,25 +147,30 @@ public:
void SetCurrentMode(const Standard_Boolean theCurrentMode) { myCurrentMode = theCurrentMode; }
//! Returns true if the display mode selected, aMode, is valid for planes.
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer aMode) const
Standard_OVERRIDE;
//! connection to <aCtx> default drawer implies a recomputation of Frame values.
Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& aCtx) Standard_OVERRIDE;
Standard_EXPORT virtual void SetContext(const Handle(AIS_InteractiveContext)& aCtx)
Standard_OVERRIDE;
//! Returns the type of sensitivity for the plane;
Select3D_TypeOfSensitivity TypeOfSensitivity() const { return myTypeOfSensitivity; }
//! Sets the type of sensitivity for the plane.
void SetTypeOfSensitivity (Select3D_TypeOfSensitivity theTypeOfSensitivity) { myTypeOfSensitivity = theTypeOfSensitivity; }
void SetTypeOfSensitivity(Select3D_TypeOfSensitivity theTypeOfSensitivity)
{
myTypeOfSensitivity = theTypeOfSensitivity;
}
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT void SetColor(const Quantity_Color& aColor) Standard_OVERRIDE;
Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
@ -159,7 +182,6 @@ private:
Standard_EXPORT void InitDrawerAttributes();
private:
Handle(Geom_Plane) myComponent;
Handle(Geom_Axis2Placement) myAx2;
gp_Pnt myCenter;
@ -171,7 +193,6 @@ private:
Standard_Boolean myIsXYZPlane;
Standard_Boolean myHasOwnSize;
Select3D_TypeOfSensitivity myTypeOfSensitivity;
};
DEFINE_STANDARD_HANDLE(AIS_Plane, AIS_InteractiveObject)

View File

@ -47,12 +47,12 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_PlaneTrihedron, AIS_InteractiveObject)
void ExtremityPoints(TColgp_Array1OfPnt& PP,const Handle(Geom_Plane)& myPlane,const Handle(Prs3d_Drawer)& myDrawer);
void ExtremityPoints(TColgp_Array1OfPnt& PP,
const Handle(Geom_Plane)& myPlane,
const Handle(Prs3d_Drawer)& myDrawer);
//=================================================================================================
//=======================================================================
//function : AIS_PlaneTrihedron
//purpose :
//=======================================================================
AIS_PlaneTrihedron::AIS_PlaneTrihedron(const Handle(Geom_Plane)& aPlane)
: myPlane(aPlane)
{
@ -73,31 +73,22 @@ AIS_PlaneTrihedron::AIS_PlaneTrihedron(const Handle(Geom_Plane)& aPlane)
myYLabel = TCollection_AsciiString("Y");
}
//=======================================================================
//function : Component
//purpose :
//=======================================================================
//=================================================================================================
Handle(Geom_Plane) AIS_PlaneTrihedron::Component()
{
return myPlane;
}
//=======================================================================
//function : SetComponent
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PlaneTrihedron::SetComponent(const Handle(Geom_Plane)& aPlane)
{
myPlane = aPlane;
}
//=======================================================================
//function : XAxis
//purpose :
//=======================================================================
//=================================================================================================
Handle(AIS_Line) AIS_PlaneTrihedron::XAxis() const
{
Handle(Geom_Line) aGLine = new Geom_Line(myPlane->Pln().XAxis());
@ -106,10 +97,8 @@ Handle(AIS_Line) AIS_PlaneTrihedron::XAxis() const
return aLine;
}
//=======================================================================
//function : YAxis
//purpose :
//=======================================================================
//=================================================================================================
Handle(AIS_Line) AIS_PlaneTrihedron::YAxis() const
{
Handle(Geom_Line) aGLine = new Geom_Line(myPlane->Pln().YAxis());
@ -118,10 +107,8 @@ Handle(AIS_Line) AIS_PlaneTrihedron::YAxis() const
return aLine;
}
//=======================================================================
//function : Position
//purpose :
//=======================================================================
//=================================================================================================
Handle(AIS_Point) AIS_PlaneTrihedron::Position() const
{
gp_Pnt aPnt = myPlane->Pln().Location();
@ -130,19 +117,19 @@ Handle(AIS_Point) AIS_PlaneTrihedron::Position() const
return aPt;
}
void AIS_PlaneTrihedron::SetLength(const Standard_Real theLength) {
void AIS_PlaneTrihedron::SetLength(const Standard_Real theLength)
{
myDrawer->DatumAspect()->SetAxisLength(theLength, theLength, theLength);
SetToUpdate();
}
Standard_Real AIS_PlaneTrihedron::GetLength() const {
Standard_Real AIS_PlaneTrihedron::GetLength() const
{
return myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PlaneTrihedron::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer)
@ -163,7 +150,11 @@ void AIS_PlaneTrihedron::Compute (const Handle(PrsMgr_PresentationManager)& ,
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis),
myDrawer->ArrowAspect(),
myDrawer->TextAspect(),
xDir, value, myXLabel.ToCString(), first, last);
xDir,
value,
myXLabel.ToCString(),
first,
last);
// drawing axis in Y direction
value = myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_YAxis);
@ -175,15 +166,16 @@ void AIS_PlaneTrihedron::Compute (const Handle(PrsMgr_PresentationManager)& ,
myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis),
myDrawer->ArrowAspect(),
myDrawer->TextAspect(),
yDir, value, myYLabel.ToCString(), first, last);
yDir,
value,
myYLabel.ToCString(),
first,
last);
thePrs->SetInfiniteState(Standard_True);
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
@ -193,9 +185,9 @@ void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSe
TColgp_Array1OfPnt PP(1, 4), PO(1, 4);
// ExtremityPoints(PP);
ExtremityPoints(PP, myPlane, myDrawer);
switch (aMode) {
case 0:
{ // triedre complet
switch (aMode)
{
case 0: { // triedre complet
Prior = 5;
// gp_Ax2 theax = gp_Ax2(myPlane->Position().Ax2());
// gp_Pnt p1 = theax.Location();
@ -206,8 +198,7 @@ void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSe
break;
}
case 1:
{ //origine
case 1: { // origine
Prior = 8;
const Handle(SelectMgr_SelectableObject)& anObj = myShapes[0]; // to avoid ambiguity
eown = new SelectMgr_EntityOwner(anObj, Prior);
@ -215,19 +206,17 @@ void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSe
break;
}
case 2:
{ //axes ... priorite 7
case 2: { // axes ... priorite 7
Prior = 7;
for (Standard_Integer i=1; i<=2;i++){
for (Standard_Integer i = 1; i <= 2; i++)
{
const Handle(SelectMgr_SelectableObject)& anObj = myShapes[i]; // to avoid ambiguity
eown = new SelectMgr_EntityOwner(anObj, Prior);
aSelection->Add(new Select3D_SensitiveSegment(eown, PP(1), PP(i + 1)));
}
break;
}
case -1:
{
case -1: {
Prior = 5;
aSelection->Clear();
break;
@ -249,7 +238,9 @@ void AIS_PlaneTrihedron::SetColor(const Quantity_Color &aCol)
// purpose : to avoid warning
//=======================================================================
// void AIS_Trihedron::ExtremityPoints(TColgp_Array1OfPnt& PP) const
void ExtremityPoints(TColgp_Array1OfPnt& PP,const Handle(Geom_Plane)& myPlane,const Handle(Prs3d_Drawer)& myDrawer )
void ExtremityPoints(TColgp_Array1OfPnt& PP,
const Handle(Geom_Plane)& myPlane,
const Handle(Prs3d_Drawer)& myDrawer)
{
// gp_Ax2 theax(myPlane->Ax2());
gp_Ax2 theax(myPlane->Position().Ax2());
@ -264,13 +255,11 @@ void ExtremityPoints(TColgp_Array1OfPnt& PP,const Handle(Geom_Plane)& myPlane,c
vec = theax.YDirection();
vec *= len;
PP(3) = PP(1).Translated(vec);
}
//=======================================================================
//function : AcceptDisplayMode
//purpose :
//=======================================================================
Standard_Boolean AIS_PlaneTrihedron::AcceptDisplayMode(const Standard_Integer aMode) const
{return aMode == 0;}
//=================================================================================================
Standard_Boolean AIS_PlaneTrihedron::AcceptDisplayMode(const Standard_Integer aMode) const
{
return aMode == 0;
}

View File

@ -45,7 +45,6 @@ class AIS_PlaneTrihedron : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_PlaneTrihedron, AIS_InteractiveObject)
public:
//! Initializes the plane aPlane. The plane trihedron is
//! constructed from this and an axis.
Standard_EXPORT AIS_PlaneTrihedron(const Handle(Geom_Plane)& aPlane);
@ -72,12 +71,16 @@ public:
Standard_EXPORT Standard_Real GetLength() const;
//! Returns true if the display mode selected, aMode, is valid.
Standard_EXPORT Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean
AcceptDisplayMode(const Standard_Integer aMode) const Standard_OVERRIDE;
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 4; }
//! Returns datum as the type of Interactive Object.
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
//! Allows you to provide settings for the color aColor.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
@ -87,23 +90,19 @@ public:
void SetYLabel(const TCollection_AsciiString& theLabel) { myYLabel = theLabel; }
protected:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& theprsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
private:
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSel,
const Standard_Integer theMode) Standard_OVERRIDE;
private:
Handle(Geom_Plane) myPlane;
Handle(AIS_InteractiveObject) myShapes[3];
TCollection_AsciiString myXLabel;
TCollection_AsciiString myYLabel;
};
DEFINE_STANDARD_HANDLE(AIS_PlaneTrihedron, AIS_InteractiveObject)

View File

@ -32,12 +32,10 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Point, AIS_InteractiveObject)
//=======================================================================
//function : AIS_Point
//purpose :
//=======================================================================
AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent):
myComponent(aComponent),
//=================================================================================================
AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent)
: myComponent(aComponent),
myHasTOM(Standard_False),
myTOM(Aspect_TOM_PLUS)
{
@ -48,35 +46,28 @@ myTOM(Aspect_TOM_PLUS)
myHilightDrawer->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
myDynHilightDrawer = new Prs3d_Drawer();
myDynHilightDrawer->SetDisplayMode(-99);
myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 3.0));
myDynHilightDrawer->SetPointAspect(
new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 3.0));
myDynHilightDrawer->SetColor(Quantity_NOC_CYAN1);
myDynHilightDrawer->SetZLayer(Graphic3d_ZLayerId_Top);
}
//=======================================================================
//function : Component
//purpose :
//=======================================================================
//=================================================================================================
Handle(Geom_Point) AIS_Point::Component()
{
return myComponent;
}
//=======================================================================
//function : SetComponent
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
{
myComponent = aComponent;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
@ -96,23 +87,18 @@ void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager)& ,
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer /*aMode*/)
{
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this, 10);
Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
myComponent->Pnt());
Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown, myComponent->Pnt());
aSelection->Add(sp);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Point::SetColor(const Quantity_Color& theCol)
{
hasOwnColor = Standard_True;
@ -120,31 +106,23 @@ void AIS_Point::SetColor (const Quantity_Color& theCol)
UpdatePointValues();
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Point::UnsetColor()
{
hasOwnColor = Standard_False;
UpdatePointValues();
}
//=================================================================================================
//=======================================================================
//function : Vertex
//purpose :
//=======================================================================
TopoDS_Vertex AIS_Point::Vertex() const
{
gp_Pnt P = myComponent->Pnt();
return BRepBuilderAPI_MakeVertex(P);
}
//=======================================================================
//function : SetMarker
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
{
@ -153,31 +131,23 @@ void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
UpdatePointValues();
}
//=======================================================================
//function : UnsetMarker
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Point::UnsetMarker()
{
myHasTOM = Standard_False;
UpdatePointValues();
}
//=======================================================================
//function : AcceptDisplayMode
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_Point::AcceptDisplayMode(const Standard_Integer theMode) const
{
return theMode == 0
|| theMode == -99;
return theMode == 0 || theMode == -99;
}
//=======================================================================
//function : replaceWithNewPointAspect
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Point::replaceWithNewPointAspect(const Handle(Prs3d_PointAspect)& theAspect)
{
if (!myDrawer->HasLink())
@ -187,7 +157,8 @@ void AIS_Point::replaceWithNewPointAspect (const Handle(Prs3d_PointAspect)& theA
}
const Handle(Graphic3d_AspectMarker3d) anAspectOld = myDrawer->PointAspect()->Aspect();
const Handle(Graphic3d_AspectMarker3d) anAspectNew = !theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->PointAspect()->Aspect();
const Handle(Graphic3d_AspectMarker3d) anAspectNew =
!theAspect.IsNull() ? theAspect->Aspect() : myDrawer->Link()->PointAspect()->Aspect();
if (anAspectNew != anAspectOld)
{
myDrawer->SetPointAspect(theAspect);
@ -197,16 +168,11 @@ void AIS_Point::replaceWithNewPointAspect (const Handle(Prs3d_PointAspect)& theA
}
}
//=======================================================================
//function : UpdatePointValues
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Point::UpdatePointValues()
{
if (!hasOwnColor
&& myOwnWidth == 0.0f
&& !myHasTOM)
if (!hasOwnColor && myOwnWidth == 0.0f && !myHasTOM)
{
replaceWithNewPointAspect(Handle(Prs3d_PointAspect)());
return;
@ -222,9 +188,12 @@ void AIS_Point::UpdatePointValues()
aScale = myDrawer->Link()->PointAspect()->Aspect()->Scale();
}
if(hasOwnColor) aCol = myDrawer->Color();
if(myOwnWidth != 0.0f) aScale = myOwnWidth;
if(myHasTOM) aTOM = myTOM;
if (hasOwnColor)
aCol = myDrawer->Color();
if (myOwnWidth != 0.0f)
aScale = myOwnWidth;
if (myHasTOM)
aTOM = myTOM;
if (myDrawer->HasOwnPointAspect())
{
@ -239,4 +208,3 @@ void AIS_Point::UpdatePointValues()
replaceWithNewPointAspect(new Prs3d_PointAspect(aTOM, aCol, aScale));
}
}

View File

@ -28,7 +28,6 @@ class AIS_Point : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_Point, AIS_InteractiveObject)
public:
//! Initializes the point aComponent from which the point
//! datum will be built.
Standard_EXPORT AIS_Point(const Handle(Geom_Point)& aComponent);
@ -37,7 +36,10 @@ public:
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 1; }
//! Indicates that a point is a datum.
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
//! Returns the component specified in SetComponent.
Standard_EXPORT Handle(Geom_Point) Component();
@ -46,7 +48,8 @@ public:
Standard_EXPORT void SetComponent(const Handle(Geom_Point)& aComponent);
//! Returns true if the display mode selected is valid for point datums.
Standard_EXPORT Standard_Boolean AcceptDisplayMode (const Standard_Integer aMode) const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean
AcceptDisplayMode(const Standard_Integer aMode) const Standard_OVERRIDE;
//! Allows you to provide settings for the Color.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
@ -70,14 +73,13 @@ public:
Standard_EXPORT TopoDS_Vertex Vertex() const;
protected:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
private:
Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
Standard_EXPORT void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode) Standard_OVERRIDE;
Standard_EXPORT void UpdatePointValues();
@ -85,11 +87,9 @@ private:
void replaceWithNewPointAspect(const Handle(Prs3d_PointAspect)& theAspect);
private:
Handle(Geom_Point) myComponent;
Standard_Boolean myHasTOM;
Aspect_TypeOfMarker myTOM;
};
DEFINE_STANDARD_HANDLE(AIS_Point, AIS_InteractiveObject)

View File

@ -31,10 +31,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner)
IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject)
//=======================================================================
//function : AIS_PointCloudOwner
//purpose :
//=======================================================================
//=================================================================================================
AIS_PointCloudOwner::AIS_PointCloudOwner(const Handle(AIS_PointCloud)& theOrigin)
: SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)theOrigin, 5),
myDetPoints(new TColStd_HPackedMapOfInteger()),
@ -43,28 +41,22 @@ AIS_PointCloudOwner::AIS_PointCloudOwner (const Handle(AIS_PointCloud)& theOrigi
//
}
//=======================================================================
//function : ~AIS_PointCloudOwner
//purpose :
//=======================================================================
//=================================================================================================
AIS_PointCloudOwner::~AIS_PointCloudOwner()
{
//
}
//=======================================================================
//function : HilightWithColor
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_PointCloudOwner::IsForcedHilight() const
{
return true;
}
//=======================================================================
//function : HilightWithColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PointCloudOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Drawer)& theStyle,
const Standard_Integer)
@ -75,25 +67,30 @@ void AIS_PointCloudOwner::HilightWithColor (const Handle(PrsMgr_PresentationMana
throw Standard_ProgramError("Internal Error within AIS_PointCloud::PointsOwner!");
}
const Handle(TColStd_HPackedMapOfInteger)& aMap = thePrsMgr->IsImmediateModeOn()
? myDetPoints
: mySelPoints;
const Handle(TColStd_HPackedMapOfInteger)& aMap =
thePrsMgr->IsImmediateModeOn() ? myDetPoints : mySelPoints;
Handle(Prs3d_Presentation) aPrs = thePrsMgr->IsImmediateModeOn()
? anObj->GetHilightPresentation(thePrsMgr)
: anObj->GetSelectPresentation(thePrsMgr);
const Graphic3d_ZLayerId aZLayer = theStyle->ZLayer() != -1
const Graphic3d_ZLayerId aZLayer =
theStyle->ZLayer() != -1
? theStyle->ZLayer()
: (thePrsMgr->IsImmediateModeOn() ? Graphic3d_ZLayerId_Top : anObj->ZLayer());
aMap->ChangeMap().Clear();
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
for (SelectMgr_SequenceOfSelection::Iterator aSelIter(anObj->Selections()); aSelIter.More();
aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter(
aSel->Entities());
aSelEntIter.More();
aSelEntIter.Next())
{
const Handle(SelectMgr_SensitiveEntity)& aSelEnt = aSelEntIter.Value();
if (aSelEnt->BaseSensitive()->OwnerId() == this)
{
if (Handle(Select3D_SensitivePrimitiveArray) aSensitive = Handle(Select3D_SensitivePrimitiveArray)::DownCast (aSelEnt->BaseSensitive()))
if (Handle(Select3D_SensitivePrimitiveArray) aSensitive =
Handle(Select3D_SensitivePrimitiveArray)::DownCast(aSelEnt->BaseSensitive()))
{
aMap->ChangeMap() = aSensitive->LastDetectedElementMap()->Map();
if (aSensitive->LastDetectedElement() != -1)
@ -142,31 +139,28 @@ void AIS_PointCloudOwner::HilightWithColor (const Handle(PrsMgr_PresentationMana
}
}
//=======================================================================
//function : Unhilight
//purpose :
//=======================================================================
void AIS_PointCloudOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer )
//=================================================================================================
void AIS_PointCloudOwner::Unhilight(const Handle(PrsMgr_PresentationManager)&,
const Standard_Integer)
{
if (Handle(Prs3d_Presentation) aPrs = Selectable()->GetSelectPresentation (Handle(PrsMgr_PresentationManager)()))
if (Handle(Prs3d_Presentation) aPrs =
Selectable()->GetSelectPresentation(Handle(PrsMgr_PresentationManager)()))
{
aPrs->Erase();
}
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void AIS_PointCloudOwner::Clear (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode)
//=================================================================================================
void AIS_PointCloudOwner::Clear(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode)
{
SelectMgr_EntityOwner::Clear(thePrsMgr, theMode);
}
//==================================================
// Function: AIS_PointCloud
// Purpose : Constructor
//==================================================
//=================================================================================================
AIS_PointCloud::AIS_PointCloud()
{
myDrawer->SetupOwnShadingAspect();
@ -175,22 +169,19 @@ AIS_PointCloud::AIS_PointCloud()
SetDisplayMode(AIS_PointCloud::DM_Points);
SetHilightMode(AIS_PointCloud::DM_BndBox);
myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 1.0));
myDynHilightDrawer->SetPointAspect(
new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 1.0));
}
//=======================================================================
//function : GetPoints
//purpose :
//=======================================================================
//=================================================================================================
const Handle(Graphic3d_ArrayOfPoints) AIS_PointCloud::GetPoints() const
{
return myPoints;
}
//=======================================================================
//function : GetBoundingBox
//purpose :
//=======================================================================
//=================================================================================================
Bnd_Box AIS_PointCloud::GetBoundingBox() const
{
return myBndBox;
@ -213,20 +204,16 @@ static inline Bnd_Box getBoundingBox (const Handle(Graphic3d_ArrayOfPoints)& the
return aBndBox;
}
//=======================================================================
//function : SetPoints
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PointCloud::SetPoints(const Handle(Graphic3d_ArrayOfPoints)& thePoints)
{
myPoints = thePoints;
myBndBox = getBoundingBox(thePoints);
}
//=======================================================================
//function : SetPoints
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PointCloud::SetPoints(const Handle(TColgp_HArray1OfPnt)& theCoords,
const Handle(Quantity_HArray1OfColor)& theColors,
const Handle(TColgp_HArray1OfDir)& theNormals)
@ -258,8 +245,7 @@ void AIS_PointCloud::SetPoints (const Handle(TColgp_HArray1OfPnt)& theCoords
myPoints->AddVertex(theCoords->Value(aPntIter));
if (hasColors)
{
myPoints->SetVertexColor (myPoints->VertexNumber(),
theColors->Value (aPntIter + aDiffColors));
myPoints->SetVertexColor(myPoints->VertexNumber(), theColors->Value(aPntIter + aDiffColors));
}
if (hasNormals)
{
@ -270,10 +256,8 @@ void AIS_PointCloud::SetPoints (const Handle(TColgp_HArray1OfPnt)& theCoords
myBndBox = getBoundingBox(myPoints);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PointCloud::SetColor(const Quantity_Color& theColor)
{
AIS_InteractiveObject::SetColor(theColor);
@ -282,10 +266,8 @@ void AIS_PointCloud::SetColor (const Quantity_Color& theColor)
SynchronizeAspects();
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PointCloud::UnsetColor()
{
if (!HasColor())
@ -322,10 +304,8 @@ void AIS_PointCloud::UnsetColor()
SynchronizeAspects();
}
//=======================================================================
//function : SetMaterial
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PointCloud::SetMaterial(const Graphic3d_MaterialAspect& theMat)
{
hasOwnMaterial = Standard_True;
@ -339,10 +319,8 @@ void AIS_PointCloud::SetMaterial (const Graphic3d_MaterialAspect& theMat)
SynchronizeAspects();
}
//=======================================================================
//function : UnsetMaterial
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PointCloud::UnsetMaterial()
{
if (!HasMaterial())
@ -352,9 +330,9 @@ void AIS_PointCloud::UnsetMaterial()
{
Graphic3d_MaterialAspect aDefaultMat(Graphic3d_NameOfMaterial_Brass);
myDrawer->ShadingAspect()->SetMaterial (myDrawer->HasLink() ?
myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel) :
aDefaultMat,
myDrawer->ShadingAspect()->SetMaterial(
myDrawer->HasLink() ? myDrawer->Link()->ShadingAspect()->Material(myCurrentFacingModel)
: aDefaultMat,
myCurrentFacingModel);
if (HasColor())
{
@ -366,18 +344,15 @@ void AIS_PointCloud::UnsetMaterial()
SynchronizeAspects();
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PointCloud::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
switch (theMode)
{
case AIS_PointCloud::DM_Points:
{
case AIS_PointCloud::DM_Points: {
const Handle(Graphic3d_ArrayOfPoints) aPoints = GetPoints();
if (aPoints.IsNull())
{
@ -389,8 +364,7 @@ void AIS_PointCloud::Compute (const Handle(PrsMgr_PresentationManager)& ,
aGroup->AddPrimitiveArray(aPoints);
break;
}
case AIS_PointCloud::DM_BndBox:
{
case AIS_PointCloud::DM_BndBox: {
Bnd_Box aBndBox = GetBoundingBox();
if (aBndBox.IsVoid())
{
@ -403,10 +377,8 @@ void AIS_PointCloud::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_PointCloud::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
@ -414,11 +386,9 @@ void AIS_PointCloud::ComputeSelection (const Handle(SelectMgr_Selection)& theSel
switch (theMode)
{
case SM_Points:
case SM_SubsetOfPoints:
{
case SM_SubsetOfPoints: {
const Handle(Graphic3d_ArrayOfPoints) aPoints = GetPoints();
if (!aPoints.IsNull()
&& !aPoints->Attributes().IsNull())
if (!aPoints.IsNull() && !aPoints->Attributes().IsNull())
{
if (theMode == SM_SubsetOfPoints)
{
@ -427,23 +397,26 @@ void AIS_PointCloud::ComputeSelection (const Handle(SelectMgr_Selection)& theSel
// split large point clouds into several groups
const Standard_Integer aNbGroups = aPoints->Attributes()->NbElements > 500000 ? 8 : 1;
Handle(Select3D_SensitivePrimitiveArray) aSensitive = new Select3D_SensitivePrimitiveArray (anOwner);
Handle(Select3D_SensitivePrimitiveArray) aSensitive =
new Select3D_SensitivePrimitiveArray(anOwner);
aSensitive->SetDetectElements(true);
aSensitive->SetDetectElementMap(theMode == SM_SubsetOfPoints);
aSensitive->SetSensitivityFactor(8);
aSensitive->InitPoints (aPoints->Attributes(), aPoints->Indices(), TopLoc_Location(), true, aNbGroups);
aSensitive->InitPoints(aPoints->Attributes(),
aPoints->Indices(),
TopLoc_Location(),
true,
aNbGroups);
aSensitive->BVH();
theSelection->Add(aSensitive);
return;
}
break;
}
case SM_BndBox:
{
case SM_BndBox: {
break;
}
default:
{
default: {
return;
}
}

View File

@ -42,7 +42,6 @@ class AIS_PointCloud : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject)
public:
//! Display modes supported by this Point Cloud object
enum DisplayMode
{
@ -59,7 +58,6 @@ public:
};
public:
//! Constructor.
Standard_EXPORT AIS_PointCloud();
@ -80,9 +78,9 @@ public:
const Handle(TColgp_HArray1OfDir)& theNormals = NULL);
public:
//! Get the points array.
//! Method might be overridden to fill in points array dynamically from application data structures.
//! Method might be overridden to fill in points array dynamically from application data
//! structures.
//! @return the array of points
Standard_EXPORT virtual const Handle(Graphic3d_ArrayOfPoints) GetPoints() const;
@ -90,21 +88,21 @@ public:
Standard_EXPORT virtual Bnd_Box GetBoundingBox() const;
public:
//! Setup custom color. Affects presentation only when no per-point color attribute has been assigned.
//! Setup custom color. Affects presentation only when no per-point color attribute has been
//! assigned.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
//! Restore default color.
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
//! Setup custom material. Affects presentation only when normals are defined.
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE;
Standard_EXPORT virtual void SetMaterial(const Graphic3d_MaterialAspect& theMat)
Standard_OVERRIDE;
//! Restore default material.
Standard_EXPORT virtual void UnsetMaterial() Standard_OVERRIDE;
protected:
//! Prepare presentation for this object.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
@ -115,10 +113,8 @@ protected:
const Standard_Integer theMode) Standard_OVERRIDE;
private:
Handle(Graphic3d_ArrayOfPoints) myPoints; //!< points array for presentation
Bnd_Box myBndBox; //!< bounding box for presentation
};
DEFINE_STANDARD_HANDLE(AIS_PointCloud, AIS_InteractiveObject)
@ -135,11 +131,13 @@ public:
Standard_EXPORT virtual ~AIS_PointCloudOwner();
//! Return selected points.
//! WARNING! Indexation starts with 0 (shifted by -1 comparing to Graphic3d_ArrayOfPoints::Vertice()).
//! WARNING! Indexation starts with 0 (shifted by -1 comparing to
//! Graphic3d_ArrayOfPoints::Vertice()).
const Handle(TColStd_HPackedMapOfInteger)& SelectedPoints() const { return mySelPoints; }
//! Return last detected points.
//! WARNING! Indexation starts with 0 (shifted by -1 comparing to Graphic3d_ArrayOfPoints::Vertice()).
//! WARNING! Indexation starts with 0 (shifted by -1 comparing to
//! Graphic3d_ArrayOfPoints::Vertice()).
const Handle(TColStd_HPackedMapOfInteger)& DetectedPoints() const { return myDetPoints; }
//! Always update dynamic highlighting.
@ -151,10 +149,13 @@ public:
const Standard_Integer theMode) Standard_OVERRIDE;
//! Removes highlighting.
Standard_EXPORT virtual void Unhilight (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void Unhilight(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Clears presentation.
Standard_EXPORT virtual void Clear (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode) Standard_OVERRIDE;
Standard_EXPORT virtual void Clear(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Standard_Integer theMode) Standard_OVERRIDE;
protected:
Handle(TColStd_HPackedMapOfInteger) myDetPoints; //!< last detected points
Handle(TColStd_HPackedMapOfInteger) mySelPoints; //!< selected points

View File

@ -26,14 +26,12 @@
#include <SelectMgr_EntityOwner.hxx>
#include <V3d_View.hxx>
#define MEMORY_BLOCK_SIZE 512 * 7
IMPLEMENT_STANDARD_RTTIEXT(AIS_RubberBand, AIS_InteractiveObject)
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
//=================================================================================================
AIS_RubberBand::AIS_RubberBand()
: myIsPolygonClosed(Standard_True)
{
@ -50,10 +48,8 @@ AIS_RubberBand::AIS_RubberBand()
SetZLayer(Graphic3d_ZLayerId_TopOSD);
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
//=================================================================================================
AIS_RubberBand::AIS_RubberBand(const Quantity_Color& theLineColor,
const Aspect_TypeOfLine theLineType,
const Standard_Real theWidth,
@ -73,10 +69,8 @@ AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
SetZLayer(Graphic3d_ZLayerId_TopOSD);
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
//=================================================================================================
AIS_RubberBand::AIS_RubberBand(const Quantity_Color& theLineColor,
const Aspect_TypeOfLine theLineType,
const Quantity_Color theFillColor,
@ -98,10 +92,8 @@ AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
SetZLayer(Graphic3d_ZLayerId_TopOSD);
}
//=======================================================================
//function : Destructor
//purpose :
//=======================================================================
//=================================================================================================
AIS_RubberBand::~AIS_RubberBand()
{
myPoints.Clear();
@ -109,12 +101,12 @@ AIS_RubberBand::~AIS_RubberBand()
myBorders.Nullify();
}
//=======================================================================
//function : SetRectangle
//purpose :
//=======================================================================
void AIS_RubberBand::SetRectangle (const Standard_Integer theMinX, const Standard_Integer theMinY,
const Standard_Integer theMaxX, const Standard_Integer theMaxY)
//=================================================================================================
void AIS_RubberBand::SetRectangle(const Standard_Integer theMinX,
const Standard_Integer theMinY,
const Standard_Integer theMaxX,
const Standard_Integer theMaxY)
{
myPoints.Clear();
myPoints.Append(Graphic3d_Vec2i(theMinX, theMinY));
@ -123,136 +115,107 @@ void AIS_RubberBand::SetRectangle (const Standard_Integer theMinX, const Standar
myPoints.Append(Graphic3d_Vec2i(theMaxX, theMinY));
}
//=======================================================================
//function : AddPoint
//purpose :
//=======================================================================
//=================================================================================================
void AIS_RubberBand::AddPoint(const Graphic3d_Vec2i& thePoint)
{
myPoints.Append(thePoint);
}
//=======================================================================
//function : AddPoint
//purpose :
//=======================================================================
//=================================================================================================
void AIS_RubberBand::RemoveLastPoint()
{
myPoints.Remove(myPoints.Length());
}
//=======================================================================
//function : GetPoints
//purpose :
//=======================================================================
//=================================================================================================
const NCollection_Sequence<Graphic3d_Vec2i>& AIS_RubberBand::Points() const
{
return myPoints;
}
//=======================================================================
//function : LineColor
//purpose :
//=======================================================================
//=================================================================================================
Quantity_Color AIS_RubberBand::LineColor() const
{
return myDrawer->LineAspect()->Aspect()->Color();
}
//=======================================================================
//function : SetLineColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_RubberBand::SetLineColor(const Quantity_Color& theColor)
{
myDrawer->LineAspect()->SetColor(theColor);
}
//=======================================================================
//function : FillColor
//purpose :
//=======================================================================
//=================================================================================================
Quantity_Color AIS_RubberBand::FillColor() const
{
return myDrawer->ShadingAspect()->Color();
}
//=======================================================================
//function : SetFillColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_RubberBand::SetFillColor(const Quantity_Color& theColor)
{
myDrawer->ShadingAspect()->SetColor(theColor);
}
//=======================================================================
//function : SetLineWidth
//purpose :
//=======================================================================
//=================================================================================================
void AIS_RubberBand::SetLineWidth(const Standard_Real theWidth) const
{
myDrawer->LineAspect()->SetWidth(theWidth);
}
//=======================================================================
//function : SetLineWidth
//purpose :
//=======================================================================
//=================================================================================================
Standard_Real AIS_RubberBand::LineWidth() const
{
return myDrawer->LineAspect()->Aspect()->Width();
}
//=======================================================================
//function : SetLineType
//purpose :
//=======================================================================
//=================================================================================================
void AIS_RubberBand::SetLineType(const Aspect_TypeOfLine theType)
{
myDrawer->LineAspect()->SetTypeOfLine(theType);
}
//=======================================================================
//function : LineType
//purpose :
//=======================================================================
//=================================================================================================
Aspect_TypeOfLine AIS_RubberBand::LineType() const
{
return myDrawer->LineAspect()->Aspect()->Type();
}
//=======================================================================
//function : SetFillTransparency
//purpose :
//=======================================================================
//=================================================================================================
void AIS_RubberBand::SetFillTransparency(const Standard_Real theValue) const
{
myDrawer->ShadingAspect()->SetTransparency(theValue);
}
//=======================================================================
//function : SetFillTransparency
//purpose :
//=======================================================================
//=================================================================================================
Standard_Real AIS_RubberBand::FillTransparency() const
{
return myDrawer->ShadingAspect()->Transparency();
}
//=======================================================================
//function : SetFilling
//purpose :
//=======================================================================
//=================================================================================================
void AIS_RubberBand::SetFilling(const Standard_Boolean theIsFilling)
{
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (theIsFilling ? Aspect_IS_SOLID : Aspect_IS_EMPTY);
myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle(theIsFilling ? Aspect_IS_SOLID
: Aspect_IS_EMPTY);
}
//=======================================================================
//function : SetFilling
//purpose :
//=======================================================================
//=================================================================================================
void AIS_RubberBand::SetFilling(const Quantity_Color theColor, const Standard_Real theTransparency)
{
SetFilling(Standard_True);
@ -260,49 +223,41 @@ void AIS_RubberBand::SetFilling (const Quantity_Color theColor, const Standard_R
SetFillColor(theColor);
}
//=======================================================================
//function : IsFilling
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_RubberBand::IsFilling() const
{
Aspect_InteriorStyle aStyle = myDrawer->ShadingAspect()->Aspect()->InteriorStyle();
return aStyle != Aspect_IS_EMPTY;
}
//=======================================================================
//function : IsPolygonClosed
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_RubberBand::IsPolygonClosed() const
{
return myIsPolygonClosed;
}
//=======================================================================
//function : SetPolygonClosed
//purpose :
//=======================================================================
//=================================================================================================
void AIS_RubberBand::SetPolygonClosed(Standard_Boolean theIsPolygonClosed)
{
myIsPolygonClosed = theIsPolygonClosed;
}
//=======================================================================
//function : fillTriangles
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_RubberBand::fillTriangles()
{
Handle(NCollection_IncAllocator) anAllocator = new NCollection_IncAllocator(MEMORY_BLOCK_SIZE);
Handle(BRepMesh_DataStructureOfDelaun) aMeshStructure = new BRepMesh_DataStructureOfDelaun(anAllocator);
Handle(BRepMesh_DataStructureOfDelaun) aMeshStructure =
new BRepMesh_DataStructureOfDelaun(anAllocator);
Standard_Integer aPtsLower = myPoints.Lower();
Standard_Integer aPtsUpper = myPoints.Upper();
IMeshData::VectorOfInteger anIndexes(myPoints.Length(), anAllocator);
for (Standard_Integer aPtIdx = aPtsLower; aPtIdx <= aPtsUpper; ++aPtIdx)
{
gp_XY aP ((Standard_Real)myPoints.Value (aPtIdx).x(),
(Standard_Real)myPoints.Value (aPtIdx).y());
gp_XY aP((Standard_Real)myPoints.Value(aPtIdx).x(), (Standard_Real)myPoints.Value(aPtIdx).y());
BRepMesh_Vertex aVertex(aP, aPtIdx, BRepMesh_Frontier);
anIndexes.Append(aMeshStructure->AddNode(aVertex));
}
@ -320,9 +275,7 @@ Standard_Boolean AIS_RubberBand::fillTriangles()
{
Standard_Integer aPtIdx = isClockwiseOrdered ? aIdx : (aIdx + 1) % anIndexes.Length();
Standard_Integer aNextPtIdx = isClockwiseOrdered ? (aIdx + 1) % anIndexes.Length() : aIdx;
BRepMesh_Edge anEdge (anIndexes.Value (aPtIdx),
anIndexes.Value (aNextPtIdx),
BRepMesh_Frontier);
BRepMesh_Edge anEdge(anIndexes.Value(aPtIdx), anIndexes.Value(aNextPtIdx), BRepMesh_Frontier);
aMeshStructure->AddLink(anEdge);
}
@ -331,7 +284,6 @@ Standard_Boolean AIS_RubberBand::fillTriangles()
if (aTriangles.Extent() < 1)
return Standard_False;
Standard_Boolean toFill = Standard_False;
if (myTriangles.IsNull() || myTriangles->VertexNumber() != aTriangles.Extent() * 3)
{
@ -364,15 +316,18 @@ Standard_Boolean AIS_RubberBand::fillTriangles()
gp_Dir aNorm = gp::DZ();
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
myTriangles->AddVertex (aPts[anIt].X(), aPts[anIt].Y(), 0.0,
aNorm.X(), aNorm.Y(), aNorm.Z());
myTriangles
->AddVertex(aPts[anIt].X(), aPts[anIt].Y(), 0.0, aNorm.X(), aNorm.Y(), aNorm.Z());
}
}
else
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
myTriangles->SetVertice (aVertexIndex++, (Standard_ShortReal)aPts[anIt].X(), (Standard_ShortReal)aPts[anIt].Y(), 0.0f);
myTriangles->SetVertice(aVertexIndex++,
(Standard_ShortReal)aPts[anIt].X(),
(Standard_ShortReal)aPts[anIt].Y(),
0.0f);
}
}
}
@ -383,10 +338,8 @@ Standard_Boolean AIS_RubberBand::fillTriangles()
return Standard_True;
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_RubberBand::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
@ -405,34 +358,40 @@ void AIS_RubberBand::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
// Draw frame
if (myBorders.IsNull() || myBorders->VertexNumber() != myPoints.Length() + (myIsPolygonClosed ? 1 : 0))
if (myBorders.IsNull()
|| myBorders->VertexNumber() != myPoints.Length() + (myIsPolygonClosed ? 1 : 0))
{
myBorders = new Graphic3d_ArrayOfPolylines(myPoints.Length() + (myIsPolygonClosed ? 1 : 0));
for (Standard_Integer anIt = 1; anIt <= myPoints.Length(); anIt++)
{
myBorders->AddVertex((Standard_Real)myPoints.Value(anIt).x(),
(Standard_Real)myPoints.Value (anIt).y(), 0.0);
(Standard_Real)myPoints.Value(anIt).y(),
0.0);
}
if (myIsPolygonClosed)
{
myBorders->AddVertex((Standard_Real)myPoints.Value(1).x(),
(Standard_Real)myPoints.Value(1).y(), 0.0);
(Standard_Real)myPoints.Value(1).y(),
0.0);
}
}
else
{
for (Standard_Integer anIt = 1; anIt <= myPoints.Length(); anIt++)
{
myBorders->SetVertice (anIt, (Standard_ShortReal)myPoints.Value (anIt).x(),
(Standard_ShortReal)myPoints.Value (anIt).y(), 0.0f);
myBorders->SetVertice(anIt,
(Standard_ShortReal)myPoints.Value(anIt).x(),
(Standard_ShortReal)myPoints.Value(anIt).y(),
0.0f);
}
if (myIsPolygonClosed)
{
myBorders->SetVertice(myPoints.Length() + 1, (Standard_ShortReal)myPoints.Value(1).x(),
(Standard_ShortReal)myPoints.Value(1).y(), 0.0f);
myBorders->SetVertice(myPoints.Length() + 1,
(Standard_ShortReal)myPoints.Value(1).x(),
(Standard_ShortReal)myPoints.Value(1).y(),
0.0f);
}
}

View File

@ -33,7 +33,6 @@ DEFINE_STANDARD_HANDLE(AIS_RubberBand, AIS_InteractiveObject)
class AIS_RubberBand : public AIS_InteractiveObject
{
public:
DEFINE_STANDARD_RTTIEXT(AIS_RubberBand, AIS_InteractiveObject)
//! Constructs rubber band with default configuration: empty filling and white solid lines.
@ -54,7 +53,8 @@ public:
//! @param[in] theLineColor color of rubber band lines
//! @param[in] theType type of rubber band lines
//! @param[in] theFillColor color of rubber band filling
//! @param[in] theTransparency transparency of the filling. 0 is for opaque filling. By default it is transparent.
//! @param[in] theTransparency transparency of the filling. 0 is for opaque filling. By default
//! it is transparent.
//! @param[in] theLineWidth width of rubber band line. By default it is 1.
//! @warning It binds this object with Graphic3d_ZLayerId_TopOSD layer.
Standard_EXPORT AIS_RubberBand(const Quantity_Color& theLineColor,
@ -67,8 +67,10 @@ public:
Standard_EXPORT virtual ~AIS_RubberBand();
//! Sets rectangle bounds.
Standard_EXPORT void SetRectangle (const Standard_Integer theMinX, const Standard_Integer theMinY,
const Standard_Integer theMaxX, const Standard_Integer theMaxY);
Standard_EXPORT void SetRectangle(const Standard_Integer theMinX,
const Standard_Integer theMinY,
const Standard_Integer theMaxX,
const Standard_Integer theMaxY);
//! Adds last point to the list of points. They are used to build polygon for rubber band.
//! @sa RemoveLastPoint(), GetPoints()
@ -121,7 +123,8 @@ public:
//! Enable filling of rubber band with defined parameters.
//! @param[in] theColor color of filling
//! @param[in] theTransparency transparency of the filling. 0 is for opaque filling.
Standard_EXPORT void SetFilling (const Quantity_Color theColor, const Standard_Real theTransparency);
Standard_EXPORT void SetFilling(const Quantity_Color theColor,
const Standard_Real theTransparency);
//! @return true if filling of rubber band is enabled.
Standard_EXPORT Standard_Boolean IsFilling() const;
@ -134,7 +137,6 @@ public:
Standard_EXPORT void SetPolygonClosed(Standard_Boolean theIsPolygonClosed);
protected:
//! Returns true if the interactive object accepts the display mode.
Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{
@ -156,7 +158,6 @@ protected:
Standard_EXPORT Standard_Boolean fillTriangles();
protected:
NCollection_Sequence<Graphic3d_Vec2i> myPoints; //!< Array of screen points
Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for rubber band filling

View File

@ -17,7 +17,6 @@
#ifndef _AIS_SelectStatus_HeaderFile
#define _AIS_SelectStatus_HeaderFile
enum AIS_SelectStatus
{
AIS_SS_Added,

View File

@ -25,20 +25,16 @@ namespace
static const Standard_Integer THE_MaxSizeOfResult = 100000;
}
//=======================================================================
//function : AIS_Selection
//purpose :
//=======================================================================
//=================================================================================================
AIS_Selection::AIS_Selection()
{
// for maximum performance on medium selections (< 100000 objects)
myResultMap.ReSize(THE_MaxSizeOfResult);
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Selection::Clear()
{
for (AIS_NListOfEntityOwner::Iterator aSelIter(Objects()); aSelIter.More(); aSelIter.Next())
@ -51,23 +47,20 @@ void AIS_Selection::Clear()
myIterator = AIS_NListOfEntityOwner::Iterator();
}
//=======================================================================
//function : Select
//purpose :
//=======================================================================
//=================================================================================================
AIS_SelectStatus AIS_Selection::Select(const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(SelectMgr_Filter)& theFilter,
const AIS_SelectionScheme theSelScheme,
const Standard_Boolean theIsDetected)
{
if (theOwner.IsNull()
|| !theOwner->HasSelectable())
if (theOwner.IsNull() || !theOwner->HasSelectable())
{
return AIS_SS_NotDone;
}
const Standard_Boolean isDetected = theIsDetected
&& (theFilter.IsNull() || theFilter->IsOk (theOwner));
const Standard_Boolean isDetected =
theIsDetected && (theFilter.IsNull() || theFilter->IsOk(theOwner));
const Standard_Boolean wasSelected = theOwner->IsSelected();
const Standard_Boolean toSelect = theOwner->Select(theSelScheme, isDetected);
@ -101,7 +94,8 @@ AIS_SelectStatus AIS_Selection::Select (const Handle(SelectMgr_EntityOwner)& the
// In the mode of advanced mesh selection only one owner is created for all selection modes.
// It is necessary to check the current detected entity
// and remove the owner from map only if the detected entity is the same as previous selected (IsForcedHilight call)
// and remove the owner from map only if the detected entity is the same as previous selected
// (IsForcedHilight call)
if (theOwner->IsForcedHilight())
{
return AIS_SS_Added;
@ -127,15 +121,11 @@ AIS_SelectStatus AIS_Selection::Select (const Handle(SelectMgr_EntityOwner)& the
return AIS_SS_Removed;
}
//=======================================================================
//function : AddSelect
//purpose :
//=======================================================================
//=================================================================================================
AIS_SelectStatus AIS_Selection::AddSelect(const Handle(SelectMgr_EntityOwner)& theObject)
{
if (theObject.IsNull()
|| !theObject->HasSelectable()
|| myResultMap.IsBound (theObject))
if (theObject.IsNull() || !theObject->HasSelectable() || myResultMap.IsBound(theObject))
{
return AIS_SS_NotDone;
}
@ -147,10 +137,8 @@ AIS_SelectStatus AIS_Selection::AddSelect (const Handle(SelectMgr_EntityOwner)&
return AIS_SS_Added;
}
//=======================================================================
//function : SelectOwners
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Selection::SelectOwners(const AIS_NArray1OfEntityOwner& thePickedOwners,
const AIS_SelectionScheme theSelScheme,
const Standard_Boolean theToAllowSelOverlap,
@ -158,12 +146,12 @@ void AIS_Selection::SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwner
{
(void)theToAllowSelOverlap;
if (theSelScheme == AIS_SelectionScheme_ReplaceExtra
&& thePickedOwners.Size() == myresult.Size())
if (theSelScheme == AIS_SelectionScheme_ReplaceExtra && thePickedOwners.Size() == myresult.Size())
{
// If picked owners is equivalent to the selected then just clear selected.
Standard_Boolean isTheSame = Standard_True;
for (AIS_NArray1OfEntityOwner::Iterator aPickedIter (thePickedOwners); aPickedIter.More(); aPickedIter.Next())
for (AIS_NArray1OfEntityOwner::Iterator aPickedIter(thePickedOwners); aPickedIter.More();
aPickedIter.Next())
{
if (!myResultMap.IsBound(aPickedIter.Value()))
{
@ -185,23 +173,20 @@ void AIS_Selection::SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwner
Clear();
}
for (AIS_NArray1OfEntityOwner::Iterator aPickedIter (thePickedOwners); aPickedIter.More(); aPickedIter.Next())
for (AIS_NArray1OfEntityOwner::Iterator aPickedIter(thePickedOwners); aPickedIter.More();
aPickedIter.Next())
{
const Handle(SelectMgr_EntityOwner)& anOwner = aPickedIter.Value();
Select(anOwner, theFilter, theSelScheme, true);
}
}
//=======================================================================
//function : appendOwner
//purpose :
//=======================================================================
//=================================================================================================
AIS_SelectStatus AIS_Selection::appendOwner(const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(SelectMgr_Filter)& theFilter)
{
if (theOwner.IsNull()
|| !theOwner->HasSelectable()
|| !theFilter->IsOk (theOwner))
if (theOwner.IsNull() || !theOwner->HasSelectable() || !theFilter->IsOk(theOwner))
{
return AIS_SS_NotDone;
}

View File

@ -31,7 +31,6 @@ class AIS_Selection : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
public:
//! creates a new selection.
Standard_EXPORT AIS_Selection();
@ -52,7 +51,8 @@ public:
//! the object is always add int the selection.
//! faster when the number of objects selected is great.
Standard_EXPORT virtual AIS_SelectStatus AddSelect (const Handle(SelectMgr_EntityOwner)& theObject);
Standard_EXPORT virtual AIS_SelectStatus AddSelect(
const Handle(SelectMgr_EntityOwner)& theObject);
//! clears the selection and adds the object in the selection.
//! @param[in] theObject element to change selection state
@ -67,7 +67,10 @@ public:
}
//! checks if the object is in the selection.
Standard_Boolean IsSelected (const Handle(SelectMgr_EntityOwner)& theObject) const { return myResultMap.IsBound (theObject); }
Standard_Boolean IsSelected(const Handle(SelectMgr_EntityOwner)& theObject) const
{
return myResultMap.IsBound(theObject);
}
//! Return the list of selected objects.
const AIS_NListOfEntityOwner& Objects() const { return myresult; }
@ -79,7 +82,6 @@ public:
Standard_Boolean IsEmpty() const { return myresult.IsEmpty(); }
public:
//! Start iteration through selected objects.
void Init() { myIterator = AIS_NListOfEntityOwner::Iterator(myresult); }
@ -103,20 +105,18 @@ public:
const Handle(SelectMgr_Filter)& theFilter);
protected:
//! Append the owner into the current selection if filter is Ok.
//! @param[in] theOwner element to change selection state
//! @param[in] theFilter context filter to skip not acceptable owners
//! @return result of selection
Standard_EXPORT virtual AIS_SelectStatus appendOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
Standard_EXPORT virtual AIS_SelectStatus appendOwner(
const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(SelectMgr_Filter)& theFilter);
protected:
AIS_NListOfEntityOwner myresult;
AIS_NListOfEntityOwner::Iterator myIterator;
NCollection_DataMap<Handle(SelectMgr_EntityOwner), AIS_NListOfEntityOwner::Iterator> myResultMap;
};
DEFINE_STANDARD_HANDLE(AIS_Selection, Standard_Transient)

View File

@ -14,11 +14,16 @@
#ifndef _AIS_SelectionModesConcurrency_HeaderFile
#define _AIS_SelectionModesConcurrency_HeaderFile
//! The mode specifying how multiple active Selection Modes should be treated during activation of new one.
//! The mode specifying how multiple active Selection Modes should be treated during activation of
//! new one.
enum AIS_SelectionModesConcurrency
{
AIS_SelectionModesConcurrency_Single, //!< only one selection mode can be activated at the same moment - previously activated should be deactivated
AIS_SelectionModesConcurrency_GlobalOrLocal, //!< either Global (AIS_InteractiveObject::GlobalSelectionMode() or Local (multiple) selection modes can be active at the same moment
AIS_SelectionModesConcurrency_Single, //!< only one selection mode can be activated at the same
//!< moment - previously activated should be deactivated
AIS_SelectionModesConcurrency_GlobalOrLocal, //!< either Global
//!< (AIS_InteractiveObject::GlobalSelectionMode() or
//!< Local (multiple) selection modes can be active
//!< at the same moment
AIS_SelectionModesConcurrency_Multiple, //!< any combination of selection modes can be activated
};

View File

@ -23,8 +23,9 @@ enum AIS_SelectionScheme
AIS_SelectionScheme_Remove, //!< removes detected object from the current selection
AIS_SelectionScheme_XOR, //!< performs XOR for detected objects, other selected not touched
AIS_SelectionScheme_Clear, //!< clears current selection
AIS_SelectionScheme_ReplaceExtra, //!< replace with one difference: if result of replace is an empty,
//!< and current selection contains detected element, it will be selected
AIS_SelectionScheme_ReplaceExtra, //!< replace with one difference: if result of replace is an
//!< empty, and current selection contains detected element, it
//!< will be selected
};
#endif // _AIS_SelectionScheme_HeaderFile

View File

@ -63,10 +63,8 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject)
theMap.Bind(myDrawer->Link()->theAspect()->Aspect(), myDrawer->theAspect()->Aspect()); \
}
//=======================================================================
//function : replaceWithNewOwnAspects
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::replaceWithNewOwnAspects()
{
Graphic3d_MapOfAspectsToAspects aReplaceMap;
@ -83,10 +81,8 @@ void AIS_Shape::replaceWithNewOwnAspects()
replaceAspects(aReplaceMap);
}
//==================================================
// Function: AIS_Shape
// Purpose :
//==================================================
//=================================================================================================
AIS_Shape::AIS_Shape(const TopoDS_Shape& theShape)
: AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependent),
myshape(theShape),
@ -99,23 +95,19 @@ AIS_Shape::AIS_Shape(const TopoDS_Shape& theShape)
//
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
if (myshape.IsNull()
|| (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0))
if (myshape.IsNull() || (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0))
{
return;
}
// wire,edge,vertex -> pas de HLR + priorite display superieure
if (myshape.ShapeType() >= TopAbs_WIRE
&& myshape.ShapeType() <= TopAbs_VERTEX)
if (myshape.ShapeType() >= TopAbs_WIRE && myshape.ShapeType() <= TopAbs_VERTEX)
{
// TopAbs_WIRE -> 7, TopAbs_EDGE -> 8, TopAbs_VERTEX -> 9 (Graphic3d_DisplayPriority_Highlight)
const Standard_Integer aPrior = (Standard_Integer)Graphic3d_DisplayPriority_Above1
@ -131,8 +123,7 @@ void AIS_Shape::Compute (const Handle(PrsMgr_PresentationManager)& ,
switch (theMode)
{
case AIS_WireFrame:
{
case AIS_WireFrame: {
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange(myshape, myDrawer, Standard_True);
try
{
@ -141,13 +132,14 @@ void AIS_Shape::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
catch (Standard_Failure const& anException)
{
Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::Compute() wireframe presentation builder has failed (")
Message::SendFail(
TCollection_AsciiString(
"Error: AIS_Shape::Compute() wireframe presentation builder has failed (")
+ anException.GetMessageString() + ")");
}
break;
}
case AIS_Shaded:
{
case AIS_Shaded: {
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange(myshape, myDrawer, Standard_True);
if ((Standard_Integer)myshape.ShapeType() > 4)
{
@ -164,14 +156,21 @@ void AIS_Shape::Compute (const Handle(PrsMgr_PresentationManager)& ,
try
{
OCC_CATCH_SIGNALS
StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer,
StdPrs_ShadedShape::Add(
thePrs,
myshape,
myDrawer,
myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
&& !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
myUVOrigin, myUVRepeat, myUVScale);
myUVOrigin,
myUVRepeat,
myUVScale);
}
catch (Standard_Failure const& anException)
{
Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::Compute() shaded presentation builder has failed (")
Message::SendFail(
TCollection_AsciiString(
"Error: AIS_Shape::Compute() shaded presentation builder has failed (")
+ anException.GetMessageString() + ")");
StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
}
@ -186,8 +185,7 @@ void AIS_Shape::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
// Bounding box.
case 2:
{
case 2: {
if (IsInfinite())
{
StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
@ -203,10 +201,8 @@ void AIS_Shape::Compute (const Handle(PrsMgr_PresentationManager)& ,
thePrs->ReCompute();
}
//=======================================================================
//function : computeHlrPresentation
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::computeHlrPresentation(const Handle(Graphic3d_Camera)& theProjector,
const Handle(Prs3d_Presentation)& thePrs,
const TopoDS_Shape& theShape,
@ -221,22 +217,19 @@ void AIS_Shape::computeHlrPresentation (const Handle(Graphic3d_Camera)& theProje
{
case TopAbs_VERTEX:
case TopAbs_EDGE:
case TopAbs_WIRE:
{
case TopAbs_WIRE: {
thePrs->SetDisplayPriority(Graphic3d_DisplayPriority_Below);
StdPrs_WFShape::Add(thePrs, theShape, theDrawer);
return;
}
case TopAbs_COMPOUND:
{
case TopAbs_COMPOUND: {
if (theShape.NbChildren() == 0)
{
return;
}
break;
}
default:
{
default: {
break;
}
}
@ -264,15 +257,13 @@ void AIS_Shape::computeHlrPresentation (const Handle(Graphic3d_Camera)& theProje
OCC_CATCH_SIGNALS
switch (theDrawer->TypeOfHLR())
{
case Prs3d_TOH_Algo:
{
case Prs3d_TOH_Algo: {
StdPrs_HLRShape aBuilder;
aBuilder.ComputeHLR(thePrs, theShape, theDrawer, theProjector);
break;
}
case Prs3d_TOH_PolyAlgo:
case Prs3d_TOH_NotSet:
{
case Prs3d_TOH_NotSet: {
StdPrs_HLRPolyShape aBuilder;
aBuilder.ComputeHLR(thePrs, theShape, theDrawer, theProjector);
break;
@ -281,7 +272,8 @@ void AIS_Shape::computeHlrPresentation (const Handle(Graphic3d_Camera)& theProje
}
catch (Standard_Failure const& anException)
{
Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::Compute() HLR Algorithm has failed (")
Message::SendFail(
TCollection_AsciiString("Error: AIS_Shape::Compute() HLR Algorithm has failed (")
+ anException.GetMessageString() + ")");
StdPrs_WFShape::Add(thePrs, theShape, theDrawer);
}
@ -290,15 +282,13 @@ void AIS_Shape::computeHlrPresentation (const Handle(Graphic3d_Camera)& theProje
aDefDrawer->SetTypeOfDeflection(aPrevDef);
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
{
if(myshape.IsNull()) return;
if (myshape.IsNull())
return;
if (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0)
{
// empty Shape -> empty Assembly.
@ -324,8 +314,8 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
}
catch (Standard_Failure const& anException)
{
Message::SendFail (TCollection_AsciiString("Error: AIS_Shape::ComputeSelection(") + aMode + ") has failed ("
+ anException.GetMessageString() + ")");
Message::SendFail(TCollection_AsciiString("Error: AIS_Shape::ComputeSelection(") + aMode
+ ") has failed (" + anException.GetMessageString() + ")");
if (aMode == 0)
{
aSelection->Clear();
@ -351,23 +341,17 @@ void AIS_Shape::Color (Quantity_Color& theColor) const
Graphic3d_NameOfMaterial AIS_Shape::Material() const
{
const Handle(Prs3d_ShadingAspect)& aShading = myDrawer->ShadingAspect();
return !aShading.IsNull()
? aShading->Material(myCurrentFacingModel).Name()
return !aShading.IsNull() ? aShading->Material(myCurrentFacingModel).Name()
: Graphic3d_NameOfMaterial_DEFAULT;
}
Standard_Real AIS_Shape::Transparency() const
{
const Handle(Prs3d_ShadingAspect)& aShading = myDrawer->ShadingAspect();
return !aShading.IsNull()
? aShading->Transparency(myCurrentFacingModel)
: 0.0;
return !aShading.IsNull() ? aShading->Transparency(myCurrentFacingModel) : 0.0;
}
//=======================================================================
//function : setColor
//purpose :
//=======================================================================
//=================================================================================================
bool AIS_Shape::setColor(const Handle(Prs3d_Drawer)& theDrawer,
const Quantity_Color& theColor) const
@ -389,10 +373,7 @@ bool AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
return toRecompute;
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::SetColor(const Quantity_Color& theColor)
{
@ -400,8 +381,7 @@ void AIS_Shape::SetColor (const Quantity_Color& theColor)
myDrawer->SetColor(theColor);
hasOwnColor = Standard_True;
if (!toRecompute
|| !myDrawer->HasLink())
if (!toRecompute || !myDrawer->HasLink())
{
SynchronizeAspects();
}
@ -412,10 +392,7 @@ void AIS_Shape::SetColor (const Quantity_Color& theColor)
recomputeComputed();
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::UnsetColor()
{
@ -425,7 +402,8 @@ void AIS_Shape::UnsetColor()
}
hasOwnColor = Standard_False;
myDrawer->SetColor (myDrawer->HasLink() ? myDrawer->Link()->Color() : Quantity_Color (Quantity_NOC_WHITE));
myDrawer->SetColor(myDrawer->HasLink() ? myDrawer->Link()->Color()
: Quantity_Color(Quantity_NOC_WHITE));
Graphic3d_MapOfAspectsToAspects aReplaceMap;
if (!HasWidth())
@ -486,9 +464,7 @@ void AIS_Shape::UnsetColor()
{
//
}
else if (HasMaterial()
|| IsTransparent()
|| myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
else if (HasMaterial() || IsTransparent() || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
{
const Graphic3d_MaterialAspect aDefaultMat(Graphic3d_NameOfMaterial_Brass);
Graphic3d_MaterialAspect mat = aDefaultMat;
@ -500,15 +476,15 @@ void AIS_Shape::UnsetColor()
}
if (HasMaterial() || myDrawer->HasLink())
{
const Handle(Graphic3d_AspectFillArea3d)& aSrcAspect = (HasMaterial() ? myDrawer : myDrawer->Link())->ShadingAspect()->Aspect();
mat = myCurrentFacingModel != Aspect_TOFM_BACK_SIDE
? aSrcAspect->FrontMaterial()
const Handle(Graphic3d_AspectFillArea3d)& aSrcAspect =
(HasMaterial() ? myDrawer : myDrawer->Link())->ShadingAspect()->Aspect();
mat = myCurrentFacingModel != Aspect_TOFM_BACK_SIDE ? aSrcAspect->FrontMaterial()
: aSrcAspect->BackMaterial();
}
if (HasMaterial())
{
const Quantity_Color aColor = myDrawer->HasLink()
? myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel)
const Quantity_Color aColor =
myDrawer->HasLink() ? myDrawer->Link()->ShadingAspect()->Color(myCurrentFacingModel)
: aDefaultMat.AmbientColor();
mat.SetColor(aColor);
}
@ -536,10 +512,7 @@ void AIS_Shape::UnsetColor()
recomputeComputed();
}
//=======================================================================
//function : setWidth
//purpose :
//=======================================================================
//=================================================================================================
bool AIS_Shape::setWidth(const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Real theLineWidth) const
@ -556,17 +529,13 @@ bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
return toRecompute;
}
//=======================================================================
//function : SetWidth
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::SetWidth(const Standard_Real theLineWidth)
{
myOwnWidth = (Standard_ShortReal)theLineWidth;
if (!setWidth (myDrawer, theLineWidth)
|| !myDrawer->HasLink())
if (!setWidth(myDrawer, theLineWidth) || !myDrawer->HasLink())
{
SynchronizeAspects();
}
@ -577,10 +546,7 @@ void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
recomputeComputed();
}
//=======================================================================
//function : UnsetWidth
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::UnsetWidth()
{
@ -609,27 +575,25 @@ void AIS_Shape::UnsetWidth()
}
else
{
myDrawer->LineAspect() ->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.);
myDrawer->WireAspect() ->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Wire) : 1.);
myDrawer->FreeBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Free) : 1.);
myDrawer->UnFreeBoundaryAspect()->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_UnFree) : 1.);
myDrawer->SeenLineAspect() ->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Seen) : 1.);
myDrawer->FaceBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_FaceBoundary) : 1.);
myDrawer->LineAspect()->SetWidth(
myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Line) : 1.);
myDrawer->WireAspect()->SetWidth(
myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Wire) : 1.);
myDrawer->FreeBoundaryAspect()->SetWidth(
myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Free) : 1.);
myDrawer->UnFreeBoundaryAspect()->SetWidth(
myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_UnFree) : 1.);
myDrawer->SeenLineAspect()->SetWidth(
myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_Seen) : 1.);
myDrawer->FaceBoundaryAspect()->SetWidth(
myDrawer->HasLink() ? AIS_GraphicTool::GetLineWidth(myDrawer->Link(), AIS_TOA_FaceBoundary)
: 1.);
SynchronizeAspects();
}
recomputeComputed();
}
//=======================================================================
//function : setMaterial
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::setMaterial(const Handle(Prs3d_Drawer)& theDrawer,
const Graphic3d_MaterialAspect& theMaterial,
@ -652,10 +616,7 @@ void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)& theDrawer,
}
}
//=======================================================================
//function : SetMaterial
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& theMat)
{
@ -663,8 +624,7 @@ void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
setMaterial(myDrawer, theMat, HasColor(), IsTransparent());
hasOwnMaterial = Standard_True;
if (!toRecompute
|| !myDrawer->HasLink())
if (!toRecompute || !myDrawer->HasLink())
{
SynchronizeAspects();
}
@ -674,10 +634,7 @@ void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
}
}
//=======================================================================
//function : UnsetMaterial
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::UnsetMaterial()
{
@ -690,13 +647,12 @@ void AIS_Shape::UnsetMaterial()
{
//
}
else if (HasColor()
|| IsTransparent()
|| myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
else if (HasColor() || IsTransparent() || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
{
if (myDrawer->HasLink())
{
myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel),
myDrawer->ShadingAspect()->SetMaterial(
myDrawer->Link()->ShadingAspect()->Material(myCurrentFacingModel),
myCurrentFacingModel);
}
if (HasColor())
@ -715,10 +671,7 @@ void AIS_Shape::UnsetMaterial()
}
}
//=======================================================================
//function : setTransparency
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::setTransparency(const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Real theValue) const
@ -728,10 +681,7 @@ void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
theDrawer->ShadingAspect()->SetTransparency(theValue, myCurrentFacingModel);
}
//=======================================================================
//function : SetTransparency
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::SetTransparency(const Standard_Real theValue)
{
@ -739,8 +689,7 @@ void AIS_Shape::SetTransparency (const Standard_Real theValue)
setTransparency(myDrawer, theValue);
myDrawer->SetTransparency((Standard_ShortReal)theValue);
if (!toRecompute
|| !myDrawer->HasLink())
if (!toRecompute || !myDrawer->HasLink())
{
SynchronizeAspects();
}
@ -750,10 +699,7 @@ void AIS_Shape::SetTransparency (const Standard_Real theValue)
}
}
//=======================================================================
//function : UnsetTransparency
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::UnsetTransparency()
{
@ -762,9 +708,7 @@ void AIS_Shape::UnsetTransparency()
{
return;
}
else if (HasColor()
|| HasMaterial()
|| myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
else if (HasColor() || HasMaterial() || myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
{
myDrawer->ShadingAspect()->SetTransparency(0.0, myCurrentFacingModel);
SynchronizeAspects();
@ -778,10 +722,7 @@ void AIS_Shape::UnsetTransparency()
}
}
//=======================================================================
//function : BoundingBox
//purpose :
//=======================================================================
//=================================================================================================
const Bnd_Box& AIS_Shape::BoundingBox()
{
@ -792,7 +733,8 @@ const Bnd_Box& AIS_Shape::BoundingBox()
return myBB;
}
if(myCompBB) {
if (myCompBB)
{
BRepBndLib::Add(myshape, myBB, false);
myCompBB = Standard_False;
}
@ -810,7 +752,8 @@ const Bnd_Box& AIS_Shape::BoundingBox()
Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient()
{
Standard_Boolean itSet = myDrawer->HasOwnDeviationCoefficient();
if(itSet) myDrawer->SetDeviationCoefficient();
if (itSet)
myDrawer->SetDeviationCoefficient();
return itSet;
}
@ -823,15 +766,12 @@ Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient ()
Standard_Boolean AIS_Shape::SetOwnDeviationAngle()
{
Standard_Boolean itSet = myDrawer->HasOwnDeviationAngle();
if(itSet) myDrawer->SetDeviationAngle();
if (itSet)
myDrawer->SetDeviationAngle();
return itSet;
}
//=======================================================================
//function : SetOwnDeviationCoefficient
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::SetOwnDeviationCoefficient(const Standard_Real aCoefficient)
{
@ -839,20 +779,15 @@ void AIS_Shape::SetOwnDeviationCoefficient ( const Standard_Real aCoefficient )
SetToUpdate();
}
//=======================================================================
//function : SetOwnDeviationAngle
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::SetOwnDeviationAngle(const Standard_Real theAngle)
{
myDrawer->SetDeviationAngle(theAngle);
SetToUpdate(AIS_WireFrame);
}
//=======================================================================
//function : SetOwnDeviationAngle
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::SetAngleAndDeviation(const Standard_Real anAngle)
{
@ -864,20 +799,14 @@ void AIS_Shape::SetAngleAndDeviation ( const Standard_Real anAngle )
SetToUpdate();
}
//=======================================================================
//function : UserAngle
//purpose :
//=======================================================================
//=================================================================================================
Standard_Real AIS_Shape::UserAngle() const
{
return myInitAng == 0. ? GetContext()->DeviationAngle() : myInitAng;
}
//=======================================================================
//function : OwnDeviationCoefficient
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_Shape::OwnDeviationCoefficient(Standard_Real& aCoefficient,
Standard_Real& aPreviousCoefficient) const
@ -887,10 +816,7 @@ Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real & aCoeffici
return myDrawer->HasOwnDeviationCoefficient();
}
//=======================================================================
//function : OwnDeviationAngle
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_Shape::OwnDeviationAngle(Standard_Real& anAngle,
Standard_Real& aPreviousAngle) const
@ -900,10 +826,8 @@ Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real & anAngle,
return myDrawer->HasOwnDeviationAngle();
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Shape::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)

View File

@ -47,21 +47,22 @@
//! true indicating that there is a local setting available
//! for the specific object.
//!
//! This class allows to map textures on shapes using native UV parametric space of underlying surface of each Face
//! (this means that texture will be visually duplicated on all Faces).
//! To generate texture coordinates, appropriate shading attribute should be set before computing presentation in AIS_Shaded display mode:
//! This class allows to map textures on shapes using native UV parametric space of underlying
//! surface of each Face (this means that texture will be visually duplicated on all Faces). To
//! generate texture coordinates, appropriate shading attribute should be set before computing
//! presentation in AIS_Shaded display mode:
//! @code
//! Handle(AIS_Shape) aPrs = new AIS_Shape();
//! aPrs->Attributes()->SetupOwnShadingAspect();
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn();
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMap (new Graphic3d_Texture2Dmanual (Graphic3d_NOT_2D_ALUMINUM));
//! aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMap (new Graphic3d_Texture2Dmanual
//! (Graphic3d_NOT_2D_ALUMINUM));
//! @endcode
//! The texture itself is parametrized in (0,1)x(0,1).
class AIS_Shape : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_Shape, AIS_InteractiveObject)
public:
//! Initializes construction of the shape shap from wires,
//! edges and vertices.
Standard_EXPORT AIS_Shape(const TopoDS_Shape& shap);
@ -70,13 +71,22 @@ public:
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; }
//! Returns Object as the type of Interactive Object.
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Shape; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Shape;
}
//! Returns true if the Interactive Object accepts shape decomposition.
virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE { return Standard_True; }
virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE
{
return Standard_True;
}
//! Return true if specified display mode is supported.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode >= 0 && theMode <= 2; }
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{
return theMode >= 0 && theMode <= 2;
}
//! Returns this shape object.
const TopoDS_Shape& Shape() const { return myshape; }
@ -114,12 +124,14 @@ public:
//! coefficient aCoefficient and the previous deviation
//! coefficient aPreviousCoefficient. If these values are
//! not already set, false is returned.
Standard_EXPORT Standard_Boolean OwnDeviationCoefficient (Standard_Real& aCoefficient, Standard_Real& aPreviousCoefficient) const;
Standard_EXPORT Standard_Boolean
OwnDeviationCoefficient(Standard_Real& aCoefficient, Standard_Real& aPreviousCoefficient) const;
//! Returns true and the values of the deviation angle
//! anAngle and the previous deviation angle aPreviousAngle.
//! If these values are not already set, false is returned.
Standard_EXPORT Standard_Boolean OwnDeviationAngle (Standard_Real& anAngle, Standard_Real& aPreviousAngle) const;
Standard_EXPORT Standard_Boolean OwnDeviationAngle(Standard_Real& anAngle,
Standard_Real& aPreviousAngle) const;
//! Sets the type of HLR algorithm used by the shape
void SetTypeOfHLR(const Prs3d_TypeOfHLR theTypeOfHLR) { myDrawer->SetTypeOfHLR(theTypeOfHLR); }
@ -190,15 +202,24 @@ public:
{
switch (theSelMode)
{
case 1: return TopAbs_VERTEX;
case 2: return TopAbs_EDGE;
case 3: return TopAbs_WIRE;
case 4: return TopAbs_FACE;
case 5: return TopAbs_SHELL;
case 6: return TopAbs_SOLID;
case 7: return TopAbs_COMPSOLID;
case 8: return TopAbs_COMPOUND;
case 0: return TopAbs_SHAPE;
case 1:
return TopAbs_VERTEX;
case 2:
return TopAbs_EDGE;
case 3:
return TopAbs_WIRE;
case 4:
return TopAbs_FACE;
case 5:
return TopAbs_SHELL;
case 6:
return TopAbs_SOLID;
case 7:
return TopAbs_COMPSOLID;
case 8:
return TopAbs_COMPOUND;
case 0:
return TopAbs_SHAPE;
}
return TopAbs_SHAPE;
}
@ -208,26 +229,35 @@ public:
{
switch (theShapeType)
{
case TopAbs_VERTEX: return 1;
case TopAbs_EDGE: return 2;
case TopAbs_WIRE: return 3;
case TopAbs_FACE: return 4;
case TopAbs_SHELL: return 5;
case TopAbs_SOLID: return 6;
case TopAbs_COMPSOLID: return 7;
case TopAbs_COMPOUND: return 8;
case TopAbs_SHAPE: return 0;
case TopAbs_VERTEX:
return 1;
case TopAbs_EDGE:
return 2;
case TopAbs_WIRE:
return 3;
case TopAbs_FACE:
return 4;
case TopAbs_SHELL:
return 5;
case TopAbs_SOLID:
return 6;
case TopAbs_COMPSOLID:
return 7;
case TopAbs_COMPOUND:
return 8;
case TopAbs_SHAPE:
return 0;
}
return 0;
}
public: //! @name methods to alter texture mapping properties
//! Return texture repeat UV values; (1, 1) by default.
const gp_Pnt2d& TextureRepeatUV() const { return myUVRepeat; }
//! Sets the number of occurrences of the texture on each face. The texture itself is parameterized in (0,1) by (0,1).
//! Each face of the shape to be textured is parameterized in UV space (Umin,Umax) by (Vmin,Vmax).
//! Sets the number of occurrences of the texture on each face. The texture itself is
//! parameterized in (0,1) by (0,1). Each face of the shape to be textured is parameterized in UV
//! space (Umin,Umax) by (Vmin,Vmax).
void SetTextureRepeatUV(const gp_Pnt2d& theRepeatUV) { myUVRepeat = theRepeatUV; }
//! Return texture origin UV position; (0, 0) by default.
@ -247,7 +277,6 @@ public: //! @name methods to alter texture mapping properties
void SetTextureScaleUV(const gp_Pnt2d& theScaleUV) { myUVScale = theScaleUV; }
protected:
//! Compute normal presentation.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
@ -258,8 +287,7 @@ protected:
const Handle(TopLoc_Datum3D)& theTrsf,
const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE
{
if (!theTrsf.IsNull()
&& theTrsf->Form() != gp_Identity)
if (!theTrsf.IsNull() && theTrsf->Form() != gp_Identity)
{
const TopLoc_Location& aLoc = myshape.Location();
const TopoDS_Shape aShape = myshape.Located(TopLoc_Location(theTrsf->Trsf()) * aLoc);
@ -277,21 +305,26 @@ protected:
//! Create own aspects (if they do not exist) and set color to them.
//! @return TRUE if new aspects have been created
Standard_EXPORT bool setColor (const Handle(Prs3d_Drawer)& theDrawer, const Quantity_Color& theColor) const;
Standard_EXPORT bool setColor(const Handle(Prs3d_Drawer)& theDrawer,
const Quantity_Color& theColor) const;
//! Create own aspects (if they do not exist) and set width to them.
//! @return TRUE if new aspects have been created
Standard_EXPORT bool setWidth (const Handle(Prs3d_Drawer)& theDrawer, const Standard_Real theWidth) const;
Standard_EXPORT bool setWidth(const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Real theWidth) const;
Standard_EXPORT void setTransparency (const Handle(Prs3d_Drawer)& theDrawer, const Standard_Real theValue) const;
Standard_EXPORT void setTransparency(const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Real theValue) const;
Standard_EXPORT void setMaterial (const Handle(Prs3d_Drawer)& theDrawer, const Graphic3d_MaterialAspect& theMaterial, const Standard_Boolean theToKeepColor, const Standard_Boolean theToKeepTransp) const;
Standard_EXPORT void setMaterial(const Handle(Prs3d_Drawer)& theDrawer,
const Graphic3d_MaterialAspect& theMaterial,
const Standard_Boolean theToKeepColor,
const Standard_Boolean theToKeepTransp) const;
//! Replace aspects of already computed groups from drawer link by the new own value.
Standard_EXPORT void replaceWithNewOwnAspects();
public:
//! Compute HLR presentation for specified shape.
Standard_EXPORT static void computeHlrPresentation(const Handle(Graphic3d_Camera)& theProjector,
const Handle(Prs3d_Presentation)& thePrs,
@ -299,10 +332,10 @@ public:
const Handle(Prs3d_Drawer)& theDrawer);
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
protected:
TopoDS_Shape myshape; //!< shape to display
Bnd_Box myBB; //!< cached bounding box of the shape
gp_Pnt2d myUVOrigin; //!< UV origin vector for generating texture coordinates
@ -310,7 +343,6 @@ protected:
gp_Pnt2d myUVScale; //!< UV scale vector for generating texture coordinates
Standard_Real myInitAng;
Standard_Boolean myCompBB; //!< if TRUE, then bounding box should be recomputed
};
DEFINE_STANDARD_HANDLE(AIS_Shape, AIS_InteractiveObject)

View File

@ -14,7 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AIS_InteractiveObject.hxx>
#include <AIS_SignatureFilter.hxx>
#include <SelectMgr_EntityOwner.hxx>
@ -23,9 +22,11 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_SignatureFilter, AIS_TypeFilter)
AIS_SignatureFilter::AIS_SignatureFilter(const AIS_KindOfInteractive TheKind,
const Standard_Integer TheSignature):
AIS_TypeFilter(TheKind),
mySig(TheSignature){}
const Standard_Integer TheSignature)
: AIS_TypeFilter(TheKind),
mySig(TheSignature)
{
}
Standard_Boolean AIS_SignatureFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
{
@ -33,7 +34,5 @@ Standard_Boolean AIS_SignatureFilter::IsOk(const Handle(SelectMgr_EntityOwner)&
if (IO.IsNull())
return Standard_False;
return
(IO->Signature()==mySig &&
IO->Type()==myKind);
return (IO->Signature() == mySig && IO->Type() == myKind);
}

View File

@ -25,7 +25,6 @@
#include <AIS_KindOfInteractive.hxx>
class SelectMgr_EntityOwner;
class AIS_SignatureFilter;
DEFINE_STANDARD_HANDLE(AIS_SignatureFilter, AIS_TypeFilter)
@ -60,40 +59,23 @@ class AIS_SignatureFilter : public AIS_TypeFilter
{
public:
//! Initializes the signature filter, adding the signature
//! specification, aGivenSignature, to that for type,
//! aGivenKind, in AIS_TypeFilter.
Standard_EXPORT AIS_SignatureFilter(const AIS_KindOfInteractive aGivenKind, const Standard_Integer aGivenSignature);
Standard_EXPORT AIS_SignatureFilter(const AIS_KindOfInteractive aGivenKind,
const Standard_Integer aGivenSignature);
//! Returns False if the transient is not an AIS_InteractiveObject.
//! Returns False if the signature of InteractiveObject
//! is not the same as the stored one in the filter...
Standard_EXPORT Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
Standard_EXPORT Standard_Boolean
IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(AIS_SignatureFilter, AIS_TypeFilter)
protected:
private:
Standard_Integer mySig;
};
#endif // _AIS_SignatureFilter_HeaderFile

View File

@ -17,7 +17,6 @@
#ifndef _AIS_StatusOfDetection_HeaderFile
#define _AIS_StatusOfDetection_HeaderFile
enum AIS_StatusOfDetection
{
AIS_SOD_Error,

View File

@ -17,7 +17,6 @@
#ifndef _AIS_StatusOfPick_HeaderFile
#define _AIS_StatusOfPick_HeaderFile
enum AIS_StatusOfPick
{
AIS_SOP_Error,

View File

@ -34,10 +34,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_TextLabel, AIS_InteractiveObject)
//=======================================================================
//function : AIS_TextLabel
//purpose :
//=======================================================================
//=================================================================================================
AIS_TextLabel::AIS_TextLabel()
: myText("?"),
myHasOrientation3D(Standard_False),
@ -48,10 +46,8 @@ AIS_TextLabel::AIS_TextLabel()
myDrawer->SetDisplayMode(0);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetColor(const Quantity_Color& theColor)
{
hasOwnColor = Standard_True;
@ -60,10 +56,8 @@ void AIS_TextLabel::SetColor (const Quantity_Color& theColor)
SynchronizeAspects();
}
//=======================================================================
//function : SetTransparency
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetTransparency(const Standard_Real theValue)
{
Quantity_ColorRGBA aTextColor(myDrawer->TextAspect()->Aspect()->Color());
@ -78,28 +72,22 @@ void AIS_TextLabel::SetTransparency (const Standard_Real theValue)
SynchronizeAspects();
}
//=======================================================================
//function : SetText
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetText(const TCollection_ExtendedString& theText)
{
myText = theText;
}
//=======================================================================
//function : SetPosition
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetPosition(const gp_Pnt& thePosition)
{
myOrientation3D.SetLocation(thePosition);
}
//=======================================================================
//function : SetHJustification
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetHJustification(const Graphic3d_HorizontalTextAlignment theHJust)
{
myDrawer->TextAspect()->SetHorizontalJustification(theHJust);
@ -114,163 +102,128 @@ void AIS_TextLabel::SetVJustification (const Graphic3d_VerticalTextAlignment the
myDrawer->TextAspect()->SetVerticalJustification(theVJust);
}
//=======================================================================
//function : SetAngle
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetAngle(const Standard_Real theAngle)
{
myDrawer->TextAspect()->Aspect()->SetTextAngle(theAngle * 180.0 / M_PI);
}
//=======================================================================
//function : SetZoom
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetZoomable(const Standard_Boolean theIsZoomable)
{
myDrawer->TextAspect()->Aspect()->SetTextZoomable(theIsZoomable == Standard_True);
}
//=======================================================================
//function : SetHeight
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetHeight(const Standard_Real theHeight)
{
myDrawer->TextAspect()->SetHeight(theHeight);
}
//=======================================================================
//function : SetAngle
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetFontAspect(const Font_FontAspect theFontAspect)
{
myDrawer->TextAspect()->Aspect()->SetTextFontAspect(theFontAspect);
}
//=======================================================================
//function : SetFont
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetFont(Standard_CString theFont)
{
myDrawer->TextAspect()->SetFont(theFont);
}
//=======================================================================
//function : SetOrientation3D
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetOrientation3D(const gp_Ax2& theOrientation)
{
myHasOrientation3D = Standard_True;
myOrientation3D = theOrientation;
}
//=======================================================================
//function : UnsetOrientation3D
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::UnsetOrientation3D()
{
myHasOrientation3D = Standard_False;
}
//=======================================================================
//function : Position
//purpose :
//=======================================================================
//=================================================================================================
const gp_Pnt& AIS_TextLabel::Position() const
{
return myOrientation3D.Location();
}
//=======================================================================
//function : FontName
//purpose :
//=======================================================================
//=================================================================================================
const TCollection_AsciiString& AIS_TextLabel::FontName() const
{
return myDrawer->TextAspect()->Aspect()->Font();
}
//=======================================================================
//function : FontAspect
//purpose :
//=======================================================================
//=================================================================================================
Font_FontAspect AIS_TextLabel::FontAspect() const
{
return myDrawer->TextAspect()->Aspect()->GetTextFontAspect();
}
//=======================================================================
//function : Orientation3D
//purpose :
//=======================================================================
//=================================================================================================
const gp_Ax2& AIS_TextLabel::Orientation3D() const
{
return myOrientation3D;
}
//=======================================================================
//function : HasOrientation3D
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_TextLabel::HasOrientation3D() const
{
return myHasOrientation3D;
}
//=======================================================================
//function : SetFlipping
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetFlipping(const Standard_Boolean theIsFlipping)
{
myHasFlipping = theIsFlipping;
}
//=======================================================================
//function : HasFlipping
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_TextLabel::HasFlipping() const
{
return myHasFlipping;
}
//=======================================================================
//function : SetDisplayType
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetDisplayType(const Aspect_TypeOfDisplayText theDisplayType)
{
myDrawer->TextAspect()->Aspect()->SetDisplayType(theDisplayType);
}
//=======================================================================
//function : SetColorSubTitle
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::SetColorSubTitle(const Quantity_Color& theColor)
{
myDrawer->TextAspect()->Aspect()->SetColorSubTitle(theColor);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
switch (theMode)
{
case 0:
{
case 0: {
Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
gp_Pnt aPosition = Position();
@ -281,12 +234,12 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager)& ,
SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_ZoomPers, aPosition));
aPosition = gp::Origin();
}
else if (isTextZoomable
|| TransformPersistence().IsNull()
else if (isTextZoomable || TransformPersistence().IsNull()
|| TransformPersistence()->Mode() != Graphic3d_TMF_2d)
{
Handle(Graphic3d_TransformPers) aTrsfPers =
new Graphic3d_TransformPers (isTextZoomable ? Graphic3d_TMF_RotatePers : Graphic3d_TMF_ZoomRotatePers, aPosition);
Handle(Graphic3d_TransformPers) aTrsfPers = new Graphic3d_TransformPers(
isTextZoomable ? Graphic3d_TMF_RotatePers : Graphic3d_TMF_ZoomRotatePers,
aPosition);
SetTransformPersistence(aTrsfPers);
aPosition = gp::Origin();
}
@ -299,7 +252,9 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager)& ,
{
if (myHasFlipping)
{
gp_Ax2 aFlippingAxes (aCenterOfLabel, myOrientation3D.Direction(), myOrientation3D.XDirection());
gp_Ax2 aFlippingAxes(aCenterOfLabel,
myOrientation3D.Direction(),
myOrientation3D.XDirection());
thePrs->CurrentGroup()->SetFlippingOptions(Standard_True, aFlippingAxes);
}
gp_Ax2 anOrientation = myOrientation3D;
@ -343,17 +298,14 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TextLabel::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
switch (theMode)
{
case 0:
{
case 0: {
Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this, 10);
gp_Pnt aPosition = Position();
@ -367,7 +319,8 @@ void AIS_TextLabel::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
if (!calculateLabelParams(aPosition, aCenterOfLabel, aWidth, aHeight))
{
Handle(Select3D_SensitivePoint) aTextSensitive = new Select3D_SensitivePoint (anEntityOwner, aPosition);
Handle(Select3D_SensitivePoint) aTextSensitive =
new Select3D_SensitivePoint(anEntityOwner, aPosition);
theSelection->Add(aTextSensitive);
break;
}
@ -393,10 +346,8 @@ void AIS_TextLabel::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
}
}
//=======================================================================
//function : calculateLabelParams
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_TextLabel::calculateLabelParams(const gp_Pnt& thePosition,
gp_Pnt& theCenterOfLabel,
Standard_Real& theWidth,
@ -404,7 +355,8 @@ Standard_Boolean AIS_TextLabel::calculateLabelParams (const gp_Pnt& thePosition,
{
// Get width and height of text
Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
const Graphic3d_RenderingParams& aRendParams = GetContext()->CurrentViewer()->DefaultRenderingParams();
const Graphic3d_RenderingParams& aRendParams =
GetContext()->CurrentViewer()->DefaultRenderingParams();
Font_FTFontParams aFontParams;
aFontParams.PointSize = (unsigned int)anAsp->Height();
aFontParams.Resolution = aRendParams.Resolution;
@ -419,7 +371,8 @@ Standard_Boolean AIS_TextLabel::calculateLabelParams (const gp_Pnt& thePosition,
}
const NCollection_String aText(myText.ToExtString());
Font_Rect aBndBox = aFont->BoundingBox (aText, anAsp->HorizontalJustification(), anAsp->VerticalJustification());
Font_Rect aBndBox =
aFont->BoundingBox(aText, anAsp->HorizontalJustification(), anAsp->VerticalJustification());
theWidth = Abs(aBndBox.Width());
theHeight = Abs(aBndBox.Height());
@ -444,10 +397,8 @@ Standard_Boolean AIS_TextLabel::calculateLabelParams (const gp_Pnt& thePosition,
return Standard_True;
}
//=======================================================================
//function : calculateLabelTrsf
//purpose :
//=======================================================================
//=================================================================================================
gp_Trsf AIS_TextLabel::calculateLabelTrsf(const gp_Pnt& thePosition, gp_Pnt& theCenterOfLabel) const
{
const Standard_Real anAngle = myDrawer->TextAspect()->Aspect()->TextAngle() * M_PI / 180.0;

View File

@ -30,12 +30,14 @@ class Font_TextFormatter;
class AIS_TextLabel : public AIS_InteractiveObject
{
public:
//! Default constructor
Standard_EXPORT AIS_TextLabel();
//! Return TRUE for supported display mode.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{
return theMode == 0;
}
//! Setup color of entire text.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
@ -108,7 +110,10 @@ public:
Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; }
//! Set flag if text uses position as point of attach
void SetOwnAnchorPoint (const Standard_Boolean theOwnAnchorPoint) { myHasOwnAnchorPoint = theOwnAnchorPoint; }
void SetOwnAnchorPoint(const Standard_Boolean theOwnAnchorPoint)
{
myHasOwnAnchorPoint = theOwnAnchorPoint;
}
//! Define the display type of the text.
//!
@ -123,14 +128,17 @@ public:
//! and the colour of backgroubd for the TODT_DEKALE TextDisplayType.
Standard_EXPORT void SetColorSubTitle(const Quantity_Color& theColor);
//! Returns text presentation formatter; NULL by default, which means standard text formatter will be used.
//! Returns text presentation formatter; NULL by default, which means standard text formatter will
//! be used.
const Handle(Font_TextFormatter)& TextFormatter() const { return myFormatter; }
//! Setup text formatter for presentation. It's empty by default.
void SetTextFormatter (const Handle(Font_TextFormatter)& theFormatter) { myFormatter = theFormatter; }
void SetTextFormatter(const Handle(Font_TextFormatter)& theFormatter)
{
myFormatter = theFormatter;
}
protected:
//! Compute
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& theprsMgr,
const Handle(Prs3d_Presentation)& thePrs,
@ -151,7 +159,6 @@ protected:
gp_Pnt& theCenterOfLabel) const;
protected:
Handle(Font_TextFormatter) myFormatter;
TCollection_ExtendedString myText;
@ -161,10 +168,8 @@ protected:
Standard_Boolean myHasFlipping;
public:
//! CASCADE RTTI
DEFINE_STANDARD_RTTIEXT(AIS_TextLabel, AIS_InteractiveObject)
};
DEFINE_STANDARD_HANDLE(AIS_TextLabel, AIS_InteractiveObject)

View File

@ -35,13 +35,10 @@
#include <StdPrs_ToolTriangulatedShape.hxx>
#include <StdPrs_WFShape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_TexturedShape, AIS_Shape)
//=======================================================================
//function : AIS_TexturedShape
//purpose :
//=======================================================================
//=================================================================================================
AIS_TexturedShape::AIS_TexturedShape(const TopoDS_Shape& theShape)
: AIS_Shape(theShape),
myPredefTexture(Graphic3d_NameOfTexture2D(0)),
@ -54,10 +51,8 @@ AIS_TexturedShape::AIS_TexturedShape (const TopoDS_Shape& theShape)
{
}
//=======================================================================
//function : SetTextureFileName
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::SetTextureFileName(const TCollection_AsciiString& theTextureFileName)
{
myTexturePixMap.Nullify();
@ -65,8 +60,7 @@ void AIS_TexturedShape::SetTextureFileName (const TCollection_AsciiString& theTe
if (theTextureFileName.IsIntegerValue())
{
const Standard_Integer aValue = theTextureFileName.IntegerValue();
if (aValue < Graphic3d_Texture2D::NumberOfTextures()
&& aValue >= 0)
if (aValue < Graphic3d_Texture2D::NumberOfTextures() && aValue >= 0)
{
myPredefTexture = Graphic3d_NameOfTexture2D(aValue);
}
@ -85,10 +79,8 @@ void AIS_TexturedShape::SetTextureFileName (const TCollection_AsciiString& theTe
}
}
//=======================================================================
//function : SetTexturePixMap
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::SetTexturePixMap(const Handle(Image_PixMap)& theTexturePixMap)
{
myTextureFile = "";
@ -96,10 +88,7 @@ void AIS_TexturedShape::SetTexturePixMap (const Handle(Image_PixMap)& theTexture
myTexturePixMap = theTexturePixMap;
}
//=======================================================================
//function : SetTextureRepeat
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::SetTextureRepeat(const Standard_Boolean theToRepeat,
const Standard_Real theURepeat,
@ -109,30 +98,21 @@ void AIS_TexturedShape::SetTextureRepeat (const Standard_Boolean theToRepeat,
myUVRepeat.SetCoord(theURepeat, theVRepeat);
}
//=======================================================================
//function : SetTextureMapOn
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::SetTextureMapOn()
{
myToMapTexture = Standard_True;
}
//=======================================================================
//function : SetTextureMapOff
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::SetTextureMapOff()
{
myToMapTexture = Standard_False;
}
//=======================================================================
//function : SetTextureOrigin
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::SetTextureOrigin(const Standard_Boolean theToSetTextureOrigin,
const Standard_Real theUOrigin,
@ -142,10 +122,7 @@ void AIS_TexturedShape::SetTextureOrigin (const Standard_Boolean theToSetTexture
myUVOrigin.SetCoord(theUOrigin, theVOrigin);
}
//=======================================================================
//function : SetTextureScale
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::SetTextureScale(const Standard_Boolean theToSetTextureScale,
const Standard_Real theScaleU,
@ -155,40 +132,28 @@ void AIS_TexturedShape::SetTextureScale (const Standard_Boolean theToSetTextureS
myUVScale.SetCoord(theScaleU, theScaleV);
}
//=======================================================================
//function : ShowTriangles
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::ShowTriangles(const Standard_Boolean theToShowTriangles)
{
myToShowTriangles = theToShowTriangles;
}
//=======================================================================
//function : EnableTextureModulate
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::EnableTextureModulate()
{
myModulate = Standard_True;
}
//=======================================================================
//function : DisableTextureModulate
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::DisableTextureModulate()
{
myModulate = Standard_False;
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::SetColor(const Quantity_Color& theColor)
{
@ -203,20 +168,14 @@ void AIS_TexturedShape::SetColor (const Quantity_Color& theColor)
}
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::UnsetColor()
{
AIS_Shape::UnsetColor();
}
//=======================================================================
//function : SetMaterial
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::SetMaterial(const Graphic3d_MaterialAspect& theMat)
{
@ -230,10 +189,8 @@ void AIS_TexturedShape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
}
}
//=======================================================================
//function : UnsetMaterial
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::UnsetMaterial()
{
AIS_Shape::UnsetMaterial();
@ -246,20 +203,14 @@ void AIS_TexturedShape::UnsetMaterial()
}
}
//=======================================================================
//function : UpdateAttributes
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::UpdateAttributes()
{
updateAttributes(Presentation());
}
//=======================================================================
//function : updateAttributes
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::updateAttributes(const Handle(Prs3d_Presentation)& thePrs)
{
@ -307,7 +258,8 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP
}
else
{
Message::SendFail (TCollection_AsciiString ("Error: texture can not be loaded ") + aTextureDesc);
Message::SendFail(TCollection_AsciiString("Error: texture can not be loaded ")
+ aTextureDesc);
}
}
@ -331,29 +283,26 @@ void AIS_TexturedShape::updateAttributes (const Handle(Prs3d_Presentation)& theP
}
// Go through all groups to change fill aspect for all primitives
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (thePrs->Groups()); aGroupIt.More(); aGroupIt.Next())
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt(thePrs->Groups()); aGroupIt.More();
aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
aGroup->SetGroupPrimitivesAspect(myAspect);
}
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_TexturedShape::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
if (myshape.IsNull()
|| (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0))
if (myshape.IsNull() || (myshape.ShapeType() == TopAbs_COMPOUND && myshape.NbChildren() == 0))
{
return;
}
if (myshape.ShapeType() >= TopAbs_WIRE
&& myshape.ShapeType() <= TopAbs_VERTEX)
if (myshape.ShapeType() >= TopAbs_WIRE && myshape.ShapeType() <= TopAbs_VERTEX)
{
// TopAbs_WIRE -> 7, TopAbs_EDGE -> 8, TopAbs_VERTEX -> 9 (Graphic3d_DisplayPriority_Highlight)
const Standard_Integer aPrior = (Standard_Integer)Graphic3d_DisplayPriority_Above1
@ -369,8 +318,7 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager)& ,
switch (theMode)
{
case AIS_WireFrame:
{
case AIS_WireFrame: {
StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange(myshape, myDrawer, Standard_True);
StdPrs_WFShape::Add(thePrs, myshape, myDrawer);
break;
@ -399,7 +347,9 @@ void AIS_TexturedShape::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
else
{
StdPrs_ShadedShape::Add (thePrs, myshape, myDrawer,
StdPrs_ShadedShape::Add(thePrs,
myshape,
myDrawer,
Standard_True,
myIsCustomOrigin ? myUVOrigin : gp_Pnt2d(0.0, 0.0),
myUVRepeat,

View File

@ -30,8 +30,8 @@ class Graphic3d_AspectFillArea3d;
class Graphic3d_Texture2D;
//! This class allows to map textures on shapes.
//! Presentations modes AIS_WireFrame (0) and AIS_Shaded (1) behave in the same manner as in AIS_Shape,
//! whilst new modes 2 (bounding box) and 3 (texture mapping) extends it functionality.
//! Presentations modes AIS_WireFrame (0) and AIS_Shaded (1) behave in the same manner as in
//! AIS_Shape, whilst new modes 2 (bounding box) and 3 (texture mapping) extends it functionality.
//!
//! The texture itself is parametrized in (0,1)x(0,1).
//! Each face of a shape located in UV space is provided with these parameters:
@ -49,19 +49,21 @@ class AIS_TexturedShape : public AIS_Shape
{
public: //! @name main methods
//! Initializes the textured shape.
Standard_EXPORT AIS_TexturedShape(const TopoDS_Shape& theShape);
//! Sets the texture source. <theTextureFileName> can specify path to texture image or one of the standard predefined textures.
//! The accepted file types are those used in Image_AlienPixMap with extensions such as rgb, png, jpg and more.
//! To specify the standard predefined texture, the <theTextureFileName> should contain integer - the Graphic3d_NameOfTexture2D enumeration index.
//! Sets the texture source. <theTextureFileName> can specify path to texture image or one of the
//! standard predefined textures. The accepted file types are those used in Image_AlienPixMap with
//! extensions such as rgb, png, jpg and more. To specify the standard predefined texture, the
//! <theTextureFileName> should contain integer - the Graphic3d_NameOfTexture2D enumeration index.
//! Setting texture source using this method resets the source pixmap (if was set previously).
Standard_EXPORT virtual void SetTextureFileName (const TCollection_AsciiString& theTextureFileName);
Standard_EXPORT virtual void SetTextureFileName(
const TCollection_AsciiString& theTextureFileName);
//! Sets the texture source. <theTexturePixMap> specifies image data.
//! Please note that the data should be in Bottom-Up order, the flag of Image_PixMap::IsTopDown() will be ignored by graphic driver.
//! Setting texture source using this method resets the source by filename (if was set previously).
//! Please note that the data should be in Bottom-Up order, the flag of Image_PixMap::IsTopDown()
//! will be ignored by graphic driver. Setting texture source using this method resets the source
//! by filename (if was set previously).
Standard_EXPORT virtual void SetTexturePixMap(const Handle(Image_PixMap)& theTexturePixMap);
//! @return flag to control texture mapping (for presentation mode 3)
@ -80,10 +82,10 @@ public: //! @name main methods
const Handle(Image_PixMap)& TexturePixMap() const { return myTexturePixMap; }
public: //! @name methods to alter texture mapping properties
//! Use this method to display the textured shape without recomputing the whole presentation.
//! Use this method when ONLY the texture content has been changed.
//! If other parameters (ie: scale factors, texture origin, texture repeat...) have changed, the whole presentation has to be recomputed:
//! If other parameters (ie: scale factors, texture origin, texture repeat...) have changed, the
//! whole presentation has to be recomputed:
//! @code
//! if (myShape->DisplayMode() == 3)
//! {
@ -104,7 +106,8 @@ public: //! @name methods to alter texture mapping properties
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
//! Sets the material aspect.
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
Standard_EXPORT virtual void SetMaterial(const Graphic3d_MaterialAspect& theAspect)
Standard_OVERRIDE;
//! Removes settings for material aspect.
Standard_EXPORT virtual void UnsetMaterial() Standard_OVERRIDE;
@ -124,9 +127,10 @@ public: //! @name methods to alter texture mapping properties
//! @return texture repeat V value
Standard_Real VRepeat() const { return myUVRepeat.Y(); }
//! Sets the number of occurrences of the texture on each face. The texture itself is parameterized in (0,1) by (0,1).
//! Each face of the shape to be textured is parameterized in UV space (Umin,Umax) by (Vmin,Vmax).
//! If RepeatYN is set to false, texture coordinates are clamped in the range (0,1)x(0,1) of the face.
//! Sets the number of occurrences of the texture on each face. The texture itself is
//! parameterized in (0,1) by (0,1). Each face of the shape to be textured is parameterized in UV
//! space (Umin,Umax) by (Vmin,Vmax). If RepeatYN is set to false, texture coordinates are clamped
//! in the range (0,1)x(0,1) of the face.
Standard_EXPORT void SetTextureRepeat(const Standard_Boolean theToRepeat,
const Standard_Real theURepeat = 1.0,
const Standard_Real theVRepeat = 1.0);
@ -140,7 +144,8 @@ public: //! @name methods to alter texture mapping properties
//! @return texture origin V position (0.0 by default)
Standard_Real TextureVOrigin() const { return myUVOrigin.Y(); }
//! Use this method to change the origin of the texture. The texel (0,0) will be mapped to the surface (UOrigin,VOrigin)
//! Use this method to change the origin of the texture. The texel (0,0) will be mapped to the
//! surface (UOrigin,VOrigin)
Standard_EXPORT void SetTextureOrigin(const Standard_Boolean theToSetTextureOrigin,
const Standard_Real theUOrigin = 0.0,
const Standard_Real theVOrigin = 0.0);
@ -172,10 +177,12 @@ public: //! @name methods to alter texture mapping properties
Standard_Boolean TextureModulate() const { return myModulate; }
//! Return true if specified display mode is supported (extends AIS_Shape with Display Mode 3).
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode >= 0 && theMode <= 3; }
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{
return theMode >= 0 && theMode <= 3;
}
protected: //! @name overridden methods
//! Compute presentation with texture mapping support.
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
@ -184,18 +191,15 @@ protected: //! @name overridden methods
Standard_EXPORT void updateAttributes(const Handle(Prs3d_Presentation)& thePrs);
protected: //! @name presentation fields
Handle(Graphic3d_Texture2D) myTexture;
Handle(Graphic3d_AspectFillArea3d) myAspect;
protected: //! @name texture source fields
Handle(Image_PixMap) myTexturePixMap;
TCollection_AsciiString myTextureFile;
Graphic3d_NameOfTexture2D myPredefTexture;
protected: //! @name texture mapping properties
Standard_Boolean myToMapTexture;
Standard_Boolean myModulate;
Standard_Boolean myIsCustomOrigin;
@ -204,9 +208,7 @@ protected: //! @name texture mapping properties
Standard_Boolean myToShowTriangles;
public:
DEFINE_STANDARD_RTTIEXT(AIS_TexturedShape, AIS_Shape)
};
DEFINE_STANDARD_HANDLE(AIS_TexturedShape, AIS_Shape)

View File

@ -24,7 +24,6 @@
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
IMPLEMENT_STANDARD_RTTIEXT(AIS_Triangulation, AIS_InteractiveObject)
AIS_Triangulation::AIS_Triangulation(const Handle(Poly_Triangulation)& Triangulation)
@ -35,10 +34,8 @@ AIS_Triangulation::AIS_Triangulation(const Handle(Poly_Triangulation)& Triangula
myFlagColor = 0;
}
//=======================================================================
//function : SetTransparency
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Triangulation::SetTransparency(const Standard_Real theValue)
{
if (!myDrawer->HasOwnShadingAspect())
@ -57,10 +54,8 @@ void AIS_Triangulation::SetTransparency (const Standard_Real theValue)
updatePresentation();
}
//=======================================================================
//function : UnsetTransparency
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Triangulation::UnsetTransparency()
{
myDrawer->SetTransparency(0.0f);
@ -76,10 +71,8 @@ void AIS_Triangulation::UnsetTransparency()
updatePresentation();
}
//=======================================================================
//function : updatePresentation
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Triangulation::updatePresentation()
{
if (HasVertexColors())
@ -99,7 +92,8 @@ void AIS_Triangulation::updatePresentation()
}
const Handle(Prs3d_Presentation)& aPrs = aPrsIter.Value();
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt(aPrs->Groups()); aGroupIt.More();
aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
aGroup->SetGroupPrimitivesAspect(anAreaAsp);
@ -108,10 +102,8 @@ void AIS_Triangulation::updatePresentation()
}
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
@ -124,8 +116,11 @@ void AIS_Triangulation::Compute (const Handle(PrsMgr_PresentationManager)& ,
Standard_Boolean hasVNormals = myTriangulation->HasNormals();
Standard_Boolean hasVColors = HasVertexColors();
Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles (myNbNodes, myNbTriangles * 3,
hasVNormals, hasVColors, Standard_False);
Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles(myNbNodes,
myNbTriangles * 3,
hasVNormals,
hasVColors,
Standard_False);
Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
Handle(Graphic3d_AspectFillArea3d) anAspect = myDrawer->ShadingAspect()->Aspect();
@ -138,7 +133,8 @@ void AIS_Triangulation::Compute (const Handle(PrsMgr_PresentationManager)& ,
const TColStd_Array1OfInteger& colors = myColor->Array1();
for (Standard_Integer aNodeIter = 1; aNodeIter <= myTriangulation->NbNodes(); ++aNodeIter)
{
anArray->AddVertex (myTriangulation->Node (aNodeIter), attenuateColor (colors[aNodeIter], anAmbient));
anArray->AddVertex(myTriangulation->Node(aNodeIter),
attenuateColor(colors[aNodeIter], anAmbient));
myTriangulation->Normal(aNodeIter, aNormal);
anArray->SetVertexNormal(aNodeIter, aNormal.x(), aNormal.y(), aNormal.z());
}
@ -160,7 +156,8 @@ void AIS_Triangulation::Compute (const Handle(PrsMgr_PresentationManager)& ,
const TColStd_Array1OfInteger& colors = myColor->Array1();
for (Standard_Integer aNodeIter = 1; aNodeIter <= myTriangulation->NbNodes(); ++aNodeIter)
{
anArray->AddVertex (myTriangulation->Node (aNodeIter), attenuateColor (colors[aNodeIter], anAmbient));
anArray->AddVertex(myTriangulation->Node(aNodeIter),
attenuateColor(colors[aNodeIter], anAmbient));
}
}
else // !hasVColors
@ -184,14 +181,11 @@ void AIS_Triangulation::Compute (const Handle(PrsMgr_PresentationManager)& ,
aGroup->AddPrimitiveArray(anArray);
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Triangulation::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
const Standard_Integer /*aMode*/)
{
}
//=======================================================================
@ -218,35 +212,32 @@ Handle(TColStd_HArray1OfInteger) AIS_Triangulation::GetColors() const
return myColor;
}
//=================================================================================================
//=======================================================================
//function : SetTriangulation
//purpose :
//=======================================================================
void AIS_Triangulation::SetTriangulation(const Handle(Poly_Triangulation)& aTriangulation)
{
myTriangulation = aTriangulation;
}
//=======================================================================
//function : GetTriangulation
//purpose :
//=======================================================================
Handle(Poly_Triangulation) AIS_Triangulation::GetTriangulation() const{
//=================================================================================================
Handle(Poly_Triangulation) AIS_Triangulation::GetTriangulation() const
{
return myTriangulation;
}
//=======================================================================
//function : AttenuateColor
//purpose :
//=======================================================================
//=================================================================================================
Graphic3d_Vec4ub AIS_Triangulation::attenuateColor(const Standard_Integer theColor,
const Standard_Real theComposition)
{
const Standard_Byte* anRgbx = reinterpret_cast<const Standard_Byte*>(&theColor);
// If IsTranparent() is false alpha value will be ignored anyway.
Standard_Byte anAlpha = IsTransparent() ? static_cast<Standard_Byte> (255.0 - myDrawer->ShadingAspect()->Aspect()->FrontMaterial().Transparency() * 255.0)
Standard_Byte anAlpha =
IsTransparent()
? static_cast<Standard_Byte>(
255.0 - myDrawer->ShadingAspect()->Aspect()->FrontMaterial().Transparency() * 255.0)
: 255;
return Graphic3d_Vec4ub((Standard_Byte)(theComposition * anRgbx[0]),

View File

@ -31,26 +31,20 @@ class AIS_Triangulation : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_Triangulation, AIS_InteractiveObject)
public:
//! Constructs the Triangulation display object
Standard_EXPORT AIS_Triangulation(const Handle(Poly_Triangulation)& aTriangulation);
//! Set the color for each node.
//! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
//! Order of color components is essential for further usage by OpenGL
Standard_EXPORT void SetColors(const Handle(TColStd_HArray1OfInteger)& aColor);
//! Get the color for each node.
//! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetColors() const;
//! Returns true if triangulation has vertex colors.
Standard_Boolean HasVertexColors() const
{
return (myFlagColor == 1);
}
Standard_Boolean HasVertexColors() const { return (myFlagColor == 1); }
Standard_EXPORT void SetTriangulation(const Handle(Poly_Triangulation)& aTriangulation);
@ -64,11 +58,9 @@ public:
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
protected:
Standard_EXPORT void updatePresentation();
private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
@ -78,17 +70,18 @@ private:
//! Attenuates 32-bit color by a given attenuation factor (0...1):
//! aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
//! All color components are multiplied by aComponent, the result is then packed again as 32-bit integer.
//! Color attenuation is applied to the vertex colors in order to have correct visual result
//! after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and flat.
Standard_EXPORT Graphic3d_Vec4ub attenuateColor (const Standard_Integer theColor, const Standard_Real theComponent);
//! All color components are multiplied by aComponent, the result is then packed again as 32-bit
//! integer. Color attenuation is applied to the vertex colors in order to have correct visual
//! result after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and
//! flat.
Standard_EXPORT Graphic3d_Vec4ub attenuateColor(const Standard_Integer theColor,
const Standard_Real theComponent);
Handle(Poly_Triangulation) myTriangulation;
Handle(TColStd_HArray1OfInteger) myColor;
Standard_Integer myFlagColor;
Standard_Integer myNbNodes;
Standard_Integer myNbTriangles;
};
#endif // _AIS_Triangulation_HeaderFile

View File

@ -46,10 +46,8 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject)
//=======================================================================
//function : AIS_Trihedron
//purpose :
//=======================================================================
//=================================================================================================
AIS_Trihedron::AIS_Trihedron(const Handle(Geom_Axis2Placement)& theComponent)
: myComponent(theComponent),
myTrihDispMode(Prs3d_DM_WireFrame),
@ -81,20 +79,16 @@ AIS_Trihedron::AIS_Trihedron (const Handle(Geom_Axis2Placement)& theComponent)
myLabels[Prs3d_DatumParts_ZAxis] = "Z";
}
//=======================================================================
//function : SetComponent
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::SetComponent(const Handle(Geom_Axis2Placement)& theComponent)
{
myComponent = theComponent;
SetToUpdate();
}
//=======================================================================
//function : setOwnDatumAspect
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::setOwnDatumAspect()
{
if (myDrawer->HasOwnDatumAspect())
@ -110,10 +104,8 @@ void AIS_Trihedron::setOwnDatumAspect()
}
}
//=======================================================================
//function : SetSize
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::SetSize(const Standard_Real theValue)
{
myHasOwnSize = Standard_True;
@ -125,10 +117,8 @@ void AIS_Trihedron::SetSize(const Standard_Real theValue)
UpdateSelection();
}
//=======================================================================
//function : UnsetSize
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::UnsetSize()
{
if (!myHasOwnSize)
@ -139,9 +129,8 @@ void AIS_Trihedron::UnsetSize()
myHasOwnSize = Standard_False;
if (hasOwnColor)
{
const Handle(Prs3d_DatumAspect) DA = myDrawer->HasLink()
? myDrawer->Link()->DatumAspect()
: new Prs3d_DatumAspect();
const Handle(Prs3d_DatumAspect) DA =
myDrawer->HasLink() ? myDrawer->Link()->DatumAspect() : new Prs3d_DatumAspect();
myDrawer->DatumAspect()->SetAxisLength(DA->AxisLength(Prs3d_DatumParts_XAxis),
DA->AxisLength(Prs3d_DatumParts_YAxis),
DA->AxisLength(Prs3d_DatumParts_ZAxis));
@ -153,19 +142,15 @@ void AIS_Trihedron::UnsetSize()
UpdateSelection();
}
//=======================================================================
//function : Size
//purpose :
//=======================================================================
//=================================================================================================
Standard_Real AIS_Trihedron::Size() const
{
return myDrawer->DatumAspect()->AxisLength(Prs3d_DatumParts_XAxis);
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
@ -178,26 +163,29 @@ void AIS_Trihedron::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr
thePrs->SetInfiniteState(Standard_True);
gp_Ax2 anAxis(myComponent->Ax2());
updatePrimitives (myDrawer->DatumAspect(), myTrihDispMode, anAxis.Location(),
anAxis.XDirection(), anAxis.YDirection(), anAxis.Direction());
updatePrimitives(myDrawer->DatumAspect(),
myTrihDispMode,
anAxis.Location(),
anAxis.XDirection(),
anAxis.YDirection(),
anAxis.Direction());
computePresentation(thePrsMgr, thePrs);
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect();
switch (theMode)
{
case AIS_TrihedronSelectionMode_EntireObject:
{
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this, mySelectionPriority[Prs3d_DatumParts_None]);
case AIS_TrihedronSelectionMode_EntireObject: {
Handle(SelectMgr_EntityOwner) anOwner =
new SelectMgr_EntityOwner(this, mySelectionPriority[Prs3d_DatumParts_None]);
const bool isShadingMode = myTrihDispMode == Prs3d_DM_Shaded;
for (int aPartIter = isShadingMode ? Prs3d_DatumParts_Origin : Prs3d_DatumParts_XAxis; aPartIter <= Prs3d_DatumParts_ZAxis;
for (int aPartIter = isShadingMode ? Prs3d_DatumParts_Origin : Prs3d_DatumParts_XAxis;
aPartIter <= Prs3d_DatumParts_ZAxis;
++aPartIter)
{
const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPartIter;
@ -209,19 +197,18 @@ void AIS_Trihedron::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
}
break;
}
case AIS_TrihedronSelectionMode_Origin:
{
case AIS_TrihedronSelectionMode_Origin: {
const Prs3d_DatumParts aPart = Prs3d_DatumParts_Origin;
if (anAspect->DrawDatumPart(aPart))
{
Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart, mySelectionPriority[aPart]);
Handle(SelectMgr_EntityOwner) anOwner =
new AIS_TrihedronOwner(this, aPart, mySelectionPriority[aPart]);
Handle(Graphic3d_ArrayOfPrimitives) aPrimitives = arrayOfPrimitives(aPart);
theSelection->Add(createSensitiveEntity(aPart, anOwner));
}
break;
}
case AIS_TrihedronSelectionMode_Axes:
{
case AIS_TrihedronSelectionMode_Axes: {
for (int aPartIter = Prs3d_DatumParts_XAxis; aPartIter <= Prs3d_DatumParts_ZAxis; ++aPartIter)
{
const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPartIter;
@ -229,23 +216,25 @@ void AIS_Trihedron::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
{
continue;
}
Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart, mySelectionPriority[aPart]);
Handle(SelectMgr_EntityOwner) anOwner =
new AIS_TrihedronOwner(this, aPart, mySelectionPriority[aPart]);
theSelection->Add(createSensitiveEntity(aPart, anOwner));
}
break;
}
case AIS_TrihedronSelectionMode_MainPlanes:
{
case AIS_TrihedronSelectionMode_MainPlanes: {
// create owner for each trihedron plane
{
for (int aPartIter = Prs3d_DatumParts_XOYAxis; aPartIter <= Prs3d_DatumParts_XOZAxis; ++aPartIter)
for (int aPartIter = Prs3d_DatumParts_XOYAxis; aPartIter <= Prs3d_DatumParts_XOZAxis;
++aPartIter)
{
const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPartIter;
if (!anAspect->DrawDatumPart(aPart))
{
continue;
}
Handle(SelectMgr_EntityOwner) anOwner = new AIS_TrihedronOwner (this, aPart, mySelectionPriority[aPart]);
Handle(SelectMgr_EntityOwner) anOwner =
new AIS_TrihedronOwner(this, aPart, mySelectionPriority[aPart]);
theSelection->Add(createSensitiveEntity(aPart, anOwner));
}
}
@ -254,10 +243,8 @@ void AIS_Trihedron::ComputeSelection (const Handle(SelectMgr_Selection)& theSele
}
}
//=======================================================================
//function : HilightOwnerWithColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner)
@ -305,7 +292,8 @@ void AIS_Trihedron::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManag
}
aGroup->AddPrimitiveArray(arrayOfPrimitives(aPart));
const Graphic3d_ZLayerId aLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : myDrawer->ZLayer();
const Graphic3d_ZLayerId aLayer =
theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : myDrawer->ZLayer();
if (aPresentation->GetZLayer() != aLayer)
{
aPresentation->SetZLayer(aLayer);
@ -315,10 +303,8 @@ void AIS_Trihedron::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManag
thePM->AddToImmediateList(aPresentation);
}
//========================================================================
//function : HilightSelected
//purpose :
//========================================================================
//=================================================================================================
void AIS_Trihedron::HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM,
const SelectMgr_SequenceOfOwner& theOwners)
{
@ -329,8 +315,10 @@ void AIS_Trihedron::HilightSelected (const Handle(PrsMgr_PresentationManager)& t
const bool isShadingMode = myTrihDispMode == Prs3d_DM_Shaded;
Handle(Prs3d_Drawer) anAspect = !myHilightDrawer.IsNull() ? myHilightDrawer : GetContext()->SelectionStyle();
for (SelectMgr_SequenceOfOwner::Iterator anIterator (theOwners); anIterator.More(); anIterator.Next())
Handle(Prs3d_Drawer) anAspect =
!myHilightDrawer.IsNull() ? myHilightDrawer : GetContext()->SelectionStyle();
for (SelectMgr_SequenceOfOwner::Iterator anIterator(theOwners); anIterator.More();
anIterator.Next())
{
const Handle(SelectMgr_EntityOwner)& anOwner = anIterator.Value();
Handle(AIS_TrihedronOwner) aTrihedronOwner = Handle(AIS_TrihedronOwner)::DownCast(anOwner);
@ -341,15 +329,13 @@ void AIS_Trihedron::HilightSelected (const Handle(PrsMgr_PresentationManager)& t
}
const Prs3d_DatumParts aPart = aTrihedronOwner->DatumPart();
if (myPartToGroup[aPart].IsNull()
|| mySelectedParts.Contains (aPart))
if (myPartToGroup[aPart].IsNull() || mySelectedParts.Contains(aPart))
{
continue;
}
const Handle(Graphic3d_Group)& aGroup = myPartToGroup[aPart];
if (aPart >= Prs3d_DatumParts_XOYAxis
&& aPart <= Prs3d_DatumParts_XOZAxis)
if (aPart >= Prs3d_DatumParts_XOYAxis && aPart <= Prs3d_DatumParts_XOZAxis)
{
aGroup->SetGroupPrimitivesAspect(anAspect->LineAspect()->Aspect());
}
@ -375,10 +361,8 @@ void AIS_Trihedron::HilightSelected (const Handle(PrsMgr_PresentationManager)& t
}
}
//=======================================================================
//function : ClearSelected
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::ClearSelected()
{
Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect();
@ -388,8 +372,7 @@ void AIS_Trihedron::ClearSelected()
{
const Prs3d_DatumParts aPart = anIterator.Value();
const Handle(Graphic3d_Group)& aGroup = myPartToGroup[aPart];
if (aPart >= Prs3d_DatumParts_XOYAxis
&& aPart <= Prs3d_DatumParts_XOZAxis)
if (aPart >= Prs3d_DatumParts_XOYAxis && aPart <= Prs3d_DatumParts_XOZAxis)
{
aGroup->SetGroupPrimitivesAspect(myHiddenLineAspect);
}
@ -412,10 +395,8 @@ void AIS_Trihedron::ClearSelected()
mySelectedParts.Clear();
}
//=======================================================================
//function : computePresentation
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::computePresentation(const Handle(PrsMgr_PresentationManager)& /*thePrsMgr*/,
const Handle(Prs3d_Presentation)& thePrs)
{
@ -448,7 +429,8 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
// display axes
{
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter)
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis;
++anAxisIter)
{
Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
if (!anAspect->DrawDatumPart(aPart))
@ -493,7 +475,8 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
{
Handle(Geom_Axis2Placement) aComponent = myComponent;
const gp_Pnt anOrigin = aComponent->Location();
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter)
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis;
++anAxisIter)
{
const Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
if (!anAspect->DrawDatumPart(aPart))
@ -506,10 +489,17 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
gp_Dir aDir;
switch (aPart)
{
case Prs3d_DatumParts_XAxis: aDir = aComponent->XDirection(); break;
case Prs3d_DatumParts_YAxis: aDir = aComponent->YDirection(); break;
case Prs3d_DatumParts_ZAxis: aDir = aComponent->Direction(); break;
default: break;
case Prs3d_DatumParts_XAxis:
aDir = aComponent->XDirection();
break;
case Prs3d_DatumParts_YAxis:
aDir = aComponent->YDirection();
break;
case Prs3d_DatumParts_ZAxis:
aDir = aComponent->Direction();
break;
default:
break;
}
Handle(Graphic3d_Group) aLabelGroup = thePrs->NewGroup();
const gp_Pnt aPoint = anOrigin.XYZ() + aDir.XYZ() * anAxisLength;
@ -518,7 +508,9 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
}
// planes invisible group for planes selection
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XOYAxis; anAxisIter <= Prs3d_DatumParts_XOZAxis; ++anAxisIter)
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XOYAxis;
anAxisIter <= Prs3d_DatumParts_XOZAxis;
++anAxisIter)
{
Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
if (!anAspect->DrawDatumPart(aPart))
@ -534,10 +526,8 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
}
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::SetDatumPartColor(const Prs3d_DatumParts thePart,
const Quantity_Color& theColor)
{
@ -550,21 +540,16 @@ void AIS_Trihedron::SetDatumPartColor (const Prs3d_DatumParts thePart,
}
}
//=======================================================================
//function : SetTextColor
//purpose :
//=======================================================================
void AIS_Trihedron::SetTextColor (const Prs3d_DatumParts thePart,
const Quantity_Color& theColor)
//=================================================================================================
void AIS_Trihedron::SetTextColor(const Prs3d_DatumParts thePart, const Quantity_Color& theColor)
{
setOwnDatumAspect();
myDrawer->DatumAspect()->TextAspect(thePart)->SetColor(theColor);
}
//=======================================================================
//function : SetTextColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::SetTextColor(const Quantity_Color& theColor)
{
setOwnDatumAspect();
@ -573,10 +558,8 @@ void AIS_Trihedron::SetTextColor (const Quantity_Color& theColor)
myDrawer->DatumAspect()->TextAspect(Prs3d_DatumParts_ZAxis)->SetColor(theColor);
}
//=======================================================================
//function : Color
//purpose :
//=======================================================================
//=================================================================================================
Quantity_Color AIS_Trihedron::DatumPartColor(Prs3d_DatumParts thePart)
{
if (myTrihDispMode == Prs3d_DM_Shaded)
@ -589,10 +572,8 @@ Quantity_Color AIS_Trihedron::DatumPartColor (Prs3d_DatumParts thePart)
}
}
//=======================================================================
//function : SetOriginColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::SetOriginColor(const Quantity_Color& theColor)
{
if (myTrihDispMode == Prs3d_DM_Shaded)
@ -601,37 +582,29 @@ void AIS_Trihedron::SetOriginColor (const Quantity_Color& theColor)
}
}
//=======================================================================
//function : SetXAxisColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::SetXAxisColor(const Quantity_Color& theColor)
{
SetDatumPartColor(Prs3d_DatumParts_XAxis, theColor);
}
//=======================================================================
//function : SetYAxisColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::SetYAxisColor(const Quantity_Color& theColor)
{
SetDatumPartColor(Prs3d_DatumParts_YAxis, theColor);
}
//=======================================================================
//function : SetAxisColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::SetAxisColor(const Quantity_Color& theColor)
{
SetDatumPartColor(Prs3d_DatumParts_ZAxis, theColor);
}
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::SetColor(const Quantity_Color& theColor)
{
hasOwnColor = Standard_True;
@ -643,12 +616,9 @@ void AIS_Trihedron::SetColor (const Quantity_Color& theColor)
SetDatumPartColor(Prs3d_DatumParts_ZAxis, theColor);
}
//=======================================================================
//function : SetArrowColor
//purpose :
//=======================================================================
void AIS_Trihedron::SetArrowColor (const Prs3d_DatumParts thePart,
const Quantity_Color& theColor)
//=================================================================================================
void AIS_Trihedron::SetArrowColor(const Prs3d_DatumParts thePart, const Quantity_Color& theColor)
{
setOwnDatumAspect();
myHasOwnArrowColor = Standard_True;
@ -657,45 +627,38 @@ void AIS_Trihedron::SetArrowColor (const Prs3d_DatumParts thePart,
myDrawer->DatumAspect()->LineAspect(anArrowPart)->SetColor(theColor);
}
//=======================================================================
//function : SetArrowColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::SetArrowColor(const Quantity_Color& theColor)
{
setOwnDatumAspect();
myHasOwnArrowColor = Standard_True;
myDrawer->DatumAspect()->ArrowAspect()->SetColor(theColor);
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XArrow; anAxisIter <= Prs3d_DatumParts_ZArrow; ++anAxisIter)
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XArrow; anAxisIter <= Prs3d_DatumParts_ZArrow;
++anAxisIter)
{
myDrawer->DatumAspect()->ShadingAspect((Prs3d_DatumParts)anAxisIter)->SetColor(theColor);
myDrawer->DatumAspect()->LineAspect((Prs3d_DatumParts)anAxisIter)->SetColor(theColor);
}
}
//=======================================================================
//function : TextColor
//purpose :
//=======================================================================
//=================================================================================================
Quantity_Color AIS_Trihedron::TextColor() const
{
return myDrawer->DatumAspect()->TextAspect(Prs3d_DatumParts_XAxis)->Aspect()->Color();
}
//=======================================================================
//function : ArrowColor
//purpose :
//=======================================================================
//=================================================================================================
Quantity_Color AIS_Trihedron::ArrowColor() const
{
return myDrawer->DatumAspect()->ArrowAspect()->Aspect()->Color();
}
//=======================================================================
//function : UnsetColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::UnsetColor()
{
hasOwnColor = Standard_False;
@ -713,30 +676,25 @@ void AIS_Trihedron::UnsetColor()
}
}
//=======================================================================
//function : ToDrawArrows
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_Trihedron::ToDrawArrows() const
{
return myDrawer->DatumAspect()->ToDrawArrows();
}
//=======================================================================
//function : SetDrawArrows
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::SetDrawArrows(const Standard_Boolean theToDraw)
{
setOwnDatumAspect();
myDrawer->DatumAspect()->SetDrawArrows(theToDraw);
}
//=======================================================================
//function : createSensitiveEntity
//purpose :
//=======================================================================
Handle(Select3D_SensitiveEntity) AIS_Trihedron::createSensitiveEntity (const Prs3d_DatumParts thePart,
//=================================================================================================
Handle(Select3D_SensitiveEntity) AIS_Trihedron::createSensitiveEntity(
const Prs3d_DatumParts thePart,
const Handle(SelectMgr_EntityOwner)& theOwner) const
{
Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect();
@ -746,8 +704,7 @@ Handle(Select3D_SensitiveEntity) AIS_Trihedron::createSensitiveEntity (const Prs
return Handle(Select3D_SensitiveEntity)();
}
if (thePart >= Prs3d_DatumParts_XOYAxis
&& thePart <= Prs3d_DatumParts_XOZAxis)
if (thePart >= Prs3d_DatumParts_XOYAxis && thePart <= Prs3d_DatumParts_XOZAxis)
{ // plane
const gp_Pnt anXYZ1 = aPrimitives->Vertice(1);
const gp_Pnt anXYZ2 = aPrimitives->Vertice(2);
@ -757,17 +714,22 @@ Handle(Select3D_SensitiveEntity) AIS_Trihedron::createSensitiveEntity (const Prs
if (myTrihDispMode == Prs3d_DM_Shaded)
{
Handle(Select3D_SensitivePrimitiveArray) aSelArray = new Select3D_SensitivePrimitiveArray (theOwner);
aSelArray->InitTriangulation (aPrimitives->Attributes(), aPrimitives->Indices(), TopLoc_Location());
Handle(Select3D_SensitivePrimitiveArray) aSelArray =
new Select3D_SensitivePrimitiveArray(theOwner);
aSelArray->InitTriangulation(aPrimitives->Attributes(),
aPrimitives->Indices(),
TopLoc_Location());
return aSelArray;
}
if (Handle(Graphic3d_ArrayOfPoints) aPoints = Handle(Graphic3d_ArrayOfPoints)::DownCast(aPrimitives))
if (Handle(Graphic3d_ArrayOfPoints) aPoints =
Handle(Graphic3d_ArrayOfPoints)::DownCast(aPrimitives))
{
const gp_Pnt anXYZ1 = aPoints->Vertice(1);
return new Select3D_SensitivePoint(theOwner, anXYZ1);
}
else if (Handle(Graphic3d_ArrayOfSegments) aSegments = Handle(Graphic3d_ArrayOfSegments)::DownCast(aPrimitives))
else if (Handle(Graphic3d_ArrayOfSegments) aSegments =
Handle(Graphic3d_ArrayOfSegments)::DownCast(aPrimitives))
{
const gp_Pnt anXYZ1 = aSegments->Vertice(1);
const gp_Pnt anXYZ2 = aSegments->Vertice(2);
@ -802,8 +764,9 @@ void AIS_Trihedron::updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
for (int anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter)
{
Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
anAxisPoints.Bind(aPart, gp_Pnt(anXYZOrigin + anAxisDirs.Find(aPart).XYZ() *
theAspect->AxisLength(aPart)));
anAxisPoints.Bind(
aPart,
gp_Pnt(anXYZOrigin + anAxisDirs.Find(aPart).XYZ() * theAspect->AxisLength(aPart)));
}
if (theMode == Prs3d_DM_WireFrame)
@ -830,9 +793,12 @@ void AIS_Trihedron::updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis(aPart);
if (theAspect->DrawDatumPart(anArrowPart))
{
myPrimitives[anArrowPart] = Prs3d_Arrow::DrawSegments (anAxisPoints.Find(aPart), anAxisDirs.Find(aPart),
myPrimitives[anArrowPart] = Prs3d_Arrow::DrawSegments(
anAxisPoints.Find(aPart),
anAxisDirs.Find(aPart),
theAspect->ArrowAspect()->Angle(),
theAspect->AxisLength(aPart) * theAspect->Attribute(Prs3d_DatumAttribute_ShadingConeLengthPercent),
theAspect->AxisLength(aPart)
* theAspect->Attribute(Prs3d_DatumAttribute_ShadingConeLengthPercent),
(Standard_Integer)theAspect->Attribute(Prs3d_DatumAttribute_ShadingNumberOfFacettes));
}
}
@ -843,22 +809,29 @@ void AIS_Trihedron::updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
// origin
if (theAspect->DrawDatumPart(Prs3d_DatumParts_Origin))
{
const Standard_Real aSphereRadius = theAspect->AxisLength(Prs3d_DatumParts_XAxis) *
theAspect->Attribute(Prs3d_DatumAttribute_ShadingOriginRadiusPercent);
const Standard_Real aSphereRadius =
theAspect->AxisLength(Prs3d_DatumParts_XAxis)
* theAspect->Attribute(Prs3d_DatumAttribute_ShadingOriginRadiusPercent);
const Standard_Integer aNbOfFacettes =
(Standard_Integer)theAspect->Attribute(Prs3d_DatumAttribute_ShadingNumberOfFacettes);
gp_Trsf aSphereTransform;
aSphereTransform.SetTranslationPart(gp_Vec(gp::Origin(), theOrigin));
myPrimitives[Prs3d_DatumParts_Origin] = Prs3d_ToolSphere::Create (aSphereRadius, aNbOfFacettes, aNbOfFacettes, aSphereTransform);
myPrimitives[Prs3d_DatumParts_Origin] =
Prs3d_ToolSphere::Create(aSphereRadius, aNbOfFacettes, aNbOfFacettes, aSphereTransform);
}
// axes
{
const Standard_Integer aNbOfFacettes =
(Standard_Integer)theAspect->Attribute(Prs3d_DatumAttribute_ShadingNumberOfFacettes);
const Standard_Real aTubeRadiusPercent = theAspect->Attribute(Prs3d_DatumAttribute_ShadingTubeRadiusPercent);
const Standard_Real aConeLengthPercent = theAspect->Attribute(Prs3d_DatumAttribute_ShadingConeLengthPercent);
const Standard_Real aConeRadiusPercent = theAspect->Attribute(Prs3d_DatumAttribute_ShadingConeRadiusPercent);
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter)
const Standard_Real aTubeRadiusPercent =
theAspect->Attribute(Prs3d_DatumAttribute_ShadingTubeRadiusPercent);
const Standard_Real aConeLengthPercent =
theAspect->Attribute(Prs3d_DatumAttribute_ShadingConeLengthPercent);
const Standard_Real aConeRadiusPercent =
theAspect->Attribute(Prs3d_DatumAttribute_ShadingConeRadiusPercent);
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis;
anAxisIter <= Prs3d_DatumParts_ZAxis;
++anAxisIter)
{
const Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
const Prs3d_DatumParts anArrowPart = Prs3d_DatumAspect::ArrowPartForAxis(aPart);
@ -869,23 +842,32 @@ void AIS_Trihedron::updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
if (theAspect->DrawDatumPart(aPart))
{
// draw cylinder
myPrimitives[aPart] = Prs3d_Arrow::DrawShaded (anAxis, anAxisLength * aTubeRadiusPercent,
myPrimitives[aPart] = Prs3d_Arrow::DrawShaded(
anAxis,
anAxisLength * aTubeRadiusPercent,
aDrawArrow ? (anAxisLength - anAxisLength * aConeLengthPercent) : anAxisLength,
0.0, 0.0, aNbOfFacettes);
0.0,
0.0,
aNbOfFacettes);
}
// draw arrow
if (aDrawArrow)
{
myPrimitives[anArrowPart] = Prs3d_Arrow::DrawShaded (anAxis, 0.0, anAxisLength,
myPrimitives[anArrowPart] = Prs3d_Arrow::DrawShaded(anAxis,
0.0,
anAxisLength,
anAxisLength * aConeRadiusPercent,
anAxisLength * aConeLengthPercent, aNbOfFacettes);
anAxisLength * aConeLengthPercent,
aNbOfFacettes);
}
}
}
}
// planes
for (Standard_Integer aPlaneIter = Prs3d_DatumParts_XOYAxis; aPlaneIter <= Prs3d_DatumParts_XOZAxis; ++aPlaneIter)
for (Standard_Integer aPlaneIter = Prs3d_DatumParts_XOYAxis;
aPlaneIter <= Prs3d_DatumParts_XOZAxis;
++aPlaneIter)
{
const Prs3d_DatumParts aPart = (Prs3d_DatumParts)aPlaneIter;
if (!theAspect->DrawDatumPart(aPart))
@ -899,25 +881,23 @@ void AIS_Trihedron::updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
Prs3d_DatumParts aPart1 = Prs3d_DatumParts_XAxis, aPart2 = Prs3d_DatumParts_XAxis;
switch (aPart)
{
case Prs3d_DatumParts_XOYAxis:
{
case Prs3d_DatumParts_XOYAxis: {
aPart1 = Prs3d_DatumParts_XAxis;
aPart2 = Prs3d_DatumParts_YAxis;
break;
}
case Prs3d_DatumParts_YOZAxis:
{
case Prs3d_DatumParts_YOZAxis: {
aPart1 = Prs3d_DatumParts_YAxis;
aPart2 = Prs3d_DatumParts_ZAxis;
break;
}
case Prs3d_DatumParts_XOZAxis:
{
case Prs3d_DatumParts_XOZAxis: {
aPart1 = Prs3d_DatumParts_XAxis;
aPart2 = Prs3d_DatumParts_ZAxis;
break;
}
default: break;
default:
break;
}
aPrims->AddVertex(anAxisPoints.Find(aPart1));
aPrims->AddVertex(anAxisPoints.Find(aPart2));
@ -927,10 +907,8 @@ void AIS_Trihedron::updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
}
}
//=======================================================================
//function : DumpJson
//purpose :
//=======================================================================
//=================================================================================================
void AIS_Trihedron::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
{
OCCT_DUMP_TRANSIENT_CLASS_BEGIN(theOStream)

View File

@ -52,7 +52,6 @@ class AIS_Trihedron : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject)
public:
//! Initializes a trihedron entity.
Standard_EXPORT AIS_Trihedron(const Handle(Geom_Axis2Placement)& theComponent);
@ -93,8 +92,7 @@ public:
Standard_EXPORT void SetTextColor(const Quantity_Color& theColor);
//! Sets color of label of trihedron axis.
Standard_EXPORT void SetTextColor (const Prs3d_DatumParts thePart,
const Quantity_Color& theColor);
Standard_EXPORT void SetTextColor(const Prs3d_DatumParts thePart, const Quantity_Color& theColor);
//! Returns true if trihedron has own arrow color
Standard_Boolean HasArrowColor() const { return myHasOwnArrowColor; }
@ -139,11 +137,13 @@ public:
Standard_EXPORT void SetDrawArrows(const Standard_Boolean theToDraw);
//! Returns priority of selection for owner of the given type
Standard_Integer SelectionPriority (Prs3d_DatumParts thePart) { return mySelectionPriority[thePart]; }
Standard_Integer SelectionPriority(Prs3d_DatumParts thePart)
{
return mySelectionPriority[thePart];
}
//! Sets priority of selection for owner of the given type
void SetSelectionPriority (Prs3d_DatumParts thePart,
Standard_Integer thePriority)
void SetSelectionPriority(Prs3d_DatumParts thePart, Standard_Integer thePriority)
{
mySelectionPriority[thePart] = thePriority;
}
@ -152,14 +152,12 @@ public:
const TCollection_ExtendedString& Label(Prs3d_DatumParts thePart) { return myLabels[thePart]; }
//! Sets text label for trihedron axis. Parameter thePart should be XAxis, YAxis or ZAxis
void SetLabel (const Prs3d_DatumParts thePart,
const TCollection_ExtendedString& theName)
void SetLabel(const Prs3d_DatumParts thePart, const TCollection_ExtendedString& theName)
{
myLabels[thePart] = theName;
}
public:
//! Sets the color theColor for this trihedron object, it changes color of axes.
Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
@ -173,29 +171,32 @@ public:
virtual Standard_Integer Signature() const Standard_OVERRIDE { return 3; }
//! Indicates that the type of Interactive Object is datum.
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
{
return AIS_KindOfInteractive_Datum;
}
//! Removes the settings for color.
Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
public:
//! Method which clear all selected owners belonging
//! to this selectable object ( for fast presentation draw ).
Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
//! Method which draws selected owners ( for fast presentation draw ).
Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM,
const SelectMgr_SequenceOfOwner& theOwners) Standard_OVERRIDE;
const SelectMgr_SequenceOfOwner& theOwners)
Standard_OVERRIDE;
//! Method which hilight an owner belonging to
//! this selectable object ( for fast presentation draw ).
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
Standard_EXPORT virtual void HilightOwnerWithColor(
const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
protected:
//! Compute trihedron presentation.
Standard_EXPORT void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
@ -206,12 +207,13 @@ protected:
const Standard_Integer theMode) Standard_OVERRIDE;
//! Dumps the content of me into the stream
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
protected:
//! Creates a sensitive entity for the datum part that will be used in selection owner creation.
Standard_EXPORT Handle(Select3D_SensitiveEntity) createSensitiveEntity (const Prs3d_DatumParts thePart,
Standard_EXPORT Handle(Select3D_SensitiveEntity) createSensitiveEntity(
const Prs3d_DatumParts thePart,
const Handle(SelectMgr_EntityOwner)& theOwner) const;
//! Computes presentation for display mode equal 1.
@ -222,7 +224,10 @@ protected:
Standard_EXPORT void setOwnDatumAspect();
//! Returns primitives.
const Handle(Graphic3d_ArrayOfPrimitives)& arrayOfPrimitives (Prs3d_DatumParts thePart) const { return myPrimitives[thePart]; }
const Handle(Graphic3d_ArrayOfPrimitives)& arrayOfPrimitives(Prs3d_DatumParts thePart) const
{
return myPrimitives[thePart];
}
//! Updates graphic groups for the current datum mode
//! Parameters of datum position and orientation

View File

@ -24,7 +24,6 @@ class AIS_TrihedronOwner : public SelectMgr_EntityOwner
{
DEFINE_STANDARD_RTTIEXT(AIS_TrihedronOwner, SelectMgr_EntityOwner)
public:
//! Creates an owner of AIS_Trihedron object.
Standard_EXPORT AIS_TrihedronOwner(const Handle(SelectMgr_SelectableObject)& theSelObject,
const Prs3d_DatumParts theDatumPart,
@ -40,7 +39,8 @@ public:
//! Returns true if the presentation manager thePM
//! highlights selections corresponding to the selection mode aMode.
Standard_EXPORT Standard_Boolean IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
Standard_EXPORT Standard_Boolean
IsHilighted(const Handle(PrsMgr_PresentationManager)& thePM,
const Standard_Integer theMode) const Standard_OVERRIDE;
//! Removes highlighting from the owner of a detected

View File

@ -14,7 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AIS_InteractiveObject.hxx>
#include <AIS_TypeFilter.hxx>
#include <SelectMgr_EntityOwner.hxx>
@ -22,8 +21,10 @@
IMPLEMENT_STANDARD_RTTIEXT(AIS_TypeFilter, SelectMgr_Filter)
AIS_TypeFilter::AIS_TypeFilter(const AIS_KindOfInteractive TheKind):
myKind(TheKind){}
AIS_TypeFilter::AIS_TypeFilter(const AIS_KindOfInteractive TheKind)
: myKind(TheKind)
{
}
Standard_Boolean AIS_TypeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
{

View File

@ -24,7 +24,6 @@
#include <SelectMgr_Filter.hxx>
class SelectMgr_EntityOwner;
class AIS_TypeFilter;
DEFINE_STANDARD_HANDLE(AIS_TypeFilter, SelectMgr_Filter)
@ -55,38 +54,21 @@ class AIS_TypeFilter : public SelectMgr_Filter
{
public:
//! Initializes filter for type, aGivenKind.
Standard_EXPORT AIS_TypeFilter(const AIS_KindOfInteractive aGivenKind);
//! Returns False if the transient is not an Interactive
//! Object, or if the type of the Interactive Object is not
//! the same as that stored in the filter.
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const
Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(AIS_TypeFilter, SelectMgr_Filter)
protected:
AIS_KindOfInteractive myKind;
private:
};
#endif // _AIS_TypeFilter_HeaderFile

View File

@ -17,7 +17,6 @@
#ifndef _AIS_TypeOfAttribute_HeaderFile
#define _AIS_TypeOfAttribute_HeaderFile
enum AIS_TypeOfAttribute
{
AIS_TOA_Line,

File diff suppressed because it is too large Load Diff

View File

@ -48,12 +48,12 @@ class WNT_HIDSpaceMouse;
//! Class implements the following features:
//! - Buffers storing the state of user input (mouse, touches and keyboard).
//! - Mapping mouse/multi-touch input to View camera manipulations (panning/rotating/zooming).
//! - Input events are not applied immediately but queued for separate processing from two working threads
//! - Input events are not applied immediately but queued for separate processing from two working
//! threads
//! UI thread receiving user input and Rendering thread for OCCT 3D Viewer drawing.
class AIS_ViewController : public Aspect_WindowInputListener
{
public:
//! Empty constructor.
Standard_EXPORT AIS_ViewController();
@ -61,16 +61,25 @@ public:
Standard_EXPORT virtual ~AIS_ViewController();
//! Return input buffer.
const AIS_ViewInputBuffer& InputBuffer (AIS_ViewInputBufferType theType) const { return theType == AIS_ViewInputBufferType_UI ? myUI : myGL; }
const AIS_ViewInputBuffer& InputBuffer(AIS_ViewInputBufferType theType) const
{
return theType == AIS_ViewInputBufferType_UI ? myUI : myGL;
}
//! Return input buffer.
AIS_ViewInputBuffer& ChangeInputBuffer (AIS_ViewInputBufferType theType) { return theType == AIS_ViewInputBufferType_UI ? myUI : myGL; }
AIS_ViewInputBuffer& ChangeInputBuffer(AIS_ViewInputBufferType theType)
{
return theType == AIS_ViewInputBufferType_UI ? myUI : myGL;
}
//! Return view animation; empty (but not NULL) animation by default.
const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
//! Set view animation to be handled within handleViewRedraw().
void SetViewAnimation (const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; }
void SetViewAnimation(const Handle(AIS_AnimationCamera)& theAnimation)
{
myViewAnimation = theAnimation;
}
//! Interrupt active view animation.
Standard_EXPORT void AbortViewAnimation();
@ -79,7 +88,10 @@ public:
const Handle(AIS_Animation)& ObjectsAnimation() const { return myObjAnimation; }
//! Set object animation to be handled within handleViewRedraw().
void SetObjectsAnimation (const Handle(AIS_Animation)& theAnimation) { myObjAnimation = theAnimation; }
void SetObjectsAnimation(const Handle(AIS_Animation)& theAnimation)
{
myObjAnimation = theAnimation;
}
//! Return TRUE if object animation should be paused on mouse click; FALSE by default.
bool ToPauseObjectsAnimation() const { return myToPauseObjAnimation; }
@ -88,14 +100,14 @@ public:
void SetPauseObjectsAnimation(bool theToPause) { myToPauseObjAnimation = theToPause; }
//! Return TRUE if continuous redrawing is enabled; FALSE by default.
//! This option would request a next viewer frame to be completely redrawn right after current frame is finished.
//! This option would request a next viewer frame to be completely redrawn right after current
//! frame is finished.
bool IsContinuousRedraw() const { return myIsContinuousRedraw; }
//! Enable or disable continuous updates.
void SetContinuousRedraw(bool theToEnable) { myIsContinuousRedraw = theToEnable; }
public: //! @name global parameters
//! Return camera rotation mode, AIS_RotationMode_BndBoxActive by default.
AIS_RotationMode RotationMode() const { return myRotationMode; }
@ -120,7 +132,8 @@ public: //! @name global parameters
//! Set orbit rotation acceleration ratio.
void SetOrbitAcceleration(float theRatio) { myOrbitAccel = theRatio; }
//! Return TRUE if panning anchor point within perspective projection should be displayed in 3D Viewer; TRUE by default.
//! Return TRUE if panning anchor point within perspective projection should be displayed in 3D
//! Viewer; TRUE by default.
bool ToShowPanAnchorPoint() const { return myToShowPanAnchorPoint; }
//! Set if panning anchor point within perspective projection should be displayed in 3D Viewer.
@ -132,10 +145,12 @@ public: //! @name global parameters
//! Set if rotation point should be displayed in 3D Viewer.
void SetShowRotateCenter(bool theToShow) { myToShowRotateCenter = theToShow; }
//! Return TRUE if camera up orientation within AIS_NavigationMode_Orbit rotation mode should be forced Z up; FALSE by default.
//! Return TRUE if camera up orientation within AIS_NavigationMode_Orbit rotation mode should be
//! forced Z up; FALSE by default.
bool ToLockOrbitZUp() const { return myToLockOrbitZUp; }
//! Set if camera up orientation within AIS_NavigationMode_Orbit rotation mode should be forced Z up.
//! Set if camera up orientation within AIS_NavigationMode_Orbit rotation mode should be forced Z
//! up.
void SetLockOrbitZUp(bool theToForceUp) { myToLockOrbitZUp = theToForceUp; }
//! Return TRUE if z-rotation via two-touches gesture is enabled; FALSE by default.
@ -180,19 +195,22 @@ public: //! @name global parameters
//! Set if dynamic highlight on mouse move is allowed.
void SetAllowDragging(bool theToEnable) { myToAllowDragging = theToEnable; }
//! Return TRUE if picked point should be projected to picking ray on zooming at point; TRUE by default.
//! Return TRUE if picked point should be projected to picking ray on zooming at point; TRUE by
//! default.
bool ToStickToRayOnZoom() const { return myToStickToRayOnZoom; }
//! Set if picked point should be projected to picking ray on zooming at point.
void SetStickToRayOnZoom(bool theToEnable) { myToStickToRayOnZoom = theToEnable; }
//! Return TRUE if picked point should be projected to picking ray on rotating around point; TRUE by default.
//! Return TRUE if picked point should be projected to picking ray on rotating around point; TRUE
//! by default.
bool ToStickToRayOnRotation() const { return myToStickToRayOnRotation; }
//! Set if picked point should be projected to picking ray on rotating around point.
void SetStickToRayOnRotation(bool theToEnable) { myToStickToRayOnRotation = theToEnable; }
//! Return TRUE if pitch direction should be inverted while processing Aspect_VKey_NavLookUp/Aspect_VKey_NavLookDown; FALSE by default.
//! Return TRUE if pitch direction should be inverted while processing
//! Aspect_VKey_NavLookUp/Aspect_VKey_NavLookDown; FALSE by default.
bool ToInvertPitch() const { return myToInvertPitch; }
//! Set flag inverting pitch direction.
@ -238,9 +256,8 @@ public: //! @name global parameters
void SetDisplayXRHands(bool theToDisplay) { myToDisplayXRHands = theToDisplay; }
public: //! @name keyboard input
using Aspect_WindowInputListener::Keys;
using Aspect_WindowInputListener::ChangeKeys;
using Aspect_WindowInputListener::Keys;
//! Press key.
//! Default implementation updates internal cache.
@ -254,8 +271,7 @@ public: //! @name keyboard input
//! Default implementation updates internal cache.
//! @param theKey key pressed
//! @param theTime event timestamp
Standard_EXPORT virtual void KeyUp (Aspect_VKey theKey,
double theTime) Standard_OVERRIDE;
Standard_EXPORT virtual void KeyUp(Aspect_VKey theKey, double theTime) Standard_OVERRIDE;
//! Simulate key up/down events from axis value.
//! Default implementation updates internal cache.
@ -269,7 +285,6 @@ public: //! @name keyboard input
Standard_Real theRunRatio);
public: //! @name mouse input
//! Return map defining mouse gestures.
const AIS_MouseGestureMap& MouseGestureMap() const { return myMouseGestureMap; }
@ -277,7 +292,10 @@ public: //! @name mouse input
AIS_MouseGestureMap& ChangeMouseGestureMap() { return myMouseGestureMap; }
//! Return map defining mouse selection schemes.
const AIS_MouseSelectionSchemeMap& MouseSelectionSchemes() const { return myMouseSelectionSchemes; }
const AIS_MouseSelectionSchemeMap& MouseSelectionSchemes() const
{
return myMouseSelectionSchemes;
}
//! Return map defining mouse gestures.
AIS_MouseSelectionSchemeMap& ChangeMouseSelectionSchemes() { return myMouseSelectionSchemes; }
@ -292,14 +310,16 @@ public: //! @name mouse input
//! This method is expected to be called from UI thread.
//! @param thePnt picking point
//! @param theScheme selection scheme
Standard_EXPORT virtual void SelectInViewer (const Graphic3d_Vec2i& thePnt,
Standard_EXPORT virtual void SelectInViewer(
const Graphic3d_Vec2i& thePnt,
const AIS_SelectionScheme theScheme = AIS_SelectionScheme_Replace);
//! Perform selection in 3D viewer.
//! This method is expected to be called from UI thread.
//! @param thePnts picking point
//! @param theScheme selection scheme
Standard_EXPORT virtual void SelectInViewer (const NCollection_Sequence<Graphic3d_Vec2i>& thePnts,
Standard_EXPORT virtual void SelectInViewer(
const NCollection_Sequence<Graphic3d_Vec2i>& thePnts,
const AIS_SelectionScheme theScheme = AIS_SelectionScheme_Replace);
//! Update rectangle selection tool.
@ -313,8 +333,7 @@ public: //! @name mouse input
//! This method is expected to be called from UI thread.
//! @param thePnt new point to add to polygon
//! @param theToAppend append new point or update the last point
Standard_EXPORT virtual void UpdatePolySelection (const Graphic3d_Vec2i& thePnt,
bool theToAppend);
Standard_EXPORT virtual void UpdatePolySelection(const Graphic3d_Vec2i& thePnt, bool theToAppend);
//! Update zoom event (e.g. from mouse scroll).
//! This method is expected to be called from UI thread.
@ -331,7 +350,8 @@ public: //! @name mouse input
//! This method is expected to be called from UI thread.
//! @param theDelta mouse cursor position and delta
//! @return TRUE if new event has been created or FALSE if existing one has been updated
Standard_EXPORT virtual bool UpdateMouseScroll (const Aspect_ScrollDelta& theDelta) Standard_OVERRIDE;
Standard_EXPORT virtual bool UpdateMouseScroll(const Aspect_ScrollDelta& theDelta)
Standard_OVERRIDE;
//! Handle mouse button press/release event.
//! This method is expected to be called from UI thread.
@ -359,10 +379,10 @@ public: //! @name mouse input
Aspect_VKeyFlags theModifiers,
bool theIsEmulated) Standard_OVERRIDE;
//! Handle mouse button click event (emulated by UpdateMouseButtons() while releasing single button).
//! Note that as this method is called by UpdateMouseButtons(), it should be executed from UI thread.
//! Default implementation redirects to SelectInViewer().
//! This method is expected to be called from UI thread.
//! Handle mouse button click event (emulated by UpdateMouseButtons() while releasing single
//! button). Note that as this method is called by UpdateMouseButtons(), it should be executed
//! from UI thread. Default implementation redirects to SelectInViewer(). This method is expected
//! to be called from UI thread.
//! @param thePoint mouse cursor position
//! @param theButton clicked button
//! @param theModifiers key modifiers
@ -376,12 +396,11 @@ public: //! @name mouse input
using Aspect_WindowInputListener::PressMouseButton;
using Aspect_WindowInputListener::ReleaseMouseButton;
using Aspect_WindowInputListener::PressedMouseButtons;
using Aspect_WindowInputListener::LastMouseFlags;
using Aspect_WindowInputListener::LastMousePosition;
using Aspect_WindowInputListener::PressedMouseButtons;
public: //! @name multi-touch input
//! Return scale factor for adjusting tolerances for starting multi-touch gestures; 1.0 by default
//! This scale factor is expected to be computed from touch screen resolution.
float TouchToleranceScale() const { return myTouchToleranceScale; }
@ -396,7 +415,8 @@ public: //! @name multi-touch input
//! @param theClearBefore if TRUE previously registered touches will be removed
Standard_EXPORT virtual void AddTouchPoint(Standard_Size theId,
const Graphic3d_Vec2d& thePnt,
Standard_Boolean theClearBefore = false) Standard_OVERRIDE;
Standard_Boolean theClearBefore = false)
Standard_OVERRIDE;
//! Remove touch point with the given ID.
//! This method is expected to be called from UI thread.
@ -404,7 +424,8 @@ public: //! @name multi-touch input
//! @param theClearSelectPnts if TRUE will initiate clearing of selection points
//! @return TRUE if point has been removed
Standard_EXPORT virtual bool RemoveTouchPoint(Standard_Size theId,
Standard_Boolean theClearSelectPnts = false) Standard_OVERRIDE;
Standard_Boolean theClearSelectPnts = false)
Standard_OVERRIDE;
//! Update touch point with the given ID.
//! If point with specified ID was not registered before, it will be added.
@ -417,25 +438,21 @@ public: //! @name multi-touch input
using Aspect_WindowInputListener::HasTouchPoints;
public: //! @name 3d mouse input
//! Process 3d mouse input event (redirects to translation, rotation and keys).
Standard_EXPORT virtual bool Update3dMouse(const WNT_HIDSpaceMouse& theEvent) Standard_OVERRIDE;
public: //! @name resize events
//! Handle expose event (window content has been invalidation and should be redrawn).
//! Default implementation does nothing.
virtual void ProcessExpose() Standard_OVERRIDE {}
//! Handle window resize event.
//! Default implementation does nothing.
virtual void ProcessConfigure (bool theIsResized) Standard_OVERRIDE
{
(void )theIsResized;
}
virtual void ProcessConfigure(bool theIsResized) Standard_OVERRIDE { (void)theIsResized; }
//! Handle window input event immediately.
//! Default implementation does nothing - input events are accumulated in internal buffer until explicit FlushViewEvents() call.
//! Default implementation does nothing - input events are accumulated in internal buffer until
//! explicit FlushViewEvents() call.
virtual void ProcessInput() Standard_OVERRIDE {}
//! Handle focus event.
@ -453,7 +470,6 @@ public: //! @name resize events
virtual void ProcessClose() Standard_OVERRIDE {}
public:
using Aspect_WindowInputListener::EventTime;
//! Reset input state (pressed keys, mouse buttons, etc.) e.g. on window focus loss.
@ -480,7 +496,6 @@ public:
const Handle(V3d_View)& theView);
public:
//! Callback called by handleMoveTo() on Selection in 3D Viewer.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void OnSelectionChanged(const Handle(AIS_InteractiveContext)& theCtx,
@ -530,21 +545,24 @@ public:
const Handle(V3d_View)& theView);
//! Modify view camera to fit all objects.
//! Default implementation fits either all visible and all selected objects (swapped on each call).
//! Default implementation fits either all visible and all selected objects (swapped on each
//! call).
Standard_EXPORT virtual void FitAllAuto(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
public:
//! Handle hot-keys defining new camera orientation (Aspect_VKey_ViewTop and similar keys).
//! Default implementation starts an animated transaction from the current to the target camera orientation, when specific action key was pressed.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void handleViewOrientationKeys (const Handle(AIS_InteractiveContext)& theCtx,
//! Default implementation starts an animated transaction from the current to the target camera
//! orientation, when specific action key was pressed. This method is expected to be called from
//! rendering thread.
Standard_EXPORT virtual void handleViewOrientationKeys(
const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
//! Perform navigation (Aspect_VKey_NavForward and similar keys).
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual AIS_WalkDelta handleNavigationKeys (const Handle(AIS_InteractiveContext)& theCtx,
Standard_EXPORT virtual AIS_WalkDelta handleNavigationKeys(
const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
//! Perform immediate camera actions (rotate/zoom/pan) on gesture progress.
@ -599,7 +617,8 @@ public:
//! Handle orbital rotation events myGL.OrbitRotation.
//! @param theView view to modify
//! @param thePnt 3D point to rotate around
//! @param theToLockZUp amend camera to exclude roll angle (put camera Up vector to plane containing global Z and view direction)
//! @param theToLockZUp amend camera to exclude roll angle (put camera Up vector to plane
//! containing global Z and view direction)
Standard_EXPORT virtual void handleOrbitRotation(const Handle(V3d_View)& theView,
const gp_Pnt& thePnt,
bool theToLockZUp);
@ -623,7 +642,6 @@ public:
const Handle(V3d_View)& theView);
public:
//! Perform XR input.
//! This method is expected to be called from rendering thread.
Standard_EXPORT virtual void handleXRInput(const Handle(AIS_InteractiveContext)& theCtx,
@ -651,13 +669,13 @@ public:
const Handle(V3d_View)& theView);
//! Perform picking with/without dynamic highlighting for XR pose.
Standard_EXPORT virtual Standard_Integer handleXRMoveTo (const Handle(AIS_InteractiveContext)& theCtx,
Standard_EXPORT virtual Standard_Integer handleXRMoveTo(
const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView,
const gp_Trsf& thePose,
const Standard_Boolean theToHighlight);
protected:
//! Flush buffers.
Standard_EXPORT virtual void flushBuffers(const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView);
@ -670,8 +688,7 @@ protected:
//! This callback is intended to compute delta between sequentially processed events.
//! @param[out] thePrevTime events time fetched previous time by this method
//! @param[out] theCurrTime actual events time
void updateEventsTime (double& thePrevTime,
double& theCurrTime)
void updateEventsTime(double& thePrevTime, double& theCurrTime)
{
thePrevTime = myLastEventsTime;
myLastEventsTime = EventTime();
@ -699,7 +716,6 @@ protected:
const Graphic3d_Vec2i& thePnt);
protected:
AIS_ViewInputBuffer myUI; //!< buffer for UI thread
AIS_ViewInputBuffer myGL; //!< buffer for rendering thread
@ -813,7 +829,6 @@ protected: //! @name rotation/panning transient state variables
gp_Vec myCamStartOpToEye; //!< vector from rotation gravity point to camera Eye at the beginning of rotation
Graphic3d_Vec3d myRotateStartYawPitchRoll; //!< camera yaw pitch roll at the beginning of rotation
// clang-format on
};
#endif // _AIS_ViewController_HeaderFile

View File

@ -52,12 +52,10 @@ namespace
}
return aNbComps;
}
}
} // namespace
//=================================================================================================
//=======================================================================
//function : AIS_ViewCubeSensitive
//purpose :
//=======================================================================
AIS_ViewCubeSensitive::AIS_ViewCubeSensitive(const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(Graphic3d_ArrayOfTriangles)& theTris)
: Select3D_SensitivePrimitiveArray(theOwner)
@ -65,20 +63,16 @@ AIS_ViewCubeSensitive::AIS_ViewCubeSensitive (const Handle(SelectMgr_EntityOwner
InitTriangulation(theTris->Attributes(), theTris->Indices(), TopLoc_Location());
}
//=======================================================================
//function : Matches
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ViewCubeSensitive::Matches(SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
return isValidRay(theMgr) && Select3D_SensitivePrimitiveArray::Matches(theMgr, thePickResult);
}
//=======================================================================
//function : isValidRay
//purpose :
//=======================================================================
//=================================================================================================
bool AIS_ViewCubeSensitive::isValidRay(const SelectBasics_SelectingVolumeManager& theMgr) const
{
if (theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point)
@ -97,37 +91,29 @@ bool AIS_ViewCubeSensitive::isValidRay (const SelectBasics_SelectingVolumeManage
return true;
}
//=======================================================================
//function : IsBoxSide
//purpose :
//=======================================================================
//=================================================================================================
bool AIS_ViewCube::IsBoxSide(V3d_TypeOfOrientation theOrient)
{
return nbDirectionComponents(V3d::GetProjAxis(theOrient)) == 1;
}
//=======================================================================
//function : IsBoxEdge
//purpose :
//=======================================================================
//=================================================================================================
bool AIS_ViewCube::IsBoxEdge(V3d_TypeOfOrientation theOrient)
{
return nbDirectionComponents(V3d::GetProjAxis(theOrient)) == 2;
}
//=======================================================================
//function : IsBoxCorner
//purpose :
//=======================================================================
//=================================================================================================
bool AIS_ViewCube::IsBoxCorner(V3d_TypeOfOrientation theOrient)
{
return nbDirectionComponents(V3d::GetProjAxis(theOrient)) == 3;
}
//=======================================================================
//function : AIS_ViewCube
//purpose :
//=======================================================================
//=================================================================================================
AIS_ViewCube::AIS_ViewCube()
: myBoxEdgeAspect(new Prs3d_ShadingAspect()),
myBoxCornerAspect(new Prs3d_ShadingAspect()),
@ -157,7 +143,9 @@ AIS_ViewCube::AIS_ViewCube()
myInfiniteState = true;
myIsMutable = true;
myDrawer->SetZLayer(Graphic3d_ZLayerId_Topmost);
myTransformPersistence = new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (100, 100));
myTransformPersistence = new Graphic3d_TransformPers(Graphic3d_TMF_TriedronPers,
Aspect_TOTP_LEFT_LOWER,
Graphic3d_Vec2i(100, 100));
myDrawer->SetTextAspect(new Prs3d_TextAspect());
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
@ -185,10 +173,8 @@ AIS_ViewCube::AIS_ViewCube()
SetSize(70.0);
}
//=======================================================================
//function : setDefaultAttributes
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::setDefaultAttributes()
{
myDrawer->TextAspect()->SetHorizontalJustification(Graphic3d_HTA_CENTER);
@ -220,10 +206,8 @@ void AIS_ViewCube::setDefaultAttributes()
myBoxCornerAspect->SetColor(Quantity_NOC_GRAY30);
}
//=======================================================================
//function : setDefaultHighlightAttributes
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::setDefaultHighlightAttributes()
{
Graphic3d_MaterialAspect aHighlightMaterial;
@ -239,12 +223,9 @@ void AIS_ViewCube::setDefaultHighlightAttributes()
myDynHilightDrawer->SetColor(Quantity_NOC_CYAN1);
}
//=======================================================================
//function : SetYup
//purpose :
//=======================================================================
void AIS_ViewCube::SetYup (Standard_Boolean theIsYup,
Standard_Boolean theToUpdateLabels)
//=================================================================================================
void AIS_ViewCube::SetYup(Standard_Boolean theIsYup, Standard_Boolean theToUpdateLabels)
{
if (myIsYup == theIsYup)
{
@ -253,18 +234,18 @@ void AIS_ViewCube::SetYup (Standard_Boolean theIsYup,
myIsYup = theIsYup;
static const V3d_TypeOfOrientation THE_ZUP_ORI_LIST[6] =
{
V3d_TypeOfOrientation_Zup_Front, V3d_TypeOfOrientation_Zup_Back,
V3d_TypeOfOrientation_Zup_Top, V3d_TypeOfOrientation_Zup_Bottom,
V3d_TypeOfOrientation_Zup_Left, V3d_TypeOfOrientation_Zup_Right
};
static const V3d_TypeOfOrientation THE_YUP_ORI_LIST[6] =
{
V3d_TypeOfOrientation_Yup_Front, V3d_TypeOfOrientation_Yup_Back,
V3d_TypeOfOrientation_Yup_Top, V3d_TypeOfOrientation_Yup_Bottom,
V3d_TypeOfOrientation_Yup_Left, V3d_TypeOfOrientation_Yup_Right
};
static const V3d_TypeOfOrientation THE_ZUP_ORI_LIST[6] = {V3d_TypeOfOrientation_Zup_Front,
V3d_TypeOfOrientation_Zup_Back,
V3d_TypeOfOrientation_Zup_Top,
V3d_TypeOfOrientation_Zup_Bottom,
V3d_TypeOfOrientation_Zup_Left,
V3d_TypeOfOrientation_Zup_Right};
static const V3d_TypeOfOrientation THE_YUP_ORI_LIST[6] = {V3d_TypeOfOrientation_Yup_Front,
V3d_TypeOfOrientation_Yup_Back,
V3d_TypeOfOrientation_Yup_Top,
V3d_TypeOfOrientation_Yup_Bottom,
V3d_TypeOfOrientation_Yup_Left,
V3d_TypeOfOrientation_Yup_Right};
if (theToUpdateLabels)
{
NCollection_Array1<TCollection_AsciiString> aLabels(0, 5);
@ -283,10 +264,8 @@ void AIS_ViewCube::SetYup (Standard_Boolean theIsYup,
SetToUpdate();
}
//=======================================================================
//function : ResetStyles
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::ResetStyles()
{
UnsetAttributes();
@ -306,12 +285,9 @@ void AIS_ViewCube::ResetStyles()
SetSize(70.0);
}
//=======================================================================
//function : SetSize
//purpose :
//=======================================================================
void AIS_ViewCube::SetSize (Standard_Real theValue,
Standard_Boolean theToAdaptAnother)
//=================================================================================================
void AIS_ViewCube::SetSize(Standard_Real theValue, Standard_Boolean theToAdaptAnother)
{
const bool isNewSize = Abs(mySize - theValue) > Precision::Confusion();
mySize = theValue;
@ -333,10 +309,8 @@ void AIS_ViewCube::SetSize (Standard_Real theValue,
}
}
//=======================================================================
//function : SetRoundRadius
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::SetRoundRadius(const Standard_Real theValue)
{
Standard_OutOfRange_Raise_if(theValue < 0.0 || theValue > 0.5,
@ -348,10 +322,8 @@ void AIS_ViewCube::SetRoundRadius (const Standard_Real theValue)
}
}
//=======================================================================
//function : createRoundRectangleTriangles
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::createRoundRectangleTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes,
Standard_Integer& theNbTris,
@ -376,23 +348,43 @@ void AIS_ViewCube::createRoundRectangleTriangles (const Handle(Graphic3d_ArrayOf
theTris->AddVertex(gp_Pnt(0.0, 0.0, 0.0).Transformed(theTrsf));
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
{
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (M_PI * 0.5, 0.0, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
theTris->AddVertex (gp_Pnt (aHSize.X() + aRadius * Cos (anAngle), aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate(
M_PI * 0.5,
0.0,
Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
theTris->AddVertex(
gp_Pnt(aHSize.X() + aRadius * Cos(anAngle), aHSize.Y() + aRadius * Sin(anAngle), 0.0)
.Transformed(theTrsf));
}
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
{
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (0.0, -M_PI * 0.5, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
theTris->AddVertex (gp_Pnt (aHSize.X() + aRadius * Cos (anAngle), -aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate(
0.0,
-M_PI * 0.5,
Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
theTris->AddVertex(
gp_Pnt(aHSize.X() + aRadius * Cos(anAngle), -aHSize.Y() + aRadius * Sin(anAngle), 0.0)
.Transformed(theTrsf));
}
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
{
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (-M_PI * 0.5, -M_PI, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
theTris->AddVertex (gp_Pnt (-aHSize.X() + aRadius * Cos (anAngle), -aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate(
-M_PI * 0.5,
-M_PI,
Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
theTris->AddVertex(
gp_Pnt(-aHSize.X() + aRadius * Cos(anAngle), -aHSize.Y() + aRadius * Sin(anAngle), 0.0)
.Transformed(theTrsf));
}
for (Standard_Integer aNodeIter = 0; aNodeIter <= THE_NB_ROUND_SPLITS; ++aNodeIter)
{
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (-M_PI, -M_PI * 1.5, Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
theTris->AddVertex (gp_Pnt (-aHSize.X() + aRadius * Cos (anAngle), aHSize.Y() + aRadius * Sin (anAngle), 0.0).Transformed (theTrsf));
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate(
-M_PI,
-M_PI * 1.5,
Standard_Real(aNodeIter) / Standard_Real(THE_NB_ROUND_SPLITS));
theTris->AddVertex(
gp_Pnt(-aHSize.X() + aRadius * Cos(anAngle), aHSize.Y() + aRadius * Sin(anAngle), 0.0)
.Transformed(theTrsf));
}
// split triangle fan
@ -414,16 +406,15 @@ void AIS_ViewCube::createRoundRectangleTriangles (const Handle(Graphic3d_ArrayOf
theTris->AddQuadTriangleEdges(aVertFirst + 1, aVertFirst + 2, aVertFirst + 3, aVertFirst + 4);
}
for (Standard_Integer aVertIter = aVertFirst + 1; aVertIter <= theTris->VertexNumber(); ++aVertIter)
for (Standard_Integer aVertIter = aVertFirst + 1; aVertIter <= theTris->VertexNumber();
++aVertIter)
{
theTris->SetVertexNormal(aVertIter, -aNorm);
}
}
//=======================================================================
//function : createBoxPartTriangles
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::createBoxPartTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes,
Standard_Integer& theNbTris,
@ -433,22 +424,18 @@ void AIS_ViewCube::createBoxPartTriangles (const Handle(Graphic3d_ArrayOfTriangl
{
createBoxSideTriangles(theTris, theNbNodes, theNbTris, theDir);
}
else if (IsBoxEdge (theDir)
&& myToDisplayEdges)
else if (IsBoxEdge(theDir) && myToDisplayEdges)
{
createBoxEdgeTriangles(theTris, theNbNodes, theNbTris, theDir);
}
else if (IsBoxCorner (theDir)
&& myToDisplayVertices)
else if (IsBoxCorner(theDir) && myToDisplayVertices)
{
createBoxCornerTriangles(theTris, theNbNodes, theNbTris, theDir);
}
}
//=======================================================================
//function : createBoxSideTriangles
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::createBoxSideTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes,
Standard_Integer& theNbTris,
@ -462,37 +449,43 @@ void AIS_ViewCube::createBoxSideTriangles (const Handle(Graphic3d_ArrayOfTriangl
gp_Trsf aTrsf;
aTrsf.SetTransformation(aSystem, gp_Ax3());
createRoundRectangleTriangles (theTris, theNbNodes, theNbTris,
gp_XY (mySize, mySize), myRoundRadius * mySize, aTrsf);
createRoundRectangleTriangles(theTris,
theNbNodes,
theNbTris,
gp_XY(mySize, mySize),
myRoundRadius * mySize,
aTrsf);
}
//=======================================================================
//function : createBoxEdgeTriangles
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::createBoxEdgeTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes,
Standard_Integer& theNbTris,
V3d_TypeOfOrientation theDirection) const
{
const Standard_Real aThickness = Max (myBoxFacetExtension * gp_XY (1.0, 1.0).Modulus() - myBoxEdgeGap, myBoxEdgeMinSize);
const Standard_Real aThickness =
Max(myBoxFacetExtension * gp_XY(1.0, 1.0).Modulus() - myBoxEdgeGap, myBoxEdgeMinSize);
const gp_Dir aDir = V3d::GetProjAxis(theDirection);
const gp_Pnt aPos = aDir.XYZ() * (mySize * 0.5 * gp_XY (1.0, 1.0).Modulus() + myBoxFacetExtension * Cos (M_PI_4));
const gp_Pnt aPos =
aDir.XYZ() * (mySize * 0.5 * gp_XY(1.0, 1.0).Modulus() + myBoxFacetExtension * Cos(M_PI_4));
const gp_Ax2 aPosition(aPos, aDir.Reversed());
gp_Ax3 aSystem(aPosition);
gp_Trsf aTrsf;
aTrsf.SetTransformation(aSystem, gp_Ax3());
createRoundRectangleTriangles (theTris, theNbNodes, theNbTris,
gp_XY (aThickness, mySize), myRoundRadius * mySize, aTrsf);
createRoundRectangleTriangles(theTris,
theNbNodes,
theNbTris,
gp_XY(aThickness, mySize),
myRoundRadius * mySize,
aTrsf);
}
//=======================================================================
//function : createBoxCornerTriangles
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::createBoxCornerTriangles(const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes,
Standard_Integer& theNbTris,
@ -523,8 +516,12 @@ void AIS_ViewCube::createBoxCornerTriangles (const Handle(Graphic3d_ArrayOfTrian
theTris->AddVertex(gp_Pnt(0.0, 0.0, 0.0).Transformed(aTrsf));
for (Standard_Integer aNodeIter = 0; aNodeIter < THE_NB_DISK_SLICES; ++aNodeIter)
{
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate (2.0 * M_PI, 0.0, Standard_Real(aNodeIter) / Standard_Real(THE_NB_DISK_SLICES));
theTris->AddVertex (gp_Pnt (aRadius * Cos (anAngle), aRadius * Sin (anAngle), 0.0).Transformed (aTrsf));
const Standard_Real anAngle = NCollection_Lerp<Standard_Real>::Interpolate(
2.0 * M_PI,
0.0,
Standard_Real(aNodeIter) / Standard_Real(THE_NB_DISK_SLICES));
theTris->AddVertex(
gp_Pnt(aRadius * Cos(anAngle), aRadius * Sin(anAngle), 0.0).Transformed(aTrsf));
}
theTris->AddTriangleFanEdges(aVertFirst + 1, theTris->VertexNumber(), true);
}
@ -555,16 +552,15 @@ void AIS_ViewCube::createBoxCornerTriangles (const Handle(Graphic3d_ArrayOfTrian
}
}
for (Standard_Integer aVertIter = aVertFirst + 1; aVertIter <= theTris->VertexNumber(); ++aVertIter)
for (Standard_Integer aVertIter = aVertFirst + 1; aVertIter <= theTris->VertexNumber();
++aVertIter)
{
theTris->SetVertexNormal(aVertIter, aDir);
}
}
//=======================================================================
//function : Compute
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::Compute(const Handle(PrsMgr_PresentationManager)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
@ -575,14 +571,16 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
return;
}
const gp_Pnt aLocation = (mySize * 0.5 + myBoxFacetExtension + myAxesPadding) * gp_XYZ (-1.0, -1.0, -1.0);
const gp_Pnt aLocation =
(mySize * 0.5 + myBoxFacetExtension + myAxesPadding) * gp_XYZ(-1.0, -1.0, -1.0);
// Display axes
if (myToDisplayAxes)
{
const Standard_Real anAxisSize = mySize + 2.0 * myBoxFacetExtension + myAxesPadding;
const Handle(Prs3d_DatumAspect)& aDatumAspect = myDrawer->DatumAspect();
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis; ++anAxisIter)
for (Standard_Integer anAxisIter = Prs3d_DatumParts_XAxis; anAxisIter <= Prs3d_DatumParts_ZAxis;
++anAxisIter)
{
const Prs3d_DatumParts aPart = (Prs3d_DatumParts)anAxisIter;
if (!aDatumAspect->DrawDatumPart(aPart))
@ -593,10 +591,17 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
gp_Ax1 anAx1;
switch (aPart)
{
case Prs3d_DatumParts_XAxis: anAx1 = gp_Ax1 (aLocation, gp::DX()); break;
case Prs3d_DatumParts_YAxis: anAx1 = gp_Ax1 (aLocation, gp::DY()); break;
case Prs3d_DatumParts_ZAxis: anAx1 = gp_Ax1 (aLocation, gp::DZ()); break;
default: break;
case Prs3d_DatumParts_XAxis:
anAx1 = gp_Ax1(aLocation, gp::DX());
break;
case Prs3d_DatumParts_YAxis:
anAx1 = gp_Ax1(aLocation, gp::DY());
break;
case Prs3d_DatumParts_ZAxis:
anAx1 = gp_Ax1(aLocation, gp::DZ());
break;
default:
break;
}
Handle(Graphic3d_Group) anAxisGroup = thePrs->NewGroup();
@ -604,19 +609,28 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
anAxisGroup->SetGroupPrimitivesAspect(aDatumAspect->ShadingAspect(aPart)->Aspect());
const Standard_Real anArrowLength = 0.2 * anAxisSize;
Handle(Graphic3d_ArrayOfTriangles) aTriangleArray = Prs3d_Arrow::DrawShaded (anAx1, myAxesRadius, anAxisSize, myAxesConeRadius, anArrowLength, THE_NB_ARROW_FACETTES);
Handle(Graphic3d_ArrayOfTriangles) aTriangleArray =
Prs3d_Arrow::DrawShaded(anAx1,
myAxesRadius,
anAxisSize,
myAxesConeRadius,
anArrowLength,
THE_NB_ARROW_FACETTES);
anAxisGroup->AddPrimitiveArray(aTriangleArray);
TCollection_AsciiString anAxisLabel;
if (aDatumAspect->ToDrawLabels()
&& myAxesLabels.Find (aPart, anAxisLabel)
if (aDatumAspect->ToDrawLabels() && myAxesLabels.Find(aPart, anAxisLabel)
&& !anAxisLabel.IsEmpty())
{
Handle(Graphic3d_Group) anAxisLabelGroup = thePrs->NewGroup();
gp_Pnt aTextOrigin = anAx1.Location().Translated (gp_Vec (anAx1.Direction().X() * (anAxisSize + anArrowLength),
gp_Pnt aTextOrigin =
anAx1.Location().Translated(gp_Vec(anAx1.Direction().X() * (anAxisSize + anArrowLength),
anAx1.Direction().Y() * (anAxisSize + anArrowLength),
anAx1.Direction().Z() * (anAxisSize + anArrowLength)));
Prs3d_Text::Draw (anAxisLabelGroup, aDatumAspect->TextAspect (aPart), TCollection_ExtendedString (anAxisLabel), aTextOrigin);
Prs3d_Text::Draw(anAxisLabelGroup,
aDatumAspect->TextAspect(aPart),
TCollection_ExtendedString(anAxisLabel),
aTextOrigin);
}
}
@ -639,20 +653,26 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
// Display box sides
{
Standard_Integer aNbNodes = 0, aNbTris = 0;
for (Standard_Integer aPartIter = V3d_Xpos; aPartIter <= Standard_Integer(V3d_Zneg); ++aPartIter)
for (Standard_Integer aPartIter = V3d_Xpos; aPartIter <= Standard_Integer(V3d_Zneg);
++aPartIter)
{
createBoxPartTriangles (Handle(Graphic3d_ArrayOfTriangles)(), aNbNodes, aNbTris, (V3d_TypeOfOrientation )aPartIter);
createBoxPartTriangles(Handle(Graphic3d_ArrayOfTriangles)(),
aNbNodes,
aNbTris,
(V3d_TypeOfOrientation)aPartIter);
}
if (aNbNodes > 0)
{
Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles (aNbNodes, aNbTris * 3, Graphic3d_ArrayFlags_VertexNormal);
Handle(Graphic3d_ArrayOfTriangles) aTris =
new Graphic3d_ArrayOfTriangles(aNbNodes, aNbTris * 3, Graphic3d_ArrayFlags_VertexNormal);
Handle(Graphic3d_ArrayOfSegments) aSegs;
if (myDrawer->FaceBoundaryDraw())
{
aSegs = new Graphic3d_ArrayOfSegments(aNbNodes, aNbNodes * 2, Graphic3d_ArrayFlags_None);
}
aNbNodes = aNbTris = 0;
for (Standard_Integer aPartIter = V3d_Xpos; aPartIter <= Standard_Integer(V3d_Zneg); ++aPartIter)
for (Standard_Integer aPartIter = V3d_Xpos; aPartIter <= Standard_Integer(V3d_Zneg);
++aPartIter)
{
Standard_Integer aTriNodesFrom = aTris->VertexNumber();
const Standard_Integer aTriFrom = aNbTris;
@ -666,7 +686,8 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
// clang-format off
for (Standard_Integer aVertIter = (aNbTris - aTriFrom) > 2 ? aTriNodesFrom + 2 : aTriNodesFrom + 1; // skip triangle fan center
// clang-format on
aVertIter <= aTris->VertexNumber(); ++aVertIter)
aVertIter <= aTris->VertexNumber();
++aVertIter)
{
aSegs->AddVertex(aTris->Vertice(aVertIter));
}
@ -691,13 +712,13 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
// Display box sides labels
Handle(Graphic3d_Group) aTextGroup = thePrs->NewGroup();
aTextGroup->SetGroupPrimitivesAspect(myDrawer->TextAspect()->Aspect());
for (Standard_Integer aPartIter = V3d_Xpos; aPartIter <= Standard_Integer(V3d_Zneg); ++aPartIter)
for (Standard_Integer aPartIter = V3d_Xpos; aPartIter <= Standard_Integer(V3d_Zneg);
++aPartIter)
{
const V3d_TypeOfOrientation anOrient = (V3d_TypeOfOrientation)aPartIter;
TCollection_AsciiString aLabel;
if (!myBoxSideLabels.Find (anOrient, aLabel)
|| aLabel.IsEmpty())
if (!myBoxSideLabels.Find(anOrient, aLabel) || aLabel.IsEmpty())
{
continue;
}
@ -706,8 +727,7 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
gp_Dir anUp = myIsYup ? gp::DY() : gp::DZ();
if (myIsYup)
{
if (anOrient == V3d_Ypos
|| anOrient == V3d_Yneg)
if (anOrient == V3d_Ypos || anOrient == V3d_Yneg)
{
anUp = -gp::DZ();
}
@ -728,7 +748,8 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
const gp_Pnt aPos = aDir.XYZ() * (mySize * 0.5 + myBoxFacetExtension + anOffset);
const gp_Ax2 aPosition(aPos, aDir, anUp.Crossed(aDir));
Handle(Graphic3d_Text) aText = new Graphic3d_Text ((Standard_ShortReal)myDrawer->TextAspect()->Height());
Handle(Graphic3d_Text) aText =
new Graphic3d_Text((Standard_ShortReal)myDrawer->TextAspect()->Height());
aText->SetText(aLabel);
aText->SetOrientation(aPosition);
aText->SetOwnAnchorPoint(false);
@ -741,15 +762,21 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
// Display box edges
{
Standard_Integer aNbNodes = 0, aNbTris = 0;
for (Standard_Integer aPartIter = V3d_XposYpos; aPartIter <= Standard_Integer(V3d_YposZneg); ++aPartIter)
for (Standard_Integer aPartIter = V3d_XposYpos; aPartIter <= Standard_Integer(V3d_YposZneg);
++aPartIter)
{
createBoxPartTriangles (Handle(Graphic3d_ArrayOfTriangles)(), aNbNodes, aNbTris, (V3d_TypeOfOrientation )aPartIter);
createBoxPartTriangles(Handle(Graphic3d_ArrayOfTriangles)(),
aNbNodes,
aNbTris,
(V3d_TypeOfOrientation)aPartIter);
}
if (aNbNodes > 0)
{
Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles (aNbNodes, aNbTris * 3, Graphic3d_ArrayFlags_VertexNormal);
Handle(Graphic3d_ArrayOfTriangles) aTris =
new Graphic3d_ArrayOfTriangles(aNbNodes, aNbTris * 3, Graphic3d_ArrayFlags_VertexNormal);
aNbNodes = aNbTris = 0;
for (Standard_Integer aPartIter = V3d_XposYpos; aPartIter <= Standard_Integer(V3d_YposZneg); ++aPartIter)
for (Standard_Integer aPartIter = V3d_XposYpos; aPartIter <= Standard_Integer(V3d_YposZneg);
++aPartIter)
{
const V3d_TypeOfOrientation anOrient = (V3d_TypeOfOrientation)aPartIter;
createBoxPartTriangles(aTris, aNbNodes, aNbTris, anOrient);
@ -765,15 +792,23 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
// Display box corners
{
Standard_Integer aNbNodes = 0, aNbTris = 0;
for (Standard_Integer aPartIter = V3d_XposYposZpos; aPartIter <= Standard_Integer(V3d_XnegYnegZneg); ++aPartIter)
for (Standard_Integer aPartIter = V3d_XposYposZpos;
aPartIter <= Standard_Integer(V3d_XnegYnegZneg);
++aPartIter)
{
createBoxPartTriangles (Handle(Graphic3d_ArrayOfTriangles)(), aNbNodes, aNbTris, (V3d_TypeOfOrientation )aPartIter);
createBoxPartTriangles(Handle(Graphic3d_ArrayOfTriangles)(),
aNbNodes,
aNbTris,
(V3d_TypeOfOrientation)aPartIter);
}
if (aNbNodes > 0)
{
Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles (aNbNodes, aNbTris * 3, Graphic3d_ArrayFlags_VertexNormal);
Handle(Graphic3d_ArrayOfTriangles) aTris =
new Graphic3d_ArrayOfTriangles(aNbNodes, aNbTris * 3, Graphic3d_ArrayFlags_VertexNormal);
aNbNodes = aNbTris = 0;
for (Standard_Integer aPartIter = V3d_XposYposZpos; aPartIter <= Standard_Integer(V3d_XnegYnegZneg); ++aPartIter)
for (Standard_Integer aPartIter = V3d_XposYposZpos;
aPartIter <= Standard_Integer(V3d_XnegYnegZneg);
++aPartIter)
{
const V3d_TypeOfOrientation anOrient = (V3d_TypeOfOrientation)aPartIter;
createBoxPartTriangles(aTris, aNbNodes, aNbTris, anOrient);
@ -787,10 +822,8 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager)& ,
}
}
//=======================================================================
//function : ComputeSelection
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
@ -809,7 +842,8 @@ void AIS_ViewCube::ComputeSelection (const Handle(SelectMgr_Selection)& theSelec
continue;
}
Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles (aNbNodes, aNbTris * 3, Graphic3d_ArrayFlags_None);
Handle(Graphic3d_ArrayOfTriangles) aTris =
new Graphic3d_ArrayOfTriangles(aNbNodes, aNbTris * 3, Graphic3d_ArrayFlags_None);
aNbNodes = aNbTris = 0;
createBoxPartTriangles(aTris, aNbNodes, aNbTris, anOri);
@ -829,43 +863,35 @@ void AIS_ViewCube::ComputeSelection (const Handle(SelectMgr_Selection)& theSelec
}
}
//=======================================================================
//function : Duration
//purpose :
//=======================================================================
//=================================================================================================
Standard_Real AIS_ViewCube::Duration() const
{
return myViewAnimation->OwnDuration();
}
//=======================================================================
//function : SetDuration
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::SetDuration(Standard_Real theDurationSec)
{
myViewAnimation->SetOwnDuration(theDurationSec);
}
//=======================================================================
//function : HasAnimation
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ViewCube::HasAnimation() const
{
return !myViewAnimation->IsStopped();
}
//=======================================================================
//function : viewFitAll
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::viewFitAll(const Handle(V3d_View)& theView,
const Handle(Graphic3d_Camera)& theCamera)
{
Bnd_Box aBndBox = myToFitSelected ? GetContext()->BoundingBoxOfSelection (theView) : theView->View()->MinMaxValues();
if (aBndBox.IsVoid()
&& myToFitSelected)
Bnd_Box aBndBox = myToFitSelected ? GetContext()->BoundingBoxOfSelection(theView)
: theView->View()->MinMaxValues();
if (aBndBox.IsVoid() && myToFitSelected)
{
aBndBox = theView->View()->MinMaxValues();
}
@ -875,15 +901,12 @@ void AIS_ViewCube::viewFitAll (const Handle(V3d_View)& theView,
}
}
//=======================================================================
//function : StartAnimation
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::StartAnimation(const Handle(AIS_ViewCubeOwner)& theOwner)
{
Handle(V3d_View) aView = GetContext()->LastActiveView();
if (theOwner.IsNull()
|| aView.IsNull())
if (theOwner.IsNull() || aView.IsNull())
{
return;
}
@ -902,14 +925,12 @@ void AIS_ViewCube::StartAnimation (const Handle(AIS_ViewCubeOwner)& theOwner)
}
const gp_Dir aNewDir = myEndState->Direction();
if (!myToResetCameraUp
&& !aNewDir.IsEqual (myStartState->Direction(), Precision::Angular()))
if (!myToResetCameraUp && !aNewDir.IsEqual(myStartState->Direction(), Precision::Angular()))
{
// find the Up direction closest to current instead of default one
const gp_Ax1 aNewDirAx1(gp::Origin(), aNewDir);
const gp_Dir anOldUp = myStartState->Up();
const gp_Dir anUpList[4] =
{
const gp_Dir anUpList[4] = {
myEndState->Up(),
myEndState->Up().Rotated(aNewDirAx1, M_PI_2),
myEndState->Up().Rotated(aNewDirAx1, M_PI),
@ -939,10 +960,8 @@ void AIS_ViewCube::StartAnimation (const Handle(AIS_ViewCubeOwner)& theOwner)
myViewAnimation->StartTimer(0.0, 1.0, true, false);
}
//=======================================================================
//function : updateAnimation
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ViewCube::updateAnimation()
{
const Standard_Real aPts = myViewAnimation->UpdateTimer();
@ -956,21 +975,17 @@ Standard_Boolean AIS_ViewCube::updateAnimation()
return Standard_True;
}
//=======================================================================
//function : UpdateAnimation
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean AIS_ViewCube::UpdateAnimation(const Standard_Boolean theToUpdate)
{
Handle(V3d_View) aView = myViewAnimation->View();
if (!HasAnimation()
|| !updateAnimation())
if (!HasAnimation() || !updateAnimation())
{
return Standard_False;
}
if (theToUpdate
&& !aView.IsNull())
if (theToUpdate && !aView.IsNull())
{
aView->IsInvalidated() ? aView->Redraw() : aView->RedrawImmediate();
}
@ -979,10 +994,8 @@ Standard_Boolean AIS_ViewCube::UpdateAnimation (const Standard_Boolean theToUpda
return Standard_True;
}
//=======================================================================
//function : HandleClick
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::HandleClick(const Handle(AIS_ViewCubeOwner)& theOwner)
{
if (!myToAutoStartAnim)
@ -1001,21 +1014,19 @@ void AIS_ViewCube::HandleClick (const Handle(AIS_ViewCubeOwner)& theOwner)
}
}
//=======================================================================
//function : HilightOwnerWithColor
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner)
{
if (theOwner.IsNull()
|| !thePrsMgr->IsImmediateModeOn())
if (theOwner.IsNull() || !thePrsMgr->IsImmediateModeOn())
{
return;
}
const Graphic3d_ZLayerId aLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : myDrawer->ZLayer();
const Graphic3d_ZLayerId aLayer =
theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : myDrawer->ZLayer();
const AIS_ViewCubeOwner* aCubeOwner = dynamic_cast<AIS_ViewCubeOwner*>(theOwner.get());
Handle(Prs3d_Presentation) aHiPrs = GetHilightPresentation(thePrsMgr);
@ -1028,10 +1039,14 @@ void AIS_ViewCube::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManage
Handle(Graphic3d_Group) aGroup = aHiPrs->NewGroup();
aGroup->SetGroupPrimitivesAspect(theStyle->ShadingAspect()->Aspect());
Standard_Integer aNbNodes = 0, aNbTris = 0;
createBoxPartTriangles (Handle(Graphic3d_ArrayOfTriangles)(), aNbNodes, aNbTris, aCubeOwner->MainOrientation());
createBoxPartTriangles(Handle(Graphic3d_ArrayOfTriangles)(),
aNbNodes,
aNbTris,
aCubeOwner->MainOrientation());
if (aNbNodes > 0)
{
Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles (aNbNodes, aNbTris * 3, Graphic3d_ArrayFlags_None);
Handle(Graphic3d_ArrayOfTriangles) aTris =
new Graphic3d_ArrayOfTriangles(aNbNodes, aNbTris * 3, Graphic3d_ArrayFlags_None);
aNbNodes = aNbTris = 0;
createBoxPartTriangles(aTris, aNbNodes, aNbTris, aCubeOwner->MainOrientation());
aGroup->AddPrimitiveArray(aTris);
@ -1044,14 +1059,13 @@ void AIS_ViewCube::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManage
}
}
//=======================================================================
//function : HilightSelected
//purpose :
//=======================================================================
//=================================================================================================
void AIS_ViewCube::HilightSelected(const Handle(PrsMgr_PresentationManager)&,
const SelectMgr_SequenceOfOwner& theSeq)
{
// this method should never be called since AIS_InteractiveObject::HandleClick() has been overridden
// this method should never be called since AIS_InteractiveObject::HandleClick() has been
// overridden
if (theSeq.Size() == 1)
{
// HandleClick (Handle(AIS_ViewCubeOwner)::DownCast (theSeq.First()));

View File

@ -40,7 +40,8 @@ class V3d_View;
//!
//! The object is expected to behave like a trihedron in the view corner,
//! therefore its position should be defined using transformation persistence flags:
//! @code SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (100, 100)); @endcode
//! @code SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers,
//! Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (100, 100)); @endcode
//!
//! View Cube parts are sensitive to detection, or dynamic highlighting (but not selection),
//! and every its owner AIS_ViewCubeOwner corresponds to camera transformation.
@ -54,13 +55,12 @@ class V3d_View;
//! or
//! @code aViewCube->HandleClick (aDetectedOwner); @endcode
//! that includes transformation loop.
//! This loop allows external actions like application updating. For this purpose AIS_ViewCube has virtual interface onAfterAnimation(),
//! that is to be redefined on application level.
//! This loop allows external actions like application updating. For this purpose AIS_ViewCube has
//! virtual interface onAfterAnimation(), that is to be redefined on application level.
class AIS_ViewCube : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
public:
//! Return TRUE if specified orientation belongs to box side.
Standard_EXPORT static bool IsBoxSide(V3d_TypeOfOrientation theOrient);
@ -71,7 +71,6 @@ public:
Standard_EXPORT static bool IsBoxCorner(V3d_TypeOfOrientation theOrient);
public:
//! Empty constructor.
Standard_EXPORT AIS_ViewCube();
@ -79,9 +78,13 @@ public:
const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
//! Set view animation.
void SetViewAnimation (const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; }
void SetViewAnimation(const Handle(AIS_AnimationCamera)& theAnimation)
{
myViewAnimation = theAnimation;
}
//! Return TRUE if automatic camera transformation on selection (highlighting) is enabled; TRUE by default.
//! Return TRUE if automatic camera transformation on selection (highlighting) is enabled; TRUE by
//! default.
Standard_Boolean ToAutoStartAnimation() const { return myToAutoStartAnim; }
//! Enable/disable automatic camera transformation on selection (highlighting).
@ -100,7 +103,6 @@ public:
Standard_EXPORT void ResetStyles();
protected:
//! Set default visual attributes
Standard_EXPORT void setDefaultAttributes();
@ -108,14 +110,12 @@ protected:
Standard_EXPORT void setDefaultHighlightAttributes();
public: //! @name Geometry management API
//! @return size (width and height) of View cube sides; 100 by default.
Standard_Real Size() const { return mySize; }
//! Sets size (width and height) of View cube sides.
//! @param theToAdaptAnother if TRUE, then other parameters will be adapted to specified size
Standard_EXPORT void SetSize (Standard_Real theValue,
Standard_Boolean theToAdaptAnother = true);
Standard_EXPORT void SetSize(Standard_Real theValue, Standard_Boolean theToAdaptAnother = true);
//! Return box facet extension to edge/corner facet split; 10 by default.
Standard_Real BoxFacetExtension() const { return myBoxFacetExtension; }
@ -276,7 +276,6 @@ public: //! @name Geometry management API
Standard_Boolean theToUpdateLabels = Standard_True);
public: //! @name Style management API
//! Return shading style of box sides.
const Handle(Prs3d_ShadingAspect)& BoxSideStyle() const { return myDrawer->ShadingAspect(); }
@ -323,7 +322,10 @@ public: //! @name Style management API
}
//! Return color of sides back material.
const Quantity_Color& InnerColor() const { return myDrawer->ShadingAspect()->Color (Aspect_TOFM_BACK_SIDE); }
const Quantity_Color& InnerColor() const
{
return myDrawer->ShadingAspect()->Color(Aspect_TOFM_BACK_SIDE);
}
//! Set color of sides back material. Alias for:
//! @code Attributes()->ShadingAspect()->Aspect()->ChangeBackMaterial().SetColor() @endcode
@ -342,8 +344,7 @@ public: //! @name Style management API
}
//! Set box side label.
void SetBoxSideLabel (const V3d_TypeOfOrientation theSide,
const TCollection_AsciiString& theLabel)
void SetBoxSideLabel(const V3d_TypeOfOrientation theSide, const TCollection_AsciiString& theLabel)
{
if (!IsBoxSide(theSide))
{
@ -410,13 +411,9 @@ public: //! @name Style management API
}
public:
//! Set new value of color for the whole object.
//! @param[in] theColor input color value.
virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE
{
SetBoxColor (theColor);
}
virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE { SetBoxColor(theColor); }
//! Reset color for the whole object.
virtual void UnsetColor() Standard_OVERRIDE
@ -435,10 +432,7 @@ public:
}
//! Reset transparency for the whole object.
virtual void UnsetTransparency() Standard_OVERRIDE
{
SetBoxTransparency (0.0f);
}
virtual void UnsetTransparency() Standard_OVERRIDE { SetBoxTransparency(0.0f); }
//! Sets the material for the interactive object.
virtual void SetMaterial(const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE
@ -464,7 +458,6 @@ public:
}
public: //! @name animation methods
//! Return duration of animation in seconds; 0.5 sec by default
Standard_EXPORT Standard_Real Duration() const;
@ -472,15 +465,17 @@ public: //! @name animation methods
//! @param[in] theValue input value of duration in seconds
Standard_EXPORT void SetDuration(Standard_Real theValue);
//! Return TRUE if new camera Up direction should be always set to default value for a new camera Direction; FALSE by default.
//! When this flag is FALSE, the new camera Up will be set as current Up orthogonalized to the new camera Direction,
//! and will set to default Up on second click.
//! Return TRUE if new camera Up direction should be always set to default value for a new camera
//! Direction; FALSE by default. When this flag is FALSE, the new camera Up will be set as current
//! Up orthogonalized to the new camera Direction, and will set to default Up on second click.
Standard_Boolean ToResetCameraUp() const { return myToResetCameraUp; }
//! Set if new camera Up direction should be always set to default value for a new camera Direction.
//! Set if new camera Up direction should be always set to default value for a new camera
//! Direction.
void SetResetCamera(Standard_Boolean theToReset) { myToResetCameraUp = theToReset; }
//! Return TRUE if animation should fit selected objects and FALSE to fit entire scene; TRUE by default.
//! Return TRUE if animation should fit selected objects and FALSE to fit entire scene; TRUE by
//! default.
Standard_Boolean ToFitSelected() const { return myToFitSelected; }
//! Set if animation should fit selected objects or to fit entire scene.
@ -502,7 +497,6 @@ public: //! @name animation methods
Standard_EXPORT virtual void HandleClick(const Handle(AIS_ViewCubeOwner)& theOwner);
protected:
//! Perform internal single step of animation.
//! @return FALSE if animation has been finished
Standard_EXPORT Standard_Boolean updateAnimation();
@ -514,7 +508,6 @@ protected:
const Handle(Graphic3d_Camera)& theCamera);
protected: //! @name protected virtual API
//! Method that is called after one step of transformation.
virtual void onAfterAnimation() {}
@ -522,12 +515,17 @@ protected: //! @name protected virtual API
virtual void onAnimationFinished() {}
public: //! @name Presentation computation
//! Return TRUE for supported display mode.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
{
return theMode == 0;
}
//! Global selection has no meaning for this class.
virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE { return Handle(SelectMgr_EntityOwner)(); }
virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE
{
return Handle(SelectMgr_EntityOwner)();
}
//! Compute 3D part of View Cube.
//! @param[in] thePrsMgr presentation manager.
@ -545,7 +543,8 @@ public: //! @name Presentation computation
Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
//! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden
//! methods.
virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
//! Method which clear all selected owners belonging to this selectable object.
@ -556,13 +555,15 @@ public: //! @name Presentation computation
//! @param[in] thePM presentation manager
//! @param[in] theStyle style for dynamic highlighting.
//! @param[in] theOwner input entity owner.
Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager)& thePM,
Standard_EXPORT virtual void HilightOwnerWithColor(
const Handle(PrsMgr_PresentationManager)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
//! Method which draws selected owners.
Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM,
const SelectMgr_SequenceOfOwner& theSeq) Standard_OVERRIDE;
const SelectMgr_SequenceOfOwner& theSeq)
Standard_OVERRIDE;
//! Set default parameters for visual attributes
//! @sa Attributes()
@ -581,57 +582,70 @@ public: //! @name Presentation computation
}
protected: //! @name Auxiliary classes to fill presentation with proper primitives
//! Create triangulation for a box part - for presentation and selection purposes.
//! @param theTris [in,out] triangulation to fill, or NULL to return size
//! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation
//! @param theNbNodes [in,out] should be incremented by a number of nodes defining this
//! triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this
//! triangulation
//! @param[in] theDir part to define
Standard_EXPORT virtual void createBoxPartTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_EXPORT virtual void createBoxPartTriangles(
const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes,
Standard_Integer& theNbTris,
V3d_TypeOfOrientation theDir) const;
//! Create triangulation for a box side.
//! @param theTris [in,out] triangulation to fill, or NULL to return size
//! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation
//! @param theNbNodes [in,out] should be incremented by a number of nodes defining this
//! triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this
//! triangulation
//! @param[in] theDir part to define
Standard_EXPORT virtual void createBoxSideTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_EXPORT virtual void createBoxSideTriangles(
const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes,
Standard_Integer& theNbTris,
V3d_TypeOfOrientation theDir) const;
//! Create triangulation for a box edge.
//! @param theTris [in,out] triangulation to fill, or NULL to return size
//! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation
//! @param theNbNodes [in,out] should be incremented by a number of nodes defining this
//! triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this
//! triangulation
//! @param[in] theDir part to define
Standard_EXPORT virtual void createBoxEdgeTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_EXPORT virtual void createBoxEdgeTriangles(
const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes,
Standard_Integer& theNbTris,
V3d_TypeOfOrientation theDir) const;
//! Create triangulation for a box corner (vertex).
//! @param theTris [in,out] triangulation to fill, or NULL to return size
//! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation
//! @param theNbNodes [in,out] should be incremented by a number of nodes defining this
//! triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this
//! triangulation
//! @param[in] theDir part to define
Standard_EXPORT virtual void createBoxCornerTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_EXPORT virtual void createBoxCornerTriangles(
const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes,
Standard_Integer& theNbTris,
V3d_TypeOfOrientation theDir) const;
protected:
//! Create triangulation for a rectangle with round corners.
//! @param theTris [in,out] triangulation to fill, or NULL to return size
//! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this triangulation
//! @param theNbNodes [in,out] should be incremented by a number of nodes defining this
//! triangulation
//! @param theNbTris [in,out] should be incremented by a number of triangles defining this
//! triangulation
//! @param[in] theSize rectangle dimensions
//! @param[in] theRadius radius at corners
//! @param[in] theTrsf transformation
Standard_EXPORT static void createRoundRectangleTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_EXPORT static void createRoundRectangleTriangles(
const Handle(Graphic3d_ArrayOfTriangles)& theTris,
Standard_Integer& theNbNodes,
Standard_Integer& theNbTris,
const gp_XY& theSize,
@ -639,7 +653,6 @@ protected:
const gp_Trsf& theTrsf);
protected:
NCollection_DataMap<V3d_TypeOfOrientation, TCollection_AsciiString>
myBoxSideLabels; //!< map with box side labels
NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString>
@ -665,7 +678,6 @@ protected:
// clang-format on
protected: //! @name Animation options
Handle(AIS_AnimationCamera) myViewAnimation; //!< Camera animation object
Handle(Graphic3d_Camera) myStartState; //!< Start state of view camera
Handle(Graphic3d_Camera) myEndState; //!< End state of view camera
@ -675,7 +687,6 @@ protected: //! @name Animation options
// clang-format off
Standard_Boolean myToResetCameraUp; //!< always reset camera up direction to default
// clang-format on
};
//! Redefined entity owner that is highlighted when owner is detected,
@ -684,7 +695,6 @@ class AIS_ViewCubeOwner : public SelectMgr_EntityOwner
{
DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
public:
//! Main constructor.
AIS_ViewCubeOwner(const Handle(AIS_ViewCube)& theObject,
V3d_TypeOfOrientation theOrient,
@ -708,16 +718,17 @@ public:
Aspect_VKeyFlags theModifiers,
bool theIsDoubleClick) Standard_OVERRIDE
{
(void )thePoint; (void )theButton; (void )theModifiers; (void )theIsDoubleClick;
(void)thePoint;
(void)theButton;
(void)theModifiers;
(void)theIsDoubleClick;
AIS_ViewCube* aCubePrs = dynamic_cast<AIS_ViewCube*>(mySelectable);
aCubePrs->HandleClick(this);
return Standard_True;
}
protected:
V3d_TypeOfOrientation myMainOrient; //!< new orientation to set
};
//! Simple sensitive element for picking by point only.
@ -725,20 +736,18 @@ class AIS_ViewCubeSensitive : public Select3D_SensitivePrimitiveArray
{
DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeSensitive, Select3D_SensitivePrimitiveArray)
public:
//! Constructor.
Standard_EXPORT AIS_ViewCubeSensitive(const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(Graphic3d_ArrayOfTriangles)& theTris);
//! Checks whether element overlaps current selecting volume.
Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
SelectBasics_PickResult& thePickResult)
Standard_OVERRIDE;
protected:
//! Checks if picking ray can be used for detection.
Standard_EXPORT bool isValidRay(const SelectBasics_SelectingVolumeManager& theMgr) const;
};
#endif // _AIS_ViewCube_HeaderFile

View File

@ -41,7 +41,6 @@ enum AIS_ViewInputBufferType
class AIS_ViewInputBuffer
{
public:
bool IsNewGesture; //!< transition from one action to another
NCollection_Sequence<Aspect_ScrollDelta> ZoomActions; //!< the queue with zoom actions
@ -52,7 +51,12 @@ public:
bool ToSetViewOrient; //!< set new view orientation
V3d_TypeOfOrientation ViewOrient; //!< new view orientation
_orientation() : ToFitAll (false), ToSetViewOrient (false), ViewOrient (V3d_Xpos) {}
_orientation()
: ToFitAll(false),
ToSetViewOrient(false),
ViewOrient(V3d_Xpos)
{
}
} Orientation;
struct _highlighting
@ -60,18 +64,25 @@ public:
bool ToHilight; //!< perform dynamic highlighting at specified point
Graphic3d_Vec2i Point; //!< the new point for dynamic highlighting
_highlighting() : ToHilight (false) {}
_highlighting()
: ToHilight(false)
{
}
} MoveTo;
struct _selection
{
AIS_ViewSelectionTool Tool; //!< perform selection
AIS_SelectionScheme Scheme; //!< selection scheme
NCollection_Sequence<Graphic3d_Vec2i>
Points; //!< the points for selection
NCollection_Sequence<Graphic3d_Vec2i> Points; //!< the points for selection
bool ToApplyTool; //!< apply rubber-band selection tool
_selection() : Tool (AIS_ViewSelectionTool_Picking), Scheme (AIS_SelectionScheme_UNKNOWN), ToApplyTool (false) {}
_selection()
: Tool(AIS_ViewSelectionTool_Picking),
Scheme(AIS_SelectionScheme_UNKNOWN),
ToApplyTool(false)
{
}
} Selection;
struct _panningParams
@ -81,7 +92,11 @@ public:
bool ToPan; //!< perform panning
Graphic3d_Vec2i Delta; //!< panning delta
_panningParams() : ToStart (false), ToPan (false) {}
_panningParams()
: ToStart(false),
ToPan(false)
{
}
} Panning;
struct _draggingParams
@ -94,7 +109,14 @@ public:
Graphic3d_Vec2i PointStart; //!< drag start point
Graphic3d_Vec2i PointTo; //!< drag end point
_draggingParams() : ToStart (false), ToConfirm (false), ToMove (false), ToStop (false), ToAbort (false) {}
_draggingParams()
: ToStart(false),
ToConfirm(false),
ToMove(false),
ToStop(false),
ToAbort(false)
{
}
} Dragging;
struct _orbitRotation
@ -104,7 +126,11 @@ public:
bool ToRotate; //!< perform orbit rotation
Graphic3d_Vec2d PointTo; //!< orbit rotation end point
_orbitRotation() : ToStart (false), ToRotate (false) {}
_orbitRotation()
: ToStart(false),
ToRotate(false)
{
}
} OrbitRotation;
struct _viewRotation
@ -114,7 +140,11 @@ public:
bool ToRotate; //!< perform view rotation
Graphic3d_Vec2d PointTo; //!< view rotation end point
_viewRotation() : ToStart (false), ToRotate (false) {}
_viewRotation()
: ToStart(false),
ToRotate(false)
{
}
} ViewRotation;
struct _zrotateParams
@ -123,13 +153,18 @@ public:
double Angle; //!< Z rotation angle
bool ToRotate; //!< start Z rotation
_zrotateParams() : Angle (0.0), ToRotate (false) {}
_zrotateParams()
: Angle(0.0),
ToRotate(false)
{
}
} ZRotate;
public:
AIS_ViewInputBuffer()
: IsNewGesture (false) {}
: IsNewGesture(false)
{
}
//! Reset events buffer.
void Reset()
@ -153,7 +188,6 @@ public:
ViewRotation.ToRotate = false;
ZRotate.ToRotate = false;
}
};
#endif // _AIS_ViewInputBuffer_HeaderFile

View File

@ -43,7 +43,12 @@ struct AIS_WalkPart
bool IsEmpty() const { return Abs(Value) <= RealSmall(); }
//! Empty constructor.
AIS_WalkPart() : Value (0.0), Pressure (1.0), Duration (0.0) {}
AIS_WalkPart()
: Value(0.0),
Pressure(1.0),
Duration(0.0)
{
}
};
//! Walking values.
@ -51,10 +56,18 @@ struct AIS_WalkDelta
{
//! Empty constructor.
AIS_WalkDelta()
: myIsDefined (false), myIsJumping (false), myIsCrouching (false), myIsRunning (false) {}
: myIsDefined(false),
myIsJumping(false),
myIsCrouching(false),
myIsRunning(false)
{
}
//! Return translation component.
const AIS_WalkPart& operator[] (AIS_WalkTranslation thePart) const { return myTranslation[thePart]; }
const AIS_WalkPart& operator[](AIS_WalkTranslation thePart) const
{
return myTranslation[thePart];
}
//! Return translation component.
AIS_WalkPart& operator[](AIS_WalkTranslation thePart) { return myTranslation[thePart]; }
@ -109,14 +122,12 @@ struct AIS_WalkDelta
}
private:
AIS_WalkPart myTranslation[3];
AIS_WalkPart myRotation[3];
bool myIsDefined;
bool myIsJumping;
bool myIsCrouching;
bool myIsRunning;
};
#endif // _AIS_WalkDelta_HeaderFile

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